OSDN Git Service

>>555
[kita/kita.git] / kita / src / libkita / thread.cpp
index 36608d7..4c02c57 100644 (file)
@@ -9,26 +9,7 @@
 ***************************************************************************/
 
 #include "thread.h"
-#include "qcp932codec.h"
 
-#include <config.h>
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <kurl.h>
-#include <kdebug.h>
-#include <kprotocolmanager.h>
-#include <kglobal.h>
-#include <kstandarddirs.h>
-
-#include <kio/slaveconfig.h>
-#include <kio/jobclasses.h>
-#include <kio/scheduler.h>
-#include <kio/netaccess.h>
-
-#include <qwidget.h>
-#include <qapplication.h>
 #include <qregexp.h>
 
 
@@ -36,17 +17,14 @@ using namespace Kita;
 
 QDict<Thread>* Thread::m_threadDict = 0;
 
-Thread::Thread()
-{}
-
-Thread::Thread( const QString& datURL, const QString& threadName )
-    : m_datURL( datURL ), m_threadName( threadName ), m_cached( 0 )
+Thread::Thread( const KURL& datURL )
+    : m_datURL( datURL ), m_threadName( 0 ) , m_resNum( 0 ), m_readNum( 0 ), m_viewPos( 0 )
 {}
 
 Thread::~Thread()
 {}
 
-const QString& Thread::datURL() const
+const KURL& Thread::datURL() const
 {
     return m_datURL;
 }
@@ -58,29 +36,70 @@ const QString& Thread::threadName() const
 }
 
 /* public */
-const bool Thread::isCached() const
+void Thread::setThreadName( QString threadName )
 {
-    return m_cached;
+    /* remove space */
+    QRegExp qrx(" +$");    
+    threadName.replace( qrx, "" );
+
+    /* unescape */
+    threadName.replace( "&lt;", "<" ).replace( "&gt;", ">" ).replace( "&amp;", "&" );
+    
+    m_threadName = threadName;
 }
 
 /* public */
-void Thread::setCached( bool cached )
+const int Thread::resNum() const
 {
-    m_cached = cached;
+    return m_resNum;
 }
 
+/* public */
+void Thread::setResNum( int num )
+{
+    m_resNum = num;
+}
 
-Thread* Thread::getByURL( const QString& datURL )
+/* public */
+const int Thread::readNum() const
+{
+    return m_readNum;
+}
+
+/* public */
+void Thread::setReadNum( int num )
+{
+    m_readNum = num;
+    if ( m_resNum < m_readNum ) setResNum( m_readNum );
+}
+
+/* public */
+const int Thread::viewPos() const
+{
+    return m_viewPos;
+}
+
+/* public */
+void Thread::setViewPos( int num )
+{
+    m_viewPos = num;
+}
+
+/*--------------------------------------------*/
+
+/* static functions */
+
+Thread* Thread::getByURL( const KURL& datURL )
 {
     if ( m_threadDict == 0 ) {
         m_threadDict = new QDict<Thread>();
     }
 
-    Thread* thread = m_threadDict->find( datURL );
+    Thread* thread = m_threadDict->find( datURL.prettyURL() );
     if ( thread ) return thread;
 
     Thread* newThread = new Thread( datURL );
-    m_threadDict->insert( datURL, newThread );
+    m_threadDict->insert( datURL.prettyURL(), newThread );
 
     return newThread;
 }
@@ -93,39 +112,6 @@ Thread* Thread::getByURLNew( const KURL& datURL )
     return m_threadDict->find( datURL.prettyURL() );
 }
 
-const QString& Thread::getName( const KURL& datURL )
-{
-    Thread* thread = Thread::getByURLNew( datURL );
-    if ( thread == NULL ) {
-        return QString::null;
-    }
-    return thread->m_threadName;
-}
-
-void Thread::setName( const QString& datURL, QString threadName )
-{
-    QRegExp qrx(" +$");    
-    threadName.replace( qrx, "" );
-    
-    if ( datURL.isNull() ) {
-        return ;
-    }
-
-    if ( m_threadDict == 0 ) {
-        m_threadDict = new QDict<Thread>();
-    }
-
-    if ( m_threadDict->find( datURL ) ) {
-        Thread * thread = getByURL( datURL );
-        thread->m_threadName = threadName;
-    } else {
-        Thread* newThread = new Thread( datURL, threadName );
-        m_threadDict->insert( datURL, newThread );
-    }
-
-    return ;
-}
-
 void Thread::replace( const QString& fromURL, const QString& toURL )
 {
     if( m_threadDict == NULL ) return;