OSDN Git Service

add FavoriteThreads::threadList()
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 20 Mar 2004 11:06:06 +0000 (11:06 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 20 Mar 2004 11:06:06 +0000 (11:06 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@923 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/libkita/favoritethreads.cpp
kita/src/libkita/favoritethreads.h
kita/src/libkita/tests/favoritethreadstest.cpp

index 9596090..65a22db 100644 (file)
@@ -57,6 +57,19 @@ bool FavoriteThreads::contains( const QString& datURL ) const
     }
 }
 
+const QValueList<QString> FavoriteThreads::threadList() const
+{
+    QValueList<QString> list;
+    
+    QDictIterator<Kita::Thread> it( m_threadDict );
+    for ( ; it.current(); ++it ) {
+        const Kita::Thread* thread = it.current();
+        list.append( thread->datURL() );
+    }
+    
+    return list;
+}
+
 bool FavoriteThreads::readFromXML( const QString& xml )
 {
     FavoriteThreads * instance = FavoriteThreads::getInstance();
index 3f1fc9c..5c67e88 100644 (file)
@@ -36,6 +36,7 @@ public:
   void remove( const QString& datURL );
   bool contains( const QString& datURL ) const;
   const QDict<Kita::Thread>& threads() const { return m_threadDict; };
+  const QValueList<QString> threadList() const;
   const QString toXML() const;
   static bool readFromXML( const QString& xml );
   static void processThreadNode( QDomNode& node );
index 4759e8e..737751a 100644 (file)
@@ -60,25 +60,26 @@ void FavoriteThreadsTest::testToXML()
 void FavoriteThreadsTest::testThreads()
 {
     const QDict<Kita::Thread> threads = FavoriteThreads::getInstance() ->threads();
-    CPPUNIT_ASSERT_EQUAL( ( uint ) 3, threads.count() );
+    const QValueList<QString> threadList = FavoriteThreads::getInstance() ->threadList();
+    CPPUNIT_ASSERT_EQUAL( ( uint ) 3, threadList.count() );
 
-    Kita::Thread* thread1 = threads[ "http://pc.2ch.net/unix/dat/956134538.dat" ];
+    Kita::Thread* thread1 = Kita::Thread::getByURL( threadList[ 0 ] );
     CPPUNIT_ASSERT_EQUAL( QString( "NeXT" ), thread1->name() );
     CPPUNIT_ASSERT_EQUAL( 10, thread1->resNum() );
     CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/unix/" ), thread1->boardURL() );
     CPPUNIT_ASSERT_EQUAL( QString( "Unix" ), thread1->boardName() );
     CPPUNIT_ASSERT_EQUAL( QString( "unix" ), thread1->boardID() );
 
-    Kita::Thread* thread2 = threads[ "http://pc.2ch.net/linux/dat/1022744633.dat" ];
-    CPPUNIT_ASSERT_EQUAL( QString( "2ch browser thread" ), thread2->name() );
-    CPPUNIT_ASSERT_EQUAL( 20, thread2->resNum() );
+    Kita::Thread* thread2 = Kita::Thread::getByURL( threadList[ 1 ] );
+    CPPUNIT_ASSERT_EQUAL( QString( "&lt;test&gt; &amp;" ), thread2->name() );
+    CPPUNIT_ASSERT_EQUAL( 30, thread2->resNum() );
     CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/" ), thread2->boardURL() );
     CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), thread2->boardName() );
     CPPUNIT_ASSERT_EQUAL( QString( "linux" ), thread2->boardID() );
-
-    Kita::Thread* thread3 = threads[ "http://pc.2ch.net/linux/dat/1234567890.dat" ];
-    CPPUNIT_ASSERT_EQUAL( QString( "&lt;test&gt; &amp;" ), thread3->name() );
-    CPPUNIT_ASSERT_EQUAL( 30, thread3->resNum() );
+    
+    Kita::Thread* thread3 = Kita::Thread::getByURL( threadList[ 2 ] );
+    CPPUNIT_ASSERT_EQUAL( QString( "2ch browser thread" ), thread3->name() );
+    CPPUNIT_ASSERT_EQUAL( 20, thread3->resNum() );
     CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/" ), thread3->boardURL() );
     CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), thread3->boardName() );
     CPPUNIT_ASSERT_EQUAL( QString( "linux" ), thread3->boardID() );