~ubuntu-branches/debian/experimental/calibre/experimental

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-02-12 16:45:34 UTC
  • mfrom: (1.3.38)
  • Revision ID: package-import@ubuntu.com-20130212164534-4tue9c37ui3lgdsl
Tags: 0.9.18+dfsg-1
* New upstream release. (Closes: #699700)
* Unfuzz patches.
* Add new libqt4-private-dev build dependency, required by this version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
class AddEmptyBookDialog(QDialog):
14
14
 
15
 
    def __init__(self, parent, db, author):
 
15
    def __init__(self, parent, db, author, series=None):
16
16
        QDialog.__init__(self, parent)
17
17
        self.db = db
18
18
 
45
45
        self.clear_button.clicked.connect(self.reset_author)
46
46
        self._layout.addWidget(self.clear_button, 3, 1, 1, 1)
47
47
 
 
48
        self.series_label = QLabel(_('Set the series of the new books to:'))
 
49
        self._layout.addWidget(self.series_label, 4, 0, 1, 2)
 
50
 
 
51
        self.series_combo = EditWithComplete(self)
 
52
        self.authors_combo.setSizeAdjustPolicy(
 
53
                self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
 
54
        self.series_combo.setEditable(True)
 
55
        self._layout.addWidget(self.series_combo, 5, 0, 1, 1)
 
56
        self.initialize_series(db, series)
 
57
 
 
58
        self.sclear_button = QToolButton(self)
 
59
        self.sclear_button.setIcon(QIcon(I('trash.png')))
 
60
        self.sclear_button.setToolTip(_('Reset series'))
 
61
        self.sclear_button.clicked.connect(self.reset_series)
 
62
        self._layout.addWidget(self.sclear_button, 5, 1, 1, 1)
 
63
 
48
64
        button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
49
65
        button_box.accepted.connect(self.accept)
50
66
        button_box.rejected.connect(self.reject)
54
70
    def reset_author(self, *args):
55
71
        self.authors_combo.setEditText(_('Unknown'))
56
72
 
 
73
    def reset_series(self):
 
74
        self.series_combo.setEditText('')
 
75
 
57
76
    def initialize_authors(self, db, author):
58
77
        au = author
59
78
        if not au:
65
84
        self.authors_combo.set_add_separator(tweaks['authors_completer_append_separator'])
66
85
        self.authors_combo.update_items_cache(db.all_author_names())
67
86
 
 
87
    def initialize_series(self, db, series):
 
88
        self.series_combo.show_initial_value(series or '')
 
89
        self.series_combo.update_items_cache(db.all_series_names())
 
90
        self.series_combo.set_separator(None)
 
91
 
68
92
    @property
69
93
    def qty_to_add(self):
70
94
        return self.qty_spinbox.value()
73
97
    def selected_authors(self):
74
98
        return string_to_authors(unicode(self.authors_combo.text()))
75
99
 
 
100
    @property
 
101
    def selected_series(self):
 
102
        return unicode(self.series_combo.text())
 
103
 
76
104
if __name__ == '__main__':
77
105
    app = QApplication([])
78
106
    d = AddEmptyBookDialog()