knode
knarticlecollection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef KNARTICLECOLLECTION_H
00016 #define KNARTICLECOLLECTION_H
00017
00018 #include "kncollection.h"
00019
00020 #include <QByteArray>
00021
00022 class KNArticle;
00023
00024
00027 class KNArticleVector {
00028
00029 public:
00030 enum SortingType { STid, STmsgId, STunsorted };
00031
00032 KNArticleVector(KNArticleVector *master=0, SortingType sorting=STunsorted);
00033 virtual ~KNArticleVector();
00034
00035
00036 KNArticleVector* master() { return m_aster; }
00037 void setMaster(KNArticleVector *m) { m_aster=m; }
00038 bool isMaster() { return (m_aster==0); }
00039
00040 bool isEmpty() { return ( (l_ist==0) || (l_en==0) ); }
00041 int length() { return l_en; }
00042 int size() { return s_ize; }
00043
00044
00045 bool resize(int s=0);
00046 bool append(KNArticle *a, bool autoSort=false);
00047 void remove(int pos, bool autoDel=false, bool autoCompact=false);
00048 void clear();
00049 void compact();
00050 void syncWithMaster();
00051
00052
00053 SortingType sortMode() { return s_ortType; }
00054 void setSortMode(SortingType s) { s_ortType=s; }
00055 void sort();
00056 static int compareById(const void *a1, const void *a2);
00057 static int compareByMsgId(const void *a1, const void *a2);
00058
00059
00060 KNArticle* at(int i) { return ( (i>=0 && i<l_en) ? l_ist[i] : 0 ); }
00061 KNArticle* bsearch(int id);
00062 KNArticle* bsearch( const QByteArray &id );
00063
00064 int indexForId(int id);
00065 int indexForMsgId( const QByteArray &id );
00066
00067 protected:
00068 KNArticleVector *m_aster;
00069 int l_en,
00070 s_ize;
00071 KNArticle **l_ist;
00072 SortingType s_ortType;
00073 };
00074
00075
00078 class KNArticleCollection : public KNCollection {
00079
00080 public:
00081 KNArticleCollection(KNCollection *p=0);
00082 ~KNArticleCollection();
00083
00085 bool isEmpty() { return a_rticles.isEmpty(); }
00086 bool isLoaded() { return (c_ount==0 || a_rticles.length()>0); }
00087 int size() { return a_rticles.size(); }
00088 int length() { return a_rticles.length(); }
00089
00090
00091 bool isNotUnloadable() { return n_otUnloadable; }
00092 void setNotUnloadable(bool b=true) { n_otUnloadable = b; }
00093
00094
00095 unsigned int lockedArticles() { return l_ockedArticles; }
00096 void articleLocked() { l_ockedArticles++; }
00097 void articleUnlocked() { l_ockedArticles--; }
00098
00099
00100 bool resize(int s=0);
00101 bool append(KNArticle *a, bool autoSync=false);
00102 void clear();
00103 void compact();
00104 void setLastID();
00105
00106
00107 KNArticle* at(int i) { return a_rticles.at(i); }
00108 KNArticle* byId(int id);
00109 KNArticle* byMessageId( const QByteArray &mid );
00110
00111
00112 void syncSearchIndex();
00113 void clearSearchIndex();
00114
00115 protected:
00116 int l_astID;
00117 unsigned int l_ockedArticles;
00118 bool n_otUnloadable;
00119 KNArticleVector a_rticles;
00120 KNArticleVector m_idIndex;
00121 };
00122
00123
00124 #endif