mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure that a column in a book view cannot be sized to bigger than the displayable area.
This commit is contained in:
parent
3bae54056f
commit
d16df15022
@ -110,6 +110,7 @@ class BooksView(QTableView): # {{{
|
|||||||
self.column_header.sectionMoved.connect(self.save_state)
|
self.column_header.sectionMoved.connect(self.save_state)
|
||||||
self.column_header.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.column_header.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||||
self.column_header.customContextMenuRequested.connect(self.show_column_header_context_menu)
|
self.column_header.customContextMenuRequested.connect(self.show_column_header_context_menu)
|
||||||
|
self.column_header.sectionResized.connect(self.column_resized)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
self._model.database_changed.connect(self.database_changed)
|
self._model.database_changed.connect(self.database_changed)
|
||||||
@ -451,7 +452,9 @@ class BooksView(QTableView): # {{{
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
old_state['sort_history'] = sh
|
old_state['sort_history'] = sh
|
||||||
|
|
||||||
|
self.column_header.blockSignals(True)
|
||||||
self.apply_state(old_state)
|
self.apply_state(old_state)
|
||||||
|
self.column_header.blockSignals(False)
|
||||||
|
|
||||||
# Resize all rows to have the correct height
|
# Resize all rows to have the correct height
|
||||||
if self.model().rowCount(QModelIndex()) > 0:
|
if self.model().rowCount(QModelIndex()) > 0:
|
||||||
@ -460,6 +463,15 @@ class BooksView(QTableView): # {{{
|
|||||||
|
|
||||||
self.was_restored = True
|
self.was_restored = True
|
||||||
|
|
||||||
|
def column_resized(self, col, old_size, new_size):
|
||||||
|
# arbitrary: scroll bar + header + some
|
||||||
|
max_width = self.width() - (self.verticalScrollBar().width() +
|
||||||
|
self.verticalHeader().width() + 10)
|
||||||
|
if new_size > max_width:
|
||||||
|
self.column_header.blockSignals(True)
|
||||||
|
self.setColumnWidth(col, max_width)
|
||||||
|
self.column_header.blockSignals(False)
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Initialization/Delegate Setup {{{
|
# Initialization/Delegate Setup {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user