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


Python KListView.currentItem方法代码示例

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


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

示例1: ImportsMainWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class ImportsMainWindow(BaseMainWindow):
    def __init__(self, parent, name='ImportsMainWindow'):
        BaseMainWindow.__init__(self, parent, name=name)
        self.handler = AbandonGamesHandler(self.app)
        self.splitView = QSplitter(self)
        self.listView = KListView(self.splitView)
        self.connect(self.listView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)
        
        self.initlistView()
        self.textView = MainAbandoniaPart(self.splitView)
        self.setCentralWidget(self.splitView)
        
        
    def initlistView(self):
        self.listView.addColumn('games', -1)
        self.refreshListView()
        
    def refreshListView(self):
        self.listView.clear()
        gameids = self.handler.get_all_html_ids()
        print 'in initlistView', gameids
        for gameid in gameids:
            #item = KListViewItem(self.listView, str(gameid))
            #item.gameid = gameid
            self.handler.get_game_data(gameid)
            item = KListViewItem(self.listView, self.handler.parser.title)
            item.gameid = gameid
            
    def selectionChanged(self):
        item = self.listView.currentItem()
        self.handler.get_game_data(item.gameid)
        print 'in selectionChanged', self.handler.parser.gameid
        self.textView.set_game_info(self.handler)
开发者ID:BackupTheBerlios,项目名称:dosbox-pykde-svn,代码行数:36,代码来源:importbrowser.py

示例2: ProfileSelectorDialog

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class ProfileSelectorDialog(BaseDialogWindow):
    def __init__(self, parent, name='ProfileSelectorDialog'):
        BaseDialogWindow.__init__(self, parent, name=name)
        self.dbox = self.app.make_new_dosbox_object()
        profiles = self.dbox.get_profile_list()
        self.listView = KListView(self)
        self.listView.addColumn('profile')
        self.setMainWidget(self.listView)
        for profile in profiles:
            item = KListViewItem(self.listView, profile)
            item.profile = profile

    def get_selected_profile(self):
        item = self.listView.currentItem()
        return item.profile
开发者ID:BackupTheBerlios,项目名称:dosbox-pykde-svn,代码行数:17,代码来源:profile.py

示例3: ClientsMainWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class ClientsMainWindow(BasePaellaWindow):
    def __init__(self, parent):
        BasePaellaWindow.__init__(self, parent, name='ClientsMainWindow')
        self.initPaellaCommon()
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.cursor = self.conn.cursor(statement=True)
        self.listView = KListView(self)
        self.setCentralWidget(self.listView)
        self.refreshListView()
        self.resize(600, 800)
        self.setCaption('Paella Profiles')

    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newClientAction = KStdAction.openNew(self.slotNewClient, collection)

    def initMenus(self):
        mainmenu = KPopupMenu(self)
        menubar = self.menuBar()
        menubar.insertItem('&Main', mainmenu)
        menubar.insertItem('&Help', self.helpMenu(''))
        self.newClientAction.plug(mainmenu)
        self.quitAction.plug(mainmenu)

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newClientAction.plug(toolbar)
        self.quitAction.plug(toolbar)

    def initlistView(self):
        self.listView.setRootIsDecorated(False)
        self.listView.addColumn('profile')

    def refreshListView(self):
        self.listView.clear()
        for row in self.profile.select(fields=['profile', 'suite'], order=['profile']):
            item = KListViewItem(self.listView, row.profile)
            item.profile = row.profile

    def slotNewClient(self):
        KMessageBox.information(self, 'New Client not ready yet.')

    def selectionChanged(self):
        item = self.listView.currentItem()
        self.mainView.set_profile(item.profile)
开发者ID:joelsefus,项目名称:paella,代码行数:50,代码来源:clients.py

