def Components_Manager_Ui_treeView_setModel( self ): ''' This Method Sets The Components_Manager_Ui_treeView Model. Columns : Collections | Activated | Categorie | Rank | Version Rows : * Path : { _type : "Path" } ** Component : { _type : "Component", _datas : profile } ''' LOGGER.debug( "> Setting Up '{0}' Model !".format( "Components_Manager_Ui_treeView" ) ) self._model.clear() self._model.setHorizontalHeaderLabels( self._modelHeaders ) self._model.setColumnCount( len( self._modelHeaders ) ) for path in self._container.componentsManager.paths : components = [component for component in self._container.componentsManager.components if os.path.normpath( self._container.componentsManager.paths[path] ) in os.path.normpath( self._container.componentsManager.components[component].path )] if components : pathStandardItem = QStandardItem( QString( path ) ) pathStandardItem._type = "Path" LOGGER.debug( "> Adding '{0}' Path To '{1}' Model.".format( path, "Components_Manager_Ui_treeView" ) ) self._model.appendRow( pathStandardItem ) for component in components : componentStandardItem = QStandardItem( QString( strings.getNiceName( self._container.componentsManager.components[component].module ) ) ) iconPath = os.path.join( self._uiResources, "{0}{1}".format( strings.getNiceName( self._container.componentsManager.components[component].categorie ), self._uiCategorieAffixe ) ) componentStandardItem.setIcon( QIcon( iconPath ) ) componentActivationStandardItem = QStandardItem( QString( str( self._container.componentsManager.components[component].interface.activated ) ) ) iconPath = self._container.componentsManager.components[component].interface.activated and os.path.join( self._uiResources, self._uiActivatedIcon ) or os.path.join( self._uiResources, self._uiDeactivatedIcon ) componentActivationStandardItem.setIcon( QIcon( iconPath ) ) componentCategorieStandardItem = QStandardItem( QString( self._container.componentsManager.components[component].categorie and strings.getNiceName( self._container.componentsManager.components[component].categorie ) or "" ) ) componentCategorieStandardItem.setTextAlignment( Qt.AlignCenter ) componentRankStandardItem = QStandardItem( QString( self._container.componentsManager.components[component].rank or "" ) ) componentRankStandardItem.setTextAlignment( Qt.AlignCenter ) componentVersionStandardItem = QStandardItem( QString( self._container.componentsManager.components[component].version or "" ) ) componentVersionStandardItem.setTextAlignment( Qt.AlignCenter ) componentStandardItem._datas = self._container.componentsManager.components[component] componentStandardItem._type = "Component" LOGGER.debug( "> Adding '{0}' Component To '{1}'.".format( component, "Components_Manager_Ui_treeView" ) ) pathStandardItem.appendRow( [componentStandardItem, componentActivationStandardItem, componentCategorieStandardItem, componentRankStandardItem, componentVersionStandardItem] ) self.emit( SIGNAL( "modelChanged()" ) )
def setInterfaces(self, pattern=".*", flags=re.IGNORECASE): """ This method sets the Model interfaces. :param pattern: Interface name. ( String ) :param flags: Regex filtering flags. ( Integer ) :return: Method success. ( Boolean ) """ try: pattern = re.compile(pattern, flags) except Exception: return self.__model.clear() for name, module in self.__modulesManager: if not module.interfaces: continue for interface in module.interfaces: name = strings.getNiceName(self.getMethodName(interface)) if re.search(pattern, name): self.__model.registerInterface(Interface(name=name, attribute=interface, module=module)) return True
def testGetNiceName(self): """ This method tests :func:`foundations.strings.getNiceName` definition. """ self.assertIsInstance(strings.getNiceName("testGetNiceName"), str) self.assertEqual(strings.getNiceName("testGetNiceName"), "Test Get Nice Name") self.assertEqual(strings.getNiceName("TestGetNiceName"), "Test Get Nice Name") self.assertEqual(strings.getNiceName("_testGetNiceName"), "_Test Get Nice Name") self.assertEqual(strings.getNiceName("Test Get NiceName"), "Test Get Nice Name") self.assertEqual(strings.getNiceName("testGetMeANiceName"), "Test Get Me A Nice Name")
def Components_Manager_Ui_treeView_OnSelectionChanged( self, selectedItems, deselectedItems ): ''' This Method Sets The Additional_Informations_textEdit Widget. @param selectedItems: Selected Items. ( QItemSelection ) @param deselectedItems: Deselected Items. ( QItemSelection ) ''' LOGGER.debug( "> Initializing '{0}' Widget.".format( "Additional_Informations_textEdit" ) ) content = [] subContent = """ <h4><center>{0}</center></h4> <p> <b>Categorie :</b> {1} <br/> <b>Author :</b> {2} <br/> <b>Email :</b> <a href="mailto:{3}"><span style=" text-decoration: underline; color:#000000;">{3}</span></a> <br/> <b>Url :</b> <a href="{4}"><span style=" text-decoration: underline; color:#000000;">{4}</span></a> <p> <b>Description :</b> {5} </p> </p> """ selectedItems = self.getSelectedItems() for item in selectedItems : if item._type == "Component" : content.append( subContent.format( item._datas.name, strings.getNiceName( item._datas.categorie ), item._datas.author, item._datas.email, item._datas.url, item._datas.description ) ) else: len( selectedItems ) == 1 and content.append( self._Components_Informations_textBrowser_defaultText ) separator = len( content ) == 1 and "" or "<p><center>* * *<center/></p>" self.ui.Components_Informations_textBrowser.setText( separator.join( content ) )
def setOptionsToolBox( self, section, tableWidget ) : ''' This Method Defines And Sets Options TableWidgets. @param section: Section Attributes. ( Dictionary ) @param tableWidget: Table Widget. ( QTableWidget ) ''' LOGGER.debug( "> Updating '{0}'.".format( tableWidget.objectName() ) ) tableWidget.hide() tableWidget.clear() tableWidget.setRowCount( len( section ) ) tableWidget.setColumnCount( len( self._optionsToolboxesHeaders ) ) tableWidget.horizontalHeader().setStretchLastSection( True ) tableWidget.setHorizontalHeaderLabels( self._optionsToolboxesHeaders ) tableWidget.horizontalHeader().hide() tableWidget.setMinimumHeight( len( section ) * self._tableWidgetRowHeight + self._tableWidgetHeaderHeight ) palette = QPalette() palette.setColor( QPalette.Base, Qt.transparent ) tableWidget.setPalette( palette ) verticalHeaderLabels = [] for row, attribute in enumerate( section.keys() ) : LOGGER.debug( "> Current Attribute : '{0}'.".format( attribute ) ) attributeCompound = foundations.parser.getAttributeCompound( attribute, section[attribute] ) if attributeCompound.name : verticalHeaderLabels.append( attributeCompound.alias ) else: verticalHeaderLabels.append( strings.getNiceName( attributeCompound.name ) ) LOGGER.debug( "> Attribute Type : '{0}'.".format( "Boolean" ) ) if attributeCompound.type == "Boolean" : if attributeCompound.value == "1": item = Variable_QPushButton( True, ( self._uiLightGrayColor, self._uiDarkGrayColor ), ( "True", "False" ) ) item.setChecked( True ) item._datas = attributeCompound tableWidget.setCellWidget( row, 0, item ) else : item = Variable_QPushButton( False, ( self._uiLightGrayColor, self._uiDarkGrayColor ), ( "True", "False" ) ) item.setChecked( False ) item._datas = attributeCompound tableWidget.setCellWidget( row, 0, item ) elif attributeCompound.type == "Float" : item = QDoubleSpinBox() item.setMinimum( 0 ) item.setMaximum( 65535 ) item.setValue( float ( attributeCompound.value ) ) item._datas = attributeCompound tableWidget.setCellWidget( row, 0, item ) else : item = QTableWidgetItem( QString( attributeCompound.value ) ) item.setTextAlignment( Qt.AlignCenter ) item._datas = attributeCompound tableWidget.setItem( row, 0, item ) tableWidget.setVerticalHeaderLabels ( verticalHeaderLabels ) tableWidget.show()