/* update screen */ /* public */
void KitaHTMLPart::updateScreen( bool showHeaderEtc, bool clock )
{
- if( !m_domtree ) return;
+ if( !m_domtree ){
+ view()->setFocus();
+ return;
+ }
/* show clock cursor */
if( clock ){
bool KitaHTMLPart::gotoAnchor( const QString& anc, bool pushPosition )
{
if( anc == QString::null ) return FALSE;
- if( !m_domtree ) return KHTMLPart::gotoAnchor( anc );
+ if( !m_domtree || m_mode == HTMLPART_MODE_KHTML || m_mode == HTMLPART_MODE_POPUP )
+ return KHTMLPart::gotoAnchor( anc );
hidePopup();
if( m_mode != HTMLPART_MODE_MAINPART ) return;
int kokoyon = Kita::DatManager::getKokoyonNum( m_datURL );
- gotoAnchor( QString().setNum( kokoyon ), TRUE );
+ gotoAnchor( QString().setNum( kokoyon ), FALSE );
}
if( !m_domtree
|| m_mode != HTMLPART_MODE_MAINPART
){
- gotoAnchor( "footer", TRUE );
+ gotoAnchor( "footer", FALSE );
return;
}
updateScreen( TRUE, TRUE );
}
- gotoAnchor( "footer", TRUE );
+ gotoAnchor( "footer", FALSE );
}
clipboard->setText( url , QClipboard::Selection );
break;
- case ID_Home_Link: gotoAnchor( "header", TRUE ); break;
+ case ID_Home_Link: gotoAnchor( "header", FALSE ); break;
- case ID_Temp_Link: gotoAnchor( "mae100", TRUE ); break;
+ case ID_Temp_Link: gotoAnchor( "mae100", FALSE ); break;
case ID_Koko_Link: slotGotoKokoyon(); break;
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 );
+ else if( ( m_mode == HTMLPART_MODE_KHTML || m_mode == HTMLPART_MODE_POPUP )
+ || ( m_mode == HTMLPART_MODE_NAVI && !m_domtree->isResShown( refNum ) ) ){
+ KParts::URLArgs argdummy;
+ emit openURLRequest( urlin, argdummy );
+ }
+ else gotoAnchor( QString().setNum( refNum ), TRUE );
}
break;
case WRITEMENU_REVERSERESTREE:
-// KitaNavi::showKitaNaviRevResTree( m_datURL, resNum);
+ KitaNavi::showKitaNaviRevResTree( m_datURL, resNum );
break;
case WRITEMENU_EXTRACTNAME:
-// KitaNavi::showKitaNaviByName( m_datURL, namestr );
+ KitaNavi::showKitaNaviByName( m_datURL, namestr );
break;
case WRITEMENU_ABONENAME:
**************************************************************************/
#include <qlayout.h>
+#include <qregexp.h>
#include <kaction.h>
#include <kstdaccel.h>
#include <kpopupmenu.h>
/*-------------------------*/
/* show thread on the tab */
-/*-------------------------*/
+/*-------------------------*/ /* private */
void KitaNavi::addTab(int mode,
const KURL& datURL,
const QString& query,
const int margin = 5;
int count = 0,totalNum = 0;
- QString headstr = "",footstr = "",str,urlstr,anchor="",cmbstr="";
+ QString headstr = QString::null;
+ QString footstr = QString::null;
+ QString anchor = QString::null;
+ QString cmbstr = QString::null;
+ QString str, urlstr;
QStringList queries;
QRegExp qrx(" +");
bool ext_OR;
QString labelstr;
- int serverTime = Kita::DatManager::getServerTime(datURL);
- Kita::Thread* thread = Kita::Thread::getByURL( datURL.prettyURL() );
/* set title and label */
switch(mode){
case KITANAVI_EXTBYID:
case KITANAVI_EXTBYWORD:
+ case KITANAVI_EXTBYNAME:
labelstr = query
+ " :"+ Kita::ParseMisc::utf8ToUnicode(KITAUTF8_EXTRACT);
break;
case KITANAVI_SHOWRESTREE:
+ case KITANAVI_SHOWREVRESTREE:
labelstr = QString().setNum(startnum);
break;
}
- labelstr += " :"+QString( "[%1] %2" ).arg(thread->boardName()).arg( thread->name() );
+ labelstr += " :"+QString( "[%1] %2" )
+ .arg( Kita::DatManager::thread_boardName( datURL ) )
+ .arg( Kita::DatManager::thread_name( datURL ) );
/* create KitaThreadView and setup it */
KitaThreadView *view = new KitaThreadView(m_qtw);
connect( Kita::SignalCollection::getInstance(), SIGNAL( signalChangeStatusbar( const QString&) ),
this,SLOT( slotChangeCaption( const QString& )));
- connect( view, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
- Kita::SignalCollection::getInstance(), SLOT( slotOpenURLRequest( const KURL&, const KParts::URLArgs& ) ) );
- view->setupEx(thread , serverTime, VIEWMODE_KITANAVI);
- totalNum = Kita::DatManager::getMaxResNumber(thread->datURL());
+ view->setup( datURL, VIEWMODE_KITANAVI );
+ totalNum = Kita::DatManager::getMaxResNumber( datURL );
/*---------------------------------------------*/
/* copy data from DatManager to KitaThreadView */
for(int i = QMAX(1,startnum-margin); i <= QMIN(totalNum,endnum+margin); i++){
if(i == startnum) view->domAppendBelt("belt1");
- str = Kita::DatManager::getDat(thread->datURL(),i);
+ str = Kita::DatManager::getDat( datURL ,i);
view->domAppendData(str,i,i);
if(i == endnum) view->domAppendBelt("belt2");
}
case KITANAVI_EXTBYID:
for(int i = 1; i<= totalNum; i++){
- if(Kita::DatManager::checkID(thread->datURL(),query,i)){
- str = Kita::DatManager::getDat(thread->datURL(),i);
+ if(Kita::DatManager::checkID( datURL, query, i )){
+ str = Kita::DatManager::getDat( datURL, i );
view->domAppendData(str,i,i);
count++;
}
break;
/*--------------------------------*/
+
+ case KITANAVI_EXTBYNAME:
+
+ for(int i = 1; i<= totalNum; i++){
+ if( Kita::DatManager::getName( datURL, i ) == query ){
+ str = Kita::DatManager::getDat( datURL, i );
+ view->domAppendData( str, i, i );
+ count++;
+ }
+ }
+ headstr = Kita::ParseMisc::utf8ToUnicode(KITAUTF8_EXTRACT)
+ +QString(": %1 : [%2]").arg( query ).arg( count );
+ footstr = headstr;
+ anchor = "header";
+ break;
+
+ /*--------------------------------*/
case KITANAVI_EXTBYWORD:
queries = QStringList::split(" ", str);
for(int i = 1; i<= totalNum; i++){
- if(Kita::DatManager::checkWord(thread->datURL(),queries,i,ext_OR)){
- str = Kita::DatManager::getDat(thread->datURL(),i);
+ if(Kita::DatManager::checkWord( datURL, queries, i, ext_OR )){
+ str = Kita::DatManager::getDat( datURL, i );
view->domAppendData(str,i,i);
count++;
}
/*--------------------------------*/
case KITANAVI_SHOWRESTREE:
+ case KITANAVI_SHOWREVRESTREE:
- str = QString("[%1] %2 : No.%3 [%4]<br>").arg(thread->boardName()).arg( thread->name() ).arg(startnum ).arg( endnum );
- urlstr = Kita::DatManager::thread_url( thread->datURL()) + QString().setNum(startnum);
+ str = QString("[%1] %2 : No.%3 [%4]<br>")
+ .arg( Kita::DatManager::thread_boardName( datURL ) )
+ .arg( Kita::DatManager::thread_name( datURL ) )
+ .arg(startnum ).arg( endnum );
+ urlstr = Kita::DatManager::thread_url( datURL ) + QString().setNum( startnum );
str += "<a href=\""+urlstr+"\">"+urlstr+"</a><br>";
- str += Kita::DatManager::getHtml(thread->datURL(), startnum, startnum);
+ str += Kita::DatManager::getHtml( datURL, startnum, startnum );
if( endnum ){
str += "<div style=\"background-color: #CCCCCC; text-align: center\"><br></div>";
str += query;
}
view->domSetInnerHTML(str);
- m_qtw->showPage(view);
- raise();
- setActiveWindow();
- return;
+
break;
default:
if( ! m_kitanavi ) return;
m_kitanavi->show();
-
- m_kitanavi->addTab(KITANAVI_SHOWRES,datURL,QString::null,startnum,endnum);
+
+ KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
+ m_kitanavi->addTab( KITANAVI_SHOWRES, parsedURL, QString::null, startnum, endnum );
}
if( ! m_kitanavi ) return;
m_kitanavi->show();
- m_kitanavi->addTab(KITANAVI_EXTBYID,datURL,strid,0,0);
+ KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
+ m_kitanavi->addTab( KITANAVI_EXTBYID, parsedURL, strid, 0, 0 );
}
if( ! m_kitanavi ) return;
m_kitanavi->show();
- m_kitanavi->addTab(KITANAVI_EXTBYWORD,datURL,query,0,0);
+ KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
+ m_kitanavi->addTab( KITANAVI_EXTBYWORD, parsedURL, query, 0, 0 );
}
+/* extract by name */
+void KitaNavi::showKitaNaviByName( const KURL& datURL, QString query){
+
+ if( ! m_kitanavi ) return;
+ m_kitanavi->show();
+
+ KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
+ m_kitanavi->addTab( KITANAVI_EXTBYNAME, parsedURL, query, 0, 0 );
+}
+
+
+
/* res tree */
void KitaNavi::showKitaNaviResTree( const KURL& datURL, int resNum){
m_kitanavi->show();
int num;
- QString htmlstr = Kita::DatManager::getTreeByRes( datURL, resNum, num);
- m_kitanavi->addTab(KITANAVI_SHOWRESTREE,datURL,htmlstr,resNum,num);
+ KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
+ QString htmlstr = Kita::DatManager::getTreeByRes( parsedURL, resNum, num);
+ m_kitanavi->addTab( KITANAVI_SHOWRESTREE, parsedURL, htmlstr, resNum, num);
+}
+
+
+/* reverse res tree */
+void KitaNavi::showKitaNaviRevResTree( const KURL& datURL, int resNum){
+
+ if( ! m_kitanavi ) return;
+ m_kitanavi->show();
+
+ int num;
+ KURL parsedURL = Kita::ParseMisc::parseURLonly( datURL );
+ QString htmlstr = Kita::DatManager::getTreeByResReverse( parsedURL, resNum, num );
+ m_kitanavi->addTab( KITANAVI_SHOWREVRESTREE, parsedURL, htmlstr, resNum, num );
}
KITANAVI_SHOWRES,
KITANAVI_EXTBYID,
KITANAVI_EXTBYWORD,
+ KITANAVI_EXTBYNAME,
KITANAVI_SHOWRESTREE,
+ KITANAVI_SHOWREVRESTREE,
KITANAVI_TITLE
};
int m_navimode;
public:
- void addTab(int mode,const KURL& datURL,const QString& query,int startnum,int endnum);
/* interfaces */
static void createKitaNavi(QWidget* parent,KitaThreadTabWidget* threadTab);
static void showKitaNavi( const KURL& datURL, int startnum, int endnum);
static void showKitaNaviByID( const KURL& datURL, QString strid);
static void showKitaNaviByWord( const KURL& datURL, QString query);
+ static void showKitaNaviByName( const KURL& datURL, QString query );
static void showKitaNaviResTree( const KURL& datURL, int resNum);
+ static void showKitaNaviRevResTree( const KURL& datURL, int resNum );
private:
KitaNavi(QWidget* parent,int navimode);
~KitaNavi();
-
+ void addTab( int mode, const KURL& datURL, const QString& query, int startnum, int endnum );
+
protected:
void windowActivationChange( bool );
void KitaThreadPart::guiActivateEvent ( KParts::GUIActivateEvent* event )
{
//KParts::ReadOnlyPart::guiActivateEvent( event );
- if ( event->activated() )
+ if ( event->activated() ){
emit setWindowCaption( m_threadview->threadName() );
+ m_threadview->showStatusBar( QString::null );
+ }
}
KitaThreadBrowserExtension::KitaThreadBrowserExtension( KitaThreadPart* parent )
connect( gotoCombo, SIGNAL( activated( int ) ),
SLOT( slotComboActivated( int ) ) );
- KParts::BrowserExtension* ext = m_threadPart->browserExtension();
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
- connect( this, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
- signalCollection, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ) );
- connect( ext, SIGNAL( createNewWindow ( const KURL&, const KParts::URLArgs& ) ),
- SIGNAL( createNewWindow ( const KURL&, const KParts::URLArgs& ) ) );
- connect( ext, SIGNAL( setLocationBarURL( const QString& ) ),
- SIGNAL( setLocationBarURL( const QString& ) ) );
- connect( ext, SIGNAL( enableAction( const char*, bool ) ),
- SIGNAL( enableAction( const char*, bool ) ) );
connect( this, SIGNAL( signalChangeStatusbar( const QString& ) ),
signalCollection, SIGNAL( signalChangeStatusbar( const QString& ) ) );
- connect( ext, SIGNAL( popupMenu( KXMLGUIClient*, const QPoint&, const KURL&, const QString&, mode_t ) ),
- this, SLOT( slotPopupMenu( KXMLGUIClient*, const QPoint&, const KURL&, const QString&, mode_t ) ) );
connect( this, SIGNAL( bookmarked( const QString&, bool ) ),
signalCollection, SIGNAL( bookmarked( const QString&, bool ) ) );
connect( this, SIGNAL( showThreadCompleted( const KURL& ) ),
/*-------*/
/* setup */
/*-------*/
-void KitaThreadView::setupEx( const Kita::Thread* thread, int , int mode )
+void KitaThreadView::setup( const KURL& datURL, int mode )
{
/* config. */
/*---------------------------------------*/
/* setup */
- m_thread = const_cast<Kita::Thread *>( thread );
- QString refstr;
- m_datURL = Kita::ParseMisc::parseURL(m_thread->datURL(),refstr);
-
+ m_datURL = Kita::ParseMisc::parseURLonly( datURL );
+ m_thread = Kita::Thread::getByURL( m_datURL.prettyURL() );
+
/* setup HTMLPart */
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;
- /* If curreent mode is VIEWMODE_PREVIEW , hide buttons */
- if ( m_viewmode == VIEWMODE_PREVIEW )
- {
- QLayout* Base = layout();
- Base->remove( Subjectframe );
- Base->removeItem( layout2 );
- }
-
/* reset search direction */
m_revsearch = FALSE;
}
setActiveWindow();
/* setup */
- Kita::Thread* thread2ch = Kita::Thread::getByURL( datURL.prettyURL() );
- setupEx( thread2ch , 0, VIEWMODE_PARENT );
+ setup( datURL, VIEWMODE_PARENT );
/* get log from cahce */
m_rescode = 200;
/*------------------------*/ /* private slots */
void KitaThreadView::slotSearchButton()
{
- if ( m_viewmode == VIEWMODE_PREVIEW ) return ;
-
if ( m_datURL.isEmpty() ) return ; /* Nothing is shown on the screen.*/
/* jump */
if ( str.at( 0 ) == ':' )
{
QString anc = str.mid( 1 );
- m_threadPart->gotoAnchor( anc, TRUE );
+ m_threadPart->gotoAnchor( anc, FALSE );
SearchCombo->setFocus();
return ;
}
if ( index == gotoCombo->count() - 1 )
{
// last
- m_threadPart->gotoAnchor( "footer", TRUE );
+ m_threadPart->gotoAnchor( "footer", FALSE );
}
else if ( index == 1 )
{
// kokomade yonda
- m_threadPart->gotoAnchor( "kokomade_yonda", TRUE );
+ m_threadPart->gotoAnchor( "kokomade_yonda", FALSE );
}
else if ( index != 0 )
{
QString numText = gotoCombo->text( index );
numText.truncate( numText.length() - 1 );
- m_threadPart->gotoAnchor( numText, TRUE );
+ m_threadPart->gotoAnchor( numText, FALSE );
}
}
if ( hstr != NULL ) m_threadPart->insertHeaderNode( hstr );
if ( fstr != NULL ) m_threadPart->insertFooterNode( fstr );
if ( cmbstr != NULL ) SearchCombo->insertItem( cmbstr );
- if ( anchor != NULL ) m_threadPart->gotoAnchor( anchor, TRUE );
+ if ( anchor != NULL ) m_threadPart->gotoAnchor( anchor, FALSE );
if ( lbstr != QString::null ){
QString str = QString( "<a href=\"%1\">[%2]</a> " )
.arg( Kita::DatManager::thread_boardURL( m_datURL ) )
}
/* update display */
- m_threadPart->updateScreen(FALSE,FALSE);
+ m_threadPart->updateScreen(FALSE,FALSE);
updateButton();
showStatusBar( "" );
#include "kita2ch.h"
#include "libkita/thread.h"
-#include "kitadomtree.h"
class KURL;
class KitaHTMLPart;
namespace Kita
{
- class Access;
class KitaSubjectLabel;
- class PopupTextBrowser;
- class ResPopup;
}
/* mode , m_viewmode uses them. */
enum{
VIEWMODE_PARENT,
- VIEWMODE_KITANAVI,
- VIEWMODE_PREVIEW
+ VIEWMODE_KITANAVI
};
namespace KIO
const QString threadName() const;
const KURL threadURL() const;
- void setupEx( const Kita::Thread* thread, int serverTime, int mode );
+ void setup( const KURL& datURL, int mode );
void showStatusBar( QString info );
Kita::Thread* get2chThread() { return m_thread; }
int getViewMode() { return m_viewmode; }