示例4: RecordSelector

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class RecordSelector(QSplitter):
    def __init__(self, parent, db, table, fields, idcol, groupfields, view, name='RecordSelector'):
        QSplitter.__init__(self, parent, name)
        self.current = currentobject()
        self.db = db
        self.table = table
        self.fields = fields
        self.idcol = idcol
        self.groupfields = groupfields
        self.listView = KListView(self)
        self.vsplit = QSplitter(self)
        self.vsplit.setOrientation(Qt.Vertical)
        self.recView = view(db, self.vsplit)
        frame = QFrame(self.vsplit)
        self.recForm = EditableRecord(frame, fields)
        self.connect(self.listView, SIGNAL('selectionChanged()'), self.groupChanged)
        self.connect(self.recForm.insButton, SIGNAL('clicked()'), self.insertRecord)
        self.connect(self.recForm.updButton, SIGNAL('clicked()'), self.updateRecord)
        self.initlistView()
        self.setSource(self.handleURL)
    
    def initlistView(self):
        self.listView.addColumn('group')
        self.listView.setRootIsDecorated(True)
        all = KListViewItem(self.listView, 'all')
        groups = [KListViewItem(self.listView, g) for g in self.groupfields]
        for g, parent in zip(self.groupfields, groups):
            fields = ['distinct %s' % g]
            rows = self.db.mcursor.select(fields=fields, table=self.table, order=g)
            for row in rows:
                item = KListViewItem(parent, row[g])
                item.groupfield = g
                

    def groupChanged(self):
        item = self.listView.currentItem()
        self.current.group = item.text(0)
        if hasattr(item, 'groupfield'):
            clause = Eq(item.groupfield, self.current.group)
            self.recView.set_clause(clause)
        elif self.current.group == 'all':
            self.recView.set_clause(None)
        else:
            self.recView.set_clause('NULL')

    def handleURL(self, url):
        action, obj, ident = str(url).split('.')
        row = self.db.mcursor.select_row(fields=self.fields,
                                         table=self.table, clause=Eq(self.idcol, ident))
        entries = self.recForm.entries
        for field in entries:
            entries[field].setText(row[field])
        self.current.id = ident
        

    def setSource(self, handler):
        self.recView.setSource = handler

    def insertRecord(self):
        data = self.recForm.get_data()
        self.db.insertData(self.idcol, self.table, data)
        self.groupChanged()

    def updateRecord(self):
        if self.current.id is not None:
            data = self.recForm.get_data()
            clause = Eq(self.idcol, self.current.id)
            row = self.db.mcursor.select_row(table=self.table, clause=clause)
            updict = {}
            for k, v in data.items():
                if str(row[k]) != str(v) and str(v):
                    print v
                    updict[k] = v
            print updict
        if updict:
            self.db.mcursor.update(table=self.table, data=updict, clause=clause)
            self.groupChanged()
开发者ID:BackupTheBerlios,项目名称:konsultant-svn,代码行数:79,代码来源:gui.py

示例5: MainWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]

