/* 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 */
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 );
/* 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)
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 */
/*-------------*/
/* 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();
+ }
}
/*------*/
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 );
/* 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 ;
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 ) {
/*------------------------*/
/* 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 */
| 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 );
{
if ( m_textBrowser ) delete m_textBrowser;
if ( m_htmlPart ) delete m_htmlPart;
- if( m_imgview ) delete m_imgview;
+ if ( m_imgview ) delete m_imgview;
}
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;
}
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;
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;
}
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 );
}
/*----------------------------------------------------------*/
- /* 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 );
+ }
}
-
+
}
/* 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
};
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 */
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 );
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();
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 */
/* 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& );
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 );
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();
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;
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;
}
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();
}
}
/* public slot */
void KitaImgView::slotFitToWin()
{
- if( m_size == 0 ) return;
-
+ if ( m_size == 0 ) return ;
+
m_size = 0;
slotShowImage();
}
/* public slot */
void KitaImgView::slotOriginalSize()
{
- if( m_size == 100 ) return;
-
+ if ( m_size == 100 ) return ;
+
m_size = 100;
slotShowImage();
}
/* public slot */
void KitaImgView::slotSetSize( int size )
{
- if( m_size == size ) return;
-
+ if ( m_size == size ) return ;
+
m_size = size;
slotShowImage();
}
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 );
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();
}
{
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();
}
/* 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. */
}
}
/* 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 );
}
}
/* 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 );
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();
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;
}
}
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 );
}
}
/* 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 );
}
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();
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:
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 );
private slots:
void slotPopupMenu( const QString&, const QPoint& );
-
+
signals:
- void newImage( const QImage & ); /* to KviewViewer */
+ void newImage( const QImage & ); /* to KviewViewer */
};
#endif