def __update(self): """Update the current description. """ if self.__currentIndex != -1: index = self.model().index(self.__currentIndex, 0) else: index = QModelIndex() if not index.isValid(): description = "" name = "" path = "" svg = NO_PREVIEW_SVG else: description = index.data(Qt.WhatsThisRole) if description: description = description else: description = "No description." description = escape(description) description = description.replace("\n", "<br/>") name = index.data(Qt.DisplayRole) if name: name = name else: name = "Untitled" name = escape(name) path = str(index.data(Qt.StatusTipRole)) svg = str(index.data(previewmodel.ThumbnailSVGRole)) desc_text = self.__template.format(description=description, name=name) self.__label.setText(desc_text) self.__path.setText(contractuser(path)) if not svg: svg = NO_PREVIEW_SVG if svg: self.__image.load(QByteArray(svg.encode("utf-8")))
def rowCount(self, parent=QModelIndex()): return 0 if parent.isValid() else self.n_attributes
def insert(self, i, val): self.beginInsertRows(QModelIndex(), i, i) self._list.insert(i, val) self._other_data.insert(i, _store()) self.endInsertRows()
def index(self, row, column=0, parent=QModelIndex()): if self._is_index_valid_for(row, self) and column == 0: return QAbstractListModel.createIndex(self, row, column, parent) else: return QModelIndex()
def insertRows(self, row, count, parent=QModelIndex()): self.beginInsertRows(parent, row, row + count - 1) self._table[row:row] = [[''] * self.columnCount() for _ in range(count)] self.endInsertRows() return True
def parent(self, index=QModelIndex()): """Reimplemented from `QAbstractTableModel.parent`.""" return QModelIndex()
def setModelData(self, editor: QLineEdit, model: PyListModel, index: QModelIndex): model[index.row()].name = str(editor.text())
def removeRows(self, row, count, parent=QModelIndex()): # reimplemented return False
def columnCount(parent=QModelIndex()): return 0 if parent.isValid() else 3
def columnCount(self, parent=QModelIndex()): if parent.isValid(): return 0 return 1 + max((len(row.var.values) for row in self.attrdescs), default=0)
def rowCount(self, parent=QModelIndex(), *args, **kwargs): return 0 if parent.isValid() or self.word_index is None else len( self.word_index)
def rowCount(self, parent=QModelIndex()): if parent.isValid(): return 0 else: return len(self._source_key)
def parent(self, child): return QModelIndex()
def index(self, row, column=0, parent=QModelIndex()): if not parent.isValid(): return self.createIndex(row, column, object=row) else: return QModelIndex()
def _closeRequested(self, row): model = self.model() assert 0 <= row < model.rowCount() model.removeRows(row, 1, QModelIndex())
def columnCount(self, index=QModelIndex()): return 1
def columnCount(self, parent=QModelIndex()): if parent.isValid(): return 0 else: return len(self.__headers)
def setEditorData(self, editor: QLineEdit, index: QModelIndex): word_list = index.data(Qt.DisplayRole) editor.setText(word_list.name)
def createEditor(self, parent: QWidget, _: QStyleOptionViewItem, index: QModelIndex) -> VariableEditor: variable = index.data(VariableRole) values = index.data(ValuesRole) return _create_editor(variable, values, parent, self._commit_data)
def columnCount(self, parent=QModelIndex()): return 0 if parent.isValid() else max(map(len, self._table), default=0)
def setEditorData(self, editor: VariableEditor, index: QModelIndex): editor.value = index.model().data(index, ValueRole)
def columnCount(self, parent=QModelIndex()): """Reimplemented from `QAbstractTableModel.columnCount`.""" return 0 if parent.isValid() else self.__columnCount
def sizeHint(self, _: QStyleOptionViewItem, index: QModelIndex) -> QSize: return _create_editor(index.data(role=VariableRole), np.array([0]), None, lambda: 1).sizeHint()
def insertColumns(self, column, count, parent=QModelIndex()): self.beginInsertColumns(parent, column, column + count - 1) for row in self._table: row[column:column] = [''] * count self.endInsertColumns() return True
def index(self, row, col, parent=QModelIndex()): return self.createIndex(row, col, 0)
def parent(self, index=QModelIndex()): return QModelIndex()
def rowCount(self, index=QModelIndex()): if index.isValid(): return 0 else: return len(self._data)
def rowCount(self, parent=QModelIndex()): return 0 if parent.isValid() else len(self)
def columnCount(self, index=QModelIndex()): return len(self._header)
def columnCount(self, parent=QModelIndex()): return 0 if parent.isValid() else len(self.Columns)
def rowCount(self, index=QModelIndex()): return 0 if index.isValid() else len(self.scores)