#.........这里部分代码省略.........
    def slotLaunchDosboxPrompt(self, game=None):
        self._launchdosbox_common(game, launch_game=False)

    def slotLaunchMainDosboxPrompt(self):
        KMessageBox.information(self, 'Not implemented')
        
    def slotManageDosboxProfiles(self):
        #from dosboxcfg.profile import ProfileDialogWindow
        #win = ProfileDialogWindow(self)
        win = ManageDosboxProfilesWindow(self)
        win.show()

    def slotSetCurrentProfile(self):
        dlg = ProfileSelectorDialog(self)
        self.connect(dlg, SIGNAL('okClicked()'), self._current_profile_selected)
        self.set_profile_dlg = dlg
        dlg.show()

    def slotImportZipFile(self):
        #KMessageBox.information(self, 'Import a new game, not yet implemented.')
        #dlg = ImportGameUrlDialog(self)
        
        #dlg.show()
        win = ImportsMainWindow(self)
        win.show()
        
    def slotConfigureDosboxPyKDE(self):
        #KMessageBox.information(self, 'ConfigureDosboxPyKDE')
        dlg = SettingsWidgetDialog(self)
        dlg.show()
        
    def _launchdosbox_common(self, game, launch_game=True):
        if game is None:
            game = self.listView.currentItem().game
        if self.app.game_fileshandler.get_game_status(game):
            if launch_game:
                self.app.dosbox.run_game(game)
            else:
                self.app.dosbox.launch_dosbox_prompt(game)
        else:
            title = self.game_titles[game]
            KMessageBox.error(self, '%s is unavailable' % title)

    def _current_profile_selected(self):
        dlg = self.set_profile_dlg
        if dlg is not None:
            profile = dlg.get_selected_profile()
            self._set_current_profile(profile)
            self.set_profile_dlg = None
            
    def _set_current_profile(self, profile):
        dosbox = self.app.dosbox
        dosbox.set_current_profile(profile)
        msg = 'Current Profile:  %s' % dosbox.current_profile
        self.statusbar.message(msg)        
            
    def new_game_path_selected(self):
        # url is a KURL
        url = self.new_game_dir_dialog.url()
        # since the url should be file://path/to/game
        # we only want the /path/to/game
        fullpath = str(url.path())
        # here we set the name of the game to the base
        # directory of the path.  This is probably not a good
        # idea in the long run, and I'll change this behaviour one day.
        name = os.path.basename(fullpath)
开发者ID:BackupTheBerlios,项目名称:dosbox-pykde-svn,代码行数:70,代码来源:mainwindow.py

示例6: MainWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class MainWindow(KMainWindow):
    def __init__(self, parent):
        KMainWindow.__init__(self, parent, 'Uncover Truth Frontend')
        self.app = get_application_pointer()
        self.splitView = QSplitter(self, 'splitView')
        self.listView = KListView(self.splitView, 'guests_view')
        self.textView = InfoPart(self.splitView)
        self.initlistView()

        self.connect(self.listView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)
        self.connect(self.textView,
                     PYSIGNAL('GuestInfoUpdated'), self.refreshDisplay)
        self.setCentralWidget(self.splitView)

        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newGuestAction = KStdAction.openNew(self.slotNewGuest, collection)
        self.selectAllAction = KStdAction.selectAll(self.slotSelectAll,
                                                    collection)
        mainmenu = KPopupMenu(self)
        self.newGuestAction.plug(mainmenu)
        self.selectAllAction.plug(mainmenu)
        self.quitAction.plug(mainmenu)
        menubar = self.menuBar()
        menubar.insertItem('&Main', mainmenu)

        toolbar = self.toolBar()
        self.newGuestAction.plug(toolbar)
        self.quitAction.plug(toolbar)
        
        self.new_guest_dialog = None

        # resize window
        self.resize(400, 500)
        self.splitView.setSizes([75, 325])
        

    def initlistView(self):
        self.listView.addColumn('guests', -1)
        self.refreshListView()

    def refreshListView(self):
        self.listView.clear()
        cursor = self.app.conn.stmtcursor()
        rows = self.app.guests.get_guest_rows()
        for row in rows:
            name = '%s %s' % (row.firstname, row.lastname)
            item = KListViewItem(self.listView, name)
            item.guestid = row['guestid']
            
    
    def slotNewGuest(self):
        win = BaseGuestDialog(self)
        self.connect(win, SIGNAL('okClicked()'),
                     self._new_guest_added)
        self.new_guest_dialog = win
        win.show()
    
    def slotSelectAll(self):
        self.textView.view_all_guests()
        
    def _new_guest_added(self):
        dlg = self.new_guest_dialog
        if dlg is not None:
            data = dlg.get_guest_data()
            self.app.guests.insert_guest_data(data)
            self.refreshListView()
            self.new_guest_dialog = None
            
    def selectionChanged(self):
        item = self.listView.currentItem()
        guestid = item.guestid
        self.textView.set_guest_info(item.guestid)

    def refreshDisplay(self):
        #KMessageBox.error(self, 'ack refreshDisplay called')
        #self.refreshListView()
        self.selectionChanged()
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:81,代码来源:utmainwin.py

