[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):
|
class MainWindow(QtMainWindow):
|
||||||
def __init__(self, config, weboob, parent=None):
|
def __init__(self, config, weboob, app, parent=None):
|
||||||
QtMainWindow.__init__(self, parent)
|
QtMainWindow.__init__(self, parent)
|
||||||
self.ui = Ui_MainWindow()
|
self.ui = Ui_MainWindow()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.weboob = weboob
|
self.weboob = weboob
|
||||||
|
self.app = app
|
||||||
self.minis = []
|
self.minis = []
|
||||||
self.current_info_widget = None
|
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.searchEdit, SIGNAL("returnPressed()"), self.search)
|
||||||
self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
|
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.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
|
||||||
self.connect(self.ui.actionQuit, SIGNAL("triggered()"), self.close)
|
self.connect(self.ui.actionQuit, SIGNAL("triggered()"), self.close)
|
||||||
|
|
||||||
|
|
@ -111,6 +115,13 @@ class MainWindow(QtMainWindow):
|
||||||
qc.setCaseSensitivity(Qt.CaseInsensitive)
|
qc.setCaseSensitivity(Qt.CaseInsensitive)
|
||||||
self.ui.searchEdit.setCompleter(qc)
|
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):
|
def doAction(self, description, fun, args):
|
||||||
''' Call fun with args as arguments
|
''' Call fun with args as arguments
|
||||||
and save it in the action history
|
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())
|
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
||||||
|
|
||||||
self.process = QtDo(self.weboob, self.addRecipe)
|
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):
|
def addRecipe(self, backend, recipe):
|
||||||
if not backend:
|
if not backend:
|
||||||
|
|
@ -210,6 +221,7 @@ class MainWindow(QtMainWindow):
|
||||||
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(
|
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(
|
||||||
self.ui.backendEdit.currentIndex()).toString()))
|
self.ui.backendEdit.currentIndex()).toString()))
|
||||||
self.saveSearchHistory()
|
self.saveSearchHistory()
|
||||||
|
self.config.set('settings', 'maxresultsnumber', self.ui.countSpin.value())
|
||||||
|
|
||||||
self.config.save()
|
self.config.save()
|
||||||
ev.accept()
|
ev.accept()
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class QCookboob(QtApplication):
|
||||||
SHORT_DESCRIPTION = "search recipes"
|
SHORT_DESCRIPTION = "search recipes"
|
||||||
CAPS = ICapRecipe
|
CAPS = ICapRecipe
|
||||||
CONFIG = {'settings': {'backend': '',
|
CONFIG = {'settings': {'backend': '',
|
||||||
|
'maxresultsnumber': '10'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,6 +40,6 @@ class QCookboob(QtApplication):
|
||||||
self.load_backends([ICapRecipe])
|
self.load_backends([ICapRecipe])
|
||||||
self.load_config()
|
self.load_config()
|
||||||
|
|
||||||
self.main_window = MainWindow(self.config, self.weboob)
|
self.main_window = MainWindow(self.config, self.weboob, self)
|
||||||
self.main_window.show()
|
self.main_window.show()
|
||||||
return self.weboob.loop()
|
return self.weboob.loop()
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,23 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="backendEdit"/>
|
<widget class="QComboBox" name="backendEdit"/>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -161,8 +178,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>63</width>
|
<width>96</width>
|
||||||
<height>18</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8"/>
|
<layout class="QVBoxLayout" name="verticalLayout_8"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue