Exemple #1
0
    def setSelection(self, selection):
        """
        Set the model item selection.

        Parameters
        ----------
        selection : QtCore.QItemSelection
            Item selection.
        """
        if self.values_view.selectionModel() is not None:
            indices = selection.indexes()
            pind = defaultdict(list)

            for index in indices:
                parent = index.parent()
                if parent.isValid():
                    if parent == self.__model.index(parent.row(),
                                                    parent.column()):
                        pind[parent.row()].append(
                            QtCore.QPersistentModelIndex(index))
                    else:
                        warnings.warn("Die Die Die")
                else:
                    # top level index
                    pass

            self.__selections = pind
            self.__restoreSelection()
Exemple #2
0
 def __storeSelection(self, groupind, indices):
     # Store current values selection for the current group
     groupind = self.__currentIndex
     indices = [
         QtCore.QPersistentModelIndex(ind)
         for ind in self.values_view.selectedIndexes()
     ]
     self.__selections[groupind] = indices