From 84897e88053788e594e9add766281742f917ee61 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 14 Mar 2013 03:03:53 +0100 Subject: [PATCH] [qcineoob] clarify history --- weboob/applications/qcineoob/main_window.py | 45 ++++++++++++--------- weboob/applications/qcineoob/qcineoob.py | 9 ++--- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/weboob/applications/qcineoob/main_window.py b/weboob/applications/qcineoob/main_window.py index 3105373c..445ec8c8 100644 --- a/weboob/applications/qcineoob/main_window.py +++ b/weboob/applications/qcineoob/main_window.py @@ -51,17 +51,8 @@ class MainWindow(QtMainWindow): self.minis = [] self.current_info_widget = None - self.search_history = [] - history_path = os.path.join(self.weboob.workdir, 'qcineoob_history') - if os.path.exists(history_path): - f=codecs.open(history_path,'r','utf-8') - conf_hist = f.read() - f.close() - if conf_hist != None and conf_hist.strip() != '': - self.search_history = conf_hist.strip().split('\n') - qc = QCompleter(QStringList(self.search_history),self) - qc.setCaseSensitivity(Qt.CaseInsensitive) - self.ui.searchEdit.setCompleter(qc) + self.search_history = self.loadHistory() + self.updateCompletion() self.history = {'last_action':None,'action_list':[]} self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack) @@ -105,6 +96,29 @@ class MainWindow(QtMainWindow): else: self.ui.searchEdit.setEnabled(True) + def loadHistory(self): + result = [] + history_path = os.path.join(self.weboob.workdir, 'qcineoob_history') + if os.path.exists(history_path): + f=codecs.open(history_path,'r','utf-8') + conf_hist = f.read() + f.close() + if conf_hist != None and conf_hist.strip() != '': + result = conf_hist.strip().split('\n') + return result + + def saveHistory(self): + if len(self.search_history) > 0: + history_path = os.path.join(self.weboob.workdir, 'qcineoob_history') + f=codecs.open(history_path,'w','utf-8') + f.write('\n'.join(self.search_history)) + f.close() + + def updateCompletion(self): + qc = QCompleter(QStringList(self.search_history),self) + qc.setCaseSensitivity(Qt.CaseInsensitive) + self.ui.searchEdit.setCompleter(qc) + def typeComboChanged(self,value): if unicode(value) == 'subtitle': self.ui.langCombo.show() @@ -172,9 +186,7 @@ class MainWindow(QtMainWindow): self.search_history.pop(0) if pattern not in self.search_history: self.search_history.append(pattern) - qc = QCompleter(QStringList(self.search_history),self) - qc.setCaseSensitivity(Qt.CaseInsensitive) - self.ui.searchEdit.setCompleter(qc) + self.updateCompletion() tosearch = self.ui.typeCombo.currentText() if tosearch == 'person': @@ -359,10 +371,7 @@ class MainWindow(QtMainWindow): def closeEvent(self, ev): self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())) - history_path = os.path.join(self.weboob.workdir, 'qcineoob_history') - f=codecs.open(history_path,'w','utf-8') - f.write('\n'.join(self.search_history)) - f.close() + self.saveHistory() self.config.save() ev.accept() diff --git a/weboob/applications/qcineoob/qcineoob.py b/weboob/applications/qcineoob/qcineoob.py index 3183eba1..b072413e 100644 --- a/weboob/applications/qcineoob/qcineoob.py +++ b/weboob/applications/qcineoob/qcineoob.py @@ -30,13 +30,10 @@ class QCineoob(QtApplication): APPNAME = 'qcineoob' VERSION = '0.f' COPYRIGHT = 'Copyright(C) 2013 Julien Veyssier' - DESCRIPTION = "Qt application allowing to search movies etc..." - SHORT_DESCRIPTION = "search movies" + DESCRIPTION = "Qt application allowing to search movies, people, torrent and subtitles." + SHORT_DESCRIPTION = "search movies, people, torrent and subtitles" CAPS = ICapCinema,ICapTorrent,ICapSubtitle - CONFIG = {'settings': {'nsfw': 1, - 'sfw': 1, - 'sortby': 0, - 'backend': '' + CONFIG = {'settings': {'backend': '', } } def main(self, argv):