dateset.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _DATESET_H
00024 #define _DATESET_H
00025
00026 #include <qdatetime.h>
00027 #include <qpair.h>
00028 #include <qptrlist.h>
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 class RangeList : public QPtrList< QPair<QDate, QDate> > {
00050 protected:
00051 virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2) {
00052 QPair<QDate,QDate> *i1 = static_cast<QPair<QDate,QDate> *> (item1);
00053 QPair<QDate,QDate> *i2 = static_cast<QPair<QDate,QDate> *> (item2);
00054 if ( *i1 < *i2 ) return -1;
00055 if ( *i2 < *i1 ) return 1;
00056 return 0;
00057 }
00058 };
00059
00060 class DateSet {
00061 public:
00062 DateSet();
00063 ~DateSet();
00064
00065 void add( QDate const& date );
00066 void add( QDate const& from, QDate const& to );
00067
00068 void remove( QDate const& date );
00069 void remove( QDate const& from, QDate const& to );
00070
00071 bool contains( QDate const& date );
00072
00073 bool contains( QDate const& from, QDate const& to );
00074
00075 int find( QDate const &date );
00076 void print();
00077
00078 protected:
00079 private:
00080 bool tryMerge( int i );
00081 RangeList *mDates;
00082
00083 QDate mOldestDate;
00084 QDate mNewestDate;
00085 };
00086
00087 #endif
This file is part of the documentation for libkpimexchange Library Version 3.2.2.