kmail

kmmsglist.h
1/*
2 * kmail: KDE mail client
3 * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef kmmsglist_h
21#define kmmsglist_h
22
23#include "kmmsgbase.h"
24
25#include <tqmemarray.h>
26
37class KMMsgList: public TQMemArray<KMMsgBase*>
38{
39public:
40
42 KMMsgList(int initialSize=32);
43
45 ~KMMsgList();
46
49 void remove(unsigned int idx);
50
53 KMMsgBase* take(unsigned int idx);
54
57 void insert(unsigned int idx, KMMsgBase* msg, bool syncDict = true);
58
62 unsigned int append(KMMsgBase* msg, bool syncDict = true);
63
67 void clear(bool autoDelete=TRUE, bool syncDict = false);
68
71 bool resize(unsigned int size);
72
75 bool reset(unsigned int size);
76
80 void set(unsigned int idx, KMMsgBase* msg);
81
83 unsigned int high() const { return mHigh; }
84
86 unsigned int count() const { return mCount; }
87
88protected:
90 void rethinkHigh();
91
92 unsigned int mHigh, mCount;
93};
94
95
96#endif /*kmmsglist_h*/
An abstraction of an array of pointers to messages.
Definition: kmmsglist.h:38
void insert(unsigned int idx, KMMsgBase *msg, bool syncDict=true)
Insert message at given index.
Definition: kmmsglist.cpp:107
KMMsgBase * take(unsigned int idx)
Returns message at given index and removes it from the list.
Definition: kmmsglist.cpp:161
unsigned int append(KMMsgBase *msg, bool syncDict=true)
Append given message after the last used message.
Definition: kmmsglist.cpp:131
~KMMsgList()
Destructor also deletes all messages in the list.
Definition: kmmsglist.cpp:25
bool reset(unsigned int size)
Clear the array and resize it to given size.
Definition: kmmsglist.cpp:83
void remove(unsigned int idx)
Remove message at given index without deleting it.
Definition: kmmsglist.cpp:140
KMMsgList(int initialSize=32)
Constructor with optional initial size.
Definition: kmmsglist.cpp:14
void rethinkHigh()
Set mHigh to proper value.
Definition: kmmsglist.cpp:170
bool resize(unsigned int size)
Resize array and initialize new elements if any.
Definition: kmmsglist.cpp:51
void clear(bool autoDelete=TRUE, bool syncDict=false)
Clear messages.
Definition: kmmsglist.cpp:32
unsigned int high() const
Returns first unused index (index of last message plus one).
Definition: kmmsglist.h:83
void set(unsigned int idx, KMMsgBase *msg)
Set message at given index.
Definition: kmmsglist.cpp:92
unsigned int count() const
Number of messages in the array.
Definition: kmmsglist.h:86