Nepomuk
daterange.h
Go to the documentation of this file.
00001 /* 00002 Copyright (c) 2009-2010 Sebastian Trueg <trueg@kde.org> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License as 00006 published by the Free Software Foundation; either version 2 of 00007 the License or (at your option) version 3 or any later version 00008 accepted by the membership of KDE e.V. (or its successor approved 00009 by the membership of KDE e.V.), which shall act as a proxy 00010 defined in Section 14 of version 3 of the license. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef _DATE_RANGE_H_ 00023 #define _DATE_RANGE_H_ 00024 00025 #include <QtCore/QDate> 00026 #include <QtCore/QSharedDataPointer> 00027 00028 class QDebug; 00029 00041 class DateRange 00042 { 00043 public: 00047 DateRange( const QDate& s = QDate(), 00048 const QDate& e = QDate() ); 00049 00053 DateRange( const DateRange& other ); 00054 00058 ~DateRange(); 00059 00063 DateRange& operator=( const DateRange& other ); 00064 00068 QDate start() const; 00069 00073 QDate end() const; 00074 00079 bool isValid() const; 00080 00084 void setStart( const QDate& date ); 00085 00089 void setEnd( const QDate& date ); 00090 00095 static DateRange today(); 00096 00102 enum DateRangeFlag { 00106 NoDateRangeFlags = 0x0, 00107 00113 ExcludeFutureDays = 0x1 00114 }; 00115 Q_DECLARE_FLAGS( DateRangeFlags, DateRangeFlag ) 00116 00117 00121 static DateRange thisWeek( DateRangeFlags flags = NoDateRangeFlags ); 00122 00129 static DateRange weekOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags ); 00130 00136 static DateRange thisMonth( DateRangeFlags flags = NoDateRangeFlags ); 00137 00145 static DateRange monthOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags ); 00146 00151 static DateRange thisYear( DateRangeFlags flags = NoDateRangeFlags ); 00152 00160 static DateRange yearOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags ); 00161 00165 static DateRange lastNDays( int n ); 00166 00171 static DateRange lastNWeeks( int n ); 00172 00177 static DateRange lastNMonths( int n ); 00178 00179 private: 00180 class Private; 00181 QSharedDataPointer<Private> d; 00182 }; 00183 00189 bool operator==( const DateRange& r1, const DateRange& r2 ); 00190 00196 bool operator!=( const DateRange& r1, const DateRange& r2 ); 00197 00203 uint qHash( const DateRange& range ); 00204 00210 QDebug operator<<( QDebug dbg, const DateRange& range ); 00211 00212 Q_DECLARE_OPERATORS_FOR_FLAGS( DateRange::DateRangeFlags ) 00213 00214 #endif
KDE 4.6 API Reference