Add buttons to easily select all/none in the configuration window for the book details popup. Fixes #1786663 [Add option to hide details in the Book details window](https://bugs.launchpad.net/calibre/+bug/1786663)

This commit is contained in:
Kovid Goyal 2019-01-05 09:27:34 +05:30
parent d08e0a33e1
commit 77ccbc4cf6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 0 deletions

View File

@ -55,9 +55,19 @@ class Configure(Dialog):
b = self.bb.addButton(_('Restore &defaults'), self.bb.ActionRole)
b.clicked.connect(self.restore_defaults)
b = self.bb.addButton(_('Select &all'), self.bb.ActionRole)
b.clicked.connect(self.select_all)
b = self.bb.addButton(_('Select &none'), self.bb.ActionRole)
b.clicked.connect(self.select_none)
self.l.addWidget(self.bb)
self.setMinimumHeight(500)
def select_all(self):
self.model.toggle_all(True)
def select_none(self):
self.model.toggle_all(False)
def restore_defaults(self):
self.model.initialize(use_defaults=True)

View File

@ -256,6 +256,12 @@ class DisplayedFields(QAbstractListModel): # {{{
return QIcon(I('column.png'))
return None
def toggle_all(self, show=True):
for i in range(self.rowCount()):
idx = self.index(i)
if idx.isValid():
self.setData(idx, show, Qt.CheckStateRole)
def flags(self, index):
ans = QAbstractListModel.flags(self, index)
return ans | Qt.ItemIsUserCheckable