From: ikemo Date: Sat, 29 May 2004 11:02:15 +0000 (+0000) Subject: reformat X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0e3c6ba5cd244f74ba386502e9308e2d12f86b97;p=kita%2Fkita.git reformat git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1114 56b19765-1e22-0410-a548-a0f45d66c51a --- diff --git a/kita/src/part/kitathreadview.cpp b/kita/src/part/kitathreadview.cpp index 9f525ca..4081247 100644 --- a/kita/src/part/kitathreadview.cpp +++ b/kita/src/part/kitathreadview.cpp @@ -140,20 +140,23 @@ KitaThreadView::KitaThreadView( QWidget* parent, const char* name ) KitaThreadView::~KitaThreadView() { - if ( m_popup ) { + if ( m_popup ) + { delete m_popup; m_popup = NULL; } - + /* unlock URL */ Kita::DatManager::unlock(m_datURL); /* don't delete m_threadPart before deleting m_domtree */ - if ( m_domtree ) { + if ( m_domtree ) + { delete m_domtree; m_domtree = NULL; } - if ( m_threadPart ) { + if ( m_threadPart ) + { delete m_threadPart; m_threadPart = NULL; } @@ -174,7 +177,8 @@ void KitaThreadView::slotDOMNodeActivated( const DOM::Node& node ) { //process Anchor tags. Anchor tags not proccessed here cause 'emit KParts::BrowserExtention::openURLRequest()' DOM::HTMLAnchorElement anchor = node; - if ( ! anchor.href().isEmpty() ) { + if ( ! anchor.href().isEmpty() ) + { kdDebug() << "AnchorNodeActivated::" << endl; } // end: anchor.href().isEmpty() } // end of Anchor tags. @@ -183,9 +187,12 @@ void KitaThreadView::slotDOMNodeActivated( const DOM::Node& node ) void KitaThreadView::setSubjectLabel( const QString& boardName, const QString& threadName, const QString boardURL ) { QString disp; - if ( boardName.isEmpty() ) { + if ( boardName.isEmpty() ) + { disp = threadName; - } else { + } + else + { disp = QString( "[%2] %3" ).arg( boardURL ).arg( boardName ).arg( threadName ); } @@ -205,12 +212,16 @@ void KitaThreadView::updateButton() BookmarkButton->setEnabled( true ); ReloadButton->setEnabled( true ); - if ( HighLightButton->isOn() ) { + if ( HighLightButton->isOn() ) + { HighLightButton->toggle(); } - if ( FavoriteThreads::getInstance() ->contains( m_thread->datURL() ) ) { + if ( FavoriteThreads::getInstance() ->contains( m_thread->datURL() ) ) + { BookmarkButton->setOn( true ); - } else { + } + else + { BookmarkButton->setOn( false ); } } @@ -224,7 +235,8 @@ void KitaThreadView::slotShowErrorDialog( const QString& input, const KURL& ) Kita::WriteResult writeResult( input ); kdDebug() << "code = " << writeResult.code() << endl; - switch ( writeResult.code() ) { + switch ( writeResult.code() ) + { case Kita::K2ch_Unknown: // probably OK. emit writeSucceeded(); @@ -244,10 +256,13 @@ void KitaThreadView::slotShowErrorDialog( const QString& input, const KURL& ) case Kita::K2ch_Cookie: if ( KMessageBox::questionYesNo( 0, eucjpCodec->toUnicode( cookie_message ), eucjpCodec->toUnicode( cookie_title ) ) - == KMessageBox::Yes ) { + == KMessageBox::Yes ) + { KitaWriteDialog * dialog = openDialog( m_postInfo ); dialog->postMessage(); - } else { + } + else + { KitaWriteDialog* dialog = openDialog( m_postInfo ); dialog->show(); } @@ -294,8 +309,10 @@ void KitaThreadView::slotWriteButtonClicked( QString resstr ) void KitaThreadView::insertSearchCombo() { - for ( int count = 0; count < SearchCombo->count(); ++count ) { - if ( SearchCombo->text( count ) == SearchCombo->currentText() ) { + for ( int count = 0; count < SearchCombo->count(); ++count ) + { + if ( SearchCombo->text( count ) == SearchCombo->currentText() ) + { // found return ; } @@ -317,7 +334,8 @@ QStringList KitaThreadView::parseSearchQuery( const QString& input ) const void KitaThreadView::hidePopup() { - if ( m_popup ) { + if ( m_popup ) + { m_popup->hide(); } } @@ -371,45 +389,45 @@ namespace Kita paletteChanged(); if (kapp) { - connect(kapp, SIGNAL(kdisplayPaletteChanged()), - this, SLOT(paletteChanged())); + connect(kapp, SIGNAL(kdisplayPaletteChanged()), + this, SLOT(paletteChanged())); } } void KitaSubjectLabel::paletteChanged() { - QPalette p = kapp ? kapp->palette() : palette(); - p.setBrush(QColorGroup::Base, p.brush(QPalette::Normal, QColorGroup::Background)); - p.setColor(QColorGroup::Text, p.color(QPalette::Normal, QColorGroup::Foreground)); - setPalette(p); + QPalette p = kapp ? kapp->palette() : palette(); + p.setBrush(QColorGroup::Base, p.brush(QPalette::Normal, QColorGroup::Background)); + p.setColor(QColorGroup::Text, p.color(QPalette::Normal, QColorGroup::Foreground)); + setPalette(p); } QSize KitaSubjectLabel::minimumSizeHint() const { - QSize ms = minimumSize(); - if ((ms.width() > 0) && (ms.height() > 0)) - return ms; - - int w = 400; - if (ms.width() > 0) - w = ms.width(); - - QString txt = text(); - QSimpleRichText rt(txt, font()); - rt.setWidth(w - 2*frameWidth() - 10); - w = 10 + rt.widthUsed() + 2*frameWidth(); - if (w < ms.width()) - w = ms.width(); - int h = rt.height() + 2*frameWidth(); - if ( h < ms.height()) - h = ms.height(); - - return QSize(w, h); + QSize ms = minimumSize(); + if ((ms.width() > 0) && (ms.height() > 0)) + return ms; + + int w = 400; + if (ms.width() > 0) + w = ms.width(); + + QString txt = text(); + QSimpleRichText rt(txt, font()); + rt.setWidth(w - 2*frameWidth() - 10); + w = 10 + rt.widthUsed() + 2*frameWidth(); + if (w < ms.width()) + w = ms.width(); + int h = rt.height() + 2*frameWidth(); + if ( h < ms.height()) + h = ms.height(); + + return QSize(w, h); } QSize KitaSubjectLabel::sizeHint() const { - return minimumSizeHint(); + return minimumSizeHint(); } PopupTextBrowser::PopupTextBrowser( QFrame* frame ) @@ -479,14 +497,14 @@ void KitaThreadView::setupEx( const Kita::Thread* thread, int serverTime, int mo /*---------------------------------------*/ /* setup */ - /* unlock previous URL */ - Kita::DatManager::unlock(m_datURL); + /* unlock previous URL */ + Kita::DatManager::unlock(m_datURL); m_thread = const_cast( thread ); m_datURL = m_thread->datURL(); - /* lock new URL */ - Kita::DatManager::lock(m_datURL); + /* lock new URL */ + Kita::DatManager::lock(m_datURL); /* setup HTMLPart */ m_threadPart->setupEx( this, m_domtree, m_thread ); @@ -498,7 +516,8 @@ void KitaThreadView::setupEx( const Kita::Thread* thread, int serverTime, int mo m_viewmode = mode; /* If curreent mode is VIEWMODE_PREVIEW , hide buttons */ - if ( m_viewmode == VIEWMODE_PREVIEW ) { + if ( m_viewmode == VIEWMODE_PREVIEW ) + { QLayout* Base = layout(); Base->remove( Subjectframe ); Base->removeItem( layout2 ); @@ -532,35 +551,38 @@ void KitaThreadView::showThread( const Kita::Thread* thread2h ) /* get log from cahce */ int maxnum = Kita::DatManager::getMaxResNumber(m_datURL); m_rescode = 200; - if ( maxnum ) { + if ( maxnum ) + { - /* copy data to dom */ - for(int i = 1; i <= maxnum; i++){ - const QString& line = Kita::DatManager::getDat(m_datURL,i); - if(line != QString::null) m_domtree->setDat( line , i ); - } + /* copy data to dom */ + for(int i = 1; i <= maxnum; i++) + { + const QString& line = Kita::DatManager::getDat(m_datURL,i); + if(line != QString::null) m_domtree->setDat( line , i ); + } - /* show templates (No.1->No.KitaDomTree::m_templateNum) */ - m_domtree->appendTemplate(); + /* show templates (No.1->No.KitaDomTree::m_templateNum) */ + m_domtree->appendTemplate(); - /* rendering */ - m_kokoyonNum = Kita::DatManager::getKokoyonNum(m_datURL); - for ( int i = m_kokoyonNum - m_preShowNum ; i <= m_kokoyonNum ; i++ ) - m_domtree->appendRes( i, FALSE ); - updateScreen(); + /* rendering */ + m_kokoyonNum = Kita::DatManager::getKokoyonNum(m_datURL); + for ( int i = m_kokoyonNum - m_preShowNum ; i <= m_kokoyonNum ; i++ ) + m_domtree->appendRes( i, FALSE ); + updateScreen(); - m_threadPart->gotoKokoyon(); + m_threadPart->gotoKokoyon(); } - else { - m_kokoyonNum = 0; - showStatusBar( "" ); + else + { + m_kokoyonNum = 0; + showStatusBar( "" ); } - + /* update data */ - m_firstReceive = TRUE; + m_firstReceive = TRUE; if( m_online ) slotReloadButton(); else updateInfo(); - + topLevelWidget() ->raise(); setActiveWindow(); } @@ -572,22 +594,24 @@ void KitaThreadView::showThread( const Kita::Thread* thread2h ) /*---------*/ /* public slot */ void KitaThreadView::slotReloadButton() { - switch ( m_viewmode ) { + switch ( m_viewmode ) + { case VIEWMODE_PREVIEW: break; case VIEWMODE_PARENT: - - /* update cache */ - /* After updating cache, DatManager will call slotFinishLoad.*/ - if( m_online ){ - m_domtree->StopParseThread(); - m_showNum = m_domtree->getBottomResNumber() + m_afterShowNum; - Kita::DatManager::updateCache(m_datURL,this); - m_threadPart->view()->setFocus(); - showStatusBar( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_NOWRENEW ) ); - } - break; + + /* update cache */ + /* After updating cache, DatManager will call slotFinishLoad.*/ + if( m_online ) + { + m_domtree->StopParseThread(); + m_showNum = m_domtree->getBottomResNumber() + m_afterShowNum; + Kita::DatManager::updateCache(m_datURL,this); + m_threadPart->view()->setFocus(); + showStatusBar( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_NOWRENEW ) ); + } + break; default: @@ -602,7 +626,8 @@ void KitaThreadView::slotReloadButton() /*-----------------------------------*/ /* slot called when Kita::DatManager received new data. */ /* public slot */ -void KitaThreadView::slotReceiveData(){ +void KitaThreadView::slotReceiveData() +{ int bottomNum = m_domtree->getBottomResNumber(); int beforeNum = m_domtree->getMaxResNumber(); @@ -610,31 +635,36 @@ void KitaThreadView::slotReceiveData(){ m_rescode = Kita::DatManager::getResponseCode(m_datURL); m_serverTime = Kita::DatManager::getServerTime(m_datURL); - + /* copy new data to DOM */ - for(int i = beforeNum+1; i <= afterNum; i++){ - const QString& line = Kita::DatManager::getDat(m_datURL,i); - if(line != QString::null){ - m_domtree->setDat( line , i ); - m_domtree->parseRes( i, i ); - } + for(int i = beforeNum+1; i <= afterNum; i++) + { + const QString& line = Kita::DatManager::getDat(m_datURL,i); + if(line != QString::null) + { + m_domtree->setDat( line , i ); + m_domtree->parseRes( i, i ); + } } /* rendering */ - if(bottomNum < m_showNum ){ - for ( int i = bottomNum+1 ; i <= m_showNum; i++ ) m_domtree->appendRes( i, FALSE ); - updateScreen(); - if(m_firstReceive && m_kokoyonNum < afterNum ){ - m_threadPart->gotoKokoyon(); - m_firstReceive = FALSE; - } + if(bottomNum < m_showNum ) + { + for ( int i = bottomNum+1 ; i <= m_showNum; i++ ) m_domtree->appendRes( i, FALSE ); + updateScreen(); + if(m_firstReceive && m_kokoyonNum < afterNum ) + { + m_threadPart->gotoKokoyon(); + m_firstReceive = FALSE; + } } } /*-----------------------------------*/ /* slot called when Kita::DatManager finished updating new data. */ /* public slot */ -void KitaThreadView::slotFinishLoad(){ +void KitaThreadView::slotFinishLoad() +{ m_firstReceive = FALSE; slotReceiveData(); @@ -653,7 +683,8 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg /* convert to the correct URL */ /* see also comments in KitaDomTree::createHTMLDocument for details */ - if ( urlin.protocol() == "file" ) { + if ( urlin.protocol() == "file" ) + { if ( urlin.prettyURL().mid( 5, 14 ) == "/test/read.cgi" ) url = KURL( m_thread->datURL(), ".." + urlin.prettyURL().mid( 5 ) ); @@ -665,7 +696,8 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg /* If this is not anchor, then emit openURLRequest and return */ if ( datURL.host() != KURL( m_thread->datURL() ).host() - || datURL.path() != KURL( m_thread->datURL() ).path() ) { + || datURL.path() != KURL( m_thread->datURL() ).path() ) + { emit openURLRequest( datURL, args ); return ; } @@ -676,41 +708,46 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg /*---------------------------*/ /* show popupmenu for #write */ - if ( datURL.ref().left( 5 ) == "write" ) { + if ( datURL.ref().left( 5 ) == "write" ) + { QClipboard * clipboard = QApplication::clipboard(); QString str, resstr; int resNum = datURL.ref().mid( 5 ).toInt(); - - /* show res tree on the popup */ - if(m_threadPart->isRightClick()){ - int num; - QString htmlstr - = Kita::DatManager::getTreeByRes(m_thread->datURL(),resNum,num); - if ( !num ) return ; - QString tmpstr = QString("
No.%1 : [%2]
").arg(resNum).arg(num); - tmpstr += htmlstr; - tmpstr += "

"; - showPopup( tmpstr, QString::null ); - return; - } - /* show tree on the kitanavi */ - else if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick()){ - showKitaNaviResTree(resNum); - return; - } + + /* show res tree on the popup */ + if(m_threadPart->isRightClick()) + { + int num; + QString htmlstr + = Kita::DatManager::getTreeByRes(m_thread->datURL(),resNum,num); + if ( !num ) return ; + QString tmpstr = QString("
No.%1 : [%2]
").arg(resNum).arg(num); + tmpstr += htmlstr; + tmpstr += "

"; + showPopup( tmpstr, QString::null ); + return; + } + /* show tree on the kitanavi */ + else if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick()) + { + showKitaNaviResTree(resNum); + return; + } KPopupMenu *popupMenu = new KPopupMenu( m_threadPart->view() ); popupMenu->clear(); popupMenu->insertItem( i18n( "write response" ), 0 ); popupMenu->insertItem( i18n( "quote this" ), 1 ); popupMenu->insertItem( i18n( "copy" ), 3 ); - if ( m_viewmode == VIEWMODE_PARENT ) { + if ( m_viewmode == VIEWMODE_PARENT ) + { popupMenu->insertSeparator(); popupMenu->insertItem( i18n( "set Kokomade Yonda" ), 2 ); } - switch ( popupMenu->exec( QCursor::pos() ) ) { + switch ( popupMenu->exec( QCursor::pos() ) ) + { case 0: resstr = ">>" + QString().setNum( resNum ) + "\n"; break; @@ -722,10 +759,10 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg case 2: delete popupMenu; - m_kokoyonNum = resNum; - Kita::DatManager::setKokoyonNum(m_datURL,resNum); - updateScreen(); - gotoAnchor( QString().setNum( resNum ) ); + m_kokoyonNum = resNum; + Kita::DatManager::setKokoyonNum(m_datURL,resNum); + updateScreen(); + gotoAnchor( QString().setNum( resNum ) ); return ; case 3: @@ -750,30 +787,34 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg /*----------------------------*/ /* extract responses by ID */ - if(datURL.ref().left(5) == "idpop"){ - - QString strid = datURL.ref().mid(5).replace("%2B","+").replace("%2F", "/"); /* decode %2B -> +, %2F -> / */ - - /* show them on the popup */ - if(m_threadPart->isRightClick()){ - int num; - QString htmlstr - = Kita::DatManager::getHtmlByID(m_thread->datURL(),strid,num ); - if ( num <= 1 ) return ; - QString tmpstr = QString("
ID:%1:[%2]
").arg(strid).arg(num); - tmpstr += htmlstr; - tmpstr += "

"; - showPopup( tmpstr, QString::null ); - } - - /* show them on the kitanavi */ - else if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick()) - showKitaNaviByID(strid); - else { + if(datURL.ref().left(5) == "idpop") + { + + QString strid = datURL.ref().mid(5).replace("%2B","+").replace("%2F", "/"); /* decode %2B -> +, %2F -> / */ + + /* show them on the popup */ + if(m_threadPart->isRightClick()) + { + int num; + QString htmlstr + = Kita::DatManager::getHtmlByID(m_thread->datURL(),strid,num ); + if ( num <= 1 ) return ; + QString tmpstr = QString("
ID:%1:[%2]
").arg(strid).arg(num); + tmpstr += htmlstr; + tmpstr += "

"; + showPopup( tmpstr, QString::null ); + } + + /* show them on the kitanavi */ + else if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick()) + showKitaNaviByID(strid); + else + { KPopupMenu *popupMenu = new KPopupMenu( m_threadPart->view() ); popupMenu->clear(); popupMenu->insertItem( i18n( "add id to abone list" ), 0 ); - switch ( popupMenu->exec( QCursor::pos() ) ) { + switch ( popupMenu->exec( QCursor::pos() ) ) + { case 0: KitaConfig::addAboneID( strid ); delete popupMenu; @@ -784,9 +825,9 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg } } - return; + return; } - + /*----------------------------*/ /* next 100 ,before 100 ,etc. */ @@ -794,52 +835,69 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg int bottom = m_domtree->getBottomResNumber(); int totalNum = m_domtree->getMaxResNumber(); - if ( datURL.ref().left( 7 ) == "tugi100" ) { + if ( datURL.ref().left( 7 ) == "tugi100" ) + { - if ( totalNum != bottom ) { + if ( totalNum != bottom ) + { appendRes( bottom + 1, bottom + 100 ); } gotoAnchor( QString().setNum( bottom ) ); return ; - } else if ( datURL.ref().left( 6 ) == "nokori" ) { + } + else if ( datURL.ref().left( 6 ) == "nokori" ) + { - if ( totalNum != bottom ) { + if ( totalNum != bottom ) + { appendRes( bottom + 1, totalNum ); } gotoAnchor( QString().setNum( bottom ) ); return ; - } else if ( datURL.ref().left( 7 ) == "tosaigo" ) { + } + else if ( datURL.ref().left( 7 ) == "tosaigo" ) + { - if ( totalNum != bottom ) { + if ( totalNum != bottom ) + { appendRes( bottom + 1, totalNum ); } gotoAnchor( "footer" ); return ; - } else if ( datURL.ref().left( 6 ) == "mae100" ) { + } + else if ( datURL.ref().left( 6 ) == "mae100" ) + { - if ( top != 1 ) { + if ( top != 1 ) + { m_domtree->appendTemplate(); appendRes( top - 100, bottom ); gotoAnchor( QString().setNum( top ) ); } return ; - } else if ( datURL.ref().left( 8 ) == "maezenbu" ) { + } + else if ( datURL.ref().left( 8 ) == "maezenbu" ) + { - if ( top != 1 ) { + if ( top != 1 ) + { appendRes( 1, bottom ); gotoAnchor( QString().setNum( top ) ); } return ; - } else if ( datURL.ref().left( 6 ) == "tmp100" ) { + } + else if ( datURL.ref().left( 6 ) == "tmp100" ) + { int tmpnum = m_domtree->getTemplateNumber(); - if ( tmpnum < top ) { + if ( tmpnum < top ) + { m_domtree->setTemplateNumber( tmpnum + 100 ); m_domtree->appendTemplate(); appendRes( top, bottom ); @@ -847,9 +905,12 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg } return ; - } else if ( datURL.ref().left( 5 ) == "zenbu" ) { + } + else if ( datURL.ref().left( 5 ) == "zenbu" ) + { - if ( top != 1 || bottom != totalNum ) { + if ( top != 1 || bottom != totalNum ) + { appendRes( 1, totalNum ); gotoAnchor( "header" ); } @@ -864,19 +925,22 @@ void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArg int refNum,refNum2; int i = refstr.find( "-" ); - if ( i != -1 ) { + if ( i != -1 ) + { refNum = refstr.left( i ).toInt(); - refNum2 = QMIN(refstr.mid(i+1).toInt(),totalNum); - if(refNum2 < refNum) refNum2 = refNum; + refNum2 = QMIN(refstr.mid(i+1).toInt(),totalNum); + if(refNum2 < refNum) refNum2 = refNum; refstr = datURL.ref().left( i ); - } else refNum = refNum2 = refstr.toInt(); + } + else refNum = refNum2 = refstr.toInt(); if ( !refNum ) return ; /* show Kita Navi or goto anchor */ if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick() - || m_viewmode == VIEWMODE_KITANAVI){ - showKitaNavi(refNum,refNum2); + || m_viewmode == VIEWMODE_KITANAVI) + { + showKitaNavi(refNum,refNum2); } else gotoAnchor( refstr ); } @@ -892,40 +956,41 @@ void KitaThreadView::showStatusBar( QString info ) bool broken = FALSE; QString infostr = QString::null; QString errstr = QString::null; - - switch( m_viewmode ){ + + switch( m_viewmode ) + { case VIEWMODE_PARENT: - totalNum = Kita::DatManager::getMaxResNumber(m_datURL); - broken = Kita::DatManager::isBroken(m_datURL); - datSize = Kita::DatManager::getDatSize(m_datURL); + totalNum = Kita::DatManager::getMaxResNumber(m_datURL); + broken = Kita::DatManager::isBroken(m_datURL); + datSize = Kita::DatManager::getDatSize(m_datURL); - errstr = QString::null; - if ( m_rescode != 200 && m_rescode != 206 ) - errstr = QString( "Error %1" ).arg( m_rescode ); - if ( broken ) info += " This thread is broken."; + errstr = QString::null; + if ( m_rescode != 200 && m_rescode != 206 ) + errstr = QString( "Error %1" ).arg( m_rescode ); + if ( broken ) info += " This thread is broken."; /* show status bar */ infostr = m_thread->name() + - QString( " [Total: %1 New: %2] %3 k" ).arg( totalNum ).arg( totalNum - m_kokoyonNum ).arg( datSize / 1024 ) - + info + " " + errstr; + QString( " [Total: %1 New: %2] %3 k" ).arg( totalNum ).arg( totalNum - m_kokoyonNum ).arg( datSize / 1024 ) + + info + " " + errstr; emit signalChangeStatusbar( infostr ); emit showThreadCompleted( m_thread->url() ); topLevelWidget() ->setCaption( m_thread->name() ); - - return; - break; + + return; + break; case VIEWMODE_KITANAVI: - QString infostr = QString( "[%1] %2" ).arg(m_thread->boardName()).arg( m_thread->name() ); - emit signalChangeStatusbar( infostr ); + QString infostr = QString( "[%1] %2" ).arg(m_thread->boardName()).arg( m_thread->name() ); + emit signalChangeStatusbar( infostr ); - return; - break; - } + return; + break; + } } @@ -935,7 +1000,8 @@ KURL KitaThreadView::filterReadCGI( const KURL& url, const Kita::Thread* thread { KURL newURL = url; - if ( url.path().contains( "/test/read.cgi" ) ) { + if ( url.path().contains( "/test/read.cgi" ) ) + { newURL.setProtocol( KURL( thread->datURL() ).protocol() ); QString tmp = url.path().section( "/test/read.cgi", 1 ); @@ -945,7 +1011,8 @@ KURL KitaThreadView::filterReadCGI( const KURL& url, const Kita::Thread* thread newURL.setPath( newPath ); QString refBase = tmp.section( '/', 3 ); - if ( ! refBase.isEmpty() ) { + if ( ! refBase.isEmpty() ) + { QString newRef; if ( refBase.at( 0 ) == '-' ) newRef = "1" + refBase; @@ -973,26 +1040,33 @@ void KitaThreadView::gotoAnchor( QString anc ) int bottom = m_domtree->getBottomResNumber(); int res = anc.toInt(); - if ( res == 1 ) { + if ( res == 1 ) + { anc = "header"; - } else if ( res > 1 ) { + } + else if ( res > 1 ) + { /* data is not set */ if ( !m_domtree->isResDataSet( res ) ) return ; /* show res if it is not shown */ - if ( !m_domtree->isResShown( res ) ) { + if ( !m_domtree->isResShown( res ) ) + { if ( res > bottom ) appendRes( bottom + 1, res + 99 ); - else if ( res < top ) { + else if ( res < top ) + { m_domtree->appendTemplate(); appendRes( res, bottom ); } } /* aboned */ - if ( !m_domtree->isResShown( res ) ) { - while ( res > 0 ) { + if ( !m_domtree->isResShown( res ) ) + { + while ( res > 0 ) + { if ( m_domtree->isResShown( res ) ) break; res--; } @@ -1028,27 +1102,29 @@ void KitaThreadView::updateScreen() /*--------------------*/ /* update information */ /* public */ -void KitaThreadView::updateInfo(){ - +void KitaThreadView::updateInfo() +{ + /* uptate informations */ setSubjectLabel(Kita::DatManager::thread_boardName(m_datURL), - Kita::DatManager::thread_name(m_datURL) - + QString( " (%1)" ) - .arg( Kita::DatManager::getMaxResNumber(m_datURL) ), + Kita::DatManager::thread_name(m_datURL) + + QString( " (%1)" ) + .arg( Kita::DatManager::getMaxResNumber(m_datURL) ), Kita::DatManager::thread_boardURL( m_datURL ) ); emit showThreadCompleted( Kita::DatManager::thread_url(m_datURL) ); m_domtree->findTextInit(); updateButton(); - + gotoCombo->clear(); gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_GOTO ) ); gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_KOKOYON ) ); - for( int i = 1; i < m_thread->resNum(); i += 100 ) { + for( int i = 1; i < m_thread->resNum(); i += 100 ) + { gotoCombo->insertItem( QString().setNum( i ) + "-" ); } gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_SAIGO ) ); gotoCombo->adjustSize(); - + emit thread( m_thread ); showStatusBar( "" ); m_threadPart->view() ->setFocus(); @@ -1082,13 +1158,15 @@ void KitaThreadView::appendRes( int startnum, int endnum ) void KitaThreadView::showPopup( QString innerHTML, QString imgfile ) { - if ( m_popup ) { + if ( m_popup ) + { delete m_popup; m_popup = NULL; } /* text popup */ - if ( imgfile == NULL ) { + if ( imgfile == NULL ) + { m_popup = new Kita::ResPopup( m_threadPart->view() ); m_popup->setText( innerHTML ); m_popup->adjustSize(); @@ -1104,19 +1182,28 @@ void KitaThreadView::showPopup( QString innerHTML, QString imgfile ) QPoint pos = QCursor::pos(); int x = pos.x(), y = pos.y(); - if ( x + mrg + pw < sw ) { + if ( x + mrg + pw < sw ) + { x = x + mrg; y = QMAX( 0, y - ( ph + mrg ) ); - } else if ( y - ( mrg + ph ) >= 0 ) { + } + else if ( y - ( mrg + ph ) >= 0 ) + { x = QMAX( 0, sw - pw ); y = y - ( ph + mrg ); - } else if ( y + ( mrg + ph ) <= sh ) { + } + else if ( y + ( mrg + ph ) <= sh ) + { x = QMAX( 0, sw - pw ); y = y + mrg; - } else if ( x - ( mrg + pw ) >= 0 ) { + } + else if ( x - ( mrg + pw ) >= 0 ) + { x = x - ( mrg + pw ); y = QMAX( 0, y - ( ph + mrg ) ); - } else { + } + else + { x = x + mrg; y = QMAX( 0, y - ( ph + mrg ) ); } @@ -1138,13 +1225,15 @@ void KitaThreadView::slotOnURL( const QString& url ) if ( !isActiveWindow() ) return ; if ( url.isEmpty() ) return ; - if ( m_popup ) { + if ( m_popup ) + { delete m_popup; m_popup = NULL; } /* id popup */ - if ( url.left( 6 ) == "#idpop" ) { + if ( url.left( 6 ) == "#idpop" ) + { int num = Kita::DatManager::getNumByID( m_thread->datURL(), url.mid( 6 ) ); if ( num <= 1 ) return ; QString tmpstr = QString( "
ID:%1:[%2]

" ).arg( url.mid( 6 ) ).arg( num ); @@ -1162,11 +1251,14 @@ void KitaThreadView::slotOnURL( const QString& url ) int refNum2; if ( url.at( 0 ) == '#' ) refstr = url.mid( 1 ); - else if ( url.left( 7 ) == "mailto:" ) { + else if ( url.left( 7 ) == "mailto:" ) + { DOM::Node node = m_threadPart->nodeUnderMouse().firstChild(); QString nodeValue = node.nodeValue().string(); refstr = nodeValue; - } else { + } + else + { datURL = filterReadCGI( KURL( m_thread->datURL(), url ) , m_thread ); refstr = datURL.ref(); } @@ -1177,24 +1269,29 @@ void KitaThreadView::slotOnURL( const QString& url ) if ( regexp.search( datURL.url() ) == -1 ) return ; int i = refstr.find( "-" ); - if ( i != -1 ) { /* >>refNum-refNum2 */ + if ( i != -1 ) + { /* >>refNum-refNum2 */ refNum = refstr.left( i ).toInt(); refNum2 = refstr.mid( i + 1 ).toInt(); - if ( refNum ) { + if ( refNum ) + { if ( refNum2 < refNum ) refNum2 = refNum; if ( refNum2 - refNum > m_maxpopup - 1 ) refNum2 = refNum + m_maxpopup - 1; } - } else { /* >>refNum */ + } + else + { /* >>refNum */ refNum = refstr.toInt(); refNum2 = refNum; } /* another thread ? */ if ( datURL.host() != KURL( m_thread->datURL() ).host() - || datURL.path() != KURL( m_thread->datURL() ).path() ) { + || datURL.path() != KURL( m_thread->datURL() ).path() ) + { /* show subject */ innerHTML = Kita::DatManager::getSubject( datURL ); @@ -1222,7 +1319,8 @@ void KitaThreadView::slotSearchButton() /* jump */ QString str = SearchCombo->currentText(); - if ( str.at( 0 ) == ':' ) { + if ( str.at( 0 ) == ':' ) + { QString anc = str.mid( 1 ); gotoAnchor( anc ); SearchCombo->setFocus(); @@ -1230,18 +1328,21 @@ void KitaThreadView::slotSearchButton() } /* extract responses by keywords */ - else if(str.at(0) == '?'){ - QString query = str.mid(1); - showKitaNaviByWord(query); - return; + else if(str.at(0) == '?') + { + QString query = str.mid(1); + showKitaNaviByWord(query); + return; } /* if this is parent, then show all responses, and search */ - if ( m_viewmode == VIEWMODE_PARENT ) { + if ( m_viewmode == VIEWMODE_PARENT ) + { int top = m_domtree->getTopResNumber(); int bottom = m_domtree->getBottomResNumber(); int totalNum = m_domtree->getMaxResNumber(); - if ( top != 1 || bottom != totalNum ) { + if ( top != 1 || bottom != totalNum ) + { appendRes( 1, totalNum ); } } @@ -1255,13 +1356,18 @@ void KitaThreadView::slotSearchButton() void KitaThreadView::slotComboActivated( int index ) { - if ( index == gotoCombo->count() - 1 ) { + if ( index == gotoCombo->count() - 1 ) + { // last gotoAnchor( "footer" ); - } else if ( index == 1 ) { + } + else if ( index == 1 ) + { // kokomade yonda gotoAnchor( "kokomade_yonda" ); - } else if ( index != 0 ) { + } + else if ( index != 0 ) + { QString numText = gotoCombo->text( index ); numText.truncate( numText.length() - 1 ); gotoAnchor( numText ); @@ -1327,22 +1433,23 @@ void KitaThreadView::domApplyChange( QString lbstr, /* label */ GobackAnchorButton->setEnabled( FALSE ); BookmarkButton->setEnabled( FALSE ); - switch( m_viewmode ){ + switch( m_viewmode ) + { case VIEWMODE_PREVIEW: - writeButton->setEnabled( FALSE ); + writeButton->setEnabled( FALSE ); SearchCombo->setEnabled( FALSE ); SearchButton->setEnabled( FALSE ); HighLightButton->setEnabled( FALSE ); - ReloadButton->setEnabled( FALSE ); - break; + ReloadButton->setEnabled( FALSE ); + break; case VIEWMODE_KITANAVI: - writeButton->setEnabled( TRUE ); - ReloadButton->setEnabled( TRUE ); - break; + writeButton->setEnabled( TRUE ); + ReloadButton->setEnabled( TRUE ); + break; } - + if ( cmbstr != NULL ) SearchCombo->insertItem( cmbstr ); if ( anchor != NULL ) gotoAnchor( anchor ); @@ -1357,13 +1464,13 @@ void KitaThreadView::domApplyChange( QString lbstr, /* label */ /*-----------------------*/ /* show Kita Navi */ /*-----------------------*/ /* private */ -void KitaThreadView::showKitaNavi(int startnum, int endnum){ - +void KitaThreadView::showKitaNavi(int startnum, int endnum) +{ hidePopup(); KitaNavi* kitanavi; - + if(!(kitanavi = KitaNavi::getKitaNavi())) return; - + kitanavi->addTab(KITANAVI_SHOWRES,m_thread,m_serverTime,QString::null,startnum,endnum); } @@ -1371,8 +1478,8 @@ void KitaThreadView::showKitaNavi(int startnum, int endnum){ /*-------------------------------*/ /* extract ID & show Kita Navi */ /*-------------------------------*/ /* private */ -void KitaThreadView::showKitaNaviByID(QString strid){ - +void KitaThreadView::showKitaNaviByID(QString strid) +{ hidePopup(); KitaNavi* kitanavi; @@ -1385,33 +1492,33 @@ void KitaThreadView::showKitaNaviByID(QString strid){ /*--------------------------------------*/ /* extract by keywords & show kita navi */ -/*--------------------------------------*/ - /* called from KitaHTMLPart::slotPopupMenu */ /* public */ -void KitaThreadView::showKitaNaviByWord(QString query){ - +/*--------------------------------------*/ +/* called from KitaHTMLPart::slotPopupMenu */ /* public */ +void KitaThreadView::showKitaNaviByWord(QString query) +{ hidePopup(); KitaNavi* kitanavi; if(!(kitanavi = KitaNavi::getKitaNavi())) return; - - kitanavi->addTab(KITANAVI_EXTBYWORD,m_thread,m_serverTime,query,0,0); + + kitanavi->addTab(KITANAVI_EXTBYWORD,m_thread,m_serverTime,query,0,0); } /*--------------------------------------*/ /* show res tree on the kitanavi */ /*--------------------------------------*/ /* private */ -void KitaThreadView::showKitaNaviResTree(int resNum){ - +void KitaThreadView::showKitaNaviResTree(int resNum) +{ hidePopup(); KitaNavi* kitanavi; - + if(!(kitanavi = KitaNavi::getKitaNavi())) return; int num; QString htmlstr = - Kita::DatManager::getTreeByRes(m_thread->datURL(),resNum,num); + Kita::DatManager::getTreeByRes(m_thread->datURL(),resNum,num); if ( !num ) return ; - + kitanavi->addTab(KITANAVI_SHOWRESTREE,m_thread,m_serverTime,htmlstr,resNum,num); }