-rw-r--r-- | libopie2/opiepim/core/oconversion.cpp | 213 | ||||
-rw-r--r-- | libopie2/opiepim/core/oconversion.h | 7 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimcache.h | 10 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimmaintainer.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimmaintainer.h | 5 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimresolver.cpp | 11 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimresolver.h | 16 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimstate.cpp | 5 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimstate.h | 11 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxref.cpp | 14 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxref.h | 22 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefmanager.cpp | 22 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefmanager.h | 9 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefpartner.cpp | 12 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefpartner.h | 7 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 754 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.h | 17 | ||||
-rw-r--r-- | libopie2/opiepim/core/otemplatebase.h | 9 | ||||
-rw-r--r-- | libopie2/opiepim/core/otimezone.cpp | 168 | ||||
-rw-r--r-- | libopie2/opiepim/core/otimezone.h | 13 |
20 files changed, 751 insertions, 576 deletions
diff --git a/libopie2/opiepim/core/oconversion.cpp b/libopie2/opiepim/core/oconversion.cpp index b7eebef..160c2c6 100644 --- a/libopie2/opiepim/core/oconversion.cpp +++ b/libopie2/opiepim/core/oconversion.cpp | |||
@@ -1,30 +1,30 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | .=l. |
5 | .=l. | 5 | .>+-= |
6 | .>+-= | 6 | _;:, .> :=|. This program is free software; you can |
7 | _;:, .> :=|. This program is free software; you can | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | ._= =} : or (at your option) any later version. |
12 | ._= =} : or (at your option) any later version. | 12 | .%`+i> _;_. |
13 | .%`+i> _;_. | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | : .. .:, . . . without even the implied warranty of |
16 | : .. .:, . . . without even the implied warranty of | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | ..}^=.= = ; Library General Public License for more |
19 | ..}^=.= = ; Library General Public License for more | 19 | ++= -. .` .: details. |
20 | ++= -. .` .: details. | 20 | : = ...= . :.=- |
21 | : = ...= . :.=- | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -_. . . )=. = Library General Public License along with |
23 | -_. . . )=. = Library General Public License along with | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | If not, write to the Free Software Foundation, |
25 | If not, write to the Free Software Foundation, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Boston, MA 02111-1307, USA. |
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | 27 | */ |
29 | 28 | ||
29 | /* OPIE */ | ||
30 | #include <opie2/oconversion.h> | 30 | #include <opie2/oconversion.h> |
@@ -32,4 +32,4 @@ | |||
32 | 32 | ||
33 | 33 | namespace Opie | |
34 | namespace Opie { | 34 | { |
35 | 35 | ||
@@ -37,89 +37,100 @@ QString OConversion::dateToString( const QDate &d ) | |||
37 | { | 37 | { |
38 | if ( d.isNull() || !d.isValid() ) | 38 | if ( d.isNull() || !d.isValid() ) |
39 | return QString::null; | 39 | return QString::null; |
40 | 40 | ||
41 | // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 | 41 | // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 |
42 | QString year = QString::number( d.year() ); | 42 | QString year = QString::number( d.year() ); |
43 | QString month = QString::number( d.month() ); | 43 | QString month = QString::number( d.month() ); |
44 | month = month.rightJustify( 2, '0' ); | 44 | month = month.rightJustify( 2, '0' ); |
45 | QString day = QString::number( d.day() ); | 45 | QString day = QString::number( d.day() ); |
46 | day = day.rightJustify( 2, '0' ); | 46 | day = day.rightJustify( 2, '0' ); |
47 | 47 | ||
48 | QString str = year + month + day; | 48 | QString str = year + month + day; |
49 | //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); | 49 | //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); |
50 | 50 | ||
51 | return str; | 51 | return str; |
52 | } | 52 | } |
53 | 53 | ||
54 | |||
54 | QDate OConversion::dateFromString( const QString& s ) | 55 | QDate OConversion::dateFromString( const QString& s ) |
55 | { | 56 | { |
56 | QDate date; | 57 | QDate date; |
57 | 58 | ||
58 | if ( s.isEmpty() ) | 59 | if ( s.isEmpty() ) |
59 | return date; | 60 | return date; |
60 | 61 | ||
61 | // Be backward compatible to old Opie format: | 62 | // Be backward compatible to old Opie format: |
62 | // Try to load old format. If it fails, try new ISO-Format! | 63 | // Try to load old format. If it fails, try new ISO-Format! |
63 | date = TimeConversion::fromString ( s ); | 64 | date = TimeConversion::fromString ( s ); |
64 | if ( date.isValid() ) | 65 | if ( date.isValid() ) |
65 | return date; | 66 | return date; |
66 | 67 | ||
67 | // Read ISO-Format (YYYYMMDD) | 68 | // Read ISO-Format (YYYYMMDD) |
68 | int year = s.mid(0, 4).toInt(); | 69 | int year = s.mid( 0, 4 ).toInt(); |
69 | int month = s.mid(4,2).toInt(); | 70 | int month = s.mid( 4, 2 ).toInt(); |
70 | int day = s.mid(6,2).toInt(); | 71 | int day = s.mid( 6, 2 ).toInt(); |
71 | 72 | ||
72 | // do some quick sanity checking -eilers | 73 | // do some quick sanity checking -eilers |
73 | // but we isValid() again? -zecke | 74 | // but we isValid() again? -zecke |
74 | if ( year < 1900 || year > 3000 ) { | 75 | if ( year < 1900 || year > 3000 ) |
75 | qWarning( "PimContact year is not in range"); | 76 | { |
76 | return date; | 77 | qWarning( "PimContact year is not in range" ); |
77 | } | 78 | return date; |
78 | if ( month < 0 || month > 12 ) { | 79 | } |
79 | qWarning( "PimContact month is not in range"); | 80 | if ( month < 0 || month > 12 ) |
80 | return date; | 81 | { |
81 | } | 82 | qWarning( "PimContact month is not in range" ); |
82 | if ( day < 0 || day > 31 ) { | 83 | return date; |
83 | qWarning( "PimContact day is not in range"); | 84 | } |
84 | return date; | 85 | if ( day < 0 || day > 31 ) |
85 | } | 86 | { |
86 | 87 | qWarning( "PimContact day is not in range" ); | |
87 | date.setYMD( year, month, day ); | 88 | return date; |
88 | if ( !date.isValid() ) { | 89 | } |
89 | qWarning( "PimContact date is not valid"); | 90 | |
90 | return date; | 91 | date.setYMD( year, month, day ); |
91 | } | 92 | if ( !date.isValid() ) |
92 | 93 | { | |
93 | return date; | 94 | qWarning( "PimContact date is not valid" ); |
95 | return date; | ||
96 | } | ||
97 | |||
98 | return date; | ||
94 | } | 99 | } |
95 | QString OConversion::dateTimeToString( const QDateTime& dt ) { | ||
96 | if (!dt.isValid() || dt.isNull() ) return QString::null; | ||
97 | 100 | ||
98 | QString year = QString::number( dt.date().year() ); | ||
99 | QString month = QString::number( dt.date().month() ); | ||
100 | QString day = QString::number( dt.date().day() ); | ||
101 | 101 | ||
102 | QString hour = QString::number( dt.time().hour() ); | 102 | QString OConversion::dateTimeToString( const QDateTime& dt ) |
103 | QString min = QString::number( dt.time().minute() ); | 103 | { |
104 | QString sec = QString::number( dt.time().second() ); | 104 | if ( !dt.isValid() || dt.isNull() ) |
105 | return QString::null; | ||
105 | 106 | ||
106 | month = month.rightJustify( 2, '0' ); | 107 | QString year = QString::number( dt.date().year() ); |
107 | day = day. rightJustify( 2, '0' ); | 108 | QString month = QString::number( dt.date().month() ); |
108 | hour = hour. rightJustify( 2, '0' ); | 109 | QString day = QString::number( dt.date().day() ); |
109 | min = min. rightJustify( 2, '0' ); | ||
110 | sec = sec. rightJustify( 2, '0' ); | ||
111 | 110 | ||
112 | QString str = day + month + year + hour + min + sec; | 111 | QString hour = QString::number( dt.time().hour() ); |
112 | QString min = QString::number( dt.time().minute() ); | ||
113 | QString sec = QString::number( dt.time().second() ); | ||
113 | 114 | ||
114 | return str; | 115 | month = month.rightJustify( 2, '0' ); |
116 | day = day. rightJustify( 2, '0' ); | ||
117 | hour = hour. rightJustify( 2, '0' ); | ||
118 | min = min. rightJustify( 2, '0' ); | ||
119 | sec = sec. rightJustify( 2, '0' ); | ||
120 | |||
121 | return day + month + year + hour + min + sec; | ||
115 | } | 122 | } |
116 | QDateTime OConversion::dateTimeFromString( const QString& str) { | ||
117 | 123 | ||
118 | if ( str.isEmpty() ) return QDateTime(); | 124 | |
119 | int day = str.mid(0, 2).toInt(); | 125 | QDateTime OConversion::dateTimeFromString( const QString& str ) |
120 | int month = str.mid(2, 2).toInt(); | 126 | { |
121 | int year = str.mid(4, 4).toInt(); | 127 | |
122 | int hour = str.mid(8, 2).toInt(); | 128 | if ( str.isEmpty() ) |
123 | int min = str.mid(10, 2).toInt(); | 129 | return QDateTime(); |
124 | int sec = str.mid(12, 2).toInt(); | 130 | int day = str.mid( 0, 2 ).toInt(); |
131 | int month = str.mid( 2, 2 ).toInt(); | ||
132 | int year = str.mid( 4, 4 ).toInt(); | ||
133 | int hour = str.mid( 8, 2 ).toInt(); | ||
134 | int min = str.mid( 10, 2 ).toInt(); | ||
135 | int sec = str.mid( 12, 2 ).toInt(); | ||
125 | 136 | ||
@@ -131,2 +142,2 @@ QDateTime OConversion::dateTimeFromString( const QString& str) { | |||
131 | 142 | ||
132 | } \ No newline at end of file | 143 | } |
diff --git a/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/oconversion.h index 3c4fdf3..eeb97e5 100644 --- a/libopie2/opiepim/core/oconversion.h +++ b/libopie2/opiepim/core/oconversion.h | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #ifndef __oconversion_h__ | 30 | #ifndef OCONVERSION_H |
31 | #define __oconversion_h__ | 31 | #define OCONVERSION_H |
32 | 32 | ||
33 | /* #include <time.h> */ | 33 | /* QT */ |
34 | /* #include <sys/types.h> */ | ||
35 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
diff --git a/libopie2/opiepim/core/opimcache.h b/libopie2/opiepim/core/opimcache.h index e70a910..a033574 100644 --- a/libopie2/opiepim/core/opimcache.h +++ b/libopie2/opiepim/core/opimcache.h | |||
@@ -28,9 +28,11 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_CACHE_H | 29 | #ifndef OPIMCACHE_H |
30 | #define OPIE_PIM_CACHE_H | 30 | #define OPIMCACHE_H |
31 | |||
32 | #include <qintcache.h> | ||
33 | 31 | ||
32 | /* OPIE */ | ||
34 | #include <opie2/opimrecord.h> | 33 | #include <opie2/opimrecord.h> |
35 | 34 | ||
35 | /* QT */ | ||
36 | #include <qintcache.h> | ||
37 | |||
36 | namespace Opie { | 38 | namespace Opie { |
diff --git a/libopie2/opiepim/core/opimmaintainer.cpp b/libopie2/opiepim/core/opimmaintainer.cpp index b2eff12..b8d829a 100644 --- a/libopie2/opiepim/core/opimmaintainer.cpp +++ b/libopie2/opiepim/core/opimmaintainer.cpp | |||
@@ -29,3 +29,3 @@ | |||
29 | 29 | ||
30 | #include <opie2/opimmaintainer.h> | 30 | #include "opimmaintainer.h" |
31 | 31 | ||
diff --git a/libopie2/opiepim/core/opimmaintainer.h b/libopie2/opiepim/core/opimmaintainer.h index 46bc9d2..e7e7eeb 100644 --- a/libopie2/opiepim/core/opimmaintainer.h +++ b/libopie2/opiepim/core/opimmaintainer.h | |||
@@ -28,5 +28,6 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_MAINTAINER_H | 29 | #ifndef OPIMMAINTAINER_H |
30 | #define OPIE_PIM_MAINTAINER_H | 30 | #define OPIMMAINTAINER_H |
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qstring.h> | 33 | #include <qstring.h> |
diff --git a/libopie2/opiepim/core/opimresolver.cpp b/libopie2/opiepim/core/opimresolver.cpp index eceabcb..73d7de1 100644 --- a/libopie2/opiepim/core/opimresolver.cpp +++ b/libopie2/opiepim/core/opimresolver.cpp | |||
@@ -28,11 +28,12 @@ | |||
28 | */ | 28 | */ |
29 | #include <qcopchannel_qws.h> | ||
30 | 29 | ||
31 | #include <qpe/qcopenvelope_qws.h> | 30 | #include "opimresolver.h" |
32 | 31 | ||
33 | #include <opie2/otodoaccess.h> | 32 | /* OPIE */ |
34 | #include <opie2/ocontactaccess.h> | 33 | #include <opie2/ocontactaccess.h> |
34 | #include <opie2/otodoaccess.h> | ||
35 | #include <qpe/qcopenvelope_qws.h> | ||
35 | 36 | ||
36 | //#include "opimfactory.h" | 37 | /* QT */ |
37 | #include <opie2/opimresolver.h> | 38 | #include <qcopchannel_qws.h> |
38 | 39 | ||
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h index adc7c16..dd6f07f 100644 --- a/libopie2/opiepim/core/opimresolver.h +++ b/libopie2/opiepim/core/opimresolver.h | |||
@@ -28,5 +28,9 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_RESOLVER | 29 | #ifndef OPIMRESOLVER_H |
30 | #define OPIE_PIM_RESOLVER | 30 | #define OPIMRESOLVER_H |
31 | 31 | ||
32 | /* OPIE */ | ||
33 | #include <opie2/otemplatebase.h> | ||
34 | |||
35 | /* QT */ | ||
32 | #include <qstring.h> | 36 | #include <qstring.h> |
@@ -34,4 +38,2 @@ | |||
34 | 38 | ||
35 | #include <opie2/otemplatebase.h> | ||
36 | |||
37 | namespace Opie { | 39 | namespace Opie { |
@@ -49,3 +51,4 @@ namespace Opie { | |||
49 | class OPimResolver { | 51 | class OPimResolver { |
50 | public: | 52 | |
53 | public: | ||
51 | enum BuiltIn { TodoList = 0, | 54 | enum BuiltIn { TodoList = 0, |
@@ -102,3 +105,4 @@ public: | |||
102 | OPimBase* backend( int rtti ); | 105 | OPimBase* backend( int rtti ); |
103 | private: | 106 | |
107 | private: | ||
104 | OPimResolver(); | 108 | OPimResolver(); |
diff --git a/libopie2/opiepim/core/opimstate.cpp b/libopie2/opiepim/core/opimstate.cpp index 1013a1c..8aff558 100644 --- a/libopie2/opiepim/core/opimstate.cpp +++ b/libopie2/opiepim/core/opimstate.cpp | |||
@@ -28,6 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | #include <qshared.h> | ||
30 | |||
31 | #include "opimstate.h" | 29 | #include "opimstate.h" |
32 | 30 | ||
31 | /* QT */ | ||
32 | #include <qshared.h> | ||
33 | |||
33 | namespace Opie { | 34 | namespace Opie { |
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h index 78e8cd0..8336b3e 100644 --- a/libopie2/opiepim/core/opimstate.h +++ b/libopie2/opiepim/core/opimstate.h | |||
@@ -28,5 +28,6 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_STATE_H | 29 | #ifndef OPIMSTATE_H |
30 | #define OPIE_PIM_STATE_H | 30 | #define OPIMSTATE_H |
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qstring.h> | 33 | #include <qstring.h> |
@@ -46,3 +47,4 @@ namespace Opie { | |||
46 | class OPimState { | 47 | class OPimState { |
47 | public: | 48 | |
49 | public: | ||
48 | enum State { | 50 | enum State { |
@@ -62,3 +64,4 @@ public: | |||
62 | int state()const; | 64 | int state()const; |
63 | private: | 65 | |
66 | private: | ||
64 | void deref(); | 67 | void deref(); |
diff --git a/libopie2/opiepim/core/opimxref.cpp b/libopie2/opiepim/core/opimxref.cpp index 85d3345..f58ebb5 100644 --- a/libopie2/opiepim/core/opimxref.cpp +++ b/libopie2/opiepim/core/opimxref.cpp | |||
@@ -28,3 +28,3 @@ | |||
28 | */ | 28 | */ |
29 | #include <opie2/opimxref.h> | 29 | #include "opimxref.h" |
30 | 30 | ||
@@ -38,4 +38,3 @@ OPimXRef::OPimXRef( const OPimXRefPartner& one, const OPimXRefPartner& two ) | |||
38 | } | 38 | } |
39 | OPimXRef::OPimXRef() | 39 | OPimXRef::OPimXRef():m_partners(2) |
40 | : m_partners(2) | ||
41 | { | 40 | { |
@@ -43,2 +42,3 @@ OPimXRef::OPimXRef() | |||
43 | } | 42 | } |
43 | |||
44 | OPimXRef::OPimXRef( const OPimXRef& ref) { | 44 | OPimXRef::OPimXRef( const OPimXRef& ref) { |
@@ -46,4 +46,6 @@ OPimXRef::OPimXRef( const OPimXRef& ref) { | |||
46 | } | 46 | } |
47 | |||
47 | OPimXRef::~OPimXRef() { | 48 | OPimXRef::~OPimXRef() { |
48 | } | 49 | } |
50 | |||
49 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { | 51 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { |
@@ -52,4 +54,5 @@ OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { | |||
52 | 54 | ||
53 | return* this; | 55 | return *this; |
54 | } | 56 | } |
57 | |||
55 | bool OPimXRef::operator==( const OPimXRef& oper ) { | 58 | bool OPimXRef::operator==( const OPimXRef& oper ) { |
@@ -62,2 +65,3 @@ OPimXRefPartner OPimXRef::partner( enum Partners par) const{ | |||
62 | } | 65 | } |
66 | |||
63 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { | 67 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { |
@@ -65,2 +69,3 @@ void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { | |||
65 | } | 69 | } |
70 | |||
66 | bool OPimXRef::containsString( const QString& string ) const{ | 71 | bool OPimXRef::containsString( const QString& string ) const{ |
@@ -71,2 +76,3 @@ bool OPimXRef::containsString( const QString& string ) const{ | |||
71 | } | 76 | } |
77 | |||
72 | bool OPimXRef::containsUid( int uid ) const{ | 78 | bool OPimXRef::containsUid( int uid ) const{ |
diff --git a/libopie2/opiepim/core/opimxref.h b/libopie2/opiepim/core/opimxref.h index 820c9c4..f3e814e 100644 --- a/libopie2/opiepim/core/opimxref.h +++ b/libopie2/opiepim/core/opimxref.h | |||
@@ -29,5 +29,9 @@ | |||
29 | 29 | ||
30 | #ifndef OPIM_XREF_H | 30 | #ifndef OPIMXREF_H |
31 | #define OPIM_XREF_H | 31 | #define OPIMXREF_H |
32 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/opimxrefpartner.h> | ||
35 | |||
36 | /* QT */ | ||
33 | #include <qarray.h> | 37 | #include <qarray.h> |
@@ -35,4 +39,2 @@ | |||
35 | 39 | ||
36 | #include <opie2/opimxrefpartner.h> | ||
37 | |||
38 | namespace Opie { | 40 | namespace Opie { |
@@ -43,3 +45,3 @@ namespace Opie { | |||
43 | class OPimXRef { | 45 | class OPimXRef { |
44 | public: | 46 | public: |
45 | typedef QValueList<OPimXRef> ValueList; | 47 | typedef QValueList<OPimXRef> ValueList; |
@@ -54,10 +56,10 @@ public: | |||
54 | 56 | ||
55 | OPimXRefPartner partner( enum Partners )const; | 57 | OPimXRefPartner partner( enum Partners ) const; |
56 | 58 | ||
57 | void setPartner( enum Partners, const OPimXRefPartner& ); | 59 | void setPartner( enum Partners, const OPimXRefPartner& ); |
58 | 60 | ||
59 | bool containsString( const QString& service)const; | 61 | bool containsString( const QString& service) const; |
60 | bool containsUid( int uid )const; | 62 | bool containsUid( int uid ) const; |
61 | 63 | ||
62 | private: | 64 | private: |
63 | QArray<OPimXRefPartner> m_partners; | 65 | QArray<OPimXRefPartner> m_partners; |
diff --git a/libopie2/opiepim/core/opimxrefmanager.cpp b/libopie2/opiepim/core/opimxrefmanager.cpp index bf6fed6..e7c6c5a 100644 --- a/libopie2/opiepim/core/opimxrefmanager.cpp +++ b/libopie2/opiepim/core/opimxrefmanager.cpp | |||
@@ -28,3 +28,3 @@ | |||
28 | */ | 28 | */ |
29 | #include <opie2/opimxrefmanager.h> | 29 | #include "opimxrefmanager.h" |
30 | 30 | ||
@@ -34,2 +34,3 @@ OPimXRefManager::OPimXRefManager() { | |||
34 | } | 34 | } |
35 | |||
35 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { | 36 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { |
@@ -37,4 +38,6 @@ OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { | |||
37 | } | 38 | } |
39 | |||
38 | OPimXRefManager::~OPimXRefManager() { | 40 | OPimXRefManager::~OPimXRefManager() { |
39 | } | 41 | } |
42 | |||
40 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { | 43 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { |
@@ -43,2 +46,3 @@ OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { | |||
43 | } | 46 | } |
47 | |||
44 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { | 48 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { |
@@ -48,2 +52,3 @@ bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { | |||
48 | } | 52 | } |
53 | |||
49 | void OPimXRefManager::add( const OPimXRef& ref) { | 54 | void OPimXRefManager::add( const OPimXRef& ref) { |
@@ -51,2 +56,3 @@ void OPimXRefManager::add( const OPimXRef& ref) { | |||
51 | } | 56 | } |
57 | |||
52 | void OPimXRefManager::remove( const OPimXRef& ref) { | 58 | void OPimXRefManager::remove( const OPimXRef& ref) { |
@@ -54,2 +60,3 @@ void OPimXRefManager::remove( const OPimXRef& ref) { | |||
54 | } | 60 | } |
61 | |||
55 | void OPimXRefManager::replace( const OPimXRef& ref) { | 62 | void OPimXRefManager::replace( const OPimXRef& ref) { |
@@ -58,2 +65,3 @@ void OPimXRefManager::replace( const OPimXRef& ref) { | |||
58 | } | 65 | } |
66 | |||
59 | void OPimXRefManager::clear() { | 67 | void OPimXRefManager::clear() { |
@@ -61,3 +69,4 @@ void OPimXRefManager::clear() { | |||
61 | } | 69 | } |
62 | QStringList OPimXRefManager::apps()const { | 70 | |
71 | QStringList OPimXRefManager::apps() const { | ||
63 | OPimXRef::ValueList::ConstIterator it; | 72 | OPimXRef::ValueList::ConstIterator it; |
@@ -75,6 +84,8 @@ QStringList OPimXRefManager::apps()const { | |||
75 | } | 84 | } |
76 | OPimXRef::ValueList OPimXRefManager::list()const { | 85 | |
86 | OPimXRef::ValueList OPimXRefManager::list() const { | ||
77 | return m_list; | 87 | return m_list; |
78 | } | 88 | } |
79 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ | 89 | |
90 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName ) const{ | ||
80 | OPimXRef::ValueList list; | 91 | OPimXRef::ValueList list; |
@@ -89,3 +100,4 @@ OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ | |||
89 | } | 100 | } |
90 | OPimXRef::ValueList OPimXRefManager::list( int uid )const { | 101 | |
102 | OPimXRef::ValueList OPimXRefManager::list( int uid ) const { | ||
91 | OPimXRef::ValueList list; | 103 | OPimXRef::ValueList list; |
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h index fa2d7f4..b80a645 100644 --- a/libopie2/opiepim/core/opimxrefmanager.h +++ b/libopie2/opiepim/core/opimxrefmanager.h | |||
@@ -28,9 +28,12 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIM_XREF_MANAGER_H | ||
30 | #define OPIM_XREF_MANAGER_H | ||
31 | 29 | ||
32 | #include <qstringlist.h> | 30 | #ifndef OPIMXREFMANAGER_H |
31 | #define OPIMXREFMANAGER_H | ||
33 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/opimxref.h> | 34 | #include <opie2/opimxref.h> |
35 | 35 | ||
36 | /* QT */ | ||
37 | #include <qstringlist.h> | ||
38 | |||
36 | namespace Opie { | 39 | namespace Opie { |
diff --git a/libopie2/opiepim/core/opimxrefpartner.cpp b/libopie2/opiepim/core/opimxrefpartner.cpp index f6ccc7f..3741bc3 100644 --- a/libopie2/opiepim/core/opimxrefpartner.cpp +++ b/libopie2/opiepim/core/opimxrefpartner.cpp | |||
@@ -28,3 +28,3 @@ | |||
28 | */ | 28 | */ |
29 | #include <opie2/opimxrefpartner.h> | 29 | #include "opimxrefpartner.h" |
30 | 30 | ||
@@ -36,2 +36,3 @@ OPimXRefPartner::OPimXRefPartner( const QString& appName, | |||
36 | } | 36 | } |
37 | |||
37 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { | 38 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { |
@@ -39,4 +40,6 @@ OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { | |||
39 | } | 40 | } |
41 | |||
40 | OPimXRefPartner::~OPimXRefPartner() { | 42 | OPimXRefPartner::~OPimXRefPartner() { |
41 | } | 43 | } |
44 | |||
42 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { | 45 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { |
@@ -48,2 +51,3 @@ OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { | |||
48 | } | 51 | } |
52 | |||
49 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { | 53 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { |
@@ -55,2 +59,3 @@ bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { | |||
55 | } | 59 | } |
60 | |||
56 | QString OPimXRefPartner::service()const { | 61 | QString OPimXRefPartner::service()const { |
@@ -58,2 +63,3 @@ QString OPimXRefPartner::service()const { | |||
58 | } | 63 | } |
64 | |||
59 | int OPimXRefPartner::uid()const { | 65 | int OPimXRefPartner::uid()const { |
@@ -61,2 +67,3 @@ int OPimXRefPartner::uid()const { | |||
61 | } | 67 | } |
68 | |||
62 | int OPimXRefPartner::field()const { | 69 | int OPimXRefPartner::field()const { |
@@ -64,2 +71,3 @@ int OPimXRefPartner::field()const { | |||
64 | } | 71 | } |
72 | |||
65 | void OPimXRefPartner::setService( const QString& appName ) { | 73 | void OPimXRefPartner::setService( const QString& appName ) { |
@@ -67,2 +75,3 @@ void OPimXRefPartner::setService( const QString& appName ) { | |||
67 | } | 75 | } |
76 | |||
68 | void OPimXRefPartner::setUid( int uid ) { | 77 | void OPimXRefPartner::setUid( int uid ) { |
@@ -70,2 +79,3 @@ void OPimXRefPartner::setUid( int uid ) { | |||
70 | } | 79 | } |
80 | |||
71 | void OPimXRefPartner::setField( int field ) { | 81 | void OPimXRefPartner::setField( int field ) { |
diff --git a/libopie2/opiepim/core/opimxrefpartner.h b/libopie2/opiepim/core/opimxrefpartner.h index 6853d5b..005dbc0 100644 --- a/libopie2/opiepim/core/opimxrefpartner.h +++ b/libopie2/opiepim/core/opimxrefpartner.h | |||
@@ -31,2 +31,3 @@ | |||
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qstring.h> | 33 | #include <qstring.h> |
@@ -42,3 +43,4 @@ namespace Opie { | |||
42 | class OPimXRefPartner { | 43 | class OPimXRefPartner { |
43 | public: | 44 | |
45 | public: | ||
44 | OPimXRefPartner( const QString& service = QString::null, | 46 | OPimXRefPartner( const QString& service = QString::null, |
@@ -58,3 +60,4 @@ public: | |||
58 | void setField( int field ); | 60 | void setField( int field ); |
59 | private: | 61 | |
62 | private: | ||
60 | QString m_app; | 63 | QString m_app; |
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index 033f264..5e2da25 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp | |||
@@ -29,12 +29,16 @@ | |||
29 | 29 | ||
30 | #include <time.h> | 30 | #include "orecur.h" |
31 | 31 | ||
32 | #include <qshared.h> | 32 | /* OPIE */ |
33 | #include <opie2/otimezone.h> | ||
34 | #include <qpe/timeconversion.h> | ||
33 | 35 | ||
34 | #include <qtopia/timeconversion.h> | 36 | /* QT */ |
37 | #include <qshared.h> | ||
35 | 38 | ||
36 | #include <opie2/otimezone.h> | 39 | /* STD */ |
37 | #include <opie2/orecur.h> | 40 | #include <time.h> |
38 | 41 | ||
39 | namespace Opie { | 42 | namespace Opie { |
43 | |||
40 | struct ORecur::Data : public QShared { | 44 | struct ORecur::Data : public QShared { |
@@ -69,4 +73,4 @@ ORecur::ORecur( const QMap<int, QString>& map ) | |||
69 | { | 73 | { |
70 | ORecur(); | 74 | ORecur(); |
71 | fromMap( map ); | 75 | fromMap( map ); |
72 | } | 76 | } |
@@ -79,2 +83,4 @@ ORecur::ORecur( const ORecur& rec) | |||
79 | } | 83 | } |
84 | |||
85 | |||
80 | ORecur::~ORecur() { | 86 | ORecur::~ORecur() { |
@@ -85,2 +91,4 @@ ORecur::~ORecur() { | |||
85 | } | 91 | } |
92 | |||
93 | |||
86 | void ORecur::deref() { | 94 | void ORecur::deref() { |
@@ -91,2 +99,4 @@ void ORecur::deref() { | |||
91 | } | 99 | } |
100 | |||
101 | |||
92 | bool ORecur::operator==( const ORecur& )const { | 102 | bool ORecur::operator==( const ORecur& )const { |
@@ -94,2 +104,4 @@ bool ORecur::operator==( const ORecur& )const { | |||
94 | } | 104 | } |
105 | |||
106 | |||
95 | ORecur &ORecur::operator=( const ORecur& re) { | 107 | ORecur &ORecur::operator=( const ORecur& re) { |
@@ -103,2 +115,4 @@ ORecur &ORecur::operator=( const ORecur& re) { | |||
103 | } | 115 | } |
116 | |||
117 | |||
104 | bool ORecur::doesRecur()const { | 118 | bool ORecur::doesRecur()const { |
@@ -106,2 +120,4 @@ bool ORecur::doesRecur()const { | |||
106 | } | 120 | } |
121 | |||
122 | |||
107 | /* | 123 | /* |
@@ -120,2 +136,4 @@ bool ORecur::doesRecur( const QDate& date ) { | |||
120 | } | 136 | } |
137 | |||
138 | |||
121 | // FIXME unuglify! | 139 | // FIXME unuglify! |
@@ -131,2 +149,4 @@ bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { | |||
131 | } | 149 | } |
150 | |||
151 | |||
132 | bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { | 152 | bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { |
@@ -144,7 +164,7 @@ bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { | |||
144 | if (hasEndDate() && endDate() < from) | 164 | if (hasEndDate() && endDate() < from) |
145 | return FALSE; | 165 | return FALSE; |
146 | 166 | ||
147 | if (start() >= from ) { | 167 | if (start() >= from ) { |
148 | next = start(); | 168 | next = start(); |
149 | return TRUE; | 169 | return TRUE; |
150 | } | 170 | } |
@@ -152,253 +172,255 @@ bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { | |||
152 | switch ( type() ) { | 172 | switch ( type() ) { |
153 | case Weekly: | 173 | case Weekly: |
154 | /* weekly is just daily by 7 */ | 174 | /* weekly is just daily by 7 */ |
155 | /* first convert the repeatPattern.Days() mask to the next | 175 | /* first convert the repeatPattern.Days() mask to the next |
156 | day of week valid after from */ | 176 | day of week valid after from */ |
157 | dayOfWeek = from.dayOfWeek(); | 177 | dayOfWeek = from.dayOfWeek(); |
158 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ | 178 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ |
159 | 179 | ||
160 | /* this is done in case freq > 1 and from in week not | 180 | /* this is done in case freq > 1 and from in week not |
161 | for this round */ | 181 | for this round */ |
162 | // firstOfWeek = 0; this is already done at decl. | 182 | // firstOfWeek = 0; this is already done at decl. |
163 | while(!((1 << firstOfWeek) & days() )) | 183 | while(!((1 << firstOfWeek) & days() )) |
164 | firstOfWeek++; | 184 | firstOfWeek++; |
165 | 185 | ||
166 | /* there is at least one 'day', or there would be no event */ | 186 | /* there is at least one 'day', or there would be no event */ |
167 | while(!((1 << (dayOfWeek % 7)) & days() )) | 187 | while(!((1 << (dayOfWeek % 7)) & days() )) |
168 | dayOfWeek++; | 188 | dayOfWeek++; |
169 | 189 | ||
170 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ | 190 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ |
171 | dayOfWeek -= start().dayOfWeek() -1; | 191 | dayOfWeek -= start().dayOfWeek() -1; |
172 | 192 | ||
173 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ | 193 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ |
174 | firstOfWeek -= start().dayOfWeek() -1; | 194 | firstOfWeek -= start().dayOfWeek() -1; |
175 | 195 | ||
176 | // dayOfWeek may be negitive now | 196 | // dayOfWeek may be negitive now |
177 | // day of week is number of days to add to start day | 197 | // day of week is number of days to add to start day |
178 | 198 | ||
179 | freq *= 7; | 199 | freq *= 7; |
180 | // FALL-THROUGH !!!!! | 200 | // FALL-THROUGH !!!!! |
181 | case Daily: | 201 | case Daily: |
182 | // the add is for the possible fall through from weekly */ | 202 | // the add is for the possible fall through from weekly */ |
183 | if(start().addDays(dayOfWeek) > from) { | 203 | if(start().addDays(dayOfWeek) > from) { |
184 | /* first week exception */ | 204 | /* first week exception */ |
185 | next = QDate(start().addDays(dayOfWeek) ); | 205 | next = QDate(start().addDays(dayOfWeek) ); |
186 | if ((next > endDate()) | 206 | if ((next > endDate()) |
187 | && hasEndDate() ) | 207 | && hasEndDate() ) |
188 | return FALSE; | 208 | return FALSE; |
189 | return TRUE; | 209 | return TRUE; |
190 | } | 210 | } |
191 | /* if from is middle of a non-week */ | 211 | /* if from is middle of a non-week */ |
192 | 212 | ||
193 | diff = start().addDays(dayOfWeek).daysTo(from) % freq; | 213 | diff = start().addDays(dayOfWeek).daysTo(from) % freq; |
194 | diff2 = start().addDays(firstOfWeek).daysTo(from) % freq; | 214 | diff2 = start().addDays(firstOfWeek).daysTo(from) % freq; |
195 | 215 | ||
196 | if(diff != 0) | 216 | if(diff != 0) |
197 | diff = freq - diff; | 217 | diff = freq - diff; |
198 | if(diff2 != 0) | 218 | if(diff2 != 0) |
199 | diff2 = freq - diff2; | 219 | diff2 = freq - diff2; |
200 | diff = QMIN(diff, diff2); | 220 | diff = QMIN(diff, diff2); |
201 | 221 | ||
202 | next = QDate(from.addDays(diff)); | 222 | next = QDate(from.addDays(diff)); |
203 | if ( (next > endDate()) | 223 | if ( (next > endDate()) |
204 | && hasEndDate() ) | 224 | && hasEndDate() ) |
205 | return FALSE; | 225 | return FALSE; |
206 | return TRUE; | 226 | return TRUE; |
207 | case MonthlyDay: | 227 | case MonthlyDay: |
208 | iday = from.day(); | 228 | iday = from.day(); |
209 | iyear = from.year(); | 229 | iyear = from.year(); |
210 | imonth = from.month(); | 230 | imonth = from.month(); |
211 | /* find equivelent day of month for this month */ | 231 | /* find equivelent day of month for this month */ |
212 | dayOfWeek = start().dayOfWeek(); | 232 | dayOfWeek = start().dayOfWeek(); |
213 | weekOfMonth = (start().day() - 1) / 7; | 233 | weekOfMonth = (start().day() - 1) / 7; |
214 | 234 | ||
215 | /* work out when the next valid month is */ | 235 | /* work out when the next valid month is */ |
216 | a = from.year() - start().year(); | 236 | a = from.year() - start().year(); |
217 | a *= 12; | 237 | a *= 12; |
218 | a = a + (imonth - start().month()); | 238 | a = a + (imonth - start().month()); |
219 | /* a is e.start()monthsFrom(from); */ | 239 | /* a is e.start()monthsFrom(from); */ |
220 | if(a % freq) { | 240 | if(a % freq) { |
221 | a = freq - (a % freq); | 241 | a = freq - (a % freq); |
222 | imonth = from.month() + a; | 242 | imonth = from.month() + a; |
223 | if (imonth > 12) { | 243 | if (imonth > 12) { |
224 | imonth--; | 244 | imonth--; |
225 | iyear += imonth / 12; | 245 | iyear += imonth / 12; |
226 | imonth = imonth % 12; | 246 | imonth = imonth % 12; |
227 | imonth++; | 247 | imonth++; |
228 | } | 248 | } |
229 | } | 249 | } |
230 | /* imonth is now the first month after or on | 250 | /* imonth is now the first month after or on |
231 | from that matches the frequency given */ | 251 | from that matches the frequency given */ |
232 | 252 | ||
233 | /* find for this month */ | 253 | /* find for this month */ |
234 | tmpDate = QDate( iyear, imonth, 1 ); | 254 | tmpDate = QDate( iyear, imonth, 1 ); |
235 | 255 | ||
236 | iday = 1; | 256 | iday = 1; |
237 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; | 257 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; |
238 | iday += 7 * weekOfMonth; | 258 | iday += 7 * weekOfMonth; |
239 | while (iday > tmpDate.daysInMonth()) { | 259 | while (iday > tmpDate.daysInMonth()) { |
240 | imonth += freq; | 260 | imonth += freq; |
241 | if (imonth > 12) { | 261 | if (imonth > 12) { |
242 | imonth--; | 262 | imonth--; |
243 | iyear += imonth / 12; | 263 | iyear += imonth / 12; |
244 | imonth = imonth % 12; | 264 | imonth = imonth % 12; |
245 | imonth++; | 265 | imonth++; |
246 | } | 266 | } |
247 | tmpDate = QDate( iyear, imonth, 1 ); | 267 | tmpDate = QDate( iyear, imonth, 1 ); |
248 | /* these loops could go for a while, check end case now */ | 268 | /* these loops could go for a while, check end case now */ |
249 | if ((tmpDate > endDate()) && hasEndDate() ) | 269 | if ((tmpDate > endDate()) && hasEndDate() ) |
250 | return FALSE; | 270 | return FALSE; |
251 | iday = 1; | 271 | iday = 1; |
252 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; | 272 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; |
253 | iday += 7 * weekOfMonth; | 273 | iday += 7 * weekOfMonth; |
254 | } | 274 | } |
255 | tmpDate = QDate(iyear, imonth, iday); | 275 | tmpDate = QDate(iyear, imonth, iday); |
256 | 276 | ||
257 | if (tmpDate >= from) { | 277 | if (tmpDate >= from) { |
258 | next = tmpDate; | 278 | next = tmpDate; |
259 | if ((next > endDate() ) && hasEndDate() ) | 279 | if ((next > endDate() ) && hasEndDate() ) |
260 | return FALSE; | 280 | return FALSE; |
261 | return TRUE; | 281 | return TRUE; |
262 | } | 282 | } |
263 | 283 | ||
264 | /* need to find the next iteration */ | 284 | /* need to find the next iteration */ |
265 | do { | 285 | do { |
266 | imonth += freq; | 286 | imonth += freq; |
267 | if (imonth > 12) { | 287 | if (imonth > 12) { |
268 | imonth--; | 288 | imonth--; |
269 | iyear += imonth / 12; | 289 | iyear += imonth / 12; |
270 | imonth = imonth % 12; | 290 | imonth = imonth % 12; |
271 | imonth++; | 291 | imonth++; |
272 | } | 292 | } |
273 | tmpDate = QDate( iyear, imonth, 1 ); | 293 | tmpDate = QDate( iyear, imonth, 1 ); |
274 | /* these loops could go for a while, check end case now */ | 294 | /* these loops could go for a while, check end case now */ |
275 | if ((tmpDate > endDate()) && hasEndDate() ) | 295 | if ((tmpDate > endDate()) && hasEndDate() ) |
276 | return FALSE; | 296 | return FALSE; |
277 | iday = 1; | 297 | iday = 1; |
278 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; | 298 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; |
279 | iday += 7 * weekOfMonth; | 299 | iday += 7 * weekOfMonth; |
280 | } while (iday > tmpDate.daysInMonth()); | 300 | } while (iday > tmpDate.daysInMonth()); |
281 | tmpDate = QDate(iyear, imonth, iday); | 301 | tmpDate = QDate(iyear, imonth, iday); |
282 | 302 | ||
283 | next = tmpDate; | 303 | next = tmpDate; |
284 | if ((next > endDate()) && hasEndDate() ) | 304 | if ((next > endDate()) && hasEndDate() ) |
285 | return FALSE; | 305 | return FALSE; |
286 | return TRUE; | 306 | return TRUE; |
287 | case MonthlyDate: | 307 | case MonthlyDate: |
288 | iday = start().day(); | 308 | iday = start().day(); |
289 | iyear = from.year(); | 309 | iyear = from.year(); |
290 | imonth = from.month(); | 310 | imonth = from.month(); |
291 | 311 | ||
292 | a = from.year() - start().year(); | 312 | a = from.year() - start().year(); |
293 | a *= 12; | 313 | a *= 12; |
294 | a = a + (imonth - start().month()); | 314 | a = a + (imonth - start().month()); |
295 | /* a is e.start()monthsFrom(from); */ | 315 | /* a is e.start()monthsFrom(from); */ |
296 | if(a % freq) { | 316 | if(a % freq) { |
297 | a = freq - (a % freq); | 317 | a = freq - (a % freq); |
298 | imonth = from.month() + a; | 318 | imonth = from.month() + a; |
299 | if (imonth > 12) { | 319 | if (imonth > 12) { |
300 | imonth--; | 320 | imonth--; |
301 | iyear += imonth / 12; | 321 | iyear += imonth / 12; |
302 | imonth = imonth % 12; | 322 | imonth = imonth % 12; |
303 | imonth++; | 323 | imonth++; |
304 | } | 324 | } |
305 | } | 325 | } |
306 | /* imonth is now the first month after or on | 326 | /* imonth is now the first month after or on |
307 | from that matches the frequencey given */ | 327 | from that matches the frequencey given */ |
308 | 328 | ||
309 | /* this could go for a while, worse case, 4*12 iterations, probably */ | 329 | /* this could go for a while, worse case, 4*12 iterations, probably */ |
310 | while(!QDate::isValid(iyear, imonth, iday) ) { | 330 | while(!QDate::isValid(iyear, imonth, iday) ) { |
311 | imonth += freq; | 331 | imonth += freq; |
312 | if (imonth > 12) { | 332 | if (imonth > 12) { |
313 | imonth--; | 333 | imonth--; |
314 | iyear += imonth / 12; | 334 | iyear += imonth / 12; |
315 | imonth = imonth % 12; | 335 | imonth = imonth % 12; |
316 | imonth++; | 336 | imonth++; |
317 | } | 337 | } |
318 | /* these loops could go for a while, check end case now */ | 338 | /* these loops could go for a while, check end case now */ |
319 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) | 339 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) |
320 | return FALSE; | 340 | return FALSE; |
321 | } | 341 | } |
322 | 342 | ||
323 | if(QDate(iyear, imonth, iday) >= from) { | 343 | if(QDate(iyear, imonth, iday) >= from) { |
324 | /* done */ | 344 | /* done */ |
325 | next = QDate(iyear, imonth, iday); | 345 | next = QDate(iyear, imonth, iday); |
326 | if ((next > endDate()) && hasEndDate() ) | 346 | if ((next > endDate()) && hasEndDate() ) |
327 | return FALSE; | 347 | return FALSE; |
328 | return TRUE; | 348 | return TRUE; |
329 | } | 349 | } |
330 | 350 | ||
331 | /* ok, need to cycle */ | 351 | /* ok, need to cycle */ |
332 | imonth += freq; | 352 | imonth += freq; |
333 | imonth--; | 353 | imonth--; |
334 | iyear += imonth / 12; | 354 | iyear += imonth / 12; |
335 | imonth = imonth % 12; | 355 | imonth = imonth % 12; |
336 | imonth++; | 356 | imonth++; |
337 | 357 | ||
338 | while(!QDate::isValid(iyear, imonth, iday) ) { | 358 | while(!QDate::isValid(iyear, imonth, iday) ) { |
339 | imonth += freq; | 359 | imonth += freq; |
340 | imonth--; | 360 | imonth--; |
341 | iyear += imonth / 12; | 361 | iyear += imonth / 12; |
342 | imonth = imonth % 12; | 362 | imonth = imonth % 12; |
343 | imonth++; | 363 | imonth++; |
344 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) | 364 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) |
345 | return FALSE; | 365 | return FALSE; |
346 | } | 366 | } |
347 | 367 | ||
348 | next = QDate(iyear, imonth, iday); | 368 | next = QDate(iyear, imonth, iday); |
349 | if ((next > endDate()) && hasEndDate() ) | 369 | if ((next > endDate()) && hasEndDate() ) |
350 | return FALSE; | 370 | return FALSE; |
351 | return TRUE; | 371 | return TRUE; |
352 | case Yearly: | 372 | case Yearly: |
353 | iday = start().day(); | 373 | iday = start().day(); |
354 | imonth = start().month(); | 374 | imonth = start().month(); |
355 | iyear = from.year(); // after all, we want to start in this year | 375 | iyear = from.year(); // after all, we want to start in this year |
356 | 376 | ||
357 | diff = 1; | 377 | diff = 1; |
358 | if(imonth == 2 && iday > 28) { | 378 | if(imonth == 2 && iday > 28) { |
359 | /* leap year, and it counts, calculate actual frequency */ | 379 | /* leap year, and it counts, calculate actual frequency */ |
360 | if(freq % 4) | 380 | if(freq % 4) |
361 | if (freq % 2) | 381 | if (freq % 2) |
362 | freq = freq * 4; | 382 | freq = freq * 4; |
363 | else | 383 | else |
364 | freq = freq * 2; | 384 | freq = freq * 2; |
365 | /* else divides by 4 already, leave freq alone */ | 385 | /* else divides by 4 already, leave freq alone */ |
366 | diff = 4; | 386 | diff = 4; |
367 | } | 387 | } |
368 | 388 | ||
369 | a = from.year() - start().year(); | 389 | a = from.year() - start().year(); |
370 | if(a % freq) { | 390 | if(a % freq) { |
371 | a = freq - (a % freq); | 391 | a = freq - (a % freq); |
372 | iyear = iyear + a; | 392 | iyear = iyear + a; |
373 | } | 393 | } |
374 | 394 | ||
375 | /* under the assumption we won't hit one of the special not-leap years twice */ | 395 | /* under the assumption we won't hit one of the special not-leap years twice */ |
376 | if(!QDate::isValid(iyear, imonth, iday)) { | 396 | if(!QDate::isValid(iyear, imonth, iday)) { |
377 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ | 397 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ |
378 | iyear += freq; | 398 | iyear += freq; |
379 | } | 399 | } |
380 | 400 | ||
381 | if(QDate(iyear, imonth, iday) >= from) { | 401 | if(QDate(iyear, imonth, iday) >= from) { |
382 | next = QDate(iyear, imonth, iday); | 402 | next = QDate(iyear, imonth, iday); |
383 | 403 | ||
384 | if ((next > endDate()) && hasEndDate() ) | 404 | if ((next > endDate()) && hasEndDate() ) |
385 | return FALSE; | 405 | return FALSE; |
386 | return TRUE; | 406 | return TRUE; |
387 | } | 407 | } |
388 | /* iyear == from.year(), need to advance again */ | 408 | /* iyear == from.year(), need to advance again */ |
389 | iyear += freq; | 409 | iyear += freq; |
390 | /* under the assumption we won't hit one of the special not-leap years twice */ | 410 | /* under the assumption we won't hit one of the special not-leap years twice */ |
391 | if(!QDate::isValid(iyear, imonth, iday)) { | 411 | if(!QDate::isValid(iyear, imonth, iday)) { |
392 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ | 412 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ |
393 | iyear += freq; | 413 | iyear += freq; |
394 | } | 414 | } |
395 | 415 | ||
396 | next = QDate(iyear, imonth, iday); | 416 | next = QDate(iyear, imonth, iday); |
397 | if ((next > endDate()) && hasEndDate() ) | 417 | if ((next > endDate()) && hasEndDate() ) |
398 | return FALSE; | 418 | return FALSE; |
399 | return TRUE; | 419 | return TRUE; |
400 | default: | 420 | default: |
401 | return FALSE; | 421 | return FALSE; |
402 | } | 422 | } |
403 | } | 423 | } |
424 | |||
425 | |||
404 | ORecur::RepeatType ORecur::type()const{ | 426 | ORecur::RepeatType ORecur::type()const{ |
@@ -406,2 +428,4 @@ ORecur::RepeatType ORecur::type()const{ | |||
406 | } | 428 | } |
429 | |||
430 | |||
407 | int ORecur::frequency()const { | 431 | int ORecur::frequency()const { |
@@ -409,2 +433,4 @@ int ORecur::frequency()const { | |||
409 | } | 433 | } |
434 | |||
435 | |||
410 | int ORecur::position()const { | 436 | int ORecur::position()const { |
@@ -412,2 +438,4 @@ int ORecur::position()const { | |||
412 | } | 438 | } |
439 | |||
440 | |||
413 | char ORecur::days() const{ | 441 | char ORecur::days() const{ |
@@ -415,2 +443,4 @@ char ORecur::days() const{ | |||
415 | } | 443 | } |
444 | |||
445 | |||
416 | bool ORecur::hasEndDate()const { | 446 | bool ORecur::hasEndDate()const { |
@@ -418,2 +448,4 @@ bool ORecur::hasEndDate()const { | |||
418 | } | 448 | } |
449 | |||
450 | |||
419 | QDate ORecur::endDate()const { | 451 | QDate ORecur::endDate()const { |
@@ -421,2 +453,4 @@ QDate ORecur::endDate()const { | |||
421 | } | 453 | } |
454 | |||
455 | |||
422 | QDate ORecur::start()const{ | 456 | QDate ORecur::start()const{ |
@@ -424,2 +458,4 @@ QDate ORecur::start()const{ | |||
424 | } | 458 | } |
459 | |||
460 | |||
425 | QDateTime ORecur::createdDateTime()const { | 461 | QDateTime ORecur::createdDateTime()const { |
@@ -427,2 +463,4 @@ QDateTime ORecur::createdDateTime()const { | |||
427 | } | 463 | } |
464 | |||
465 | |||
428 | int ORecur::repetition()const { | 466 | int ORecur::repetition()const { |
@@ -430,2 +468,4 @@ int ORecur::repetition()const { | |||
430 | } | 468 | } |
469 | |||
470 | |||
431 | QString ORecur::service()const { | 471 | QString ORecur::service()const { |
@@ -433,2 +473,4 @@ QString ORecur::service()const { | |||
433 | } | 473 | } |
474 | |||
475 | |||
434 | ORecur::ExceptionList& ORecur::exceptions() { | 476 | ORecur::ExceptionList& ORecur::exceptions() { |
@@ -436,2 +478,4 @@ ORecur::ExceptionList& ORecur::exceptions() { | |||
436 | } | 478 | } |
479 | |||
480 | |||
437 | void ORecur::setType( const RepeatType& z) { | 481 | void ORecur::setType( const RepeatType& z) { |
@@ -440,2 +484,4 @@ void ORecur::setType( const RepeatType& z) { | |||
440 | } | 484 | } |
485 | |||
486 | |||
441 | void ORecur::setFrequency( int freq ) { | 487 | void ORecur::setFrequency( int freq ) { |
@@ -444,2 +490,4 @@ void ORecur::setFrequency( int freq ) { | |||
444 | } | 490 | } |
491 | |||
492 | |||
445 | void ORecur::setPosition( int pos ) { | 493 | void ORecur::setPosition( int pos ) { |
@@ -448,2 +496,4 @@ void ORecur::setPosition( int pos ) { | |||
448 | } | 496 | } |
497 | |||
498 | |||
449 | void ORecur::setDays( char c ) { | 499 | void ORecur::setDays( char c ) { |
@@ -452,2 +502,4 @@ void ORecur::setDays( char c ) { | |||
452 | } | 502 | } |
503 | |||
504 | |||
453 | void ORecur::setEndDate( const QDate& dt) { | 505 | void ORecur::setEndDate( const QDate& dt) { |
@@ -456,2 +508,4 @@ void ORecur::setEndDate( const QDate& dt) { | |||
456 | } | 508 | } |
509 | |||
510 | |||
457 | void ORecur::setCreatedDateTime( const QDateTime& t) { | 511 | void ORecur::setCreatedDateTime( const QDateTime& t) { |
@@ -460,2 +514,4 @@ void ORecur::setCreatedDateTime( const QDateTime& t) { | |||
460 | } | 514 | } |
515 | |||
516 | |||
461 | void ORecur::setHasEndDate( bool b) { | 517 | void ORecur::setHasEndDate( bool b) { |
@@ -464,2 +520,4 @@ void ORecur::setHasEndDate( bool b) { | |||
464 | } | 520 | } |
521 | |||
522 | |||
465 | void ORecur::setRepitition( int rep ) { | 523 | void ORecur::setRepitition( int rep ) { |
@@ -468,2 +526,4 @@ void ORecur::setRepitition( int rep ) { | |||
468 | } | 526 | } |
527 | |||
528 | |||
469 | void ORecur::setService( const QString& app ) { | 529 | void ORecur::setService( const QString& app ) { |
@@ -472,2 +532,4 @@ void ORecur::setService( const QString& app ) { | |||
472 | } | 532 | } |
533 | |||
534 | |||
473 | void ORecur::setStart( const QDate& dt ) { | 535 | void ORecur::setStart( const QDate& dt ) { |
@@ -476,2 +538,4 @@ void ORecur::setStart( const QDate& dt ) { | |||
476 | } | 538 | } |
539 | |||
540 | |||
477 | void ORecur::checkOrModify() { | 541 | void ORecur::checkOrModify() { |
@@ -494,2 +558,4 @@ void ORecur::checkOrModify() { | |||
494 | } | 558 | } |
559 | |||
560 | |||
495 | QString ORecur::toString()const { | 561 | QString ORecur::toString()const { |
@@ -502,5 +568,5 @@ QString ORecur::toString()const { | |||
502 | if (data->days > 0 ) | 568 | if (data->days > 0 ) |
503 | buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; | 569 | buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; |
504 | if ( data->pos != 0 ) | 570 | if ( data->pos != 0 ) |
505 | buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; | 571 | buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; |
506 | 572 | ||
@@ -509,5 +575,5 @@ QString ORecur::toString()const { | |||
509 | if ( data->hasEnd ) | 575 | if ( data->hasEnd ) |
510 | buf += " enddt=\"" | 576 | buf += " enddt=\"" |
511 | + recMap[ORecur::EndDate] | 577 | + recMap[ORecur::EndDate] |
512 | + "\""; | 578 | + "\""; |
513 | buf += " created=\"" + recMap[ORecur::Created] + "\""; | 579 | buf += " created=\"" + recMap[ORecur::Created] + "\""; |
@@ -524,26 +590,26 @@ QString ORecur::rTypeString() const | |||
524 | { | 590 | { |
525 | QString retString; | 591 | QString retString; |
526 | switch ( data->type ) { | 592 | switch ( data->type ) { |
527 | case ORecur::Daily: | 593 | case ORecur::Daily: |
528 | retString = "Daily"; | 594 | retString = "Daily"; |
529 | break; | 595 | break; |
530 | case ORecur::Weekly: | 596 | case ORecur::Weekly: |
531 | retString = "Weekly"; | 597 | retString = "Weekly"; |
532 | break; | 598 | break; |
533 | case ORecur::MonthlyDay: | 599 | case ORecur::MonthlyDay: |
534 | retString = "MonthlyDay"; | 600 | retString = "MonthlyDay"; |
535 | break; | 601 | break; |
536 | case ORecur::MonthlyDate: | 602 | case ORecur::MonthlyDate: |
537 | retString = "MonthlyDate"; | 603 | retString = "MonthlyDate"; |
538 | break; | 604 | break; |
539 | case ORecur::Yearly: | 605 | case ORecur::Yearly: |
540 | retString = "Yearly"; | 606 | retString = "Yearly"; |
541 | break; | 607 | break; |
542 | default: | 608 | default: |
543 | retString = "NoRepeat"; | 609 | retString = "NoRepeat"; |
544 | break; | 610 | break; |
545 | 611 | ||
546 | } | 612 | } |
547 | 613 | ||
548 | return retString; | 614 | return retString; |
549 | } | 615 | } |
@@ -552,12 +618,12 @@ QMap<QString, ORecur::RepeatType> ORecur::rTypeValueConvertMap() const | |||
552 | { | 618 | { |
553 | QMap<QString, RepeatType> convertMap; | 619 | QMap<QString, RepeatType> convertMap; |
554 | 620 | ||
555 | convertMap.insert( QString( "Daily" ), ORecur::Daily ); | 621 | convertMap.insert( QString( "Daily" ), ORecur::Daily ); |
556 | convertMap.insert( QString( "Weekly" ), ORecur::Weekly ); | 622 | convertMap.insert( QString( "Weekly" ), ORecur::Weekly ); |
557 | convertMap.insert( QString( "MonthlyDay" ), ORecur::MonthlyDay ); | 623 | convertMap.insert( QString( "MonthlyDay" ), ORecur::MonthlyDay ); |
558 | convertMap.insert( QString( "MonthlyDate" ), ORecur::MonthlyDate ); | 624 | convertMap.insert( QString( "MonthlyDate" ), ORecur::MonthlyDate ); |
559 | convertMap.insert( QString( "Yearly" ), ORecur::Yearly ); | 625 | convertMap.insert( QString( "Yearly" ), ORecur::Yearly ); |
560 | convertMap.insert( QString( "NoRepeat" ), ORecur::NoRepeat ); | 626 | convertMap.insert( QString( "NoRepeat" ), ORecur::NoRepeat ); |
561 | 627 | ||
562 | return convertMap; | 628 | return convertMap; |
563 | } | 629 | } |
@@ -567,30 +633,30 @@ QMap<int, QString> ORecur::toMap() const | |||
567 | { | 633 | { |
568 | QMap<int, QString> retMap; | 634 | QMap<int, QString> retMap; |
569 | 635 | ||
570 | retMap.insert( ORecur::RType, rTypeString() ); | 636 | retMap.insert( ORecur::RType, rTypeString() ); |
571 | retMap.insert( ORecur::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); | 637 | retMap.insert( ORecur::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); |
572 | retMap.insert( ORecur::RPosition, QString::number(data->pos ) ); | 638 | retMap.insert( ORecur::RPosition, QString::number(data->pos ) ); |
573 | retMap.insert( ORecur::RFreq, QString::number( data->freq ) ); | 639 | retMap.insert( ORecur::RFreq, QString::number( data->freq ) ); |
574 | retMap.insert( ORecur::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); | 640 | retMap.insert( ORecur::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); |
575 | if( data -> hasEnd ) | 641 | if( data -> hasEnd ) |
576 | retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); | 642 | retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); |
577 | retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); | 643 | retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); |
578 | 644 | ||
579 | if ( data->list.isEmpty() ) return retMap; | 645 | if ( data->list.isEmpty() ) return retMap; |
580 | 646 | ||
581 | // save exceptions list here!! | 647 | // save exceptions list here!! |
582 | ExceptionList::ConstIterator it; | 648 | ExceptionList::ConstIterator it; |
583 | ExceptionList list = data->list; | 649 | ExceptionList list = data->list; |
584 | QString exceptBuf; | 650 | QString exceptBuf; |
585 | QDate date; | 651 | QDate date; |
586 | for ( it = list.begin(); it != list.end(); ++it ) { | 652 | for ( it = list.begin(); it != list.end(); ++it ) { |
587 | date = (*it); | 653 | date = (*it); |
588 | if ( it != list.begin() ) exceptBuf += " "; | 654 | if ( it != list.begin() ) exceptBuf += " "; |
589 | 655 | ||
590 | exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); | 656 | exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); |
591 | } | 657 | } |
592 | 658 | ||
593 | retMap.insert( ORecur::Exceptions, exceptBuf ); | 659 | retMap.insert( ORecur::Exceptions, exceptBuf ); |
594 | 660 | ||
595 | return retMap; | 661 | return retMap; |
596 | } | 662 | } |
@@ -599,27 +665,27 @@ void ORecur::fromMap( const QMap<int, QString>& map ) | |||
599 | { | 665 | { |
600 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); | 666 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); |
601 | 667 | ||
602 | data -> type = repTypeMap[ map [ORecur::RType] ]; | 668 | data -> type = repTypeMap[ map [ORecur::RType] ]; |
603 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); | 669 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); |
604 | data -> pos = map[ ORecur::RPosition ].toInt(); | 670 | data -> pos = map[ ORecur::RPosition ].toInt(); |
605 | data -> freq = map[ ORecur::RFreq ].toInt(); | 671 | data -> freq = map[ ORecur::RFreq ].toInt(); |
606 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; | 672 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; |
607 | OTimeZone utc = OTimeZone::utc(); | 673 | OTimeZone utc = OTimeZone::utc(); |
608 | if ( data -> hasEnd ){ | 674 | if ( data -> hasEnd ){ |
609 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); | 675 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); |
610 | } | 676 | } |
611 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); | 677 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); |
612 | 678 | ||
613 | #if 0 | 679 | #if 0 |
614 | // FIXME: Exceptions currently not supported... | 680 | // FIXME: Exceptions currently not supported... |
615 | // Convert the list of exceptions from QString into ExceptionList | 681 | // Convert the list of exceptions from QString into ExceptionList |
616 | data -> list.clear(); | 682 | data -> list.clear(); |
617 | QString exceptStr = map[ ORecur::Exceptions ]; | 683 | QString exceptStr = map[ ORecur::Exceptions ]; |
618 | QStringList exceptList = QStringList::split( " ", exceptStr ); | 684 | QStringList exceptList = QStringList::split( " ", exceptStr ); |
619 | ... | 685 | ... |
620 | #endif | 686 | #endif |
621 | 687 | ||
622 | 688 | ||
623 | } | 689 | } |
624 | 690 | ||
625 | } \ No newline at end of file | 691 | } |
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h index 60508f5..7808897 100644 --- a/libopie2/opiepim/core/orecur.h +++ b/libopie2/opiepim/core/orecur.h | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #ifndef OPIE_RECUR_H | 30 | #ifndef ORECUR_H |
31 | #define OPIE_RECUR_H | 31 | #define ORECUR_H |
32 | |||
33 | #include <sys/types.h> | ||
34 | 32 | ||
33 | /* QT */ | ||
35 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
@@ -38,2 +37,4 @@ | |||
38 | 37 | ||
38 | /* STD */ | ||
39 | #include <sys/types.h> | ||
39 | 40 | ||
@@ -45,3 +46,4 @@ namespace Opie { | |||
45 | class ORecur { | 46 | class ORecur { |
46 | public: | 47 | |
48 | public: | ||
47 | typedef QValueList<QDate> ExceptionList; | 49 | typedef QValueList<QDate> ExceptionList; |
@@ -52,3 +54,3 @@ public: | |||
52 | enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, | 54 | enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, |
53 | EndDate, Created, Exceptions }; | 55 | EndDate, Created, Exceptions }; |
54 | 56 | ||
@@ -116,3 +118,4 @@ public: | |||
116 | QString toString()const; | 118 | QString toString()const; |
117 | private: | 119 | |
120 | private: | ||
118 | bool p_nextOccurrence( const QDate& from, QDate& next ); | 121 | bool p_nextOccurrence( const QDate& from, QDate& next ); |
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h index 17d9961..58cbfeb 100644 --- a/libopie2/opiepim/core/otemplatebase.h +++ b/libopie2/opiepim/core/otemplatebase.h | |||
@@ -28,9 +28,10 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIE_TEMPLATE_BASE_H | 29 | #ifndef OTEMPLATEBASE_H |
30 | #define OPIE_TEMPLATE_BASE_H | 30 | #define OTEMPLATEBASE_H |
31 | |||
32 | #include <qarray.h> | ||
33 | 31 | ||
32 | /* OPIE */ | ||
34 | #include <opie2/opimrecord.h> | 33 | #include <opie2/opimrecord.h> |
35 | 34 | ||
35 | /* QT */ | ||
36 | #include <qarray.h> | ||
36 | 37 | ||
diff --git a/libopie2/opiepim/core/otimezone.cpp b/libopie2/opiepim/core/otimezone.cpp index dab68af..e67715f 100644 --- a/libopie2/opiepim/core/otimezone.cpp +++ b/libopie2/opiepim/core/otimezone.cpp | |||
@@ -29,72 +29,86 @@ | |||
29 | 29 | ||
30 | #include "otimezone.h" | ||
31 | |||
32 | /* STD */ | ||
30 | #include <stdio.h> | 33 | #include <stdio.h> |
31 | #include <stdlib.h> | 34 | #include <stdlib.h> |
32 | |||
33 | #include <sys/types.h> | 35 | #include <sys/types.h> |
34 | 36 | ||
35 | #include <opie2/otimezone.h> | 37 | namespace Opie |
36 | 38 | { | |
37 | namespace Opie { | ||
38 | 39 | ||
39 | QDateTime utcTime( time_t t) { | 40 | QDateTime utcTime( time_t t ) |
40 | tm* broken = ::gmtime( &t ); | 41 | { |
41 | QDateTime ret; | 42 | tm * broken = ::gmtime( &t ); |
42 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); | 43 | QDateTime ret; |
43 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 44 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); |
44 | return ret; | 45 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
45 | } | 46 | return ret; |
46 | QDateTime utcTime( time_t t, const QString& zone) { | 47 | } |
47 | QCString org = ::getenv( "TZ" ); | 48 | QDateTime utcTime( time_t t, const QString& zone ) |
49 | { | ||
50 | QCString org = ::getenv( "TZ" ); | ||
48 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 51 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
49 | ::setenv( "TZ", zone.latin1(), true ); | ||
50 | ::tzset(); | ||
51 | 52 | ||
52 | tm* broken = ::localtime( &t ); | 53 | ::setenv( "TZ", zone.latin1(), true ); |
53 | ::setenv( "TZ", org, true ); | 54 | ::tzset(); |
55 | |||
56 | tm* broken = ::localtime( &t ); | ||
57 | ::setenv( "TZ", org, true ); | ||
54 | #else | 58 | #else |
55 | #warning "Need a replacement for MacOSX!!" | 59 | #warning "Need a replacement for MacOSX!!" |
56 | tm* broken = ::localtime( &t ); | 60 | |
61 | tm* broken = ::localtime( &t ); | ||
57 | #endif | 62 | #endif |
58 | 63 | ||
59 | QDateTime ret; | 64 | QDateTime ret; |
60 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); | 65 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); |
61 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 66 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
62 | 67 | ||
63 | return ret; | 68 | return ret; |
64 | } | 69 | } |
65 | time_t to_Time_t( const QDateTime& utc, const QString& str ) { | 70 | time_t to_Time_t( const QDateTime& utc, const QString& str ) |
66 | QDate d = utc.date(); | 71 | { |
67 | QTime t = utc.time(); | 72 | QDate d = utc.date(); |
68 | 73 | QTime t = utc.time(); | |
69 | tm broken; | 74 | |
70 | broken.tm_year = d.year() - 1900; | 75 | tm broken; |
71 | broken.tm_mon = d.month() - 1; | 76 | broken.tm_year = d.year() - 1900; |
72 | broken.tm_mday = d.day(); | 77 | broken.tm_mon = d.month() - 1; |
73 | broken.tm_hour = t.hour(); | 78 | broken.tm_mday = d.day(); |
74 | broken.tm_min = t.minute(); | 79 | broken.tm_hour = t.hour(); |
75 | broken.tm_sec = t.second(); | 80 | broken.tm_min = t.minute(); |
76 | 81 | broken.tm_sec = t.second(); | |
77 | QCString org = ::getenv( "TZ" ); | 82 | |
83 | QCString org = ::getenv( "TZ" ); | ||
78 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 84 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
79 | ::setenv( "TZ", str.latin1(), true ); | ||
80 | ::tzset(); | ||
81 | 85 | ||
82 | time_t ti = ::mktime( &broken ); | 86 | ::setenv( "TZ", str.latin1(), true ); |
83 | ::setenv( "TZ", org, true ); | 87 | ::tzset(); |
88 | |||
89 | time_t ti = ::mktime( &broken ); | ||
90 | ::setenv( "TZ", org, true ); | ||
84 | #else | 91 | #else |
85 | #warning "Need a replacement for MacOSX!!" | 92 | #warning "Need a replacement for MacOSX!!" |
86 | time_t ti = ::mktime( &broken ); | 93 | |
94 | time_t ti = ::mktime( &broken ); | ||
87 | #endif | 95 | #endif |
88 | return ti; | ||
89 | } | ||
90 | } | ||
91 | 96 | ||
92 | namespace Opie { | 97 | return ti; |
93 | OTimeZone::OTimeZone( const ZoneName& zone ) | ||
94 | : m_name(zone) { | ||
95 | } | 98 | } |
96 | OTimeZone::~OTimeZone() { | ||
97 | } | 99 | } |
98 | 100 | ||
99 | bool OTimeZone::isValid()const { | 101 | namespace Opie |
102 | { | ||
103 | OTimeZone::OTimeZone( const ZoneName& zone ) | ||
104 | : m_name( zone ) | ||
105 | {} | ||
106 | |||
107 | |||
108 | OTimeZone::~OTimeZone() | ||
109 | {} | ||
110 | |||
111 | |||
112 | bool OTimeZone::isValid() const | ||
113 | { | ||
100 | return !m_name.isEmpty(); | 114 | return !m_name.isEmpty(); |
@@ -106,14 +120,26 @@ bool OTimeZone::isValid()const { | |||
106 | */ | 120 | */ |
107 | QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt) { | 121 | QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt ) |
122 | { | ||
108 | return OTimeZone::current().toDateTime( dt, *this ); | 123 | return OTimeZone::current().toDateTime( dt, *this ); |
109 | } | 124 | } |
110 | QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) { | 125 | |
126 | |||
127 | QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) | ||
128 | { | ||
111 | return OTimeZone::utc().toDateTime( dt, *this ); | 129 | return OTimeZone::utc().toDateTime( dt, *this ); |
112 | } | 130 | } |
113 | QDateTime OTimeZone::fromUTCDateTime( time_t t) { | 131 | |
132 | |||
133 | QDateTime OTimeZone::fromUTCDateTime( time_t t ) | ||
134 | { | ||
114 | return utcTime( t ); | 135 | return utcTime( t ); |
115 | } | 136 | } |
116 | QDateTime OTimeZone::toDateTime( time_t t) { | 137 | |
138 | |||
139 | QDateTime OTimeZone::toDateTime( time_t t ) | ||
140 | { | ||
117 | return utcTime( t, m_name ); | 141 | return utcTime( t, m_name ); |
118 | } | 142 | } |
143 | |||
144 | |||
119 | /* | 145 | /* |
@@ -122,15 +148,25 @@ QDateTime OTimeZone::toDateTime( time_t t) { | |||
122 | */ | 148 | */ |
123 | QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) { | 149 | QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) |
150 | { | ||
124 | time_t utc = to_Time_t( dt, zone.m_name ); | 151 | time_t utc = to_Time_t( dt, zone.m_name ); |
125 | qWarning("%d %s", utc, zone.m_name.latin1() ); | 152 | qWarning( "%d %s", utc, zone.m_name.latin1() ); |
126 | return utcTime( utc, m_name ); | 153 | return utcTime( utc, m_name ); |
127 | } | 154 | } |
128 | time_t OTimeZone::fromDateTime( const QDateTime& time ) { | 155 | |
156 | |||
157 | time_t OTimeZone::fromDateTime( const QDateTime& time ) | ||
158 | { | ||
129 | return to_Time_t( time, m_name ); | 159 | return to_Time_t( time, m_name ); |
130 | } | 160 | } |
131 | time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) { | 161 | |
162 | |||
163 | time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) | ||
164 | { | ||
132 | return to_Time_t( time, "UTC" ); | 165 | return to_Time_t( time, "UTC" ); |
133 | } | 166 | } |
134 | OTimeZone OTimeZone::current() { | 167 | |
135 | QCString str = ::getenv("TZ"); | 168 | |
169 | OTimeZone OTimeZone::current() | ||
170 | { | ||
171 | QCString str = ::getenv( "TZ" ); | ||
136 | OTimeZone zone( str ); | 172 | OTimeZone zone( str ); |
@@ -138,6 +174,12 @@ OTimeZone OTimeZone::current() { | |||
138 | } | 174 | } |
139 | OTimeZone OTimeZone::utc() { | 175 | |
140 | return OTimeZone("UTC"); | 176 | |
177 | OTimeZone OTimeZone::utc() | ||
178 | { | ||
179 | return OTimeZone( "UTC" ); | ||
141 | } | 180 | } |
142 | QString OTimeZone::timeZone()const { | 181 | |
182 | |||
183 | QString OTimeZone::timeZone() const | ||
184 | { | ||
143 | return m_name; | 185 | return m_name; |
diff --git a/libopie2/opiepim/core/otimezone.h b/libopie2/opiepim/core/otimezone.h index 28ae6cb..f0b4022 100644 --- a/libopie2/opiepim/core/otimezone.h +++ b/libopie2/opiepim/core/otimezone.h | |||
@@ -29,8 +29,11 @@ | |||
29 | 29 | ||
30 | #ifndef OPIE_TIME_ZONE_H | 30 | #ifndef OTIMEZONE_H |
31 | #define OPIE_TIME_ZONE_H | 31 | #define OTIMEZONE_H |
32 | 32 | ||
33 | #include <time.h> | 33 | /* QT */ |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | 35 | ||
36 | /* STD */ | ||
37 | #include <time.h> | ||
38 | |||
36 | namespace Opie | 39 | namespace Opie |
@@ -44,2 +47,3 @@ namespace Opie | |||
44 | class OTimeZone { | 47 | class OTimeZone { |
48 | |||
45 | public: | 49 | public: |
@@ -93,3 +97,4 @@ class OTimeZone { | |||
93 | 97 | ||
94 | QString timeZone()const; | 98 | QString timeZone() const; |
99 | |||
95 | private: | 100 | private: |