mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix text alignment in device views and only save valid states
This commit is contained in:
parent
7c65e0e63a
commit
7491a8d20e
@ -1011,6 +1011,12 @@ class DeviceBooksModel(BooksModel): # {{{
|
|||||||
elif role == Qt.DecorationRole and cname == 'inlibrary':
|
elif role == Qt.DecorationRole and cname == 'inlibrary':
|
||||||
if self.db[self.map[row]].in_library:
|
if self.db[self.map[row]].in_library:
|
||||||
return QVariant(self.bool_yes_icon)
|
return QVariant(self.bool_yes_icon)
|
||||||
|
elif role == Qt.TextAlignmentRole:
|
||||||
|
cname = self.column_map[index.column()]
|
||||||
|
ans = Qt.AlignVCenter | ALIGNMENT_MAP[self.alignment_map.get(cname,
|
||||||
|
'left')]
|
||||||
|
return QVariant(ans)
|
||||||
|
|
||||||
|
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ class BooksView(QTableView): # {{{
|
|||||||
self.selectionModel().currentRowChanged.connect(self._model.current_changed)
|
self.selectionModel().currentRowChanged.connect(self._model.current_changed)
|
||||||
|
|
||||||
# {{{ Column Header setup
|
# {{{ Column Header setup
|
||||||
|
self.was_restored = False
|
||||||
self.column_header = self.horizontalHeader()
|
self.column_header = self.horizontalHeader()
|
||||||
self.column_header.setMovable(True)
|
self.column_header.setMovable(True)
|
||||||
self.column_header.sectionMoved.connect(self.save_state)
|
self.column_header.sectionMoved.connect(self.save_state)
|
||||||
@ -198,7 +199,7 @@ class BooksView(QTableView): # {{{
|
|||||||
|
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
# Only save if we have been initialized (set_database called)
|
# Only save if we have been initialized (set_database called)
|
||||||
if len(self.column_map) > 0:
|
if len(self.column_map) > 0 and self.was_restored:
|
||||||
state = self.get_state()
|
state = self.get_state()
|
||||||
name = unicode(self.objectName())
|
name = unicode(self.objectName())
|
||||||
if name:
|
if name:
|
||||||
@ -287,6 +288,7 @@ class BooksView(QTableView): # {{{
|
|||||||
old_state['sort_history'] = tweaks['sort_columns_at_startup']
|
old_state['sort_history'] = tweaks['sort_columns_at_startup']
|
||||||
|
|
||||||
self.apply_state(old_state)
|
self.apply_state(old_state)
|
||||||
|
self.was_restored = True
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user