mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-05 08:40:13 -04:00
Added a button to force recomputation of the author sort field. Useful after changing the tweak.
This commit is contained in:
parent
a191541914
commit
489de50192
@ -48,8 +48,10 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
||||
select_item = sort
|
||||
self.table.resizeColumnsToContents()
|
||||
|
||||
# set up the signal after the table is filled
|
||||
# set up the cellChanged signal only after the table is filled
|
||||
self.table.cellChanged.connect(self.cell_changed)
|
||||
|
||||
# set up sort buttons
|
||||
self.sort_by_author.setCheckable(True)
|
||||
self.sort_by_author.setChecked(False)
|
||||
self.sort_by_author.clicked.connect(self.do_sort_by_author)
|
||||
@ -61,6 +63,9 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
||||
self.sort_by_author_sort.setChecked(True)
|
||||
self.author_sort_order = 1
|
||||
|
||||
# set up author sort calc button
|
||||
self.recalc_author_sort.clicked.connect(self.do_recalc_author_sort)
|
||||
|
||||
if select_item is not None:
|
||||
self.table.setCurrentItem(select_item)
|
||||
self.table.editItem(select_item)
|
||||
@ -89,6 +94,17 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
||||
if orig_aut != aut or orig_sort != sort:
|
||||
self.result.append((id, orig_aut, aut, sort))
|
||||
|
||||
def do_recalc_author_sort(self):
|
||||
self.table.cellChanged.disconnect()
|
||||
for row in range(0,self.table.rowCount()):
|
||||
item = self.table.item(row, 0)
|
||||
aut = unicode(item.text()).strip()
|
||||
c = self.table.item(row, 1)
|
||||
# Sometimes trailing commas are left by changing between copy algs
|
||||
c.setText(author_to_author_sort(aut).rstrip(','))
|
||||
self.table.setFocus(Qt.OtherFocusReason)
|
||||
self.table.cellChanged.connect(self.cell_changed)
|
||||
|
||||
def cell_changed(self, row, col):
|
||||
if col == 0:
|
||||
item = self.table.item(row, 0)
|
||||
|
@ -49,6 +49,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="recalc_author_sort">
|
||||
<property name="text">
|
||||
<string>Recalculate all author sort values</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
|
Loading…
x
Reference in New Issue
Block a user