当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QItemSelection类代码示例

本文整理汇总了Python中PyQt4.QtGui.QItemSelection的典型用法代码示例。如果您正苦于以下问题:Python QItemSelection类的具体用法?Python QItemSelection怎么用?Python QItemSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QItemSelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: select

    def select(self, selection, flags):
        if isinstance(selection, QModelIndex):
            selection = QItemSelection(selection, selection)

        model = self.model()
        indexes = selection.indexes()
        sel_inds = {ind.row() for ind in indexes} | \
                   {ind.column() for ind in indexes}
        if flags == QItemSelectionModel.ClearAndSelect:
            selected = set()
        else:
            selected = {ind.row() for ind in self.selectedIndexes()}
        if flags & QItemSelectionModel.Select:
            selected |= sel_inds
        elif flags & QItemSelectionModel.Deselect:
            selected -= sel_inds
        new_selection = QItemSelection()
        regions = list(ranges(sorted(selected)))
        for r_start, r_end in regions:
            for c_start, c_end in regions:
                top_left = model.index(r_start, c_start)
                bottom_right = model.index(r_end - 1, c_end - 1)
                new_selection.select(top_left, bottom_right)
        QItemSelectionModel.select(self, new_selection,
                                   QItemSelectionModel.ClearAndSelect)
开发者ID:OXPHOS,项目名称:orange3,代码行数:25,代码来源:owdistancematrix.py

示例2: _set_selection

 def _set_selection(self):
     selection = QItemSelection()
     index = self.tableview.model().index
     for row, col in self.selection:
         sel = index(row + 2, col + 2)
         selection.select(sel, sel)
     self.tableview.selectionModel().select(
         selection, QItemSelectionModel.ClearAndSelect)
开发者ID:BlazZupan,项目名称:orange3,代码行数:8,代码来源:owconfusionmatrix.py

示例3: setSelectedItems

 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)
开发者ID:cvhciKIT,项目名称:sloth,代码行数:8,代码来源:model.py

示例4: select_correct

    def select_correct(self):
        selection = QItemSelection()
        n = self.tablemodel.rowCount()
        for i in range(n):
            index = self.tablemodel.index(i, i)
            selection.select(index, index)

        self.tableview.selectionModel().select(selection, QItemSelectionModel.ClearAndSelect)
开发者ID:nedaeh,项目名称:vpe,代码行数:8,代码来源:owconfusionmatrix.py

示例5: select_correct

 def select_correct(self):
     """Select the diagonal elements of the matrix"""
     selection = QItemSelection()
     n = self.tablemodel.rowCount()
     for i in range(2, n):
         index = self.tablemodel.index(i, i)
         selection.select(index, index)
     self.tableview.selectionModel().select(
         selection, QItemSelectionModel.ClearAndSelect)
开发者ID:BlazZupan,项目名称:orange3,代码行数:9,代码来源:owconfusionmatrix.py

示例6: on_actionSelect_odd_images_triggered

 def on_actionSelect_odd_images_triggered(self):
     widget = self.activ_selection
     model = widget.model()
     selection = widget.selectionModel()
     sel = QItemSelection()
     for i in  range(0,len(model),2):
         sel.select(model.index(i,0), model.index(i,1))
     selection.select(sel, QItemSelectionModel.ClearAndSelect)
     widget.viewport().update()
开发者ID:PierreBdR,项目名称:point_tracker,代码行数:9,代码来源:growth_computation.py

示例7: _restoreSelection

 def _restoreSelection(self):
     newSelection = QItemSelection()
     for index in self.model.selected_indexes:
         newSelection.select(self.createIndex(index, 0), self.createIndex(index, 0))
     self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
     if len(newSelection.indexes()):
         currentIndex = newSelection.indexes()[0]
         self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
         self.view.scrollTo(currentIndex)
开发者ID:glasmasin,项目名称:moneyguru,代码行数:9,代码来源:selectable_list.py

示例8: _updateViewSelection

 def _updateViewSelection(self):
     # Takes the selection on the model's side and update the view with it.
     newSelection = QItemSelection()
     columnCount = self.columnCount(QModelIndex())
     for index in self.model.selected_indexes:
         newSelection.select(self.createIndex(index, 0), self.createIndex(index, columnCount-1))
     self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
     if len(newSelection.indexes()):
         currentIndex = newSelection.indexes()[0]
         self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
         self.view.scrollTo(currentIndex)
开发者ID:prodigeni,项目名称:moneyguru,代码行数:11,代码来源:table.py

示例9: _learner_changed

 def _learner_changed(self):
     # The selected learner has changed
     indices = self.tableview.selectedIndexes()
     self._update()
     selection = QItemSelection()
     for sel in indices:
         selection.select(sel, sel)
     self.tableview.selectionModel().select(
         selection, QItemSelectionModel.ClearAndSelect
     )
     self.commit()
开发者ID:marinkaz,项目名称:orange3,代码行数:11,代码来源:owconfusionmatrix.py

