From 85a3e1ba7cbe637bfbd894d0152aa0995c8b11b5 Mon Sep 17 00:00:00 2001 From: bionel Date: Sun, 6 Oct 2019 17:43:10 +0300 Subject: fix GUI when unable to install packages with same name from different categories --- src/frontend/gui/sisyphus-gui.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index af98396..3c89200 100644 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -228,25 +228,30 @@ class Sisyphus(QtWidgets.QMainWindow): self.statusBar().showMessage("I am syncing myself, hope to finish soon ...") self.updateThread.start() + def getSelectedPackages(self): + def byRow(e): + return e['row'] + + pkg_categs = [{'row': pkg.row(), 'cat': pkg.data()} for pkg in self.databaseTable.selectionModel().selectedRows(0)] + pkg_names = [{'row': pkg.row(), 'name': pkg.data()} for pkg in self.databaseTable.selectionModel().selectedRows(1)] + pkg_categs = sorted(pkg_categs, key=byRow) + pkg_names = sorted(pkg_names, key=byRow) + selected_pkgs = [pkg_categs[i]['cat'] + '/' + pkg_names[i]['name'] for i in range(len(pkg_categs))] + return(selected_pkgs) + def packageInstall(self): - indexes = self.databaseTable.selectionModel().selectedRows(1) - if len(indexes) == 0: + if not self.databaseTable.selectionModel().hasSelection(): self.statusBar().showMessage("No package selected, please pick at least one!") else: - Sisyphus.pkgList = [] - for index in sorted(indexes): - Sisyphus.pkgList.append(index.data()) + Sisyphus.pkgList = self.getSelectedPackages() self.statusBar().showMessage("I am installing requested package(s), please wait ...") self.installThread.start() def packageUninstall(self): - indexes = self.databaseTable.selectionModel().selectedRows(1) - if len(indexes) == 0: + if not self.databaseTable.selectionModel().hasSelection(): self.statusBar().showMessage("No package selected, please pick at least one!") else: - Sisyphus.pkgList = [] - for index in sorted(indexes): - Sisyphus.pkgList.append(index.data()) + Sisyphus.pkgList = self.getSelectedPackages() self.statusBar().showMessage("I am removing requested package(s), please wait ...") self.uninstallThread.start() -- cgit v1.2.3