summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorionel busuioc <ionel.busuioc@gmail.com>2017-09-23 17:44:20 +0000
committerGhiunhan Mamut (aka V3n3RiX) <venerix@redcorelinux.org>2017-09-23 17:44:20 +0000
commit69f38922be9d041a368a4be51f9484a9977a92a8 (patch)
tree607cf93d332e02fb32a0519a0f8e5f3354e0fae0 /src/frontend
parent362b77e7665cb16fa68db9c71a9cebd1ded5a6d9 (diff)
show packages count in statusbar
Diffstat (limited to 'src/frontend')
-rwxr-xr-xsrc/frontend/gui/sisyphus-gui.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py
index 0391869..6f916e2 100755
--- a/src/frontend/gui/sisyphus-gui.py
+++ b/src/frontend/gui/sisyphus-gui.py
@@ -11,6 +11,8 @@ class Sisyphus(QtWidgets.QMainWindow):
self.centerOnScreen()
self.show()
+# set globals
+
self.SEARCHFIELDS = OrderedDict ([
('Category', 'cat'),
('Name', 'pn'),
@@ -19,7 +21,8 @@ class Sisyphus(QtWidgets.QMainWindow):
self.selectfield.addItems(self.SEARCHFIELDS.keys())
self.selectfield.setCurrentIndex(1)
self.selectfield.currentIndexChanged.connect(self.setSearchField)
-
+ Sisyphus.SEARCHFIELD = self.SEARCHFIELDS['Name']
+
self.SEARCHFILTERS = OrderedDict ([
('All', ''),
('Available', 'AND iv IS NULL'),
@@ -27,14 +30,18 @@ class Sisyphus(QtWidgets.QMainWindow):
('Upgradable', 'AND iv < av'),
('Downgradable', 'AND iv > av')
])
+ Sisyphus.SEARCHFILTER = self.SEARCHFILTERS['All']
+
+ Sisyphus.SEARCHTERM = "'%%'"
+
+# connect signals
+
self.selectfilter.addItems(self.SEARCHFILTERS.keys())
self.selectfilter.setCurrentIndex(0)
self.selectfilter.currentIndexChanged.connect(self.setSearchFilter)
-
- Sisyphus.SEARCHTERM = "'%%'"
- Sisyphus.SEARCHFIELD = self.SEARCHFIELDS['Name']
- Sisyphus.SEARCHFILTER = self.SEARCHFILTERS['All']
-
+
+ self.database.clicked.connect(self.rowClicked)
+
self.input.textEdited.connect(self.filterDatabase)
self.updateThread = UpdateThread()
@@ -66,6 +73,18 @@ class Sisyphus(QtWidgets.QMainWindow):
self.abort.clicked.connect(self.sisyphusExit)
+ def centerOnScreen(self):
+ resolution = QtWidgets.QDesktopWidget().screenGeometry()
+ self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
+ (resolution.height() / 2) - (self.frameSize().height() / 2))
+
+ def rowClicked(self):
+ Sisyphus.PKGSELECTED = len(self.database.selectionModel().selectedRows())
+ self.showPackageCount()
+
+ def showPackageCount(self):
+ self.statusBar().showMessage("Found: %d, Selected: %d packages" %(Sisyphus.PKGCOUNT, Sisyphus.PKGSELECTED))
+
def setSearchField(self):
Sisyphus.SEARCHFIELD = self.SEARCHFIELDS[self.selectfield.currentText()]
self.loadDatabase(Sisyphus.SEARCHFIELD,Sisyphus.SEARCHTERM,Sisyphus.SEARCHFILTER)
@@ -73,11 +92,6 @@ class Sisyphus(QtWidgets.QMainWindow):
def setSearchFilter(self):
Sisyphus.SEARCHFILTER = self.SEARCHFILTERS[self.selectfilter.currentText()]
self.loadDatabase(Sisyphus.SEARCHFIELD,Sisyphus.SEARCHTERM,Sisyphus.SEARCHFILTER)
-
- def centerOnScreen(self):
- resolution = QtWidgets.QDesktopWidget().screenGeometry()
- self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
- (resolution.height() / 2) - (self.frameSize().height() / 2))
def loadDatabase(self,searchField,searchTerm,searchFilter):
with sqlite3.connect('/var/lib/sisyphus/db/sisyphus.db') as db:
@@ -96,6 +110,8 @@ class Sisyphus(QtWidgets.QMainWindow):
WHERE %s LIKE %s %s
''' % (searchField, searchTerm, searchFilter))
rows = cursor.fetchall()
+ Sisyphus.PKGCOUNT = len(rows)
+ Sisyphus.PKGSELECTED = 0
model = QtGui.QStandardItemModel(len(rows), 5)
model.setHorizontalHeaderLabels(['Category', 'Name', 'Available Version', 'Installed Version', 'Description'])
for row in rows:
@@ -104,6 +120,7 @@ class Sisyphus(QtWidgets.QMainWindow):
item = QtGui.QStandardItem("%s"%(row[column]))
model.setItem(indx, column, item)
self.database.setModel(model)
+ self.showPackageCount()
def filterDatabase(self):
search = self.input.text()