示例7: MainEntityWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class MainEntityWindow(BaseToolboxWindow):
    def __init__(self, parent, name='MainEntityWindow'):
        BaseToolboxWindow.__init__(self, parent, name=name)
        self.splitView = QSplitter(self, 'splitView')
        self.listView = KListView(self.splitView, 'entities_view')
        self.textView = InfoPart(self.splitView)
        self.initActions()
        self.initMenus()
        self.initToolbar()
        
        #self._sortby = 'name'
        self.initlistView()

        self.connect(self.listView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)
        self.connect(self.textView,
                     PYSIGNAL('EntityInfoUpdated'), self.refreshDisplay)
        self.setCentralWidget(self.splitView)

        # dialogs
        self._new_entity_dlg = None
        
        # resize window
        self.resize(400, 500)
        self.splitView.setSizes([75, 325])

    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newEntityAction = KStdAction.openNew(self.slotNewEntity, collection)
        self.newTagAction = NewTagAction(self.slotNewTag, collection)
        self.manageEntityTypesAction = KStdAction.addBookmark(self.slotManageEntityTypes,
                                                              collection)
        
    def initMenus(self):
        mainmenu = KPopupMenu(self)
        self.newEntityAction.plug(mainmenu)
        self.newTagAction.plug(mainmenu)
        self.manageEntityTypesAction.plug(mainmenu)
        self.quitAction.plug(mainmenu)
        menubar = self.menuBar()
        menubar.insertItem('&Main', mainmenu)

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newEntityAction.plug(toolbar)
        self.newTagAction.plug(toolbar)
        self.manageEntityTypesAction.plug(toolbar)
        self.quitAction.plug(toolbar)

    def initlistView(self):
        self.listView.addColumn('entity', -1)
        #self.listView.setSorting(-1)
        self.refreshListView()

    def refreshListView(self):
        self.listView.clear()
        #cursor = self.app.conn.stmtcursor()
        #rows = self.app.db.get_entities()
        #for row in rows:
        #    item = KListViewItem(self.listView, row['name'])
        #    item.entityid = row['entityid']
        entities = self.app.db.get_entities()
        for entity in entities:
            item = KListViewItem(self.listView, entity.name)
            # we don't need the id anymore
            item.entityid = entity.entityid
            # since we can hold the whole object
            # which will talk to the db as needed
            item.entity = entity
            
    def slotNewEntity(self):
        from dialogs import SelectEntityTypeDialog
        win = SelectEntityTypeDialog(self)
        
        #win = MainEntityDialog(self, dtype='insert')
        #self._new_entity_dlg = win
        win.show()

    def slotNewTag(self):
        dlg = NewTagDialog(self)
        dlg.show()
        
    def slotManageEntityTypes(self):
        win = EntityTypeWindow(self)
        win.show()
    
    def _new_entity_added(self):
        dlg = self._new_entity_dlg
        if dlg is not None:
            data = dlg.get_data()
            self.app.db.create_entity(data)
            self.refreshListView()
            self._new_entity_dlg = None
            
    def selectionChanged(self):
        item = self.listView.currentItem()
        entityid = item.entityid
        self.textView.set_info(item.entity)
                
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:103,代码来源:entitywin.py

