本文整理汇总了Python中AnyQt.QtCore.QItemSelection类的典型用法代码示例。如果您正苦于以下问题:Python QItemSelection类的具体用法?Python QItemSelection怎么用?Python QItemSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QItemSelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: selectvars
def selectvars(varlist, command=selmodel.ClearAndSelect):
indices = [data.domain.index(var) for var in varlist]
itemsel = QItemSelection()
for ind in indices:
midx = model.index(ind)
itemsel.select(midx, midx)
selmodel.select(itemsel, command)
示例2: _vizrank_select
def _vizrank_select(self):
model = self.vizrank.rank_table.model()
if not model.rowCount():
return
selection = QItemSelection()
# This flag is needed because data in the model could be
# filtered by a feature and therefore selection could not be found
selection_in_model = False
if self.selection:
sel_names = sorted(name for name, _ in self.selection)
for i in range(model.rowCount()):
# pylint: disable=protected-access
names = sorted(x.name for x in model.data(
model.index(i, 0), CorrelationRank._AttrRole))
if names == sel_names:
selection.select(model.index(i, 0),
model.index(i, model.columnCount() - 1))
selection_in_model = True
break
if not selection_in_model:
selection.select(model.index(0, 0),
model.index(0, model.columnCount() - 1))
self.vizrank.rank_table.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
示例3: _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)
示例4: 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)
示例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)
示例6: set_selection
def set_selection(self, selection):
if selection:
sel = QItemSelection()
for row in selection:
index = self.conc_view.model().index(row, 0)
sel.select(index, index)
self.conc_view.selectionModel().select(sel,
QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows)
示例7: __restore_selection
def __restore_selection(self):
"""Restore the selection on the table view from saved settings."""
selection_model = self.table_view.selectionModel()
selection = QItemSelection()
if len(self.selected_rows):
for row in self.model.mapFromSourceRows(self.selected_rows):
selection.append(QItemSelectionRange(
self.model.index(row, 0),
self.model.index(row, self.model.columnCount() - 1)
))
selection_model.select(selection, QItemSelectionModel.ClearAndSelect)
示例8: 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)
示例9: 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)
示例10: _vizrank_select
def _vizrank_select(self):
model = self.vizrank.rank_table.model()
selection = QItemSelection()
names = sorted(x.name for x in self.selection)
for i in range(model.rowCount()):
# pylint: disable=protected-access
if sorted(x.name for x in model.data(
model.index(i, 0), CorrelationRank._AttrRole)) == names:
selection.select(model.index(i, 0), model.index(i, 1))
self.vizrank.rank_table.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
break
示例11: 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)
示例12: move_rows
def move_rows(self, view, rows, offset):
model = view.model()
newrows = [min(max(0, row + offset), len(model) - 1) for row in rows]
for row, newrow in sorted(zip(rows, newrows), reverse=offset > 0):
model[row], model[newrow] = model[newrow], model[row]
selection = QItemSelection()
for nrow in newrows:
index = model.index(nrow, 0)
selection.select(index, index)
view.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
示例13: select_rows
def select_rows(rows: List[int], widget: OWFeatureStatistics):
"""Since the widget sorts the rows, selecting rows isn't trivial."""
indices = widget.model.mapToSourceRows(rows)
selection = QItemSelection()
for idx in indices:
selection.append(QItemSelectionRange(
widget.model.index(idx, 0),
widget.model.index(idx, widget.model.columnCount() - 1)
))
widget.table_view.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
示例14: update_selection
def update_selection(self, words):
nonlocal model, proxymodel
selection = QItemSelection()
for i, (_, word) in enumerate(model):
if word in words:
index = proxymodel.mapFromSource(model.index(i, 1))
selection.select(index, index)
self.__nope = True
self.clearSelection()
self.selectionModel().select(
selection,
QItemSelectionModel.Select | QItemSelectionModel.Rows)
self.__nope = False
示例15: set_selection
def set_selection(self):
view = self.doc_list
if len(self.selection):
selection = QItemSelection()
for row in self.selection:
selection.append(
QItemSelectionRange(
view.model().index(row, 0),
view.model().index(row, 0)
)
)
view.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)