mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression that broke column layout saving in the device views
This commit is contained in:
parent
f4b097fad0
commit
f7d5dbaf5f
@ -214,14 +214,17 @@ class BooksView(QTableView): # {{{
|
||||
state['column_sizes'][name] = h.sectionSize(i)
|
||||
return state
|
||||
|
||||
def write_state(self, state):
|
||||
db = getattr(self.model(), 'db', None)
|
||||
name = unicode(self.objectName())
|
||||
if name and db is not None:
|
||||
db.prefs.set(name + ' books view state', state)
|
||||
|
||||
def save_state(self):
|
||||
# Only save if we have been initialized (set_database called)
|
||||
if len(self.column_map) > 0 and self.was_restored:
|
||||
state = self.get_state()
|
||||
db = getattr(self.model(), 'db', None)
|
||||
name = unicode(self.objectName())
|
||||
if name and db is not None:
|
||||
db.prefs.set(name + ' books view state', state)
|
||||
self.write_state(state)
|
||||
|
||||
def cleanup_sort_history(self, sort_history):
|
||||
history = []
|
||||
@ -524,6 +527,19 @@ class DeviceBooksView(BooksView): # {{{
|
||||
self.context_menu.popup(event.globalPos())
|
||||
event.accept()
|
||||
|
||||
def get_old_state(self):
|
||||
ans = None
|
||||
name = unicode(self.objectName())
|
||||
if name:
|
||||
name += ' books view state'
|
||||
ans = gprefs.get(name, None)
|
||||
return ans
|
||||
|
||||
def write_state(self, state):
|
||||
name = unicode(self.objectName())
|
||||
if name:
|
||||
gprefs.set(name + ' books view state', state)
|
||||
|
||||
def set_database(self, db):
|
||||
self._model.set_database(db)
|
||||
self.restore_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user