subjectList->clear();
- for( int i = 0; FavoriteThreads::count() > i; i++ ) {
+ for ( int i = 0; FavoriteThreads::count() > i; i++ ) {
QString datURL = FavoriteThreads::getDatURL( i );
QDateTime since;
{
if ( ! item ) return ;
- for( int i = 0; FavoriteThreads::count() > i; i++ ) {
+ for ( int i = 0; FavoriteThreads::count() > i; i++ ) {
QString datURL = FavoriteThreads::getDatURL( i );
- qDebug("FavoriteListView::loadThread(() datURL = %s", datURL.latin1());
+ qDebug( "FavoriteListView::loadThread(() datURL = %s", datURL.latin1() );
if ( datURL == item->text( Col_DatURL ) ) {
emit openURLRequestExt( datURL, KParts::URLArgs(), "kita_open_2chthread", 0 );
clipboard->setText( threadURL );
break;
case Menu_CopyTitleAndURL:
- cliptxt = Kita::DatManager::threadName( datURL ) + "\n" + threadURL;
- clipboard->setText( cliptxt , QClipboard::Clipboard );
- clipboard->setText( cliptxt , QClipboard::Selection );
+ cliptxt = Kita::DatManager::threadName( datURL ) + "\n" + threadURL;
+ clipboard->setText( cliptxt , QClipboard::Clipboard );
+ clipboard->setText( cliptxt , QClipboard::Selection );
break;
case Menu_RemoveFromFavorites:
emit bookmarked( datURL, false );
{
QValueList<QString> boardList;
- for( int i = 0; FavoriteThreads::count() > i; i++ ) {
+ for ( int i = 0; FavoriteThreads::count() > i; i++ ) {
QString datURL = FavoriteThreads::getDatURL( i );
- qDebug("FavoriteListView::update() datURL = %s", datURL.latin1());
+ qDebug( "FavoriteListView::update() datURL = %s", datURL.latin1() );
QString boardURL = Kita::datToBoard( datURL );
if ( boardList.contains( boardURL ) == 0 ) {
boardList.append( boardURL );
QValueList<QString>::const_iterator it2;
for ( it2 = boardList.begin(); it2 != boardList.end(); ++it2 ) {
- bool online = TRUE;
- QPtrList<Kita::Thread> threadList;
- QPtrList<Kita::Thread> tmpList;
- Kita::BoardManager::getThreadList( ( *it2 ), FALSE, online, threadList, tmpList );
+ bool online = TRUE;
+ QPtrList<Kita::Thread> threadList;
+ QPtrList<Kita::Thread> tmpList;
+ Kita::BoardManager::getThreadList( ( *it2 ), FALSE, online, threadList, tmpList );
}
}
m_printer( 0 )
{
// FIXME: merge *.po
- KGlobal::locale()->insertCatalogue( "kitapart" );
+ KGlobal::locale() ->insertCatalogue( "kitapart" );
// accept dnd
setAcceptDrops( true );
saveFavoriteBoards();
saveFavorites();
-
+
saveCache();
saveMainWindowSettings( KGlobal::config(), "MainWindow" );
KStdAction::configureToolbars( this, SLOT( optionsConfigureToolbars() ), actionCollection() );
KStdAction::preferences( this, SLOT( optionsPreferences() ), actionCollection() );
-/* new KAction( i18n( "Edit Favorites" ),
- 0,
- this,
- SLOT( favoritesEdit() ),
- actionCollection(),
- "favorites_edit" );*/
+ /* new KAction( i18n( "Edit Favorites" ),
+ 0,
+ this,
+ SLOT( favoritesEdit() ),
+ actionCollection(),
+ "favorites_edit" );*/
new KAction( i18n( "Load board list" ),
0,
QMessageBox::warning( this,
"Kita",
i18n( "be.2ch.net is currently not supported." ) );
- return;
+ return ;
}
kdDebug() << QString( "Requested OpenURL: \"%1\"" ).arg( url.url() ) << endl;
}
/* open thread with new thread tab */
- if ( Kita::DatManager::isThreadEnrolled( url ) ){
- m_threadDock->slotShowThread( url, true );
- return;
+ if ( Kita::DatManager::isThreadEnrolled( url ) ) {
+ m_threadDock->slotShowThread( url, true );
+ return ;
}
- /* bmp file */
- if ( Kita::ImgManager::isBMP( url ) ) {
- QMessageBox::warning( this,
- "Kita",
- i18n( "This is a BMP file. It might contain a Troy." ) );
- return ;
- }
+ /* bmp file */
+ if ( Kita::ImgManager::isBMP( url ) ) {
+ QMessageBox::warning( this,
+ "Kita",
+ i18n( "This is a BMP file. It might contain a Troy." ) );
+ return ;
+ }
- /* open with image viewer */
- /* if usr1 == 0, image viewer is hidden. */
- /* usrUrl1 is datURL. */
- if ( KitaConfig::useImageViewer() ) {
- if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
+ /* open with image viewer */
+ /* if usr1 == 0, image viewer is hidden. */
+ /* usrUrl1 is datURL. */
+ if ( KitaConfig::useImageViewer() ) {
+ if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
- if ( !usr1 ) m_imgDock->slotHideDock();
- m_imgDock->slotOpenURL( url, usrUrl1, usr1 );
- return ;
- }
+ if ( !usr1 ) m_imgDock->slotHideDock();
+ m_imgDock->slotOpenURL( url, usrUrl1, usr1 );
+ return ;
}
+ }
- if ( mimetype == QString::null ) {
+ if ( mimetype == QString::null ) {
#if KDE_IS_VERSION( 3, 2, 0 )
- mimetype = KIO::NetAccess::mimetype( url , this );
+ mimetype = KIO::NetAccess::mimetype( url , this );
#else
- mimetype = KIO::NetAccess::mimetype( url );
+ mimetype = KIO::NetAccess::mimetype( url );
#endif
- }
- kdDebug() << QString( "queried MIME type: \"%1\"" ).arg( mimetype ) << endl;
-
- /* open with kpart */
- if ( KitaConfig::usePart() ) {
- if ( KitaConfig::partMimeList().find( mimetype ) != KitaConfig::partMimeList().end() ) {
- KService::Ptr service = KServiceTypeProfile::preferredService( mimetype, "KParts/ReadOnlyPart" );
- if ( service ) {
- QString libName = QFile::encodeName( service->library() );
-
- if ( !KitaConfig::useKitaNavi() ) m_threadDock->slotShowPart( url, libName, mimetype );
- else m_naviDock ->slotShowPart( url, libName, mimetype );
- return ;
- }
+ }
+ kdDebug() << QString( "queried MIME type: \"%1\"" ).arg( mimetype ) << endl;
+
+ /* open with kpart */
+ if ( KitaConfig::usePart() ) {
+ if ( KitaConfig::partMimeList().find( mimetype ) != KitaConfig::partMimeList().end() ) {
+ KService::Ptr service = KServiceTypeProfile::preferredService( mimetype, "KParts/ReadOnlyPart" );
+ if ( service ) {
+ QString libName = QFile::encodeName( service->library() );
+
+ if ( !KitaConfig::useKitaNavi() ) m_threadDock->slotShowPart( url, libName, mimetype );
+ else m_naviDock ->slotShowPart( url, libName, mimetype );
+ return ;
}
}
+ }
- if ( KitaConfig::copyOnClick() ) {
- QClipboard * clipboard = QApplication::clipboard();
- clipboard->setText( url.prettyURL(), QClipboard::Clipboard );
- clipboard->setText( url.prettyURL(), QClipboard::Selection );
- } else {
- KRun::runURL( url, mimetype );
- }
+ if ( KitaConfig::copyOnClick() ) {
+ QClipboard * clipboard = QApplication::clipboard();
+ clipboard->setText( url.prettyURL(), QClipboard::Clipboard );
+ clipboard->setText( url.prettyURL(), QClipboard::Selection );
+ } else {
+ KRun::runURL( url, mimetype );
+ }
}
void KitaMainWindow::favoritesEdit()
{
- FavoritesWindow* window = new FavoritesWindow( this );
+ FavoritesWindow * window = new FavoritesWindow( this );
window->show();
}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include <kapplication.h>
#include <dcopclient.h>
#include <qdatastream.h>
#include <qstring.h>
-int main(int argc, char **argv)
+int main( int argc, char **argv )
{
- KApplication app(argc, argv, "kita_client", false);
+ KApplication app( argc, argv, "kita_client", false );
// get our DCOP client and attach so that we may use it
DCOPClient *client = app.dcopClient();
// do a 'send' for now
QByteArray data;
- QDataStream ds(data, IO_WriteOnly);
- if (argc > 1)
- ds << QString(argv[1]);
+ QDataStream ds( data, IO_WriteOnly );
+ if ( argc > 1 )
+ ds << QString( argv[ 1 ] );
else
- ds << QString("http://www.kde.org");
- client->send("kita", "KitaIface", "openURL(QString)", data);
+ ds << QString( "http://www.kde.org" );
+ client->send( "kita", "KitaIface", "openURL(QString)", data );
return app.exec();
}
m_boardList->header() ->setClickEnabled( FALSE );
/* default colors */
- QColorGroup colors = m_boardList->viewport()->colorGroup();
+ QColorGroup colors = m_boardList->viewport() ->colorGroup();
m_textColor = colors.text();
m_baseColor = colors.base();
- m_backColor = m_boardList->viewport()->paletteBackgroundColor();
+ m_backColor = m_boardList->viewport() ->paletteBackgroundColor();
m_altColor = m_boardList->alternateBackground();
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
QString url = KitaConfig::boardListURL();
if ( !
#if KDE_IS_VERSION( 3, 2, 0 )
- KIO::NetAccess::download( url, tmpFile, NULL )
+ KIO::NetAccess::download( url, tmpFile, NULL )
#else
- KIO::NetAccess::download( url, tmpFile )
-#endif
- ) {
+ KIO::NetAccess::download( url, tmpFile )
+#endif
+ ) {
return FALSE;
}
QValueList<Kita::Category>::iterator it;
/* Are there new boards or moved boards ? */
- QString newBoards = QString::null;
+ QString newBoards = QString::null;
QString oldBoards = QString::null;
for ( it = categoryList.begin(); it != categoryList.end(); ++it ) {
Kita::Category category = ( *it );
int count = 0;
for ( QValueList<QString>::iterator it2 = board_url_list.begin();
- it2 != board_url_list.end(); ++it2 ) {
-
+ it2 != board_url_list.end(); ++it2 ) {
+
QString boardURL = *it2;
QString boardName = category.boardNameList[ count ];
QString oldURL;
int ret = Kita::BoardManager::enrollBoard( boardURL, boardName, oldURL, Kita::Board_Unknown,
- TRUE /* test only */
- );
- if( ret == Kita::Board_enrollNew ) newBoards += boardName + " ( " + category.category_name + " ) " + boardURL + "\n";
- if( ret == Kita::Board_enrollMoved ) oldBoards += boardName + " ( " + category.category_name + " ) " + oldURL + " -> " + boardURL + "\n";
+ TRUE /* test only */
+ );
+ if ( ret == Kita::Board_enrollNew ) newBoards += boardName + " ( " + category.category_name + " ) " + boardURL + "\n";
+ if ( ret == Kita::Board_enrollMoved ) oldBoards += boardName + " ( " + category.category_name + " ) " + oldURL + " -> " + boardURL + "\n";
count++;
}
}
const int maxNewBoard = 64;
/* show new board names */
- if( newBoards != QString::null && newBoards.contains( "\n" ) < maxNewBoard ){
+ if ( newBoards != QString::null && newBoards.contains( "\n" ) < maxNewBoard ) {
- QStringList boardList = QStringList::split( "\n", newBoards);
+ QStringList boardList = QStringList::split( "\n", newBoards );
KMessageBox::informationList( this,
i18n( "New boards:\n\n" ),
boardList, "Kita" );
}
- /* show moved board names */
- if( oldBoards != QString::null ){
+ /* show moved board names */
+ if ( oldBoards != QString::null ) {
- QStringList boardList = QStringList::split( "\n", oldBoards);
+ QStringList boardList = QStringList::split( "\n", oldBoards );
KMessageBox::informationList( this,
i18n( "These boards were moved:\n\n" )
+ i18n( "\nPlease create the backup of those caches.\n" ),
boardList, "Kita" );
}
- if( ( newBoards != QString::null && newBoards.contains( "\n" ) < maxNewBoard )
- || oldBoards != QString::null ){
+ if ( ( newBoards != QString::null && newBoards.contains( "\n" ) < maxNewBoard )
+ || oldBoards != QString::null ) {
QMessageBox mb( "kita", i18n( "Do you really want to update board list?" ),
QMessageBox::Information,
mb.setButtonText( QMessageBox::No, i18n( "Copy" ) );
int ret;
- while( ( ret = mb.exec() ) == QMessageBox::No ){
+ while ( ( ret = mb.exec() ) == QMessageBox::No ) {
QString str = i18n( "New boards:\n\n" ) + newBoards + "\n"
- + i18n( "These boards were moved:\n\n" ) + oldBoards;
- QApplication::clipboard()->setText( str , QClipboard::Clipboard );
- QApplication::clipboard()->setText( str , QClipboard::Selection );
+ + i18n( "These boards were moved:\n\n" ) + oldBoards;
+ QApplication::clipboard() ->setText( str , QClipboard::Clipboard );
+ QApplication::clipboard() ->setText( str , QClipboard::Selection );
}
- if( ret == QMessageBox::Cancel ) return FALSE;
- }
- else if( newBoards == QString::null && oldBoards == QString::null ){
-
- QMessageBox::information( this, "Kita", i18n( "no new boards" ) );
- return FALSE;
+ if ( ret == QMessageBox::Cancel ) return FALSE;
+ } else if ( newBoards == QString::null && oldBoards == QString::null ) {
+
+ QMessageBox::information( this, "Kita", i18n( "no new boards" ) );
+ return FALSE;
}
/*------------------------------------------------*/
-
+
/* save config */
QString configPath = locateLocal( "appdata", "board_list" );
KSimpleConfig config( configPath );
QValueList<QString>::iterator it2;
int count = 0;
for ( it2 = board_url_list.begin(); it2 != board_url_list.end(); ++it2 ) {
- QString key = QString( "item%1").arg( count );
+ QString key = QString( "item%1" ).arg( count );
QString boardURL = *it2;
QString boardName = category.boardNameList[ count ];
QStringList tmpList;
void KitaBoardView::updateBoardList()
{
- if( downloadBoardList() ) showBoardList();
+ if ( downloadBoardList() ) showBoardList();
}
void KitaBoardView::showBoardList()
{
/* color setting */
-/*
- m_textColor = QColor( "white" );
- m_baseColor = QColor( "red" );
- m_backColor = QColor( "yellow" );
- m_altColor = QColor( "blue" );
-*/
+ /*
+ m_textColor = QColor( "white" );
+ m_baseColor = QColor( "red" );
+ m_backColor = QColor( "yellow" );
+ m_altColor = QColor( "blue" );
+ */
/*-------------------------------------------------*/
/* set background color */
- m_boardList->viewport()->setPaletteBackgroundColor( m_backColor );
+ m_boardList->viewport() ->setPaletteBackgroundColor( m_backColor );
m_boardList->setAlternateBackground( m_altColor );
-
+
// clear list
m_boardList->clear();
m_favorites = NULL;
if ( value.count() != 2 ) {
break;
}
- QString boardURL = value[0];
- QString boardName = value[1];
+ QString boardURL = value[ 0 ];
+ QString boardName = value[ 1 ];
QString oldURL;
Kita::BoardManager::enrollBoard( boardURL, boardName, oldURL );
Kita::BoardManager::loadBBSHistory( boardURL );
QString board_url = list[ 1 ];
Kita::ListViewItem* tmpitem = new Kita::ListViewItem( categoryItem, board_title, board_url );
- tmpitem->setColor( m_textColor, m_baseColor );
+ tmpitem->setColor( m_textColor, m_baseColor );
QString oldURL;
int type = Kita::Board_Unknown;
- if( list.size() == 3 ) type = list[ 2 ].toInt();
- Kita::BoardManager::enrollBoard( board_url, board_title, oldURL, type );
+ if ( list.size() == 3 ) type = list[ 2 ].toInt();
+ Kita::BoardManager::enrollBoard( board_url, board_title, oldURL, type );
}
}
}
Kita::Category current_category;
current_category.category_name = QString::null;
current_category.boardNameList.clear();
- current_category.boardURLList.clear();
+ current_category.boardURLList.clear();
for ( it = lines.begin(); it != lines.end(); ++it ) {
QString category_name = getCategory( *it );
if ( category_name != QString::null ) {
}
current_category.category_name = category_name;
current_category.boardNameList.clear();
- current_category.boardURLList.clear();
+ current_category.boardURLList.clear();
} else {
- QRegExp regexp( "<A HREF=([^ ]*).*>(.*)</A>", false );
- if ( regexp.search( ( *it ) ) != -1 ) {
- QString url = regexp.cap( 1 );
- QString title = regexp.cap( 2 );
- if( isBoardURL( url ) && current_category.category_name != QString::null ){
- current_category.boardNameList.append( title );
- current_category.boardURLList.append( url );
- }
- }
+ QRegExp regexp( "<A HREF=([^ ]*).*>(.*)</A>", false );
+ if ( regexp.search( ( *it ) ) != -1 ) {
+ QString url = regexp.cap( 1 );
+ QString title = regexp.cap( 2 );
+ if ( isBoardURL( url ) && current_category.category_name != QString::null ) {
+ current_category.boardNameList.append( title );
+ current_category.boardURLList.append( url );
+ }
+ }
}
}
return result;
if ( ! m_favorites ) {
m_favorites = new Kita::ListViewItem( m_boardList, 0, i18n( "Favorites" ) );
}
- m_favorites->setColor( m_textColor, m_baseColor );
+ m_favorites->setColor( m_textColor, m_baseColor );
do {
QListViewItem* child = m_favorites->firstChild();
break;
case Menu_CopyTitleAndURL:
clipboard->setText( boardName + "\n" + boardURL.prettyURL(), QClipboard::Clipboard );
- clipboard->setText( boardName + "\n" + boardURL.prettyURL(), QClipboard::Selection );
+ clipboard->setText( boardName + "\n" + boardURL.prettyURL(), QClipboard::Selection );
break;
case Menu_AddToFavorites:
Kita::FavoriteBoards::append( boardURL );
QColor m_baseColor;
QColor m_backColor;
QColor m_altColor;
-
+
QString getCategory( const QString& line ) const;
QString getBoardURL( const QString& line ) const;
bool isBoardURL( const QString& url ) const;
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef _KITAIFACE_H_
#define _KITAIFACE_H_
class KitaIface : virtual public DCOPObject
{
- K_DCOP
+ K_DCOP
public:
k_dcop:
- virtual void openURL(QString url) = 0;
+ virtual void openURL( QString url ) = 0;
};
#endif // _KITAIFACE_H_
QStringList selectlist;
selectlist << "20%" << "25%" << "50%" << "75%" << "100%" << "125%"
- << "150%" << "175%" << "200%" << "300%" << "400%" << "500%" ;
+ << "150%" << "175%" << "200%" << "300%" << "400%" << "500%" ;
m_sizeaction->setItems( selectlist );
}
Q_OBJECT
KSelectAction* m_sizeaction;
-
+
public:
KitaImgTabWidget( QWidget* parent, const char* name = 0, WFlags fl = 0 );
~KitaImgTabWidget();
if ( !isSubjectView( w ) ) w = page( count() - 2 );
view = static_cast< KitaSubjectView *>( w );
- view->init();
+ view->init();
setTabLabel( view, boardName );
}
}
SLOT( slotShowOldLogs() ),
actionCollection(),
"subjectview_showoldlogs" );
-
+
new KAction( i18n( "Show Title Image" ),
0,
this,
void KitaSubjectTabWidget::slotShowOldLogs( int idx )
{
KitaSubjectView * view;
- if( idx == -1 ) view = isSubjectView( currentPage() );
- else view = isSubjectView( page( idx ) );
+ if ( idx == -1 ) view = isSubjectView( currentPage() );
+ else view = isSubjectView( page( idx ) );
if ( view ) view->toggleShowOldLogs();
}
void KitaSubjectTabWidget::slotShowTitleImg( int idx )
{
KitaSubjectView * view;
- if( idx == -1 ) view = isSubjectView( currentPage() );
- else view = isSubjectView( page( idx ) );
- if ( view ){
+ if ( idx == -1 ) view = isSubjectView( currentPage() );
+ else view = isSubjectView( page( idx ) );
+ if ( view ) {
KURL imgURL = Kita::BoardManager::titleImgURL( view->boardURL() );
- if( !imgURL.isEmpty() ) {
- emit openURLRequestExt( imgURL, KParts::URLArgs(), QString::null, 1, 0, view->boardURL() );
- }
+ if ( !imgURL.isEmpty() ) {
+ emit openURLRequestExt( imgURL, KParts::URLArgs(), QString::null, 1, 0, view->boardURL() );
+ }
}
}
popup->insertItem( i18n( "Open with Web Browser" ), MENU_OPENBROWSER );
popup->insertItem( i18n( "Copy title and URL" ), MENU_COPYTITLE );
popup->insertItem( i18n( "Show Title Image" ) , MENU_SHOWTITLEIMG );
-
+
popup->insertSeparator();
collection->action( "tab_configkeys" ) ->plug( popup );
case MENU_CLOSEOTHER: tabwidget->slotCloseOtherTab( idx ); break;
case MENU_CLOSERIGHT: tabwidget->slotCloseRightTab( idx ); break;
case MENU_CLOSELEFT: tabwidget->slotCloseLeftTab( idx ); break;
- case MENU_SHOWOLDLOGS: tabwidget->slotShowOldLogs( idx ); break;
+ case MENU_SHOWOLDLOGS: tabwidget->slotShowOldLogs( idx ); break;
case MENU_SHOWTITLEIMG: tabwidget->slotShowTitleImg( idx ); break;
case MENU_OPENBROWSER:
KRun::runURL( subjectView->boardURL(), "text/html" );
protected:
virtual void deleteWidget( QWidget* w );
-
+
/* tab actions */
private:
void slotFocusSearchCombo();
void slotNewThread();
void slotShowOldLogs( int idx = -1 );
- void slotShowTitleImg( int idx = -1 );
+ void slotShowTitleImg( int idx = -1 );
};
/*--------------------------------------------------*/
/* public */
void KitaSubjectView::init()
{
- m_unreadNum = 0;
+ m_unreadNum = 0;
m_readNum = 0;
- m_newNum = 0;
+ m_newNum = 0;
m_showOldLogs = FALSE;
m_enableSizeChange = FALSE;
}
if ( KitaConfig::alwaysUseTab() ) {
emit openURLRequestExt( datURL.prettyURL(), KParts::URLArgs(), "kita_open_2chthread", 1 );
- } else {
+ } else {
emit openURLRequestExt( datURL.prettyURL(), KParts::URLArgs(), "kita_open_2chthread", 0 );
}
}
QDateTime current = QDateTime::currentDateTime();
unsigned int countNew = threadList.count();
- unsigned int countOld = oldLogList.count();
+ unsigned int countOld = oldLogList.count();
for ( unsigned i = 0; i < countNew + countOld; i++ ) {
Kita::Thread* thread = i < countNew ? threadList.at( i ) : oldLogList.at( i - countNew );
Kita::ThreadListViewItem* item = new Kita::ThreadListViewItem( subjectList );
- int id = ( i < countNew ? i + 1 : 0 );
- int order = i + 1;
- updateListViewItem( item, thread, current, id, order );
+ int id = ( i < countNew ? i + 1 : 0 );
+ int order = i + 1;
+ updateListViewItem( item, thread, current, id, order );
}
if ( HideButton->isOn() ) {
case ts_hasunread : m_unreadNum--; break;
}
- Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread == NULL ) return;
- int id = item->text( Col_ID ).toInt();
- int order = item->text( Col_IDOrder ).toInt();
- updateListViewItem( item, thread, current, id, order );
+ Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
+ if ( thread == NULL ) return ;
+ int id = item->text( Col_ID ).toInt();
+ int order = item->text( Col_IDOrder ).toInt();
+ updateListViewItem( item, thread, current, id, order );
UpdateKindLabel();
- return;
+ return ;
}
}
}
/* if id == 0, this thread is old thread. */
/* private */
-void KitaSubjectView::updateListViewItem( QListViewItem* item, Kita::Thread* thread, const QDateTime& current, int id, int order)
+void KitaSubjectView::updateListViewItem( QListViewItem* item, Kita::Thread* thread, const QDateTime& current, int id, int order )
{
KURL datURL = thread->datURL();
-
+
QDateTime since;
since.setTime_t( Kita::datToSince( datURL ) );
QString threadName = thread->threadName();
int viewPos = thread->viewPos();
double speed = resNum / ( since.secsTo( current ) / ( 60.0 * 60.0 * 24.0 ) );
- if( id ) item->setText( Col_ID, QString().setNum( id ) );
+ if ( id ) item->setText( Col_ID, QString().setNum( id ) );
item->setText( Col_IDOrder, QString().setNum( order ) );
item->setText( Col_Subject, threadName );
item->setText( Col_ResNum, QString( "%1" ).arg( resNum, 4 ) );
/* set mark order */
- if( !id ){ /* old thread */
+ if ( !id ) { /* old thread */
- item->setText( Col_MarkOrder, QString::number( ts_old ) );
- }
- else if ( readNum > 0 && ( resNum > readNum || resNum > viewPos ) ) { /* There are new responses. */
+ item->setText( Col_MarkOrder, QString::number( ts_old ) );
+ } else if ( readNum > 0 && ( resNum > readNum || resNum > viewPos ) ) { /* There are new responses. */
- item->setPixmap( Col_Mark, SmallIcon( "unread" ) );
- m_unreadNum++;
- item->setText( Col_MarkOrder, QString::number( ts_hasunread ) );
+ item->setPixmap( Col_Mark, SmallIcon( "unread" ) );
+ m_unreadNum++;
+ item->setText( Col_MarkOrder, QString::number( ts_hasunread ) );
} else if ( readNum > 0 ) { /* Cache exists */
- item->setPixmap( Col_Mark, SmallIcon( "read" ) );
- m_readNum++;
- item->setText( Col_MarkOrder, QString::number( ( viewPos > 1000 ) ? ts_readed : ts_read ) );
+ item->setPixmap( Col_Mark, SmallIcon( "read" ) );
+ m_readNum++;
+ item->setText( Col_MarkOrder, QString::number( ( viewPos > 1000 ) ? ts_readed : ts_read ) );
} else if ( since.secsTo( current ) < 3600 * KitaConfig::MarkTime() ) { /* new thread */
- item->setPixmap( Col_Mark, SmallIcon( "newthread" ) );
- m_newNum++;
- item->setText( Col_MarkOrder, QString::number( ts_new ) );
+ item->setPixmap( Col_Mark, SmallIcon( "newthread" ) );
+ m_newNum++;
+ item->setText( Col_MarkOrder, QString::number( ts_new ) );
} else { /* normal */
- item->setText( Col_MarkOrder, QString::number( ts_normal ) );
- item->setPixmap( Col_Mark, NULL );
+ item->setText( Col_MarkOrder, QString::number( ts_normal ) );
+ item->setPixmap( Col_Mark, NULL );
}
// no effect: m_unreadNum, m_readNum, m_newNum, markOrder
popup.insertItem( i18n( "Add to Favorites" ), Menu_Favorites );
}
- if( Kita::DatManager::getReadNum( datURL ) ){
- popup.insertSeparator();
- popup.insertItem( i18n( "Delete Log" ), Menu_DeleteLog );
+ if ( Kita::DatManager::getReadNum( datURL ) ) {
+ popup.insertSeparator();
+ popup.insertItem( i18n( "Delete Log" ), Menu_DeleteLog );
}
-
+
popup.insertSeparator();
popup.insertItem( i18n( "Property" ), Menu_Property );
clipboard->setText( threadURL );
break;
case Menu_CopyTitleAndURL:
- cliptxt = Kita::DatManager::threadName( datURL ) + "\n" + threadURL;
- clipboard->setText( cliptxt , QClipboard::Clipboard );
- clipboard->setText( cliptxt , QClipboard::Selection );
+ cliptxt = Kita::DatManager::threadName( datURL ) + "\n" + threadURL;
+ clipboard->setText( cliptxt , QClipboard::Clipboard );
+ clipboard->setText( cliptxt , QClipboard::Selection );
break;
case Menu_Favorites:
if ( isFavorites ) {
case Menu_DeleteLog:
deleteLog( threadURL );
break;
- case Menu_Property:
- {
+ case Menu_Property: {
// FIXME: memory leak
Kita::ThreadProperty* propertyWidget = new Kita::ThreadProperty( 0 );
propertyWidget->threadURLLabel->setText( threadURL );
i18n( "Do you want to delete Log ?" ),
QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
== QMessageBox::Ok ) {
- if ( Kita::DatManager::deleteCache( url ) ){
- emit closeThreadTab( url );
- slotUpdateSubject( url );
- }
+ if ( Kita::DatManager::deleteCache( url ) ) {
+ emit closeThreadTab( url );
+ slotUpdateSubject( url );
+ }
}
}
void KitaSubjectView::slotSizeChange( int section, int oldSize, int newSize )
{
- if ( ! m_enableSizeChange ) return;
- if ( autoResize() ) return;
+ if ( ! m_enableSizeChange ) return ;
+ if ( autoResize() ) return ;
// FIXME: cache KConfig
QString configPath = locateLocal( "appdata", "subjectview.conf" );
KConfig config( configPath );
void KitaSubjectView::loadLayout()
{
- if ( autoResize() ) return;
+ if ( autoResize() ) return ;
QString configPath = locateLocal( "appdata", "subjectview.conf" );
KConfig config( configPath );
subjectList->restoreLayout( &config, "Layout" );
bool KitaSubjectView::eventFilter( QObject* watched, QEvent* e )
{
if ( e->type() == QEvent::MouseButtonPress ) {
- QMouseEvent* mouseEvent = static_cast<QMouseEvent *>( e );
+ QMouseEvent * mouseEvent = static_cast<QMouseEvent *>( e );
if ( mouseEvent->button() == RightButton ) {
KPopupMenu popup;
popup.setCheckable( true );
- for( int i = Col_Begin; i <= Col_End; i++ ) {
+ for ( int i = Col_Begin; i <= Col_End; i++ ) {
if ( i != Col_Subject && i != Col_MarkOrder && i != Col_IDOrder ) {
popup.insertItem( i18n( s_colAttr[ i ].itemName ), i );
popup.setItemChecked( i, subjectList->columnWidth( i ) != 0 );
} else if ( popup.isItemChecked( id ) ) {
// hide
subjectList->setColumnWidthMode( id, QListView::Manual );
- subjectList->header()->setResizeEnabled( false );
+ subjectList->header() ->setResizeEnabled( false );
subjectList->setColumnWidth( id, 0 );
} else {
// show
subjectList->setColumnWidthMode( id, QListView::Manual );
- subjectList->header()->setResizeEnabled( true );
+ subjectList->header() ->setResizeEnabled( true );
#if QT_VERSION >= 0x030200
subjectList->adjustColumn( id );
#else
subjectList->setColumnWidth( id, 30 );
#endif
+
}
saveHeaderOnOff();
return true;
return false;
}
} else {
- return subjectList->header()->eventFilter( watched, e );
+ return subjectList->header() ->eventFilter( watched, e );
}
}
config.setGroup( "Column" );
for ( int i = Col_Begin; i <= Col_End; i++ ) {
if ( subjectList->columnWidth( i ) != 0 ) {
- config.writeEntry( s_colAttr[i].keyName, true );
+ config.writeEntry( s_colAttr[ i ].keyName, true );
} else {
- config.writeEntry( s_colAttr[i].keyName, false );
+ config.writeEntry( s_colAttr[ i ].keyName, false );
}
}
}
config.setGroup( "Column" );
for ( int i = Col_Begin; i <= Col_End; i++ ) {
- bool isShown = config.readBoolEntry( s_colAttr[i].keyName, s_colAttr[i].showDefault );
+ bool isShown = config.readBoolEntry( s_colAttr[ i ].keyName, s_colAttr[ i ].showDefault );
if ( isShown ) {
subjectList->setColumnWidthMode( i, QListView::Maximum );
header->setResizeEnabled( i, true );
#else
subjectList->setColumnWidth( i, 30 );
#endif
+
} else {
subjectList->setColumnWidthMode( i, QListView::Manual );
header->setResizeEnabled( i, false );
public slots:
virtual void setFocus();
- void slotFocusSearchCombo();
+ void slotFocusSearchCombo();
void reloadSubject();
void slotCreateNewThread();
void loadBoard( const KURL& url, bool online = TRUE );
void UpdateKindLabel();
void deleteLog( const KURL& url );
void loadLayout();
- void updateListViewItem( QListViewItem* item, Kita::Thread* thread, const QDateTime& current, int id, int order);
+ void updateListViewItem( QListViewItem* item, Kita::Thread* thread, const QDateTime& current, int id, int order );
bool eventFilter( QObject* watched, QEvent* e );
void saveHeaderOnOff();
void loadHeaderOnOff();
signals:
void loadBoardCompleted( const KURL& );
void closeThreadTab( const KURL& );
- void createNewThread( const KURL& , const QString&, const QString& );
+ void createNewThread( const KURL& , const QString&, const QString& );
void closeCurrentTab();
};
collection->action( "tab_closealltab" ) ->plug( popup );
popup->insertSeparator();
- collection->action( "tab_configkeys" )->plug( popup );
-
+ collection->action( "tab_configkeys" ) ->plug( popup );
+
int ret = popup->exec( global );
delete popup;
{
m_mode = mode;
- switch( m_mode ){
+ switch ( m_mode ) {
case TABMODE_THREADVIEW: setXMLFile( "kitathreadtabwidgetui.rc" ); break;
- case TABMODE_KITANAVI: setXMLFile( "kitanaviui.rc" ); break;
+ case TABMODE_KITANAVI: setXMLFile( "kitanaviui.rc" ); break;
}
-
+
setTabBar( new KitaThreadTabBar( this ) );
connectSignals();
setupActions();
/* default view */
- if( m_mode == TABMODE_THREADVIEW ) createView( "thread" );
+ if ( m_mode == TABMODE_THREADVIEW ) createView( "thread" );
}
-KitaThreadTabWidget::~KitaThreadTabWidget(){}
+KitaThreadTabWidget::~KitaThreadTabWidget() {}
/* show "Main thread" view */ /* public slots */
void KitaThreadTabWidget::slotShowMainThread( const KURL& url, bool withNewTab )
{
QString refstr;
- KURL datURL = Kita::ParseMisc::parseURL( url, refstr);
+ KURL datURL = Kita::ParseMisc::parseURL( url, refstr );
QString threadName = Kita::DatManager::threadName( datURL );
int jumpNum = 0;
-
+
int viewMode = VIEWMODE_MAINVIEW;
KitaThreadView* currentView = isThreadView( currentPage() );
- if( currentView ) viewMode = currentView->getViewMode();
+ if ( currentView ) viewMode = currentView->getViewMode();
- if( refstr != QString::null ){
- int i = refstr.find( "-" );
- if( i != -1 ) jumpNum = refstr.left( i ).toInt();
- else jumpNum = refstr.toInt();
+ if ( refstr != QString::null ) {
+ int i = refstr.find( "-" );
+ if ( i != -1 ) jumpNum = refstr.left( i ).toInt();
+ else jumpNum = refstr.toInt();
}
KitaThreadView* view = findMainView( datURL );
if ( view ) {
-
+
setCurrentPage( indexOf( view ) );
- /* Show on the default view */
+ /* Show on the default view */
if ( view->threadURL().isEmpty() ) view->showThread( datURL, jumpNum );
- /* The view is already shown */
- /* TODO: jump to jumpNum after reloading */
- else view->slotReloadButton( jumpNum );
-
- }
- else if ( withNewTab
- || currentView == NULL /* Current page is not KitaThreadView. */
- || viewMode != VIEWMODE_MAINVIEW /* Current page is KitaThreadView, but not Main View. */
- ){
+ /* The view is already shown */
+ /* TODO: jump to jumpNum after reloading */
+ else view->slotReloadButton( jumpNum );
+
+ } else if ( withNewTab
+ || currentView == NULL /* Current page is not KitaThreadView. */
+ || viewMode != VIEWMODE_MAINVIEW /* Current page is KitaThreadView, but not Main View. */
+ ) {
KitaThreadView * newView = createView( threadName );
newView->showThread( datURL, jumpNum );
showPage( newView );
}
- }
- else static_cast<KitaThreadView *>( currentPage() )->showThread( datURL, jumpNum );
+ } else static_cast<KitaThreadView *>( currentPage() ) ->showThread( datURL, jumpNum );
slotUpdateThreadTab( datURL );
}
/* show "KitaNavi" view */ /* public slot */
-void KitaThreadTabWidget::slotShowKitaNavi(int mode,
- const KURL& datURL,
- const QString& query,
- int startnum,
- int endnum)
+void KitaThreadTabWidget::slotShowKitaNavi( int mode,
+ const KURL& datURL,
+ const QString& query,
+ int startnum,
+ int endnum )
{
const int margin = 5;
- int count = 0,totalNum = 0;
+ int count = 0, totalNum = 0;
QString headstr = QString::null;
QString footstr = QString::null;
QString anchor = QString::null;
QString cmbstr = QString::null;
QString str, urlstr;
QStringList queries;
- QRegExp qrx(" +");
+ QRegExp qrx( " +" );
bool ext_OR;
QString labelstr = QString::null;
- QString tabstr = QString::null;
-
+ QString tabstr = QString::null;
+
/* set title and label */
- switch(mode){
+ switch ( mode ) {
case KITANAVI_SHOWRES:
-
- if( startnum == endnum ) tabstr = QString().setNum( startnum );
- else tabstr = QString( "%1-%2" ).arg(startnum).arg( endnum );
- break;
-
+
+ if ( startnum == endnum ) tabstr = QString().setNum( startnum );
+ else tabstr = QString( "%1-%2" ).arg( startnum ).arg( endnum );
+ break;
+
case KITANAVI_EXTBYID:
- tabstr = "ID";
- break;
+ tabstr = "ID";
+ break;
case KITANAVI_EXTBYWORD:
- tabstr = Kita::ParseMisc::utf8ToUnicode( KITAUTF8_EXTRACT );
- break;
+ tabstr = Kita::ParseMisc::utf8ToUnicode( KITAUTF8_EXTRACT );
+ break;
case KITANAVI_EXTBYNAME:
- tabstr = "Name";
- break;
+ tabstr = "Name";
+ break;
case KITANAVI_SHOWRESTREE:
- case KITANAVI_SHOWREVRESTREE:
- tabstr = "Tree";
- break;
+ case KITANAVI_SHOWREVRESTREE:
+ tabstr = "Tree";
+ break;
}
/* create KitaThreadView and setup it */
KitaThreadView *view = createView( tabstr );
- if( view == NULL) return;
+ if ( view == NULL ) return ;
+
+ QString toolstr = tabstr + " : " + QString( "[%1] %2" )
+ .arg( Kita::BoardManager::boardName( datURL ) )
+ .arg( Kita::DatManager::threadName( datURL ) );
- QString toolstr = tabstr + " : "+QString( "[%1] %2" )
- .arg( Kita::BoardManager::boardName( datURL ) )
- .arg( Kita::DatManager::threadName( datURL ) );
-
view->setup( datURL, VIEWMODE_KITANAVI );
setTabToolTip( view , toolstr );
totalNum = Kita::DatManager::getResNum( datURL );
labelstr = Kita::DatManager::threadName( datURL ) + " : " + tabstr;
-
- /*---------------------------------------------*/
+
+ /*---------------------------------------------*/
/* copy data from DatManager to KitaThreadView */
- switch(mode){
+ switch ( mode ) {
case KITANAVI_SHOWRES:
- for(int i = QMAX(1,startnum-margin); i <= QMIN(totalNum,endnum+margin); i++){
- if(i == startnum) view->domAppendBelt("belt1");
- str = Kita::DatManager::getDat( datURL ,i);
- view->domAppendData(str,i,i);
- if(i == endnum) view->domAppendBelt("belt2");
- }
- if(startnum == endnum) headstr = QString("No. %1").arg(startnum);
- else headstr = QString("No. %1 - %2").arg(startnum).arg(endnum);
- footstr = headstr;
-
- anchor = QString().setNum(startnum);
-
- break;
-
- /*--------------------------------*/
-
+ for ( int i = QMAX( 1, startnum - margin ); i <= QMIN( totalNum, endnum + margin ); i++ ) {
+ if ( i == startnum ) view->domAppendBelt( "belt1" );
+ str = Kita::DatManager::getDat( datURL , i );
+ view->domAppendData( str, i, i );
+ if ( i == endnum ) view->domAppendBelt( "belt2" );
+ }
+ if ( startnum == endnum ) headstr = QString( "No. %1" ).arg( startnum );
+ else headstr = QString( "No. %1 - %2" ).arg( startnum ).arg( endnum );
+ footstr = headstr;
+
+ anchor = QString().setNum( startnum );
+
+ break;
+
+ /*--------------------------------*/
+
case KITANAVI_EXTBYID:
- for(int i = 1; i<= totalNum; i++){
- if(Kita::DatManager::checkID( datURL, query, i )){
- str = Kita::DatManager::getDat( datURL, i );
- view->domAppendData(str,i,i);
- count++;
- }
- }
- headstr = QString("ID:%1 : [%2]").arg(query).arg(count);
- footstr = headstr;
- anchor = "header";
- break;
-
- /*--------------------------------*/
-
+ for ( int i = 1; i <= totalNum; i++ ) {
+ if ( Kita::DatManager::checkID( datURL, query, i ) ) {
+ str = Kita::DatManager::getDat( datURL, i );
+ view->domAppendData( str, i, i );
+ count++;
+ }
+ }
+ headstr = QString( "ID:%1 : [%2]" ).arg( query ).arg( count );
+ footstr = headstr;
+ anchor = "header";
+ break;
+
+ /*--------------------------------*/
+
case KITANAVI_EXTBYNAME:
- for(int i = 1; i<= totalNum; i++){
- if( Kita::DatManager::getPlainName( datURL, i ) == query ){
- str = Kita::DatManager::getDat( datURL, i );
- view->domAppendData( str, i, i );
- count++;
- }
- }
- headstr = Kita::ParseMisc::utf8ToUnicode(KITAUTF8_EXTRACT)
- +QString(": %1 : [%2]").arg( query ).arg( count );
- footstr = headstr;
- anchor = "header";
- break;
-
- /*--------------------------------*/
+ for ( int i = 1; i <= totalNum; i++ ) {
+ if ( Kita::DatManager::getPlainName( datURL, i ) == query ) {
+ str = Kita::DatManager::getDat( datURL, i );
+ view->domAppendData( str, i, i );
+ count++;
+ }
+ }
+ headstr = Kita::ParseMisc::utf8ToUnicode( KITAUTF8_EXTRACT )
+ + QString( ": %1 : [%2]" ).arg( query ).arg( count );
+ footstr = headstr;
+ anchor = "header";
+ break;
+
+ /*--------------------------------*/
case KITANAVI_EXTBYWORD:
- if(query.at(0) == '|'){ /* OR */
- ext_OR = TRUE;
- str = query.mid(1);
- }
- else{ /* AND */
- ext_OR = FALSE;
- str = query;
- }
- str.replace(Kita::ParseMisc::utf8ToUnicode(KITAUTF8_ZENSPACE)," ");
- str.replace(qrx," "); /* pack space */
- queries = QStringList::split(" ", str);
-
- for(int i = 1; i<= totalNum; i++){
- if(Kita::DatManager::checkWord( datURL, queries, i, ext_OR )){
- str = Kita::DatManager::getDat( datURL, i );
- view->domAppendData(str,i,i);
- count++;
- }
- }
- headstr = Kita::ParseMisc::utf8ToUnicode(KITAUTF8_EXTRACT)
- +QString(": %1 : [%2]").arg(query).arg(count);
- footstr = headstr;
- anchor = "header";
- cmbstr = ":?"+query;
- break;
-
- /*--------------------------------*/
-
+ if ( query.at( 0 ) == '|' ) { /* OR */
+ ext_OR = TRUE;
+ str = query.mid( 1 );
+ } else { /* AND */
+ ext_OR = FALSE;
+ str = query;
+ }
+ str.replace( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_ZENSPACE ), " " );
+ str.replace( qrx, " " ); /* pack space */
+ queries = QStringList::split( " ", str );
+
+ for ( int i = 1; i <= totalNum; i++ ) {
+ if ( Kita::DatManager::checkWord( datURL, queries, i, ext_OR ) ) {
+ str = Kita::DatManager::getDat( datURL, i );
+ view->domAppendData( str, i, i );
+ count++;
+ }
+ }
+ headstr = Kita::ParseMisc::utf8ToUnicode( KITAUTF8_EXTRACT )
+ + QString( ": %1 : [%2]" ).arg( query ).arg( count );
+ footstr = headstr;
+ anchor = "header";
+ cmbstr = ":?" + query;
+ break;
+
+ /*--------------------------------*/
+
case KITANAVI_SHOWRESTREE:
- case KITANAVI_SHOWREVRESTREE:
-
- str = QString("[%1] %2 : No.%3 [%4]<br>")
- .arg( Kita::BoardManager::boardName( datURL ) )
- .arg( Kita::DatManager::threadName( datURL ) )
- .arg(startnum ).arg( endnum );
- urlstr = Kita::DatManager::threadURL( datURL ) + QString().setNum( startnum );
- str += "<a href=\""+urlstr+"\">"+urlstr+"</a><br>";
- str += Kita::DatManager::getHtml( datURL, startnum, startnum );
- if( endnum ){
- str += "<div style=\"background-color: #CCCCCC; text-align: center\"><br></div>";
- str += query;
- }
- view->domSetInnerHTML(str);
-
- break;
+ case KITANAVI_SHOWREVRESTREE:
+
+ str = QString( "[%1] %2 : No.%3 [%4]<br>" )
+ .arg( Kita::BoardManager::boardName( datURL ) )
+ .arg( Kita::DatManager::threadName( datURL ) )
+ .arg( startnum ).arg( endnum );
+ urlstr = Kita::DatManager::threadURL( datURL ) + QString().setNum( startnum );
+ str += "<a href=\"" + urlstr + "\">" + urlstr + "</a><br>";
+ str += Kita::DatManager::getHtml( datURL, startnum, startnum );
+ if ( endnum ) {
+ str += "<div style=\"background-color: #CCCCCC; text-align: center\"><br></div>";
+ str += query;
+ }
+ view->domSetInnerHTML( str );
+
+ break;
default:
- break;
+ break;
}
-
- showPage(view);
- view->domApplyChange(labelstr,headstr,footstr,anchor,cmbstr);
+
+ showPage( view );
+ view->domApplyChange( labelstr, headstr, footstr, anchor, cmbstr );
}
void KitaThreadTabWidget::slotCloseThreadTab( const KURL& url )
{
int max = count();
- if( max == 0 ) return;
+ if ( max == 0 ) return ;
KURL datURL = Kita::ParseMisc::parseURLonly( url );
-
+
int i, i2;
i = i2 = 0;
- while( i < max ){
- KitaThreadView* view = isThreadView( page ( i ) );
- if( view ){
- if( view->datURL() == datURL ){
- slotCloseTab( i2 );
- i2--;
- }
- }
- i++; i2++;
+ while ( i < max ) {
+ KitaThreadView * view = isThreadView( page ( i ) );
+ if ( view ) {
+ if ( view->datURL() == datURL ) {
+ slotCloseTab( i2 );
+ i2--;
+ }
+ }
+ i++; i2++;
}
}
/* create KitaThreadView */ /* private */
KitaThreadView* KitaThreadTabWidget::createView( QString label )
{
- KitaThreadView* view = new KitaThreadView( this );
- if( view ){
- addTab( view, label );
- connect( view, SIGNAL( closeCurrentTab() ), SLOT( slotCloseCurrentTab() ) );
+ KitaThreadView * view = new KitaThreadView( this );
+ if ( view ) {
+ addTab( view, label );
+ connect( view, SIGNAL( closeCurrentTab() ), SLOT( slotCloseCurrentTab() ) );
}
-
+
return view;
}
/* private */
void KitaThreadTabWidget::connectSignals()
{
- Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
+ Kita::SignalCollection * signalCollection = Kita::SignalCollection::getInstance();
connect( signalCollection, SIGNAL( updateThreadTab( const KURL& ) ),
this, SLOT( slotUpdateThreadTab( const KURL& ) ) );
connect( signalCollection, SIGNAL( closeThreadTab( const KURL& ) ),
- SLOT( slotCloseThreadTab( const KURL& )));
+ SLOT( slotCloseThreadTab( const KURL& ) ) );
}
KURL datURL = Kita::ParseMisc::parseURLonly( url );
int max = count();
- if( max == 0 ) return NULL;
+ if ( max == 0 ) return NULL;
int i = 0;
- while( i < max ){
- KitaThreadView* view = isThreadView( page ( i ) );
- if( view ){
- if( view->getViewMode() == VIEWMODE_MAINVIEW ){
-
- if ( view->datURL() == datURL
- || view->datURL().isEmpty() /* default view */
- ) return view;
- }
- }
- i++;
+ while ( i < max ) {
+ KitaThreadView * view = isThreadView( page ( i ) );
+ if ( view ) {
+ if ( view->getViewMode() == VIEWMODE_MAINVIEW ) {
+
+ if ( view->datURL() == datURL
+ || view->datURL().isEmpty() /* default view */
+ ) return view;
+ }
+ }
+ i++;
}
return NULL;
/* private */
KitaThreadView* KitaThreadTabWidget::isThreadView( QWidget* w )
{
- KitaThreadView* view = NULL;
- if( w ){
- if( w->isA( "KitaThreadView" ) ) view = static_cast< KitaThreadView* >( w );
+ KitaThreadView * view = NULL;
+ if ( w ) {
+ if ( w->isA( "KitaThreadView" ) ) view = static_cast< KitaThreadView* >( w );
}
return view;
KURL datURL = Kita::ParseMisc::parseURLonly( url );
KitaThreadView * view = findMainView( datURL );
- if ( view ){
- QString threadName = Kita::DatManager::threadName( datURL );
+ if ( view ) {
+ QString threadName = Kita::DatManager::threadName( datURL );
- setTabLabel( view, threadName );
- setTabToolTip( view, threadName );
+ setTabLabel( view, threadName );
+ setTabToolTip( view, threadName );
}
}
void KitaThreadTabWidget::deleteWidget( QWidget* w )
{
KitaTabWidgetBase::deleteWidget( w );
-
- if ( count() == 0 ){
-
- if( m_mode == TABMODE_THREADVIEW ){
-
- emit setMainCaption( QString::null );
- emit setMainStatusbar( QString::null );
- emit setMainURLLine( QString::null );
-
- /* default view */
- KitaThreadView * threadView = createView( "thread" );
-
- if ( threadView ) {
- showPage( threadView );
- emit switchToSubject();
- }
- }
- else if( m_mode == TABMODE_KITANAVI ){
- static_cast< KitaDockWidgetBase* >( parentWidget() )->slotHideDock();
- }
+
+ if ( count() == 0 ) {
+
+ if ( m_mode == TABMODE_THREADVIEW ) {
+
+ emit setMainCaption( QString::null );
+ emit setMainStatusbar( QString::null );
+ emit setMainURLLine( QString::null );
+
+ /* default view */
+ KitaThreadView * threadView = createView( "thread" );
+
+ if ( threadView ) {
+ showPage( threadView );
+ emit switchToSubject();
+ }
+ } else if ( m_mode == TABMODE_KITANAVI ) {
+ static_cast< KitaDockWidgetBase* >( parentWidget() ) ->slotHideDock();
+ }
}
}
void KitaThreadTabWidget::setupActions()
{
KStdAction::copy( this, SLOT( slotCopyText() ), actionCollection() );
-
+
new KAction( i18n( "Open with Web Browser" ),
0,
this,
new KAction( i18n( "copy URL" ),
0,
this,
- SLOT( slotCopyURL() ),
+ SLOT( slotCopyURL() ),
actionCollection(),
- "threadview_copyurl" );
-
+ "threadview_copyurl" );
+
new KAction( i18n( "Copy title and URL" ),
0,
this,
- SLOT( slotCopyTitleURL() ),
+ SLOT( slotCopyTitleURL() ),
actionCollection(),
- "threadview_copytitleurl" );
-
+ "threadview_copytitleurl" );
+
new KAction( i18n( "Find" ),
"find",
KStdAccel::find(),
SLOT( slotFocusSearchCombo() ),
actionCollection(),
"threadview_find" );
-
+
KStdAction::findNext( this,
- SLOT( slotSearchNext() ),
- actionCollection(),
- "threadview_findnext");
+ SLOT( slotSearchNext() ),
+ actionCollection(),
+ "threadview_findnext" );
KStdAction::findPrev( this,
- SLOT( slotSearchPrev() ),
- actionCollection(),
- "threadview_findprev");
+ SLOT( slotSearchPrev() ),
+ actionCollection(),
+ "threadview_findprev" );
new KAction( i18n( "go back anchor" ),
- "2leftarrow",
- Key_Backspace,
- this,
- SLOT( slotGobackAnchor() ),
- actionCollection(),
- "threadview_goback" );
+ "2leftarrow",
+ Key_Backspace,
+ this,
+ SLOT( slotGobackAnchor() ),
+ actionCollection(),
+ "threadview_goback" );
new KAction( i18n( "Start" ),
- "up",
- Key_Home,
- this,
- SLOT( slotGotoHeader() ),
- actionCollection(),
- "threadview_gotoheader" );
-
+ "up",
+ Key_Home,
+ this,
+ SLOT( slotGotoHeader() ),
+ actionCollection(),
+ "threadview_gotoheader" );
+
new KAction( i18n( "End" ),
- "down",
- Key_End,
- this,
- SLOT( slotGotoFooter() ),
- actionCollection(),
- "threadview_gotofooter" );
+ "down",
+ Key_End,
+ this,
+ SLOT( slotGotoFooter() ),
+ actionCollection(),
+ "threadview_gotofooter" );
new KAction( i18n( "Reload" ),
"reload",
actionCollection(),
"threadview_reload" );
- new KAction(i18n("Stop"),
- "stop",
- Key_Escape,
- this,
- SLOT(slotStopLoading()),
- actionCollection(),
- "threadview_stop");
+ new KAction( i18n( "Stop" ),
+ "stop",
+ Key_Escape,
+ this,
+ SLOT( slotStopLoading() ),
+ actionCollection(),
+ "threadview_stop" );
- new KAction(i18n("Delete"),
- "edittrash",
- Key_Delete,
- this,
- SLOT(slotDeleteButtonClicked()),
- actionCollection(),
- "threadview_delete");
+ new KAction( i18n( "Delete" ),
+ "edittrash",
+ Key_Delete,
+ this,
+ SLOT( slotDeleteButtonClicked() ),
+ actionCollection(),
+ "threadview_delete" );
}
/* copy selected text (Ctrl+C) */ /* public slot */
void KitaThreadTabWidget::slotCopyText()
{
- QWidget* w = currentPage();
+ QWidget * w = currentPage();
KitaThreadView * view = isThreadView( w );
- if( view ){
- QClipboard * clipboard = QApplication::clipboard();
- QString text = view->selectedText();
- clipboard->setText( text, QClipboard::Clipboard );
+ if ( view ) {
+ QClipboard * clipboard = QApplication::clipboard();
+ QString text = view->selectedText();
+ clipboard->setText( text, QClipboard::Clipboard );
}
}
/* public slot */
void KitaThreadTabWidget::slotOpenBrowser( int idx )
{
- QWidget* w = currentPage();
- if( idx != -1 ) w = page( idx );
+ QWidget * w = currentPage();
+ if ( idx != -1 ) w = page( idx );
KURL url;
-
- if( w ){
-
- KitaThreadView * view = isThreadView( w );
- if( view ){
- new KRun( view->threadURL() );
- return;
- }
-
- KParts::Part* part = findPartFromWidget( w );
- if( part && part->inherits( "KParts::ReadOnlyPart" ) ){
- url = static_cast<KParts::ReadOnlyPart*>( part )->url();
- new KRun( url );
- return;
- }
+
+ if ( w ) {
+
+ KitaThreadView * view = isThreadView( w );
+ if ( view ) {
+ new KRun( view->threadURL() );
+ return ;
+ }
+
+ KParts::Part* part = findPartFromWidget( w );
+ if ( part && part->inherits( "KParts::ReadOnlyPart" ) ) {
+ url = static_cast<KParts::ReadOnlyPart*>( part ) ->url();
+ new KRun( url );
+ return ;
+ }
}
}
/* public slot */
void KitaThreadTabWidget::slotCopyURL( int idx )
{
- QWidget* w = currentPage();
- if( idx != -1 ) w = page( idx );
-
+ QWidget * w = currentPage();
+ if ( idx != -1 ) w = page( idx );
+
QClipboard* clipboard = QApplication::clipboard();
- KitaThreadView * view = isThreadView( w );
- if( view ){
- KURL datURL = view->datURL();
-
- QString cliptxt = Kita::DatManager::threadURL( datURL );
- clipboard->setText( cliptxt , QClipboard::Clipboard );
- clipboard->setText( cliptxt , QClipboard::Selection );
+ KitaThreadView * view = isThreadView( w );
+ if ( view ) {
+ KURL datURL = view->datURL();
+
+ QString cliptxt = Kita::DatManager::threadURL( datURL );
+ clipboard->setText( cliptxt , QClipboard::Clipboard );
+ clipboard->setText( cliptxt , QClipboard::Selection );
}
}
/* public slot */
void KitaThreadTabWidget::slotCopyTitleURL( int idx )
{
- QWidget* w = currentPage();
- if( idx != -1 ) w = page( idx );
-
+ QWidget * w = currentPage();
+ if ( idx != -1 ) w = page( idx );
+
QClipboard* clipboard = QApplication::clipboard();
- KitaThreadView * view = isThreadView( w );
- if( view ){
- KURL datURL = view->datURL();
-
- QString cliptxt = Kita::DatManager::threadName( datURL )
- + "\n" + Kita::DatManager::threadURL( datURL );
- clipboard->setText( cliptxt , QClipboard::Clipboard );
- clipboard->setText( cliptxt , QClipboard::Selection );
+ KitaThreadView * view = isThreadView( w );
+ if ( view ) {
+ KURL datURL = view->datURL();
+
+ QString cliptxt = Kita::DatManager::threadName( datURL )
+ + "\n" + Kita::DatManager::threadURL( datURL );
+ clipboard->setText( cliptxt , QClipboard::Clipboard );
+ clipboard->setText( cliptxt , QClipboard::Selection );
}
}
/* public slot */
void KitaThreadTabWidget::slotFocusSearchCombo()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->focusSearchCombo();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->focusSearchCombo();
}
/* public slot */
void KitaThreadTabWidget::slotSearchNext()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotSearchNext();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotSearchNext();
}
/* public slot */
void KitaThreadTabWidget::slotSearchPrev()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotSearchPrev();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotSearchPrev();
}
/* public slot */
void KitaThreadTabWidget::slotGobackAnchor()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotGobackAnchor();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotGobackAnchor();
}
/* public slot */
void KitaThreadTabWidget::slotGotoHeader()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotGotoHeader();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotGotoHeader();
}
/* public slot */
void KitaThreadTabWidget::slotGotoFooter()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotGotoFooter();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotGotoFooter();
}
/* public slot */
void KitaThreadTabWidget::slotReloadButton()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotReloadButton();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotReloadButton();
}
/* public slot */
void KitaThreadTabWidget::slotStopLoading()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotStopLoading();
-}
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotStopLoading();
+}
/* public slot */
void KitaThreadTabWidget::slotDeleteButtonClicked()
{
- KitaThreadView * view = isThreadView( currentPage() );
- if( view ) view->slotDeleteButtonClicked();
+ KitaThreadView * view = isThreadView( currentPage() );
+ if ( view ) view->slotDeleteButtonClicked();
}
-KitaThreadTabBar::KitaThreadTabBar( QWidget* parent, const char* name ) : KitaTabBarBase( parent, name ){}
+KitaThreadTabBar::KitaThreadTabBar( QWidget* parent, const char* name ) : KitaTabBarBase( parent, name ) {}
-KitaThreadTabBar::~KitaThreadTabBar(){}
+KitaThreadTabBar::~KitaThreadTabBar() {}
/* private */ /* virtual */
void KitaThreadTabBar::showPopupMenu( int idx, QPoint global )
{
enum{
- MENU_CLOSE,
+ MENU_CLOSE,
MENU_CLOSEOTHER,
MENU_CLOSELEFT,
- MENU_CLOSERIGHT,
+ MENU_CLOSERIGHT,
MENU_OPENBROWSER,
MENU_COPYURL,
- MENU_COPYTITLE
+ MENU_COPYTITLE
};
KitaThreadTabWidget* tabwidget = static_cast<KitaThreadTabWidget*>( parentWidget() );
KPopupMenu* popup = new KPopupMenu( this );
popup->clear();
-
+
popup->insertItem( i18n( "Close this tab" ) , MENU_CLOSE );
- collection->action( "tab_prevtab" )->plug( popup );
- collection->action( "tab_nexttab" )->plug( popup );
+ collection->action( "tab_prevtab" ) ->plug( popup );
+ collection->action( "tab_nexttab" ) ->plug( popup );
popup->insertSeparator();
- popup->insertItem( i18n( "Close Other Tabs" ) , MENU_CLOSEOTHER );
+ popup->insertItem( i18n( "Close Other Tabs" ) , MENU_CLOSEOTHER );
popup->insertItem( i18n( "Close right tabs" ) , MENU_CLOSERIGHT );
popup->insertItem( i18n( "Close left tabs" ) , MENU_CLOSELEFT );
- collection->action( "tab_closealltab" )->plug( popup );
+ collection->action( "tab_closealltab" ) ->plug( popup );
popup->insertSeparator();
-
+
popup->insertItem( i18n( "Open with Web Browser" ) , MENU_OPENBROWSER );
popup->insertItem( i18n( "Copy URL" ) , MENU_COPYURL );
popup->insertItem( i18n( "Copy title and URL" ) , MENU_COPYTITLE );
-
+
popup->insertSeparator();
- collection->action( "tab_configkeys" )->plug( popup );
+ collection->action( "tab_configkeys" ) ->plug( popup );
+
-
int ret = popup->exec( global );
delete popup;
-
- switch( ret ){
+
+ switch ( ret ) {
case MENU_CLOSE: tabwidget->slotCloseTab( idx ); break;
case MENU_CLOSEOTHER: tabwidget->slotCloseOtherTab( idx ); break;
case MENU_CLOSERIGHT: tabwidget->slotCloseRightTab( idx ); break;
case MENU_CLOSELEFT: tabwidget->slotCloseLeftTab( idx ); break;
case MENU_OPENBROWSER: tabwidget->slotOpenBrowser( idx ); break;
case MENU_COPYURL: tabwidget->slotCopyURL( idx ); break;
- case MENU_COPYTITLE: tabwidget->slotCopyTitleURL( idx ); break;
+ case MENU_COPYTITLE: tabwidget->slotCopyTitleURL( idx ); break;
}
}
/* Don't forget to call setup later ! */
KitaThreadDock::KitaThreadDock( KDockManager* dockManager,
- const char* name,
- const QPixmap &pixmap,
- QWidget* parent,
- const QString& strCaption,
- const QString& strTabPageLabel,
- WFlags f )
- :KitaDockWidgetBase( dockManager, name, pixmap, parent, strCaption, strTabPageLabel, f ){}
+ const char* name,
+ const QPixmap &pixmap,
+ QWidget* parent,
+ const QString& strCaption,
+ const QString& strTabPageLabel,
+ WFlags f )
+ : KitaDockWidgetBase( dockManager, name, pixmap, parent, strCaption, strTabPageLabel, f ) {}
-KitaThreadDock::~KitaThreadDock(){}
+KitaThreadDock::~KitaThreadDock() {}
/*-----------------------------*/
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
connect( signalCollection, SIGNAL( switchToThread() ),
- SLOT( slotShowThreadDock() ) );
-
+ SLOT( slotShowThreadDock() ) );
+
return m_threadTab;
}
{
showDock();
- if( m_threadTab ) m_threadTab->slotShowMainThread( url, withNewTab );
+ if ( m_threadTab ) m_threadTab->slotShowMainThread( url, withNewTab );
}
KitaThreadTabWidget* KitaThreadDock::setupAsKitaNavi()
{
/* create KitaNaviTabWidget */
- m_threadTab = new KitaThreadTabWidget( TABMODE_KITANAVI, this, "Kita Navi");
+ m_threadTab = new KitaThreadTabWidget( TABMODE_KITANAVI, this, "Kita Navi" );
setWidget( m_threadTab );
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
connect( signalCollection, SIGNAL( switchToKitanavi() ),
- SLOT( slotShowThreadDock() ) );
-
+ SLOT( slotShowThreadDock() ) );
+
return m_threadTab;
}
/* public */
void KitaThreadDock::connectNaviSignals()
{
- Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
+ Kita::SignalCollection * signalCollection = Kita::SignalCollection::getInstance();
- connect( signalCollection, SIGNAL( showKitaNavi( const KURL& , int , int )),
- SLOT( slotShowKitaNavi( const KURL& , int , int )));
- connect( signalCollection, SIGNAL( showKitaNaviByID( const KURL& , QString )),
- SLOT( slotShowKitaNaviByID( const KURL& , QString )));
- connect( signalCollection, SIGNAL( showKitaNaviByWord( const KURL& , QString)),
- SLOT( slotShowKitaNaviByWord( const KURL& , QString)));
- connect( signalCollection, SIGNAL( showKitaNaviByName( const KURL& , QString)),
- SLOT( slotShowKitaNaviByName( const KURL& , QString)));
- connect( signalCollection, SIGNAL( showKitaNaviResTree( const KURL&, int )),
- SLOT( slotShowKitaNaviResTree( const KURL&, int )));
- connect( signalCollection, SIGNAL( showKitaNaviRevResTree( const KURL&, int )),
- SLOT( slotShowKitaNaviRevResTree( const KURL&, int )));
+ connect( signalCollection, SIGNAL( showKitaNavi( const KURL& , int , int ) ),
+ SLOT( slotShowKitaNavi( const KURL& , int , int ) ) );
+ connect( signalCollection, SIGNAL( showKitaNaviByID( const KURL& , QString ) ),
+ SLOT( slotShowKitaNaviByID( const KURL& , QString ) ) );
+ connect( signalCollection, SIGNAL( showKitaNaviByWord( const KURL& , QString ) ),
+ SLOT( slotShowKitaNaviByWord( const KURL& , QString ) ) );
+ connect( signalCollection, SIGNAL( showKitaNaviByName( const KURL& , QString ) ),
+ SLOT( slotShowKitaNaviByName( const KURL& , QString ) ) );
+ connect( signalCollection, SIGNAL( showKitaNaviResTree( const KURL&, int ) ),
+ SLOT( slotShowKitaNaviResTree( const KURL&, int ) ) );
+ connect( signalCollection, SIGNAL( showKitaNaviRevResTree( const KURL&, int ) ),
+ SLOT( slotShowKitaNaviRevResTree( const KURL&, int ) ) );
}
/* show Thread Dock */ /* private slot */
void KitaThreadDock::slotShowThreadDock()
{
- QWidget* topWidget = topLevelWidget();
+ QWidget * topWidget = topLevelWidget();
if ( topWidget->isMinimized() ) topWidget->showNormal();
topWidget->raise();
topWidget->setActiveWindow();
void KitaThreadDock::slotShowKitaNavi( const KURL& datURL, int startnum, int endnum )
{
showDock();
-
+
KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
m_threadTab->slotShowKitaNavi( KITANAVI_SHOWRES, parsedURL, QString::null, startnum, endnum );
}
void KitaThreadDock::slotShowKitaNaviByID( const KURL& datURL, QString strid )
{
showDock();
-
+
KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
m_threadTab->slotShowKitaNavi( KITANAVI_EXTBYID, parsedURL, strid, 0, 0 );
}
void KitaThreadDock::slotShowKitaNaviByWord( const KURL& datURL, QString query )
{
showDock();
-
+
KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
- m_threadTab->slotShowKitaNavi( KITANAVI_EXTBYWORD, parsedURL, query, 0, 0 );
+ m_threadTab->slotShowKitaNavi( KITANAVI_EXTBYWORD, parsedURL, query, 0, 0 );
}
void KitaThreadDock::slotShowKitaNaviByName( const KURL& datURL, QString query )
{
showDock();
-
+
KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
- m_threadTab->slotShowKitaNavi( KITANAVI_EXTBYNAME, parsedURL, query, 0, 0 );
+ m_threadTab->slotShowKitaNavi( KITANAVI_EXTBYNAME, parsedURL, query, 0, 0 );
}
void KitaThreadDock::slotShowKitaNaviResTree( const KURL& datURL, int resNum )
{
showDock();
-
+
int num;
KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
- QString htmlstr = Kita::DatManager::getTreeByRes( parsedURL, resNum, num);
- m_threadTab->slotShowKitaNavi( KITANAVI_SHOWRESTREE, parsedURL, htmlstr, resNum, num);
+ QString htmlstr = Kita::DatManager::getTreeByRes( parsedURL, resNum, num );
+ m_threadTab->slotShowKitaNavi( KITANAVI_SHOWRESTREE, parsedURL, htmlstr, resNum, num );
}
KITANAVI_SHOWRES,
KITANAVI_EXTBYID,
KITANAVI_EXTBYWORD,
- KITANAVI_EXTBYNAME,
+ KITANAVI_EXTBYNAME,
KITANAVI_SHOWRESTREE,
- KITANAVI_SHOWREVRESTREE,
- KITANAVI_TITLE
+ KITANAVI_SHOWREVRESTREE,
+ KITANAVI_TITLE
};
-/*-----------------------------------------------*/
+/*-----------------------------------------------*/
class KitaThreadTabWidget : public KitaTabWidgetBase
Q_OBJECT
int m_mode;
-
+
public:
KitaThreadTabWidget( int mode, QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
~KitaThreadTabWidget();
-
+
public slots:
void slotShowMainThread( const KURL& datURL, bool withNewTab );
void slotShowKitaNavi( int mode, const KURL& datURL, const QString& query, int startnum, int endnum );
- void slotCloseThreadTab( const KURL& url );
+ void slotCloseThreadTab( const KURL& url );
private:
KitaThreadView* createView( QString label );
void connectSignals();
KitaThreadView* findMainView( const KURL& url );
KitaThreadView* isThreadView( QWidget* w );
-
+
private slots:
void slotUpdateThreadTab( const KURL& url );
-
+
protected:
virtual void deleteWidget( QWidget* w );
-
+
/*------------------------------------*/
/* KitaThreadView actions */
private:
void setupActions();
-
+
public slots:
void slotCopyText();
void slotOpenBrowser( int idx = -1 );
void slotCopyURL( int idx = -1 );
- void slotCopyTitleURL( int idx = -1 );
+ void slotCopyTitleURL( int idx = -1 );
void slotFocusSearchCombo();
void slotSearchNext();
void slotSearchPrev();
void slotGotoHeader();
void slotGotoFooter();
void slotReloadButton();
- void slotStopLoading();
- void slotDeleteButtonClicked();
+ void slotStopLoading();
+ void slotDeleteButtonClicked();
};
/*------------------------------------------------------------*/
-class KitaThreadDock : public KitaDockWidgetBase{
+class KitaThreadDock : public KitaDockWidgetBase
+{
Q_OBJECT
- KitaThreadTabWidget* m_threadTab;
-
+ KitaThreadTabWidget* m_threadTab;
+
public:
KitaThreadDock( KDockManager* dockManager,
- const char* name,
- const QPixmap &pixmap,
- QWidget* parent = 0L,
- const QString& strCaption = QString::null,
- const QString& strTabPageLabel = QString::fromLatin1( " " ),
- WFlags f = 0);
+ const char* name,
+ const QPixmap &pixmap,
+ QWidget* parent = 0L,
+ const QString& strCaption = QString::null,
+ const QString& strTabPageLabel = QString::fromLatin1( " " ),
+ WFlags f = 0 );
~KitaThreadDock();
/* Main Thread view */
-
-public:
+
+public:
KitaThreadTabWidget* setupAsMainView();
public slots:
void slotShowThread( const KURL& datURL, bool withNewTab );
-
- /* Kita Navi */
-
+
+ /* Kita Navi */
+
public:
KitaThreadTabWidget* setupAsKitaNavi();
- void connectNaviSignals();
+ void connectNaviSignals();
private slots:
void slotShowThreadDock();
-
- void slotShowKitaNavi( const KURL& datURL, int startnum, int endnum);
- void slotShowKitaNaviByID( const KURL& datURL, QString strid);
- void slotShowKitaNaviByWord( const KURL& datURL, QString query);
- void slotShowKitaNaviByName( const KURL& datURL, QString query );
- void slotShowKitaNaviResTree( const KURL& datURL, int resNum);
- void slotShowKitaNaviRevResTree( const KURL& datURL, int resNum );
+
+ void slotShowKitaNavi( const KURL& datURL, int startnum, int endnum );
+ void slotShowKitaNaviByID( const KURL& datURL, QString strid );
+ void slotShowKitaNaviByWord( const KURL& datURL, QString query );
+ void slotShowKitaNaviByName( const KURL& datURL, QString query );
+ void slotShowKitaNaviResTree( const KURL& datURL, int resNum );
+ void slotShowKitaNaviRevResTree( const KURL& datURL, int resNum );
};
/* close view which URL is url. */ /* public slot */
void KitaWriteTabWidget::slotCloseWriteTab( const KURL& url )
{
- KitaWriteView* view = findWriteView( url );
+ KitaWriteView * view = findWriteView( url );
if ( view ) slotCloseTab( indexOf( view ) );
}
KitaWriteView* KitaWriteTabWidget::findWriteView( const KURL& url )
{
KURL datURL = Kita::getDatURL( url );
- if( datURL.isEmpty() ) return NULL;
+ if ( datURL.isEmpty() ) return NULL;
int max = count();
if ( max == 0 ) return NULL;
class KitaWriteView;
-/*-----------------------------------------------*/
+/*-----------------------------------------------*/
class KitaWriteTabWidget : public KitaTabWidgetBase
{
Q_OBJECT
-
+
public:
KitaWriteTabWidget( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
~KitaWriteTabWidget();
public slots:
void slotShowWriteView( const KURL& url, const QString& resStr );
- void slotCreateNewThread( const KURL& url, const QString& resStr, const QString& subject);
- void slotCloseWriteTab( const KURL& url );
-
+ void slotCreateNewThread( const KURL& url, const QString& resStr, const QString& subject );
+ void slotCloseWriteTab( const KURL& url );
+
private:
void openWriteView( int mode, const KURL& url, const QString& resStr, const QString& subject );
- void connectSignals();
+ void connectSignals();
KitaWriteView* findWriteView( const KURL& url );
KitaWriteView* isWriteView( QWidget* w );
private slots:
void slotChangeWriteTab( const KURL& url );
-
+
protected:
virtual void deleteWidget( QWidget* w );
/*------------------------------------*/
/* KitaWriteTabWidget actions */
-
-private:
+
+private:
void setupActions();
-
+
public slots:
void slotQuoteClipboard();
};
/*------------------------------------------------------------*/
-class KitaWriteDock : public KitaDockWidgetBase{
+class KitaWriteDock : public KitaDockWidgetBase
+{
Q_OBJECT
- KitaWriteTabWidget* m_writeTab;
-
+ KitaWriteTabWidget* m_writeTab;
+
public:
KitaWriteDock( KDockManager* dockManager,
- const char* name,
- const QPixmap &pixmap,
- QWidget* parent = 0L,
- const QString& strCaption = QString::null,
- const QString& strTabPageLabel = QString::fromLatin1( " " ),
- WFlags f = 0);
+ const char* name,
+ const QPixmap &pixmap,
+ QWidget* parent = 0L,
+ const QString& strCaption = QString::null,
+ const QString& strTabPageLabel = QString::fromLatin1( " " ),
+ WFlags f = 0 );
~KitaWriteDock();
KitaWriteTabWidget* setup();
public slots:
void slotShowWriteView( const KURL& url, const QString& resStr );
- void slotCreateNewThread( const KURL& url, const QString& resStr, const QString& subject);
+ void slotCreateNewThread( const KURL& url, const QString& resStr, const QString& subject );
};
{
QString orgData;
init();
-
+
QString cachePath = Kita::Cache::getPath( m_datURL );
if ( cachePath != QString::null ) {
}
}
- if( orgData == QString::null ) return;
+ if ( orgData == QString::null ) return ;
m_dataSize = orgData.length();
- switch( m_bbstype ){
+ switch ( m_bbstype ) {
case Board_2ch:
- case Board_MachiBBS: /* Machi BBS's data is already parsed as 2ch dat. */
+ case Board_MachiBBS: /* Machi BBS's data is already parsed as 2ch dat. */
- {
- QString tmpData = Kita::qcpToUnicode( orgData );
- QStringList tmpList = QStringList::split( "\n", tmpData );
- emit receiveData( tmpList );
- }
- break;
+ {
+ QString tmpData = Kita::qcpToUnicode( orgData );
+ QStringList tmpList = QStringList::split( "\n", tmpData );
+ emit receiveData( tmpList );
+ }
+ break;
default:
- emitDatLineList( orgData );
- break;
+ emitDatLineList( orgData );
+ break;
}
}
m_threadData = QString::null;
m_firstReceive = FALSE;
m_invalidDataReceived = FALSE;
- m_lastLine = QString::null;
+ m_lastLine = QString::null;
/* set URL of data */
QString getURL;
- switch( m_bbstype ){
+ switch ( m_bbstype ) {
case Board_MachiBBS:
- getURL = Kita::getThreadURL( m_datURL );
- if( m_readNum > 0 ) getURL += "&START=" + QString().setNum( m_readNum +1 );
- Kita::InitParseMachiBBS();
- break;
+ getURL = Kita::getThreadURL( m_datURL );
+ if ( m_readNum > 0 ) getURL += "&START=" + QString().setNum( m_readNum + 1 );
+ Kita::InitParseMachiBBS();
+ break;
case Board_JBBS:
- getURL = Kita::getThreadURL( m_datURL );
- getURL.replace( "read.cgi", "rawmode.cgi" ); /* adhoc... */
- if( m_readNum > 0 ) getURL += "/" + QString().setNum( m_readNum +1 ) + "-";
- break;
+ getURL = Kita::getThreadURL( m_datURL );
+ getURL.replace( "read.cgi", "rawmode.cgi" ); /* adhoc... */
+ if ( m_readNum > 0 ) getURL += "/" + QString().setNum( m_readNum + 1 ) + "-";
+ break;
default:
- getURL = m_datURL.prettyURL();
+ getURL = m_datURL.prettyURL();
}
-
+
/* set UserAgent */
const QString useragent = QString( "Monazilla/1.00 (Kita/%1)" ).arg( VERSION );
KIO::SlaveConfig::self() ->setConfigData( "http",
- KURL( getURL ).host(),
- "UserAgent", useragent );
+ KURL( getURL ).host(),
+ "UserAgent", useragent );
/* create new job */
KIO::TransferJob* job = KIO::get( getURL, true, false );
/* resume */
if ( m_bbstype != Board_MachiBBS
- && m_bbstype != Board_JBBS
- && m_dataSize > 0 ) {
+ && m_bbstype != Board_JBBS
+ && m_dataSize > 0 ) {
m_firstReceive = TRUE; /* remove first char (i.e. \n). see also slotReceiveThreadData() */
job->addMetaData( "resume", QString::number( m_dataSize - 1 ) );
job->addMetaData( "AllowCompressedPage", "false" );
{
QString cstr( data );
- if( m_bbstype == Board_MachiBBS
- || m_bbstype == Board_JBBS ){
-
- emitDatLineList( cstr );
- return;
+ if ( m_bbstype == Board_MachiBBS
+ || m_bbstype == Board_JBBS ) {
+
+ emitDatLineList( cstr );
+ return ;
}
-
+
/* check if received data is invalid ( or broken ). */
if ( ( m_dataSize > 0 && responseCode() != 206 )
|| ( m_firstReceive && cstr[ 0 ] != '\n' )
{
QStringList lineList;
QStringList datLineList;
- if( dataStream == QString::null ) return;
+ if ( dataStream == QString::null ) return ;
bool endIsLF = FALSE;
if ( dataStream.at( dataStream.length() - 1 ) == '\n' ) endIsLF = TRUE;
/* split the stream */
m_lastLine += dataStream;
lineList = QStringList::split( "\n", m_lastLine );
- m_lastLine = QString::null;
+ m_lastLine = QString::null;
/* save the last line */
- if( !endIsLF ){
+ if ( !endIsLF ) {
+
+ QStringList::iterator lastit = lineList.end();
+ lastit--;
+ if ( lastit != lineList.end() ) {
- QStringList::iterator lastit = lineList.end();
- lastit--;
- if ( lastit != lineList.end() ) {
-
m_lastLine = ( *lastit );
lineList.remove( lastit );
}
}
/* filtering */
-
+
/* convert lines into 2ch dat */
int count = lineList.count();
- for ( int i = 0; i < count ; ++i ){
+ for ( int i = 0; i < count ; ++i ) {
if ( lineList[ i ] != QString::null ) {
-
- QString line;
- int nextNum = m_readNum +1;
-
- /* convert line */
- switch( m_bbstype ){
-
- case Board_MachiBBS:
- line = Kita::ParseMachiBBSOneLine( lineList[ i ] , nextNum );
- break;
-
- case Board_JBBS:
- line = Kita::ParseJBBSOneLine( lineList[ i ] , nextNum );
- break;
-
- case Board_FlashCGI:
- line = Kita::ParseFlashCGIOneLine( lineList[ i ] );
- break;
-
- default:
- line = lineList[ i ];
- }
-
- if( line == QString::null ) continue;
-
- /* add abone lines */
- const QString aboneStr = "abone<><><>abone<>";
- while( nextNum > m_readNum +1 ){
- datLineList += aboneStr;
- m_threadData += aboneStr +"\n";
- ++m_readNum;
- }
-
- /* save line */
- if( m_bbstype == Board_MachiBBS ) m_threadData += line + "\n";
- else m_threadData += lineList[ i ] + "\n";
- ++m_readNum;
-
- /* encode line */
- switch( m_bbstype ){
-
- case Board_JBBS:
- datLineList += Kita::ecuToUnicode( line );
- break;
-
- default:
- datLineList += Kita::qcpToUnicode( line );
- }
+
+ QString line;
+ int nextNum = m_readNum + 1;
+
+ /* convert line */
+ switch ( m_bbstype ) {
+
+ case Board_MachiBBS:
+ line = Kita::ParseMachiBBSOneLine( lineList[ i ] , nextNum );
+ break;
+
+ case Board_JBBS:
+ line = Kita::ParseJBBSOneLine( lineList[ i ] , nextNum );
+ break;
+
+ case Board_FlashCGI:
+ line = Kita::ParseFlashCGIOneLine( lineList[ i ] );
+ break;
+
+ default:
+ line = lineList[ i ];
+ }
+
+ if ( line == QString::null ) continue;
+
+ /* add abone lines */
+ const QString aboneStr = "abone<><><>abone<>";
+ while ( nextNum > m_readNum + 1 ) {
+ datLineList += aboneStr;
+ m_threadData += aboneStr + "\n";
+ ++m_readNum;
+ }
+
+ /* save line */
+ if ( m_bbstype == Board_MachiBBS ) m_threadData += line + "\n";
+ else m_threadData += lineList[ i ] + "\n";
+ ++m_readNum;
+
+ /* encode line */
+ switch ( m_bbstype ) {
+
+ case Board_JBBS:
+ datLineList += Kita::ecuToUnicode( line );
+ break;
+
+ default:
+ datLineList += Kita::qcpToUnicode( line );
+ }
}
}
if ( m_invalidDataReceived ) return ;
// "+OK ....../1024K\tLocation:temp/\n"
- if ( m_threadData.isEmpty() && cstr[0] == '+' ) {
+ if ( m_threadData.isEmpty() && cstr[ 0 ] == '+' ) {
// skip first line.
int index = cstr.find( '\n' );
cstr = cstr.mid( index + 1 );
Access( const KURL& datURL );
virtual ~Access() {};
- void init();
+ void init();
QString get();
void killJob();
void stopJob();
protected:
void writeCacheData();
- void emitDatLineList( const QString& dataStream );
+ void emitDatLineList( const QString& dataStream );
const KURL m_datURL;
KIO::Job* m_currentJob;
int m_dataSize;
bool m_firstReceive;
bool m_invalidDataReceived;
- int m_bbstype;
+ int m_bbstype;
int m_readNum;
QString m_lastLine;
/***************************************************************************
- * Copyright (C) 2004 by Kita Developers *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2004 by Kita Developers *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "account.h"
#include <config.h>
bool Account::login( const QString& userID, const QString& password )
{
- return getInstance()->loginInternal( userID, password );
+ return getInstance() ->loginInternal( userID, password );
}
bool Account::loginInternal( const QString& userID, const QString& password )
m_data.resize( 0 );
KURL url( "https://2chv.tora3.net/futen.cgi" );
- QString postData = QString("ID=") + userID + QString("&PW=") + password;
+ QString postData = QString( "ID=" ) + userID + QString( "&PW=" ) + password;
KIO::SlaveConfig::self() ->setConfigData( "https",
url.host(),
void Account::slotResult( KIO::Job* job )
{
m_job = 0;
- if ( job->error() )
- {
+ if ( job->error() ) {
job->showErrorDialog();
}
QString str( m_data );
QRegExp regexp( "SESSION-ID=(.*)" );
- if ( regexp.search( str ) == -1 )
- {
+ if ( regexp.search( str ) == -1 ) {
m_sessionID = QString::null;
m_isLogged = false;
- }
- else
- {
+ } else {
QString value = regexp.cap( 1 );
QRegExp error( "^ERROR:p+$" );
- if ( error.search( value ) == -1 )
- {
+ if ( error.search( value ) == -1 ) {
m_isLogged = true;
m_sessionID = value;
- }
- else
- {
+ } else {
m_isLogged = false;
m_sessionID = QString::null;
}
/***************************************************************************
- * Copyright (C) 2004 by Kita Developers *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2004 by Kita Developers *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef KITAACCOUNT_H
#define KITAACCOUNT_H
void slotReceiveData( KIO::Job* job, const QByteArray& data );
void slotResult( KIO::Job* job );
public:
- static const QString& getSessionID() { return getInstance()->m_sessionID; }
- static bool isLogged() { return getInstance()->m_isLogged; }
+ static const QString& getSessionID() { return getInstance() ->m_sessionID; }
+ static bool isLogged() { return getInstance() ->m_isLogged; }
static bool login( const QString& userID, const QString& password );
};
/* BoardData */
BoardData::BoardData( const QString& boardName,
- const QString& hostname,
- const QString& rootPath,
- const QString& delimiter,
- const QString& bbsPath,
- const QString& ext,
- int boardtype )
+ const QString& hostname,
+ const QString& rootPath,
+ const QString& delimiter,
+ const QString& bbsPath,
+ const QString& ext,
+ int boardtype )
{
m_readIdx = FALSE;
m_boardName = boardName;
setHostName( hostname );
/* create default key */
- QStringList keyHosts = m_hostname;
+ QStringList keyHosts = m_hostname;
createKeys( keyHosts );
/* reset SETTING.TXT */
/* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
m_basePath = m_hostname + m_rootPath + m_bbsPath + "/";
- switch( m_type ){
+ switch ( m_type ) {
- case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
- m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + "?BBS=" + m_bbsPath.mid( 1 );
- break;
+ case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
+ m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + "?BBS=" + m_bbsPath.mid( 1 );
+ break;
- /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+ /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
default:
- m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + m_bbsPath + "/";
- break;
+ m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + m_bbsPath + "/";
+ break;
}
}
void BoardData::setSettingLoaded( bool set )
{
m_settingLoaded = set;
- if( ! set ){
- m_defaultName = QString::null;
- m_linenum = 0;
- m_msgCount = 0;
- m_titleImgURL = QString::null;
- }
+ if ( ! set ) {
+ m_defaultName = QString::null;
+ m_linenum = 0;
+ m_msgCount = 0;
+ m_titleImgURL = QString::null;
+ }
}
/* public */
m_keyBasePathList.clear();
m_keyCgiBasePathList.clear();
m_keyHostList.clear();
-
+
m_keyHostList = keyHostList;
- /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
- for( unsigned int i = 0; i < m_keyHostList.count(); ++i ){
- if( m_keyHostList[i].length() > 0 )
- m_keyBasePathList += m_keyHostList[i] + m_rootPath + m_bbsPath + "/";
+ /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
+ for ( unsigned int i = 0; i < m_keyHostList.count(); ++i ) {
+ if ( m_keyHostList[ i ].length() > 0 )
+ m_keyBasePathList += m_keyHostList[ i ] + m_rootPath + m_bbsPath + "/";
}
- switch( m_type ){
+ switch ( m_type ) {
- case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
- for( unsigned int i = 0; i < m_keyHostList.count(); ++i )
- m_keyCgiBasePathList += m_keyHostList[i] + m_rootPath + m_delimiter
- + "?BBS=" + m_bbsPath.mid( 1 );
- break;
+ case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
+ for ( unsigned int i = 0; i < m_keyHostList.count(); ++i )
+ m_keyCgiBasePathList += m_keyHostList[ i ] + m_rootPath + m_delimiter
+ + "?BBS=" + m_bbsPath.mid( 1 );
+ break;
- /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+ /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
default:
- for( unsigned int i = 0; i < m_keyHostList.count(); ++i )
- m_keyCgiBasePathList += m_keyHostList[i] + m_rootPath + m_delimiter + m_bbsPath + "/";
- break;
+ for ( unsigned int i = 0; i < m_keyHostList.count(); ++i )
+ m_keyCgiBasePathList += m_keyHostList[ i ] + m_rootPath + m_delimiter + m_bbsPath + "/";
+ break;
}
}
/* (hostname)/(rootPath)/(bbsPath)/ */ /* public */ /* static */
const QString BoardManager::boardURL( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->basePath();
}
urlList.clear();
for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it )
- urlList += (*it)->basePath();
-
+ urlList += ( *it ) ->basePath();
+
return urlList;
}
/* (hostname)/(rootPath) */ /* public */ /* static */
const QString BoardManager::boardRoot( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
- return bdata->hostName() + bdata->rootPath();
+ return bdata->hostName() + bdata->rootPath();
}
/* (bbspath) */ /* public */ /* static */
const QString BoardManager::boardPath( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->bbsPath();
}
/* (ext) */ /* public */ /* static */
const QString BoardManager::ext( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->ext();
}
/* ID of board for writing */ /* public */ /* static */
const QString BoardManager::boardID( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->bbsPath().mid( 1 ); /* remove "/" */
}
/* (hostname)/(rootPath)/(bbsPath)/subject.txt */ /* public */ /* static */
const QString BoardManager::subjectURL( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->basePath() + "subject.txt";
}
/* public */ /* static */
const QString BoardManager::boardName( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->boardName();
}
/* public */ /* static */
const int BoardManager::type( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return Board_Unknown;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return Board_Unknown;
return bdata->type();
}
/* get list of pointers of Thread classes. */
/*
Input:
-
+
url: URL of board.
oldLogs: If TRUE, search cache and get list of pointer of old threads.
online: online or offline mode.
-
+
Output:
-
+
threadList: list of pointers of Thread classes.
oldLogList: list of pointers of old threads.
-
+
*/ /* public */ /* static */
void BoardManager::getThreadList(
const KURL& url,
bool oldLogs,
bool online,
-
+
/* output */
QPtrList< Thread >& threadList,
QPtrList< Thread >& oldLogList )
/* get all obtained threads list from cache */
if ( url.prettyURL() == "http://virtual/obtained/" ) {
- QStringList bbslist = allBoardURLList();
+ QStringList bbslist = allBoardURLList();
- /* search all cache dirs */
+ /* search all cache dirs */
for ( QStringList::iterator it = bbslist.begin() ; it != bbslist.end(); ++it ) {
- getCachedThreadList( ( *it ), threadList );
+ getCachedThreadList( ( *it ), threadList );
}
- return;
+ return ;
}
/*-------------------------*/
BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return;
-
+ if ( bdata == NULL ) return ;
+
/* download subject.txt */
- if( online ){
-
- /* make directory */
- QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
- if( !Kita::mkdir( cacheDir ) ) return;
-
- KIO::SlaveConfig::self() ->setConfigData( "http",
- url.host() ,
- "UserAgent",
- QString( "Monazilla/1.00 (Kita/%1)" ).arg( VERSION ) );
- QString subjectPath = Cache::getSubjectPath( url );
+ if ( online ) {
+
+ /* make directory */
+ QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
+ if ( !Kita::mkdir( cacheDir ) ) return ;
+
+ KIO::SlaveConfig::self() ->setConfigData( "http",
+ url.host() ,
+ "UserAgent",
+ QString( "Monazilla/1.00 (Kita/%1)" ).arg( VERSION ) );
+ QString subjectPath = Cache::getSubjectPath( url );
#if KDE_IS_VERSION( 3, 2, 0 )
- KIO::NetAccess::download( subjectURL( url ), subjectPath, NULL );
+ KIO::NetAccess::download( subjectURL( url ), subjectPath, NULL );
#else
- KIO::NetAccess::download( subjectURL( url ), subjectPath );
+ KIO::NetAccess::download( subjectURL( url ), subjectPath );
#endif
- /* download SETTING.TXT */
- loadBBSSetting( url );
+ /* download SETTING.TXT */
+ loadBBSSetting( url );
}
/* open and read subject.txt */
readSubjectTxt( bdata, url, threadList );
-
+
/* get old logs */
- if( oldLogs ){
-
- QPtrList< Thread > tmpList;
- tmpList.clear();
- getCachedThreadList( url, tmpList );
-
- for ( unsigned i = 0; i < tmpList.count(); i++ ) {
-
- if( threadList.contains( tmpList.at( i ) ) == 0 ) oldLogList.append( tmpList.at( i ) );
- }
+ if ( oldLogs ) {
+
+ QPtrList< Thread > tmpList;
+ tmpList.clear();
+ getCachedThreadList( url, tmpList );
+
+ for ( unsigned i = 0; i < tmpList.count(); i++ ) {
+
+ if ( threadList.contains( tmpList.at( i ) ) == 0 ) oldLogList.append( tmpList.at( i ) );
+ }
}
}
void BoardManager::getCachedThreadList( const KURL& url, QPtrList< Thread >& threadList )
{
QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
- QDir d( cacheDir );
+ QDir d( cacheDir );
if ( d.exists() ) {
-
- /* get all file names */
- QString ext = BoardManager::getBoardData( url )->ext();
- QString boardURL = BoardManager::getBoardData( url )->basePath();
- QStringList flist = d.entryList( "*" + ext );
-
- for ( QStringList::iterator it = flist.begin(); it != flist.end(); ++it ) {
- if ( ( *it ) == QString::null ) continue;
-
- QString datURL = boardURL + "dat/" + ( *it );
-
- /* read idx file */
- Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread == NULL ){
-
- thread = Kita::Thread::getByURL( datURL );
- if( thread == NULL ) continue;
- ThreadIndex::loadIndex( thread, datURL, FALSE );
- }
-
- if( thread != NULL ) threadList.append( thread );
- }
+
+ /* get all file names */
+ QString ext = BoardManager::getBoardData( url ) ->ext();
+ QString boardURL = BoardManager::getBoardData( url ) ->basePath();
+ QStringList flist = d.entryList( "*" + ext );
+
+ for ( QStringList::iterator it = flist.begin(); it != flist.end(); ++it ) {
+ if ( ( *it ) == QString::null ) continue;
+
+ QString datURL = boardURL + "dat/" + ( *it );
+
+ /* read idx file */
+ Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
+ if ( thread == NULL ) {
+
+ thread = Kita::Thread::getByURL( datURL );
+ if ( thread == NULL ) continue;
+ ThreadIndex::loadIndex( thread, datURL, FALSE );
+ }
+
+ if ( thread != NULL ) threadList.append( thread );
+ }
}
}
-/* open subject.txt and get list of Thread classes */ /* private */ /* static */
+/* open subject.txt and get list of Thread classes */ /* private */ /* static */
bool BoardManager::readSubjectTxt( BoardData* bdata, const KURL& url, QPtrList< Thread >& threadList )
{
/* get all names of cached files to read idx. */
QStringList cacheList;
- if( !bdata->readIdx() ){
-
- QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
- QDir d( cacheDir );
- if ( d.exists() ) {
- QString ext = BoardManager::getBoardData( url )->ext();
- cacheList = d.entryList( "*" + ext );
- }
+ if ( !bdata->readIdx() ) {
+
+ QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
+ QDir d( cacheDir );
+ if ( d.exists() ) {
+ QString ext = BoardManager::getBoardData( url ) ->ext();
+ cacheList = d.entryList( "*" + ext );
+ }
}
/* open subject.txt */
QString subjectPath = Cache::getSubjectPath( url );
QIODevice * device = KFilterDev::deviceForFile( subjectPath, "application/x-gzip" );
- if( !device->open( IO_ReadOnly ) ) return FALSE;
+ if ( !device->open( IO_ReadOnly ) ) return FALSE;
QTextStream stream( device );
if ( BoardManager::type( url ) == Board_JBBS ) {
- if ( !m_eucJpCodec ) m_eucJpCodec = new QEucJpCodec();
- stream.setCodec( m_eucJpCodec );
+ if ( !m_eucJpCodec ) m_eucJpCodec = new QEucJpCodec();
+ stream.setCodec( m_eucJpCodec );
} else {
- if ( !m_cp932Codec ) m_cp932Codec = new QCp932Codec();
- stream.setCodec( m_cp932Codec );
+ if ( !m_cp932Codec ) m_cp932Codec = new QCp932Codec();
+ stream.setCodec( m_cp932Codec );
}
// parse subject.txt(only one format...)
case Board_MachiBBS:
case Board_JBBS:
- regexp.setPattern( "(\\d+\\.cgi),(.*)\\((\\d+)\\)" );
- break;
+ regexp.setPattern( "(\\d+\\.cgi),(.*)\\((\\d+)\\)" );
+ break;
default:
- regexp.setPattern( "(\\d+\\.dat)<>(.*)\\((\\d+)\\)" );
- break;
+ regexp.setPattern( "(\\d+\\.dat)<>(.*)\\((\\d+)\\)" );
+ break;
}
QString line;
while ( ( line = stream.readLine() ) != QString::null ) {
- int pos = regexp.search( line );
- if ( pos != -1 ) {
- QString fname = regexp.cap( 1 );
- QString subject = regexp.cap( 2 );
- QString num = regexp.cap( 3 );
-
- /* get pointer of Thread class */
- QString datURL = boardURL( url ) + "dat/" + fname;
- Kita::Thread* thread = Kita::Thread::getByURL( datURL );
+ int pos = regexp.search( line );
+ if ( pos != -1 ) {
+ QString fname = regexp.cap( 1 );
+ QString subject = regexp.cap( 2 );
+ QString num = regexp.cap( 3 );
+
+ /* get pointer of Thread class */
+ QString datURL = boardURL( url ) + "dat/" + fname;
+ Kita::Thread* thread = Kita::Thread::getByURL( datURL );
if ( threadList.find( thread ) == -1 ) {
- threadList.append( thread );
+ threadList.append( thread );
}
- /* set thread name */
- thread->setThreadName( subject );
+ /* set thread name */
+ thread->setThreadName( subject );
- /* load index file */
- if( !bdata->readIdx() ){
+ /* load index file */
+ if ( !bdata->readIdx() ) {
- if( cacheList.contains( fname ) ) ThreadIndex::loadIndex( thread, datURL, FALSE );
- }
+ if ( cacheList.contains( fname ) ) ThreadIndex::loadIndex( thread, datURL, FALSE );
+ }
- /* update res num */
- int newNum = num.toInt();
- if( thread->readNum() ){ /* cache exists */
- int oldNum = thread->resNum();
+ /* update res num */
+ int newNum = num.toInt();
+ if ( thread->readNum() ) { /* cache exists */
+ int oldNum = thread->resNum();
- if( newNum > oldNum ){
- Kita::ThreadIndex::setResNum( datURL, newNum );
- }
- }
- thread->setResNum( newNum );
- }
+ if ( newNum > oldNum ) {
+ Kita::ThreadIndex::setResNum( datURL, newNum );
+ }
+ }
+ thread->setResNum( newNum );
+ }
}
device->close();
/* BoardData */
/* reset all BoardData */ /* public */ /* static */
-void BoardManager::clearBoardData()
+void BoardManager::clearBoardData()
{
for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it )
- delete( *it );
+ delete( *it );
m_boardDataList.clear();
m_previousBoardData = NULL;
/* Input: board, boardName, type, test
Output: oldURL
-
+
return:
If board is already enrolled, return Board_enrollEnrolled and oldURL is QString::null.
If board is new board, return Board_enrollNew and oldURL is QString::null.
If board is moved, return Board_enrollMoved, and oldURL is old URL.
-
+
Note that board is NOT enrolled when board is moved.
To enroll new URL, call BoardManager::moveBoard().
-
+
"int type" is type of board. It could be "Kita::Board_Unknown". See also parseBoardURL().
If "bool test" is TRUE, this function just checks if the board is enrolled (never enroll board).
-
-*/
+
+*/
/* public */ /* static */
int BoardManager::enrollBoard( const KURL& url, const QString& boardName, QString& oldURL, int type, bool test )
{
type = parseBoardURL( url, type, hostname, rootPath, delimiter, bbsPath, ext );
oldURL = QString::null;
- if( type == Board_Unknown ) return Board_enrollFailed;
-
+ if ( type == Board_Unknown ) return Board_enrollFailed;
+
/* check if the board is enrolled or moved. */
- for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ){
-
- if( ( *it )->boardName() == boardName
- && ( *it )->type() == type
- && ( *it )->bbsPath() == bbsPath ){
-
- if( ( *it )->hostName() == hostname
- && ( *it )->rootPath() == rootPath ){ /* enrolled */
- return Board_enrollEnrolled;
- }
- else{ /* moved */
- oldURL = ( *it )->basePath();
- return Board_enrollMoved;
- }
- }
+ for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ) {
+
+ if ( ( *it ) ->boardName() == boardName
+ && ( *it ) ->type() == type
+ && ( *it ) ->bbsPath() == bbsPath ) {
+
+ if ( ( *it ) ->hostName() == hostname
+ && ( *it ) ->rootPath() == rootPath ) { /* enrolled */
+ return Board_enrollEnrolled;
+ } else { /* moved */
+ oldURL = ( *it ) ->basePath();
+ return Board_enrollMoved;
+ }
+ }
}
/* test only */
- if( test ) return Board_enrollNew;
-
+ if ( test ) return Board_enrollNew;
+
/* enroll new board */
BoardData* bdata = new BoardData( boardName, hostname, rootPath, delimiter, bbsPath, ext, type );
m_boardDataList.append( bdata );
/* input */
const KURL& url,
- int type, /* If type = Board_Unknown, type will be decided according to url. */
+ int type, /* If type = Board_Unknown, type will be decided according to url. */
/* output */
QString& hostname,
ext = QString::null;
/* decide type */
- if( type == Board_Unknown ){
-
- if( url.host().contains( "machi.to" ) ) type = Board_MachiBBS;
- else if( url.host().contains( "jbbs.livedoor.jp" ) ) type = Board_JBBS;
- else type = Board_2ch;
+ if ( type == Board_Unknown ) {
+
+ if ( url.host().contains( "machi.to" ) ) type = Board_MachiBBS;
+ else if ( url.host().contains( "jbbs.livedoor.jp" ) ) type = Board_JBBS;
+ else type = Board_2ch;
}
/* parse */
- switch( type ){
-
- case Board_MachiBBS: /* MACHI : http:// *.machi.to/(bbsPath)/ */
-
- delimiter = "/bbs/read.pl";
- bbsPath = url.filename();
- ext = ".cgi";
- break;
-
- case Board_JBBS: /* JBBS : http://jbbs.livedoor.jp/(bbsPath)/ */
-
- delimiter = "/bbs/read.cgi";
- bbsPath = url.prettyURL().remove( hostname );
- type = Board_JBBS;
- ext = ".cgi";
- break;
-
- case Board_FlashCGI: /* test for Flash CGI/Mini Thread */
-
- delimiter = "/test/read.cgi";
- bbsPath = url.filename();
- rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
- if( rootPath.length() == 0 ) rootPath = QString::null;
- ext = ".dat";
- break;
-
- default: /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
-
- delimiter = "/test/read.cgi";
- bbsPath = url.filename();
- rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
- if( rootPath.length() == 0 ) rootPath = QString::null;
- ext = ".dat";
- type = Board_2ch;
- break;
+ switch ( type ) {
+
+ case Board_MachiBBS: /* MACHI : http:// *.machi.to/(bbsPath)/ */
+
+ delimiter = "/bbs/read.pl";
+ bbsPath = url.filename();
+ ext = ".cgi";
+ break;
+
+ case Board_JBBS: /* JBBS : http://jbbs.livedoor.jp/(bbsPath)/ */
+
+ delimiter = "/bbs/read.cgi";
+ bbsPath = url.prettyURL().remove( hostname );
+ type = Board_JBBS;
+ ext = ".cgi";
+ break;
+
+ case Board_FlashCGI: /* test for Flash CGI/Mini Thread */
+
+ delimiter = "/test/read.cgi";
+ bbsPath = url.filename();
+ rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
+ if ( rootPath.length() == 0 ) rootPath = QString::null;
+ ext = ".dat";
+ break;
+
+ default: /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
+
+ delimiter = "/test/read.cgi";
+ bbsPath = url.filename();
+ rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
+ if ( rootPath.length() == 0 ) rootPath = QString::null;
+ ext = ".dat";
+ type = Board_2ch;
+ break;
}
/* For example, if bbsPath = "linux/", then m_bbsPath = "/linux" */
const QRegExp exp( "/$" );
rootPath.remove( exp );
bbsPath.remove( exp );
- if( rootPath != QString::null && rootPath.at( 0 ) != '/' ) rootPath = "/" + rootPath;
- if( bbsPath != QString::null && bbsPath.at( 0 ) != '/' ) bbsPath = "/" + bbsPath;
+ if ( rootPath != QString::null && rootPath.at( 0 ) != '/' ) rootPath = "/" + rootPath;
+ if ( bbsPath != QString::null && bbsPath.at( 0 ) != '/' ) bbsPath = "/" + bbsPath;
return type;
}
/* public */ /* static */
bool BoardManager::isEnrolled( const KURL& url )
{
- if( getBoardData( url ) == NULL ) return FALSE;
+ if ( getBoardData( url ) == NULL ) return FALSE;
return TRUE;
}
/* public */ /* static */
BoardData* BoardManager::getBoardData( const KURL& url )
{
- if( url.isEmpty() ) return NULL;
+ if ( url.isEmpty() ) return NULL;
QString urlstr = url.prettyURL();
/* cache */
- if( m_previousBoardData != NULL && m_previousBoardURL == urlstr ) return m_previousBoardData;
-
- for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ){
-
- int count = (*it)->keyBasePathList().count();
- for( int i = 0; i < count ; ++i ){
- if( urlstr.contains( (*it)->keyBasePathList()[i] )
- || urlstr.contains( (*it)->keyCgiBasePathList()[i] ) ){
-
- /* cache */
- m_previousBoardData = (*it);
- m_previousBoardURL = urlstr;
-
- return (*it);
- }
- }
+ if ( m_previousBoardData != NULL && m_previousBoardURL == urlstr ) return m_previousBoardData;
+
+ for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ) {
+
+ int count = ( *it ) ->keyBasePathList().count();
+ for ( int i = 0; i < count ; ++i ) {
+ if ( urlstr.contains( ( *it ) ->keyBasePathList() [ i ] )
+ || urlstr.contains( ( *it ) ->keyCgiBasePathList() [ i ] ) ) {
+
+ /* cache */
+ m_previousBoardData = ( *it );
+ m_previousBoardURL = urlstr;
+
+ return ( *it );
+ }
+ }
}
-
+
return NULL;
}
/* load the bbs history file ( BBSHISTORY ), and create keys of Data Base. */
-/* Before calling this, enroll the board by enrollBoard(). */
+/* Before calling this, enroll the board by enrollBoard(). */
/*
ex) If the host of board moved like :
-
+
http:://aaa.com -> http://bbb.com -> http://ccc.com -> http://ddd.com
then, BBSHISTORY is
-
+
http://ccc.com
http://bbb.com
http://aaa.com
-
+
*/ /* public */ /* static */
bool BoardManager::loadBBSHistory( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return FALSE;
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return FALSE;
+
+ QStringList keyHosts = bdata->hostName();
- QStringList keyHosts = bdata->hostName();
-
QFile file( Cache::getBBSHistoryPath( url ) );
- if ( file.open( IO_ReadOnly ) ){
+ if ( file.open( IO_ReadOnly ) ) {
- QTextStream ts( &file );
+ QTextStream ts( &file );
- QString line;
- while( !ts.eof() ){
+ QString line;
+ while ( !ts.eof() ) {
- line = ts.readLine();
- keyHosts += line;
- }
+ line = ts.readLine();
+ keyHosts += line;
+ }
- bdata->createKeys( keyHosts );
- file.close();
+ bdata->createKeys( keyHosts );
+ file.close();
- return TRUE;
+ return TRUE;
}
return FALSE;
/* public */ /* static */
bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
{
- QString oldhost = fromURL.protocol() + "://" + fromURL.host();
+ QString oldhost = fromURL.protocol() + "://" + fromURL.host();
QString newhost = toURL.protocol() + "://" + toURL.host();
const QRegExp exp( "/$" );
newURL.remove( exp );
oldURL += "/";
newURL += "/";
-
- if( oldURL == newURL ) return FALSE;
-
+
+ if ( oldURL == newURL ) return FALSE;
+
/* Is oldURL enrolled? */
- BoardData* bdata = getBoardData( oldURL );
- if( bdata == NULL ){
+ BoardData* bdata = getBoardData( oldURL );
+ if ( bdata == NULL ) {
- /* Is newURL enrolled? */
- bdata = getBoardData( newURL );
- if( bdata == NULL ) return FALSE;
+ /* Is newURL enrolled? */
+ bdata = getBoardData( newURL );
+ if ( bdata == NULL ) return FALSE;
}
QStringList keyHosts = bdata->keyHostList();
keyHosts.remove( oldhost );
keyHosts.prepend( oldhost );
- bdata->createKeys( keyHosts );
+ bdata->createKeys( keyHosts );
QString oldCachePath = Cache::baseDir() + Cache::serverDir( bdata->basePath() )
- + Cache::boardDir( bdata->basePath() );
+ + Cache::boardDir( bdata->basePath() );
/* update URL */
bdata->setHostName( newhost );
-
+
/* update keys */
/* The order of keyHosts will be like this:
bdata->setReadIdx( FALSE );
bdata->setSettingLoaded( FALSE );
-
+
/*---------------------------*/
/* move cache dir */
-
+
QDir qdir;
- if( ! qdir.exists( oldCachePath ) ) return TRUE;
-
+ if ( ! qdir.exists( oldCachePath ) ) return TRUE;
+
/* mkdir new server dir */
- QString newCachePath = Cache::baseDir() + Cache::serverDir( bdata->basePath() );
+ QString newCachePath = Cache::baseDir() + Cache::serverDir( bdata->basePath() );
Kita::mkdir( newCachePath );
-
+
/* backup old dir */
- newCachePath += Cache::boardDir( bdata->basePath() );
- if( qdir.exists ( newCachePath ) ){
- QString bkupPath = newCachePath;
- bkupPath.truncate( bkupPath.length() -1 ); /* remove '/' */
- bkupPath += "." + QString().setNum( QDateTime::currentDateTime().toTime_t() );
- qdir.rename( newCachePath, bkupPath );
+ newCachePath += Cache::boardDir( bdata->basePath() );
+ if ( qdir.exists ( newCachePath ) ) {
+ QString bkupPath = newCachePath;
+ bkupPath.truncate( bkupPath.length() - 1 ); /* remove '/' */
+ bkupPath += "." + QString().setNum( QDateTime::currentDateTime().toTime_t() );
+ qdir.rename( newCachePath, bkupPath );
}
/* move cache dir */
- if( qdir.exists( oldCachePath ) ){
- qdir.rename( oldCachePath, newCachePath );
- }
- else Kita::mkdir( newCachePath );
+ if ( qdir.exists( oldCachePath ) ) {
+ qdir.rename( oldCachePath, newCachePath );
+ } else Kita::mkdir( newCachePath );
/* make old dir */
if ( ! qdir.exists( oldCachePath ) ) {
/*---------------------------*/
/* update BBSHISTRY */
-
+
QFile file( Cache::getBBSHistoryPath( bdata->basePath() ) );
- if ( file.open( IO_WriteOnly ) ){
+ if ( file.open( IO_WriteOnly ) ) {
+
+ QTextStream ts( &file );
- QTextStream ts( &file );
-
- keyHosts.remove( newhost );
- for ( QStringList::iterator it = keyHosts.begin() ; it != keyHosts.end(); ++it ) {
- ts << (*it) << endl;
- }
+ keyHosts.remove( newhost );
+ for ( QStringList::iterator it = keyHosts.begin() ; it != keyHosts.end(); ++it ) {
+ ts << ( *it ) << endl;
+ }
- file.close();
+ file.close();
}
-
+
/*---------------------------*/
/* update other information */
FavoriteThreads::replace( oldURL, newURL );
bool BoardManager::loadBBSSetting( const KURL& url, bool reload )
{
/* Is board enrolled ? */
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return FALSE;
- if( bdata->type() != Board_2ch ) return FALSE;
-
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return FALSE;
+ if ( bdata->type() != Board_2ch ) return FALSE;
+
KURL settingURL = bdata->settingURL();
QString path = Cache::getSettingPath( url );
-
+
/* now loading */
- if( DownloadManager::isLoadingNow( settingURL ) ) return FALSE;
+ if ( DownloadManager::isLoadingNow( settingURL ) ) return FALSE;
/* already loaded */
- if( bdata->settingLoaded() && !reload ) return TRUE;
+ if ( bdata->settingLoaded() && !reload ) return TRUE;
/* reset names, linenum, etc. */
bdata->setSettingLoaded( FALSE );
-
+
/* download SETTING.TXT.*/
DownloadManager::download( settingURL, path );
bdata->setSettingLoaded( TRUE );
-
+
return TRUE;
}
/* public */ /* static */
QString BoardManager::getBBSDefaultName( const KURL& url )
{
- BoardData* bdata = openSettingTxt( url );
- if( bdata == NULL ) bdata = getBoardData( url );
- if( bdata == NULL ) return "(default name)";
- if( bdata->defaultName() == QString::null ) return "(default name)";
+ BoardData * bdata = openSettingTxt( url );
+ if ( bdata == NULL ) bdata = getBoardData( url );
+ if ( bdata == NULL ) return "(default name)";
+ if ( bdata->defaultName() == QString::null ) return "(default name)";
return bdata->defaultName();
}
/* public */ /* static */
int BoardManager::getBBSMaxLine( const KURL& url )
{
- BoardData* bdata = openSettingTxt( url );
- if( bdata == NULL ) bdata = getBoardData( url );
- if( bdata == NULL ) return 0;
+ BoardData * bdata = openSettingTxt( url );
+ if ( bdata == NULL ) bdata = getBoardData( url );
+ if ( bdata == NULL ) return 0;
return bdata->lineNum();
}
/* public */ /* static */
int BoardManager::getBBSMsgCount( const KURL& url )
{
- BoardData* bdata = openSettingTxt( url );
- if( bdata == NULL ) bdata = getBoardData( url );
- if( bdata == NULL ) return 0;
+ BoardData * bdata = openSettingTxt( url );
+ if ( bdata == NULL ) bdata = getBoardData( url );
+ if ( bdata == NULL ) return 0;
return bdata->msgCount();
}
/* public */ /* static */
const KURL BoardManager::titleImgURL( const KURL& url )
{
- BoardData* bdata = openSettingTxt( url );
- if( bdata == NULL ) bdata = getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ BoardData * bdata = openSettingTxt( url );
+ if ( bdata == NULL ) bdata = getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
return bdata->titleImgURL();
}
/* open local SETTING.TXT, then get names, linenum, etc. */ /* private */ /* static */
BoardData* BoardManager::openSettingTxt( const KURL& url )
{
- BoardData* bdata = getBoardData( url );
- if( bdata == NULL ) return NULL;
- if( !bdata->settingLoaded() ) return NULL;
- if( DownloadManager::isLoadingNow( bdata->settingURL() ) ) return NULL;
- if( bdata->defaultName() != QString::null ) return bdata;
-
+ BoardData * bdata = getBoardData( url );
+ if ( bdata == NULL ) return NULL;
+ if ( !bdata->settingLoaded() ) return NULL;
+ if ( DownloadManager::isLoadingNow( bdata->settingURL() ) ) return NULL;
+ if ( bdata->defaultName() != QString::null ) return bdata;
+
QFile file( Cache::getSettingPath( url ) );
- if ( file.open( IO_ReadOnly ) ){
-
- QTextStream ts( &file );
- if( m_cp932Codec == NULL) m_cp932Codec = new QCp932Codec();
- ts.setCodec( m_cp932Codec );
-
- QString line;
- while( !ts.eof() ){
-
- line = ts.readLine();
-
- /* default name */
- QString key = "BBS_NONAME_NAME=";
- if( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
-
- /* 0ch type */
- key = "NANASI_NAME=";
- if( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
-
- /* line number */
- key = "BBS_LINE_NUMBER=";
- if( line.find( key ) != -1 ) bdata->setLineNum( line.remove( key ).toInt() * 2 );
-
- /* msg count */
- key = "BBS_MESSAGE_COUNT=";
- if( line.find( key ) != -1 ) bdata->setMsgCount( line.remove( key ).toInt() );
-
- /* title image */
- key = "BBS_TITLE_PICTURE=";
- if( line.find( key ) != -1 ){
- QString path = line.remove( key );
- KURL titleImgURL = KURL( bdata->basePath(), path );
- bdata->setTitleImgURL( titleImgURL );
- }
- }
-
- file.close();
+ if ( file.open( IO_ReadOnly ) ) {
+
+ QTextStream ts( &file );
+ if ( m_cp932Codec == NULL ) m_cp932Codec = new QCp932Codec();
+ ts.setCodec( m_cp932Codec );
+
+ QString line;
+ while ( !ts.eof() ) {
+
+ line = ts.readLine();
+
+ /* default name */
+ QString key = "BBS_NONAME_NAME=";
+ if ( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
+
+ /* 0ch type */
+ key = "NANASI_NAME=";
+ if ( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
+
+ /* line number */
+ key = "BBS_LINE_NUMBER=";
+ if ( line.find( key ) != -1 ) bdata->setLineNum( line.remove( key ).toInt() * 2 );
+
+ /* msg count */
+ key = "BBS_MESSAGE_COUNT=";
+ if ( line.find( key ) != -1 ) bdata->setMsgCount( line.remove( key ).toInt() );
+
+ /* title image */
+ key = "BBS_TITLE_PICTURE=";
+ if ( line.find( key ) != -1 ) {
+ QString path = line.remove( key );
+ KURL titleImgURL = KURL( bdata->basePath(), path );
+ bdata->setTitleImgURL( titleImgURL );
+ }
+ }
+
+ file.close();
}
- if( bdata->defaultName() == QString::null ) bdata->setDefaultName( "(default name)" );
-
+ if ( bdata->defaultName() == QString::null ) bdata->setDefaultName( "(default name)" );
+
return bdata;
}
namespace Kita
{
class Thread;
-
+
/* type of board */
enum {
Board_MachiBBS,
Board_JBBS,
Board_2ch,
Board_FlashCGI,
- Board_Unknown
+ Board_Unknown
};
/* return value of BoardManager::enrollBoard */
enum {
- Board_enrollNew,
- Board_enrollEnrolled,
- Board_enrollMoved,
- Board_enrollFailed
+ Board_enrollNew,
+ Board_enrollEnrolled,
+ Board_enrollMoved,
+ Board_enrollFailed
};
/*---------------------------------*/
/* Data Base of board */
class BoardData
{
- QString m_boardName;
- bool m_readIdx; /* If TRUE, idx file has been read. */
-
- QString m_hostname; /* latest host name */
- QString m_rootPath;
- QString m_delimiter; /* "/test/read.cgi", "/bbs/read.pl", etc. */
- QString m_bbsPath;
- QString m_ext; /* ".dat", ".cgi", etc. */
- int m_type;
-
- QString m_basePath; /* = (hostname)/(rootPath)/(bbsPath)/ */
- QString m_cgiBasePath; /* = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
-
- /* SETTING.TXT */
- bool m_settingLoaded;
- QString m_defaultName;
- int m_linenum;
- int m_msgCount;
- KURL m_titleImgURL;
-
- /* keys */
- QStringList m_keyHostList; /* list of host names. They are keys of DB. */
- QStringList m_keyBasePathList;
- QStringList m_keyCgiBasePathList;
-
+ QString m_boardName;
+ bool m_readIdx; /* If TRUE, idx file has been read. */
+
+ QString m_hostname; /* latest host name */
+ QString m_rootPath;
+ QString m_delimiter; /* "/test/read.cgi", "/bbs/read.pl", etc. */
+ QString m_bbsPath;
+ QString m_ext; /* ".dat", ".cgi", etc. */
+ int m_type;
+
+ QString m_basePath; /* = (hostname)/(rootPath)/(bbsPath)/ */
+ QString m_cgiBasePath; /* = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+
+ /* SETTING.TXT */
+ bool m_settingLoaded;
+ QString m_defaultName;
+ int m_linenum;
+ int m_msgCount;
+ KURL m_titleImgURL;
+
+ /* keys */
+ QStringList m_keyHostList; /* list of host names. They are keys of DB. */
+ QStringList m_keyBasePathList;
+ QStringList m_keyCgiBasePathList;
+
public:
- BoardData( const QString& boardName, const QString& hostname,
- const QString& rootPath, const QString& delimiter,
- const QString& bbsPath, const QString& ext, int boardtype );
- ~BoardData();
-
- void setHostName( const QString& hostname );
-
- /* information */
- const bool readIdx() const;
- void setReadIdx( bool idx );
- const QString& boardName() const;
- const QString& hostName() const;
- const QString& rootPath() const;
- const QString& delimiter() const;
- const QString& bbsPath() const;
- const QString& ext() const;
- const int type() const;
-
- const QString& basePath() const;
- const QString& cgiBasePath() const;
-
- /* SETTING.TXT */
- const QString settingURL() const;
- const bool settingLoaded() const;
- const QString& defaultName() const;
- const int lineNum() const;
- const int msgCount() const;
- const KURL& titleImgURL() const;
- void setSettingLoaded( bool set );
- void setDefaultName( const QString& newName );
- void setLineNum( int newLine );
- void setMsgCount( int msgCount );
- void setTitleImgURL( const KURL& url );
-
- /* keys */
- void createKeys( const QStringList& keyHostList );
- const QStringList& keyHostList() const;
- const QStringList& keyBasePathList() const;
- const QStringList& keyCgiBasePathList() const;
+ BoardData( const QString& boardName, const QString& hostname,
+ const QString& rootPath, const QString& delimiter,
+ const QString& bbsPath, const QString& ext, int boardtype );
+ ~BoardData();
+
+ void setHostName( const QString& hostname );
+
+ /* information */
+ const bool readIdx() const;
+ void setReadIdx( bool idx );
+ const QString& boardName() const;
+ const QString& hostName() const;
+ const QString& rootPath() const;
+ const QString& delimiter() const;
+ const QString& bbsPath() const;
+ const QString& ext() const;
+ const int type() const;
+
+ const QString& basePath() const;
+ const QString& cgiBasePath() const;
+
+ /* SETTING.TXT */
+ const QString settingURL() const;
+ const bool settingLoaded() const;
+ const QString& defaultName() const;
+ const int lineNum() const;
+ const int msgCount() const;
+ const KURL& titleImgURL() const;
+ void setSettingLoaded( bool set );
+ void setDefaultName( const QString& newName );
+ void setLineNum( int newLine );
+ void setMsgCount( int msgCount );
+ void setTitleImgURL( const KURL& url );
+
+ /* keys */
+ void createKeys( const QStringList& keyHostList );
+ const QStringList& keyHostList() const;
+ const QStringList& keyBasePathList() const;
+ const QStringList& keyCgiBasePathList() const;
};
/*--------------------------------------*/
-
+
typedef QValueList< BoardData* > BoardDataList;
-
+
/**
@author Hideki Ikemoto
*/
class BoardManager
{
- static BoardDataList m_boardDataList;
- static BoardData* m_previousBoardData; /* used in getBoardData() */
- static QString m_previousBoardURL; /* used in getBoardData() */
- static QCp932Codec* m_cp932Codec;
- static QEucJpCodec* m_eucJpCodec;
-
+ static BoardDataList m_boardDataList;
+ static BoardData* m_previousBoardData; /* used in getBoardData() */
+ static QString m_previousBoardURL; /* used in getBoardData() */
+ static QCp932Codec* m_cp932Codec;
+ static QEucJpCodec* m_eucJpCodec;
+
public:
BoardManager();
~BoardManager();
- static const QString boardURL( const KURL& url );
- static const QStringList allBoardURLList();
- static const QString boardRoot( const KURL& url );
- static const QString boardPath( const KURL& url );
- static const QString ext( const KURL& url );
- static const QString boardID( const KURL& url );
- static const QString subjectURL( const KURL& url );
- static const QString boardName( const KURL& url );
- static const int type( const KURL& url );
-
- /* ThreadList */
- static void getThreadList( const KURL& url, bool oldLogs, bool online,
- QPtrList< Thread >& threadList, QPtrList< Thread >& oldLogList );
-
- /* BoardData */
- static void clearBoardData();
- static int enrollBoard( const KURL& url, const QString& boardName, QString& oldURL,
- int type = Board_Unknown, bool test = FALSE );
- static bool isEnrolled( const KURL& url );
- static BoardData* getBoardData( const KURL& url );
-
- /* BBSHISTORY */
- static bool loadBBSHistory( const KURL& url );
- static bool moveBoard( const KURL& fromURL, const KURL& toURL );
-
- /* SETTING.TXT */
- static bool loadBBSSetting( const KURL& url, bool reload = FALSE );
- static QString getBBSDefaultName( const KURL& url );
- static int getBBSMaxLine( const KURL& url );
- static int getBBSMsgCount( const KURL& url );
- static const KURL titleImgURL( const KURL& url );
-
- private:
-
- /* BoardData */
- static int parseBoardURL( const KURL& url, int type, QString& hostname,
- QString& rootPath, QString& delimiter,
- QString& bbsPath, QString& ext);
-
-
- /* ThreadList */
- static void getCachedThreadList( const KURL& url, QPtrList< Thread >& threadList );
- static bool readSubjectTxt( BoardData* bdata, const KURL& url, QPtrList< Thread >& threadList );
-
-
- /* SETTING.TXT */
- static BoardData* openSettingTxt( const KURL& url );
+ static const QString boardURL( const KURL& url );
+ static const QStringList allBoardURLList();
+ static const QString boardRoot( const KURL& url );
+ static const QString boardPath( const KURL& url );
+ static const QString ext( const KURL& url );
+ static const QString boardID( const KURL& url );
+ static const QString subjectURL( const KURL& url );
+ static const QString boardName( const KURL& url );
+ static const int type( const KURL& url );
+
+ /* ThreadList */
+ static void getThreadList( const KURL& url, bool oldLogs, bool online,
+ QPtrList< Thread >& threadList, QPtrList< Thread >& oldLogList );
+
+ /* BoardData */
+ static void clearBoardData();
+ static int enrollBoard( const KURL& url, const QString& boardName, QString& oldURL,
+ int type = Board_Unknown, bool test = FALSE );
+ static bool isEnrolled( const KURL& url );
+ static BoardData* getBoardData( const KURL& url );
+
+ /* BBSHISTORY */
+ static bool loadBBSHistory( const KURL& url );
+ static bool moveBoard( const KURL& fromURL, const KURL& toURL );
+
+ /* SETTING.TXT */
+ static bool loadBBSSetting( const KURL& url, bool reload = FALSE );
+ static QString getBBSDefaultName( const KURL& url );
+ static int getBBSMaxLine( const KURL& url );
+ static int getBBSMsgCount( const KURL& url );
+ static const KURL titleImgURL( const KURL& url );
+
+ private:
+
+ /* BoardData */
+ static int parseBoardURL( const KURL& url, int type, QString& hostname,
+ QString& rootPath, QString& delimiter,
+ QString& bbsPath, QString& ext );
+
+
+ /* ThreadList */
+ static void getCachedThreadList( const KURL& url, QPtrList< Thread >& threadList );
+ static bool readSubjectTxt( BoardData* bdata, const KURL& url, QPtrList< Thread >& threadList );
+
+
+ /* SETTING.TXT */
+ static BoardData* openSettingTxt( const KURL& url );
};
}
QString Cache::serverDir( const KURL& url )
{
/* Is board enrolled ? */
- BoardData* bdata = BoardManager::getBoardData( url );
- if( bdata == NULL ) return QString::null;
-
+ BoardData * bdata = BoardManager::getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
+
QString root = bdata->hostName() + bdata->rootPath();
-
+
return root.remove( "http://" ).replace( "/", "_" ) + "/";
}
QString Cache::boardDir( const KURL& url )
{
/* Is board enrolled ? */
- BoardData* bdata = BoardManager::getBoardData( url );
- if( bdata == NULL ) return QString::null;
-
+ BoardData * bdata = BoardManager::getBoardData( url );
+ if ( bdata == NULL ) return QString::null;
+
QString bbs = bdata->bbsPath();
-
+
return bbs.mid( 1 ).replace( "/", "_" ) + "/";
}
QString path = baseDir() + serverDir( url ) + boardDir( url );
if ( path == QString::null ) return QString::null;
-// qDebug( "%s -> %s",url.prettyURL().ascii(),path.ascii());
-
+ // qDebug( "%s -> %s",url.prettyURL().ascii(),path.ascii());
+
return path + url.fileName();
}
{
QString path = baseDir() + serverDir( url ) + boardDir( url );
if ( path == QString::null ) return QString::null;
-
+
return path + "SETTING.TXT";
}
{
QString path = baseDir() + serverDir( url ) + boardDir( url );
if ( path == QString::null ) return QString::null;
-
+
return path + "BBSHISTORY";
}
{
QString path = baseDir() + serverDir( url ) + boardDir( url );
if ( path == QString::null ) return QString::null;
-
+
return path + "subject.txt";
}
static QString baseDir();
static QString serverDir( const KURL& url );
static QString boardDir( const KURL& url );
-
+
static QString getPath( const KURL& url );
static QString getIndexPath( const KURL& url );
static QString getSettingPath( const KURL& url );
static QString getBBSHistoryPath( const KURL& url );
- static QString getSubjectPath( const KURL& url );
+ static QString getSubjectPath( const KURL& url );
static QString getImgPath( const KURL& url );
static QString getImgIdxPath( const KURL& url );
};
/* get the pointer of Thread class */
m_thread = Kita::Thread::getByURLNew( m_datURL );
- if( m_thread == NULL ){
-
- /* create Thread */
- m_thread = Kita::Thread::getByURL( m_datURL );
- if( m_thread == NULL ) return;
-
- /* read idx file */
- ThreadIndex::loadIndex( m_thread, m_datURL );
+ if ( m_thread == NULL ) {
+
+ /* create Thread */
+ m_thread = Kita::Thread::getByURL( m_datURL );
+ if ( m_thread == NULL ) return ;
+
+ /* read idx file */
+ ThreadIndex::loadIndex( m_thread, m_datURL );
}
m_thread = Thread::getByURL( m_datURL );
-
+
/* japanese strings */
#if KDE_IS_VERSION( 3, 3, 0 )
m_spacestr = Kita::utf8ToUnicode( KITAUTF8_ZENSPACE );
/* make directory */
QString cacheDir = Cache::baseDir() + Cache::serverDir( m_datURL ) + Cache::boardDir( m_datURL );
- if( !Kita::mkdir( cacheDir ) ) return;
-
+ if ( !Kita::mkdir( cacheDir ) ) return ;
+
initPrivate(
- TRUE /* load cache */
- );
+ TRUE /* load cache */
+ );
}
DatInfo::~DatInfo()
connect( m_access, SIGNAL( receiveData( const QStringList& ) ),
SLOT( slotReceiveData( const QStringList& ) ) );
connect( m_access, SIGNAL( finishLoad() ), SLOT( slotFinishLoad() ) );
-
- if( !loadCache ) return;
+
+ if ( !loadCache ) return ;
/* reset ReadNum before loading cache. */
/* ReadNum & subject are updated by Access::getcache() */
- m_thread->setReadNum( 0 );
-
+ m_thread->setReadNum( 0 );
+
/* get dat from cahce */
/* slotReceiveData() is called from Access::getcache() */
m_access->getcache();
connect( this, SIGNAL( finishLoad() ),
parent, SLOT( slotFinishLoad() ) );
-
+
m_access->getupdate( m_thread->readNum() );
return TRUE;
bool DatInfo::copyOneLineToResDat( const QString& line )
{
if ( line == QString::null ) return FALSE;
-
+
/* update ReadNum */
- const int num = m_thread->readNum() +1;
+ const int num = m_thread->readNum() + 1;
m_thread->setReadNum( num );
-
+
/* If resdat vector is short, then resize the vector. */
- while( ( int ) m_resDatVec.size() <= num ) increaseResDatVec( RESDAT_DELTA );
+ while ( ( int ) m_resDatVec.size() <= num ) increaseResDatVec( RESDAT_DELTA );
/* reset ResDat */
RESDAT& resdat = m_resDatVec[ num ];
resdat.linestr = line;
/* get subject */
- if( num == 1 ) parseDat( num );
+ if ( num == 1 ) parseDat( num );
/* search all responses which are responsed by this line. */
- if( KitaConfig::checkResponsed() ){
+ if ( KitaConfig::checkResponsed() ) {
+
+ if ( parseDat( num ) && !checkAbonePrivate( num ) ) { /* parse line here to get AncList */
- if ( parseDat( num ) && !checkAbonePrivate( num ) ){ /* parse line here to get AncList */
-
const int maxRange = 10;
AncList& anclist = m_resDatVec[ num ].anclist;
int fromNum = ( *it ).from;
int toNum = QMIN( num - 1, ( *it ).to );
- if( toNum - fromNum +1 > maxRange ) continue;
+ if ( toNum - fromNum + 1 > maxRange ) continue;
- for( int i = fromNum; i <= toNum; ++i ){
-
- if( !checkAbonePrivate( i ) ) m_resDatVec[ i ].isResponsed = TRUE;
+ for ( int i = fromNum; i <= toNum; ++i ) {
+
+ if ( !checkAbonePrivate( i ) ) m_resDatVec[ i ].isResponsed = TRUE;
}
}
}
}
-
+
return TRUE;
}
initPrivate( TRUE );
m_access2 = new OfflawAccess( m_datURL );
connect( m_access2, SIGNAL( receiveData( const QStringList& ) ),
- SLOT( slotReceiveData( const QStringList& ) ) );
+ SLOT( slotReceiveData( const QStringList& ) ) );
connect( m_access2, SIGNAL( finishLoad() ), SLOT( slotFinishLoad() ) );
m_access2->get();
- return;
+ return ;
}
}
/* finish loading session & emit signal to the parent object */
{
QMutexLocker locker( &m_mutex );
if ( !parseDat( num ) ) return QString::null;
-
+
return m_resDatVec[ num ].name;
}
QString retStr;
Kita::DatToText( titleHTML, retStr );
-
+
return retStr;
}
QString retStr;
Kita::DatToText( m_resDatVec[ num ].bodyHTML, retStr );
-
+
return retStr;
}
/* get HTML strings of title & body.
-
+
return values are defined in datinfo.h. */ /* public */
int DatInfo::getHTML( int num, bool checkAbone, QString& titleHTML, QString& bodyHTML )
bool abone = checkAbone & checkAbonePrivate( num );
RESDAT& resdat = m_resDatVec[ num ];
- if ( !resdat.broken && !abone ){
-
- createTitleHTML( resdat, titleHTML );
- bodyHTML = resdat.bodyHTML;
- }
- else {
-
- /* "abone" */
- if ( abone ){
- titleHTML = QString().setNum( num ) + " " + i18n( "Abone" );
- bodyHTML = "<a href=\"#abone" + QString().setNum( num ) + "\">";
- bodyHTML += i18n( "Abone" ) + "</a>";
-
- return KITA_HTML_ABONE;
- }
-
- /* "broken" */
+ if ( !resdat.broken && !abone ) {
+
+ createTitleHTML( resdat, titleHTML );
+ bodyHTML = resdat.bodyHTML;
+ } else {
+
+ /* "abone" */
+ if ( abone ) {
+ titleHTML = QString().setNum( num ) + " " + i18n( "Abone" );
+ bodyHTML = "<a href=\"#abone" + QString().setNum( num ) + "\">";
+ bodyHTML += i18n( "Abone" ) + "</a>";
+
+ return KITA_HTML_ABONE;
+ }
+
+ /* "broken" */
else {
- titleHTML = QString().setNum( num ) + " " + i18n( "Broken" );
- bodyHTML = i18n( "Broken" );
+ titleHTML = QString().setNum( num ) + " " + i18n( "Broken" );
+ bodyHTML = i18n( "Broken" );
- return KITA_HTML_BROKEN;
- }
+ return KITA_HTML_BROKEN;
+ }
}
return KITA_HTML_NORMAL;
/* get HTML strings from startnum to endnum.
-
+
return value is HTML strings */ /* public */
QString DatInfo::getHTMLString( int startnum, int endnum, bool checkAbone )
{
for ( int num = startnum; num <= endnum; num++ ) {
- QString html;
- getHTMLofOneRes( num, checkAbone, html );
- retHTML += html;
+ QString html;
+ getHTMLofOneRes( num, checkAbone, html );
+ retHTML += html;
}
return retHTML;
if ( m_resDatVec[ i ].id == strid ) {
count ++;
- QString html;
- getHTMLofOneRes( i, TRUE, html );
- retHTML += html;
+ QString html;
+ getHTMLofOneRes( i, TRUE, html );
+ retHTML += html;
}
}
{
html = QString::null;
QString titleHTML, bodyHTML;
- if( getHTMLPrivate( num, checkAbone, titleHTML, bodyHTML ) == KITA_HTML_NOTPARSED ) return;
-
- if( m_resDatVec[ num ].isResponsed ) titleHTML.replace( "<a href=\"#write", "<a class=\"coloredLink\" href=\"#write" );
+ if ( getHTMLPrivate( num, checkAbone, titleHTML, bodyHTML ) == KITA_HTML_NOTPARSED ) return ;
+
+ if ( m_resDatVec[ num ].isResponsed ) titleHTML.replace( "<a href=\"#write", "<a class=\"coloredLink\" href=\"#write" );
html += "<div class=\"pop_res_title\">" + titleHTML + "</div>";
html += "<div class=\"pop_res_body\">" + bodyHTML + "</div>";
}
/* private */
QString DatInfo::getTreeByResPrivate(
const int rootnum,
- bool reverse, /* reverse search */
+ bool reverse, /* reverse search */
int& count )
{
/* private */
QString DatInfo::getTreeByResCore(
const int rootnum,
- bool reverse, /* reverse search */
+ bool reverse, /* reverse search */
int& count, QString prestr )
{
if ( !parseDat( rootnum ) ) return QString::null;
AncList& anclist = m_resDatVec[ num ].anclist;
for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it ) {
- if( ( *it ).to - ( *it ).from > range ) continue;
+ if ( ( *it ).to - ( *it ).from > range ) continue;
if ( target >= ( *it ).from && target <= ( *it ).to ) return TRUE;
}
/* Are keywords included ? */ /* public */
-bool DatInfo::checkWord( QStringList& stlist, /* list of keywords */
+bool DatInfo::checkWord( QStringList& stlist, /* list of keywords */
int num,
bool checkOR /* AND or OR search */
)
checktmp = checkAboneCore( m_resDatVec[ num ].bodyHTML, KitaConfig::aboneWordList() );
if ( !checktmp && m_aboneChain ) {
- AncList& anclist = m_resDatVec[ num ].anclist;
+ AncList & anclist = m_resDatVec[ num ].anclist;
for ( AncList::iterator it = anclist.begin();
it != anclist.end() && !checktmp ; ++it ) {
-/* parsing function for ResDat */
+/* parsing function for ResDat */
/* This function parses the raw data by Kita::parseResDat() */ /* private */
bool DatInfo::parseDat( int num )
{
- if( num <= 0 || m_thread->readNum() < num ) return FALSE;
- if( m_resDatVec[ num ].parsed ) return TRUE;
+ if ( num <= 0 || m_thread->readNum() < num ) return FALSE;
+ if ( m_resDatVec[ num ].parsed ) return TRUE;
+
+ // qDebug("parseDat %d",num);
-// qDebug("parseDat %d",num);
-
- QString subject = QString::null;
- Kita::parseResDat( m_resDatVec[ num ], subject );
- if( num == 1 && subject != QString::null ) m_thread->setThreadName( subject );
- if ( m_resDatVec[ num ].broken ) m_broken = TRUE;
+ QString subject = QString::null;
+ Kita::parseResDat( m_resDatVec[ num ], subject );
+ if ( num == 1 && subject != QString::null ) m_thread->setThreadName( subject );
+ if ( m_resDatVec[ num ].broken ) m_broken = TRUE;
- return TRUE;
+ return TRUE;
}
/* Data Base of anchor
-
+
For example, No.5 res has name = "foo", id "id1234", and anchors >>2-3 and >>4, then,
m_resDatVec[5].name = "foo",
{
int num; /* number */
QString linestr; /* raw line data */
-
+
bool parsed;
bool broken;
QDateTime dateTime;
QString id;
QString host;
- QString bodyHTML;
+ QString bodyHTML;
AncList anclist; /* anchor list. See above. */
QMutex m_mutex;
- /* pointer of Thread class */
- Thread* m_thread;
+ /* pointer of Thread class */
+ Thread* m_thread;
/* basic information */
KURL m_datURL;
DatInfo( const KURL& url );
~DatInfo();
void init();
- void wait();
+ void wait();
const KURL& url();
/* for caching */
/* string data */
const QString& getDat( int num );
const QString& getId( int num );
- QString getPlainName( int num );
+ QString getPlainName( int num );
QString getPlainTitle( int num );
QString getPlainBody( int num );
/* numerical data */
int getResNum();
int getReadNum();
- int getViewPos();
+ int getViewPos();
int getNumByID( const QString& strid );
int getDatSize();
/* abone check */
bool checkAbone( int num );
void resetAbone();
-
+
/*-------------------------*/
private:
/* copy data */
bool copyOneLineToResDat( const QString& line );
-
+
/* HTML data */
int getHTMLPrivate( int num, bool checkAbone, QString& titleHTML, QString& bodyHTML );
- void getHTMLofOneRes( int num, bool checkAbone, QString& html );
+ void getHTMLofOneRes( int num, bool checkAbone, QString& html );
QString getTreeByResPrivate( const int rootnum, bool reverse, int& count );
QString getTreeByResCore( const int rootnum, bool reverse, int& count, QString prestr );
bool checkRes( const int num, const int target );
if cache does not exist( i.e. ReadNum == 0 ). */ /* public */
bool DatManager::createDatInfo( const KURL& url )
{
- if( getDatInfo( url,
- FALSE /* don't check the existence of cache */
- ) == NULL ) return FALSE;
+ if ( getDatInfo( url,
+ FALSE /* don't check the existence of cache */
+ ) == NULL ) return FALSE;
return TRUE;
}
/* This function searches instance of DatInfo in m_datInfoList.
-
+
If cache exists, create DatInfo and return its pointer.
-
+
If checkCached == TRUE and cache does not exist, return NULL.
-
+
If checkCached == FALSE and cache does not exist,
create DatInfo and return its pointer anyway.
-
+
see also DatManager::searchDatInfo() and DatManager::createDatInfo() */ /* private */
DatInfo* DatManager::getDatInfo( const KURL& url, bool checkCached )
{
/* search */
- DatInfo* datInfo = searchDatInfo( url );
- if( datInfo != NULL ) return datInfo;
+ DatInfo * datInfo = searchDatInfo( url );
+ if ( datInfo != NULL ) return datInfo;
/* create and enroll instance */
return enrollDatInfo( url, checkCached );
DatInfo* DatManager::searchDatInfo( const KURL& url )
{
QMutexLocker locker( &m_mutex );
-
+
KURL datURL = Kita::getDatURL( url );
if ( datURL.isEmpty() ) return NULL; /* This url is not enrolled in BoardManager. */
if ( m_datInfoList.count() == 0 ) return NULL;
int i = 0;
DatInfoList::Iterator it;
DatInfo* datInfo;
-
+
for ( it = m_datInfoList.begin(); it != m_datInfoList.end(); ++it, i++ ) {
- datInfo = ( *it );
+ datInfo = ( *it );
- if ( datURL == datInfo->url() ) {
+ if ( datURL == datInfo->url() ) {
- /* LRU */
- if ( i ) {
- m_datInfoList.remove( it );
- m_datInfoList.prepend( datInfo );
- }
+ /* LRU */
+ if ( i ) {
+ m_datInfoList.remove( it );
+ m_datInfoList.prepend( datInfo );
+ }
- return datInfo;
- }
+ return datInfo;
+ }
}
return NULL;
}
-/* create and enroll the instance of DatInfo and delete old instances.
+/* create and enroll the instance of DatInfo and delete old instances.
Note that DatInfo::DatInfo() opens cached data and reads it. */ /* private */
DatInfo* DatManager::enrollDatInfo( const KURL& url, bool checkCached )
{
QMutexLocker locker( &m_mutex );
-
+
KURL datURL = Kita::getDatURL( url );
- if( datURL.isEmpty() ) return NULL; /* This url is not enrolled in BoardManager. */
+ if ( datURL.isEmpty() ) return NULL; /* This url is not enrolled in BoardManager. */
/* create DatInfo & read cached data */
DatInfo* datInfo = new DatInfo( datURL );
/* Does cache exist ? */
/* If cache does not exist, delete DatInfo here. */
- if( checkCached && datInfo->getReadNum() == 0 ){
- delete datInfo;
- return NULL;
+ if ( checkCached && datInfo->getReadNum() == 0 ) {
+ delete datInfo;
+ return NULL;
}
m_datInfoList.prepend( datInfo );
/* delete the all old instances ( LRU algorithm )*/
if ( m_datInfoList.count() > DMANAGER_MAXQUEUE ) {
- DatInfoList::Iterator it;
- for ( it = m_datInfoList.at( DMANAGER_MAXQUEUE ); it != m_datInfoList.end(); ++it ){
+ DatInfoList::Iterator it;
+ for ( it = m_datInfoList.at( DMANAGER_MAXQUEUE ); it != m_datInfoList.end(); ++it ) {
+
+ if ( ( *it ) == NULL ) continue;
+ DatInfo* deleteInfo = ( *it );
- if( ( *it ) == NULL ) continue;
- DatInfo* deleteInfo = ( *it );
-
- if ( ! deleteInfo->isLocked() ){
+ if ( ! deleteInfo->isLocked() ) {
m_datInfoList.remove( it );
--it;
deleteInfo->wait(); /* wait until DatInfo::m_mutex is released. */
delete deleteInfo;
- }
- }
+ }
+ }
}
return datInfo;
void DatManager::deleteAllDatInfo()
{
DatInfoList::Iterator it;
- for ( it = m_datInfoList.begin(); it != m_datInfoList.end(); ++it ){
+ for ( it = m_datInfoList.begin(); it != m_datInfoList.end(); ++it ) {
- if( ( *it ) == NULL ) continue;
- ( *it )->wait();
- delete ( *it );
+ if ( ( *it ) == NULL ) continue;
+ ( *it ) ->wait();
+ delete ( *it );
}
}
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread == NULL ) return FALSE;
- if( thread->readNum() == 0 ) return FALSE;
+ if ( thread == NULL ) return FALSE;
+ if ( thread->readNum() == 0 ) return FALSE;
/* init DatInfo */
DatInfo * datInfo = searchDatInfo( datURL );
- if( datInfo ){
- if( !datInfo->deleteCache() ) return FALSE;
+ if ( datInfo ) {
+ if ( !datInfo->deleteCache() ) return FALSE;
}
/* reset readNum & veiwPos */
/* lock, unlock DatInfo */
/* public */
-void DatManager::lock( const KURL& url )
+void DatManager::lock ( const KURL& url )
{
DatInfo * datInfo = getDatInfo( url );
- if( datInfo == NULL ) return;
+ if ( datInfo == NULL ) return ;
datInfo->lock ();
}
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread != NULL ) return thread->threadName();
+ if ( thread != NULL ) return thread->threadName();
return QString::null;
}
/* public */
QString DatManager::getHtmlByID( const KURL& url, const QString& strid, int &count )
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return QString::null;
return datInfo->getHtmlByID( strid, count );
/* Get HTML document of res tree.*/ /* public */
QString DatManager::getTreeByRes( const KURL& url, const int rootnum, int &count )
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return QString::null;
return datInfo->getTreeByRes( rootnum, count );
/* Get HTML document of reverse res tree.*/ /* public */
QString DatManager::getTreeByResReverse( const KURL& url, const int rootnum, int &count )
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return QString::null;
return datInfo->getTreeByResReverse( rootnum, count );
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread != NULL ) return thread->resNum();
+ if ( thread != NULL ) return thread->resNum();
return 0;
}
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread != NULL ) return thread->readNum();
+ if ( thread != NULL ) return thread->readNum();
return 0;
}
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread != NULL ) return thread->viewPos();
+ if ( thread != NULL ) return thread->viewPos();
return 0;
}
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread != NULL ) thread->setViewPos( num );
+ if ( thread != NULL ) thread->setViewPos( num );
/* save idx */
Kita::ThreadIndex::setViewPos( url, num );
/* public */
bool DatManager::isThreadEnrolled( const KURL& url )
{
- if( Kita::getDatURL( url ).isEmpty() ) return FALSE;
+ if ( Kita::getDatURL( url ).isEmpty() ) return FALSE;
return TRUE;
}
/* public */
bool DatManager::is2chThread( const KURL& url )
{
- if( BoardManager::type( url ) != Board_2ch ) return FALSE;
- if( Kita::getDatURL( url ).isEmpty() ) return FALSE;
-
+ if ( BoardManager::type( url ) != Board_2ch ) return FALSE;
+ if ( Kita::getDatURL( url ).isEmpty() ) return FALSE;
+
QRegExp url_2ch( ".*\\.2ch\\.net" );
QRegExp url_bbspink( ".*\\.bbspink\\.com" );
-
+
if ( url_2ch.search( url.host() ) != -1
- || url_bbspink.search( url.host() ) != -1 ) return TRUE;
-
+ || url_bbspink.search( url.host() ) != -1 ) return TRUE;
+
return FALSE;
}
/* check if ID == strid */ /* public */
bool DatManager::checkID( const KURL& url, const QString& strid, int num )
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return FALSE;
return datInfo->checkID( strid, num );
bool checkOR /* AND or OR search */
)
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return FALSE;
return datInfo->checkWord( strlist, num, checkOR );
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread == NULL ) return FALSE;
+ if ( thread == NULL ) return FALSE;
return thread->isMarked( num );
}
{
KURL datURL = Kita::getDatURL( url );
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread == NULL ) return;
+ if ( thread == NULL ) return ;
- if( thread->setMark( num, mark ) ) Kita::ThreadIndex::setMarkList( url, thread->markList() );
+ if ( thread->setMark( num, mark ) ) Kita::ThreadIndex::setMarkList( url, thread->markList() );
}
/* public */
bool DatManager::checkAbone( const KURL& url, int num )
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return FALSE;
return datInfo->checkAbone( num );
/* public */
void DatManager::resetAbone( const KURL& url )
{
- DatInfo* datInfo = getDatInfo( url );
+ DatInfo * datInfo = getDatInfo( url );
if ( datInfo == NULL ) return ;
datInfo->resetAbone();
{
KURL datURL = Kita::getDatURL( url ).prettyURL();
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread == NULL ) return FALSE;
+ if ( thread == NULL ) return FALSE;
return thread->isOpened();
}
{
KURL datURL = Kita::getDatURL( url ).prettyURL();
Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
- if( thread != NULL ) thread->setIsOpened( isOpened );
+ if ( thread != NULL ) thread->setIsOpened( isOpened );
}
static void setViewPos( const KURL& url, int num );
static int getDatSize( const KURL& url );
static int getNumByID( const KURL& url, const QString& strid );
-
-
+
+
/* another information */
static bool isThreadEnrolled( const KURL& url );
static bool is2chThread( const KURL& url );
static void setMainThreadOpened( const KURL& url, bool isOpened );
/* obsolete. Don't use them. */
-
+
static const QString threadURL( const KURL& url );
-
+
private:
static DatInfo* getDatInfo( const KURL& url, bool checkCached = TRUE );
/* Download file. Return value is pointer of FileLoader.
If path = QString::null, DownloadManager does not open local file.
-
+
ex.1 )
-
+
If you just want to download "http://www.hoge.com/foo.jpg", then:
-
+
Kita::DownloadManager::download( "http://www.hoge.com/foo.jpg", "/tmp/foo.jpg" );
-
+
ex.2 )
-
+
If you want to do someting when received the data and when done,
then connect signals like this:
-
+
FileLoader* loader = Kita::DownloadManager::download( "http://www.hoge.com/foo.jpg", "/tmp/foo.jpg" );
connect( loader, SIGNAL( data( const Kita::LoaderData&, const QByteArray& ) ),
SLOT( slotData( const Kita::LoaderData&, const QByteArray& ) ) );
connect( loader, SIGNAL( result( const Kita::LoaderData& ) ),
SLOT( slotResult( const Kita::LoaderData& ) ) );
-
+
[ Notice ] DownloadManager deletes FileLoader when done. Never delete it in slotResult().
See also ImgManager::loadPrivate(), and ImgManager::slotResult().
-
+
*/ /* public */ /* static */
FileLoader* DownloadManager::download( const KURL& url, const QString& path,
- const LoaderOption& option /* option user data */
- )
+ const LoaderOption& option /* option user data */
+ )
{
QMutexLocker locker( &m_mutex );
/* to use SIGNAL & SLOT, create instance of DownloadManager here. */
/* ( You CANNOT use SIGNAL & SLOT without instance. ) */
- if( instance == NULL ) instance = new DownloadManager();
-
+ if ( instance == NULL ) instance = new DownloadManager();
+
return instance->downloadPrivate( url, path, option );
}
{
QMutexLocker locker( &m_mutex );
- if( instance ) instance->stopLoadingPrivate( url );
+ if ( instance ) instance->stopLoadingPrivate( url );
}
/* public */ /* static */
bool DownloadManager::isLoadingNow( const KURL& url )
{
- if( instance == NULL ) return FALSE;
+ if ( instance == NULL ) return FALSE;
return instance->isLoadingNowPrivate( url );
}
/* private */
FileLoader* DownloadManager::downloadPrivate( const KURL& url, const QString& path,
- const LoaderOption& option )
+ const LoaderOption& option )
{
if ( isLoadingNowPrivate( url ) ) return NULL;
loader = new FileLoader( url, path, option );
m_loaderList.append( loader );
- if( loader->get() ){
- connect( loader, SIGNAL( result( const Kita::LoaderData& ) ),
+ if ( loader->get() ) {
+ connect( loader, SIGNAL( result( const Kita::LoaderData& ) ),
SLOT( slotResult( const Kita::LoaderData& ) ) );
}
else {
deleteLoader( loader );
return NULL;
}
-
+
return loader;
}
}
-/* private */
+/* private */
FileLoader* DownloadManager::getLoader( const KURL& url )
{
if ( m_loaderList.count() == 0 ) return NULL;
/* This slot is called when loading is done. */ /* private slot */
void DownloadManager::slotResult( const LoaderData& data )
{
- FileLoader* loader = getLoader( data.url );
+ FileLoader * loader = getLoader( data.url );
- /* Deleting the FileLoader here may crush kita,
- because loader may be also used in the other classes.
- So, delete it later. See also customEvent(). */
+ /* Deleting the FileLoader here may crush kita,
+ because loader may be also used in the other classes.
+ So, delete it later. See also customEvent(). */
DeleteLoaderEvent * e = new DeleteLoaderEvent( loader );
QApplication::postEvent( this, e ); // Qt will delete it when done
}
/*
-
+
url: url of target
path: path of save file. It can be QString::null. Then data is not saved in HDD.
option: user defined option. See also downloadmanager.h
-
+
Call get() to start. Call stopJob() to stop.
SIGNAL data() is emitted when data is received.
SIGNAL result() is emitted when done.
-
+
The pointer of struct Kita::LoaderData is sent by SIGNAL data() and result().
For example, to get result code:
-
+
void TmpClass::slotResult( const Kita::LoaderData& data )
{
int result_code = data.code;
}
-
+
See also ImgManager::slotResult() and ImgManager::slotData().
-
+
*/
FileLoader::FileLoader( const KURL& url, const QString& path, const LoaderOption& option )
{
m_data.url = url;
m_data.path = path;
m_data.tmppath = path;
- if( path != QString::null ) m_data.tmppath += ".tmp";
+ if ( path != QString::null ) m_data.tmppath += ".tmp";
m_data.option = option;
m_ds = NULL;
void FileLoader::killJob()
{
/* now loading */
- if ( m_currentJob ){
+ if ( m_currentJob ) {
- m_currentJob->kill(); /* without emitting result SIGNAL */
- m_currentJob = NULL;
- m_data.code = 0;
- closeFile();
+ m_currentJob->kill(); /* without emitting result SIGNAL */
+ m_currentJob = NULL;
+ m_data.code = 0;
+ closeFile();
}
}
if ( m_currentJob ) return FALSE;
/* create directory */
- if( m_data.tmppath != QString::null ){
- QFileInfo qi( m_data.tmppath );
- if( !Kita::mkdir( qi.dirPath( TRUE ) ) ) return FALSE;
+ if ( m_data.tmppath != QString::null ) {
+ QFileInfo qi( m_data.tmppath );
+ if ( !Kita::mkdir( qi.dirPath( TRUE ) ) ) return FALSE;
}
m_data.totalsize = 0;
m_data.redirection = FALSE;
m_file = NULL;
m_ds = NULL;
-
+
/* If path of file is not QString::null, open file here */
/* Note that data is saved as "m_data.tmppath".
This file will be renamed in FileLoader::slotResult(). */
- if( m_data.tmppath != QString::null ){
- m_file = new QFile( m_data.tmppath );
- if ( m_file == NULL || ! m_file->open( IO_WriteOnly ) ) {
- closeFile();
- return FALSE;
- }
- m_ds = new QDataStream( m_file );
+ if ( m_data.tmppath != QString::null ) {
+ m_file = new QFile( m_data.tmppath );
+ if ( m_file == NULL || ! m_file->open( IO_WriteOnly ) ) {
+ closeFile();
+ return FALSE;
+ }
+ m_ds = new QDataStream( m_file );
}
/* create job */
const LoaderData& FileLoader::getData() const
{
return m_data;
-}
+}
/* close file */
/* if code != 200, then remove file. */ /* private */
m_file = NULL;
/* If loading failed, remove file */
- if ( m_data.code != 200 && m_data.tmppath != QString::null && QFile::exists( m_data.tmppath ) ){
+ if ( m_data.code != 200 && m_data.tmppath != QString::null && QFile::exists( m_data.tmppath ) ) {
- QFile::remove( m_data.tmppath );
+ QFile::remove( m_data.tmppath );
}
}
if ( job->error() == 0 ) {
m_data.size += barray.size();
- if( m_ds ) m_ds->writeRawBytes( barray.data(), barray.size() );
+ if ( m_ds ) m_ds->writeRawBytes( barray.data(), barray.size() );
emit data( m_data, barray );
}
closeFile();
/* rename */
- if( m_data.code == 200 && m_data.tmppath != QString::null ){
- if ( QFile::exists( m_data.path ) ) QFile::remove( m_data.path );
- QDir qdir;
- qdir.rename( m_data.tmppath, m_data.path );
+ if ( m_data.code == 200 && m_data.tmppath != QString::null ) {
+ if ( QFile::exists( m_data.path ) ) QFile::remove( m_data.path );
+ QDir qdir;
+ qdir.rename( m_data.tmppath, m_data.path );
}
-
+
emit result( m_data );
}
/* user option */
struct LoaderOption
{
- KURL usrurl;
- QString usrstr;
- QStringList userstrlist;
- int usrnum;
+ KURL usrurl;
+ QString usrstr;
+ QStringList userstrlist;
+ int usrnum;
};
-
+
/* data */
struct LoaderData
{
- /* URL and path of target */
- KURL url;
- QString path;
-
- /* path of tmpfile */
- QString tmppath;
-
- /* redirection */
- bool redirection;
- KURL redirectURL; /* = new URL */
-
- /* file info */
- int code;
- QString header;
- KIO::filesize_t size;
- KIO::filesize_t totalsize;
-
- /* user option */
- LoaderOption option;
+ /* URL and path of target */
+ KURL url;
+ QString path;
+
+ /* path of tmpfile */
+ QString tmppath;
+
+ /* redirection */
+ bool redirection;
+ KURL redirectURL; /* = new URL */
+
+ /* file info */
+ int code;
+ QString header;
+ KIO::filesize_t size;
+ KIO::filesize_t totalsize;
+
+ /* user option */
+ LoaderOption option;
};
-
+
/*-----------------------------------------*/
-
+
class DownloadManager : public QObject
{
Q_OBJECT
~DownloadManager();
static FileLoader* download( const KURL& url, const QString& path,
- const LoaderOption& option = LoaderOption() );
+ const LoaderOption& option = LoaderOption() );
static void stopLoading( const KURL& url );
static bool isLoadingNow( const KURL& url );
FileLoader* getLoader( const KURL& url );
void deleteLoader( Kita::FileLoader* );
-
+
private slots:
void slotResult( const Kita::LoaderData& );
class FileLoader : public QObject
{
Q_OBJECT
-
+
LoaderData m_data;
-
+
KIO::Job* m_currentJob;
QFile *m_file;
QDataStream *m_ds;
-
+
public:
FileLoader( const KURL& url, const QString& path, const LoaderOption& option );
~FileLoader();
/*-----------------------------------------*/
-
+
/* delete loader event */
class DeleteLoaderEvent : public QCustomEvent
{
- Kita::FileLoader* m_loader;
+ Kita::FileLoader* m_loader;
public:
- DeleteLoaderEvent( Kita::FileLoader* loader ) : QCustomEvent( EVENT_DeleteLoader )
- , m_loader( loader ) {}
+ DeleteLoaderEvent( Kita::FileLoader* loader ) : QCustomEvent( EVENT_DeleteLoader )
+ , m_loader( loader ) {}
- Kita::FileLoader* getLoader() const { return m_loader; }
+ Kita::FileLoader* getLoader() const { return m_loader; }
};
}
{
if ( ! getInstance() ->m_list.contains( url ) ) {
getInstance() ->m_list.append( url );
- getInstance()->notifyChange();
+ getInstance() ->notifyChange();
}
}
{
if ( getInstance() ->m_list.contains( url ) ) {
getInstance() ->m_list.remove( url );
- getInstance()->notifyChange();
+ getInstance() ->notifyChange();
}
}
void FavoriteBoards::processChildNode( QDomNode& node )
{
QDomNode urlNode = node.namedItem( "url" );
- if ( ! urlNode.isElement() ) return;
+ if ( ! urlNode.isElement() ) return ;
QString urlText = urlNode.toElement().text();
KURL url = KURL( urlText );
if ( url.isValid() ) {
//FavoriteBoards::append( url );
- if ( !getInstance()->m_list.contains( url ) )
- getInstance()->m_list.append( url );
+ if ( !getInstance() ->m_list.contains( url ) )
+ getInstance() ->m_list.append( url );
}
}
QString FavoriteBoards::toXML()
{
QDomDocument document;
-
+
QDomProcessingInstruction pi = document.createProcessingInstruction( "xml", "version=\"1.0\"" );
document.appendChild( pi );
-
+
QDomElement root = document.createElementNS( "http://kita.sourceforge.jp/ns/boardlist", "boardlist" );
document.appendChild( root );
-
+
QValueList<KURL> boards = FavoriteBoards::boards();
QValueList<KURL>::iterator it;
- for( it = boards.begin(); it != boards.end(); ++it ) {
+ for ( it = boards.begin(); it != boards.end(); ++it ) {
QDomElement board = document.createElementNS( "http://kita.sourceforge.jp/ns/board", "board" );
root.appendChild( board );
-
- QString boardURL = (*it).url();
+
+ QString boardURL = ( *it ).url();
QDomElement urlElement = document.createElement( "url" );
board.appendChild( urlElement );
urlElement.appendChild( document.createTextNode( boardURL ) );
-
+
QString boardName = Kita::BoardManager::boardName( boardURL );
QDomElement nameElement = document.createElement( "name" );
board.appendChild( nameElement );
void FavoriteBoards::replace( QString fromURL, QString toURL )
{
- if( FavoriteBoards::getInstance() == NULL ) return;
- QValueList<KURL>& boardList = FavoriteBoards::getInstance()->m_list;
+ if ( FavoriteBoards::getInstance() == NULL ) return ;
+ QValueList<KURL>& boardList = FavoriteBoards::getInstance() ->m_list;
QValueList<KURL>::iterator it;
for ( it = boardList.begin(); it != boardList.end(); ++it ) {
- QString url = (*it).url();
+ QString url = ( *it ).url();
if ( url.find( fromURL ) == 0 ) {
url = url.replace( 0, fromURL.length(), toURL );
boardList.remove( it );
it = boardList.begin();
}
}
- FavoriteBoards::getInstance()->notifyChange();
+ FavoriteBoards::getInstance() ->notifyChange();
}
void FavoriteBoards::notifyChange()
// FavoriteThreadItem
FavoriteThreadItem::FavoriteThreadItem()
-{
-}
+{}
FavoriteThreadItem::~ FavoriteThreadItem()
-{
-}
+{}
bool FavoriteThreadItem::operator==( const FavoriteThreadItem& item ) const
{
QDomNode datURLNode = node.namedItem( "daturl" );
QDomNode nameNode = node.namedItem( "name" );
- if ( !datURLNode.isElement() || !nameNode.isElement() ) return;
+ if ( !datURLNode.isElement() || !nameNode.isElement() ) return ;
QString url = datURLNode.toElement().text();
QString name = nameNode.toElement().text();
Kita::Thread* thread = Kita::Thread::getByURL( datURL );
thread->setThreadName( name );
Kita::ThreadIndex::loadIndex( thread, datURL );
-
+
FavoriteThreads::getInstance() ->insert( datURL.prettyURL() );
}
QDomElement nameElement = document.createElement( "name" );
threadElement.appendChild( nameElement );
nameElement.appendChild( document.createTextNode( threadName ) );
-
- QString resNum = QString::number( Kita::DatManager::getResNum( datURL ) );
- QDomElement resNumElement = document.createElement( "resnum" );
- threadElement.appendChild( resNumElement );
- resNumElement.appendChild( document.createTextNode( resNum ) );
-
- // board
- QDomElement board = document.createElementNS( "http://kita.sourceforge.jp/ns/board", "board" );
- threadElement.appendChild( board );
-
- QString boardURL = Kita::BoardManager::boardURL( datURL );
- QDomElement boardURLElement = document.createElement( "url" );
- board.appendChild( boardURLElement );
- boardURLElement.appendChild( document.createTextNode( boardURL ) );
-
- QString boardName = Kita::BoardManager::boardName( boardURL );
- QDomElement boardNameElement = document.createElement( "name" );
- board.appendChild( boardNameElement );
+
+ QString resNum = QString::number( Kita::DatManager::getResNum( datURL ) );
+ QDomElement resNumElement = document.createElement( "resnum" );
+ threadElement.appendChild( resNumElement );
+ resNumElement.appendChild( document.createTextNode( resNum ) );
+
+ // board
+ QDomElement board = document.createElementNS( "http://kita.sourceforge.jp/ns/board", "board" );
+ threadElement.appendChild( board );
+
+ QString boardURL = Kita::BoardManager::boardURL( datURL );
+ QDomElement boardURLElement = document.createElement( "url" );
+ board.appendChild( boardURLElement );
+ boardURLElement.appendChild( document.createTextNode( boardURL ) );
+
+ QString boardName = Kita::BoardManager::boardName( boardURL );
+ QDomElement boardNameElement = document.createElement( "name" );
+ board.appendChild( boardNameElement );
boardNameElement.appendChild( document.createTextNode( boardName ) );
}
return document.toString( 0 );
void FavoriteThreads::replace( QString fromURL, QString toURL )
{
- if( FavoriteThreads::getInstance() == NULL ) return;
+ if ( FavoriteThreads::getInstance() == NULL ) return ;
QValueList<FavoriteThreadItem>& threadList = FavoriteThreads::getInstance() ->m_threadList;
QValueList<FavoriteThreadItem>::iterator it;
for ( it = threadList.begin(); it != threadList.end(); ++it ) {
QString FavoriteThreads::getDatURL( int i )
{
- if ( getInstance()->m_threadList.count() > i ) {
- return getInstance()->m_threadList[ i ].m_datURL;
+ if ( getInstance() ->m_threadList.count() > i ) {
+ return getInstance() ->m_threadList[ i ].m_datURL;
} else {
return QString::null;
}
static void replace( QString fromURL, QString toURL );
// FIXME: use Iterator
static QString getDatURL( int i );
- static int count() { return getInstance()->m_threadList.count(); }
+static int count() { return getInstance() ->m_threadList.count(); }
};
#endif
const unsigned int maxload = 5; // = KitaConfig::maxLoader();
/*------------------------------*/
-
+
if ( DownloadManager::isLoadingNow( url ) ) return FALSE;
/* cache exists? */
return TRUE;
}
- if( m_urlList.count() > maxload ) return FALSE;
-
+ if ( m_urlList.count() > maxload ) return FALSE;
+
QString path = Cache::getImgPath( url );
deleteImgDat( url );
option.usrurl = datURL;
FileLoader* loader = DownloadManager::download( url, path, option );
if ( loader == NULL ) return FALSE;
-
+
connect( loader, SIGNAL( data( const Kita::LoaderData&, const QByteArray& ) ),
- SLOT( slotData( const Kita::LoaderData&, const QByteArray& ) ) );
+ SLOT( slotData( const Kita::LoaderData&, const QByteArray& ) ) );
connect( loader, SIGNAL( result( const Kita::LoaderData& ) ),
- SLOT( slotResult( const Kita::LoaderData& ) ) );
+ SLOT( slotResult( const Kita::LoaderData& ) ) );
m_urlList += url.prettyURL();
namespace Kita
{
class LoaderData;
-
+
class ImgManager : public QObject
{
Q_OBJECT
static QMutex m_mutex;
QDict< IMGDAT > m_imgDatDict;
QWidget* m_mainwidget;
- QStringList m_urlList;
+ QStringList m_urlList;
public:
ImgManager( QWidget* mainwidget );
/* finish event */
class EmitFinishEvent : public QCustomEvent
{
- KURL m_url;
+ KURL m_url;
- public:
- EmitFinishEvent( KURL url ) : QCustomEvent( EVENT_EmitFinigh ), m_url( url ) {}
+ public:
+ EmitFinishEvent( KURL url ) : QCustomEvent( EVENT_EmitFinigh ), m_url( url ) {}
- KURL url() const { return m_url; }
+ KURL url() const { return m_url; }
};
}
{
static QMutex codecMutex;
static QCp932Codec* qcpCodec = NULL;
- static QTextCodec* utf8Codec = NULL;
- static QTextCodec* eucCodec = NULL;
+ static QTextCodec* utf8Codec = NULL;
+ static QTextCodec* eucCodec = NULL;
static QString m_weekstr[ 7 ];
static QString m_colonstr;
static int m_prevConvMode;
static QString m_prevConvURL;
static QString m_prevConvNewURL;
- static QString m_prevConvRefstr;
+ static QString m_prevConvRefstr;
/* for ParseMachiBBSOneLine */
static QString m_machiSubject;
)
{
text = QString::null;
-
+
unsigned int startPos, pos;
const QChar *chpt = rawData.unicode();
unsigned int length = rawData.length();
/* remove HTML tags <[^>]*> */
else {
-
- if( i - startPos ) text += rawData.mid( startPos, i - startPos );
+
+ if ( i - startPos ) text += rawData.mid( startPos, i - startPos );
while ( chpt[ i ] != '>' && i < length ) i++;
startPos = i + 1;
}
/*----------------------------------*/
case '&':
-
+
/* special char */
{
QString tmpstr;
}
-/* convert thread URL, and get reference.
+/* convert thread URL, and get reference.
If mode = URLMODE_DAT, output is URL of dat file.
If mode = URLMODE_THREAD, output is URL of read.cgi .
-
+
If url is NOT enrolled, return QString::null.
(ex.1)
-
+
mode = 0
url = http://pc5.2ch.net/linux/dat/1069738960.dat#20-30
->
return : http://pc5.2ch.net/linux/dat/1069738960.dat
retstr : 20-30
-
+
(ex.2)
-
+
mode = 1
url = http://pc5.2ch.net/linux/dat/1069738960.dat#20-30
->
return : http://pc5.2ch.net/test/read.cgi/linux/1069738960
retstr : 20-30
-
+
(ex.3)
-
+
mode = 0
url = http://pc5.2ch.net/test/read.cgi/linux/1069738960/-100
->
QString Kita::convertURL(
/* input */
- int mode, /* if 0, output is dat URL. If 1, output is thread URL */
+ int mode, /* if 0, output is dat URL. If 1, output is thread URL */
const KURL& url ,
/* output */
QString& refstr )
{
refstr = QString::null;
-
- if( url.isEmpty() ) return QString::null;
-
+
+ if ( url.isEmpty() ) return QString::null;
+
/* cache */
- if( m_prevConvMode == mode && m_prevConvURL == url.prettyURL() ) {
+ if ( m_prevConvMode == mode && m_prevConvURL == url.prettyURL() ) {
- refstr = m_prevConvRefstr;
- return m_prevConvNewURL;
+ refstr = m_prevConvRefstr;
+ return m_prevConvNewURL;
}
-
+
/* Is board enrolled ? */
BoardData* bdata = Kita::BoardManager::getBoardData( url );
- if( bdata == NULL ) return QString::null;
+ if ( bdata == NULL ) return QString::null;
QString urlstr = url.prettyURL();
QString thread = QString::null;
QString refBase = QString::null;;
- if( urlstr.contains( "/dat/" ) ){
+ if ( urlstr.contains( "/dat/" ) ) {
- /* url = (hostname)/(rootPath)/(bbsPath)/dat/(thread_ID).(ext)#(refBase) */
- thread = url.filename().remove( bdata->ext() );
- refBase = url.ref();
- }
- else if( urlstr.contains( bdata->delimiter() ) ) {
-
- QString tmpstr;
- switch( bdata->type() ){
-
- /* machi BBS */
- /* ex.) If url = http://kanto.machi.to/bbs/read.pl?BBS=kana&KEY=1096716679 ,
- then, thread = 1096716679 */
- case Board_MachiBBS:
- thread = url.queryItem( "KEY" );
- refBase = QString::null;
- break;
-
- /* url = (hostname)/(rootPath)/(delimiter)/(bbsPath)/(thread_ID)/(refBase) */
- default:
- tmpstr = urlstr.section( bdata->delimiter() + bdata->bbsPath(), 1, 1 );
+ /* url = (hostname)/(rootPath)/(bbsPath)/dat/(thread_ID).(ext)#(refBase) */
+ thread = url.filename().remove( bdata->ext() );
+ refBase = url.ref();
+ } else if ( urlstr.contains( bdata->delimiter() ) ) {
+
+ QString tmpstr;
+ switch ( bdata->type() ) {
+
+ /* machi BBS */
+ /* ex.) If url = http://kanto.machi.to/bbs/read.pl?BBS=kana&KEY=1096716679 ,
+ then, thread = 1096716679 */
+ case Board_MachiBBS:
+ thread = url.queryItem( "KEY" );
+ refBase = QString::null;
+ break;
+
+ /* url = (hostname)/(rootPath)/(delimiter)/(bbsPath)/(thread_ID)/(refBase) */
+ default:
+ tmpstr = urlstr.section( bdata->delimiter() + bdata->bbsPath(), 1, 1 );
thread = tmpstr.section( '/', 1, 1 );
- refBase = tmpstr.section( '/', 2, 2 );
- break;
- }
+ refBase = tmpstr.section( '/', 2, 2 );
+ break;
+ }
}
- if( thread == QString::null ) return QString::null;
+ if ( thread == QString::null ) return QString::null;
+
+ if ( refBase != QString::null ) {
- if ( refBase != QString::null ){
-
- if ( refBase.at( 0 ) == '-' ) refstr = "1" + refBase;
- else refstr = refBase;
+ if ( refBase.at( 0 ) == '-' ) refstr = "1" + refBase;
+ else refstr = refBase;
}
/* create new URL */
QString newURL;
- if( mode == URLMODE_DAT ) newURL = bdata->basePath() + "dat/" + thread + bdata->ext();
+ if ( mode == URLMODE_DAT ) newURL = bdata->basePath() + "dat/" + thread + bdata->ext();
else {
- newURL = bdata->cgiBasePath();
-
- switch( bdata->type() ){
-
- case Board_MachiBBS:
- newURL += "&KEY=" + thread;
- break;
-
- default:
- newURL += thread;
- break;
- }
+ newURL = bdata->cgiBasePath();
+
+ switch ( bdata->type() ) {
+
+ case Board_MachiBBS:
+ newURL += "&KEY=" + thread;
+ break;
+
+ default:
+ newURL += thread;
+ break;
+ }
}
/* cache */
m_prevConvURL = url.prettyURL();
m_prevConvNewURL = newURL;
m_prevConvRefstr = refstr;
-
+
return newURL;
}
bool Kita::mkdir( const QString& targetPath )
{
QDir qdir( targetPath );
- if( !qdir.exists() ){
+ if ( !qdir.exists() ) {
+
+ QStringList pathList = QStringList::split( "/", targetPath );
+ QString path = QString::null;
- QStringList pathList = QStringList::split( "/", targetPath );
- QString path = QString::null;
+ for ( unsigned int i = 0; i < pathList.count(); ++i ) {
- for( unsigned int i = 0; i < pathList.count(); ++i ){
-
- path += "/" + pathList[ i ];
+ path += "/" + pathList[ i ];
- qdir = path;
- if( !qdir.exists() ){
- if( !qdir.mkdir( path ) ) return FALSE;
- }
- }
+ qdir = path;
+ if ( !qdir.exists() ) {
+ if ( !qdir.mkdir( path ) ) return FALSE;
+ }
+ }
}
return TRUE;
}
-/* if cdat == str, return str.length() */
+/* if cdat == str, return str.length() */
int Kita::isEqual( const QChar *cdat, const QString& str )
{
int i = 0;
/* init parser. Don't forget to call this before parsing. */
-void Kita::InitParseMachiBBS(){
+void Kita::InitParseMachiBBS()
+{
m_machiSubject = QString::null;
m_machiLine = QString::null;
}
// Subject
QRegExp title_regexp( "<title>(.*)</title>" );
-
+
// pattern 1 (tokyo,kanagawa,...)
QRegExp regexp ( "<dt>(\\d*) .*<font color=\"#......\"><b> (.*) </b></font> .* (..../../..).* (..:..:..) ID:([^<]*)<br><dd>(.*)" );
QRegExp regexp2( "<dt>(\\d*) .*<a href=\"mailto:(.*)\"><b> (.*) </B></a> .* (..../../..).* (..:..:..) ID:([^<]*)<br><dd>(.*)" );
/* abone */
QRegExp regexp5( "<dt>(\\d*) .*<br><dd>.*" );
-
+
if ( regexp.search( m_machiLine ) != -1 ) {
-
- num = regexp.cap( 1 ).toInt();
- name = regexp.cap( 2 );
- date = regexp.cap( 3 );
- time = regexp.cap( 4 );
- id = regexp.cap( 5 );
- message = regexp.cap( 6 );
-
+
+ num = regexp.cap( 1 ).toInt();
+ name = regexp.cap( 2 );
+ date = regexp.cap( 3 );
+ time = regexp.cap( 4 );
+ id = regexp.cap( 5 );
+ message = regexp.cap( 6 );
+
} else if ( regexp2.search( m_machiLine ) != -1 ) {
-
- num = regexp2.cap( 1 ).toInt();
- mail = regexp2.cap( 2 );
- name = regexp2.cap( 3 );
- date = regexp2.cap( 4 );
- time = regexp2.cap( 5 );
- id = regexp2.cap( 6 );
- message = regexp2.cap( 7 );
-
+
+ num = regexp2.cap( 1 ).toInt();
+ mail = regexp2.cap( 2 );
+ name = regexp2.cap( 3 );
+ date = regexp2.cap( 4 );
+ time = regexp2.cap( 5 );
+ id = regexp2.cap( 6 );
+ message = regexp2.cap( 7 );
+
} else if ( regexp3.search( m_machiLine ) != -1 ) {
-
- num = regexp3.cap( 1 ).toInt();
- name = regexp3.cap( 2 );
- date = regexp3.cap( 3 );
- time = regexp3.cap( 4 );
- id = regexp3.cap( 5 );
- host = regexp3.cap( 6 );
- message = regexp3.cap( 7 );
-
+
+ num = regexp3.cap( 1 ).toInt();
+ name = regexp3.cap( 2 );
+ date = regexp3.cap( 3 );
+ time = regexp3.cap( 4 );
+ id = regexp3.cap( 5 );
+ host = regexp3.cap( 6 );
+ message = regexp3.cap( 7 );
+
} else if ( regexp4.search( m_machiLine ) != -1 ) {
-
- num = regexp4.cap( 1 ).toInt();
- mail = regexp4.cap( 2 );
- name = regexp4.cap( 3 );
- date = regexp4.cap( 4 );
- time = regexp4.cap( 5 );
- id = regexp4.cap( 6 );
- host = regexp4.cap( 7 );
- message = regexp4.cap( 8 );
+
+ num = regexp4.cap( 1 ).toInt();
+ mail = regexp4.cap( 2 );
+ name = regexp4.cap( 3 );
+ date = regexp4.cap( 4 );
+ time = regexp4.cap( 5 );
+ id = regexp4.cap( 6 );
+ host = regexp4.cap( 7 );
+ message = regexp4.cap( 8 );
} else if ( regexp5.search( m_machiLine ) != -1 ) { /* abone */
-
- num = regexp5.cap( 1 ).toInt();
- m_machiLine = QString::null;
- if( num == nextNum ) return "abone<><><>abone<>";
- else return QString::null;
-
+
+ num = regexp5.cap( 1 ).toInt();
+ m_machiLine = QString::null;
+ if ( num == nextNum ) return "abone<><><>abone<>";
+ else return QString::null;
+
} else if ( title_regexp.search( m_machiLine ) != -1 ) { /* get title */
-
- m_machiSubject = title_regexp.cap( 1 );
- m_machiLine = QString::null;
- return QString::null;
+
+ m_machiSubject = title_regexp.cap( 1 );
+ m_machiLine = QString::null;
+ return QString::null;
}
-
else return QString::null;
- if( num >= nextNum ){
-
- if( num != 1 ) m_machiSubject = QString::null;
- ret += name + "<><>" + date + " " + time + " ID:" + id;
- if( host != QString::null ) ret += " HOST:" + host;
- ret += "<>" + message + "<>" + m_machiSubject;
- nextNum = num;
+ if ( num >= nextNum ) {
+
+ if ( num != 1 ) m_machiSubject = QString::null;
+ ret += name + "<><>" + date + " " + time + " ID:" + id;
+ if ( host != QString::null ) ret += " HOST:" + host;
+ ret += "<>" + message + "<>" + m_machiSubject;
+ nextNum = num;
}
-
+
m_machiLine = QString::null;
return ret;
}
QString Kita::ParseJBBSOneLine( const QString& line, int& nextNum )
{
- QString ret = QString::null;
- QStringList list = QStringList::split( "<>", line, true );
- if( list.size() != 7 ) return QString::null;
-
- int num = list[ 0 ].toInt();
- QString name = list[ 1 ];
- QString mail = list[ 2 ];
- QString date = list[ 3 ];
- QString body = list[ 4 ];
- QString subject = list[ 5 ];
- QString id = list[ 6 ];
-
- if( num < nextNum ) return QString::null;
-
- /* remove tag */
- QRegExp rex( "<[^<]*>" );
- name.remove( rex );
+ QString ret = QString::null;
+ QStringList list = QStringList::split( "<>", line, true );
+ if ( list.size() != 7 ) return QString::null;
- /* remove week */
- rex = QRegExp( "\\(.*\\)" );
- date.remove( rex );
-
- ret += name + "<>" + mail + "<>" + date + " ID:" + id + "<>" + body + "<>" + subject;
- nextNum = num;
-
- return ret;
+ int num = list[ 0 ].toInt();
+ QString name = list[ 1 ];
+ QString mail = list[ 2 ];
+ QString date = list[ 3 ];
+ QString body = list[ 4 ];
+ QString subject = list[ 5 ];
+ QString id = list[ 6 ];
+
+ if ( num < nextNum ) return QString::null;
+
+ /* remove tag */
+ QRegExp rex( "<[^<]*>" );
+ name.remove( rex );
+
+ /* remove week */
+ rex = QRegExp( "\\(.*\\)" );
+ date.remove( rex );
+
+ ret += name + "<>" + mail + "<>" + date + " ID:" + id + "<>" + body + "<>" + subject;
+ nextNum = num;
+
+ return ret;
}
QString Kita::ParseFlashCGIOneLine( const QString& line )
{
- QString ret = QString::null;
- QStringList list = QStringList::split( "<>", line, true );
- if( list.size() != 13 ) return QString::null;
-
- QString name = list[ 0 ];
- QString mail = list[ 1 ];
- QString date = list[ 2 ];
- QString body = list[ 3 ];
- QString subject = list[ 4 ];
- QString id = list[ 6 ];
- QString host = list[ 7 ];
-
- /* remove tag */
- QRegExp rex( "<[^<]*>" );
- name.remove( rex );
-
- ret += name + "<>" + mail + "<>" + date + " ID:" + id;
- if( host != QString::null ) ret += " HOST:" + host;
- ret += "<>" + body + "<>" + subject;
-
- return ret;
+ QString ret = QString::null;
+ QStringList list = QStringList::split( "<>", line, true );
+ if ( list.size() != 13 ) return QString::null;
+
+ QString name = list[ 0 ];
+ QString mail = list[ 1 ];
+ QString date = list[ 2 ];
+ QString body = list[ 3 ];
+ QString subject = list[ 4 ];
+ QString id = list[ 6 ];
+ QString host = list[ 7 ];
+
+ /* remove tag */
+ QRegExp rex( "<[^<]*>" );
+ name.remove( rex );
+
+ ret += name + "<>" + mail + "<>" + date + " ID:" + id;
+ if ( host != QString::null ) ret += " HOST:" + host;
+ ret += "<>" + body + "<>" + subject;
+
+ return ret;
}
This function is called from Kita::DatToHtml() and DatInfo::parseDat()
input:
-
+
resdat.num ... number
resdat.linestr ... raw line strings
-
+
output:
resdat.*
subject
-*/
+*/
bool Kita::parseResDat( RESDAT& resdat, QString& subject )
{
if ( resdat.parsed ) return TRUE;
-
+
resdat.parsed = TRUE;
resdat.broken = FALSE;
resdat.anclist.clear();
-
+
/* search the staring positions of each section to split raw data. */
const QChar *chpt = resdat.linestr.unicode();
unsigned int length = resdat.linestr.length();
unsigned int sectionPos[ 5 ];
for ( unsigned int i = 0 ; i < length ; i++ ) {
- /* sections are splitted by "<>" */
- if ( chpt[ i ] == '<' && chpt[ i + 1 ] == '>' ){
- section++;
+ /* sections are splitted by "<>" */
+ if ( chpt[ i ] == '<' && chpt[ i + 1 ] == '>' ) {
+ section++;
- if( section >= 5 ){
- resdat.broken = TRUE;
- return TRUE;
- }
+ if ( section >= 5 ) {
+ resdat.broken = TRUE;
+ return TRUE;
+ }
- sectionPos[ section ] = i + 2;
- i++;
- }
+ sectionPos[ section ] = i + 2;
+ i++;
+ }
}
- /* broken data */
- if( section != 4 ){
- resdat.broken = TRUE;
- return TRUE;
+ /* broken data */
+ if ( section != 4 ) {
+ resdat.broken = TRUE;
+ return TRUE;
}
-// qDebug("[%d] %d %d %d %d",section, sectionPos[1],sectionPos[2],sectionPos[3],sectionPos[4] );
+ // qDebug("[%d] %d %d %d %d",section, sectionPos[1],sectionPos[2],sectionPos[3],sectionPos[4] );
/* name */
- length = sectionPos[ 1 ] -2 ;
+ length = sectionPos[ 1 ] - 2 ;
parseName( resdat.linestr.mid( 0, length ), resdat );
/* mail */
- length = sectionPos[ 2 ] -2 - sectionPos[ 1 ];
+ length = sectionPos[ 2 ] - 2 - sectionPos[ 1 ];
DatToText( resdat.linestr.mid( sectionPos[ 1 ], length ), resdat.address );
/* date, ID, host */
- length = sectionPos[ 3 ] -2 - sectionPos[ 2 ];
+ length = sectionPos[ 3 ] - 2 - sectionPos[ 2 ];
parseDateId( resdat.linestr.mid( sectionPos[ 2 ], length ), resdat );
/* body */
- length = sectionPos[ 4 ] -2 - sectionPos[ 3 ];
+ length = sectionPos[ 4 ] - 2 - sectionPos[ 3 ];
parseBody( resdat.linestr.mid( sectionPos[ 3 ], length ), resdat );
/* subject */
*/
void Kita::parseName( const QString& rawStr, RESDAT& resdat )
{
- unsigned int i = 0, pos;
+ unsigned int i = 0, pos;
int refNum[ 2 ];
QString linkurl, linkstr;
const QChar * chpt = resdat.name.unicode();
unsigned int length = resdat.name.length();
resdat.nameHTML = QString::null;
-
+
/* anchor */
- while( parseResAnchor( chpt + i, length - i, linkstr, refNum, pos ) ) {
-
- linkurl = QString( "#%1" ).arg( refNum[ 0 ] );
- if ( refNum[ 1 ] ) linkurl += QString( "-%1" ).arg( refNum[ 1 ] );
-
- resdat.nameHTML += "<a href=\"" + linkurl + "\">";
- resdat.nameHTML += linkstr;
- resdat.nameHTML += "</a>";
-
- ANCNUM anctmp;
- if ( refNum[ 1 ] < refNum[ 0 ] ) refNum[ 1 ] = refNum[ 0 ];
- anctmp.from = refNum[ 0 ];
- anctmp.to = refNum[ 1 ];
- resdat.anclist += anctmp;
-
- i += pos;
+ while ( parseResAnchor( chpt + i, length - i, linkstr, refNum, pos ) ) {
+
+ linkurl = QString( "#%1" ).arg( refNum[ 0 ] );
+ if ( refNum[ 1 ] ) linkurl += QString( "-%1" ).arg( refNum[ 1 ] );
+
+ resdat.nameHTML += "<a href=\"" + linkurl + "\">";
+ resdat.nameHTML += linkstr;
+ resdat.nameHTML += "</a>";
+
+ ANCNUM anctmp;
+ if ( refNum[ 1 ] < refNum[ 0 ] ) refNum[ 1 ] = refNum[ 0 ];
+ anctmp.from = refNum[ 0 ];
+ anctmp.to = refNum[ 1 ];
+ resdat.anclist += anctmp;
+
+ i += pos;
}
/* non-digits strings */
- if( i < length ){
-
- resdat.nameHTML += "<span class=\"name_noaddr\">";
- resdat.nameHTML += resdat.name.mid( i );
- resdat.nameHTML += "</span>";
+ if ( i < length ) {
+
+ resdat.nameHTML += "<span class=\"name_noaddr\">";
+ resdat.nameHTML += resdat.name.mid( i );
+ resdat.nameHTML += "</span>";
}
-
+
}
resdat.date
resdat.id
resdat.host
-
+
*/
void Kita::parseDateId( const QString& rawStr, RESDAT& resdat )
{
resdat.date = rawStr;
resdat.id = QString::null;
resdat.host = QString::null;
-
+
const QChar *chpt = rawStr.unicode();
unsigned int pos = 0, startpos = 0;
unsigned int length = rawStr.length();
/* year */
- while( chpt[ pos ] != '/' && pos++ < length );
- if( pos >= length ) return;
+ while ( chpt[ pos ] != '/' && pos++ < length );
+ if ( pos >= length ) return ;
int year = rawStr.mid( 0, pos ).toInt();
pos++;
year += 2000;
}
-// qDebug("year %d, pos %d",year,pos );
+ // qDebug("year %d, pos %d",year,pos );
/* month */
startpos = pos;
- while( chpt[ pos ] != '/' && pos++ < length );
- if( pos >= length ) return;
+ while ( chpt[ pos ] != '/' && pos++ < length );
+ if ( pos >= length ) return ;
int month = rawStr.mid( startpos, pos - startpos ).toInt();
pos++;
-// qDebug("month %d, pos %d",month,pos );
+ // qDebug("month %d, pos %d",month,pos );
/* day */
startpos = pos;
- while( chpt[ pos ] != ' ' && chpt[ pos ] != '(' && pos++ < length );
- if( pos >= length ) return;
+ while ( chpt[ pos ] != ' ' && chpt[ pos ] != '(' && pos++ < length );
+ if ( pos >= length ) return ;
int day = rawStr.mid( startpos, pos - startpos ).toInt();
pos++;
-// qDebug("day %d, pos %d",day,pos );
+ // qDebug("day %d, pos %d",day,pos );
/* skip week */
- if( chpt[ pos -1 ] == '(' ){
+ if ( chpt[ pos - 1 ] == '(' ) {
- while ( chpt[ pos ] != ')' && pos++ < length );
- pos++;
+ while ( chpt[ pos ] != ')' && pos++ < length );
+ pos++;
}
-
+
/* hour */
startpos = pos;
- while( chpt[ pos ] != ':' && pos++ < length );
- if( pos >= length ) return;
+ while ( chpt[ pos ] != ':' && pos++ < length );
+ if ( pos >= length ) return ;
int hour = rawStr.mid( startpos, pos - startpos ).toInt();
pos++;
-// qDebug("h %d, pos %d",hour,pos );
+ // qDebug("h %d, pos %d",hour,pos );
/* min */
startpos = pos;
- while( chpt[ pos ] != ':' && chpt[ pos ] != ' ' && pos++ < length );
+ while ( chpt[ pos ] != ':' && chpt[ pos ] != ' ' && pos++ < length );
int min = rawStr.mid( startpos, pos - startpos ).toInt();
pos++;
-// qDebug("min %d, pos %d",min,pos );
+ // qDebug("min %d, pos %d",min,pos );
/* sec */
int sec = 0;
- if( pos < length && chpt[ pos -1 ] == ':' ){
- startpos = pos;
- while( chpt[ pos ] != ' ' && pos++ < length );
- sec = rawStr.mid( startpos, pos - startpos ).toInt();
- pos++;
+ if ( pos < length && chpt[ pos - 1 ] == ':' ) {
+ startpos = pos;
+ while ( chpt[ pos ] != ' ' && pos++ < length );
+ sec = rawStr.mid( startpos, pos - startpos ).toInt();
+ pos++;
-// qDebug("sec %d, pos %d",sec,pos );
+ // qDebug("sec %d, pos %d",sec,pos );
}
/* date */
resdat.dateTime = QDateTime( QDate( year, month, day ), QTime( hour, min, sec ) );
resdat.date = resdat.dateTime.toString( "yy/MM/dd" )
- + m_weekstr[ resdat.dateTime.date().dayOfWeek() - 1 ]
- + resdat.dateTime.toString( "hh:mm:ss" );
+ + m_weekstr[ resdat.dateTime.date().dayOfWeek() - 1 ]
+ + resdat.dateTime.toString( "hh:mm:ss" );
+
+ if ( pos >= length ) return ;
- if( pos >= length ) return;
-
/* id */
- if( chpt[ pos ] == 'I' && chpt[ pos +1 ] == 'D' ){
- pos += 3;
- startpos = pos;
- while( chpt[ pos ] != ' ' && pos++ < length );
- resdat.id = rawStr.mid( startpos, pos - startpos );
- pos++;
+ if ( chpt[ pos ] == 'I' && chpt[ pos + 1 ] == 'D' ) {
+ pos += 3;
+ startpos = pos;
+ while ( chpt[ pos ] != ' ' && pos++ < length );
+ resdat.id = rawStr.mid( startpos, pos - startpos );
+ pos++;
}
-// qDebug("date %s, ID %s", (const char*)resdat.date.local8Bit(), resdat.id.ascii() );
-
- if( pos >= length ) return;
+ // qDebug("date %s, ID %s", (const char*)resdat.date.local8Bit(), resdat.id.ascii() );
+
+ if ( pos >= length ) return ;
/* host */
- if( chpt[ pos ] == 'H' && chpt[ pos +1 ] == 'O' ){
- pos += 5;
- startpos = pos;
- while( chpt[ pos ] != ' ' && pos++ < length );
- resdat.host = rawStr.mid( startpos, pos - startpos );
- pos++;
-// qDebug("host %s", resdat.host.ascii());
+ if ( chpt[ pos ] == 'H' && chpt[ pos + 1 ] == 'O' ) {
+ pos += 5;
+ startpos = pos;
+ while ( chpt[ pos ] != ' ' && pos++ < length );
+ resdat.host = rawStr.mid( startpos, pos - startpos );
+ pos++;
+ // qDebug("host %s", resdat.host.ascii());
}
}
/* output :
resdat.bodyHTML
-
+
*/
void Kita::parseBody( const QString &rawStr, RESDAT& resdat )
{
bool showAA = KitaConfig::showAA();
resdat.bodyHTML = "<div>";
#endif
-
+
unsigned int startPos, pos;
QString linkstr, linkurl;
const QChar *chpt = rawStr.unicode();
unsigned int length = rawStr.length();
bool ancChain = FALSE;
-
+
/* ancChain is chain for anchor. For examle, if anchor ">2"
appeared, ancChain is set to TRUE. Moreover, if next strings
are "=5", anchor for 5 is also set. Thus, we can obtain anchors
*/
int offset = 0;
- if( chpt[ 0 ] == ' ' ) offset = 1; /* remove one space after <> */
+ if ( chpt[ 0 ] == ' ' ) offset = 1; /* remove one space after <> */
for ( unsigned int i = startPos = offset ; i < length ; i++ ) {
switch ( chpt[ i ].unicode() ) {
/* " <br> " */
if ( chpt[ i + 1 ] == 'b' && chpt[ i + 2 ] == 'r' && chpt[ i + 3 ] == '>' ) {
- /* reset anchor chain */
+ /* reset anchor chain */
ancChain = FALSE;
unsigned int i2 = i - startPos;
if ( i > 0 && chpt[ i - 1 ] == ' ' ) i2--; /* remove space before <br> */
resdat.bodyHTML += rawStr.mid( startPos, i2 );
- resdat.bodyHTML += "<br>";
-
+ resdat.bodyHTML += "<br>";
+
#if KDE_IS_VERSION( 3, 2, 0 )
#else
- /* show Ascii Art (for KDE3.1*) */
- if ( showAA ) resdat.bodyHTML += "<span style=\"color: white\">_</span>";
-#endif
+ /* show Ascii Art (for KDE3.1*) */
+ if ( showAA ) resdat.bodyHTML += "<span style=\"color: white\">_</span>";
+#endif
startPos = i + 4;
if ( chpt[ startPos ] == ' ' ) startPos++; /* remove space after <br> */
/* remove HTML tags <[^>]*> */
else {
-
- if( i - startPos ) resdat.bodyHTML += rawStr.mid( startPos, i - startPos );
+
+ if ( i - startPos ) resdat.bodyHTML += rawStr.mid( startPos, i - startPos );
while ( chpt[ i ] != '>' && i < length ) i++;
startPos = i + 1;
}
/*----------------------------------------*/
- case 'h': /* "http://" or "ttp://" or "tp:" */
+ case 'h': /* "http://" or "ttp://" or "tp:" */
case 't':
if ( parseLink( chpt + i, length - i, linkstr, linkurl, pos ) ) {
resdat.bodyHTML += rawStr.mid( startPos, i - startPos );
- resdat.bodyHTML += "<a href=\"" + linkurl + "\">";
- resdat.bodyHTML += linkstr;
- resdat.bodyHTML += "</a>";
+ resdat.bodyHTML += "<a href=\"" + linkurl + "\">";
+ resdat.bodyHTML += linkstr;
+ resdat.bodyHTML += "</a>";
startPos = i + pos;
i = startPos - 1;
/* unicode '>' */
case UTF16_BRACKET:
-
+
ancChain = createResAnchor( rawStr, resdat, chpt, i, startPos );
break;
/*----------------------------------*/
default:
-
+
if ( ancChain ) ancChain = createResAnchor( rawStr, resdat, chpt, i, startPos );
}
}
if ( c == '-'
|| ( c >= 0x2010 && c <= 0x2015 )
|| ( c == 0x2212 )
- || ( c == 0xFF0D ) /* UTF8: 0xEFBC8D */
+ || ( c == 0xFF0D ) /* UTF8: 0xEFBC8D */
) {
return TRUE;
}
/* create res anchor */
/* This function is called from parseBody internally.
- See also parseBody. */
+ See also parseBody. */
bool Kita::createResAnchor( const QString &rawStr, RESDAT& resdat,
- const QChar *chpt, unsigned int &i, unsigned int &startPos )
+ const QChar *chpt, unsigned int &i, unsigned int &startPos )
{
QString linkstr, linkurl;
int refNum[ 2 ];
/* parse anchor */
if ( !parseResAnchor( chpt + i, length - i, linkstr, refNum, pos ) ) {
-
+
i += pos - 1;
return FALSE;
}
anctmp.from = refNum[ 0 ];
anctmp.to = refNum[ 1 ];
resdat.anclist += anctmp;
-
+
startPos = i + pos;
i = startPos - 1;
/* create HTML of title.
struct RESDAT resdat should be parsed by parseResDat before calling this function.
-
+
output: titleHTML
*/
void Kita::createTitleHTML( RESDAT& resdat, QString& titleHTML )
{
titleHTML = QString::null;
- if ( !resdat.parsed ) return;
+ if ( !resdat.parsed ) return ;
bool showMailAddress = KitaConfig::showMailAddress();
bool useTableTag = KitaConfig::useStyleSheet();
-
+
if ( m_colonstr == QString::null ) {
m_colonstr = utf8ToUnicode( KITAUTF8_COLON );
m_colonnamestr = utf8ToUnicode( KITAUTF8_NAME );
/* For KDE3.1 */
useTableTag = TRUE;
#endif
-
- if( useTableTag ) titleHTML += "<table class=\"res_title\"><tr>";
-
+
+ if ( useTableTag ) titleHTML += "<table class=\"res_title\"><tr>";
+
/* res number */
- if( useTableTag ) titleHTML += "<td class=\"res_title_number\">";
+ if ( useTableTag ) titleHTML += "<td class=\"res_title_number\">";
titleHTML += "<a href=\"#write" + QString().setNum( resdat.num ) + "\">";
titleHTML += QString().setNum( resdat.num );
titleHTML += "</a> ";
-
+
/* name & mail address */
- if( useTableTag ) titleHTML += "<td class=\"res_title_name\">";
+ if ( useTableTag ) titleHTML += "<td class=\"res_title_name\">";
titleHTML += "<b>" + m_colonnamestr;
/* show name with mail address */
- if ( showMailAddress ){
-
- titleHTML += resdat.nameHTML;
- if ( resdat.address != QString::null ) titleHTML += " [" + resdat.address + "]";
+ if ( showMailAddress ) {
+
+ titleHTML += resdat.nameHTML;
+ if ( resdat.address != QString::null ) titleHTML += " [" + resdat.address + "]";
} else { /* don't show mail address */
- if( resdat.address == QString::null ){
-
- titleHTML += "<span class=\"name_noaddr\">";
- titleHTML += resdat.name;
- titleHTML += "</span>";
-
- } else{
-
- titleHTML += "<a href=\"mailto:" + resdat.address + "\"";
- titleHTML += " title=\"" + resdat.address + "\">";
- titleHTML += resdat.name;
- titleHTML += "</a>";
- }
+ if ( resdat.address == QString::null ) {
+
+ titleHTML += "<span class=\"name_noaddr\">";
+ titleHTML += resdat.name;
+ titleHTML += "</span>";
+
+ } else {
+
+ titleHTML += "<a href=\"mailto:" + resdat.address + "\"";
+ titleHTML += " title=\"" + resdat.address + "\">";
+ titleHTML += resdat.name;
+ titleHTML += "</a>";
+ }
}
titleHTML += "</b> ";
/* date */
- if( useTableTag ) titleHTML += "<td class=\"res_title_date\">";
+ if ( useTableTag ) titleHTML += "<td class=\"res_title_date\">";
titleHTML += m_colonstr + resdat.date + " ";
/* ID */
if ( resdat.id != QString::null ) {
- if( useTableTag ) titleHTML += "<td class=\"res_title_id\">";
+ if ( useTableTag ) titleHTML += "<td class=\"res_title_id\">";
if ( resdat.id == "???" ) titleHTML += "ID:" + resdat.id;
else titleHTML += "<a href=\"#idpop" + resdat.id + "\">ID</a>" + ":" + resdat.id;
}
/* host */
- if( resdat.host != QString::null ){
+ if ( resdat.host != QString::null ) {
- if( useTableTag ) titleHTML += "<td class=\"res_title_host\">";
- titleHTML += "HOST:" + resdat.host;
+ if ( useTableTag ) titleHTML += "<td class=\"res_title_host\">";
+ titleHTML += "HOST:" + resdat.host;
}
- if( useTableTag ) titleHTML += "</tr></table>";
+ if ( useTableTag ) titleHTML += "</tr></table>";
}
/*--------------------------------*/
/* obsolete */
-QString Kita::datToBoard( const KURL& datURL ){ return BoardManager::boardURL( datURL ); }
+QString Kita::datToBoard( const KURL& datURL ) { return BoardManager::boardURL( datURL ); }
int Kita::boardType( const KURL& url ) { return BoardManager::type( url ); }
* @author Hideki Ikemoto
*/
- /*------------------------------*/
+ /*------------------------------*/
/* text codecs */
QString qcpToUnicode( const QString& str );
QString utf8ToUnicode( const QString& str );
QString ecuToUnicode( const QString& str );
-
+
/*------------------------------*/
/* conversion of DAT */
QString DatToHtml( const QString& rawData, int num );
void DatToText( const QString &rawData, QString& text );
QString parseSpecialChar( const QChar *cdat, unsigned int& pos );
-
+
/*------------------------------*/
/* conversion of URL */
QString convertURL( int mode, const KURL& url , QString& refstr );
QString datToOfflaw( const KURL& datURL );
-
-
- /*------------------------------*/
+
+
+ /*------------------------------*/
/* utilities */
bool mkdir( const QString& path );
QString unescape( const QString& str );
uint datToSince( const KURL& datURL );
int isEqual( const QChar *cdat, const QString& str );
int stringToPositiveNum( const QChar *cdat, const unsigned int length );
-
+
/*------------------------------*/
/* internal parsing funtions */
-
+
/* for MACHI BBS */
void InitParseMachiBBS();
QString ParseMachiBBSOneLine( const QString& inputLine, int& nextNum );
-
+
/* for JBBS */
QString ParseJBBSOneLine( const QString& line, int& nextNum );
/* for Flash CGI/Mini Thread */
QString ParseFlashCGIOneLine( const QString& line );
-
+
/* for 2ch */
bool parseResDat( RESDAT& resdat, QString& subject );
-
- void parseName( const QString& rawStr, RESDAT& resdat );
+
+ void parseName( const QString& rawStr, RESDAT& resdat );
void parseDateId( const QString& rawStr, RESDAT& resdat );
void parseBody( const QString &rawStr, RESDAT& resdat );
bool parseLink( const QChar *cdat, const unsigned int length,
- QString& linkstr, QString& linkurl, unsigned int& pos );
+ QString& linkstr, QString& linkurl, unsigned int& pos );
bool parseResAnchor( const QChar *cdat, const unsigned int length,
- QString& linkstr, int* refNum, unsigned int& pos );
+ QString& linkstr, int* refNum, unsigned int& pos );
bool createResAnchor( const QString &rawStr, RESDAT& resdat,
- const QChar *chpt, unsigned int &i, unsigned int &index );
+ const QChar *chpt, unsigned int &i, unsigned int &index );
+
+ void createTitleHTML( RESDAT& resdat, QString& titletext );
- void createTitleHTML( RESDAT& resdat, QString& titletext );
-
/*--------------------------------*/
/* obsolete */
QString datToBoard( const KURL& datURL );
"a.coloredLink:link\n"
"{\n"
" color: magenta;"
- "}\n"
-
+ "}\n"
+
"div.res_title,\n"
"div.pop_res_title {\n"
" white-space: nowrap;\n"
" padding-bottom: .2em;\n"
"}\n"
-
+
"span.name_noaddr {\n"
" color: green;\n"
"}\n"
" margin-left: 3.5em;\n"
" padding-bottom: 1.8em;\n"
"}\n"
-
+
"div.kokoyon {\n"
" background-color: #CCCCCC;\n"
" text-align: center;\n"
static bool aboneChain() { return getInstance() ->m_aboneChain; }
static void setAboneChain( bool value ) { getInstance() ->m_aboneChain = value; }
static bool defaultAboneChain() { return false; }
-
+
static QStringList& aboneWordList() { return getInstance() ->m_aboneWordList; }
static void setAboneWordList( QStringList list ) { getInstance() ->m_aboneWordList = list; }
static void addAboneWord( QString word ) { getInstance() ->m_aboneWordList.append( word ); }
class ParseMisc
{
public:
- static KURL parseURL( const KURL& url , QString& refstr ){
- return Kita::getDatURL( url , refstr ); }
-
- static KURL parseURLonly( const KURL& url ){ return Kita::getDatURL( url ); }
-
- static QString qcpToUnicode( const QString& str ){ return Kita::qcpToUnicode( str ); }
-
- static QString utf8ToUnicode( const QString& str ){ return Kita::utf8ToUnicode( str ); }
-
- static int stringToPositiveNum( const QChar *cdat, const unsigned int length ){
- return Kita::stringToPositiveNum( cdat, length ); }
+ static KURL parseURL( const KURL& url , QString& refstr )
+ {
+ return Kita::getDatURL( url , refstr );
+ }
+
+ static KURL parseURLonly( const KURL& url ) { return Kita::getDatURL( url ); }
+
+ static QString qcpToUnicode( const QString& str ) { return Kita::qcpToUnicode( str ); }
+
+ static QString utf8ToUnicode( const QString& str ) { return Kita::utf8ToUnicode( str ); }
+
+ static int stringToPositiveNum( const QChar *cdat, const unsigned int length )
+ {
+ return Kita::stringToPositiveNum( cdat, length );
+ }
};
}
// FIXME: implement
int QCp932Codec::heuristicContentMatch( const char*, int ) const
{
-// kdWarning( 7743 ) << "XXX heuristicContentMatch" << endl;
+ // kdWarning( 7743 ) << "XXX heuristicContentMatch" << endl;
return 0;
}
// FIXME: implement
int QCp932Codec::heuristicNameMatch( const char * hint ) const
{
-// kdWarning( 7743 ) << "XXX heuristicNameMatch hint = " << hint << endl;
+ // kdWarning( 7743 ) << "XXX heuristicNameMatch hint = " << hint << endl;
return 0;
}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining *
- * a copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, sublicense, and/or sell copies of the Software, and to *
- * permit persons to whom the Software is furnished to do so, subject to *
- * the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be *
- * included in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
- * OTHER DEALINGS IN THE SOFTWARE. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* Permission is hereby granted, free of charge, to any person obtaining *
+* a copy of this software and associated documentation files (the *
+* "Software"), to deal in the Software without restriction, including *
+* without limitation the rights to use, copy, modify, merge, publish, *
+* distribute, sublicense, and/or sell copies of the Software, and to *
+* permit persons to whom the Software is furnished to do so, subject to *
+* the following conditions: *
+* *
+* The above copyright notice and this permission notice shall be *
+* included in all copies or substantial portions of the Software. *
+* *
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
+* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
+* OTHER DEALINGS IN THE SOFTWARE. *
+***************************************************************************/
#ifndef _QCP932CODEC_H_
#define _QCP932CODEC_H_
class QCp932Codec : public QTextCodec
{
private:
- QJpUnicodeConv* conv;
+ QJpUnicodeConv* conv;
public:
- QCp932Codec();
- ~QCp932Codec();
- virtual const char * name() const;
- virtual const char * mimeName() const;
- virtual int mibEnum() const;
- virtual QTextDecoder* makeDecoder() const;
-// virtual QTextEncoder* makeEncoder() const;
-// virtual QString toUnicode(const char* chars, int len) const;
-// using QTextCodec::fromUnicode;
- virtual QCString fromUnicode(const QString& uc, int& lenInOut) const;
-// virtual bool canEncode(QChar ch) const;
-// virtual bool canEncode(const QString& s) const;
- virtual int heuristicContentMatch(const char* chars, int len) const;
- virtual int heuristicNameMatch(const char * hint) const;
+ QCp932Codec();
+ ~QCp932Codec();
+ virtual const char * name() const;
+ virtual const char * mimeName() const;
+ virtual int mibEnum() const;
+ virtual QTextDecoder* makeDecoder() const;
+ // virtual QTextEncoder* makeEncoder() const;
+ // virtual QString toUnicode(const char* chars, int len) const;
+ // using QTextCodec::fromUnicode;
+ virtual QCString fromUnicode( const QString& uc, int& lenInOut ) const;
+ // virtual bool canEncode(QChar ch) const;
+ // virtual bool canEncode(const QString& s) const;
+ virtual int heuristicContentMatch( const char* chars, int len ) const;
+ virtual int heuristicNameMatch( const char * hint ) const;
};
class QCp932Decoder : public QTextDecoder
{
private:
- QJpUnicodeConv* conv;
+ QJpUnicodeConv* conv;
public:
- QCp932Decoder(QJpUnicodeConv* _conv);
- ~QCp932Decoder();
- virtual QString toUnicode(const char* chars, int len);
+ QCp932Decoder( QJpUnicodeConv* _conv );
+ ~QCp932Decoder();
+ virtual QString toUnicode( const char* chars, int len );
};
#endif
/***************************************************************************
- * Copyright (C) 2004 by Kita Developers *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2004 by Kita Developers *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "signalcollection.h"
using namespace Kita;
/* to : KitaWriteDock */
void showWriteView( const KURL& , const QString& );
- void createNewThread( const KURL& , const QString&, const QString& );
+ void createNewThread( const KURL& , const QString&, const QString& );
void switchToWritedock();
};
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "boardtest.h"
using namespace Kita;
}
void BoardTest::tearDown()
-{
-}
+{}
void BoardTest::testID()
{
void BoardTest::testReplace()
{
Kita::Board::replace( QString( "http://pc.2ch.net/linux/" ), QString( "http://pc3.2ch.net/linux/" ) );
-
+
CPPUNIT_ASSERT_EQUAL( QString( "linux" ), Kita::Board::getID( "http://pc3.2ch.net/linux/" ) );
CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), Kita::Board::getName( "http://pc3.2ch.net/linux/" ) );
}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef BOARDTEST_H
#define BOARDTEST_H
/**
@author Hideki Ikemoto
*/
-class BoardTest : public CppUnit::TestFixture {
+class BoardTest : public CppUnit::TestFixture
+{
CPPUNIT_TEST_SUITE( BoardTest );
CPPUNIT_TEST( testID );
CPPUNIT_TEST( testStaticName );
using namespace Kita;
void CacheTest::setUp()
-{
-}
+{}
void CacheTest::tearDown()
-{
-}
+{}
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 = 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/" ), thread2->boardURL() );
CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), thread2->boardName() );
CPPUNIT_ASSERT_EQUAL( QString( "linux" ), thread2->boardID() );
-
+
Kita::Thread* thread3 = Kita::Thread::getByURL( threadList[ 2 ] );
CPPUNIT_ASSERT_EQUAL( QString( "2ch browser thread" ), thread3->name() );
CPPUNIT_ASSERT_EQUAL( 20, thread3->resNum() );
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "k2ch_articlefiletest.h"
#include "../k2ch_articlefile.h"
#include <cppunit/TestCaller.h>
void K2chArticleFileTest::setUp()
{
- m_empty = new K2chArticleFile();
- m_empty->parse( "()" );
+ m_empty = new K2chArticleFile();
+ m_empty->parse( "()" );
- m_one = new K2chArticleFile();
- m_one->parse( "((\"1000000000\" :seen 100 :access-time (16122 26923 0)))" );
+ m_one = new K2chArticleFile();
+ m_one->parse( "((\"1000000000\" :seen 100 :access-time (16122 26923 0)))" );
- m_many = new K2chArticleFile();
- m_many->parse( "((\"1000000000\" :seen 100 :access-time (16122 26923 0))"
- "(\"999999999\" :seen -1 :access-time (16122 26778 0))"
- "(\"1234567890\" :seen 999 :access-time (16205 63250 0)))" );
+ m_many = new K2chArticleFile();
+ m_many->parse( "((\"1000000000\" :seen 100 :access-time (16122 26923 0))"
+ "(\"999999999\" :seen -1 :access-time (16122 26778 0))"
+ "(\"1234567890\" :seen 999 :access-time (16205 63250 0)))" );
}
void K2chArticleFileTest::tearDown()
{
- delete m_empty;
- delete m_one;
- delete m_many;
+ delete m_empty;
+ delete m_one;
+ delete m_many;
}
void K2chArticleFileTest::testCount()
{
- CPPUNIT_ASSERT_EQUAL( 0, m_empty->count() );
- CPPUNIT_ASSERT_EQUAL( 1, m_one->count() );
- CPPUNIT_ASSERT_EQUAL( 3, m_many->count() );
+ CPPUNIT_ASSERT_EQUAL( 0, m_empty->count() );
+ CPPUNIT_ASSERT_EQUAL( 1, m_one->count() );
+ CPPUNIT_ASSERT_EQUAL( 3, m_many->count() );
}
void K2chArticleFileTest::testName()
{
- CPPUNIT_ASSERT_EQUAL( QString( "1000000000" ), m_one->item( 0 ).name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "1000000000" ), m_one->item( 0 ).name() );
- CPPUNIT_ASSERT_EQUAL( QString( "1000000000" ), m_many->item( 0 ).name() );
- CPPUNIT_ASSERT_EQUAL( QString( "999999999" ), m_many->item( 1 ).name() );
- CPPUNIT_ASSERT_EQUAL( QString( "1234567890" ), m_many->item( 2 ).name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "1000000000" ), m_many->item( 0 ).name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "999999999" ), m_many->item( 1 ).name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "1234567890" ), m_many->item( 2 ).name() );
}
void K2chArticleFileTest::testSeen()
{
- CPPUNIT_ASSERT_EQUAL( 100, m_one->item( 0 ).seen() );
+ CPPUNIT_ASSERT_EQUAL( 100, m_one->item( 0 ).seen() );
- CPPUNIT_ASSERT_EQUAL( 100, m_many->item( 0 ).seen() );
- CPPUNIT_ASSERT_EQUAL( -1, m_many->item( 1 ).seen() );
- CPPUNIT_ASSERT_EQUAL( 999, m_many->item( 2 ).seen() );
+ CPPUNIT_ASSERT_EQUAL( 100, m_many->item( 0 ).seen() );
+ CPPUNIT_ASSERT_EQUAL( -1, m_many->item( 1 ).seen() );
+ CPPUNIT_ASSERT_EQUAL( 999, m_many->item( 2 ).seen() );
}
void K2chArticleFileTest::testAccessTime()
{
- CPPUNIT_ASSERT_EQUAL( (time_t)1056598315, m_one->item( 0 ).accessTime() );
+ CPPUNIT_ASSERT_EQUAL( ( time_t ) 1056598315, m_one->item( 0 ).accessTime() );
- CPPUNIT_ASSERT_EQUAL( (time_t)1056598315, m_many->item( 0 ).accessTime() );
- CPPUNIT_ASSERT_EQUAL( (time_t)1056598170, m_many->item( 1 ).accessTime() );
- CPPUNIT_ASSERT_EQUAL( (time_t)1062074130, m_many->item( 2 ).accessTime() );
+ CPPUNIT_ASSERT_EQUAL( ( time_t ) 1056598315, m_many->item( 0 ).accessTime() );
+ CPPUNIT_ASSERT_EQUAL( ( time_t ) 1056598170, m_many->item( 1 ).accessTime() );
+ CPPUNIT_ASSERT_EQUAL( ( time_t ) 1062074130, m_many->item( 2 ).accessTime() );
}
void K2chArticleFileTest::testToString()
{
- CPPUNIT_ASSERT_EQUAL( QString( "()" ), m_empty->toString() );
+ CPPUNIT_ASSERT_EQUAL( QString( "()" ), m_empty->toString() );
- CPPUNIT_ASSERT_EQUAL( QString( "((\"1000000000\" :seen 100 :access-time (16122 26923 0)))" ),
- m_one->toString() );
+ CPPUNIT_ASSERT_EQUAL( QString( "((\"1000000000\" :seen 100 :access-time (16122 26923 0)))" ),
+ m_one->toString() );
- CPPUNIT_ASSERT_EQUAL( QString( "((\"1000000000\" :seen 100 :access-time (16122 26923 0))"
- "(\"999999999\" :seen -1 :access-time (16122 26778 0))"
- "(\"1234567890\" :seen 999 :access-time (16205 63250 0)))" ),
- m_many->toString() );
+ CPPUNIT_ASSERT_EQUAL( QString( "((\"1000000000\" :seen 100 :access-time (16122 26923 0))"
+ "(\"999999999\" :seen -1 :access-time (16122 26778 0))"
+ "(\"1234567890\" :seen 999 :access-time (16205 63250 0)))" ),
+ m_many->toString() );
}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef K2CH_ARTICLEFILETEST_H
#define K2CH_ARTICLEFILETEST_H
*/
class K2chArticleFileTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE( K2chArticleFileTest );
- CPPUNIT_TEST( testCount );
- CPPUNIT_TEST( testName );
- CPPUNIT_TEST( testSeen );
- CPPUNIT_TEST( testAccessTime );
- CPPUNIT_TEST( testToString );
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE( K2chArticleFileTest );
+ CPPUNIT_TEST( testCount );
+ CPPUNIT_TEST( testName );
+ CPPUNIT_TEST( testSeen );
+ CPPUNIT_TEST( testAccessTime );
+ CPPUNIT_TEST( testToString );
+ CPPUNIT_TEST_SUITE_END();
- K2chArticleFile *m_empty, *m_one, *m_many;
+ K2chArticleFile *m_empty, *m_one, *m_many;
public:
- void setUp();
- void tearDown();
+ void setUp();
+ void tearDown();
- void testCount();
- void testName();
- void testSeen();
- void testAccessTime();
- void testToString();
+ void testCount();
+ void testName();
+ void testSeen();
+ void testAccessTime();
+ void testToString();
};
#endif
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TextTestResult.h>
int main( int argc, char* argv[] )
{
- CppUnit::TextUi::TestRunner runner;
+ CppUnit::TextUi::TestRunner runner;
- runner.addTest( K2chArticleFileTest::suite() );
- runner.addTest( URLConvertTest::suite() );
- runner.addTest( ThreadTest::suite() );
- runner.addTest( BoardTest::suite() );
- runner.addTest( MiscTest::suite() );
- runner.addTest( FavoriteThreadsTest::suite() );
- runner.addTest( FavoriteBoardsTest::suite() );
- runner.addTest( CacheTest::suite() );
- runner.run( "" );
- return 0;
+ runner.addTest( K2chArticleFileTest::suite() );
+ runner.addTest( URLConvertTest::suite() );
+ runner.addTest( ThreadTest::suite() );
+ runner.addTest( BoardTest::suite() );
+ runner.addTest( MiscTest::suite() );
+ runner.addTest( FavoriteThreadsTest::suite() );
+ runner.addTest( FavoriteBoardsTest::suite() );
+ runner.addTest( CacheTest::suite() );
+ runner.run( "" );
+ return 0;
}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "threadtest.h"
#include "../board.h"
{
Kita::Board::setName( "http://pc.2ch.net/linux/", "Linux" );
Kita::Thread::setName( "http://pc.2ch.net/linux/dat/1069738960.dat",
- "Kita - 2ch client for KDE" );
+ "Kita - 2ch client for KDE" );
m_normal = Kita::Thread::getByURL( "http://pc.2ch.net/linux/dat/1069738960.dat" );
Kita::Board::setName( "http://pc.2ch.net/unix/", "Unix" );
}
void ThreadTest::tearDown()
-{
-}
+{}
void ThreadTest::testDatURL()
{
- CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/dat/1069738960.dat"),
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/dat/1069738960.dat" ),
m_normal->datURL() );
}
void ThreadTest::testURL()
{
- CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/test/read.cgi/linux/1069738960/"),
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/test/read.cgi/linux/1069738960/" ),
m_normal->url() );
}
Kita::Thread::replace( QString( "http://pc.2ch.net/unix/" ),
QString( "http://pc3.2ch.net/unix/" ) );
Kita::Thread* unix = Kita::Thread::getByURL( "http://pc3.2ch.net/unix/dat/1069738960.dat" );
-
- CPPUNIT_ASSERT_EQUAL( QString( "http://pc3.2ch.net/unix/dat/1069738960.dat"),
+
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc3.2ch.net/unix/dat/1069738960.dat" ),
unix->datURL() );
- CPPUNIT_ASSERT_EQUAL( QString( "http://pc3.2ch.net/test/read.cgi/unix/1069738960/"),
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc3.2ch.net/test/read.cgi/unix/1069738960/" ),
unix->url() );
CPPUNIT_ASSERT_EQUAL( QString( "1069738960" ), unix->datID() );
CPPUNIT_ASSERT_EQUAL( 0, unix->resNum() );
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@wakaba.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@wakaba.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef THREADTEST_H
#define THREADTEST_H
/**
@author Hideki Ikemoto
*/
-class ThreadTest : public CppUnit::TestFixture {
+class ThreadTest : public CppUnit::TestFixture
+{
CPPUNIT_TEST_SUITE( ThreadTest );
CPPUNIT_TEST( testDatURL );
CPPUNIT_TEST( testURL );
// FIXME: invalid dat url.
m_machibbsDatURL = "http://kanto.machi.to/kana/dat/1234567890.cgi";
-
+
m_machibbsThreadURL = "http://kanto.machi.to/bbs/read.pl?BBS=kana&KEY=1234567890";
-
+
// relative path.
m_cachePath = QString( "pc.2ch.net/linux/1022744633.dat" );
}
QString m_boardURL2_k2ch;
QString m_cachePath;
QString m_cachePath_k2ch;
-
+
QString m_machibbsDatURL;
QString m_machibbsThreadURL;
QDict<Thread>* Thread::m_threadDict = 0;
Thread::Thread( const KURL& datURL )
- : m_datURL( datURL ), m_threadName( 0 ) , m_resNum( 0 ), m_readNum( 0 ), m_viewPos( 0 ), m_isOpened( 0 )
+ : m_datURL( datURL ), m_threadName( 0 ) , m_resNum( 0 ), m_readNum( 0 ), m_viewPos( 0 ), m_isOpened( 0 )
{}
Thread::~Thread()
void Thread::setThreadName( QString threadName )
{
/* remove space */
- QRegExp qrx(" +$");
+ QRegExp qrx( " +$" );
threadName.replace( qrx, "" );
/* unescape */
threadName.replace( "<", "<" ).replace( ">", ">" ).replace( "&", "&" );
-
+
m_threadName = threadName;
}
{
QValueList< int >::iterator it;
for ( it = m_markList.begin(); it != m_markList.end(); ++it ) {
- if( ( *it ) == num ) return TRUE;
+ if ( ( *it ) == num ) return TRUE;
}
return FALSE;
bool Thread::setMark( int num, bool newStatus )
{
bool status = isMarked( num );
- if( status == newStatus ) return FALSE;
+ if ( status == newStatus ) return FALSE;
- if( newStatus ) m_markList += num;
+ if ( newStatus ) m_markList += num;
else m_markList.remove( num );
return TRUE;
void Thread::replace( const QString& fromURL, const QString& toURL )
{
- if( m_threadDict == NULL ) return;
+ if ( m_threadDict == NULL ) return ;
QDictIterator<Kita::Thread> it( *m_threadDict );
- for( ; it.current(); ++it ) {
+ for ( ; it.current(); ++it ) {
QString url = it.currentKey();
Kita::Thread* thread = it.current();
if ( url.find( fromURL ) == 0 ) {
KURL m_datURL;
QString m_threadName;
- int m_resNum;
- int m_readNum;
- int m_viewPos;
- bool m_isOpened;
+ int m_resNum;
+ int m_readNum;
+ int m_viewPos;
+ bool m_isOpened;
QValueList< int > m_markList;
public:
~Thread();
const KURL& datURL() const;
-
+
const QString& threadName() const;
- void setThreadName( QString threadName );
+ void setThreadName( QString threadName );
+
+ const int resNum() const;
+ void setResNum( int num );
- const int resNum() const;
- void setResNum( int num );
+ const int readNum() const;
+ void setReadNum( int num );
- const int readNum() const;
- void setReadNum( int num );
-
- const int viewPos() const;
- void setViewPos( int viewPos );
+ const int viewPos() const;
+ void setViewPos( int viewPos );
- bool isOpened() const;
- void setIsOpened( bool isOpend );
+ bool isOpened() const;
+ void setIsOpened( bool isOpend );
const QValueList< int >& markList() const;
void setMarkList( const QValueList< int >& markList );
bool isMarked( int num );
bool setMark( int num, bool newStatus );
-
- /*----------------------*/
-
+
+ /*----------------------*/
+
static Thread* getByURL( const KURL& datURL );
static Thread* getByURLNew( const KURL& datURL );
static void replace( const QString& fromURL, const QString& toURL );
/* load read number */
int readNum = getReadNumPrivate( url, config, checkCached );
- if( readNum == 0 ) return; /* cache does not exist. */
+ if ( readNum == 0 ) return ; /* cache does not exist. */
thread->setReadNum( readNum );
-
+
/* load thread name */
QString subject = getSubjectPrivate( config );
- if( subject == QString::null && thread->threadName() != QString::null ){
- subject = thread->threadName();
- config.writeEntry( "Subject", subject );
+ if ( subject == QString::null && thread->threadName() != QString::null ) {
+ subject = thread->threadName();
+ config.writeEntry( "Subject", subject );
}
- if( subject == QString::null ) thread->setThreadName( "?" );
+ if ( subject == QString::null ) thread->setThreadName( "?" );
else thread->setThreadName( subject );
/* load res number */
/* load view pos */
thread->setViewPos( getViewPosPrivate( config ) );
- if( thread->viewPos() > thread->readNum() ) thread->setReadNum( thread->viewPos() );
+ if ( thread->viewPos() > thread->readNum() ) thread->setReadNum( thread->viewPos() );
/* load mark */
thread->setMarkList( getMarkListPrivate( config ) );
void ThreadIndex::saveIndex( const Kita::Thread* thread, const KURL& url )
{
/* If readNum == 0, delete idx file */
- if( thread->readNum() == 0 ){
-
- QString indexPath = Kita::DatManager::getCacheIndexPath( url );
- QFile::remove( indexPath );
- qDebug("delete %s",indexPath.ascii());
+ if ( thread->readNum() == 0 ) {
+
+ QString indexPath = Kita::DatManager::getCacheIndexPath( url );
+ QFile::remove( indexPath );
+ qDebug( "delete %s", indexPath.ascii() );
}
QString indexPath = Kita::Cache::getIndexPath( url );
KConfig config( indexPath );
-
+
/* save thread name */
setSubjectPrivate( thread->threadName(), config );
-
+
/* save res number */
setResNumPrivate( thread->resNum(), config );
/* save mark */
setMarkListPrivate( thread->markList(), config );
-
+
/* save "cache" */
KURL datURL = Kita::getDatURL( url );
int num = ( thread->viewPos() ? thread->viewPos() : thread->readNum() );
int ThreadIndex::getResNumPrivate( const KURL& url, KConfig& config )
{
int resNum = config.readNumEntry( "ResNum" );
-
+
/* use obsoleted "cache" file */
- if( !resNum ){
- KURL datURL = Kita::getDatURL( url );
- resNum = KitaThreadInfo::readNum( datURL.prettyURL() );
- if( resNum ) config.writeEntry( "ResNum", resNum );
+ if ( !resNum ) {
+ KURL datURL = Kita::getDatURL( url );
+ resNum = KitaThreadInfo::readNum( datURL.prettyURL() );
+ if ( resNum ) config.writeEntry( "ResNum", resNum );
}
return resNum;
int ThreadIndex::getReadNumPrivate( const KURL& url, KConfig& config, bool checkCached )
{
/* If cache does not exist, return 0 */
- if( checkCached ){
-
- QString path = Kita::DatManager::getCachePath( url );
- if( ! QFile::exists( path ) ){
- qDebug("%s does not exits",path.ascii());
- return 0;
- }
+ if ( checkCached ) {
+
+ QString path = Kita::DatManager::getCachePath( url );
+ if ( ! QFile::exists( path ) ) {
+ qDebug( "%s does not exits", path.ascii() );
+ return 0;
+ }
}
-
+
int readNum = config.readNumEntry( "ReadNum" );
- if( !readNum ){
+ if ( !readNum ) {
+
+ /* use ViewPos instead of ReadNum. */
+ readNum = config.readNumEntry( "ViewPos" );
- /* use ViewPos instead of ReadNum. */
- readNum = config.readNumEntry( "ViewPos" );
-
- /* use obsoleted "cache" file */
- if( !readNum ){
- KURL datURL = Kita::getDatURL( url );
- readNum = KitaThreadInfo::readNum( datURL.prettyURL() );
- }
+ /* use obsoleted "cache" file */
+ if ( !readNum ) {
+ KURL datURL = Kita::getDatURL( url );
+ readNum = KitaThreadInfo::readNum( datURL.prettyURL() );
+ }
- if( readNum ) config.writeEntry( "ReadNum", readNum );
+ if ( readNum ) config.writeEntry( "ReadNum", readNum );
}
return readNum;
namespace Kita
{
class Thread;
-
+
/**
@author Hideki Ikemoto
*/
static void setViewPos( const KURL& url, int viewPos );
static void setMarkList( const KURL& url, const QValueList< int >& markList );
-
- /*---------------------------------*/
-
- static void loadIndex( Kita::Thread* thread, const KURL& url, bool checkCached = TRUE );
- static void saveIndex( const Kita::Thread* thread, const KURL& url );
-
- private:
-
+
+ /*---------------------------------*/
+
+ static void loadIndex( Kita::Thread* thread, const KURL& url, bool checkCached = TRUE );
+ static void saveIndex( const Kita::Thread* thread, const KURL& url );
+
+ private:
+
static QString getSubjectPrivate( KConfig& config );
static void setSubjectPrivate( const QString& str, KConfig& config );
static int getViewPosPrivate( KConfig& config );
static void setViewPosPrivate( int viewPos, KConfig& config );
-
+
static QValueList< int > getMarkListPrivate( KConfig& config );
static void setMarkListPrivate( const QValueList< int >& markList, KConfig& config );
};
{
QMap<QString, int>::Iterator it;
KitaThreadInfo* instance = KitaThreadInfo::getInstance();
- if( instance == NULL ) return;
+ if ( instance == NULL ) return ;
for ( it = instance->m_readDict.begin(); it != instance->m_readDict.end(); ++it ) {
QString url = it.key();
namespace Kita
{
ListViewItem::ListViewItem( QListView *parent, QListViewItem *after,
- QString label1, QString label2, QString label3, QString label4,
- QString label5, QString label6, QString label7, QString label8)
- : KListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
+ QString label1, QString label2, QString label3, QString label4,
+ QString label5, QString label6, QString label7, QString label8 )
+ : KListViewItem( parent, after, label1, label2, label3, label4, label5, label6, label7, label8 )
{
- init();
+ init();
}
ListViewItem::ListViewItem( QListViewItem *parent, QListViewItem *after,
- QString label1, QString label2, QString label3, QString label4,
- QString label5, QString label6, QString label7, QString label8)
- : KListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
+ QString label1, QString label2, QString label3, QString label4,
+ QString label5, QString label6, QString label7, QString label8 )
+ : KListViewItem( parent, after, label1, label2, label3, label4, label5, label6, label7, label8 )
{
- init();
+ init();
}
- ListViewItem::ListViewItem( QListView* parent, QString label1, QString label2 )
- : KListViewItem( parent, label1, label2 )
+ ListViewItem::ListViewItem( QListView* parent, QString label1, QString label2 )
+ : KListViewItem( parent, label1, label2 )
{
- init();
+ init();
}
- ListViewItem::ListViewItem( QListViewItem* parent, QString label1, QString label2 )
- : KListViewItem( parent, label1, label2 )
+ ListViewItem::ListViewItem( QListViewItem* parent, QString label1, QString label2 )
+ : KListViewItem( parent, label1, label2 )
{
- init();
+ init();
}
-
+
ListViewItem::~ListViewItem()
{}
/* private */
void ListViewItem::init()
{
- QColorGroup colors = listView()->viewport()->colorGroup();
- m_textColor = colors.text();
- m_baseColor = colors.base();
+ QColorGroup colors = listView() ->viewport() ->colorGroup();
+ m_textColor = colors.text();
+ m_baseColor = colors.base();
}
/* public */
void ListViewItem::setColor( QColor textColor, QColor baseColor )
{
- m_textColor = textColor;
- m_baseColor = baseColor;
+ m_textColor = textColor;
+ m_baseColor = baseColor;
}
/* public */ /* virtual */
void ListViewItem::paintCell( QPainter *p, const QColorGroup &cg,
- int column, int width, int align )
+ int column, int width, int align )
{
QColorGroup color = cg;
color.setColor( QColorGroup::Text, m_textColor );
SubjectListViewItem::SubjectListViewItem( QListView* parent )
- : Kita::ListViewItem( parent )
+ : Kita::ListViewItem( parent )
{}
SubjectListViewItem::~SubjectListViewItem()
{}
-
- /* public */ /* virtual */
+
+ /* public */ /* virtual */
int SubjectListViewItem::compare( QListViewItem* i, int col, bool ascending ) const
{
- switch ( col ) {
- case Col_ResNum:
- case Col_ReadNum:
- case Col_Unread:
- return i->key( col, ascending ).toInt() - key( col, ascending ).toInt();
- case Col_ID:
- return key( Col_IDOrder, ascending ).toInt() - i->key( Col_IDOrder, ascending ).toInt();
- case Col_Mark:
- return QString::localeAwareCompare( i->key( Col_MarkOrder, ascending ), key( Col_MarkOrder, ascending ) );
- case Col_Since:
- return QString::localeAwareCompare( i->key( col, ascending ), key( col, ascending ) );
- case Col_Speed:
- return static_cast<int>( i->key( col, ascending ).toDouble() * 1000 - key( col, ascending ).toDouble() * 1000 );
- default:
- return QString::localeAwareCompare( key( col, ascending ), i->key( col, ascending ) );
- }
+ switch ( col ) {
+ case Col_ResNum:
+ case Col_ReadNum:
+ case Col_Unread:
+ return i->key( col, ascending ).toInt() - key( col, ascending ).toInt();
+ case Col_ID:
+ return key( Col_IDOrder, ascending ).toInt() - i->key( Col_IDOrder, ascending ).toInt();
+ case Col_Mark:
+ return QString::localeAwareCompare( i->key( Col_MarkOrder, ascending ), key( Col_MarkOrder, ascending ) );
+ case Col_Since:
+ return QString::localeAwareCompare( i->key( col, ascending ), key( col, ascending ) );
+ case Col_Speed:
+ return static_cast<int>( i->key( col, ascending ).toDouble() * 1000 - key( col, ascending ).toDouble() * 1000 );
+ default:
+ return QString::localeAwareCompare( key( col, ascending ), i->key( col, ascending ) );
+ }
}
-}
+}
{
class ListViewItem : public KListViewItem
{
- QColor m_textColor; /* text color */
- QColor m_baseColor; /* background color */
-
- public:
-
- ListViewItem( QListView *parent, QListViewItem *after,
- QString, QString = QString::null,
- QString = QString::null, QString = QString::null,
- QString = QString::null, QString = QString::null,
- QString = QString::null, QString = QString::null);
-
- ListViewItem( QListViewItem *parent, QListViewItem *after,
- QString, QString = QString::null,
- QString = QString::null, QString = QString::null,
- QString = QString::null, QString = QString::null,
- QString = QString::null, QString = QString::null);
-
- ListViewItem( QListView* parent, QString = QString::null, QString = QString::null );
-
- ListViewItem( QListViewItem* parent, QString = QString::null, QString = QString::null );
-
- ~ListViewItem();
-
- void setColor( QColor textColor, QColor baseColor );
- virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
-
- private:
- void init();
+ QColor m_textColor; /* text color */
+ QColor m_baseColor; /* background color */
+
+ public:
+
+ ListViewItem( QListView *parent, QListViewItem *after,
+ QString, QString = QString::null,
+ QString = QString::null, QString = QString::null,
+ QString = QString::null, QString = QString::null,
+ QString = QString::null, QString = QString::null );
+
+ ListViewItem( QListViewItem *parent, QListViewItem *after,
+ QString, QString = QString::null,
+ QString = QString::null, QString = QString::null,
+ QString = QString::null, QString = QString::null,
+ QString = QString::null, QString = QString::null );
+
+ ListViewItem( QListView* parent, QString = QString::null, QString = QString::null );
+
+ ListViewItem( QListViewItem* parent, QString = QString::null, QString = QString::null );
+
+ ~ListViewItem();
+
+ void setColor( QColor textColor, QColor baseColor );
+ virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
+
+ private:
+ void init();
};
/*----------------------------------------*/
-
+
/* for KitaSubjectView */
class SubjectListViewItem : public Kita::ListViewItem
{
- SubjectListViewItem( QListView* parent );
- ~SubjectListViewItem();
-
+ SubjectListViewItem( QListView* parent );
+ ~SubjectListViewItem();
+
public:
virtual int compare( QListViewItem* i, int col, bool ascending ) const;
};
-
-}
+
+}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "kita.h"
#include "libkita/kitaconfig.h"
static const char *description =
- I18N_NOOP("Kita - 2ch client for KDE");
+ I18N_NOOP( "Kita - 2ch client for KDE" );
static const char *version = VERSION;
static KCmdLineOptions options[] =
-{
- { "+[URL]", I18N_NOOP( "Document to open." ), 0 },
- { "boardlist <boardlist>", I18N_NOOP( "board list's URL." ), "http://www.ff.iij4u.or.jp/~ch2/bbsmenu.html" },
- { 0, 0, 0 }
-};
+ {
+ { "+[URL]", I18N_NOOP( "Document to open." ), 0 },
+ { "boardlist <boardlist>", I18N_NOOP( "board list's URL." ), "http://www.ff.iij4u.or.jp/~ch2/bbsmenu.html" },
+ { 0, 0, 0 }
+ };
-int main(int argc, char **argv)
+int main( int argc, char **argv )
{
- KAboutData about("kita", I18N_NOOP("Kita"), version, description,
- KAboutData::License_GPL, "(C) 2003-2004 Kita Developers", 0, 0, "ikemo@users.sourceforge.jp");
- about.addAuthor( "Hideki Ikemoto", I18N_NOOP("maintainer, initial code"), "ikemo@users.sourceforge.jp" );
- about.addAuthor( "konqueror plugin no hito", I18N_NOOP("konqueror plugin, KDE part"), "ogirin@users.sourceforge.jp");
- about.addAuthor( "421", I18N_NOOP("kitanavi, threadview's improvement") );
- about.addAuthor( "Toshihiko Okada", I18N_NOOP("improvements"), "tossi@users.sourceforge.jp");
- about.addAuthor( "75", I18N_NOOP("stylesheet support") );
- KCmdLineArgs::init(argc, argv, &about);
- KCmdLineArgs::addCmdLineOptions(options);
+ KAboutData about( "kita", I18N_NOOP( "Kita" ), version, description,
+ KAboutData::License_GPL, "(C) 2003-2004 Kita Developers", 0, 0, "ikemo@users.sourceforge.jp" );
+ about.addAuthor( "Hideki Ikemoto", I18N_NOOP( "maintainer, initial code" ), "ikemo@users.sourceforge.jp" );
+ about.addAuthor( "konqueror plugin no hito", I18N_NOOP( "konqueror plugin, KDE part" ), "ogirin@users.sourceforge.jp" );
+ about.addAuthor( "421", I18N_NOOP( "kitanavi, threadview's improvement" ) );
+ about.addAuthor( "Toshihiko Okada", I18N_NOOP( "improvements" ), "tossi@users.sourceforge.jp" );
+ about.addAuthor( "75", I18N_NOOP( "stylesheet support" ) );
+ KCmdLineArgs::init( argc, argv, &about );
+ KCmdLineArgs::addCmdLineOptions( options );
KUniqueApplication app;
// register ourselves as a dcop client
- app.dcopClient()->registerAs(app.name(), false);
+ app.dcopClient() ->registerAs( app.name(), false );
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
KitaConfig::setBoardListURL( QString( args->getOption( "boardlist" ) ) );
// see if we are starting with session management
- if (app.isRestored())
- RESTORE(KitaMainWindow)
- else
- {
- // no session.. just start up normally
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- if (args->count() == 0)
- {
- KitaMainWindow *widget = new KitaMainWindow;
- widget->show();
- }
- else
- {
- int i = 0;
- for (; i < args->count(); i++)
- {
- KitaMainWindow *widget = new KitaMainWindow;
+ if ( app.isRestored() )
+ RESTORE( KitaMainWindow )
+ else {
+ // no session.. just start up normally
+ KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
+ if ( args->count() == 0 ) {
+ KitaMainWindow * widget = new KitaMainWindow;
widget->show();
- widget->load(args->url(i));
+ } else {
+ int i = 0;
+ for ( ; i < args->count(); i++ ) {
+ KitaMainWindow *widget = new KitaMainWindow;
+ widget->show();
+ widget->load( args->url( i ) );
+ }
}
+ args->clear();
}
- args->clear();
- }
return app.exec();
}
if ( m_resStatus[ num ] != KITA_HTML_NOTPARSED ) return TRUE; /* already parsed */
}
/* resize buffer size */
- else{
+ else {
- if ( m_bufLng == 0 ) m_bufLng = mrg;
- while ( num >= m_bufLng ) m_bufLng += delta;
+ if ( m_bufLng == 0 ) m_bufLng = mrg;
+ while ( num >= m_bufLng ) m_bufLng += delta;
- m_titleElm.resize( m_bufLng );
- m_bodyElm.resize( m_bufLng );
- m_resshown.resize( m_bufLng, FALSE );
- m_resStatus.resize( m_bufLng, KITA_HTML_NOTPARSED );
+ m_titleElm.resize( m_bufLng );
+ m_bodyElm.resize( m_bufLng );
+ m_resshown.resize( m_bufLng, FALSE );
+ m_resStatus.resize( m_bufLng, KITA_HTML_NOTPARSED );
m_coloredNum.resize( m_bufLng, FALSE );
}
/* cleate elements */
QString titleHTML, bodyHTML;
m_resStatus[ num ] = m_datInfo->getHTML( num, TRUE, titleHTML, bodyHTML );
- if( m_resStatus[ num ] == KITA_HTML_NOTPARSED ) return FALSE;
-
+ if ( m_resStatus[ num ] == KITA_HTML_NOTPARSED ) return FALSE;
+
m_titleElm[ num ] = m_hdoc.createElement( "DIV" );
m_titleElm[ num ].setAttribute( "class", "res_title" );
m_titleElm[ num ].setAttribute( "id", QString().setNum( num ) );
m_titleElm[ num ].setInnerHTML( titleHTML );
-
+
m_bodyElm[ num ] = m_hdoc.createElement( "DIV" );
m_bodyElm[ num ].setAttribute( "class", "res_body" );
m_bodyElm[ num ].setAttribute( "id", QString().setNum( num ) );
#if KDE_IS_VERSION( 3, 2, 0 )
#else
- if( KitaConfig::showAA() ){
+ if ( KitaConfig::showAA() ) {
/* clear text in the span */
DOM::Node tmpnode = m_bodyElm[ num ].firstChild().firstChild();
- while( !tmpnode.isNull() ){
- if ( tmpnode.nodeName().string() == "span" ){
- if( !tmpnode.firstChild().isNull() ) tmpnode.firstChild().setNodeValue( "" );
+ while ( !tmpnode.isNull() ) {
+ if ( tmpnode.nodeName().string() == "span" ) {
+ if ( !tmpnode.firstChild().isNull() ) tmpnode.firstChild().setNodeValue( "" );
}
tmpnode = tmpnode.nextSibling();
}
}
-#endif
-
+#endif
+
return TRUE;
}
if ( !createResElement( num ) ) return FALSE;
m_hdoc.body().appendChild( m_titleElm[ num ] );
- m_hdoc.body().appendChild( m_bodyElm[ num ] );
+ m_hdoc.body().appendChild( m_bodyElm[ num ] );
m_resshown[ num ] = TRUE;
if ( num < m_topNum ) m_topNum = num;
if ( !m_resshown[ i ] ) continue;
- QString titleHTML, bodyHTML;
+ QString titleHTML, bodyHTML;
int oldStatus = m_resStatus[ i ];
- m_resStatus[ i ] = m_datInfo->getHTML( i , TRUE, titleHTML, bodyHTML );
-
- if ( force || oldStatus != m_resStatus[ i ] ){
-
- m_titleElm[ i ].setInnerHTML( titleHTML );
- m_bodyElm[ i ].setInnerHTML( bodyHTML );
+ m_resStatus[ i ] = m_datInfo->getHTML( i , TRUE, titleHTML, bodyHTML );
+
+ if ( force || oldStatus != m_resStatus[ i ] ) {
+
+ m_titleElm[ i ].setInnerHTML( titleHTML );
+ m_bodyElm[ i ].setInnerHTML( bodyHTML );
}
}
}
and DatInfo::collectResponsedRes(). */ /* public */
void KitaDomTree::changeColorOfAllResponsedNumber()
{
- for( int i = 1; i <= m_bottomNum; ++i ){
-
- if( m_resshown[ i ] && m_datInfo->isResponsed( i ) ) changeColorOfNumber( i );
+ for ( int i = 1; i <= m_bottomNum; ++i ) {
+
+ if ( m_resshown[ i ] && m_datInfo->isResponsed( i ) ) changeColorOfNumber( i );
}
}
if ( tmpNum > m_templateNum ) m_templateNum = tmpNum;
for ( int i = 1; i <= m_templateNum; i++ ) {
-
+
if ( !createResElement( i ) ) continue;
m_hdoc.body().appendChild( m_titleElm[ i ] );
}
int i = m_topNum;
- if ( i > readNum ) return;
+ if ( i > readNum ) return ;
while ( !m_resshown[ i ] && i <= readNum ) i++;
if ( i <= readNum ) {
/* update footer or header No */ /* private */
void KitaDomTree::updateFooterOrHeader(
- DOM::Element& targetelm, /* = m_header or m_footer */
+ DOM::Element& targetelm, /* = m_header or m_footer */
QString strType /* = "header" or "footer" */
)
{
m_mae100 = rootnode;
}
-/* change color of number */
+/* change color of number */
/*
specify color like this: "a.coloredLink:link{ color: red; }" */ /* private */
{
if ( ! m_datInfo ) return ;
if ( m_hdoc == NULL ) return ;
- if ( m_coloredNum[ num ] ) return;
- if ( !m_resshown[ num ] ) return;
+ if ( m_coloredNum[ num ] ) return ;
+ if ( !m_resshown[ num ] ) return ;
m_coloredNum[ num ] = TRUE;
DOM::Node node = m_titleElm[ num ];
node = node.firstChild();
- while( node.nodeName().string() != "a" ) node = node.firstChild(); /* table tag is used. */
+ while ( node.nodeName().string() != "a" ) node = node.firstChild(); /* table tag is used. */
static_cast< DOM::HTMLElement> ( node ).setAttribute( "class", "coloredLink" );
}
int m_bottomNum;
int m_headerMaxNum;
QValueVector < bool > m_resshown; /* the res is shown */
- QValueVector < int > m_resStatus; /* return val of DatInfo::getHTML(). See datinfo.h */
+ QValueVector < int > m_resStatus; /* return val of DatInfo::getHTML(). See datinfo.h */
QValueVector < bool > m_coloredNum; /* colored number */
/* DOM elements */
{
slotDeletePopup();
-
+
/* delete KitaDomTree */
if ( m_domtree ) delete m_domtree;
m_domtree = NULL;
/* update ViewPos */
if ( m_mode == HTMLPART_MODE_MAINPART && !m_updatedKokoyon && !m_datURL.isEmpty() ) {
int readNum = Kita::DatManager::getReadNum( m_datURL );
- if ( readNum ){
- Kita::DatManager::setViewPos( m_datURL, readNum );
- }
+ if ( readNum ) {
+ Kita::DatManager::setViewPos( m_datURL, readNum );
+ }
}
m_updatedKokoyon = FALSE;
-
+
/* clear variables */
m_anchorStack.clear();
m_centerNum = 0;
/* don't forget to unlock previous datURL here. */
Kita::DatManager::unlock( m_datURL );
- if ( m_mode == HTMLPART_MODE_MAINPART ){ /* This part is on the main thread view. */
+ if ( m_mode == HTMLPART_MODE_MAINPART ) { /* This part is on the main thread view. */
+
+ /* tell Thread class that "thread is closed" */
+ Kita::DatManager::setMainThreadOpened( m_datURL, FALSE );
- /* tell Thread class that "thread is closed" */
- Kita::DatManager::setMainThreadOpened( m_datURL, FALSE );
-
- /* emit "deactivated all thread view" SIGNAL */
- emit activateThreadView( QString::null );
+ /* emit "deactivated all thread view" SIGNAL */
+ emit activateThreadView( QString::null );
- /* update subject tab. */
- emit updateSubjectTab( m_datURL );
- }
+ /* update subject tab. */
+ emit updateSubjectTab( m_datURL );
+ }
}
m_datURL = QString::null;
m_mode = HTMLPART_MODE_KHTML;
m_datURL = Kita::getDatURL( url );
m_mode = mode;
-
- if( m_mode == HTMLPART_MODE_MAINPART ){ /* This part is on the main thread view. */
- /* create DatInfo explicitly to open new thread. */
- /* Usually, DatInfo is NOT created if ReadNum == 0.*/
- /* See also DatManager::createDatInfo() and */
- /* DatManager::getDatInfo(). */
- Kita::DatManager::createDatInfo( m_datURL );
+ if ( m_mode == HTMLPART_MODE_MAINPART ) { /* This part is on the main thread view. */
+
+ /* create DatInfo explicitly to open new thread. */
+ /* Usually, DatInfo is NOT created if ReadNum == 0.*/
+ /* See also DatManager::createDatInfo() and */
+ /* DatManager::getDatInfo(). */
+ Kita::DatManager::createDatInfo( m_datURL );
- /* tell Thread class that "thread is opend" */
- Kita::DatManager::setMainThreadOpened( m_datURL, TRUE );
+ /* tell Thread class that "thread is opend" */
+ Kita::DatManager::setMainThreadOpened( m_datURL, TRUE );
- /* reset abone */
- Kita::DatManager::resetAbone( m_datURL );
+ /* reset abone */
+ Kita::DatManager::resetAbone( m_datURL );
}
-
+
/* Lock datURL. Don't forget to unlock it later ! */
Kita::DatManager::lock ( m_datURL );
if ( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) {
m_domtree = new KitaDomTree( htmlDocument(), m_datURL );
}
-
+
return TRUE;
}
/* change color of number of the res which is responsed. */
if ( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) {
-
- if( KitaConfig::checkResponsed() ) m_domtree->changeColorOfAllResponsedNumber();
+
+ if ( KitaConfig::checkResponsed() ) m_domtree->changeColorOfAllResponsedNumber();
}
/*----------------------------*/
{
if ( e->type() == EVENT_GotoAnchor ) {
KHTMLPart::gotoAnchor( static_cast< GotoAnchorEvent* >( e ) ->getAnc() );
- return;
+ return ;
}
KHTMLPart::customEvent( e );
case WRITEMENU_SETKOKOYON:
Kita::DatManager::setViewPos( m_datURL, resNum );
- emit updateSubjectTab( m_datURL );
+ emit updateSubjectTab( m_datURL );
m_updatedKokoyon = TRUE;
updateScreen( TRUE, TRUE );
gotoAnchor( QString().setNum( resNum ), FALSE );
KURL datURL = m_datURL;
if ( url.at( 0 ) == '#' ) refstr = url.mid( 1 );
else datURL = Kita::getDatURL( KURL( m_datURL, url ) , refstr );
-
+
/*------------------------*/
/* id popup */
if ( url.left( 6 ) == "#idpop" ) {
int num = Kita::DatManager::getNumByID( m_datURL, url.mid( 6 ) );
QString tmpstr;
- if( num >=2 ) tmpstr = QString( "<DIV>ID:%1:[%2]</DIV>" ).arg( url.mid( 6 ) ).arg( num );
- else tmpstr = "<DIV>" + i18n( "None" ) + "</DIV>";
+ if ( num >= 2 ) tmpstr = QString( "<DIV>ID:%1:[%2]</DIV>" ).arg( url.mid( 6 ) ).arg( num );
+ else tmpstr = "<DIV>" + i18n( "None" ) + "</DIV>";
showPopup( m_datURL, tmpstr );
return ;
}
/*------------------------*/
/* show reffered num */
-
- if ( refstr.left( 5 ) == "write" ){
- int no = refstr.mid( 5 ).toInt();
+
+ if ( refstr.left( 5 ) == "write" ) {
+ int no = refstr.mid( 5 ).toInt();
int num = 0;
Kita::DatManager::getTreeByRes( m_datURL, no, num );
QString tmpstr;
- if( num ) tmpstr = QString( "<DIV>No.%1 : [%2]</DIV>" ).arg( no ).arg( num );
- else tmpstr = "<DIV>" + i18n( "None" ) + "</DIV>";
+ if ( num ) tmpstr = QString( "<DIV>No.%1 : [%2]</DIV>" ).arg( no ).arg( num );
+ else tmpstr = "<DIV>" + i18n( "None" ) + "</DIV>";
showPopup( m_datURL, tmpstr );
return ;
}
if ( url.left( 6 ) == "#abone" ) {
int no = url.mid( 6 ).toInt();
- QString tmpstr = Kita::DatManager::getHtml( m_datURL, no, no, FALSE );
+ QString tmpstr = Kita::DatManager::getHtml( m_datURL, no, no, FALSE );
showPopup( m_datURL, tmpstr );
return ;
}
-
+
/*------------------------*/
/* image popup */
if ( KitaConfig::useImagePopup() ) {
QString boardName = Kita::BoardManager::boardName( datURL );
if ( boardName != QString::null ) innerHTML += "[" + boardName + "] ";
- /* If idx file of datURL is not read, thread name cannot be obtained.
- so, create DatInfo if cache exists, and read idx file in DatInfo::DatInfo(). */
- Kita::DatManager::getDatInfoPointer( datURL );
+ /* If idx file of datURL is not read, thread name cannot be obtained.
+ so, create DatInfo if cache exists, and read idx file in DatInfo::DatInfo(). */
+ Kita::DatManager::getDatInfoPointer( datURL );
- /* get thread Name */
+ /* get thread Name */
QString subName = Kita::DatManager::threadName( datURL );
if ( subName != QString::null ) innerHTML += subName + "<br><br>";
if ( qr.bottom() > maxheight ) maxheight = qr.bottom();
/* move to the next node */
- DOM::Node next = curnode.firstChild();
+ DOM::Node next = curnode.firstChild();
- if ( next.isNull() ) next = curnode.nextSibling();
+ if ( next.isNull() ) next = curnode.nextSibling();
- while ( !curnode.isNull() && next.isNull() ) {
- curnode = curnode.parentNode();
- if ( !curnode.isNull() ) next = curnode.nextSibling();
- }
+ while ( !curnode.isNull() && next.isNull() ) {
+ curnode = curnode.parentNode();
+ if ( !curnode.isNull() ) next = curnode.nextSibling();
+ }
- curnode = next;
+ curnode = next;
if ( curnode.isNull() ) break;
}
public:
GotoAnchorEvent( const QString& anc )
- : QCustomEvent( EVENT_GotoAnchor ), m_anc( anc ){};
+ : QCustomEvent( EVENT_GotoAnchor ), m_anc( anc ) {};
const QString& getAnc() const { return m_anc; }
};
void KitaHTMLView::keyPressEvent( QKeyEvent* e )
{
if ( e->key() == Key_Space || e->key() == Key_PageDown
- || e->key() == Key_Down || e->key() == Key_End )
- {
- if( emitPushDown() ) return;
+ || e->key() == Key_Down || e->key() == Key_End ) {
+ if ( emitPushDown() ) return ;
}
KHTMLView::keyPressEvent( e );
}
/* protected */
-void KitaHTMLView::viewportWheelEvent(QWheelEvent * e)
+void KitaHTMLView::viewportWheelEvent( QWheelEvent * e )
{
- if( e->delta() < 0 )
- { /* scroll down */
- if( emitPushDown() ) return;
+ if ( e->delta() < 0 ) { /* scroll down */
+ if ( emitPushDown() ) return ;
}
KHTMLView::viewportWheelEvent( e );
{
int y = contentsY();
- if( y >= contentsHeight() - visibleHeight() )
- {
- emit pushDown();/* to KitaHTMLPart in order to call slotClickTugi100 */
+ if ( y >= contentsHeight() - visibleHeight() ) {
+ emit pushDown(); /* to KitaHTMLPart in order to call slotClickTugi100 */
return TRUE;
}
protected:
void leaveEvent( QEvent* );
void keyPressEvent( QKeyEvent* e );
- void viewportWheelEvent(QWheelEvent * e);
+ void viewportWheelEvent( QWheelEvent * e );
private:
bool emitPushDown();
-
+
signals:
void leave();
- void pushDown();
+ void pushDown();
};
#endif
QString dummy;
slotPopupMenu( dummy, e->globalPos() );
return ;
- }
- else if ( e->button() & Qt::LeftButton ) { /* start dragscrolling */
+ } else if ( e->button() & Qt::LeftButton ) { /* start dragscrolling */
m_dragScroll = TRUE;
QApplication::setOverrideCursor( KCursor::handCursor() );
m_dragx = e->globalX();
- m_dragy = e->globalY();
+ m_dragy = e->globalY();
}
QScrollView::contentsMousePressEvent( e );
/* Note that e->button() is always NoButton. */ /* virtual protected */
void KitaImgView::contentsMouseMoveEvent( QMouseEvent * e )
{
- if( !m_dragScroll ) return;
-
+ if ( !m_dragScroll ) return ;
+
/* drag & scroll */
int dx = m_dragx - e->globalX();
int dy = m_dragy - e->globalY();
scrollBy( dx, dy );
m_dragx = e->globalX();
- m_dragy = e->globalY();
+ m_dragy = e->globalY();
}
/* virtual protected */
-void KitaImgView::contentsMouseReleaseEvent( QMouseEvent * )
+void KitaImgView::contentsMouseReleaseEvent( QMouseEvent * )
{
- if( m_dragScroll ){
+ if ( m_dragScroll ) {
m_dragScroll = FALSE;
QApplication::restoreOverrideCursor();
}
signalCollection, SIGNAL( showWriteView( const KURL& , const QString& ) ) );
connect( this, SIGNAL( createNewThread( const KURL& , const QString&, const QString& ) ),
signalCollection, SIGNAL( createNewThread( const KURL& , const QString&, const QString& ) ) );
-
+
m_viewmode = VIEWMODE_MAINVIEW;
m_rescode = 200;
/* setup */
m_datURL = Kita::getDatURL( datURL );
-
+
/* setup HTMLPart */
int partMode = HTMLPART_MODE_MAINPART;
if ( mode == VIEWMODE_KITANAVI ) partMode = HTMLPART_MODE_NAVI;
}
/* create new thread */
else if ( str.mid( 1, 3 ) == "new" ) {
- emit createNewThread( m_datURL, QString::null, QString::null );
+ emit createNewThread( m_datURL, QString::null, QString::null );
return ;
- }
+ }
/* jump */
QString anc = str.mid( 1 );
QStringList query;
query += SearchCombo->currentText();
int ResNum = Kita::DatManager::getResNum( m_datURL );
- for( int i = 1; i <= ResNum; i++){
-
- if( Kita::DatManager::checkWord( m_datURL, query, i, FALSE ) ){
-
- /* if this is parent, then show all responses, and search */
- if ( m_viewmode == VIEWMODE_MAINVIEW ) m_threadPart->showAll();
-
- insertSearchCombo();
- QStringList list = parseSearchQuery( SearchCombo->currentText() );
- m_threadPart->findText( SearchCombo->currentText(), rev );
- SearchCombo->setFocus();
-
- return;
- }
+ for ( int i = 1; i <= ResNum; i++ ) {
+
+ if ( Kita::DatManager::checkWord( m_datURL, query, i, FALSE ) ) {
+
+ /* if this is parent, then show all responses, and search */
+ if ( m_viewmode == VIEWMODE_MAINVIEW ) m_threadPart->showAll();
+
+ insertSearchCombo();
+ QStringList list = parseSearchQuery( SearchCombo->currentText() );
+ m_threadPart->findText( SearchCombo->currentText(), rev );
+ SearchCombo->setFocus();
+
+ return ;
+ }
}
QMessageBox::information( this, i18n( "kita" ), i18n( "Not Found" ) );
!= QMessageBox::Ok ) return ;
}
- if( Kita::DatManager::deleteCache( m_datURL ) ){
- emit closeThreadTab( m_datURL );
- emit updateSubjectTab( m_datURL );
+ if ( Kita::DatManager::deleteCache( m_datURL ) ) {
+ emit closeThreadTab( m_datURL );
+ emit updateSubjectTab( m_datURL );
}
}
/* kita navi */
void showKitaNaviByWord( const KURL& , QString );
void showWriteView( const KURL& , const QString& );
- void createNewThread( const KURL& , const QString&, const QString& );
+ void createNewThread( const KURL& , const QString&, const QString& );
void activateThreadView( const KURL& );
};
void KitaWriteDialogBase::sageBoxToggled( bool on )
{
if ( on ) {
- m_mailswap = mailLine->text();
- mailLine->setText("sage");
- mailLine->setReadOnly(true);
+ m_mailswap = mailLine->text();
+ mailLine->setText( "sage" );
+ mailLine->setReadOnly( true );
} else {
- mailLine->setReadOnly(false);
- mailLine->setText(m_mailswap);
+ mailLine->setReadOnly( false );
+ mailLine->setText( m_mailswap );
}
}
: KitaWriteDialogBase( parent, name, 0 )
{
if ( !m_cp932Codec ) m_cp932Codec = new QCp932Codec();
-
+
m_mode = mode;
if ( m_mode == WRITEMODE_NORMAL ) m_datURL = Kita::getDatURL( url );
m_bbstype = Kita::BoardManager::type( m_datURL );
/* set path of bbs.cgi */
- switch( m_bbstype ){
-
- case Kita::Board_JBBS:
- {
- QString cgipath = Kita::BoardManager::boardRoot( m_datURL )
- + "/bbs/write.cgi/" + Kita::BoardManager::boardID( m_datURL ) + "/";
-
- if( m_mode == WRITEMODE_NORMAL ) cgipath += Kita::DatManager::threadID( m_datURL ) + "/";
- else cgipath += "new/";
-
- m_bbscgi = cgipath;
- }
+ switch ( m_bbstype ) {
+
+ case Kita::Board_JBBS: {
+ QString cgipath = Kita::BoardManager::boardRoot( m_datURL )
+ + "/bbs/write.cgi/" + Kita::BoardManager::boardID( m_datURL ) + "/";
- break;
+ if ( m_mode == WRITEMODE_NORMAL ) cgipath += Kita::DatManager::threadID( m_datURL ) + "/";
+ else cgipath += "new/";
+
+ m_bbscgi = cgipath;
+ }
+
+ break;
default:
- m_bbscgi = Kita::BoardManager::boardRoot( m_datURL ) + "/test/bbs.cgi";
+ m_bbscgi = Kita::BoardManager::boardRoot( m_datURL ) + "/test/bbs.cgi";
}
-
+
/* connect signals */
connect( buttonOk, SIGNAL( clicked() ),
SLOT( slotPostMessage() ) );
return ;
}
- if ( !slotBodyTextChanged() ){
+ if ( !slotBodyTextChanged() ) {
QMessageBox::warning( this, "Kita", i18n( "Body text is too long." ) );
return ;
}
/* set post message */
QString postStr;
- switch( m_bbstype ){
-
+ switch ( m_bbstype ) {
+
case Kita::Board_JBBS: postStr = setJBBSPostStr(); break;
-
+
case Kita::Board_FlashCGI: postStr = setFlashCGIPostStr(); break;
default: postStr = setPostStr(); break;
{
QString response;
- if( m_array.contains( "x-euc-jp" ) ) response = QTextCodec::codecForName( "eucJP" )->toUnicode( m_array );
- else response = QTextCodec::codecForName( "sjis" )->toUnicode( m_array );
-
+ if ( m_array.contains( "x-euc-jp" ) ) response = QTextCodec::codecForName( "eucJP" ) ->toUnicode( m_array );
+ else response = QTextCodec::codecForName( "sjis" ) ->toUnicode( m_array );
+
int retcode = resultCode( response );
switch ( retcode ) {
/* replace '\n' -> " <br> ", '>' -> "<", and etc. */
length += ( ( bodyText->text().contains( '\n' ) ) * 5
- +( bodyText->text().contains( '>' ) ) * 3
- +( bodyText->text().contains( '<' ) ) * 3
- );
+ + ( bodyText->text().contains( '>' ) ) * 3
+ + ( bodyText->text().contains( '<' ) ) * 3
+ );
int maxLength = Kita::BoardManager::getBBSMsgCount( m_datURL );
QString str;
str = QString().setNum( lines ) + "/" + ( maxLines != 0 ? QString().setNum( maxLines ) : QString( "--" ) );
- str += " | " + QString().setNum( length ) + "/" + ( maxLength != 0 ? QString().setNum( maxLength ) : QString( "--" ) );
+ str += " | " + QString().setNum( length ) + "/" + ( maxLength != 0 ? QString().setNum( maxLength ) : QString( "--" ) );
lengthLabel->setText( str );
- if( maxLines != 0 && lines > maxLines ) return FALSE;
- if( maxLength != 0 && length > maxLength ) return FALSE;
-
+ if ( maxLines != 0 && lines > maxLines ) return FALSE;
+ if ( maxLength != 0 && length > maxLength ) return FALSE;
+
return TRUE;
}
{
QString ret;
- int mib = QTextCodec::codecForName( "eucJP" )->mibEnum();
+ int mib = QTextCodec::codecForName( "eucJP" ) ->mibEnum();
int serverTime;
if ( m_mode == WRITEMODE_NORMAL ) serverTime = Kita::DatManager::getServerTime( m_datURL );
( ret += "&BBS=" ) += Kita::BoardManager::boardID( m_datURL ).section( "/", 1, 1 );
/* DIR */
- ( ret += "&DIR=" ) +=Kita::BoardManager::boardID( m_datURL ).section( "/", 0, 0 );
+ ( ret += "&DIR=" ) += Kita::BoardManager::boardID( m_datURL ).section( "/", 0, 0 );
/* SUBJECT */
if ( m_mode == WRITEMODE_NEWTHREAD ) ( ret += "&SUBJECT=" ) += KURL::encode_string( threadName->text(), mib );
-
+
/* KEY */
if ( m_mode == WRITEMODE_NORMAL ) ( ret += "&KEY=" ) += Kita::DatManager::threadID( m_datURL );
else if ( title.contains( truestr ) ) retcode = K2ch_True;
else if ( title.contains( ckstr ) ) retcode = K2ch_Cookie;
- /* re-post new thread message. adhock... */
+ /* re-post new thread message. adhock... */
else if ( m_mode == WRITEMODE_NEWTHREAD
&& response.contains( ckstr )
&& response.contains( "subbbs.cgi" ) ) retcode = K2ch_NewThread;
/* for Flash CGI */
- else if( m_bbstype == Kita::Board_FlashCGI ){
-
- if( title.contains( "ERROR!!" ) ) retcode = K2ch_Error;
+ else if ( m_bbstype == Kita::Board_FlashCGI ) {
+
+ if ( title.contains( "ERROR!!" ) ) retcode = K2ch_Error;
else retcode = K2ch_True;
}
-
+
/* for JBBS. adhoc... */
- else if( m_bbstype == Kita::Board_JBBS ){
-
- if ( response.contains( "x-euc-jp" ) ) retcode = K2ch_True;
- else retcode = K2ch_Error;
+ else if ( m_bbstype == Kita::Board_JBBS ) {
+
+ if ( response.contains( "x-euc-jp" ) ) retcode = K2ch_True;
+ else retcode = K2ch_Error;
}
}
}
/* private */
QString KitaWriteView::resultMessage( const QString& response ) const
{
- if( m_bbstype == Kita::Board_FlashCGI ){
-
- QRegExp regexp( "<blockquote>(.*)</blockquote>" );
- int pos = regexp.search( response );
- if ( pos != -1 ) {
- return regexp.cap( 1 ).replace( "<br>", "\n" );
- }
-
- return QString::null;
+ if ( m_bbstype == Kita::Board_FlashCGI ) {
+
+ QRegExp regexp( "<blockquote>(.*)</blockquote>" );
+ int pos = regexp.search( response );
+ if ( pos != -1 ) {
+ return regexp.cap( 1 ).replace( "<br>", "\n" );
+ }
+
+ return QString::null;
}
-
+
QRegExp regexp( "<b>([^<]*)</b>" );
int pos = regexp.search( response );
if ( pos != -1 ) {
int m_bbstype;
int m_mode;
- static QCp932Codec* m_cp932Codec;
-
+ static QCp932Codec* m_cp932Codec;
+
public:
-
+
KitaWriteView( QWidget* parent, const char* name, const KURL& url, int mode, const QString& newThreadName = QString::null );
virtual ~KitaWriteView();
void setMessage( const QString& bodyStr );
const QString mail() const;
const QString body() const;
const KURL datURL() const;
-
+
public slots:
virtual void setFocus();
private slots:
-
+
void slotRecieveData( KIO::Job*, const QByteArray& );
void slotPostFinished( KIO::Job* );
void slotCurrentChanged ( QWidget * w );
bool slotBodyTextChanged();
-
+
private:
-
+
QString setPostStr();
QString setJBBSPostStr();
QString setFlashCGIPostStr();
- void logPostMessage();
+ void logPostMessage();
int resultCode( const QString& response ) const;
QString resultMessage( const QString& response ) const;
QString resultTitle( const QString& response ) const;
nameAboneText->setText( KitaConfig::aboneNameList().join( "\n" ) );
wordAboneText->setText( KitaConfig::aboneWordList().join( "\n" ) );
- connect( idAboneText, SIGNAL( textChanged() ), SLOT( slotTextChanged() ));
- connect( nameAboneText, SIGNAL( textChanged() ), SLOT( slotTextChanged() ));
- connect( wordAboneText, SIGNAL( textChanged() ), SLOT( slotTextChanged() ));
+ connect( idAboneText, SIGNAL( textChanged() ), SLOT( slotTextChanged() ) );
+ connect( nameAboneText, SIGNAL( textChanged() ), SLOT( slotTextChanged() ) );
+ connect( wordAboneText, SIGNAL( textChanged() ), SLOT( slotTextChanged() ) );
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
connect( this, SIGNAL( redrawAllHTMLPart( bool ) ),
- signalCollection, SIGNAL( redrawAllHTMLPart( bool ) ));
+ signalCollection, SIGNAL( redrawAllHTMLPart( bool ) ) );
m_changed = FALSE;
}
void AbonePrefPage::apply()
{
- if( m_changed )
- {
+ if ( m_changed ) {
QString idText = idAboneText->text();
QStringList idList = QStringList::split( '\n', idText );
KitaConfig::setAboneIDList( idList );
/***************************************************************************
- * Copyright (C) 2004 by Kita Developers *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2004 by Kita Developers *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "loginprefpage.h"
#include "libkita/kitaconfig.h"
userIDLine->setText( KitaConfig::userID() );
passwordLine->insert( KitaConfig::password() );
autoLoginCheckBox->setChecked( KitaConfig::autoLogin() );
-
+
connect( userIDLine, SIGNAL( textChanged( const QString& ) ), SIGNAL( changed() ) );
connect( passwordLine, SIGNAL( textChanged( const QString& ) ), SIGNAL( changed() ) );
connect( autoLoginCheckBox, SIGNAL( toggled( bool ) ), SIGNAL( changed() ) );
/***************************************************************************
- * Copyright (C) 2004 by Kita Developers *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2004 by Kita Developers *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef KITALOGINPREFPAGE_H
#define KITALOGINPREFPAGE_H
QVBox * loginFrame = addVBoxPage( i18n( "Login" ), i18n( "Login" ) );
m_loginPage = new Kita::LoginPrefPage( loginFrame );
-// QVBox * debugFrame = addVBoxPage( i18n( "Debug" ), i18n( "Debug" ) );
-// m_debugPage = new DebugPrefPage( debugFrame );
+ // QVBox * debugFrame = addVBoxPage( i18n( "Debug" ), i18n( "Debug" ) );
+ // m_debugPage = new DebugPrefPage( debugFrame );
connect( m_facePage, SIGNAL( changed() ), SLOT( slotChanged() ) );
connect( m_asciiArtPage, SIGNAL( changed() ), SLOT( slotChanged() ) );
"Are you ready?" ), QMessageBox::Ok,
QMessageBox::Cancel | QMessageBox::Default | QMessageBox::Escape ) == QMessageBox::Ok ) {
- if( BoardManager::moveBoard( fromURL, toURL ) )
- QMessageBox::information( this, i18n( "replace" ), i18n( "Complete." ) );
- else KMessageBox::error( this, i18n( "replace" ), i18n( "Failed.." ) );
+ if ( BoardManager::moveBoard( fromURL, toURL ) )
+ QMessageBox::information( this, i18n( "replace" ), i18n( "Complete." ) );
+ else KMessageBox::error( this, i18n( "replace" ), i18n( "Failed.." ) );
}
}
Kita::UIPrefPage* m_uiPage;
Kita::AbonePrefPage* m_abonePage;
Kita::LoginPrefPage* m_loginPage;
-// DebugPrefPage* m_debugPage;
+ // DebugPrefPage* m_debugPage;
private slots:
void slotChanged();
using namespace Kita;
-struct Col_Attr ThreadListView::s_colAttr[] = {
- // labelName, itemName, keyName, showDefault
- { I18N_NOOP(" "), I18N_NOOP("Mark"), "Col_Mark", true },
- { I18N_NOOP("No."), I18N_NOOP("ID"), "Col_ID", true},
- { I18N_NOOP(" "), I18N_NOOP("Icon"), "Col_Icon", true},
- { I18N_NOOP("Title"), I18N_NOOP("Subject"), "Col_Subject", true},
- { I18N_NOOP("ResNum"), I18N_NOOP("ResNum"), "Col_ResNum", true},
- { I18N_NOOP("ReadNum"), I18N_NOOP("ReadNum"), "Col_ReadNum", true},
- { I18N_NOOP("ViewPos"), I18N_NOOP("ViewPos"), "Col_ViewPos", false},
- { I18N_NOOP("Unread"), I18N_NOOP("Unread"), "Col_Unread", true},
- { I18N_NOOP("Since"), I18N_NOOP("Since"), "Col_Since", true},
- { I18N_NOOP("Thread's speed"), I18N_NOOP("Speed"), "Col_Speed", true},
- { I18N_NOOP("Board"), I18N_NOOP("Board"), "Col_Board", false},
- { I18N_NOOP("Dat URL"), I18N_NOOP("DatURL"), "Col_DatURL", false},
- { I18N_NOOP("Mark Order"), I18N_NOOP("MarkOrder"), "Col_MarkOrder", false},
- { I18N_NOOP("ID Order"), I18N_NOOP("IDOrder"), "Col_IDOrder", false}
-};
+struct Col_Attr ThreadListView::s_colAttr[] =
+ {
+ // labelName, itemName, keyName, showDefault
+ { I18N_NOOP( " " ), I18N_NOOP( "Mark" ), "Col_Mark", true },
+ { I18N_NOOP( "No." ), I18N_NOOP( "ID" ), "Col_ID", true},
+ { I18N_NOOP( " " ), I18N_NOOP( "Icon" ), "Col_Icon", true},
+ { I18N_NOOP( "Title" ), I18N_NOOP( "Subject" ), "Col_Subject", true},
+ { I18N_NOOP( "ResNum" ), I18N_NOOP( "ResNum" ), "Col_ResNum", true},
+ { I18N_NOOP( "ReadNum" ), I18N_NOOP( "ReadNum" ), "Col_ReadNum", true},
+ { I18N_NOOP( "ViewPos" ), I18N_NOOP( "ViewPos" ), "Col_ViewPos", false},
+ { I18N_NOOP( "Unread" ), I18N_NOOP( "Unread" ), "Col_Unread", true},
+ { I18N_NOOP( "Since" ), I18N_NOOP( "Since" ), "Col_Since", true},
+ { I18N_NOOP( "Thread's speed" ), I18N_NOOP( "Speed" ), "Col_Speed", true},
+ { I18N_NOOP( "Board" ), I18N_NOOP( "Board" ), "Col_Board", false},
+ { I18N_NOOP( "Dat URL" ), I18N_NOOP( "DatURL" ), "Col_DatURL", false},
+ { I18N_NOOP( "Mark Order" ), I18N_NOOP( "MarkOrder" ), "Col_MarkOrder", false},
+ { I18N_NOOP( "ID Order" ), I18N_NOOP( "IDOrder" ), "Col_IDOrder", false}
+ };
ThreadListView::ThreadListView( QWidget* parent, const char* name )
: ThreadListViewBase( parent, name )
closeButton->setPixmap( SmallIcon( "fileclose" ) );
QHeader* header = subjectList->header();
- for( int i = Col_Begin; i <= Col_End; i++ ) {
- subjectList->addColumn( i18n( s_colAttr[i].labelName ) );
+ for ( int i = Col_Begin; i <= Col_End; i++ ) {
+ subjectList->addColumn( i18n( s_colAttr[ i ].labelName ) );
- if ( s_colAttr[i].showDefault != true ) {
+ if ( s_colAttr[ i ].showDefault != true ) {
subjectList->setColumnWidthMode( i, QListView::Manual );
header->setResizeEnabled( false, i );
subjectList->setColumnWidth( i, 0 );