Add button to manage authors dialog to automatically reset all author sort values

This commit is contained in:
Kovid Goyal 2010-08-09 08:06:40 -06:00
commit 1f82492007
2 changed files with 28 additions and 2 deletions

View File

@ -48,8 +48,10 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
select_item = sort select_item = sort
self.table.resizeColumnsToContents() 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) self.table.cellChanged.connect(self.cell_changed)
# set up sort buttons
self.sort_by_author.setCheckable(True) self.sort_by_author.setCheckable(True)
self.sort_by_author.setChecked(False) self.sort_by_author.setChecked(False)
self.sort_by_author.clicked.connect(self.do_sort_by_author) 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.sort_by_author_sort.setChecked(True)
self.author_sort_order = 1 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: if select_item is not None:
self.table.setCurrentItem(select_item) self.table.setCurrentItem(select_item)
self.table.editItem(select_item) self.table.editItem(select_item)
@ -89,6 +94,17 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
if orig_aut != aut or orig_sort != sort: if orig_aut != aut or orig_sort != sort:
self.result.append((id, orig_aut, aut, 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): def cell_changed(self, row, col):
if col == 0: if col == 0:
item = self.table.item(row, 0) item = self.table.item(row, 0)

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>730</width> <width>768</width>
<height>342</height> <height>342</height>
</rect> </rect>
</property> </property>
@ -49,6 +49,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="recalc_author_sort">
<property name="toolTip">
<string>Reset all the author sort values to a value automatically generated from the author. Exactly how this value is automatically generated can be controlled via Preferences-&gt;Advanced-&gt;Tweaks</string>
</property>
<property name="text">
<string>Recalculate all author sort values</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
<property name="orientation"> <property name="orientation">