mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add entry to context menu for column headers to launch the Quickview dialog (for columns that support quick view)
This commit is contained in:
commit
4cfeaac8b4
@ -38,6 +38,13 @@ class ShowQuickviewAction(InterfaceAction):
|
||||
Quickview(self.gui, self.gui.library_view, index)
|
||||
self.current_instance.show()
|
||||
|
||||
def change_quickview_column(self, idx):
|
||||
self.show_quickview()
|
||||
if self.current_instance:
|
||||
if self.current_instance.is_closed:
|
||||
return
|
||||
self.current_instance.change_quickview_column.emit(idx)
|
||||
|
||||
def library_changed(self, db):
|
||||
if self.current_instance and not self.current_instance.is_closed:
|
||||
self.current_instance.set_database(db)
|
||||
|
@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt4.Qt import (Qt, QDialog, QAbstractItemView, QTableWidgetItem,
|
||||
QListWidgetItem, QByteArray, QCoreApplication,
|
||||
QApplication)
|
||||
QApplication, pyqtSignal)
|
||||
|
||||
from calibre.customize.ui import find_plugin
|
||||
from calibre.gui2 import gprefs
|
||||
@ -44,6 +44,8 @@ class TableItem(QTableWidgetItem):
|
||||
|
||||
class Quickview(QDialog, Ui_Quickview):
|
||||
|
||||
change_quickview_column = pyqtSignal(object)
|
||||
|
||||
def __init__(self, gui, view, row):
|
||||
QDialog.__init__(self, gui, flags=Qt.Window)
|
||||
Ui_Quickview.__init__(self)
|
||||
@ -105,6 +107,7 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
self.refresh(row)
|
||||
|
||||
self.view.clicked.connect(self.slave)
|
||||
self.change_quickview_column.connect(self.slave)
|
||||
QCoreApplication.instance().aboutToQuit.connect(self.save_state)
|
||||
self.search_button.clicked.connect(self.do_search)
|
||||
view.model().new_bookdisplay_data.connect(self.book_was_changed)
|
||||
@ -164,6 +167,8 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
|
||||
if vals:
|
||||
self.no_valid_items = False
|
||||
if self.db.field_metadata[key]['datatype'] == 'rating':
|
||||
vals = unicode(vals/2)
|
||||
if not isinstance(vals, list):
|
||||
vals = [vals]
|
||||
vals.sort(key=sort_key)
|
||||
|
@ -197,6 +197,16 @@ class BooksView(QTableView): # {{{
|
||||
elif action.startswith('align_'):
|
||||
alignment = action.partition('_')[-1]
|
||||
self._model.change_alignment(column, alignment)
|
||||
elif action == 'quickview':
|
||||
from calibre.customize.ui import find_plugin
|
||||
qv = find_plugin('Show Quickview')
|
||||
if qv:
|
||||
rows = self.selectionModel().selectedRows()
|
||||
if len(rows) > 0:
|
||||
current_row = rows[0].row()
|
||||
current_col = self.column_map.index(column)
|
||||
index = self.model().index(current_row, current_col)
|
||||
qv.actual_plugin_.change_quickview_column(index)
|
||||
|
||||
self.save_state()
|
||||
|
||||
@ -240,7 +250,14 @@ class BooksView(QTableView): # {{{
|
||||
a.setCheckable(True)
|
||||
a.setChecked(True)
|
||||
|
||||
|
||||
if self._model.db.field_metadata[col]['is_category']:
|
||||
act = self.column_header_context_menu.addAction(_('Quickview column %s') %
|
||||
name,
|
||||
partial(self.column_header_context_handler, action='quickview',
|
||||
column=col))
|
||||
rows = self.selectionModel().selectedRows()
|
||||
if len(rows) > 1:
|
||||
act.setEnabled(False)
|
||||
|
||||
hidden_cols = [self.column_map[i] for i in
|
||||
range(self.column_header.count()) if
|
||||
|
Loading…
x
Reference in New Issue
Block a user