OSDN Git Service

reformat
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Thu, 26 Aug 2004 15:46:16 +0000 (15:46 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Thu, 26 Aug 2004 15:46:16 +0000 (15:46 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1324 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/part/kitahtmlpart.cpp

index cd07cb5..13566bf 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
-*   Copyright (C) 2003 by Hideki Ikemoto , 2004 by 421                    *
+*   Copyright (C) 2003,2004 by Hideki Ikemoto , 2004 by 421               *
 *   ikemo@users.sourceforge.jp                                            *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
@@ -72,21 +72,20 @@ void KitaHTMLPart::clearPart()
     m_domtree = NULL;
 
     /* update Kokomade Yonda */
-    if( m_mode == HTMLPART_MODE_MAINPART && !m_updatedKokoyon && !m_datURL.isEmpty())
-    {
+    if ( m_mode == HTMLPART_MODE_MAINPART && !m_updatedKokoyon && !m_datURL.isEmpty() ) {
         int readNum = Kita::DatManager::getReadNum( m_datURL );
-        if( readNum ) Kita::DatManager::setKokoyonNum( m_datURL, readNum );
+        if ( readNum ) Kita::DatManager::setKokoyonNum( m_datURL, readNum );
     }
     m_updatedKokoyon = FALSE;
 
-    if( !m_datURL.isEmpty() ) {
+    if ( !m_datURL.isEmpty() ) {
+
+        /* don't forget to unlock previous datURL here. */
+        Kita::DatManager::unlock( m_datURL );
 
-       /* don't forget to unlock previous datURL here. */
-       Kita::DatManager::unlock( m_datURL );
+        /* emit deactivated all thread view SIGNAL */
+        if ( m_mode == HTMLPART_MODE_MAINPART ) emit activateThreadView( QString::null );
 
-       /* emit deactivated all thread view SIGNAL */
-       if( m_mode == HTMLPART_MODE_MAINPART ) emit activateThreadView( QString::null );
-       
     }
 
     m_anchorStack.clear();
@@ -100,13 +99,13 @@ void KitaHTMLPart::clearPart()
 /* public */
 bool KitaHTMLPart::setup( int mode, const KURL& url )
 {
-    if( url.isEmpty() ) return FALSE;
+    if ( url.isEmpty() ) return FALSE;
 
     clearPart();
 
     /* Lock datURL. Don't forget to unlock it later ! */
     m_datURL = Kita::ParseMisc::parseURLonly( url );
-    Kita::DatManager::lock( m_datURL );
+    Kita::DatManager::lock ( m_datURL );
 
     /* reset abone */
     Kita::DatManager::resetAbone( m_datURL );
@@ -116,8 +115,7 @@ bool KitaHTMLPart::setup( int mode, const KURL& url )
 
     /* create DOM manager */
     m_mode = mode;
-    if( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI )
-    {
+    if ( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) {
         m_domtree = new KitaDomTree( htmlDocument(), m_datURL );
     }
 
@@ -129,26 +127,26 @@ bool KitaHTMLPart::setup( int mode, const KURL& url )
 void KitaHTMLPart::connectSignals()
 {
 
-    Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
+    Kita::SignalCollection * signalCollection = Kita::SignalCollection::getInstance();
 
 
     /* rendering */
-    connect( this, SIGNAL( redrawHTMLPart( const KURL&, bool ) ), signalCollection, SIGNAL( redrawHTMLPart( const KURL&, bool ) ));
-    connect( signalCollection, SIGNAL( redrawHTMLPart( const KURL&, bool ) ), SLOT( slotRedrawHTMLPart( const KURL& , bool) ));
-    connect( signalCollection, SIGNAL( redrawAllHTMLPart( bool ) ), SLOT( slotRedrawAllHTMLPart( bool ) ));
-    connect( signalCollection, SIGNAL( setFontOfHTMLPart() ), SLOT( slotSetFontOfHTMLPart() ));
-    connect( signalCollection, SIGNAL( setStyleSheetOfHTMLPart() ), SLOT( slotSetStyleSheetOfHTMLPart() ));
+    connect( this, SIGNAL( redrawHTMLPart( const KURL&, bool ) ), signalCollection, SIGNAL( redrawHTMLPart( const KURL&, bool ) ) );
+    connect( signalCollection, SIGNAL( redrawHTMLPart( const KURL&, bool ) ), SLOT( slotRedrawHTMLPart( const KURL& , bool ) ) );
+    connect( signalCollection, SIGNAL( redrawAllHTMLPart( bool ) ), SLOT( slotRedrawAllHTMLPart( bool ) ) );
+    connect( signalCollection, SIGNAL( setFontOfHTMLPart() ), SLOT( slotSetFontOfHTMLPart() ) );
+    connect( signalCollection, SIGNAL( setStyleSheetOfHTMLPart() ), SLOT( slotSetStyleSheetOfHTMLPart() ) );
 
     /* popup */
-    connect( this, SIGNAL( onURL( const QString& ) ), SLOT( slotOnURL( const QString& ) ));
-    connect( this, SIGNAL( isKitaActive() ), signalCollection, SIGNAL( isKitaActive() ));
+    connect( this, SIGNAL( onURL( const QString& ) ), SLOT( slotOnURL( const QString& ) ) );
+    connect( this, SIGNAL( isKitaActive() ), signalCollection, SIGNAL( isKitaActive() ) );
 
-    connect( view(), SIGNAL( leave() ), SLOT( slotLeave() ));
-    connect( view(), SIGNAL( verticalSliderReleased() ), SLOT( slotVSliderReleased() ));
-    connect( view(), SIGNAL( horizontalSliderReleased() ), SLOT( slotHSliderReleased() ));
+    connect( view(), SIGNAL( leave() ), SLOT( slotLeave() ) );
+    connect( view(), SIGNAL( verticalSliderReleased() ), SLOT( slotVSliderReleased() ) );
+    connect( view(), SIGNAL( horizontalSliderReleased() ), SLOT( slotHSliderReleased() ) );
 
-    connect( signalCollection, SIGNAL( kitaIsActive() ), SLOT( slotKitaIsActive() ));
-    connect( signalCollection, SIGNAL( windowDeactivated() ), SLOT( slotHideChildPopup() ));
+    connect( signalCollection, SIGNAL( kitaIsActive() ), SLOT( slotKitaIsActive() ) );
+    connect( signalCollection, SIGNAL( windowDeactivated() ), SLOT( slotHideChildPopup() ) );
 
 
     /* click */
@@ -157,28 +155,28 @@ void KitaHTMLPart::connectSignals()
 
 
     /* goto anchor */
-    connect( view(), SIGNAL( pushDown() ), SLOT( slotClickTugi100() ));
+    connect( view(), SIGNAL( pushDown() ), SLOT( slotClickTugi100() ) );
 
     /* kitanavi */
-    connect( this, SIGNAL( showKitaNavi( const KURL& , int , int )),
-             signalCollection, SIGNAL( showKitaNavi( const KURL& , int , int )));
-    connect( this, SIGNAL( showKitaNaviByID( const KURL& , QString )),
-            signalCollection, SIGNAL( showKitaNaviByID( const KURL& , QString )));
-    connect( this, SIGNAL( showKitaNaviByWord( const KURL& , QString)),
-            signalCollection, SIGNAL( showKitaNaviByWord( const KURL& , QString)));
-    connect( this, SIGNAL( showKitaNaviByName( const KURL& , QString)),
-            signalCollection, SIGNAL( showKitaNaviByName( const KURL& , QString)));
-    connect( this, SIGNAL( showKitaNaviResTree( const KURL&,  int )),
-            signalCollection, SIGNAL( showKitaNaviResTree( const KURL&,  int )));
-    connect( this, SIGNAL( showKitaNaviRevResTree( const KURL&,  int )),
-            signalCollection, SIGNAL( showKitaNaviRevResTree( const KURL&,  int )));
+    connect( this, SIGNAL( showKitaNavi( const KURL& , int , int ) ),
+             signalCollection, SIGNAL( showKitaNavi( const KURL& , int , int ) ) );
+    connect( this, SIGNAL( showKitaNaviByID( const KURL& , QString ) ),
+             signalCollection, SIGNAL( showKitaNaviByID( const KURL& , QString ) ) );
+    connect( this, SIGNAL( showKitaNaviByWord( const KURL& , QString ) ),
+             signalCollection, SIGNAL( showKitaNaviByWord( const KURL& , QString ) ) );
+    connect( this, SIGNAL( showKitaNaviByName( const KURL& , QString ) ),
+             signalCollection, SIGNAL( showKitaNaviByName( const KURL& , QString ) ) );
+    connect( this, SIGNAL( showKitaNaviResTree( const KURL&, int ) ),
+             signalCollection, SIGNAL( showKitaNaviResTree( const KURL&, int ) ) );
+    connect( this, SIGNAL( showKitaNaviRevResTree( const KURL&, int ) ),
+             signalCollection, SIGNAL( showKitaNaviRevResTree( const KURL&, int ) ) );
 
     /* write dock */
-    connect( this,SIGNAL( activateThreadView( const KURL& ) ),
-            signalCollection, SIGNAL( activateThreadView( const KURL& ) ) );
-    connect( this,SIGNAL( closeWriteTab( const KURL& ) ),
-            signalCollection, SIGNAL( closeWriteTab( const KURL& ) ) );
-    
+    connect( this, SIGNAL( activateThreadView( const KURL& ) ),
+             signalCollection, SIGNAL( activateThreadView( const KURL& ) ) );
+    connect( this, SIGNAL( closeWriteTab( const KURL& ) ),
+             signalCollection, SIGNAL( closeWriteTab( const KURL& ) ) );
+
 }
 
 
@@ -191,8 +189,8 @@ void KitaHTMLPart::createHTMLDocument()
                     .arg( KitaConfig::threadFont().pointSize() )
                     .arg( KitaConfig::threadFont().family() );
 #if 0
-                    .arg( KitaConfig::threadColor().name() )
-                    .arg( KitaConfig::threadBackgroundColor().name() );
+    .arg( KitaConfig::threadColor().name() )
+    .arg( KitaConfig::threadBackgroundColor().name() );
 #endif
     QString text = "<html><head><style>";
     text += KitaConfig::defaultStyleSheetText();
@@ -232,7 +230,7 @@ const int KitaHTMLPart::getMode() const { return m_mode; }
 /* !!! don't forget to call updateScreen() later !!! */   /* public */
 void KitaHTMLPart::showResponses( int startnum, int endnum )
 {
-    if( !m_domtree ) return;
+    if ( !m_domtree ) return ;
 
     for ( int i = startnum ; i <= endnum; i++ ) m_domtree->appendRes( i, FALSE );
 }
@@ -242,7 +240,7 @@ void KitaHTMLPart::showResponses( int startnum, int endnum )
 /* call showResponses() later  */ /* public */
 void KitaHTMLPart::parseResponses( int startnum, int endnum )
 {
-    if( !m_domtree ) return;
+    if ( !m_domtree ) return ;
 
     for ( int i = startnum ; i <= endnum; i++ ) m_domtree->parseRes( i, i );
 }
@@ -256,13 +254,12 @@ void KitaHTMLPart::parseResponses( int startnum, int endnum )
 /* So, you need not call it later.                */  /* public slot */
 void KitaHTMLPart::showAll()
 {
-    if( !m_domtree ) return;
+    if ( !m_domtree ) return ;
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
     int readNum = Kita::DatManager::getReadNum( m_datURL );
-    if ( top != 1 || bottom != readNum )
-    {
+    if ( top != 1 || bottom != readNum ) {
         showResponses( 1, readNum );
         updateScreen( TRUE, TRUE );
     }
@@ -275,7 +272,7 @@ void KitaHTMLPart::showAll()
 /* !!! don't forget to call updateScreen() later !!! */   /* public */
 void KitaHTMLPart::insertBeltNode( const QString& idstr )
 {
-    if( !m_domtree ) return;
+    if ( !m_domtree ) return ;
 
     m_domtree->createBeltNode( idstr );
 }
@@ -287,7 +284,7 @@ void KitaHTMLPart::insertBeltNode( const QString& idstr )
 /* !!! don't forget to call updateScreen() later !!! */   /* public */
 void KitaHTMLPart::insertHeaderNode( const QString& str )
 {
-    if( !m_domtree ) return;
+    if ( !m_domtree ) return ;
 
     m_domtree->createCommentNode( str, "header", 0, 2, TRUE );
 }
@@ -299,7 +296,7 @@ void KitaHTMLPart::insertHeaderNode( const QString& str )
 /* !!! don't forget to call updateScreen() later !!! */   /* public */
 void KitaHTMLPart::insertFooterNode( const QString& str )
 {
-    if( !m_domtree ) return;
+    if ( !m_domtree ) return ;
 
     m_domtree->createCommentNode( str, "footer", 0, 0, FALSE );
 }
@@ -310,24 +307,21 @@ void KitaHTMLPart::insertFooterNode( const QString& str )
 /* update screen     */ /* public */
 void KitaHTMLPart::updateScreen( bool showHeaderEtc, bool clock )
 {
-    if( !m_domtree )
-    {
-        view()->setFocus();
-        return;
+    if ( !m_domtree ) {
+        view() ->setFocus();
+        return ;
     }
 
     /* show clock cursor */
-    if( clock )
-    {
+    if ( clock ) {
         QCursor qc; qc.setShape( Qt::WaitCursor );
         QApplication::setOverrideCursor( qc );
     }
 
     /* show header, footer, and kokomadeyonda, etc. */
-    if( showHeaderEtc )
-    {
+    if ( showHeaderEtc ) {
 
-        int readNum = Kita::DatManager::getReadNum( m_datURL);
+        int readNum = Kita::DatManager::getReadNum( m_datURL );
 
         m_domtree->appendMae100();
         m_domtree->appendTugi100();
@@ -339,11 +333,11 @@ void KitaHTMLPart::updateScreen( bool showHeaderEtc, bool clock )
 
     /* update display */
     htmlDocument().applyChanges();
-    view()->layout();
-    view()->setVScrollBarMode( QScrollView::AlwaysOn );
-    view()->setFocus();
+    view() ->layout();
+    view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+    view() ->setFocus();
 
-    if(clock) QApplication::restoreOverrideCursor();
+    if ( clock ) QApplication::restoreOverrideCursor();
 }
 
 
@@ -361,8 +355,8 @@ void KitaHTMLPart::setInnerHTML( const QString& innerHTML )
 void KitaHTMLPart::slotRedrawHTMLPart( const KURL& datURL, bool force )
 {
 
-    if( m_domtree == NULL ) return;
-    if( m_datURL != datURL ) return;
+    if ( m_domtree == NULL ) return ;
+    if ( m_datURL != datURL ) return ;
 
     m_domtree->redraw( force );
 }
@@ -370,7 +364,7 @@ void KitaHTMLPart::slotRedrawHTMLPart( const KURL& datURL, bool force )
 /* public slot */
 void KitaHTMLPart::slotRedrawAllHTMLPart( bool force )
 {
-    if( m_domtree == NULL ) return;
+    if ( m_domtree == NULL ) return ;
 
     m_domtree->redraw( force );
 }
@@ -391,20 +385,18 @@ void KitaHTMLPart::slotSetFontOfHTMLPart()
 void KitaHTMLPart::slotSetStyleSheetOfHTMLPart()
 {
     /* [0]<html> -> [1]<head> -> [2]<style> */
-    DOM::HTMLCollection  collection = htmlDocument().all();
-    DOM::HTMLElement     elm;
-    unsigned int         i;
-    for(i = 0 ; i < collection.length() ; i++)
-    {
-        elm = collection.item(i);
-       if(elm.tagName().upper() == "STYLE")
-        {
+    DOM::HTMLCollection collection = htmlDocument().all();
+    DOM::HTMLElement elm;
+    unsigned int i;
+    for ( i = 0 ; i < collection.length() ; i++ ) {
+        elm = collection.item( i );
+        if ( elm.tagName().upper() == "STYLE" ) {
             QString style = QString( "body { font-size: %1pt; font-family: %2; }" )
                             .arg( KitaConfig::threadFont().pointSize() )
                             .arg( KitaConfig::threadFont().family() );
 #if 0
-                            .arg( KitaConfig::threadColor().name() )
-                            .arg( KitaConfig::threadBackgroundColor().name() );
+            .arg( KitaConfig::threadColor().name() )
+            .arg( KitaConfig::threadBackgroundColor().name() );
 #endif
             QString style0 = KitaConfig::defaultStyleSheetText();
             style0 += style;
@@ -414,8 +406,8 @@ void KitaHTMLPart::slotSetStyleSheetOfHTMLPart()
 
             elm.setInnerText( style0 );
             htmlDocument().applyChanges();
-           break;
-       }
+            break;
+        }
     }
 }
 
@@ -430,7 +422,7 @@ void KitaHTMLPart::slotSetStyleSheetOfHTMLPart()
 /*  top = centerNum - preShowNum
     bottom = centerNum + afterShowNum
     readNum = Kita::DatManager::getReadNum
-
     No.1 <- show -> No.20 <- not show -> No.(top) <- show -> No.(bottom) <- not show -> No.(readNum) */
 
 bool KitaHTMLPart::load( int centerNum )
@@ -439,21 +431,21 @@ bool KitaHTMLPart::load( int centerNum )
     /* config */
 
     int showNum = KitaConfig::showNum();
-    if( showNum == 0 ) showNum = 5000;
+    if ( showNum == 0 ) showNum = 5000;
 
     /*--------------------------------*/
     m_centerNum = centerNum;
     m_jumpNumAfterLoading = 0;
 
-    if( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
-    if( !m_domtree ) return FALSE;
-    if( Kita::DatManager::getReadNum( m_datURL ) == 0 ) return FALSE;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
+    if ( !m_domtree ) return FALSE;
+    if ( Kita::DatManager::getReadNum( m_datURL ) == 0 ) return FALSE;
 
     m_domtree->appendTemplate();
     showResponses( m_centerNum - showNum, m_centerNum + showNum );
     updateScreen( TRUE , FALSE );
     gotoAnchor( QString().setNum( m_centerNum ), FALSE );
-    view()->setFocus();
+    view() ->setFocus();
 
     return TRUE;
 }
@@ -473,10 +465,9 @@ bool KitaHTMLPart::reload( int jumpNum )
 
     /*--------------------------------*/
 
-    if( !online ) return FALSE;
-    if( !m_domtree ) return FALSE;
-    if( m_mode != HTMLPART_MODE_MAINPART )
-    {
+    if ( !online ) return FALSE;
+    if ( !m_domtree ) return FALSE;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) {
         /* If this is not MainPart, then open MainPart.  */
         KParts::URLArgs argdummy;
         emit openURLRequest( m_datURL, argdummy );
@@ -485,12 +476,12 @@ bool KitaHTMLPart::reload( int jumpNum )
 
     m_domtree->StopParseThread();
     m_firstReceive = TRUE;
-    if( m_centerNum == 0 ) m_centerNum = m_domtree->getBottomResNumber();
+    if ( m_centerNum == 0 ) m_centerNum = m_domtree->getBottomResNumber();
     m_jumpNumAfterLoading = jumpNum;
 
     /* DatManager will call back slotReceiveData and slotFinishLoad. */
     Kita::DatManager::updateCache( m_datURL , this );
-    view()->setFocus();
+    view() ->setFocus();
 
     return TRUE;
 }
@@ -507,35 +498,31 @@ void KitaHTMLPart::slotReceiveData()
     const int delta = 20;
     const int oneAfterAnother = TRUE;
     int showNum = KitaConfig::showNum();
-    if( showNum == 0 ) showNum = 5000;  /* TODO: fix it. */
+    if ( showNum == 0 ) showNum = 5000;  /* TODO: fix it. */
 
     /*--------------------------------*/
 
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
-    if( !m_domtree ) return;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
+    if ( !m_domtree ) return ;
 
     int readNum = Kita::DatManager::getReadNum( m_datURL );
     int bottom = m_domtree->getBottomResNumber();
     showNum += m_centerNum;
 
     /* parsing */
-    if( oneAfterAnother ) parseResponses( bottom+1, readNum );
+    if ( oneAfterAnother ) parseResponses( bottom + 1, readNum );
 
     /* rendering */
-    if( m_firstReceive
-            || ( bottom + delta < readNum && readNum <= showNum + delta -1 ) )
-    {
+    if ( m_firstReceive
+            || ( bottom + delta < readNum && readNum <= showNum + delta - 1 ) ) {
 
-        if( oneAfterAnother )
-        {
-            showResponses( bottom+1, QMIN( readNum, showNum ) );
+        if ( oneAfterAnother ) {
+            showResponses( bottom + 1, QMIN( readNum, showNum ) );
             updateScreen( TRUE, FALSE );
-        }
-        else parseResponses( bottom+1, QMIN( readNum, showNum ) );
+        } else parseResponses( bottom + 1, QMIN( readNum, showNum ) );
     }
 
-    if( m_firstReceive  && m_centerNum < readNum )
-    {
+    if ( m_firstReceive && m_centerNum < readNum ) {
         gotoAnchor( QString().setNum( m_centerNum ), FALSE );
         m_firstReceive = FALSE;
     }
@@ -552,24 +539,24 @@ void KitaHTMLPart::slotFinishLoad()
 {
     /* config */
     int showNum = KitaConfig::showNum();
-    if( showNum == 0 ) showNum = 5000;  /* TODO: fix it. */
+    if ( showNum == 0 ) showNum = 5000;  /* TODO: fix it. */
 
     /*--------------------------------*/
 
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
-    if( !m_domtree ) return;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
+    if ( !m_domtree ) return ;
 
     int bottom = m_domtree->getBottomResNumber();
     int shownNum = m_centerNum + showNum;
 
-    showResponses(bottom+1, shownNum );
+    showResponses( bottom + 1, shownNum );
     updateScreen( TRUE, FALSE );
     m_domtree->parseAllRes();
     m_centerNum = 0;
 
-    if( m_jumpNumAfterLoading ) gotoAnchor( QString().setNum( m_jumpNumAfterLoading ), FALSE );
+    if ( m_jumpNumAfterLoading ) gotoAnchor( QString().setNum( m_jumpNumAfterLoading ), FALSE );
     m_jumpNumAfterLoading = 0;
-    
+
     emit finishReload();
 }
 
@@ -584,8 +571,8 @@ void KitaHTMLPart::slotFinishLoad()
 /* public */
 bool KitaHTMLPart::gotoAnchor( const QString& anc, bool pushPosition )
 {
-    if( anc == QString::null ) return FALSE;
-    if( !m_domtree || m_mode == HTMLPART_MODE_KHTML || m_mode == HTMLPART_MODE_POPUP )
+    if ( anc == QString::null ) return FALSE;
+    if ( !m_domtree || m_mode == HTMLPART_MODE_KHTML || m_mode == HTMLPART_MODE_POPUP )
         return KHTMLPart::gotoAnchor( anc );
 
     hidePopup();
@@ -593,28 +580,23 @@ bool KitaHTMLPart::gotoAnchor( const QString& anc, bool pushPosition )
     QString ancstr = anc;
     int res = ancstr.toInt();
 
-    if ( res > 1 )
-    {
+    if ( res > 1 ) {
 
         /* is target valid ? */
         if ( !Kita::DatManager::isResValid( m_datURL, res ) ) return FALSE;
 
         /* show res if it is not shown */
-        if ( !m_domtree->isResShown( res ) )
-        {
+        if ( !m_domtree->isResShown( res ) ) {
 
-            if( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
+            if ( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
 
             int top = m_domtree->getTopResNumber();
             int bottom = m_domtree->getBottomResNumber();
 
-            if ( res > bottom )
-            {
+            if ( res > bottom ) {
                 showResponses( bottom + 1, res );
                 updateScreen( TRUE, TRUE );
-            }
-            else if ( res < top )
-            {
+            } else if ( res < top ) {
                 m_domtree->appendTemplate();
                 showResponses( res, bottom );
                 updateScreen( TRUE , TRUE );
@@ -637,8 +619,8 @@ bool KitaHTMLPart::gotoAnchor( const QString& anc, bool pushPosition )
 /* jump to kokomade yonda */ /* public slot */
 void KitaHTMLPart::slotGotoKokoyon()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int kokoyon = Kita::DatManager::getKokoyonNum( m_datURL );
     gotoAnchor( QString().setNum( kokoyon ), FALSE );
@@ -649,7 +631,7 @@ void KitaHTMLPart::slotGotoKokoyon()
 /* public slot  */
 void KitaHTMLPart::slotGobackAnchor()
 {
-    if ( m_anchorStack.empty() ) return;
+    if ( m_anchorStack.empty() ) return ;
 
     QString anc = m_anchorStack.last();
     m_anchorStack.pop_back();
@@ -686,14 +668,13 @@ void KitaHTMLPart::pushCurrentPosition()
 /* public slot */
 void KitaHTMLPart::slotClickTugi100()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int bottom = m_domtree->getBottomResNumber();
     int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( readNum != bottom )
-    {
+    if ( readNum != bottom ) {
         showResponses( bottom + 1, bottom + 100 );
         updateScreen( TRUE, TRUE );
     }
@@ -704,14 +685,13 @@ void KitaHTMLPart::slotClickTugi100()
 /* public slot */
 void KitaHTMLPart::slotClickNokori()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int bottom = m_domtree->getBottomResNumber();
     int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( readNum != bottom )
-    {
+    if ( readNum != bottom ) {
         showResponses( bottom + 1, readNum );
         updateScreen( TRUE, TRUE );
     }
@@ -721,19 +701,17 @@ void KitaHTMLPart::slotClickNokori()
 /* public slot */
 void KitaHTMLPart::slotClickGotoFooter()
 {
-    if( !m_domtree
+    if ( !m_domtree
             || m_mode != HTMLPART_MODE_MAINPART
-      )
-    {
+       ) {
         gotoAnchor( "footer", FALSE );
-        return;
+        return ;
     }
 
     int bottom = m_domtree->getBottomResNumber();
     int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( readNum != bottom )
-    {
+    if ( readNum != bottom ) {
         showResponses( bottom + 1, readNum );
         updateScreen( TRUE, TRUE );
     }
@@ -746,14 +724,13 @@ void KitaHTMLPart::slotClickGotoFooter()
 /* public slot */
 void KitaHTMLPart::slotClickMae100()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
 
-    if ( top != 1 )
-    {
+    if ( top != 1 ) {
         m_domtree->appendTemplate();
         showResponses( top - 100, bottom );
         updateScreen( TRUE, TRUE );
@@ -767,16 +744,15 @@ void KitaHTMLPart::slotClickMae100()
 /* public slot */
 void KitaHTMLPart::slotClickMaeZenbu()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
 
-    if ( top != 1 )
-    {
+    if ( top != 1 ) {
         showResponses( 1, bottom );
-        updateScreen( TRUE, TRUE);
+        updateScreen( TRUE, TRUE );
 
         gotoAnchor( QString().setNum( top ), FALSE );
     }
@@ -786,15 +762,14 @@ void KitaHTMLPart::slotClickMaeZenbu()
 /* public slot */
 void KitaHTMLPart::slotClickTmpNext100()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
     int tmpnum = m_domtree->getTemplateNumber();
 
-    if ( tmpnum < top )
-    {
+    if ( tmpnum < top ) {
         m_domtree->setTemplateNumber( tmpnum + 100 );
         m_domtree->appendTemplate();
         showResponses( top, bottom );
@@ -808,15 +783,14 @@ void KitaHTMLPart::slotClickTmpNext100()
 /* public slot */
 void KitaHTMLPart::slotClickShowAll()
 {
-    if( !m_domtree ) return;
-    if( m_mode != HTMLPART_MODE_MAINPART ) return;
+    if ( !m_domtree ) return ;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return ;
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
     int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( top != 1 || bottom != readNum )
-    {
+    if ( top != 1 || bottom != readNum ) {
         showResponses( 1, readNum );
         updateScreen( TRUE, TRUE );
 
@@ -847,32 +821,28 @@ void KitaHTMLPart::findTextInit()
 /* public */
 bool KitaHTMLPart::findText( const QString &query, bool reverse )
 {
-    if( m_mode != HTMLPART_MODE_MAINPART && m_mode != HTMLPART_MODE_NAVI ) return FALSE;
+    if ( m_mode != HTMLPART_MODE_MAINPART && m_mode != HTMLPART_MODE_NAVI ) return FALSE;
 
     QRegExp regexp( query );
     regexp.setCaseSensitive( FALSE );
 
     /* init */
-    if ( m_findNode.isNull() )
-    {
+    if ( m_findNode.isNull() ) {
 
         m_findNode = htmlDocument().body();
         m_find_y = 0;
 
         /* move to the last child node */
-        if ( reverse )
-        {
+        if ( reverse ) {
             while ( !m_findNode.lastChild().isNull() ) m_findNode = m_findNode.lastChild();
-            m_find_y = view()->contentsHeight();
+            m_find_y = view() ->contentsHeight();
         }
     }
 
-    while ( 1 )
-    {
+    while ( 1 ) {
 
         if ( m_findNode.nodeType() == DOM::Node::TEXT_NODE
-                || m_findNode.nodeType() == DOM::Node::CDATA_SECTION_NODE )
-        {
+                || m_findNode.nodeType() == DOM::Node::CDATA_SECTION_NODE ) {
 
             /* find the word in the current node */
             DOM::DOMString nodeText = m_findNode.nodeValue();
@@ -883,13 +853,12 @@ bool KitaHTMLPart::findText( const QString &query, bool reverse )
             else m_findPos = nodestr.find( regexp, m_findPos + 1 );
 
             /* scroll & select & return */
-            if ( m_findPos != -1 )
-            {
+            if ( m_findPos != -1 ) {
 
                 int matchLen = regexp.matchedLength();
 
                 QRect qr = m_findNode.getRect();
-                view()->setContentsPos( qr.left() - 50, m_find_y - 100 );
+                view() ->setContentsPos( qr.left() - 50, m_find_y - 100 );
                 DOM::Range rg( m_findNode, m_findPos, m_findNode, m_findPos + matchLen );
                 setSelection( rg );
 
@@ -899,31 +868,28 @@ bool KitaHTMLPart::findText( const QString &query, bool reverse )
         }
 
         /*------------------------*/
-        else if ( m_findNode.nodeName().string() == "table" )
-        {
+        else if ( m_findNode.nodeName().string() == "table" ) {
 
             QRect qr = m_findNode.getRect();
 
             m_find_y = qr.bottom();
         }
 
-        /*------------------------*/   
-        else if ( m_findNode.nodeName().string() == "div" ){
-           
+        /*------------------------*/
+        else if ( m_findNode.nodeName().string() == "div" ) {
+
             QRect qr = m_findNode.getRect();
 
             if ( reverse ) m_find_y = qr.bottom();
             else m_find_y = qr.top();
-       }
+        }
 
         /*------------------------*/
-        else if ( m_findNode.nodeName().string() == "br" )
-        {
+        else if ( m_findNode.nodeName().string() == "br" ) {
 
             DOM::Node tmpnode = m_findNode.previousSibling();
 
-            if ( tmpnode != NULL )
-            {
+            if ( tmpnode != NULL ) {
 
                 QRect qr = tmpnode.getRect();
                 if ( reverse ) m_find_y -= qr.bottom() - qr.top();
@@ -937,35 +903,30 @@ bool KitaHTMLPart::findText( const QString &query, bool reverse )
         DOM::Node next;
 
         /* move to the next node */
-        if ( !reverse )
-        {
+        if ( !reverse ) {
 
             next = m_findNode.firstChild();
             if ( next.isNull() ) next = m_findNode.nextSibling();
 
-            while ( !m_findNode.isNull() && next.isNull() )
-            {
+            while ( !m_findNode.isNull() && next.isNull() ) {
                 m_findNode = m_findNode.parentNode();
                 if ( !m_findNode.isNull() ) next = m_findNode.nextSibling();
             }
         }
         /* revearse */
-        else
-        {
+        else {
 
             next = m_findNode.lastChild();
             if ( next.isNull() ) next = m_findNode.previousSibling();
 
-            while ( !m_findNode.isNull() && next.isNull() )
-            {
+            while ( !m_findNode.isNull() && next.isNull() ) {
                 m_findNode = m_findNode.parentNode();
                 if ( !m_findNode.isNull() ) next = m_findNode.previousSibling();
             }
         }
 
         m_findNode = next;
-        if ( m_findNode.isNull() )
-        {
+        if ( m_findNode.isNull() ) {
             m_findNode = NULL;
             return FALSE;
         }
@@ -1012,7 +973,7 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
     QString str;
 
     /* If selected Text is composed of only digits, then show res popup. */
-    if( !m_pushctrl && showSelectedDigitPopup() ) return;
+    if ( !m_pushctrl && showSelectedDigitPopup() ) return ;
 
     /*-----------------------------------*/
     /* create menu items                 */
@@ -1026,24 +987,21 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
     /*------*/
     /* jump */
-    if( m_domtree &&
-            (m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) )
-    {
+    if ( m_domtree &&
+            ( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) ) {
 
         showppm = TRUE;
 
         /* back */
-        if ( !m_anchorStack.empty() )
-        {
+        if ( !m_anchorStack.empty() ) {
             backSubMenu = new KPopupMenu( view() );
             backSubMenu->clear();
 
             int i = m_anchorStack.size();
             QStringList::iterator it;
-            for ( it = m_anchorStack.begin(); it != m_anchorStack.end(); it++,i-- )
-            {
-                str = (*it) + "   " + Kita::DatManager::getPlainBody( m_datURL, (*it).toInt() ).left( 10 );
-                backSubMenu->insertItem( str, ID_Back_Link +(i-1), 0 );
+            for ( it = m_anchorStack.begin(); it != m_anchorStack.end(); it++, i-- ) {
+                str = ( *it ) + "   " + Kita::DatManager::getPlainBody( m_datURL, ( *it ).toInt() ).left( 10 );
+                backSubMenu->insertItem( str, ID_Back_Link + ( i - 1 ), 0 );
             }
 
             popupMenu->insertItem( i18n( "Back" ), backSubMenu );
@@ -1052,14 +1010,11 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
         /* mark */
         /* !! very dangerous to call DatManager::getDatInfoPointer without locking !! */
-        Kita::DatManager::lock( m_datURL );
+        Kita::DatManager::lock ( m_datURL );
         Kita::DatInfo* datInfo = Kita::DatManager::getDatInfoPointer( m_datURL );
-        for( int i = 1; i <= datInfo->getReadNum() ; i++ )
-        {
-            if( datInfo->isMarked( i ) )
-            {
-                if( !markSubMenu )
-                {
+        for ( int i = 1; i <= datInfo->getReadNum() ; i++ ) {
+            if ( datInfo->isMarked( i ) ) {
+                if ( !markSubMenu ) {
                     markSubMenu = new KPopupMenu( view() );
                     markSubMenu->clear();
                     popupMenu->insertItem( i18n( "Mark" ), markSubMenu );
@@ -1077,14 +1032,12 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
 
         /* template */
-        if ( m_mode == HTMLPART_MODE_MAINPART )
-        {
+        if ( m_mode == HTMLPART_MODE_MAINPART ) {
 
-            if( m_domtree->isMae100Shown() ) popupMenu->insertItem( i18n( "template" ), ID_Temp_Link );
+            if ( m_domtree->isMae100Shown() ) popupMenu->insertItem( i18n( "template" ), ID_Temp_Link );
 
             int kokoyon = Kita::DatManager::getKokoyonNum( m_datURL );
-            if( kokoyon )
-            {
+            if ( kokoyon ) {
                 str = i18n( "Kokomade Yonda (%1)" ).arg( kokoyon );
                 popupMenu->insertItem( str, ID_Koko_Link );
             }
@@ -1092,15 +1045,14 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
 
         /* end */
-        popupMenu->insertItem( i18n("End"), ID_End_Link );
+        popupMenu->insertItem( i18n( "End" ), ID_End_Link );
     }
 
 
     /*--------------*/
     /* copy & abone */
-    if ( hasSelection() )
-    {
-        if( showppm ) popupMenu->insertSeparator();
+    if ( hasSelection() ) {
+        if ( showppm ) popupMenu->insertSeparator();
         showppm = TRUE;
 
         popupMenu->insertItem( "Copy", ID_Copy_Str );
@@ -1113,9 +1065,8 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
     /*-----------*/
     /* copy link */
-    if ( url != QString::null )
-    {
-        if( showppm ) popupMenu->insertSeparator();
+    if ( url != QString::null ) {
+        if ( showppm ) popupMenu->insertSeparator();
         showppm = TRUE;
 
         popupMenu->insertItem( i18n( "Open with Web Browser" ), ID_Open_Browser );
@@ -1127,15 +1078,13 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
     /*-----------------------------------*/
 
     /* show menu */
-    if( showppm )
-    {
+    if ( showppm ) {
 
-        QClipboard* clipboard = QApplication::clipboard();
+        QClipboard * clipboard = QApplication::clipboard();
         KParts::URLArgs argdummy;
 
         int ret = popupMenu->exec( point );
-        switch ( ret  )
-        {
+        switch ( ret ) {
 
         case ID_COPY_Link:
             clipboard->setText( url , QClipboard::Clipboard );
@@ -1152,7 +1101,7 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
         case ID_Koko_Link: slotGotoKokoyon(); break;
 
-        case ID_End_Link:  slotClickGotoFooter(); break;
+        case ID_End_Link: slotClickGotoFooter(); break;
 
         case ID_Copy_Str:
             clipboard->setText( selectedText(), QClipboard::Clipboard );
@@ -1160,11 +1109,10 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
         case ID_Abone_Word:
 
-            if ( QMessageBox::information( view(),"Kita",
+            if ( QMessageBox::information( view(), "Kita",
                                            i18n( "Do you want to add '%1' to abone list ?" ).arg( selectedText() ),
                                            QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
-                    == QMessageBox::Ok )
-            {
+                    == QMessageBox::Ok ) {
 
                 KitaConfig::addAboneWord( selectedText() );
                 emit redrawHTMLPart( m_datURL, FALSE );
@@ -1173,13 +1121,12 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
             break;
 
         case ID_Extract:
-           emit showKitaNaviByWord( m_datURL, selectedText() );
+            emit showKitaNaviByWord( m_datURL, selectedText() );
             break;
 
-        case ID_Search_Google:
-            {
+        case ID_Search_Google: {
                 QString google_url = QString( "http://www.google.com/search?ie=UTF-8&q=%1" ).arg(
-                 KURL::encode_string( selectedText(), 106 ) ); // TODO: don't use magic number.
+                                         KURL::encode_string( selectedText(), 106 ) ); // TODO: don't use magic number.
                 // 106 == UTF-8
                 emit openURLRequest( google_url, argdummy );
             }
@@ -1188,15 +1135,13 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
         default:
 
             /* mark */
-            if( ret >= ID_Goto_Mark )
-            {
+            if ( ret >= ID_Goto_Mark ) {
                 gotoAnchor( QString().setNum( ret - ID_Goto_Mark ), FALSE );
             }
 
             /* back */
-            else if( ret >= ID_Back_Link )
-            {
-                for(int i = 0; i < ret - ID_Back_Link; i++ ) m_anchorStack.pop_back();
+            else if ( ret >= ID_Back_Link ) {
+                for ( int i = 0; i < ret - ID_Back_Link; i++ ) m_anchorStack.pop_back();
                 slotGobackAnchor();
             }
 
@@ -1205,9 +1150,9 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
     }
 
-    if( popupMenu ) delete popupMenu;
-    if( backSubMenu ) delete backSubMenu;
-    if( markSubMenu ) delete markSubMenu;
+    if ( popupMenu ) delete popupMenu;
+    if ( backSubMenu ) delete backSubMenu;
+    if ( markSubMenu ) delete markSubMenu;
 }
 
 
@@ -1221,36 +1166,33 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 void KitaHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent* e )
 {
     emit mousePressed(); /* to KitaThreadView to focus this view. */
-    
+
     KURL kurl;
-    if( e->url().string() != QString::null )
+    if ( e->url().string() != QString::null )
         kurl = KURL( Kita::DatManager::boardURL( m_datURL ), e->url().string() );
 
     m_pushctrl = m_pushmidbt = m_pushrightbt = FALSE;
-    if(e->qmouseEvent()->button() & Qt::RightButton) m_pushrightbt = TRUE;
+    if ( e->qmouseEvent() ->button() & Qt::RightButton ) m_pushrightbt = TRUE;
     if ( e->qmouseEvent() ->state() & Qt::ControlButton ) m_pushctrl = TRUE;
     if ( e->qmouseEvent() ->button() & Qt::MidButton ) m_pushmidbt = TRUE;
 
-    if ( e->url() != NULL )
-    {
+    if ( e->url() != NULL ) {
 
-        if ( e->url().string().at( 0 ) == '#' )
-        { /* anchor */
-            kurl =  m_datURL;
-            kurl.setRef( e->url().string().mid(1) ) ;
+        if ( e->url().string().at( 0 ) == '#' ) { /* anchor */
+            kurl = m_datURL;
+            kurl.setRef( e->url().string().mid( 1 ) ) ;
         }
 
         clickAnchor( kurl );
         m_pushctrl = m_pushmidbt = m_pushrightbt = FALSE;
-        return;
+        return ;
     }
 
     /* popup menu */
-    if( m_pushrightbt )
-    {
+    if ( m_pushrightbt ) {
         showPopupMenu( kurl );
         m_pushctrl = m_pushmidbt = m_pushrightbt = FALSE;
-        return;
+        return ;
     }
 
     KHTMLPart::khtmlMousePressEvent( e );
@@ -1269,7 +1211,7 @@ void KitaHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent* e )
 /* private slot */
 void KitaHTMLPart::slotOpenURLRequest( const KURL& urlin, const KParts::URLArgs& )
 {
-    clickAnchor(urlin);
+    clickAnchor( urlin );
 }
 
 
@@ -1278,30 +1220,27 @@ void KitaHTMLPart::slotOpenURLRequest( const KURL& urlin, const KParts::URLArgs&
 void KitaHTMLPart::clickAnchor( const KURL& urlin )
 {
     QString refstr;
-    KURL datURL = Kita::ParseMisc::parseURL( urlin ,refstr );
+    KURL datURL = Kita::ParseMisc::parseURL( urlin , refstr );
 
     /*--------------------*/
     /* Ctrl + right click */
-    if( m_pushctrl && m_pushrightbt )
-    {
+    if ( m_pushctrl && m_pushrightbt ) {
         showPopupMenu( urlin );
-        return;
+        return ;
     }
 
     /*--------------------------------*/
     /* If this is not anchor, then    */
     /* emit openURLRequest and return */
 
-    if ( datURL.host() != m_datURL.host() || datURL.path() != m_datURL.path() )
-    {
+    if ( datURL.host() != m_datURL.host() || datURL.path() != m_datURL.path() ) {
 
-        if( m_pushrightbt )
-        { /* right click */
+        if ( m_pushrightbt ) { /* right click */
 
             /* start multi-popup mode or show popup menu */
-            if( !startMultiPopup() ) showPopupMenu( urlin );
+            if ( !startMultiPopup() ) showPopupMenu( urlin );
 
-            return;
+            return ;
         }
 
         KParts::URLArgs argdummy;
@@ -1314,55 +1253,49 @@ void KitaHTMLPart::clickAnchor( const KURL& urlin )
     /*---------------------------*/
     /* show popupmenu for #write */
 
-    if ( refstr.left( 5 ) == "write" )
-    {
+    if ( refstr.left( 5 ) == "write" ) {
         showWritePopupMenu( refstr );
-        return;
+        return ;
     }
 
     /*----------------------------*/
     /* extract responses by ID    */
 
-    if( refstr.left(5) == "idpop")
-    {
+    if ( refstr.left( 5 ) == "idpop" ) {
         showIDPopup( refstr );
-        return;
+        return ;
     }
 
     /*-------------------------*/
     /* start multi-popup mdde  */
-    if( m_pushrightbt && startMultiPopup() ) return;
+    if ( m_pushrightbt && startMultiPopup() ) return ;
 
 
     /*----------------------------*/
     /* next 100 ,before 100 ,etc. */
-    if( showNext100Etc( refstr ) ) return;
+    if ( showNext100Etc( refstr ) ) return ;
 
 
     /*-------------------------------*/
     /* open Kita Navi or goto anchor */
 
-    int refNum,refNum2;
+    int refNum, refNum2;
 
     int i = refstr.find( "-" );
-    if ( i != -1 )
-    {
+    if ( i != -1 ) {
         refNum = refstr.left( i ).toInt();
-        refNum2 = refstr.mid(i+1).toInt();
-        if( refNum2 < refNum ) refNum2 = refNum;
-    }
-    else refNum = refNum2 = refstr.toInt();
+        refNum2 = refstr.mid( i + 1 ).toInt();
+        if ( refNum2 < refNum ) refNum2 = refNum;
+    } else refNum = refNum2 = refstr.toInt();
 
     if ( !refNum ) return ;
 
-    if( m_pushctrl || m_pushmidbt ) emit showKitaNavi( m_datURL, refNum, refNum2 );
-    else if( ( m_mode == HTMLPART_MODE_KHTML || m_mode == HTMLPART_MODE_POPUP )
-             || ( m_mode == HTMLPART_MODE_NAVI && !m_domtree->isResShown( refNum ) ) )
-    {
+    if ( m_pushctrl || m_pushmidbt ) emit showKitaNavi( m_datURL, refNum, refNum2 );
+    else if ( ( m_mode == HTMLPART_MODE_KHTML || m_mode == HTMLPART_MODE_POPUP )
+              || ( m_mode == HTMLPART_MODE_NAVI && !m_domtree->isResShown( refNum ) ) ) {
         KParts::URLArgs argdummy;
         emit openURLRequest( urlin, argdummy );
-    }
-    else gotoAnchor( QString().setNum( refNum ), TRUE );
+    } else gotoAnchor( QString().setNum( refNum ), TRUE );
 }
 
 
@@ -1370,7 +1303,7 @@ void KitaHTMLPart::clickAnchor( const KURL& urlin )
 /*---------------------------------------------------------*/
 /* popup menu that is opened when user clicked res number. */
 /* This funtcion is called in only clickAnchor().          */ /* private */
-void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
+void KitaHTMLPart::showWritePopupMenu( const QString& refstr )
 {
     enum{
         WRITEMENU_RES,
@@ -1394,23 +1327,21 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
     QString namestr = Kita::DatManager::getPlainName( m_datURL, resNum );
 
     /* show res tree */
-    if( m_pushrightbt )
-    {
+    if ( m_pushrightbt ) {
         int num;
         QString htmlstr = Kita::DatManager::getTreeByRes( m_datURL, resNum, num );
         if ( !num ) return ;
-        QString tmpstr = QString("<DIV>No.%1 : [%2]<BR>").arg( resNum ).arg( num );
+        QString tmpstr = QString( "<DIV>No.%1 : [%2]<BR>" ).arg( resNum ).arg( num );
         tmpstr += htmlstr + "<BR><BR></DIV>";
         showPopup( m_datURL, tmpstr );
         startMultiPopup();
-        return;
+        return ;
     }
 
     /* open kitanavi */
-    else if( m_pushctrl | m_pushmidbt )
-    {
-       emit showKitaNaviResTree(m_datURL,resNum);
-        return;
+    else if ( m_pushctrl | m_pushmidbt ) {
+        emit showKitaNaviResTree( m_datURL, resNum );
+        return ;
     }
 
     /*---------------------*/
@@ -1421,8 +1352,7 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
     popupMenu->clear();
 
     /* write */
-    if( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI )
-    {
+    if ( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) {
 
         popupMenu->insertItem( i18n( "write response" ), WRITEMENU_RES );
         popupMenu->insertItem( i18n( "quote this" ), WRITEMENU_QUOTE );
@@ -1452,8 +1382,7 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
     popupMenu->insertItem( i18n( "copy" ), WRITEMENU_COPY );
 
     /* kokkoma de yonda */
-    if( m_domtree && m_mode == HTMLPART_MODE_MAINPART )
-    {
+    if ( m_domtree && m_mode == HTMLPART_MODE_MAINPART ) {
         popupMenu->insertSeparator();
         popupMenu->insertItem( i18n( "set Kokomade Yonda" ), WRITEMENU_SETKOKOYON );
     }
@@ -1468,8 +1397,7 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
 
     int ret = popupMenu->exec( QCursor::pos() );
     delete popupMenu;
-    switch ( ret )
-    {
+    switch ( ret ) {
 
     case WRITEMENU_RES:
         resstr = ">>" + QString().setNum( resNum ) + "\n";
@@ -1479,7 +1407,7 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
     case WRITEMENU_QUOTE:
         resstr = ">>" + QString().setNum( resNum ) + "\n"
                  + "> " + Kita::DatManager::getPlainTitle( m_datURL, resNum ) + "\n"
-                 + "> " + Kita::DatManager::getPlainBody( m_datURL, resNum ).replace("\n","\n> ") + "\n";
+                 + "> " + Kita::DatManager::getPlainBody( m_datURL, resNum ).replace( "\n", "\n> " ) + "\n";
         emit openWriteDialog( resstr );
         break;
 
@@ -1493,18 +1421,16 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
         str = QString::null;
 
         /* title */
-        if( ret == WRITEMENU_COPYTHREADNAME || ret == WRITEMENU_COPY )
-        {
+        if ( ret == WRITEMENU_COPYTHREADNAME || ret == WRITEMENU_COPY ) {
             str = Kita::DatManager::threadName( m_datURL );
         }
 
         /* url */
-        if( str != QString::null ) str += "\n";
+        if ( str != QString::null ) str += "\n";
         str += Kita::DatManager::threadURL( m_datURL ) + QString().setNum( resNum ) + "\n";
 
         /* body */
-        if( ret == WRITEMENU_COPY )
-        {
+        if ( ret == WRITEMENU_COPY ) {
             str += "\n"
                    + Kita::DatManager::getPlainTitle( m_datURL, resNum ) + "\n"
                    + Kita::DatManager::getPlainBody( m_datURL, resNum ) + "\n";
@@ -1532,28 +1458,27 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
 
 
     case WRITEMENU_SHOWNAVI:
-       emit showKitaNavi( m_datURL, resNum, resNum);
+        emit showKitaNavi( m_datURL, resNum, resNum );
         break;
 
 
     case WRITEMENU_RESTREE:
-       emit showKitaNaviResTree( m_datURL, resNum);
+        emit showKitaNaviResTree( m_datURL, resNum );
         break;
 
     case WRITEMENU_REVERSERESTREE:
-       emit showKitaNaviRevResTree( m_datURL, resNum );
+        emit showKitaNaviRevResTree( m_datURL, resNum );
         break;
 
     case WRITEMENU_EXTRACTNAME:
-       emit showKitaNaviByName( m_datURL, namestr );
+        emit showKitaNaviByName( m_datURL, namestr );
         break;
 
     case WRITEMENU_ABONENAME:
-        if ( QMessageBox::information( view(),"Kita",
+        if ( QMessageBox::information( view(), "Kita",
                                        i18n( "Do you want to add '%1' to abone list ?" ).arg( namestr ),
                                        QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
-                == QMessageBox::Ok )
-        {
+                == QMessageBox::Ok ) {
 
             KitaConfig::addAboneName( namestr );
             emit redrawHTMLPart( m_datURL, FALSE );
@@ -1573,28 +1498,26 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
 /* This funtcion is called in only clickAnchor().   */ /* private */
 void KitaHTMLPart::showIDPopup( const QString& refstr )
 {
-    QString strid = refstr.mid(5)
-                    .replace("%2B","+")   /* decode %2B -> + */
-                    .replace("%2F", "/"); /* decode %2F -> / */
+    QString strid = refstr.mid( 5 )
+                    .replace( "%2B", "+" )    /* decode %2B -> + */
+                    .replace( "%2F", "/" ); /* decode %2F -> / */
 
     /* popup */
-    if( m_pushrightbt )
-    {
+    if ( m_pushrightbt ) {
         int num;
         QString htmlstr
         = Kita::DatManager::getHtmlByID( m_datURL, strid, num );
         if ( num <= 1 ) return ;
-        QString tmpstr = QString("<DIV>ID:%1:[%2]<BR>").arg( strid ).arg( num );
+        QString tmpstr = QString( "<DIV>ID:%1:[%2]<BR>" ).arg( strid ).arg( num );
         tmpstr += htmlstr + "<BR><BR></DIV>";
         showPopup( m_datURL, tmpstr );
         startMultiPopup();
     }
 
     /* open kitanavi when user pushed Ctrl+Left or Mid button. */
-    else if( m_pushctrl | m_pushmidbt ) emit showKitaNaviByID( m_datURL, strid );
+    else if ( m_pushctrl | m_pushmidbt ) emit showKitaNaviByID( m_datURL, strid );
 
-    else
-    {
+    else {
 
         enum{
             IDMENU_EXTRACT,
@@ -1603,25 +1526,23 @@ void KitaHTMLPart::showIDPopup( const QString& refstr )
 
         KPopupMenu *popupMenu = new KPopupMenu( view() );
         popupMenu->clear();
-        if( Kita::DatManager::getNumByID( m_datURL, strid ) > 1 )
+        if ( Kita::DatManager::getNumByID( m_datURL, strid ) > 1 )
             popupMenu->insertItem( i18n( "extract by ID" ), IDMENU_EXTRACT );
         popupMenu->insertItem( i18n( "add id to abone list" ), IDMENU_ABONE );
         int ret = popupMenu->exec( QCursor::pos() );
         delete popupMenu;
-        switch ( ret  )
-        {
+        switch ( ret ) {
 
         case IDMENU_EXTRACT:
-           emit showKitaNaviByID( m_datURL, strid );
+            emit showKitaNaviByID( m_datURL, strid );
             break;
 
         case IDMENU_ABONE:
             /* add ID to abone list */
-            if ( QMessageBox::information( view(),"Kita",
+            if ( QMessageBox::information( view(), "Kita",
                                            i18n( "Do you want to add '%1' to abone list ?" ).arg( strid ),
                                            QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
-                    == QMessageBox::Ok )
-            {
+                    == QMessageBox::Ok ) {
 
                 KitaConfig::addAboneID( strid );
                 emit redrawHTMLPart( m_datURL, FALSE );
@@ -1641,46 +1562,33 @@ void KitaHTMLPart::showIDPopup( const QString& refstr )
 /* This funtcion is called in only clickAnchor().        */ /* private */
 bool KitaHTMLPart::showNext100Etc( const QString& refstr )
 {
-    if( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
+    if ( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
 
-    if ( refstr.left( 7 ) == "tugi100" )
-    {
+    if ( refstr.left( 7 ) == "tugi100" ) {
         slotClickTugi100();
         return TRUE;
 
-    }
-    else if ( refstr.left( 6 ) == "nokori" )
-    {
+    } else if ( refstr.left( 6 ) == "nokori" ) {
         slotClickNokori();
         return TRUE;
 
-    }
-    else if ( refstr.left( 7 ) == "tosaigo" )
-    {
+    } else if ( refstr.left( 7 ) == "tosaigo" ) {
         slotClickGotoFooter();
         return TRUE;
 
-    }
-    else if ( refstr.left( 6 ) == "mae100" )
-    {
+    } else if ( refstr.left( 6 ) == "mae100" ) {
         slotClickMae100();
         return TRUE;
 
-    }
-    else if ( refstr.left( 8 ) == "maezenbu" )
-    {
+    } else if ( refstr.left( 8 ) == "maezenbu" ) {
         slotClickMaeZenbu();
         return TRUE;
 
-    }
-    else if ( refstr.left( 6 ) == "tmp100" )
-    {
+    } else if ( refstr.left( 6 ) == "tmp100" ) {
         slotClickTmpNext100();
         return TRUE;
 
-    }
-    else if ( refstr.left( 5 ) == "zenbu" )
-    {
+    } else if ( refstr.left( 5 ) == "zenbu" ) {
         slotClickShowAll();
         return TRUE;
     }
@@ -1716,7 +1624,7 @@ void KitaHTMLPart::slotDeletePopup()
 void KitaHTMLPart::slotShowResPopup( QPoint point, int refNum, int refNum2 )
 {
     QString innerHTML = Kita::DatManager::getHtml( m_datURL, refNum, refNum2 );
-    if ( innerHTML == QString::null ) return;
+    if ( innerHTML == QString::null ) return ;
 
     showPopupCore( m_datURL, innerHTML, point );
 }
@@ -1737,7 +1645,7 @@ void KitaHTMLPart::showPopupCore( const KURL& url, const QString& innerHTML, QPo
 
     m_popup = new Kita::ResPopup( view() , url );
 
-    connect( m_popup, SIGNAL( hideChildPopup() ),SLOT( slotHideChildPopup() ) );
+    connect( m_popup, SIGNAL( hideChildPopup() ), SLOT( slotHideChildPopup() ) );
 
     m_popup->setText( innerHTML );
     m_popup->adjustSize();
@@ -1751,12 +1659,10 @@ void KitaHTMLPart::showPopupCore( const KURL& url, const QString& innerHTML, QPo
 bool KitaHTMLPart::startMultiPopup()
 {
 
-    if( m_popup && m_popup->isVisible() )
-    {
+    if ( m_popup && m_popup->isVisible() ) {
         m_multiPopup = TRUE;
         m_popup->moveMouseAbove();
-    }
-    else m_multiPopup = FALSE;
+    } else m_multiPopup = FALSE;
 
     return m_multiPopup;
 }
@@ -1765,8 +1671,8 @@ bool KitaHTMLPart::startMultiPopup()
 /* Is it multi-popup mode now ? */ /* private */
 bool KitaHTMLPart::isMultiPopupMode()
 {
-    if( !m_popup ) m_multiPopup = FALSE;
-    else if( m_popup->isHidden() ) m_multiPopup = FALSE;
+    if ( !m_popup ) m_multiPopup = FALSE;
+    else if ( m_popup->isHidden() ) m_multiPopup = FALSE;
 
     return m_multiPopup;
 }
@@ -1775,7 +1681,7 @@ bool KitaHTMLPart::isMultiPopupMode()
 /* private */
 void KitaHTMLPart::hidePopup()
 {
-    if( m_popup ) m_popup->hide();
+    if ( m_popup ) m_popup->hide();
     m_multiPopup = FALSE;
 }
 
@@ -1787,13 +1693,12 @@ bool KitaHTMLPart::isUnderMouse( int mrgwd, int mrght )
     QPoint pos = QCursor::pos();
     int cx = pos.x(), cy = pos.y();
 
-    QPoint viewpos = view()->mapToGlobal( QPoint(0,0) );
+    QPoint viewpos = view() ->mapToGlobal( QPoint( 0, 0 ) );
     int px = viewpos.x(), py = viewpos.y();
-    int wd = view()->visibleWidth(), ht = view()->visibleHeight();
+    int wd = view() ->visibleWidth(), ht = view() ->visibleHeight();
 
-    if( ( px < cx && cx < px + wd + mrgwd )
-            && ( py  < cy && cy < py + ht + mrght  ) )
-    {
+    if ( ( px < cx && cx < px + wd + mrgwd )
+            && ( py < cy && cy < py + ht + mrght ) ) {
         return TRUE;
     }
 
@@ -1804,14 +1709,14 @@ bool KitaHTMLPart::isUnderMouse( int mrgwd, int mrght )
 /* private slot */
 void KitaHTMLPart::slotLeave()
 {
-    if ( isMultiPopupMode() ) return;
-    if( view()->isHorizontalSliderPressed() ) return;
-    if( view()->isVerticalSliderPressed () ) return;
+    if ( isMultiPopupMode() ) return ;
+    if ( view() ->isHorizontalSliderPressed() ) return ;
+    if ( view() ->isVerticalSliderPressed () ) return ;
 
     hidePopup();
 
     /* emit signal to have parent hide this if this is popup . */
-    if( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( 0, 0 ) ) emit hideChildPopup();
+    if ( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( 0, 0 ) ) emit hideChildPopup();
 }
 
 
@@ -1819,14 +1724,14 @@ void KitaHTMLPart::slotLeave()
 void KitaHTMLPart::slotVSliderReleased()
 {
 
-    QScrollBar* bar = view()->verticalScrollBar();
+    QScrollBar * bar = view() ->verticalScrollBar();
     QRect rt = bar->sliderRect();
     int mrg = rt.right() - rt.left();
 
     hidePopup();
 
     /* emit signal to have parent hide this if this is popup . */
-    if( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( mrg, 0 ) ) emit hideChildPopup();
+    if ( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( mrg, 0 ) ) emit hideChildPopup();
 }
 
 
@@ -1834,14 +1739,14 @@ void KitaHTMLPart::slotVSliderReleased()
 void KitaHTMLPart::slotHSliderReleased()
 {
 
-    QScrollBar* bar = view()->horizontalScrollBar();
+    QScrollBar * bar = view() ->horizontalScrollBar();
     QRect rt = bar->sliderRect();
     int mrg = rt.bottom() - rt.top();
 
     hidePopup();
 
     /* emit signal to have parent hide this if this is popup . */
-    if( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( 0, mrg ) ) emit hideChildPopup();
+    if ( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( 0, mrg ) ) emit hideChildPopup();
 }
 
 
@@ -1852,7 +1757,7 @@ void KitaHTMLPart::slotHideChildPopup()
     hidePopup();
 
     /* emit signal to have parent hide this if this is popup . */
-    if( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( 0, 0 ) ) emit hideChildPopup();
+    if ( m_mode == HTMLPART_MODE_POPUP && !isUnderMouse( 0, 0 ) ) emit hideChildPopup();
 }
 
 
@@ -1877,12 +1782,12 @@ void KitaHTMLPart::slotOnURL( const QString& url )
 
     /*----------------------------*/
 
-    if( isMultiPopupMode() ) return;
+    if ( isMultiPopupMode() ) return ;
 
     slotDeletePopup();
 
     if ( url.isEmpty() ) return ;
-    if ( url.left( 7 ) == "mailto:" ) return;
+    if ( url.left( 7 ) == "mailto:" ) return ;
 
     /* Is Kita active now ?
 
@@ -1891,13 +1796,12 @@ void KitaHTMLPart::slotOnURL( const QString& url )
        back, and m_kitaIsActive is set to TRUE.   */
     m_kitaIsActive = FALSE;
     emit isKitaActive();
-    if( !m_kitaIsActive ) return;
+    if ( !m_kitaIsActive ) return ;
 
     /*------------------------*/
     /* id popup               */
 
-    if ( url.left( 6 ) == "#idpop" )
-    {
+    if ( url.left( 6 ) == "#idpop" ) {
         int num = Kita::DatManager::getNumByID( m_datURL, url.mid( 6 ) );
         if ( num <= 1 ) return ;
         QString tmpstr = QString( "<DIV>ID:%1:[%2]</DIV>" ).arg( url.mid( 6 ) ).arg( num );
@@ -1917,37 +1821,32 @@ void KitaHTMLPart::slotOnURL( const QString& url )
 
     /* get reference */
     if ( url.at( 0 ) == '#' ) refstr = url.mid( 1 );
-    else datURL = Kita::ParseMisc::parseURL( KURL( m_datURL, url ) ,refstr);
+    else datURL = Kita::ParseMisc::parseURL( KURL( m_datURL, url ) , refstr );
 
     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 > maxpopup - 1 ) refNum2 = refNum + maxpopup - 1;
         }
 
-    }
-    else
-    { /* >>refNum */
+    } else { /* >>refNum */
         refNum = refstr.toInt();
         refNum2 = refNum;
     }
 
     /* another thread ? */
-    if ( datURL.host() != m_datURL.host() || datURL.path() != m_datURL.path() )
-    {
+    if ( datURL.host() != m_datURL.host() || datURL.path() != m_datURL.path() ) {
 
         /* show them with boadname & subject */
         QString boardName = Kita::DatManager::boardName( datURL );
-        if ( boardName != QString::null ) innerHTML += "[" +boardName +"] ";
+        if ( boardName != QString::null ) innerHTML += "[" + boardName + "] ";
         QString subName = Kita::DatManager::threadName( datURL );
-        if ( subName != QString::null ) innerHTML += subName +"<br><br>";
+        if ( subName != QString::null ) innerHTML += subName + "<br><br>";
 
         if ( !refNum ) refNum = refNum2 = 1;
     }
@@ -1956,7 +1855,7 @@ void KitaHTMLPart::slotOnURL( const QString& url )
     if ( !refNum ) return ;
     innerHTML += Kita::DatManager::getHtml( datURL, refNum, refNum2 );
 
-    if ( innerHTML != QString::null ) showPopup( datURL,  innerHTML );
+    if ( innerHTML != QString::null ) showPopup( datURL, innerHTML );
 }
 
 
@@ -1966,7 +1865,7 @@ void KitaHTMLPart::slotOnURL( const QString& url )
 bool KitaHTMLPart::showSelectedDigitPopup()
 {
 
-    if( !hasSelection() ) return FALSE;
+    if ( !hasSelection() ) return FALSE;
 
     QString linkstr;
     int refNum;
@@ -1974,12 +1873,10 @@ bool KitaHTMLPart::showSelectedDigitPopup()
     const QChar *chpt = selectText.unicode();
     unsigned int length = selectText.length();
 
-    if( ( refNum = Kita::ParseMisc::stringToPositiveNum( chpt, length ) ) != -1 )
-    {
+    if ( ( refNum = Kita::ParseMisc::stringToPositiveNum( chpt, length ) ) != -1 ) {
         QString innerHTML = Kita::DatManager::getHtml( m_datURL, refNum, refNum );
-        if ( innerHTML != QString::null )
-        {
-            showPopup( m_datURL,  innerHTML );
+        if ( innerHTML != QString::null ) {
+            showPopup( m_datURL, innerHTML );
             startMultiPopup();
             return TRUE;
         }
@@ -2012,7 +1909,7 @@ namespace Kita
         m_textBrowser->setResizePolicy( QScrollView::AutoOne );
         m_textBrowser->setFont( KitaConfig::threadFont() );
 
-        m_htmlPart = new KitaHTMLPart(this);
+        m_htmlPart = new KitaHTMLPart( this );
         m_htmlPart->setup( HTMLPART_MODE_POPUP , datURL );
         connect( m_htmlPart, SIGNAL( hideChildPopup() ), SIGNAL( hideChildPopup() ) );
     }
@@ -2020,9 +1917,9 @@ namespace Kita
 
     ResPopup::~ResPopup()
     {
-        if(m_textBrowser) delete m_textBrowser;
+        if ( m_textBrowser ) delete m_textBrowser;
         m_textBrowser = NULL;
-        if(m_htmlPart) delete m_htmlPart;
+        if ( m_htmlPart ) delete m_htmlPart;
         m_htmlPart = NULL;
     }
 
@@ -2045,24 +1942,23 @@ namespace Kita
 
         QString text = "<html><head><style>";
         text += KitaConfig::defaultStyleSheetText();
-       text += style;
+        text += style;
         if ( KitaConfig::useStyleSheet() ) {
             text += KitaConfig::styleSheetText();
         }
         text += "</style></head><body class=\"pop\">";
-       text += str;
-       text += "</body></html>";
+        text += str;
+        text += "</body></html>";
 
-        if( m_textBrowser ) m_textBrowser->setText( text );
+        if ( m_textBrowser ) m_textBrowser->setText( text );
 
-        if( m_htmlPart )
-        {
-            m_htmlPart->setJScriptEnabled(false);
-            m_htmlPart->setJavaEnabled(false);
-            m_htmlPart->begin("file:/dummy.htm");
-            m_htmlPart->write(text);
+        if ( m_htmlPart ) {
+            m_htmlPart->setJScriptEnabled( false );
+            m_htmlPart->setJavaEnabled( false );
+            m_htmlPart->begin( "file:/dummy.htm" );
+            m_htmlPart->write( text );
             m_htmlPart->end();
-            m_htmlPart->view()->setVScrollBarMode(QScrollView::AlwaysOff);
+            m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOff );
         }
     }
 
@@ -2077,19 +1973,19 @@ namespace Kita
 
         /*---------------------------*/
 
-        if( !m_textBrowser || !m_htmlPart ) return;
+        if ( !m_textBrowser || !m_htmlPart ) return ;
 
         /* get frame size from qtextbrowser because I could not
            get size by resizing the view of KHTMLPart...
            ( It is very ugly... Is there any good idea? ) */
         m_textBrowser->resize( m_textBrowser->contentsWidth() + mrg2,
                                m_textBrowser->contentsHeight() );
-        int wd = m_textBrowser->contentsWidth()  +mrg;
-        int ht = m_textBrowser->contentsHeight() +mrg;
+        int wd = m_textBrowser->contentsWidth() mrg;
+        int ht = m_textBrowser->contentsHeight() + mrg;
         delete m_textBrowser;
         m_textBrowser = NULL;
 
-        m_htmlPart->view()->resize( wd,ht );
+        m_htmlPart->view() ->resize( wd, ht );
         QFrame::adjustSize();
     }
 
@@ -2097,117 +1993,116 @@ namespace Kita
     /* public */
     void ResPopup::adjustPos( QPoint pos )
     {
-       enum{
-           POS_LeftUp,
-           POS_RightUp,            
-           POS_LeftDown,
-           POS_RightDown
-       };
-       
+        enum{
+            POS_LeftUp,
+            POS_RightUp,
+            POS_LeftDown,
+            POS_RightDown
+        };
+
         /* config */
 
         const int mrg = 16;
 
         /*----------------------------*/
 
-        if( !m_htmlPart ) return;
+        if ( !m_htmlPart ) return ;
 
         QRect qr = QApplication::desktop() ->rect();
         int sw = qr.width(), sh = qr.height();
         int wd = width(), ht = height();
         int x = pos.x(), y = pos.y();
-       int idx;
+        int idx;
 
         if ( ( x + mrg ) + wd < sw
-            && ( y - mrg ) - ht >= 0 ) idx = POS_RightUp;
+                && ( y - mrg ) - ht >= 0 ) idx = POS_RightUp;
 
         else if ( ( x - mrg ) - wd >= 0
-                 && y - ( ht + mrg ) >= 0 ) idx = POS_LeftUp;
+                  && y - ( ht + mrg ) >= 0 ) idx = POS_LeftUp;
 
         else if ( ( x + mrg ) + wd < sw
-                 && ( y + mrg ) + ht < sh ) idx = POS_RightDown;
+                  && ( y + mrg ) + ht < sh ) idx = POS_RightDown;
 
         else if ( ( x - mrg ) - wd >= 0
-                 && ( y + mrg ) + ht < sh ) idx = POS_LeftDown;
+                  && ( y + mrg ) + ht < sh ) idx = POS_LeftDown;
 
-        else{
-           int area[4];
-           area[0] = ( sw - x ) * y;
-           area[1] = x * y;
-           area[2] = ( sw - x ) * ( sh - y );
-           area[3] = x * ( sh - y );
+        else {
+            int area[ 4 ];
+            area[ 0 ] = ( sw - x ) * y;
+            area[ 1 ] = x * y;
+            area[ 2 ] = ( sw - x ) * ( sh - y );
+            area[ 3 ] = x * ( sh - y );
 
-           idx = 0;
-           for( int i = 1; i < 4; ++i) if( area[ i ] > area[ idx ] ) idx = i;
-       }
+            idx = 0;
+            for ( int i = 1; i < 4; ++i ) if ( area[ i ] > area[ idx ] ) idx = i;
+        }
 
-       switch( idx ){
+        switch ( idx ) {
 
-       case POS_RightUp: 
+        case POS_RightUp:
             x = x + mrg;
             y = ( y - mrg ) - ht;
-           break;
+            break;
 
-       case POS_LeftUp:
+        case POS_LeftUp:
             x = ( x - mrg ) - wd;
             y = ( y - mrg ) - ht;
-           break;
+            break;
 
-       case POS_RightDown:
+        case POS_RightDown:
             x = x + mrg;
             y = y + mrg;
-           break;
+            break;
 
-       case POS_LeftDown:
+        case POS_LeftDown:
             x = ( x - mrg ) - wd;
             y = y + mrg;
-           break;
-       }
+            break;
+        }
 
-        if( x < 0 ){
+        if ( x < 0 ) {
 
-           x = ht % 16;
+            x = ht % 16;
         }
-        if( x + wd >= sw ){
+        if ( x + wd >= sw ) {
+
+            x = sw - wd - ( ht % 16 );
 
-           x = sw - wd - ( ht % 16 );
+            if ( x < 0 ) {
+                m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                x = 0;
+                wd = sw;
+            }
+        }
 
-           if( x < 0 ) {
-               m_htmlPart->view()->setVScrollBarMode( QScrollView::AlwaysOn );
-               x = 0;
-               wd = sw;
-           }
+        if ( y < 0 ) {
+            if ( x <= pos.x() && pos.x() < x + wd ) {
+                m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                ht += y;
+            }
+            y = 0;
         }
-       
-        if( y < 0 ){
-           if( x <= pos.x() && pos.x() < x + wd ){ 
-               m_htmlPart->view()->setVScrollBarMode( QScrollView::AlwaysOn );
-               ht += y;
-           }
-           y = 0;
+        if ( y + ht >= sh ) {
+
+            if ( x <= pos.x() && pos.x() < x + wd ) {
+                m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                ht = sh - y;
+            } else {
+                y = sh - ht;
+
+                if ( y < 0 ) {
+                    m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                    y = 0;
+                    ht = sh;
+                }
+            }
         }
-        if( y + ht >= sh ){
-           
-           if( x <= pos.x() && pos.x() < x + wd ){ 
-               m_htmlPart->view()->setVScrollBarMode( QScrollView::AlwaysOn );
-               ht = sh - y;
-           }
-           else{
-               y = sh - ht;
-
-               if( y < 0 ){
-                   m_htmlPart->view()->setVScrollBarMode( QScrollView::AlwaysOn );
-                   y = 0;
-                   ht = sh;
-               }
-           }
-       }
-       
+
         pos.setX( x );
         pos.setY( y );
         move( pos );
 
-        m_htmlPart->view()->resize( wd, ht );
+        m_htmlPart->view() ->resize( wd, ht );
         resize( wd, ht );
     }
 
@@ -2223,16 +2118,16 @@ namespace Kita
 
         QPoint pos = QCursor::pos();
         int cx = pos.x(), cy = pos.y();
-        int px =  x();
-        int py =  y();
+        int px = x();
+        int py = y();
         int wd = width();
         int ht = height();
 
-        if( cx <= px ) cx = px+mrg;
-        else if(cx >= px+wd ) cx = px+wd-mrg;
+        if ( cx <= px ) cx = px + mrg;
+        else if ( cx >= px + wd ) cx = px + wd - mrg;
 
-        if( cy <= py ) cy = py+mrg;
-        else if( cy >= py+ht ) cy = py+ht-mrg;
+        if ( cy <= py ) cy = py + mrg;
+        else if ( cy >= py + ht ) cy = py + ht - mrg;
 
         QCursor::setPos( cx, cy );
     }