def refreshItems(self): filenames = sorted(self.items.keys()) for i in range(len(filenames)): filename = filenames[i] item = self.items[filename] file = self.files.item(i) if not file: file = QListWidgetItem(filenames[i]) self.files.insertItem(i, file) if item['active']: file.setTextColor(QColor.fromRgbF(0.0, 0.5, 0.0)) else: file.setTextColor(QColor.fromRgbF(0.5, 0.0, 0.0)) while self.files.count() > len(filenames): self.files.takeItem(len(filenames))
def Event_AppendToList(self): maya_cmds.undoInfo(stateWithoutFlush=False) try: selection = maya_cmds.ls(selection=True) maya_cmds.select(hierarchy=True) transforms = maya_cmds.ls(selection=True, transforms=True) transforms.sort(key=lambda s: s.lower()) if self.window.Check_IgnoreInstances.isChecked(): for i in xrange(len(transforms)): if '|' in transforms[ i] and not self.window.List_IdenticalNames.findItems( transforms[i], Qt.MatchExactly): transformParents = maya_cmds.listRelatives( transforms[i], path=True, allParents=True) if (len(transformParents) if transformParents is not None else 0) <= 1: self.window.List_IdenticalNames.addItem( transforms[i]) else: for i in xrange(len(transforms)): if '|' in transforms[ i] and not self.window.List_IdenticalNames.findItems( transforms[i], Qt.MatchExactly): transformParents = maya_cmds.listRelatives( transforms[i], path=True, allParents=True) if (len(transformParents) if transformParents is not None else 0) <= 1: self.window.List_IdenticalNames.addItem( transforms[i]) else: transformWidget = QListWidgetItem(transforms[i]) transformWidget.setTextColor( QColor.fromRgb(255, 64, 64)) self.window.List_IdenticalNames.addItem( transformWidget) self.window.Label_IdenticalNamesCount.setText( str(self.window.List_IdenticalNames.count())) maya_cmds.select(selection) except Exception as e: print >> stderr, str(e) maya_cmds.undoInfo(stateWithoutFlush=True)