OSDN Git Service

impl fromXml (not tested)
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Mon, 9 Jun 2003 15:30:15 +0000 (15:30 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Mon, 9 Jun 2003 15:30:15 +0000 (15:30 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@337 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/libkita/favoritethreads.cpp

index b682e6f..aecbac0 100644 (file)
@@ -47,6 +47,24 @@ FavoriteThreads* FavoriteThreads::fromXml( const QString& xml )
 {
   FavoriteThreads* instance = FavoriteThreads::getInstance();
 
+  FavoritesXmlParser parser;
+  QXmlSimpleReader reader;
+  QXmlInputSource source;
+  source.setData( xml );
+  reader.setContentHandler( &parser );
+  reader.parse( &source );
+
+  if( parser.isValid() ) {
+    QPtrList<Kita::Thread> threads = parser.getThreads();
+
+    instance->m_threadMap.clear();
+    for( Kita::Thread* thread = threads.first(); thread; thread = threads.next() ) {
+      instance->insert( Kita::Thread( *(thread->getBoard()), thread->datURL(), thread->name(), thread->resNum() ) );
+    }
+  } else {
+    qDebug("inValid");
+  }
+
   return instance;
 }
 
@@ -85,6 +103,7 @@ bool FavoriteThreads::test()
                 "</board>\n"
                 "</thread>\n"
                 "</favorites>\n";
+
   return true;
 }