KDECore
kcalendarsystemprivate_p.h
Go to the documentation of this file.
00001 /* 00002 Copyright 2010 John Layt <john@layt.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KCALENDARSYSTEMPRIVATE_H 00021 #define KCALENDARSYSTEMPRIVATE_H 00022 00023 class QChar; 00024 class QString; 00025 class QDate; 00026 00027 class KCalendarSystem; 00028 class KCalendarEra; 00029 class KLocale; 00030 00031 class KCalendarSystemPrivate 00032 { 00033 public: 00034 explicit KCalendarSystemPrivate(KCalendarSystem *q); 00035 00036 virtual ~KCalendarSystemPrivate(); 00037 00038 // Virtual methods each calendar system must re-implement 00039 virtual KLocale::CalendarSystem calendarSystem() const; 00040 virtual void loadDefaultEraList(); 00041 virtual int monthsInYear(int year) const; 00042 virtual int daysInMonth(int year, int month) const; 00043 virtual int daysInYear(int year) const; 00044 virtual int daysInWeek() const; 00045 virtual bool isLeapYear(int year) const; 00046 virtual bool hasLeapMonths() const; 00047 virtual bool hasYearZero() const; 00048 virtual int maxDaysInWeek() const; 00049 virtual int maxMonthsInYear() const; 00050 virtual int earliestValidYear() const; 00051 virtual int latestValidYear() const; 00052 virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive = false) const; 00053 virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const; 00054 00055 // Virtual methods to re-implement if special maths needed 00056 virtual int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum) const; 00057 virtual int isoWeekNumber(const QDate &date, int *yearNum) const; 00058 virtual int regularWeekNumber(const QDate &date, int weekStartDay, int firstWeekNumber, int *weekYear) const; 00059 virtual int simpleWeekNumber(const QDate &date, int *yearNum) const; 00060 virtual int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const; 00061 virtual int isoWeeksInYear(int year) const; 00062 virtual int regularWeeksInYear(int year, int weekStartDay, int firstWeekNumber) const; 00063 virtual int simpleWeeksInYear(int year) const; 00064 00065 // Virtual methods to re-implement if special maths needed 00066 // Currently only Hebrew may need special conversion, rest should be OK 00067 virtual int yearsDifference(const QDate &fromDate, const QDate &toDate) const; 00068 virtual int monthsDifference(const QDate &fromDate, const QDate &toDate) const; 00069 virtual void dateDifference(const QDate &fromDate, const QDate &toDate, 00070 int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const; 00071 00072 // Virtual methods to re-implement if special number/string conversion needed 00073 // Currently only Hebrew needs special conversion, rest use KLocale DigitSet 00074 virtual int integerFromString(const QString &string, int maxLength, int &readLength) const; 00075 virtual QString stringFromInteger(int number, int padWidth = 0, QChar padChar = QLatin1Char('0')) const; 00076 virtual QString stringFromInteger(int number, int padWidth, QChar padChar, KLocale::DigitSet digitSet) const; 00077 00078 // Utility functions 00079 bool setAnyDate(QDate &date, int year, int month, int day) const; 00080 int addYears(int startYear, int yearsToAdd) const; 00081 int differenceYearNumbers(int fromYear, int toYear) const; 00082 QDate invalidDate() const; 00083 QString simpleDateString(const QString &str) const; 00084 int dayOfYear(const QDate &date) const; 00085 int dayOfWeek(const QDate &date) const; 00086 QDate firstDayOfYear(int year) const; 00087 QDate lastDayOfYear(int year) const; 00088 QDate firstDayOfMonth(int year, int month) const; 00089 QDate lastDayOfMonth(int year, int month) const; 00090 const KLocale *locale() const; 00091 void loadEraList(const KConfigGroup & cg); 00092 void addEra(char direction, int offset, const QDate &startDate, int startYear, const QDate &endDate, 00093 const QString &name, const QString &shortName, const QString &format); 00094 QList<KCalendarEra> *eraList() const; 00095 KCalendarEra era(const QDate &eraDate) const; 00096 KCalendarEra era(const QString &eraName, int yearInEra) const; 00097 int shortYearWindowStartYear() const; 00098 int applyShortYearWindow(int inputYear) const; 00099 void loadShortYearWindowStartYear(const KConfigGroup & cg); 00100 KSharedConfig::Ptr config(); 00101 void loadConfig(const QString & calendarType); 00102 00103 // Global variables each calendar system must initialise 00104 const KCalendarSystem *q; 00105 const KLocale *m_locale; 00106 KSharedConfig::Ptr m_config; 00107 QList<KCalendarEra> *m_eraList; 00108 int m_shortYearWindowStartYear; 00109 }; 00110 00111 #endif // KCALENDARSYSTEMPRIVATE_H
KDE 4.7 API Reference