kalarm/lib
colourlist.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef COLOURLIST_H
00022 #define COLOURLIST_H
00023
00024 #include <qtl.h>
00025 #include <qcolor.h>
00026 #include <qvaluelist.h>
00027
00028
00039 class ColourList
00040 {
00041 public:
00042 typedef size_t size_type;
00043 typedef QValueListConstIterator<QRgb> const_iterator;
00044
00046 ColourList() { }
00048 ColourList(const ColourList& l) : mList(l.mList) { }
00050 ColourList(const QValueList<QRgb>& list) : mList(list) { qHeapSort(mList); }
00054 ColourList(const QColor* list);
00056 ColourList& operator=(const ColourList& l) { mList = l.mList; return *this; }
00058 ColourList& operator=(const QValueList<QRgb>& list) { mList = list; qHeapSort(mList); return *this; }
00060 void clear() { mList.clear(); }
00062 void insert(const QColor& c);
00064 void remove(const QColor& c) { mList.remove(c.rgb()); }
00066 ColourList& operator+=(const QColor& c) { insert(c); return *this; }
00068 ColourList& operator+=(const ColourList& list) { mList += list.mList; qHeapSort(mList); return *this; }
00070 bool operator==(const ColourList& l) const { return mList == l.mList; }
00072 bool operator!=(const ColourList& l) const { return mList != l.mList; }
00074 size_type count() const { return mList.count(); }
00076 bool isEmpty() const { return mList.isEmpty(); }
00078 const_iterator begin() const { return mList.begin(); }
00080 const_iterator end() const { return mList.end(); }
00082 const_iterator fromLast() const { return mList.fromLast(); }
00084 const_iterator at(size_type i) const { return mList.at(i); }
00086 size_type contains(const QColor& c) const { return mList.contains(c.rgb()); }
00090 const_iterator find(const QColor& c) const { return mList.find(c.rgb()); }
00094 const_iterator find(const_iterator it, const QColor& c) const { return mList.find(it, c.rgb()); }
00098 int findIndex(const QColor& c) const { return mList.findIndex(c.rgb()); }
00100 QColor first() const { return QColor(mList.first()); }
00102 QColor last() const { return QColor(mList.last()); }
00104 QColor operator[](size_type i) const { return QColor(mList[i]); }
00105 private:
00106 void sort();
00107 QValueList<QRgb> mList;
00108 };
00109
00110 #endif // COLOURLIST_H
|