Fix regression that broke the On Device/In Library column

This commit is contained in:
Kovid Goyal 2011-04-17 07:19:00 -06:00
commit 99ed3e4477
6 changed files with 25 additions and 36 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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.') + '<br><br>'
@ -374,6 +373,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']:
@ -404,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)

View File

@ -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()

View File

@ -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()

View File

@ -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