[Kita-svn] [2535] add const

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 8月 9日 (日) 16:20:20 JST


Revision: 2535
          http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2535
Author:   nogu
Date:     2009-08-09 16:20:20 +0900 (Sun, 09 Aug 2009)

Log Message:
-----------
add const

Modified Paths:
--------------
    kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/datmanager.h

Modified: kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp	2009-08-08 23:45:45 UTC (rev 2534)
+++ kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp	2009-08-09 07:20:20 UTC (rev 2535)
@@ -43,9 +43,9 @@
 /* create DatInfo explicitly.                    */
 /* Usually, DatInfo is NOT created
    if cache does not exist(i.e. ReadNum == 0). */ /* public */
-bool DatManager::createDatInfo()
+bool DatManager::createDatInfo() const
 {
-    return !(getDatInfo(false /* don't check the existence of cache */) == 0);
+    return getDatInfo(false /* don't check the existence of cache */) != 0;
 }
 
 
@@ -54,7 +54,7 @@
 /*    !!!  NOTICE  !!!   */
 /* It is very dangerous to access to DatInfo directly. */
 /* Usually, access to it through DatManager.           */ /* public */
-DatInfo * DatManager::getDatInfoPointer()
+DatInfo * DatManager::getDatInfoPointer() const
 {
     return m_datInfo;
 }
@@ -74,20 +74,18 @@
  
    see also DatManager::searchDatInfo() and DatManager::createDatInfo() */ /* private */
 
-DatInfo* DatManager::getDatInfo(bool checkCached)
+DatInfo* DatManager::getDatInfo(bool checkCached) const
 {
     /* search */
-    if (m_searchDatInfo != 0)
-        return m_searchDatInfo;
-
     /* create and enroll instance */
-    return enrollDatInfo(checkCached);
+    return (m_searchDatInfo != 0)
+        ? m_searchDatInfo : enrollDatInfo(checkCached);
 }
 
 
 /* This function just searches instance of DatInfo specified by datURL
    without creating instance.  */ /* private */