示例8: PaellaMainWindowSmall

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class PaellaMainWindowSmall(BasePaellaMainWindow):
    def __init__(self, parent=None, name='PaellaMainWindowSmall'):
        print 'using window', name
        BasePaellaMainWindow.__init__(self, parent, name)
        # In this window, we use a listbox to select the other
        # parts of the application
        self.listView = KListView(self)
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('widget')
        self.setCentralWidget(self.listView)
        if self.app.conn is not None:
            self.refreshListView()
        self.setCaption('Main Menu')
        self.connect(self.listView,
                     SIGNAL('selectionChanged()'),
                     self.selectionChanged)

    def _import_export_directory_selected(self):
        BasePaellaMainWindow._import_export_directory_selected(self)
        self.refreshListView()
        
    def refreshListView(self):
        self.listView.clear()
        self._refresh_suites()
        suite_folder = KListViewItem(self.listView, 'suites')
        suite_folder.folder = True
        for suite in self._suites:
            item = KListViewItem(suite_folder, suite)
            item.suite = suite
        profile_folder = KListViewItem(self.listView, 'profiles')
        profile_folder.profiles = True
        family_folder = KListViewItem(self.listView, 'families')
        family_folder.families = True
        machine_folder = KListViewItem(self.listView, 'machines')
        machine_folder.machines = True
        differ_folder = KListViewItem(self.listView, 'differs')
        differ_folder.differs = True
        differ_folder.folder = True
        for dtype in ['trait', 'family']:
            item = KListViewItem(differ_folder, dtype)
            item.dtype = dtype
        environ_folder = KListViewItem(self.listView, 'environ')
        environ_folder.environ = True
        environ_folder.folder = True
        for etype in ['default', 'current']:
            item = KListViewItem(environ_folder, etype)
            item.etype = etype
        # installer widget is still unimplemented
        if False:
            installer_folder = KListViewItem(self.listView, 'installer')
            installer_folder.installer = True
        if self.app.cfg.getboolean('management_gui', 'client_widget'):
            clients_folder = KListViewItem(self.listView, 'clients')
            clients_folder.clients = True
        
    def selectionChanged(self):
        current = self.listView.currentItem()
        win = None
        if hasattr(current, 'suite'):
            print 'suite is', current.suite
            if  not self._suites:
                KMessageBox.information(self, "No suites are present.")
            else:
                win = TraitMainWindow(self, current.suite)
        elif hasattr(current, 'profiles'):
            win = ProfileMainWindow(self)
        elif hasattr(current, 'families'):
            self.slotManageFamilies()
        elif hasattr(current, 'machines'):
            win = MachineMainWindow(self)
        elif hasattr(current, 'dtype'):
            print 'differ', current.dtype
            win = DifferWindow(self, current.dtype)
        elif hasattr(current, 'etype'):
            win = EnvironmentWindow(self, current.etype)
        elif hasattr(current, 'installer'):
            #win = InstallerMainWin(self)
            KMessageBox.information(self, 'Not Implemented')
        elif hasattr(current, 'clients'):
            win = ClientsMainWindow(self)
        elif hasattr(current, 'folder'):
            # nothing important selected, do nothing
            pass
        else:
            KMessageBox.error(self, 'something bad happened in the list selection')
        if win is not None:
            win.show()
            self._all_my_children.append(win)
            
    def slotManageFamilies(self):
        print 'running families'
        #FamilyMainWindow(self.app, self)
        #KMessageBox.error(self, 'Managing families unimplemented')
        win = FamilyMainWindow(self)
        win.show()
        self._all_my_children.append(win)
        
    def slotManageSuite(self, wid=-1):
        print 'in slotManageSuite suite is', wid
        #TraitMainWindow(self.app, self, current.suite)
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:103,代码来源:main.py

