def setSelectedItems(self, items): #block = self.blockSignals(True) sel = QItemSelection() for item in items: sel.merge(QItemSelection(item.index(), item.index(1)), QItemSelectionModel.SelectCurrent) if set(sel) != set(self.selectionModel().selection()): self.selectionModel().clear() self.selectionModel().select(sel, QItemSelectionModel.Select)
def redoSelection(self, selectedCoordinates): selection = QItemSelection() for i, c in enumerate(self.coordinates): if c in selectedCoordinates: selection.merge( QItemSelection(self.createIndex(i, 0), self.createIndex(i, 1)), QItemSelectionModel.Select) self.app.aw.ui.tableView.selectionModel().select( selection, QItemSelectionModel.Select)
def set_selection(self): if len(self.selected_rows) and len(self.selected_cols): view = self.tabs.currentWidget() selection = QItemSelection() temp_selection = QItemSelection() for row in self.selected_rows: for col in self.selected_cols: index = view.model().index(row, col) temp_selection.select(index, index) selection.merge(temp_selection, QItemSelectionModel.Select) view.selectionModel().select(selection, QItemSelectionModel.ClearAndSelect)
def updateCoordinate(self,row,c0,c1): # respect the limits # NOSORT if False and ((row > 0 and c0 <= self.coordinates[row-1][0]) or ((row < len(self.coordinates) - 1 and c0 >= self.coordinates[row+1][0]))): return else: selectedCoordinates = self.getSelectedCoordinates() self.beginResetModel() self.coordinates[row][0] = c0 self.coordinates[row][1] = int(c1) self.endResetModel() self.computePolyfit() selection = QItemSelection() for i,c in enumerate(self.coordinates): if c in selectedCoordinates: selection.merge(QItemSelection(self.createIndex(i,0),self.createIndex(i,1)),QItemSelectionModel.Select) self.app.aw.ui.tableView.selectionModel().select(selection,QItemSelectionModel.Select) self.app.contentModified()
def redoSelection(self,selectedCoordinates): selection = QItemSelection() for i,c in enumerate(self.coordinates): if c in selectedCoordinates: selection.merge(QItemSelection(self.createIndex(i,0),self.createIndex(i,1)),QItemSelectionModel.Select) self.app.aw.ui.tableView.selectionModel().select(selection,QItemSelectionModel.Select)