/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
+* Copyright (C) 2003 by Hideki Ikemoto , 2004 by 421 *
* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
* (at your option) any later version. *
***************************************************************************/
-#include "kitahtmlpart.h"
-
-#include "kitathreadview.h"
-#include "kitahtmlview.h"
-#include "kitadomtree.h"
-#include "libkita/kitaconfig.h"
-
#include <kpopupmenu.h>
#include <klocale.h>
-#include <khtmlview.h>
-#include <dom/html_element.h>
#include <khtml_events.h>
+#include <kdebug.h>
+#include <krun.h>
+
+#include <dom/html_element.h>
+#include <qcursor.h>
#include <qapplication.h>
#include <qclipboard.h>
+#include <qmessagebox.h>
+#include <qregexp.h>
+
+#include "kitahtmlpart.h"
+#include "kitahtmlview.h"
+#include "kitadomtree.h"
+#include "kitanavi.h"
-#include "libkita/thread.h"
-#include "libkita/access.h"
+#include "libkita/kitaconfig.h"
+#include "libkita/datmanager.h"
+#include "libkita/parsemisc.h"
#include "libkita/signalcollection.h"
-enum {
- ID_COPY_Link,
- ID_Start_Link,
- ID_Temp_Link,
- ID_Koko_Link,
- ID_End_Link,
- ID_SAVEC_Link,
- ID_Back_Link,
- ID_Copy_Str,
- ID_Ext_Str,
- ID_Del_IMGCache,
- ID_COPY_IMGCachepath,
- ID_DEL_ThreadLog,
- ID_Abone_Word
-};
+/*-------------------------------------------*/
+
+
+/*-------------------------------------*/
+/* Don't forget to call setup() later. */
KitaHTMLPart::KitaHTMLPart( QWidget* parent, const char* name )
: KHTMLPart( new KitaHTMLView( this, parent, name ) )
- , m_parent( parent )
- , m_thread ( 0)
{
- connect( this, SIGNAL( popupMenu( const QString&, const QPoint& ) ),
- SLOT( slotPopupMenu( const QString&, const QPoint& ) ) );
+ m_mode = HTMLPART_MODE_KHTML;
+ m_popup = NULL;
+ m_domtree = NULL;
+ m_datURL = QString::null;
+ m_updatedKokoyon = FALSE;
+
+ clearPart();
+ createHTMLDocument();
+ connectSignals();
+}
+
+
+KitaHTMLPart::~KitaHTMLPart()
+{
+ clearPart();
+}
+
+
+/* private */
+void KitaHTMLPart::clearPart(){
+
+ deletePopup();
+
+ /* delete KitaDomTree */
+ if ( m_domtree ) delete m_domtree;
+ m_domtree = NULL;
+
+ /* update Kokomade Yonda */
+ if( m_mode == HTMLPART_MODE_MAINPART && !m_updatedKokoyon && !m_datURL.isEmpty()) {
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+ if( maxNum ) Kita::DatManager::setKokoyonNum( m_datURL, maxNum );
+ }
+ m_updatedKokoyon = FALSE;
+
+ /* don't forget to unlock previous datURL here. */
+ if( !m_datURL.isEmpty() ) Kita::DatManager::unlock( m_datURL );
+
+ m_anchorStack.clear();
+ m_centerNum = 0;
+ findTextInit();
+
+ for( int i = 0; i < 1200 ; i++ ) m_check[ i ] = FALSE;
+}
+
+
+
+/* public */
+bool KitaHTMLPart::setup( int mode, const KURL& url )
+{
+ 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 );
+
+ /* reset abone */
+ Kita::DatManager::resetAbone( m_datURL );
+
+ /* create HTML Document */
+ createHTMLDocument();
+
+ /* create DOM manager */
+ m_mode = mode;
+ if( m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ){
+ m_domtree = new KitaDomTree( htmlDocument(), m_datURL );
+ }
+
+ return TRUE;
+}
+
+
+/* private */
+void KitaHTMLPart::connectSignals(){
+
+ Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
+
+
+ /* rendering */
+ connect( this, SIGNAL( redrawScreen( const KURL&, bool ) ), signalCollection, SIGNAL( redrawScreen( const KURL&, bool ) ));
+ connect( signalCollection, SIGNAL( redrawScreen( const KURL&, bool ) ), SLOT( slotRedrawScreen( const KURL& , bool) ));
+
+ /* popup */
+ 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( signalCollection, SIGNAL( kitaIsActive() ), SLOT( slotKitaIsActive() ));
+ connect( signalCollection, SIGNAL( windowDeactivated() ), SLOT( slotHideChildPopup() ));
+
+
+ /* click */
connect( this, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
- Kita::SignalCollection::getInstance(), SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ) );
+ signalCollection, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ) );
-
- m_popupMenu = new KPopupMenu( view() );
- m_domtree = NULL;
- m_threadView = NULL;
- begin();
- write( " " );
+ /* goto anchor */
+ connect( view(), SIGNAL( pushDown() ), SLOT( slotClickTugi100() ));
+}
+
+
+
+/* private */
+void KitaHTMLPart::createHTMLDocument()
+{
+ /* style */
+ QString style = QString( "style=\"font-size: %1pt; "
+ "font-family: %2; "
+ "color: %3; "
+ "background-color: %4; border-width: 0; \"" )
+ .arg( KitaConfig::threadFont().pointSize() )
+ .arg( KitaConfig::threadFont().family() )
+ .arg( KitaConfig::threadColor().name() )
+ .arg( KitaConfig::threadBackgroundColor().name() );
+
+ QString text = "<html><head></head>";
+ text += "<body " + style + "></body></html>";
+
+ setJScriptEnabled( false );
+ setJavaEnabled( false );
+
+ /* Use dummy URL here, and protocol should be "file:".
+ If protocol is "http:", local image files are not shown
+ (for security reasons ?).
+ */
+ begin( "file:/dummy.htm" );
+ write( text );
end();
- show();
}
-KitaHTMLPart::~KitaHTMLPart()
+
+/* public */
+const int KitaHTMLPart::getMode() const { return m_mode; }
+
+
+
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* direct rendering functions */
+
+
+/*-----------------*/
+/* show responses */
+
+/* !!! don't forget to call updateScreen() later !!! */ /* public */
+void KitaHTMLPart::showResponses( int startnum, int endnum )
{
- if(m_popupMenu) delete m_popupMenu;
+ if( !m_domtree ) return;
+
+ for ( int i = startnum ; i <= endnum; i++ ) m_domtree->appendRes( i, FALSE );
}
-bool KitaHTMLPart::gotoAnchor( const QString& name )
+
+/* do parsing only. */
+/* call showResponses() later */ /* public */
+void KitaHTMLPart::parseResponses( int startnum, int endnum )
{
- pushCurrentPosition();
- return KHTMLPart::gotoAnchor( name );
+ if( !m_domtree ) return;
+
+ for ( int i = startnum ; i <= endnum; i++ ) m_domtree->parseRes( i, i );
}
-/* setup */
-void KitaHTMLPart::setupEx( KitaThreadView* threadView, KitaDomTree* domtree,
- Kita::Thread* thread )
+/*------------------------------------------------*/
+/* Show all responses ,header, footer, and etc,
+ if these are not shown. */
+
+/* note that updateScreen() is called internally. */
+/* So, you need not call it later. */ /* public slot */
+void KitaHTMLPart::showAll()
{
- m_threadView = threadView;
- m_domtree = domtree;
- m_thread = thread;
- m_anchorStack.clear();
+ if( !m_domtree ) return;
+
+ int top = m_domtree->getTopResNumber();
+ int bottom = m_domtree->getBottomResNumber();
+ int totalNum = Kita::DatManager::getMaxResNumber( m_datURL );
+ if ( top != 1 || bottom != totalNum ) {
+ showResponses( 1, totalNum );
+ updateScreen( TRUE, TRUE );
+ }
}
-void KitaHTMLPart::pushCurrentPosition()
+/*------------------------*/
+/* insert belt node */
+
+/* !!! don't forget to call updateScreen() later !!! */ /* public */
+void KitaHTMLPart::insertBeltNode( const QString& idstr )
{
- QString anchor, ancundermouse;
- DOM::Node node;
+ if( !m_domtree ) return;
- /* find the current node */
- node = nodeUnderMouse();
- while ( node != NULL && node.nodeName().string() != "div" )
- node = node.parentNode();
- if ( node == NULL ) return ;
- anchor = static_cast<DOM::Element>( node ).getAttribute( "id" ).string();
+ m_domtree->createBeltNode( idstr );
+}
- m_anchorStack += anchor;
+
+/*--------------------------*/
+/* insert header node */
+
+/* !!! don't forget to call updateScreen() later !!! */ /* public */
+void KitaHTMLPart::insertHeaderNode( const QString& str )
+{
+ if( !m_domtree ) return;
+
+ m_domtree->createCommentNode( str, "header", 0, 2, TRUE );
}
-/* jump to kokomade yonda */
-void KitaHTMLPart::gotoKokoyon()
+/*--------------------------*/
+/* insert footer node */
+
+/* !!! 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 );
+}
+
- int num = m_domtree->getKokoyonNum() - 1;
- while ( num > 0 ) {
- if ( m_domtree->isResShown( num ) ) break;
- num--;
+/*-------------------*/
+/* update screen */ /* public */
+void KitaHTMLPart::updateScreen( bool showHeaderEtc, bool clock )
+{
+ if( !m_domtree ) return;
+
+ /* show clock cursor */
+ if( clock ){
+ QCursor qc; qc.setShape( Qt::WaitCursor );
+ QApplication::setOverrideCursor( qc );
}
- KHTMLPart::gotoAnchor( QString().setNum( num ) );
-}
+ /* show header, footer, and kokomadeyonda, etc. */
+ if( showHeaderEtc ){
+
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL);
+ m_domtree->appendMae100();
+ m_domtree->appendTugi100();
+ m_domtree->appendKokoyon();
+ m_domtree->appendFooter( maxNum );
+ }
+ /*----------------------------*/
+
+ /* update display */
+ htmlDocument().applyChanges();
+ view()->layout();
+ view()->setVScrollBarMode( QScrollView::AlwaysOn );
+ view()->setFocus();
-/*-------------------------------------------------------------------*/
+ if(clock) QApplication::restoreOverrideCursor();
+}
-/* public slots */
-bool KitaHTMLPart::gobackAnchor()
+/* public */
+void KitaHTMLPart::setInnerHTML( const QString& innerHTML )
{
- QString anchor;
+ createHTMLDocument();
+ htmlDocument().body().setInnerHTML( innerHTML );
+}
- if ( m_anchorStack.empty() ) return FALSE;
- anchor = m_anchorStack.last();
- m_anchorStack.pop_back();
- return KHTMLPart::gotoAnchor( anchor );
+/* redraw screen */
+/* This slot is connected to signalCollection. */ /* public slot */
+void KitaHTMLPart::slotRedrawScreen( const KURL& datURL, bool force ){
+
+ if( m_domtree == NULL ) return;
+ if( m_datURL != datURL ) return;
+
+ m_domtree->redraw( force );
}
-/*--------------------------------------------------*/
-/* private slot */
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* cache functions */
-/* show popup menu */
-void KitaHTMLPart::slotPopupMenu( const QString& url, const QPoint& point )
-{
- if(!m_threadView) return;
- if(!m_domtree) return;
+
+/*----------------------------------*/
+/* load thread from cache & show it */ /* public */
+
+/* top = centerNum - preShowNum
+ bottom = centerNum + afterShowNum
+ maxNum = ita::DatManager::getMaxResNumber
+
+ No.1 <- show -> No.20 <- not show -> No.(top) <- show -> No.(bottom) <- not show -> No.(maxNum) */
+
+bool KitaHTMLPart::load( int centerNum ){
- QString str;
- DOM::Node node = nodeUnderMouse();
+ /* config */
+
+ const int preShowNum = 50;
+ const int afterShowNum = KitaConfig::afterShowNum();
+
+ /*--------------------------------*/
+ m_centerNum = centerNum;
+
+ if( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
+ if( !m_domtree ) return FALSE;
+ if( Kita::DatManager::getMaxResNumber( m_datURL ) == 0 ) return FALSE;
+
+ m_domtree->appendTemplate();
+ showResponses( m_centerNum - preShowNum, m_centerNum + afterShowNum );
+ updateScreen( TRUE , FALSE );
+ gotoAnchor( QString().setNum( m_centerNum ), FALSE );
+ view()->setFocus();
+
+ return TRUE;
+}
+
+
+
+/*----------------------------*/
+/* start reloading */
- m_popupMenu->clear();
+/* see also slotReceiveData()
+ and slotFinishLoad(). */ /* public */
+bool KitaHTMLPart::reload()
+{
+ /* config */
+
+ const bool online = TRUE;
+
+ /*--------------------------------*/
- if ( !m_anchorStack.empty() ) {
- str = i18n( "Back (%1)" ).arg( m_anchorStack.last() );
- m_popupMenu->insertItem( str, ID_Back_Link );
- m_popupMenu->insertSeparator();
+ 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 );
+ return FALSE;
}
- m_popupMenu->insertItem( i18n( "Start" ), ID_Start_Link );
+ m_domtree->StopParseThread();
+ m_firstReceive = TRUE;
+ if( m_centerNum == 0 ) m_centerNum = m_domtree->getBottomResNumber();
+
+ /* DatManager will call back slotReceiveData and slotFinishLoad. */
+ Kita::DatManager::updateCache( m_datURL , this );
+ view()->setFocus();
+
+ return TRUE;
+}
+
+
+
+/*---------------------------------------------*/
+/* This slot is called after Kita::DatManager
+ received new data, and emits receiveData() */ /* !!! "public" slot !!! */
+void KitaHTMLPart::slotReceiveData()
+{
+ /* config */
+
+ const int delta = 20;
+ const int afterShowNum = KitaConfig::afterShowNum();;
+ const int oneAfterAnother = TRUE;
+
+ /*--------------------------------*/
+
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
+ if( !m_domtree ) return;
+
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+ int bottom = m_domtree->getBottomResNumber();
+ int showNum = m_centerNum + afterShowNum;
+
+ /* parsing */
+ if( oneAfterAnother ) parseResponses( bottom+1, maxNum );
- if ( m_domtree->isMae100Shown() ) {
- m_popupMenu->insertItem( i18n( "template" ), ID_Temp_Link );
+ /* rendering */
+ if( m_firstReceive
+ || ( bottom + delta < maxNum && maxNum <= showNum + delta -1 ) ){
+
+ if( oneAfterAnother ){
+ showResponses( bottom+1, QMIN( maxNum, showNum ) );
+ updateScreen( TRUE, FALSE );
+ }
+ else parseResponses( bottom+1, QMIN( maxNum, showNum ) );
+ }
+
+ if( m_firstReceive && m_centerNum < maxNum ){
+ gotoAnchor( QString().setNum( m_centerNum ), FALSE );
+ m_firstReceive = FALSE;
}
+
+ emit receiveData();
+}
+
+
+/*--------------------------------------------*/
+/* This slot is called after Kita::DatManager
+ finished updating new data,
+ and emits finishReload() */ /* !!! "public" slot !!! */
+void KitaHTMLPart::slotFinishLoad()
+{
+ /* config */
+ const int afterShowNum = KitaConfig::afterShowNum();;
+
+ /*--------------------------------*/
+
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
+ if( !m_domtree ) return;
+
+ int bottom = m_domtree->getBottomResNumber();
+ int shownNum = m_centerNum + afterShowNum;
+
+ showResponses(bottom+1, shownNum );
+ updateScreen( TRUE, FALSE );
+ m_domtree->parseAllRes();
+ m_centerNum = 0;
+
+ emit finishReload();
+}
+
+
+
+
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* goto anchor */
+
+
+/* public */
+bool KitaHTMLPart::gotoAnchor( const QString& anc, bool pushPosition )
+{
+ if( anc == QString::null ) return FALSE;
+ if( !m_domtree ) return KHTMLPart::gotoAnchor( anc );
+
+ hidePopup();
+
+ QString ancstr = anc;
+ int res = ancstr.toInt();
- if ( m_domtree->getKokoyonNum() ) {
- str = i18n( "Kokomade Yonda (%1)" ).arg( m_domtree->getKokoyonNum() );
- m_popupMenu->insertItem( str, ID_Koko_Link );
+ 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_mode != HTMLPART_MODE_MAINPART ) return FALSE;
+
+ int top = m_domtree->getTopResNumber();
+ int bottom = m_domtree->getBottomResNumber();
+
+ if ( res > bottom ){
+ showResponses( bottom + 1, res );
+ updateScreen( TRUE, TRUE );
+ }
+ else if ( res < top ) {
+ m_domtree->appendTemplate();
+ showResponses( res, bottom );
+ updateScreen( TRUE , TRUE );
+ }
+ }
+
+ /* Target is not shown. Maybe it is aboned. */
+ while ( res > 1 && !m_domtree->isResShown( res ) ) res--;
+
+ ancstr = QString().setNum( res );
}
+
+ if ( res == 1 ) ancstr = "header";
+ if ( pushPosition ) pushCurrentPosition();
+ return KHTMLPart::gotoAnchor( ancstr );
+}
+
+
+
+/* jump to kokomade yonda */ /* public slot */
+void KitaHTMLPart::slotGotoKokoyon()
+{
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
+
+ int kokoyon = Kita::DatManager::getKokoyonNum( m_datURL );
+ gotoAnchor( QString().setNum( kokoyon ), TRUE );
+}
+
+
+
+/* public slot */
+void KitaHTMLPart::slotGobackAnchor()
+{
+ if ( m_anchorStack.empty() ) return;
- m_popupMenu->insertItem( i18n( "End" ), ID_End_Link );
+ QString anc = m_anchorStack.last();
+ m_anchorStack.pop_back();
+ gotoAnchor( anc , FALSE );
+}
+
+
+
+
+/* private */
+void KitaHTMLPart::pushCurrentPosition()
+{
+ QString anchor, ancundermouse;
+ DOM::Node node;
+
+ /* find the id of current node */
+ node = nodeUnderMouse();
+ while ( node != NULL && node.nodeName().string() != "div" ) node = node.parentNode();
+ if ( node == NULL ) return ;
+ anchor = static_cast<DOM::Element>( node ).getAttribute( "id" ).string();
+
+ m_anchorStack += anchor;
+}
+
+
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* Tugi100, Mae100 etc. */
+
+
+/* public slot */
+void KitaHTMLPart::slotClickTugi100()
+{
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
- if ( hasSelection() ) {
- m_popupMenu->insertSeparator();
- m_popupMenu->insertItem( i18n( "Copy" ), ID_Copy_Str );
- m_popupMenu->insertItem( i18n( "Add '%1' to abone list" ).arg( selectedText() ), ID_Abone_Word );
+ int bottom = m_domtree->getBottomResNumber();
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+
+ if ( maxNum != bottom ) {
+ showResponses( bottom + 1, bottom + 100 );
+ updateScreen( TRUE, TRUE );
}
+}
+
+
+
+/* public slot */
+void KitaHTMLPart::slotClickNokori()
+{
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
- if ( url != NULL ) {
- m_popupMenu->insertSeparator();
- m_popupMenu->insertItem( i18n( "Copy Link Location" ), ID_COPY_Link );
+ int bottom = m_domtree->getBottomResNumber();
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+
+ if ( maxNum != bottom ) {
+ showResponses( bottom + 1, maxNum );
+ updateScreen( TRUE, TRUE );
+ }
+}
+
+/* public slot */
+void KitaHTMLPart::slotClickGotoFooter()
+{
+ if( !m_domtree
+ || m_mode != HTMLPART_MODE_MAINPART
+ ){
+ gotoAnchor( "footer", TRUE );
+ return;
}
- if ( m_threadView->getViewMode() == VIEWMODE_PARENT ) {
- m_popupMenu->insertSeparator();
- m_popupMenu->insertItem( i18n( "Clear Log and Reload" ), ID_DEL_ThreadLog );
+ int bottom = m_domtree->getBottomResNumber();
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+
+ if ( maxNum != bottom ) {
+ showResponses( bottom + 1, maxNum );
+ updateScreen( TRUE, TRUE );
}
- QClipboard* clipboard = QApplication::clipboard();
+ gotoAnchor( "footer", TRUE );
+}
- switch ( m_popupMenu->exec( point ) ) {
- case ID_COPY_Link:
- clipboard->setText( url , QClipboard::Clipboard );
- clipboard->setText( url , QClipboard::Selection );
- break;
- case ID_Start_Link: gotoAnchor( "header" ); break;
- case ID_Temp_Link: gotoAnchor( "mae100" ); break;
- case ID_Koko_Link: gotoKokoyon();break;
- case ID_End_Link: gotoAnchor( "footer" ); break;
- case ID_Back_Link: gobackAnchor(); break;
- case ID_Copy_Str:
- clipboard->setText( selectedText(), QClipboard::Clipboard );
- break;
- case ID_DEL_ThreadLog:
- if ( Kita::Access::deleteLog( m_thread, m_parent ) )
- m_threadView->showThread( m_thread );
- break;
+/* public slot */
+void KitaHTMLPart::slotClickMae100()
+{
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
+
+ int top = m_domtree->getTopResNumber();
+ int bottom = m_domtree->getBottomResNumber();
+
+ if ( top != 1 ) {
+ m_domtree->appendTemplate();
+ showResponses( top - 100, bottom );
+ updateScreen( TRUE, TRUE );
- case ID_Abone_Word:
- KitaConfig::addAboneWord( selectedText() );
- break;
-
- default:
- break;
+ gotoAnchor( QString().setNum( top ), FALSE );
}
}
-/*----------------------------------------------------*/
-
-/* protected functions */
-void KitaHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent* e )
+/* public slot */
+void KitaHTMLPart::slotClickMaeZenbu()
{
- m_pushctrl = FALSE;
- m_pushmidbt = FALSE;
- m_pushrightbt = FALSE;
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
+
+ int top = m_domtree->getTopResNumber();
+ int bottom = m_domtree->getBottomResNumber();
+
+ if ( top != 1 ) {
+ showResponses( 1, bottom );
+ updateScreen( TRUE, TRUE);
- /* cancel popup */
- if(e->qmouseEvent()->button() & Qt::RightButton){
- m_pushrightbt = TRUE;
- return;
+ gotoAnchor( QString().setNum( top ), FALSE );
}
+}
+
+
+/* public slot */
+void KitaHTMLPart::slotClickTmpNext100()
+{
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
- /* check if ctrl key is pushed */
- if ( e->url() != NULL ) {
+ int top = m_domtree->getTopResNumber();
+ int bottom = m_domtree->getBottomResNumber();
+ int tmpnum = m_domtree->getTemplateNumber();
- if ( e->qmouseEvent() ->state() & Qt::ControlButton ) {
- m_pushctrl = TRUE;
- }
- if ( e->qmouseEvent() ->button() & Qt::MidButton ) {
- m_pushmidbt = TRUE;
- }
+ if ( tmpnum < top ) {
+ m_domtree->setTemplateNumber( tmpnum + 100 );
+ m_domtree->appendTemplate();
+ showResponses( top, bottom );
+ updateScreen( TRUE, TRUE );
- if ( m_pushctrl || m_pushmidbt ) {
- KURL kurl;
- if ( e->url().string().at( 0 ) == '#' ) {
- kurl = m_thread->datURL() + e->url().string();
- } else {
- kurl = KURL( m_thread->boardURL(), e->url().string() );
- }
+ gotoAnchor( QString().setNum( tmpnum ), FALSE );
+ }
+}
- if ( m_pushctrl ) {
- emit browserExtension() ->openURLRequest( kurl );
- }
+
+/* public slot */
+void KitaHTMLPart::slotClickShowAll()
+{
+ if( !m_domtree ) return;
+ if( m_mode != HTMLPART_MODE_MAINPART ) return;
+
+ int top = m_domtree->getTopResNumber();
+ int bottom = m_domtree->getBottomResNumber();
+ int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
- return ;
- }
+ if ( top != 1 || bottom != maxNum ) {
+ showResponses( 1, maxNum );
+ updateScreen( TRUE, TRUE );
+
+ gotoAnchor( "header", FALSE );
}
- KHTMLPart::khtmlMousePressEvent( e );
}
-void KitaHTMLPart::khtmlMouseMoveEvent( khtml::MouseMoveEvent* e )
+
+
+
+
+
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* search */
+
+
+/* private */
+void KitaHTMLPart::findTextInit()
{
- KHTMLPart::khtmlMouseMoveEvent( e );
+ m_findNode = NULL;
+ m_findPos = -1;
+ m_find_y = 0;
}
-void KitaHTMLPart::khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *e )
+
+
+/* public */
+bool KitaHTMLPart::findText( const QString &query, bool reverse )
{
- if ( e->qmouseEvent() ->button() & Qt::RightButton ) {
- /* popup */
- if ( e->url().string().left(6) == "#idpop" ||
- (m_pushrightbt && e->url().string().left(6) == "#write" )) {
- KURL kurl;
- kurl = m_thread->datURL() + e->url().string();
- emit browserExtension() ->openURLRequest( kurl );
- return ;
- }
+ if( m_mode != HTMLPART_MODE_MAINPART && m_mode != HTMLPART_MODE_NAVI ) return FALSE;
- /* popup here & return */
- slotPopupMenu( e->url().string(), e->qmouseEvent() ->globalPos() );
- return ;
+ QRegExp regexp( query );
+ regexp.setCaseSensitive( FALSE );
+
+ /* init */
+ if ( m_findNode.isNull() ) {
+
+ m_findNode = htmlDocument().body();
+ m_find_y = 0;
+
+ /* move to the last child node */
+ if ( reverse ) {
+ while ( !m_findNode.lastChild().isNull() ) m_findNode = m_findNode.lastChild();
+ m_find_y = view()->contentsHeight();
+ }
}
- KHTMLPart::khtmlMouseReleaseEvent( e );
-}
+
+ while ( 1 ) {
+
+ if ( m_findNode.nodeType() == DOM::Node::TEXT_NODE
+ || m_findNode.nodeType() == DOM::Node::CDATA_SECTION_NODE ){
+
+ /* find the word in the current node */
+ DOM::DOMString nodeText = m_findNode.nodeValue();
+ QString nodestr = nodeText.string();
+ if ( reverse && m_findPos != -1 ) nodestr.setLength( m_findPos );
+
+ if ( reverse ) m_findPos = nodestr.findRev( regexp, m_findPos );
+ else m_findPos = nodestr.find( regexp, m_findPos + 1 );
+
+ /* scroll & select & return */
+ if ( m_findPos != -1 ) {
+
+ int matchLen = regexp.matchedLength();
+
+ QRect qr = m_findNode.getRect();
+ view()->setContentsPos( qr.left() - 50, m_find_y - 100 );
+ DOM::Range rg( m_findNode, m_findPos, m_findNode, m_findPos + matchLen );
+ setSelection( rg );
+
+ return TRUE;
+ }
+
+ }
+
+ /*------------------------*/
+ else if ( m_findNode.nodeName().string() == "dt"
+ || m_findNode.nodeName().string() == "dd" ){
+
+ 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" ) {
+
+ DOM::Node tmpnode = m_findNode.previousSibling();
+
+ if ( tmpnode != NULL ) {
+
+ QRect qr = tmpnode.getRect();
+ if ( reverse ) m_find_y -= qr.bottom() - qr.top();
+ else m_find_y += qr.bottom() - qr.top();
+ }
+ }
+
+ /*------------------------*/
+
+ m_findPos = -1;
+ DOM::Node next;
+
+ /* move to the next node */
+ if ( !reverse ) {
+
+ next = m_findNode.firstChild();
+ if ( next.isNull() ) next = m_findNode.nextSibling();
+
+ while ( !m_findNode.isNull() && next.isNull() ) {
+ m_findNode = m_findNode.parentNode();
+ if ( !m_findNode.isNull() ) next = m_findNode.nextSibling();
+ }
+ }
+ /* revearse */
+ else {
+
+ next = m_findNode.lastChild();
+ if ( next.isNull() ) next = m_findNode.previousSibling();
+
+ 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() ) {
+ m_findNode = NULL;
+ return FALSE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+
+
+
+
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* popup menu */
+
+
+/* private */
+void KitaHTMLPart::showPopupMenu( const KURL& kurl )
+{
+ enum {
+ ID_Home_Link,
+ ID_Temp_Link,
+ ID_Koko_Link,
+ ID_End_Link,
+
+ ID_COPY_Link,
+ ID_Copy_Str,
+ ID_Abone_Word,
+ ID_Extract,
+
+
+ /*-----------------*/
+ ID_Back_Link /* stay bottom */
+ };
+
+ QPoint point = QCursor::pos();
+ QString url = kurl.prettyURL();
+ bool showppm = FALSE;
+ const int ID_Goto_Check = ID_Back_Link + m_anchorStack.size();
+
+ QString str;
+
+ /* If selected Text is composed of only digits, then show res popup. */
+ if( !m_pushctrl && showSelectedDigitPopup() ) return;
+
+ /*-----------------------------------*/
+ /* create menu items */
+
+ KPopupMenu* popupMenu = new KPopupMenu( view() );
+ KPopupMenu* backSubMenu = NULL;
+ KPopupMenu* checkSubMenu = NULL;
+
+ popupMenu->clear();
+
+
+ /*------*/
+ /* jump */
+ if( m_domtree &&
+ (m_mode == HTMLPART_MODE_MAINPART || m_mode == HTMLPART_MODE_NAVI ) ){
+
+ showppm = TRUE;
+
+ /* back */
+ 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 );
+ }
+
+ popupMenu->insertItem( i18n( "Back" ), backSubMenu );
+ popupMenu->insertSeparator();
+ }
+
+ /* check */
+ for( int i = 1; i <= Kita::DatManager::getMaxResNumber( m_datURL ) ; i++ ){
+ if( m_check[ i ] ){
+ if( !checkSubMenu ){
+ checkSubMenu = new KPopupMenu( view() );
+ checkSubMenu->clear();
+ popupMenu->insertItem( i18n( "Check" ), checkSubMenu );
+ popupMenu->insertSeparator();
+ }
+
+ str = QString().setNum( i ) + " "
+ + Kita::DatManager::getPlainBody( m_datURL, i ).left( 10 );
+ checkSubMenu->insertItem( str, ID_Goto_Check + i );
+ }
+ }
+
+ /* home */
+ popupMenu->insertItem( i18n( "Start" ), ID_Home_Link );
+
+
+ /* template */
+ if ( m_mode == HTMLPART_MODE_MAINPART ){
+
+ if( m_domtree->isMae100Shown() ) popupMenu->insertItem( i18n( "template" ), ID_Temp_Link );
+
+ int kokoyon = Kita::DatManager::getKokoyonNum( m_datURL );
+ if( kokoyon ){
+ str = i18n( "Kokomade Yonda (%1)" ).arg( kokoyon );
+ popupMenu->insertItem( str, ID_Koko_Link );
+ }
+ }
+
+
+ /* end */
+ popupMenu->insertItem( i18n("End"), ID_End_Link );
+ }
+
+
+ /*--------------*/
+ /* copy & abone */
+ if ( hasSelection() ) {
+ if( showppm ) popupMenu->insertSeparator();
+ showppm = TRUE;
+
+ popupMenu->insertItem( "Copy", ID_Copy_Str );
+
+ popupMenu->insertItem( i18n( "Extract by '%1'" ).arg( selectedText() ), ID_Extract );
+ popupMenu->insertItem( i18n( "Add '%1' to abone list" ).arg( selectedText() ), ID_Abone_Word );
+ }
+
+
+ /*-----------*/
+ /* copy link */
+ if ( url != QString::null ) {
+ if( showppm ) popupMenu->insertSeparator();
+ showppm = TRUE;
+
+ popupMenu->insertItem( i18n( "Copy Link Location" ), ID_COPY_Link );
+ }
+
+
+ /*-----------------------------------*/
+
+ /* show menu */
+ if( showppm ){
+
+ QClipboard* clipboard = QApplication::clipboard();
+
+ int ret = popupMenu->exec( point );
+ switch ( ret ) {
+
+ case ID_COPY_Link:
+ clipboard->setText( url , QClipboard::Clipboard );
+ clipboard->setText( url , QClipboard::Selection );
+ break;
+
+ case ID_Home_Link: gotoAnchor( "header", TRUE ); break;
+
+ case ID_Temp_Link: gotoAnchor( "mae100", TRUE ); break;
+
+ case ID_Koko_Link: slotGotoKokoyon(); break;
+
+ case ID_End_Link: slotClickGotoFooter(); break;
+
+ case ID_Copy_Str:
+ clipboard->setText( selectedText(), QClipboard::Clipboard );
+ break;
+
+ case ID_Abone_Word:
+
+ if ( QMessageBox::question( view(),"Kita",
+ i18n( "Do you want to add '%1' to abone list ?" ).arg( selectedText() ),
+ QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
+ == QMessageBox::Ok ){
+
+ KitaConfig::addAboneWord( selectedText() );
+ Kita::DatManager::resetAbone( m_datURL );
+ emit redrawScreen( m_datURL, FALSE );
+ }
+
+ break;
+
+ case ID_Extract:
+ KitaNavi::showKitaNaviByWord( m_datURL, selectedText() );
+ break;
+
+ default:
+
+ /* check */
+ if( ret >= ID_Goto_Check ){
+ gotoAnchor( QString().setNum( ret - ID_Goto_Check ), FALSE );
+ }
+
+ /* back */
+ else if( ret >= ID_Back_Link ){
+ for(int i = 0; i < ret - ID_Back_Link; i++ ) m_anchorStack.pop_back();
+ slotGobackAnchor();
+ }
+
+ break;
+ }
+
+ }
+
+ if( popupMenu ) delete popupMenu;
+ if( backSubMenu ) delete backSubMenu;
+ if( checkSubMenu ) delete checkSubMenu;
+}
+
+
+
+/*---------------------------------------------------------------*/
+/*---------------------------------------------------------------*/
+/* mouse event */
+
+
+/* protected */
+void KitaHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent* e )
+{
+ KURL kurl;
+ if( e->url().string() != QString::null )
+ kurl = KURL( Kita::DatManager::thread_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() ->state() & Qt::ControlButton ) m_pushctrl = TRUE;
+ if ( e->qmouseEvent() ->button() & Qt::MidButton ) m_pushmidbt = TRUE;
+
+ if ( e->url() != NULL ){
+
+ 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;
+ }
+
+ /* popup menu */
+ if( m_pushrightbt ) {
+ showPopupMenu( kurl );
+ m_pushctrl = m_pushmidbt = m_pushrightbt = FALSE;
+ return;
+ }
+
+ KHTMLPart::khtmlMousePressEvent( e );
+}
+
+
+
+
+
+/*-------------------------------------------------------*/
+/*-------------------------------------------------------*/
+/* click */
+
+
+
+/* private slot */
+void KitaHTMLPart::slotOpenURLRequest( const KURL& urlin, const KParts::URLArgs& ){
+ clickAnchor(urlin);
+}
+
+
+/*------------------------------------------------------*/
+/* This function is called when user clicked res anchor */ /* private */
+void KitaHTMLPart::clickAnchor( const KURL& urlin )
+{
+ QString refstr;
+ KURL datURL = Kita::ParseMisc::parseURL( urlin ,refstr );
+
+ /*--------------------*/
+ /* Ctrl + right click */
+ if( m_pushctrl && m_pushrightbt ){
+ showPopupMenu( urlin );
+ return;
+ }
+
+ /*--------------------------------*/
+ /* If this is not anchor, then */
+ /* emit openURLRequest and return */
+
+ if ( datURL.host() != m_datURL.host() || datURL.path() != m_datURL.path() ) {
+
+ if( m_pushrightbt ){ /* right click */
+
+ /* start multi-popup mode or show popup menu */
+ if( !startMultiPopup() ) showPopupMenu( urlin );
+
+ return;
+ }
+
+ KParts::URLArgs argdummy;
+ emit openURLRequest( urlin, argdummy );
+ return ;
+ }
+
+ if ( refstr == QString::null ) return ;
+
+ /*---------------------------*/
+ /* show popupmenu for #write */
+
+ if ( refstr.left( 5 ) == "write" ) {
+ showWritePopupMenu( refstr );
+ return;
+ }
+
+ /*----------------------------*/
+ /* extract responses by ID */
+
+ if( refstr.left(5) == "idpop"){
+ showIDPopup( refstr );
+ return;
+ }
+
+ /*-------------------------*/
+ /* start multi-popup mdde */
+ if( m_pushrightbt && startMultiPopup() ) return;
+
+
+ /*----------------------------*/
+ /* next 100 ,before 100 ,etc. */
+ if( showNext100Etc( refstr ) ) return;
+
+
+ /*-------------------------------*/
+ /* open Kita Navi or goto anchor */
+
+ int refNum,refNum2;
+
+ int i = refstr.find( "-" );
+ if ( i != -1 ) {
+ refNum = refstr.left( i ).toInt();
+ refNum2 = refstr.mid(i+1).toInt();
+ if( refNum2 < refNum ) refNum2 = refNum;
+ refstr = datURL.ref().left( i );
+ } else refNum = refNum2 = refstr.toInt();
+
+ if ( !refNum ) return ;
+
+ if( m_pushctrl || m_pushmidbt ) KitaNavi::showKitaNavi( m_datURL, refNum, refNum2 );
+ else gotoAnchor( refstr, TRUE );
+}
+
+
+
+/*---------------------------------------------------------*/
+/* popup menu that is opened when user clicked res number. */
+/* This funtcion is called in only clickAnchor(). */ /* private */
+void KitaHTMLPart::showWritePopupMenu( const QString& refstr)
+{
+ enum{
+ WRITEMENU_RES,
+ WRITEMENU_QUOTE,
+ WRITEMENU_SHOWBROWSER,
+ WRITEMENU_SHOWNAVI,
+ WRITEMENU_RESTREE,
+ WRITEMENU_REVERSERESTREE,
+ WRITEMENU_EXTRACTNAME,
+ WRITEMENU_COPY,
+ WRITEMENU_COPYURL,
+ WRITEMENU_COPYTHREADNAME,
+ WRITEMENU_SETKOKOYON,
+ WRITEMENU_CHECK,
+ WRITEMENU_ABONENAME
+ };
+
+ QClipboard * clipboard = QApplication::clipboard();
+ QString str, resstr;
+ int resNum = refstr.mid( 5 ).toInt();
+ QString namestr = Kita::DatManager::getName( m_datURL, resNum );
+
+ /* show res tree */
+ 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 );
+ tmpstr += htmlstr + "<BR><BR></DIV>";
+ showPopup( m_datURL, tmpstr );
+ startMultiPopup();
+ return;
+ }
+
+ /* open kitanavi */
+ else if( m_pushctrl | m_pushmidbt ){
+ KitaNavi::showKitaNaviResTree(m_datURL,resNum);
+ return;
+ }
+
+ /*---------------------*/
+ /* create popup menu */
+ QString plainStr;
+
+ KPopupMenu *popupMenu = new KPopupMenu( view() );
+ popupMenu->clear();
+
+ /* write */
+ 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 );
+ popupMenu->insertSeparator();
+
+ }
+
+ /* check */
+ if( m_mode == HTMLPART_MODE_MAINPART ){
+ popupMenu->insertItem( i18n( "Check" ), WRITEMENU_CHECK );
+ popupMenu->setItemChecked( WRITEMENU_CHECK, m_check[ resNum ] );
+ popupMenu->insertSeparator();
+ }
+
+ /* open */
+ popupMenu->insertItem( i18n( "Open with KitaNavi" ), WRITEMENU_SHOWNAVI );
+ popupMenu->insertItem( i18n( "Open with Web Browser" ), WRITEMENU_SHOWBROWSER );
+ popupMenu->insertSeparator();
+
+ /* util */
+ popupMenu->insertItem( i18n( "res tree" ), WRITEMENU_RESTREE );
+ popupMenu->insertItem( i18n( "reverse res tree" ), WRITEMENU_REVERSERESTREE );
+ popupMenu->insertItem( i18n( "extract by name" ), WRITEMENU_EXTRACTNAME );
+ popupMenu->insertSeparator();
+
+ /* copy */
+ popupMenu->insertItem( i18n( "copy URL" ), WRITEMENU_COPYURL );
+ popupMenu->insertItem( i18n( "Copy title and URL" ), WRITEMENU_COPYTHREADNAME );
+ popupMenu->insertItem( i18n( "copy" ), WRITEMENU_COPY );
+
+ /* kokkoma de yonda */
+ if( m_domtree && m_mode == HTMLPART_MODE_MAINPART ){
+ popupMenu->insertSeparator();
+ popupMenu->insertItem( i18n( "set Kokomade Yonda" ), WRITEMENU_SETKOKOYON );
+ }
+
+ /* abone */
+ popupMenu->insertSeparator();
+ popupMenu->insertItem( i18n( "add name to abone list" ), WRITEMENU_ABONENAME );
+
+
+ /*--------------------------------------*/
+ /* show popup menu */
+
+ int ret = popupMenu->exec( QCursor::pos() );
+ delete popupMenu;
+ switch ( ret ) {
+
+ case WRITEMENU_RES:
+ resstr = ">>" + QString().setNum( resNum ) + "\n";
+ emit openWriteDialog( resstr );
+ break;
+
+ 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";
+ emit openWriteDialog( resstr );
+ break;
+
+ case WRITEMENU_CHECK:
+ m_check[ resNum ] = !m_check[ resNum ];
+ break;
+
+ case WRITEMENU_COPY:
+ case WRITEMENU_COPYURL:
+ case WRITEMENU_COPYTHREADNAME:
+ str = QString::null;
+
+ /* title */
+ if( ret == WRITEMENU_COPYTHREADNAME || ret == WRITEMENU_COPY ){
+ str = Kita::DatManager::thread_name( m_datURL );
+ }
+
+ /* url */
+ if( str != QString::null ) str += "\n";
+ str += Kita::DatManager::thread_url( m_datURL ) + QString().setNum( resNum ) + "\n";
+
+ /* body */
+ if( ret == WRITEMENU_COPY ){
+ str += "\n"
+ + Kita::DatManager::getPlainTitle( m_datURL, resNum ) + "\n"
+ + Kita::DatManager::getPlainBody( m_datURL, resNum ) + "\n";
+ }
+
+ /* copy */
+ clipboard->setText( str , QClipboard::Clipboard );
+ clipboard->setText( str , QClipboard::Selection );
+ break;
+
+
+ case WRITEMENU_SETKOKOYON:
+ Kita::DatManager::setKokoyonNum( m_datURL, resNum );
+ m_updatedKokoyon = TRUE;
+ updateScreen( TRUE, TRUE );
+ gotoAnchor( QString().setNum( resNum ), FALSE );
+ break;
+
+ case WRITEMENU_SHOWBROWSER:
+ str = Kita::DatManager::thread_url( m_datURL )
+ + QString().setNum( resNum );
+
+ KRun::runURL( str, "text/html" );
+ break;
+
+
+ case WRITEMENU_SHOWNAVI:
+ KitaNavi::showKitaNavi( m_datURL, resNum, resNum);
+ break;
+
+
+ case WRITEMENU_RESTREE:
+ KitaNavi::showKitaNaviResTree( m_datURL, resNum);
+ break;
+
+ case WRITEMENU_REVERSERESTREE:
+// KitaNavi::showKitaNaviRevResTree( m_datURL, resNum);
+ break;
+
+ case WRITEMENU_EXTRACTNAME:
+// KitaNavi::showKitaNaviByName( m_datURL, namestr );
+ break;
+
+ case WRITEMENU_ABONENAME:
+ if ( QMessageBox::question( view(),"Kita",
+ i18n( "Do you want to add '%1' to abone list ?" ).arg( namestr ),
+ QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
+ == QMessageBox::Ok ){
+
+ KitaConfig::addAboneName( namestr );
+ Kita::DatManager::resetAbone( m_datURL );
+ emit redrawScreen( m_datURL, FALSE );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+
+
+/*--------------------------------------------------*/
+/* popup that is opened when user clicked ID */
+/* 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 -> / */
+
+ /* popup */
+ 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 );
+ 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 ) KitaNavi::showKitaNaviByID( m_datURL, strid );
+
+ else {
+
+ enum{
+ IDMENU_EXTRACT,
+ IDMENU_ABONE
+ };
+
+ KPopupMenu *popupMenu = new KPopupMenu( view() );
+ popupMenu->clear();
+ 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 ) {
+
+ case IDMENU_EXTRACT:
+ KitaNavi::showKitaNaviByID( m_datURL, strid );
+ break;
+
+ case IDMENU_ABONE:
+ /* add ID to abone list */
+ if ( QMessageBox::question( view(),"Kita",
+ i18n( "Do you want to add '%1' to abone list ?" ).arg( strid ),
+ QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
+ == QMessageBox::Ok ){
+
+ KitaConfig::addAboneID( strid );
+ Kita::DatManager::resetAbone( m_datURL );
+ emit redrawScreen( m_datURL, FALSE );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+
+/*-------------------------------------------------------*/
+/* funtcion when user clicked next 100 ,before 100 ,etc. */
+/* This funtcion is called in only clickAnchor(). */ /* private */
+bool KitaHTMLPart::showNext100Etc( const QString& refstr )
+{
+ if( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
+
+ if ( refstr.left( 7 ) == "tugi100" ) {
+ slotClickTugi100();
+ return TRUE;
+
+ } else if ( refstr.left( 6 ) == "nokori" ) {
+ slotClickNokori();
+ return TRUE;
+
+ } else if ( refstr.left( 7 ) == "tosaigo" ) {
+ slotClickGotoFooter();
+ return TRUE;
+
+ } else if ( refstr.left( 6 ) == "mae100" ) {
+ slotClickMae100();
+ return TRUE;
+
+ } else if ( refstr.left( 8 ) == "maezenbu" ) {
+ slotClickMaeZenbu();
+ return TRUE;
+
+ } else if ( refstr.left( 6 ) == "tmp100" ) {
+ slotClickTmpNext100();
+ return TRUE;
+
+ } else if ( refstr.left( 5 ) == "zenbu" ) {
+ slotClickShowAll();
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+/*-------------------------------------------------------*/
+/*-------------------------------------------------------*/
+/* popup */
+
+
+/*---------------------*/
+/* show popup window */ /* private */
+void KitaHTMLPart::showPopup( const KURL& url, const QString& innerHTML )
+{
+ deletePopup();
+ m_multiPopup = FALSE;
+
+ m_popup = new Kita::ResPopup( view() , url );
+
+ connect( m_popup, SIGNAL( hideChildPopup() ),SLOT( slotHideChildPopup() ) );
+
+ m_popup->setText( innerHTML );
+ m_popup->adjustSize();
+ m_popup->adjustPos();
+ m_popup->show();
+}
+
+
+/*------------------------*/
+/* start multi-popup mode */ /* private */
+bool KitaHTMLPart::startMultiPopup(){
+
+ if( m_popup && m_popup->isVisible() ){
+ m_multiPopup = TRUE;
+ m_popup->moveMouseAbove();
+ }
+ else m_multiPopup = FALSE;
+
+ return m_multiPopup;
+}
+
+
+/* Is it multi-popup mode now ? */ /* private */
+bool KitaHTMLPart::isMultiPopupMode()
+{
+ if( !m_popup ) m_multiPopup = FALSE;
+ else if( m_popup->isHidden() ) m_multiPopup = FALSE;
+
+ return m_multiPopup;
+}
+
+
+/* private */
+void KitaHTMLPart::hidePopup()
+{
+ if( m_popup ) m_popup->hide();
+ m_multiPopup = FALSE;
+}
+
+
+
+/* private */
+void KitaHTMLPart::deletePopup()
+{
+ if ( m_popup ) delete m_popup;
+ m_popup = NULL;
+ m_multiPopup = FALSE;
+}
+
+
+/* return TRUE if this view is under mouse. */ /* private */
+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) );
+ int px = viewpos.x(), py = viewpos.y();
+ int wd = view()->visibleWidth(), ht = view()->visibleHeight();
+
+ if( ( px < cx && cx < px + wd + mrgwd )
+ && ( py < cy && cy < py + ht + mrght ) ){
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/* private slot */
+void KitaHTMLPart::slotLeave()
+{
+ 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();
+}
+
+
+/* private slot */
+void KitaHTMLPart::slotVSliderReleased(){
+
+ 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();
+}
+
+
+/* private slot */
+void KitaHTMLPart::slotHSliderReleased(){
+
+ 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();
+}
+
+
+
+/* private slot */
+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();
+}
+
+
+
+/*------------------------------------------*/
+/* called back when kita is active .
+ see also an explanation in slotOnURL. */ /* private slot */
+void KitaHTMLPart::slotKitaIsActive(){
+ m_kitaIsActive = TRUE;
+}
+
+
+
+/*---------------------------------------------------*/
+/* This slot is called when mouse moves onto the URL */ /* private slot */
+void KitaHTMLPart::slotOnURL( const QString& url )
+{
+ /* config */
+
+ const int maxpopup = 10; /* max number of responses shown in the popup window */
+
+ /*----------------------------*/
+
+ if( isMultiPopupMode() ) return;
+
+ deletePopup();
+
+ if ( url.isEmpty() ) return ;
+ if ( url.left( 7 ) == "mailto:" ) return;
+
+ /* Is Kita active now ?
+
+ emit SIGNAL( isKitaActive() ) to KitaMainWindow, KitaNavi, etc. ,
+ and if one of them is active, then slotKitaIsActive() is called
+ back, and m_kitaIsActive is set to TRUE. */
+ m_kitaIsActive = FALSE;
+ emit isKitaActive();
+ if( !m_kitaIsActive ) return;
+
+ /*------------------------*/
+ /* id popup */
+
+ 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 );
+ showPopup( m_datURL, tmpstr );
+ return ;
+ }
+
+
+ /*-------------------------*/
+ /* popup for anchor */
+
+ QString innerHTML = QString::null;
+ QString refstr;
+ KURL datURL = m_datURL;
+ int refNum;
+ int refNum2;
+
+ /* get reference */
+ if ( url.at( 0 ) == '#' ) refstr = url.mid( 1 );
+ else datURL = Kita::ParseMisc::parseURL( KURL( m_datURL, url ) ,refstr);
+
+ int i = refstr.find( "-" );
+ if ( i != -1 ) { /* >>refNum-refNum2 */
+
+ refNum = refstr.left( i ).toInt();
+ refNum2 = refstr.mid( i + 1 ).toInt();
+
+ if ( refNum ) {
+ if ( refNum2 < refNum ) refNum2 = refNum;
+ if ( refNum2 - refNum > maxpopup - 1 ) refNum2 = refNum + maxpopup - 1;
+ }
+
+ } else { /* >>refNum */
+ refNum = refstr.toInt();
+ refNum2 = refNum;
+ }
+
+ /* another thread ? */
+ if ( datURL.host() != m_datURL.host() || datURL.path() != m_datURL.path() ) {
+
+ /* show them with boadname & subject */
+ QString boardName = Kita::DatManager::thread_boardName( datURL );
+ if ( boardName != QString::null ) innerHTML += "[" +boardName +"] ";
+ QString subName = Kita::DatManager::getSubject( datURL );
+ if ( subName != QString::null ) innerHTML += subName +"<br><br>";
+
+ if ( !refNum ) refNum = refNum2 = 1;
+ }
+
+ /* get HTML and show it */
+ if ( !refNum ) return ;
+ innerHTML += Kita::DatManager::getHtml( datURL, refNum, refNum2 );
+
+ if ( innerHTML != QString::null ) showPopup( datURL, innerHTML );
+}
+
+
+
+/* If selected Text is composed of only digits,
+ then show res popup. */ /* private */
+bool KitaHTMLPart::showSelectedDigitPopup(){
+
+ if( !hasSelection() ) return FALSE;
+
+ QString linkstr;
+ int refNum[2];
+ unsigned int pos;
+ QString selectText = selectedText();
+ const QChar *chpt = selectText.unicode();
+ unsigned int length = selectText.length();
+
+ if( Kita::ParseMisc::parseResAnchor( chpt, length, linkstr, refNum, pos ) ){
+ if( refNum[1] < refNum[0] ) refNum[1] = refNum[0];
+ QString innerHTML = Kita::DatManager::getHtml( m_datURL, refNum[0], refNum[1] );
+ if ( innerHTML != QString::null ) {
+ showPopup( m_datURL, innerHTML );
+ startMultiPopup();
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+
+
+/*--------------------------------------------------------------*/
+/*--------------------------------------------------------------*/
+/* class ResPopup */
+
+
+namespace Kita
+{
+ ResPopup::ResPopup( KHTMLView* view, const KURL& datURL )
+ : QFrame( view, "res_popup",
+ WStyle_Customize
+ | WStyle_NoBorder
+ | WStyle_Tool
+ | WType_TopLevel
+ | WX11BypassWM
+ )
+ {
+ m_textBrowser = new QTextBrowser( this );
+ m_textBrowser->setWordWrap( QTextEdit::NoWrap );
+ m_textBrowser->setResizePolicy( QScrollView::AutoOne );
+ m_textBrowser->setFont( KitaConfig::threadFont() );
+
+ m_htmlPart = new KitaHTMLPart(this);
+ m_htmlPart->setup( HTMLPART_MODE_POPUP , datURL );
+ connect( m_htmlPart, SIGNAL( hideChildPopup() ), SIGNAL( hideChildPopup() ) );
+ }
+
+
+ ResPopup::~ResPopup()
+ {
+ if(m_textBrowser) delete m_textBrowser;
+ m_textBrowser = NULL;
+ if(m_htmlPart) delete m_htmlPart;
+ m_htmlPart = NULL;
+ }
+
+
+ /* public */
+ void ResPopup::setText( const QString& str )
+ {
+
+ QString style = QString( "style=\"font-size: %1pt; "
+ "font-family: %2; "
+ "color: %3; "
+ "background-color: %4; border-width: 0; \"" )
+ .arg( KitaConfig::threadFont().pointSize() )
+ .arg( KitaConfig::threadFont().family() )
+ .arg( KitaConfig::popupColor().name() )
+ .arg( KitaConfig::popupBackgroundColor().name() );
+
+ QString text = "<html><head>";
+ text += "</head><body " + style + ">";
+ text += str + "</body></html>";
+
+ 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);
+ m_htmlPart->end();
+ m_htmlPart->view()->setVScrollBarMode(QScrollView::AlwaysOff);
+ }
+ }
+
+
+ /* public */
+ void ResPopup::adjustSize()
+ {
+ /* config */
+
+ const int mrg = 50;
+ const int mrg2 = 10;
+
+ /*---------------------------*/
+
+ 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;
+ delete m_textBrowser;
+ m_textBrowser = NULL;
+
+ m_htmlPart->view()->resize( wd,ht );
+ QFrame::adjustSize();
+ }
+
+
+ /* public */
+ void ResPopup::adjustPos()
+ {
+ /* config */
+
+ const int mrg = 10;
+
+ /*----------------------------*/
+
+ if( !m_htmlPart ) return;
+
+ QRect qr = QApplication::desktop() ->rect();
+ int sw = qr.width(), sh = qr.height();
+ int wd = width(), ht = height();
+
+ QPoint pos = QCursor::pos();
+ int x = pos.x(), y = pos.y();
+
+ if ( x + mrg + wd < sw ) {
+ x = x + mrg;
+ y = QMAX( 0, y - ( ht + mrg ) );
+
+ } else if ( y - ( mrg + ht ) >= 0 ) {
+ x = QMAX( 0, sw - wd );
+ y = y - ( ht + mrg );
+
+ } else if ( y + ( mrg + ht ) <= sh ) {
+ x = QMAX( 0, sw - wd );
+ y = y + mrg;
+
+ } else if ( x - ( mrg + wd ) >= 0 ) {
+ x = x - ( mrg + wd );
+ y = QMAX( 0, y - ( ht + mrg ) );
+
+ } else {
+ x = x + mrg;
+ y = QMAX( 0, y - ( ht + mrg ) );
+ }
+
+ pos.setX( x );
+ pos.setY( y );
+ move( pos );
+
+ if( x + wd >= sw ){
+ m_htmlPart->view()->setVScrollBarMode( QScrollView::AlwaysOn );
+ wd = sw - x;
+ }
+ if( y + ht >= sh ){
+ m_htmlPart->view()->setVScrollBarMode( QScrollView::AlwaysOn );
+ ht = sh - y;
+ }
+ m_htmlPart->view()->resize( wd, ht );
+ resize( wd, ht );
+ }
+
+
+ /* move mouse pointer above the popup frame */ /* public */
+ void ResPopup::moveMouseAbove()
+ {
+ /* config */
+
+ const int mrg = 10;
+
+ /*-------------------------------*/
+
+ QPoint pos = QCursor::pos();
+ int cx = pos.x(), cy = pos.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( cy <= py ) cy = py+mrg;
+ else if( cy >= py+ht ) cy = py+ht-mrg;
+
+ QCursor::setPos( cx, cy );
+ }
+
+}
+
"Á´ÀÕǤ¤òÉ餦¤³¤È¤ò¾µÂú¤·¤Æ½ñ¤¹þ¤ß¤Þ¤¹¤«\n";
KitaThreadView::KitaThreadView( QWidget* parent, const char* name )
- : KitaThreadViewBase( parent, name ), m_popup( 0 )
+ : KitaThreadViewBase( parent, name )
{
m_thread = new Kita::NullThread();
m_threadPart = new KitaHTMLPart( threadFrame );
- m_domtree = new KitaDomTree( m_threadPart );
QHBoxLayout* aLayout = new QHBoxLayout( threadFrame );
aLayout->addWidget( m_threadPart->view() );
connect( writeButton, SIGNAL( clicked() ),
SLOT( slotWriteButtonClicked() ) );
+ connect( m_threadPart, SIGNAL( openWriteDialog( QString ) ),
+ SLOT( slotWriteButtonClicked ( QString ) ) );
+ connect( m_threadPart, SIGNAL( finishReload() ),
+ SLOT( slotUpdateInfo() ) );
connect( m_threadPart, SIGNAL( nodeActivated( const DOM::Node& ) ),
SLOT( slotDOMNodeActivated( const DOM::Node& ) ) );
- connect( m_threadPart, SIGNAL( onURL( const QString& ) ),
- SLOT( slotOnURL( const QString& ) ) );
- connect( m_threadPart, SIGNAL( setLocationBarURL( const QString& ) ),
- SIGNAL( setLocationBarURL( const QString& ) ) );
connect( BookmarkButton, SIGNAL( toggled( bool ) ),
SLOT( slotBookmarkButtonClicked( bool ) ) );
connect( SearchButton, SIGNAL( clicked() ),
connect( SearchCombo, SIGNAL( activated( int ) ),
SLOT( slotSearchButton() ) );
connect( GobackAnchorButton, SIGNAL( clicked() ),
- m_threadPart, SLOT( gobackAnchor() ) );
+ m_threadPart, SLOT( slotGobackAnchor() ) );
connect( ReloadButton, SIGNAL( clicked() ),
SLOT( slotReloadButton() ) );
connect( gotoCombo, SIGNAL( activated( int ) ),
KParts::BrowserExtension* ext = m_threadPart->browserExtension();
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
- connect( ext, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
- SLOT( slotOpenURLRequest( const KURL&, const KParts::URLArgs& ) ) );
connect( this, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
signalCollection, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ) );
- connect( this, SIGNAL( writeSucceeded() ),
- signalCollection, SIGNAL( writeSucceeded() ) );
connect( ext, SIGNAL( createNewWindow ( const KURL&, const KParts::URLArgs& ) ),
SIGNAL( createNewWindow ( const KURL&, const KParts::URLArgs& ) ) );
connect( ext, SIGNAL( setLocationBarURL( const QString& ) ),
KitaThreadView::~KitaThreadView()
{
- if ( m_popup )
- {
- delete m_popup;
- m_popup = NULL;
- }
-
- /* unlock URL */
- Kita::DatManager::unlock(m_datURL);
-
- /* don't delete m_threadPart before deleting m_domtree */
- if ( m_domtree )
- {
- delete m_domtree;
- m_domtree = NULL;
- }
if ( m_threadPart )
{
delete m_threadPart;
{
case Kita::K2ch_Unknown:
// probably OK.
- emit writeSucceeded();
slotReloadButton();
break;
case Kita::K2ch_True:
/*--------------------*/ /* private slots */
void KitaThreadView::slotWriteButtonClicked( QString resstr )
{
+ m_serverTime = Kita::DatManager::getServerTime(m_datURL);
if ( ! m_serverTime ) return ;
// TODO: machiBBS kakiko support.
}
-void KitaThreadView::hidePopup()
-{
- if ( m_popup )
- {
- m_popup->hide();
- }
-}
-
void KitaThreadView::slotPopupMenu( KXMLGUIClient* client, const QPoint& global, const KURL& url, const QString& mimeType, mode_t mode )
{
KActionCollection * collection = client->actionCollection();
}
}
- PopupTextBrowser::PopupTextBrowser( QFrame* frame )
- : QTextBrowser( frame )
- {
- zoomOut( static_cast<int>( pointSize() * 0.3 ) );
- setWordWrap( QTextEdit::NoWrap );
- setResizePolicy( QScrollView::AutoOne );
- setFont( KitaConfig::threadFont() );
- setPaletteForegroundColor( KitaConfig::popupColor() );
- setPaletteBackgroundColor( KitaConfig::popupBackgroundColor() );
- }
-
- PopupTextBrowser::~ PopupTextBrowser()
- {}
-
- ResPopup::ResPopup( KHTMLView* view )
- : QFrame( view, "res_popup", WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WType_TopLevel | WX11BypassWM )
- {
- m_browser = new Kita::PopupTextBrowser( this );
- }
-
- ResPopup::~ ResPopup()
- {}
-
- void ResPopup::setText( QString& str )
- {
- m_browser->setText( str );
- }
-
- void ResPopup::adjustSize()
- {
- m_browser->resize( m_browser->contentsWidth() + 10, m_browser->contentsHeight() );
- QFrame::adjustSize();
- }
-
}
/*-------*/
/* setup */
/*-------*/
-void KitaThreadView::setupEx( const Kita::Thread* thread, int serverTime, int mode )
+void KitaThreadView::setupEx( const Kita::Thread* thread, int , int mode )
{
/* config. */
- /* show m_preShowNum responses before 'kokomade yonda' */
- m_preShowNum = 50;
-
- /* max size of responses in the popup window */
- m_maxpopup = 10;
-
/* default name */
m_mailaddr = "sage";
- /* online mode */
- m_online = TRUE;
-
-
/*---------------------------------------*/
/* setup */
- /* unlock previous URL */
- Kita::DatManager::unlock(m_datURL);
-
m_thread = const_cast<Kita::Thread *>( thread );
QString refstr;
m_datURL = Kita::ParseMisc::parseURL(m_thread->datURL(),refstr);
- /* lock new URL */
- Kita::DatManager::lock(m_datURL);
-
/* setup HTMLPart */
- m_threadPart->setupEx( this, m_domtree, m_thread );
-
- /* setup DOM */
- m_domtree->parseResInit( m_thread );
+ int partMode = HTMLPART_MODE_MAINPART;
+ if( mode == VIEWMODE_KITANAVI ) partMode = HTMLPART_MODE_NAVI;
+ if( mode == VIEWMODE_PREVIEW ) partMode = HTMLPART_MODE_KHTML;
+ m_threadPart->setup( partMode, m_datURL );
/* mode. Mode is defined in kitathreadview.h */
m_viewmode = mode;
Base->removeItem( layout2 );
}
- /* m_serverTime is used for writing */
- m_serverTime = serverTime;
-
/* reset search direction */
m_revsearch = FALSE;
}
/* Show thread */
/* This function is called from KitaThreadTabWidget class */
/*--------------------------------------------------------*/
-void KitaThreadView::showThread( const Kita::Thread* thread2h )
+void KitaThreadView::showThread( const KURL& datURL, int num )
{
-
/* If this widget is not parent, then do nothing. */
if ( m_viewmode != VIEWMODE_PARENT ) return ;
setActiveWindow();
/* setup */
- setupEx( thread2h , 0, VIEWMODE_PARENT );
+ Kita::Thread* thread2ch = Kita::Thread::getByURL( datURL.prettyURL() );
+ setupEx( thread2ch , 0, VIEWMODE_PARENT );
/* get log from cahce */
- int maxnum = Kita::DatManager::getMaxResNumber(m_datURL);
m_rescode = 200;
- if ( maxnum )
- {
- /* show templates (No.1->No.KitaDomTree::m_templateNum) */
- m_domtree->appendTemplate();
-
- /* rendering */
- m_kokoyonNum = Kita::DatManager::getKokoyonNum(m_datURL);
- for ( int i = m_kokoyonNum - m_preShowNum ; i <= m_kokoyonNum ; i++ )
- m_domtree->appendRes( i, FALSE );
- updateScreen();
-
- m_threadPart->gotoKokoyon();
- }
- else
- {
- m_kokoyonNum = 0;
- showStatusBar( "" );
- }
+ if( !m_threadPart->load( num ) ) showStatusBar( "" );
/* update data */
- updateInfo();
- m_firstReceive = TRUE;
- if( m_online ) slotReloadButton();
-
- topLevelWidget() ->raise();
- setActiveWindow();
+ slotUpdateInfo();
+ slotReloadButton();
}
/*---------*/ /* public slot */
void KitaThreadView::slotReloadButton()
{
- switch ( m_viewmode )
- {
-
- case VIEWMODE_PREVIEW: break;
-
- case VIEWMODE_PARENT:
-
- /* update cache */
- /* After updating cache, DatManager will call slotFinishLoad.*/
- if( m_online )
- {
- m_domtree->StopParseThread();
- if ( KitaConfig::afterShowNum() != 0 ) {
- m_showNum = m_domtree->getBottomResNumber() + KitaConfig::afterShowNum();
- } else {
- // TODO: fix it.
- m_showNum = 5000;
- }
- Kita::DatManager::updateCache(m_datURL,this);
- m_threadPart->view()->setFocus();
- showStatusBar( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_NOWRENEW ) );
- }
- break;
-
- default:
-
- /* When this is not parent, show the thread with new tab */
- KParts::URLArgs tmp;
- emit openURLRequest( m_thread->datURL() , tmp );
- break;
-
- }
-}
-
-/*-----------------------------------*/
-/* slot called when Kita::DatManager
- received new data. */ /* public slot */
-void KitaThreadView::slotReceiveData()
-{
-
- int bottomNum = m_domtree->getBottomResNumber();
- int afterNum = Kita::DatManager::getMaxResNumber(m_datURL);
-
- m_rescode = Kita::DatManager::getResponseCode(m_datURL);
- m_serverTime = Kita::DatManager::getServerTime(m_datURL);
-
- /* rendering */
- if( (m_firstReceive && bottomNum < afterNum )
- || (bottomNum + 20 < afterNum && m_showNum +2 >= afterNum ) )
- {
- for ( int i = bottomNum+1 ; i <= QMIN( m_showNum, afterNum ) ; i++ ) m_domtree->appendRes( i, FALSE );
- updateScreen();
- if(m_firstReceive && m_kokoyonNum < afterNum )
- {
- m_threadPart->gotoKokoyon();
- m_firstReceive = FALSE;
- }
+ topLevelWidget() ->raise();
+ setActiveWindow();
+
+ if( m_threadPart->reload() ){
+ showStatusBar( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_NOWRENEW ) );
}
}
-/*-----------------------------------*/
-/* slot called when Kita::DatManager
- finished updating new data. */ /* public slot */
-void KitaThreadView::slotFinishLoad()
-{
-
- m_firstReceive = FALSE;
- int bottomNum = m_domtree->getBottomResNumber();
- for ( int i = bottomNum+1 ; i <= m_showNum; i++ ) m_domtree->appendRes( i, FALSE );
- updateScreen();
- updateInfo();
-}
/*-----------------------------------*/
/* stop loading the thread */ /* public slot */
}
-/*---------------------------------------------------*/
-/* This function is called when user clicks the link */
-/*---------------------------------------------------*/ /* public slot */
-void KitaThreadView::slotOpenURLRequest( const KURL& urlin, const KParts::URLArgs& args )
-{
- KURL url = urlin;
-
- /* convert to the correct URL */
- /* see also comments in KitaDomTree::createHTMLDocument for details */
- if ( urlin.protocol() == "file" )
- {
-
- if ( urlin.prettyURL().mid( 5, 14 ) == "/test/read.cgi" )
- url = KURL( m_thread->datURL(), ".." + urlin.prettyURL().mid( 5 ) );
- else
- url = KURL( m_thread->datURL(), urlin.prettyURL().mid( 15 ) );
- }
-
- KURL datURL = filterReadCGI( url , m_thread );
-
- /* If this is not anchor, then emit openURLRequest and return */
- if ( datURL.host() != KURL( m_thread->datURL() ).host()
- || datURL.path() != KURL( m_thread->datURL() ).path() )
- {
- emit openURLRequest( datURL, args );
- return ;
- }
-
- if ( ! datURL.hasRef() ) return ;
- if ( m_viewmode == VIEWMODE_PREVIEW ) return ;
-
- /*---------------------------*/
- /* show popupmenu for #write */
-
- if ( datURL.ref().left( 5 ) == "write" )
- {
-
- QClipboard * clipboard = QApplication::clipboard();
- QString str, resstr;
- int resNum = datURL.ref().mid( 5 ).toInt();
-
- /* show res tree on the popup */
- if(m_threadPart->isRightClick())
- {
- int num;
- QString htmlstr
- = Kita::DatManager::getTreeByRes(m_thread->datURL(),resNum,num);
- if ( !num ) return ;
- QString tmpstr = QString("<DIV>No.%1 : [%2]<BR>").arg(resNum).arg(num);
- tmpstr += htmlstr;
- tmpstr += "<BR><BR></DIV>";
- showPopup( tmpstr, QString::null );
- return;
- }
- /* show tree on the kitanavi */
- else if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick())
- {
- KitaNavi::showKitaNaviResTree(m_datURL,resNum);
- return;
- }
-
- KPopupMenu *popupMenu = new KPopupMenu( m_threadPart->view() );
- popupMenu->clear();
- popupMenu->insertItem( i18n( "write response" ), 0 );
- popupMenu->insertItem( i18n( "quote this" ), 1 );
- popupMenu->insertItem( i18n( "copy" ), 3 );
- if ( m_viewmode == VIEWMODE_PARENT )
- {
- popupMenu->insertSeparator();
- popupMenu->insertItem( i18n( "set Kokomade Yonda" ), 2 );
- }
-
- switch ( popupMenu->exec( QCursor::pos() ) )
- {
- case 0:
- resstr = ">>" + QString().setNum( resNum ) + "\n";
- break;
-
- case 1:
- resstr = ">>" + QString().setNum( resNum ) + "\n";
- resstr += m_domtree->getResStr( resNum, "> " );
- break;
-
- case 2:
- delete popupMenu;
- m_kokoyonNum = resNum;
- Kita::DatManager::setKokoyonNum(m_datURL,resNum);
- updateScreen();
- gotoAnchor( QString().setNum( resNum ) );
- return ;
-
- case 3:
- delete popupMenu;
- str = threadName()
- + "\n" + threadURL().url() + QString().setNum( resNum )
- + "\n\n" + m_domtree->getResStr( resNum, "" );
- clipboard->setText( str , QClipboard::Clipboard );
- clipboard->setText( str , QClipboard::Selection );
- return ;
-
- default:
- delete popupMenu;
- return ;
- }
-
- delete popupMenu;
- slotWriteButtonClicked( resstr );
- return ;
- }
-
- /*----------------------------*/
- /* extract responses by ID */
-
- if(datURL.ref().left(5) == "idpop")
- {
-
- QString strid = datURL.ref().mid(5).replace("%2B","+").replace("%2F", "/"); /* decode %2B -> +, %2F -> / */
-
- /* show them on the popup */
- if(m_threadPart->isRightClick())
- {
- int num;
- QString htmlstr
- = Kita::DatManager::getHtmlByID(m_thread->datURL(),strid,num );
- if ( num <= 1 ) return ;
- QString tmpstr = QString("<DIV>ID:%1:[%2]<BR>").arg(strid).arg(num);
- tmpstr += htmlstr;
- tmpstr += "<BR><BR></DIV>";
- showPopup( tmpstr, QString::null );
- }
-
- /* show them on the kitanavi */
- else if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick())
- KitaNavi::showKitaNaviByID(m_datURL,strid);
- else
- {
- KPopupMenu *popupMenu = new KPopupMenu( m_threadPart->view() );
- popupMenu->clear();
- popupMenu->insertItem( i18n( "add id to abone list" ), 0 );
- switch ( popupMenu->exec( QCursor::pos() ) )
- {
- case 0:
- KitaConfig::addAboneID( strid );
- delete popupMenu;
- break;
- default:
- delete popupMenu;
- break;
- }
- }
-
- return;
- }
-
- /*----------------------------*/
- /* next 100 ,before 100 ,etc. */
-
- int top = m_domtree->getTopResNumber();
- int bottom = m_domtree->getBottomResNumber();
- int totalNum = Kita::DatManager::getMaxResNumber(m_datURL);
-
- if ( datURL.ref().left( 7 ) == "tugi100" )
- {
-
- if ( totalNum != bottom )
- {
- appendRes( bottom + 1, bottom + 100 );
- }
- gotoAnchor( QString().setNum( bottom ) );
- return ;
-
- }
- else if ( datURL.ref().left( 6 ) == "nokori" )
- {
-
- if ( totalNum != bottom )
- {
- appendRes( bottom + 1, totalNum );
- }
- gotoAnchor( QString().setNum( bottom ) );
- return ;
-
- }
- else if ( datURL.ref().left( 7 ) == "tosaigo" )
- {
-
- if ( totalNum != bottom )
- {
- appendRes( bottom + 1, totalNum );
- }
- gotoAnchor( "footer" );
- return ;
-
- }
- else if ( datURL.ref().left( 6 ) == "mae100" )
- {
-
- if ( top != 1 )
- {
- m_domtree->appendTemplate();
- appendRes( top - 100, bottom );
- gotoAnchor( QString().setNum( top ) );
- }
- return ;
-
- }
- else if ( datURL.ref().left( 8 ) == "maezenbu" )
- {
-
- if ( top != 1 )
- {
- appendRes( 1, bottom );
- gotoAnchor( QString().setNum( top ) );
- }
- return ;
-
- }
- else if ( datURL.ref().left( 6 ) == "tmp100" )
- {
-
- int tmpnum = m_domtree->getTemplateNumber();
-
- if ( tmpnum < top )
- {
- m_domtree->setTemplateNumber( tmpnum + 100 );
- m_domtree->appendTemplate();
- appendRes( top, bottom );
- gotoAnchor( QString().setNum( tmpnum ) );
- }
- return ;
-
- }
- else if ( datURL.ref().left( 5 ) == "zenbu" )
- {
-
- if ( top != 1 || bottom != totalNum )
- {
- appendRes( 1, totalNum );
- gotoAnchor( "header" );
- }
- return ;
-
- }
-
- /*---------------------*/
- /* jump to anchor */
-
- QString refstr = datURL.ref();
- int refNum,refNum2;
-
- int i = refstr.find( "-" );
- if ( i != -1 )
- {
- refNum = refstr.left( i ).toInt();
- refNum2 = QMIN(refstr.mid(i+1).toInt(),totalNum);
- if(refNum2 < refNum) refNum2 = refNum;
- refstr = datURL.ref().left( i );
- }
- else refNum = refNum2 = refstr.toInt();
-
- if ( !refNum ) return ;
-
- /* show Kita Navi or goto anchor */
- if(m_threadPart->isCtrlClick() || m_threadPart->isMidClick()
- || m_viewmode == VIEWMODE_KITANAVI)
- {
- KitaNavi::showKitaNavi(m_datURL,refNum,refNum2);
- }
- else gotoAnchor( refstr );
-}
-
-
-
/*-----------------------------------------*/
/* show the information at the statusbar. */
/*-----------------------------------------*/
bool broken = FALSE;
QString infostr = QString::null;
QString errstr = QString::null;
-
+ int kokoyonNum = Kita::DatManager::getKokoyonNum(m_datURL);
+
switch( m_viewmode )
{
/* show status bar */
infostr = m_thread->name() +
- QString( " [Total: %1 New: %2] %3 k" ).arg( totalNum ).arg( totalNum - m_kokoyonNum ).arg( datSize / 1024 )
+ QString( " [Total: %1 New: %2] %3 k" ).arg( totalNum ).arg( totalNum - kokoyonNum ).arg( datSize / 1024 )
+ info + " " + errstr;
emit signalChangeStatusbar( infostr );
-/* TODO: need to write test case. */ /* !!! public & static !!! */
-KURL KitaThreadView::filterReadCGI( const KURL& url, const Kita::Thread* thread )
-{
- KURL newURL = url;
-
- if ( url.path().contains( "/test/read.cgi" ) )
- {
- newURL.setProtocol( KURL( thread->datURL() ).protocol() );
- QString tmp = url.path().section( "/test/read.cgi", 1 );
-
- QString newPath = QString( "/%1/dat/%2.dat" )
- .arg( tmp.section( '/', 1, 1 ) )
- .arg( tmp.section( '/', 2, 2 ) );
- newURL.setPath( newPath );
-
- QString refBase = tmp.section( '/', 3 );
- if ( ! refBase.isEmpty() )
- {
-
- QString newRef;
- if ( refBase.at( 0 ) == '-' ) newRef = "1" + refBase;
- else newRef = refBase;
-
- newURL.setRef( newRef );
-
- }
- }
- kdDebug() << "newURL: " << newURL.url() << endl;
- return newURL;
-}
-
-
-
-
-
-/*----------------------*/
-/* move to anchor */
-/*----------------------*/
-void KitaThreadView::gotoAnchor( QString anc )
-{
-
- int top = m_domtree->getTopResNumber();
- int bottom = m_domtree->getBottomResNumber();
- int res = anc.toInt();
-
- if ( res == 1 )
- {
- anc = "header";
- }
- else if ( res > 1 )
- {
-
- /* data is not set */
- if ( !m_domtree->isResDataSet( res ) ) return ;
-
- /* show res if it is not shown */
- if ( !m_domtree->isResShown( res ) )
- {
-
- if ( res > bottom ) appendRes( bottom + 1, res + 99 );
- else if ( res < top )
- {
- m_domtree->appendTemplate();
- appendRes( res, bottom );
- }
- }
-
- /* aboned */
- if ( !m_domtree->isResShown( res ) )
- {
- while ( res > 0 )
- {
- if ( m_domtree->isResShown( res ) ) break;
- res--;
- }
- }
-
- anc = QString().setNum( res );
- }
-
- m_threadPart->gotoAnchor( anc );
-}
-
-
-/*-------------------*/
-/* update screen */ /* public */
-void KitaThreadView::updateScreen()
-{
- int totalNum = Kita::DatManager::getMaxResNumber(m_datURL);
-
- /* set header, footer , etc. */
- m_domtree->appendMae100();
- m_domtree->appendTugi100();
- m_domtree->setKokoyonNum( m_kokoyonNum );
- m_domtree->appendKokoyon();
- m_domtree->appendFooter( totalNum );
-
- /* update display */
- m_threadPart->htmlDocument().applyChanges();
- m_threadPart->view() ->layout();
- m_threadPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
-
-}
-
/*--------------------*/
/* update information */ /* public */
-void KitaThreadView::updateInfo()
+void KitaThreadView::slotUpdateInfo()
{
+ m_rescode = Kita::DatManager::getResponseCode(m_datURL);
+ m_serverTime = Kita::DatManager::getServerTime(m_datURL);
/* uptate informations */
setSubjectLabel(Kita::DatManager::thread_boardName(m_datURL),
.arg( Kita::DatManager::getMaxResNumber(m_datURL) ),
Kita::DatManager::thread_boardURL( m_datURL ) );
emit showThreadCompleted( Kita::DatManager::thread_url(m_datURL) );
- m_domtree->findTextInit();
updateButton();
-
- gotoCombo->clear();
- gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_GOTO ) );
- gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_KOKOYON ) );
- for( int i = 1; i < m_thread->resNum(); i += 100 )
- {
- gotoCombo->insertItem( QString().setNum( i ) + "-" );
- }
- gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_SAIGO ) );
- gotoCombo->adjustSize();
-
emit signalThread( m_thread );
showStatusBar( "" );
- m_threadPart->view() ->setFocus();
- m_domtree->parseAllRes();
}
-/*-------------------*/
-/* append responses */
-/*-------------------*/
-void KitaThreadView::appendRes( int startnum, int endnum )
-{
-
- showStatusBar( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_NOWEXPAND ) );
-
- /* show clock cursor */
- QCursor qc; qc.setShape( Qt::WaitCursor );
- QApplication::setOverrideCursor( qc );
-
- for ( int i = startnum ; i <= endnum; i++ ) m_domtree->appendRes( i, FALSE );
-
- updateScreen();
- showStatusBar( "" );
- QApplication::restoreOverrideCursor();
-}
-
-/*---------------------*/
-/* open popup window */
-/*---------------------*/
-void KitaThreadView::showPopup( QString innerHTML, QString imgfile )
-{
-
- if ( m_popup )
- {
- delete m_popup;
- m_popup = NULL;
- }
-
- /* text popup */
- if ( imgfile == NULL )
- {
- m_popup = new Kita::ResPopup( m_threadPart->view() );
- m_popup->setText( innerHTML );
- m_popup->adjustSize();
- }
-
- connect( m_threadPart->view(), SIGNAL( leave() ), SLOT( hidePopup() ) );
-
- QRect qr = QApplication::desktop() ->rect();
- int sw = qr.width(), sh = qr.height();
- int pw = m_popup->width(), ph = m_popup->height();
- const int mrg = 10;
-
- QPoint pos = QCursor::pos();
- int x = pos.x(), y = pos.y();
-
- if ( x + mrg + pw < sw )
- {
- x = x + mrg;
- y = QMAX( 0, y - ( ph + mrg ) );
- }
- else if ( y - ( mrg + ph ) >= 0 )
- {
- x = QMAX( 0, sw - pw );
- y = y - ( ph + mrg );
- }
- else if ( y + ( mrg + ph ) <= sh )
- {
- x = QMAX( 0, sw - pw );
- y = y + mrg;
- }
- else if ( x - ( mrg + pw ) >= 0 )
- {
- x = x - ( mrg + pw );
- y = QMAX( 0, y - ( ph + mrg ) );
- }
- else
- {
- x = x + mrg;
- y = QMAX( 0, y - ( ph + mrg ) );
- }
-
- pos.setX( x );
- pos.setY( y );
-
- m_popup->move( pos );
- m_popup->show();
-
-}
-
-/*------------------------------------------------------*/
-/* This function is called when the mouse is on the URL */
-/*------------------------------------------------------*/ /* private slots */
-void KitaThreadView::slotOnURL( const QString& url )
-{
- hidePopup();
- if ( !isActiveWindow() ) return ;
- if ( url.isEmpty() ) return ;
-
- if ( m_popup )
- {
- delete m_popup;
- m_popup = NULL;
- }
-
- /* id popup */
- if ( url.left( 6 ) == "#idpop" )
- {
- int num = Kita::DatManager::getNumByID( m_thread->datURL(), url.mid( 6 ) );
- if ( num <= 1 ) return ;
- QString tmpstr = QString( "<DIV>ID:%1:[%2]<BR><BR></DIV>" ).arg( url.mid( 6 ) ).arg( num );
- showPopup( tmpstr, QString::null );
- return ;
- }
-
- /*-------------------------*/
- /* popup for anchor */
-
- QString innerHTML = QString::null;
- QString refstr;
- KURL datURL = m_thread->datURL();
- int refNum;
- int refNum2;
-
- if ( url.at( 0 ) == '#' ) refstr = url.mid( 1 );
- else if ( url.left( 7 ) == "mailto:" )
- {
- DOM::Node node = m_threadPart->nodeUnderMouse().firstChild();
- QString nodeValue = node.nodeValue().string();
- refstr = nodeValue;
- }
- else
- {
- datURL = filterReadCGI( KURL( m_thread->datURL(), url ) , m_thread );
- refstr = datURL.ref();
- }
-
- /* Is this url 2ch ? */
- /* copied from KitaThreadTabWidget::slotOpenURLRequest */
- QRegExp regexp( "http://([^/]*)/([^/]*)/dat/(.*)\\.dat" );
- if ( regexp.search( datURL.url() ) == -1 ) {
- if( Kita::boardType( datURL.url() ) != Kita::Board_MachiBBS )
- return ;
- }
-
- int i = refstr.find( "-" );
- if ( i != -1 )
- { /* >>refNum-refNum2 */
-
- refNum = refstr.left( i ).toInt();
- refNum2 = refstr.mid( i + 1 ).toInt();
-
- if ( refNum )
- {
- if ( refNum2 < refNum ) refNum2 = refNum;
- if ( refNum2 - refNum > m_maxpopup - 1 ) refNum2 = refNum + m_maxpopup - 1;
- }
-
- }
- else
- { /* >>refNum */
- refNum = refstr.toInt();
- refNum2 = refNum;
- }
-
- /* another thread ? */
- if ( datURL.host() != KURL( m_thread->datURL() ).host()
- || datURL.path() != KURL( m_thread->datURL() ).path() )
- {
-
- /* show subject */
- innerHTML = Kita::DatManager::getSubject( datURL );
- if ( innerHTML != QString::null ) innerHTML += "<br><br>";
-
- if ( !refNum ) refNum = refNum2 = 1;
- }
-
- /* get HTML and show it */
- if ( !refNum ) return ;
- innerHTML += Kita::DatManager::getHtml( datURL, refNum, refNum2 );
-
- if ( innerHTML != QString::null ) showPopup( innerHTML, QString::null );
-}
-
/*------------------------*/
/* search function */
if ( str.at( 0 ) == ':' )
{
QString anc = str.mid( 1 );
- gotoAnchor( anc );
+ m_threadPart->gotoAnchor( anc, TRUE );
SearchCombo->setFocus();
return ;
}
}
/* if this is parent, then show all responses, and search */
- if ( m_viewmode == VIEWMODE_PARENT )
- {
- int top = m_domtree->getTopResNumber();
- int bottom = m_domtree->getBottomResNumber();
- int totalNum = m_domtree->getMaxResNumber();
- if ( top != 1 || bottom != totalNum )
- {
- appendRes( 1, totalNum );
- }
- }
+ if ( m_viewmode == VIEWMODE_PARENT ) m_threadPart->showAll();
insertSearchCombo();
QStringList list = parseSearchQuery( SearchCombo->currentText() );
- m_domtree->findText( SearchCombo->currentText(), m_revsearch );
+ m_threadPart->findText( SearchCombo->currentText(), m_revsearch );
SearchCombo->setFocus();
}
// vim:sw=2:
if ( index == gotoCombo->count() - 1 )
{
// last
- gotoAnchor( "footer" );
+ m_threadPart->gotoAnchor( "footer", TRUE );
}
else if ( index == 1 )
{
// kokomade yonda
- gotoAnchor( "kokomade_yonda" );
+ m_threadPart->gotoAnchor( "kokomade_yonda", TRUE );
}
else if ( index != 0 )
{
QString numText = gotoCombo->text( index );
numText.truncate( numText.length() - 1 );
- gotoAnchor( numText );
+ m_threadPart->gotoAnchor( numText, TRUE );
}
}
/*---------------------*/
/* set data & parse it */
/*---------------------*/ /* public */
-void KitaThreadView::domAppendData( QString& str, int bufnum , int num )
+void KitaThreadView::domAppendData( QString& , int bufnum , int )
{
- m_domtree->appendRes( bufnum, FALSE );
+ m_threadPart->showResponses(bufnum,bufnum);
}
/* public */
-void KitaThreadView::domDeleteRes( int bufnum )
+void KitaThreadView::domDeleteRes( int )
{
- m_domtree->removeRes( bufnum );
+
}
/* public */
void KitaThreadView::domAppendBelt( QString idstr )
{
- m_domtree->createBeltNode( idstr );
+ m_threadPart->insertBeltNode(idstr);
}
/* public */
void KitaThreadView::domSetInnerHTML(const QString& html )
{
- m_threadPart->htmlDocument().body().setInnerHTML(html);
- KitaThreadViewBaseLayout->remove( subjectLabel );
- KitaThreadViewBaseLayout->removeItem( layout2 );
+ m_threadPart->setInnerHTML( html );
showStatusBar( "" );
}
{
/* label, header & footer */
- if ( hstr != NULL ) m_domtree->createCommentNode( hstr, "header", 0, 2, TRUE );
- if ( fstr != NULL ) m_domtree->createCommentNode( fstr, "footer", 0, 0, FALSE );
- if ( lbstr != NULL ) subjectLabel->setText( lbstr );
-
- /* update display */
- m_threadPart->htmlDocument().applyChanges();
- m_threadPart->view() ->layout();
- m_threadPart->view() ->setVScrollBarMode( QScrollView::AlwaysOn );
- m_threadPart->view() ->setFocus();
-
- GobackAnchorButton->setEnabled( FALSE );
- BookmarkButton->setEnabled( FALSE );
- switch( m_viewmode )
- {
-
- case VIEWMODE_PREVIEW:
- writeButton->setEnabled( FALSE );
- SearchCombo->setEnabled( FALSE );
- SearchButton->setEnabled( FALSE );
- HighLightButton->setEnabled( FALSE );
- ReloadButton->setEnabled( FALSE );
- break;
-
- case VIEWMODE_KITANAVI:
- writeButton->setEnabled( TRUE );
- ReloadButton->setEnabled( TRUE );
- break;
- }
-
+ if ( hstr != NULL ) m_threadPart->insertHeaderNode( hstr );
+ if ( fstr != NULL ) m_threadPart->insertFooterNode( fstr );
if ( cmbstr != NULL ) SearchCombo->insertItem( cmbstr );
- if ( anchor != NULL ) gotoAnchor( anchor );
+ if ( anchor != NULL ) m_threadPart->gotoAnchor( anchor, TRUE );
+ if ( lbstr != QString::null ){
+ QString str = QString( "<a href=\"%1\">[%2]</a> " )
+ .arg( Kita::DatManager::thread_boardURL( m_datURL ) )
+ .arg( Kita::DatManager::thread_boardName(m_datURL) ) + lbstr;
+ subjectLabel->setText( str );
+ }
+
+ /* update display */
+ m_threadPart->updateScreen(FALSE,FALSE);
+ updateButton();
showStatusBar( "" );
}