mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
5a4808bb91
@ -177,7 +177,16 @@ class ChooseLibraryAction(InterfaceAction):
|
||||
return error_dialog(self.gui, _('Already exists'),
|
||||
_('The folder %s already exists. Delete it first.') %
|
||||
newloc, show=True)
|
||||
os.rename(loc, newloc)
|
||||
try:
|
||||
os.rename(loc, newloc)
|
||||
except:
|
||||
import traceback
|
||||
error_dialog(self.gui, _('Rename failed'),
|
||||
_('Failed to rename the library at %s. '
|
||||
'The most common cause for this is if one of the files'
|
||||
' in the library is open in another program.') % loc,
|
||||
det_msg=traceback.format_exc(), show=True)
|
||||
return
|
||||
self.stats.rename(location, newloc)
|
||||
self.build_menus()
|
||||
|
||||
|
@ -32,6 +32,9 @@ class LibraryViewMixin(object): # {{{
|
||||
|
||||
def __init__(self, db):
|
||||
self.library_view.files_dropped.connect(self.iactions['Add Books'].files_dropped, type=Qt.QueuedConnection)
|
||||
self.library_view.add_column_signal.connect(partial(self.iactions['Preferences'].do_config,
|
||||
initial_plugin=('Interface', 'Custom Columns')),
|
||||
type=Qt.QueuedConnection)
|
||||
for func, args in [
|
||||
('connect_to_search_box', (self.search,
|
||||
self.search_done)),
|
||||
|
@ -23,6 +23,7 @@ from calibre.gui2.library import DEFAULT_SORT
|
||||
class BooksView(QTableView): # {{{
|
||||
|
||||
files_dropped = pyqtSignal(object)
|
||||
add_column_signal = pyqtSignal()
|
||||
|
||||
def __init__(self, parent, modelcls=BooksModel):
|
||||
QTableView.__init__(self, parent)
|
||||
@ -54,6 +55,7 @@ class BooksView(QTableView): # {{{
|
||||
self.selectionModel().currentRowChanged.connect(self._model.current_changed)
|
||||
|
||||
# {{{ Column Header setup
|
||||
self.can_add_columns = True
|
||||
self.was_restored = False
|
||||
self.column_header = self.horizontalHeader()
|
||||
self.column_header.setMovable(True)
|
||||
@ -93,6 +95,8 @@ class BooksView(QTableView): # {{{
|
||||
self.sortByColumn(idx, Qt.DescendingOrder)
|
||||
elif action == 'defaults':
|
||||
self.apply_state(self.get_default_state())
|
||||
elif action == 'addcustcol':
|
||||
self.add_column_signal.emit()
|
||||
elif action.startswith('align_'):
|
||||
alignment = action.partition('_')[-1]
|
||||
self._model.change_alignment(column, alignment)
|
||||
@ -166,6 +170,12 @@ class BooksView(QTableView): # {{{
|
||||
partial(self.column_header_context_handler,
|
||||
action='defaults', column=col))
|
||||
|
||||
if self.can_add_columns:
|
||||
self.column_header_context_menu.addAction(
|
||||
_('Add your own columns'),
|
||||
partial(self.column_header_context_handler,
|
||||
action='addcustcol', column=col))
|
||||
|
||||
self.column_header_context_menu.popup(self.column_header.mapToGlobal(pos))
|
||||
# }}}
|
||||
|
||||
@ -494,6 +504,7 @@ class DeviceBooksView(BooksView): # {{{
|
||||
|
||||
def __init__(self, parent):
|
||||
BooksView.__init__(self, parent, DeviceBooksModel)
|
||||
self.can_add_columns = False
|
||||
self.columns_resized = False
|
||||
self.resize_on_select = False
|
||||
self.rating_delegate = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user