示例9: BaseRtorrentWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class BaseRtorrentWindow(BaseToolboxWindow, MainDropCatcher):
    def __init__(self, parent, name='MainEntityWindow'):
        BaseToolboxWindow.__init__(self, parent, name=name)
        self.splitView = QSplitter(self, 'splitView')
        self.listView = KListView(self.splitView, 'entities_view')
        self.textView = RtorrentInfoPart(self.splitView)
        self.initActions()
        self.initMenus()
        self.initToolbar()
        
        self.app.rtserver = Server(url="http://roujin/RPC2")
        self.app.rtorrent = Rtorrent(self.app.rtserver)

        #self._sortby = 'name'
        self.initlistView()

        self.connect(self.listView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)
        self.connect(self.textView,
                     PYSIGNAL('EntityInfoUpdated'), self.refreshDisplay)
        self.setCentralWidget(self.splitView)

        
        # dialogs
        self._new_entity_dlg = None
        
        # resize window
        self.resize(400, 500)
        self.splitView.setSizes([75, 325])

        self.setAcceptDrops(True)
        
    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newEntityAction = KStdAction.openNew(self.slotNewEntity, collection)
        self.newTagAction = NewTagAction(self.slotNewTag, collection)
        self.manageEntityTypesAction = KStdAction.addBookmark(self.slotManageEntityTypes,
                                                              collection)
        
    def initMenus(self):
        mainmenu = KPopupMenu(self)
        self.newEntityAction.plug(mainmenu)
        self.newTagAction.plug(mainmenu)
        self.manageEntityTypesAction.plug(mainmenu)
        self.quitAction.plug(mainmenu)
        menubar = self.menuBar()
        menubar.insertItem('&Main', mainmenu)

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newEntityAction.plug(toolbar)
        self.newTagAction.plug(toolbar)
        self.manageEntityTypesAction.plug(toolbar)
        self.quitAction.plug(toolbar)

    def initlistView(self):
        self.listView.addColumn('entity', -1)
        #self.listView.setSorting(-1)
        self.refreshListView()

    def refreshListView(self):
        self.listView.clear()
        torrents = self.app.rtorrent.torrents
        for k, v in self.app.rtorrent.torrents.items():
            item = KListViewItem(self.listView, v.name)
            item.infohash = k

    def slotNewEntity(self):
        from dialogs import SelectEntityTypeDialog
        win = SelectEntityTypeDialog(self)
        
        #win = MainEntityDialog(self, dtype='insert')
        #self._new_entity_dlg = win
        win.show()

    def slotNewTag(self):
        dlg = NewTagDialog(self)
        dlg.show()
        
    def slotManageEntityTypes(self):
        win = EntityTypeWindow(self)
        win.show()
    
    def _new_entity_added(self):
        dlg = self._new_entity_dlg
        if dlg is not None:
            data = dlg.get_data()
            self.app.db.create_entity(data)
            self.refreshListView()
            self._new_entity_dlg = None
            
    def selectionChanged(self):
        item = self.listView.currentItem()
        infohash = item.infohash
        tv = self.textView
        self.textView.set_info(infohash)
                
    def refreshDisplay(self):
        #KMessageBox.error(self, 'ack refreshDisplay called')
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:103,代码来源:mainwin.py

示例10: EntityTypeWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class EntityTypeWindow(BaseMainWindow):
    def __init__(self, parent, name='EntityTypeWindow'):
        BaseMainWindow.__init__(self, parent, name=name)
        self.splitView = QSplitter(self, 'splitView')
        self.etypeView = KListView(self.splitView, 'etypes_view')
        self.extfieldsView = KListView(self.splitView, 'extfields_view')
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.setCentralWidget(self.splitView)
        self.connect(self.etypeView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)
        self.initlistView()
        self.current_etype = None
        
        

    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newEntityTypeAction = KStdAction.openNew(self.slotNewEntityType, collection)
        self.newExtraFieldAction = KStdAction.addBookmark(self.slotNewExtraField, collection)
        
    def initMenus(self):
        mainmenu = KPopupMenu(self)
        self.newEntityTypeAction.plug(mainmenu)
        self.newExtraFieldAction.plug(mainmenu)
        self.quitAction.plug(mainmenu)
        menubar = self.menuBar()
        menubar.insertItem('&Main', mainmenu)
                
    def initToolbar(self):
        toolbar = self.toolBar()
        self.newEntityTypeAction.plug(toolbar)
        self.newExtraFieldAction.plug(toolbar)
        self.quitAction.plug(toolbar)
        
    def initlistView(self):
        self.etypeView.addColumn('entity type', -1)
        self.extfieldsView.addColumn('fieldname')
        self.extfieldsView.addColumn('fieldtype')
        self.refreshListView()

    def refreshListView(self):
        self.etypeView.clear()
        etypes = self.app.db.get_entity_types()
        for etype in etypes:
            item = KListViewItem(self.etypeView, etype)
            item.etype = etype
        
    def selectionChanged(self):
        item = self.etypeView.currentItem()
        etype = item.etype
        self.current_etype = etype
        fields = self.app.db.get_etype_extra_fields(etype)
        self.extfieldsView.clear()
        for field in fields:
            item = KListViewItem(self.extfieldsView, *field)
            item.fieldname = field[0]
            
            
    def slotNewEntityType(self):
        dlg = NewEntityTypeDialog(self)
        dlg.show()

    def slotNewExtraField(self):
        if self.current_etype is not None:
            dlg = NewExtraFieldDialog(self, self.current_etype)
            dlg.show()
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:71,代码来源:etypewin.py

