[qcineoob] clarify history
This commit is contained in:
parent
a69d4a0eee
commit
84897e8805
2 changed files with 30 additions and 24 deletions
|
|
@ -51,17 +51,8 @@ class MainWindow(QtMainWindow):
|
||||||
self.minis = []
|
self.minis = []
|
||||||
self.current_info_widget = None
|
self.current_info_widget = None
|
||||||
|
|
||||||
self.search_history = []
|
self.search_history = self.loadHistory()
|
||||||
history_path = os.path.join(self.weboob.workdir, 'qcineoob_history')
|
self.updateCompletion()
|
||||||
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.history = {'last_action':None,'action_list':[]}
|
self.history = {'last_action':None,'action_list':[]}
|
||||||
self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack)
|
self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack)
|
||||||
|
|
@ -105,6 +96,29 @@ class MainWindow(QtMainWindow):
|
||||||
else:
|
else:
|
||||||
self.ui.searchEdit.setEnabled(True)
|
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):
|
def typeComboChanged(self,value):
|
||||||
if unicode(value) == 'subtitle':
|
if unicode(value) == 'subtitle':
|
||||||
self.ui.langCombo.show()
|
self.ui.langCombo.show()
|
||||||
|
|
@ -172,9 +186,7 @@ class MainWindow(QtMainWindow):
|
||||||
self.search_history.pop(0)
|
self.search_history.pop(0)
|
||||||
if pattern not in self.search_history:
|
if pattern not in self.search_history:
|
||||||
self.search_history.append(pattern)
|
self.search_history.append(pattern)
|
||||||
qc = QCompleter(QStringList(self.search_history),self)
|
self.updateCompletion()
|
||||||
qc.setCaseSensitivity(Qt.CaseInsensitive)
|
|
||||||
self.ui.searchEdit.setCompleter(qc)
|
|
||||||
|
|
||||||
tosearch = self.ui.typeCombo.currentText()
|
tosearch = self.ui.typeCombo.currentText()
|
||||||
if tosearch == 'person':
|
if tosearch == 'person':
|
||||||
|
|
@ -359,10 +371,7 @@ class MainWindow(QtMainWindow):
|
||||||
|
|
||||||
def closeEvent(self, ev):
|
def closeEvent(self, ev):
|
||||||
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString()))
|
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')
|
self.saveHistory()
|
||||||
f=codecs.open(history_path,'w','utf-8')
|
|
||||||
f.write('\n'.join(self.search_history))
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
self.config.save()
|
self.config.save()
|
||||||
ev.accept()
|
ev.accept()
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,10 @@ class QCineoob(QtApplication):
|
||||||
APPNAME = 'qcineoob'
|
APPNAME = 'qcineoob'
|
||||||
VERSION = '0.f'
|
VERSION = '0.f'
|
||||||
COPYRIGHT = 'Copyright(C) 2013 Julien Veyssier'
|
COPYRIGHT = 'Copyright(C) 2013 Julien Veyssier'
|
||||||
DESCRIPTION = "Qt application allowing to search movies etc..."
|
DESCRIPTION = "Qt application allowing to search movies, people, torrent and subtitles."
|
||||||
SHORT_DESCRIPTION = "search movies"
|
SHORT_DESCRIPTION = "search movies, people, torrent and subtitles"
|
||||||
CAPS = ICapCinema,ICapTorrent,ICapSubtitle
|
CAPS = ICapCinema,ICapTorrent,ICapSubtitle
|
||||||
CONFIG = {'settings': {'nsfw': 1,
|
CONFIG = {'settings': {'backend': '',
|
||||||
'sfw': 1,
|
|
||||||
'sortby': 0,
|
|
||||||
'backend': ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue