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

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 struct DateComponents
00032 {
00033     int day;
00034     int month;
00035     int year;
00036     bool parsedYear;
00037     QString eraName;
00038     int yearInEra;
00039     int dayInYear;
00040     int isoWeekNumber;
00041     int dayOfIsoWeek;
00042     int inputPosition;
00043     int formatPosition;
00044     bool error;
00045 };
00046 
00047 class KCalendarSystemPrivate
00048 {
00049 public:
00050     explicit KCalendarSystemPrivate( KCalendarSystem *q );
00051 
00052     virtual ~KCalendarSystemPrivate();
00053 
00054     // Virtual methods each calendar system must re-implement
00055     virtual KLocale::CalendarSystem calendarSystem() const;
00056     virtual void loadDefaultEraList();
00057     virtual int monthsInYear( int year ) const;
00058     virtual int daysInMonth( int year, int month ) const;
00059     virtual int daysInYear( int year ) const;
00060     virtual int daysInWeek() const;
00061     virtual bool isLeapYear( int year ) const;
00062     virtual bool hasLeapMonths() const;
00063     virtual bool hasYearZero() const;
00064     virtual int maxDaysInWeek() const;
00065     virtual int maxMonthsInYear() const;
00066     virtual int earliestValidYear() const;
00067     virtual int latestValidYear() const;
00068 
00069     // Virtual methods to re-implement if special maths needed
00070     // Currently only Hebrew may need special conversion, rest should be OK
00071     virtual int yearsDifference( const QDate &fromDate, const QDate &toDate ) const;
00072     virtual int monthsDifference( const QDate &fromDate, const QDate &toDate ) const;
00073     virtual void dateDifference( const QDate &fromDate, const QDate &toDate,
00074                                  int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction ) const;
00075 
00076     // Virtual methods to re-implement if special number/string conversion needed
00077     // Currently only Hebrew needs special conversion, rest use KLocale DigitSet
00078     virtual int integerFromString( const QString &string, int maxLength, int &readLength ) const;
00079     virtual QString stringFromInteger( int number, int padWidth = 0, QChar padChar = QLatin1Char('0') ) const;
00080     virtual QString stringFromInteger( int number, int padWidth, QChar padChar, KLocale::DigitSet digitSet ) const;
00081 
00082     // Utility functions
00083     bool setAnyDate( QDate &date, int year, int month, int day ) const;
00084     int addYears( int startYear, int yearsToAdd ) const;
00085     int differenceYearNumbers( int fromYear, int toYear ) const;
00086     QDate invalidDate() const;
00087     QString simpleDateString( const QString &str ) const;
00088     QDate firstDayOfYear( int year ) const;
00089     QDate lastDayOfYear( int year ) const;
00090     QDate firstDayOfMonth( int year, int month ) const;
00091     QDate lastDayOfMonth( int year, int month ) const;
00092     const KLocale *locale() const;
00093     void loadEraList( const KConfigGroup & cg );
00094     void addEra( char direction, int offset, const QDate &startDate, int startYear, const QDate &endDate,
00095                  const QString &name, const QString &shortName, const QString &format );
00096     QList<KCalendarEra> *eraList() const;
00097     KCalendarEra era( const QDate &eraDate ) const;
00098     KCalendarEra era( const QString &eraName, int yearInEra ) const;
00099     int shortYearWindowStartYear() const;
00100     int applyShortYearWindow( int inputYear ) const;
00101     void loadShortYearWindowStartYear( const KConfigGroup & cg );
00102     KSharedConfig::Ptr config();
00103     void loadConfig( const QString & calendarType );
00104 
00105     // Global variables each calendar system must initialise
00106     const KCalendarSystem *q;
00107     const KLocale *m_locale;
00108     KSharedConfig::Ptr m_config;
00109     QList<KCalendarEra> *m_eraList;
00110     int m_shortYearWindowStartYear;
00111 };
00112 
00113 #endif // KCALENDARSYSTEMPRIVATE_H

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal