OSDN Git Service

refactoring.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Thu, 7 Oct 2004 15:49:58 +0000 (15:49 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Thu, 7 Oct 2004 15:49:58 +0000 (15:49 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1420 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/favoritelistview.cpp
kita/src/kitasubjectview.cpp

index d104a4f..f701d3c 100644 (file)
@@ -15,6 +15,7 @@
 #include "libkita/threadinfo.h"
 #include "libkita/signalcollection.h"
 #include "libkita/parsemisc.h"
+#include "libkita/datmanager.h"
 
 #include <qmap.h>
 #include <qapplication.h>
@@ -71,12 +72,13 @@ void FavoriteListView::update()
     QValueList<QString>::const_iterator it;
     for ( it = threadList.begin(); it != threadList.end(); ++it ) {
         const Kita::Thread* thread = Kita::Thread::getByURL( *it );
+        QString datURL = thread->datURL();
 
         QDateTime since;
-        since.setTime_t( Kita::datToSince( thread->datURL() ) );
+        since.setTime_t( Kita::datToSince( datURL ) );
 
-        int readNum = cache->readNum( thread->datURL() );
-        int resNum = KitaThreadInfo::resNum( thread->datURL() );
+        int readNum = cache->readNum( datURL );
+        int resNum = KitaThreadInfo::resNum( datURL );
 
         KListViewItem* item = new KListViewItem( subjectList );
         item->setText( Col_Board, thread->boardName() );
@@ -89,7 +91,7 @@ void FavoriteListView::update()
             }
         }
         item->setText( Col_Since, since.toString( "yy/MM/dd hh:mm" ) );
-        item->setText( Col_DatURL, thread->datURL() );
+        item->setText( Col_DatURL, datURL );
     }
     subjectList->setSorting( Col_Board );
 }
@@ -137,22 +139,23 @@ void FavoriteListView::slotContextMenuRequested( QListViewItem* item, const QPoi
     popup.insertItem( i18n( "Copy title and URL" ), 2 );
     popup.insertItem( i18n( "Remove from Favorites" ), 3 );
 
-    Kita::Thread* thread = Kita::Thread::getByURL( item->text( Col_DatURL ) );
+    QString datURL = item->text( Col_DatURL );
+    Kita::Thread* thread = Kita::Thread::getByURL( datURL );
 
     QClipboard* clipboard = QApplication::clipboard();
 
     switch ( popup.exec( point ) ) {
     case 0:
-        KRun::runURL( thread->url(), "text/html" );
+        KRun::runURL( Kita::DatManager::threadURL( datURL ), "text/html" );
         break;
     case 1:
-        emit openURLRequestExt( thread->datURL(), KParts::URLArgs(), "kita_open_2chthread", 1 );
+        emit openURLRequestExt( datURL, KParts::URLArgs(), "kita_open_2chthread", 1 );
         break;
     case 2:
         clipboard->setText( thread->name() + "\n" + thread->url() );
         break;
     case 3:
-        emit bookmarked( thread->datURL(), false );
+        emit bookmarked( datURL, false );
         break;
     default:
         break;
index 689ee3b..82f7f78 100644 (file)
@@ -108,7 +108,7 @@ void KitaSubjectView::loadThread( QListViewItem* item )
     if ( KitaConfig::alwaysUseTab() ) {
         emit openURLRequestExt( thread->datURL(), KParts::URLArgs(), "kita_open_2chthread", 1 );
     } else { 
-        emit openURLRequestExt( thread->datURL(), KParts::URLArgs(), "kita_open_2chthread", 0 );       
+        emit openURLRequestExt( thread->datURL(), KParts::URLArgs(), "kita_open_2chthread", 0 );
     }
 }
 /*
@@ -155,12 +155,13 @@ void KitaSubjectView::loadBoard( const QString& boardURL )
 
     for ( unsigned i = 0; i < threadList.count(); i++ ) {
         Kita::Thread* thread = threadList.at( i );
+        QString datURL = thread->datURL();
 
         QDateTime since;
-        since.setTime_t( Kita::datToSince( thread->datURL() ) );
+        since.setTime_t( Kita::datToSince( datURL ) );
         QDateTime current = QDateTime::currentDateTime();
 
-        int readNum = cache->readNum( thread->datURL() );
+        int readNum = cache->readNum( datURL );
         int resNum = thread->resNum();
         double speed = resNum / ( since.secsTo( current ) / ( 60.0 * 60.0 * 24.0 ) );
 
@@ -172,7 +173,7 @@ void KitaSubjectView::loadBoard( const QString& boardURL )
         item->setText( Col_Unread, ( readNum > 0 && resNum != readNum ) ? QString( "%1" ).arg( resNum - readNum, 4 ) : QString( "" ) );
         item->setText( Col_Board, thread->boardName() );
         item->setText( Col_Since, since.toString( "yy/MM/dd hh:mm" ) );
-        item->setText( Col_DatURL, thread->datURL() );
+        item->setText( Col_DatURL, datURL );
         item->setText( Col_Speed, QString( " %1 " ).arg( speed, 0, 'f', 2 ) );
 
         // FIXME: updateThread¤Ë¥³¥Ô¡¼¤·¤Æ¤¤¤ë
@@ -262,7 +263,7 @@ void KitaSubjectView::slotUpdateSubject( const KURL& url )
             since.setTime_t( Kita::datToSince( datURL.prettyURL() ) );
 
             int resNum = updated_thread->resNum();
-            int readNum = KitaThreadInfo::readNum( updated_thread->datURL() );
+            int readNum = KitaThreadInfo::readNum( datURL.prettyURL() );
             item->setText( Col_ResNum, QString( "%1" ).arg( resNum, 4 ) );
             item->setText( Col_Read, ( readNum > 0 ) ? QString( "%1" ).arg( readNum, 4 ) : QString( "" ) );
             item->setText( Col_Unread, readNum > 0 && resNum != readNum ? QString( "%1" ).arg( resNum - readNum, 4 ) : QString( "" ) );
@@ -314,8 +315,10 @@ void KitaSubjectView::slotContextMenuRequested( QListViewItem* item, const QPoin
         return ;
     }
 
-    Kita::Thread* thread = Kita::Thread::getByURL( item->text( Col_DatURL ) );
-    bool isFavorites = FavoriteThreads::getInstance() ->contains( thread->datURL() );
+    QString datURL = item->text( Col_DatURL );
+    Kita::Thread* thread = Kita::Thread::getByURL( datURL );
+    QString threadURL = Kita::DatManager::threadURL( datURL );
+    bool isFavorites = FavoriteThreads::getInstance() ->contains( datURL );
 
     KPopupMenu popup( 0 );
     popup.insertItem( i18n( "Open with Web Browser" ), Menu_OpenWithBrowser );
@@ -335,30 +338,29 @@ void KitaSubjectView::slotContextMenuRequested( QListViewItem* item, const QPoin
 
     switch ( popup.exec( point ) ) {
     case Menu_OpenWithBrowser:
-        KRun::runURL( thread->url(), "text/html" );
+        KRun::runURL( threadURL, "text/html" );
         break;
     case Menu_OpenWithNewTab:
-        emit openURLRequestExt( thread->datURL(), KParts::URLArgs(), "kita_open_2chthread", 1 );
+        emit openURLRequestExt( datURL, KParts::URLArgs(), "kita_open_2chthread", 1 );
         break;
     case Menu_CopyTitleAndURL:
-        clipboard->setText( thread->name() + "\n" + thread->url() );
+        clipboard->setText( thread->name() + "\n" + threadURL );
         break;
     case Menu_Favorites:
         if ( isFavorites ) {
-            emit bookmarked( thread->datURL(), false );
+            emit bookmarked( datURL, false );
         } else {
-            emit bookmarked( thread->datURL(), true );
+            emit bookmarked( datURL, true );
         }
         break;
     case Menu_DeleteLog:
-        deleteLog( Kita::DatManager::threadURL( thread->datURL() ) );
+        deleteLog( threadURL );
         break;
     case Menu_Property:
         {
             // FIXME: memory leak
             Kita::ThreadProperty* propertyWidget = new Kita::ThreadProperty( 0 );
-            KURL datURL = thread->datURL();
-            propertyWidget->threadURLLabel->setText( datURL.url() );
+            propertyWidget->threadURLLabel->setText( datURL );
             propertyWidget->threadNameLabel->setText( Kita::DatManager::threadName( datURL ) );
             propertyWidget->cachePathLabel->setText( Kita::DatManager::getCachePath( datURL ) );
             propertyWidget->indexPathLabel->setText( Kita::DatManager::getCacheIndexPath( datURL ) );