-rw-r--r-- | library/calendar.cpp | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/library/calendar.cpp b/library/calendar.cpp index b9ef585..c7536c3 100644 --- a/library/calendar.cpp +++ b/library/calendar.cpp | |||
@@ -1,66 +1,112 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "calendar.h" | 20 | #include "calendar.h" |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qobject.h> | ||
24 | |||
25 | /*! \class Calendar calendar.html | ||
26 | |||
27 | \brief The Calendar class provides programmers with an easy to calculate | ||
28 | and get information about dates, months and years. | ||
29 | |||
30 | \ingroup qtopiaemb | ||
31 | */ | ||
32 | |||
33 | |||
34 | |||
35 | static void never_called_tr_function_um_libqpe_ts_etwas_unter_zu_jubeln() { | ||
36 | (void)QObject::tr("Jan"); | ||
37 | (void)QObject::tr("Feb"); | ||
38 | (void)QObject::tr("Mar"); | ||
39 | (void)QObject::tr("Apr"); | ||
40 | (void)QObject::tr("May"); | ||
41 | (void)QObject::tr("Jun"); | ||
42 | (void)QObject::tr("Jul"); | ||
43 | (void)QObject::tr("Aug"); | ||
44 | (void)QObject::tr("Sep"); | ||
45 | (void)QObject::tr("Oct"); | ||
46 | (void)QObject::tr("Nov"); | ||
47 | (void)QObject::tr("Dec"); | ||
48 | (void)QObject::tr("Mon"); | ||
49 | (void)QObject::tr("Tue"); | ||
50 | (void)QObject::tr("Wed"); | ||
51 | (void)QObject::tr("Thu"); | ||
52 | (void)QObject::tr("Fri"); | ||
53 | (void)QObject::tr("Sat"); | ||
54 | (void)QObject::tr("Sun"); | ||
55 | } | ||
56 | |||
57 | |||
58 | |||
59 | /*! | ||
60 | Returns the name of the month for \a m. | ||
61 | Equivalent to QDate::monthName(). | ||
62 | */ | ||
23 | 63 | ||
24 | QString Calendar::nameOfMonth( int m ) | 64 | QString Calendar::nameOfMonth( int m ) |
25 | { | 65 | { |
26 | QDate d; | 66 | QDate d; |
27 | return d.monthName( m ); | 67 | qDebug( d.monthName( m ) ); |
68 | return QObject::tr( d.monthName( m ) ); | ||
28 | } | 69 | } |
29 | 70 | ||
71 | /*! | ||
72 | Returns the name of the day for \a d. | ||
73 | Equivalent to QDate::dayName(). | ||
74 | */ | ||
30 | QString Calendar::nameOfDay( int d ) | 75 | QString Calendar::nameOfDay( int d ) |
31 | { | 76 | { |
32 | QDate dt; | 77 | QDate dt; |
33 | return dt.dayName( d ); | 78 | return QObject::tr( dt.dayName( d ) ); |
34 | } | 79 | } |
35 | 80 | ||
81 | /*! \obsolete */ | ||
36 | QValueList<Calendar::Day> Calendar::daysOfMonth( int year, int month, | 82 | QValueList<Calendar::Day> Calendar::daysOfMonth( int year, int month, |
37 | bool startWithMonday ) | 83 | bool startWithMonday ) |
38 | { | 84 | { |
39 | QDate temp; | 85 | QDate temp; |
40 | temp.setYMD( year, month, 1 ); | 86 | temp.setYMD( year, month, 1 ); |
41 | int firstDay = temp.dayOfWeek(); | 87 | int firstDay = temp.dayOfWeek(); |
42 | int i; | 88 | int i; |
43 | QDate prev; | 89 | QDate prev; |
44 | QValueList<Day> days; | 90 | QValueList<Day> days; |
45 | 91 | ||
46 | if ( startWithMonday ) | 92 | if ( startWithMonday ) |
47 | i = 1; | 93 | i = 1; |
48 | else | 94 | else |
49 | i = 0; | 95 | i = 0; |
50 | 96 | ||
51 | if ( month > 1 ) | 97 | if ( month > 1 ) |
52 | prev.setYMD( year, month - 1, 1 ); | 98 | prev.setYMD( year, month - 1, 1 ); |
53 | else | 99 | else |
54 | prev.setYMD( year - 1, 12, 1 ); | 100 | prev.setYMD( year - 1, 12, 1 ); |
55 | for ( ; i < firstDay; i++ ) { | 101 | for ( ; i < firstDay; i++ ) { |
56 | days.append( Day( prev.daysInMonth() - ( firstDay - i - 1 ), | 102 | days.append( Day( prev.daysInMonth() - ( firstDay - i - 1 ), |
57 | Day::PrevMonth, FALSE ) ); | 103 | Day::PrevMonth, FALSE ) ); |
58 | } | 104 | } |
59 | for ( i = 1; i <= temp.daysInMonth(); i++ ) | 105 | for ( i = 1; i <= temp.daysInMonth(); i++ ) |
60 | days.append( Day( i, Day::ThisMonth, FALSE ) ); | 106 | days.append( Day( i, Day::ThisMonth, FALSE ) ); |
61 | i = 0; | 107 | i = 0; |
62 | while ( days.count() < 6 * 7 ) | 108 | while ( days.count() < 6 * 7 ) |
63 | days.append( Day( ++i, Day::NextMonth, FALSE ) ); | 109 | days.append( Day( ++i, Day::NextMonth, FALSE ) ); |
64 | 110 | ||
65 | return days; | 111 | return days; |
66 | } | 112 | } |