author | zautrix <zautrix> | 2005-06-04 10:29:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-04 10:29:18 (UTC) |
commit | a7939017000e165e711e3f0cffeab46852a9fb2e (patch) (unidiff) | |
tree | 6b1c0d44051039e47f7b7f6cf55e25af9a6e7024 | |
parent | d40cf5135c640506011334364274b8ee5df9998b (diff) | |
download | kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.zip kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.tar.gz kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.tar.bz2 |
fixes
-rw-r--r-- | bin/kdepim/korganizer/ic_family.png | bin | 0 -> 7865 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/ic_female.png | bin | 0 -> 6234 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/ic_kids.png | bin | 0 -> 9039 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/ic_male.png | bin | 0 -> 6440 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/ic_penguin.png | bin | 0 -> 5343 bytes | |||
-rw-r--r-- | korganizer/calendarview.cpp | 40 |
6 files changed, 27 insertions, 13 deletions
diff --git a/bin/kdepim/korganizer/ic_family.png b/bin/kdepim/korganizer/ic_family.png new file mode 100644 index 0000000..6b0dec6 --- a/dev/null +++ b/bin/kdepim/korganizer/ic_family.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/ic_female.png b/bin/kdepim/korganizer/ic_female.png new file mode 100644 index 0000000..74deae4 --- a/dev/null +++ b/bin/kdepim/korganizer/ic_female.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/ic_kids.png b/bin/kdepim/korganizer/ic_kids.png new file mode 100644 index 0000000..fdbdabc --- a/dev/null +++ b/bin/kdepim/korganizer/ic_kids.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/ic_male.png b/bin/kdepim/korganizer/ic_male.png new file mode 100644 index 0000000..f22eaab --- a/dev/null +++ b/bin/kdepim/korganizer/ic_male.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/ic_penguin.png b/bin/kdepim/korganizer/ic_penguin.png new file mode 100644 index 0000000..a78da37 --- a/dev/null +++ b/bin/kdepim/korganizer/ic_penguin.png | |||
Binary files differ | |||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 42166ab..608b73b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2204 +1,2218 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | setBackgroundColor( QColor( 86, 153, 205 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->type() == "Event" ) { | 173 | if ( inc->type() == "Event" ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->type() == "Todo" ) { | 175 | } else if ( inc->type() == "Todo" ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->type() == "Todo" ) | 179 | if ( inc->type() == "Todo" ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() == QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | ||
192 | mText += "<table>"; | ||
191 | time = 1; | 193 | time = 1; |
192 | mText +="</table>"; | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | ||
196 | if ( time > 0 ) | ||
197 | mText +="</table>"; | ||
193 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
194 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | ||
195 | 201 | ||
196 | } | 202 | } |
197 | if ( dt.date() > QDate::currentDate() && time != 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
198 | time = 2; | 204 | if ( time > 0 ) |
199 | mText +="</table>"; | 205 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
201 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | ||
202 | } | 209 | } |
203 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
204 | mText += timestr; | 211 | mText += timestr; |
205 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
206 | mText += tempText; | 213 | mText += tempText; |
207 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
208 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
209 | } | 216 | } |
210 | mText +="</table>"; | 217 | mText +="</table>"; |
211 | setText( mText ); | 218 | setText( mText ); |
212 | } | 219 | } |
213 | 220 | ||
214 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
215 | { | 222 | { |
216 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
217 | } | 224 | } |
218 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
219 | { | 226 | { |
220 | QDateTime dt ; | 227 | QDateTime dt ; |
221 | Incidence * retInc; | 228 | Incidence * retInc; |
222 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
223 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
224 | return 0; | 231 | return 0; |
225 | bool ok; | 232 | bool ok; |
226 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
227 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
228 | QDateTime dtn ; | 235 | QDateTime dtn ; |
229 | retInc = inc; | 236 | retInc = inc; |
230 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
231 | while ( inc ) { | 238 | while ( inc ) { |
232 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
233 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
234 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
235 | dt = dtn; | 242 | dt = dtn; |
236 | retInc = inc; | 243 | retInc = inc; |
237 | } | 244 | } |
238 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
239 | } | 246 | } |
240 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
241 | return retInc; | 248 | return retInc; |
242 | 249 | ||
243 | } | 250 | } |
244 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
245 | { | 252 | { |
246 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
247 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
248 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
249 | #else | 256 | #else |
250 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
251 | #endif | 258 | #endif |
252 | return; | 259 | return; |
253 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
254 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
256 | #else | 263 | #else |
257 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
258 | #endif | 265 | #endif |
259 | return; | 266 | return; |
260 | } | 267 | } |
261 | } | 268 | } |
262 | 269 | ||
263 | 270 | ||
264 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
265 | { | 272 | { |
266 | public: | 273 | public: |
267 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
268 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
269 | { | 276 | { |
270 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
271 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
272 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
273 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
274 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
275 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
276 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
277 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
278 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
279 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
280 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
281 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
282 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
283 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
284 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
285 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
286 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
287 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
288 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
289 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
290 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
291 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
292 | } | 299 | } |
293 | 300 | ||
294 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
295 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
296 | private: | 303 | private: |
297 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
298 | }; | 305 | }; |
299 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
300 | { | 307 | { |
301 | public: | 308 | public: |
302 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
303 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
304 | { | 311 | { |
305 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
306 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
307 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
308 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
309 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
310 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
311 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
312 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
313 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
314 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
315 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
316 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
317 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
318 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
319 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
320 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
321 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
322 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
323 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
324 | } | 331 | } |
325 | 332 | ||
326 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
327 | private: | 334 | private: |
328 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
329 | }; | 336 | }; |
330 | 337 | ||
331 | 338 | ||
332 | 339 | ||
333 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
334 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
335 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
336 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
337 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
338 | { | 345 | { |
339 | 346 | ||
340 | mEventEditor = 0; | 347 | mEventEditor = 0; |
341 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
342 | 349 | ||
343 | init(); | 350 | init(); |
344 | } | 351 | } |
345 | 352 | ||
346 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
347 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
348 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
349 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
350 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
351 | { | 358 | { |
352 | 359 | ||
353 | mEventEditor = 0; | 360 | mEventEditor = 0; |
354 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
355 | init(); | 362 | init(); |
356 | } | 363 | } |
357 | 364 | ||
358 | void CalendarView::init() | 365 | void CalendarView::init() |
359 | { | 366 | { |
360 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
361 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
362 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
363 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
364 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
365 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
366 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
367 | writeLocale(); | 374 | writeLocale(); |
368 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
369 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
370 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
371 | mModified = false; | 378 | mModified = false; |
372 | mReadOnly = false; | 379 | mReadOnly = false; |
373 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
374 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
375 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
376 | 383 | ||
377 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
378 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
379 | 386 | ||
380 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
381 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
382 | 389 | ||
383 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
384 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
385 | // create the main layout frames. | 392 | // create the main layout frames. |
386 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
387 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
388 | 395 | ||
389 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
390 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
391 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
392 | 399 | ||
393 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
394 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
395 | 402 | ||
396 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
397 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
398 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
399 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
400 | 407 | ||
401 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
402 | mResourceView = 0; | 409 | mResourceView = 0; |
403 | #else | 410 | #else |
404 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
405 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
406 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
407 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
408 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
409 | } else { | 416 | } else { |
410 | mResourceView = 0; | 417 | mResourceView = 0; |
411 | } | 418 | } |
412 | #endif | 419 | #endif |
413 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
414 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
415 | 422 | ||
416 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
417 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
418 | 425 | ||
419 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
420 | #else | 427 | #else |
421 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
422 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
423 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
424 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
425 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
426 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
427 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
428 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
429 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
430 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
431 | } else { | 438 | } else { |
432 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
433 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
438 | } | 445 | } |
439 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
440 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
441 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
442 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
443 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
444 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
445 | #if 0 | 452 | #if 0 |
446 | // FIXME | 453 | // FIXME |
447 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
448 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
449 | #endif | 456 | #endif |
450 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
451 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
452 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
453 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
454 | mTodoList->setNavigator( mNavigator ); | 461 | mTodoList->setNavigator( mNavigator ); |
455 | #if 0 | 462 | #if 0 |
456 | if ( QApplication::desktop()->width() < 480 ) { | 463 | if ( QApplication::desktop()->width() < 480 ) { |
457 | leftFrameLayout->addWidget(mFilterView); | 464 | leftFrameLayout->addWidget(mFilterView); |
458 | leftFrameLayout->addWidget(mTodoList, 2 ); | 465 | leftFrameLayout->addWidget(mTodoList, 2 ); |
459 | 466 | ||
460 | } else { | 467 | } else { |
461 | leftFrameLayout->addWidget(mTodoList,2 ); | 468 | leftFrameLayout->addWidget(mTodoList,2 ); |
462 | leftFrameLayout->addWidget(mFilterView ); | 469 | leftFrameLayout->addWidget(mFilterView ); |
463 | } | 470 | } |
464 | #endif | 471 | #endif |
465 | mFilterView->hide(); | 472 | mFilterView->hide(); |
466 | QWidget *rightBox = new QWidget( mMainFrame ); | 473 | QWidget *rightBox = new QWidget( mMainFrame ); |
467 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 474 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
468 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 475 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
469 | mRightFrame = new QWidgetStack( rightBox ); | 476 | mRightFrame = new QWidgetStack( rightBox ); |
470 | rightLayout->addWidget( mRightFrame, 10 ); | 477 | rightLayout->addWidget( mRightFrame, 10 ); |
471 | 478 | ||
472 | //mLeftFrame = (QWidget *)leftFrame; | 479 | //mLeftFrame = (QWidget *)leftFrame; |
473 | if ( KOPrefs::instance()->mVerticalScreen ) { | 480 | if ( KOPrefs::instance()->mVerticalScreen ) { |
474 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 481 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
475 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 482 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
476 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
477 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 484 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
478 | } else { | 485 | } else { |
479 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 486 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
480 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 487 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
481 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
482 | } | 489 | } |
483 | if ( !KOPrefs::instance()->mShowDateNavigator) | 490 | if ( !KOPrefs::instance()->mShowDateNavigator) |
484 | mDateNavigator->hide(); | 491 | mDateNavigator->hide(); |
485 | //qDebug("Calendarview Size %d %d ", width(), height()); | 492 | //qDebug("Calendarview Size %d %d ", width(), height()); |
486 | #endif | 493 | #endif |
487 | 494 | ||
488 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 495 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
489 | SLOT( showDates( const KCal::DateList & ) ) ); | 496 | SLOT( showDates( const KCal::DateList & ) ) ); |
490 | 497 | ||
491 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 498 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
492 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 499 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
493 | 500 | ||
494 | 501 | ||
495 | 502 | ||
496 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 503 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
497 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 504 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
498 | 505 | ||
499 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 506 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
500 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 507 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
501 | 508 | ||
502 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 509 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
503 | mNavigator, SLOT( selectPreviousYear() ) ); | 510 | mNavigator, SLOT( selectPreviousYear() ) ); |
504 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 511 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
505 | mNavigator, SLOT( selectNextYear() ) ); | 512 | mNavigator, SLOT( selectNextYear() ) ); |
506 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 513 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
507 | mNavigator, SLOT( selectPreviousMonth() ) ); | 514 | mNavigator, SLOT( selectPreviousMonth() ) ); |
508 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
509 | mNavigator, SLOT( selectNextMonth() ) ); | 516 | mNavigator, SLOT( selectNextMonth() ) ); |
510 | 517 | ||
511 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 518 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
512 | mNavigator, SLOT( selectPrevious() ) ); | 519 | mNavigator, SLOT( selectPrevious() ) ); |
513 | connect( mDateNavigator, SIGNAL( goNext() ), | 520 | connect( mDateNavigator, SIGNAL( goNext() ), |
514 | mNavigator, SLOT( selectNext() ) ); | 521 | mNavigator, SLOT( selectNext() ) ); |
515 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 522 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
516 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 523 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
517 | 524 | ||
518 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 525 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
519 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 526 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
520 | #if 0 | 527 | #if 0 |
521 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 528 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
522 | SLOT( incidenceAdded( Incidence *) ) ); | 529 | SLOT( incidenceAdded( Incidence *) ) ); |
523 | #endif | 530 | #endif |
524 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 531 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
525 | 532 | ||
526 | connect( this, SIGNAL( configChanged() ), | 533 | connect( this, SIGNAL( configChanged() ), |
527 | mDateNavigator, SLOT( updateConfig() ) ); | 534 | mDateNavigator, SLOT( updateConfig() ) ); |
528 | 535 | ||
529 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 536 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
530 | SLOT( newTodo() ) ); | 537 | SLOT( newTodo() ) ); |
531 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 538 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
532 | SLOT( newSubTodo( Todo * ) ) ); | 539 | SLOT( newSubTodo( Todo * ) ) ); |
533 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 540 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
534 | SLOT( editTodo( Todo * ) ) ); | 541 | SLOT( editTodo( Todo * ) ) ); |
535 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
536 | SLOT( showTodo( Todo *) ) ); | 543 | SLOT( showTodo( Todo *) ) ); |
537 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 544 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
538 | SLOT( deleteTodo( Todo *) ) ); | 545 | SLOT( deleteTodo( Todo *) ) ); |
539 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 546 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
540 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 547 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
541 | SLOT( purgeCompleted() ) ); | 548 | SLOT( purgeCompleted() ) ); |
542 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 549 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
543 | SIGNAL( todoModified( Todo *, int ) ) ); | 550 | SIGNAL( todoModified( Todo *, int ) ) ); |
544 | 551 | ||
545 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 552 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
546 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 553 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
547 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
548 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 555 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
549 | 556 | ||
550 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 557 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
551 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 558 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
552 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
553 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 560 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
554 | 561 | ||
555 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
556 | this, SLOT ( todo_unsub( Todo * ) ) ); | 563 | this, SLOT ( todo_unsub( Todo * ) ) ); |
557 | 564 | ||
558 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 565 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
559 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 566 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
560 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 567 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
561 | SLOT( updateTodo( Todo *, int ) ) ); | 568 | SLOT( updateTodo( Todo *, int ) ) ); |
562 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
563 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 570 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
564 | 571 | ||
565 | 572 | ||
566 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 573 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
567 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 574 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
568 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 575 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
569 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 576 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
570 | 577 | ||
571 | 578 | ||
572 | 579 | ||
573 | 580 | ||
574 | 581 | ||
575 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 582 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
576 | SLOT(checkClipboard())); | 583 | SLOT(checkClipboard())); |
577 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 584 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
578 | SLOT( processTodoListSelection( Incidence * ) ) ); | 585 | SLOT( processTodoListSelection( Incidence * ) ) ); |
579 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 586 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
580 | 587 | ||
581 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 588 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
582 | 589 | ||
583 | mDateFrame = new QVBox(0,0,WType_Popup); | 590 | mDateFrame = new QVBox(0,0,WType_Popup); |
584 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 591 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
585 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 592 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
586 | mDateFrame->setLineWidth(3); | 593 | mDateFrame->setLineWidth(3); |
587 | mDateFrame->hide(); | 594 | mDateFrame->hide(); |
588 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 595 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
589 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 596 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
590 | 597 | ||
591 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 598 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
592 | 599 | ||
593 | mEventEditor = mDialogManager->getEventEditor(); | 600 | mEventEditor = mDialogManager->getEventEditor(); |
594 | mTodoEditor = mDialogManager->getTodoEditor(); | 601 | mTodoEditor = mDialogManager->getTodoEditor(); |
595 | 602 | ||
596 | mFlagEditDescription = false; | 603 | mFlagEditDescription = false; |
597 | 604 | ||
598 | mSuspendTimer = new QTimer( this ); | 605 | mSuspendTimer = new QTimer( this ); |
599 | mAlarmTimer = new QTimer( this ); | 606 | mAlarmTimer = new QTimer( this ); |
600 | mRecheckAlarmTimer = new QTimer( this ); | 607 | mRecheckAlarmTimer = new QTimer( this ); |
601 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 608 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
602 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 609 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
603 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 610 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
604 | mAlarmDialog = new AlarmDialog( this ); | 611 | mAlarmDialog = new AlarmDialog( this ); |
605 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 612 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
606 | mAlarmDialog->setServerNotification( false ); | 613 | mAlarmDialog->setServerNotification( false ); |
607 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 614 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
608 | 615 | ||
609 | 616 | ||
610 | #ifndef DESKTOP_VERSION | 617 | #ifndef DESKTOP_VERSION |
611 | //US listen for arriving address resultsets | 618 | //US listen for arriving address resultsets |
612 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 619 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
613 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 620 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
614 | #endif | 621 | #endif |
615 | mDateNavigator->setCalendar( mCalendar ); | 622 | mDateNavigator->setCalendar( mCalendar ); |
616 | } | 623 | } |
617 | 624 | ||
618 | 625 | ||
619 | CalendarView::~CalendarView() | 626 | CalendarView::~CalendarView() |
620 | { | 627 | { |
621 | // kdDebug() << "~CalendarView()" << endl; | 628 | // kdDebug() << "~CalendarView()" << endl; |
622 | //qDebug("CalendarView::~CalendarView() "); | 629 | //qDebug("CalendarView::~CalendarView() "); |
623 | delete mDialogManager; | 630 | delete mDialogManager; |
624 | delete mViewManager; | 631 | delete mViewManager; |
625 | delete mStorage; | 632 | delete mStorage; |
626 | delete mDateFrame ; | 633 | delete mDateFrame ; |
627 | delete beamDialog; | 634 | delete beamDialog; |
628 | delete mEventViewerDialog; | 635 | delete mEventViewerDialog; |
629 | //kdDebug() << "~CalendarView() done" << endl; | 636 | //kdDebug() << "~CalendarView() done" << endl; |
630 | } | 637 | } |
631 | void CalendarView::checkAlarms() | 638 | void CalendarView::checkAlarms() |
632 | { | 639 | { |
633 | KConfig *config = KOGlobals::config(); | 640 | KConfig *config = KOGlobals::config(); |
634 | config->setGroup( "AppRun" ); | 641 | config->setGroup( "AppRun" ); |
635 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 642 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
636 | int secs = config->readNumEntry( "LatestProgramStop" ) - 30; | 643 | int secs = config->readNumEntry( "LatestProgramStop" ) - 30; |
637 | secs -= ( 3600 * 24*3 ); // debug only | 644 | //secs -= ( 3600 * 24*3 ); // debug only |
638 | QDateTime latest = dt.addSecs ( secs ); | 645 | QDateTime latest = dt.addSecs ( secs ); |
639 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 646 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
640 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 647 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
641 | QPtrList<Incidence> al; | 648 | QPtrList<Incidence> al; |
642 | Incidence* inL = el.first(); | 649 | Incidence* inL = el.first(); |
643 | while ( inL ) { | 650 | while ( inL ) { |
644 | bool ok = false; | 651 | bool ok = false; |
645 | int offset = 0; | 652 | int offset = 0; |
646 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 653 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
647 | if ( ok ) { | 654 | if ( ok ) { |
648 | //qDebug("OK %s",next.toString().latin1()); | 655 | //qDebug("OK %s",next.toString().latin1()); |
649 | if ( next < QDateTime::currentDateTime() ) { | 656 | if ( next < QDateTime::currentDateTime() ) { |
650 | al.append( inL ); | 657 | al.append( inL ); |
651 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 658 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
652 | } | 659 | } |
653 | } | 660 | } |
654 | inL = el.next(); | 661 | inL = el.next(); |
655 | } | 662 | } |
656 | if ( al.count() ) { | 663 | if ( al.count() ) { |
657 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 664 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
658 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 665 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
659 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 666 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
660 | lay->setSpacing( 0 ); | 667 | lay->setSpacing( 0 ); |
661 | lay->setMargin( 0 ); | 668 | lay->setMargin( 0 ); |
662 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 669 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
663 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 670 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
664 | lay->addWidget( matb ); | 671 | lay->addWidget( matb ); |
665 | int si = 220; | 672 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
666 | if ( QApplication::desktop()->width() > 470 ) | 673 | int wid = 210; |
667 | si = 400; | 674 | int x = QApplication::desktop()->width() - wid - 7; |
668 | dia->resize(si,si/2); | 675 | int y = QApplication::desktop()->height() - wid - 70; |
676 | dia->setGeometry ( x,y,wid,wid); | ||
677 | } else { | ||
678 | int si = 220; | ||
679 | if ( QApplication::desktop()->width() > 470 ) | ||
680 | si = 400; | ||
681 | dia->resize(si,si/2); | ||
682 | } | ||
669 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 683 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
670 | dia->show(); | 684 | dia->show(); |
671 | 685 | ||
672 | } | 686 | } |
673 | } | 687 | } |
674 | void CalendarView::showDay( QDate d ) | 688 | void CalendarView::showDay( QDate d ) |
675 | { | 689 | { |
676 | dateNavigator()->blockSignals( true ); | 690 | dateNavigator()->blockSignals( true ); |
677 | dateNavigator()->selectDate( d ); | 691 | dateNavigator()->selectDate( d ); |
678 | dateNavigator()->blockSignals( false ); | 692 | dateNavigator()->blockSignals( false ); |
679 | mViewManager->showDayView(); | 693 | mViewManager->showDayView(); |
680 | //dateNavigator()->selectDate( d ); | 694 | //dateNavigator()->selectDate( d ); |
681 | } | 695 | } |
682 | void CalendarView::timerAlarm() | 696 | void CalendarView::timerAlarm() |
683 | { | 697 | { |
684 | //qDebug("CalendarView::timerAlarm() "); | 698 | //qDebug("CalendarView::timerAlarm() "); |
685 | computeAlarm(mAlarmNotification ); | 699 | computeAlarm(mAlarmNotification ); |
686 | } | 700 | } |
687 | 701 | ||
688 | void CalendarView::suspendAlarm() | 702 | void CalendarView::suspendAlarm() |
689 | { | 703 | { |
690 | //qDebug(" CalendarView::suspendAlarm() "); | 704 | //qDebug(" CalendarView::suspendAlarm() "); |
691 | computeAlarm(mSuspendAlarmNotification ); | 705 | computeAlarm(mSuspendAlarmNotification ); |
692 | 706 | ||
693 | } | 707 | } |
694 | 708 | ||
695 | void CalendarView::startAlarm( QString mess , QString filename) | 709 | void CalendarView::startAlarm( QString mess , QString filename) |
696 | { | 710 | { |
697 | 711 | ||
698 | topLevelWidget()->showNormal(); | 712 | topLevelWidget()->showNormal(); |
699 | topLevelWidget()->setActiveWindow(); | 713 | topLevelWidget()->setActiveWindow(); |
700 | topLevelWidget()->raise(); | 714 | topLevelWidget()->raise(); |
701 | 715 | ||
702 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 716 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
703 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 717 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
704 | 718 | ||
705 | } | 719 | } |
706 | 720 | ||
707 | void CalendarView::checkNextTimerAlarm() | 721 | void CalendarView::checkNextTimerAlarm() |
708 | { | 722 | { |
709 | mCalendar->checkAlarmForIncidence( 0, true ); | 723 | mCalendar->checkAlarmForIncidence( 0, true ); |
710 | } | 724 | } |
711 | 725 | ||
712 | void CalendarView::computeAlarm( QString msg ) | 726 | void CalendarView::computeAlarm( QString msg ) |
713 | { | 727 | { |
714 | 728 | ||
715 | QString mess = msg; | 729 | QString mess = msg; |
716 | QString mAlarmMessage = mess.mid( 9 ); | 730 | QString mAlarmMessage = mess.mid( 9 ); |
717 | QString filename = MainWindow::resourcePath(); | 731 | QString filename = MainWindow::resourcePath(); |
718 | filename += "koalarm.wav"; | 732 | filename += "koalarm.wav"; |
719 | QString tempfilename; | 733 | QString tempfilename; |
720 | if ( mess.left( 13 ) == "suspend_alarm") { | 734 | if ( mess.left( 13 ) == "suspend_alarm") { |
721 | bool error = false; | 735 | bool error = false; |
722 | int len = mess.mid( 13 ).find("+++"); | 736 | int len = mess.mid( 13 ).find("+++"); |
723 | if ( len < 2 ) | 737 | if ( len < 2 ) |
724 | error = true; | 738 | error = true; |
725 | else { | 739 | else { |
726 | tempfilename = mess.mid( 13, len ); | 740 | tempfilename = mess.mid( 13, len ); |
727 | if ( !QFile::exists( tempfilename ) ) | 741 | if ( !QFile::exists( tempfilename ) ) |
728 | error = true; | 742 | error = true; |
729 | } | 743 | } |
730 | if ( ! error ) { | 744 | if ( ! error ) { |
731 | filename = tempfilename; | 745 | filename = tempfilename; |
732 | } | 746 | } |
733 | mAlarmMessage = mess.mid( 13+len+3 ); | 747 | mAlarmMessage = mess.mid( 13+len+3 ); |
734 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 748 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
735 | startAlarm( mAlarmMessage, filename); | 749 | startAlarm( mAlarmMessage, filename); |
736 | return; | 750 | return; |
737 | } | 751 | } |
738 | if ( mess.left( 11 ) == "timer_alarm") { | 752 | if ( mess.left( 11 ) == "timer_alarm") { |
739 | //mTimerTime = 0; | 753 | //mTimerTime = 0; |
740 | startAlarm( mess.mid( 11 ), filename ); | 754 | startAlarm( mess.mid( 11 ), filename ); |
741 | return; | 755 | return; |
742 | } | 756 | } |
743 | if ( mess.left( 10 ) == "proc_alarm") { | 757 | if ( mess.left( 10 ) == "proc_alarm") { |
744 | bool error = false; | 758 | bool error = false; |
745 | int len = mess.mid( 10 ).find("+++"); | 759 | int len = mess.mid( 10 ).find("+++"); |
746 | if ( len < 2 ) | 760 | if ( len < 2 ) |
747 | error = true; | 761 | error = true; |
748 | else { | 762 | else { |
749 | tempfilename = mess.mid( 10, len ); | 763 | tempfilename = mess.mid( 10, len ); |
750 | if ( !QFile::exists( tempfilename ) ) | 764 | if ( !QFile::exists( tempfilename ) ) |
751 | error = true; | 765 | error = true; |
752 | } | 766 | } |
753 | if ( error ) { | 767 | if ( error ) { |
754 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 768 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
755 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 769 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
756 | } else { | 770 | } else { |
757 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 771 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
758 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 772 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
759 | #ifndef _WIN32_ | 773 | #ifndef _WIN32_ |
760 | if ( vfork () == 0 ) { | 774 | if ( vfork () == 0 ) { |
761 | execl ( tempfilename.latin1(), 0 ); | 775 | execl ( tempfilename.latin1(), 0 ); |
762 | return; | 776 | return; |
763 | } | 777 | } |
764 | #else | 778 | #else |
765 | QProcess* p = new QProcess(); | 779 | QProcess* p = new QProcess(); |
766 | p->addArgument( tempfilename.latin1() ); | 780 | p->addArgument( tempfilename.latin1() ); |
767 | p->start(); | 781 | p->start(); |
768 | return; | 782 | return; |
769 | #endif | 783 | #endif |
770 | 784 | ||
771 | return; | 785 | return; |
772 | } | 786 | } |
773 | 787 | ||
774 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 788 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
775 | } | 789 | } |
776 | if ( mess.left( 11 ) == "audio_alarm") { | 790 | if ( mess.left( 11 ) == "audio_alarm") { |
777 | bool error = false; | 791 | bool error = false; |
778 | int len = mess.mid( 11 ).find("+++"); | 792 | int len = mess.mid( 11 ).find("+++"); |
779 | if ( len < 2 ) | 793 | if ( len < 2 ) |
780 | error = true; | 794 | error = true; |
781 | else { | 795 | else { |
782 | tempfilename = mess.mid( 11, len ); | 796 | tempfilename = mess.mid( 11, len ); |
783 | if ( !QFile::exists( tempfilename ) ) | 797 | if ( !QFile::exists( tempfilename ) ) |
784 | error = true; | 798 | error = true; |
785 | } | 799 | } |
786 | if ( ! error ) { | 800 | if ( ! error ) { |
787 | filename = tempfilename; | 801 | filename = tempfilename; |
788 | } | 802 | } |
789 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 803 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
790 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 804 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
791 | } | 805 | } |
792 | if ( mess.left( 9 ) == "cal_alarm") { | 806 | if ( mess.left( 9 ) == "cal_alarm") { |
793 | mAlarmMessage = mess.mid( 9 ) ; | 807 | mAlarmMessage = mess.mid( 9 ) ; |
794 | } | 808 | } |
795 | 809 | ||
796 | startAlarm( mAlarmMessage, filename ); | 810 | startAlarm( mAlarmMessage, filename ); |
797 | 811 | ||
798 | 812 | ||
799 | } | 813 | } |
800 | 814 | ||
801 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 815 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
802 | { | 816 | { |
803 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 817 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
804 | 818 | ||
805 | mSuspendAlarmNotification = noti; | 819 | mSuspendAlarmNotification = noti; |
806 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 820 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
807 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 821 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
808 | mSuspendTimer->start( ms , true ); | 822 | mSuspendTimer->start( ms , true ); |
809 | 823 | ||
810 | } | 824 | } |
811 | 825 | ||
812 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 826 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
813 | { | 827 | { |
814 | mNextAlarmDateTime = qdt; | 828 | mNextAlarmDateTime = qdt; |
815 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 829 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
816 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 830 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
817 | #ifndef DESKTOP_VERSION | 831 | #ifndef DESKTOP_VERSION |
818 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 832 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
819 | #endif | 833 | #endif |
820 | return; | 834 | return; |
821 | } | 835 | } |
822 | int maxSec; | 836 | int maxSec; |
823 | //maxSec = 5; //testing only | 837 | //maxSec = 5; //testing only |
824 | maxSec = 86400+3600; // one day+1hour | 838 | maxSec = 86400+3600; // one day+1hour |
825 | mAlarmNotification = noti; | 839 | mAlarmNotification = noti; |
826 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 840 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
827 | if ( sec > maxSec ) { | 841 | if ( sec > maxSec ) { |
828 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 842 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
829 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 843 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
830 | return; | 844 | return; |
831 | } else { | 845 | } else { |
832 | mRecheckAlarmTimer->stop(); | 846 | mRecheckAlarmTimer->stop(); |
833 | } | 847 | } |
834 | //qDebug("Alarm timer started with secs: %d ", sec); | 848 | //qDebug("Alarm timer started with secs: %d ", sec); |
835 | mAlarmTimer->start( sec *1000 , true ); | 849 | mAlarmTimer->start( sec *1000 , true ); |
836 | 850 | ||
837 | } | 851 | } |
838 | // called by mRecheckAlarmTimer to get next alarm | 852 | // called by mRecheckAlarmTimer to get next alarm |
839 | // we need this, because a QTimer has only a max range of 25 days | 853 | // we need this, because a QTimer has only a max range of 25 days |
840 | void CalendarView::recheckTimerAlarm() | 854 | void CalendarView::recheckTimerAlarm() |
841 | { | 855 | { |
842 | mAlarmTimer->stop(); | 856 | mAlarmTimer->stop(); |
843 | mRecheckAlarmTimer->stop(); | 857 | mRecheckAlarmTimer->stop(); |
844 | mCalendar->checkAlarmForIncidence( 0, true ); | 858 | mCalendar->checkAlarmForIncidence( 0, true ); |
845 | } | 859 | } |
846 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 860 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
847 | { | 861 | { |
848 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 862 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
849 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 863 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
850 | #ifndef DESKTOP_VERSION | 864 | #ifndef DESKTOP_VERSION |
851 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 865 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
852 | #endif | 866 | #endif |
853 | return; | 867 | return; |
854 | } | 868 | } |
855 | mAlarmTimer->stop(); | 869 | mAlarmTimer->stop(); |
856 | } | 870 | } |
857 | void CalendarView::selectWeekNum ( int num ) | 871 | void CalendarView::selectWeekNum ( int num ) |
858 | { | 872 | { |
859 | dateNavigator()->blockSignals( true ); | 873 | dateNavigator()->blockSignals( true ); |
860 | dateNavigator()->selectWeek( num ); | 874 | dateNavigator()->selectWeek( num ); |
861 | dateNavigator()->blockSignals( false ); | 875 | dateNavigator()->blockSignals( false ); |
862 | mViewManager->showWeekView(); | 876 | mViewManager->showWeekView(); |
863 | } | 877 | } |
864 | KOViewManager *CalendarView::viewManager() | 878 | KOViewManager *CalendarView::viewManager() |
865 | { | 879 | { |
866 | return mViewManager; | 880 | return mViewManager; |
867 | } | 881 | } |
868 | 882 | ||
869 | KODialogManager *CalendarView::dialogManager() | 883 | KODialogManager *CalendarView::dialogManager() |
870 | { | 884 | { |
871 | return mDialogManager; | 885 | return mDialogManager; |
872 | } | 886 | } |
873 | 887 | ||
874 | QDate CalendarView::startDate() | 888 | QDate CalendarView::startDate() |
875 | { | 889 | { |
876 | DateList dates = mNavigator->selectedDates(); | 890 | DateList dates = mNavigator->selectedDates(); |
877 | 891 | ||
878 | return dates.first(); | 892 | return dates.first(); |
879 | } | 893 | } |
880 | 894 | ||
881 | QDate CalendarView::endDate() | 895 | QDate CalendarView::endDate() |
882 | { | 896 | { |
883 | DateList dates = mNavigator->selectedDates(); | 897 | DateList dates = mNavigator->selectedDates(); |
884 | 898 | ||
885 | return dates.last(); | 899 | return dates.last(); |
886 | } | 900 | } |
887 | 901 | ||
888 | 902 | ||
889 | void CalendarView::createPrinter() | 903 | void CalendarView::createPrinter() |
890 | { | 904 | { |
891 | #ifndef KORG_NOPRINTER | 905 | #ifndef KORG_NOPRINTER |
892 | if (!mCalPrinter) { | 906 | if (!mCalPrinter) { |
893 | mCalPrinter = new CalPrinter(this, mCalendar); | 907 | mCalPrinter = new CalPrinter(this, mCalendar); |
894 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 908 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
895 | } | 909 | } |
896 | #endif | 910 | #endif |
897 | } | 911 | } |
898 | 912 | ||
899 | 913 | ||
900 | //KOPrefs::instance()->mWriteBackFile | 914 | //KOPrefs::instance()->mWriteBackFile |
901 | //KOPrefs::instance()->mWriteBackExistingOnly | 915 | //KOPrefs::instance()->mWriteBackExistingOnly |
902 | 916 | ||
903 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 917 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
904 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 918 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
905 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 919 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
906 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 920 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
907 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 921 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
908 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 922 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
909 | 923 | ||
910 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 924 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
911 | { | 925 | { |
912 | 926 | ||
913 | // 0 equal | 927 | // 0 equal |
914 | // 1 take local | 928 | // 1 take local |
915 | // 2 take remote | 929 | // 2 take remote |
916 | // 3 cancel | 930 | // 3 cancel |
917 | QDateTime lastSync = mLastCalendarSync; | 931 | QDateTime lastSync = mLastCalendarSync; |
918 | QDateTime localMod = local->lastModified(); | 932 | QDateTime localMod = local->lastModified(); |
919 | QDateTime remoteMod = remote->lastModified(); | 933 | QDateTime remoteMod = remote->lastModified(); |
920 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 934 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
921 | bool remCh, locCh; | 935 | bool remCh, locCh; |
922 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 936 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
923 | //if ( remCh ) | 937 | //if ( remCh ) |
924 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 938 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
925 | locCh = ( localMod > mLastCalendarSync ); | 939 | locCh = ( localMod > mLastCalendarSync ); |
926 | if ( !remCh && ! locCh ) { | 940 | if ( !remCh && ! locCh ) { |
927 | //qDebug("both not changed "); | 941 | //qDebug("both not changed "); |
928 | lastSync = localMod.addDays(1); | 942 | lastSync = localMod.addDays(1); |
929 | if ( mode <= SYNC_PREF_ASK ) | 943 | if ( mode <= SYNC_PREF_ASK ) |
930 | return 0; | 944 | return 0; |
931 | } else { | 945 | } else { |
932 | if ( locCh ) { | 946 | if ( locCh ) { |
933 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 947 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
934 | lastSync = localMod.addDays( -1 ); | 948 | lastSync = localMod.addDays( -1 ); |
935 | if ( !remCh ) | 949 | if ( !remCh ) |
936 | remoteMod = ( lastSync.addDays( -1 ) ); | 950 | remoteMod = ( lastSync.addDays( -1 ) ); |
937 | } else { | 951 | } else { |
938 | //qDebug(" not loc changed "); | 952 | //qDebug(" not loc changed "); |
939 | lastSync = localMod.addDays( 1 ); | 953 | lastSync = localMod.addDays( 1 ); |
940 | if ( remCh ) | 954 | if ( remCh ) |
941 | remoteMod =( lastSync.addDays( 1 ) ); | 955 | remoteMod =( lastSync.addDays( 1 ) ); |
942 | 956 | ||
943 | } | 957 | } |
944 | } | 958 | } |
945 | full = true; | 959 | full = true; |
946 | if ( mode < SYNC_PREF_ASK ) | 960 | if ( mode < SYNC_PREF_ASK ) |
947 | mode = SYNC_PREF_ASK; | 961 | mode = SYNC_PREF_ASK; |
948 | } else { | 962 | } else { |
949 | if ( localMod == remoteMod ) | 963 | if ( localMod == remoteMod ) |
950 | // if ( local->revision() == remote->revision() ) | 964 | // if ( local->revision() == remote->revision() ) |
951 | return 0; | 965 | return 0; |
952 | 966 | ||
953 | } | 967 | } |
954 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 968 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
955 | 969 | ||
956 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 970 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
957 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 971 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
958 | //full = true; //debug only | 972 | //full = true; //debug only |
959 | if ( full ) { | 973 | if ( full ) { |
960 | bool equ = false; | 974 | bool equ = false; |
961 | if ( local->type() == "Event" ) { | 975 | if ( local->type() == "Event" ) { |
962 | equ = (*((Event*) local) == *((Event*) remote)); | 976 | equ = (*((Event*) local) == *((Event*) remote)); |
963 | } | 977 | } |
964 | else if ( local->type() =="Todo" ) | 978 | else if ( local->type() =="Todo" ) |
965 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 979 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
966 | else if ( local->type() =="Journal" ) | 980 | else if ( local->type() =="Journal" ) |
967 | equ = (*((Journal*) local) == *((Journal*) remote)); | 981 | equ = (*((Journal*) local) == *((Journal*) remote)); |
968 | if ( equ ) { | 982 | if ( equ ) { |
969 | //qDebug("equal "); | 983 | //qDebug("equal "); |
970 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 984 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
971 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 985 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
972 | } | 986 | } |
973 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 987 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
974 | return 0; | 988 | return 0; |
975 | 989 | ||
976 | }//else //debug only | 990 | }//else //debug only |
977 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 991 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
978 | } | 992 | } |
979 | int result; | 993 | int result; |
980 | bool localIsNew; | 994 | bool localIsNew; |
981 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 995 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
982 | 996 | ||
983 | 997 | ||
984 | // ************************************************ | 998 | // ************************************************ |
985 | // ************************************************ | 999 | // ************************************************ |
986 | // ************************************************ | 1000 | // ************************************************ |
987 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1001 | // We may have that lastSync > remoteMod AND lastSync > localMod |
988 | // BUT remoteMod != localMod | 1002 | // BUT remoteMod != localMod |
989 | 1003 | ||
990 | 1004 | ||
991 | if ( full && mode < SYNC_PREF_NEWEST ) | 1005 | if ( full && mode < SYNC_PREF_NEWEST ) |
992 | mode = SYNC_PREF_ASK; | 1006 | mode = SYNC_PREF_ASK; |
993 | 1007 | ||
994 | switch( mode ) { | 1008 | switch( mode ) { |
995 | case SYNC_PREF_LOCAL: | 1009 | case SYNC_PREF_LOCAL: |
996 | if ( lastSync > remoteMod ) | 1010 | if ( lastSync > remoteMod ) |
997 | return 1; | 1011 | return 1; |
998 | if ( lastSync > localMod ) | 1012 | if ( lastSync > localMod ) |
999 | return 2; | 1013 | return 2; |
1000 | return 1; | 1014 | return 1; |
1001 | break; | 1015 | break; |
1002 | case SYNC_PREF_REMOTE: | 1016 | case SYNC_PREF_REMOTE: |
1003 | if ( lastSync > localMod ) | 1017 | if ( lastSync > localMod ) |
1004 | return 2; | 1018 | return 2; |
1005 | if ( lastSync > remoteMod ) | 1019 | if ( lastSync > remoteMod ) |
1006 | return 1; | 1020 | return 1; |
1007 | return 2; | 1021 | return 2; |
1008 | break; | 1022 | break; |
1009 | case SYNC_PREF_NEWEST: | 1023 | case SYNC_PREF_NEWEST: |
1010 | if ( localMod >= remoteMod ) | 1024 | if ( localMod >= remoteMod ) |
1011 | return 1; | 1025 | return 1; |
1012 | else | 1026 | else |
1013 | return 2; | 1027 | return 2; |
1014 | break; | 1028 | break; |
1015 | case SYNC_PREF_ASK: | 1029 | case SYNC_PREF_ASK: |
1016 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1030 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1017 | if ( lastSync > remoteMod && lastSync > localMod) | 1031 | if ( lastSync > remoteMod && lastSync > localMod) |
1018 | return 0; | 1032 | return 0; |
1019 | if ( lastSync > remoteMod ) | 1033 | if ( lastSync > remoteMod ) |
1020 | return 1; | 1034 | return 1; |
1021 | if ( lastSync > localMod ) | 1035 | if ( lastSync > localMod ) |
1022 | return 2; | 1036 | return 2; |
1023 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1037 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1024 | localIsNew = localMod >= remoteMod; | 1038 | localIsNew = localMod >= remoteMod; |
1025 | if ( localIsNew ) | 1039 | if ( localIsNew ) |
1026 | getEventViewerDialog()->setColorMode( 1 ); | 1040 | getEventViewerDialog()->setColorMode( 1 ); |
1027 | else | 1041 | else |
1028 | getEventViewerDialog()->setColorMode( 2 ); | 1042 | getEventViewerDialog()->setColorMode( 2 ); |
1029 | getEventViewerDialog()->setIncidence(local); | 1043 | getEventViewerDialog()->setIncidence(local); |
1030 | if ( localIsNew ) | 1044 | if ( localIsNew ) |
1031 | getEventViewerDialog()->setColorMode( 2 ); | 1045 | getEventViewerDialog()->setColorMode( 2 ); |
1032 | else | 1046 | else |
1033 | getEventViewerDialog()->setColorMode( 1 ); | 1047 | getEventViewerDialog()->setColorMode( 1 ); |
1034 | getEventViewerDialog()->addIncidence(remote); | 1048 | getEventViewerDialog()->addIncidence(remote); |
1035 | getEventViewerDialog()->setColorMode( 0 ); | 1049 | getEventViewerDialog()->setColorMode( 0 ); |
1036 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1050 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1037 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1051 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1038 | getEventViewerDialog()->showMe(); | 1052 | getEventViewerDialog()->showMe(); |
1039 | result = getEventViewerDialog()->executeS( localIsNew ); | 1053 | result = getEventViewerDialog()->executeS( localIsNew ); |
1040 | return result; | 1054 | return result; |
1041 | 1055 | ||
1042 | break; | 1056 | break; |
1043 | case SYNC_PREF_FORCE_LOCAL: | 1057 | case SYNC_PREF_FORCE_LOCAL: |
1044 | return 1; | 1058 | return 1; |
1045 | break; | 1059 | break; |
1046 | case SYNC_PREF_FORCE_REMOTE: | 1060 | case SYNC_PREF_FORCE_REMOTE: |
1047 | return 2; | 1061 | return 2; |
1048 | break; | 1062 | break; |
1049 | 1063 | ||
1050 | default: | 1064 | default: |
1051 | // SYNC_PREF_TAKE_BOTH not implemented | 1065 | // SYNC_PREF_TAKE_BOTH not implemented |
1052 | break; | 1066 | break; |
1053 | } | 1067 | } |
1054 | return 0; | 1068 | return 0; |
1055 | } | 1069 | } |
1056 | Event* CalendarView::getLastSyncEvent() | 1070 | Event* CalendarView::getLastSyncEvent() |
1057 | { | 1071 | { |
1058 | Event* lse; | 1072 | Event* lse; |
1059 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1073 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1060 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1074 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1061 | if (!lse) { | 1075 | if (!lse) { |
1062 | lse = new Event(); | 1076 | lse = new Event(); |
1063 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1077 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1064 | QString sum = ""; | 1078 | QString sum = ""; |
1065 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1079 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1066 | sum = "E: "; | 1080 | sum = "E: "; |
1067 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1081 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1068 | lse->setDtStart( mLastCalendarSync ); | 1082 | lse->setDtStart( mLastCalendarSync ); |
1069 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1083 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1070 | lse->setCategories( i18n("SyncEvent") ); | 1084 | lse->setCategories( i18n("SyncEvent") ); |
1071 | lse->setReadOnly( true ); | 1085 | lse->setReadOnly( true ); |
1072 | mCalendar->addEvent( lse ); | 1086 | mCalendar->addEvent( lse ); |
1073 | } | 1087 | } |
1074 | 1088 | ||
1075 | return lse; | 1089 | return lse; |
1076 | 1090 | ||
1077 | } | 1091 | } |
1078 | 1092 | ||
1079 | // we check, if the to delete event has a id for a profile | 1093 | // we check, if the to delete event has a id for a profile |
1080 | // if yes, we set this id in the profile to delete | 1094 | // if yes, we set this id in the profile to delete |
1081 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1095 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1082 | { | 1096 | { |
1083 | if ( lastSync.count() == 0 ) { | 1097 | if ( lastSync.count() == 0 ) { |
1084 | //qDebug(" lastSync.count() == 0"); | 1098 | //qDebug(" lastSync.count() == 0"); |
1085 | return; | 1099 | return; |
1086 | } | 1100 | } |
1087 | if ( toDelete->type() == "Journal" ) | 1101 | if ( toDelete->type() == "Journal" ) |
1088 | return; | 1102 | return; |
1089 | 1103 | ||
1090 | Event* eve = lastSync.first(); | 1104 | Event* eve = lastSync.first(); |
1091 | 1105 | ||
1092 | while ( eve ) { | 1106 | while ( eve ) { |
1093 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1107 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1094 | if ( !id.isEmpty() ) { | 1108 | if ( !id.isEmpty() ) { |
1095 | QString des = eve->description(); | 1109 | QString des = eve->description(); |
1096 | QString pref = "e"; | 1110 | QString pref = "e"; |
1097 | if ( toDelete->type() == "Todo" ) | 1111 | if ( toDelete->type() == "Todo" ) |
1098 | pref = "t"; | 1112 | pref = "t"; |
1099 | des += pref+ id + ","; | 1113 | des += pref+ id + ","; |
1100 | eve->setReadOnly( false ); | 1114 | eve->setReadOnly( false ); |
1101 | eve->setDescription( des ); | 1115 | eve->setDescription( des ); |
1102 | //qDebug("setdes %s ", des.latin1()); | 1116 | //qDebug("setdes %s ", des.latin1()); |
1103 | eve->setReadOnly( true ); | 1117 | eve->setReadOnly( true ); |
1104 | } | 1118 | } |
1105 | eve = lastSync.next(); | 1119 | eve = lastSync.next(); |
1106 | } | 1120 | } |
1107 | 1121 | ||
1108 | } | 1122 | } |
1109 | void CalendarView::checkExternalId( Incidence * inc ) | 1123 | void CalendarView::checkExternalId( Incidence * inc ) |
1110 | { | 1124 | { |
1111 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1125 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1112 | checkExternSyncEvent( lastSync, inc ); | 1126 | checkExternSyncEvent( lastSync, inc ); |
1113 | 1127 | ||
1114 | } | 1128 | } |
1115 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1129 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1116 | { | 1130 | { |
1117 | bool syncOK = true; | 1131 | bool syncOK = true; |
1118 | int addedEvent = 0; | 1132 | int addedEvent = 0; |
1119 | int addedEventR = 0; | 1133 | int addedEventR = 0; |
1120 | int deletedEventR = 0; | 1134 | int deletedEventR = 0; |
1121 | int deletedEventL = 0; | 1135 | int deletedEventL = 0; |
1122 | int changedLocal = 0; | 1136 | int changedLocal = 0; |
1123 | int changedRemote = 0; | 1137 | int changedRemote = 0; |
1124 | int filteredIN = 0; | 1138 | int filteredIN = 0; |
1125 | int filteredOUT = 0; | 1139 | int filteredOUT = 0; |
1126 | //QPtrList<Event> el = local->rawEvents(); | 1140 | //QPtrList<Event> el = local->rawEvents(); |
1127 | Event* eventR; | 1141 | Event* eventR; |
1128 | QString uid; | 1142 | QString uid; |
1129 | int take; | 1143 | int take; |
1130 | Event* eventL; | 1144 | Event* eventL; |
1131 | Event* eventRSync; | 1145 | Event* eventRSync; |
1132 | Event* eventLSync; | 1146 | Event* eventLSync; |
1133 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1147 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1134 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1148 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1135 | bool fullDateRange = false; | 1149 | bool fullDateRange = false; |
1136 | local->resetTempSyncStat(); | 1150 | local->resetTempSyncStat(); |
1137 | mLastCalendarSync = QDateTime::currentDateTime(); | 1151 | mLastCalendarSync = QDateTime::currentDateTime(); |
1138 | if ( mSyncManager->syncWithDesktop() ) { | 1152 | if ( mSyncManager->syncWithDesktop() ) { |
1139 | remote->resetPilotStat(1); | 1153 | remote->resetPilotStat(1); |
1140 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1154 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1141 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1155 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1142 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1156 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1143 | } else { | 1157 | } else { |
1144 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1158 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1145 | } | 1159 | } |
1146 | } | 1160 | } |
1147 | QDateTime modifiedCalendar = mLastCalendarSync; | 1161 | QDateTime modifiedCalendar = mLastCalendarSync; |
1148 | eventLSync = getLastSyncEvent(); | 1162 | eventLSync = getLastSyncEvent(); |
1149 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1163 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1150 | if ( eventR ) { | 1164 | if ( eventR ) { |
1151 | eventRSync = (Event*) eventR->clone(); | 1165 | eventRSync = (Event*) eventR->clone(); |
1152 | remote->deleteEvent(eventR ); | 1166 | remote->deleteEvent(eventR ); |
1153 | 1167 | ||
1154 | } else { | 1168 | } else { |
1155 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1169 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1156 | eventRSync = (Event*)eventLSync->clone(); | 1170 | eventRSync = (Event*)eventLSync->clone(); |
1157 | } else { | 1171 | } else { |
1158 | fullDateRange = true; | 1172 | fullDateRange = true; |
1159 | eventRSync = new Event(); | 1173 | eventRSync = new Event(); |
1160 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1174 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1161 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1175 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1162 | eventRSync->setDtStart( mLastCalendarSync ); | 1176 | eventRSync->setDtStart( mLastCalendarSync ); |
1163 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1177 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1164 | eventRSync->setCategories( i18n("SyncEvent") ); | 1178 | eventRSync->setCategories( i18n("SyncEvent") ); |
1165 | } | 1179 | } |
1166 | } | 1180 | } |
1167 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1181 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1168 | fullDateRange = true; | 1182 | fullDateRange = true; |
1169 | 1183 | ||
1170 | if ( ! fullDateRange ) { | 1184 | if ( ! fullDateRange ) { |
1171 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1185 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1172 | 1186 | ||
1173 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1187 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1174 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1188 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1175 | fullDateRange = true; | 1189 | fullDateRange = true; |
1176 | } | 1190 | } |
1177 | } | 1191 | } |
1178 | if ( mSyncManager->syncWithDesktop() ) { | 1192 | if ( mSyncManager->syncWithDesktop() ) { |
1179 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1193 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1180 | } | 1194 | } |
1181 | if ( fullDateRange ) | 1195 | if ( fullDateRange ) |
1182 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1196 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1183 | else | 1197 | else |
1184 | mLastCalendarSync = eventLSync->dtStart(); | 1198 | mLastCalendarSync = eventLSync->dtStart(); |
1185 | // for resyncing if own file has changed | 1199 | // for resyncing if own file has changed |
1186 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1200 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1187 | mLastCalendarSync = loadedFileVersion; | 1201 | mLastCalendarSync = loadedFileVersion; |
1188 | //qDebug("setting mLastCalendarSync "); | 1202 | //qDebug("setting mLastCalendarSync "); |
1189 | } | 1203 | } |
1190 | //qDebug("*************************** "); | 1204 | //qDebug("*************************** "); |
1191 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1205 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1192 | QPtrList<Incidence> er = remote->rawIncidences(); | 1206 | QPtrList<Incidence> er = remote->rawIncidences(); |
1193 | Incidence* inR = er.first(); | 1207 | Incidence* inR = er.first(); |
1194 | Incidence* inL; | 1208 | Incidence* inL; |
1195 | QProgressBar bar( er.count(),0 ); | 1209 | QProgressBar bar( er.count(),0 ); |
1196 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1210 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1197 | 1211 | ||
1198 | // ************** setting up filter ************* | 1212 | // ************** setting up filter ************* |
1199 | CalFilter *filterIN = 0; | 1213 | CalFilter *filterIN = 0; |
1200 | CalFilter *filterOUT = 0; | 1214 | CalFilter *filterOUT = 0; |
1201 | CalFilter *filter = mFilters.first(); | 1215 | CalFilter *filter = mFilters.first(); |
1202 | while(filter) { | 1216 | while(filter) { |
1203 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1217 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1204 | filterIN = filter; | 1218 | filterIN = filter; |
1205 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1219 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1206 | filterOUT = filter; | 1220 | filterOUT = filter; |
1207 | filter = mFilters.next(); | 1221 | filter = mFilters.next(); |
1208 | } | 1222 | } |
1209 | int w = 300; | 1223 | int w = 300; |
1210 | if ( QApplication::desktop()->width() < 320 ) | 1224 | if ( QApplication::desktop()->width() < 320 ) |
1211 | w = 220; | 1225 | w = 220; |
1212 | int h = bar.sizeHint().height() ; | 1226 | int h = bar.sizeHint().height() ; |
1213 | int dw = QApplication::desktop()->width(); | 1227 | int dw = QApplication::desktop()->width(); |
1214 | int dh = QApplication::desktop()->height(); | 1228 | int dh = QApplication::desktop()->height(); |
1215 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1229 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1216 | bar.show(); | 1230 | bar.show(); |
1217 | int modulo = (er.count()/10)+1; | 1231 | int modulo = (er.count()/10)+1; |
1218 | int incCounter = 0; | 1232 | int incCounter = 0; |
1219 | while ( inR ) { | 1233 | while ( inR ) { |
1220 | if ( ! bar.isVisible() ) | 1234 | if ( ! bar.isVisible() ) |
1221 | return false; | 1235 | return false; |
1222 | if ( incCounter % modulo == 0 ) | 1236 | if ( incCounter % modulo == 0 ) |
1223 | bar.setProgress( incCounter ); | 1237 | bar.setProgress( incCounter ); |
1224 | ++incCounter; | 1238 | ++incCounter; |
1225 | uid = inR->uid(); | 1239 | uid = inR->uid(); |
1226 | bool skipIncidence = false; | 1240 | bool skipIncidence = false; |
1227 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1241 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1228 | skipIncidence = true; | 1242 | skipIncidence = true; |
1229 | QString idS; | 1243 | QString idS; |
1230 | qApp->processEvents(); | 1244 | qApp->processEvents(); |
1231 | if ( !skipIncidence ) { | 1245 | if ( !skipIncidence ) { |
1232 | inL = local->incidence( uid ); | 1246 | inL = local->incidence( uid ); |
1233 | if ( inL ) { // maybe conflict - same uid in both calendars | 1247 | if ( inL ) { // maybe conflict - same uid in both calendars |
1234 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1248 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1235 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1249 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1236 | if ( take == 3 ) | 1250 | if ( take == 3 ) |
1237 | return false; | 1251 | return false; |
1238 | if ( take == 1 ) {// take local ********************** | 1252 | if ( take == 1 ) {// take local ********************** |
1239 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1253 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1240 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1254 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1241 | else | 1255 | else |
1242 | idS = inR->IDStr(); | 1256 | idS = inR->IDStr(); |
1243 | remote->deleteIncidence( inR ); | 1257 | remote->deleteIncidence( inR ); |
1244 | inR = inL->clone(); | 1258 | inR = inL->clone(); |
1245 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1259 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1246 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1260 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1247 | inR->setIDStr( idS ); | 1261 | inR->setIDStr( idS ); |
1248 | remote->addIncidence( inR ); | 1262 | remote->addIncidence( inR ); |
1249 | if ( mSyncManager->syncWithDesktop() ) | 1263 | if ( mSyncManager->syncWithDesktop() ) |
1250 | inR->setPilotId( 2 ); | 1264 | inR->setPilotId( 2 ); |
1251 | ++changedRemote; | 1265 | ++changedRemote; |
1252 | } else {// take remote ********************** | 1266 | } else {// take remote ********************** |
1253 | idS = inL->IDStr(); | 1267 | idS = inL->IDStr(); |
1254 | int pid = inL->pilotId(); | 1268 | int pid = inL->pilotId(); |
1255 | local->deleteIncidence( inL ); | 1269 | local->deleteIncidence( inL ); |
1256 | inL = inR->clone(); | 1270 | inL = inR->clone(); |
1257 | if ( mSyncManager->syncWithDesktop() ) | 1271 | if ( mSyncManager->syncWithDesktop() ) |
1258 | inL->setPilotId( pid ); | 1272 | inL->setPilotId( pid ); |
1259 | inL->setIDStr( idS ); | 1273 | inL->setIDStr( idS ); |
1260 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1274 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1261 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1275 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1262 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1276 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1263 | } | 1277 | } |
1264 | local->addIncidence( inL ); | 1278 | local->addIncidence( inL ); |
1265 | ++changedLocal; | 1279 | ++changedLocal; |
1266 | } | 1280 | } |
1267 | } | 1281 | } |
1268 | } else { // no conflict ********** add or delete remote | 1282 | } else { // no conflict ********** add or delete remote |
1269 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1283 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1270 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1284 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1271 | QString des = eventLSync->description(); | 1285 | QString des = eventLSync->description(); |
1272 | QString pref = "e"; | 1286 | QString pref = "e"; |
1273 | if ( inR->type() == "Todo" ) | 1287 | if ( inR->type() == "Todo" ) |
1274 | pref = "t"; | 1288 | pref = "t"; |
1275 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1289 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1276 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1290 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1277 | //remote->deleteIncidence( inR ); | 1291 | //remote->deleteIncidence( inR ); |
1278 | ++deletedEventR; | 1292 | ++deletedEventR; |
1279 | } else { | 1293 | } else { |
1280 | inR->setLastModified( modifiedCalendar ); | 1294 | inR->setLastModified( modifiedCalendar ); |
1281 | inL = inR->clone(); | 1295 | inL = inR->clone(); |
1282 | inL->setIDStr( ":" ); | 1296 | inL->setIDStr( ":" ); |
1283 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1297 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1284 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1298 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1285 | local->addIncidence( inL ); | 1299 | local->addIncidence( inL ); |
1286 | ++addedEvent; | 1300 | ++addedEvent; |
1287 | 1301 | ||
1288 | } | 1302 | } |
1289 | } else { | 1303 | } else { |
1290 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1304 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1291 | inR->setLastModified( modifiedCalendar ); | 1305 | inR->setLastModified( modifiedCalendar ); |
1292 | inL = inR->clone(); | 1306 | inL = inR->clone(); |
1293 | inL->setIDStr( ":" ); | 1307 | inL->setIDStr( ":" ); |
1294 | local->addIncidence( inL ); | 1308 | local->addIncidence( inL ); |
1295 | ++addedEvent; | 1309 | ++addedEvent; |
1296 | 1310 | ||
1297 | } else { | 1311 | } else { |
1298 | checkExternSyncEvent(eventRSyncSharp, inR); | 1312 | checkExternSyncEvent(eventRSyncSharp, inR); |
1299 | remote->deleteIncidence( inR ); | 1313 | remote->deleteIncidence( inR ); |
1300 | ++deletedEventR; | 1314 | ++deletedEventR; |
1301 | } | 1315 | } |
1302 | } | 1316 | } |
1303 | } else { | 1317 | } else { |
1304 | ++filteredIN; | 1318 | ++filteredIN; |
1305 | } | 1319 | } |
1306 | } | 1320 | } |
1307 | } | 1321 | } |
1308 | inR = er.next(); | 1322 | inR = er.next(); |
1309 | } | 1323 | } |
1310 | QPtrList<Incidence> el = local->rawIncidences(); | 1324 | QPtrList<Incidence> el = local->rawIncidences(); |
1311 | inL = el.first(); | 1325 | inL = el.first(); |
1312 | modulo = (el.count()/10)+1; | 1326 | modulo = (el.count()/10)+1; |
1313 | bar.setCaption (i18n("Add / remove events") ); | 1327 | bar.setCaption (i18n("Add / remove events") ); |
1314 | bar.setTotalSteps ( el.count() ) ; | 1328 | bar.setTotalSteps ( el.count() ) ; |
1315 | bar.show(); | 1329 | bar.show(); |
1316 | incCounter = 0; | 1330 | incCounter = 0; |
1317 | 1331 | ||
1318 | while ( inL ) { | 1332 | while ( inL ) { |
1319 | 1333 | ||
1320 | qApp->processEvents(); | 1334 | qApp->processEvents(); |
1321 | if ( ! bar.isVisible() ) | 1335 | if ( ! bar.isVisible() ) |
1322 | return false; | 1336 | return false; |
1323 | if ( incCounter % modulo == 0 ) | 1337 | if ( incCounter % modulo == 0 ) |
1324 | bar.setProgress( incCounter ); | 1338 | bar.setProgress( incCounter ); |
1325 | ++incCounter; | 1339 | ++incCounter; |
1326 | uid = inL->uid(); | 1340 | uid = inL->uid(); |
1327 | bool skipIncidence = false; | 1341 | bool skipIncidence = false; |
1328 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1342 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1329 | skipIncidence = true; | 1343 | skipIncidence = true; |
1330 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1344 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1331 | skipIncidence = true; | 1345 | skipIncidence = true; |
1332 | if ( !skipIncidence ) { | 1346 | if ( !skipIncidence ) { |
1333 | inR = remote->incidence( uid ); | 1347 | inR = remote->incidence( uid ); |
1334 | if ( ! inR ) { | 1348 | if ( ! inR ) { |
1335 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1349 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1336 | // no conflict ********** add or delete local | 1350 | // no conflict ********** add or delete local |
1337 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1351 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1338 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1352 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1339 | checkExternSyncEvent(eventLSyncSharp, inL); | 1353 | checkExternSyncEvent(eventLSyncSharp, inL); |
1340 | local->deleteIncidence( inL ); | 1354 | local->deleteIncidence( inL ); |
1341 | ++deletedEventL; | 1355 | ++deletedEventL; |
1342 | } else { | 1356 | } else { |
1343 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1357 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1344 | inL->removeID(mCurrentSyncDevice ); | 1358 | inL->removeID(mCurrentSyncDevice ); |
1345 | ++addedEventR; | 1359 | ++addedEventR; |
1346 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1360 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1347 | inL->setLastModified( modifiedCalendar ); | 1361 | inL->setLastModified( modifiedCalendar ); |
1348 | inR = inL->clone(); | 1362 | inR = inL->clone(); |
1349 | inR->setIDStr( ":" ); | 1363 | inR->setIDStr( ":" ); |
1350 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1364 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1351 | remote->addIncidence( inR ); | 1365 | remote->addIncidence( inR ); |
1352 | } | 1366 | } |
1353 | } | 1367 | } |
1354 | } else { | 1368 | } else { |
1355 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1369 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1356 | checkExternSyncEvent(eventLSyncSharp, inL); | 1370 | checkExternSyncEvent(eventLSyncSharp, inL); |
1357 | local->deleteIncidence( inL ); | 1371 | local->deleteIncidence( inL ); |
1358 | ++deletedEventL; | 1372 | ++deletedEventL; |
1359 | } else { | 1373 | } else { |
1360 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1374 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1361 | ++addedEventR; | 1375 | ++addedEventR; |
1362 | inL->setLastModified( modifiedCalendar ); | 1376 | inL->setLastModified( modifiedCalendar ); |
1363 | inR = inL->clone(); | 1377 | inR = inL->clone(); |
1364 | inR->setIDStr( ":" ); | 1378 | inR->setIDStr( ":" ); |
1365 | remote->addIncidence( inR ); | 1379 | remote->addIncidence( inR ); |
1366 | } | 1380 | } |
1367 | } | 1381 | } |
1368 | } | 1382 | } |
1369 | } else { | 1383 | } else { |
1370 | ++filteredOUT; | 1384 | ++filteredOUT; |
1371 | } | 1385 | } |
1372 | } | 1386 | } |
1373 | } | 1387 | } |
1374 | inL = el.next(); | 1388 | inL = el.next(); |
1375 | } | 1389 | } |
1376 | int delFut = 0; | 1390 | int delFut = 0; |
1377 | int remRem = 0; | 1391 | int remRem = 0; |
1378 | if ( mSyncManager->mWriteBackInFuture ) { | 1392 | if ( mSyncManager->mWriteBackInFuture ) { |
1379 | er = remote->rawIncidences(); | 1393 | er = remote->rawIncidences(); |
1380 | remRem = er.count(); | 1394 | remRem = er.count(); |
1381 | inR = er.first(); | 1395 | inR = er.first(); |
1382 | QDateTime dt; | 1396 | QDateTime dt; |
1383 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1397 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1384 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1398 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1385 | while ( inR ) { | 1399 | while ( inR ) { |
1386 | if ( inR->type() == "Todo" ) { | 1400 | if ( inR->type() == "Todo" ) { |
1387 | Todo * t = (Todo*)inR; | 1401 | Todo * t = (Todo*)inR; |
1388 | if ( t->hasDueDate() ) | 1402 | if ( t->hasDueDate() ) |
1389 | dt = t->dtDue(); | 1403 | dt = t->dtDue(); |
1390 | else | 1404 | else |
1391 | dt = cur.addSecs( 62 ); | 1405 | dt = cur.addSecs( 62 ); |
1392 | } | 1406 | } |
1393 | else if (inR->type() == "Event" ) { | 1407 | else if (inR->type() == "Event" ) { |
1394 | bool ok; | 1408 | bool ok; |
1395 | dt = inR->getNextOccurence( cur, &ok ); | 1409 | dt = inR->getNextOccurence( cur, &ok ); |
1396 | if ( !ok ) | 1410 | if ( !ok ) |
1397 | dt = cur.addSecs( -62 ); | 1411 | dt = cur.addSecs( -62 ); |
1398 | } | 1412 | } |
1399 | else | 1413 | else |
1400 | dt = inR->dtStart(); | 1414 | dt = inR->dtStart(); |
1401 | if ( dt < cur || dt > end ) { | 1415 | if ( dt < cur || dt > end ) { |
1402 | remote->deleteIncidence( inR ); | 1416 | remote->deleteIncidence( inR ); |
1403 | ++delFut; | 1417 | ++delFut; |
1404 | } | 1418 | } |
1405 | inR = er.next(); | 1419 | inR = er.next(); |
1406 | } | 1420 | } |
1407 | } | 1421 | } |
1408 | bar.hide(); | 1422 | bar.hide(); |
1409 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1423 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1410 | eventLSync->setReadOnly( false ); | 1424 | eventLSync->setReadOnly( false ); |
1411 | eventLSync->setDtStart( mLastCalendarSync ); | 1425 | eventLSync->setDtStart( mLastCalendarSync ); |
1412 | eventRSync->setDtStart( mLastCalendarSync ); | 1426 | eventRSync->setDtStart( mLastCalendarSync ); |
1413 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1427 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1414 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1428 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1415 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1429 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1416 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1430 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1417 | eventLSync->setReadOnly( true ); | 1431 | eventLSync->setReadOnly( true ); |
1418 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1432 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1419 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1433 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1420 | remote->addEvent( eventRSync ); | 1434 | remote->addEvent( eventRSync ); |
1421 | else | 1435 | else |
1422 | delete eventRSync; | 1436 | delete eventRSync; |
1423 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1437 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1424 | QString mes; | 1438 | QString mes; |
1425 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1439 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1426 | QString delmess; | 1440 | QString delmess; |
1427 | if ( delFut ) { | 1441 | if ( delFut ) { |
1428 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1442 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1429 | mes += delmess; | 1443 | mes += delmess; |
1430 | } | 1444 | } |
1431 | mes = i18n("Local calendar changed!\n") +mes; | 1445 | mes = i18n("Local calendar changed!\n") +mes; |
1432 | mCalendar->checkAlarmForIncidence( 0, true ); | 1446 | mCalendar->checkAlarmForIncidence( 0, true ); |
1433 | qDebug( mes ); | 1447 | qDebug( mes ); |
1434 | if ( mSyncManager->mShowSyncSummary ) { | 1448 | if ( mSyncManager->mShowSyncSummary ) { |
1435 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1449 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1436 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1450 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1437 | qDebug("KO: WB cancelled "); | 1451 | qDebug("KO: WB cancelled "); |
1438 | mSyncManager->mWriteBackFile = false; | 1452 | mSyncManager->mWriteBackFile = false; |
1439 | return syncOK; | 1453 | return syncOK; |
1440 | } | 1454 | } |
1441 | } | 1455 | } |
1442 | return syncOK; | 1456 | return syncOK; |
1443 | } | 1457 | } |
1444 | 1458 | ||
1445 | void CalendarView::setSyncDevice( QString s ) | 1459 | void CalendarView::setSyncDevice( QString s ) |
1446 | { | 1460 | { |
1447 | mCurrentSyncDevice= s; | 1461 | mCurrentSyncDevice= s; |
1448 | } | 1462 | } |
1449 | void CalendarView::setSyncName( QString s ) | 1463 | void CalendarView::setSyncName( QString s ) |
1450 | { | 1464 | { |
1451 | mCurrentSyncName= s; | 1465 | mCurrentSyncName= s; |
1452 | } | 1466 | } |
1453 | bool CalendarView::syncCalendar(QString filename, int mode) | 1467 | bool CalendarView::syncCalendar(QString filename, int mode) |
1454 | { | 1468 | { |
1455 | //qDebug("syncCalendar %s ", filename.latin1()); | 1469 | //qDebug("syncCalendar %s ", filename.latin1()); |
1456 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1470 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1457 | CalendarLocal* calendar = new CalendarLocal(); | 1471 | CalendarLocal* calendar = new CalendarLocal(); |
1458 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1472 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1459 | FileStorage* storage = new FileStorage( calendar ); | 1473 | FileStorage* storage = new FileStorage( calendar ); |
1460 | bool syncOK = false; | 1474 | bool syncOK = false; |
1461 | storage->setFileName( filename ); | 1475 | storage->setFileName( filename ); |
1462 | // qDebug("loading ... "); | 1476 | // qDebug("loading ... "); |
1463 | if ( storage->load() ) { | 1477 | if ( storage->load() ) { |
1464 | getEventViewerDialog()->setSyncMode( true ); | 1478 | getEventViewerDialog()->setSyncMode( true ); |
1465 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1479 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1466 | getEventViewerDialog()->setSyncMode( false ); | 1480 | getEventViewerDialog()->setSyncMode( false ); |
1467 | if ( syncOK ) { | 1481 | if ( syncOK ) { |
1468 | if ( mSyncManager->mWriteBackFile ) | 1482 | if ( mSyncManager->mWriteBackFile ) |
1469 | { | 1483 | { |
1470 | storage->setSaveFormat( new ICalFormat() ); | 1484 | storage->setSaveFormat( new ICalFormat() ); |
1471 | storage->save(); | 1485 | storage->save(); |
1472 | } | 1486 | } |
1473 | } | 1487 | } |
1474 | setModified( true ); | 1488 | setModified( true ); |
1475 | } | 1489 | } |
1476 | delete storage; | 1490 | delete storage; |
1477 | delete calendar; | 1491 | delete calendar; |
1478 | if ( syncOK ) | 1492 | if ( syncOK ) |
1479 | updateView(); | 1493 | updateView(); |
1480 | return syncOK; | 1494 | return syncOK; |
1481 | } | 1495 | } |
1482 | 1496 | ||
1483 | void CalendarView::syncExternal( int mode ) | 1497 | void CalendarView::syncExternal( int mode ) |
1484 | { | 1498 | { |
1485 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1499 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1486 | 1500 | ||
1487 | qApp->processEvents(); | 1501 | qApp->processEvents(); |
1488 | CalendarLocal* calendar = new CalendarLocal(); | 1502 | CalendarLocal* calendar = new CalendarLocal(); |
1489 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1503 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1490 | bool syncOK = false; | 1504 | bool syncOK = false; |
1491 | bool loadSuccess = false; | 1505 | bool loadSuccess = false; |
1492 | PhoneFormat* phoneFormat = 0; | 1506 | PhoneFormat* phoneFormat = 0; |
1493 | emit tempDisableBR(true); | 1507 | emit tempDisableBR(true); |
1494 | #ifndef DESKTOP_VERSION | 1508 | #ifndef DESKTOP_VERSION |
1495 | SharpFormat* sharpFormat = 0; | 1509 | SharpFormat* sharpFormat = 0; |
1496 | if ( mode == 0 ) { // sharp | 1510 | if ( mode == 0 ) { // sharp |
1497 | sharpFormat = new SharpFormat () ; | 1511 | sharpFormat = new SharpFormat () ; |
1498 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1512 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1499 | 1513 | ||
1500 | } else | 1514 | } else |
1501 | #endif | 1515 | #endif |
1502 | if ( mode == 1 ) { // phone | 1516 | if ( mode == 1 ) { // phone |
1503 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1517 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1504 | mSyncManager->mPhoneDevice, | 1518 | mSyncManager->mPhoneDevice, |
1505 | mSyncManager->mPhoneConnection, | 1519 | mSyncManager->mPhoneConnection, |
1506 | mSyncManager->mPhoneModel); | 1520 | mSyncManager->mPhoneModel); |
1507 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1521 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1508 | 1522 | ||
1509 | } else { | 1523 | } else { |
1510 | emit tempDisableBR(false); | 1524 | emit tempDisableBR(false); |
1511 | return; | 1525 | return; |
1512 | } | 1526 | } |
1513 | if ( loadSuccess ) { | 1527 | if ( loadSuccess ) { |
1514 | getEventViewerDialog()->setSyncMode( true ); | 1528 | getEventViewerDialog()->setSyncMode( true ); |
1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1529 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1516 | getEventViewerDialog()->setSyncMode( false ); | 1530 | getEventViewerDialog()->setSyncMode( false ); |
1517 | qApp->processEvents(); | 1531 | qApp->processEvents(); |
1518 | if ( syncOK ) { | 1532 | if ( syncOK ) { |
1519 | if ( mSyncManager->mWriteBackFile ) | 1533 | if ( mSyncManager->mWriteBackFile ) |
1520 | { | 1534 | { |
1521 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1535 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1522 | Incidence* inc = iL.first(); | 1536 | Incidence* inc = iL.first(); |
1523 | if ( phoneFormat ) { | 1537 | if ( phoneFormat ) { |
1524 | while ( inc ) { | 1538 | while ( inc ) { |
1525 | inc->removeID(mCurrentSyncDevice); | 1539 | inc->removeID(mCurrentSyncDevice); |
1526 | inc = iL.next(); | 1540 | inc = iL.next(); |
1527 | } | 1541 | } |
1528 | } | 1542 | } |
1529 | #ifndef DESKTOP_VERSION | 1543 | #ifndef DESKTOP_VERSION |
1530 | if ( sharpFormat ) | 1544 | if ( sharpFormat ) |
1531 | sharpFormat->save(calendar); | 1545 | sharpFormat->save(calendar); |
1532 | #endif | 1546 | #endif |
1533 | if ( phoneFormat ) | 1547 | if ( phoneFormat ) |
1534 | phoneFormat->save(calendar); | 1548 | phoneFormat->save(calendar); |
1535 | iL = calendar->rawIncidences(); | 1549 | iL = calendar->rawIncidences(); |
1536 | inc = iL.first(); | 1550 | inc = iL.first(); |
1537 | Incidence* loc; | 1551 | Incidence* loc; |
1538 | while ( inc ) { | 1552 | while ( inc ) { |
1539 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1553 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1540 | loc = mCalendar->incidence(inc->uid() ); | 1554 | loc = mCalendar->incidence(inc->uid() ); |
1541 | if ( loc ) { | 1555 | if ( loc ) { |
1542 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1556 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1543 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1557 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1544 | } | 1558 | } |
1545 | } | 1559 | } |
1546 | inc = iL.next(); | 1560 | inc = iL.next(); |
1547 | } | 1561 | } |
1548 | Incidence* lse = getLastSyncEvent(); | 1562 | Incidence* lse = getLastSyncEvent(); |
1549 | if ( lse ) { | 1563 | if ( lse ) { |
1550 | lse->setReadOnly( false ); | 1564 | lse->setReadOnly( false ); |
1551 | lse->setDescription( "" ); | 1565 | lse->setDescription( "" ); |
1552 | lse->setReadOnly( true ); | 1566 | lse->setReadOnly( true ); |
1553 | } | 1567 | } |
1554 | } | 1568 | } |
1555 | } else { | 1569 | } else { |
1556 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1570 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1557 | } | 1571 | } |
1558 | setModified( true ); | 1572 | setModified( true ); |
1559 | } else { | 1573 | } else { |
1560 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1574 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1561 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1575 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1562 | question, i18n("Ok")) ; | 1576 | question, i18n("Ok")) ; |
1563 | 1577 | ||
1564 | } | 1578 | } |
1565 | delete calendar; | 1579 | delete calendar; |
1566 | updateView(); | 1580 | updateView(); |
1567 | emit tempDisableBR(false); | 1581 | emit tempDisableBR(false); |
1568 | return ;//syncOK; | 1582 | return ;//syncOK; |
1569 | 1583 | ||
1570 | } | 1584 | } |
1571 | 1585 | ||
1572 | bool CalendarView::importBday() | 1586 | bool CalendarView::importBday() |
1573 | { | 1587 | { |
1574 | #ifndef KORG_NOKABC | 1588 | #ifndef KORG_NOKABC |
1575 | 1589 | ||
1576 | #ifdef DESKTOP_VERSION | 1590 | #ifdef DESKTOP_VERSION |
1577 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1591 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1578 | KABC::AddressBook::Iterator it; | 1592 | KABC::AddressBook::Iterator it; |
1579 | int count = 0; | 1593 | int count = 0; |
1580 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1594 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1581 | ++count; | 1595 | ++count; |
1582 | } | 1596 | } |
1583 | QProgressBar bar(count,0 ); | 1597 | QProgressBar bar(count,0 ); |
1584 | int w = 300; | 1598 | int w = 300; |
1585 | if ( QApplication::desktop()->width() < 320 ) | 1599 | if ( QApplication::desktop()->width() < 320 ) |
1586 | w = 220; | 1600 | w = 220; |
1587 | int h = bar.sizeHint().height() ; | 1601 | int h = bar.sizeHint().height() ; |
1588 | int dw = QApplication::desktop()->width(); | 1602 | int dw = QApplication::desktop()->width(); |
1589 | int dh = QApplication::desktop()->height(); | 1603 | int dh = QApplication::desktop()->height(); |
1590 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1604 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1591 | bar.show(); | 1605 | bar.show(); |
1592 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1606 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1593 | qApp->processEvents(); | 1607 | qApp->processEvents(); |
1594 | count = 0; | 1608 | count = 0; |
1595 | int addCount = 0; | 1609 | int addCount = 0; |
1596 | KCal::Attendee* a = 0; | 1610 | KCal::Attendee* a = 0; |
1597 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1611 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1598 | if ( ! bar.isVisible() ) | 1612 | if ( ! bar.isVisible() ) |
1599 | return false; | 1613 | return false; |
1600 | bar.setProgress( count++ ); | 1614 | bar.setProgress( count++ ); |
1601 | qApp->processEvents(); | 1615 | qApp->processEvents(); |
1602 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1616 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1603 | if ( (*it).birthday().date().isValid() ){ | 1617 | if ( (*it).birthday().date().isValid() ){ |
1604 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1618 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1605 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1619 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1606 | ++addCount; | 1620 | ++addCount; |
1607 | } | 1621 | } |
1608 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1622 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1609 | if ( anni.isValid() ){ | 1623 | if ( anni.isValid() ){ |
1610 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1624 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1611 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1625 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1612 | ++addCount; | 1626 | ++addCount; |
1613 | } | 1627 | } |
1614 | } | 1628 | } |
1615 | updateView(); | 1629 | updateView(); |
1616 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1630 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1617 | #else //DESKTOP_VERSION | 1631 | #else //DESKTOP_VERSION |
1618 | 1632 | ||
1619 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1633 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1620 | // the result should now arrive through method insertBirthdays | 1634 | // the result should now arrive through method insertBirthdays |
1621 | 1635 | ||
1622 | #endif //DESKTOP_VERSION | 1636 | #endif //DESKTOP_VERSION |
1623 | 1637 | ||
1624 | #endif //KORG_NOKABC | 1638 | #endif //KORG_NOKABC |
1625 | 1639 | ||
1626 | 1640 | ||
1627 | return true; | 1641 | return true; |
1628 | } | 1642 | } |
1629 | 1643 | ||
1630 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1644 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1631 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1645 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1632 | const QStringList& anniversaryList, const QStringList& realNameList, | 1646 | const QStringList& anniversaryList, const QStringList& realNameList, |
1633 | const QStringList& emailList, const QStringList& assembledNameList, | 1647 | const QStringList& emailList, const QStringList& assembledNameList, |
1634 | const QStringList& uidList) | 1648 | const QStringList& uidList) |
1635 | { | 1649 | { |
1636 | //qDebug("KO::CalendarView::insertBirthdays"); | 1650 | //qDebug("KO::CalendarView::insertBirthdays"); |
1637 | if (uid == this->name()) | 1651 | if (uid == this->name()) |
1638 | { | 1652 | { |
1639 | int count = birthdayList.count(); | 1653 | int count = birthdayList.count(); |
1640 | int addCount = 0; | 1654 | int addCount = 0; |
1641 | KCal::Attendee* a = 0; | 1655 | KCal::Attendee* a = 0; |
1642 | 1656 | ||
1643 | //qDebug("CalView 1 %i", count); | 1657 | //qDebug("CalView 1 %i", count); |
1644 | 1658 | ||
1645 | QProgressBar bar(count,0 ); | 1659 | QProgressBar bar(count,0 ); |
1646 | int w = 300; | 1660 | int w = 300; |
1647 | if ( QApplication::desktop()->width() < 320 ) | 1661 | if ( QApplication::desktop()->width() < 320 ) |
1648 | w = 220; | 1662 | w = 220; |
1649 | int h = bar.sizeHint().height() ; | 1663 | int h = bar.sizeHint().height() ; |
1650 | int dw = QApplication::desktop()->width(); | 1664 | int dw = QApplication::desktop()->width(); |
1651 | int dh = QApplication::desktop()->height(); | 1665 | int dh = QApplication::desktop()->height(); |
1652 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1666 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1653 | bar.show(); | 1667 | bar.show(); |
1654 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1668 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1655 | qApp->processEvents(); | 1669 | qApp->processEvents(); |
1656 | 1670 | ||
1657 | QDate birthday; | 1671 | QDate birthday; |
1658 | QDate anniversary; | 1672 | QDate anniversary; |
1659 | QString realName; | 1673 | QString realName; |
1660 | QString email; | 1674 | QString email; |
1661 | QString assembledName; | 1675 | QString assembledName; |
1662 | QString uid; | 1676 | QString uid; |
1663 | bool ok = true; | 1677 | bool ok = true; |
1664 | for ( int i = 0; i < count; i++) | 1678 | for ( int i = 0; i < count; i++) |
1665 | { | 1679 | { |
1666 | if ( ! bar.isVisible() ) | 1680 | if ( ! bar.isVisible() ) |
1667 | return; | 1681 | return; |
1668 | bar.setProgress( i ); | 1682 | bar.setProgress( i ); |
1669 | qApp->processEvents(); | 1683 | qApp->processEvents(); |
1670 | 1684 | ||
1671 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1685 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1672 | if (!ok) { | 1686 | if (!ok) { |
1673 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1687 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1674 | } | 1688 | } |
1675 | 1689 | ||
1676 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1690 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1677 | if (!ok) { | 1691 | if (!ok) { |
1678 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1692 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1679 | } | 1693 | } |
1680 | realName = realNameList[i]; | 1694 | realName = realNameList[i]; |
1681 | email = emailList[i]; | 1695 | email = emailList[i]; |
1682 | assembledName = assembledNameList[i]; | 1696 | assembledName = assembledNameList[i]; |
1683 | uid = uidList[i]; | 1697 | uid = uidList[i]; |
1684 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1698 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1685 | 1699 | ||
1686 | if ( birthday.isValid() ){ | 1700 | if ( birthday.isValid() ){ |
1687 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1701 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1688 | KCal::Attendee::ReqParticipant,uid) ; | 1702 | KCal::Attendee::ReqParticipant,uid) ; |
1689 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1703 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1690 | ++addCount; | 1704 | ++addCount; |
1691 | } | 1705 | } |
1692 | 1706 | ||
1693 | if ( anniversary.isValid() ){ | 1707 | if ( anniversary.isValid() ){ |
1694 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1708 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1695 | KCal::Attendee::ReqParticipant,uid) ; | 1709 | KCal::Attendee::ReqParticipant,uid) ; |
1696 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1710 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1697 | ++addCount; | 1711 | ++addCount; |
1698 | } | 1712 | } |
1699 | } | 1713 | } |
1700 | 1714 | ||
1701 | updateView(); | 1715 | updateView(); |
1702 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1716 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1703 | 1717 | ||
1704 | } | 1718 | } |
1705 | 1719 | ||
1706 | } | 1720 | } |
1707 | 1721 | ||
1708 | 1722 | ||
1709 | 1723 | ||
1710 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1724 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1711 | { | 1725 | { |
1712 | //qDebug("addAnni "); | 1726 | //qDebug("addAnni "); |
1713 | Event * ev = new Event(); | 1727 | Event * ev = new Event(); |
1714 | ev->setOrganizer(KOPrefs::instance()->email()); | 1728 | ev->setOrganizer(KOPrefs::instance()->email()); |
1715 | if ( a ) { | 1729 | if ( a ) { |
1716 | ev->addAttendee( a ); | 1730 | ev->addAttendee( a ); |
1717 | } | 1731 | } |
1718 | QString kind; | 1732 | QString kind; |
1719 | if ( birthday ) { | 1733 | if ( birthday ) { |
1720 | kind = i18n( "Birthday" ); | 1734 | kind = i18n( "Birthday" ); |
1721 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1735 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1722 | } | 1736 | } |
1723 | else { | 1737 | else { |
1724 | kind = i18n( "Anniversary" ); | 1738 | kind = i18n( "Anniversary" ); |
1725 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1739 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1726 | } | 1740 | } |
1727 | ev->setCategories( kind ); | 1741 | ev->setCategories( kind ); |
1728 | ev->setDtStart( QDateTime(date) ); | 1742 | ev->setDtStart( QDateTime(date) ); |
1729 | ev->setDtEnd( QDateTime(date) ); | 1743 | ev->setDtEnd( QDateTime(date) ); |
1730 | ev->setFloats( true ); | 1744 | ev->setFloats( true ); |
1731 | Recurrence * rec = ev->recurrence(); | 1745 | Recurrence * rec = ev->recurrence(); |
1732 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1746 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1733 | rec->addYearlyNum( date.month() ); | 1747 | rec->addYearlyNum( date.month() ); |
1734 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1748 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1735 | delete ev; | 1749 | delete ev; |
1736 | return false; | 1750 | return false; |
1737 | } | 1751 | } |
1738 | return true; | 1752 | return true; |
1739 | 1753 | ||
1740 | } | 1754 | } |
1741 | bool CalendarView::importQtopia( const QString &categories, | 1755 | bool CalendarView::importQtopia( const QString &categories, |
1742 | const QString &datebook, | 1756 | const QString &datebook, |
1743 | const QString &todolist ) | 1757 | const QString &todolist ) |
1744 | { | 1758 | { |
1745 | 1759 | ||
1746 | QtopiaFormat qtopiaFormat; | 1760 | QtopiaFormat qtopiaFormat; |
1747 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1761 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1748 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1762 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1749 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1763 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1750 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1764 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1751 | 1765 | ||
1752 | updateView(); | 1766 | updateView(); |
1753 | return true; | 1767 | return true; |
1754 | 1768 | ||
1755 | #if 0 | 1769 | #if 0 |
1756 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1770 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1757 | mCurrentSyncDevice = "qtopia-XML"; | 1771 | mCurrentSyncDevice = "qtopia-XML"; |
1758 | if ( mSyncManager->mAskForPreferences ) | 1772 | if ( mSyncManager->mAskForPreferences ) |
1759 | edit_sync_options(); | 1773 | edit_sync_options(); |
1760 | qApp->processEvents(); | 1774 | qApp->processEvents(); |
1761 | CalendarLocal* calendar = new CalendarLocal(); | 1775 | CalendarLocal* calendar = new CalendarLocal(); |
1762 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1776 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1763 | bool syncOK = false; | 1777 | bool syncOK = false; |
1764 | QtopiaFormat qtopiaFormat; | 1778 | QtopiaFormat qtopiaFormat; |
1765 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1779 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1766 | bool loadOk = true; | 1780 | bool loadOk = true; |
1767 | if ( !categories.isEmpty() ) | 1781 | if ( !categories.isEmpty() ) |
1768 | loadOk = qtopiaFormat.load( calendar, categories ); | 1782 | loadOk = qtopiaFormat.load( calendar, categories ); |
1769 | if ( loadOk && !datebook.isEmpty() ) | 1783 | if ( loadOk && !datebook.isEmpty() ) |
1770 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1784 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1771 | if ( loadOk && !todolist.isEmpty() ) | 1785 | if ( loadOk && !todolist.isEmpty() ) |
1772 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1786 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1773 | 1787 | ||
1774 | if ( loadOk ) { | 1788 | if ( loadOk ) { |
1775 | getEventViewerDialog()->setSyncMode( true ); | 1789 | getEventViewerDialog()->setSyncMode( true ); |
1776 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1790 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1777 | getEventViewerDialog()->setSyncMode( false ); | 1791 | getEventViewerDialog()->setSyncMode( false ); |
1778 | qApp->processEvents(); | 1792 | qApp->processEvents(); |
1779 | if ( syncOK ) { | 1793 | if ( syncOK ) { |
1780 | if ( mSyncManager->mWriteBackFile ) | 1794 | if ( mSyncManager->mWriteBackFile ) |
1781 | { | 1795 | { |
1782 | // write back XML file | 1796 | // write back XML file |
1783 | 1797 | ||
1784 | } | 1798 | } |
1785 | setModified( true ); | 1799 | setModified( true ); |
1786 | } | 1800 | } |
1787 | } else { | 1801 | } else { |
1788 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1802 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1789 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1803 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1790 | question, i18n("Ok")) ; | 1804 | question, i18n("Ok")) ; |
1791 | } | 1805 | } |
1792 | delete calendar; | 1806 | delete calendar; |
1793 | updateView(); | 1807 | updateView(); |
1794 | return syncOK; | 1808 | return syncOK; |
1795 | 1809 | ||
1796 | 1810 | ||
1797 | #endif | 1811 | #endif |
1798 | 1812 | ||
1799 | } | 1813 | } |
1800 | 1814 | ||
1801 | void CalendarView::setSyncEventsReadOnly() | 1815 | void CalendarView::setSyncEventsReadOnly() |
1802 | { | 1816 | { |
1803 | Event * ev; | 1817 | Event * ev; |
1804 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1818 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1805 | ev = eL.first(); | 1819 | ev = eL.first(); |
1806 | while ( ev ) { | 1820 | while ( ev ) { |
1807 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1821 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1808 | ev->setReadOnly( true ); | 1822 | ev->setReadOnly( true ); |
1809 | ev = eL.next(); | 1823 | ev = eL.next(); |
1810 | } | 1824 | } |
1811 | } | 1825 | } |
1812 | bool CalendarView::openCalendar(QString filename, bool merge) | 1826 | bool CalendarView::openCalendar(QString filename, bool merge) |
1813 | { | 1827 | { |
1814 | 1828 | ||
1815 | if (filename.isEmpty()) { | 1829 | if (filename.isEmpty()) { |
1816 | return false; | 1830 | return false; |
1817 | } | 1831 | } |
1818 | 1832 | ||
1819 | if (!QFile::exists(filename)) { | 1833 | if (!QFile::exists(filename)) { |
1820 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1834 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1821 | return false; | 1835 | return false; |
1822 | } | 1836 | } |
1823 | 1837 | ||
1824 | globalFlagBlockAgenda = 1; | 1838 | globalFlagBlockAgenda = 1; |
1825 | if (!merge) { | 1839 | if (!merge) { |
1826 | mTodoList->clearList(); | 1840 | mTodoList->clearList(); |
1827 | mViewManager->setDocumentId( filename ); | 1841 | mViewManager->setDocumentId( filename ); |
1828 | mCalendar->close(); | 1842 | mCalendar->close(); |
1829 | } | 1843 | } |
1830 | mStorage->setFileName( filename ); | 1844 | mStorage->setFileName( filename ); |
1831 | 1845 | ||
1832 | if ( mStorage->load() ) { | 1846 | if ( mStorage->load() ) { |
1833 | if ( merge ) ;//setModified( true ); | 1847 | if ( merge ) ;//setModified( true ); |
1834 | else { | 1848 | else { |
1835 | //setModified( true ); | 1849 | //setModified( true ); |
1836 | mViewManager->setDocumentId( filename ); | 1850 | mViewManager->setDocumentId( filename ); |
1837 | mDialogManager->setDocumentId( filename ); | 1851 | mDialogManager->setDocumentId( filename ); |
1838 | mTodoList->setDocumentId( filename ); | 1852 | mTodoList->setDocumentId( filename ); |
1839 | } | 1853 | } |
1840 | globalFlagBlockAgenda = 2; | 1854 | globalFlagBlockAgenda = 2; |
1841 | // if ( getLastSyncEvent() ) | 1855 | // if ( getLastSyncEvent() ) |
1842 | // getLastSyncEvent()->setReadOnly( true ); | 1856 | // getLastSyncEvent()->setReadOnly( true ); |
1843 | mCalendar->reInitAlarmSettings(); | 1857 | mCalendar->reInitAlarmSettings(); |
1844 | setSyncEventsReadOnly(); | 1858 | setSyncEventsReadOnly(); |
1845 | updateUnmanagedViews(); | 1859 | updateUnmanagedViews(); |
1846 | updateView(); | 1860 | updateView(); |
1847 | if ( filename != MainWindow::defaultFileName() ) { | 1861 | if ( filename != MainWindow::defaultFileName() ) { |
1848 | saveCalendar( MainWindow::defaultFileName() ); | 1862 | saveCalendar( MainWindow::defaultFileName() ); |
1849 | } else { | 1863 | } else { |
1850 | QFileInfo finf ( MainWindow::defaultFileName()); | 1864 | QFileInfo finf ( MainWindow::defaultFileName()); |
1851 | if ( finf.exists() ) { | 1865 | if ( finf.exists() ) { |
1852 | setLoadedFileVersion( finf.lastModified () ); | 1866 | setLoadedFileVersion( finf.lastModified () ); |
1853 | } | 1867 | } |
1854 | } | 1868 | } |
1855 | return true; | 1869 | return true; |
1856 | } else { | 1870 | } else { |
1857 | // while failing to load, the calendar object could | 1871 | // while failing to load, the calendar object could |
1858 | // have become partially populated. Clear it out. | 1872 | // have become partially populated. Clear it out. |
1859 | if ( !merge ) { | 1873 | if ( !merge ) { |
1860 | mCalendar->close(); | 1874 | mCalendar->close(); |
1861 | mViewManager->setDocumentId( filename ); | 1875 | mViewManager->setDocumentId( filename ); |
1862 | mDialogManager->setDocumentId( filename ); | 1876 | mDialogManager->setDocumentId( filename ); |
1863 | mTodoList->setDocumentId( filename ); | 1877 | mTodoList->setDocumentId( filename ); |
1864 | } | 1878 | } |
1865 | 1879 | ||
1866 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1880 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1867 | 1881 | ||
1868 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1882 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1869 | globalFlagBlockAgenda = 2; | 1883 | globalFlagBlockAgenda = 2; |
1870 | mCalendar->reInitAlarmSettings(); | 1884 | mCalendar->reInitAlarmSettings(); |
1871 | setSyncEventsReadOnly(); | 1885 | setSyncEventsReadOnly(); |
1872 | updateUnmanagedViews(); | 1886 | updateUnmanagedViews(); |
1873 | updateView(); | 1887 | updateView(); |
1874 | } | 1888 | } |
1875 | return false; | 1889 | return false; |
1876 | } | 1890 | } |
1877 | void CalendarView::showOpenError() | 1891 | void CalendarView::showOpenError() |
1878 | { | 1892 | { |
1879 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1893 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1880 | } | 1894 | } |
1881 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1895 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1882 | { | 1896 | { |
1883 | loadedFileVersion = dt; | 1897 | loadedFileVersion = dt; |
1884 | } | 1898 | } |
1885 | bool CalendarView::checkFileChanged(QString fn) | 1899 | bool CalendarView::checkFileChanged(QString fn) |
1886 | { | 1900 | { |
1887 | QFileInfo finf ( fn ); | 1901 | QFileInfo finf ( fn ); |
1888 | if ( !finf.exists() ) | 1902 | if ( !finf.exists() ) |
1889 | return true; | 1903 | return true; |
1890 | QDateTime dt = finf.lastModified (); | 1904 | QDateTime dt = finf.lastModified (); |
1891 | if ( dt <= loadedFileVersion ) | 1905 | if ( dt <= loadedFileVersion ) |
1892 | return false; | 1906 | return false; |
1893 | return true; | 1907 | return true; |
1894 | 1908 | ||
1895 | } | 1909 | } |
1896 | void CalendarView::watchSavedFile() | 1910 | void CalendarView::watchSavedFile() |
1897 | { | 1911 | { |
1898 | QFileInfo finf ( MainWindow::defaultFileName()); | 1912 | QFileInfo finf ( MainWindow::defaultFileName()); |
1899 | if ( !finf.exists() ) | 1913 | if ( !finf.exists() ) |
1900 | return; | 1914 | return; |
1901 | QDateTime dt = finf.lastModified (); | 1915 | QDateTime dt = finf.lastModified (); |
1902 | if ( dt < loadedFileVersion ) { | 1916 | if ( dt < loadedFileVersion ) { |
1903 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1917 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1904 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1918 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1905 | return; | 1919 | return; |
1906 | } | 1920 | } |
1907 | loadedFileVersion = dt; | 1921 | loadedFileVersion = dt; |
1908 | } | 1922 | } |
1909 | 1923 | ||
1910 | bool CalendarView::checkFileVersion(QString fn) | 1924 | bool CalendarView::checkFileVersion(QString fn) |
1911 | { | 1925 | { |
1912 | QFileInfo finf ( fn ); | 1926 | QFileInfo finf ( fn ); |
1913 | if ( !finf.exists() ) | 1927 | if ( !finf.exists() ) |
1914 | return true; | 1928 | return true; |
1915 | QDateTime dt = finf.lastModified (); | 1929 | QDateTime dt = finf.lastModified (); |
1916 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1930 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1917 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1931 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1918 | if ( dt <= loadedFileVersion ) | 1932 | if ( dt <= loadedFileVersion ) |
1919 | return true; | 1933 | return true; |
1920 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1934 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1921 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1935 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1922 | i18n("Sync+save")); | 1936 | i18n("Sync+save")); |
1923 | 1937 | ||
1924 | if ( km == KMessageBox::Cancel ) | 1938 | if ( km == KMessageBox::Cancel ) |
1925 | return false; | 1939 | return false; |
1926 | if ( km == KMessageBox::Yes ) | 1940 | if ( km == KMessageBox::Yes ) |
1927 | return true; | 1941 | return true; |
1928 | 1942 | ||
1929 | setSyncDevice("deleteaftersync" ); | 1943 | setSyncDevice("deleteaftersync" ); |
1930 | mSyncManager->mAskForPreferences = true; | 1944 | mSyncManager->mAskForPreferences = true; |
1931 | mSyncManager->mSyncAlgoPrefs = 3; | 1945 | mSyncManager->mSyncAlgoPrefs = 3; |
1932 | mSyncManager->mWriteBackFile = false; | 1946 | mSyncManager->mWriteBackFile = false; |
1933 | mSyncManager->mWriteBackExistingOnly = false; | 1947 | mSyncManager->mWriteBackExistingOnly = false; |
1934 | mSyncManager->mShowSyncSummary = false; | 1948 | mSyncManager->mShowSyncSummary = false; |
1935 | syncCalendar( fn, 3 ); | 1949 | syncCalendar( fn, 3 ); |
1936 | Event * e = getLastSyncEvent(); | 1950 | Event * e = getLastSyncEvent(); |
1937 | mCalendar->deleteEvent ( e ); | 1951 | mCalendar->deleteEvent ( e ); |
1938 | updateView(); | 1952 | updateView(); |
1939 | return true; | 1953 | return true; |
1940 | } | 1954 | } |
1941 | 1955 | ||
1942 | bool CalendarView::saveCalendar( QString filename ) | 1956 | bool CalendarView::saveCalendar( QString filename ) |
1943 | { | 1957 | { |
1944 | 1958 | ||
1945 | // Store back all unsaved data into calendar object | 1959 | // Store back all unsaved data into calendar object |
1946 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1960 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1947 | if ( mViewManager->currentView() ) | 1961 | if ( mViewManager->currentView() ) |
1948 | mViewManager->currentView()->flushView(); | 1962 | mViewManager->currentView()->flushView(); |
1949 | 1963 | ||
1950 | 1964 | ||
1951 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1965 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1952 | mStorage->setSaveFormat( new ICalFormat() ); | 1966 | mStorage->setSaveFormat( new ICalFormat() ); |
1953 | mStorage->setFileName( filename ); | 1967 | mStorage->setFileName( filename ); |
1954 | bool success; | 1968 | bool success; |
1955 | success = mStorage->save(); | 1969 | success = mStorage->save(); |
1956 | if ( !success ) { | 1970 | if ( !success ) { |
1957 | return false; | 1971 | return false; |
1958 | } | 1972 | } |
1959 | if ( filename == MainWindow::defaultFileName() ) { | 1973 | if ( filename == MainWindow::defaultFileName() ) { |
1960 | setLoadedFileVersion( lfv ); | 1974 | setLoadedFileVersion( lfv ); |
1961 | watchSavedFile(); | 1975 | watchSavedFile(); |
1962 | } | 1976 | } |
1963 | return true; | 1977 | return true; |
1964 | } | 1978 | } |
1965 | 1979 | ||
1966 | void CalendarView::closeCalendar() | 1980 | void CalendarView::closeCalendar() |
1967 | { | 1981 | { |
1968 | 1982 | ||
1969 | // child windows no longer valid | 1983 | // child windows no longer valid |
1970 | emit closingDown(); | 1984 | emit closingDown(); |
1971 | 1985 | ||
1972 | mCalendar->close(); | 1986 | mCalendar->close(); |
1973 | setModified(false); | 1987 | setModified(false); |
1974 | updateView(); | 1988 | updateView(); |
1975 | } | 1989 | } |
1976 | 1990 | ||
1977 | void CalendarView::archiveCalendar() | 1991 | void CalendarView::archiveCalendar() |
1978 | { | 1992 | { |
1979 | mDialogManager->showArchiveDialog(); | 1993 | mDialogManager->showArchiveDialog(); |
1980 | } | 1994 | } |
1981 | 1995 | ||
1982 | 1996 | ||
1983 | void CalendarView::readSettings() | 1997 | void CalendarView::readSettings() |
1984 | { | 1998 | { |
1985 | 1999 | ||
1986 | 2000 | ||
1987 | // mViewManager->showAgendaView(); | 2001 | // mViewManager->showAgendaView(); |
1988 | QString str; | 2002 | QString str; |
1989 | //qDebug("CalendarView::readSettings() "); | 2003 | //qDebug("CalendarView::readSettings() "); |
1990 | // read settings from the KConfig, supplying reasonable | 2004 | // read settings from the KConfig, supplying reasonable |
1991 | // defaults where none are to be found | 2005 | // defaults where none are to be found |
1992 | KConfig *config = KOGlobals::config(); | 2006 | KConfig *config = KOGlobals::config(); |
1993 | #ifndef KORG_NOSPLITTER | 2007 | #ifndef KORG_NOSPLITTER |
1994 | config->setGroup("KOrganizer Geometry"); | 2008 | config->setGroup("KOrganizer Geometry"); |
1995 | 2009 | ||
1996 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2010 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1997 | if (sizes.count() != 2) { | 2011 | if (sizes.count() != 2) { |
1998 | sizes << mDateNavigator->minimumSizeHint().width(); | 2012 | sizes << mDateNavigator->minimumSizeHint().width(); |
1999 | sizes << 300; | 2013 | sizes << 300; |
2000 | } | 2014 | } |
2001 | mPanner->setSizes(sizes); | 2015 | mPanner->setSizes(sizes); |
2002 | 2016 | ||
2003 | sizes = config->readIntListEntry("Separator2"); | 2017 | sizes = config->readIntListEntry("Separator2"); |
2004 | if ( ( mResourceView && sizes.count() == 4 ) || | 2018 | if ( ( mResourceView && sizes.count() == 4 ) || |
2005 | ( !mResourceView && sizes.count() == 3 ) ) { | 2019 | ( !mResourceView && sizes.count() == 3 ) ) { |
2006 | mLeftSplitter->setSizes(sizes); | 2020 | mLeftSplitter->setSizes(sizes); |
2007 | } | 2021 | } |
2008 | #endif | 2022 | #endif |
2009 | globalFlagBlockAgenda = 1; | 2023 | globalFlagBlockAgenda = 1; |
2010 | mViewManager->showAgendaView(); | 2024 | mViewManager->showAgendaView(); |
2011 | //mViewManager->readSettings( config ); | 2025 | //mViewManager->readSettings( config ); |
2012 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2026 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2013 | readFilterSettings(config); | 2027 | readFilterSettings(config); |
2014 | 2028 | ||
2015 | #ifdef DESKTOP_VERSION | 2029 | #ifdef DESKTOP_VERSION |
2016 | config->setGroup("WidgetLayout"); | 2030 | config->setGroup("WidgetLayout"); |
2017 | QStringList list; | 2031 | QStringList list; |
2018 | list = config->readListEntry("MainLayout"); | 2032 | list = config->readListEntry("MainLayout"); |
2019 | int x,y,w,h; | 2033 | int x,y,w,h; |
2020 | if ( ! list.isEmpty() ) { | 2034 | if ( ! list.isEmpty() ) { |
2021 | x = list[0].toInt(); | 2035 | x = list[0].toInt(); |
2022 | y = list[1].toInt(); | 2036 | y = list[1].toInt(); |
2023 | w = list[2].toInt(); | 2037 | w = list[2].toInt(); |
2024 | h = list[3].toInt(); | 2038 | h = list[3].toInt(); |
2025 | KApplication::testCoords( &x,&y,&w,&h ); | 2039 | KApplication::testCoords( &x,&y,&w,&h ); |
2026 | topLevelWidget()->setGeometry(x,y,w,h); | 2040 | topLevelWidget()->setGeometry(x,y,w,h); |
2027 | 2041 | ||
2028 | } else { | 2042 | } else { |
2029 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2043 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2030 | } | 2044 | } |
2031 | list = config->readListEntry("EditEventLayout"); | 2045 | list = config->readListEntry("EditEventLayout"); |
2032 | if ( ! list.isEmpty() ) { | 2046 | if ( ! list.isEmpty() ) { |
2033 | x = list[0].toInt(); | 2047 | x = list[0].toInt(); |
2034 | y = list[1].toInt(); | 2048 | y = list[1].toInt(); |
2035 | w = list[2].toInt(); | 2049 | w = list[2].toInt(); |
2036 | h = list[3].toInt(); | 2050 | h = list[3].toInt(); |
2037 | KApplication::testCoords( &x,&y,&w,&h ); | 2051 | KApplication::testCoords( &x,&y,&w,&h ); |
2038 | mEventEditor->setGeometry(x,y,w,h); | 2052 | mEventEditor->setGeometry(x,y,w,h); |
2039 | 2053 | ||
2040 | } | 2054 | } |
2041 | list = config->readListEntry("EditTodoLayout"); | 2055 | list = config->readListEntry("EditTodoLayout"); |
2042 | if ( ! list.isEmpty() ) { | 2056 | if ( ! list.isEmpty() ) { |
2043 | x = list[0].toInt(); | 2057 | x = list[0].toInt(); |
2044 | y = list[1].toInt(); | 2058 | y = list[1].toInt(); |
2045 | w = list[2].toInt(); | 2059 | w = list[2].toInt(); |
2046 | h = list[3].toInt(); | 2060 | h = list[3].toInt(); |
2047 | KApplication::testCoords( &x,&y,&w,&h ); | 2061 | KApplication::testCoords( &x,&y,&w,&h ); |
2048 | mTodoEditor->setGeometry(x,y,w,h); | 2062 | mTodoEditor->setGeometry(x,y,w,h); |
2049 | 2063 | ||
2050 | } | 2064 | } |
2051 | list = config->readListEntry("ViewerLayout"); | 2065 | list = config->readListEntry("ViewerLayout"); |
2052 | if ( ! list.isEmpty() ) { | 2066 | if ( ! list.isEmpty() ) { |
2053 | x = list[0].toInt(); | 2067 | x = list[0].toInt(); |
2054 | y = list[1].toInt(); | 2068 | y = list[1].toInt(); |
2055 | w = list[2].toInt(); | 2069 | w = list[2].toInt(); |
2056 | h = list[3].toInt(); | 2070 | h = list[3].toInt(); |
2057 | KApplication::testCoords( &x,&y,&w,&h ); | 2071 | KApplication::testCoords( &x,&y,&w,&h ); |
2058 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2072 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2059 | } | 2073 | } |
2060 | #endif | 2074 | #endif |
2061 | config->setGroup( "Views" ); | 2075 | config->setGroup( "Views" ); |
2062 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2076 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2063 | 2077 | ||
2064 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2078 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2065 | 2079 | ||
2066 | int resetval = 0; | 2080 | int resetval = 0; |
2067 | int maxVal = 0; | 2081 | int maxVal = 0; |
2068 | if (sizes.count() != 3) { | 2082 | if (sizes.count() != 3) { |
2069 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2083 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2070 | resetval = mDateNavigator->sizeHint().width()+2; | 2084 | resetval = mDateNavigator->sizeHint().width()+2; |
2071 | } else { | 2085 | } else { |
2072 | resetval = mDateNavigator->sizeHint().height()+2; | 2086 | resetval = mDateNavigator->sizeHint().height()+2; |
2073 | } | 2087 | } |
2074 | } | 2088 | } |
2075 | if ( resetval ) { | 2089 | if ( resetval ) { |
2076 | sizes.clear(); | 2090 | sizes.clear(); |
2077 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2091 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2078 | maxVal = QApplication::desktop()->width() -10; | 2092 | maxVal = QApplication::desktop()->width() -10; |
2079 | } else { | 2093 | } else { |
2080 | maxVal = QApplication::desktop()->height()-10; | 2094 | maxVal = QApplication::desktop()->height()-10; |
2081 | } | 2095 | } |
2082 | sizes << resetval; | 2096 | sizes << resetval; |
2083 | if ( maxVal < resetval + resetval) | 2097 | if ( maxVal < resetval + resetval) |
2084 | resetval = maxVal - resetval; | 2098 | resetval = maxVal - resetval; |
2085 | sizes << resetval; | 2099 | sizes << resetval; |
2086 | sizes << 100; | 2100 | sizes << 100; |
2087 | } | 2101 | } |
2088 | mLeftFrame->setSizes(sizes); | 2102 | mLeftFrame->setSizes(sizes); |
2089 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2103 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2090 | resetval = 0; | 2104 | resetval = 0; |
2091 | maxVal = 0; | 2105 | maxVal = 0; |
2092 | if (sizes.count() != 2) { | 2106 | if (sizes.count() != 2) { |
2093 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2107 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2094 | resetval = mDateNavigator->sizeHint().width()+2; | 2108 | resetval = mDateNavigator->sizeHint().width()+2; |
2095 | } else { | 2109 | } else { |
2096 | resetval = mDateNavigator->sizeHint().height()+2; | 2110 | resetval = mDateNavigator->sizeHint().height()+2; |
2097 | } | 2111 | } |
2098 | } | 2112 | } |
2099 | if ( resetval ) { | 2113 | if ( resetval ) { |
2100 | sizes.clear(); | 2114 | sizes.clear(); |
2101 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2115 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2102 | maxVal = QApplication::desktop()->width() -10; | 2116 | maxVal = QApplication::desktop()->width() -10; |
2103 | } else { | 2117 | } else { |
2104 | maxVal = QApplication::desktop()->height()-10; | 2118 | maxVal = QApplication::desktop()->height()-10; |
2105 | } | 2119 | } |
2106 | sizes << resetval; | 2120 | sizes << resetval; |
2107 | if ( maxVal < resetval + resetval) | 2121 | if ( maxVal < resetval + resetval) |
2108 | resetval = maxVal - resetval; | 2122 | resetval = maxVal - resetval; |
2109 | sizes << resetval; | 2123 | sizes << resetval; |
2110 | } | 2124 | } |
2111 | mMainFrame->setSizes(sizes); | 2125 | mMainFrame->setSizes(sizes); |
2112 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2126 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2113 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2127 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2114 | else mNavigator->selectDates( dateCount ); | 2128 | else mNavigator->selectDates( dateCount ); |
2115 | // mViewManager->readSettings( config ); | 2129 | // mViewManager->readSettings( config ); |
2116 | updateConfig(); | 2130 | updateConfig(); |
2117 | globalFlagBlockAgenda = 2; | 2131 | globalFlagBlockAgenda = 2; |
2118 | mViewManager->readSettings( config ); | 2132 | mViewManager->readSettings( config ); |
2119 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2133 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2120 | } | 2134 | } |
2121 | 2135 | ||
2122 | 2136 | ||
2123 | void CalendarView::writeSettings() | 2137 | void CalendarView::writeSettings() |
2124 | { | 2138 | { |
2125 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2139 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2126 | 2140 | ||
2127 | KConfig *config = KOGlobals::config(); | 2141 | KConfig *config = KOGlobals::config(); |
2128 | 2142 | ||
2129 | mViewManager->writeSettings( config ); | 2143 | mViewManager->writeSettings( config ); |
2130 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2144 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2131 | mDialogManager->writeSettings( config ); | 2145 | mDialogManager->writeSettings( config ); |
2132 | //KOPrefs::instance()->usrWriteConfig(); | 2146 | //KOPrefs::instance()->usrWriteConfig(); |
2133 | KOPrefs::instance()->writeConfig(); | 2147 | KOPrefs::instance()->writeConfig(); |
2134 | 2148 | ||
2135 | writeFilterSettings(config); | 2149 | writeFilterSettings(config); |
2136 | config->setGroup( "AppRun" ); | 2150 | config->setGroup( "AppRun" ); |
2137 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2151 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2138 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); | 2152 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); |
2139 | config->setGroup( "Views" ); | 2153 | config->setGroup( "Views" ); |
2140 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2154 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2141 | 2155 | ||
2142 | QValueList<int> listINT = mLeftFrame->sizes(); | 2156 | QValueList<int> listINT = mLeftFrame->sizes(); |
2143 | config->writeEntry("Left Splitter Frame",listINT); | 2157 | config->writeEntry("Left Splitter Frame",listINT); |
2144 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2158 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2145 | config->writeEntry("Main Splitter Frame",listINT2); | 2159 | config->writeEntry("Main Splitter Frame",listINT2); |
2146 | #ifdef DESKTOP_VERSION | 2160 | #ifdef DESKTOP_VERSION |
2147 | config->setGroup("WidgetLayout"); | 2161 | config->setGroup("WidgetLayout"); |
2148 | QStringList list ;//= config->readListEntry("MainLayout"); | 2162 | QStringList list ;//= config->readListEntry("MainLayout"); |
2149 | int x,y,w,h; | 2163 | int x,y,w,h; |
2150 | QWidget* wid; | 2164 | QWidget* wid; |
2151 | wid = topLevelWidget(); | 2165 | wid = topLevelWidget(); |
2152 | x = wid->geometry().x(); | 2166 | x = wid->geometry().x(); |
2153 | y = wid->geometry().y(); | 2167 | y = wid->geometry().y(); |
2154 | w = wid->width(); | 2168 | w = wid->width(); |
2155 | h = wid->height(); | 2169 | h = wid->height(); |
2156 | list.clear(); | 2170 | list.clear(); |
2157 | list << QString::number( x ); | 2171 | list << QString::number( x ); |
2158 | list << QString::number( y ); | 2172 | list << QString::number( y ); |
2159 | list << QString::number( w ); | 2173 | list << QString::number( w ); |
2160 | list << QString::number( h ); | 2174 | list << QString::number( h ); |
2161 | config->writeEntry("MainLayout",list ); | 2175 | config->writeEntry("MainLayout",list ); |
2162 | 2176 | ||
2163 | wid = mEventEditor; | 2177 | wid = mEventEditor; |
2164 | x = wid->geometry().x(); | 2178 | x = wid->geometry().x(); |
2165 | y = wid->geometry().y(); | 2179 | y = wid->geometry().y(); |
2166 | w = wid->width(); | 2180 | w = wid->width(); |
2167 | h = wid->height(); | 2181 | h = wid->height(); |
2168 | list.clear(); | 2182 | list.clear(); |
2169 | list << QString::number( x ); | 2183 | list << QString::number( x ); |
2170 | list << QString::number( y ); | 2184 | list << QString::number( y ); |
2171 | list << QString::number( w ); | 2185 | list << QString::number( w ); |
2172 | list << QString::number( h ); | 2186 | list << QString::number( h ); |
2173 | config->writeEntry("EditEventLayout",list ); | 2187 | config->writeEntry("EditEventLayout",list ); |
2174 | 2188 | ||
2175 | wid = mTodoEditor; | 2189 | wid = mTodoEditor; |
2176 | x = wid->geometry().x(); | 2190 | x = wid->geometry().x(); |
2177 | y = wid->geometry().y(); | 2191 | y = wid->geometry().y(); |
2178 | w = wid->width(); | 2192 | w = wid->width(); |
2179 | h = wid->height(); | 2193 | h = wid->height(); |
2180 | list.clear(); | 2194 | list.clear(); |
2181 | list << QString::number( x ); | 2195 | list << QString::number( x ); |
2182 | list << QString::number( y ); | 2196 | list << QString::number( y ); |
2183 | list << QString::number( w ); | 2197 | list << QString::number( w ); |
2184 | list << QString::number( h ); | 2198 | list << QString::number( h ); |
2185 | config->writeEntry("EditTodoLayout",list ); | 2199 | config->writeEntry("EditTodoLayout",list ); |
2186 | wid = getEventViewerDialog(); | 2200 | wid = getEventViewerDialog(); |
2187 | x = wid->geometry().x(); | 2201 | x = wid->geometry().x(); |
2188 | y = wid->geometry().y(); | 2202 | y = wid->geometry().y(); |
2189 | w = wid->width(); | 2203 | w = wid->width(); |
2190 | h = wid->height(); | 2204 | h = wid->height(); |
2191 | list.clear(); | 2205 | list.clear(); |
2192 | list << QString::number( x ); | 2206 | list << QString::number( x ); |
2193 | list << QString::number( y ); | 2207 | list << QString::number( y ); |
2194 | list << QString::number( w ); | 2208 | list << QString::number( w ); |
2195 | list << QString::number( h ); | 2209 | list << QString::number( h ); |
2196 | config->writeEntry("ViewerLayout",list ); | 2210 | config->writeEntry("ViewerLayout",list ); |
2197 | wid = mDialogManager->getSearchDialog(); | 2211 | wid = mDialogManager->getSearchDialog(); |
2198 | if ( wid ) { | 2212 | if ( wid ) { |
2199 | x = wid->geometry().x(); | 2213 | x = wid->geometry().x(); |
2200 | y = wid->geometry().y(); | 2214 | y = wid->geometry().y(); |
2201 | w = wid->width(); | 2215 | w = wid->width(); |
2202 | h = wid->height(); | 2216 | h = wid->height(); |
2203 | list.clear(); | 2217 | list.clear(); |
2204 | list << QString::number( x ); | 2218 | list << QString::number( x ); |