From e7a0485fa1a9458e1a9c540cd0e7817de89952b4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 20 May 2002 14:23:02 +0000 Subject: [PATCH] given: typedef KMMsgBase* KMMsgBasePtr then: const KMMsgBasePtr != ( const KMMsgBase* == "(const KMMsgBase)*" ) but rather "const (KMMsgBase*)" Fix: s/KMMsgBasePtr/KMMsgBase*/ + clean-up const business. Did anyone need KMMsgBasePtr? svn path=/trunk/kdenetwork/kmail/; revision=156512 --- kmfolder.cpp | 12 ++++++------ kmfolder.h | 7 ++++--- kmmsgbase.cpp | 2 +- kmmsgbase.h | 2 -- kmmsgdict.cpp | 2 +- kmmsglist.cpp | 14 +++++++------- kmmsglist.h | 20 ++++++++++---------- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/kmfolder.cpp b/kmfolder.cpp index 198bbd257..2c452f043 100644 --- a/kmfolder.cpp +++ b/kmfolder.cpp @@ -492,7 +492,7 @@ void KMFolder::markNewAsUnread() void KMFolder::markUnreadAsRead() { - KMMsgBase* msgBase; + const KMMsgBase* msgBase; QValueList items; for (int i=count()-1; i>=0; --i) @@ -549,7 +549,7 @@ int KMFolder::reduceSize( int aSize ) kdDebug(5006) << "Reducing folder to size of " << aSize << " Mo" << endl; QSortedList * slice=0L; QPtrList< QSortedList > sliceArr; - KMMsgBase* mb; + const KMMsgBase* mb; ulong folderSize, msgSize, sliceSize, firstSliceSize, lastSliceSize, size; int sliceIndex; int delMsg = 0; @@ -630,7 +630,7 @@ int KMFolder::expungeOldMsg(int days) { int i, msgnb=0; time_t msgTime, maxTime; - KMMsgBase* mb; + const KMMsgBase* mb; QValueList rmvMsgList; maxTime = time(0L) - days * 3600 * 24; @@ -682,7 +682,7 @@ void KMFolder::expireOldMessages() { int days = 0; int maxUnreadTime = 0; int maxReadTime = 0; - KMMsgBase *mb = NULL; + const KMMsgBase *mb = NULL; QValueList rmvMsgList; int i = 0; time_t msgTime, maxTime = 0; @@ -775,7 +775,7 @@ void KMFolder::reallyAddCopyOfMsg(KMMessage* aMsg) //----------------------------------------------------------------------------- -void KMFolder::removeMsg(KMMsgBasePtr aMsg) +void KMFolder::removeMsg(const KMMsgBase* aMsg) { int idx = find(aMsg); assert( idx != -1); @@ -1224,7 +1224,7 @@ void KMFolder::headerOfMsgChanged(const KMMsgBase* aMsg, int idx) return; } if (idx < 0) - idx = mMsgList.find((KMMsgBasePtr)aMsg); + idx = mMsgList.find((KMMsgBase*)aMsg); if (idx >= 0) emit msgHeaderChanged(idx); else diff --git a/kmfolder.h b/kmfolder.h index 586521de5..bb02250b8 100644 --- a/kmfolder.h +++ b/kmfolder.h @@ -107,7 +107,8 @@ public: in the index. Whenever you only need subject, from, date, status you should use this method instead of getMsg() because getMsg() will load the message if necessary and this method does not. */ - virtual KMMsgBase* getMsgBase(int idx) const { return mMsgList[idx]; } + virtual const KMMsgBase* getMsgBase(int idx) const { return mMsgList[idx]; } + virtual KMMsgBase* getMsgBase(int idx) { return mMsgList[idx]; } /** Same as getMsgBase(int). */ const KMMsgBase* operator[](int idx) const { return mMsgList[idx]; } @@ -134,7 +135,7 @@ public: /** Remove (first occurance of) given message from the folder. */ virtual void removeMsg(int i, bool imapQuiet = FALSE); - virtual void removeMsg(KMMsgBasePtr msg); + virtual void removeMsg(const KMMsgBase* msg); virtual void removeMsg(QPtrList msgList, bool imapQuiet = FALSE); /** Delete messages in the folder that are older than days. Return the @@ -153,7 +154,7 @@ public: virtual int moveMsg(QPtrList, int* index_return = NULL); /** Returns the index of the given message or -1 if not found. */ - virtual int find(const KMMsgBasePtr msg) const { return mMsgList.find(msg); } + virtual int find(const KMMsgBase* msg) const { return mMsgList.find((KMMsgBase*)msg); } /** Returns the index of the given message or -1 if not found. */ virtual int find(const QString& msgIdMD5) const; diff --git a/kmmsgbase.cpp b/kmmsgbase.cpp index f8e3b064f..37adcc696 100644 --- a/kmmsgbase.cpp +++ b/kmmsgbase.cpp @@ -766,7 +766,7 @@ unsigned long KMMsgBase::getMsgSerNum() const { unsigned long msn = 0; if (mParent) { - int index = mParent->find((KMMsgBasePtr)this); + int index = mParent->find((KMMsgBase*)this); msn = kernel->msgDict()->getMsgSerNum(mParent, index); } return msn; diff --git a/kmmsgbase.h b/kmmsgbase.h index 305d8003d..04778cead 100644 --- a/kmmsgbase.h +++ b/kmmsgbase.h @@ -263,6 +263,4 @@ public: bool syncIndexString() const; }; -typedef KMMsgBase* KMMsgBasePtr; - #endif /*kmmsgbase_h*/ diff --git a/kmmsgdict.cpp b/kmmsgdict.cpp index 09a8c46e2..22958ffd8 100644 --- a/kmmsgdict.cpp +++ b/kmmsgdict.cpp @@ -176,7 +176,7 @@ unsigned long KMMsgDict::insert(unsigned long msgSerNum, KMFolder *folder = msg->parent(); if (folder && index == -1) - index = folder->find((const KMMsgBasePtr)msg); + index = folder->find(msg); KMMsgDictEntry *entry = new KMMsgDictEntry(folder, index); dict->replace((long)msn, entry); diff --git a/kmmsglist.cpp b/kmmsglist.cpp index 0b2219354..8f530ae6b 100644 --- a/kmmsglist.cpp +++ b/kmmsglist.cpp @@ -26,7 +26,7 @@ KMMsgList::~KMMsgList() //----------------------------------------------------------------------------- void KMMsgList::clear(bool doDelete, bool syncDict) { - KMMsgBasePtr msg = 0; + KMMsgBase* msg = 0; long i; KMMsgDict *dict = 0; @@ -52,7 +52,7 @@ void KMMsgList::clear(bool doDelete, bool syncDict) bool KMMsgList::resize(int aSize) { int i, oldSize = size(); - KMMsgBasePtr msg; + KMMsgBase* msg; assert(aSize>=0); @@ -92,7 +92,7 @@ bool KMMsgList::reset(int aSize) //----------------------------------------------------------------------------- -void KMMsgList::set(int idx, KMMsgBasePtr aMsg) +void KMMsgList::set(int idx, KMMsgBase* aMsg) { int doubleSize; @@ -116,7 +116,7 @@ void KMMsgList::set(int idx, KMMsgBasePtr aMsg) //----------------------------------------------------------------------------- -void KMMsgList::insert(int idx, KMMsgBasePtr aMsg, bool syncDict) +void KMMsgList::insert(int idx, KMMsgBase* aMsg, bool syncDict) { int i, doubleSize; @@ -150,7 +150,7 @@ void KMMsgList::insert(int idx, KMMsgBasePtr aMsg, bool syncDict) //----------------------------------------------------------------------------- -int KMMsgList::append(KMMsgBasePtr aMsg, bool syncDict) +int KMMsgList::append(KMMsgBase* aMsg, bool syncDict) { int idx = mHigh; insert(idx, aMsg, syncDict); // mHigh gets modified in here @@ -186,9 +186,9 @@ void KMMsgList::remove(int idx) //----------------------------------------------------------------------------- -KMMsgBasePtr KMMsgList::take(int idx) +KMMsgBase* KMMsgList::take(int idx) { - KMMsgBasePtr msg=at(idx); + KMMsgBase* msg=at(idx); remove(idx); return msg; } diff --git a/kmmsglist.h b/kmmsglist.h index 210809910..7e44069e4 100644 --- a/kmmsglist.h +++ b/kmmsglist.h @@ -10,8 +10,8 @@ class KMMsgDict; -#define KMMsgListInherited QMemArray -class KMMsgList: public QMemArray +#define KMMsgListInherited QMemArray +class KMMsgList: public QMemArray { public: /** Valid parameters for sort() */ @@ -29,16 +29,16 @@ public: /** Returns message at given index and removes it from the list. Also removes from message dictionary. */ - virtual KMMsgBasePtr take(int idx); + virtual KMMsgBase* take(int idx); /** Insert message at given index. Resizes the array if necessary. If @p syncDict, also updates message dictionary. */ - virtual void insert(int idx, KMMsgBasePtr msg, bool syncDict = true); + virtual void insert(int idx, KMMsgBase* msg, bool syncDict = true); /** Append given message after the last used message. Resizes the array if necessary. Returns index of new position. If @p syncDict, also updates message dictionary. */ - virtual int append(KMMsgBasePtr msg, bool syncDict = true); + virtual int append(KMMsgBase* msg, bool syncDict = true); /** Clear messages. If autoDelete is set (default) the messages are deleted. The array is not resized. If @p syncDict, also updates @@ -54,15 +54,15 @@ public: virtual bool reset(int size); /** Returns message at given index. */ - virtual KMMsgBasePtr at(int idx) { return KMMsgListInherited::at(idx); } - KMMsgBasePtr at(int idx) const { return KMMsgListInherited::at(idx); } - KMMsgBasePtr operator[](int idx) { return KMMsgListInherited::at(idx); } - KMMsgBasePtr operator[](int idx) const { return KMMsgListInherited::at(idx); } + virtual KMMsgBase* at(int idx) { return KMMsgListInherited::at(idx); } + const KMMsgBase* at(int idx) const { return KMMsgListInherited::at(idx); } + KMMsgBase* operator[](int idx) { return KMMsgListInherited::at(idx); } + const KMMsgBase* operator[](int idx) const { return KMMsgListInherited::at(idx); } /** Set message at given index. The array is resized if necessary. If there is already a message at the given index this message is *not* deleted. Does not sync the message dictionary. */ - virtual void set(int idx, KMMsgBasePtr msg); + virtual void set(int idx, KMMsgBase* msg); /** Returns first unused index (index of last message plus one). */ int high(void) const { return mHigh; }