From 92086fe386df83975583df4a58bd158eaf3f509e Mon Sep 17 00:00:00 2001 From: "beville@gmail.com" Date: Tue, 27 Nov 2012 18:02:08 +0000 Subject: [PATCH] Properly overlay fetched online data git-svn-id: http://comictagger.googlecode.com/svn/trunk@94 6c5673fe-1810-88d6-992b-cd32ca31540c --- genericmetadata.py | 26 +++++++++++++++----------- taggerwindow.py | 10 ++++++++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/genericmetadata.py b/genericmetadata.py index e01a78e..332e6a8 100644 --- a/genericmetadata.py +++ b/genericmetadata.py @@ -144,10 +144,22 @@ class GenericMetadata: assign( "comments", new_md.comments ) assign( "notes", new_md.notes ) + self.overlayCredits( new_md.credits ) # TODO - # not sure if the tags, credits, and pages should broken down, or treated + + # not sure if the tags and pages should broken down, or treated # as whole lists.... - for c in new_md.credits: + + # For now, go the easy route, where any overlay + # value wipes out the whole list + if len(new_md.tags) > 0: + assign( "tags", new_md.tags ) + if len(new_md.pages) > 0: + assign( "pages", new_md.pages ) + + + def overlayCredits( self, new_credits ): + for c in new_credits: if c.has_key('primary') and c['primary']: primary = True else: @@ -158,17 +170,9 @@ class GenericMetadata: for r in reversed(self.credits): if r['role'].lower() == c['role'].lower(): self.credits.remove(r) + # otherwise, add it! else: self.addCredit( c['person'], c['role'], primary ) - - - # For now, go the easy route, where any overlay - # value wipes out the whole list - if len(new_md.tags) > 0: - assign( "tags", new_md.tags ) - if len(new_md.pages) > 0: - assign( "pages", new_md.pages ) - def addCredit( self, person, role, primary = False ): diff --git a/taggerwindow.py b/taggerwindow.py index 693a2df..07231d0 100644 --- a/taggerwindow.py +++ b/taggerwindow.py @@ -756,11 +756,17 @@ class TaggerWindow( QtGui.QMainWindow): #we should now have a volume ID QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) + #copy the form onto metadata object + self.formToMetadata() + comicVine = ComicVineTalker( ) - self.metadata = comicVine.fetchIssueData( selector.volume_id, selector.issue_number ) + new_metadata = comicVine.fetchIssueData( selector.volume_id, selector.issue_number ) - # Now push the right data into the edit controls + self.metadata.overlay( new_metadata ) + + # Now push the new combined data into the edit controls self.metadataToForm() + #!!!ATB should I clear the form??? QtGui.QApplication.restoreOverrideCursor()