def mapSelectionToSource(self, proxySelection): sourceSelection = QItemSelection() if self.sourceModel() is None: return sourceSelection cursor = proxySelection.constBegin() end = proxySelection.constEnd() while cursor != end: topLeft = self.mapToSource(cursor.topLeft()) bottomRight = self.mapToSource(cursor.bottomRight()) sourceRange = QItemSelectionRange(topLeft, bottomRight) sourceSelection.append(sourceRange) cursor += 1 return sourceSelection
def mapSelectionFromSource(self, sourceSelection): proxySelection = QItemSelection() if self.sourceModel() is None: return proxySelection cursor = sourceSelection.constBegin() end = sourceSelection.constEnd() while cursor != end: topLeft = self.mapFromSource(cursor.topLeft()) bottomRight = self.mapFromSource(cursor.bottomRight()) proxyRange = QItemSelectionRange(topLeft, bottomRight) proxySelection.append(proxyRange) cursor += 1 return proxySelection