mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
15ded1182f
@ -725,7 +725,9 @@ class BooksView(QTableView): # {{{
|
|||||||
saved_history)[:max_sort_levels]):
|
saved_history)[:max_sort_levels]):
|
||||||
self.sort_by_column_and_order(self.column_map.index(col), order)
|
self.sort_by_column_and_order(self.column_map.index(col), order)
|
||||||
|
|
||||||
def apply_state(self, state, max_sort_levels=3):
|
def apply_state(self, state, max_sort_levels=3, save_state=True):
|
||||||
|
# set save_state=False if you will save the state yourself after calling
|
||||||
|
# this method.
|
||||||
h = self.column_header
|
h = self.column_header
|
||||||
cmap = {}
|
cmap = {}
|
||||||
hidden = state.get('hidden_columns', [])
|
hidden = state.get('hidden_columns', [])
|
||||||
@ -739,13 +741,18 @@ class BooksView(QTableView): # {{{
|
|||||||
for col, pos in positions.items():
|
for col, pos in positions.items():
|
||||||
if col in cmap:
|
if col in cmap:
|
||||||
pmap[pos] = col
|
pmap[pos] = col
|
||||||
|
need_save_state = False
|
||||||
|
self.column_header.blockSignals(True)
|
||||||
for pos in sorted(pmap.keys()):
|
for pos in sorted(pmap.keys()):
|
||||||
col = pmap[pos]
|
col = pmap[pos]
|
||||||
idx = cmap[col]
|
idx = cmap[col]
|
||||||
current_pos = h.visualIndex(idx)
|
current_pos = h.visualIndex(idx)
|
||||||
if current_pos != pos:
|
if current_pos != pos:
|
||||||
|
need_save_state = True
|
||||||
h.moveSection(current_pos, pos)
|
h.moveSection(current_pos, pos)
|
||||||
|
self.column_header.blockSignals(False)
|
||||||
|
if need_save_state and save_state:
|
||||||
|
self.save_state()
|
||||||
# Because of a bug in Qt 5 we have to ensure that the header is actually
|
# Because of a bug in Qt 5 we have to ensure that the header is actually
|
||||||
# relaid out by changing this value, without this sometimes ghost
|
# relaid out by changing this value, without this sometimes ghost
|
||||||
# columns remain visible when changing libraries
|
# columns remain visible when changing libraries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user