From c41df1537cee61c21c8be34977930c75b8450a46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Jun 2013 15:25:41 +0530 Subject: [PATCH] Get Books: Use a better HistoryLineEdit Get Books: Fix unable to change case of words in the title/author/keywords boxes because of completion. --- src/calibre/gui2/store/search/search.py | 12 +-------- src/calibre/gui2/store/search/search.ui | 18 ++++++------- src/calibre/gui2/widgets2.py | 34 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 src/calibre/gui2/widgets2.py diff --git a/src/calibre/gui2/store/search/search.py b/src/calibre/gui2/store/search/search.py index d8147ddb22..893ec9ba42 100644 --- a/src/calibre/gui2/store/search/search.py +++ b/src/calibre/gui2/store/search/search.py @@ -10,8 +10,7 @@ import re from random import shuffle from PyQt4.Qt import (Qt, QDialog, QDialogButtonBox, QTimer, QCheckBox, QLabel, - QVBoxLayout, QIcon, QWidget, QTabWidget, QGridLayout, - QComboBox) + QVBoxLayout, QIcon, QWidget, QTabWidget, QGridLayout) from calibre.gui2 import JSONConfig, info_dialog, error_dialog from calibre.gui2.dialogs.choose_format import ChooseFormatDialog @@ -72,15 +71,6 @@ class SearchDialog(QDialog, Ui_Dialog): self.search_author.setText(query['author']) if 'title' in query: self.search_title.setText(query['title']) - # Title - self.search_title.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) - self.search_title.setMinimumContentsLength(25) - # Author - self.search_author.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) - self.search_author.setMinimumContentsLength(25) - # Keyword - self.search_edit.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) - self.search_edit.setMinimumContentsLength(25) # Create and add the progress indicator self.pi = ProgressIndicator(self, 24) diff --git a/src/calibre/gui2/store/search/search.ui b/src/calibre/gui2/store/search/search.ui index 715f6788e7..60f87e47ad 100644 --- a/src/calibre/gui2/store/search/search.ui +++ b/src/calibre/gui2/store/search/search.ui @@ -14,7 +14,7 @@ Get Books - + :/images/store.png:/images/store.png @@ -22,7 +22,7 @@ - + Search by title @@ -42,7 +42,7 @@ - + Search by author @@ -69,7 +69,7 @@ - + 0 @@ -107,8 +107,8 @@ 0 0 - 204 - 141 + 207 + 163 @@ -314,9 +314,9 @@
results_view.h
- HistoryLineEdit + HistoryLineEdit2 QLineEdit -
widgets.h
+
calibre/gui2/widgets2.h
@@ -335,7 +335,7 @@ close - + diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py new file mode 100644 index 0000000000..c6b0bdaf0c --- /dev/null +++ b/src/calibre/gui2/widgets2.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 +from __future__ import (unicode_literals, division, absolute_import, + print_function) + +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + +from calibre.gui2.complete2 import LineEdit +from calibre.gui2.widgets import history + +class HistoryLineEdit2(LineEdit): + + @property + def store_name(self): + return 'lineedit_history_'+self._name + + def initialize(self, name): + self._name = name + self.history = history.get(self.store_name, []) + self.set_separator(None) + self.update_items_cache(self.history) + self.setText('') + self.editingFinished.connect(self.save_history) + + def save_history(self): + ct = unicode(self.text()) + try: + self.history.remove(ct) + except ValueError: + pass + self.history.insert(0, ct) + history.set(self.store_name, self.history) +