~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/gui2/actions/copy_to_library.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
Import upstream version 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
from collections import defaultdict
13
13
 
14
14
from PyQt4.Qt import (
15
 
    QToolButton, QDialog, QGridLayout, QIcon, QLabel, QDialogButtonBox,
 
15
    QToolButton, QDialog, QGridLayout, QIcon, QLabel, QDialogButtonBox, QApplication,
16
16
    QFormLayout, QCheckBox, QWidget, QScrollArea, QVBoxLayout, Qt, QListWidgetItem, QListWidget)
17
17
 
18
18
from calibre.gui2.actions import InterfaceAction
281
281
        bb.accepted.connect(self.accept)
282
282
        bb.rejected.connect(self.reject)
283
283
        self.a = b = bb.addButton(_('Select &all'), bb.ActionRole)
284
 
        b.clicked.connect(self.select_all)
 
284
        b.clicked.connect(self.select_all), b.setIcon(QIcon(I('plus.png')))
285
285
        self.n = b = bb.addButton(_('Select &none'), bb.ActionRole)
286
 
        b.clicked.connect(self.select_none)
 
286
        b.clicked.connect(self.select_none), b.setIcon(QIcon(I('minus.png')))
 
287
        self.ctc = b = bb.addButton(_('&Copy to clipboard'), bb.ActionRole)
 
288
        b.clicked.connect(self.copy_to_clipboard), b.setIcon(QIcon(I('edit-copy.png')))
287
289
        l.addWidget(bb)
288
290
        self.resize(600, 400)
289
291
 
 
292
    def copy_to_clipboard(self):
 
293
        items = [('✓' if item.checkState() == Qt.Checked else '✗') + ' ' + unicode(item.text())
 
294
                 for item in self.items]
 
295
        QApplication.clipboard().setText('\n'.join(items))
 
296
 
290
297
    def select_all(self):
291
298
        for i in self.items:
292
299
            i.setCheckState(Qt.Checked)