From 3add34d19816fcecd6b1b783224da2fe4b725396 Mon Sep 17 00:00:00 2001 From: ikemo Date: Wed, 4 May 2005 04:58:35 +0000 Subject: [PATCH] be.2ch.net popup thanks to http://jbbs.livedoor.jp/bbs/read.cgi/computer/18420/1104462454/9 git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1720 56b19765-1e22-0410-a548-a0f45d66c51a --- kita/src/libkita/datinfo.h | 2 ++ kita/src/libkita/kita_misc.cpp | 41 +++++++++++++++++++++++++---- kita/src/mainwindow.cpp | 2 +- kita/src/thread/htmlpart.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ kita/src/thread/htmlpart.h | 1 + 5 files changed, 99 insertions(+), 6 deletions(-) diff --git a/kita/src/libkita/datinfo.h b/kita/src/libkita/datinfo.h index 800029c..3d41d49 100644 --- a/kita/src/libkita/datinfo.h +++ b/kita/src/libkita/datinfo.h @@ -73,6 +73,8 @@ struct RESDAT QString date; QDateTime dateTime; QString id; + QString be; + QString bepointmark; QString host; QString bodyHTML; diff --git a/kita/src/libkita/kita_misc.cpp b/kita/src/libkita/kita_misc.cpp index a9d32e4..b848b61 100644 --- a/kita/src/libkita/kita_misc.cpp +++ b/kita/src/libkita/kita_misc.cpp @@ -818,12 +818,16 @@ void Kita::parseDateId( const QString& rawStr, RESDAT& resdat ) resdat.date = rawStr; resdat.id = QString::null; resdat.host = QString::null; + resdat.be = QString::null; + resdat.bepointmark = QString::null; const QChar *chpt = rawStr.unicode(); unsigned int pos = 0, startpos = 0; unsigned int length = rawStr.length(); - while ( chpt[ pos ] != '\0' && chpt[ pos ] != 'I' && chpt[ pos + 1 ] != 'D' ) { + while ( chpt[ pos ] != '\0' && + !( chpt[ pos ] == 'I' && chpt[ pos + 1 ] == 'D' ) && + !( chpt[ pos ] == 'B' && chpt[ pos + 1 ] == 'E' ) ) { pos++; } resdat.date = rawStr.left( pos ); @@ -841,6 +845,22 @@ void Kita::parseDateId( const QString& rawStr, RESDAT& resdat ) if ( pos >= length ) return ; + /* be */ + if ( chpt[ pos ] == 'B' && chpt[ pos + 1 ] == 'E' ) { + pos += 3; + startpos = pos; + while ( chpt[ pos ] != '-' && pos++ < length ); + resdat.be = rawStr.mid( startpos, pos - startpos ); + pos++; + if ( pos < length && chpt[ pos ] == '#') { + startpos = pos; + while ( chpt[ pos ] == '#' && pos++ < length ); + resdat.bepointmark = rawStr.mid( startpos, pos - startpos ); + } + } + + if ( pos >= length ) return ; + /* host */ if ( chpt[ pos ] == 'H' && chpt[ pos + 1 ] == 'O' ) { pos += 5; @@ -1274,21 +1294,32 @@ void Kita::createTitleHTML( RESDAT& resdat, QString& titleHTML ) /* date */ if ( useTableTag ) titleHTML += ""; - titleHTML += m_colonstr + resdat.date + " "; + titleHTML += m_colonstr + resdat.date; + if ( useTableTag ) titleHTML += ""; /* ID */ if ( resdat.id != QString::null ) { if ( useTableTag ) titleHTML += ""; - if ( resdat.id == "???" ) titleHTML += "ID:" + resdat.id; - else titleHTML += "ID" + ":" + resdat.id; + if ( resdat.id.contains( "???", true ) >= 1 ) titleHTML += " ID:" + resdat.id; + else titleHTML += " ID" + ":" + resdat.id; + if ( useTableTag ) titleHTML += ""; + } + + /* BE */ + if ( resdat.be != QString::null ) { + + if ( useTableTag ) titleHTML += ""; + titleHTML += " ?" + resdat.bepointmark + ""; + if ( useTableTag ) titleHTML += ""; } /* host */ if ( resdat.host != QString::null ) { if ( useTableTag ) titleHTML += ""; - titleHTML += "HOST:" + resdat.host; + titleHTML += " HOST:" + resdat.host; + if ( useTableTag ) titleHTML += ""; } if ( useTableTag ) titleHTML += ""; diff --git a/kita/src/mainwindow.cpp b/kita/src/mainwindow.cpp index c648344..f91927f 100644 --- a/kita/src/mainwindow.cpp +++ b/kita/src/mainwindow.cpp @@ -792,7 +792,7 @@ void KitaMainWindow::slotOpenURLRequestExt( const KURL& usrUrl1 ) { // FIXME: support be.2ch.net - if ( url.host() == "be.2ch.net" ) { + if ( url.host() == "be.2ch.net" && url.path().contains( "/test/p.php", true ) < 1 ) { QMessageBox::warning( this, "Kita", i18n( "be.2ch.net is currently not supported." ) ); diff --git a/kita/src/thread/htmlpart.cpp b/kita/src/thread/htmlpart.cpp index 6538dc9..fd23672 100644 --- a/kita/src/thread/htmlpart.cpp +++ b/kita/src/thread/htmlpart.cpp @@ -1432,6 +1432,14 @@ void KitaHTMLPart::clickAnchor( const KURL& urlin ) return ; } + /*---------------------------*/ + /* show popupmenu for #bepop */ + + if ( refstr.left( 5 ) == "bepop" ) { + showBePopupMenu( refstr ); + return ; + } + /*-------------------------*/ /* start multi-popup mdde */ if ( m_pushrightbt && startMultiPopup() ) return ; @@ -1722,6 +1730,57 @@ void KitaHTMLPart::showIDPopup( const QString& refstr ) +/*---------------------------------------------------------*/ +/* popup menu that is opened when user clicked be anchor. */ +/* This funtcion is called in only clickAnchor(). */ /* private */ +void KitaHTMLPart::showBePopupMenu( const QString& refstr ) +{ + QString strURL = "http://be.2ch.net/test/p.php?i=" + refstr.mid( 5 ) + + "&u=d:" + Kita::DatManager::threadURL( m_datURL ) + "/l50"; + + if ( m_pushrightbt ) { + /*---------------------*/ + /* create popup menu */ + KPopupMenu *popupMenu = new KPopupMenu( view() ); + popupMenu->clear(); + + enum{ + BEMENU_COPYURL, + BEMENU_SHOWBROWSER + }; + + QClipboard * clipboard = QApplication::clipboard(); + + popupMenu->insertItem( i18n( "copy URL" ), BEMENU_COPYURL ); + popupMenu->insertItem( i18n( "Open with Web Browser" ), BEMENU_SHOWBROWSER ); + + /*--------------------------------------*/ + /* show popup menu */ + + int ret = popupMenu->exec( QCursor::pos() ); + delete popupMenu; + switch ( ret ) { + + case BEMENU_COPYURL: + /* copy */ + clipboard->setText( strURL, QClipboard::Clipboard ); + clipboard->setText( strURL, QClipboard::Selection ); + break; + + case BEMENU_SHOWBROWSER: + emit openURLRequestExt( strURL, KParts::URLArgs(), "text/html" ); + break; + + default: + break; + } + } else { + emit openURLRequestExt( strURL, KParts::URLArgs(), "text/html" ); + } +} + + + /*-------------------------------------------------------*/ /* funtcion when user clicked next 100 ,before 100 ,etc. */ /* This funtcion is called in only clickAnchor(). */ /* private */ diff --git a/kita/src/thread/htmlpart.h b/kita/src/thread/htmlpart.h index fe6a442..11a3662 100644 --- a/kita/src/thread/htmlpart.h +++ b/kita/src/thread/htmlpart.h @@ -164,6 +164,7 @@ private: void clickAnchor( const KURL& urlin ); void showWritePopupMenu( const QString& refstr ); void showIDPopup( const QString& refstr ); + void showBePopupMenu( const QString& refstr ); bool showNext100Etc( const QString& refstr ); /* search */ -- 2.11.0