From b956214563f29208bff368eab4a477cd46fd9aa4 Mon Sep 17 00:00:00 2001 From: bionel Date: Tue, 19 Sep 2017 22:53:55 +0300 Subject: implement search by field --- src/frontend/gui/sisyphus-gui.py | 24 +++++-- src/frontend/gui/ui/sisyphus-gui.ui | 134 +++++++++++++++--------------------- 2 files changed, 74 insertions(+), 84 deletions(-) (limited to 'src/frontend') diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index 7e7a703..f8be306 100755 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 import sys, subprocess, sqlite3 +from collections import OrderedDict from PyQt5 import QtCore, QtGui, QtWidgets, uic from libsisyphus import * @@ -12,9 +13,17 @@ class Sisyphus(QtWidgets.QMainWindow): self.show() self.progress.hide() - Sisyphus.SFIELD = "name" # forced to 'name' until ui implementation - #print(Sisyphus.SFIELD) - self.loadDatabase(Sisyphus.SFIELD,"'%%'") + self.SEARCHFIELDS = OrderedDict ([ + ('Category', 'cat'), + ('Name', 'pn'), + ('Description', 'descr') + ]) + self.selectfield.addItems(self.SEARCHFIELDS.keys()) + self.selectfield.setCurrentIndex(1) # defaults to package name + self.selectfield.activated.connect(self.setSearchField) + + Sisyphus.SEARCHFIELD = "pn" # defaults to package name + self.loadDatabase(Sisyphus.SEARCHFIELD,"'%%'") self.input.textEdited.connect(self.filterDatabase) @@ -35,7 +44,10 @@ class Sisyphus(QtWidgets.QMainWindow): self.orphansThread.orphansFinished.connect(self.finishedOrphans) self.abort.clicked.connect(self.sisyphusExit) - + + def setSearchField(self): + Sisyphus.SEARCHFIELD = self.SEARCHFIELDS[self.selectfield.currentText()] + def updateSystem(self): sisyphus_pkg_system_update() @@ -58,7 +70,7 @@ class Sisyphus(QtWidgets.QMainWindow): ON a.category = i.category AND a.name = i.name AND a.slot = i.slot - WHERE a.%s LIKE %s + WHERE %s LIKE %s ''' % (searchField, searchTerm)) rows = cursor.fetchall() model = QtGui.QStandardItemModel(len(rows), 5) @@ -73,7 +85,7 @@ class Sisyphus(QtWidgets.QMainWindow): def filterDatabase(self): search = self.input.text() searchTerm = "'%" + search + "%'" - self.loadDatabase(Sisyphus.SFIELD,searchTerm) + self.loadDatabase(Sisyphus.SEARCHFIELD,searchTerm) def packageInstall(self): indexes = self.database.selectionModel().selectedRows(1) diff --git a/src/frontend/gui/ui/sisyphus-gui.ui b/src/frontend/gui/ui/sisyphus-gui.ui index 8dcedb8..3364640 100644 --- a/src/frontend/gui/ui/sisyphus-gui.ui +++ b/src/frontend/gui/ui/sisyphus-gui.ui @@ -71,43 +71,7 @@ 25 - - - - <html><head/><body><p align="center">Write package name and press Enter</p></body></html> - - - true - - - - - - - - 16777215 - 25 - - - - <html><head/><body><p align="center">Uninstall package</p></body></html> - - - - - - - ../icon/uninstall.png../icon/uninstall.png - - - - 16 - 16 - - - - - + QFrame::Panel @@ -145,35 +109,10 @@ false - - - Category - - - - - Name - - - - - Available Version - - - - - Installed Version - - - - - Description - - - - + + 16777215 @@ -181,14 +120,11 @@ - <html><head/><body><p align="center">Install package</p></body></html> - - - + <html><head/><body><p align="center">Upgrade system</p></body></html> - ../icon/install.png../icon/install.png + ../icon/upgrade.png../icon/upgrade.png @@ -198,8 +134,8 @@ - - + + 16777215 @@ -207,11 +143,14 @@ - <html><head/><body><p align="center">Exit Sisyphus</p></body></html> + <html><head/><body><p align="center">Install package</p></body></html> + + + - ../icon/exit.png../icon/exit.png + ../icon/install.png../icon/install.png @@ -221,8 +160,8 @@ - - + + 16777215 @@ -230,11 +169,14 @@ - <html><head/><body><p align="center">Upgrade system</p></body></html> + <html><head/><body><p align="center">Uninstall package</p></body></html> + + + - ../icon/upgrade.png../icon/upgrade.png + ../icon/uninstall.png../icon/uninstall.png @@ -244,7 +186,7 @@ - + @@ -270,6 +212,42 @@ + + + + + 16777215 + 25 + + + + <html><head/><body><p align="center">Exit Sisyphus</p></body></html> + + + + ../icon/exit.png../icon/exit.png + + + + 16 + 16 + + + + + + + + <html><head/><body><p align="center">Write package name and press Enter</p></body></html> + + + true + + + + + + -- cgit v1.2.3