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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • date
kcalendarsystemprivate_p.h
Go to the documentation of this file.
1 /*
2  Copyright 2010 John Layt <john@layt.net>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KCALENDARSYSTEMPRIVATE_H
21 #define KCALENDARSYSTEMPRIVATE_H
22 
23 class QChar;
24 class QString;
25 class QDate;
26 
27 class KCalendarSystem;
28 class KCalendarEra;
29 class KLocale;
30 
31 class KCalendarSystemPrivate
32 {
33 public:
34  explicit KCalendarSystemPrivate(KCalendarSystem *q);
35 
36  virtual ~KCalendarSystemPrivate();
37 
38  // Virtual methods each calendar system must re-implement
39  virtual KLocale::CalendarSystem calendarSystem() const;
40  virtual void loadDefaultEraList();
41  virtual int monthsInYear(int year) const;
42  virtual int daysInMonth(int year, int month) const;
43  virtual int daysInYear(int year) const;
44  virtual int daysInWeek() const;
45  virtual bool isLeapYear(int year) const;
46  virtual bool hasLeapMonths() const;
47  virtual bool hasYearZero() const;
48  virtual int maxDaysInWeek() const;
49  virtual int maxMonthsInYear() const;
50  virtual int earliestValidYear() const;
51  virtual int latestValidYear() const;
52  virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive = false) const;
53  virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
54 
55  // Virtual methods to re-implement if special maths needed
56  virtual int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum) const;
57  virtual int isoWeekNumber(const QDate &date, int *yearNum) const;
58  virtual int regularWeekNumber(const QDate &date, int weekStartDay, int firstWeekNumber, int *weekYear) const;
59  virtual int simpleWeekNumber(const QDate &date, int *yearNum) const;
60  virtual int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const;
61  virtual int isoWeeksInYear(int year) const;
62  virtual int regularWeeksInYear(int year, int weekStartDay, int firstWeekNumber) const;
63  virtual int simpleWeeksInYear(int year) const;
64 
65  // Virtual methods to re-implement if special maths needed
66  // Currently only Hebrew may need special conversion, rest should be OK
67  virtual int yearsDifference(const QDate &fromDate, const QDate &toDate) const;
68  virtual int monthsDifference(const QDate &fromDate, const QDate &toDate) const;
69  virtual void dateDifference(const QDate &fromDate, const QDate &toDate,
70  int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
71 
72  // Virtual methods to re-implement if special number/string conversion needed
73  // Currently only Hebrew needs special conversion, rest use KLocale DigitSet
74  virtual int integerFromString(const QString &string, int maxLength, int &readLength) const;
75  virtual QString stringFromInteger(int number, int padWidth = 0, QChar padChar = QLatin1Char('0')) const;
76  virtual QString stringFromInteger(int number, int padWidth, QChar padChar, KLocale::DigitSet digitSet) const;
77 
78  // Utility functions
79  bool setAnyDate(QDate &date, int year, int month, int day) const;
80  int addYears(int startYear, int yearsToAdd) const;
81  int differenceYearNumbers(int fromYear, int toYear) const;
82  QDate invalidDate() const;
83  QString simpleDateString(const QString &str) const;
84  int dayOfYear(const QDate &date) const;
85  int dayOfWeek(const QDate &date) const;
86  QDate firstDayOfYear(int year) const;
87  QDate lastDayOfYear(int year) const;
88  QDate firstDayOfMonth(int year, int month) const;
89  QDate lastDayOfMonth(int year, int month) const;
90  const KLocale *locale() const;
91  void loadEraList(const KConfigGroup & cg);
92  void addEra(char direction, int offset, const QDate &startDate, int startYear, const QDate &endDate,
93  const QString &name, const QString &shortName, const QString &format);
94  QList<KCalendarEra> *eraList() const;
95  KCalendarEra era(const QDate &eraDate) const;
96  KCalendarEra era(const QString &eraName, int yearInEra) const;
97  int shortYearWindowStartYear() const;
98  int applyShortYearWindow(int inputYear) const;
99  void loadShortYearWindowStartYear(const KConfigGroup & cg);
100  KSharedConfig::Ptr config();
101  void loadConfig(const QString & calendarType);
102 
103  // Global variables each calendar system must initialise
104  const KCalendarSystem *q;
105  const KLocale *m_locale;
106  KSharedConfig::Ptr m_config;
107  QList<KCalendarEra> *m_eraList;
108  int m_shortYearWindowStartYear;
109 };
110 
111 #endif // KCALENDARSYSTEMPRIVATE_H
KCalendarSystemPrivate::m_eraList
QList< KCalendarEra > * m_eraList
Definition: kcalendarsystemprivate_p.h:107
KCalendarSystemPrivate::config
KSharedConfig::Ptr config()
Definition: kcalendarsystem.cpp:1055
KSharedPtr< KSharedConfig >
KCalendarSystemPrivate::era
KCalendarEra era(const QDate &eraDate) const
Definition: kcalendarsystem.cpp:922
KCalendarSystemPrivate::applyShortYearWindow
int applyShortYearWindow(int inputYear) const
Definition: kcalendarsystem.cpp:1029
KCalendarSystemPrivate::week
virtual int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum) const
Definition: kcalendarsystem.cpp:406
KCalendarSystemPrivate::earliestValidYear
virtual int earliestValidYear() const
Definition: kcalendarsystem.cpp:371
KCalendarSystemPrivate::locale
const KLocale * locale() const
Definition: kcalendarsystem.cpp:908
KCalendarSystemPrivate::KCalendarSystemPrivate
KCalendarSystemPrivate(KCalendarSystem *q)
Definition: kcalendarsystem.cpp:247
KCalendarSystemPrivate::regularWeekNumber
virtual int regularWeekNumber(const QDate &date, int weekStartDay, int firstWeekNumber, int *weekYear) const
Definition: kcalendarsystem.cpp:482
KCalendarSystemPrivate::addYears
int addYears(int startYear, int yearsToAdd) const
Definition: kcalendarsystem.cpp:808
KCalendarSystemPrivate::simpleWeekNumber
virtual int simpleWeekNumber(const QDate &date, int *yearNum) const
Definition: kcalendarsystem.cpp:508
KCalendarSystemPrivate::monthsDifference
virtual int monthsDifference(const QDate &fromDate, const QDate &toDate) const
Definition: kcalendarsystem.cpp:703
KCalendarSystemPrivate::loadDefaultEraList
virtual void loadDefaultEraList()
Definition: kcalendarsystem.cpp:269
QChar
KCalendarSystemPrivate::regularWeeksInYear
virtual int regularWeeksInYear(int year, int weekStartDay, int firstWeekNumber) const
Definition: kcalendarsystem.cpp:553
KCalendarSystemPrivate::integerFromString
virtual int integerFromString(const QString &string, int maxLength, int &readLength) const
Definition: kcalendarsystem.cpp:750
KCalendarSystemPrivate::m_config
KSharedConfig::Ptr m_config
Definition: kcalendarsystemprivate_p.h:106
KCalendarSystemPrivate::monthsInYear
virtual int monthsInYear(int year) const
Definition: kcalendarsystem.cpp:277
KCalendarSystemPrivate::m_locale
const KLocale * m_locale
Definition: kcalendarsystemprivate_p.h:105
KCalendarSystemPrivate::loadConfig
void loadConfig(const QString &calendarType)
Definition: kcalendarsystem.cpp:1064
KCalendarSystemPrivate::maxMonthsInYear
virtual int maxMonthsInYear() const
Definition: kcalendarsystem.cpp:362
KCalendarSystem
KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE...
Definition: kcalendarsystem.h:40
KLocale::DateTimeComponentFormat
DateTimeComponentFormat
Definition: klocale.h:908
KCalendarSystemPrivate::daysInYear
virtual int daysInYear(int year) const
Definition: kcalendarsystem.cpp:304
KCalendarSystemPrivate::daysInWeek
virtual int daysInWeek() const
Definition: kcalendarsystem.cpp:315
KCalendarEra
Definition: kcalendarera_p.h:43
KLocale::CalendarSystem
CalendarSystem
Definition: klocale.h:780
KCalendarSystemPrivate::invalidDate
QDate invalidDate() const
Definition: kcalendarsystem.cpp:840
KCalendarSystemPrivate::lastDayOfMonth
QDate lastDayOfMonth(int year, int month) const
Definition: kcalendarsystem.cpp:900
KCalendarSystemPrivate::simpleWeeksInYear
virtual int simpleWeeksInYear(int year) const
Definition: kcalendarsystem.cpp:559
KLocale::WeekNumberSystem
WeekNumberSystem
Definition: klocale.h:815
KCalendarSystemPrivate::m_shortYearWindowStartYear
int m_shortYearWindowStartYear
Definition: kcalendarsystemprivate_p.h:108
QDate
QString
QList< KCalendarEra >
KCalendarSystemPrivate::stringFromInteger
virtual QString stringFromInteger(int number, int padWidth=0, QChar padChar=QLatin1Char('0')) const
Definition: kcalendarsystem.cpp:781
KCalendarSystemPrivate::hasLeapMonths
virtual bool hasLeapMonths() const
Definition: kcalendarsystem.cpp:341
KCalendarSystemPrivate::q
const KCalendarSystem * q
Definition: kcalendarsystemprivate_p.h:104
KCalendarSystemPrivate::firstDayOfMonth
QDate firstDayOfMonth(int year, int month) const
Definition: kcalendarsystem.cpp:893
QLatin1Char
KCalendarSystemPrivate::setAnyDate
bool setAnyDate(QDate &date, int year, int month, int day) const
Definition: kcalendarsystem.cpp:798
KCalendarSystemPrivate::maxDaysInWeek
virtual int maxDaysInWeek() const
Definition: kcalendarsystem.cpp:355
KCalendarSystemPrivate::eraList
QList< KCalendarEra > * eraList() const
Definition: kcalendarsystem.cpp:917
KCalendarSystemPrivate::differenceYearNumbers
int differenceYearNumbers(int fromYear, int toYear) const
Definition: kcalendarsystem.cpp:825
KCalendarSystemPrivate::hasYearZero
virtual bool hasYearZero() const
Definition: kcalendarsystem.cpp:348
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:53
KCalendarSystemPrivate::dayOfWeek
int dayOfWeek(const QDate &date) const
Definition: kcalendarsystem.cpp:869
KCalendarSystemPrivate::~KCalendarSystemPrivate
virtual ~KCalendarSystemPrivate()
Definition: kcalendarsystem.cpp:254
KCalendarSystemPrivate
Definition: kcalendarsystemprivate_p.h:31
KCalendarSystemPrivate::weeksInYear
virtual int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const
Definition: kcalendarsystem.cpp:519
KCalendarSystemPrivate::monthName
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive=false) const
Definition: kcalendarsystem.cpp:387
KCalendarSystemPrivate::latestValidYear
virtual int latestValidYear() const
Definition: kcalendarsystem.cpp:380
KCalendarSystemPrivate::daysInMonth
virtual int daysInMonth(int year, int month) const
Definition: kcalendarsystem.cpp:285
KCalendarSystemPrivate::dateDifference
virtual void dateDifference(const QDate &fromDate, const QDate &toDate, int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const
Definition: kcalendarsystem.cpp:567
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:69
KCalendarSystemPrivate::weekDayName
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
Definition: kcalendarsystem.cpp:398
KCalendarSystemPrivate::lastDayOfYear
QDate lastDayOfYear(int year) const
Definition: kcalendarsystem.cpp:885
KCalendarSystemPrivate::firstDayOfYear
QDate firstDayOfYear(int year) const
Definition: kcalendarsystem.cpp:878
KCalendarSystemPrivate::loadEraList
void loadEraList(const KConfigGroup &cg)
Definition: kcalendarsystem.cpp:946
KCalendarSystemPrivate::calendarSystem
virtual KLocale::CalendarSystem calendarSystem() const
Definition: kcalendarsystem.cpp:261
KCalendarSystemPrivate::loadShortYearWindowStartYear
void loadShortYearWindowStartYear(const KConfigGroup &cg)
Definition: kcalendarsystem.cpp:1044
KCalendarSystemPrivate::isLeapYear
virtual bool isLeapYear(int year) const
Definition: kcalendarsystem.cpp:322
KLocale::DigitSet
DigitSet
Definition: klocale.h:309
KCalendarSystemPrivate::isoWeekNumber
virtual int isoWeekNumber(const QDate &date, int *yearNum) const
Definition: kcalendarsystem.cpp:427
KCalendarSystemPrivate::dayOfYear
int dayOfYear(const QDate &date) const
Definition: kcalendarsystem.cpp:860
KCalendarSystemPrivate::isoWeeksInYear
virtual int isoWeeksInYear(int year) const
Definition: kcalendarsystem.cpp:537
KCalendarSystemPrivate::yearsDifference
virtual int yearsDifference(const QDate &fromDate, const QDate &toDate) const
Definition: kcalendarsystem.cpp:653
KCalendarSystemPrivate::shortYearWindowStartYear
int shortYearWindowStartYear() const
Definition: kcalendarsystem.cpp:1024
KCalendarSystemPrivate::simpleDateString
QString simpleDateString(const QString &str) const
Definition: kcalendarsystem.cpp:846
KCalendarSystemPrivate::addEra
void addEra(char direction, int offset, const QDate &startDate, int startYear, const QDate &endDate, const QString &name, const QString &shortName, const QString &format)
Definition: kcalendarsystem.cpp:1000
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • 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