OSDN Git Service

reformat.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Fri, 17 Sep 2004 14:43:51 +0000 (14:43 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Fri, 17 Sep 2004 14:43:51 +0000 (14:43 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1374 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/part/kitahtmlpart.cpp
kita/src/part/kitahtmlpart.h
kita/src/part/kitaimgview.cpp
kita/src/part/kitaimgview.h

index 0ebd1b3..940191e 100644 (file)
@@ -152,11 +152,11 @@ void KitaHTMLPart::connectSignals()
 
     /* click */
     connect( this, SIGNAL( openURLRequestExt(
-                              const KURL&, const KParts::URLArgs&, QString, int, int,
-                              const KURL&, const KURL&, const QString&, const QString& )),
+                               const KURL&, const KParts::URLArgs&, QString, int, int,
+                               const KURL&, const KURL&, const QString&, const QString& ) ),
              signalCollection, SIGNAL( openURLRequestExt(
-                                          const KURL& , const KParts::URLArgs&, QString, int, int,
-                                          const KURL&, const KURL&, const QString&, const QString& ) ) );
+                                           const KURL& , const KParts::URLArgs&, QString, int, int,
+                                           const KURL&, const KURL&, const QString&, const QString& ) ) );
 
 
     /* goto anchor */
@@ -558,7 +558,7 @@ void KitaHTMLPart::slotFinishLoad()
 
     showResponses( bottom + 1, shownNum );
     updateScreen( TRUE, FALSE );
-//    m_domtree->parseAllRes();
+    //    m_domtree->parseAllRes();
     m_centerNum = 0;
 
     if ( m_jumpNumAfterLoading ) gotoAnchor( QString().setNum( m_jumpNumAfterLoading ), FALSE );