示例10: select_wrong

    def select_wrong(self):
        selection = QItemSelection()
        n = self.tablemodel.rowCount()

        for i in range(n):
            for j in range(i + 1, n):
                index = self.tablemodel.index(i, j)
                selection.select(index, index)
                index = self.tablemodel.index(j, i)
                selection.select(index, index)

        self.tableview.selectionModel().select(selection, QItemSelectionModel.ClearAndSelect)
开发者ID:nedaeh,项目名称:vpe,代码行数:12,代码来源:owconfusionmatrix.py

示例11: select_wrong

 def select_wrong(self):
     """Select the off-diagonal elements of the matrix"""
     selection = QItemSelection()
     n = self.tablemodel.rowCount()
     for i in range(2, n):
         for j in range(i + 1, n):
             index = self.tablemodel.index(i, j)
             selection.select(index, index)
             index = self.tablemodel.index(j, i)
             selection.select(index, index)
     self.tableview.selectionModel().select(
         selection, QItemSelectionModel.ClearAndSelect)
开发者ID:BlazZupan,项目名称:orange3,代码行数:12,代码来源:owconfusionmatrix.py

示例12: select

        def select(model, selection_model, selected_items):
            all_items = list(model)
            try:
                indices = [all_items.index(item) for item in selected_items]
            except:
                indices = []
            selection = QItemSelection()
            for ind in indices:
                index = model.index(ind)
                selection.select(index, index)

            selection_model.select(selection, QItemSelectionModel.Select)
开发者ID:r0b1n1983liu,项目名称:o3env,代码行数:12,代码来源:OWGenotypeDistances.py

示例13: selectFiltered

    def selectFiltered(self):
        if not self.data:
            return
        itemSelection = QItemSelection()

        index = self.treeWidget.model().sourceModel().index
        mapFromSource = self.treeWidget.model().mapFromSource
        for i, row in enumerate(self.cells):
            if not self.rowFiltered(i):
                itemSelection.select(mapFromSource(index(i, 0)),
                                     mapFromSource(index(i, 0)))
        self.treeWidget.selectionModel().select(
            itemSelection,
            QItemSelectionModel.Select | QItemSelectionModel.Rows)
开发者ID:r0b1n1983liu,项目名称:o3env,代码行数:14,代码来源:OWGeneInfo.py

示例14: select_rows

def select_rows(view, row_indices, command=QItemSelectionModel.ClearAndSelect):
    """
    Select rows in view.

    :param PyQt4.QtGui.QAbstractItemView view:
    :param row_indices: Integer indices of rows to select.
    :param command: QItemSelectionModel.SelectionFlags
    """
    selmodel = view.selectionModel()
    model = view.model()
    selection = QItemSelection()
    for row in row_indices:
        index = model.index(row, 0)
        selection.select(index, index)
    selmodel.select(selection, command | QItemSelectionModel.Rows)
开发者ID:Coding4Sec,项目名称:orange3,代码行数:15,代码来源:owcorrespondence.py

示例15: selectionChanged

    def selectionChanged(self):
        X = self.X
        mapping = self.onehot_mapping
        instances = set()
        where = np.where

        def whole_subtree(node):
            yield node
            for i in range(node.childCount()):
                yield from whole_subtree(node.child(i))

        def itemset(node):
            while node:
                yield node.data(0, self.ITEM_DATA_ROLE)
                node = node.parent()

        def selection_ranges(node):
            n_children = node.childCount()
            if n_children:
                yield (self.tree.indexFromItem(node.child(0)), self.tree.indexFromItem(node.child(n_children - 1)))
            for i in range(n_children):
                yield from selection_ranges(node.child(i))

        nSelectedItemsets = 0
        item_selection = QItemSelection()
        for node in self.tree.selectedItems():
            nodes = (node,) if node.isExpanded() else whole_subtree(node)
            if not node.isExpanded():
                for srange in selection_ranges(node):
                    item_selection.select(*srange)
            for node in nodes:
                nSelectedItemsets += 1
                cols, vals = zip(*(mapping[i] for i in itemset(node)))
                if issparse(X):
                    rows = (len(cols) == np.bincount((X[:, cols] != 0).indices, minlength=X.shape[0])).nonzero()[0]
                else:
                    rows = where((X[:, cols] == vals).all(axis=1))[0]
                instances.update(rows)
        self.tree.itemSelectionChanged.disconnect(self.selectionChanged)
        self.tree.selectionModel().select(item_selection, QItemSelectionModel.Select | QItemSelectionModel.Rows)
        self.tree.itemSelectionChanged.connect(self.selectionChanged)

        self.nSelectedExamples = len(instances)
        self.nSelectedItemsets = nSelectedItemsets
        self.output = self.data[sorted(instances)] or None
        self.commit()
开发者ID:biolab,项目名称:orange3-associate,代码行数:46,代码来源:owitemsets.py


注:本文中的PyQt4.QtGui.QItemSelection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。