[qcineoob] limit number of result by backend

This commit is contained in:
Julien Veyssier 2013-03-18 03:17:54 +01:00
commit b91266f2d7
3 changed files with 37 additions and 7 deletions

View file

@ -43,13 +43,14 @@ from .subtitle import Subtitle
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
@ -66,6 +67,7 @@ class MainWindow(QtMainWindow):
self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search)
self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"), self.typeComboChanged)
self.ui.countSpin.setValue(10)
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.actionQuit, SIGNAL("triggered()"), self.close)
@ -136,6 +138,13 @@ class MainWindow(QtMainWindow):
self.ui.langCombo.hide()
self.ui.langLabel.hide()
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
@ -233,7 +242,8 @@ class MainWindow(QtMainWindow):
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addMovie)
self.process.do('iter_movies', pattern, backends=backend_name, caps=ICapCinema)
#self.process.do('iter_movies', pattern, backends=backend_name, caps=ICapCinema)
self.process.do(self.app._do_complete, self.getCount(), ('original_title'), 'iter_movies', pattern, backends=backend_name, caps=ICapCinema)
def addMovie(self, backend, movie):
if not backend:
@ -276,7 +286,8 @@ class MainWindow(QtMainWindow):
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addPerson)
self.process.do('iter_persons', pattern, backends=backend_name, caps=ICapCinema)
#self.process.do('iter_persons', pattern, backends=backend_name, caps=ICapCinema)
self.process.do(self.app._do_complete, self.getCount(), ('name'), 'iter_persons', pattern, backends=backend_name, caps=ICapCinema)
def addPerson(self, backend, person):
if not backend:
@ -319,7 +330,8 @@ class MainWindow(QtMainWindow):
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addTorrent)
self.process.do('iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
#self.process.do('iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
self.process.do(self.app._do_complete, self.getCount(), ('name'), 'iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
def addTorrent(self, backend, torrent):
if not backend:
@ -362,7 +374,8 @@ class MainWindow(QtMainWindow):
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addSubtitle)
self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
#self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
self.process.do(self.app._do_complete, self.getCount(), ('name'), 'iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
def addSubtitle(self, backend, subtitle):
if not backend:

View file

@ -41,6 +41,6 @@ class QCineoob(QtApplication):
self.load_backends([ICapCinema, ICapTorrent, ICapSubtitle])
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()

View file

@ -85,6 +85,23 @@
<item>
<widget class="QComboBox" name="backendEdit"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Maximum results by backend&lt;/p&gt;&lt;p&gt;0 = no limit&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>max results</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="countSpin">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Maximum results by backend&lt;/p&gt;&lt;p&gt;0 = no limit&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -200,7 +217,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>63</width>
<width>78</width>
<height>18</height>
</rect>
</property>