mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
d08e0a33e1
commit
77ccbc4cf6
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user