diff options
author | bionel <ionel.busuioc@gmail.com> | 2017-09-19 22:53:55 +0300 |
---|---|---|
committer | bionel <ionel.busuioc@gmail.com> | 2017-09-19 22:53:55 +0300 |
commit | b956214563f29208bff368eab4a477cd46fd9aa4 (patch) | |
tree | a609ec059bb8a0a08175ff79bca10f66f90dfcd7 /src/frontend | |
parent | 5e21c2ef54d66fa0ca6fec45637917bfaf0da5bc (diff) |
implement search by field
Diffstat (limited to 'src/frontend')
-rwxr-xr-x | src/frontend/gui/sisyphus-gui.py | 24 | ||||
-rw-r--r-- | src/frontend/gui/ui/sisyphus-gui.ui | 134 |
2 files changed, 74 insertions, 84 deletions
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 @@ <property name="spacing"> <number>25</number> </property> - <item row="0" column="1" colspan="3"> - <widget class="QLineEdit" name="input"> - <property name="toolTip"> - <string><html><head/><body><p align="center">Write package name and press Enter</p></body></html></string> - </property> - <property name="clearButtonEnabled"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="uninstall"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>25</height> - </size> - </property> - <property name="toolTip"> - <string><html><head/><body><p align="center">Uninstall package</p></body></html></string> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset> - <normaloff>../icon/uninstall.png</normaloff>../icon/uninstall.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - </widget> - </item> - <item row="1" column="0" colspan="5"> + <item row="3" column="0" colspan="5"> <widget class="QTableView" name="database"> <property name="frameShape"> <enum>QFrame::Panel</enum> @@ -145,35 +109,10 @@ <attribute name="verticalHeaderHighlightSections"> <bool>false</bool> </attribute> - <column> - <property name="text"> - <string>Category</string> - </property> - </column> - <column> - <property name="text"> - <string>Name</string> - </property> - </column> - <column> - <property name="text"> - <string>Available Version</string> - </property> - </column> - <column> - <property name="text"> - <string>Installed Version</string> - </property> - </column> - <column> - <property name="text"> - <string>Description</string> - </property> - </column> </widget> </item> - <item row="3" column="0"> - <widget class="QPushButton" name="install"> + <item row="5" column="2"> + <widget class="QPushButton" name="upgrade"> <property name="maximumSize"> <size> <width>16777215</width> @@ -181,14 +120,11 @@ </size> </property> <property name="toolTip"> - <string><html><head/><body><p align="center">Install package</p></body></html></string> - </property> - <property name="text"> - <string/> + <string><html><head/><body><p align="center">Upgrade system</p></body></html></string> </property> <property name="icon"> <iconset> - <normaloff>../icon/install.png</normaloff>../icon/install.png</iconset> + <normaloff>../icon/upgrade.png</normaloff>../icon/upgrade.png</iconset> </property> <property name="iconSize"> <size> @@ -198,8 +134,8 @@ </property> </widget> </item> - <item row="3" column="4"> - <widget class="QPushButton" name="abort"> + <item row="5" column="0"> + <widget class="QPushButton" name="install"> <property name="maximumSize"> <size> <width>16777215</width> @@ -207,11 +143,14 @@ </size> </property> <property name="toolTip"> - <string><html><head/><body><p align="center">Exit Sisyphus</p></body></html></string> + <string><html><head/><body><p align="center">Install package</p></body></html></string> + </property> + <property name="text"> + <string/> </property> <property name="icon"> <iconset> - <normaloff>../icon/exit.png</normaloff>../icon/exit.png</iconset> + <normaloff>../icon/install.png</normaloff>../icon/install.png</iconset> </property> <property name="iconSize"> <size> @@ -221,8 +160,8 @@ </property> </widget> </item> - <item row="3" column="2"> - <widget class="QPushButton" name="upgrade"> + <item row="5" column="1"> + <widget class="QPushButton" name="uninstall"> <property name="maximumSize"> <size> <width>16777215</width> @@ -230,11 +169,14 @@ </size> </property> <property name="toolTip"> - <string><html><head/><body><p align="center">Upgrade system</p></body></html></string> + <string><html><head/><body><p align="center">Uninstall package</p></body></html></string> + </property> + <property name="text"> + <string/> </property> <property name="icon"> <iconset> - <normaloff>../icon/upgrade.png</normaloff>../icon/upgrade.png</iconset> + <normaloff>../icon/uninstall.png</normaloff>../icon/uninstall.png</iconset> </property> <property name="iconSize"> <size> @@ -244,7 +186,7 @@ </property> </widget> </item> - <item row="3" column="3"> + <item row="5" column="3"> <widget class="QPushButton" name="orphans"> <property name="maximumSize"> <size> @@ -270,6 +212,42 @@ </property> </widget> </item> + <item row="5" column="4"> + <widget class="QPushButton" name="abort"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>25</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p align="center">Exit Sisyphus</p></body></html></string> + </property> + <property name="icon"> + <iconset> + <normaloff>../icon/exit.png</normaloff>../icon/exit.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + </widget> + </item> + <item row="1" column="1" colspan="3"> + <widget class="QLineEdit" name="input"> + <property name="toolTip"> + <string><html><head/><body><p align="center">Write package name and press Enter</p></body></html></string> + </property> + <property name="clearButtonEnabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QComboBox" name="selectfield"/> + </item> </layout> </item> <item row="1" column="0"> |