本文整理汇总了Python中PyQt4.QtGui.QItemSelection.append方法的典型用法代码示例。如果您正苦于以下问题:Python QItemSelection.append方法的具体用法?Python QItemSelection.append怎么用?Python QItemSelection.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QItemSelection
的用法示例。
在下文中一共展示了QItemSelection.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_selection
# 需要导入模块: from PyQt4.QtGui import QItemSelection [as 别名]
# 或者: from PyQt4.QtGui.QItemSelection import append [as 别名]
def set_selection(self):
if len(self.selected_rows) and len(self.selected_cols):
view = self.tabs.currentWidget()
model = view.model()
if model.rowCount() <= self.selected_rows[-1] or \
model.columnCount() <= self.selected_cols[-1]:
return
selection = QItemSelection()
rowranges = list(ranges(self.selected_rows))
colranges = list(ranges(self.selected_cols))
for rowstart, rowend in rowranges:
for colstart, colend in colranges:
selection.append(
QtGui.QItemSelectionRange(
view.model().index(rowstart, colstart),
view.model().index(rowend - 1, colend - 1)
)
)
view.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
示例2: set_selection
# 需要导入模块: from PyQt4.QtGui import QItemSelection [as 别名]
# 或者: from PyQt4.QtGui.QItemSelection import append [as 别名]
def set_selection(self, data):
""" Set the selected data.
"""
block_list = []
for b in data['blocks']:
cl = None
rp = None
if len(b) > 2:
cl = NeoDataProvider.find_io_class(b[2])
if len(b) > 3:
rp = b[3]
loaded = NeoDataProvider.get_block(
b[1], b[0], force_io=cl, read_params=rp)
if loaded is None:
raise IOError('One of the files contained in the '
'selection could not be loaded!')
block_list.append(loaded)
block_set = set([(b[0], b[1]) for b in data['blocks']])
# Select blocks
self.ensure_not_filtered(block_list, self.parent.block_names.keys(),
self.parent.get_active_filters('Block'))
self.populate_neo_block_list()
selection = QItemSelection()
for i in self.block_model.findItems(
'*', Qt.MatchWrap | Qt.MatchWildcard):
block = i.data(Qt.UserRole)
t = (NeoDataProvider.block_indices[block],
self.parent.block_files[block])
if t in block_set:
selection.append(QItemSelectionRange(
self.block_model.indexFromItem(i)))
self.neoBlockList.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
# Select segments
seg_list = [block_list[idx[1]].segments[idx[0]]
for idx in data['segments']]
all_segs = []
for b in self.blocks():
all_segs.extend(b.segments)
self.ensure_not_filtered(seg_list, all_segs,
self.parent.get_active_filters('Segment'))
self.populate_neo_segment_list()
selection = QItemSelection()
for i in self.segment_model.findItems(
'*', Qt.MatchWrap | Qt.MatchWildcard):
segment = i.data(Qt.UserRole)
if not segment.block in block_list:
continue
seg_idx = segment.block.segments.index(segment)
block_idx = block_list.index(segment.block)
if [seg_idx, block_idx] in data['segments']:
selection.append(QItemSelectionRange(
self.segment_model.indexFromItem(i)))
self.neoSegmentList.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
# Select recording channel groups
rcg_list = [block_list[rcg[1]].recordingchannelgroups[rcg[0]]
for rcg in data['channel_groups']]
all_rcgs = []
for b in self.blocks():
all_rcgs.extend(b.recordingchannelgroups)
self.ensure_not_filtered(
rcg_list, all_rcgs,
self.parent.get_active_filters('Recording Channel Group'))
self.populate_neo_channel_group_list()
selection = QItemSelection()
for i in self.channelgroup_model.findItems(
'*', Qt.MatchWrap | Qt.MatchWildcard):
rcg = i.data(Qt.UserRole)
if not rcg.block in block_list:
continue
rcg_idx = rcg.block.recordingchannelgroups.index(rcg)
block_idx = block_list.index(rcg.block)
if [rcg_idx, block_idx] in data['channel_groups']:
selection.append(QItemSelectionRange(
self.channelgroup_model.indexFromItem(i)))
self.neoChannelGroupList.selectionModel().select(
selection, QItemSelectionModel.ClearAndSelect)
# Select channels
rc_list = [rcg_list[rc[1]].recordingchannels[rc[0]]
for rc in data['channels']]
all_rcs = []
for rcg in self.recording_channel_groups():
for rc in rcg.recordingchannels:
if not api.config.duplicate_channels and rc in all_rcs:
continue
all_rcs.append(rc)
self.ensure_not_filtered(
rc_list, all_rcs,
self.parent.get_active_filters('Recording Channel'))
self.populate_neo_channel_list()
#.........这里部分代码省略.........