示例11: PaellaMainWindow

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class PaellaMainWindow(KMainWindow):
    def __init__(self, app, *args):
        KMainWindow.__init__(self, *args)
        self.app = app
        self.icons = KIconLoader()
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.conn = app.conn
        self.cfg = app.cfg
        self.cursor = StatementCursor(self.conn)
        self.listView = KListView(self)
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('widget')
        self.setCentralWidget(self.listView)
        self.refreshListView()
        self.connect(self.listView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)

    def initActions(self):
        collection = self.actionCollection()
        self.manageFamiliesAction = ManageFamilies(self.slotManageFamilies, collection)
        self.editTemplatesAction = EditTemplateAction(self.slotEditTemplates, collection)
        self.quitAction = KStdAction.quit(self.app.quit, collection)
       
    def initMenus(self):
        mainMenu = KPopupMenu(self)
        actions = [self.manageFamiliesAction,
                   self.editTemplatesAction,
                   self.quitAction]
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))
        for action in actions:
            action.plug(mainMenu)
            
    def initToolbar(self):
        toolbar = self.toolBar()
        actions = [self.manageFamiliesAction,
                   self.editTemplatesAction,
                   self.quitAction]
        for action in actions:
            action.plug(toolbar)
            
    def refreshListView(self):
        suite_folder = KListViewItem(self.listView, 'suites')
        for row in self.cursor.select(table='suites'):
            item = KListViewItem(suite_folder, row.suite)
            item.suite = row.suite
        profile_folder = KListViewItem(self.listView, 'profiles')
        profile_folder.profiles = True
        family_folder = KListViewItem(self.listView, 'families')
        family_folder.families = True
        machine_folder = KListViewItem(self.listView, 'machines')
        machine_folder.machines = True
        differ_folder = KListViewItem(self.listView, 'differs')
        differ_folder.differs = True
        for dtype in ['trait', 'family']:
            item = KListViewItem(differ_folder, dtype)
            item.dtype = dtype
        environ_folder = KListViewItem(self.listView, 'environ')
        environ_folder.environ = True
        for etype in ['default', 'current']:
            item = KListViewItem(environ_folder, etype)
            item.etype = etype
            
    def selectionChanged(self):
        current = self.listView.currentItem()
        if hasattr(current, 'suite'):
            print 'suite is', current.suite
            TraitMainWindow(self.app, self, current.suite)
        elif hasattr(current, 'profiles'):
            ProfileMainWindow(self.app, self)
        elif hasattr(current, 'families'):
            self.slotManageFamilies()
        elif hasattr(current, 'machines'):
            MachineMainWindow(self.app, self)
        elif hasattr(current, 'dtype'):
            print 'differ', current.dtype
            DifferWin(self.app, self, current.dtype)
        elif hasattr(current, 'etype'):
            DefEnvWin(self.app, self, current.etype)
            
    def slotManageFamilies(self):
        print 'running families'
        FamilyMainWindow(self.app, self)
            
    def slotEditTemplates(self):
        print 'edit templates'
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:90,代码来源:main.py

