OSDN Git Service

>>968 more fixes.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 10 Jul 2004 10:34:24 +0000 (10:34 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 10 Jul 2004 10:34:24 +0000 (10:34 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1233 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/kitasubjectview.cpp
kita/src/kitathreadtabwidget.cpp
kita/src/libkita/datinfo.cpp
kita/src/libkita/datinfo.h
kita/src/libkita/datmanager.cpp
kita/src/libkita/datmanager.h
kita/src/part/kitadomtree.cpp
kita/src/part/kitahtmlpart.cpp
kita/src/part/kitanavi.cpp
kita/src/part/kitathreadview.cpp
kita/src/part/kitawritedialog.cpp

index 1b5a060..e82402b 100644 (file)
@@ -219,10 +219,15 @@ void KitaSubjectView::setFont( const QFont& font )
 
 void KitaSubjectView::slotUpdateSubject( const KURL& url )
 {
+    QDateTime currentdat = QDateTime::currentDateTime();
+
     KURL datURL = Kita::ParseMisc::parseURLonly( url );
     Kita::Thread* updated_thread = Kita::Thread::getByURLNew( datURL );
     for ( QListViewItem * item = subjectList->firstChild(); item; item = item->nextSibling() ) {
         if ( item->text( Col_DatURL ) == datURL.prettyURL() ) {
+           QDateTime since;
+           since.setTime_t( Kita::datToSince( datURL.prettyURL() ) );
+           
             int resNum = updated_thread->resNum();
             int readNum = KitaThreadInfo::readNum( updated_thread->datURL() );
             item->setText( Col_ResNum, QString( "%1" ).arg( resNum, 4 ) );
@@ -245,9 +250,15 @@ void KitaSubjectView::slotUpdateSubject( const KURL& url )
                 // ´ûÆÉ
                 item->setPixmap( Col_Mark, SmallIcon( "read" ) );
                 m_readNum++;
-                item->setText( Col_MarkOrder, QString::number( ts_read ) );
+                //if( readNum > 1000) item->setText( Col_MarkOrder, "0" );
+                //else item->setText( Col_MarkOrder, "3" );
+                item->setText( Col_MarkOrder, QString::number( ( readNum > 1000 ) ? ts_readed : ts_read ) );
+            } else if ( since.secsTo( currentdat ) < 3600 * KitaConfig::MarkTime() ) {
+                item->setPixmap( Col_Mark, SmallIcon( "newthread" ) );
+                m_newNum++;
+                item->setText( Col_MarkOrder, QString::number( ts_new ) );
             } else {
-               item->setPixmap( Col_Mark, NULL );
+                item->setPixmap( Col_Mark, NULL );         
                 item->setText( Col_MarkOrder, QString::number( ts_normal ) );
             }
             UpdateKindLabel();
index 2dff656..c2346e6 100644 (file)
@@ -72,7 +72,7 @@ void KitaThreadTabWidget::showThread( const QString& url, bool withNewTab )
     QString refstr;
     KURL datURL = Kita::ParseMisc::parseURL( url, refstr);
     QString threadName = Kita::DatManager::threadName( datURL );
-    int maxNum = Kita::DatManager::getMaxResNumber( datURL );
+    int maxNum = Kita::DatManager::getReadNum( datURL );
     int num = 0;
     if( refstr != QString::null ){
        int i = refstr.find( "-" );
index 4280a17..c5c5531 100644 (file)
@@ -72,7 +72,7 @@ void DatInfo::initPrivate()
     deleteAccessJob();
 
     /* init variables */
-    m_maxNum = 0;
+    m_readNum = 0;
     m_rawData = QString::null;
     m_subject = QString::null;
     m_broken = FALSE;
@@ -139,13 +139,13 @@ void DatInfo::deleteAccessJob()
 void DatInfo::copyRawDataToBuffer(const QString& rawData)
 {
     QStringList linelist;
-    int basenum = m_maxNum + 1;
+    int basenum = m_readNum + 1;
 
     // hack for machiBBS
     if ( Kita::boardType( m_datURL.url() ) == Board_MachiBBS && m_lastLine == QString::null && m_access->responseCode() == 200 )
     {
         basenum = 1;
-        m_maxNum = 0;
+        m_readNum = 0;
     }
 
     bool endIsLF = FALSE;
@@ -200,8 +200,10 @@ void DatInfo::copyRawDataToBuffer(const QString& rawData)
     }
 
     /* update thread info */
-    if( m_thread ) m_thread->setResNum( m_maxNum );
-    KitaThreadInfo::setReadNum( m_datURL.prettyURL(), m_maxNum );
+    if( m_thread ){
+       if( m_thread->resNum() < m_readNum ) m_thread->setResNum( m_readNum );
+       KitaThreadInfo::setReadNum( m_datURL.prettyURL(), m_readNum );
+    }
 }
 
 
@@ -219,7 +221,7 @@ bool DatInfo::setDat( const QString& line, int num )
 
     resdat.set = TRUE;
     resdat.linestr = line;
-    if(m_maxNum < num) m_maxNum = num;
+    if(m_readNum < num) m_readNum = num;
     m_rawData += line + '\n';
 
     if(num == 1) parseDat ( num ); /* to get subject */
@@ -535,7 +537,7 @@ QString DatInfo::getHtmlByID(const QString& strid, int &count )
 
     count = 0;
 
-    for ( int i = 1; i <= m_maxNum; i++ )
+    for ( int i = 1; i <= m_readNum; i++ )
     {
 
         if(!parseDat(i)) continue;
@@ -648,7 +650,7 @@ QString DatInfo::getTreeByResCore(
     {
 
         /* collect responses that have anchor to rootnum */
-        for ( int i = rootnum+1; i <= m_maxNum; i++ )
+        for ( int i = rootnum+1; i <= m_readNum; i++ )
         {
             if(checkAbonePrivate( i ) ) continue;
             if(checkRes(i,rootnum))
@@ -924,11 +926,11 @@ bool DatInfo::getDomElement(
 /* several information */
 
 /* public */
-int DatInfo::getMaxResNumber()
+int DatInfo::getReadNum()
 {
     QMutexLocker locker( &m_mutex );
 
-    return m_maxNum;
+    return m_readNum;
 }
 
 
@@ -940,7 +942,7 @@ int DatInfo::getNumByID( const QString& strid )
 
     int count = 0;
 
-    for ( int i = 1; i <= m_maxNum; i++ )
+    for ( int i = 1; i <= m_readNum; i++ )
     {
 
         if( !parseDat(i) ) continue;
@@ -957,7 +959,7 @@ int DatInfo::getKokoyonNum()
 {
     QMutexLocker locker( &m_mutex );
 
-    return QMIN(m_kokoyonNum, m_maxNum);
+    return QMIN(m_kokoyonNum, m_readNum);
 }
 
 /* public */
@@ -965,7 +967,7 @@ void DatInfo::setKokoyonNum(int num)
 {
     QMutexLocker locker( &m_mutex );
 
-    num = QMIN(num, m_maxNum);
+    num = QMIN(num, m_readNum);
 
     m_kokoyonNum = num;
     KitaThreadInfo::setReadNum( m_datURL.prettyURL(), num );
index 27f5418..8e8fa67 100644 (file)
@@ -106,7 +106,7 @@ namespace Kita
         QMutex m_mutex;
 
         /* basic information */
-        int m_maxNum;
+        int m_readNum;
         QString m_rawData;
         KURL m_datURL;
         QString m_subject;
@@ -178,7 +178,7 @@ namespace Kita
         bool getDomElement(int num, DOM::HTMLDocument& hdoc, DOM::Element& retelm);
 
         /* numerical data */
-        int getMaxResNumber();
+        int getReadNum();
         int getNumByID( const QString& strid );
         int getKokoyonNum();
         void setKokoyonNum(int num);
index 928e6b4..63bc8d1 100644 (file)
@@ -13,6 +13,7 @@
 #include <qstringlist.h>
 
 #include "thread.h"
+#include "threadinfo.h"
 #include "parsemisc.h"
 #include "datmanager.h"
 #include "datinfo.h"
@@ -501,31 +502,27 @@ bool DatManager::getDomElement(const KURL& url, int num, DOM::HTMLDocument& hdoc
 
 
 /* public */
-int DatManager::getMaxResNumber( const KURL& url )
+int DatManager::getResNum( const KURL& url )
 {
     QMutexLocker locker( &m_mutex );
-    
-    DatInfo * datInfo = getDatInfo( url );
-    if ( datInfo == NULL ) return 0;
 
-    return datInfo->getMaxResNumber();
+    KURL datURL =  Kita::ParseMisc::parseURLonly( url );
+    return KitaThreadInfo::resNum( datURL.prettyURL() );
 }
 
 
-
 /* public */
-int DatManager::getNumByID( const KURL& url, const QString& strid )
+int DatManager::getReadNum( const KURL& url )
 {
     QMutexLocker locker( &m_mutex );
     
     DatInfo * datInfo = getDatInfo( url );
     if ( datInfo == NULL ) return 0;
 
-    return datInfo->getNumByID(strid);
+    return datInfo->getReadNum();
 }
 
 
-
 /* public */
 int DatManager::getKokoyonNum( const KURL& url )
 {
@@ -561,7 +558,16 @@ int DatManager::getDatSize( const KURL& url )
     return datInfo->getDatSize();
 }
 
+/* public */
+int DatManager::getNumByID( const KURL& url, const QString& strid )
+{
+    QMutexLocker locker( &m_mutex );
+    
+    DatInfo * datInfo = getDatInfo( url );
+    if ( datInfo == NULL ) return 0;
 
+    return datInfo->getNumByID(strid);
+}
 
 
 /* public */
index d7cb8af..8ef1fa6 100644 (file)
@@ -82,12 +82,13 @@ class DatManager
        static bool getDomElement(const KURL& url, int num, DOM::HTMLDocument& hdoc, DOM::Element& retelm);
        
        /* numerical data */
-       static int getMaxResNumber( const KURL& url );
-       static int getNumByID( const KURL& url, const QString& strid );
+       static int getResNum( const KURL& url );
+       static int getReadNum( const KURL& url );       
        static int getKokoyonNum( const KURL& url );
        static void setKokoyonNum( const KURL& url, int num);
        static int getDatSize(  const KURL& url );
-
+       static int getNumByID( const KURL& url, const QString& strid );
+       
        /* another information */
        static bool isResValid( const KURL& url , int num);
        static bool isBroken( const KURL& url );        
index 6a953f7..c5382fd 100644 (file)
@@ -402,7 +402,7 @@ void KitaDomTree::appendTugi100()
     if ( ! m_datInfo ) return ;
     if ( m_hdoc == NULL ) return ;
 
-    if ( m_bottomNum == m_datInfo->getMaxResNumber() )
+    if ( m_bottomNum == m_datInfo->getReadNum() )
     {
         removeTugi100();
         return ;
index c77002b..9ae7fdb 100644 (file)
@@ -74,8 +74,8 @@ void KitaHTMLPart::clearPart()
     /* 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 );
+        int readNum = Kita::DatManager::getReadNum( m_datURL );
+        if( readNum ) Kita::DatManager::setKokoyonNum( m_datURL, readNum );
     }
     m_updatedKokoyon = FALSE;
 
@@ -227,10 +227,10 @@ void KitaHTMLPart::showAll()
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
-    int totalNum = Kita::DatManager::getMaxResNumber( m_datURL );
-    if ( top != 1 || bottom != totalNum )
+    int readNum = Kita::DatManager::getReadNum( m_datURL );
+    if ( top != 1 || bottom != readNum )
     {
-        showResponses( 1, totalNum );
+        showResponses( 1, readNum );
         updateScreen( TRUE, TRUE );
     }
 }
@@ -294,12 +294,12 @@ void KitaHTMLPart::updateScreen( bool showHeaderEtc, bool clock )
     if( showHeaderEtc )
     {
 
-        int maxNum = Kita::DatManager::getMaxResNumber( m_datURL);
+        int readNum = Kita::DatManager::getReadNum( m_datURL);
 
         m_domtree->appendMae100();
         m_domtree->appendTugi100();
         m_domtree->appendKokoyon();
-        m_domtree->appendFooter( maxNum );
+        m_domtree->appendFooter( readNum );
     }
 
     /*----------------------------*/
@@ -365,9 +365,9 @@ void KitaHTMLPart::slotSetFontOfHTMLPart()
 
 /*  top = centerNum - preShowNum
     bottom = centerNum + afterShowNum
-    maxNum = ita::DatManager::getMaxResNumber
+    readNum = Kita::DatManager::getReadNum
  
-    No.1 <- show -> No.20 <- not show -> No.(top) <- show -> No.(bottom) <- not show -> No.(maxNum) */
+    No.1 <- show -> No.20 <- not show -> No.(top) <- show -> No.(bottom) <- not show -> No.(readNum) */
 
 bool KitaHTMLPart::load( int centerNum )
 {
@@ -384,7 +384,7 @@ bool KitaHTMLPart::load( int centerNum )
 
     if( m_mode != HTMLPART_MODE_MAINPART ) return FALSE;
     if( !m_domtree ) return FALSE;
-    if( Kita::DatManager::getMaxResNumber( m_datURL ) == 0 ) return FALSE;
+    if( Kita::DatManager::getReadNum( m_datURL ) == 0 ) return FALSE;
 
     m_domtree->appendTemplate();
     showResponses( m_centerNum - preShowNum, m_centerNum + afterShowNum );
@@ -450,27 +450,27 @@ void KitaHTMLPart::slotReceiveData()
     if( m_mode != HTMLPART_MODE_MAINPART ) return;
     if( !m_domtree ) return;
 
-    int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+    int readNum = Kita::DatManager::getReadNum( m_datURL );
     int bottom = m_domtree->getBottomResNumber();
     int showNum = m_centerNum + afterShowNum;
 
     /* parsing */
-    if( oneAfterAnother ) parseResponses( bottom+1, maxNum );
+    if( oneAfterAnother ) parseResponses( bottom+1, readNum );
 
     /* rendering */
     if( m_firstReceive
-            || ( bottom + delta < maxNum && maxNum <= showNum + delta -1 ) )
+            || ( bottom + delta < readNum && readNum <= showNum + delta -1 ) )
     {
 
         if( oneAfterAnother )
         {
-            showResponses( bottom+1, QMIN( maxNum, showNum ) );
+            showResponses( bottom+1, QMIN( readNum, showNum ) );
             updateScreen( TRUE, FALSE );
         }
-        else parseResponses( bottom+1, QMIN( maxNum, showNum ) );
+        else parseResponses( bottom+1, QMIN( readNum, showNum ) );
     }
 
-    if( m_firstReceive  && m_centerNum < maxNum )
+    if( m_firstReceive  && m_centerNum < readNum )
     {
         gotoAnchor( QString().setNum( m_centerNum ), FALSE );
         m_firstReceive = FALSE;
@@ -620,9 +620,9 @@ void KitaHTMLPart::slotClickTugi100()
     if( m_mode != HTMLPART_MODE_MAINPART ) return;
 
     int bottom = m_domtree->getBottomResNumber();
-    int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+    int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( maxNum != bottom )
+    if ( readNum != bottom )
     {
         showResponses( bottom + 1, bottom + 100 );
         updateScreen( TRUE, TRUE );
@@ -638,11 +638,11 @@ void KitaHTMLPart::slotClickNokori()
     if( m_mode != HTMLPART_MODE_MAINPART ) return;
 
     int bottom = m_domtree->getBottomResNumber();
-    int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+    int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( maxNum != bottom )
+    if ( readNum != bottom )
     {
-        showResponses( bottom + 1, maxNum );
+        showResponses( bottom + 1, readNum );
         updateScreen( TRUE, TRUE );
     }
 }
@@ -660,11 +660,11 @@ void KitaHTMLPart::slotClickGotoFooter()
     }
 
     int bottom = m_domtree->getBottomResNumber();
-    int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+    int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( maxNum != bottom )
+    if ( readNum != bottom )
     {
-        showResponses( bottom + 1, maxNum );
+        showResponses( bottom + 1, readNum );
         updateScreen( TRUE, TRUE );
     }
 
@@ -743,11 +743,11 @@ void KitaHTMLPart::slotClickShowAll()
 
     int top = m_domtree->getTopResNumber();
     int bottom = m_domtree->getBottomResNumber();
-    int maxNum = Kita::DatManager::getMaxResNumber( m_datURL );
+    int readNum = Kita::DatManager::getReadNum( m_datURL );
 
-    if ( top != 1 || bottom != maxNum )
+    if ( top != 1 || bottom != readNum )
     {
-        showResponses( 1, maxNum );
+        showResponses( 1, readNum );
         updateScreen( TRUE, TRUE );
 
         gotoAnchor( "header", FALSE );
@@ -976,7 +976,7 @@ void KitaHTMLPart::showPopupMenu( const KURL& kurl )
         /* !! very dangerous to call DatManager::getDatInfoPointer without locking !! */
         Kita::DatManager::lock( m_datURL );
         Kita::DatInfo* datInfo = Kita::DatManager::getDatInfoPointer( m_datURL );
-        for( int i = 1; i <= datInfo->getMaxResNumber() ; i++ )
+        for( int i = 1; i <= datInfo->getReadNum() ; i++ )
         {
             if( datInfo->isMarked( i ) )
             {
index 94e85c9..6e12f53 100644 (file)
@@ -146,7 +146,7 @@ void KitaNavi::addTab(int mode,
              this,SLOT( slotChangeCaption( const QString& )));
 
     view->setup( datURL, VIEWMODE_KITANAVI );
-    totalNum = Kita::DatManager::getMaxResNumber( datURL );
+    totalNum = Kita::DatManager::getReadNum( datURL );
 
     /*---------------------------------------------*/
     /* copy data from DatManager to KitaThreadView */
index 94fecd3..82bf59e 100644 (file)
@@ -600,7 +600,7 @@ void KitaThreadView::showStatusBar( QString info )
 
     case VIEWMODE_PARENT:
 
-        totalNum = Kita::DatManager::getMaxResNumber(m_datURL);
+        totalNum = Kita::DatManager::getReadNum(m_datURL);
         broken = Kita::DatManager::isBroken(m_datURL);
         datSize =  Kita::DatManager::getDatSize(m_datURL);
 
@@ -640,7 +640,7 @@ void KitaThreadView::slotUpdateInfo()
     setSubjectLabel(Kita::DatManager::thread_boardName(m_datURL),
                     Kita::DatManager::thread_name(m_datURL)
                     + QString( " (%1)" )
-                    .arg( Kita::DatManager::getMaxResNumber(m_datURL) ),
+                    .arg( Kita::DatManager::getReadNum(m_datURL) ),
                     Kita::DatManager::thread_boardURL( m_datURL ) );
     emit setMainURLLine( Kita::DatManager::thread_url(m_datURL) );
     updateButton();
@@ -648,7 +648,7 @@ void KitaThreadView::slotUpdateInfo()
     gotoCombo->clear();
     gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_GOTO ) );
     gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_KOKOYON ) );
-    for( int i = 1; i < Kita::DatManager::getMaxResNumber(m_datURL); i += 100 )
+    for( int i = 1; i < Kita::DatManager::getReadNum(m_datURL); i += 100 )
     {
         gotoCombo->insertItem( QString().setNum( i ) + "-" );
     }
@@ -659,7 +659,7 @@ void KitaThreadView::slotUpdateInfo()
     emit updateThreadTab( m_datURL );
 
     QString captionStr = Kita::DatManager::thread_name( m_datURL )
-                         + QString( " (%1)" ).arg( Kita::DatManager::getMaxResNumber( m_datURL ) );
+                         + QString( " (%1)" ).arg( Kita::DatManager::getReadNum( m_datURL ) );
     emit setMainCaption( captionStr );
     showStatusBar( "" );
 
index e19bf3b..1c6e2e6 100644 (file)
@@ -274,7 +274,7 @@ void KitaWriteDialog::slotCurrentChanged ( QWidget * w )
 {
     if ( w == bodyText ) return ;
 
-    int resnum = Kita::DatManager::getMaxResNumber( m_datURL ) + 1 ;
+    int resnum = Kita::DatManager::getReadNum( m_datURL ) + 1 ;
 
     QDateTime now = QDateTime::currentDateTime();
     QString bodystr = body();