def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: return to_qvariant( self.dataDarcyLawZones[index.row()][index.column()]) return to_qvariant()
def headerData(self, section, orientation, role): """ Return the header column data. """ if orientation == Qt.Horizontal and role == Qt.DisplayRole: return to_qvariant(self.headers[section]) return to_qvariant()
def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: if section == 0: return to_qvariant(self.tr("variable name")) elif section == 1: return to_qvariant(self.tr("value")) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: return to_qvariant(self.dataAverage[index.row()][index.column()]) elif role == Qt.TextAlignmentRole: return to_qvariant(Qt.AlignCenter) return to_qvariant()
def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: if section == 0: return to_qvariant(self.tr("Output label")) if section == 1: return to_qvariant(self.tr("Internal name")) elif section == 2: return to_qvariant(self.tr("Post-\nprocessing")) return to_qvariant()
def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: if section == 0: return to_qvariant(self.tr("File name")) elif section == 1: return to_qvariant(self.tr("Status")) elif section == 2: return to_qvariant(self.tr("Subplot")) return to_qvariant()
def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: if section == 0: return to_qvariant(self.tr("Filename")) elif section == 1: return to_qvariant(self.tr("Variables")) elif role == Qt.TextAlignmentRole: return to_qvariant(Qt.AlignCenter) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.ToolTipRole: return to_qvariant(self.tooltip[index.column()]) if role == Qt.DisplayRole: return to_qvariant(self.dataSyrthes[index.row()][index.column()]) elif role == Qt.TextAlignmentRole: return to_qvariant(Qt.AlignCenter) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() # ToolTips BUG if role == Qt.ToolTipRole: if index.column() == 2: return to_qvariant(self.tr("Code_Saturne keyword: ipstdv")) # StatusTips if role == Qt.StatusTipRole: if index.column() == 2: return to_qvariant("Post-processing") # Display if role == Qt.DisplayRole: row = index.row() if index.column() == 0: return to_qvariant(self.dataLabel[row]) elif index.column() == 1: return to_qvariant(self.dataName[row]) else: return to_qvariant() # CheckState if role == Qt.CheckStateRole: row = index.row() if index.column() == 2: value = self.dataPost[row] if value == 'on': return to_qvariant(Qt.Checked) else: return to_qvariant(Qt.Unchecked) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() row = index.row() column = index.column() dico = self.dataScheme[row] key = self.keys[column] if dico[key] == None: return to_qvariant() if role == Qt.ToolTipRole: if index.column() > 0: return to_qvariant(self.tr("Code_Saturne keyword: " + key.upper())) elif role == Qt.DisplayRole and not column in [3, 4]: if key == 'ischcv': return to_qvariant(self.dicoM2V[dico[key]]) else: return to_qvariant(dico[key]) elif role == Qt.CheckStateRole and column in [3, 4]: st = None if key in ['isstpc', 'ircflu']: st = dico[key] if st == 'on': return to_qvariant(Qt.Checked) else: return to_qvariant(Qt.Unchecked) elif role == Qt.TextAlignmentRole: return to_qvariant(Qt.AlignCenter) return to_qvariant()
def data(self, index, role): """ Called when table need to read the data """ # return value only for Qt.DisplayRole if index.isValid() and role == Qt.DisplayRole: row = index.row() col = index.column() return to_qvariant(self.__data[row][col]) return to_qvariant()
def data(self, column, role): if self.item == None: if column == 0: return to_qvariant(self.header) else: return to_qvariant() else: if column == 0 and role == Qt.DisplayRole: return to_qvariant(self.item.name) elif column == 1 and role == Qt.DisplayRole: return to_qvariant(self.item.value) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: if index.column() == 0: return to_qvariant(self.lst[index.row()][1]) elif index.column() == 1: key = self.lst[index.row()][3] return to_qvariant(self.dataScalars[key]) elif index.column() == 2: return to_qvariant(self.lst[index.row()][2]) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: classe = index.row() coal = index.column() if classe < self.coalClassesNumber[coal]: try: return to_qvariant(self.ratio[coal][classe]) except: log.debug("ERROR no data for self.ratio[%i][%i] "%(coal, classe)) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() # ToolTips if role == Qt.ToolTipRole: return to_qvariant(self.tr("Code_Saturne key word: " + self.kwords[index.column()])) # Display if role == Qt.DisplayRole: return to_qvariant(self.dataCoals[index.row()][index.column()]) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() row = index.row() col = index.column() if role == Qt.ToolTipRole: return to_qvariant(self.toolTipRole[col]) if role == Qt.DisplayRole: return to_qvariant(self._data[row][col]) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.ToolTipRole: return to_qvariant() elif role == Qt.DisplayRole: data = self._data[index.row()][index.column()] if data: return to_qvariant(data) else: return to_qvariant() elif role == Qt.CheckStateRole: data = self._data[index.row()][index.column()] if index.column() == 2: if data == 'on': return to_qvariant(Qt.Checked) else: return to_qvariant(Qt.Unchecked) elif role == Qt.TextAlignmentRole: return to_qvariant(Qt.AlignCenter) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() item = index.internalPointer() # ToolTips if role == Qt.ToolTipRole: return to_qvariant() # StatusTips if role == Qt.StatusTipRole: if index.column() == 0: return to_qvariant(self.tr("Case name")) elif index.column() == 1: return to_qvariant(self.tr("Status")) elif index.column() == 2: return to_qvariant(self.tr("Compute")) elif index.column() == 3: return to_qvariant(self.tr("Post-processing")) elif index.column() == 4: return to_qvariant(self.tr("Run_id")) # Display if role == Qt.DisplayRole: return item.data(index.column(), role) elif role == Qt.CheckStateRole: return item.data(index.column(), role) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.ToolTipRole: return to_qvariant() elif role == Qt.DisplayRole: data = self._data[index.row()][index.column()] if data: return to_qvariant(data) else: return to_qvariant() return to_qvariant()
def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.combo_mdl.dicoV2M[txt] selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole)
def setModelData(self, editor, model, index): if editor.validator().state == QValidator.Acceptable: value = from_qvariant(editor.text(), int) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value))
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.ToolTipRole: return to_qvariant(self.tooltip[index.column()]) if role == Qt.DisplayRole: data = self._data[index.row()][index.column()] if index.column() in (0, 1): if data: return to_qvariant(data) else: return to_qvariant() return to_qvariant()
def setModelData(self, editor, model, index): if not editor.isModified(): return if editor.validator().state == QValidator.Acceptable: value = from_qvariant(editor.text(), float) model.setData(index, to_qvariant(value), Qt.DisplayRole)
def __init__(self): """ Constructor """ QWidget.__init__(self) Ui_BrowserForm.__init__(self) self.setupUi(self) tree = self._browser() self.model = TreeModel(from_qvariant(to_qvariant(tree), to_text_string)) self.treeView.setModel(self.model) self.treeView.header().hide() self.treeView.setAnimated(True) self.treeView.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.treeView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.treeView.setAlternatingRowColors(True) self.treeView.setWindowTitle("Simple Tree Model") # Popup menu self.treeView.setContextMenuPolicy(Qt.CustomContextMenu) self.treeView.customContextMenuRequested[QPoint].connect( self.displayPopup) # Receive change in selection self.treeView.pressed[QModelIndex].connect(self.onItemPressed) self.treeView.expanded[QModelIndex].connect(self.onFolderOpen) self.treeView.collapsed[QModelIndex].connect(self.onFolderClose)
def setModelData(self, editor, model, index): value = editor.text() if editor.validator().state == QValidator.Acceptable: selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole)
def __init__(self): """ Constructor """ QWidget.__init__(self) Ui_BrowserForm.__init__(self) self.setupUi(self) tree = self._browser() self.model = TreeModel(from_qvariant(to_qvariant(tree), to_text_string)) self.treeView.setModel(self.model) self.treeView.header().hide() self.treeView.setAnimated(True) self.treeView.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.treeView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.treeView.setAlternatingRowColors(True) self.treeView.setWindowTitle("Simple Tree Model") # Popup menu self.treeView.setContextMenuPolicy(Qt.CustomContextMenu) self.connect(self.treeView, SIGNAL("customContextMenuRequested(QPoint)"), self.displayPopup) # Receive change in selection self.connect(self.treeView, SIGNAL('pressed(const QModelIndex &)'), self.onItemPressed) self.connect(self.treeView, SIGNAL('expanded(const QModelIndex &)'), self.onFolderOpen) self.connect(self.treeView, SIGNAL('collapsed(const QModelIndex &)'), self.onFolderClose)
def slotActivated(self, index): value = self.itemData(index, Qt.CheckStateRole) state = from_qvariant(value, int) if state == Qt.Unchecked: s = Qt.Checked else: s = Qt.Unchecked self.setItemData(index, to_qvariant(s), Qt.CheckStateRole)
def setModelData(self, editor, model, index): if not editor.isModified(): return if editor.validator().state == QValidator.Acceptable: value = from_qvariant(editor.text(), float) for idx in self.parent.selectionModel().selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole)
def data(self, index, role): if not index.isValid(): return to_qvariant() item = index.internalPointer() # ToolTips if role == Qt.ToolTipRole: return to_qvariant() # StatusTips if role == Qt.StatusTipRole: if index.column() == 0: return to_qvariant(self.tr("variable name")) elif index.column() == 1: return to_qvariant(self.tr("value")) elif index.column() == 2: return to_qvariant(self.tr("OpenTurns Variable")) elif index.column() == 3: return to_qvariant(self.tr("Description")) # Display if role == Qt.DisplayRole: return item.data(index.column(), role) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() item = index.internalPointer() # ToolTips if role == Qt.ToolTipRole: return to_qvariant() # StatusTips if role == Qt.StatusTipRole: if index.column() == 0: return to_qvariant(self.tr("Variable/Scalar name")) elif index.column() == 2: return to_qvariant(self.tr("Print in listing")) elif index.column() == 3: return to_qvariant(self.tr("Post-processing")) elif index.column() == 4: return to_qvariant(self.tr("Monitoring")) # Display if role == Qt.DisplayRole: return item.data(index.column(), role) elif role == Qt.CheckStateRole: return item.data(index.column(), role) #if role == Qt.TextAlignmentRole and index.column() > 1: # return to_qvariant(Qt.AlignHCenter) return to_qvariant()
def headerData(self, section, orientation, role): """Return the header of the tree.* @return: C{QVariant} """ if orientation == Qt.Horizontal and role == Qt.DisplayRole: return self.rootItem.data(section) return to_qvariant()
def setModelData(self, editor, model, index): if editor.validator().state == QValidator.Acceptable: row = index.row() stype = index.model().getData(row, 2) if stype == 'time step': value = from_qvariant(editor.text(), int) else: value = from_qvariant(editor.text(), float) model.setData(index, to_qvariant(value), Qt.DisplayRole)
def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] log.debug("CarrierDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole)
def setModelData(self, comboBox, model, index): value = str(comboBox.currentText()) key = '' for i in range(len(self.lst)): if value == self.lst[i][1] + self.lst[i][2]: key = self.lst[i][0] model.setData(index, to_qvariant(key)) if self.updateLayout != None: self.updateLayout()
def data(self, index, role): """Returns the data stored under the given I{role} for the item referred to by the I{index}. @type index: C{QModelIndex} @param index: used to locate data in a data model @type role: C{Qt.ItemDataRole} @param role: used by the view to indicate to the model which type of data it needs @return: C{QVariant} """ if not index.isValid(): return to_qvariant() item = index.internalPointer() column = index.column() if role == Qt.DisplayRole: # return text for columns if column == 0: return to_qvariant(item.itemData[column]) elif role == Qt.DecorationRole: # return icon for first column if column == 0: style = QWidget().style() if item.itemType == "folder-new": icon = style.standardIcon(QStyle.SP_FileDialogNewFolder) elif item.itemType == "folder-close": icon = style.standardIcon(QStyle.SP_DirClosedIcon) elif item.itemType == "folder-open": icon = style.standardIcon(QStyle.SP_DirOpenIcon) elif item.itemType == "file-open": icon = style.standardIcon(QStyle.SP_FileIcon) elif item.itemType == "file-new": icon = style.standardIcon(QStyle.SP_FileLinkIcon) if sys.platform.startswith("win"): if item.itemType == "file-open": icon = style.standardIcon( QStyle.SP_ToolBarHorizontalExtensionButton) elif item.itemType == "file-new": icon = style.standardIcon( QStyle.SP_ToolBarHorizontalExtensionButton) return to_qvariant(icon) return to_qvariant()
def setModelData(self, editor, model, index): if editor.validator().state == QValidator.Acceptable: if index.column() == 3: value = from_qvariant(editor.text(), float) elif (index.column() == 2 or index.column() == 4): value = from_qvariant(editor.text(), int) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value))
def data(self, index, role): """Returns the data stored under the given I{role} for the item referred to by the I{index}. @type index: C{QModelIndex} @param index: used to locate data in a data model @type role: C{Qt.ItemDataRole} @param role: used by the view to indicate to the model which type of data it needs @return: C{QVariant} """ if not index.isValid(): return to_qvariant() item = index.internalPointer() column = index.column() if role == Qt.DisplayRole: # return text for columns if column == 0: return to_qvariant(item.itemData[column]) elif role == Qt.DecorationRole: # return icon for first column if column == 0: style = QWidget().style() if item.itemType == "folder-new": icon = style.standardIcon(QStyle.SP_FileDialogNewFolder) elif item.itemType == "folder-close": icon = style.standardIcon(QStyle.SP_DirClosedIcon) elif item.itemType == "folder-open": icon = style.standardIcon(QStyle.SP_DirOpenIcon) elif item.itemType == "file-open": icon = style.standardIcon(QStyle.SP_FileIcon) elif item.itemType == "file-new": icon = style.standardIcon(QStyle.SP_FileLinkIcon) if sys.platform.startswith("win"): if item.itemType == "file-open": icon = style.standardIcon(QStyle.SP_ToolBarHorizontalExtensionButton) elif item.itemType == "file-new": icon = style.standardIcon(QStyle.SP_ToolBarHorizontalExtensionButton) return to_qvariant(icon) return to_qvariant()
def setModelData(self, editor, model, index): if not editor.isModified(): return if editor.validator().state == QValidator.Acceptable: value = from_qvariant(editor.text(), float) for idx in self.parent.selectionModel().selectedIndexes(): if idx.column() == index.column(): maxi = model.getData(idx)['scamax'] name = model.getData(idx)['name'] if model.checkMinMax(name, value, maxi): model.setData(idx, to_qvariant(value), Qt.DisplayRole)
def setModelData(self, editor, model, index): value = editor.text() if value != self.value and str(value) in self.mdl.getLocalizationsZonesList(): title = self.tr("Warning") msg = self.tr("This localization is already used.\n"\ "Please give another one.") QMessageBox.information(self.parent, title, msg) return if str(value) != "" : model.setData(index, to_qvariant(value), Qt.DisplayRole)
def setModelData(self, editor, model, index): if editor.validator().state == QValidator.Acceptable: value = from_qvariant(editor.text(), int) # Check for unicity if value != self.value and str(value) in self.mdl.getCodeNumbersList(): title = self.tr("Warning") msg = self.tr("Zone number can be used only once.\n"\ "Please give another value.") QMessageBox.warning(self.parent, title, msg) return model.setData(index, to_qvariant(value), Qt.DisplayRole)
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: row = index.row() col = index.column() if col in [0, 1, 3]: return to_qvariant(self._data[row][col]) elif col == 2: if self.zoneType == "VolumicZone": data = self._data[row][col] item = string.join([self.dicoM2V[key] for key in list(self.dicoM2V.keys()) if data[key] == "on"], "\n") return to_qvariant(item) elif self.zoneType == "BoundaryZone": key = self._data[row][col] return to_qvariant(self.dicoM2V[key]) return to_qvariant()
def __init__(self, data, parent=None): """Constructs a new item model with the given I{parent}. @type data: C{QString} @param data: content of the new item @type parent: C{QObject} or C{None} @param parent: parent of the new item """ QAbstractItemModel.__init__(self, parent) rootData = [] rootData.append(to_qvariant("Pages")) self.rootItem = TreeItem(rootData, "folder") self.populateModel(data.split("\n"), self.rootItem)
def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: if section == 0: return to_qvariant(self.tr("Name")) elif section == 1: return to_qvariant(self.tr("Solver\nChoice")) elif section == 2: return to_qvariant(self.tr("Maximum\nIteration Number")) elif section == 3: return to_qvariant(self.tr("Solver\nPrecision")) elif section == 4: return to_qvariant(self.tr("Time Step\nFactor")) else: return to_qvariant() return to_qvariant()
def itemLocalization(self, data, role=Qt.DisplayRole): """ """ info = [] search_item = from_qvariant(to_qvariant(data), to_text_string) start = self.index(0, 0, QModelIndex()) indexList = self.match(start, role, search_item, -1, Qt.MatchExactly) for index in indexList: item = index.internalPointer() column = index.column() row = index.row() parent = self.parent(index) info.append( (row, column, parent) ) return info
def data(self, index, role): if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: if index.column() == 0: return to_qvariant(self.lst[index.row()][1]) elif index.column() == 1: key = self.lst[index.row()][3] return to_qvariant(self.dataScalars[key]) elif index.column() == 2: return to_qvariant(self.lst[index.row()][2]) if role == Qt.ToolTipRole: kword = self.lst[index.row()][3] return to_qvariant(self.tr("Code_Saturne keyword: " + kword)) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() row = index.row() col = index.column() if role == Qt.ToolTipRole: return to_qvariant(self.tooltip[col]) if role == Qt.DisplayRole: if col == 0: return to_qvariant(self.dataFaces[row]['fraction']) elif col == 1: return to_qvariant(self.dataFaces[row]['plane']) elif col == 2: return to_qvariant(self.dataFaces[row]['verbosity']) elif col == 3: return to_qvariant(self.dataFaces[row]['visualization']) elif col == 4: return to_qvariant(self.dataFaces[row]['selector']) return to_qvariant()
def data(self, index, role): if not index.isValid(): return to_qvariant() row = index.row() col = index.column() if role == Qt.ToolTipRole: return to_qvariant(self.toolTipRole[col]) if role == Qt.DisplayRole: row = index.row() dico = self._data[row] if col == 0: return to_qvariant(dico['name']) elif col == 1: return to_qvariant(dico['scamin']) elif col == 2: return to_qvariant(dico['scamax']) else: return to_qvariant() elif role == Qt.TextAlignmentRole: return to_qvariant(Qt.AlignCenter) return to_qvariant()