[qcookboob] search by id

This commit is contained in:
Julien Veyssier 2013-03-17 15:47:10 +01:00
commit 303172a816
2 changed files with 36 additions and 3 deletions

View file

@ -55,6 +55,7 @@ class MainWindow(QtMainWindow):
self.ui.backButton.hide()
self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search)
self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.actionQuit, SIGNAL("triggered()"), self.close)
@ -190,6 +191,24 @@ class MainWindow(QtMainWindow):
self.current_info_widget = wrecipe
QApplication.restoreOverrideCursor()
def searchId(self):
QApplication.setOverrideCursor(Qt.WaitCursor)
id = unicode(self.ui.idEdit.text())
if '@' in id:
backend_name = id.split('@')[1]
id = id.split('@')[0]
else:
backend_name = None
fail = True
for backend in self.weboob.iter_backends():
if (backend_name != None and backend.name == backend_name) or backend_name == None:
recipe = backend.get_recipe(id)
if recipe:
fail = False
self.doAction('Details of recipe "%s"' %
recipe.title, self.displayRecipe, [recipe, backend])
QApplication.restoreOverrideCursor()
def closeEvent(self, ev):
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(
self.ui.backendEdit.currentIndex()).toString()))

View file

@ -140,7 +140,7 @@
<x>0</x>
<y>0</y>
<width>708</width>
<height>292</height>
<height>261</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
@ -161,8 +161,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<height>26</height>
<width>63</width>
<height>18</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8"/>
@ -173,6 +173,20 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>search by ID:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="idEdit"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">