From 99be7da6c8a52bf20a734fa8b6b7fc96eeaa7814 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 30 Jun 2011 16:33:25 +0100 Subject: [PATCH 1/2] Add context menu item to resize a column to the viewport size if it is bigger. --- src/calibre/gui2/library/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 377ca4a9b6..6cad9f8da9 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -215,6 +215,9 @@ class BooksView(QTableView): # {{{ self.column_header_context_menu.addSeparator() + self.column_header_context_menu.addAction( + _('Resize column to fit'), + partial(self.resize_column_to_fit, column=self.column_map[idx])) self.column_header_context_menu.addAction( _('Restore default layout'), partial(self.column_header_context_handler, @@ -463,6 +466,10 @@ class BooksView(QTableView): # {{{ self.was_restored = True + def resize_column_to_fit(self, column): + col = self.column_map.index(column) + self.column_resized(col, self.columnWidth(col), self.columnWidth(col)) + def column_resized(self, col, old_size, new_size): # arbitrary: scroll bar + header + some max_width = self.width() - (self.verticalScrollBar().width() + From a42e1556489df09a6eb5c210cc5fa6b5aeb048dc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 30 Jun 2011 10:45:31 -0600 Subject: [PATCH 2/2] ... --- src/calibre/gui2/library/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 19397f490f..27939c3519 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -219,7 +219,7 @@ class BooksView(QTableView): # {{{ self.column_header_context_menu.addSeparator() self.column_header_context_menu.addAction( - _('Resize column to fit'), + _('Shrink column if it is too wide to fit'), partial(self.resize_column_to_fit, column=self.column_map[idx])) self.column_header_context_menu.addAction( _('Restore default layout'),