def __onItemChange(self, item): if self._editingItem is not None and item is self._editingItem: self.closePersistentEditor(self._editingItem) newName = self._editingItem.text(0) newName = newName.replace(' ', '') if newName == self._editingText: return revert = False if not newName or newName in self.__libraries: revert = True if not revert: self._editingItem = None oldName, self._editingText = self._editingText, '' self._editingInternal = True globals.librarySignals.renameLibrary.emit(oldName, newName) self._editingInternal = False return if revert: self._editingItem.setText(0, self._editingText) title = trStr('Rename error!', 'Ошибка при изменении имени!').text() message = trStr('Library with name \"<b>{0}</b>\"<br/>is already exist!'.format(newName), 'Библиотека с именем \"<b>{0}</b>\"<br/>уже существует!'.format(newName)).text() QMessageBox.critical(self, title, message) self._editingItem = None self._editingText = ''
def onItemChange(self, item): if self.editingItem is not None and item is self.editingItem: self.closePersistentEditor(self.editingItem) text = self.editingItem.text(0) text = text.replace(' ', '') revert = False fullname = '{0}/{1}'.format(self.editingItem.path, text) if text != self.editingText: if not text or fullname in self.__project.trees: revert = True if not revert: oldname = '{0}/{1}'.format(self.editingItem.path, self.editingText) if self.__project.trees.rename(oldname, fullname): fileItem = self.editingItem.parent() if fileItem is not None: fileItem.sortChildren(0, Qt.AscendingOrder) uid = self.__project.trees.get(fullname) if uid in self.__project.nodes: self.editingItem.node = self.__project.nodes[uid] else: revert = True else: revert = True if revert: self.editingItem.setText(0, self.editingText) title = trStr('Rename error!', 'Ошибка при изменении имени!').text() message = trStr('Branch with name \"<b>{0}</b>\"<br/>is already exist!'.format(text), \ 'Ветвь с именем \"<b>{0}</b>\"<br/>уже существует!'.format(text)).text() QMessageBox.critical(self, title, message) self.editingItem = None
def __onRemoveNode(self, libname, nodename): if libname in self.libraries and nodename in self.libraries[libname]: usedBy = globals.project.trees.getBranchesByNode(libname, nodename, self.nodes) if usedBy: message = '<font color=\"red\">' message += trStr('Node <b>\'{0}\'</b> is used by branches:'.format(nodename), 'Узел <b>\'{0}\'</b> используется в деревьях:'.format(nodename)).text() message += '</font>' for branchName in usedBy: message += '<br/>- <b>{0}</b>'.format(usedBy[branchName].refname()) message += '<br/>' else: message = '' message += trStr('<font color=\"red\">Do You really want to delete \ node <b>\'{0}\'</b>?</font>'.format(nodename), '<font color=\"red\">Вы действительно хотите удалить \ узел <b>\'{0}\'</b>?</font>'.format(nodename))\ .text() title = trStr('Delete node', 'Удаление узла').text() if QMessageBox.warning(None, title, message, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes: globals.historySignals.pushState.emit( 'Delete \'{0}\' node from library \'{1}\''.format(nodename, libname)) library = self.libraries[libname] print('warning: {0} {1} node \'{2}\' have been removed from \'{3}\' library!' .format(library.list[nodename].nodeType, library.list[nodename].nodeClass, nodename, libname)) nodeClass = library.list[nodename].nodeClass del library.list[nodename] self.modified = True globals.librarySignals.nodeRemoved.emit(libname, nodename, nodeClass)
def __onItemChange(self, item): if self._editingItem is not None and item is self._editingItem: self.closePersistentEditor(self._editingItem) newName = self._editingItem.text(0) newName = newName.replace(' ', '') if newName == self._editingText: return revert = False if not newName or newName in self.__libraries: revert = True if not revert: self._editingItem = None oldName, self._editingText = self._editingText, '' self._editingInternal = True globals.librarySignals.renameLibrary.emit(oldName, newName) self._editingInternal = False return if revert: self._editingItem.setText(0, self._editingText) title = trStr('Rename error!', 'Ошибка при изменении имени!').text() message = trStr( 'Library with name \"<b>{0}</b>\"<br/>is already exist!'. format(newName), 'Библиотека с именем \"<b>{0}</b>\"<br/>уже существует!'. format(newName)).text() QMessageBox.critical(self, title, message) self._editingItem = None self._editingText = ''
def excludeLibrary(self, libname): if libname in self.libraries: usedBy = self.trees.getBranchesByLibrary(libname, self.nodes) if usedBy: message = '<font color=\"red\">' message += trStr('Library <b>\'{0}\'</b> is used by branches:'.format(libname), 'Библиотека <b>\'{0}\'</b> используется в деревьях:'.format(libname)).text() message += '</font>' for branchName in usedBy: message += '<br/>- <b>{0}</b>'.format(usedBy[branchName].refname()) message += '<br/>' else: message = '' message += trStr( '<font color=\"red\">Do You really want to exclude library <b>\'{0}\'</b> \ from the project?</font>'.format(libname), '<font color=\"red\">Вы действительно хотите исключить библиотеку <b>\'{0}\'</b> \ из проекта?</font>'.format(libname)).text() title = trStr('Excluding library', 'Исключение библиотеки').text() if QMessageBox.warning(None, title, message, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes: globals.historySignals.pushState.emit('Exclude library \'{0}\' from project'.format(libname)) self.modified = True del self.libraries[libname] globals.librarySignals.libraryExcluded.emit(libname)
def setLibsSave(val): global saveLibraries saveLibraries = val if val: print(trStr('info: Saving libraries is \'ON\'', u'info: Сохранение библиотек \'ВКЛ\'').text()) else: print(trStr('info: Saving libraries is \'OFF\'', u'info: Сохранение библиотек \'ВЫКЛ\'').text()) print('')
def setAnimation(val): global itemsAnimation itemsAnimation = val if val: print(trStr('info: Animation is \'ON\'', u'info: Анимация \'ВКЛ\'').text()) else: print(trStr('info: Animation is \'OFF\'', u'info: Анимация \'ВЫКЛ\'').text()) print('')
def setDebugMode(val): global debugMode if not val: print(trStr('debug: DEBUG MODE is \'OFF\'', u'debug: РЕЖИМ ОТЛАДКИ \'ВЫКЛ\'').text()) print('') debugMode = val if val: print(trStr('debug: DEBUG MODE is \'ON\'', u'debug: РЕЖИМ ОТЛАДКИ \'ВКЛ\'').text()) print('')
def setLibsEdit(val): global editLibraries editLibraries = val if val: print(trStr('info: Editing node libraries is \'ON\'', u'info: Редактирование библиотек \'ВКЛ\'').text()) else: print(trStr('info: Editing node libraries is \'OFF\'', u'info: Редактирование библиотек \'ВЫКЛ\'').text()) print('') librarySignals.editPermissionChanged.emit(editLibraries)
def setAutosaveEnabled(val): global autosaveEnabled global autosaveTime autosaveEnabled = val if val: print(trStr('info: Auto saving is \'ON\'. Auto save interval is {0} seconds'.format(autosaveTime), u'info: Автосохранение \'ВКЛ\'. Интервал автосохранения {0} секунд'.format(autosaveTime)).text()) else: print(trStr('info: Auto saving is \'OFF\'', u'info: Автосохранение \'ВЫКЛ\'').text()) print('')
def setDropShadow(val): global itemsShadow global optionsSignals itemsShadow = val if val: print(trStr('info: Drop shadows is \'ON\'', u'info: Тени \'ВКЛ\'').text()) else: print(trStr('info: Drop shadows is \'OFF\'', u'info: Тени \'ВЫКЛ\'').text()) print('') optionsSignals.shadowsChanged.emit(bool(itemsShadow))
def setAnimation(val): global itemsAnimation itemsAnimation = val if val: print( trStr('info: Animation is \'ON\'', u'info: Анимация \'ВКЛ\'').text()) else: print( trStr('info: Animation is \'OFF\'', u'info: Анимация \'ВЫКЛ\'').text()) print('')
def __init__(self, *args, **kwargs): QMainWindow.__init__(self, *args, **kwargs) self.setObjectName('helpWindow') self._title = trStr('Behavior Studio Help', 'Справка Behavior Studio') QMainWindow.setWindowTitle(self, self._title.text()) self.setWindowIcon( QIcon(joinPath(globals.applicationIconsPath, 'help.png'))) # Create text window self.__textEdit = QTextEdit() self.__textEdit.setAcceptRichText(True) self.__textEdit.setTextInteractionFlags(Qt.TextBrowserInteraction | Qt.TextSelectableByKeyboard) self.__textEditFocusProxy = scrollProxy(self.__textEdit) # Fill table of contents self.__subjectHeaderLabel = trStr('Table of contents', 'Содержание') self.__subjectIndex = QTreeWidget() self.__subjectIndex.setAlternatingRowColors(True) self.__subjectIndex.setAnimated(True) self.__subjectIndex.setColumnCount(1) self.__subjectIndex.setHeaderLabel(self.__subjectHeaderLabel.text()) self.__subjectFocusProxy = scrollProxy(self.__subjectIndex) self.__topics = [] topItem = self.__fillContents() self.__subjectIndex.addTopLevelItem(topItem) self.__subjectIndex.currentItemChanged.connect(self.__onTopicChange) self.__subjectIndex.setCurrentItem(topItem) dock = QDockWidget() dock.setObjectName('helpIndex') dock.setAllowedAreas(Qt.LeftDockWidgetArea) dock.setFeatures(QDockWidget.NoDockWidgetFeatures) dock.setTitleBarWidget(QWidget()) dock.setWidget(self.__subjectIndex) self.addDockWidget(Qt.LeftDockWidgetArea, dock) dock = QDockWidget() dock.setObjectName('helpContents') dock.setAllowedAreas(Qt.RightDockWidgetArea) dock.setFeatures(QDockWidget.NoDockWidgetFeatures) dock.setTitleBarWidget(QWidget()) dock.setWidget(self.__textEdit) self.addDockWidget(Qt.RightDockWidgetArea, dock) self.setStatusBar(QStatusBar()) globalLanguage.languageChanged.connect(self.__onLanguageChange) self.readSettings()
def setLibsSave(val): global saveLibraries saveLibraries = val if val: print( trStr('info: Saving libraries is \'ON\'', u'info: Сохранение библиотек \'ВКЛ\'').text()) else: print( trStr('info: Saving libraries is \'OFF\'', u'info: Сохранение библиотек \'ВЫКЛ\'').text()) print('')
def setConnectorsBold(val): global connectorsBold global optionsSignals connectorsBold = val if val: print(trStr('info: Bold active connectors is \'ON\'', u'info: Выделение жирным активных соединительных линий \'ВКЛ\'').text()) else: print(trStr('info: Bold active connectors is \'OFF\'', u'info: Выделение жирным активных соединительных линий \'ВЫКЛ\'').text()) print('') optionsSignals.connectorsBoldChanged.emit(bool(connectorsBold))
def setConnectorsHighlight(val): global connectorsHighlight global optionsSignals connectorsHighlight = val if val: print(trStr('info: Active connector highlighting is \'ON\'', u'info: Подсвечивание активных соединительных линий \'ВКЛ\'').text()) else: print(trStr('info: Active connector highlighting is \'OFF\'', u'info: Подсвечивание активных соединительных линий \'ВЫКЛ\'').text()) print('') optionsSignals.connectorHighlightingChanged.emit(bool(connectorsHighlight))
def setDebugMode(val): global debugMode if not val: print( trStr('debug: DEBUG MODE is \'OFF\'', u'debug: РЕЖИМ ОТЛАДКИ \'ВЫКЛ\'').text()) print('') debugMode = val if val: print( trStr('debug: DEBUG MODE is \'ON\'', u'debug: РЕЖИМ ОТЛАДКИ \'ВКЛ\'').text()) print('')
def setLibsEdit(val): global editLibraries editLibraries = val if val: print( trStr('info: Editing node libraries is \'ON\'', u'info: Редактирование библиотек \'ВКЛ\'').text()) else: print( trStr('info: Editing node libraries is \'OFF\'', u'info: Редактирование библиотек \'ВЫКЛ\'').text()) print('') librarySignals.editPermissionChanged.emit(editLibraries)
def __init__(self, text, parent=None): isTr = isinstance(text, trStr) if isTr: txt = text.text() else: txt = text QLabel.__init__(self, txt, parent) if isTr: self._text = text else: self._text = trStr(text, text) self._tooltip = trStr('', '') globalLanguage.languageChanged.connect(self._onLanguageChange)
def __init__(self, text, parent=None): isTr = isinstance(text, trStr) if isTr: txt = text.text() else: txt = text QPushButton.__init__(self, txt, parent) if isTr: self._text = text else: self._text = trStr(text, text) self._tooltip = trStr('', '') globalLanguage.languageChanged.connect(self._onLanguageChange)
def __init__(self, *args, **kwargs): QMainWindow.__init__(self, *args, **kwargs) self.setObjectName('helpWindow') self._title = trStr('Behavior Studio Help', 'Справка Behavior Studio') QMainWindow.setWindowTitle(self, self._title.text()) self.setWindowIcon(QIcon(joinPath(globals.applicationIconsPath, 'help.png'))) # Create text window self.__textEdit = QTextEdit() self.__textEdit.setAcceptRichText(True) self.__textEdit.setTextInteractionFlags(Qt.TextBrowserInteraction | Qt.TextSelectableByKeyboard) self.__textEditFocusProxy = scrollProxy(self.__textEdit) # Fill table of contents self.__subjectHeaderLabel = trStr('Table of contents', 'Содержание') self.__subjectIndex = QTreeWidget() self.__subjectIndex.setAlternatingRowColors(True) self.__subjectIndex.setAnimated(True) self.__subjectIndex.setColumnCount(1) self.__subjectIndex.setHeaderLabel(self.__subjectHeaderLabel.text()) self.__subjectFocusProxy = scrollProxy(self.__subjectIndex) self.__topics = [] topItem = self.__fillContents() self.__subjectIndex.addTopLevelItem(topItem) self.__subjectIndex.currentItemChanged.connect(self.__onTopicChange) self.__subjectIndex.setCurrentItem(topItem) dock = QDockWidget() dock.setObjectName('helpIndex') dock.setAllowedAreas(Qt.LeftDockWidgetArea) dock.setFeatures(QDockWidget.NoDockWidgetFeatures) dock.setTitleBarWidget(QWidget()) dock.setWidget(self.__subjectIndex) self.addDockWidget(Qt.LeftDockWidgetArea, dock) dock = QDockWidget() dock.setObjectName('helpContents') dock.setAllowedAreas(Qt.RightDockWidgetArea) dock.setFeatures(QDockWidget.NoDockWidgetFeatures) dock.setTitleBarWidget(QWidget()) dock.setWidget(self.__textEdit) self.addDockWidget(Qt.RightDockWidgetArea, dock) self.setStatusBar(QStatusBar()) globalLanguage.languageChanged.connect(self.__onLanguageChange) self.readSettings()
def __init__(self, text, parent=None): isTr = isinstance(text, trStr) if isTr: txt = text.text() else: txt = text QMenu.__init__(self, txt, parent) if isTr: self._title = text else: self._title = trStr(text, text) self._tooltip = trStr(' ', ' ') QMenu.setToolTip(self, ' ') globalLanguage.languageChanged.connect(self._onLanguageChange)
def __init__(self, text='', parent=None): isTr = isinstance(text, trStr) if isTr: txt = text.text() else: txt = text QAction.__init__(self, txt, parent) if isTr: self._text = text else: self._text = trStr(text, text) self._tooltip = trStr(' ', ' ') # trStr(self._text.eng().replace('&', ''), self._text.rus().replace('&', '')) QAction.setToolTip(self, ' ') globalLanguage.languageChanged.connect(self._onLanguageChange)
def setDropShadow(val): global itemsShadow global optionsSignals itemsShadow = val if val: print( trStr('info: Drop shadows is \'ON\'', u'info: Тени \'ВКЛ\'').text()) else: print( trStr('info: Drop shadows is \'OFF\'', u'info: Тени \'ВЫКЛ\'').text()) print('') optionsSignals.shadowsChanged.emit(bool(itemsShadow))
def setText(self, text): if isinstance(text, trStr): self._text = text QAction.setText(self, self._text.text()) else: self._text = trStr(text, text) QAction.setText(self, text)
def setToolTip(self, text): if isinstance(text, trStr): self._tooltip = text QPushButton.setToolTip(self, self._tooltip.text()) else: self._tooltip = trStr(text, text) QPushButton.setToolTip(self, text)
def setWindowTitle(self, title): if isinstance(title, trStr): self._title = title QDockWidget.setWindowTitle(self, self._title.text()) else: self._title = trStr(title, title) QDockWidget.setWindowTitle(self, title)
def setWindowTitle(self, text): if isinstance(text, trStr): self._title = text QDialog.setWindowTitle(self, self._title.text()) else: self._title = trStr(text, text) QDialog.setWindowTitle(self, text)
def setText(self, text): if isinstance(text, trStr): self._text = text QRadioButton.setText(self, self._text.text()) else: self._text = trStr(text, text) QRadioButton.setText(self, text)
def setToolTip(self, text): if isinstance(text, trStr): self._tooltip = text QMenu.setToolTip(self, self._tooltip.text()) else: self._tooltip = trStr(text, text) QMenu.setToolTip(self, text)
def setAutosaveEnabled(val): global autosaveEnabled global autosaveTime autosaveEnabled = val if val: print( trStr( 'info: Auto saving is \'ON\'. Auto save interval is {0} seconds' .format(autosaveTime), u'info: Автосохранение \'ВКЛ\'. Интервал автосохранения {0} секунд' .format(autosaveTime)).text()) else: print( trStr('info: Auto saving is \'OFF\'', u'info: Автосохранение \'ВЫКЛ\'').text()) print('')
def setTitle(self, text): if isinstance(text, trStr): self._title = text QGroupBox.setTitle(self, self._title.text()) else: self._title = trStr(text, text) QGroupBox.setTitle(self, text)
def setWindowTitle(self, text): if type(text) is trStr: self._title = text QMainWindow.setWindowTitle(self, self._title.text()) else: self._title = trStr(text, text) QMainWindow.setWindowTitle(self, text)
def __init__(self, text='', parent=None): isTr = isinstance(text, trStr) if isTr: txt = text.text() else: txt = text QAction.__init__(self, txt, parent) if isTr: self._text = text else: self._text = trStr(text, text) self._tooltip = trStr( ' ', ' ' ) # trStr(self._text.eng().replace('&', ''), self._text.rus().replace('&', '')) QAction.setToolTip(self, ' ') globalLanguage.languageChanged.connect(self._onLanguageChange)
def setText(self, text): if isinstance(text, trStr): self._text = text QCheckBox.setText(self, self._text.text()) else: self._text = trStr(text, text) QCheckBox.setText(self, text)
def setConnectorsBold(val): global connectorsBold global optionsSignals connectorsBold = val if val: print( trStr( 'info: Bold active connectors is \'ON\'', u'info: Выделение жирным активных соединительных линий \'ВКЛ\'' ).text()) else: print( trStr( 'info: Bold active connectors is \'OFF\'', u'info: Выделение жирным активных соединительных линий \'ВЫКЛ\'' ).text()) print('') optionsSignals.connectorsBoldChanged.emit(bool(connectorsBold))
def setConnectorsHighlight(val): global connectorsHighlight global optionsSignals connectorsHighlight = val if val: print( trStr( 'info: Active connector highlighting is \'ON\'', u'info: Подсвечивание активных соединительных линий \'ВКЛ\''). text()) else: print( trStr( 'info: Active connector highlighting is \'OFF\'', u'info: Подсвечивание активных соединительных линий \'ВЫКЛ\''). text()) print('') optionsSignals.connectorHighlightingChanged.emit(bool(connectorsHighlight))
def __init__(self, title, parent=None): isTr = isinstance(title, trStr) if isTr: txt = title.text() else: txt = title QGroupBox.__init__(self, txt, parent) if isTr: self._title = title else: self._title = trStr(title, title) globalLanguage.languageChanged.connect(self._onLanguageChange)
def __init__(self, text, parent=None): isTr = isinstance(text, trStr) if isTr: txt = text.text() else: txt = text QRadioButton.__init__(self, txt, parent) if isTr: self._text = text else: self._text = trStr(text, text) globalLanguage.languageChanged.connect(self._onLanguageChange)
def contextMenuEvent(self, *args, **kwargs): menu = trMenuWithTooltip('', self) actions = {} action = QAction(trStr('Expand all', 'Раскрыть все').text(), None) action.setToolTip( trStr('Expand all items in list', 'Раскрыть все элементы списка').text()) action.triggered.connect(self.expandAll) menu.addAction(action) actions['expand all'] = action action = QAction(trStr('Collapse all', 'Свернуть все').text(), None) action.setToolTip( trStr('Collapse all items in list', 'Свернуть все элементы списка').text()) action.triggered.connect(self.collapseAll) menu.addAction(action) actions['collapse all'] = action if self.topLevelItemCount() == 0: actions['expand all'].setEnabled(False) actions['collapse all'].setEnabled(False) action = _InvisibleAction(trStr('Expand', 'Раскрыть').text(), None) action.setToolTip( trStr('Expand current item', 'Раскрыть текущий элемент списка').text()) action.triggered.connect(self.__onExpandClicked) menu.addAction(action) actions['expand'] = action action = _InvisibleAction(trStr('Collapse', 'Свернуть').text(), None) action.setToolTip( trStr('Collapse current item', 'Свернуть текущий элемент списка').text()) action.triggered.connect(self.__onCollapseClicked) menu.addAction(action) actions['collapse'] = action menu.addSeparator() action = QAction( QIcon(self._icons['book_add']), trStr('Load library...', 'Загрузить библиотеку...').text(), None) action.setToolTip( trStr( 'Open existing library and\nadd it into current project', 'Открыть существующую библиотеку узлов\nи включить ее в текущий проект' ).text()) action.triggered.connect( globals.nodeListSignals.openExistingLibraryFile) menu.addAction(action) actions['add lib'] = action action = QAction( QIcon(self._icons['book_add']), trStr('Create library...', 'Создать библиотеку...').text(), None) action.setToolTip( trStr( 'Create new library and\nadd it into current project', 'Создать новую библиотеку узлов\nи включить ее в текущий проект' ).text()) action.triggered.connect(globals.nodeListSignals.createNewLibraryFile) menu.addAction(action) actions['create lib'] = action action = _InvisibleAction( QIcon(self._icons['book_edit']), trStr('Rename library', 'Переименовать библиотеку').text(), None) action.setToolTip( trStr('Rename current library', 'Переименовать текущую библиотеку').text()) action.triggered.connect(self.__onRenameLibraryClicked) menu.addAction(action) actions['rename library'] = action action = _InvisibleAction( QIcon(self._icons['book_del']), trStr('Unload library', 'Выгрузить библиотеку').text(), None) action.setToolTip( trStr('Unload current library from project', 'Выгрузить текущую библиотеку из проекта').text()) action.triggered.connect(self.__onUnloadClicked) menu.addAction(action) actions['exclude library'] = action menu.addSeparator() action = _InvisibleAction( QIcon(self._icons['binary']), trStr('Generate code', 'Генерировать код').text(), None) action.setToolTip( trStr('Generate c++ code for current node', 'Генерировать код c++ для текущего узла').text()) action.triggered.connect(self.__onGenerateCodeClicked) menu.addAction(action) actions['generate code'] = action action = _InvisibleAction( QIcon(self._icons['add']), trStr('Add new node', 'Добавить новый узел').text(), None) action.setToolTip( trStr('Add new node into current library', 'Добавить новый узел в текущую библиотеку').text()) action.triggered.connect(self.__onAddNewNodeClicked) menu.addAction(action) actions['add'] = action action = _InvisibleAction(QIcon(self._icons['delete']), trStr('Delete', 'Удалить').text(), None) action.setToolTip( trStr('Delete current node', 'Удалить текущий узел').text()) action.triggered.connect(self.__onDeleteNodeClicked) menu.addAction(action) actions['delete'] = action action = _InvisibleAction(QIcon(self._icons['copy']), trStr('Copy', 'Копировать').text(), None) action.setToolTip( trStr('Copy current node to clipboard', 'Копировать текущий узел в буфер обмена').text()) action.triggered.connect(self.__onCopyClicked) menu.addAction(action) actions['copy'] = action action = _InvisibleAction(QIcon(self._icons['paste']), trStr('Paste', 'Вставить').text(), None) action.setToolTip( trStr('Paste copy of node from clipboard', 'Вставить копию узла из буфера обмена').text()) action.triggered.connect(self.__onPasteClicked) menu.addAction(action) actions['paste'] = action if self.currentItem() is not None: if self.currentItem().isExpanded(): actions['collapse'].setVisible(True) actions['collapse'].setEnabled(True) else: actions['expand'].setVisible(True) actions['expand'].setEnabled(True) if self.indexOfTopLevelItem(self.currentItem()) >= 0: actions['rename library'].setVisible(True) actions['exclude library'].setVisible(True) if globals.editLibraries: actions['rename library'].setEnabled(True) actions['exclude library'].setEnabled(True) if self.currentItem().parent() is not None: i = self.indexOfTopLevelItem( self.currentItem().parent().parent()) if i >= 0: actions['generate code'].setVisible(True) libname = self.topLevelItem(i).text(0) nodename = self.currentItem().text(0) node = self.__libraries[libname][nodename] cls = self.__alphabet.getClass(node.nodeClass) if cls is not None and cls.codegenData is not None: actions['generate code'].setEnabled(True) actions['add'].setVisible(True) actions['delete'].setVisible(True) actions['copy'].setVisible(True) actions['paste'].setVisible(True) if globals.editLibraries and cls is not None: actions['add'].setEnabled(True) actions['delete'].setEnabled(True) actions['copy'].setEnabled(True) if globals.clipboard['node-desc'] is not None\ and globals.clipboard['node-desc'].nodeClass == node.nodeClass: actions['paste'].setEnabled(True) else: # libname = self.currentItem().parent().text(0) nodeClass = self.currentItem().groupName cls = self.__alphabet.getClass(nodeClass) actions['add'].setVisible(True) actions['paste'].setVisible(True) print('debug: Class is \'{0}\''.format(nodeClass)) if globals.editLibraries and cls is not None: actions['add'].setEnabled(True) if globals.clipboard['node-desc'] is not None\ and globals.clipboard['node-desc'].nodeClass == nodeClass: actions['paste'].setEnabled(True) else: actions['paste'].setVisible(True) if globals.editLibraries and globals.clipboard[ 'node-desc'] is not None: actions['paste'].setEnabled(True) menu.exec_(QCursor.pos())
def __fillContents(self): # top item topItem = _HelpItem() topItem.setIndex(len(self.__topics)) topItem.setText(0, trStr('Behavior Studio', 'Behavior Studio')) self.__topics.append(topItem) # graphics scene topics item = _HelpItem() item.setIndex(len(self.__topics)) item.setText(0, trStr('Working with graphics scene', 'Работа с графической областью')) topItem.addChild(item) self.__topics.append(item) eng = '<h1>Graphics scene</h1>Press \'<b>F1</b>\' when graphics scene is selected to ' \ 'see it\'s hot keys and hints.' eng += '<br/><h2>' eng += 'Graphics scene hot keys and hints' eng += '</h2><br/><h4>' eng += 'Holding <i>Ctrl</i> button you can connect and disconnect nodes' eng += '</h4>' eng += '<p style="text-indent: 20px;">Select node, press <b>Ctrl</b>+<b>LMB</b> and move mouse \ cursor: you will see a red arrow. \ Red arrow direction points from parent node to child.</p>\ <p style="text-indent: 20px;">If the arrow points from empty space to node (or from node to an \ empty space), then this node will be diconnected from it\'s parent.</p>' eng += '<br/><h4>' eng += 'Holding <i>Shift</i> button you can change nodes order' eng += '</h4>' eng += '<p style="text-indent: 20px;">Select node, press <b>Shift</b>+<b>LMB</b> and move mouse ' \ 'cursor until node will not change it\'s position.</p>' eng += '<br/><h4>' eng += 'Holding <i>Alt</i> button you can watch node attributes' eng += '</h4>' eng += '<p style="text-indent: 20px;">Press <b>Alt</b> and move mouse cursor over required node ' \ 'on graphics scene and you will see popup window with it\'s attributes.</p>' eng += '<br/><h4>' eng += 'There are copy/paste feature available' eng += '</h4>' eng += '<p style="text-indent: 20px;">Select required node and press <b>Ctrl</b>+<b>C</b> then \ selected node and <b>all</b> it\'s children will be copied into a clipboard.<br/>\ Now you can press <b>Ctrl</b>+<b>V</b> and copied tree will appear under mouse cursor.</p>\ <p><i><u>Hint:</u> You can copy a tree on one diagram and paste it to another diagram.</i></p>' rus = '<h1>Графическая область редактирования</h1>Нажмите \'<b>F1</b>\', когда графическая область активна, ' \ 'чтобы увидеть список горячих клавиш и подсказки.' rus += '<br/><h2>' rus += 'Горячие клавиши и подсказки для работы с графической областью' rus += '</h2><br/><h4>' rus += 'Удерживая <i>Ctrl</i>, можно соединять узлы' rus += '</h4>' rus += '<p style="text-indent: 20px;">Выделите нужный узел, зажмите <b>Ctrl</b>+<b>ЛКМ</b> и перемещайте \ курсор мыши: вы увидите красную стрелку. Красная стрелка рисуется от родителя к дочернему узлу.</p>\ <p style="text-indent: 20px;">Если стрелка направлена к узлу из пустой области (или от узла \ в пустую область), то узел будет отсоединен от своего родителя.</p>' rus += '<br/><h4>' rus += 'Удерживая <i>Shift</i>, можно изменять порядок узлов' rus += '</h4>' rus += '<p style="text-indent: 20px;">Выделите нужный узел, зажмите <b>Shift</b>+<b>ЛКМ</b> ' \ 'и перемещайте курсор мыши до тех пор, пока узел не изменит свою позицию.</p>' rus += '<br/><h4>' rus += 'Удерживая <i>Alt</i>, можно смотреть параметры узлов' rus += '</h4>' rus += '<p style="text-indent: 20px;">Зажмите <b>Alt</b> и переместите курсор мыши на нужный узел ' \ 'на графической области и появится окошко с параметрами этого узла.</p>' rus += '<br/><h4>' rus += 'Доступно копирование и вставка деревьев' rus += '</h4>' rus += '<p style="text-indent: 20px;">Выделите нужный узел и нажмите <b>Ctrl</b>+<b>C</b> - \ узел и <b>все</b> его дочерние узлы будут скопированы в буфер.<br/>\ Теперь вы можете нажать <b>Ctrl</b>+<b>V</b> и скопированное дерево появится под курсором мыши.</p>\ <p><i><u>Подсказка:</u> Дерево можно скопировать на одной диаграмме и \ вставить на любую другую диаграмму.</i></p>' item.setContentsEng(eng) item.setContentsRus(rus) return topItem
def __init__(self, *args, **kwargs): QTreeWidgetItem.__init__(self, *args, **kwargs) self._contents = trStr('', '') self._text = trStr('', '') self._index = -1 globalLanguage.languageChanged.connect(self._onLanguageChange)
def contextMenuEvent(self, event): cmenu = trMenuWithTooltip('', self) actions = [] action = QAction(trStr('Open existing tree file...', 'Открыть файл с деревом...').text(), None) action.setToolTip(trStr('Open existing tree file and\ninclude it into project', 'Открыть существующий файл с деревом\nи добавить его в проект').text()) action.setIcon(QIcon(self._icons['add2'])) action.triggered.connect(globals.treeListSignals.openExistingTreeFile) cmenu.addAction(action) actions.append(action) action = QAction(trStr('Create new tree file...', 'Создать файл с деревом...').text(), None) action.setToolTip(trStr('Create new tree file and\ninclude it into project', 'Создать новый файл с деревом\nи добавить его в проект').text()) action.setIcon(QIcon(self._icons['add'])) action.triggered.connect(globals.treeListSignals.createNewTreeFile) cmenu.addAction(action) actions.append(action) cmenu.addSeparator() if self.topLevelItemCount() > 0: currItem = self.currentItem() if currItem is not None: action = QAction(trStr('Create', 'Создать').text(), None) action.setToolTip(trStr('Create new tree in selected tree file', 'Создать новое дерево в выбранном файле').text()) action.setIcon(QIcon(self._icons['add2'])) action.triggered.connect(self.__onCreateClicked) cmenu.addAction(action) actions.append(action) if self.indexOfTopLevelItem(currItem) < 0: action = QAction(trStr('Copy', 'Копировать').text(), None) action.setToolTip(trStr('Create a full copy of selected tree', 'Создать полную копию выбранного дерева').text()) action.setIcon(QIcon(self._icons['copy'])) action.triggered.connect(self.__onCreateCopyClicked) cmenu.addAction(action) actions.append(action) cmenu.addSeparator() action = QAction(trStr('Rename', 'Переименовать').text(), None) action.setToolTip(trStr('Rename selected tree', 'Переименовать выбранное дерево').text()) action.setIcon(QIcon(self._icons['edit'])) action.triggered.connect(self.__onRenameClicked) cmenu.addAction(action) actions.append(action) action = QAction(trStr('Delete', 'Удалить').text(), None) action.setToolTip( trStr('Permanently delete selected tree and remove all links to it in all other trees', 'Удалить выбранное дерево и убрать все ссылки на него в других деревьях').text() ) action.setIcon(QIcon(self._icons['cancel'])) action.triggered.connect(self.__onDeleteClicked) cmenu.addAction(action) actions.append(action) cmenu.addSeparator() action = QAction(trStr('Show usages', 'Показать где используется').text(), None) action.setToolTip(trStr('Show other trees which uses the selected tree', 'Показать деревья, в которых задействовано выбранное дерево').text()) action.triggered.connect(self.__onShowWhoDependsOnClicked) cmenu.addAction(action) actions.append(action) action = QAction(trStr('Show dependence from', 'Показать от кого зависит').text(), None) action.setToolTip(trStr('Show trees that are used inside the selected tree', 'Показать деревья, которые используются внутри выбранного дерева').text()) action.triggered.connect(self.__onShowDependenciesClicked) cmenu.addAction(action) actions.append(action) cmenu.exec_(QCursor.pos())
def contextMenuEvent(self, *args, **kwargs): menu = trMenuWithTooltip('', self) actions = {} action = QAction(trStr('Expand all', 'Раскрыть все').text(), None) action.setToolTip(trStr('Expand all items in list', 'Раскрыть все элементы списка').text()) action.triggered.connect(self.expandAll) menu.addAction(action) actions['expand all'] = action action = QAction(trStr('Collapse all', 'Свернуть все').text(), None) action.setToolTip(trStr('Collapse all items in list', 'Свернуть все элементы списка').text()) action.triggered.connect(self.collapseAll) menu.addAction(action) actions['collapse all'] = action if self.topLevelItemCount() == 0: actions['expand all'].setEnabled(False) actions['collapse all'].setEnabled(False) action = _InvisibleAction(trStr('Expand', 'Раскрыть').text(), None) action.setToolTip(trStr('Expand current item', 'Раскрыть текущий элемент списка').text()) action.triggered.connect(self.__onExpandClicked) menu.addAction(action) actions['expand'] = action action = _InvisibleAction(trStr('Collapse', 'Свернуть').text(), None) action.setToolTip(trStr('Collapse current item', 'Свернуть текущий элемент списка').text()) action.triggered.connect(self.__onCollapseClicked) menu.addAction(action) actions['collapse'] = action menu.addSeparator() action = QAction(QIcon(self._icons['book_add']), trStr('Load library...', 'Загрузить библиотеку...').text(), None) action.setToolTip(trStr('Open existing library and\nadd it into current project', 'Открыть существующую библиотеку узлов\nи включить ее в текущий проект').text()) action.triggered.connect(globals.nodeListSignals.openExistingLibraryFile) menu.addAction(action) actions['add lib'] = action action = QAction(QIcon(self._icons['book_add']), trStr('Create library...', 'Создать библиотеку...').text(), None) action.setToolTip(trStr('Create new library and\nadd it into current project', 'Создать новую библиотеку узлов\nи включить ее в текущий проект').text()) action.triggered.connect(globals.nodeListSignals.createNewLibraryFile) menu.addAction(action) actions['create lib'] = action action = _InvisibleAction(QIcon(self._icons['book_edit']), trStr('Rename library', 'Переименовать библиотеку').text(), None) action.setToolTip(trStr('Rename current library', 'Переименовать текущую библиотеку').text()) action.triggered.connect(self.__onRenameLibraryClicked) menu.addAction(action) actions['rename library'] = action action = _InvisibleAction(QIcon(self._icons['book_del']), trStr('Unload library', 'Выгрузить библиотеку').text(), None) action.setToolTip(trStr('Unload current library from project', 'Выгрузить текущую библиотеку из проекта').text()) action.triggered.connect(self.__onUnloadClicked) menu.addAction(action) actions['exclude library'] = action menu.addSeparator() action = _InvisibleAction(QIcon(self._icons['binary']), trStr('Generate code', 'Генерировать код').text(), None) action.setToolTip(trStr('Generate c++ code for current node', 'Генерировать код c++ для текущего узла').text()) action.triggered.connect(self.__onGenerateCodeClicked) menu.addAction(action) actions['generate code'] = action action = _InvisibleAction(QIcon(self._icons['add']), trStr('Add new node', 'Добавить новый узел').text(), None) action.setToolTip(trStr('Add new node into current library', 'Добавить новый узел в текущую библиотеку').text()) action.triggered.connect(self.__onAddNewNodeClicked) menu.addAction(action) actions['add'] = action action = _InvisibleAction(QIcon(self._icons['delete']), trStr('Delete', 'Удалить').text(), None) action.setToolTip(trStr('Delete current node', 'Удалить текущий узел').text()) action.triggered.connect(self.__onDeleteNodeClicked) menu.addAction(action) actions['delete'] = action action = _InvisibleAction(QIcon(self._icons['copy']), trStr('Copy', 'Копировать').text(), None) action.setToolTip(trStr('Copy current node to clipboard', 'Копировать текущий узел в буфер обмена').text()) action.triggered.connect(self.__onCopyClicked) menu.addAction(action) actions['copy'] = action action = _InvisibleAction(QIcon(self._icons['paste']), trStr('Paste', 'Вставить').text(), None) action.setToolTip(trStr('Paste copy of node from clipboard', 'Вставить копию узла из буфера обмена').text()) action.triggered.connect(self.__onPasteClicked) menu.addAction(action) actions['paste'] = action if self.currentItem() is not None: if self.currentItem().isExpanded(): actions['collapse'].setVisible(True) actions['collapse'].setEnabled(True) else: actions['expand'].setVisible(True) actions['expand'].setEnabled(True) if self.indexOfTopLevelItem(self.currentItem()) >= 0: actions['rename library'].setVisible(True) actions['exclude library'].setVisible(True) if globals.editLibraries: actions['rename library'].setEnabled(True) actions['exclude library'].setEnabled(True) if self.currentItem().parent() is not None: i = self.indexOfTopLevelItem(self.currentItem().parent().parent()) if i >= 0: actions['generate code'].setVisible(True) libname = self.topLevelItem(i).text(0) nodename = self.currentItem().text(0) node = self.__libraries[libname][nodename] cls = self.__alphabet.getClass(node.nodeClass) if cls is not None and cls.codegenData is not None: actions['generate code'].setEnabled(True) actions['add'].setVisible(True) actions['delete'].setVisible(True) actions['copy'].setVisible(True) actions['paste'].setVisible(True) if globals.editLibraries and cls is not None: actions['add'].setEnabled(True) actions['delete'].setEnabled(True) actions['copy'].setEnabled(True) if globals.clipboard['node-desc'] is not None\ and globals.clipboard['node-desc'].nodeClass == node.nodeClass: actions['paste'].setEnabled(True) else: # libname = self.currentItem().parent().text(0) nodeClass = self.currentItem().groupName cls = self.__alphabet.getClass(nodeClass) actions['add'].setVisible(True) actions['paste'].setVisible(True) print('debug: Class is \'{0}\''.format(nodeClass)) if globals.editLibraries and cls is not None: actions['add'].setEnabled(True) if globals.clipboard['node-desc'] is not None\ and globals.clipboard['node-desc'].nodeClass == nodeClass: actions['paste'].setEnabled(True) else: actions['paste'].setVisible(True) if globals.editLibraries and globals.clipboard['node-desc'] is not None: actions['paste'].setEnabled(True) menu.exec_(QCursor.pos())
def __fillContents(self): # top item topItem = _HelpItem() topItem.setIndex(len(self.__topics)) topItem.setText(0, trStr('Behavior Studio', 'Behavior Studio')) self.__topics.append(topItem) # graphics scene topics item = _HelpItem() item.setIndex(len(self.__topics)) item.setText( 0, trStr('Working with graphics scene', 'Работа с графической областью')) topItem.addChild(item) self.__topics.append(item) eng = '<h1>Graphics scene</h1>Press \'<b>F1</b>\' when graphics scene is selected to ' \ 'see it\'s hot keys and hints.' eng += '<br/><h2>' eng += 'Graphics scene hot keys and hints' eng += '</h2><br/><h4>' eng += 'Holding <i>Ctrl</i> button you can connect and disconnect nodes' eng += '</h4>' eng += '<p style="text-indent: 20px;">Select node, press <b>Ctrl</b>+<b>LMB</b> and move mouse \ cursor: you will see a red arrow. \ Red arrow direction points from parent node to child.</p>\ <p style="text-indent: 20px;">If the arrow points from empty space to node (or from node to an \ empty space), then this node will be diconnected from it\'s parent.</p>' eng += '<br/><h4>' eng += 'Holding <i>Shift</i> button you can change nodes order' eng += '</h4>' eng += '<p style="text-indent: 20px;">Select node, press <b>Shift</b>+<b>LMB</b> and move mouse ' \ 'cursor until node will not change it\'s position.</p>' eng += '<br/><h4>' eng += 'Holding <i>Alt</i> button you can watch node attributes' eng += '</h4>' eng += '<p style="text-indent: 20px;">Press <b>Alt</b> and move mouse cursor over required node ' \ 'on graphics scene and you will see popup window with it\'s attributes.</p>' eng += '<br/><h4>' eng += 'There are copy/paste feature available' eng += '</h4>' eng += '<p style="text-indent: 20px;">Select required node and press <b>Ctrl</b>+<b>C</b> then \ selected node and <b>all</b> it\'s children will be copied into a clipboard.<br/>\ Now you can press <b>Ctrl</b>+<b>V</b> and copied tree will appear under mouse cursor.</p>\ <p><i><u>Hint:</u> You can copy a tree on one diagram and paste it to another diagram.</i></p>' rus = '<h1>Графическая область редактирования</h1>Нажмите \'<b>F1</b>\', когда графическая область активна, ' \ 'чтобы увидеть список горячих клавиш и подсказки.' rus += '<br/><h2>' rus += 'Горячие клавиши и подсказки для работы с графической областью' rus += '</h2><br/><h4>' rus += 'Удерживая <i>Ctrl</i>, можно соединять узлы' rus += '</h4>' rus += '<p style="text-indent: 20px;">Выделите нужный узел, зажмите <b>Ctrl</b>+<b>ЛКМ</b> и перемещайте \ курсор мыши: вы увидите красную стрелку. Красная стрелка рисуется от родителя к дочернему узлу.</p>\ <p style="text-indent: 20px;">Если стрелка направлена к узлу из пустой области (или от узла \ в пустую область), то узел будет отсоединен от своего родителя.</p>' rus += '<br/><h4>' rus += 'Удерживая <i>Shift</i>, можно изменять порядок узлов' rus += '</h4>' rus += '<p style="text-indent: 20px;">Выделите нужный узел, зажмите <b>Shift</b>+<b>ЛКМ</b> ' \ 'и перемещайте курсор мыши до тех пор, пока узел не изменит свою позицию.</p>' rus += '<br/><h4>' rus += 'Удерживая <i>Alt</i>, можно смотреть параметры узлов' rus += '</h4>' rus += '<p style="text-indent: 20px;">Зажмите <b>Alt</b> и переместите курсор мыши на нужный узел ' \ 'на графической области и появится окошко с параметрами этого узла.</p>' rus += '<br/><h4>' rus += 'Доступно копирование и вставка деревьев' rus += '</h4>' rus += '<p style="text-indent: 20px;">Выделите нужный узел и нажмите <b>Ctrl</b>+<b>C</b> - \ узел и <b>все</b> его дочерние узлы будут скопированы в буфер.<br/>\ Теперь вы можете нажать <b>Ctrl</b>+<b>V</b> и скопированное дерево появится под курсором мыши.</p>\ <p><i><u>Подсказка:</u> Дерево можно скопировать на одной диаграмме и \ вставить на любую другую диаграмму.</i></p>' item.setContentsEng(eng) item.setContentsRus(rus) return topItem
def __init__(self, project, treenode, editMode=False, parent=None, wndFlags=0): QWidget.__init__(self, parent, wndFlags) self.treeWidget = TreeWithDotLine() self.setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin) if type(editMode) is bool: self.__editMode = editMode else: self.__editMode = False if not self.__editMode: self.treeWidget.header().close() else: self.treeWidget.preferredHeight += rowHeight self.__attributeItems = [] self.__attributeBaseItems = dict() self.attributeChanged.connect(self.onAttributeChange) self.__updating = False self.isChanged = False self.__proj = project self.__node = treenode self.__class = self.__node.nodeClass self.__type = self.__node.nodeType self.__debugMode = False self.__singleBlock = False self.__invertMode = False self.__nodeDescRef = treenode.nodeDesc() self.__targetPath = '' self.__targetRef = self.__node.target texts = self.__targetRef.split('/') if len(texts) > 1: texts.pop() self.__targetPath = '/'.join(texts) else: self.__targetPath = self.__node.target self.__attributes = self.__node.getAttributesCopy() self.CommitButton = None self.UndoButton = None if self.__editMode: self.CommitButton = SubmitButton(trStr('Submit', 'Подтвердить')) self.UndoButton = trButton(trStr('Undo', 'Отменить')) self.CommitButton.clicked.connect(self.commitChanges) self.UndoButton.clicked.connect(self.undoChanges) self.CommitButton.setEnabled(False) self.UndoButton.setEnabled(False) self.__DebugModeCombobox = None self.__SingleblockModeCombobox = None self.__InvertModeCombobox = None self.__NodeCombobox = None self.__TypeCombobox = None self.__PathCombobox = None self.__RefCombobox = None self.__refConnected = False self.__debugComboIndex = -1 self.__singleBlockComboIndex = -1 self.__invertComboIndex = -1 self.__nodeComboIndex = -1 self.__typeComboIndex = -1 self.__pathComboIndex = -1 self.__refComboIndex = -1 self.singleblockItem = None # uid item uidItem = MyTreeWidgetItem(self.treeWidget, ['uid', str(self.__node.uid())]) self.treeWidget.addTopLevelItem(uidItem) self.treeWidget.preferredHeight += rowHeight # class item self.classItem = MyTreeWidgetItem(self.treeWidget, ['class', self.__class]) self.treeWidget.addTopLevelItem(self.classItem) self.treeWidget.preferredHeight += rowHeight self.attributesPreferredHeight = 0.0 # debug mode item nodeClassRef = self.__node.cls() if nodeClassRef is not None: if nodeClassRef.debuggable: self.__debugMode = self.__node.debugMode() self.debugItem = MyTreeWidgetItem(self.treeWidget) self.debugItem.setText(0, 'debugMode') self.treeWidget.addTopLevelItem(self.debugItem) self.treeWidget.preferredHeight += rowHeight if not self.__editMode: if self.__debugMode is True: self.debugItem.setText(1, 'True') else: self.debugItem.setText(1, 'False') else: self.__DebugModeCombobox = LowCombobox() self.__DebugModeCombobox.setInsertPolicy(QComboBox.NoInsert) self.__DebugModeCombobox.setMinimumWidth(minimumWidth) self.__fillDebugCombobox() self.__DebugModeCombobox.currentIndexChanged.connect(self.onDebugModeChange) self.treeWidget.setItemWidget(self.debugItem, 1, self.__DebugModeCombobox) nodeTypeRef = self.__node.type() if not self.__editMode: if nodeTypeRef is not None and nodeTypeRef.singleblockEnabled: self.__singleBlock = self.__node.singleBlock() self.singleblockItem = MyTreeWidgetItem(self.treeWidget) self.singleblockItem.setText(0, 'singleBlock') self.treeWidget.addTopLevelItem(self.singleblockItem) self.treeWidget.preferredHeight += rowHeight if self.__singleBlock is True: self.singleblockItem.setText(1, 'True') else: self.singleblockItem.setText(1, 'False') else: self.singleblockItem = MyTreeWidgetItem(self.treeWidget) self.singleblockItem.setText(0, 'singleBlock') self.treeWidget.addTopLevelItem(self.singleblockItem) self.treeWidget.preferredHeight += rowHeight self.__SingleblockModeCombobox = LowCombobox() self.__SingleblockModeCombobox.setInsertPolicy(QComboBox.NoInsert) self.__SingleblockModeCombobox.setMinimumWidth(minimumWidth) if nodeTypeRef is not None and nodeTypeRef.singleblockEnabled: self.__singleBlock = self.__node.singleBlock() else: self.__SingleblockModeCombobox.hide() self.singleblockItem.hide() self.__fillSingleblockCombobox() self.__SingleblockModeCombobox.currentIndexChanged.connect(self.onSingleblockModeChange) self.treeWidget.setItemWidget(self.singleblockItem, 1, self.__SingleblockModeCombobox) if nodeClassRef.invertible: self.__invertMode = self.__node.isInverse() self.invertItem = MyTreeWidgetItem(self.treeWidget) self.invertItem.setText(0, 'inverse') self.treeWidget.addTopLevelItem(self.invertItem) self.treeWidget.preferredHeight += rowHeight if not self.__editMode: if self.__invertMode is True: self.invertItem.setText(1, 'True') else: self.invertItem.setText(1, 'False') else: self.__InvertModeCombobox = LowCombobox() self.__InvertModeCombobox.setInsertPolicy(QComboBox.NoInsert) self.__InvertModeCombobox.setMinimumWidth(minimumWidth) self.__fillInvertCombobox() self.__InvertModeCombobox.currentIndexChanged.connect(self.onInvertModeChange) self.treeWidget.setItemWidget(self.invertItem, 1, self.__InvertModeCombobox) # type item self.typeItem = MyTreeWidgetItem(self.treeWidget) self.typeItem.setText(0, 'type') self.treeWidget.addTopLevelItem(self.typeItem) self.treeWidget.preferredHeight += rowHeight if not self.__editMode: text = 'Unknown' if self.__node.type() is not None: if self.__node.type().isLink(): text = self.__type else: text = '{0} {1}'.format(self.__type, self.__class) self.typeItem.setText(1, text) else: self.__TypeCombobox = LowCombobox() self.__TypeCombobox.setInsertPolicy(QComboBox.NoInsert) self.__TypeCombobox.setMinimumWidth(minimumWidth) self.__fillTypeCombobox() self.__TypeCombobox.currentIndexChanged.connect(self.onTypeChange) self.treeWidget.setItemWidget(self.typeItem, 1, self.__TypeCombobox) # node self.nodeItem = MyTreeWidgetItem(self.treeWidget) self.nodeItem.setText(0, 'node') self.treeWidget.addTopLevelItem(self.nodeItem) self.treeWidget.preferredHeight += rowHeight if not self.__editMode: text = 'Unknown' if self.__nodeDescRef is not None: text = self.__nodeDescRef.name self.nodeItem.setText(1, text) else: self.__NodeCombobox = LowCombobox() self.__NodeCombobox.setInsertPolicy(QComboBox.NoInsert) self.__NodeCombobox.setMinimumWidth(minimumWidth) self.__fillNodeCombobox() self.__NodeCombobox.currentIndexChanged.connect(self.onNodeChange) self.treeWidget.setItemWidget(self.nodeItem, 1, self.__NodeCombobox) # path self.pathItem = MyTreeWidgetItem(self.treeWidget) self.pathItem.setText(0, 'path') self.treeWidget.addTopLevelItem(self.pathItem) self.treeWidget.preferredHeight += rowHeight if not self.__editMode: texts = self.__targetPath.split('/') if texts: self.pathItem.setText(1, texts[len(texts) - 1]) else: self.pathItem.setText(1, self.__targetPath) self.pathItem.setToolTip(1, self.__targetPath) else: self.__PathCombobox = LowCombobox() self.__PathCombobox.setInsertPolicy(QComboBox.NoInsert) self.__PathCombobox.setMinimumWidth(minimumWidth) self.__PathCombobox.addItem('<select file>', '') k = 0 paths = self.__proj.trees.getFilesList(self.__proj.nodes) for path in paths: k += 1 texts = path.split('/') if texts: self.__PathCombobox.addItem(texts[len(texts) - 1], path) else: self.__PathCombobox.addItem(path, path) self.__PathCombobox.setItemData(k, path, Qt.ToolTipRole) self.__PathCombobox.model().sort(0) i = self.__PathCombobox.findData(self.__targetPath) if i < 0: i = 0 self.__PathCombobox.setCurrentIndex(i) self.__pathComboIndex = self.__PathCombobox.currentIndex() self.__PathCombobox.currentIndexChanged.connect(self.onReferencePathChange) self.treeWidget.setItemWidget(self.pathItem, 1, self.__PathCombobox) # reference self.refItem = MyTreeWidgetItem(self.treeWidget) self.refItem.setText(0, 'target') self.treeWidget.addTopLevelItem(self.refItem) self.treeWidget.preferredHeight += rowHeight if not self.__editMode: texts = self.__targetRef.split('/') if texts: self.refItem.setText(1, texts[len(texts) - 1]) else: self.refItem.setText(1, '') else: self.__RefCombobox = LowCombobox() self.__RefCombobox.setEditable(True) self.__RefCombobox.setInsertPolicy(QComboBox.NoInsert) self.__RefCombobox.setMinimumWidth(minimumWidth) #self.__RefCombobox.setMaximumWidth(150) self.__fillRefCombobox(self.__targetPath) self.treeWidget.setItemWidget(self.refItem, 1, self.__RefCombobox) # attributes self.attrsHeaderItem = MyTreeWidgetItem(self.treeWidget, ['', '']) # ['attributes:','']) # trColor = QColor(Qt.darkRed) # trColor.setAlpha(64) # self.attrsHeaderItem.setBackground(0,trColor) # self.attrsHeaderItem.setBackground(1,trColor) self.treeWidget.addTopLevelItem(self.attrsHeaderItem) self.treeWidget.drawLineAt = self.attrsHeaderItem self.attrsHeaderItem.hide() self.refreshAttributesItems() # layout buttonBox = None if self.CommitButton is not None and self.UndoButton is not None: buttonBox = QHBoxLayout() buttonBox.setContentsMargins(5, 3, 5, 5) buttonBox.addStretch(1) buttonBox.addWidget(self.CommitButton, 0) buttonBox.addWidget(self.UndoButton, 0) mainLayout = QVBoxLayout() mainLayout.setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin) mainLayout.addWidget(self.treeWidget) if buttonBox is not None: # mainLayout.addStretch(1) mainLayout.addLayout(buttonBox) if not self.__node.type().isLink(): self.pathItem.hide() self.refItem.hide() else: self.nodeItem.hide() self.treeWidget.preferredHeight -= rowHeight globals.librarySignals.nodeRenamed.connect(self.__onNodeRename) globals.librarySignals.attribueRenamed.connect(self.__onAttributeRename) globals.librarySignals.attribueChanged.connect(self.__onAttributeChange) globals.librarySignals.attribueAdded.connect(self.__onAttributeAddDelete) globals.librarySignals.attribueDeleted.connect(self.__onAttributeAddDelete) globals.librarySignals.nodeRemoved.connect(self.__onNodeRemove) globals.librarySignals.nodeTypeChanged.connect(self.__onNodeTypeChangeExternal) globals.librarySignals.libraryExcluded.connect(self.__onLibraryExclude) self.setLayout(mainLayout)