return Board::getByURL( boardURL ) ->name();
}
+void Board::replace( const QString& fromURL, const QString& toURL )
+{
+ QDictIterator<Kita::Board> it( *m_boardDict );
+ for( ; it.current(); ++it ) {
+ QString url = it.currentKey();
+ Kita::Board* board = it.current();
+ if ( url.find( fromURL ) == 0 ) {
+ m_boardDict->remove( url );
+ url = url.replace( 0, fromURL.length(), toURL );
+ board->m_boardURL = url;
+ m_boardDict->insert( url, board );
+ }
+ }
+}
+
NullBoard::NullBoard()
{}
// Factory method
static Board* getByURL( const QString& boardURL );
static void setName( const QString& boardURL, const QString& boardName );
+ static void replace( const QString& fromURL, const QString& toURL );
static const QString& getName( const QString& boardURL );
};
CPPUNIT_ASSERT_EQUAL( QString( "Unix" ), Kita::Board::getName( "http://pc.2ch.net/unix/" ) );
CPPUNIT_ASSERT_EQUAL( QString::null, Kita::Board::getName( QString::null ) );
}
+
+void BoardTest::testReplace()
+{
+ Kita::Board::replace( QString( "http://pc.2ch.net/linux/" ), QString( "http://pc3.2ch.net/linux/" ) );
+ Kita::Board* board = Kita::Board::getByURL( "http://pc3.2ch.net/linux/" );
+
+ CPPUNIT_ASSERT_EQUAL( QString( "linux" ), board->id() );
+ CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), board->name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc3.2ch.net/linux/subject.txt" ),
+ board->subjectTxtURL().url() );
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc3.2ch.net/linux/"),
+ board->url() );
+ CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), Kita::Board::getName( "http://pc3.2ch.net/linux/" ) );
+
+ Kita::Board::replace( QString( "http://pc3.2ch.net/linux/" ), QString( "http://pc.2ch.net/linux/" ) );
+}
CPPUNIT_TEST( testSubjectTxtURL );
CPPUNIT_TEST( testURL );
CPPUNIT_TEST( testStaticName );
+ CPPUNIT_TEST( testReplace );
CPPUNIT_TEST_SUITE_END();
Kita::Board *m_normal, *m_share1, *m_share2, *m_share3, *m_null;
void testSubjectTxtURL();
void testURL();
void testStaticName();
+ void testReplace();
};
#endif