Sort the entries in the show column menu alphabetically. Fixes #1778155 [[enhancement] would like the "show columns" drop down to be alphabetical](https://bugs.launchpad.net/calibre/+bug/1778155)

This commit is contained in:
Kovid Goyal 2018-06-22 07:37:15 +05:30
parent 7e04aba85e
commit a3d901f74c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -29,6 +29,7 @@ from calibre.gui2 import error_dialog, gprefs, FunctionDispatcher
from calibre.gui2.library import DEFAULT_SORT
from calibre.constants import filesystem_encoding
from calibre import force_unicode
from calibre.utils.icu import primary_sort_key
def restrict_column_width(self, col, old_size, new_size):
@ -449,8 +450,9 @@ class BooksView(QTableView): # {{{
ans.addSeparator()
if hidden_cols:
m = ans.addMenu(_('Show column'))
for hcol, hidx in hidden_cols.iteritems():
hname = unicode(self.model().headerData(hidx, Qt.Horizontal, Qt.DisplayRole) or '')
hcols = [(hcol, unicode(self.model().headerData(hidx, Qt.Horizontal, Qt.DisplayRole) or '')) for hcol, hidx in hidden_cols.iteritems()]
hcols.sort(key=lambda x: primary_sort_key(x[1]))
for hcol, hname in hcols:
m.addAction(hname, partial(handler, action='show', column=hcol))
ans.addSeparator()
ans.addAction(_('Shrink column if it is too wide to fit'),