~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/gui2/dialogs/metadata_bulk.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
from calibre.gui2 import qstring_to_unicode
10
10
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
11
11
from calibre.gui2.dialogs.tag_editor import TagEditor
12
 
from calibre.ebooks.metadata import string_to_authors, authors_to_sort_string
 
12
from calibre.ebooks.metadata import string_to_authors, authors_to_sort_string, \
 
13
    authors_to_string
13
14
 
14
15
class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
15
 
    
 
16
 
16
17
    def __init__(self, window, rows, db):
17
18
        QDialog.__init__(self, window)
18
19
        Ui_MetadataBulkDialog.__init__(self)
22
23
        self.write_series = False
23
24
        self.write_rating = False
24
25
        self.changed = False
25
 
        QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync)        
 
26
        QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync)
26
27
        QObject.connect(self.rating, SIGNAL('valueChanged(int)'), self.rating_changed)
27
 
        
28
 
        all_series = self.db.all_series()
29
 
        
30
 
        for i in all_series:
31
 
            id, name = i
32
 
            self.series.addItem(name)
33
 
            
 
28
 
 
29
        self.tags.update_tags_cache(self.db.all_tags())
 
30
        self.remove_tags.update_tags_cache(self.db.all_tags())
 
31
 
 
32
        self.initialize_combos()
 
33
 
34
34
        for f in self.db.all_formats():
35
35
            self.remove_format.addItem(f)
36
 
            
 
36
 
37
37
        self.remove_format.setCurrentIndex(-1)
38
 
            
39
 
        self.series.lineEdit().setText('')
 
38
 
40
39
        QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.series_changed)
41
40
        QObject.connect(self.series, SIGNAL('editTextChanged(QString)'), self.series_changed)
42
41
        QObject.connect(self.tag_editor_button, SIGNAL('clicked()'), self.tag_editor)
 
42
 
43
43
        self.exec_()
44
 
    
 
44
 
 
45
    def initialize_combos(self):
 
46
        self.initalize_authors()
 
47
        self.initialize_series()
 
48
        self.initialize_publisher()
 
49
 
 
50
    def initalize_authors(self):
 
51
        all_authors = self.db.all_authors()
 
52
        all_authors.sort(cmp=lambda x, y : cmp(x[1], y[1]))
 
53
 
 
54
        for i in all_authors:
 
55
            id, name = i
 
56
            name = authors_to_string([name.strip().replace('|', ',') for n in name.split(',')])
 
57
            self.authors.addItem(name)
 
58
        self.authors.setEditText('')
 
59
 
 
60
    def initialize_series(self):
 
61
        all_series = self.db.all_series()
 
62
        all_series.sort(cmp=lambda x, y : cmp(x[1], y[1]))
 
63
 
 
64
        for i in all_series:
 
65
            id, name = i
 
66
            self.series.addItem(name)
 
67
        self.series.setEditText('')
 
68
 
 
69
    def initialize_publisher(self):
 
70
        all_publishers = self.db.all_publishers()
 
71
        all_publishers.sort(cmp=lambda x, y : cmp(x[1], y[1]))
 
72
 
 
73
        for i in all_publishers:
 
74
            id, name = i
 
75
            self.publisher.addItem(name)
 
76
        self.publisher.setEditText('')
 
77
 
45
78
    def tag_editor(self):
46
79
        d = TagEditor(self, self.db, None)
47
80
        d.exec_()
48
81
        if d.result() == QDialog.Accepted:
49
82
            tag_string = ', '.join(d.tags)
50
83
            self.tags.setText(tag_string)
51
 
        
 
84
            self.tags.update_tags_cache(self.db.all_tags())
 
85
            self.remove_tags.update_tags_cache(self.db.all_tags())
 
86
 
52
87
    def sync(self):
53
88
        for id in self.ids:
54
89
            au = qstring_to_unicode(self.authors.text())
80
115
                self.db.set_tags(id, tags, append=True, notify=False)
81
116
            if self.write_series:
82
117
                self.db.set_series(id, qstring_to_unicode(self.series.currentText()), notify=False)
83
 
                
 
118
 
84
119
            if self.remove_format.currentIndex() > -1:
85
120
                self.db.remove_format(id, unicode(self.remove_format.currentText()), index_is_id=True, notify=False)
86
 
                
 
121
 
87
122
            self.changed = True
88
 
    
 
123
 
89
124
    def series_changed(self):
90
125
        self.write_series = True
91
 
        
 
126
 
92
127
    def rating_changed(self):
93
 
        self.write_rating = True
 
 
b'\\ No newline at end of file'
 
128
        self.write_rating = True