• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk
  • utils
daterange.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009-2010 Sebastian Trueg <trueg@kde.org>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License as
6  published by the Free Software Foundation; either version 2 of
7  the License or (at your option) version 3 or any later version
8  accepted by the membership of KDE e.V. (or its successor approved
9  by the membership of KDE e.V.), which shall act as a proxy
10  defined in Section 14 of version 3 of the license.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 #ifndef _DATE_RANGE_H_
23 #define _DATE_RANGE_H_
24 
25 #include <QtCore/QDate>
26 #include <QtCore/QSharedDataPointer>
27 
28 class QDebug;
29 
41 class DateRange
42 {
43 public:
47  DateRange( const QDate& s = QDate(),
48  const QDate& e = QDate() );
49 
53  DateRange( const DateRange& other );
54 
58  ~DateRange();
59 
63  DateRange& operator=( const DateRange& other );
64 
68  QDate start() const;
69 
73  QDate end() const;
74 
79  bool isValid() const;
80 
84  void setStart( const QDate& date );
85 
89  void setEnd( const QDate& date );
90 
95  static DateRange today();
96 
102  enum DateRangeFlag {
106  NoDateRangeFlags = 0x0,
107 
113  ExcludeFutureDays = 0x1
114  };
115  Q_DECLARE_FLAGS( DateRangeFlags, DateRangeFlag )
116 
117 
121  static DateRange thisWeek( DateRangeFlags flags = NoDateRangeFlags );
122 
129  static DateRange weekOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags );
130 
136  static DateRange thisMonth( DateRangeFlags flags = NoDateRangeFlags );
137 
145  static DateRange monthOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags );
146 
151  static DateRange thisYear( DateRangeFlags flags = NoDateRangeFlags );
152 
160  static DateRange yearOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags );
161 
165  static DateRange lastNDays( int n );
166 
171  static DateRange lastNWeeks( int n );
172 
177  static DateRange lastNMonths( int n );
178 
179 private:
180  class Private;
181  QSharedDataPointer<Private> d;
182 };
183 
189 bool operator==( const DateRange& r1, const DateRange& r2 );
190 
196 bool operator!=( const DateRange& r1, const DateRange& r2 );
197 
203 uint qHash( const DateRange& range );
204 
210 QDebug operator<<( QDebug dbg, const DateRange& range );
211 
212 Q_DECLARE_OPERATORS_FOR_FLAGS( DateRange::DateRangeFlags )
213 
214 #endif
DateRange::monthOf
static DateRange monthOf(const QDate &date, DateRangeFlags flags=NoDateRangeFlags)
DateRange::qHash
uint qHash(const DateRange &range)
Allows using DateRange in hashed structures such as QHash or QMap.
DateRange
A simple data structure storing a start and an end date.
Definition: daterange.h:41
DateRange::lastNDays
static DateRange lastNDays(int n)
DateRange::DateRangeFlag
DateRangeFlag
The flags allow to change the result returned by several of the static factory methods provided by Da...
Definition: daterange.h:102
DateRange::yearOf
static DateRange yearOf(const QDate &date, DateRangeFlags flags=NoDateRangeFlags)
DateRange::thisWeek
static DateRange thisWeek(DateRangeFlags flags=NoDateRangeFlags)
Takes KLocale::weekStartDay() into account.
DateRange::end
QDate end() const
End date of the range.
DateRange::thisMonth
static DateRange thisMonth(DateRangeFlags flags=NoDateRangeFlags)
DateRange::setEnd
void setEnd(const QDate &date)
Set the end to date.
DateRange::start
QDate start() const
Start date of the range.
DateRange::NoDateRangeFlags
No flags.
Definition: daterange.h:106
DateRange::thisYear
static DateRange thisYear(DateRangeFlags flags=NoDateRangeFlags)
DateRange::ExcludeFutureDays
Exclude days that are in the future.
Definition: daterange.h:113
DateRange::lastNWeeks
static DateRange lastNWeeks(int n)
DateRange::weekOf
static DateRange weekOf(const QDate &date, DateRangeFlags flags=NoDateRangeFlags)
Takes KLocale::weekStartDay() into account.
DateRange::DateRange
DateRange(const QDate &s=QDate(), const QDate &e=QDate())
Create a new range.
DateRange::lastNMonths
static DateRange lastNMonths(int n)
DateRange::operator=
DateRange & operator=(const DateRange &other)
Make this range a copy of other.
DateRange::today
static DateRange today()
DateRange::setStart
void setStart(const QDate &date)
Set the start to date.
DateRange::isValid
bool isValid() const
Checks if both start and end are valid dates and if end is after start.
DateRange::~DateRange
~DateRange()
Destructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk

Skip menu "Nepomuk"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal