summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorbionel <ionel.busuioc@gmail.com>2017-09-18 21:28:45 +0300
committerbionel <ionel.busuioc@gmail.com>2017-09-18 21:28:45 +0300
commit5e21c2ef54d66fa0ca6fec45637917bfaf0da5bc (patch)
treeafee02a7eaa70e50edd62f293b7888697390be31 /src/frontend
parent76065a9f0fd1038c8bf92621fe393b98e12ceb9f (diff)
step 1: prepare functions for seachByField
Diffstat (limited to 'src/frontend')
-rwxr-xr-xsrc/frontend/gui/sisyphus-gui.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py
index 49a153c..7e7a703 100755
--- a/src/frontend/gui/sisyphus-gui.py
+++ b/src/frontend/gui/sisyphus-gui.py
@@ -11,7 +11,10 @@ class Sisyphus(QtWidgets.QMainWindow):
self.centerOnScreen()
self.show()
self.progress.hide()
- self.loadDatabase("'%%'")
+
+ Sisyphus.SFIELD = "name" # forced to 'name' until ui implementation
+ #print(Sisyphus.SFIELD)
+ self.loadDatabase(Sisyphus.SFIELD,"'%%'")
self.input.textEdited.connect(self.filterDatabase)
@@ -41,7 +44,7 @@ class Sisyphus(QtWidgets.QMainWindow):
self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
(resolution.height() / 2) - (self.frameSize().height() / 2))
- def loadDatabase(self,searchTerm):
+ def loadDatabase(self,searchField,searchTerm):
with sqlite3.connect('/var/lib/sisyphus/db/sisyphus.db') as db:
cursor=db.cursor()
cursor.execute('''SELECT
@@ -55,8 +58,8 @@ class Sisyphus(QtWidgets.QMainWindow):
ON a.category = i.category
AND a.name = i.name
AND a.slot = i.slot
- WHERE a.name LIKE %s
- '''%searchTerm)
+ WHERE a.%s LIKE %s
+ ''' % (searchField, searchTerm))
rows = cursor.fetchall()
model = QtGui.QStandardItemModel(len(rows), 5)
model.setHorizontalHeaderLabels(['Category', 'Name', 'Available Version', 'Installed Version', 'Description'])
@@ -69,8 +72,8 @@ class Sisyphus(QtWidgets.QMainWindow):
def filterDatabase(self):
search = self.input.text()
- queryTerm = "'%" + search + "%'"
- self.loadDatabase(queryTerm)
+ searchTerm = "'%" + search + "%'"
+ self.loadDatabase(Sisyphus.SFIELD,searchTerm)
def packageInstall(self):
indexes = self.database.selectionModel().selectedRows(1)