}
}
+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();
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( "<test> &" ), 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( "<test> &" ), 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() );