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


Python QItemSelection.merge方法代码示例

本文整理汇总了Python中AnyQt.QtCore.QItemSelection.merge方法的典型用法代码示例。如果您正苦于以下问题:Python QItemSelection.merge方法的具体用法?Python QItemSelection.merge怎么用?Python QItemSelection.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnyQt.QtCore.QItemSelection的用法示例。


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

示例1: select

# 需要导入模块: from AnyQt.QtCore import QItemSelection [as 别名]
# 或者: from AnyQt.QtCore.QItemSelection import merge [as 别名]
    def select(self, selection, flags):
        """Reimplemented."""
        if isinstance(selection, QModelIndex):
            selection = QItemSelection(selection, selection)

        if not self.__selectBlocks:
            super().select(selection, flags)
            return

        model = self.model()

        def to_ranges(spans):
            return list(range(*r) for r in spans)

        if flags & QItemSelectionModel.Current:  # no current selection support
            flags &= ~QItemSelectionModel.Current
        if flags & QItemSelectionModel.Toggle:  # no toggle support either
            flags &= ~QItemSelectionModel.Toggle
            flags |= QItemSelectionModel.Select

        if flags == QItemSelectionModel.ClearAndSelect:
            # extend selection ranges in `selection` to span all row/columns
            sel_rows = selection_rows(selection)
            sel_cols = selection_columns(selection)
            selection = QItemSelection()
            for row_range, col_range in \
                    itertools.product(to_ranges(sel_rows), to_ranges(sel_cols)):
                selection.select(
                    model.index(row_range.start, col_range.start),
                    model.index(row_range.stop - 1, col_range.stop - 1)
                )
        elif flags & (QItemSelectionModel.Select |
                      QItemSelectionModel.Deselect):
            # extend all selection ranges in `selection` with the full current
            # row/col spans
            rows, cols = selection_blocks(self.selection())
            sel_rows = selection_rows(selection)
            sel_cols = selection_columns(selection)
            ext_selection = QItemSelection()
            for row_range, col_range in \
                    itertools.product(to_ranges(rows), to_ranges(sel_cols)):
                ext_selection.select(
                    model.index(row_range.start, col_range.start),
                    model.index(row_range.stop - 1, col_range.stop - 1)
                )
            for row_range, col_range in \
                    itertools.product(to_ranges(sel_rows), to_ranges(cols)):
                ext_selection.select(
                    model.index(row_range.start, col_range.start),
                    model.index(row_range.stop - 1, col_range.stop - 1)
                )
            selection.merge(ext_selection, QItemSelectionModel.Select)
        super().select(selection, flags)
开发者ID:ales-erjavec,项目名称:orange3,代码行数:55,代码来源:owtable.py


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