def flags(self, index=QtCore.QModelIndex()): column = self.Columns(index.column()) if column in [self.Columns.X, self.Columns.Y]: if self.is_point_complete(self._points[index.row()]): return QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled return QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsEditable if column == self.Columns.IMAGE: return QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled
def append_point(self, point=(None, None, 1.0), image=None, noflush=False): self.beginInsertRows(QtCore.QModelIndex(), len(self._points), len(self._points)) self._points.append(list(point)) self._images.append(image) self.endInsertRows() if self.is_point_complete(point) and not noflush: self.flush_file()
def columnCount(self, parent=QtCore.QModelIndex()): # noinspection PyTypeChecker return len(self.Columns)
def rowCount(self, parent=QtCore.QModelIndex()): return len(self._points)
def parent(self, index): return QtCore.QModelIndex()
def index(self, row, column, parent=QtCore.QModelIndex()): return self.createIndex(row, column)
def remove_point(self, index): self.beginRemoveRows(QtCore.QModelIndex(), index, index) self._points.pop(index) self._images.pop(index) self.endRemoveRows() self.flush_file()