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

List:       kde-commits
Subject:    playground/pim/krss/resource
From:       Dmitry Ivanov <vonami () gmail ! com>
Date:       2008-05-06 22:02:54
Message-ID: 1210111374.692871.6660.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 804782 by divanov:

Keep all the collections as we have to save them to
an OPML document upon quit


 M  +16 -15    rssresource.cpp  
 M  +6 -4      rssresource.h  


--- trunk/playground/pim/krss/resource/rssresource.cpp #804781:804782
@@ -78,11 +78,10 @@
         QStringList mimeTypes;
         mimeTypes << Collection::mimeType();
         root.setContentMimeTypes(mimeTypes);
+        m_collections[ root.remoteId() ] = root;
 
-        Collection::List list;
-        list << root;
-        loadOpml(m_path, root, list);
-        collectionsRetrieved(list);
+        loadOpml(root);
+        collectionsRetrieved(m_collections.values());
 }
 
 void RssResource::retrieveItems(const Akonadi::Collection &col)
@@ -213,9 +212,9 @@
                 return kfeedItem;
 }
 
-bool RssResource::loadOpml(const QString &path, const Collection &parent, \
Collection::List &list) +bool RssResource::loadOpml(const Collection &parent)
 {
-        QFile file(path);
+        QFile file(m_path);
         if ( !file.open(QFile::ReadOnly | QFile::Text) ) {
                 kWarning() << "Couldn't open the OPML document";
                 return false;
@@ -228,7 +227,7 @@
 
                 if ( m_reader.isStartElement() ) {
                         if ( m_reader.name() == "opml" && \
                m_reader.attributes().value("version") == "1.0")
-                                readOpml(parent, list);
+                                readOpml(parent);
                         else
                                 m_reader.raiseError("The file is not an OPML version \
1.0 document.");  }
@@ -252,7 +251,7 @@
         }
 }
 
-void RssResource::readOpml(const Collection &parent, Collection::List &list)
+void RssResource::readOpml(const Collection &parent)
 {
         Q_ASSERT(m_reader.isStartElement() && m_reader.name() == "opml");
 
@@ -266,14 +265,14 @@
                         if ( m_reader.name() == "head" )
                                 readUnknownElement();
                         else if ( m_reader.name() == "body")
-                                readBody(parent, list);
+                                readBody(parent);
                         else
                                 readUnknownElement();
                 }
         }
 }
 
-void RssResource::readBody(const Collection &parent, Collection::List &list)
+void RssResource::readBody(const Collection &parent)
 {
         Q_ASSERT(m_reader.isStartElement() && m_reader.name() == "body");
 
@@ -285,14 +284,14 @@
 
                 if ( m_reader.isStartElement() ) {
                         if ( m_reader.name() == "outline" )
-                                readOutline(parent, list);
+                                readOutline(parent);
                         else
                                 readUnknownElement();
                 }
         }
 }
 
-void RssResource::readOutline(const Collection &parent, Collection::List &list)
+void RssResource::readOutline(const Collection &parent)
 {
         Q_ASSERT(m_reader.isStartElement() && m_reader.name() == "outline");
 
@@ -303,7 +302,8 @@
                 col.setRemoteId(m_reader.attributes().value("id").toString());
                 col.setParent(parent);
                 col.setContentMimeTypes(QStringList(Collection::mimeType()));
-                list << col;
+                m_collections[ col.remoteId() ] = col;
+                m_childCollections[ parent.remoteId() ].append( col.remoteId() );
         } else {
                 kDebug() << "Feed:" << \
                m_reader.attributes().value("text").toString();
                 col.setName(m_reader.attributes().value("text").toString());
@@ -314,7 +314,8 @@
                 col.addAttribute(new \
VersionCollectionAttribute(m_reader.attributes().value("version").toString()));  \
                col.setParent(parent);
                 col.setContentMimeTypes(QStringList("application/rss+xml"));
-                list << col;
+                m_collections[ col.remoteId() ] = col;
+                m_childCollections[ parent.remoteId() ].append( col.remoteId() );
         }
 
         while ( !m_reader.atEnd() ) {
@@ -326,7 +327,7 @@
                 if ( m_reader.isStartElement() ) {
                         if ( m_reader.name() == "outline" ) {
                                 \
                Q_ASSERT(col.contentMimeTypes().contains(Collection::mimeType()));
-                                readOutline(col, list);
+                                readOutline(col);
                         }
                         else
                                 readUnknownElement();
--- trunk/playground/pim/krss/resource/rssresource.h #804781:804782
@@ -49,15 +49,17 @@
 private:
 
         KFeed::Item convertToKFeedItem(const Syndication::ItemPtr syndItem);
-        bool loadOpml(const QString &path, const Akonadi::Collection &parent, \
Akonadi::Collection::List &list); +        bool loadOpml(const Akonadi::Collection \
&parent);  void readUnknownElement();
-        void readOpml(const Akonadi::Collection &parent, Akonadi::Collection::List \
                &list);
-        void readBody(const Akonadi::Collection &parent, Akonadi::Collection::List \
                &list);
-        void readOutline(const Akonadi::Collection &parent, \
Akonadi::Collection::List &list); +        void readOpml(const Akonadi::Collection \
&parent); +        void readBody(const Akonadi::Collection &parent);
+        void readOutline(const Akonadi::Collection &parent);
 
 private:
 
         QString m_path;
+        QHash<QString, Akonadi::Collection> m_collections;
+        QHash<QString, QList<QString> > m_childCollections;
         QXmlStreamReader m_reader;
 };
 


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

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