示例12: AdminWidget

# 需要导入模块: from kdeui import KListView [as 别名]
# 或者: from kdeui.KListView import currentItem [as 别名]
class AdminWidget(KMainWindow):
    def __init__(self, app, parent):
        KMainWindow.__init__(self, parent, 'AdminWidget')
        self.app = app
        self.db = app.db
        self.manager = AdminDb(self.app)
        self.mainView = QSplitter(self, 'main view')
        self.listView = KListView(self.mainView)
        self.groupView = KListView(self.mainView)
        self.setCentralWidget(self.mainView)
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.initlistView()
        self.connect(self.listView,
                     SIGNAL('selectionChanged()'), self.selectionChanged)
        self.dialogs = {}
        self.show()

    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.adduserAction = AddDbUser(self.slotAddDbUser, collection)
        self.addgroupAction = AddDbGroup(self.slotAddDbGroup, collection)
        self.addschemaAction = AddDbSchema(self.slotAddDbSchema, collection)
        
    def initMenus(self):
        mainmenu = KPopupMenu(self)
        actions = [self.adduserAction, self.addgroupAction,
                   self.addschemaAction, self.quitAction]
        for action in actions:
            action.plug(mainmenu)
        self.menuBar().insertItem('&Main', mainmenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))
        
    def initToolbar(self):
        toolbar = self.toolBar()
        actions = [self.adduserAction, self.addgroupAction,
                   self.addschemaAction, self.quitAction]
        for action in actions:
            action.plug(toolbar)

    def initlistView(self):
        self.listView.addColumn('grouping')
        self.listView.setRootIsDecorated(True)
        self.groupView.addColumn('user')
        self.groupView.setRootIsDecorated(True)
        self.refreshlistView()
        
    def refreshlistView(self):
        self.listView.clear()
        rows = self.manager.get_users()
        print rows
        print 'helo;'
        users = KListViewItem(self.listView, 'user')
        groups = KListViewItem(self.listView, 'group')
        for row in rows:
            c = KListViewItem(users, row.usename)
            c.userid = row.usesysid
        for row in self.manager.get_groups():
            c = KListViewItem(groups, row.group)
            c.grosysid = row.grosysid

    def refreshGroupView(self):
        pass
    
    def selectionChanged(self):
        current = self.listView.currentItem()
        print current
        if hasattr(current, 'userid'):
            print 'user is', current.userid, current.text(0)
        elif hasattr(current, 'grosysid'):
            group = str(current.text(0))
            rows = self.manager.get_users(group=group)
            self.groupView.clear()
            for row in rows:
                c = KListViewItem(self.groupView, row.usename)
                
        
    def slotAddDbGroup(self):
        dlg = AddGroupDialog(self)
        dlg.connect(dlg, SIGNAL('okClicked()'), self.addDbGroupok)
        self.dialogs['new-group'] = dlg
        

    def slotAddDbUser(self):
        dlg = AddUserDialog(self)
        dlg.connect(dlg, SIGNAL('okClicked()'), self.addDbUserok)
        self.dialogs['new-user'] = dlg

    def slotAddDbSchema(self):
        dlg = SimpleRecordDialog(self, ['schema'], 'AddDbSchemaDialog')
        dlg.connect(dlg, SIGNAL('okClicked()'), self.addDbSchemaok)
        self.dialogs['new-schema'] = dlg
        
    def addDbUserok(self):
        dlg = self.dialogs['new-user']
        usename = str(dlg.grid.entries['username'].text())
        self.manager.create_user(usename)
        self.db.conn.commit()
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:103,代码来源:admin.py


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