mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Implement bug #2754: Authors drop down list in edit metadata.
This commit is contained in:
parent
03fe8b6261
commit
8c265f4bea
@ -265,12 +265,6 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
if not isbn:
|
if not isbn:
|
||||||
isbn = ''
|
isbn = ''
|
||||||
self.isbn.setText(isbn)
|
self.isbn.setText(isbn)
|
||||||
au = self.db.authors(row)
|
|
||||||
if au:
|
|
||||||
au = [a.strip().replace('|', ',') for a in au.split(',')]
|
|
||||||
self.authors.setText(authors_to_string(au))
|
|
||||||
else:
|
|
||||||
self.authors.setText('')
|
|
||||||
aus = self.db.author_sort(row)
|
aus = self.db.author_sort(row)
|
||||||
self.author_sort.setText(aus if aus else '')
|
self.author_sort.setText(aus if aus else '')
|
||||||
tags = self.db.tags(row)
|
tags = self.db.tags(row)
|
||||||
@ -295,7 +289,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
Format(self.formats, ext, size)
|
Format(self.formats, ext, size)
|
||||||
|
|
||||||
|
|
||||||
self.initialize_series_and_publisher()
|
self.initialize_combos()
|
||||||
|
|
||||||
self.series_index.setValue(self.db.series_index(row))
|
self.series_index.setValue(self.db.series_index(row))
|
||||||
QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.enable_series_index)
|
QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.enable_series_index)
|
||||||
@ -331,6 +325,30 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
def cover_dropped(self):
|
def cover_dropped(self):
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
|
|
||||||
|
def initialize_combos(self):
|
||||||
|
self.initalize_authors()
|
||||||
|
self.initialize_series()
|
||||||
|
self.initialize_publisher()
|
||||||
|
|
||||||
|
self.layout().activate()
|
||||||
|
|
||||||
|
def initalize_authors(self):
|
||||||
|
all_authors = self.db.all_authors()
|
||||||
|
all_authors.sort(cmp=lambda x, y : cmp(x[1], y[1]))
|
||||||
|
author_id = self.db.author_id(self.row)
|
||||||
|
idx, c = None, 0
|
||||||
|
for i in all_authors:
|
||||||
|
id, name = i
|
||||||
|
if id == author_id:
|
||||||
|
idx = c
|
||||||
|
name = [name.strip().replace('|', ',') for n in name.split(',')]
|
||||||
|
self.authors.addItem(authors_to_string(name))
|
||||||
|
c += 1
|
||||||
|
|
||||||
|
self.authors.setEditText('')
|
||||||
|
if idx is not None:
|
||||||
|
self.authors.setCurrentIndex(idx)
|
||||||
|
|
||||||
def initialize_series(self):
|
def initialize_series(self):
|
||||||
self.series.setSizeAdjustPolicy(self.series.AdjustToContentsOnFirstShow)
|
self.series.setSizeAdjustPolicy(self.series.AdjustToContentsOnFirstShow)
|
||||||
all_series = self.db.all_series()
|
all_series = self.db.all_series()
|
||||||
@ -349,8 +367,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.series.setCurrentIndex(idx)
|
self.series.setCurrentIndex(idx)
|
||||||
self.enable_series_index()
|
self.enable_series_index()
|
||||||
|
|
||||||
def initialize_series_and_publisher(self):
|
def initialize_publisher(self):
|
||||||
self.initialize_series()
|
|
||||||
all_publishers = self.db.all_publishers()
|
all_publishers = self.db.all_publishers()
|
||||||
all_publishers.sort(cmp=lambda x, y : cmp(x[1], y[1]))
|
all_publishers.sort(cmp=lambda x, y : cmp(x[1], y[1]))
|
||||||
publisher_id = self.db.publisher_id(self.row)
|
publisher_id = self.db.publisher_id(self.row)
|
||||||
@ -366,9 +383,6 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
if idx is not None:
|
if idx is not None:
|
||||||
self.publisher.setCurrentIndex(idx)
|
self.publisher.setCurrentIndex(idx)
|
||||||
|
|
||||||
|
|
||||||
self.layout().activate()
|
|
||||||
|
|
||||||
def edit_tags(self):
|
def edit_tags(self):
|
||||||
d = TagEditor(self, self.db, self.row)
|
d = TagEditor(self, self.db, self.row)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
@ -121,9 +121,6 @@
|
|||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
|
||||||
<cstring>authors</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
@ -345,9 +342,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="EnLineEdit" name="authors"/>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="series_index">
|
<widget class="QDoubleSpinBox" name="series_index">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -371,6 +365,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="EnComboBox" name="authors">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -655,7 +656,6 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>title</tabstop>
|
<tabstop>title</tabstop>
|
||||||
<tabstop>swap_button</tabstop>
|
<tabstop>swap_button</tabstop>
|
||||||
<tabstop>authors</tabstop>
|
|
||||||
<tabstop>author_sort</tabstop>
|
<tabstop>author_sort</tabstop>
|
||||||
<tabstop>auto_author_sort</tabstop>
|
<tabstop>auto_author_sort</tabstop>
|
||||||
<tabstop>rating</tabstop>
|
<tabstop>rating</tabstop>
|
||||||
|
@ -493,6 +493,8 @@ class EnComboBox(QComboBox):
|
|||||||
QComboBox.__init__(self, *args)
|
QComboBox.__init__(self, *args)
|
||||||
self.setLineEdit(EnLineEdit(self))
|
self.setLineEdit(EnLineEdit(self))
|
||||||
|
|
||||||
|
def text(self):
|
||||||
|
return qstring_to_unicode(self.currentText())
|
||||||
|
|
||||||
class PythonHighlighter(QSyntaxHighlighter):
|
class PythonHighlighter(QSyntaxHighlighter):
|
||||||
|
|
||||||
|
@ -928,6 +928,10 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def author_id(self, index, index_is_id=False):
|
||||||
|
id = index if index_is_id else self.id(index)
|
||||||
|
return self.conn.get('SELECT author from books_authors_link WHERE book=?', (id,), all=False)
|
||||||
|
|
||||||
def isbn(self, idx, index_is_id=False):
|
def isbn(self, idx, index_is_id=False):
|
||||||
id = idx if index_is_id else self.id(idx)
|
id = idx if index_is_id else self.id(idx)
|
||||||
return self.conn.get('SELECT isbn FROM books WHERE id=?',(id,), all=False)
|
return self.conn.get('SELECT isbn FROM books WHERE id=?',(id,), all=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user