-DatInfo* DatManager::searchDatInfo()
+DatInfo* DatManager::searchDatInfo() const
 {
     if (m_datUrl.isEmpty())
         return 0; /* This url is not enrolled in BoardManager. */
@@ -121,7 +119,7 @@
 /* create and enroll the instance of DatInfo and delete old instances.
    Note that DatInfo::DatInfo() opens cached data and reads it. */
 /* private */
-DatInfo* DatManager::enrollDatInfo(bool checkCached)
+DatInfo* DatManager::enrollDatInfo(bool checkCached) const
 {
     if (m_datUrl.isEmpty())
         return 0; /* This url is not enrolled in BoardManager. */
@@ -168,27 +166,27 @@
 
 
 /* update cache */   /* public */
-bool DatManager::updateCache(const QObject* parent)
+bool DatManager::updateCache(const QObject* parent) const
 {
     return (m_datInfo == 0) ? false : m_datInfo->updateCache(parent);
 }
 
 
 /* public */
-int DatManager::getResponseCode()
+int DatManager::getResponseCode() const
 {
     return (m_datInfo == 0) ? 0 : m_datInfo->getResponseCode();
 }
 
 /* public */
-int DatManager::getServerTime()
+int DatManager::getServerTime() const
 {
     return (m_datInfo == 0) ? 0 : m_datInfo->getServerTime();
 }
 
 
 /* public */
-bool DatManager::deleteCache()
+bool DatManager::deleteCache() const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     if (thread == 0)
@@ -219,14 +217,14 @@
 
 
 /* public */
-bool DatManager::isLoadingNow()
+bool DatManager::isLoadingNow() const
 {
     return (m_searchDatInfo == 0) ? false : m_searchDatInfo->isLoadingNow();
 }
 
 
 /* public */
-void DatManager::stopLoading()
+void DatManager::stopLoading() const
 {
     if (m_searchDatInfo == 0)
         return;
@@ -238,7 +236,7 @@
 
 
 /* public */
-QString DatManager::getDat(int num)
+QString DatManager::getDat(int num) const
 {
     return (m_datInfo == 0) ? QString() : m_datInfo->getDat(num);
 }
@@ -246,35 +244,35 @@
 
 
 /* public */
-QString DatManager::getId(int num)
+QString DatManager::getId(int num) const
 {
     return (m_datInfo == 0) ? QString() : m_datInfo->getId(num);
 }
 
 
 /* public */
-QString DatManager::getPlainName(int num)
+QString DatManager::getPlainName(int num) const
 {
     return (m_datInfo == 0) ? QString() : m_datInfo->getPlainName(num);
 }
 
 
 /* public */
-QString DatManager::getPlainBody(int num)
+QString DatManager::getPlainBody(int num) const
 {
     return (m_datInfo == 0) ? QString() : m_datInfo->getPlainBody(num);
 }
 
 
 /* public */
-QString DatManager::getPlainTitle(int num)
+QString DatManager::getPlainTitle(int num) const
 {
     return (m_datInfo == 0) ? QString() : m_datInfo->getPlainTitle(num);
 }
 
 
 /* get name (i.e. subject) of thread from URL of dat file. */ /* public */
-QString DatManager::threadName()
+QString DatManager::threadName() const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     return (thread != 0) ? thread->threadName() : QString();
@@ -282,7 +280,7 @@
 
 
 /* public */
-QString DatManager::threadId()
+QString DatManager::threadId() const
 {
     return m_datUrl.fileName().section('.', 0, 0);
 }
@@ -291,7 +289,7 @@
 /* HTML data */
 
 /* public */
-QString DatManager::getHtml(int startnum, int endnum, bool checkAbone)
+QString DatManager::getHtml(int startnum, int endnum, bool checkAbone) const
 {
     return (m_datInfo == 0)
         ? QString() : m_datInfo->getHTMLString(startnum, endnum, checkAbone);
@@ -300,7 +298,7 @@
 
 
 /* public */
-QString DatManager::getHtmlById(const QString& strid, int &count)
+QString DatManager::getHtmlById(const QString& strid, int &count) const
 {
     return (m_datInfo == 0) ? QString() : m_datInfo->getHtmlById(strid, count);
 }
@@ -308,14 +306,14 @@
 
 
 /* Get HTML document of res tree.*/ /* public */
-QString DatManager::getTreeByRes(const int rootnum, int &count)
+QString DatManager::getTreeByRes(int rootnum, int &count) const
 {
     return (m_datInfo == 0)
         ? QString() : m_datInfo->getTreeByRes(rootnum, count);
 }
 
 /* Get HTML document of reverse res tree.*/ /* public */
-QString DatManager::getTreeByResReverse(int rootnum, int &count)
+QString DatManager::getTreeByResReverse(int rootnum, int &count) const
 {
     return (m_datInfo == 0)
         ? QString() : m_datInfo->getTreeByResReverse(rootnum, count);
@@ -323,7 +321,7 @@
 
 
 /* public */
-int DatManager::getResNum()
+int DatManager::getResNum() const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     return (thread != 0) ? thread->resNum() : 0;
@@ -331,7 +329,7 @@
 
 
 /* public */
-int DatManager::getReadNum()
+int DatManager::getReadNum() const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     return (thread != 0) ? thread->readNum() : 0;
@@ -339,7 +337,7 @@
 
 
 /* public */
-int DatManager::getViewPos()
+int DatManager::getViewPos() const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     return (thread != 0) ? thread->viewPos() : 0;
@@ -347,7 +345,7 @@
 
 
 /* public */
-void DatManager::setViewPos(int num)
+void DatManager::setViewPos(int num) const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     if (thread != 0)
@@ -363,27 +361,27 @@
 
 
 /* public */
-int DatManager::getDatSize()
+int DatManager::getDatSize() const
 {
     return (m_datInfo == 0) ? 0 : m_datInfo->getDatSize();
 }
 
 /* get number of responses which have same ID. */ /* public */
-int DatManager::getNumById(const QString& strid)
+int DatManager::getNumById(const QString& strid) const
 {
     return (m_datInfo == 0) ? 0 : m_datInfo->getNumById(strid);
 }
 
 
 /* public */
-bool DatManager::isThreadEnrolled()
+bool DatManager::isThreadEnrolled() const
 {
     return !m_datUrl.isEmpty();
 }
 
 
 /* public */
-bool DatManager::is2chThread()
+bool DatManager::is2chThread() const
 {
     if (BoardManager::type(m_url) != Board_2ch)
         return false;
@@ -402,20 +400,20 @@
 
 
 /* public */
-bool DatManager::isResValid(int num)
+bool DatManager::isResValid(int num) const
 {
     return (m_datInfo == 0) ? false : m_datInfo->isResValid(num);
 }
 
 
 /* public */
-bool DatManager::isBroken()
+bool DatManager::isBroken() const
 {
     return (m_datInfo == 0) ? false : m_datInfo->isBroken();
 }
 
 /* public */
-bool DatManager::isResBroken(int num)
+bool DatManager::isResBroken(int num) const
 {
     return (m_datInfo == 0) ? false : m_datInfo->isResBroken(num);
 }
@@ -423,7 +421,7 @@
 
 
 /* check if ID == strid  */ /* public */
-bool DatManager::checkId(const QString& strid, int num)
+bool DatManager::checkId(const QString& strid, int num) const
 {
     return (m_datInfo == 0) ? false : m_datInfo->checkId(strid, num);
 }
@@ -431,8 +429,7 @@
 
 /* check if keywords are included */ /* public */
 bool DatManager::checkWord(const QStringList& strlist, int num,
-                            bool checkOr /* AND or OR search */
-                         )
+        bool checkOr /* AND or OR search */) const
 {
     return (m_datInfo == 0)
         ? false : m_datInfo->checkWord(strlist, num, checkOr);
@@ -440,7 +437,7 @@
 
 
 /* public */
-bool DatManager::isMarked(int num)
+bool DatManager::isMarked(int num) const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     return (thread == 0) ? false : thread->isMarked(num);
@@ -448,7 +445,7 @@
 
 
 /* public */
-void DatManager::setMark(int num, bool mark)
+void DatManager::setMark(int num, bool mark) const
 {
     Thread* thread = Thread::getByURLNew(m_datUrl);
     if (thread == 0)
@@ -462,14 +459,14 @@
 
 
 /* public */
-bool DatManager::checkAbone(int num)
+bool DatManager::checkAbone(int num) const
 {
     return (m_datInfo == 0) ? false : m_datInfo->checkAbone(num);
 }
 
 
 /* public */
-void DatManager::resetAbone()
+void DatManager::resetAbone() const
 {
     if (m_datInfo == 0)
         return;
@@ -478,12 +475,12 @@
 
 
 /* check if the thread is shown on the main thread tab. */ /* public */
-bool DatManager::isMainThreadOpened()
+bool DatManager::isMainThreadOpened() const
 {
     return (m_datInfo == 0) ? false : m_datInfo->isOpened();
 }
 
-void DatManager::setMainThreadOpened(bool isOpened)
+void DatManager::setMainThreadOpened(bool isOpened) const
 {
     if (m_datInfo == 0)
         return;
@@ -495,7 +492,7 @@
 /* obsolete */
 
 /* public */
-QString DatManager::threadURL()
+QString DatManager::threadURL() const
 {
     return getThreadURL(m_url);
 }

Modified: kita/branches/KITA-KDE4/kita/src/libkita/datmanager.h
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/datmanager.h	2009-08-08 23:45:45 UTC (rev 2534)
+++ kita/branches/KITA-KDE4/kita/src/libkita/datmanager.h	2009-08-09 07:20:20 UTC (rev 2535)
@@ -30,71 +30,72 @@
     public:
         explicit DatManager(const KUrl& url);
 
-        bool createDatInfo();
-        DatInfo* getDatInfoPointer();
+        bool createDatInfo() const;
+        DatInfo* getDatInfoPointer() const;
         static void deleteAllDatInfo();
 
         /* caching */
-        bool updateCache(const QObject* parent);
-        int getResponseCode();
-        int getServerTime();
-        bool deleteCache();
-        bool isLoadingNow();
-        void stopLoading();
+        bool updateCache(const QObject* parent) const;
+        int getResponseCode() const;
+        int getServerTime() const;
+        bool deleteCache() const;
+        bool isLoadingNow() const;
+        void stopLoading() const;
 
         /* string data */
-        QString getDat(int num);
-        QString getId(int num);
-        QString getPlainName(int num);
-        QString getPlainBody(int num);
-        QString getPlainTitle(int num);
+        QString getDat(int num) const;
+        QString getId(int num) const;
+        QString getPlainName(int num) const;
+        QString getPlainBody(int num) const;
+        QString getPlainTitle(int num) const;
 
-        QString threadName(); /* = subject of thread */
-        QString threadId();
+        QString threadName() const; /* = subject of thread */
+        QString threadId() const;
 
         /* HTML data */
-        QString getHtml(int startnum, int endnum, bool checkAbone = true);
-        QString getHtmlById(const QString& strid, int &count);
-        QString getTreeByRes(int rootnum, int &count);
-        QString getTreeByResReverse(int rootnum, int &count);
+        QString getHtml(int startnum, int endnum,
+                bool checkAbone = true) const;
+        QString getHtmlById(const QString& strid, int &count) const;
+        QString getTreeByRes(int rootnum, int &count) const;
+        QString getTreeByResReverse(int rootnum, int &count) const;
 
         /* numerical data */
-        int getResNum();
-        int getReadNum();
-        int getViewPos();
-        void setViewPos(int num);
-        int getDatSize();
-        int getNumById(const QString& strid);
+        int getResNum() const;
+        int getReadNum() const;
+        int getViewPos() const;
+        void setViewPos(int num) const;
+        int getDatSize() const;
+        int getNumById(const QString& strid) const;
 
 
         /* another information */
-        bool isThreadEnrolled();
-        bool is2chThread();
-        bool isResValid(int num);
-        bool isBroken();
-        bool isResBroken(int num);
-        bool checkId(const QString& strid, int num);
-        bool checkWord(const QStringList& stlist, int num, bool checkOr);
-        bool isMarked(int num);
-        void setMark(int num, bool mark);
+        bool isThreadEnrolled() const;
+        bool is2chThread() const;
+        bool isResValid(int num) const;
+        bool isBroken() const;
+        bool isResBroken(int num) const;
+        bool checkId(const QString& strid, int num) const;
+        bool checkWord(const QStringList& stlist, int num, bool checkOr) const;
+        bool isMarked(int num) const;
+        void setMark(int num, bool mark) const;
 
 
         /* abone check */
-        bool checkAbone(int num);
-        void resetAbone();
+        bool checkAbone(int num) const;
+        void resetAbone() const;
 
         /* check if the thread is shown on the main thread tab. */
-        bool isMainThreadOpened();
-        void setMainThreadOpened(bool isOpened);
+        bool isMainThreadOpened() const;
+        void setMainThreadOpened(bool isOpened) const;
 
         /* obsolete. Don't use them. */
 
-        QString threadURL();
+        QString threadURL() const;
 
     private:
-        DatInfo* getDatInfo(bool checkCached = true);
-        DatInfo* searchDatInfo();
-        DatInfo* enrollDatInfo(bool checkCached);
+        DatInfo* getDatInfo(bool checkCached = true) const;
+        DatInfo* searchDatInfo() const;
+        DatInfo* enrollDatInfo(bool checkCached) const;
 
         KUrl m_url;
         KUrl m_datUrl;




Kita-svn メーリングリストの案内
Back to archive index