本文整理汇总了Python中PyQt4.QtGui.QItemSelection.indexes方法的典型用法代码示例。如果您正苦于以下问题:Python QItemSelection.indexes方法的具体用法?Python QItemSelection.indexes怎么用?Python QItemSelection.indexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QItemSelection
的用法示例。
在下文中一共展示了QItemSelection.indexes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _restoreSelection
# 需要导入模块: from PyQt4.QtGui import QItemSelection [as 别名]
# 或者: from PyQt4.QtGui.QItemSelection import indexes [as 别名]
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)
示例2: _updateViewSelection
# 需要导入模块: from PyQt4.QtGui import QItemSelection [as 别名]
# 或者: from PyQt4.QtGui.QItemSelection import indexes [as 别名]
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)
示例3: select
# 需要导入模块: from PyQt4.QtGui import QItemSelection [as 别名]
# 或者: from PyQt4.QtGui.QItemSelection import indexes [as 别名]
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)