Added a button to force recomputation of the author sort field. Useful after changing the tweak.

This commit is contained in:
Charles Haley 2010-08-09 08:49:03 +01:00
parent a191541914
commit 489de50192
2 changed files with 24 additions and 1 deletions

View File

@ -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)

View File

@ -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">