author | zautrix <zautrix> | 2005-06-26 08:17:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-26 08:17:08 (UTC) |
commit | f27e8c6cc8abbd27f10167334d608c7e0af7f711 (patch) (unidiff) | |
tree | b516d5512178f98d105a5d77f96aff29dfe09c02 | |
parent | 6d8fdbda8cb12b768932a80ccd25d275bc4b30f9 (diff) | |
download | kdepimpi-f27e8c6cc8abbd27f10167334d608c7e0af7f711.zip kdepimpi-f27e8c6cc8abbd27f10167334d608c7e0af7f711.tar.gz kdepimpi-f27e8c6cc8abbd27f10167334d608c7e0af7f711.tar.bz2 |
rec fix
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 4 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 1fd5364..1c5e83b 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,154 +1,156 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.1.9 ************ | 3 | ********** VERSION 2.1.9 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Fixed some problems of the new search options in the search dialog. | 6 | Fixed some problems of the new search options in the search dialog. |
7 | Fixed some problems in the new resource config options. | 7 | Fixed some problems in the new resource config options. |
8 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. | 8 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. |
9 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: | 9 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: |
10 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. | 10 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. |
11 | |||
12 | Fixed a problem in recurrence range in syncing with DTM. | ||
11 | 13 | ||
12 | 14 | ||
13 | PwM/Pi: | 15 | PwM/Pi: |
14 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. | 16 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. |
15 | 17 | ||
16 | ********** VERSION 2.1.8 ************ | 18 | ********** VERSION 2.1.8 ************ |
17 | 19 | ||
18 | KO/Pi: | 20 | KO/Pi: |
19 | Added info about the completion state of a todo in the ListView/Searchdialog. | 21 | Added info about the completion state of a todo in the ListView/Searchdialog. |
20 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. | 22 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. |
21 | Fixed some updating problems when changing the filter. | 23 | Fixed some updating problems when changing the filter. |
22 | 24 | ||
23 | KA/Pi: | 25 | KA/Pi: |
24 | In the addressee selection dialog now the formatted name is shown, if not empty. | 26 | In the addressee selection dialog now the formatted name is shown, if not empty. |
25 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. | 27 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. |
26 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. | 28 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. |
27 | 29 | ||
28 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. | 30 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. |
29 | Fixed the sorting for size in the file selector on the Z. | 31 | Fixed the sorting for size in the file selector on the Z. |
30 | 32 | ||
31 | Changed the color selection dialog on the Zaurus to a more user friendly version. | 33 | Changed the color selection dialog on the Zaurus to a more user friendly version. |
32 | 34 | ||
33 | ********** VERSION 2.1.7 ************ | 35 | ********** VERSION 2.1.7 ************ |
34 | 36 | ||
35 | KO/Pi: | 37 | KO/Pi: |
36 | Fixed several problems in the new Resource handling. | 38 | Fixed several problems in the new Resource handling. |
37 | Added more options to the search dialog. | 39 | Added more options to the search dialog. |
38 | Fixed a problem in the Month view. | 40 | Fixed a problem in the Month view. |
39 | Added more options to the dialog when setting a todo to stopped. | 41 | Added more options to the dialog when setting a todo to stopped. |
40 | 42 | ||
41 | Fixed two small problems in KO/Pi Alarm applet. | 43 | Fixed two small problems in KO/Pi Alarm applet. |
42 | 44 | ||
43 | ********** VERSION 2.1.6 ************ | 45 | ********** VERSION 2.1.6 ************ |
44 | 46 | ||
45 | This release is for testing only. | 47 | This release is for testing only. |
46 | 48 | ||
47 | KO/Pi: | 49 | KO/Pi: |
48 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 50 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
49 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 51 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
50 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 52 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
51 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 53 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
52 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | 54 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. |
53 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | 55 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. |
54 | 56 | ||
55 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. | 57 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. |
56 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. | 58 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. |
57 | Now on every sync the set of calendars is synced which are enabled in the resource view. | 59 | Now on every sync the set of calendars is synced which are enabled in the resource view. |
58 | 60 | ||
59 | A calendar is enabled in the resource view if the "eye" column is checked. | 61 | A calendar is enabled in the resource view if the "eye" column is checked. |
60 | You can set a calendar to be the default for new items( "+" column ). | 62 | You can set a calendar to be the default for new items( "+" column ). |
61 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. | 63 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. |
62 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... | 64 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... |
63 | 65 | ||
64 | 66 | ||
65 | ********** VERSION 2.1.5 ************ | 67 | ********** VERSION 2.1.5 ************ |
66 | 68 | ||
67 | This is the new stable version. | 69 | This is the new stable version. |
68 | Bugfix: | 70 | Bugfix: |
69 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 71 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
70 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 72 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
71 | Added config option to not display completed todos in agenda view. | 73 | Added config option to not display completed todos in agenda view. |
72 | Addressee view is now using the formatted name, if defined. | 74 | Addressee view is now using the formatted name, if defined. |
73 | That makes it possible to display "lastname, firstname" in that view now. | 75 | That makes it possible to display "lastname, firstname" in that view now. |
74 | To set the formatted name for all contacts, please use menu: | 76 | To set the formatted name for all contacts, please use menu: |
75 | Edit->Change->Set formatted name. | 77 | Edit->Change->Set formatted name. |
76 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 78 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
77 | 79 | ||
78 | ********** VERSION 2.1.4 ************ | 80 | ********** VERSION 2.1.4 ************ |
79 | 81 | ||
80 | Fixed two more bugs in the KA/Pi CSV import dialog: | 82 | Fixed two more bugs in the KA/Pi CSV import dialog: |
81 | Made it possible to read multi-line fields and import it to the "Note" field. | 83 | Made it possible to read multi-line fields and import it to the "Note" field. |
82 | Fixed a problem in mapping custom fields, whatever a custem field is... | 84 | Fixed a problem in mapping custom fields, whatever a custem field is... |
83 | 85 | ||
84 | ********** VERSION 2.1.3 ************ | 86 | ********** VERSION 2.1.3 ************ |
85 | 87 | ||
86 | Changed the menu structure of the alarm applet: | 88 | Changed the menu structure of the alarm applet: |
87 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 89 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
88 | 90 | ||
89 | Fixed several problems in the KA/Pi CSV import dialog: | 91 | Fixed several problems in the KA/Pi CSV import dialog: |
90 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 92 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
91 | 93 | ||
92 | 94 | ||
93 | ********** VERSION 2.1.2 ************ | 95 | ********** VERSION 2.1.2 ************ |
94 | 96 | ||
95 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 97 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
96 | 98 | ||
97 | Fixed a problem when importing data from Outlook with mutiple categories set. | 99 | Fixed a problem when importing data from Outlook with mutiple categories set. |
98 | 100 | ||
99 | Changed display of days in datenavigator: | 101 | Changed display of days in datenavigator: |
100 | Birthdays are now blue, not dark green. | 102 | Birthdays are now blue, not dark green. |
101 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 103 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
102 | When journal view is shown, only holidays are shown and days with journals are blue. | 104 | When journal view is shown, only holidays are shown and days with journals are blue. |
103 | 105 | ||
104 | Added Backup options to global config: | 106 | Added Backup options to global config: |
105 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). | 107 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). |
106 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. | 108 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. |
107 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. | 109 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. |
108 | 110 | ||
109 | ********** VERSION 2.1.1 ************ | 111 | ********** VERSION 2.1.1 ************ |
110 | 112 | ||
111 | Stable release 2.1.1! | 113 | Stable release 2.1.1! |
112 | 114 | ||
113 | KO/Pi: | 115 | KO/Pi: |
114 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 116 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
115 | 117 | ||
116 | ********** VERSION 2.1.0 ************ | 118 | ********** VERSION 2.1.0 ************ |
117 | 119 | ||
118 | Stable release 2.1.0! | 120 | Stable release 2.1.0! |
119 | 121 | ||
120 | Summary of changes/fixes compared to version 2.0.6: | 122 | Summary of changes/fixes compared to version 2.0.6: |
121 | 123 | ||
122 | Many bugs of version 2.0.6 fixed. | 124 | Many bugs of version 2.0.6 fixed. |
123 | Most of them were small bugs, but some of them were important. | 125 | Most of them were small bugs, but some of them were important. |
124 | It is recommended to use version 2.1.0 and not version 2.0.6. | 126 | It is recommended to use version 2.1.0 and not version 2.0.6. |
125 | 127 | ||
126 | Important changes: | 128 | Important changes: |
127 | 129 | ||
128 | Added recurring todos to KO/Pi. | 130 | Added recurring todos to KO/Pi. |
129 | 131 | ||
130 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 132 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
131 | 133 | ||
132 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 134 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
133 | 135 | ||
134 | Datenavigator can now display many months. Very useful on the desktop. | 136 | Datenavigator can now display many months. Very useful on the desktop. |
135 | 137 | ||
136 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 138 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
137 | 139 | ||
138 | Made alarm sound working on Linux desktop. | 140 | Made alarm sound working on Linux desktop. |
139 | 141 | ||
140 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 142 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
141 | 143 | ||
142 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 144 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
143 | 145 | ||
144 | Many other usebility enhancements. | 146 | Many other usebility enhancements. |
145 | Special thanks to Ben for his suggestions! | 147 | Special thanks to Ben for his suggestions! |
146 | 148 | ||
147 | You can find the complete changelog | 149 | You can find the complete changelog |
148 | from version 1.7.7 to 2.1.0 | 150 | from version 1.7.7 to 2.1.0 |
149 | in the source package or on | 151 | in the source package or on |
150 | 152 | ||
151 | http://www.pi-sync.net/html/changelog.html | 153 | http://www.pi-sync.net/html/changelog.html |
152 | 154 | ||
153 | 155 | ||
154 | 156 | ||
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index c2ee2c9..9b757f7 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -1,1012 +1,1012 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
43 | 43 | ||
44 | #include "sharpformat.h" | 44 | #include "sharpformat.h" |
45 | #include "syncdefines.h" | 45 | #include "syncdefines.h" |
46 | 46 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | 49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY |
50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
51 | 51 | ||
52 | //ARSD silentalarm = 0 | 52 | //ARSD silentalarm = 0 |
53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | 53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly |
54 | // 12 RFRQ | 54 | // 12 RFRQ |
55 | // 13 RPOS pos = 4. monday in month | 55 | // 13 RPOS pos = 4. monday in month |
56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | 56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun |
57 | // 15 REND 0 = no end/ 1 = end | 57 | // 15 REND 0 = no end/ 1 = end |
58 | // 16 REDT rec end dt | 58 | // 16 REDT rec end dt |
59 | //ALSD | 59 | //ALSD |
60 | //ALED | 60 | //ALED |
61 | //MDAY | 61 | //MDAY |
62 | 62 | ||
63 | class SharpParser : public QObject | 63 | class SharpParser : public QObject |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { | 66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { |
67 | } | 67 | } |
68 | 68 | ||
69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) | 69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) |
70 | { | 70 | { |
71 | int i = 1; | 71 | int i = 1; |
72 | bool skip = true; | 72 | bool skip = true; |
73 | int max = attList.count() -2; | 73 | int max = attList.count() -2; |
74 | while ( i < max ) { | 74 | while ( i < max ) { |
75 | if ( !attList[i].isEmpty() ) { | 75 | if ( !attList[i].isEmpty() ) { |
76 | skip = false; | 76 | skip = false; |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | ++i ; | 79 | ++i ; |
80 | } | 80 | } |
81 | if ( skip ) | 81 | if ( skip ) |
82 | return false; | 82 | return false; |
83 | ulong cSum = SharpFormat::getCsum(attList ); | 83 | ulong cSum = SharpFormat::getCsum(attList ); |
84 | 84 | ||
85 | if ( qName == "Event" ) { | 85 | if ( qName == "Event" ) { |
86 | Event *event; | 86 | Event *event; |
87 | event = existingCalendar->event( "Sharp_DTM",attList[0] ); | 87 | event = existingCalendar->event( "Sharp_DTM",attList[0] ); |
88 | if ( event ) | 88 | if ( event ) |
89 | event = (Event*)event->clone(); | 89 | event = (Event*)event->clone(); |
90 | else | 90 | else |
91 | event = new Event; | 91 | event = new Event; |
92 | event->setID("Sharp_DTM", attList[0] ); | 92 | event->setID("Sharp_DTM", attList[0] ); |
93 | event->setCsum( "Sharp_DTM", QString::number( cSum )); | 93 | event->setCsum( "Sharp_DTM", QString::number( cSum )); |
94 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 94 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
95 | 95 | ||
96 | event->setSummary( attList[2] ); | 96 | event->setSummary( attList[2] ); |
97 | event->setLocation( attList[3] ); | 97 | event->setLocation( attList[3] ); |
98 | event->setDescription( attList[4] ); | 98 | event->setDescription( attList[4] ); |
99 | if ( attList[7] == "1" ) { | 99 | if ( attList[7] == "1" ) { |
100 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); | 100 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); |
101 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); | 101 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); |
102 | event->setFloats( true ); | 102 | event->setFloats( true ); |
103 | } else { | 103 | } else { |
104 | event->setFloats( false ); | 104 | event->setFloats( false ); |
105 | event->setDtStart( fromString( attList[5] ) ); | 105 | event->setDtStart( fromString( attList[5] ) ); |
106 | event->setDtEnd( fromString( attList[6] )); | 106 | event->setDtEnd( fromString( attList[6] )); |
107 | } | 107 | } |
108 | 108 | ||
109 | QString rtype = attList[11]; | 109 | QString rtype = attList[11]; |
110 | if ( rtype != "255" ) { | 110 | if ( rtype != "255" ) { |
111 | // qDebug("recurs "); | 111 | // qDebug("recurs "); |
112 | QDate startDate = event->dtStart().date(); | 112 | QDate startDate = event->dtStart().date(); |
113 | 113 | ||
114 | QString freqStr = attList[12]; | 114 | QString freqStr = attList[12]; |
115 | int freq = freqStr.toInt(); | 115 | int freq = freqStr.toInt(); |
116 | 116 | ||
117 | QString hasEndDateStr = attList[15] ; | 117 | QString hasEndDateStr = attList[15] ; |
118 | bool hasEndDate = hasEndDateStr == "1"; | 118 | bool hasEndDate = hasEndDateStr == "1"; |
119 | 119 | ||
120 | QString endDateStr = attList[16]; | 120 | QString endDateStr = attList[16]; |
121 | QDate endDate = fromString( endDateStr ).date(); | 121 | QDate endDate = fromString( endDateStr ).date(); |
122 | 122 | ||
123 | QString weekDaysStr = attList[14]; | 123 | QString weekDaysStr = attList[14]; |
124 | uint weekDaysNum = weekDaysStr.toInt(); | 124 | uint weekDaysNum = weekDaysStr.toInt(); |
125 | 125 | ||
126 | QBitArray weekDays( 7 ); | 126 | QBitArray weekDays( 7 ); |
127 | int i; | 127 | int i; |
128 | int bb = 1; | 128 | int bb = 1; |
129 | for( i = 1; i <= 7; ++i ) { | 129 | for( i = 1; i <= 7; ++i ) { |
130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
131 | bb = 2 << (i-1); | 131 | bb = 2 << (i-1); |
132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
133 | } | 133 | } |
134 | // qDebug("next "); | 134 | // qDebug("next "); |
135 | QString posStr = attList[13]; | 135 | QString posStr = attList[13]; |
136 | int pos = posStr.toInt(); | 136 | int pos = posStr.toInt(); |
137 | Recurrence *r = event->recurrence(); | 137 | Recurrence *r = event->recurrence(); |
138 | 138 | ||
139 | if ( rtype == "0" ) { | 139 | if ( rtype == "0" ) { |
140 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 140 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
141 | else r->setDaily( freq, -1 ); | 141 | else r->setDaily( freq, -1 ); |
142 | } else if ( rtype == "1" ) { | 142 | } else if ( rtype == "1" ) { |
143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
144 | else r->setWeekly( freq, weekDays, -1 ); | 144 | else r->setWeekly( freq, weekDays, -1 ); |
145 | } else if ( rtype == "3" ) { | 145 | } else if ( rtype == "3" ) { |
146 | if ( hasEndDate ) | 146 | if ( hasEndDate ) |
147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
148 | else | 148 | else |
149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
150 | r->addMonthlyDay( startDate.day() ); | 150 | r->addMonthlyDay( startDate.day() ); |
151 | } else if ( rtype == "2" ) { | 151 | } else if ( rtype == "2" ) { |
152 | if ( hasEndDate ) | 152 | if ( hasEndDate ) |
153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
154 | else | 154 | else |
155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
156 | QBitArray days( 7 ); | 156 | QBitArray days( 7 ); |
157 | days.fill( false ); | 157 | days.fill( false ); |
158 | days.setBit( startDate.dayOfWeek() - 1 ); | 158 | days.setBit( startDate.dayOfWeek() - 1 ); |
159 | r->addMonthlyPos( pos, days ); | 159 | r->addMonthlyPos( pos, days ); |
160 | } else if ( rtype == "4" ) { | 160 | } else if ( rtype == "4" ) { |
161 | if ( hasEndDate ) | 161 | if ( hasEndDate ) |
162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
163 | else | 163 | else |
164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
165 | r->addYearlyNum( startDate.month() ); | 165 | r->addYearlyNum( startDate.month() ); |
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | event->recurrence()->unsetRecurs(); | 168 | event->recurrence()->unsetRecurs(); |
169 | } | 169 | } |
170 | 170 | ||
171 | QString categoryList = attList[1] ; | 171 | QString categoryList = attList[1] ; |
172 | event->setCategories( categoryList ); | 172 | event->setCategories( categoryList ); |
173 | 173 | ||
174 | // strange 0 semms to mean: alarm enabled | 174 | // strange 0 semms to mean: alarm enabled |
175 | if ( attList[8] == "0" ) { | 175 | if ( attList[8] == "0" ) { |
176 | Alarm *alarm; | 176 | Alarm *alarm; |
177 | if ( event->alarms().count() > 0 ) | 177 | if ( event->alarms().count() > 0 ) |
178 | alarm = event->alarms().first(); | 178 | alarm = event->alarms().first(); |
179 | else { | 179 | else { |
180 | alarm = new Alarm( event ); | 180 | alarm = new Alarm( event ); |
181 | event->addAlarm( alarm ); | 181 | event->addAlarm( alarm ); |
182 | alarm->setType( Alarm::Audio ); | 182 | alarm->setType( Alarm::Audio ); |
183 | } | 183 | } |
184 | //alarm->setType( Alarm::Audio ); | 184 | //alarm->setType( Alarm::Audio ); |
185 | alarm->setEnabled( true ); | 185 | alarm->setEnabled( true ); |
186 | int alarmOffset = attList[9].toInt(); | 186 | int alarmOffset = attList[9].toInt(); |
187 | alarm->setStartOffset( alarmOffset * -60 ); | 187 | alarm->setStartOffset( alarmOffset * -60 ); |
188 | } else { | 188 | } else { |
189 | Alarm *alarm; | 189 | Alarm *alarm; |
190 | if ( event->alarms().count() > 0 ) { | 190 | if ( event->alarms().count() > 0 ) { |
191 | alarm = event->alarms().first(); | 191 | alarm = event->alarms().first(); |
192 | alarm->setType( Alarm::Audio ); | 192 | alarm->setType( Alarm::Audio ); |
193 | alarm->setStartOffset( -60*15 ); | 193 | alarm->setStartOffset( -60*15 ); |
194 | alarm->setEnabled( false ); | 194 | alarm->setEnabled( false ); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | mCalendar->addEvent( event); | 198 | mCalendar->addEvent( event); |
199 | } else if ( qName == "Todo" ) { | 199 | } else if ( qName == "Todo" ) { |
200 | Todo *todo; | 200 | Todo *todo; |
201 | 201 | ||
202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
203 | if (todo ) | 203 | if (todo ) |
204 | todo = (Todo*)todo->clone(); | 204 | todo = (Todo*)todo->clone(); |
205 | else | 205 | else |
206 | todo = new Todo; | 206 | todo = new Todo; |
207 | 207 | ||
208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
209 | // 0 1 2 3 4 5 6 7 8 | 209 | // 0 1 2 3 4 5 6 7 8 |
210 | //1,,,,,1,4,Loch zumachen,"" | 210 | //1,,,,,1,4,Loch zumachen,"" |
211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
213 | 213 | ||
214 | todo->setID( "Sharp_DTM", attList[0]); | 214 | todo->setID( "Sharp_DTM", attList[0]); |
215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
217 | 217 | ||
218 | todo->setSummary( attList[7] ); | 218 | todo->setSummary( attList[7] ); |
219 | todo->setDescription( attList[8]); | 219 | todo->setDescription( attList[8]); |
220 | 220 | ||
221 | int priority = attList[6].toInt(); | 221 | int priority = attList[6].toInt(); |
222 | if ( priority == 0 ) priority = 3; | 222 | if ( priority == 0 ) priority = 3; |
223 | todo->setPriority( priority ); | 223 | todo->setPriority( priority ); |
224 | 224 | ||
225 | QString categoryList = attList[1]; | 225 | QString categoryList = attList[1]; |
226 | todo->setCategories( categoryList ); | 226 | todo->setCategories( categoryList ); |
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | QString hasDateStr = attList[3]; // due | 230 | QString hasDateStr = attList[3]; // due |
231 | if ( !hasDateStr.isEmpty() ) { | 231 | if ( !hasDateStr.isEmpty() ) { |
232 | if ( hasDateStr.right(6) == "000000" ) { | 232 | if ( hasDateStr.right(6) == "000000" ) { |
233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
234 | todo->setFloats( true ); | 234 | todo->setFloats( true ); |
235 | } | 235 | } |
236 | else { | 236 | else { |
237 | todo->setDtDue( fromString( hasDateStr ) ); | 237 | todo->setDtDue( fromString( hasDateStr ) ); |
238 | todo->setFloats( false ); | 238 | todo->setFloats( false ); |
239 | } | 239 | } |
240 | 240 | ||
241 | todo->setHasDueDate( true ); | 241 | todo->setHasDueDate( true ); |
242 | } | 242 | } |
243 | hasDateStr = attList[2];//start | 243 | hasDateStr = attList[2];//start |
244 | if ( !hasDateStr.isEmpty() ) { | 244 | if ( !hasDateStr.isEmpty() ) { |
245 | 245 | ||
246 | todo->setDtStart( fromString( hasDateStr ) ); | 246 | todo->setDtStart( fromString( hasDateStr ) ); |
247 | todo->setHasStartDate( true); | 247 | todo->setHasStartDate( true); |
248 | } else | 248 | } else |
249 | todo->setHasStartDate( false ); | 249 | todo->setHasStartDate( false ); |
250 | hasDateStr = attList[4];//completed | 250 | hasDateStr = attList[4];//completed |
251 | if ( !hasDateStr.isEmpty() ) { | 251 | if ( !hasDateStr.isEmpty() ) { |
252 | todo->setCompleted(fromString( hasDateStr ) ); | 252 | todo->setCompleted(fromString( hasDateStr ) ); |
253 | } | 253 | } |
254 | QString completedStr = attList[5]; | 254 | QString completedStr = attList[5]; |
255 | if ( completedStr == "0" ) | 255 | if ( completedStr == "0" ) |
256 | todo->setCompleted( true ); | 256 | todo->setCompleted( true ); |
257 | else { | 257 | else { |
258 | // do not change percent complete | 258 | // do not change percent complete |
259 | if ( todo->isCompleted() ) | 259 | if ( todo->isCompleted() ) |
260 | todo->setCompleted( false ); | 260 | todo->setCompleted( false ); |
261 | } | 261 | } |
262 | mCalendar->addTodo( todo ); | 262 | mCalendar->addTodo( todo ); |
263 | 263 | ||
264 | } else if ( qName == "Category" ) { | 264 | } else if ( qName == "Category" ) { |
265 | /* | 265 | /* |
266 | QString id = attributes.value( "id" ); | 266 | QString id = attributes.value( "id" ); |
267 | QString name = attributes.value( "name" ); | 267 | QString name = attributes.value( "name" ); |
268 | setCategory( id, name ); | 268 | setCategory( id, name ); |
269 | */ | 269 | */ |
270 | } | 270 | } |
271 | //qDebug("end "); | 271 | //qDebug("end "); |
272 | return true; | 272 | return true; |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | QDateTime fromString ( QString s, bool useTz = true ) { | 276 | QDateTime fromString ( QString s, bool useTz = true ) { |
277 | QDateTime dt; | 277 | QDateTime dt; |
278 | int y,m,t,h,min,sec; | 278 | int y,m,t,h,min,sec; |
279 | y = s.mid(0,4).toInt(); | 279 | y = s.mid(0,4).toInt(); |
280 | m = s.mid(4,2).toInt(); | 280 | m = s.mid(4,2).toInt(); |
281 | t = s.mid(6,2).toInt(); | 281 | t = s.mid(6,2).toInt(); |
282 | h = s.mid(9,2).toInt(); | 282 | h = s.mid(9,2).toInt(); |
283 | min = s.mid(11,2).toInt(); | 283 | min = s.mid(11,2).toInt(); |
284 | sec = s.mid(13,2).toInt(); | 284 | sec = s.mid(13,2).toInt(); |
285 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 285 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
286 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 286 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
287 | if ( useTz ) | 287 | if ( useTz ) |
288 | dt = dt.addSecs ( offset*60); | 288 | dt = dt.addSecs ( offset*60); |
289 | return dt; | 289 | return dt; |
290 | 290 | ||
291 | } | 291 | } |
292 | protected: | 292 | protected: |
293 | QDateTime toDateTime( const QString &value ) | 293 | QDateTime toDateTime( const QString &value ) |
294 | { | 294 | { |
295 | QDateTime dt; | 295 | QDateTime dt; |
296 | dt.setTime_t( value.toUInt() ); | 296 | dt.setTime_t( value.toUInt() ); |
297 | 297 | ||
298 | return dt; | 298 | return dt; |
299 | } | 299 | } |
300 | 300 | ||
301 | private: | 301 | private: |
302 | Calendar *mCalendar; | 302 | Calendar *mCalendar; |
303 | }; | 303 | }; |
304 | 304 | ||
305 | 305 | ||
306 | SharpFormat::SharpFormat() | 306 | SharpFormat::SharpFormat() |
307 | { | 307 | { |
308 | 308 | ||
309 | } | 309 | } |
310 | 310 | ||
311 | SharpFormat::~SharpFormat() | 311 | SharpFormat::~SharpFormat() |
312 | { | 312 | { |
313 | } | 313 | } |
314 | ulong SharpFormat::getCsum( const QStringList & attList) | 314 | ulong SharpFormat::getCsum( const QStringList & attList) |
315 | { | 315 | { |
316 | int max = attList.count() -1; | 316 | int max = attList.count() -1; |
317 | ulong cSum = 0; | 317 | ulong cSum = 0; |
318 | int j,k,i; | 318 | int j,k,i; |
319 | int add; | 319 | int add; |
320 | for ( i = 1; i < max ; ++i ) { | 320 | for ( i = 1; i < max ; ++i ) { |
321 | QString s = attList[i]; | 321 | QString s = attList[i]; |
322 | if ( ! s.isEmpty() ){ | 322 | if ( ! s.isEmpty() ){ |
323 | j = s.length(); | 323 | j = s.length(); |
324 | for ( k = 0; k < j; ++k ) { | 324 | for ( k = 0; k < j; ++k ) { |
325 | int mul = k +1; | 325 | int mul = k +1; |
326 | add = s[k].unicode (); | 326 | add = s[k].unicode (); |
327 | if ( k < 16 ) | 327 | if ( k < 16 ) |
328 | mul = mul * mul; | 328 | mul = mul * mul; |
329 | add = add * mul *i*i*i; | 329 | add = add * mul *i*i*i; |
330 | cSum += add; | 330 | cSum += add; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | } | 333 | } |
334 | return cSum; | 334 | return cSum; |
335 | 335 | ||
336 | } | 336 | } |
337 | #include <stdlib.h> | 337 | #include <stdlib.h> |
338 | #define DEBUGMODE false | 338 | #define DEBUGMODE false |
339 | //#define DEBUGMODE true | 339 | //#define DEBUGMODE true |
340 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 340 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
341 | { | 341 | { |
342 | 342 | ||
343 | 343 | ||
344 | bool debug = DEBUGMODE; | 344 | bool debug = DEBUGMODE; |
345 | QString text; | 345 | QString text; |
346 | QString codec = "utf8"; | 346 | QString codec = "utf8"; |
347 | QLabel status ( i18n("Reading events ..."), 0 ); | 347 | QLabel status ( i18n("Reading events ..."), 0 ); |
348 | 348 | ||
349 | int w = status.sizeHint().width()+20 ; | 349 | int w = status.sizeHint().width()+20 ; |
350 | if ( w < 200 ) w = 200; | 350 | if ( w < 200 ) w = 200; |
351 | int h = status.sizeHint().height()+20 ; | 351 | int h = status.sizeHint().height()+20 ; |
352 | int dw = QApplication::desktop()->width(); | 352 | int dw = QApplication::desktop()->width(); |
353 | int dh = QApplication::desktop()->height(); | 353 | int dh = QApplication::desktop()->height(); |
354 | status.setCaption(i18n("Reading DTM Data") ); | 354 | status.setCaption(i18n("Reading DTM Data") ); |
355 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 355 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
356 | status.show(); | 356 | status.show(); |
357 | status.raise(); | 357 | status.raise(); |
358 | qApp->processEvents(); | 358 | qApp->processEvents(); |
359 | QString fileName; | 359 | QString fileName; |
360 | if ( ! debug ) { | 360 | if ( ! debug ) { |
361 | fileName = "/tmp/kopitempout"; | 361 | fileName = "/tmp/kopitempout"; |
362 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 362 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
363 | system ( command.latin1() ); | 363 | system ( command.latin1() ); |
364 | } else { | 364 | } else { |
365 | fileName = "/tmp/events.txt"; | 365 | fileName = "/tmp/events.txt"; |
366 | 366 | ||
367 | } | 367 | } |
368 | QFile file( fileName ); | 368 | QFile file( fileName ); |
369 | if (!file.open( IO_ReadOnly ) ) { | 369 | if (!file.open( IO_ReadOnly ) ) { |
370 | return false; | 370 | return false; |
371 | 371 | ||
372 | } | 372 | } |
373 | QTextStream ts( &file ); | 373 | QTextStream ts( &file ); |
374 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 374 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
375 | text = ts.read(); | 375 | text = ts.read(); |
376 | file.close(); | 376 | file.close(); |
377 | status.setText( i18n("Processing events ...") ); | 377 | status.setText( i18n("Processing events ...") ); |
378 | status.raise(); | 378 | status.raise(); |
379 | qApp->processEvents(); | 379 | qApp->processEvents(); |
380 | fromString2Cal( calendar, existngCal, text, "Event" ); | 380 | fromString2Cal( calendar, existngCal, text, "Event" ); |
381 | status.setText( i18n("Reading todos ...") ); | 381 | status.setText( i18n("Reading todos ...") ); |
382 | qApp->processEvents(); | 382 | qApp->processEvents(); |
383 | if ( ! debug ) { | 383 | if ( ! debug ) { |
384 | fileName = "/tmp/kopitempout"; | 384 | fileName = "/tmp/kopitempout"; |
385 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 385 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
386 | system ( command.latin1() ); | 386 | system ( command.latin1() ); |
387 | } else { | 387 | } else { |
388 | fileName = "/tmp/todo.txt"; | 388 | fileName = "/tmp/todo.txt"; |
389 | } | 389 | } |
390 | file.setName( fileName ); | 390 | file.setName( fileName ); |
391 | if (!file.open( IO_ReadOnly ) ) { | 391 | if (!file.open( IO_ReadOnly ) ) { |
392 | return false; | 392 | return false; |
393 | 393 | ||
394 | } | 394 | } |
395 | ts.setDevice( &file ); | 395 | ts.setDevice( &file ); |
396 | text = ts.read(); | 396 | text = ts.read(); |
397 | file.close(); | 397 | file.close(); |
398 | 398 | ||
399 | status.setText( i18n("Processing todos ...") ); | 399 | status.setText( i18n("Processing todos ...") ); |
400 | status.raise(); | 400 | status.raise(); |
401 | qApp->processEvents(); | 401 | qApp->processEvents(); |
402 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 402 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
403 | return true; | 403 | return true; |
404 | } | 404 | } |
405 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 405 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
406 | { | 406 | { |
407 | int retval = -1; | 407 | int retval = -1; |
408 | QStringList templist; | 408 | QStringList templist; |
409 | QString tempString; | 409 | QString tempString; |
410 | int start = 0; | 410 | int start = 0; |
411 | int len = answer.length(); | 411 | int len = answer.length(); |
412 | int end = answer.find ("\n",start)+1; | 412 | int end = answer.find ("\n",start)+1; |
413 | bool ok = true; | 413 | bool ok = true; |
414 | start = end; | 414 | start = end; |
415 | int ccc = 0; | 415 | int ccc = 0; |
416 | while ( start > 0 ) { | 416 | while ( start > 0 ) { |
417 | templist.clear(); | 417 | templist.clear(); |
418 | ok = true; | 418 | ok = true; |
419 | int loopCount = 0; | 419 | int loopCount = 0; |
420 | while ( ok ) { | 420 | while ( ok ) { |
421 | ++loopCount; | 421 | ++loopCount; |
422 | if ( loopCount > 25 ) { | 422 | if ( loopCount > 25 ) { |
423 | qDebug("KO: Error in while loop"); | 423 | qDebug("KO: Error in while loop"); |
424 | ok = false; | 424 | ok = false; |
425 | start = 0; | 425 | start = 0; |
426 | break; | 426 | break; |
427 | } | 427 | } |
428 | if ( ok ) | 428 | if ( ok ) |
429 | tempString = getPart( answer, ok, start ); | 429 | tempString = getPart( answer, ok, start ); |
430 | if ( start >= len || start == 0 ) { | 430 | if ( start >= len || start == 0 ) { |
431 | start = 0; | 431 | start = 0; |
432 | ok = false; | 432 | ok = false; |
433 | } | 433 | } |
434 | if ( tempString.right(1) =="\n" ) | 434 | if ( tempString.right(1) =="\n" ) |
435 | tempString = tempString.left( tempString.length()-1); | 435 | tempString = tempString.left( tempString.length()-1); |
436 | 436 | ||
437 | templist.append( tempString ); | 437 | templist.append( tempString ); |
438 | } | 438 | } |
439 | ++ccc; | 439 | ++ccc; |
440 | if ( ccc == 2 && loopCount < 25 ) { | 440 | if ( ccc == 2 && loopCount < 25 ) { |
441 | start = 0; | 441 | start = 0; |
442 | bool ok; | 442 | bool ok; |
443 | int newnum = templist[0].toInt( &ok ); | 443 | int newnum = templist[0].toInt( &ok ); |
444 | if ( ok && newnum > 0) { | 444 | if ( ok && newnum > 0) { |
445 | retval = newnum; | 445 | retval = newnum; |
446 | inc->setID( "Sharp_DTM",templist[0] ); | 446 | inc->setID( "Sharp_DTM",templist[0] ); |
447 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); | 447 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); |
448 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 448 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
449 | } | 449 | } |
450 | if ( ok && newnum == -1 ) { | 450 | if ( ok && newnum == -1 ) { |
451 | qDebug("Error writing back %s ", inc->summary().latin1()); | 451 | qDebug("Error writing back %s ", inc->summary().latin1()); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | } | 454 | } |
455 | //qDebug("getNumFromRecord returning : %d ", retval); | 455 | //qDebug("getNumFromRecord returning : %d ", retval); |
456 | return retval; | 456 | return retval; |
457 | } | 457 | } |
458 | bool SharpFormat::save( Calendar *calendar) | 458 | bool SharpFormat::save( Calendar *calendar) |
459 | { | 459 | { |
460 | 460 | ||
461 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 461 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
462 | int w = status.sizeHint().width()+20 ; | 462 | int w = status.sizeHint().width()+20 ; |
463 | if ( w < 200 ) w = 200; | 463 | if ( w < 200 ) w = 200; |
464 | int h = status.sizeHint().height()+20 ; | 464 | int h = status.sizeHint().height()+20 ; |
465 | int dw = QApplication::desktop()->width(); | 465 | int dw = QApplication::desktop()->width(); |
466 | int dh = QApplication::desktop()->height(); | 466 | int dh = QApplication::desktop()->height(); |
467 | status.setCaption(i18n("Writing DTM Data") ); | 467 | status.setCaption(i18n("Writing DTM Data") ); |
468 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 468 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
469 | status.show(); | 469 | status.show(); |
470 | status.raise(); | 470 | status.raise(); |
471 | qApp->processEvents(); | 471 | qApp->processEvents(); |
472 | bool debug = DEBUGMODE; | 472 | bool debug = DEBUGMODE; |
473 | QString codec = "utf8"; | 473 | QString codec = "utf8"; |
474 | QString answer; | 474 | QString answer; |
475 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 475 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
476 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 476 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
477 | QString command; | 477 | QString command; |
478 | QPtrList<Event> er = calendar->rawEvents(); | 478 | QPtrList<Event> er = calendar->rawEvents(); |
479 | Event* ev = er.first(); | 479 | Event* ev = er.first(); |
480 | QString fileName = "/tmp/kopitempout"; | 480 | QString fileName = "/tmp/kopitempout"; |
481 | int i = 0; | 481 | int i = 0; |
482 | QString changeString = ePrefix; | 482 | QString changeString = ePrefix; |
483 | QString deleteString = ePrefix; | 483 | QString deleteString = ePrefix; |
484 | bool deleteEnt = false; | 484 | bool deleteEnt = false; |
485 | bool changeEnt = false; | 485 | bool changeEnt = false; |
486 | QString message = i18n("Processing event # "); | 486 | QString message = i18n("Processing event # "); |
487 | int procCount = 0; | 487 | int procCount = 0; |
488 | while ( ev ) { | 488 | while ( ev ) { |
489 | //qDebug("i %d ", ++i); | 489 | //qDebug("i %d ", ++i); |
490 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 490 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
491 | status.setText ( message + QString::number ( ++procCount ) ); | 491 | status.setText ( message + QString::number ( ++procCount ) ); |
492 | qApp->processEvents(); | 492 | qApp->processEvents(); |
493 | QString eString = getEventString( ev ); | 493 | QString eString = getEventString( ev ); |
494 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 494 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
495 | // deleting empty strings does not work. | 495 | // deleting empty strings does not work. |
496 | // we write first and x and then delete the record with the x | 496 | // we write first and x and then delete the record with the x |
497 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 497 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
498 | changeString += eString + "\n"; | 498 | changeString += eString + "\n"; |
499 | deleteString += eString + "\n"; | 499 | deleteString += eString + "\n"; |
500 | deleteEnt = true; | 500 | deleteEnt = true; |
501 | changeEnt = true; | 501 | changeEnt = true; |
502 | } | 502 | } |
503 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new | 503 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new |
504 | QString fileNameIn = "/tmp/kopitempin"; | 504 | QString fileNameIn = "/tmp/kopitempin"; |
505 | QFile fileIn( fileNameIn ); | 505 | QFile fileIn( fileNameIn ); |
506 | if (!fileIn.open( IO_WriteOnly ) ) { | 506 | if (!fileIn.open( IO_WriteOnly ) ) { |
507 | return false; | 507 | return false; |
508 | } | 508 | } |
509 | QTextStream tsIn( &fileIn ); | 509 | QTextStream tsIn( &fileIn ); |
510 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 510 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
511 | tsIn << ePrefix << eString ; | 511 | tsIn << ePrefix << eString ; |
512 | fileIn.close(); | 512 | fileIn.close(); |
513 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 513 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
514 | command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; | 514 | command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; |
515 | //qDebug("command ++++++++ "); | 515 | //qDebug("command ++++++++ "); |
516 | //qDebug("%s ",command.latin1()); | 516 | //qDebug("%s ",command.latin1()); |
517 | //qDebug("command -------- "); | 517 | //qDebug("command -------- "); |
518 | system ( command.utf8() ); | 518 | system ( command.utf8() ); |
519 | QFile file( fileName ); | 519 | QFile file( fileName ); |
520 | if (!file.open( IO_ReadOnly ) ) { | 520 | if (!file.open( IO_ReadOnly ) ) { |
521 | return false; | 521 | return false; |
522 | 522 | ||
523 | } | 523 | } |
524 | QTextStream ts( &file ); | 524 | QTextStream ts( &file ); |
525 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 525 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
526 | answer = ts.read(); | 526 | answer = ts.read(); |
527 | file.close(); | 527 | file.close(); |
528 | //qDebug("answer \n%s ", answer.latin1()); | 528 | //qDebug("answer \n%s ", answer.latin1()); |
529 | getNumFromRecord( answer, ev ) ; | 529 | getNumFromRecord( answer, ev ) ; |
530 | 530 | ||
531 | } | 531 | } |
532 | else { // change existing | 532 | else { // change existing |
533 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 533 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
534 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 534 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
535 | changeString += eString + "\n"; | 535 | changeString += eString + "\n"; |
536 | changeEnt = true; | 536 | changeEnt = true; |
537 | 537 | ||
538 | } | 538 | } |
539 | } | 539 | } |
540 | ev = er.next(); | 540 | ev = er.next(); |
541 | } | 541 | } |
542 | status.setText ( i18n("Changing events ...") ); | 542 | status.setText ( i18n("Changing events ...") ); |
543 | qApp->processEvents(); | 543 | qApp->processEvents(); |
544 | //qDebug("changing... "); | 544 | //qDebug("changing... "); |
545 | if ( changeEnt ) { | 545 | if ( changeEnt ) { |
546 | QFile file( fileName ); | 546 | QFile file( fileName ); |
547 | if (!file.open( IO_WriteOnly ) ) { | 547 | if (!file.open( IO_WriteOnly ) ) { |
548 | return false; | 548 | return false; |
549 | 549 | ||
550 | } | 550 | } |
551 | QTextStream ts( &file ); | 551 | QTextStream ts( &file ); |
552 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 552 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
553 | ts << changeString ; | 553 | ts << changeString ; |
554 | file.close(); | 554 | file.close(); |
555 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | 555 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; |
556 | system ( command.latin1() ); | 556 | system ( command.latin1() ); |
557 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 557 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
558 | 558 | ||
559 | } | 559 | } |
560 | status.setText ( i18n("Deleting events ...") ); | 560 | status.setText ( i18n("Deleting events ...") ); |
561 | qApp->processEvents(); | 561 | qApp->processEvents(); |
562 | //qDebug("deleting... "); | 562 | //qDebug("deleting... "); |
563 | if ( deleteEnt ) { | 563 | if ( deleteEnt ) { |
564 | QFile file( fileName ); | 564 | QFile file( fileName ); |
565 | if (!file.open( IO_WriteOnly ) ) { | 565 | if (!file.open( IO_WriteOnly ) ) { |
566 | return false; | 566 | return false; |
567 | 567 | ||
568 | } | 568 | } |
569 | QTextStream ts( &file ); | 569 | QTextStream ts( &file ); |
570 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 570 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
571 | ts << deleteString; | 571 | ts << deleteString; |
572 | file.close(); | 572 | file.close(); |
573 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | 573 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; |
574 | system ( command.latin1() ); | 574 | system ( command.latin1() ); |
575 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 575 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
576 | } | 576 | } |
577 | 577 | ||
578 | 578 | ||
579 | changeString = tPrefix; | 579 | changeString = tPrefix; |
580 | deleteString = tPrefix; | 580 | deleteString = tPrefix; |
581 | status.setText ( i18n("Processing todos ...") ); | 581 | status.setText ( i18n("Processing todos ...") ); |
582 | qApp->processEvents(); | 582 | qApp->processEvents(); |
583 | QPtrList<Todo> tl = calendar->rawTodos(); | 583 | QPtrList<Todo> tl = calendar->rawTodos(); |
584 | Todo* to = tl.first(); | 584 | Todo* to = tl.first(); |
585 | i = 0; | 585 | i = 0; |
586 | message = i18n("Processing todo # "); | 586 | message = i18n("Processing todo # "); |
587 | procCount = 0; | 587 | procCount = 0; |
588 | while ( to ) { | 588 | while ( to ) { |
589 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 589 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
590 | status.setText ( message + QString::number ( ++procCount ) ); | 590 | status.setText ( message + QString::number ( ++procCount ) ); |
591 | qApp->processEvents(); | 591 | qApp->processEvents(); |
592 | QString eString = getTodoString( to ); | 592 | QString eString = getTodoString( to ); |
593 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 593 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
594 | // deleting empty strings does not work. | 594 | // deleting empty strings does not work. |
595 | // we write first and x and then delete the record with the x | 595 | // we write first and x and then delete the record with the x |
596 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 596 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
597 | changeString += eString + "\n"; | 597 | changeString += eString + "\n"; |
598 | deleteString += eString + "\n"; | 598 | deleteString += eString + "\n"; |
599 | deleteEnt = true; | 599 | deleteEnt = true; |
600 | changeEnt = true; | 600 | changeEnt = true; |
601 | } | 601 | } |
602 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new | 602 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new |
603 | 603 | ||
604 | 604 | ||
605 | 605 | ||
606 | QString fileNameIn = "/tmp/kopitempin"; | 606 | QString fileNameIn = "/tmp/kopitempin"; |
607 | QFile fileIn( fileNameIn ); | 607 | QFile fileIn( fileNameIn ); |
608 | if (!fileIn.open( IO_WriteOnly ) ) { | 608 | if (!fileIn.open( IO_WriteOnly ) ) { |
609 | return false; | 609 | return false; |
610 | } | 610 | } |
611 | QTextStream tsIn( &fileIn ); | 611 | QTextStream tsIn( &fileIn ); |
612 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 612 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
613 | tsIn << tPrefix << eString ; | 613 | tsIn << tPrefix << eString ; |
614 | fileIn.close(); | 614 | fileIn.close(); |
615 | command = "(cat /tmp/kopitempin | db2file todo -w -g -c " + codec+ ") > "+ fileName; | 615 | command = "(cat /tmp/kopitempin | db2file todo -w -g -c " + codec+ ") > "+ fileName; |
616 | system ( command.utf8() ); | 616 | system ( command.utf8() ); |
617 | QFile file( fileName ); | 617 | QFile file( fileName ); |
618 | if (!file.open( IO_ReadOnly ) ) { | 618 | if (!file.open( IO_ReadOnly ) ) { |
619 | return false; | 619 | return false; |
620 | } | 620 | } |
621 | QTextStream ts( &file ); | 621 | QTextStream ts( &file ); |
622 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 622 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
623 | answer = ts.read(); | 623 | answer = ts.read(); |
624 | file.close(); | 624 | file.close(); |
625 | //qDebug("answer \n%s ", answer.latin1()); | 625 | //qDebug("answer \n%s ", answer.latin1()); |
626 | getNumFromRecord( answer, to ) ; | 626 | getNumFromRecord( answer, to ) ; |
627 | 627 | ||
628 | } | 628 | } |
629 | else { // change existing | 629 | else { // change existing |
630 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); | 630 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); |
631 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 631 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
632 | changeString += eString + "\n"; | 632 | changeString += eString + "\n"; |
633 | changeEnt = true; | 633 | changeEnt = true; |
634 | 634 | ||
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | to = tl.next(); | 638 | to = tl.next(); |
639 | } | 639 | } |
640 | status.setText ( i18n("Changing todos ...") ); | 640 | status.setText ( i18n("Changing todos ...") ); |
641 | qApp->processEvents(); | 641 | qApp->processEvents(); |
642 | //qDebug("changing... "); | 642 | //qDebug("changing... "); |
643 | if ( changeEnt ) { | 643 | if ( changeEnt ) { |
644 | QFile file( fileName ); | 644 | QFile file( fileName ); |
645 | if (!file.open( IO_WriteOnly ) ) { | 645 | if (!file.open( IO_WriteOnly ) ) { |
646 | return false; | 646 | return false; |
647 | 647 | ||
648 | } | 648 | } |
649 | QTextStream ts( &file ); | 649 | QTextStream ts( &file ); |
650 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 650 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
651 | ts << changeString ; | 651 | ts << changeString ; |
652 | file.close(); | 652 | file.close(); |
653 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; | 653 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; |
654 | system ( command.latin1() ); | 654 | system ( command.latin1() ); |
655 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 655 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
656 | 656 | ||
657 | } | 657 | } |
658 | status.setText ( i18n("Deleting todos ...") ); | 658 | status.setText ( i18n("Deleting todos ...") ); |
659 | qApp->processEvents(); | 659 | qApp->processEvents(); |
660 | //qDebug("deleting... "); | 660 | //qDebug("deleting... "); |
661 | if ( deleteEnt ) { | 661 | if ( deleteEnt ) { |
662 | QFile file( fileName ); | 662 | QFile file( fileName ); |
663 | if (!file.open( IO_WriteOnly ) ) { | 663 | if (!file.open( IO_WriteOnly ) ) { |
664 | return false; | 664 | return false; |
665 | 665 | ||
666 | } | 666 | } |
667 | QTextStream ts( &file ); | 667 | QTextStream ts( &file ); |
668 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 668 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
669 | ts << deleteString; | 669 | ts << deleteString; |
670 | file.close(); | 670 | file.close(); |
671 | command = "db2file todo -d -c " + codec+ " < "+ fileName; | 671 | command = "db2file todo -d -c " + codec+ " < "+ fileName; |
672 | system ( command.latin1() ); | 672 | system ( command.latin1() ); |
673 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 673 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
674 | } | 674 | } |
675 | 675 | ||
676 | return true; | 676 | return true; |
677 | } | 677 | } |
678 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) | 678 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) |
679 | { | 679 | { |
680 | QString datestr; | 680 | QString datestr; |
681 | QString timestr; | 681 | QString timestr; |
682 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 682 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
683 | QDateTime dt; | 683 | QDateTime dt; |
684 | if (useTZ) | 684 | if (useTZ) |
685 | dt = dti.addSecs ( -(offset*60)); | 685 | dt = dti.addSecs ( -(offset*60)); |
686 | else | 686 | else |
687 | dt = dti; | 687 | dt = dti; |
688 | if(dt.date().isValid()){ | 688 | if(dt.date().isValid()){ |
689 | const QDate& date = dt.date(); | 689 | const QDate& date = dt.date(); |
690 | datestr.sprintf("%04d%02d%02d", | 690 | datestr.sprintf("%04d%02d%02d", |
691 | date.year(), date.month(), date.day()); | 691 | date.year(), date.month(), date.day()); |
692 | } | 692 | } |
693 | if(dt.time().isValid()){ | 693 | if(dt.time().isValid()){ |
694 | const QTime& time = dt.time(); | 694 | const QTime& time = dt.time(); |
695 | timestr.sprintf("T%02d%02d%02d", | 695 | timestr.sprintf("T%02d%02d%02d", |
696 | time.hour(), time.minute(), time.second()); | 696 | time.hour(), time.minute(), time.second()); |
697 | } | 697 | } |
698 | return datestr + timestr; | 698 | return datestr + timestr; |
699 | } | 699 | } |
700 | QString SharpFormat::getEventString( Event* event ) | 700 | QString SharpFormat::getEventString( Event* event ) |
701 | { | 701 | { |
702 | QStringList list; | 702 | QStringList list; |
703 | list.append( event->getID("Sharp_DTM") ); | 703 | list.append( event->getID("Sharp_DTM") ); |
704 | list.append( event->categories().join(",") ); | 704 | list.append( event->categories().join(",") ); |
705 | if ( !event->summary().isEmpty() ) | 705 | if ( !event->summary().isEmpty() ) |
706 | list.append( event->summary() ); | 706 | list.append( event->summary() ); |
707 | else | 707 | else |
708 | list.append("" ); | 708 | list.append("" ); |
709 | if ( !event->location().isEmpty() ) | 709 | if ( !event->location().isEmpty() ) |
710 | list.append( event->location() ); | 710 | list.append( event->location() ); |
711 | else | 711 | else |
712 | list.append("" ); | 712 | list.append("" ); |
713 | if ( !event->description().isEmpty() ) | 713 | if ( !event->description().isEmpty() ) |
714 | list.append( event->description() ); | 714 | list.append( event->description() ); |
715 | else | 715 | else |
716 | list.append( "" ); | 716 | list.append( "" ); |
717 | if ( event->doesFloat () ) { | 717 | if ( event->doesFloat () ) { |
718 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | 718 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); |
719 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | 719 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 |
720 | list.append( "1" ); | 720 | list.append( "1" ); |
721 | 721 | ||
722 | } | 722 | } |
723 | else { | 723 | else { |
724 | list.append( dtToString( event->dtStart()) ); | 724 | list.append( dtToString( event->dtStart()) ); |
725 | list.append( dtToString( event->dtEnd()) ); //6 | 725 | list.append( dtToString( event->dtEnd()) ); //6 |
726 | list.append( "0" ); | 726 | list.append( "0" ); |
727 | } | 727 | } |
728 | bool noAlarm = true; | 728 | bool noAlarm = true; |
729 | if ( event->alarms().count() > 0 ) { | 729 | if ( event->alarms().count() > 0 ) { |
730 | Alarm * al = event->alarms().first(); | 730 | Alarm * al = event->alarms().first(); |
731 | if ( al->enabled() ) { | 731 | if ( al->enabled() ) { |
732 | noAlarm = false; | 732 | noAlarm = false; |
733 | list.append( "0" ); // yes, 0 == alarm | 733 | list.append( "0" ); // yes, 0 == alarm |
734 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | 734 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); |
735 | if ( al->type() == Alarm::Audio ) | 735 | if ( al->type() == Alarm::Audio ) |
736 | list.append( "1" ); // type audio | 736 | list.append( "1" ); // type audio |
737 | else | 737 | else |
738 | list.append( "0" ); // type silent | 738 | list.append( "0" ); // type silent |
739 | } | 739 | } |
740 | } | 740 | } |
741 | if ( noAlarm ) { | 741 | if ( noAlarm ) { |
742 | list.append( "1" ); // yes, 1 == no alarm | 742 | list.append( "1" ); // yes, 1 == no alarm |
743 | list.append( "0" ); // no alarm offset | 743 | list.append( "0" ); // no alarm offset |
744 | list.append( "1" ); // type | 744 | list.append( "1" ); // type |
745 | } | 745 | } |
746 | // next is: 11 | 746 | // next is: 11 |
747 | // next is: 11-16 are recurrence | 747 | // next is: 11-16 are recurrence |
748 | Recurrence* rec = event->recurrence(); | 748 | Recurrence* rec = event->recurrence(); |
749 | 749 | ||
750 | bool writeEndDate = false; | 750 | bool writeEndDate = false; |
751 | switch ( rec->doesRecur() ) | 751 | switch ( rec->doesRecur() ) |
752 | { | 752 | { |
753 | case Recurrence::rDaily: // 0 | 753 | case Recurrence::rDaily: // 0 |
754 | list.append( "0" ); | 754 | list.append( "0" ); |
755 | list.append( QString::number( rec->frequency() ));//12 | 755 | list.append( QString::number( rec->frequency() ));//12 |
756 | list.append( "0" ); | 756 | list.append( "0" ); |
757 | list.append( "0" ); | 757 | list.append( "0" ); |
758 | writeEndDate = true; | 758 | writeEndDate = true; |
759 | break; | 759 | break; |
760 | case Recurrence::rWeekly:// 1 | 760 | case Recurrence::rWeekly:// 1 |
761 | list.append( "1" ); | 761 | list.append( "1" ); |
762 | list.append( QString::number( rec->frequency()) );//12 | 762 | list.append( QString::number( rec->frequency()) );//12 |
763 | list.append( "0" ); | 763 | list.append( "0" ); |
764 | { | 764 | { |
765 | int days = 0; | 765 | int days = 0; |
766 | QBitArray weekDays = rec->days(); | 766 | QBitArray weekDays = rec->days(); |
767 | int i; | 767 | int i; |
768 | for( i = 1; i <= 7; ++i ) { | 768 | for( i = 1; i <= 7; ++i ) { |
769 | if ( weekDays[i-1] ) { | 769 | if ( weekDays[i-1] ) { |
770 | days += 1 << (i-1); | 770 | days += 1 << (i-1); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | list.append( QString::number( days ) ); | 773 | list.append( QString::number( days ) ); |
774 | } | 774 | } |
775 | //pending weekdays | 775 | //pending weekdays |
776 | writeEndDate = true; | 776 | writeEndDate = true; |
777 | 777 | ||
778 | break; | 778 | break; |
779 | case Recurrence::rMonthlyPos:// 2 | 779 | case Recurrence::rMonthlyPos:// 2 |
780 | list.append( "2" ); | 780 | list.append( "2" ); |
781 | list.append( QString::number( rec->frequency()) );//12 | 781 | list.append( QString::number( rec->frequency()) );//12 |
782 | 782 | ||
783 | writeEndDate = true; | 783 | writeEndDate = true; |
784 | { | 784 | { |
785 | int count = 1; | 785 | int count = 1; |
786 | QPtrList<Recurrence::rMonthPos> rmp; | 786 | QPtrList<Recurrence::rMonthPos> rmp; |
787 | rmp = rec->monthPositions(); | 787 | rmp = rec->monthPositions(); |
788 | if ( rmp.first()->negative ) | 788 | if ( rmp.first()->negative ) |
789 | count = 5 - rmp.first()->rPos - 1; | 789 | count = 5 - rmp.first()->rPos - 1; |
790 | else | 790 | else |
791 | count = rmp.first()->rPos - 1; | 791 | count = rmp.first()->rPos - 1; |
792 | list.append( QString::number( count ) ); | 792 | list.append( QString::number( count ) ); |
793 | 793 | ||
794 | } | 794 | } |
795 | 795 | ||
796 | list.append( "0" ); | 796 | list.append( "0" ); |
797 | break; | 797 | break; |
798 | case Recurrence::rMonthlyDay:// 3 | 798 | case Recurrence::rMonthlyDay:// 3 |
799 | list.append( "3" ); | 799 | list.append( "3" ); |
800 | list.append( QString::number( rec->frequency()) );//12 | 800 | list.append( QString::number( rec->frequency()) );//12 |
801 | list.append( "0" ); | 801 | list.append( "0" ); |
802 | list.append( "0" ); | 802 | list.append( "0" ); |
803 | writeEndDate = true; | 803 | writeEndDate = true; |
804 | break; | 804 | break; |
805 | case Recurrence::rYearlyMonth://4 | 805 | case Recurrence::rYearlyMonth://4 |
806 | list.append( "4" ); | 806 | list.append( "4" ); |
807 | list.append( QString::number( rec->frequency()) );//12 | 807 | list.append( QString::number( rec->frequency()) );//12 |
808 | list.append( "0" ); | 808 | list.append( "0" ); |
809 | list.append( "0" ); | 809 | list.append( "0" ); |
810 | writeEndDate = true; | 810 | writeEndDate = true; |
811 | break; | 811 | break; |
812 | 812 | ||
813 | default: | 813 | default: |
814 | list.append( "255" ); | 814 | list.append( "255" ); |
815 | list.append( QString() ); | 815 | list.append( QString() ); |
816 | list.append( "0" ); | 816 | list.append( "0" ); |
817 | list.append( QString() ); | 817 | list.append( QString() ); |
818 | list.append( "0" ); | 818 | list.append( "0" ); |
819 | list.append( "20991231T000000" ); | 819 | list.append( "20991231T000000" ); |
820 | break; | 820 | break; |
821 | } | 821 | } |
822 | if ( writeEndDate ) { | 822 | if ( writeEndDate ) { |
823 | 823 | ||
824 | if ( rec->endDate().isValid() ) { // 15 + 16 | 824 | if ( rec->endDate().isValid() ) { // 15 + 16 |
825 | list.append( "1" ); | 825 | list.append( "1" ); |
826 | list.append( dtToString( rec->endDate()) ); | 826 | list.append( dtToString( rec->endDate(), false ) ); |
827 | } else { | 827 | } else { |
828 | list.append( "0" ); | 828 | list.append( "0" ); |
829 | list.append( "20991231T000000" ); | 829 | list.append( "20991231T000000" ); |
830 | } | 830 | } |
831 | 831 | ||
832 | } | 832 | } |
833 | if ( event->doesFloat () ) { | 833 | if ( event->doesFloat () ) { |
834 | list.append( dtToString( event->dtStart(), false ).left( 8 )); | 834 | list.append( dtToString( event->dtStart(), false ).left( 8 )); |
835 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 | 835 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 |
836 | 836 | ||
837 | } | 837 | } |
838 | else { | 838 | else { |
839 | list.append( QString() ); | 839 | list.append( QString() ); |
840 | list.append( QString() ); | 840 | list.append( QString() ); |
841 | 841 | ||
842 | } | 842 | } |
843 | if (event->dtStart().date() == event->dtEnd().date() ) | 843 | if (event->dtStart().date() == event->dtEnd().date() ) |
844 | list.append( "0" ); | 844 | list.append( "0" ); |
845 | else | 845 | else |
846 | list.append( "1" ); | 846 | list.append( "1" ); |
847 | 847 | ||
848 | 848 | ||
849 | for(QStringList::Iterator it=list.begin(); | 849 | for(QStringList::Iterator it=list.begin(); |
850 | it!=list.end(); ++it){ | 850 | it!=list.end(); ++it){ |
851 | QString& s = (*it); | 851 | QString& s = (*it); |
852 | s.replace(QRegExp("\""), "\"\""); | 852 | s.replace(QRegExp("\""), "\"\""); |
853 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 853 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
854 | s.prepend('\"'); | 854 | s.prepend('\"'); |
855 | s.append('\"'); | 855 | s.append('\"'); |
856 | } else if(s.isEmpty() && !s.isNull()){ | 856 | } else if(s.isEmpty() && !s.isNull()){ |
857 | s = "\"\""; | 857 | s = "\"\""; |
858 | } | 858 | } |
859 | } | 859 | } |
860 | return list.join(","); | 860 | return list.join(","); |
861 | 861 | ||
862 | 862 | ||
863 | } | 863 | } |
864 | QString SharpFormat::getTodoString( Todo* todo ) | 864 | QString SharpFormat::getTodoString( Todo* todo ) |
865 | { | 865 | { |
866 | QStringList list; | 866 | QStringList list; |
867 | list.append( todo->getID("Sharp_DTM") ); | 867 | list.append( todo->getID("Sharp_DTM") ); |
868 | list.append( todo->categories().join(",") ); | 868 | list.append( todo->categories().join(",") ); |
869 | 869 | ||
870 | if ( todo->hasStartDate() ) { | 870 | if ( todo->hasStartDate() ) { |
871 | list.append( dtToString( todo->dtStart()) ); | 871 | list.append( dtToString( todo->dtStart()) ); |
872 | } else | 872 | } else |
873 | list.append( QString() ); | 873 | list.append( QString() ); |
874 | 874 | ||
875 | if ( todo->hasDueDate() ) { | 875 | if ( todo->hasDueDate() ) { |
876 | QTime tim; | 876 | QTime tim; |
877 | if ( todo->doesFloat()) { | 877 | if ( todo->doesFloat()) { |
878 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | 878 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; |
879 | } else { | 879 | } else { |
880 | list.append( dtToString(todo->dtDue() ) ); | 880 | list.append( dtToString(todo->dtDue() ) ); |
881 | } | 881 | } |
882 | } else | 882 | } else |
883 | list.append( QString() ); | 883 | list.append( QString() ); |
884 | 884 | ||
885 | if ( todo->isCompleted() ) { | 885 | if ( todo->isCompleted() ) { |
886 | list.append( dtToString( todo->completed()) ); | 886 | list.append( dtToString( todo->completed()) ); |
887 | list.append( "0" ); // yes 0 == completed | 887 | list.append( "0" ); // yes 0 == completed |
888 | } else { | 888 | } else { |
889 | list.append( dtToString( todo->completed()) ); | 889 | list.append( dtToString( todo->completed()) ); |
890 | list.append( "1" ); | 890 | list.append( "1" ); |
891 | } | 891 | } |
892 | list.append( QString::number( todo->priority() )); | 892 | list.append( QString::number( todo->priority() )); |
893 | if( ! todo->summary().isEmpty() ) | 893 | if( ! todo->summary().isEmpty() ) |
894 | list.append( todo->summary() ); | 894 | list.append( todo->summary() ); |
895 | else | 895 | else |
896 | list.append( "" ); | 896 | list.append( "" ); |
897 | if (! todo->description().isEmpty() ) | 897 | if (! todo->description().isEmpty() ) |
898 | list.append( todo->description() ); | 898 | list.append( todo->description() ); |
899 | else | 899 | else |
900 | list.append( "" ); | 900 | list.append( "" ); |
901 | for(QStringList::Iterator it=list.begin(); | 901 | for(QStringList::Iterator it=list.begin(); |
902 | it!=list.end(); ++it){ | 902 | it!=list.end(); ++it){ |
903 | QString& s = (*it); | 903 | QString& s = (*it); |
904 | s.replace(QRegExp("\""), "\"\""); | 904 | s.replace(QRegExp("\""), "\"\""); |
905 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 905 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
906 | s.prepend('\"'); | 906 | s.prepend('\"'); |
907 | s.append('\"'); | 907 | s.append('\"'); |
908 | } else if(s.isEmpty() && !s.isNull()){ | 908 | } else if(s.isEmpty() && !s.isNull()){ |
909 | s = "\"\""; | 909 | s = "\"\""; |
910 | } | 910 | } |
911 | } | 911 | } |
912 | return list.join(","); | 912 | return list.join(","); |
913 | } | 913 | } |
914 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) | 914 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) |
915 | { | 915 | { |
916 | //qDebug("start %d ", start); | 916 | //qDebug("start %d ", start); |
917 | 917 | ||
918 | QString retval =""; | 918 | QString retval =""; |
919 | if ( text.at(start) == '"' ) { | 919 | if ( text.at(start) == '"' ) { |
920 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { | 920 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { |
921 | start = start +2; | 921 | start = start +2; |
922 | if ( text.mid( start,1) == "," ) { | 922 | if ( text.mid( start,1) == "," ) { |
923 | start += 1; | 923 | start += 1; |
924 | } | 924 | } |
925 | retval = ""; | 925 | retval = ""; |
926 | if ( text.mid( start,1) == "\n" ) { | 926 | if ( text.mid( start,1) == "\n" ) { |
927 | start += 1; | 927 | start += 1; |
928 | ok = false; | 928 | ok = false; |
929 | } | 929 | } |
930 | return retval; | 930 | return retval; |
931 | } | 931 | } |
932 | int hk = start+1; | 932 | int hk = start+1; |
933 | hk = text.find ('"',hk); | 933 | hk = text.find ('"',hk); |
934 | while ( text.at(hk+1) == '"' ) | 934 | while ( text.at(hk+1) == '"' ) |
935 | hk = text.find ('"',hk+2); | 935 | hk = text.find ('"',hk+2); |
936 | retval = text.mid( start+1, hk-start-1); | 936 | retval = text.mid( start+1, hk-start-1); |
937 | start = hk+1; | 937 | start = hk+1; |
938 | retval.replace( QRegExp("\"\""), "\""); | 938 | retval.replace( QRegExp("\"\""), "\""); |
939 | if ( text.mid( start,1) == "," ) { | 939 | if ( text.mid( start,1) == "," ) { |
940 | start += 1; | 940 | start += 1; |
941 | } | 941 | } |
942 | if ( text.mid( start,1) == "\n" ) { | 942 | if ( text.mid( start,1) == "\n" ) { |
943 | start += 1; | 943 | start += 1; |
944 | ok = false; | 944 | ok = false; |
945 | } | 945 | } |
946 | //qDebug("retval***%s*** ",retval.latin1() ); | 946 | //qDebug("retval***%s*** ",retval.latin1() ); |
947 | return retval; | 947 | return retval; |
948 | 948 | ||
949 | } else { | 949 | } else { |
950 | int nl = text.find ("\n",start); | 950 | int nl = text.find ("\n",start); |
951 | int kom = text.find (',',start); | 951 | int kom = text.find (',',start); |
952 | if ( kom < nl ) { | 952 | if ( kom < nl ) { |
953 | // qDebug("kom < nl %d ", kom); | 953 | // qDebug("kom < nl %d ", kom); |
954 | retval = text.mid(start, kom-start); | 954 | retval = text.mid(start, kom-start); |
955 | start = kom+1; | 955 | start = kom+1; |
956 | return retval; | 956 | return retval; |
957 | } else { | 957 | } else { |
958 | if ( nl == kom ) { | 958 | if ( nl == kom ) { |
959 | // qDebug(" nl == kom "); | 959 | // qDebug(" nl == kom "); |
960 | start = 0; | 960 | start = 0; |
961 | ok = false; | 961 | ok = false; |
962 | return "0"; | 962 | return "0"; |
963 | } | 963 | } |
964 | // qDebug(" nl < kom ", nl); | 964 | // qDebug(" nl < kom ", nl); |
965 | retval = text.mid( start, nl-start); | 965 | retval = text.mid( start, nl-start); |
966 | ok = false; | 966 | ok = false; |
967 | start = nl+1; | 967 | start = nl+1; |
968 | return retval; | 968 | return retval; |
969 | } | 969 | } |
970 | } | 970 | } |
971 | } | 971 | } |
972 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) | 972 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) |
973 | { | 973 | { |
974 | return false; | 974 | return false; |
975 | } | 975 | } |
976 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) | 976 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) |
977 | { | 977 | { |
978 | // qDebug("test %s ", text.latin1()); | 978 | // qDebug("test %s ", text.latin1()); |
979 | QStringList templist; | 979 | QStringList templist; |
980 | QString tempString; | 980 | QString tempString; |
981 | int start = 0; | 981 | int start = 0; |
982 | int len = text.length(); | 982 | int len = text.length(); |
983 | int end = text.find ("\n",start)+1; | 983 | int end = text.find ("\n",start)+1; |
984 | bool ok = true; | 984 | bool ok = true; |
985 | start = end; | 985 | start = end; |
986 | SharpParser handler( calendar ); | 986 | SharpParser handler( calendar ); |
987 | // handler.setCategoriesList( mCategories ); | 987 | // handler.setCategoriesList( mCategories ); |
988 | while ( start > 0 ) { | 988 | while ( start > 0 ) { |
989 | templist.clear(); | 989 | templist.clear(); |
990 | ok = true; | 990 | ok = true; |
991 | while ( ok ) { | 991 | while ( ok ) { |
992 | tempString = getPart( text, ok, start ); | 992 | tempString = getPart( text, ok, start ); |
993 | if ( start >= len || start == 0 ) { | 993 | if ( start >= len || start == 0 ) { |
994 | start = 0; | 994 | start = 0; |
995 | ok = false; | 995 | ok = false; |
996 | } | 996 | } |
997 | if ( tempString.right(1) =="\n" ) | 997 | if ( tempString.right(1) =="\n" ) |
998 | tempString = tempString.left( tempString.length()-1); | 998 | tempString = tempString.left( tempString.length()-1); |
999 | //if ( ok ) | 999 | //if ( ok ) |
1000 | templist.append( tempString ); | 1000 | templist.append( tempString ); |
1001 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); | 1001 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); |
1002 | } | 1002 | } |
1003 | handler.startElement( existingCalendar, templist, type ); | 1003 | handler.startElement( existingCalendar, templist, type ); |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | return false; | 1006 | return false; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | QString SharpFormat::toString( Calendar * ) | 1009 | QString SharpFormat::toString( Calendar * ) |
1010 | { | 1010 | { |
1011 | return QString::null; | 1011 | return QString::null; |
1012 | } | 1012 | } |