From 299ae3c9b6c7356217223b919440e42d50233695 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Tue, 17 Apr 2007 17:43:12 +0000 Subject: marking installed packages in pkglist --- etc/portato.cfg | 8 ++++++++ portato/gui/gui_helper.py | 2 ++ portato/gui/qt/ui/MainWindow.ui | 12 +++++++++--- portato/gui/qt/ui/PreferenceWindow.ui | 7 +++++++ portato/gui/qt/windows.py | 35 ++++++++++++++++++++++++----------- 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/etc/portato.cfg b/etc/portato.cfg index e177714..0692e88 100644 --- a/etc/portato.cfg +++ b/etc/portato.cfg @@ -55,4 +55,12 @@ useperversion = True ; control whether usetips are shown for a package in the Queue - boolean values showusetips = on +# +# Qt-Section for options of the Qt-Frontend +# +[Qt] + +; control whether to show icons instead of checkboxes in the package list +packageicons = off + # vim:ts=4:sw=4:ft=cfg diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 2b8ab44..e52b3f3 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -35,6 +35,7 @@ class Config: const = { "main_sec" : "Main", "gtk_sec" : "Gtk", + "qt_sec" : "Qt", "usePerVersion_opt" : "usePerVersion", "useFile_opt" : "usefile", "maskFile_opt" : "maskfile", @@ -47,6 +48,7 @@ class Config: "newuse_opt" : "newuse", "syncCmd_opt" : "synccommand", "useTips_opt" : "showusetips", + "pkgIcons_opt" : "packageIcons", "system_opt" : "system" } diff --git a/portato/gui/qt/ui/MainWindow.ui b/portato/gui/qt/ui/MainWindow.ui index 14127c9..d75f0d3 100644 --- a/portato/gui/qt/ui/MainWindow.ui +++ b/portato/gui/qt/ui/MainWindow.ui @@ -70,17 +70,23 @@ - + QAbstractItemView::NoEditTriggers + + false + + + true + - 1 + 0 @@ -391,7 +397,7 @@ p, li { white-space: pre-wrap; } 0 0 466 - 31 + 27 diff --git a/portato/gui/qt/ui/PreferenceWindow.ui b/portato/gui/qt/ui/PreferenceWindow.ui index 6ac29e8..fd4ccfa 100644 --- a/portato/gui/qt/ui/PreferenceWindow.ui +++ b/portato/gui/qt/ui/PreferenceWindow.ui @@ -41,6 +41,13 @@ + + + + Use icons in package list + + + diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py index b2949bd..b4662a7 100644 --- a/portato/gui/qt/windows.py +++ b/portato/gui/qt/windows.py @@ -150,7 +150,8 @@ class PreferenceWindow (Window): "newUseCheck" : "newuse_opt", "maskCheck" : "maskPerVersion_opt", "useCheck" : "usePerVersion_opt", - "testingCheck" : "testingPerVersion_opt" + "testingCheck" : "testingPerVersion_opt", + "pkgIconsCheck" : ("pkgIcons_opt", "qt_sec") } # all edits in the window @@ -552,10 +553,9 @@ class MainWindow (Window): self.cfg.modify_external_configs() # the two lists - self.build_pkg_list() self.build_cat_list() Qt.QObject.connect(self.selCatListModel, Qt.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), self.cb_cat_list_selected) - Qt.QObject.connect(self.selPkgListModel, Qt.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), self.cb_pkg_list_selected) + Qt.QObject.connect(self.pkgList, Qt.SIGNAL("currentItemChanged(QListWidgetItem*, QListWidgetItem*)"), self.cb_pkg_list_selected) # build console self.console = QtConsole(self.consoleTab) @@ -593,14 +593,26 @@ class MainWindow (Window): self.pkgDetails.update(cp, self.queue) def fill_pkg_list (self, cat): - self.pkgListModel.setStringList([name for (name,inst) in self.db.get_cat(cat)]) + use_icons = self.cfg.get_boolean("pkgIcons_opt", section = self.cfg.const["qt_sec"]) + + # installed icon + if use_icons: + yes = Qt.QApplication.style().standardIcon(Qt.QStyle.SP_DialogYesButton) + no = Qt.QApplication.style().standardIcon(Qt.QStyle.SP_DialogNoButton) + + self.pkgList.clear() - def build_pkg_list (self): - self.pkgListModel = Qt.QStringListModel([]) - self.pkgListModel.sort(0) - self.selPkgListModel = Qt.QItemSelectionModel(self.pkgListModel) - self.pkgList.setModel(self.pkgListModel) - self.pkgList.setSelectionModel(self.selPkgListModel) + for name, inst in self.db.get_cat(cat): + if use_icons: + if inst: + icon = yes + else: + icon = no + Qt.QListWidgetItem(icon, name, self.pkgList) + else: # use checkboxes + item = Qt.QListWidgetItem(name, self.pkgList) + item.setCheckState(qCheck(inst)) + item.setFlags(Qt.Qt.ItemIsSelectable | Qt.Qt.ItemIsEnabled) def build_cat_list (self): self.catListModel = Qt.QStringListModel(system.list_categories()) @@ -725,4 +737,5 @@ class MainWindow (Window): self.fill_pkg_list(self.selCatName) def cb_pkg_list_selected (self, index, prev): - self.pkgDetails.update(self.selCatName+"/"+str(index.data().toString()), self.queue) + if not index is None: + self.pkgDetails.update(self.selCatName+"/"+str(index.text()), self.queue) -- cgit v1.2.3