summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-09 11:07:44 (UTC)
committer zautrix <zautrix>2004-08-09 11:07:44 (UTC)
commit2d3e20244a156485f6001aa82c4494dfce177b8f (patch) (unidiff)
treec5cc2cc6eaa79b6d6dd1c7dd27f29d3871d6a528
parentb51c65d86224ee7d77e672fcfba5ea92d55eed0e (diff)
downloadkdepimpi-2d3e20244a156485f6001aa82c4494dfce177b8f.zip
kdepimpi-2d3e20244a156485f6001aa82c4494dfce177b8f.tar.gz
kdepimpi-2d3e20244a156485f6001aa82c4494dfce177b8f.tar.bz2
minor fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--libkcal/phoneformat.cpp16
-rw-r--r--libkcal/sharpformat.cpp8
3 files changed, 23 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index cfaec5a..c1d07e4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,99 +1,99 @@
1############################################################################# 1#############################################################################
2# Makefile for building: kopi-desktop 2# Makefile for building: kopi-desktop
3# Generated by qmake (1.07a) (Qt 3.3.2) on: Sun Aug 8 12:23:00 2004 3# Generated by qmake (1.07a) (Qt 3.3.3) on: Mon Aug 9 12:10:32 2004
4# Project: kopi-desktop.pro 4# Project: kopi-desktop.pro
5# Template: subdirs 5# Template: subdirs
6# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro 6# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro
7############################################################################# 7#############################################################################
8 8
9 MAKEFILE =Makefile 9 MAKEFILE =Makefile
10 QMAKE =qmake 10 QMAKE =qmake
11DEL_FILE = rm -f 11DEL_FILE = rm -f
12CHK_DIR_EXISTS= test -d 12CHK_DIR_EXISTS= test -d
13MKDIR = mkdir -p 13MKDIR = mkdir -p
14INSTALL_FILE= 14INSTALL_FILE=
15INSTALL_DIR = 15INSTALL_DIR =
16 SUBTARGETS = \ 16 SUBTARGETS = \
17 sub-gammu-emb-common \ 17 sub-gammu-emb-common \
18 sub-libical \ 18 sub-libical \
19 sub-libkcal \ 19 sub-libkcal \
20 sub-microkde \ 20 sub-microkde \
21 sub-libkdepim \ 21 sub-libkdepim \
22 sub-kabc \ 22 sub-kabc \
23 sub-korganizer \ 23 sub-korganizer \
24 sub-kaddressbook \ 24 sub-kaddressbook \
25 sub-kabc-plugins-file \ 25 sub-kabc-plugins-file \
26 sub-kabc-plugins-dir 26 sub-kabc-plugins-dir
27 27
28first: all 28first: all
29 29
30all: Makefile $(SUBTARGETS) 30all: Makefile $(SUBTARGETS)
31 31
32gammu/emb/common/$(MAKEFILE): 32gammu/emb/common/$(MAKEFILE):
33 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" 33 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
34 cd gammu/emb/common && $(QMAKE) common.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 34 cd gammu/emb/common && $(QMAKE) common.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
35sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE 35sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
36 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) 36 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
37 37
38libical/$(MAKEFILE): 38libical/$(MAKEFILE):
39 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" 39 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
40 cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 40 cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
41sub-libical: libical/$(MAKEFILE) FORCE 41sub-libical: libical/$(MAKEFILE) FORCE
42 cd libical && $(MAKE) -f $(MAKEFILE) 42 cd libical && $(MAKE) -f $(MAKEFILE)
43 43
44libkcal/$(MAKEFILE): 44libkcal/$(MAKEFILE):
45 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" 45 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
46 cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 46 cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
47sub-libkcal: libkcal/$(MAKEFILE) FORCE 47sub-libkcal: libkcal/$(MAKEFILE) FORCE
48 cd libkcal && $(MAKE) -f $(MAKEFILE) 48 cd libkcal && $(MAKE) -f $(MAKEFILE)
49 49
50microkde/$(MAKEFILE): 50microkde/$(MAKEFILE):
51 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" 51 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
52 cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 52 cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
53sub-microkde: microkde/$(MAKEFILE) FORCE 53sub-microkde: microkde/$(MAKEFILE) FORCE
54 cd microkde && $(MAKE) -f $(MAKEFILE) 54 cd microkde && $(MAKE) -f $(MAKEFILE)
55 55
56libkdepim/$(MAKEFILE): 56libkdepim/$(MAKEFILE):
57 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" 57 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
58 cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 58 cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
59sub-libkdepim: libkdepim/$(MAKEFILE) FORCE 59sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
60 cd libkdepim && $(MAKE) -f $(MAKEFILE) 60 cd libkdepim && $(MAKE) -f $(MAKEFILE)
61 61
62kabc/$(MAKEFILE): 62kabc/$(MAKEFILE):
63 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" 63 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
64 cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 64 cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
65sub-kabc: kabc/$(MAKEFILE) FORCE 65sub-kabc: kabc/$(MAKEFILE) FORCE
66 cd kabc && $(MAKE) -f $(MAKEFILE) 66 cd kabc && $(MAKE) -f $(MAKEFILE)
67 67
68korganizer/$(MAKEFILE): 68korganizer/$(MAKEFILE):
69 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" 69 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
70 cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 70 cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
71sub-korganizer: korganizer/$(MAKEFILE) FORCE 71sub-korganizer: korganizer/$(MAKEFILE) FORCE
72 cd korganizer && $(MAKE) -f $(MAKEFILE) 72 cd korganizer && $(MAKE) -f $(MAKEFILE)
73 73
74kaddressbook/$(MAKEFILE): 74kaddressbook/$(MAKEFILE):
75 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" 75 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
76 cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 76 cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
77sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE 77sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
78 cd kaddressbook && $(MAKE) -f $(MAKEFILE) 78 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
79 79
80kabc/plugins/file/$(MAKEFILE): 80kabc/plugins/file/$(MAKEFILE):
81 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" 81 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
82 cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 82 cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
83sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE 83sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
84 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) 84 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
85 85
86kabc/plugins/dir/$(MAKEFILE): 86kabc/plugins/dir/$(MAKEFILE):
87 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" 87 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
88 cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) 88 cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
89sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE 89sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
90 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) 90 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
91 91
92Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf 92Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf
93 $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro 93 $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro
94qmake: qmake_all 94qmake: qmake_all
95 @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro 95 @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro
96 96
97all: $(SUBTARGETS) 97all: $(SUBTARGETS)
98qmake_all: gammu/emb/common/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) 98qmake_all: gammu/emb/common/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE)
99 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 99 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 7e1c9cd..94744fb 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -77,194 +77,200 @@ public:
77 int j; 77 int j;
78 GSM_DateTime* dtp; 78 GSM_DateTime* dtp;
79 bool alarm = false; 79 bool alarm = false;
80 QDateTime alarmDt; 80 QDateTime alarmDt;
81 GSM_Category Category; 81 GSM_Category Category;
82 int error; 82 int error;
83 QString completedString = "no"; 83 QString completedString = "no";
84 for (j=0;j<ToDo->EntriesNum;j++) { 84 for (j=0;j<ToDo->EntriesNum;j++) {
85 85
86 //qDebug(" for todo %d",ToDo->Location ); 86 //qDebug(" for todo %d",ToDo->Location );
87 switch (ToDo->Entries[j].EntryType) { 87 switch (ToDo->Entries[j].EntryType) {
88 case TODO_END_DATETIME: 88 case TODO_END_DATETIME:
89 dtp = &ToDo->Entries[j].Date ; 89 dtp = &ToDo->Entries[j].Date ;
90 todo->setDtDue (fromGSM ( dtp )); 90 todo->setDtDue (fromGSM ( dtp ));
91 break; 91 break;
92 case TODO_COMPLETED: 92 case TODO_COMPLETED:
93 if ( ToDo->Entries[j].Number == 1 ) { 93 if ( ToDo->Entries[j].Number == 1 ) {
94 todo->setCompleted( true ); 94 todo->setCompleted( true );
95 completedString = "yes"; 95 completedString = "yes";
96 } 96 }
97 else { 97 else {
98 todo->setCompleted( false ); 98 todo->setCompleted( false );
99 } 99 }
100 break; 100 break;
101 case TODO_ALARM_DATETIME: 101 case TODO_ALARM_DATETIME:
102 dtp = &ToDo->Entries[j].Date ; 102 dtp = &ToDo->Entries[j].Date ;
103 alarm = true; 103 alarm = true;
104 alarmDt = fromGSM ( dtp ); 104 alarmDt = fromGSM ( dtp );
105 break; 105 break;
106 case TODO_SILENT_ALARM_DATETIME: 106 case TODO_SILENT_ALARM_DATETIME:
107 dtp = &ToDo->Entries[j].Date ; 107 dtp = &ToDo->Entries[j].Date ;
108 alarm = true; 108 alarm = true;
109 alarmDt = fromGSM ( dtp ); 109 alarmDt = fromGSM ( dtp );
110 break; 110 break;
111 case TODO_TEXT: 111 case TODO_TEXT:
112 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); 112 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text ));
113 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); 113 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text )));
114 break; 114 break;
115 case TODO_PRIVATE: 115 case TODO_PRIVATE:
116 if ( ToDo->Entries[j].Number == 1 ) 116 if ( ToDo->Entries[j].Number == 1 )
117 todo->setSecrecy( Incidence::SecrecyPrivate ); 117 todo->setSecrecy( Incidence::SecrecyPrivate );
118 else 118 else
119 todo->setSecrecy( Incidence::SecrecyPublic ); 119 todo->setSecrecy( Incidence::SecrecyPublic );
120 break; 120 break;
121 case TODO_CATEGORY: 121 case TODO_CATEGORY:
122 Category.Location = ToDo->Entries[j].Number; 122 Category.Location = ToDo->Entries[j].Number;
123 Category.Type = Category_ToDo; 123 Category.Type = Category_ToDo;
124 error=Phone->GetCategory(s, &Category); 124 error=Phone->GetCategory(s, &Category);
125 if (error == ERR_NONE) { 125 if (error == ERR_NONE) {
126 QStringList cat = todo->categories(); 126 QStringList cat = todo->categories();
127 QString nCat = QString ( (const char*)Category.Name ); 127 QString nCat = QString ( (const char*)Category.Name );
128 if ( !nCat.isEmpty() ) 128 if ( !nCat.isEmpty() )
129 if ( !cat.contains( nCat )) { 129 if ( !cat.contains( nCat )) {
130 cat << nCat; 130 cat << nCat;
131 todo->setCategories( cat ); 131 todo->setCategories( cat );
132 } 132 }
133 } 133 }
134 break; 134 break;
135 case TODO_CONTACTID: 135 case TODO_CONTACTID:
136#if 0 136#if 0
137 // not supported 137 // not supported
138 entry.Location = ToDo->Entries[j].Number; 138 entry.Location = ToDo->Entries[j].Number;
139 entry.MemoryType = MEM_ME; 139 entry.MemoryType = MEM_ME;
140 error=Phone->GetMemory(s, &entry); 140 error=Phone->GetMemory(s, &entry);
141 if (error == ERR_NONE) { 141 if (error == ERR_NONE) {
142 name = GSM_PhonebookGetEntryName(&entry); 142 name = GSM_PhonebookGetEntryName(&entry);
143 if (name != NULL) { 143 if (name != NULL) {
144 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 144 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
145 } else { 145 } else {
146 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 146 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
147 } 147 }
148 } else { 148 } else {
149 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 149 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
150 } 150 }
151#endif 151#endif
152 break; 152 break;
153 case TODO_PHONE: 153 case TODO_PHONE:
154#if 0 154#if 0
155 // not supported 155 // not supported
156 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 156 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
157#endif 157#endif
158 break; 158 break;
159 } 159 }
160 } 160 }
161 QString alarmString = ""; 161 QString alarmString = "";
162 if ( alarm ) { 162 if ( alarm ) {
163 Alarm *alarm; 163 Alarm *alarm;
164 if ( todo->alarms().count() > 0 ) 164 if ( todo->alarms().count() > 0 )
165 alarm = todo->alarms().first(); 165 alarm = todo->alarms().first();
166 else { 166 else {
167 alarm = new Alarm( todo ); 167 alarm = new Alarm( todo );
168 todo->addAlarm( alarm ); 168 todo->addAlarm( alarm );
169 } 169 }
170 alarm->setType( Alarm::Audio ); 170 alarm->setType( Alarm::Audio );
171 alarm->setEnabled( true ); 171 alarm->setEnabled( true );
172 int alarmOffset = alarmDt.secsTo( todo->dtStart() ); 172 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
173 alarm->setStartOffset( alarmOffset ); 173 alarm->setStartOffset( -alarmOffset );
174 alarmString = QString::number( alarmOffset ); 174 alarmString = QString::number( alarmOffset );
175 } else {
176 Alarm *alarm;
177 if ( todo->alarms().count() > 0 ) {
178 alarm = todo->alarms().first();
179 alarm->setEnabled( false );
180 }
175 } 181 }
176 // csum ***************************************** 182 // csum *****************************************
177 QStringList attList; 183 QStringList attList;
178 uint cSum; 184 uint cSum;
179 if ( todo->hasDueDate() ) 185 if ( todo->hasDueDate() )
180 attList << dtToString ( todo->dtDue() ); 186 attList << dtToString ( todo->dtDue() );
181 attList << QString::number( id ); 187 attList << QString::number( id );
182 attList << todo->summary(); 188 attList << todo->summary();
183 attList << completedString; 189 attList << completedString;
184 attList << QString::number( todo->priority() ); 190 attList << QString::number( todo->priority() );
185 attList << alarmString; 191 attList << alarmString;
186 attList << todo->categoriesStr(); 192 attList << todo->categoriesStr();
187 attList << todo->secrecyStr(); 193 attList << todo->secrecyStr();
188 cSum = PhoneFormat::getCsum(attList ); 194 cSum = PhoneFormat::getCsum(attList );
189 todo->setCsum( mProfileName, QString::number( cSum )); 195 todo->setCsum( mProfileName, QString::number( cSum ));
190 mCalendar->addTodo( todo); 196 mCalendar->addTodo( todo);
191 197
192 return true; 198 return true;
193 } 199 }
194 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) 200 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
195 { 201 {
196 202
197 int id = Note->Location; 203 int id = Note->Location;
198 Event *event; 204 Event *event;
199 event = existingCalendar->event( mProfileName ,QString::number( id ) ); 205 event = existingCalendar->event( mProfileName ,QString::number( id ) );
200 if ( event ) 206 if ( event )
201 event = (Event*)event->clone(); 207 event = (Event*)event->clone();
202 else 208 else
203 event = new Event; 209 event = new Event;
204 event->setID( mProfileName,QString::number( id ) ); 210 event->setID( mProfileName,QString::number( id ) );
205 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 211 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
206 212
207 213
208 int i = 0; 214 int i = 0;
209 bool repeating = false; 215 bool repeating = false;
210 int repeat_dayofweek = -1; 216 int repeat_dayofweek = -1;
211 int repeat_day = -1; 217 int repeat_day = -1;
212 int repeat_weekofmonth = -1; 218 int repeat_weekofmonth = -1;
213 int repeat_month = -1; 219 int repeat_month = -1;
214 int repeat_frequency = -1; 220 int repeat_frequency = -1;
215 int rec_type = -1; 221 int rec_type = -1;
216 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 222 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
217 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 223 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
218 GSM_DateTime* dtp; 224 GSM_DateTime* dtp;
219 bool alarm = false; 225 bool alarm = false;
220 QDateTime alarmDt; 226 QDateTime alarmDt;
221 repeat_startdate.Day= 0; 227 repeat_startdate.Day= 0;
222 repeat_stopdate.Day = 0; 228 repeat_stopdate.Day = 0;
223 for (i=0;i<Note->EntriesNum;i++) { 229 for (i=0;i<Note->EntriesNum;i++) {
224 230
225 //qDebug(" for ev"); 231 //qDebug(" for ev");
226 switch (Note->Entries[i].EntryType) { 232 switch (Note->Entries[i].EntryType) {
227 case CAL_START_DATETIME: 233 case CAL_START_DATETIME:
228 dtp = &Note->Entries[i].Date ; 234 dtp = &Note->Entries[i].Date ;
229 if ( dtp->Hour > 24 ) { 235 if ( dtp->Hour > 24 ) {
230 event->setFloats( true ); 236 event->setFloats( true );
231 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 237 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
232 } else { 238 } else {
233 event->setDtStart (fromGSM ( dtp )); 239 event->setDtStart (fromGSM ( dtp ));
234 240
235 } 241 }
236 break; 242 break;
237 case CAL_END_DATETIME: 243 case CAL_END_DATETIME:
238 dtp = &Note->Entries[i].Date ; 244 dtp = &Note->Entries[i].Date ;
239 if ( dtp->Hour > 24 ) { 245 if ( dtp->Hour > 24 ) {
240 event->setFloats( true ); 246 event->setFloats( true );
241 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 247 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
242 } else { 248 } else {
243 event->setDtEnd (fromGSM ( dtp )); 249 event->setDtEnd (fromGSM ( dtp ));
244 } 250 }
245 break; 251 break;
246 case CAL_ALARM_DATETIME: 252 case CAL_ALARM_DATETIME:
247 dtp = &Note->Entries[i].Date ; 253 dtp = &Note->Entries[i].Date ;
248 alarm = true; 254 alarm = true;
249 alarmDt = fromGSM ( dtp ); 255 alarmDt = fromGSM ( dtp );
250 break; 256 break;
251 case CAL_SILENT_ALARM_DATETIME: 257 case CAL_SILENT_ALARM_DATETIME:
252 dtp = &Note->Entries[i].Date ; 258 dtp = &Note->Entries[i].Date ;
253 alarm = true; 259 alarm = true;
254 alarmDt = fromGSM ( dtp ); 260 alarmDt = fromGSM ( dtp );
255 break; 261 break;
256 case CAL_RECURRANCE: 262 case CAL_RECURRANCE:
257 rec_type = Note->Entries[i].Number; 263 rec_type = Note->Entries[i].Number;
258 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); 264 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
259 break; 265 break;
260 case CAL_TEXT: 266 case CAL_TEXT:
261 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); 267 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) );
262 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); 268 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text )));
263 break; 269 break;
264 case CAL_LOCATION: 270 case CAL_LOCATION:
265 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); 271 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) ));
266 break; 272 break;
267 case CAL_PHONE: 273 case CAL_PHONE:
268 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 274 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
269 break; 275 break;
270 case CAL_PRIVATE: 276 case CAL_PRIVATE:
@@ -355,194 +361,200 @@ public:
355 startDate = datefromGSM ( &repeat_startdate ); 361 startDate = datefromGSM ( &repeat_startdate );
356 else 362 else
357 startDate = event->dtStart().date(); 363 startDate = event->dtStart().date();
358 int freq = repeat_frequency; 364 int freq = repeat_frequency;
359 bool hasEndDate = false; 365 bool hasEndDate = false;
360 if ( repeat_stopdate.Day > 0 ) { 366 if ( repeat_stopdate.Day > 0 ) {
361 endDate = datefromGSM ( &repeat_stopdate ); 367 endDate = datefromGSM ( &repeat_stopdate );
362 hasEndDate = true; 368 hasEndDate = true;
363 } 369 }
364 370
365 uint weekDaysNum = repeat_dayofweek ; 371 uint weekDaysNum = repeat_dayofweek ;
366 372
367 QBitArray weekDays( 7 ); 373 QBitArray weekDays( 7 );
368 int i; 374 int i;
369 int bb = 1; 375 int bb = 1;
370 for( i = 1; i <= 7; ++i ) { 376 for( i = 1; i <= 7; ++i ) {
371 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 377 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
372 bb = 2 << (i-1); 378 bb = 2 << (i-1);
373 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 379 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
374 } 380 }
375 // qDebug("next "); 381 // qDebug("next ");
376 int pos = 0; 382 int pos = 0;
377 Recurrence *r = event->recurrence(); 383 Recurrence *r = event->recurrence();
378 /* 384 /*
379 0 daily; 385 0 daily;
380 1 weekly;x 386 1 weekly;x
381 2 monthpos;x 387 2 monthpos;x
382 3 monthlyday; 388 3 monthlyday;
383 4 rYearlyMont 389 4 rYearlyMont
384 bool repeating = false; 390 bool repeating = false;
385 int repeat_dayofweek = -1; 391 int repeat_dayofweek = -1;
386 int repeat_day = -1; 392 int repeat_day = -1;
387 int repeat_weekofmonth = -1; 393 int repeat_weekofmonth = -1;
388 int repeat_month = -1; 394 int repeat_month = -1;
389 int repeat_frequency = -1; 395 int repeat_frequency = -1;
390 */ 396 */
391 int dayOfWeek = startDate.dayOfWeek(); 397 int dayOfWeek = startDate.dayOfWeek();
392 if ( repeat_weekofmonth >= 0 ) { 398 if ( repeat_weekofmonth >= 0 ) {
393 rtype = 2; 399 rtype = 2;
394 pos = repeat_weekofmonth; 400 pos = repeat_weekofmonth;
395 if ( repeat_dayofweek >= 0 ) 401 if ( repeat_dayofweek >= 0 )
396 dayOfWeek = repeat_dayofweek; 402 dayOfWeek = repeat_dayofweek;
397 } else if ( repeat_dayofweek >= 0 ) { 403 } else if ( repeat_dayofweek >= 0 ) {
398 rtype = 1; 404 rtype = 1;
399 } if ( repeat_dayofweek >= 0 ) { 405 } if ( repeat_dayofweek >= 0 ) {
400 rtype = 1; 406 rtype = 1;
401 } 407 }
402 408
403 if ( rtype == 0 ) { 409 if ( rtype == 0 ) {
404 if ( hasEndDate ) r->setDaily( freq, endDate ); 410 if ( hasEndDate ) r->setDaily( freq, endDate );
405 else r->setDaily( freq, -1 ); 411 else r->setDaily( freq, -1 );
406 } else if ( rtype == 1 ) { 412 } else if ( rtype == 1 ) {
407 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 413 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
408 else r->setWeekly( freq, weekDays, -1 ); 414 else r->setWeekly( freq, weekDays, -1 );
409 } else if ( rtype == 3 ) { 415 } else if ( rtype == 3 ) {
410 if ( hasEndDate ) 416 if ( hasEndDate )
411 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 417 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
412 else 418 else
413 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 419 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
414 r->addMonthlyDay( startDate.day() ); 420 r->addMonthlyDay( startDate.day() );
415 } else if ( rtype == 2 ) { 421 } else if ( rtype == 2 ) {
416 if ( hasEndDate ) 422 if ( hasEndDate )
417 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 423 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
418 else 424 else
419 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 425 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
420 QBitArray days( 7 ); 426 QBitArray days( 7 );
421 days.fill( false ); 427 days.fill( false );
422 days.setBit( dayOfWeek - 1 ); 428 days.setBit( dayOfWeek - 1 );
423 r->addMonthlyPos( pos, days ); 429 r->addMonthlyPos( pos, days );
424 } else if ( rtype == 4 ) { 430 } else if ( rtype == 4 ) {
425 if ( hasEndDate ) 431 if ( hasEndDate )
426 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 432 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
427 else 433 else
428 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 434 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
429 r->addYearlyNum( startDate.month() ); 435 r->addYearlyNum( startDate.month() );
430 } 436 }
431 } else { 437 } else {
432 event->recurrence()->unsetRecurs(); 438 event->recurrence()->unsetRecurs();
433 } 439 }
434 440
435 QStringList categoryList; 441 QStringList categoryList;
436 categoryList << getCategory( Note ); 442 categoryList << getCategory( Note );
437 event->setCategories( categoryList ); 443 event->setCategories( categoryList );
438 QString alarmString = ""; 444 QString alarmString = "";
439 // strange 0 semms to mean: alarm enabled 445 // strange 0 semms to mean: alarm enabled
440 if ( alarm ) { 446 if ( alarm ) {
441 Alarm *alarm; 447 Alarm *alarm;
442 if ( event->alarms().count() > 0 ) 448 if ( event->alarms().count() > 0 )
443 alarm = event->alarms().first(); 449 alarm = event->alarms().first();
444 else { 450 else {
445 alarm = new Alarm( event ); 451 alarm = new Alarm( event );
446 event->addAlarm( alarm ); 452 event->addAlarm( alarm );
447 } 453 }
448 alarm->setType( Alarm::Audio ); 454 alarm->setType( Alarm::Audio );
449 alarm->setEnabled( true ); 455 alarm->setEnabled( true );
450 int alarmOffset = alarmDt.secsTo( event->dtStart() ); 456 int alarmOffset = alarmDt.secsTo( event->dtStart() );
451 alarm->setStartOffset( alarmOffset ); 457 alarm->setStartOffset( -alarmOffset );
452 alarmString = QString::number( alarmOffset ); 458 alarmString = QString::number( alarmOffset );
459 } else {
460 Alarm *alarm;
461 if ( event->alarms().count() > 0 ) {
462 alarm = event->alarms().first();
463 alarm->setEnabled( false );
464 }
453 } 465 }
454 // csum ***************************************** 466 // csum *****************************************
455 QStringList attList; 467 QStringList attList;
456 uint cSum; 468 uint cSum;
457 attList << dtToString ( event->dtStart() ); 469 attList << dtToString ( event->dtStart() );
458 attList << dtToString ( event->dtEnd() ); 470 attList << dtToString ( event->dtEnd() );
459 attList << QString::number( id ); 471 attList << QString::number( id );
460 attList << event->summary(); 472 attList << event->summary();
461 attList << event->location(); 473 attList << event->location();
462 attList << alarmString; 474 attList << alarmString;
463 attList << recurString; 475 attList << recurString;
464 attList << event->categoriesStr(); 476 attList << event->categoriesStr();
465 attList << event->secrecyStr(); 477 attList << event->secrecyStr();
466 cSum = PhoneFormat::getCsum(attList ); 478 cSum = PhoneFormat::getCsum(attList );
467 event->setCsum( mProfileName, QString::number( cSum )); 479 event->setCsum( mProfileName, QString::number( cSum ));
468 mCalendar->addEvent( event); 480 mCalendar->addEvent( event);
469 481
470 return true; 482 return true;
471 } 483 }
472 484
473 485
474 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { 486 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) {
475 QDateTime dt; 487 QDateTime dt;
476 int y,m,t,h,min,sec; 488 int y,m,t,h,min,sec;
477 y = dtp->Year; 489 y = dtp->Year;
478 m = dtp->Month; 490 m = dtp->Month;
479 t = dtp->Day; 491 t = dtp->Day;
480 h = dtp->Hour; 492 h = dtp->Hour;
481 min = dtp->Minute; 493 min = dtp->Minute;
482 sec = dtp->Second; 494 sec = dtp->Second;
483 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 495 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
484 // dtp->Timezone: offset in hours 496 // dtp->Timezone: offset in hours
485 int offset = KGlobal::locale()->localTimeOffset( dt ); 497 int offset = KGlobal::locale()->localTimeOffset( dt );
486 if ( useTz ) 498 if ( useTz )
487 dt = dt.addSecs ( offset*60); 499 dt = dt.addSecs ( offset*60);
488 return dt; 500 return dt;
489 501
490 } 502 }
491 503
492 QString dtToString( const QDateTime& dti, bool useTZ = false ) 504 QString dtToString( const QDateTime& dti, bool useTZ = false )
493 { 505 {
494 QString datestr; 506 QString datestr;
495 QString timestr; 507 QString timestr;
496 int offset = KGlobal::locale()->localTimeOffset( dti ); 508 int offset = KGlobal::locale()->localTimeOffset( dti );
497 QDateTime dt; 509 QDateTime dt;
498 if (useTZ) 510 if (useTZ)
499 dt = dti.addSecs ( -(offset*60)); 511 dt = dti.addSecs ( -(offset*60));
500 else 512 else
501 dt = dti; 513 dt = dti;
502 if(dt.date().isValid()){ 514 if(dt.date().isValid()){
503 const QDate& date = dt.date(); 515 const QDate& date = dt.date();
504 datestr.sprintf("%04d%02d%02d", 516 datestr.sprintf("%04d%02d%02d",
505 date.year(), date.month(), date.day()); 517 date.year(), date.month(), date.day());
506 } 518 }
507 if(dt.time().isValid()){ 519 if(dt.time().isValid()){
508 const QTime& time = dt.time(); 520 const QTime& time = dt.time();
509 timestr.sprintf("T%02d%02d%02d", 521 timestr.sprintf("T%02d%02d%02d",
510 time.hour(), time.minute(), time.second()); 522 time.hour(), time.minute(), time.second());
511 } 523 }
512 return datestr + timestr; 524 return datestr + timestr;
513 } 525 }
514 QDate datefromGSM ( GSM_DateTime*dtp ) { 526 QDate datefromGSM ( GSM_DateTime*dtp ) {
515 return QDate ( dtp->Year, dtp->Month, dtp->Day ); 527 return QDate ( dtp->Year, dtp->Month, dtp->Day );
516 } 528 }
517 QString getCategory( GSM_CalendarEntry*Note) 529 QString getCategory( GSM_CalendarEntry*Note)
518 { 530 {
519 QString CATEGORY; 531 QString CATEGORY;
520 switch (Note->Type) { 532 switch (Note->Type) {
521 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; 533 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
522 case GSM_CAL_CALL : CATEGORY = QString("Call"); break; 534 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
523 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; 535 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
524 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; 536 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
525 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; 537 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
526 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; 538 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
527 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; 539 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
528 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; 540 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
529 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; 541 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
530 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; 542 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
531 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; 543 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
532 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; 544 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
533 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; 545 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
534 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; 546 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
535 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; 547 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
536 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; 548 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
537 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; 549 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
538 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; 550 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
539 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; 551 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
540 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; 552 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
541 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; 553 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
542 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; 554 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
543 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; 555 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
544 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; 556 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
545 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; 557 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
546 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; 558 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
547 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; 559 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
548 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; 560 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index 4e54fdf..f8b066d 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -72,210 +72,218 @@ class SharpParser : public QObject
72 int i = 1; 72 int i = 1;
73 bool skip = true; 73 bool skip = true;
74 int max = attList.count() -2; 74 int max = attList.count() -2;
75 while ( i < max ) { 75 while ( i < max ) {
76 if ( !attList[i].isEmpty() ) { 76 if ( !attList[i].isEmpty() ) {
77 skip = false; 77 skip = false;
78 break; 78 break;
79 } 79 }
80 ++i ; 80 ++i ;
81 } 81 }
82 if ( skip ) 82 if ( skip )
83 return false; 83 return false;
84 ulong cSum = SharpFormat::getCsum(attList ); 84 ulong cSum = SharpFormat::getCsum(attList );
85 85
86 if ( qName == "Event" ) { 86 if ( qName == "Event" ) {
87 Event *event; 87 Event *event;
88 event = existingCalendar->event( "Sharp_DTM",attList[0] ); 88 event = existingCalendar->event( "Sharp_DTM",attList[0] );
89 if ( event ) 89 if ( event )
90 event = (Event*)event->clone(); 90 event = (Event*)event->clone();
91 else 91 else
92 event = new Event; 92 event = new Event;
93 event->setID("Sharp_DTM", attList[0] ); 93 event->setID("Sharp_DTM", attList[0] );
94 event->setCsum( "Sharp_DTM", QString::number( cSum )); 94 event->setCsum( "Sharp_DTM", QString::number( cSum ));
95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
96 96
97 event->setSummary( attList[2] ); 97 event->setSummary( attList[2] );
98 event->setLocation( attList[3] ); 98 event->setLocation( attList[3] );
99 event->setDescription( attList[4] ); 99 event->setDescription( attList[4] );
100 if ( attList[7] == "1" ) { 100 if ( attList[7] == "1" ) {
101 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); 101 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) ));
102 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); 102 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 )));
103 event->setFloats( true ); 103 event->setFloats( true );
104 } else { 104 } else {
105 event->setFloats( false ); 105 event->setFloats( false );
106 event->setDtStart( fromString( attList[5] ) ); 106 event->setDtStart( fromString( attList[5] ) );
107 event->setDtEnd( fromString( attList[6] )); 107 event->setDtEnd( fromString( attList[6] ));
108 } 108 }
109 109
110 QString rtype = attList[11]; 110 QString rtype = attList[11];
111 if ( rtype != "255" ) { 111 if ( rtype != "255" ) {
112 // qDebug("recurs "); 112 // qDebug("recurs ");
113 QDate startDate = event->dtStart().date(); 113 QDate startDate = event->dtStart().date();
114 114
115 QString freqStr = attList[12]; 115 QString freqStr = attList[12];
116 int freq = freqStr.toInt(); 116 int freq = freqStr.toInt();
117 117
118 QString hasEndDateStr = attList[15] ; 118 QString hasEndDateStr = attList[15] ;
119 bool hasEndDate = hasEndDateStr == "1"; 119 bool hasEndDate = hasEndDateStr == "1";
120 120
121 QString endDateStr = attList[16]; 121 QString endDateStr = attList[16];
122 QDate endDate = fromString( endDateStr ).date(); 122 QDate endDate = fromString( endDateStr ).date();
123 123
124 QString weekDaysStr = attList[14]; 124 QString weekDaysStr = attList[14];
125 uint weekDaysNum = weekDaysStr.toInt(); 125 uint weekDaysNum = weekDaysStr.toInt();
126 126
127 QBitArray weekDays( 7 ); 127 QBitArray weekDays( 7 );
128 int i; 128 int i;
129 int bb = 1; 129 int bb = 1;
130 for( i = 1; i <= 7; ++i ) { 130 for( i = 1; i <= 7; ++i ) {
131 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 131 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
132 bb = 2 << (i-1); 132 bb = 2 << (i-1);
133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
134 } 134 }
135 // qDebug("next "); 135 // qDebug("next ");
136 QString posStr = attList[13]; 136 QString posStr = attList[13];
137 int pos = posStr.toInt(); 137 int pos = posStr.toInt();
138 Recurrence *r = event->recurrence(); 138 Recurrence *r = event->recurrence();
139 139
140 if ( rtype == "0" ) { 140 if ( rtype == "0" ) {
141 if ( hasEndDate ) r->setDaily( freq, endDate ); 141 if ( hasEndDate ) r->setDaily( freq, endDate );
142 else r->setDaily( freq, -1 ); 142 else r->setDaily( freq, -1 );
143 } else if ( rtype == "1" ) { 143 } else if ( rtype == "1" ) {
144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
145 else r->setWeekly( freq, weekDays, -1 ); 145 else r->setWeekly( freq, weekDays, -1 );
146 } else if ( rtype == "3" ) { 146 } else if ( rtype == "3" ) {
147 if ( hasEndDate ) 147 if ( hasEndDate )
148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
149 else 149 else
150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
151 r->addMonthlyDay( startDate.day() ); 151 r->addMonthlyDay( startDate.day() );
152 } else if ( rtype == "2" ) { 152 } else if ( rtype == "2" ) {
153 if ( hasEndDate ) 153 if ( hasEndDate )
154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
155 else 155 else
156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
157 QBitArray days( 7 ); 157 QBitArray days( 7 );
158 days.fill( false ); 158 days.fill( false );
159 days.setBit( startDate.dayOfWeek() - 1 ); 159 days.setBit( startDate.dayOfWeek() - 1 );
160 r->addMonthlyPos( pos, days ); 160 r->addMonthlyPos( pos, days );
161 } else if ( rtype == "4" ) { 161 } else if ( rtype == "4" ) {
162 if ( hasEndDate ) 162 if ( hasEndDate )
163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
164 else 164 else
165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
166 r->addYearlyNum( startDate.month() ); 166 r->addYearlyNum( startDate.month() );
167 } 167 }
168 } else {
169 event->recurrence()->unsetRecurs();
168 } 170 }
169 171
170 QString categoryList = attList[1] ; 172 QString categoryList = attList[1] ;
171 event->setCategories( lookupCategories( categoryList ) ); 173 event->setCategories( lookupCategories( categoryList ) );
172 174
173 // strange 0 semms to mean: alarm enabled 175 // strange 0 semms to mean: alarm enabled
174 if ( attList[8] == "0" ) { 176 if ( attList[8] == "0" ) {
175 Alarm *alarm; 177 Alarm *alarm;
176 if ( event->alarms().count() > 0 ) 178 if ( event->alarms().count() > 0 )
177 alarm = event->alarms().first(); 179 alarm = event->alarms().first();
178 else { 180 else {
179 alarm = new Alarm( event ); 181 alarm = new Alarm( event );
180 event->addAlarm( alarm ); 182 event->addAlarm( alarm );
181 } 183 }
182 alarm->setType( Alarm::Audio ); 184 alarm->setType( Alarm::Audio );
183 alarm->setEnabled( true ); 185 alarm->setEnabled( true );
184 int alarmOffset = attList[9].toInt(); 186 int alarmOffset = attList[9].toInt();
185 alarm->setStartOffset( alarmOffset * -60 ); 187 alarm->setStartOffset( alarmOffset * -60 );
188 } else {
189 Alarm *alarm;
190 if ( event->alarms().count() > 0 ) {
191 alarm = event->alarms().first();
192 alarm->setEnabled( false );
193 }
186 } 194 }
187 195
188 mCalendar->addEvent( event); 196 mCalendar->addEvent( event);
189 } else if ( qName == "Todo" ) { 197 } else if ( qName == "Todo" ) {
190 Todo *todo; 198 Todo *todo;
191 199
192 todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); 200 todo = existingCalendar->todo( "Sharp_DTM", attList[0] );
193 if (todo ) 201 if (todo )
194 todo = (Todo*)todo->clone(); 202 todo = (Todo*)todo->clone();
195 else 203 else
196 todo = new Todo; 204 todo = new Todo;
197 205
198//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 206//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
199// 0 1 2 3 4 5 6 7 8 207// 0 1 2 3 4 5 6 7 8
200//1,,,,,1,4,Loch zumachen,"" 208//1,,,,,1,4,Loch zumachen,""
201//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 209//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
202//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 210//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
203 211
204 todo->setID( "Sharp_DTM", attList[0]); 212 todo->setID( "Sharp_DTM", attList[0]);
205 todo->setCsum( "Sharp_DTM", QString::number( cSum )); 213 todo->setCsum( "Sharp_DTM", QString::number( cSum ));
206 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 214 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
207 215
208 todo->setSummary( attList[7] ); 216 todo->setSummary( attList[7] );
209 todo->setDescription( attList[8]); 217 todo->setDescription( attList[8]);
210 218
211 int priority = attList[6].toInt(); 219 int priority = attList[6].toInt();
212 if ( priority == 0 ) priority = 3; 220 if ( priority == 0 ) priority = 3;
213 todo->setPriority( priority ); 221 todo->setPriority( priority );
214 222
215 QString categoryList = attList[1]; 223 QString categoryList = attList[1];
216 todo->setCategories( lookupCategories( categoryList ) ); 224 todo->setCategories( lookupCategories( categoryList ) );
217 225
218 226
219 227
220 QString hasDateStr = attList[3]; // due 228 QString hasDateStr = attList[3]; // due
221 if ( !hasDateStr.isEmpty() ) { 229 if ( !hasDateStr.isEmpty() ) {
222 if ( hasDateStr.right(6) == "000000" ) { 230 if ( hasDateStr.right(6) == "000000" ) {
223 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 231 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
224 todo->setFloats( true ); 232 todo->setFloats( true );
225 } 233 }
226 else { 234 else {
227 todo->setDtDue( fromString( hasDateStr ) ); 235 todo->setDtDue( fromString( hasDateStr ) );
228 todo->setFloats( false ); 236 todo->setFloats( false );
229 } 237 }
230 238
231 todo->setHasDueDate( true ); 239 todo->setHasDueDate( true );
232 } 240 }
233 hasDateStr = attList[2];//start 241 hasDateStr = attList[2];//start
234 if ( !hasDateStr.isEmpty() ) { 242 if ( !hasDateStr.isEmpty() ) {
235 243
236 todo->setDtStart( fromString( hasDateStr ) ); 244 todo->setDtStart( fromString( hasDateStr ) );
237 todo->setHasStartDate( true); 245 todo->setHasStartDate( true);
238 } else 246 } else
239 todo->setHasStartDate( false ); 247 todo->setHasStartDate( false );
240 hasDateStr = attList[4];//completed 248 hasDateStr = attList[4];//completed
241 if ( !hasDateStr.isEmpty() ) { 249 if ( !hasDateStr.isEmpty() ) {
242 todo->setCompleted(fromString( hasDateStr ) ); 250 todo->setCompleted(fromString( hasDateStr ) );
243 } 251 }
244 QString completedStr = attList[5]; 252 QString completedStr = attList[5];
245 if ( completedStr == "0" ) 253 if ( completedStr == "0" )
246 todo->setCompleted( true ); 254 todo->setCompleted( true );
247 else 255 else
248 todo->setCompleted( false ); 256 todo->setCompleted( false );
249 mCalendar->addTodo( todo ); 257 mCalendar->addTodo( todo );
250 258
251 } else if ( qName == "Category" ) { 259 } else if ( qName == "Category" ) {
252 /* 260 /*
253 QString id = attributes.value( "id" ); 261 QString id = attributes.value( "id" );
254 QString name = attributes.value( "name" ); 262 QString name = attributes.value( "name" );
255 setCategory( id, name ); 263 setCategory( id, name );
256 */ 264 */
257 } 265 }
258 //qDebug("end "); 266 //qDebug("end ");
259 return true; 267 return true;
260 } 268 }
261 269
262 270
263 void setCategoriesList ( QStringList * c ) 271 void setCategoriesList ( QStringList * c )
264 { 272 {
265 oldCategories = c; 273 oldCategories = c;
266 } 274 }
267 275
268 QDateTime fromString ( QString s, bool useTz = true ) { 276 QDateTime fromString ( QString s, bool useTz = true ) {
269 QDateTime dt; 277 QDateTime dt;
270 int y,m,t,h,min,sec; 278 int y,m,t,h,min,sec;
271 y = s.mid(0,4).toInt(); 279 y = s.mid(0,4).toInt();
272 m = s.mid(4,2).toInt(); 280 m = s.mid(4,2).toInt();
273 t = s.mid(6,2).toInt(); 281 t = s.mid(6,2).toInt();
274 h = s.mid(9,2).toInt(); 282 h = s.mid(9,2).toInt();
275 min = s.mid(11,2).toInt(); 283 min = s.mid(11,2).toInt();
276 sec = s.mid(13,2).toInt(); 284 sec = s.mid(13,2).toInt();
277 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 285 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
278 int offset = KGlobal::locale()->localTimeOffset( dt ); 286 int offset = KGlobal::locale()->localTimeOffset( dt );
279 if ( useTz ) 287 if ( useTz )
280 dt = dt.addSecs ( offset*60); 288 dt = dt.addSecs ( offset*60);
281 return dt; 289 return dt;