From 48b7133f64920e78ad734e33e087c0893f715cc1 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Sun, 17 Apr 2011 09:14:58 +0100
Subject: [PATCH 1/5] Slight changes to the new 'manage' button
---
src/calibre/gui2/tag_view.py | 40 +++++++++++++++++-------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py
index 188fd3367d..7b68229da0 100644
--- a/src/calibre/gui2/tag_view.py
+++ b/src/calibre/gui2/tag_view.py
@@ -15,7 +15,7 @@ from functools import partial
from PyQt4.Qt import (Qt, QTreeView, QApplication, pyqtSignal, QFont, QSize,
QIcon, QPoint, QVBoxLayout, QHBoxLayout, QComboBox, QTimer,
QAbstractItemModel, QVariant, QModelIndex, QMenu, QFrame,
- QWidget, QItemDelegate, QString, QLabel,
+ QWidget, QItemDelegate, QString, QLabel, QPushButton,
QShortcut, QKeySequence, SIGNAL, QMimeData, QToolButton)
from calibre.ebooks.metadata import title_sort
@@ -1809,9 +1809,6 @@ class TagsModel(QAbstractItemModel): # {{{
# }}}
-category_managers = (
- )
-
class TagBrowserMixin(object): # {{{
def __init__(self, db):
@@ -1833,20 +1830,23 @@ class TagBrowserMixin(object): # {{{
self.tags_view.restriction_error.connect(self.do_restriction_error,
type=Qt.QueuedConnection)
- for text, func, args in (
- (_('Manage Authors'), self.do_author_sort_edit, (self,
- None)),
- (_('Manage Series'), self.do_tags_list_edit, (None,
- 'series')),
- (_('Manage Publishers'), self.do_tags_list_edit, (None,
- 'publisher')),
- (_('Manage Tags'), self.do_tags_list_edit, (None, 'tags')),
- (_('Manage User Categories'),
- self.do_edit_user_categories, (None,)),
- (_('Manage Saved Searches'), self.do_saved_search_edit,
- (None,))
+ for text, func, args, cat_name in (
+ (_('Manage Authors'),
+ self.do_author_sort_edit, (self, None), 'authors'),
+ (_('Manage Series'),
+ self.do_tags_list_edit, (None, 'series'), 'series'),
+ (_('Manage Publishers'),
+ self.do_tags_list_edit, (None, 'publisher'), 'publisher'),
+ (_('Manage Tags'),
+ self.do_tags_list_edit, (None, 'tags'), 'tags'),
+ (_('Manage User Categories'),
+ self.do_edit_user_categories, (None,), 'user:'),
+ (_('Manage Saved Searches'),
+ self.do_saved_search_edit, (None,), 'search')
):
- self.manage_items_button.menu().addAction(text, partial(func, *args))
+ self.manage_items_button.menu().addAction(
+ QIcon(I(category_icon_map[cat_name])),
+ text, partial(func, *args))
def do_restriction_error(self):
error_dialog(self.tags_view, _('Invalid search restriction'),
@@ -2166,11 +2166,9 @@ class TagBrowserWidget(QWidget): # {{{
parent.tag_match.setStatusTip(parent.tag_match.toolTip())
- l = parent.manage_items_button = QToolButton(self)
- l.setIcon(QIcon(I('tags.png')))
+ l = parent.manage_items_button = QPushButton(self)
+ l.setStyleSheet('QPushButton {text-align: left; }')
l.setText(_('Manage authors, tags, etc'))
- l.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
- l.setPopupMode(l.InstantPopup)
l.setToolTip(_('All of these category_managers are available by right-clicking '
'on items in the tag browser above'))
l.m = QMenu()
From b4d098bc252dc16e7fb2392b76053aca618ba024 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Sun, 17 Apr 2011 10:14:34 +0100
Subject: [PATCH 2/5] Back out change to add 'size' to the mi returned by
get_metadata. It breaks managing device metadata badly.
---
src/calibre/library/database2.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py
index b5155368c7..bdcefd13a2 100644
--- a/src/calibre/library/database2.py
+++ b/src/calibre/library/database2.py
@@ -854,7 +854,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
mi.uuid = row[fm['uuid']]
mi.title_sort = row[fm['sort']]
mi.last_modified = row[fm['last_modified']]
- mi.size = row[fm['size']]
formats = row[fm['formats']]
if not formats:
formats = None
From 1af2d395408a674a103ab197030f292c897bc19e Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Sun, 17 Apr 2011 10:40:49 +0100
Subject: [PATCH 3/5] Make the toggle search highlighting re-run the last
search.
---
src/calibre/gui2/search_box.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py
index f5b3649e27..40c9c34587 100644
--- a/src/calibre/gui2/search_box.py
+++ b/src/calibre/gui2/search_box.py
@@ -374,6 +374,8 @@ class SearchBoxMixin(object): # {{{
def highlight_only_clicked(self, state):
config['highlight_search_matches'] = not config['highlight_search_matches']
self.set_highlight_only_button_icon()
+ self.search.do_search()
+ self.focus_to_library()
def set_highlight_only_button_icon(self):
if config['highlight_search_matches']:
From 375d64e118eb8d22d58bee0c7e1cfe7b6ac498a1 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Sun, 17 Apr 2011 11:51:49 +0100
Subject: [PATCH 4/5] Completely remove the search options button. Enable and
disable the highlight_only_button when switching between library and device
views.
---
src/calibre/gui2/layout.py | 7 -------
src/calibre/gui2/search_box.py | 5 -----
src/calibre/gui2/ui.py | 4 ++--
3 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py
index 246fa168a0..e5ec5a9131 100644
--- a/src/calibre/gui2/layout.py
+++ b/src/calibre/gui2/layout.py
@@ -200,13 +200,6 @@ class SearchBar(QWidget): # {{{
x.setIcon(QIcon(I('arrow-down.png')))
l.addWidget(x)
- x = parent.search_options_button = QToolButton(self)
- x.setIcon(QIcon(I('config.png')))
- x.setObjectName("search_option_button")
- l.addWidget(x)
- x.setToolTip(_("Change the way searching for books works"))
- x.setVisible(False)
-
x = parent.saved_search = SavedSearchBox(self)
x.setMaximumSize(QSize(150, 16777215))
x.setMinimumContentsLength(15)
diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py
index 40c9c34587..c349d84a68 100644
--- a/src/calibre/gui2/search_box.py
+++ b/src/calibre/gui2/search_box.py
@@ -364,7 +364,6 @@ class SearchBoxMixin(object): # {{{
unicode(self.search.toolTip())))
self.advanced_search_button.setStatusTip(self.advanced_search_button.toolTip())
self.clear_button.setStatusTip(self.clear_button.toolTip())
- self.search_options_button.clicked.connect(self.search_options_button_clicked)
self.set_highlight_only_button_icon()
self.highlight_only_button.clicked.connect(self.highlight_only_clicked)
tt = _('Enable or disable search highlighting.') + '
'
@@ -406,10 +405,6 @@ class SearchBoxMixin(object): # {{{
self.search.do_search()
self.focus_to_library()
- def search_options_button_clicked(self):
- self.iactions['Preferences'].do_config(initial_plugin=('Interface',
- 'Search'), close_after_initial=True)
-
def focus_to_library(self):
self.current_view().setFocus(Qt.OtherFocusReason)
diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py
index 8d31d9da32..f234d48739 100644
--- a/src/calibre/gui2/ui.py
+++ b/src/calibre/gui2/ui.py
@@ -529,10 +529,10 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
action.location_selected(location)
if location == 'library':
self.search_restriction.setEnabled(True)
- self.search_options_button.setEnabled(True)
+ self.highlight_only_button.setEnabled(True)
else:
self.search_restriction.setEnabled(False)
- self.search_options_button.setEnabled(False)
+ self.highlight_only_button.setEnabled(False)
# Reset the view in case something changed while it was invisible
self.current_view().reset()
self.set_number_of_books_shown()
From f49d96871b332b4325457038c37e028dc9ce6036 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Sun, 17 Apr 2011 13:36:02 +0100
Subject: [PATCH 5/5] If the search option highlight_only is set, then only
select a book after a search if the search returned results.
---
src/calibre/gui2/library/views.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index 48fbfb7291..ce5e0d9877 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -743,6 +743,8 @@ class BooksView(QTableView): # {{{
id_to_select = self._model.get_current_highlighted_id()
if id_to_select is not None:
self.select_rows([id_to_select], using_ids=True)
+ elif self._model.highlight_only:
+ self.clearSelection()
self.setFocus(Qt.OtherFocusReason)
def connect_to_search_box(self, sb, search_done):