Add context menu item to resize a column to the viewport size if it is bigger.

This commit is contained in:
Charles Haley 2011-06-30 16:33:25 +01:00
parent 0ee4cbe48d
commit 99be7da6c8

View File

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