svnno****@sourc*****
svnno****@sourc*****
2009年 8月 9日 (日) 16:55:18 JST
Revision: 2536 http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2536 Author: nogu Date: 2009-08-09 16:55:18 +0900 (Sun, 09 Aug 2009) Log Message: ----------- add const Modified Paths: -------------- kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp kita/branches/KITA-KDE4/kita/src/libkita/datinfo.h kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp Modified: kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp 2009-08-09 07:20:20 UTC (rev 2535) +++ kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp 2009-08-09 07:55:18 UTC (rev 2536) @@ -124,7 +124,7 @@ /* private */ -void DatInfo::resetResDat(RESDAT& resdat) +void DatInfo::resetResDat(RESDAT& resdat) const { resdat.num = 0; resdat.parsed = false; @@ -164,7 +164,7 @@ } /* public */ -const KUrl& DatInfo::url() +const KUrl& DatInfo::url() const { return m_datURL; } @@ -231,7 +231,8 @@ m_thread->setReadNum(num); /* If resdat vector is short, then resize the vector. */ - while ((int) m_resDatVec.size() <= num) increaseResDatVec(RESDAT_DELTA); + while ((int) m_resDatVec.size() <= num) + increaseResDatVec(RESDAT_DELTA); /* reset ResDat */ RESDAT& resdat = m_resDatVec[ num ]; @@ -301,7 +302,7 @@ /* public */ -int DatInfo::getResponseCode() +int DatInfo::getResponseCode() const { if (m_access == 0) return 0; @@ -310,7 +311,7 @@ /* public */ -int DatInfo::getServerTime() +int DatInfo::getServerTime() const { if (m_access == 0) return 0; @@ -330,7 +331,7 @@ /* public */ -bool DatInfo::isLoadingNow() +bool DatInfo::isLoadingNow() const { return m_nowLoading; } @@ -338,7 +339,7 @@ /* public */ -void DatInfo::stopLoading() +void DatInfo::stopLoading() const { /* Don't lock the mutex here !!! @@ -414,7 +415,8 @@ return values are defined in datinfo.h. */ /* public */ -int DatInfo::getHTML(int num, bool checkAbone, QString& titleHTML, QString& bodyHTML) +int DatInfo::getHTML(int num, bool checkAbone, QString& titleHTML, + QString& bodyHTML) { return getHTMLPrivate(num, checkAbone, titleHTML, bodyHTML); } @@ -432,7 +434,8 @@ * @retval HTML_NORMAL The res dat is normal. * */ -int DatInfo::getHTMLPrivate(int num, bool checkAbone, QString& titleHTML, QString& bodyHTML) +int DatInfo::getHTMLPrivate(int num, bool checkAbone, QString& titleHTML, + QString& bodyHTML) { if (!parseDat(num)) return HTML_NOTPARSED; @@ -468,7 +471,7 @@ for (int num = startnum; num <= endnum; num++) { QString html; - getHTMLofOneRes(num, checkAbone, html); + getHtmlOfOneRes(num, checkAbone, html); retHTML += html; } @@ -490,7 +493,7 @@ count ++; QString html; - getHTMLofOneRes(i, true, html); + getHtmlOfOneRes(i, true, html); retHTML += html; } } @@ -508,11 +511,12 @@ * @param[out] html * */ -void DatInfo::getHTMLofOneRes(int num, bool checkAbone, QString& html) +void DatInfo::getHtmlOfOneRes(int num, bool checkAbone, QString& html) { html.clear(); QString titleHTML, bodyHTML; - if (getHTMLPrivate(num, checkAbone, titleHTML, bodyHTML) == HTML_NOTPARSED) return ; + if (getHTMLPrivate(num, checkAbone, titleHTML, bodyHTML) == HTML_NOTPARSED) + return; if (m_resDatVec[ num ].isResponsed) titleHTML.replace("<a href=\"#write", "<a class=\"coloredLink\" href=\"#write"); html += "<div class=\"pop_res_title\">" + titleHTML + "</div>"; @@ -532,7 +536,7 @@ |-->>20, and return count = 3. */ /* Note that this function checks Abone internally. */ /* public */ -QString DatInfo::getTreeByRes(const int rootnum, int& count) +QString DatInfo::getTreeByRes(int rootnum, int& count) { return getTreeByResPrivate(rootnum, false, count); } @@ -548,17 +552,15 @@ |-->>6, and returns count = 3. */ /* Note that this function checks Abone internally. */ /* public */ -QString DatInfo::getTreeByResReverse(const int rootnum, int& count) +QString DatInfo::getTreeByResReverse(int rootnum, int& count) { return getTreeByResPrivate(rootnum, true, count); } /* private */ -QString DatInfo::getTreeByResPrivate( - const int rootnum, - bool reverse, /* reverse search */ - int& count) +QString DatInfo::getTreeByResPrivate(int rootnum, + bool reverse /* reverse search */, int& count) { QString tmp = QString::number(rootnum); @@ -570,10 +572,8 @@ } /* private */ -QString DatInfo::getTreeByResCore( - const int rootnum, - bool reverse, /* reverse search */ - int& count, const QString& prestr) +QString DatInfo::getTreeByResCore(int rootnum, + bool reverse /* reverse search */, int& count, const QString& prestr) { if (!parseDat(rootnum)) return QString(); if (checkAbonePrivate(rootnum)) return QString(); @@ -635,7 +635,7 @@ /* For exsample, if target = 4, and No.num have an anchor >>4, or >>2-6, etc., then return true. */ /* private */ -bool DatInfo::checkRes(const int num, const int target) +bool DatInfo::checkRes(int num, int target) { const int range = 20; if (!parseDat(num)) return false; @@ -655,19 +655,19 @@ /*-----------------------*/ /* several information */ -int DatInfo::getResNum() +int DatInfo::getResNum() const { return m_thread->resNum(); } /* public */ -int DatInfo::getReadNum() +int DatInfo::getReadNum() const { return m_thread->readNum(); } /* public */ -int DatInfo::getViewPos() +int DatInfo::getViewPos() const { return m_thread->viewPos(); } @@ -681,10 +681,13 @@ for (int i = 1; i <= m_thread->readNum(); i++) { - if (!parseDat(i)) continue; - if (checkAbonePrivate(i)) continue; + if (!parseDat(i)) + continue; + if (checkAbonePrivate(i)) + continue; - if (m_resDatVec[ i ].id == strid) count++; + if (m_resDatVec[ i ].id == strid) + count++; } return count; @@ -692,7 +695,7 @@ /* public */ -int DatInfo::getDatSize() +int DatInfo::getDatSize() const { if (m_access == 0) return 0; @@ -714,7 +717,7 @@ } /* public */ -bool DatInfo::isBroken() +bool DatInfo::isBroken() const { if (m_broken) return m_broken; @@ -751,9 +754,7 @@ /* Are keywords included ? */ /* public */ bool DatInfo::checkWord(const QStringList& stlist, /* list of keywords */ - int num, - bool checkOR /* AND or OR search */ - ) + int num, bool checkOr /* AND or OR search */) { if (!parseDat(num)) return false; @@ -764,7 +765,7 @@ QRegExp regexp((*it)); regexp.setCaseSensitivity(Qt::CaseInsensitive); - if (checkOR) { /* OR */ + if (checkOr) { /* OR */ if (str_text.indexOf(regexp, 0) != -1) { return true; } @@ -773,7 +774,7 @@ } } - if (checkOR) return false; + if (checkOr) return false; return true; } @@ -798,7 +799,8 @@ /* private */ void DatInfo::resetAbonePrivate() { - for (int i = 1; i < (int) m_resDatVec.size(); i++) m_resDatVec[ i ].checkAbone = false; + for (int i = 1; i < (int) m_resDatVec.size(); i++) + m_resDatVec[ i ].checkAbone = false; m_aboneByID = (!AboneConfig::aboneIDList().isEmpty()); m_aboneByName = (!AboneConfig::aboneNameList().isEmpty()); @@ -820,24 +822,29 @@ /* private */ bool DatInfo::checkAbonePrivate(int num) { - if (!parseDat(num)) return false; + if (!parseDat(num)) + return false; - if (m_resDatVec[ num ].checkAbone) return m_resDatVec[ num ].abone; + if (m_resDatVec[num].checkAbone) + return m_resDatVec[num].abone; - m_resDatVec[ num ].checkAbone = true; + m_resDatVec[num].checkAbone = true; bool checktmp = false; if (m_aboneByID) - checktmp = checkAboneCore(m_resDatVec[ num ].id, AboneConfig::aboneIDList()); + checktmp = checkAboneCore(m_resDatVec[num].id, + AboneConfig::aboneIDList()); if (!checktmp && m_aboneByName) - checktmp = checkAboneCore(m_resDatVec[ num ].name, AboneConfig::aboneNameList()); + checktmp = checkAboneCore(m_resDatVec[num].name, + AboneConfig::aboneNameList()); if (!checktmp && m_aboneByBody) - checktmp = checkAboneCore(m_resDatVec[ num ].bodyHTML, AboneConfig::aboneWordList()); + checktmp = checkAboneCore(m_resDatVec[num].bodyHTML, + AboneConfig::aboneWordList()); if (!checktmp && m_aboneChain) { - AncList & anclist = m_resDatVec[ num ].anclist; + AncList & anclist = m_resDatVec[num].anclist; for (AncList::iterator it = anclist.begin(); it != anclist.end() && !checktmp ; ++it) { @@ -858,13 +865,14 @@ } } - m_resDatVec[ num ].abone = checktmp; + m_resDatVec[num].abone = checktmp; - return m_resDatVec[ num ].abone; + return m_resDatVec[num].abone; } /* private */ bool DatInfo::checkAboneCore(const QString& str, const QStringList& strlist) +const { if (strlist.count()) { @@ -900,12 +908,12 @@ return true; } -bool DatInfo::isOpened() +bool DatInfo::isOpened() const { return m_isOpened; } -void DatInfo::setIsOpened(bool isOpened) +void DatInfo::setOpened(bool isOpened) { m_isOpened = isOpened; } Modified: kita/branches/KITA-KDE4/kita/src/libkita/datinfo.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/datinfo.h 2009-08-09 07:20:20 UTC (rev 2535) +++ kita/branches/KITA-KDE4/kita/src/libkita/datinfo.h 2009-08-09 07:55:18 UTC (rev 2536) @@ -141,15 +141,15 @@ DatInfo(const KUrl& url); ~DatInfo(); void init(); - const KUrl& url(); + const KUrl& url() const; /* for caching */ bool updateCache(const QObject* parent); - int getResponseCode(); - int getServerTime(); + int getResponseCode() const; + int getServerTime() const; bool deleteCache(); - bool isLoadingNow(); - void stopLoading(); + bool isLoadingNow() const; + void stopLoading() const; /* string data */ QString getDat(int num); @@ -159,28 +159,30 @@ QString getPlainBody(int num); /* HTML data */ - int getHTML(int num, bool checkAbone, QString& titleHTML, QString& bodyHTML); - QString getHTMLString(int startnum, int endnum, bool checkAbone = true); + int getHTML(int num, bool checkAbone, QString& titleHTML, + QString& bodyHTML); + QString getHTMLString(int startnum, int endnum, + bool checkAbone = true); QString getHtmlById(const QString& strid, int &count); - QString getTreeByRes(const int rootnum, int& count); - QString getTreeByResReverse(const int rootnum, int& count); + QString getTreeByRes(int rootnum, int& count); + QString getTreeByResReverse(int rootnum, int& count); /* numerical data */ - int getResNum(); - int getReadNum(); - int getViewPos(); + int getResNum() const; + int getReadNum() const; + int getViewPos() const; int getNumById(const QString& strid); - int getDatSize(); + int getDatSize() const; /* several information */ bool isResponsed (int num) const; bool isResValid(int num); - bool isBroken(); + bool isBroken() const; bool isResBroken(int num); bool checkId(const QString& strid, int num); - bool checkWord(const QStringList& stlist, int num, bool checkOR); - bool isOpened(); - void setIsOpened(bool isOpened); + bool checkWord(const QStringList& stlist, int num, bool checkOr); + bool isOpened() const; + void setOpened(bool isOpened); /* abone check */ bool checkAbone(int num); @@ -191,7 +193,7 @@ private: void initPrivate(bool loadCache = true); - void resetResDat(RESDAT& resdat); + void resetResDat(RESDAT& resdat) const; void increaseResDatVec(int delta); void deleteAccessJob(); @@ -199,16 +201,19 @@ bool copyOneLineToResDat(const QString& line); /* HTML data */ - int getHTMLPrivate(int num, bool checkAbone, QString& titleHTML, QString& bodyHTML); - void getHTMLofOneRes(int num, bool checkAbone, QString& html); - QString getTreeByResPrivate(const int rootnum, bool reverse, int& count); - QString getTreeByResCore(const int rootnum, bool reverse, int& count, const QString& prestr); - bool checkRes(const int num, const int target); + int getHTMLPrivate(int num, bool checkAbone, QString& titleHTML, + QString& bodyHTML); + void getHtmlOfOneRes(int num, bool checkAbone, QString& html); + QString getTreeByResPrivate(int rootnum, bool reverse, int& count); + QString getTreeByResCore(int rootnum, bool reverse, int& count, + const QString& prestr); + bool checkRes(int num, int target); /* for abone */ void resetAbonePrivate(); bool checkAbonePrivate(int num); - bool checkAboneCore(const QString& str, const QStringList& strlist); + bool checkAboneCore(const QString& str, const QStringList& strlist) + const; /* parsing functions */ bool parseDat(int num); Modified: kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp 2009-08-09 07:20:20 UTC (rev 2535) +++ kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp 2009-08-09 07:55:18 UTC (rev 2536) @@ -484,7 +484,7 @@ { if (m_datInfo == 0) return; - m_datInfo->setIsOpened(isOpened); + m_datInfo->setOpened(isOpened); }