Esempio n. 1
0
 def parent(self, index):
     if index.isValid():
         parent = index.internalPointer().parent
         if parent:
             return QAbstractItemModel.createIndex(self, parent.row, 0,
                                                   parent)
     return QModelIndex()
Esempio n. 2
0
    def index(self, row, column, i_parent=None):
        parent = self._root if not i_parent or not i_parent.isValid(
        ) else i_parent.internalPointer()

        if not QAbstractItemModel.hasIndex(self, row, column, i_parent):
            return QModelIndex()

        child = parent.child(row)
        return QAbstractItemModel.createIndex(
            self, row, column, child) if child else QModelIndex()
    def index(self, row, column, parent=None):
        if not parent or not parent.isValid():
            parent = self.root_node
        else:
            parent = parent.internalPointer()

        if not self.hasIndex(row, column, QModelIndex()):
            return QModelIndex()

        child = parent.child(row)
        if child:
            return QAbstractItemModel.createIndex(self, row, column, child)
        else:
            return QModelIndex()
Esempio n. 4
0
    def index(self, in_row, in_column, in_parent=None):
        if not in_parent or not in_parent.isValid():
            parent = self._root
        else:
            parent = in_parent.internalPointer()
        if not QAbstractItemModel.hasIndex(self, in_row, in_column, in_parent):
            return QModelIndex()

        child = parent.child(in_row)
        if child:
            return QAbstractItemModel.createIndex(self, in_row, in_column,
                                                  child)
        else:
            return QModelIndex()
Esempio n. 5
0
    def index(self, row, column, parent=None):
        if parent.isValid():
            p = parent.internalPointer()
        else:
            p = self.root

        if not QAbstractItemModel.hasIndex(self, row, column, parent):
            return QModelIndex()

        child = p.child(row)
        if child:
            return QAbstractItemModel.createIndex(self, row, column, child)
        else:
            return QModelIndex()
Esempio n. 6
0
    def index(self, row, column, parent_index=None):
        if not parent_index:
            parent_index = QModelIndex()
        if not parent_index.isValid():
            parent = self._root
        else:
            parent = parent_index.internalPointer()

        if not QAbstractItemModel.hasIndex(self, row, column, parent_index):
            return QModelIndex()

        if child := parent.child(row):
            index = QAbstractItemModel.createIndex(self, row, column, child)
            if 'Geometry' in child._data:
                self.geo_index = index
            if 'Setups' in child._data:
                self.setup_index = index
            if hasattr(child, 'entity'):
                self.indexes[str(child.entity)] = index
            return index
 def parent(self, index):
     if index.isValid():
         p = index.internalPointer().parent()
         if p:
             return QAbstractItemModel.createIndex(self, p.row(), 0, p)
     return QModelIndex()
Esempio n. 8
0
 def index(self, row, column, parent):
     """Inheritied from QAbstractItemModel
     """
     return QAbstractItemModel.createIndex(self, row, column,
                                           CONSTS['cols'] * row + column)
Esempio n. 9
0
 def parent_idx(self, model: QAbstractItemModel) -> QModelIndex:
     if self.parent_node:
         assert self.row is not None
         return model.createIndex(self.row, 0, self.parent_node)
     else:
         return QModelIndex()
Esempio n. 10
0
 def index(self, row, column, parent=QModelIndex()):
     if row >= 0 and row < len(self._data):
         input = self._data[row]
         return QAbstractItemModel.createIndex(self, row, column, input)
     else:
         return QModelIndex()
Esempio n. 11
0
 def index(self, row, column, parent=QModelIndex()):
     if row < len(self._data):
         profile = self._data[row]
         return QAbstractItemModel.createIndex(self, row, column, profile)
     else:
         return QModelIndex()