@@ -658,7 +658,7 @@ void KitaHTMLPart::pushCurrentPosition()
 /* find the id of current node */ /* private */
 QString KitaHTMLPart::getCurrentIDofNode()
 {
-    DOM::Node node;    
+    DOM::Node node;
     node = nodeUnderMouse();
     while ( node != NULL && node.nodeName().string() != "div" ) node = node.parentNode();
     /* DIV---TABLE (title)
@@ -971,9 +971,9 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
         ID_Search_Google,
         ID_Open_Browser,
 
-       ID_Show_Imgview,
-       ID_Mosaic,
-       ID_Del_Image,
+        ID_Show_Imgview,
+        ID_Mosaic,
+        ID_Del_Image,
 
         /*-----------------*/
         ID_Back_Link /* stay bottom */
@@ -1001,22 +1001,22 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
     /*-------------*/
     /* image menu  */
-    if( KitaConfig::useImagePopup() ){
-       
-       if ( Kita::ImgManager::isImgFile( kurl, FALSE )
-            && !Kita::ImgManager::isLoadingNow( kurl )
-           ){
-       
-           if( Kita::ImgManager::code( kurl ) == 200  && Kita::ImgManager::mosaic( kurl ) )
-               popupMenu->insertItem( i18n( "Cancel mosaic" ), ID_Mosaic );
-               
-           popupMenu->insertItem( i18n( "Open with Image view" ), ID_Show_Imgview );           
-
-           if( Kita::ImgManager::code( kurl ) == 200 )
-               popupMenu->insertItem( i18n( "Delete" ) , ID_Del_Image );
-
-           popupMenu->insertSeparator();       
-       }
+    if ( KitaConfig::useImagePopup() ) {
+
+        if ( Kita::ImgManager::isImgFile( kurl, FALSE )
+                && !Kita::ImgManager::isLoadingNow( kurl )
+           ) {
+
+            if ( Kita::ImgManager::code( kurl ) == 200 && Kita::ImgManager::mosaic( kurl ) )
+                popupMenu->insertItem( i18n( "Cancel mosaic" ), ID_Mosaic );
+
+            popupMenu->insertItem( i18n( "Open with Image view" ), ID_Show_Imgview );
+
+            if ( Kita::ImgManager::code( kurl ) == 200 )
+                popupMenu->insertItem( i18n( "Delete" ) , ID_Del_Image );
+
+            popupMenu->insertSeparator();
+        }
     }
 
     /*------*/
@@ -1118,20 +1118,20 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
 
         int ret = popupMenu->exec( point );
         switch ( ret ) {
-           
-       case ID_Mosaic:
-           Kita::ImgManager::setMosaic( kurl, FALSE );
-           emit redrawImage( kurl );
-           showPopup( kurl, QString::null );
-           break;
-
-       case ID_Del_Image:
-           Kita::ImgManager::deleteCache( kurl, view() );
-           break;
-           
-       case ID_Show_Imgview:
-           emit openURLRequestExt( url, KParts::URLArgs(), QString::null, 1 );
-           break;
+
+        case ID_Mosaic:
+            Kita::ImgManager::setMosaic( kurl, FALSE );
+            emit redrawImage( kurl );
+            showPopup( kurl, QString::null );
+            break;
+
+        case ID_Del_Image:
+            Kita::ImgManager::deleteCache( kurl, view() );
+            break;
+
+        case ID_Show_Imgview:
+            emit openURLRequestExt( url, KParts::URLArgs(), QString::null, 1 );
+            break;
 
         case ID_COPY_Link:
             clipboard->setText( url , QClipboard::Clipboard );
@@ -1280,69 +1280,68 @@ void KitaHTMLPart::clickAnchor( const KURL& urlin )
     /* 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() ) {
+
+        /* right click */
+        if ( m_pushrightbt ) {
+
+            /* show image menu */
+            if ( KitaConfig::useImagePopup()
+                    && Kita::ImgManager::isImgFile( urlin, FALSE ) ) showPopupMenu( urlin );
+
+            /* start multi-popup mode or show popup menu */
+            else if ( !startMultiPopup() ) showPopupMenu( urlin );
+
+            return ;
+        }
+        /* right click */
+
+
+        /* bmp file */
+        if ( Kita::ImgManager::isBMP( urlin ) ) {
+            QMessageBox::warning( view(),
+                                  "Kita",
+                                  i18n( "This is a BMP file. It might contain a Troy." ) );
+            return ;
+        }
+        /* bmp file */
+
+
+        /* image */
+        if ( Kita::ImgManager::isImgFile( urlin, FALSE ) ) {
+
+            int active = 1;
+
+            if ( m_pushctrl || m_pushmidbt ) {
+
+                /* stop loading */
+                if ( Kita::ImgManager::isLoadingNow( urlin ) ) {
+
+                    if ( QMessageBox::information( view(),
+                                                   "Kita",
+                                                   i18n( "Do you want to stop loading ?" ),
+                                                   QMessageBox::Ok,
+                                                   QMessageBox::Cancel | QMessageBox::Default )
+                            == QMessageBox::Ok ) Kita::ImgManager::stop( urlin );
+
+                    return ;
+                }
+
+                if ( Kita::ImgManager::code( urlin ) != 200 ) showPopup( urlin, "<DIV>loading image...</DIV>" );
+                active = 0;
+            }
+
+            QString id = getCurrentIDofNode();
+            QString tmpurl = m_datURL.prettyURL();
+            if ( id != QString::null ) tmpurl += "#" + id;
+
+            emit openURLRequestExt( urlin, KParts::URLArgs(), QString::null, active, 0, tmpurl );
+            return ;
+        }
+        /* image */
 
-       /* right click */
-       if( m_pushrightbt ) { 
-
-           /* show image menu */
-           if( KitaConfig::useImagePopup()
-               && Kita::ImgManager::isImgFile( urlin, FALSE ) ) showPopupMenu( urlin );
-           
-           /* start multi-popup mode or show popup menu */
-           else if( !startMultiPopup() ) showPopupMenu( urlin );
-
-           return;
-       }
-       /* right click */       
-
-       
-       /* bmp file */
-       if( Kita::ImgManager::isBMP( urlin )){
-           QMessageBox::warning( view(),
-                                 "Kita",
-                                 i18n( "This is a BMP file. It might contain a Troy." ) );
-           return;
-       }
-       /* bmp file */  
-
-       
-       /* image */
-       if( Kita::ImgManager::isImgFile( urlin, FALSE ) ){
-
-           int active = 1;
-
-           if( m_pushctrl || m_pushmidbt ){
-               
-               /* stop loading */
-               if( Kita::ImgManager::isLoadingNow( urlin ) ){
-
-                   if ( QMessageBox::information( view(),
-                                                  "Kita",
-                                                  i18n( "Do you want to stop loading ?" ),
-                                                  QMessageBox::Ok,
-                                                  QMessageBox::Cancel | QMessageBox::Default )
-                        == QMessageBox::Ok ) Kita::ImgManager::stop( urlin );
-               
-                   return;
-               }
-               
-               if( Kita::ImgManager::code( urlin ) != 200 ) showPopup( urlin, "<DIV>loading image...</DIV>" );
-               active = 0;
-           }
-
-           QString id = getCurrentIDofNode();
-           QString tmpurl = m_datURL.prettyURL();
-           if( id != QString::null ) tmpurl += "#" + id;
-
-           emit openURLRequestExt( urlin, KParts::URLArgs(), QString::null, active, 0, tmpurl );           
-           return;
-       }
-       /* image */
-           
-       emit openURLRequestExt( urlin );
-       return ;
+        emit openURLRequestExt( urlin );
+        return ;
     }
 
     if ( refstr == QString::null ) return ;
@@ -1595,8 +1594,8 @@ void KitaHTMLPart::showWritePopupMenu( const QString& refstr )
 void KitaHTMLPart::showIDPopup( const QString& refstr )
 {
     QString strid = refstr.mid( 5 )
-                    .replace( "%2B", "+" )    /* decode %2B -> + */
-                    .replace( "%2F", "/" ); /* decode %2F -> / */
+                    .replace( "%2B", "+" )
+                    .replace( "%2F", "/" );
 
     /* popup */
     if ( m_pushrightbt ) {
@@ -1907,31 +1906,31 @@ void KitaHTMLPart::slotOnURL( const QString& url )
 
     /*------------------------*/
     /* image popup            */
-    if( KitaConfig::useImagePopup() ){
-
-       if ( Kita::ImgManager::isImgFile( url, FALSE ) ){
-
-           /* now loading */
-           if( Kita::ImgManager::isLoadingNow( url ) ){
-               showPopup( url, "<DIV>loading image...</DIV>" );
-               return;
-           }
-
-           /* show error code */
-           int code = Kita::ImgManager::code( url );
-           if( code == -1 ) return;
-           if( code != 200){
-               QString tmpstr = QString( "<DIV>error %1 </DIV>" ).arg( code );
-               showPopup( url, tmpstr );
-               return;
-           }
-
-           /* show image */
-           showPopup( url, QString::null );
-           return ;
-       }
+    if ( KitaConfig::useImagePopup() ) {
+
+        if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
+
+            /* now loading */
+            if ( Kita::ImgManager::isLoadingNow( url ) ) {
+                showPopup( url, "<DIV>loading image...</DIV>" );
+                return ;
+            }
+
+            /* show error code */
+            int code = Kita::ImgManager::code( url );
+            if ( code == -1 ) return ;
+            if ( code != 200 ) {
+                QString tmpstr = QString( "<DIV>error %1 </DIV>" ).arg( code );
+                showPopup( url, tmpstr );
+                return ;
+            }
+
+            /* show image */
+            showPopup( url, QString::null );
+            return ;
+        }
     }
-    
+
 
     /*-------------------------*/
     /* popup for anchor        */
@@ -2025,32 +2024,32 @@ namespace Kita
                       | WStyle_Tool
                       | WType_TopLevel
                       | WX11BypassWM
-               )
+                    )
     {
-       m_url = url;
-       m_textBrowser = NULL;
-       m_htmlPart = NULL;
-       m_imgview = NULL;
-
-       /* image extension */
-       if( KitaConfig::useImagePopup() ){      
-
-           if ( Kita::ImgManager::isImgFile( url, FALSE ) ){
-           
-               connect( Kita::ImgManager::getInstance(),
-                        SIGNAL( receiveImgData( const KURL&, unsigned int, unsigned int ) ),
-                        SLOT( slotReceiveImgData( const KURL&, unsigned int, unsigned int ) ) );
-               connect( Kita::ImgManager::getInstance(), SIGNAL( finishImgLoad( const KURL& ) ),
-                        SLOT( slotFinishImgLoad( const KURL& ) ) );
-
-               /* show image */
-               if( !Kita::ImgManager::isLoadingNow( url ) && Kita::ImgManager::code( url ) == 200 ){
-                   showImage( url );
-                   return;
-               }
-           }
-       }
-       
+        m_url = url;
+        m_textBrowser = NULL;
+        m_htmlPart = NULL;
+        m_imgview = NULL;
+
+        /* image extension */
+        if ( KitaConfig::useImagePopup() ) {
+
+            if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
+
+                connect( Kita::ImgManager::getInstance(),
+                         SIGNAL( receiveImgData( const KURL&, unsigned int, unsigned int ) ),
+                         SLOT( slotReceiveImgData( const KURL&, unsigned int, unsigned int ) ) );
+                connect( Kita::ImgManager::getInstance(), SIGNAL( finishImgLoad( const KURL& ) ),
+                         SLOT( slotFinishImgLoad( const KURL& ) ) );
+
+                /* show image */
+                if ( !Kita::ImgManager::isLoadingNow( url ) && Kita::ImgManager::code( url ) == 200 ) {
+                    showImage( url );
+                    return ;
+                }
+            }
+        }
+
         m_textBrowser = new QTextBrowser( this );
         m_textBrowser->setWordWrap( QTextEdit::NoWrap );
         m_textBrowser->setResizePolicy( QScrollView::AutoOne );
@@ -2066,7 +2065,7 @@ namespace Kita
     {
         if ( m_textBrowser ) delete m_textBrowser;
         if ( m_htmlPart ) delete m_htmlPart;
-       if( m_imgview ) delete m_imgview;
+        if ( m_imgview ) delete m_imgview;
     }
 
 
@@ -2216,7 +2215,7 @@ namespace Kita
             x = sw - wd - ( ht % 16 );
 
             if ( x < 0 ) {
-                if( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                if ( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
                 x = 0;
                 wd = sw;
             }
@@ -2224,7 +2223,7 @@ namespace Kita
 
         if ( y < 0 ) {
             if ( x <= pos.x() && pos.x() < x + wd ) {
-                if( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                if ( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
                 ht += y;
             }
             y = 0;
@@ -2232,13 +2231,13 @@ namespace Kita
         if ( y + ht >= sh ) {
 
             if ( x <= pos.x() && pos.x() < x + wd ) {
-                if( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                if ( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
                 ht = sh - y;
             } else {
                 y = sh - ht;
 
                 if ( y < 0 ) {
-                    if( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
+                    if ( m_htmlPart ) m_htmlPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
                     y = 0;
                     ht = sh;
                 }
@@ -2249,7 +2248,7 @@ namespace Kita
         pos.setY( y );
         move( pos );
 
-        if( m_htmlPart ) m_htmlPart->view() ->resize( wd, ht );
+        if ( m_htmlPart ) m_htmlPart->view() ->resize( wd, ht );
         resize( wd , ht );
     }
 
@@ -2281,59 +2280,58 @@ namespace Kita
 
 
     /*----------------------------------------------------------*/
-    /* image extension */ 
-    
+    /* image extension */
+
     /* private */
-    void  ResPopup::showImage( const KURL& url )
+    void ResPopup::showImage( const KURL& url )
     {
-       /* size of image popup */
-       const int wd = 320;
-       const int ht = 240;
-
-       /*---------------------------*/
-
-       if( m_imgview ) return;
-       if( m_htmlPart ) m_htmlPart->hide();
-       
-       if( Kita::ImgManager::code( url ) == 200 ){
-
-           QString path = Kita::ImgManager::getPath( url );
-           
-           m_imgview = new KitaImgView( url, KURL(), NULL, this,  "Viewer", 0L );
-           m_imgview->resize( wd, ht );
-           resize( wd, ht );
-           m_imgview->show();
-           m_imgview->slotCustomSize( wd, ht );
-       }
+        /* size of image popup */
+        const int wd = 320;
+        const int ht = 240;
+
+        /*---------------------------*/
+
+        if ( m_imgview ) return ;
+        if ( m_htmlPart ) m_htmlPart->hide();
+
+        if ( Kita::ImgManager::code( url ) == 200 ) {
+
+            QString path = Kita::ImgManager::getPath( url );
+
+            m_imgview = new KitaImgView( url, KURL(), NULL, this, "Viewer", 0L );
+            m_imgview->resize( wd, ht );
+            resize( wd, ht );
+            m_imgview->show();
+            m_imgview->slotCustomSize( wd, ht );
+        }
     }
-    
+
 
     /* private slot */
     void ResPopup::slotReceiveImgData( const KURL& url, unsigned int size, unsigned int total )
     {
-       if( url != m_url ) return;
-       
-       QString tmpstr = QString( "<DIV>loading image...<br>%1k/%2k</DIV>" )
-           .arg( size/1024 ).arg( total/1024 );
-       setText( tmpstr );
+        if ( url != m_url ) return ;
+
+        QString tmpstr = QString( "<DIV>loading image...<br>%1k/%2k</DIV>" )
+                         .arg( size / 1024 ).arg( total / 1024 );
+        setText( tmpstr );
     }
-    
+
     /* private slot */
     void ResPopup::slotFinishImgLoad( const KURL& url )
     {
-       if( url != m_url ) return;
-       if( m_htmlPart == NULL ) return;
-
-       int code = Kita::ImgManager::code( url );
-
-       if( code == 200 ){
-           showImage( url );
-       }
-       else{
-           QString tmpstr = QString( "<DIV>error %1</DIV>" ).arg( code );
-           setText( tmpstr );
-       }
+        if ( url != m_url ) return ;
+        if ( m_htmlPart == NULL ) return ;
+
+        int code = Kita::ImgManager::code( url );
+
+        if ( code == 200 ) {
+            showImage( url );
+        } else {
+            QString tmpstr = QString( "<DIV>error %1</DIV>" ).arg( code );
+            setText( tmpstr );
+        }
     }
-    
+
 }
 
index 9f0892d..d9301c1 100644 (file)
 
 /* mode */
 enum {
-    HTMLPART_MODE_KHTML, /* This part is not initialized. This part works as just KHTMLPart */
+    /* This part is not initialized. This part works as just KHTMLPart */
+    HTMLPART_MODE_KHTML,
 
-    HTMLPART_MODE_MAINPART,/* on main window */
-    HTMLPART_MODE_NAVI,    /* on Kita Navi   */
-    HTMLPART_MODE_POPUP    /* on popup       */
+    /* on main window */
+    HTMLPART_MODE_MAINPART,
+
+    /* on Kita Navi   */
+    HTMLPART_MODE_NAVI,
+
+    /* on popup       */
+    HTMLPART_MODE_POPUP
 };
 
 
@@ -94,7 +100,7 @@ public:
     void insertBeltNode( const QString& idstr );
     void insertHeaderNode( const QString& str );
     void insertFooterNode( const QString& str );
-    void updateScreen( bool showHeaderEtc, bool clock);
+    void updateScreen( bool showHeaderEtc, bool clock );
     void setInnerHTML( const QString& innerHTML );
 
     /* cache */
@@ -155,8 +161,8 @@ private:
     void showPopupMenu( const KURL& kurl );
 
     /* click */
-    void clickAnchor(  const KURL& urlin );
-    void showWritePopupMenu( const QString& refstr);
+    void clickAnchor( const KURL& urlin );
+    void showWritePopupMenu( const QString& refstr );
     void showIDPopup( const QString& refstr );
     bool showNext100Etc( const QString& refstr );
 
@@ -164,8 +170,8 @@ private:
     void findTextInit();
 
     /* res popup */
-    void showPopup(  const KURL& url, const QString& innerHTML );
-    void showPopupCore(  const KURL& url, const QString& innerHTML, QPoint point );    
+    void showPopup( const KURL& url, const QString& innerHTML );
+    void showPopupCore( const KURL& url, const QString& innerHTML, QPoint point );
     bool startMultiPopup();
     bool isMultiPopupMode();
     void hidePopup();
@@ -196,12 +202,12 @@ signals:
 
     void openWriteDialog( QString );
     void openURLRequestExt( const KURL& url, const KParts::URLArgs& args = KParts::URLArgs(),
-                           QString mimetype = QString::null,
-                           int usr1 = 0, int usr2 = 0,
-                           const KURL& usrUrl1 = KURL(),
-                           const KURL& usrUrl2 = KURL(),                               
-                           const QString& usrStr1 = QString::null,
-                           const QString& usrStr2 = QString::null );    
+                            QString mimetype = QString::null,
+                            int usr1 = 0, int usr2 = 0,
+                            const KURL& usrUrl1 = KURL(),
+                            const KURL& usrUrl2 = KURL(),
+                            const QString& usrStr1 = QString::null,
+                            const QString& usrStr2 = QString::null );
     void redrawHTMLPart( const KURL& url, bool force );
     void mousePressed(); /* to KitaThreadView */
 
@@ -216,10 +222,10 @@ signals:
     /* kita navi */
     void showKitaNavi( const KURL& , int , int );
     void showKitaNaviByID( const KURL& , QString );
-    void showKitaNaviByWord( const KURL& , QString);
-    void showKitaNaviByName( const KURL& , QString);
-    void showKitaNaviResTree( const KURL&,  int );
-    void showKitaNaviRevResTree( const KURL&,  int );
+    void showKitaNaviByWord( const KURL& , QString );
+    void showKitaNaviByName( const KURL& , QString );
+    void showKitaNaviResTree( const KURL&, int );
+    void showKitaNaviRevResTree( const KURL&, int );
 
     /* write dock */
     void activateThreadView( const KURL& );
@@ -244,9 +250,9 @@ namespace Kita
 
         KitaHTMLPart* m_htmlPart;
         QTextBrowser* m_textBrowser;
-       KitaImgView* m_imgview;
-       KURL m_url;
-       
+        KitaImgView* m_imgview;
+        KURL m_url;
+
 
     public:
         ResPopup( KHTMLView* view, const KURL& datURL );
@@ -256,12 +262,12 @@ namespace Kita
         void adjustPos( QPoint pos );
         void moveMouseAbove();
 
-      private:
-       void showImage( const KURL& url );
+    private:
+        void showImage( const KURL& url );
 
-       private slots:
-       void slotReceiveImgData( const KURL& url, unsigned int size, unsigned int total );
-       void slotFinishImgLoad( const KURL& url );
+    private slots:
+        void slotReceiveImgData( const KURL& url, unsigned int size, unsigned int total );
+        void slotFinishImgLoad( const KURL& url );
 
     signals:
         void hideChildPopup();
index 46fac4a..e173f15 100644 (file)
@@ -27,8 +27,8 @@
 
 
 KitaImgView::KitaImgView( const KURL& url, const KURL& datURL, KActionCollection* action,
-                             QWidget* parent, const char* name, WFlags fl )
-    : QScrollView( parent, name, fl )
+                          QWidget* parent, const char* name, WFlags fl )
+        : QScrollView( parent, name, fl )
 {
     m_url = url;
     m_datURL = datURL;
@@ -43,17 +43,17 @@ KitaImgView::KitaImgView( const KURL& url, const KURL& datURL, KActionCollection
     m_imgwd = m_imght = 0;
     m_custom_wd = m_custom_ht = 0;
 
-    viewport()->setEraseColor( Qt::black );
-    viewport()->setPaletteBackgroundColor( Qt::black );
+    viewport() ->setEraseColor( Qt::black );
+    viewport() ->setPaletteBackgroundColor( Qt::black );
 }
 
 
 KitaImgView::~KitaImgView()
 {
-    if( m_pixmap ) delete m_pixmap;
-    if( m_popup ) delete m_popup;
-    if( m_layout ) delete m_layout;
-    if( m_htmlPart ) delete m_htmlPart;
+    if ( m_pixmap ) delete m_pixmap;
+    if ( m_popup ) delete m_popup;
+    if ( m_layout ) delete m_layout;
+    if ( m_htmlPart ) delete m_htmlPart;
 }
 
 
@@ -83,18 +83,18 @@ void KitaImgView::showMessage( QString message )
 void KitaImgView::slotShowImage()
 {
     const int defaultsize = 0;
-    
-    if( m_size < -1 ) m_size = defaultsize; /* size is not initialized. */
-    
+
+    if ( m_size < -1 ) m_size = defaultsize; /* size is not initialized. */
+
     bool usekhtmlpart = Kita::ImgManager::isAnimationGIF( m_url );
-    if( m_htmlPart ) usekhtmlpart = TRUE;
-    if( Kita::ImgManager::mosaic( m_url ) ) usekhtmlpart = FALSE;
+    if ( m_htmlPart ) usekhtmlpart = TRUE;
+    if ( Kita::ImgManager::mosaic( m_url ) ) usekhtmlpart = FALSE;
 
-    if( usekhtmlpart ) showImageWithKHTML();
+    if ( usekhtmlpart ) showImageWithKHTML();
 
-    if( resizeImage() ) {
-       myResizeContents();
-       repaintContents();
+    if ( resizeImage() ) {
+        myResizeContents();
+        repaintContents();
     }
 }
 
@@ -102,8 +102,8 @@ void KitaImgView::slotShowImage()
 /* public slot */
 void KitaImgView::slotFitToWin()
 {
-    if( m_size == 0 ) return;
-    
+    if ( m_size == 0 ) return ;
+
     m_size = 0;
     slotShowImage();
 }
@@ -112,8 +112,8 @@ void KitaImgView::slotFitToWin()
 /* public slot */
 void KitaImgView::slotOriginalSize()
 {
-    if( m_size == 100 ) return;
-    
+    if ( m_size == 100 ) return ;
+
     m_size = 100;
     slotShowImage();
 }
@@ -122,8 +122,8 @@ void KitaImgView::slotOriginalSize()
 /* public slot */
 void KitaImgView::slotSetSize( int size )
 {
-    if( m_size == size ) return;
-    
+    if ( m_size == size ) return ;
+
     m_size = size;
     slotShowImage();
 }
@@ -133,8 +133,8 @@ void KitaImgView::slotSetSize( int size )
 void KitaImgView::slotCustomSize( int wd, int ht )
 {
     const int minsize = 8;
-    
-    if( wd == m_custom_wd && ht == m_custom_ht ) return;
+
+    if ( wd == m_custom_wd && ht == m_custom_ht ) return ;
 
     m_custom_wd = QMAX( minsize, wd );
     m_custom_ht = QMAX( minsize, ht );
@@ -147,12 +147,12 @@ void KitaImgView::slotCustomSize( int wd, int ht )
 void KitaImgView::slotZoomIn()
 {
     const int maxsize = 400;
-    
-    if( m_size >= maxsize ) return;
+
+    if ( m_size >= maxsize ) return ;
 
     /* current mode is "fit to win" or "custom size" */
-    if( m_size <= 0 && m_imgwd ) m_size = QMIN( 100, m_imgwd*100/Kita::ImgManager::width( m_url ) );
-    
+    if ( m_size <= 0 && m_imgwd ) m_size = QMIN( 100, m_imgwd * 100 / Kita::ImgManager::width( m_url ) );
+
     m_size += 10;
     slotShowImage();
 }
@@ -163,11 +163,11 @@ void KitaImgView::slotZoomOut()
 {
     const int minsize = 10;
 
-    if( m_size > 0 && m_size <= minsize ) return;
+    if ( m_size > 0 && m_size <= minsize ) return ;
 
     /* current mode is "fit to win" or "custom size" */
-    if( m_size <= 0 && m_imgwd ) m_size = QMIN( 100, m_imgwd*100/Kita::ImgManager::width( m_url ) );
-    
+    if ( m_size <= 0 && m_imgwd ) m_size = QMIN( 100, m_imgwd * 100 / Kita::ImgManager::width( m_url ) );
+
     m_size -= 10;
     slotShowImage();
 }
@@ -175,17 +175,17 @@ void KitaImgView::slotZoomOut()
 
 
 /* virtual protected */
-void KitaImgView::resizeEvent( QResizeEvent * e)
+void KitaImgView::resizeEvent( QResizeEvent * e )
 {
     QScrollView::resizeEvent( e );
 
-    if( m_htmlPart ) showImageWithKHTML();
+    if ( m_htmlPart ) showImageWithKHTML();
 
-    else if( m_pixmap ){
-       if( m_size == 0 ) resizeImage();  /* fit to window */
-       myResizeContents();
+    else if ( m_pixmap ) {
+        if ( m_size == 0 ) resizeImage();  /* fit to window */
+        myResizeContents();
 
-       /* drawContents is called later. */
+        /* drawContents is called later. */
     }
 }
 
@@ -193,29 +193,28 @@ void KitaImgView::resizeEvent( QResizeEvent * e)
 /* virtual protected */
 void KitaImgView::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph )
 {
-    if( m_htmlPart ) return; /* use KHTMLPart */
+    if ( m_htmlPart ) return ; /* use KHTMLPart */
 
-    if( m_pixmap == NULL ){
-       p->setPen( Qt::white );
-       if( m_message != QString::null ) p->drawText( 16, 16, m_message );
-    }
-    else {
-       
-       p->fillRect( clipx, clipy, clipw, cliph, QColor( "black" ) );
-
-       int x = QMAX( 0, ( QMAX( width(), m_imgwd ) - m_imgwd )/2 );
-       int y = QMAX( 0, ( QMAX( height(), m_imght ) - m_imght )/2 );
-       int sx = QMAX( 0, clipx - x );
-       int sy = QMAX( 0, clipy - y );
-       int sw = QMIN( clipw, x + m_imgwd - clipx );
-       int sh = QMIN( cliph, y + m_imght - clipy );
-       
-       if( x + m_imgwd <= clipx || x >= clipx + clipw
-           || y + m_imght <= clipy || y >= clipy + cliph ) return;
-
-       x = QMAX( x, clipx );
-       y = QMAX( y, clipy );
-       p->drawPixmap( x, y, *m_pixmap, sx, sy, sw, sh );
+    if ( m_pixmap == NULL ) {
+        p->setPen( Qt::white );
+        if ( m_message != QString::null ) p->drawText( 16, 16, m_message );
+    } else {
+
+        p->fillRect( clipx, clipy, clipw, cliph, QColor( "black" ) );
+
+        int x = QMAX( 0, ( QMAX( width(), m_imgwd ) - m_imgwd ) / 2 );
+        int y = QMAX( 0, ( QMAX( height(), m_imght ) - m_imght ) / 2 );
+        int sx = QMAX( 0, clipx - x );
+        int sy = QMAX( 0, clipy - y );
+        int sw = QMIN( clipw, x + m_imgwd - clipx );
+        int sh = QMIN( cliph, y + m_imght - clipy );
+
+        if ( x + m_imgwd <= clipx || x >= clipx + clipw
+                || y + m_imght <= clipy || y >= clipy + cliph ) return ;
+
+        x = QMAX( x, clipx );
+        y = QMAX( y, clipy );
+        p->drawPixmap( x, y, *m_pixmap, sx, sy, sw, sh );
     }
 }
 
@@ -223,10 +222,10 @@ void KitaImgView::drawContents( QPainter * p, int clipx, int clipy, int clipw, i
 /* virtual protected */
 void KitaImgView::contentsMousePressEvent( QMouseEvent * e )
 {
-    if ( e->button() & Qt::RightButton ){
-       QString dummy;
-       slotPopupMenu( dummy, e->globalPos() );
-       return;
+    if ( e->button() & Qt::RightButton ) {
+        QString dummy;
+        slotPopupMenu( dummy, e->globalPos() );
+        return ;
     }
 
     QScrollView::contentsMousePressEvent( e );
@@ -240,29 +239,29 @@ bool KitaImgView::resizeImage()
     const int mosaic_ht = 48;
 
     /*-------------------------------------------*/
-    
-    if( Kita::ImgManager::code( m_url ) != 200 ) return FALSE;
+
+    if ( Kita::ImgManager::code( m_url ) != 200 ) return FALSE;
 
     QString path = Kita::ImgManager::getPath( m_url );
     QImage orgimg = QImage( path );
-    if( orgimg.isNull() ) return FALSE;
+    if ( orgimg.isNull() ) return FALSE;
 
     int imgwd = Kita::ImgManager::width( m_url );
     int imght = Kita::ImgManager::height( m_url );
-    
+
     /* mosaic image */
-    if( Kita::ImgManager::mosaic( m_url ) )
-       orgimg = orgimg.scale( mosaic_wd, mosaic_ht, QImage::ScaleMin).scale( imgwd, imght, QImage::ScaleMin );
+    if ( Kita::ImgManager::mosaic( m_url ) )
+        orgimg = orgimg.scale( mosaic_wd, mosaic_ht, QImage::ScaleMin ).scale( imgwd, imght, QImage::ScaleMin );
 
     /* resize */
     int wd;
     int ht;
     getImgSize( wd, ht );
 
-    if( wd != imgwd || ht != imght ) orgimg = orgimg.scale( wd, ht, QImage::ScaleMin );
+    if ( wd != imgwd || ht != imght ) orgimg = orgimg.scale( wd, ht, QImage::ScaleMin );
 
     /* convert to pixmap */
-    if( m_pixmap == NULL ) m_pixmap = new QPixmap();
+    if ( m_pixmap == NULL ) m_pixmap = new QPixmap();
     m_pixmap->convertFromImage( orgimg );
     m_imgwd = m_pixmap->width();
     m_imght = m_pixmap->height();
@@ -281,24 +280,22 @@ void KitaImgView::getImgSize( int& wd, int& ht )
 
     wd = imgwd;
     ht = imght;
-    
-    if( m_size == -1 ){    /* custom size */
-       wd = m_custom_wd;
-       ht = m_custom_ht;
-    }
-    else if( m_size == 0 ){ /* fit to window */
-       
-       if( width() < imgwd || height() < imght ){
 
-           const int mrg = 16;
+    if ( m_size == -1 ) {    /* custom size */
+        wd = m_custom_wd;
+        ht = m_custom_ht;
+    } else if ( m_size == 0 ) { /* fit to window */
 
-           wd = width() -mrg;
-           ht = height() -mrg;
-       }
-    }
-    else if( m_size != 100 ){ /* % */
-       wd = imgwd * m_size / 100;
-       ht = imght * m_size / 100;
+        if ( width() < imgwd || height() < imght ) {
+
+            const int mrg = 16;
+
+            wd = width() - mrg;
+            ht = height() - mrg;
+        }
+    } else if ( m_size != 100 ) { /* % */
+        wd = imgwd * m_size / 100;
+        ht = imght * m_size / 100;
     }
 }
 
@@ -311,20 +308,20 @@ void KitaImgView::myResizeContents()
     int ht = QMAX( height(), m_imght );
 
     resizeContents( wd, ht );
-       
-    if( wd == width() ) setHScrollBarMode( AlwaysOff );
+
+    if ( wd == width() ) setHScrollBarMode( AlwaysOff );
     else setHScrollBarMode( AlwaysOn );
 
-    if( ht == height() ) setVScrollBarMode( AlwaysOff );
+    if ( ht == height() ) setVScrollBarMode( AlwaysOff );
     else setVScrollBarMode( AlwaysOn );
 
-    if( m_htmlPart ){
-    
-       if( wd == width() ) m_htmlPart->view()->setHScrollBarMode( AlwaysOff );
-       else m_htmlPart->view()->setHScrollBarMode( AlwaysOn ); 
+    if ( m_htmlPart ) {
+
+        if ( wd == width() ) m_htmlPart->view() ->setHScrollBarMode( AlwaysOff );
+        else m_htmlPart->view() ->setHScrollBarMode( AlwaysOn );
 
-       if( ht == height() ) m_htmlPart->view()->setVScrollBarMode( AlwaysOff );
-       else m_htmlPart->view()->setVScrollBarMode( AlwaysOn ); 
+        if ( ht == height() ) m_htmlPart->view() ->setVScrollBarMode( AlwaysOff );
+        else m_htmlPart->view() ->setVScrollBarMode( AlwaysOn );
     }
 }
 
@@ -332,37 +329,37 @@ void KitaImgView::myResizeContents()
 /* private slot */
 void KitaImgView::slotPopupMenu( const QString& , const QPoint& global )
 {
-    if( !m_action ) return;
-    
-    if( m_popup ) delete m_popup;
+    if ( !m_action ) return ;
+
+    if ( m_popup ) delete m_popup;
     m_popup = new KPopupMenu( this );
 
-    if( Kita::ImgManager::mosaic( m_url ) ){
-       if( m_action->action( "imgviewer_cancelmosaic" ) )
-           m_action->action( "imgviewer_cancelmosaic" )->plug( m_popup );
-       m_popup->insertSeparator();
+    if ( Kita::ImgManager::mosaic( m_url ) ) {
+        if ( m_action->action( "imgviewer_cancelmosaic" ) )
+            m_action->action( "imgviewer_cancelmosaic" ) ->plug( m_popup );
+        m_popup->insertSeparator();
     }
 
-    if( m_action->action( "imgviewer_fittowin" ) )
-       m_action->action( "imgviewer_fittowin" )->plug( m_popup ); 
-       
-    if( m_action->action( "imgviewer_original" ) )
-       m_action->action( "imgviewer_original" )->plug( m_popup );
+    if ( m_action->action( "imgviewer_fittowin" ) )
+        m_action->action( "imgviewer_fittowin" ) ->plug( m_popup );
 
-    if( m_action->action( "imgviewer_zoomin" ) )
-       m_action->action( "imgviewer_zoomin" )->plug( m_popup );
+    if ( m_action->action( "imgviewer_original" ) )
+        m_action->action( "imgviewer_original" ) ->plug( m_popup );
+
+    if ( m_action->action( "imgviewer_zoomin" ) )
+        m_action->action( "imgviewer_zoomin" ) ->plug( m_popup );
+
+    if ( m_action->action( "imgviewer_zoomout" ) )
+        m_action->action( "imgviewer_zoomout" ) ->plug( m_popup );
 
-    if( m_action->action( "imgviewer_zoomout" ) )
-       m_action->action( "imgviewer_zoomout" )->plug( m_popup );
-    
     m_popup->insertSeparator();
-    if( m_action->action( "imgviewer_openbrowser" ) )
-       m_action->action( "imgviewer_openbrowser" )->plug( m_popup );
-    if( m_action->action( "imgviewer_openthread" ) )
-       m_action->action( "imgviewer_openthread" )->plug( m_popup );
-    if( m_action->action( "imgviewer_save" ) )
-       m_action->action( "imgviewer_save" )->plug( m_popup );
-    
+    if ( m_action->action( "imgviewer_openbrowser" ) )
+        m_action->action( "imgviewer_openbrowser" ) ->plug( m_popup );
+    if ( m_action->action( "imgviewer_openthread" ) )
+        m_action->action( "imgviewer_openthread" ) ->plug( m_popup );
+    if ( m_action->action( "imgviewer_save" ) )
+        m_action->action( "imgviewer_save" ) ->plug( m_popup );
+
     m_popup->exec( global );
 }
 
@@ -374,66 +371,64 @@ void KitaImgView::slotPopupMenu( const QString& , const QPoint& global )
 
 bool KitaImgView::showImageWithKHTML()
 {
-    if( Kita::ImgManager::code( m_url ) != 200 ) return FALSE;
+    if ( Kita::ImgManager::code( m_url ) != 200 ) return FALSE;
     QString path = Kita::ImgManager::getPath( m_url );
 
     /* create KHTMLPart */
-    if( !m_htmlPart ){
-       m_htmlPart = new KHTMLPart( this );
-       m_layout = new QVBoxLayout( this, 0, 0, "BoxLayout");
-       m_layout->addWidget( m_htmlPart->view() );
+    if ( !m_htmlPart ) {
+        m_htmlPart = new KHTMLPart( this );
+        m_layout = new QVBoxLayout( this, 0, 0, "BoxLayout" );
+        m_layout->addWidget( m_htmlPart->view() );
 
-       connect( m_htmlPart, SIGNAL( popupMenu( const QString&,const QPoint& ) ),
-                SLOT( slotPopupMenu( const QString&, const QPoint& ) ) );
+        connect( m_htmlPart, SIGNAL( popupMenu( const QString&, const QPoint& ) ),
+                 SLOT( slotPopupMenu( const QString&, const QPoint& ) ) );
     }
 
     /* show image */
-    if ( m_htmlPart ){
-
-       QString sizetxt = QString::null;
-       int wd,ht;
-       int imgwd = Kita::ImgManager::width( m_url );
-       int imght = Kita::ImgManager::height( m_url );
-       m_imgwd = imgwd;
-       m_imght = imght;
-
-       getImgSize( wd, ht );
-       
-       if( m_size <= 0 ){ /* "fit to win" or "custom size" */
-           
-           if( (double)imght * wd / imgwd >= ht ) {
-               sizetxt = "height=" + QString().setNum( ht );
-               m_imgwd = (int) ( (double) imgwd * ht / imght );
-               m_imght = ht;
-           }
-           else {
-               sizetxt = "width=" + QString().setNum( wd );
-               m_imgwd = wd;
-               m_imght = (int) ( (double) imght * wd / imgwd );
-           }
-       }
-       else if( m_size != 100 ){ /* % */
-           sizetxt = "width=" + QString().setNum( wd );
-           m_imgwd = wd;
-           m_imght = (int) ( (double) imght * wd / imgwd );
-       }
-       
-       int x = QMAX( 0, ( QMAX( width(), m_imgwd ) - m_imgwd )/2 );
-       int y = QMAX( 0, ( QMAX( height(), m_imght ) - m_imght )/2 );
-       
-       QString style = QString( "body { margin:%1px %2px; background-color:black; }" )
-           .arg( y ).arg( x );
-       
-       QString text = "<html><head><style>" + style + "</style></head><body>";
-      text += "<img src=\"file:" + path + "\" " + sizetxt  + " >";
-      text += "</body></html>";
-
-       m_htmlPart->setJScriptEnabled( false );
-       m_htmlPart->setJavaEnabled( false );
-       m_htmlPart->begin( "file:/dummy.htm" );
-       m_htmlPart->write( text );
-       m_htmlPart->end();
-       m_htmlPart->view()->show();
+    if ( m_htmlPart ) {
+
+        QString sizetxt = QString::null;
+        int wd, ht;
+        int imgwd = Kita::ImgManager::width( m_url );
+        int imght = Kita::ImgManager::height( m_url );
+        m_imgwd = imgwd;
+        m_imght = imght;
+
+        getImgSize( wd, ht );
+
+        if ( m_size <= 0 ) { /* "fit to win" or "custom size" */
+
+            if ( ( double ) imght * wd / imgwd >= ht ) {
+                sizetxt = "height=" + QString().setNum( ht );
+                m_imgwd = ( int ) ( ( double ) imgwd * ht / imght );
+                m_imght = ht;
+            } else {
+                sizetxt = "width=" + QString().setNum( wd );
+                m_imgwd = wd;
+                m_imght = ( int ) ( ( double ) imght * wd / imgwd );
+            }
+        } else if ( m_size != 100 ) { /* % */
+            sizetxt = "width=" + QString().setNum( wd );
+            m_imgwd = wd;
+            m_imght = ( int ) ( ( double ) imght * wd / imgwd );
+        }
+
+        int x = QMAX( 0, ( QMAX( width(), m_imgwd ) - m_imgwd ) / 2 );
+        int y = QMAX( 0, ( QMAX( height(), m_imght ) - m_imght ) / 2 );
+
+        QString style = QString( "body { margin:%1px %2px; background-color:black; }" )
+                        .arg( y ).arg( x );
+
+        QString text = "<html><head><style>" + style + "</style></head><body>";
+        text += "<img src=\"file:" + path + "\" " + sizetxt + " >";
+        text += "</body></html>";
+
+        m_htmlPart->setJScriptEnabled( false );
+        m_htmlPart->setJavaEnabled( false );
+        m_htmlPart->begin( "file:/dummy.htm" );
+        m_htmlPart->write( text );
+        m_htmlPart->end();
+        m_htmlPart->view() ->show();
     }
 
     myResizeContents();
index c19ffb0..4527d79 100644 (file)
@@ -41,14 +41,14 @@ class KitaImgView: public QScrollView
     int m_custom_wd;
     int m_custom_ht;
     int m_imgwd;
-    int m_imght;    
-    
+    int m_imght;
+
 public:
     KitaImgView( const KURL& url, const KURL& datURL, KActionCollection* action, QWidget* parent, const char* name, WFlags fl );
     ~KitaImgView();
 
     const KURL url() const;
-    const KURL datURL() const;    
+    const KURL datURL() const;
     void showMessage( QString message );
 
 public slots:
@@ -59,9 +59,9 @@ public slots:
     void slotCustomSize( int wd, int ht );
     void slotZoomIn();
     void slotZoomOut();
-    
+
 protected:
-    virtual void resizeEvent( QResizeEvent * e);
+    virtual void resizeEvent( QResizeEvent * e );
     virtual void drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph );
     virtual void contentsMousePressEvent( QMouseEvent * e );
 
@@ -74,9 +74,9 @@ private:
 
 private slots:
     void slotPopupMenu( const QString&, const QPoint& );
-    
+
 signals:
-     void newImage( const QImage & ); /* to KviewViewer */
+    void newImage( const QImage & ); /* to KviewViewer */
 };
 
 #endif