def mouseReleaseEvent(self, event): # TODO, clean this up, so much duplicate code, it's embarrassing. if self.mouseIsDown: self.mouseIsDown = False idxs = self.model().mapToSource(self.indexAt(self.center)) idxt = self.model().mapToSource(self.indexAt(self.startCenter)) sm = self.model().sourceModel() if len(self.selectionModel().selection().indexes()) > 1: value = "=" + "%s.%s" % ( sm.toolDict[idxs.row() + 1].Name, sm.toolsInputs[idxs.row()].get( sm.attributeNameKeys[idxs.column()]).ID, ) self.commitDataDo(value) else: if (idxs.row() > -1 and idxs.column() > -1 and idxt.row() > -1 and idxt.column() > -1): fusionInput = sm.toolsInputs[idxt.row()].get( sm.attributeNameKeys[idxt.column()]) fusionOutput = sm.toolsInputs[idxs.row()].get( sm.attributeNameKeys[idxs.column()]) # Select the first cell by sampling the area under the first clicked mouse center self.setSelection( QRect(self.startCenter, self.startCenter), QItemSelectionModel.SelectCurrent, ) value = "=" + "%s.%s" % ( sm.toolDict[idxs.row() + 1].Name, sm.toolsInputs[idxs.row()].get( sm.attributeNameKeys[idxs.column()]).ID, ) self.commitDataDo(value) self.viewport().repaint() QTableView.mouseReleaseEvent(self, event)
def mouseReleaseEvent(self, event): if self.mouseIsDown: self.mouseIsDown = False idxs = self.model().mapToSource(self.indexAt(self.center)) sm = self.model().sourceModel() if len(self.selectionModel().selection().indexes()) <= 1: idxt = self.model().mapToSource(self.indexAt(self.startCenter)) if (idxs.row() > -1 and idxs.column() > -1 and idxt.row() > -1 and idxt.column() > -1): fusionInput = sm.toolsInputs[idxt.row()].get( sm.attributeNameKeys[idxt.column()]) fusionOutput = sm.toolsInputs[idxs.row()].get( sm.attributeNameKeys[idxs.column()]) # Select the first cell by sampling the area # under the first clicked mouse center self.setSelection( QRect(self.startCenter, self.startCenter), QItemSelectionModel.SelectCurrent, ) self.create_value(sm, idxs) self.viewport().repaint() QTableView.mouseReleaseEvent(self, event)