def insertRows(self, position, rows, parent=QtCore.QModelIndex()): self.beginInsertRows(parent, position, position + rows - 1) for i in range(rows): self.__data.insert(position, '') self.endInsertRows() return True
def removeRows(self, position, rows, parent=QtCore.QModelIndex()): self.beginRemoveRows(parent, position, position + rows - 1) for i in range(rows): value = self.__data[position] self.__data.remove(value) self.endRemoveRows() return True
def insertNode(self, node=None, parent=QtCore.QModelIndex()): if parent.isValid() : childCount = parent.internalPointer().childCount() else: childCount = 0 self.model.insertRows(childCount, 1, parent, node) new_index = self.model.index(childCount, 0, parent) self.addIndex(new_index, False) return new_index
def insertRows(self, position, rows, parent=QtCore.QModelIndex()): self.beginInsertRows(parent, position, position + rows - 1) for i in range(rows): default_values = ['' for i in range(self.columnCount(None))] self.__data.insert(position, default_values) self.endInsertRows() return True
def removeNode(self, row, parent=QtCore.QModelIndex()): if parent.isValid() : childCount = parent.internalPointer().childCount() else: childCount = 0 for i in range(childCount) : child_index = self.model.index(i, 0, parent) self.removeIndex(child_index) self.model.removeRows(i, 1, parent)
def insertColumns(self, position, columns, parent=QtCore.QModelIndex()): self.beginInsertColumns(parent, position, position + columns - 1) rowCount = len(self.__data) for i in range(columns): for j in range(rowCount): self.__data[j].insert(position, '') self.endInsertColumns() return True
def removeColumns(self, position, columns, parent=QtCore.QModelIndex()): self.beginRemoveRows(parent, position, position + columns - 1) rowCount = len(self.__data) for i in range(columns): for j in range(rowCount): value = self.__data[j][position] self.__data[j].remove(value) self.endRemoveRows() return True