[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/pim/krss/resources/libkrssresource
From:       Dmitry Ivanov <vonami () gmail ! com>
Date:       2009-03-21 19:18:39
Message-ID: 1237663119.075215.6768.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 942458 by divanov:

Sync the flags too


 M  +23 -1     rssitemsync.cpp  


--- trunk/playground/pim/krss/resources/libkrssresource/rssitemsync.cpp #942457:942458
@@ -46,7 +46,7 @@
     const int storedHash = storedItem.payload<KRss::RssItem>().hash();
 
     if ( !newRssItem.guidIsHash() && storedHash != newHash ) {
-        kDebug() << "The article has been updated:" << newItem.remoteId();
+        kDebug() << "The article's content is updated:" << newItem.remoteId();
         // dont overwrite the existing flags
         // and set 'New' + 'Unread'
         newItem.setFlags( storedItem.flags() );
@@ -55,5 +55,27 @@
         return true;
     }
 
+    const bool lostUnreadFlag = storedItem.hasFlag( KRss::Item::flagUnread() ) &&
+                               !newItem.hasFlag( KRss::Item::flagUnread() );
+    const bool gotUnreadFlag = !storedItem.hasFlag( KRss::Item::flagUnread() ) &&
+                                newItem.hasFlag( KRss::Item::flagUnread() );
+
+    const bool lostImportantFlag = storedItem.hasFlag( KRss::Item::flagImportant() ) &&
+                                   !newItem.hasFlag( KRss::Item::flagImportant() );
+    const bool gotImportantFlag = !storedItem.hasFlag( KRss::Item::flagImportant() ) &&
+                                  newItem.hasFlag( KRss::Item::flagImportant() );
+
+    // either 'Unread' or 'Important' was changed in the backend
+    // push the item to Akonadi clearing 'New'
+    if ( lostUnreadFlag || gotUnreadFlag || lostImportantFlag || gotImportantFlag ) {
+        kDebug() << "The article's flags are updated:" << newItem.remoteId();
+        // We need to explicitely overwrite the item's flags
+        // otherwise Akonadi::ItemModifyJob just ignores them,
+        // see Akonadi::ItemModifyJob::doStart()
+        newItem.setFlags( newItem.flags() );
+        newItem.clearFlag( KRss::Item::flagNew() );
+        return true;
+    }
+
     return false;
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic