本文整理汇总了Python中kdeui.KListView.findItem方法的典型用法代码示例。如果您正苦于以下问题:Python KListView.findItem方法的具体用法?Python KListView.findItem怎么用?Python KListView.findItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kdeui.KListView
的用法示例。
在下文中一共展示了KListView.findItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import findItem [as 别名]
#.........这里部分代码省略.........
# get a pointer to the main toolbar in the main window
# this method will create a toolbar if one is not already there.
toolbar = self.toolBar()
# add some actions to the toolbar
self.newGameAction.plug(toolbar)
self.importZipFileAction.plug(toolbar)
self.launchMainDosboxPromptAction.plug(toolbar)
self.launchDosboxAction.plug(toolbar)
self.launchDosboxPromptAction.plug(toolbar)
self.manageDosboxProfilesAction.plug(toolbar)
self.quitAction.plug(toolbar)
def refreshListView(self):
self.refreshListView_common(KListViewItem)
def _appendListItem(self, parent, name):
self._appendListItem_common(parent, name, KListViewItem)
# if this method is called externally, i.e. through dcop
# we need to select the KListViewItem that matches also
# if this method is not called externally, it means that the
# listitem has already been selected
def selectGame(self, name, called_externally=True):
if called_externally:
# if this method is called from dcop, name will be
# a QString, so we make it python string
name = str(name)
if name not in self.game_names:
KMessageBox.error(self, '%s is not a valid game name.' % name)
else:
if self.name_title_view is 'name':
# this is the easy part
# the 0 in the second arg means column
item = self.listView.findItem(name, 0)
else:
# we're using titles, so we have to get it
title = self.game_titles[name]
item = self.listView.findItem(title, 0)
# here True means select, False means unselect
self.listView.setSelected(item, True)
# calling setSelected will emit the selection changed signal
# which will result in this method being called again, although
# internally this time.
self._make_listitem_visible(item)
else:
# we only change the textView for internal calls
self.textView.set_game_info(name)
# here we make the selected item visible on the list
# if it's not currently visible
def _make_listitem_visible(self, item):
item_pos = item.itemPos()
# contentsY is the position in the contents that
# is at the top of the visible area
contentsY = self.listView.contentsY()
# contentsHeight is the height of the full list
contentsHeight = self.listView.contentsHeight()
# visibleHeight is the height of the visible part of the list
visibleHeight = self.listView.visibleHeight()
# visible_range is the interval defining the contents positions
# that are visible
visible_range = range(contentsY, contentsY + visibleHeight)
# here we test whether the item position is in the range of
# visible positions, and if not, we scroll the listview to make it so.