def initComponents(self): self.setLayout(Qt.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.list = HistoryMacrosList(self) self._model = MacrosListModel() self.list.setModel(self._model) # self.registerConfigDelegate(self.list) self.layout().addWidget(self.list) actionBar = self.createActionBar() self.layout().addLayout(actionBar)
def initComponents(self): self.setLayout(Qt.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.list = HistoryMacrosList(self) self._model = MacrosListModel() self.list.setModel(self._model) ##### self.registerConfigDelegate(self.list) self.layout().addWidget(self.list) actionBar = self.createActionBar() self.layout().addLayout(actionBar)
class HistoryMacrosViewer(TaurusWidget): __pyqtSignals__ = ("modelChanged(const QString &)", ) def __init__(self, parent=None, designMode=False): TaurusWidget.__init__(self, parent, designMode) self.setObjectName(self.__class__.__name__) self.registerConfigProperty("toXmlString", "fromXmlString", "history") self.initComponents() def initComponents(self): self.setLayout(Qt.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.list = HistoryMacrosList(self) self._model = MacrosListModel() self.list.setModel(self._model) # self.registerConfigDelegate(self.list) self.layout().addWidget(self.list) actionBar = self.createActionBar() self.layout().addLayout(actionBar) def createActionBar(self): layout = Qt.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) deleteAllButton = Qt.QToolButton() deleteAllButton.setDefaultAction(self.list.removeAllAction) layout.addWidget(deleteAllButton) spacerItem = Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Expanding) layout.addItem(spacerItem) return layout def listElementUp(self): indexPos = self.list.currentIndex() if indexPos.isValid() and indexPos.row() >= 1: self.list.setCurrentIndex( indexPos.sibling(indexPos.row() - 1, indexPos.column())) else: self.selectFirstElement() def listElementDown(self): indexPos = self.list.currentIndex() if indexPos.isValid() and indexPos.row() < self._model.rowCount() - 1: self.list.setCurrentIndex( indexPos.sibling(indexPos.row() + 1, indexPos.column())) elif indexPos.row() == self._model.rowCount() - 1: return else: self.selectFirstElement() def addMacro(self, macroNode): self.list.insertMacro(macroNode) def toXmlString(self): return self.list.toXmlString() def fromXmlString(self, xmlString): self.list.fromXmlString(xmlString) historyList = self.list.model().list macroServerObj = self.getModelObj() if macroServerObj is None: return for macroNode in historyList: macroServerObj.fillMacroNodeAdditionalInfos(macroNode) def selectFirstElement(self): self.list.removeAllAction.setEnabled(True) self.list.setCurrentIndex(self._model.index(0)) @classmethod def getQtDesignerPluginInfo(cls): return None
class HistoryMacrosViewer(TaurusWidget): __pyqtSignals__ = ("modelChanged(const QString &)",) def __init__(self, parent=None, designMode=False): TaurusWidget.__init__(self, parent, designMode) self.setObjectName(self.__class__.__name__) self.registerConfigProperty("toXmlString", "fromXmlString", "history") self.initComponents() def initComponents(self): self.setLayout(Qt.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.list = HistoryMacrosList(self) self._model = MacrosListModel() self.list.setModel(self._model) ##### self.registerConfigDelegate(self.list) self.layout().addWidget(self.list) actionBar = self.createActionBar() self.layout().addLayout(actionBar) def createActionBar(self): layout = Qt.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) deleteAllButton = Qt.QToolButton() deleteAllButton.setDefaultAction(self.list.removeAllAction) layout.addWidget(deleteAllButton) spacerItem = Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Expanding) layout.addItem(spacerItem) return layout def listElementUp(self): indexPos = self.list.currentIndex() if indexPos.isValid() and indexPos.row() >= 1: self.list.setCurrentIndex(indexPos.sibling(indexPos.row() - 1, indexPos.column())) else: self.selectFirstElement() def listElementDown(self): indexPos = self.list.currentIndex() if indexPos.isValid() and indexPos.row() < self._model.rowCount() - 1: self.list.setCurrentIndex(indexPos.sibling(indexPos.row() + 1, indexPos.column())) elif indexPos.row() == self._model.rowCount() - 1: return else: self.selectFirstElement() def addMacro(self, macroNode): self.list.insertMacro(macroNode) def toXmlString(self): return self.list.toXmlString() def fromXmlString(self, xmlString): self.list.fromXmlString(xmlString) historyList = self.list.model().list macroServerObj = self.getModelObj() if macroServerObj is None: return for macroNode in historyList: macroServerObj.fillMacroNodeAdditionalInfos(macroNode) def selectFirstElement(self): self.list.removeAllAction.setEnabled(True) self.list.setCurrentIndex(self._model.index(0)) @classmethod def getQtDesignerPluginInfo(cls): return None