mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Small cleanups after testing
This commit is contained in:
parent
f4854022a0
commit
36f6e67022
@ -23,7 +23,6 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.buttonBox.accepted.connect(self.accepted)
|
self.buttonBox.accepted.connect(self.accepted)
|
||||||
self.table.cellChanged.connect(self.cell_changed)
|
|
||||||
|
|
||||||
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
|
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
|
||||||
self.table.setColumnCount(2)
|
self.table.setColumnCount(2)
|
||||||
@ -43,13 +42,18 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
self.table.setItem(row, 1, sort)
|
self.table.setItem(row, 1, sort)
|
||||||
if id == id_to_select:
|
if id == id_to_select:
|
||||||
select_item = sort
|
select_item = sort
|
||||||
|
self.table.resizeColumnsToContents()
|
||||||
|
|
||||||
|
# set up the signal after the table is filled
|
||||||
|
self.table.cellChanged.connect(self.cell_changed)
|
||||||
|
|
||||||
|
self.table.setSortingEnabled(True)
|
||||||
|
self.table.sortByColumn(1, Qt.AscendingOrder)
|
||||||
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)
|
||||||
self.table.resizeColumnsToContents()
|
else:
|
||||||
self.table.setSortingEnabled(True)
|
self.table.setCurrentCell(0, 0)
|
||||||
self.table.sortByColumn(1, Qt.AscendingOrder)
|
|
||||||
|
|
||||||
def accepted(self):
|
def accepted(self):
|
||||||
self.result = []
|
self.result = []
|
||||||
@ -63,8 +67,16 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
|
|
||||||
def cell_changed(self, row, col):
|
def cell_changed(self, row, col):
|
||||||
if col == 0:
|
if col == 0:
|
||||||
aut = unicode(self.table.item(row, 0).text())
|
item = self.table.item(row, 0)
|
||||||
|
aut = unicode(item.text())
|
||||||
c = self.table.item(row, 1)
|
c = self.table.item(row, 1)
|
||||||
if c is not None:
|
c.setText(author_to_author_sort(aut))
|
||||||
c.setText(author_to_author_sort(aut))
|
item = c
|
||||||
self.table.setCurrentItem(c)
|
else:
|
||||||
|
item = self.table.item(row, 1)
|
||||||
|
self.table.setCurrentItem(item)
|
||||||
|
# disable and reenable sorting to force the sort now, so we can scroll
|
||||||
|
# to the item after it moves
|
||||||
|
self.table.setSortingEnabled(False)
|
||||||
|
self.table.setSortingEnabled(True)
|
||||||
|
self.table.scrollToItem(item)
|
||||||
|
@ -938,8 +938,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
def author_sort_from_authors(self, authors):
|
def author_sort_from_authors(self, authors):
|
||||||
result = []
|
result = []
|
||||||
for aut in authors:
|
for aut in authors:
|
||||||
aut = aut.replace(',', '|')
|
r = self.conn.get('SELECT sort FROM authors WHERE name=?',
|
||||||
r = self.conn.get('SELECT sort FROM authors WHERE name=?', (aut,), all=False)
|
(aut.replace(',', '|'),), all=False)
|
||||||
if r is None:
|
if r is None:
|
||||||
result.append(author_to_author_sort(aut))
|
result.append(author_to_author_sort(aut))
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user