mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
...
This commit is contained in:
commit
4087d9ab42
@ -50,15 +50,35 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
|
|
||||||
# set up the signal after the table is filled
|
# set up the signal after the table is filled
|
||||||
self.table.cellChanged.connect(self.cell_changed)
|
self.table.cellChanged.connect(self.cell_changed)
|
||||||
|
self.sort_by_author.setCheckable(True)
|
||||||
|
self.sort_by_author.setChecked(False)
|
||||||
|
self.sort_by_author.clicked.connect(self.do_sort_by_author)
|
||||||
|
self.author_order = 1
|
||||||
|
|
||||||
self.table.setSortingEnabled(True)
|
|
||||||
self.table.sortByColumn(1, Qt.AscendingOrder)
|
self.table.sortByColumn(1, Qt.AscendingOrder)
|
||||||
|
self.sort_by_author_sort.clicked.connect(self.do_sort_by_author_sort)
|
||||||
|
self.sort_by_author_sort.setCheckable(True)
|
||||||
|
self.sort_by_author_sort.setChecked(True)
|
||||||
|
self.author_sort_order = 1
|
||||||
|
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
self.table.setCurrentCell(0, 0)
|
self.table.setCurrentCell(0, 0)
|
||||||
|
|
||||||
|
def do_sort_by_author(self):
|
||||||
|
self.author_order = 1 if self.author_order == 0 else 0
|
||||||
|
self.table.sortByColumn(0, self.author_order)
|
||||||
|
self.sort_by_author.setChecked(True)
|
||||||
|
self.sort_by_author_sort.setChecked(False)
|
||||||
|
|
||||||
|
def do_sort_by_author_sort(self):
|
||||||
|
self.author_sort_order = 1 if self.author_sort_order == 0 else 0
|
||||||
|
self.table.sortByColumn(1, self.author_sort_order)
|
||||||
|
self.sort_by_author.setChecked(False)
|
||||||
|
self.sort_by_author_sort.setChecked(True)
|
||||||
|
|
||||||
def accepted(self):
|
def accepted(self):
|
||||||
self.result = []
|
self.result = []
|
||||||
for row in range(0,self.table.rowCount()):
|
for row in range(0,self.table.rowCount()):
|
||||||
@ -79,8 +99,4 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
else:
|
else:
|
||||||
item = self.table.item(row, 1)
|
item = self.table.item(row, 1)
|
||||||
self.table.setCurrentItem(item)
|
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)
|
self.table.scrollToItem(item)
|
||||||
|
@ -34,17 +34,54 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<widget class="QPushButton" name="sort_by_author">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="standardButtons">
|
<string>Sort by author</string>
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="centerButtons">
|
</item>
|
||||||
<bool>true</bool>
|
<item>
|
||||||
</property>
|
<widget class="QPushButton" name="sort_by_author_sort">
|
||||||
</widget>
|
<property name="text">
|
||||||
|
<string>Sort by author sort</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -317,6 +317,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
'title', 'timestamp', 'uuid', 'pubdate'):
|
'title', 'timestamp', 'uuid', 'pubdate'):
|
||||||
setattr(self, prop, functools.partial(get_property,
|
setattr(self, prop, functools.partial(get_property,
|
||||||
loc=self.FIELD_MAP['comments' if prop == 'comment' else prop]))
|
loc=self.FIELD_MAP['comments' if prop == 'comment' else prop]))
|
||||||
|
setattr(self, 'title_sort', functools.partial(get_property,
|
||||||
|
loc=self.FIELD_MAP['sort']))
|
||||||
|
|
||||||
def initialize_database(self):
|
def initialize_database(self):
|
||||||
metadata_sqlite = open(P('metadata_sqlite.sql'), 'rb').read()
|
metadata_sqlite = open(P('metadata_sqlite.sql'), 'rb').read()
|
||||||
@ -494,6 +496,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
mi.timestamp = self.timestamp(idx, index_is_id=index_is_id)
|
mi.timestamp = self.timestamp(idx, index_is_id=index_is_id)
|
||||||
mi.pubdate = self.pubdate(idx, index_is_id=index_is_id)
|
mi.pubdate = self.pubdate(idx, index_is_id=index_is_id)
|
||||||
mi.uuid = self.uuid(idx, index_is_id=index_is_id)
|
mi.uuid = self.uuid(idx, index_is_id=index_is_id)
|
||||||
|
mi.title_sort = self.title_sort(idx, index_is_id=index_is_id)
|
||||||
tags = self.tags(idx, index_is_id=index_is_id)
|
tags = self.tags(idx, index_is_id=index_is_id)
|
||||||
if tags:
|
if tags:
|
||||||
mi.tags = [i.strip() for i in tags.split(',')]
|
mi.tags = [i.strip() for i in tags.split(',')]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user