def __init__(self, parent=None): QAbstractProxyModel.__init__(self, parent) self.__sourceColumn = 0 self.__flatteningMode = 1 self.__sourceRootIndex = QModelIndex() self._source_key = {} self._source_offset = {}
def flags(self, index): flags = QAbstractProxyModel.flags(self, index) if self.__flatteningMode == self.InternalNodesDisabled: sourceIndex = self.mapToSource(index) sourceModel = self.sourceModel() if sourceModel.rowCount(sourceIndex) > 0 and \ flags & Qt.ItemIsEnabled: # Internal node, enabled in the source model, disable it flags ^= Qt.ItemIsEnabled return flags
def setSourceModel(self, model): self.beginResetModel() curr_model = self.sourceModel() if curr_model is not None: curr_model.dataChanged.disconnect(self._sourceDataChanged) curr_model.rowsInserted.disconnect(self._sourceRowsInserted) curr_model.rowsRemoved.disconnect(self._sourceRowsRemoved) curr_model.rowsMoved.disconnect(self._sourceRowsMoved) QAbstractProxyModel.setSourceModel(self, model) self._updateRowMapping() model.dataChanged.connect(self._sourceDataChanged) model.rowsInserted.connect(self._sourceRowsInserted) model.rowsRemoved.connect(self._sourceRowsRemoved) model.rowsMoved.connect(self._sourceRowsMoved) self.endResetModel()
def __init__(self, parent=None): QAbstractProxyModel.__init__(self, parent) self.__sourceColumn = 0 self.__flatteningMode = 1 self.__sourceRootIndex = QModelIndex()