~lifanxi/calibre/calibre-experimental

« back to all changes in this revision

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

  • Committer: Li Fanxi
  • Date: 2010-06-30 07:55:57 UTC
  • mfrom: (5545.1.99 trunk)
  • Revision ID: lifanxi@nj-byron-li-nb-20100630075557-4wyiif1qg2uitlr9
Merge changes from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from calibre.gui2.widgets import IMAGE_EXTENSIONS
22
22
from calibre.gui2.dialogs.metadata_single import MetadataSingleDialog
23
23
from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog
 
24
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
24
25
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook, \
25
26
    fetch_scheduled_recipe, generate_catalog
26
27
from calibre.constants import preferred_encoding, filesystem_encoding, \
176
177
 
177
178
            def mark_book_as_read(self,id):
178
179
                read_tag = gprefs.get('catalog_epub_mobi_read_tag')
179
 
                self.db.set_tags(id, [read_tag], append=True)
 
180
                if read_tag:
 
181
                    self.db.set_tags(id, [read_tag], append=True)
180
182
 
181
183
            def canceled(self):
182
184
                self.pd.hide()
830
832
        db.set_metadata(dest_id, dest_mi, ignore_errors=False)
831
833
        # }}}
832
834
 
 
835
    def edit_device_collections(self, view, oncard=None):
 
836
        model = view.model()
 
837
        result = model.get_collections_with_ids()
 
838
        compare = (lambda x,y:cmp(x.lower(), y.lower()))
 
839
        d = TagListEditor(self, tag_to_match=None, data=result, compare=compare)
 
840
        d.exec_()
 
841
        if d.result() == d.Accepted:
 
842
            to_rename = d.to_rename # dict of new text to old ids
 
843
            to_delete = d.to_delete # list of ids
 
844
            for text in to_rename:
 
845
                for old_id in to_rename[text]:
 
846
                    model.rename_collection(old_id, new_name=unicode(text))
 
847
            for item in to_delete:
 
848
                model.delete_collection_using_id(item)
 
849
            self.upload_collections(model.db, view=view, oncard=oncard)
 
850
            view.reset()
 
851
 
833
852
    # }}}
834
853
 
835
854
class SaveToDiskAction(object): # {{{