[qcookboob] max results
This commit is contained in:
parent
fe9c011757
commit
893437dd00
3 changed files with 35 additions and 5 deletions
|
|
@ -34,13 +34,14 @@ from .recipe import Recipe
|
|||
|
||||
|
||||
class MainWindow(QtMainWindow):
|
||||
def __init__(self, config, weboob, parent=None):
|
||||
def __init__(self, config, weboob, app, parent=None):
|
||||
QtMainWindow.__init__(self, parent)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.config = config
|
||||
self.weboob = weboob
|
||||
self.app = app
|
||||
self.minis = []
|
||||
self.current_info_widget = None
|
||||
|
||||
|
|
@ -57,6 +58,9 @@ class MainWindow(QtMainWindow):
|
|||
self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search)
|
||||
self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
|
||||
|
||||
count = self.config.get('settings', 'maxresultsnumber')
|
||||
self.ui.countSpin.setValue(int(count))
|
||||
|
||||
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
|
||||
self.connect(self.ui.actionQuit, SIGNAL("triggered()"), self.close)
|
||||
|
||||
|
|
@ -111,6 +115,13 @@ class MainWindow(QtMainWindow):
|
|||
qc.setCaseSensitivity(Qt.CaseInsensitive)
|
||||
self.ui.searchEdit.setCompleter(qc)
|
||||
|
||||
def getCount(self):
|
||||
num = self.ui.countSpin.value()
|
||||
if num == 0:
|
||||
return None
|
||||
else:
|
||||
return num
|
||||
|
||||
def doAction(self, description, fun, args):
|
||||
''' Call fun with args as arguments
|
||||
and save it in the action history
|
||||
|
|
@ -168,7 +179,7 @@ class MainWindow(QtMainWindow):
|
|||
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
||||
|
||||
self.process = QtDo(self.weboob, self.addRecipe)
|
||||
self.process.do('iter_recipes', pattern, backends=backend_name, caps=ICapRecipe)
|
||||
self.process.do(self.app._do_complete, self.getCount(), ('title'), 'iter_recipes', pattern, backends=backend_name, caps=ICapRecipe)
|
||||
|
||||
def addRecipe(self, backend, recipe):
|
||||
if not backend:
|
||||
|
|
@ -210,6 +221,7 @@ class MainWindow(QtMainWindow):
|
|||
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(
|
||||
self.ui.backendEdit.currentIndex()).toString()))
|
||||
self.saveSearchHistory()
|
||||
self.config.set('settings', 'maxresultsnumber', self.ui.countSpin.value())
|
||||
|
||||
self.config.save()
|
||||
ev.accept()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class QCookboob(QtApplication):
|
|||
SHORT_DESCRIPTION = "search recipes"
|
||||
CAPS = ICapRecipe
|
||||
CONFIG = {'settings': {'backend': '',
|
||||
'maxresultsnumber': '10'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +40,6 @@ class QCookboob(QtApplication):
|
|||
self.load_backends([ICapRecipe])
|
||||
self.load_config()
|
||||
|
||||
self.main_window = MainWindow(self.config, self.weboob)
|
||||
self.main_window = MainWindow(self.config, self.weboob, self)
|
||||
self.main_window.show()
|
||||
return self.weboob.loop()
|
||||
|
|
|
|||
|
|
@ -46,6 +46,23 @@
|
|||
<item>
|
||||
<widget class="QComboBox" name="backendEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Maximum results by backend</p><p>0 = no limit</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>max results</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="countSpin">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Maximum results by backend</p><p>0 = no limit</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -161,8 +178,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>63</width>
|
||||
<height>18</height>
|
||||
<width>96</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue