-rw-r--r-- | korganizer/calendarview.cpp | 73 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 16 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 24 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 6 |
9 files changed, 118 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8965d3b..307027a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,752 +1,753 @@ | |||
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 "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mMultiResourceSync = false; | ||
369 | flag_blockConflict = false; | 370 | flag_blockConflict = false; |
370 | flag_blockScrollBar = false; | 371 | flag_blockScrollBar = false; |
371 | flag_checkFileFirsttime = true; | 372 | flag_checkFileFirsttime = true; |
372 | flag_clearallviewsEventDisplay = false; | 373 | flag_clearallviewsEventDisplay = false; |
373 | flag_clearallviewsupdateView = false; | 374 | flag_clearallviewsupdateView = false; |
374 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 375 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
375 | setFocusPolicy (NoFocus ); | 376 | setFocusPolicy (NoFocus ); |
376 | mViewerCallerIsSearchDialog = false; | 377 | mViewerCallerIsSearchDialog = false; |
377 | mBlockShowDates = false; | 378 | mBlockShowDates = false; |
378 | mConflictingEvent = 0; | 379 | mConflictingEvent = 0; |
379 | mDatePickerMode = 0; | 380 | mDatePickerMode = 0; |
380 | mCurrentSyncDevice = ""; | 381 | mCurrentSyncDevice = ""; |
381 | mViewManager = new KOViewManager( this ); | 382 | mViewManager = new KOViewManager( this ); |
382 | mDialogManager = new KODialogManager( this ); | 383 | mDialogManager = new KODialogManager( this ); |
383 | mEventViewerDialog = 0; | 384 | mEventViewerDialog = 0; |
384 | mModified = false; | 385 | mModified = false; |
385 | mReadOnly = false; | 386 | mReadOnly = false; |
386 | mSelectedIncidence = 0; | 387 | mSelectedIncidence = 0; |
387 | mCalPrinter = 0; | 388 | mCalPrinter = 0; |
388 | mFilters.setAutoDelete(true); | 389 | mFilters.setAutoDelete(true); |
389 | 390 | ||
390 | mCalendar->registerObserver( this ); | 391 | mCalendar->registerObserver( this ); |
391 | // TODO: Make sure that view is updated, when calendar is changed. | 392 | // TODO: Make sure that view is updated, when calendar is changed. |
392 | 393 | ||
393 | mStorage = new FileStorage( mCalendar ); | 394 | mStorage = new FileStorage( mCalendar ); |
394 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 395 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
395 | 396 | ||
396 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 397 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
397 | #ifndef KORG_NOSPLITTER | 398 | #ifndef KORG_NOSPLITTER |
398 | // create the main layout frames. | 399 | // create the main layout frames. |
399 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 400 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
400 | topLayout->addWidget(mPanner); | 401 | topLayout->addWidget(mPanner); |
401 | 402 | ||
402 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 403 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
403 | "CalendarView::LeftFrame"); | 404 | "CalendarView::LeftFrame"); |
404 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 405 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
405 | 406 | ||
406 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 407 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
407 | "CalendarView::DateNavigator" ); | 408 | "CalendarView::DateNavigator" ); |
408 | 409 | ||
409 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 410 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
410 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 411 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
411 | mTodoList->setNavigator( mNavigator ); | 412 | mTodoList->setNavigator( mNavigator ); |
412 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 413 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
413 | 414 | ||
414 | #ifdef KORG_NORESOURCEVIEW | 415 | #ifdef KORG_NORESOURCEVIEW |
415 | mResourceView = 0; | 416 | mResourceView = 0; |
416 | #else | 417 | #else |
417 | if ( mResourceManager ) { | 418 | if ( mResourceManager ) { |
418 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 419 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
419 | mResourceView->updateView(); | 420 | mResourceView->updateView(); |
420 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 421 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
421 | SLOT( updateView() ) ); | 422 | SLOT( updateView() ) ); |
422 | } else { | 423 | } else { |
423 | mResourceView = 0; | 424 | mResourceView = 0; |
424 | } | 425 | } |
425 | #endif | 426 | #endif |
426 | QWidget *rightBox = new QWidget( mPanner ); | 427 | QWidget *rightBox = new QWidget( mPanner ); |
427 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 428 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
428 | 429 | ||
429 | mRightFrame = new QWidgetStack( rightBox ); | 430 | mRightFrame = new QWidgetStack( rightBox ); |
430 | rightLayout->addWidget( mRightFrame, 1 ); | 431 | rightLayout->addWidget( mRightFrame, 1 ); |
431 | 432 | ||
432 | mLeftFrame = mLeftSplitter; | 433 | mLeftFrame = mLeftSplitter; |
433 | #else | 434 | #else |
434 | //QWidget *mainBox = new QWidget( this ); | 435 | //QWidget *mainBox = new QWidget( this ); |
435 | //QWidget *leftFrame = new QWidget( mainBox ); | 436 | //QWidget *leftFrame = new QWidget( mainBox ); |
436 | //QBoxLayout * mainBoxLayout; | 437 | //QBoxLayout * mainBoxLayout; |
437 | if ( KOPrefs::instance()->mVerticalScreen ) { | 438 | if ( KOPrefs::instance()->mVerticalScreen ) { |
438 | //mainBoxLayout = new QVBoxLayout(mainBox); | 439 | //mainBoxLayout = new QVBoxLayout(mainBox); |
439 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
444 | } else { | 445 | } else { |
445 | //mainBoxLayout = new QHBoxLayout(mainBox); | 446 | //mainBoxLayout = new QHBoxLayout(mainBox); |
446 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 447 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
447 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 448 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
448 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 449 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
449 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 450 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
450 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 451 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
451 | } | 452 | } |
452 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 453 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
453 | //QBoxLayout * leftFrameLayout; | 454 | //QBoxLayout * leftFrameLayout; |
454 | topLayout->addWidget( mMainFrame ); | 455 | topLayout->addWidget( mMainFrame ); |
455 | #ifdef DESKTOP_VERSION | 456 | #ifdef DESKTOP_VERSION |
456 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 457 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
457 | topLayout->addWidget( mDateScrollBar ); | 458 | topLayout->addWidget( mDateScrollBar ); |
458 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 459 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
459 | if ( QApplication::desktop()->width() < 800 ) | 460 | if ( QApplication::desktop()->width() < 800 ) |
460 | mDateScrollBar->hide(); | 461 | mDateScrollBar->hide(); |
461 | #endif | 462 | #endif |
462 | //mainBoxLayout->addWidget (mLeftFrame); | 463 | //mainBoxLayout->addWidget (mLeftFrame); |
463 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 464 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
464 | "CalendarView::DateNavigator" ); | 465 | "CalendarView::DateNavigator" ); |
465 | #if 0 | 466 | #if 0 |
466 | // FIXME | 467 | // FIXME |
467 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 468 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
468 | "CalendarView::DateNavigator", QDate::currentDate()); | 469 | "CalendarView::DateNavigator", QDate::currentDate()); |
469 | #endif | 470 | #endif |
470 | // mDateNavigator->blockSignals( true ); | 471 | // mDateNavigator->blockSignals( true ); |
471 | //leftFrameLayout->addWidget( mDateNavigator ); | 472 | //leftFrameLayout->addWidget( mDateNavigator ); |
472 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 473 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
473 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 474 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
474 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 475 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
475 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 476 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
476 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 477 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
477 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 478 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
478 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 480 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
480 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 481 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
481 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 482 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
482 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 483 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
483 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 484 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
484 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 485 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
485 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); | 486 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); |
486 | 487 | ||
487 | 488 | ||
488 | mTodoList->setNavigator( mNavigator ); | 489 | mTodoList->setNavigator( mNavigator ); |
489 | #if 0 | 490 | #if 0 |
490 | if ( QApplication::desktop()->width() < 480 ) { | 491 | if ( QApplication::desktop()->width() < 480 ) { |
491 | leftFrameLayout->addWidget(mFilterView); | 492 | leftFrameLayout->addWidget(mFilterView); |
492 | leftFrameLayout->addWidget(mTodoList, 2 ); | 493 | leftFrameLayout->addWidget(mTodoList, 2 ); |
493 | 494 | ||
494 | } else { | 495 | } else { |
495 | leftFrameLayout->addWidget(mTodoList,2 ); | 496 | leftFrameLayout->addWidget(mTodoList,2 ); |
496 | leftFrameLayout->addWidget(mFilterView ); | 497 | leftFrameLayout->addWidget(mFilterView ); |
497 | } | 498 | } |
498 | #endif | 499 | #endif |
499 | mFilterView->hide(); | 500 | mFilterView->hide(); |
500 | mCalEditView->hide(); | 501 | mCalEditView->hide(); |
501 | QWidget *rightBox = new QWidget( mMainFrame ); | 502 | QWidget *rightBox = new QWidget( mMainFrame ); |
502 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 503 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
503 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 504 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
504 | mRightFrame = new QWidgetStack( rightBox ); | 505 | mRightFrame = new QWidgetStack( rightBox ); |
505 | rightLayout->addWidget( mRightFrame, 10 ); | 506 | rightLayout->addWidget( mRightFrame, 10 ); |
506 | 507 | ||
507 | //mLeftFrame = (QWidget *)leftFrame; | 508 | //mLeftFrame = (QWidget *)leftFrame; |
508 | if ( KOPrefs::instance()->mVerticalScreen ) { | 509 | if ( KOPrefs::instance()->mVerticalScreen ) { |
509 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 510 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
510 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 511 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
511 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 512 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
512 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 513 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
513 | } else { | 514 | } else { |
514 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 515 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
515 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 516 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
516 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 517 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
517 | } | 518 | } |
518 | if ( !KOPrefs::instance()->mShowDateNavigator) | 519 | if ( !KOPrefs::instance()->mShowDateNavigator) |
519 | mDateNavigator->hide(); | 520 | mDateNavigator->hide(); |
520 | //qDebug("Calendarview Size %d %d ", width(), height()); | 521 | //qDebug("Calendarview Size %d %d ", width(), height()); |
521 | #endif | 522 | #endif |
522 | 523 | ||
523 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 524 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
524 | SLOT( showDates( const KCal::DateList & ) ) ); | 525 | SLOT( showDates( const KCal::DateList & ) ) ); |
525 | 526 | ||
526 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 527 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
527 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 528 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
528 | 529 | ||
529 | 530 | ||
530 | 531 | ||
531 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 532 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
532 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 533 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
533 | 534 | ||
534 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 535 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
535 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 536 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
536 | 537 | ||
537 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 538 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
538 | mNavigator, SLOT( selectPreviousYear() ) ); | 539 | mNavigator, SLOT( selectPreviousYear() ) ); |
539 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 540 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
540 | mNavigator, SLOT( selectNextYear() ) ); | 541 | mNavigator, SLOT( selectNextYear() ) ); |
541 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 542 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
542 | mNavigator, SLOT( selectPreviousMonth() ) ); | 543 | mNavigator, SLOT( selectPreviousMonth() ) ); |
543 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 544 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
544 | mNavigator, SLOT( selectNextMonth() ) ); | 545 | mNavigator, SLOT( selectNextMonth() ) ); |
545 | 546 | ||
546 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 547 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
547 | mNavigator, SLOT( selectPrevious() ) ); | 548 | mNavigator, SLOT( selectPrevious() ) ); |
548 | connect( mDateNavigator, SIGNAL( goNext() ), | 549 | connect( mDateNavigator, SIGNAL( goNext() ), |
549 | mNavigator, SLOT( selectNext() ) ); | 550 | mNavigator, SLOT( selectNext() ) ); |
550 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 551 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
551 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 552 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
552 | 553 | ||
553 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 554 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
554 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 555 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
555 | #if 0 | 556 | #if 0 |
556 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 557 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
557 | SLOT( incidenceAdded( Incidence *) ) ); | 558 | SLOT( incidenceAdded( Incidence *) ) ); |
558 | #endif | 559 | #endif |
559 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 560 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
560 | 561 | ||
561 | connect( this, SIGNAL( configChanged() ), | 562 | connect( this, SIGNAL( configChanged() ), |
562 | mDateNavigator, SLOT( updateConfig() ) ); | 563 | mDateNavigator, SLOT( updateConfig() ) ); |
563 | 564 | ||
564 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 565 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
565 | SLOT( newTodo() ) ); | 566 | SLOT( newTodo() ) ); |
566 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 567 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
567 | SLOT( newSubTodo( Todo * ) ) ); | 568 | SLOT( newSubTodo( Todo * ) ) ); |
568 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 569 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
569 | SLOT( editTodo( Todo * ) ) ); | 570 | SLOT( editTodo( Todo * ) ) ); |
570 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 571 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
571 | SLOT( showTodo( Todo *) ) ); | 572 | SLOT( showTodo( Todo *) ) ); |
572 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 573 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
573 | SLOT( deleteTodo( Todo *) ) ); | 574 | SLOT( deleteTodo( Todo *) ) ); |
574 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 575 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
575 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 576 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
576 | SLOT( purgeCompleted() ) ); | 577 | SLOT( purgeCompleted() ) ); |
577 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 578 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
578 | SIGNAL( todoModified( Todo *, int ) ) ); | 579 | SIGNAL( todoModified( Todo *, int ) ) ); |
579 | 580 | ||
580 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 581 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
581 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 582 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
582 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 583 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
583 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 584 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
584 | 585 | ||
585 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 586 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
586 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 587 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
587 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 588 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
588 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 589 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
589 | 590 | ||
590 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 591 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
591 | this, SLOT ( todo_unsub( Todo * ) ) ); | 592 | this, SLOT ( todo_unsub( Todo * ) ) ); |
592 | 593 | ||
593 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 594 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
594 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 595 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
595 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 596 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
596 | SLOT( updateTodo( Todo *, int ) ) ); | 597 | SLOT( updateTodo( Todo *, int ) ) ); |
597 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 598 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
598 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 599 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
599 | 600 | ||
600 | 601 | ||
601 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 602 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
602 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 603 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
603 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 604 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
604 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 605 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
605 | 606 | ||
606 | 607 | ||
607 | 608 | ||
608 | 609 | ||
609 | 610 | ||
610 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 611 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
611 | SLOT(checkClipboard())); | 612 | SLOT(checkClipboard())); |
612 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 613 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
613 | SLOT( processTodoListSelection( Incidence * ) ) ); | 614 | SLOT( processTodoListSelection( Incidence * ) ) ); |
614 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 615 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
615 | 616 | ||
616 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 617 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
617 | 618 | ||
618 | mDateFrame = new QVBox(0,0,WType_Popup); | 619 | mDateFrame = new QVBox(0,0,WType_Popup); |
619 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 620 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
620 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 621 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
621 | mDateFrame->setLineWidth(3); | 622 | mDateFrame->setLineWidth(3); |
622 | mDateFrame->hide(); | 623 | mDateFrame->hide(); |
623 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 624 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
624 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 625 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
625 | 626 | ||
626 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 627 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
627 | 628 | ||
628 | mEventEditor = mDialogManager->getEventEditor(); | 629 | mEventEditor = mDialogManager->getEventEditor(); |
629 | mTodoEditor = mDialogManager->getTodoEditor(); | 630 | mTodoEditor = mDialogManager->getTodoEditor(); |
630 | 631 | ||
631 | mFlagEditDescription = false; | 632 | mFlagEditDescription = false; |
632 | 633 | ||
633 | mSuspendTimer = new QTimer( this ); | 634 | mSuspendTimer = new QTimer( this ); |
634 | mAlarmTimer = new QTimer( this ); | 635 | mAlarmTimer = new QTimer( this ); |
635 | mRecheckAlarmTimer = new QTimer( this ); | 636 | mRecheckAlarmTimer = new QTimer( this ); |
636 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 637 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
637 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 638 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
638 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 639 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
639 | mAlarmDialog = new AlarmDialog( this ); | 640 | mAlarmDialog = new AlarmDialog( this ); |
640 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 641 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
641 | mAlarmDialog->setServerNotification( false ); | 642 | mAlarmDialog->setServerNotification( false ); |
642 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 643 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
643 | 644 | ||
644 | 645 | ||
645 | #ifndef DESKTOP_VERSION | 646 | #ifndef DESKTOP_VERSION |
646 | //US listen for arriving address resultsets | 647 | //US listen for arriving address resultsets |
647 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 648 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
648 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 649 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
649 | #endif | 650 | #endif |
650 | mDateNavigator->setCalendar( mCalendar ); | 651 | mDateNavigator->setCalendar( mCalendar ); |
651 | } | 652 | } |
652 | 653 | ||
653 | 654 | ||
654 | CalendarView::~CalendarView() | 655 | CalendarView::~CalendarView() |
655 | { | 656 | { |
656 | // kdDebug() << "~CalendarView()" << endl; | 657 | // kdDebug() << "~CalendarView()" << endl; |
657 | //qDebug("CalendarView::~CalendarView() "); | 658 | //qDebug("CalendarView::~CalendarView() "); |
658 | delete mDialogManager; | 659 | delete mDialogManager; |
659 | delete mViewManager; | 660 | delete mViewManager; |
660 | delete mStorage; | 661 | delete mStorage; |
661 | delete mDateFrame ; | 662 | delete mDateFrame ; |
662 | delete mEventViewerDialog; | 663 | delete mEventViewerDialog; |
663 | //kdDebug() << "~CalendarView() done" << endl; | 664 | //kdDebug() << "~CalendarView() done" << endl; |
664 | } | 665 | } |
665 | 666 | ||
666 | 667 | ||
667 | void CalendarView::nextConflict( bool all, bool allday ) | 668 | void CalendarView::nextConflict( bool all, bool allday ) |
668 | { | 669 | { |
669 | if ( flag_blockConflict ) return; | 670 | if ( flag_blockConflict ) return; |
670 | flag_blockConflict = true; | 671 | flag_blockConflict = true; |
671 | QPtrList<Event> testlist = mCalendar->events(); | 672 | QPtrList<Event> testlist = mCalendar->events(); |
672 | Event * test = testlist.first(); | 673 | Event * test = testlist.first(); |
673 | while ( test ) { | 674 | while ( test ) { |
674 | test->setTagged( false ); | 675 | test->setTagged( false ); |
675 | test = testlist.next(); | 676 | test = testlist.next(); |
676 | } | 677 | } |
677 | QTime st ( 0,0,0); | 678 | QTime st ( 0,0,0); |
678 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 679 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
679 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 680 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
680 | //qDebug("time %s ", st.toString().latin1()); | 681 | //qDebug("time %s ", st.toString().latin1()); |
681 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 682 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
682 | QDateTime conflict; | 683 | QDateTime conflict; |
683 | QDateTime retVal; | 684 | QDateTime retVal; |
684 | bool found = false; | 685 | bool found = false; |
685 | Event * cE = 0; | 686 | Event * cE = 0; |
686 | Event * cE2 = 0; | 687 | Event * cE2 = 0; |
687 | QPtrList<Event> testlist2 = testlist; | 688 | QPtrList<Event> testlist2 = testlist; |
688 | test = testlist.first(); | 689 | test = testlist.first(); |
689 | bool skip = false; | 690 | bool skip = false; |
690 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 691 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
691 | //QTime tm; | 692 | //QTime tm; |
692 | //tm.start(); | 693 | //tm.start(); |
693 | while ( test ) { | 694 | while ( test ) { |
694 | qApp->processEvents(); | 695 | qApp->processEvents(); |
695 | skip = false; | 696 | skip = false; |
696 | if ( !all ) skip = ( allday != test->doesFloat() ); | 697 | if ( !all ) skip = ( allday != test->doesFloat() ); |
697 | if ( !skip ) { | 698 | if ( !skip ) { |
698 | if ( found ) | 699 | if ( found ) |
699 | skip = !test->matchTime( &startDT, &conflict ); | 700 | skip = !test->matchTime( &startDT, &conflict ); |
700 | else | 701 | else |
701 | skip = !test->matchTime( &startDT, 0 ); | 702 | skip = !test->matchTime( &startDT, 0 ); |
702 | } | 703 | } |
703 | if ( !skip ) { | 704 | if ( !skip ) { |
704 | Event * test2 = testlist2.first(); | 705 | Event * test2 = testlist2.first(); |
705 | while ( test2 ) { | 706 | while ( test2 ) { |
706 | skip = test2->isTagged(); | 707 | skip = test2->isTagged(); |
707 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 708 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
708 | if ( !skip ) { | 709 | if ( !skip ) { |
709 | if ( found ) | 710 | if ( found ) |
710 | skip = !test2->matchTime( &startDT, &conflict ); | 711 | skip = !test2->matchTime( &startDT, &conflict ); |
711 | else | 712 | else |
712 | skip = !test2->matchTime( &startDT, 0 ); | 713 | skip = !test2->matchTime( &startDT, 0 ); |
713 | } | 714 | } |
714 | if ( !skip ) { | 715 | if ( !skip ) { |
715 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 716 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
716 | //qDebug("overlap "); | 717 | //qDebug("overlap "); |
717 | if ( ! found ) { | 718 | if ( ! found ) { |
718 | if ( retVal >= startDT ) { | 719 | if ( retVal >= startDT ) { |
719 | conflict = retVal; | 720 | conflict = retVal; |
720 | cE = test; | 721 | cE = test; |
721 | cE2 = test2; | 722 | cE2 = test2; |
722 | found = true; | 723 | found = true; |
723 | } | 724 | } |
724 | } else { | 725 | } else { |
725 | if ( retVal >= startDT && retVal < conflict ) { | 726 | if ( retVal >= startDT && retVal < conflict ) { |
726 | conflict = retVal; | 727 | conflict = retVal; |
727 | cE = test; | 728 | cE = test; |
728 | cE2 = test2; | 729 | cE2 = test2; |
729 | } | 730 | } |
730 | } | 731 | } |
731 | } | 732 | } |
732 | } | 733 | } |
733 | test2 = testlist2.next(); | 734 | test2 = testlist2.next(); |
734 | } | 735 | } |
735 | } | 736 | } |
736 | test->setTagged( true ); | 737 | test->setTagged( true ); |
737 | test = testlist.next(); | 738 | test = testlist.next(); |
738 | } | 739 | } |
739 | //qDebug("Search time : %d", tm.elapsed()); | 740 | //qDebug("Search time : %d", tm.elapsed()); |
740 | if ( found ) { | 741 | if ( found ) { |
741 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 742 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
742 | mViewManager->showDayView(); | 743 | mViewManager->showDayView(); |
743 | mNavigator->slotDaySelect( conflict.date() ); | 744 | mNavigator->slotDaySelect( conflict.date() ); |
744 | int hour = conflict.time().hour(); | 745 | int hour = conflict.time().hour(); |
745 | mViewManager->agendaView()->setStartHour( hour ); | 746 | mViewManager->agendaView()->setStartHour( hour ); |
746 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 747 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
747 | flag_blockConflict = false; | 748 | flag_blockConflict = false; |
748 | return; | 749 | return; |
749 | } | 750 | } |
750 | 751 | ||
751 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 752 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
752 | //qDebug("No conflict found "); | 753 | //qDebug("No conflict found "); |
@@ -1171,1774 +1172,1824 @@ void CalendarView::computeAlarm( QString msg ) | |||
1171 | int len = mess.mid( 13 ).find("+++"); | 1172 | int len = mess.mid( 13 ).find("+++"); |
1172 | if ( len < 2 ) | 1173 | if ( len < 2 ) |
1173 | error = true; | 1174 | error = true; |
1174 | else { | 1175 | else { |
1175 | tempfilename = mess.mid( 13, len ); | 1176 | tempfilename = mess.mid( 13, len ); |
1176 | if ( !QFile::exists( tempfilename ) ) | 1177 | if ( !QFile::exists( tempfilename ) ) |
1177 | error = true; | 1178 | error = true; |
1178 | } | 1179 | } |
1179 | if ( ! error ) { | 1180 | if ( ! error ) { |
1180 | filename = tempfilename; | 1181 | filename = tempfilename; |
1181 | } | 1182 | } |
1182 | mAlarmMessage = mess.mid( 13+len+3 ); | 1183 | mAlarmMessage = mess.mid( 13+len+3 ); |
1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1184 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1184 | startAlarm( mAlarmMessage, filename); | 1185 | startAlarm( mAlarmMessage, filename); |
1185 | return; | 1186 | return; |
1186 | } | 1187 | } |
1187 | if ( mess.left( 11 ) == "timer_alarm") { | 1188 | if ( mess.left( 11 ) == "timer_alarm") { |
1188 | //mTimerTime = 0; | 1189 | //mTimerTime = 0; |
1189 | startAlarm( mess.mid( 11 ), filename ); | 1190 | startAlarm( mess.mid( 11 ), filename ); |
1190 | return; | 1191 | return; |
1191 | } | 1192 | } |
1192 | if ( mess.left( 10 ) == "proc_alarm") { | 1193 | if ( mess.left( 10 ) == "proc_alarm") { |
1193 | bool error = false; | 1194 | bool error = false; |
1194 | int len = mess.mid( 10 ).find("+++"); | 1195 | int len = mess.mid( 10 ).find("+++"); |
1195 | if ( len < 2 ) | 1196 | if ( len < 2 ) |
1196 | error = true; | 1197 | error = true; |
1197 | else { | 1198 | else { |
1198 | tempfilename = mess.mid( 10, len ); | 1199 | tempfilename = mess.mid( 10, len ); |
1199 | if ( !QFile::exists( tempfilename ) ) | 1200 | if ( !QFile::exists( tempfilename ) ) |
1200 | error = true; | 1201 | error = true; |
1201 | } | 1202 | } |
1202 | if ( error ) { | 1203 | if ( error ) { |
1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1204 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1205 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1205 | } else { | 1206 | } else { |
1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1207 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1208 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1208 | #ifndef _WIN32_ | 1209 | #ifndef _WIN32_ |
1209 | if ( vfork () == 0 ) { | 1210 | if ( vfork () == 0 ) { |
1210 | execl ( tempfilename.latin1(), 0 ); | 1211 | execl ( tempfilename.latin1(), 0 ); |
1211 | return; | 1212 | return; |
1212 | } | 1213 | } |
1213 | #else | 1214 | #else |
1214 | QProcess* p = new QProcess(); | 1215 | QProcess* p = new QProcess(); |
1215 | p->addArgument( tempfilename.latin1() ); | 1216 | p->addArgument( tempfilename.latin1() ); |
1216 | p->start(); | 1217 | p->start(); |
1217 | return; | 1218 | return; |
1218 | #endif | 1219 | #endif |
1219 | 1220 | ||
1220 | return; | 1221 | return; |
1221 | } | 1222 | } |
1222 | 1223 | ||
1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1224 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1224 | } | 1225 | } |
1225 | if ( mess.left( 11 ) == "audio_alarm") { | 1226 | if ( mess.left( 11 ) == "audio_alarm") { |
1226 | bool error = false; | 1227 | bool error = false; |
1227 | int len = mess.mid( 11 ).find("+++"); | 1228 | int len = mess.mid( 11 ).find("+++"); |
1228 | if ( len < 2 ) | 1229 | if ( len < 2 ) |
1229 | error = true; | 1230 | error = true; |
1230 | else { | 1231 | else { |
1231 | tempfilename = mess.mid( 11, len ); | 1232 | tempfilename = mess.mid( 11, len ); |
1232 | if ( !QFile::exists( tempfilename ) ) | 1233 | if ( !QFile::exists( tempfilename ) ) |
1233 | error = true; | 1234 | error = true; |
1234 | } | 1235 | } |
1235 | if ( ! error ) { | 1236 | if ( ! error ) { |
1236 | filename = tempfilename; | 1237 | filename = tempfilename; |
1237 | } | 1238 | } |
1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1239 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1240 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1240 | } | 1241 | } |
1241 | if ( mess.left( 9 ) == "cal_alarm") { | 1242 | if ( mess.left( 9 ) == "cal_alarm") { |
1242 | mAlarmMessage = mess.mid( 9 ) ; | 1243 | mAlarmMessage = mess.mid( 9 ) ; |
1243 | } | 1244 | } |
1244 | 1245 | ||
1245 | startAlarm( mAlarmMessage, filename ); | 1246 | startAlarm( mAlarmMessage, filename ); |
1246 | 1247 | ||
1247 | 1248 | ||
1248 | } | 1249 | } |
1249 | 1250 | ||
1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1251 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1251 | { | 1252 | { |
1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1253 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1253 | 1254 | ||
1254 | mSuspendAlarmNotification = noti; | 1255 | mSuspendAlarmNotification = noti; |
1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1256 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1257 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1257 | mSuspendTimer->start( ms , true ); | 1258 | mSuspendTimer->start( ms , true ); |
1258 | #ifdef DESKTOP_VERSION | 1259 | #ifdef DESKTOP_VERSION |
1259 | if ( QApplication::desktop()->width() < 1024 ) { | 1260 | if ( QApplication::desktop()->width() < 1024 ) { |
1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1261 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1262 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1263 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1263 | QFile file( fn ); | 1264 | QFile file( fn ); |
1264 | if (!file.open( IO_WriteOnly ) ) { | 1265 | if (!file.open( IO_WriteOnly ) ) { |
1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1266 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1266 | } else { | 1267 | } else { |
1267 | QTextStream ts( &file ); | 1268 | QTextStream ts( &file ); |
1268 | ts << mess; | 1269 | ts << mess; |
1269 | file.close(); | 1270 | file.close(); |
1270 | } | 1271 | } |
1271 | } | 1272 | } |
1272 | #endif | 1273 | #endif |
1273 | 1274 | ||
1274 | } | 1275 | } |
1275 | 1276 | ||
1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1277 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1277 | { | 1278 | { |
1278 | mNextAlarmDateTime = qdt; | 1279 | mNextAlarmDateTime = qdt; |
1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1280 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1281 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1281 | #ifndef DESKTOP_VERSION | 1282 | #ifndef DESKTOP_VERSION |
1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1283 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1283 | #endif | 1284 | #endif |
1284 | return; | 1285 | return; |
1285 | } | 1286 | } |
1286 | #ifdef DESKTOP_VERSION | 1287 | #ifdef DESKTOP_VERSION |
1287 | if ( QApplication::desktop()->width() < 1024 ) { | 1288 | if ( QApplication::desktop()->width() < 1024 ) { |
1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1289 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1290 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1291 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1291 | QFile file( fn ); | 1292 | QFile file( fn ); |
1292 | if (!file.open( IO_WriteOnly ) ) { | 1293 | if (!file.open( IO_WriteOnly ) ) { |
1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1294 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1294 | } else { | 1295 | } else { |
1295 | QTextStream ts( &file ); | 1296 | QTextStream ts( &file ); |
1296 | ts << mess; | 1297 | ts << mess; |
1297 | file.close(); | 1298 | file.close(); |
1298 | } | 1299 | } |
1299 | } | 1300 | } |
1300 | #endif | 1301 | #endif |
1301 | int maxSec; | 1302 | int maxSec; |
1302 | //maxSec = 5; //testing only | 1303 | //maxSec = 5; //testing only |
1303 | maxSec = 86400+3600; // one day+1hour | 1304 | maxSec = 86400+3600; // one day+1hour |
1304 | mAlarmNotification = noti; | 1305 | mAlarmNotification = noti; |
1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1306 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1306 | if ( sec > maxSec ) { | 1307 | if ( sec > maxSec ) { |
1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1308 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1309 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1309 | return; | 1310 | return; |
1310 | } else { | 1311 | } else { |
1311 | mRecheckAlarmTimer->stop(); | 1312 | mRecheckAlarmTimer->stop(); |
1312 | } | 1313 | } |
1313 | //qDebug("Alarm timer started with secs: %d ", sec); | 1314 | //qDebug("Alarm timer started with secs: %d ", sec); |
1314 | mAlarmTimer->start( sec * 1000 , true ); | 1315 | mAlarmTimer->start( sec * 1000 , true ); |
1315 | 1316 | ||
1316 | } | 1317 | } |
1317 | // called by mRecheckAlarmTimer to get next alarm | 1318 | // called by mRecheckAlarmTimer to get next alarm |
1318 | // we need this, because a QTimer has only a max range of 25 days | 1319 | // we need this, because a QTimer has only a max range of 25 days |
1319 | void CalendarView::recheckTimerAlarm() | 1320 | void CalendarView::recheckTimerAlarm() |
1320 | { | 1321 | { |
1321 | mAlarmTimer->stop(); | 1322 | mAlarmTimer->stop(); |
1322 | mRecheckAlarmTimer->stop(); | 1323 | mRecheckAlarmTimer->stop(); |
1323 | mCalendar->checkAlarmForIncidence( 0, true ); | 1324 | mCalendar->checkAlarmForIncidence( 0, true ); |
1324 | } | 1325 | } |
1325 | #ifndef DESKTOP_VERSION | 1326 | #ifndef DESKTOP_VERSION |
1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1327 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1327 | #else | 1328 | #else |
1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1329 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1329 | #endif | 1330 | #endif |
1330 | { | 1331 | { |
1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1332 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1333 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1333 | #ifndef DESKTOP_VERSION | 1334 | #ifndef DESKTOP_VERSION |
1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1335 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1335 | #endif | 1336 | #endif |
1336 | return; | 1337 | return; |
1337 | } | 1338 | } |
1338 | mAlarmTimer->stop(); | 1339 | mAlarmTimer->stop(); |
1339 | } | 1340 | } |
1340 | void CalendarView::selectWeekNum ( int num ) | 1341 | void CalendarView::selectWeekNum ( int num ) |
1341 | { | 1342 | { |
1342 | dateNavigator()->blockSignals( true ); | 1343 | dateNavigator()->blockSignals( true ); |
1343 | dateNavigator()->selectWeek( num ); | 1344 | dateNavigator()->selectWeek( num ); |
1344 | dateNavigator()->blockSignals( false ); | 1345 | dateNavigator()->blockSignals( false ); |
1345 | mViewManager->showWeekView(); | 1346 | mViewManager->showWeekView(); |
1346 | } | 1347 | } |
1347 | KOViewManager *CalendarView::viewManager() | 1348 | KOViewManager *CalendarView::viewManager() |
1348 | { | 1349 | { |
1349 | return mViewManager; | 1350 | return mViewManager; |
1350 | } | 1351 | } |
1351 | 1352 | ||
1352 | KODialogManager *CalendarView::dialogManager() | 1353 | KODialogManager *CalendarView::dialogManager() |
1353 | { | 1354 | { |
1354 | return mDialogManager; | 1355 | return mDialogManager; |
1355 | } | 1356 | } |
1356 | 1357 | ||
1357 | QDate CalendarView::startDate() | 1358 | QDate CalendarView::startDate() |
1358 | { | 1359 | { |
1359 | DateList dates = mNavigator->selectedDates(); | 1360 | DateList dates = mNavigator->selectedDates(); |
1360 | 1361 | ||
1361 | return dates.first(); | 1362 | return dates.first(); |
1362 | } | 1363 | } |
1363 | 1364 | ||
1364 | QDate CalendarView::endDate() | 1365 | QDate CalendarView::endDate() |
1365 | { | 1366 | { |
1366 | DateList dates = mNavigator->selectedDates(); | 1367 | DateList dates = mNavigator->selectedDates(); |
1367 | 1368 | ||
1368 | return dates.last(); | 1369 | return dates.last(); |
1369 | } | 1370 | } |
1370 | 1371 | ||
1371 | 1372 | ||
1372 | void CalendarView::createPrinter() | 1373 | void CalendarView::createPrinter() |
1373 | { | 1374 | { |
1374 | #ifndef KORG_NOPRINTER | 1375 | #ifndef KORG_NOPRINTER |
1375 | if (!mCalPrinter) { | 1376 | if (!mCalPrinter) { |
1376 | mCalPrinter = new CalPrinter(this, mCalendar); | 1377 | mCalPrinter = new CalPrinter(this, mCalendar); |
1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1378 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1378 | } | 1379 | } |
1379 | #endif | 1380 | #endif |
1380 | } | 1381 | } |
1381 | 1382 | ||
1382 | 1383 | ||
1383 | //KOPrefs::instance()->mWriteBackFile | 1384 | //KOPrefs::instance()->mWriteBackFile |
1384 | //KOPrefs::instance()->mWriteBackExistingOnly | 1385 | //KOPrefs::instance()->mWriteBackExistingOnly |
1385 | 1386 | ||
1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1387 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1388 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1389 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1390 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1391 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1392 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1392 | 1393 | ||
1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1394 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1394 | { | 1395 | { |
1395 | 1396 | ||
1396 | // 0 equal | 1397 | // 0 equal |
1397 | // 1 take local | 1398 | // 1 take local |
1398 | // 2 take remote | 1399 | // 2 take remote |
1399 | // 3 cancel | 1400 | // 3 cancel |
1400 | QDateTime lastSync = mLastCalendarSync; | 1401 | QDateTime lastSync = mLastCalendarSync; |
1401 | QDateTime localMod = local->lastModified(); | 1402 | QDateTime localMod = local->lastModified(); |
1402 | QDateTime remoteMod = remote->lastModified(); | 1403 | QDateTime remoteMod = remote->lastModified(); |
1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1404 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1404 | bool remCh, locCh; | 1405 | bool remCh, locCh; |
1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1406 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1406 | //if ( remCh ) | 1407 | //if ( remCh ) |
1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1408 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1408 | locCh = ( localMod > mLastCalendarSync ); | 1409 | locCh = ( localMod > mLastCalendarSync ); |
1409 | if ( !remCh && ! locCh ) { | 1410 | if ( !remCh && ! locCh ) { |
1410 | //qDebug("both not changed "); | 1411 | //qDebug("both not changed "); |
1411 | lastSync = localMod.addDays(1); | 1412 | lastSync = localMod.addDays(1); |
1412 | if ( mode <= SYNC_PREF_ASK ) | 1413 | if ( mode <= SYNC_PREF_ASK ) |
1413 | return 0; | 1414 | return 0; |
1414 | } else { | 1415 | } else { |
1415 | if ( locCh ) { | 1416 | if ( locCh ) { |
1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1417 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1417 | lastSync = localMod.addDays( -1 ); | 1418 | lastSync = localMod.addDays( -1 ); |
1418 | if ( !remCh ) | 1419 | if ( !remCh ) |
1419 | remoteMod = ( lastSync.addDays( -1 ) ); | 1420 | remoteMod = ( lastSync.addDays( -1 ) ); |
1420 | } else { | 1421 | } else { |
1421 | //qDebug(" not loc changed "); | 1422 | //qDebug(" not loc changed "); |
1422 | lastSync = localMod.addDays( 1 ); | 1423 | lastSync = localMod.addDays( 1 ); |
1423 | if ( remCh ) | 1424 | if ( remCh ) |
1424 | remoteMod =( lastSync.addDays( 1 ) ); | 1425 | remoteMod =( lastSync.addDays( 1 ) ); |
1425 | 1426 | ||
1426 | } | 1427 | } |
1427 | } | 1428 | } |
1428 | full = true; | 1429 | full = true; |
1429 | if ( mode < SYNC_PREF_ASK ) | 1430 | if ( mode < SYNC_PREF_ASK ) |
1430 | mode = SYNC_PREF_ASK; | 1431 | mode = SYNC_PREF_ASK; |
1431 | } else { | 1432 | } else { |
1432 | if ( localMod == remoteMod ) | 1433 | if ( localMod == remoteMod ) |
1433 | // if ( local->revision() == remote->revision() ) | 1434 | // if ( local->revision() == remote->revision() ) |
1434 | return 0; | 1435 | return 0; |
1435 | 1436 | ||
1436 | } | 1437 | } |
1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1438 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1438 | 1439 | ||
1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1440 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1441 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1441 | //full = true; //debug only | 1442 | //full = true; //debug only |
1442 | if ( full ) { | 1443 | if ( full ) { |
1443 | bool equ = false; | 1444 | bool equ = false; |
1444 | if ( local->typeID() == eventID ) { | 1445 | if ( local->typeID() == eventID ) { |
1445 | equ = (*((Event*) local) == *((Event*) remote)); | 1446 | equ = (*((Event*) local) == *((Event*) remote)); |
1446 | } | 1447 | } |
1447 | else if ( local->typeID() == todoID ) | 1448 | else if ( local->typeID() == todoID ) |
1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1449 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1449 | else if ( local->typeID() == journalID ) | 1450 | else if ( local->typeID() == journalID ) |
1450 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1451 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1451 | if ( equ ) { | 1452 | if ( equ ) { |
1452 | //qDebug("equal "); | 1453 | //qDebug("equal "); |
1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1454 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1455 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1455 | } | 1456 | } |
1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1457 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1457 | return 0; | 1458 | return 0; |
1458 | 1459 | ||
1459 | }//else //debug only | 1460 | }//else //debug only |
1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1461 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1461 | } | 1462 | } |
1462 | int result; | 1463 | int result; |
1463 | bool localIsNew; | 1464 | bool localIsNew; |
1464 | //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() ); | 1465 | //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() ); |
1465 | 1466 | ||
1466 | 1467 | ||
1467 | // ************************************************ | 1468 | // ************************************************ |
1468 | // ************************************************ | 1469 | // ************************************************ |
1469 | // ************************************************ | 1470 | // ************************************************ |
1470 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1471 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1471 | // BUT remoteMod != localMod | 1472 | // BUT remoteMod != localMod |
1472 | 1473 | ||
1473 | 1474 | ||
1474 | if ( full && mode < SYNC_PREF_NEWEST ) | 1475 | if ( full && mode < SYNC_PREF_NEWEST ) |
1475 | mode = SYNC_PREF_ASK; | 1476 | mode = SYNC_PREF_ASK; |
1476 | 1477 | ||
1477 | switch( mode ) { | 1478 | switch( mode ) { |
1478 | case SYNC_PREF_LOCAL: | 1479 | case SYNC_PREF_LOCAL: |
1479 | if ( lastSync > remoteMod ) | 1480 | if ( lastSync > remoteMod ) |
1480 | return 1; | 1481 | return 1; |
1481 | if ( lastSync > localMod ) | 1482 | if ( lastSync > localMod ) |
1482 | return 2; | 1483 | return 2; |
1483 | return 1; | 1484 | return 1; |
1484 | break; | 1485 | break; |
1485 | case SYNC_PREF_REMOTE: | 1486 | case SYNC_PREF_REMOTE: |
1486 | if ( lastSync > localMod ) | 1487 | if ( lastSync > localMod ) |
1487 | return 2; | 1488 | return 2; |
1488 | if ( lastSync > remoteMod ) | 1489 | if ( lastSync > remoteMod ) |
1489 | return 1; | 1490 | return 1; |
1490 | return 2; | 1491 | return 2; |
1491 | break; | 1492 | break; |
1492 | case SYNC_PREF_NEWEST: | 1493 | case SYNC_PREF_NEWEST: |
1493 | if ( localMod >= remoteMod ) | 1494 | if ( localMod >= remoteMod ) |
1494 | return 1; | 1495 | return 1; |
1495 | else | 1496 | else |
1496 | return 2; | 1497 | return 2; |
1497 | break; | 1498 | break; |
1498 | case SYNC_PREF_ASK: | 1499 | case SYNC_PREF_ASK: |
1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1500 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1500 | if ( lastSync > remoteMod && lastSync > localMod) | 1501 | if ( lastSync > remoteMod && lastSync > localMod) |
1501 | return 0; | 1502 | return 0; |
1502 | if ( lastSync > remoteMod ) | 1503 | if ( lastSync > remoteMod ) |
1503 | return 1; | 1504 | return 1; |
1504 | if ( lastSync > localMod ) | 1505 | if ( lastSync > localMod ) |
1505 | return 2; | 1506 | return 2; |
1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1507 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1507 | localIsNew = localMod >= remoteMod; | 1508 | localIsNew = localMod >= remoteMod; |
1508 | if ( localIsNew ) | 1509 | if ( localIsNew ) |
1509 | getEventViewerDialog()->setColorMode( 1 ); | 1510 | getEventViewerDialog()->setColorMode( 1 ); |
1510 | else | 1511 | else |
1511 | getEventViewerDialog()->setColorMode( 2 ); | 1512 | getEventViewerDialog()->setColorMode( 2 ); |
1512 | getEventViewerDialog()->setIncidence(local); | 1513 | getEventViewerDialog()->setIncidence(local); |
1513 | if ( localIsNew ) | 1514 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 2 ); | 1515 | getEventViewerDialog()->setColorMode( 2 ); |
1515 | else | 1516 | else |
1516 | getEventViewerDialog()->setColorMode( 1 ); | 1517 | getEventViewerDialog()->setColorMode( 1 ); |
1517 | getEventViewerDialog()->addIncidence(remote); | 1518 | getEventViewerDialog()->addIncidence(remote); |
1518 | getEventViewerDialog()->setColorMode( 0 ); | 1519 | getEventViewerDialog()->setColorMode( 0 ); |
1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1520 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1521 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1521 | getEventViewerDialog()->showMe(); | 1522 | getEventViewerDialog()->showMe(); |
1522 | result = getEventViewerDialog()->executeS( localIsNew ); | 1523 | result = getEventViewerDialog()->executeS( localIsNew ); |
1523 | return result; | 1524 | return result; |
1524 | 1525 | ||
1525 | break; | 1526 | break; |
1526 | case SYNC_PREF_FORCE_LOCAL: | 1527 | case SYNC_PREF_FORCE_LOCAL: |
1527 | return 1; | 1528 | return 1; |
1528 | break; | 1529 | break; |
1529 | case SYNC_PREF_FORCE_REMOTE: | 1530 | case SYNC_PREF_FORCE_REMOTE: |
1530 | return 2; | 1531 | return 2; |
1531 | break; | 1532 | break; |
1532 | 1533 | ||
1533 | default: | 1534 | default: |
1534 | // SYNC_PREF_TAKE_BOTH not implemented | 1535 | // SYNC_PREF_TAKE_BOTH not implemented |
1535 | break; | 1536 | break; |
1536 | } | 1537 | } |
1537 | return 0; | 1538 | return 0; |
1538 | } | 1539 | } |
1539 | Event* CalendarView::getLastSyncEvent() | 1540 | Event* CalendarView::getLastSyncEvent() |
1540 | { | 1541 | { |
1541 | Event* lse; | 1542 | Event* lse; |
1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1543 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1544 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1544 | if (!lse) { | 1545 | if (!lse) { |
1545 | lse = new Event(); | 1546 | lse = new Event(); |
1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1547 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1547 | QString sum = ""; | 1548 | QString sum = ""; |
1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1549 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1549 | sum = "E: "; | 1550 | sum = "E: "; |
1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1551 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1551 | lse->setDtStart( mLastCalendarSync ); | 1552 | lse->setDtStart( mLastCalendarSync ); |
1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1553 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1553 | lse->setCategories( i18n("SyncEvent") ); | 1554 | lse->setCategories( i18n("SyncEvent") ); |
1554 | lse->setReadOnly( true ); | 1555 | lse->setReadOnly( true ); |
1556 | lse->setCalID( 1 ); | ||
1555 | mCalendar->addEvent( lse ); | 1557 | mCalendar->addEvent( lse ); |
1556 | } | 1558 | } |
1557 | 1559 | ||
1558 | return lse; | 1560 | return lse; |
1559 | 1561 | ||
1560 | } | 1562 | } |
1561 | 1563 | ||
1562 | // we check, if the to delete event has a id for a profile | 1564 | // we check, if the to delete event has a id for a profile |
1563 | // if yes, we set this id in the profile to delete | 1565 | // if yes, we set this id in the profile to delete |
1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1566 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1565 | { | 1567 | { |
1566 | if ( lastSync.count() == 0 ) { | 1568 | if ( lastSync.count() == 0 ) { |
1567 | //qDebug(" lastSync.count() == 0"); | 1569 | //qDebug(" lastSync.count() == 0"); |
1568 | return; | 1570 | return; |
1569 | } | 1571 | } |
1570 | if ( toDelete->typeID() == journalID ) | 1572 | if ( toDelete->typeID() == journalID ) |
1571 | return; | 1573 | return; |
1572 | 1574 | ||
1573 | Event* eve = lastSync.first(); | 1575 | Event* eve = lastSync.first(); |
1574 | 1576 | ||
1575 | while ( eve ) { | 1577 | while ( eve ) { |
1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1578 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1577 | if ( !id.isEmpty() ) { | 1579 | if ( !id.isEmpty() ) { |
1578 | QString des = eve->description(); | 1580 | QString des = eve->description(); |
1579 | QString pref = "e"; | 1581 | QString pref = "e"; |
1580 | if ( toDelete->typeID() == todoID ) | 1582 | if ( toDelete->typeID() == todoID ) |
1581 | pref = "t"; | 1583 | pref = "t"; |
1582 | des += pref+ id + ","; | 1584 | des += pref+ id + ","; |
1583 | eve->setReadOnly( false ); | 1585 | eve->setReadOnly( false ); |
1584 | eve->setDescription( des ); | 1586 | eve->setDescription( des ); |
1585 | //qDebug("setdes %s ", des.latin1()); | 1587 | //qDebug("setdes %s ", des.latin1()); |
1586 | eve->setReadOnly( true ); | 1588 | eve->setReadOnly( true ); |
1587 | } | 1589 | } |
1588 | eve = lastSync.next(); | 1590 | eve = lastSync.next(); |
1589 | } | 1591 | } |
1590 | 1592 | ||
1591 | } | 1593 | } |
1592 | void CalendarView::checkExternalId( Incidence * inc ) | 1594 | void CalendarView::checkExternalId( Incidence * inc ) |
1593 | { | 1595 | { |
1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1596 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1595 | checkExternSyncEvent( lastSync, inc ); | 1597 | checkExternSyncEvent( lastSync, inc ); |
1596 | 1598 | ||
1597 | } | 1599 | } |
1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1600 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1599 | { | 1601 | { |
1600 | bool syncOK = true; | 1602 | bool syncOK = true; |
1601 | int addedEvent = 0; | 1603 | int addedEvent = 0; |
1602 | int addedEventR = 0; | 1604 | int addedEventR = 0; |
1603 | int deletedEventR = 0; | 1605 | int deletedEventR = 0; |
1604 | int deletedEventL = 0; | 1606 | int deletedEventL = 0; |
1605 | int changedLocal = 0; | 1607 | int changedLocal = 0; |
1606 | int changedRemote = 0; | 1608 | int changedRemote = 0; |
1607 | int filteredIN = 0; | 1609 | int filteredIN = 0; |
1608 | int filteredOUT = 0; | 1610 | int filteredOUT = 0; |
1609 | //QPtrList<Event> el = local->rawEvents(); | 1611 | //QPtrList<Event> el = local->rawEvents(); |
1610 | Event* eventR; | 1612 | Event* eventR; |
1611 | QString uid; | 1613 | QString uid; |
1612 | int take; | 1614 | int take; |
1613 | Event* eventRSync; | 1615 | Event* eventRSync; |
1614 | Event* eventLSync; | 1616 | Event* eventLSync; |
1615 | clearAllViews(); | 1617 | clearAllViews(); |
1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1618 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1619 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1618 | bool fullDateRange = false; | 1620 | bool fullDateRange = false; |
1619 | local->resetTempSyncStat(); | 1621 | local->resetTempSyncStat(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime(); | 1622 | mLastCalendarSync = QDateTime::currentDateTime(); |
1621 | if ( mSyncManager->syncWithDesktop() ) { | 1623 | if ( mSyncManager->syncWithDesktop() ) { |
1622 | remote->resetPilotStat(1); | 1624 | remote->resetPilotStat(1); |
1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1625 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1626 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1627 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1626 | } else { | 1628 | } else { |
1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1629 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1628 | } | 1630 | } |
1629 | } | 1631 | } |
1630 | QDateTime modifiedCalendar = mLastCalendarSync; | 1632 | QDateTime modifiedCalendar = mLastCalendarSync; |
1631 | eventLSync = getLastSyncEvent(); | 1633 | eventLSync = getLastSyncEvent(); |
1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1634 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1633 | if ( eventR ) { | 1635 | if ( eventR ) { |
1634 | qDebug("last-syncEvent on remote found "); | 1636 | qDebug("last-syncEvent on remote found "); |
1635 | eventRSync = (Event*) eventR->clone(); | 1637 | eventRSync = (Event*) eventR->clone(); |
1636 | remote->deleteEvent(eventR ); | 1638 | remote->deleteEvent(eventR ); |
1637 | 1639 | ||
1638 | } else { | 1640 | } else { |
1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1641 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1640 | eventRSync = (Event*)eventLSync->clone(); | 1642 | eventRSync = (Event*)eventLSync->clone(); |
1641 | } else { | 1643 | } else { |
1642 | fullDateRange = true; | 1644 | fullDateRange = true; |
1643 | eventRSync = new Event(); | 1645 | eventRSync = new Event(); |
1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1646 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1647 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1646 | eventRSync->setDtStart( mLastCalendarSync ); | 1648 | eventRSync->setDtStart( mLastCalendarSync ); |
1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1649 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1648 | eventRSync->setCategories( i18n("SyncEvent") ); | 1650 | eventRSync->setCategories( i18n("SyncEvent") ); |
1649 | } | 1651 | } |
1650 | } | 1652 | } |
1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1653 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1652 | fullDateRange = true; | 1654 | fullDateRange = true; |
1653 | 1655 | ||
1654 | if ( ! fullDateRange ) { | 1656 | if ( ! fullDateRange ) { |
1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1657 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1656 | 1658 | ||
1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1659 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1660 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1659 | fullDateRange = true; | 1661 | fullDateRange = true; |
1660 | } | 1662 | } |
1661 | } | 1663 | } |
1662 | if ( mSyncManager->syncWithDesktop() ) { | 1664 | if ( mSyncManager->syncWithDesktop() ) { |
1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1665 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1664 | } | 1666 | } |
1665 | if ( fullDateRange ) | 1667 | if ( fullDateRange ) |
1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1668 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1667 | else | 1669 | else |
1668 | mLastCalendarSync = eventLSync->dtStart(); | 1670 | mLastCalendarSync = eventLSync->dtStart(); |
1669 | // for resyncing if own file has changed | 1671 | // for resyncing if own file has changed |
1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1672 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1671 | mLastCalendarSync = loadedFileVersion; | 1673 | mLastCalendarSync = loadedFileVersion; |
1672 | //qDebug("setting mLastCalendarSync "); | 1674 | //qDebug("setting mLastCalendarSync "); |
1673 | } | 1675 | } |
1674 | //qDebug("*************************** "); | 1676 | //qDebug("*************************** "); |
1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1677 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1676 | QPtrList<Incidence> er = remote->rawIncidences(); | 1678 | QPtrList<Incidence> er = remote->rawIncidences(); |
1677 | Incidence* inR = er.first(); | 1679 | Incidence* inR = er.first(); |
1678 | Incidence* inL; | 1680 | Incidence* inL; |
1679 | QProgressBar bar( er.count(),0 ); | 1681 | QProgressBar bar( er.count(),0 ); |
1680 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1682 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1681 | 1683 | ||
1682 | // ************** setting up filter ************* | 1684 | // ************** setting up filter ************* |
1683 | CalFilter *filterIN = 0; | 1685 | CalFilter *filterIN = 0; |
1684 | CalFilter *filterOUT = 0; | 1686 | CalFilter *filterOUT = 0; |
1685 | CalFilter *filter = mFilters.first(); | 1687 | CalFilter *filter = mFilters.first(); |
1686 | while(filter) { | 1688 | while(filter) { |
1687 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1689 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1688 | filterIN = filter; | 1690 | filterIN = filter; |
1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1691 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1690 | filterOUT = filter; | 1692 | filterOUT = filter; |
1691 | filter = mFilters.next(); | 1693 | filter = mFilters.next(); |
1692 | } | 1694 | } |
1693 | int w = 300; | 1695 | int w = 300; |
1694 | if ( QApplication::desktop()->width() < 320 ) | 1696 | if ( QApplication::desktop()->width() < 320 ) |
1695 | w = 220; | 1697 | w = 220; |
1696 | int h = bar.sizeHint().height() ; | 1698 | int h = bar.sizeHint().height() ; |
1697 | int dw = QApplication::desktop()->width(); | 1699 | int dw = QApplication::desktop()->width(); |
1698 | int dh = QApplication::desktop()->height(); | 1700 | int dh = QApplication::desktop()->height(); |
1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1701 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1700 | bar.show(); | 1702 | bar.show(); |
1701 | int modulo = (er.count()/10)+1; | 1703 | int modulo = (er.count()/10)+1; |
1702 | int incCounter = 0; | 1704 | int incCounter = 0; |
1703 | while ( inR ) { | 1705 | while ( inR ) { |
1704 | if ( ! bar.isVisible() ) | 1706 | if ( ! bar.isVisible() ) |
1705 | return false; | 1707 | return false; |
1706 | if ( incCounter % modulo == 0 ) | 1708 | if ( incCounter % modulo == 0 ) |
1707 | bar.setProgress( incCounter ); | 1709 | bar.setProgress( incCounter ); |
1708 | ++incCounter; | 1710 | ++incCounter; |
1709 | uid = inR->uid(); | 1711 | uid = inR->uid(); |
1710 | bool skipIncidence = false; | 1712 | bool skipIncidence = false; |
1711 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1713 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1712 | skipIncidence = true; | 1714 | skipIncidence = true; |
1713 | QString idS; | 1715 | QString idS; |
1714 | qApp->processEvents(); | 1716 | qApp->processEvents(); |
1715 | if ( !skipIncidence ) { | 1717 | if ( !skipIncidence ) { |
1716 | inL = local->incidenceForUid( uid , false ); | 1718 | inL = local->incidenceForUid( uid , false ); |
1717 | if ( inL ) { // maybe conflict - same uid in both calendars | 1719 | if ( inL ) { // maybe conflict - same uid in both calendars |
1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1720 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1721 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1720 | if ( take == 3 ) | 1722 | if ( take == 3 ) |
1721 | return false; | 1723 | return false; |
1722 | if ( take == 1 ) {// take local ********************** | 1724 | if ( take == 1 ) {// take local ********************** |
1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1725 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1726 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1725 | else | 1727 | else |
1726 | idS = inR->IDStr(); | 1728 | idS = inR->IDStr(); |
1727 | int calID = inR->calID(); | 1729 | int calID = inR->calID(); |
1728 | remote->deleteIncidence( inR ); | 1730 | remote->deleteIncidence( inR ); |
1729 | inR = inL->clone(); | 1731 | inR = inL->clone(); |
1730 | inR->setCalID( calID ); | 1732 | inR->setCalID( calID ); |
1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1733 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1734 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1733 | inR->setIDStr( idS ); | 1735 | inR->setIDStr( idS ); |
1734 | remote->addIncidence( inR ); | 1736 | remote->addIncidence( inR ); |
1735 | if ( mSyncManager->syncWithDesktop() ) | 1737 | if ( mSyncManager->syncWithDesktop() ) |
1736 | inR->setPilotId( 2 ); | 1738 | inR->setPilotId( 2 ); |
1737 | ++changedRemote; | 1739 | ++changedRemote; |
1738 | } else {// take remote ********************** | 1740 | } else {// take remote ********************** |
1739 | if ( !inL->isReadOnly() ) { | 1741 | if ( !inL->isReadOnly() ) { |
1740 | idS = inL->IDStr(); | 1742 | idS = inL->IDStr(); |
1741 | int pid = inL->pilotId(); | 1743 | int pid = inL->pilotId(); |
1742 | int calID = inL->calID(); | 1744 | int calID = inL->calID(); |
1743 | local->deleteIncidence( inL ); | 1745 | local->deleteIncidence( inL ); |
1744 | inL = inR->clone(); | 1746 | inL = inR->clone(); |
1745 | inL->setCalID( calID ); | 1747 | inL->setCalID( calID ); |
1746 | if ( mSyncManager->syncWithDesktop() ) | 1748 | if ( mSyncManager->syncWithDesktop() ) |
1747 | inL->setPilotId( pid ); | 1749 | inL->setPilotId( pid ); |
1748 | inL->setIDStr( idS ); | 1750 | inL->setIDStr( idS ); |
1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1752 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1753 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1752 | } | 1754 | } |
1753 | local->addIncidence( inL ); | 1755 | local->addIncidence( inL ); |
1754 | ++changedLocal; | 1756 | ++changedLocal; |
1755 | } | 1757 | } |
1756 | } | 1758 | } |
1757 | } | 1759 | } |
1758 | } else { // no conflict ********** add or delete remote | 1760 | } else { // no conflict ********** add or delete remote |
1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1761 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1762 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1761 | QString des = eventLSync->description(); | 1763 | QString des = eventLSync->description(); |
1762 | QString pref = "e"; | 1764 | QString pref = "e"; |
1763 | if ( inR->typeID() == todoID ) | 1765 | if ( inR->typeID() == todoID ) |
1764 | pref = "t"; | 1766 | pref = "t"; |
1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1767 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1768 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1767 | //remote->deleteIncidence( inR ); | 1769 | //remote->deleteIncidence( inR ); |
1768 | ++deletedEventR; | 1770 | ++deletedEventR; |
1769 | } else { | 1771 | } else { |
1770 | inR->setLastModified( modifiedCalendar ); | 1772 | inR->setLastModified( modifiedCalendar ); |
1771 | inL = inR->clone(); | 1773 | inL = inR->clone(); |
1772 | inL->setIDStr( ":" ); | 1774 | inL->setIDStr( ":" ); |
1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1775 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1776 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1775 | 1777 | ||
1776 | inL->setCalID( 0 );// add to default cal | 1778 | inL->setCalID( 0 );// add to default cal |
1777 | local->addIncidence( inL ); | 1779 | local->addIncidence( inL ); |
1778 | ++addedEvent; | 1780 | ++addedEvent; |
1779 | 1781 | ||
1780 | } | 1782 | } |
1781 | } else { | 1783 | } else { |
1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1784 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1783 | inR->setLastModified( modifiedCalendar ); | 1785 | inR->setLastModified( modifiedCalendar ); |
1784 | inL = inR->clone(); | 1786 | inL = inR->clone(); |
1785 | inL->setIDStr( ":" ); | 1787 | inL->setIDStr( ":" ); |
1786 | inL->setCalID( 0 );// add to default cal | 1788 | inL->setCalID( 0 );// add to default cal |
1787 | local->addIncidence( inL ); | 1789 | local->addIncidence( inL ); |
1788 | ++addedEvent; | 1790 | ++addedEvent; |
1789 | 1791 | ||
1790 | } else { | 1792 | } else { |
1791 | checkExternSyncEvent(eventRSyncSharp, inR); | 1793 | checkExternSyncEvent(eventRSyncSharp, inR); |
1792 | remote->deleteIncidence( inR ); | 1794 | remote->deleteIncidence( inR ); |
1793 | ++deletedEventR; | 1795 | ++deletedEventR; |
1794 | } | 1796 | } |
1795 | } | 1797 | } |
1796 | } else { | 1798 | } else { |
1797 | ++filteredIN; | 1799 | ++filteredIN; |
1798 | } | 1800 | } |
1799 | } | 1801 | } |
1800 | } | 1802 | } |
1801 | inR = er.next(); | 1803 | inR = er.next(); |
1802 | } | 1804 | } |
1803 | QPtrList<Incidence> el = local->rawIncidences(); | 1805 | QPtrList<Incidence> el = local->rawIncidences(); |
1804 | inL = el.first(); | 1806 | inL = el.first(); |
1805 | modulo = (el.count()/10)+1; | 1807 | modulo = (el.count()/10)+1; |
1806 | bar.setCaption (i18n("Add / remove events") ); | 1808 | bar.setCaption (i18n("Add / remove events") ); |
1807 | bar.setTotalSteps ( el.count() ) ; | 1809 | bar.setTotalSteps ( el.count() ) ; |
1808 | bar.show(); | 1810 | bar.show(); |
1809 | incCounter = 0; | 1811 | incCounter = 0; |
1810 | 1812 | ||
1811 | while ( inL ) { | 1813 | while ( inL ) { |
1812 | 1814 | ||
1813 | qApp->processEvents(); | 1815 | qApp->processEvents(); |
1814 | if ( ! bar.isVisible() ) | 1816 | if ( ! bar.isVisible() ) |
1815 | return false; | 1817 | return false; |
1816 | if ( incCounter % modulo == 0 ) | 1818 | if ( incCounter % modulo == 0 ) |
1817 | bar.setProgress( incCounter ); | 1819 | bar.setProgress( incCounter ); |
1818 | ++incCounter; | 1820 | ++incCounter; |
1819 | uid = inL->uid(); | 1821 | uid = inL->uid(); |
1820 | bool skipIncidence = false; | 1822 | bool skipIncidence = false; |
1821 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1823 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1822 | skipIncidence = true; | 1824 | skipIncidence = true; |
1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1825 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1824 | skipIncidence = true; | 1826 | skipIncidence = true; |
1825 | if ( !skipIncidence ) { | 1827 | if ( !skipIncidence ) { |
1826 | inR = remote->incidenceForUid( uid , true ); | 1828 | inR = remote->incidenceForUid( uid , true ); |
1827 | if ( ! inR ) { | 1829 | if ( ! inR ) { |
1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1830 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1829 | // no conflict ********** add or delete local | 1831 | // no conflict ********** add or delete local |
1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1832 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1833 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1832 | checkExternSyncEvent(eventLSyncSharp, inL); | 1834 | checkExternSyncEvent(eventLSyncSharp, inL); |
1833 | local->deleteIncidence( inL ); | 1835 | local->deleteIncidence( inL ); |
1834 | ++deletedEventL; | 1836 | ++deletedEventL; |
1835 | } else { | 1837 | } else { |
1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1838 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1837 | inL->removeID(mCurrentSyncDevice ); | 1839 | inL->removeID(mCurrentSyncDevice ); |
1838 | ++addedEventR; | 1840 | ++addedEventR; |
1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1841 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1840 | inL->setLastModified( modifiedCalendar ); | 1842 | inL->setLastModified( modifiedCalendar ); |
1841 | inR = inL->clone(); | 1843 | inR = inL->clone(); |
1842 | inR->setIDStr( ":" ); | 1844 | inR->setIDStr( ":" ); |
1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1845 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1844 | inR->setCalID( 0 );// add to default cal | 1846 | inR->setCalID( 0 );// add to default cal |
1845 | remote->addIncidence( inR ); | 1847 | remote->addIncidence( inR ); |
1846 | } | 1848 | } |
1847 | } | 1849 | } |
1848 | } else { | 1850 | } else { |
1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1851 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1850 | checkExternSyncEvent(eventLSyncSharp, inL); | 1852 | checkExternSyncEvent(eventLSyncSharp, inL); |
1851 | local->deleteIncidence( inL ); | 1853 | local->deleteIncidence( inL ); |
1852 | ++deletedEventL; | 1854 | ++deletedEventL; |
1853 | } else { | 1855 | } else { |
1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1856 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1855 | ++addedEventR; | 1857 | ++addedEventR; |
1856 | inL->setLastModified( modifiedCalendar ); | 1858 | inL->setLastModified( modifiedCalendar ); |
1857 | inR = inL->clone(); | 1859 | inR = inL->clone(); |
1858 | inR->setIDStr( ":" ); | 1860 | inR->setIDStr( ":" ); |
1859 | inR->setCalID( 0 );// add to default cal | 1861 | inR->setCalID( 0 );// add to default cal |
1860 | remote->addIncidence( inR ); | 1862 | remote->addIncidence( inR ); |
1861 | } | 1863 | } |
1862 | } | 1864 | } |
1863 | } | 1865 | } |
1864 | } else { | 1866 | } else { |
1865 | ++filteredOUT; | 1867 | ++filteredOUT; |
1866 | } | 1868 | } |
1867 | } | 1869 | } |
1868 | } | 1870 | } |
1869 | inL = el.next(); | 1871 | inL = el.next(); |
1870 | } | 1872 | } |
1871 | int delFut = 0; | 1873 | int delFut = 0; |
1872 | int remRem = 0; | 1874 | int remRem = 0; |
1873 | if ( mSyncManager->mWriteBackInFuture ) { | 1875 | if ( mSyncManager->mWriteBackInFuture ) { |
1874 | er = remote->rawIncidences(); | 1876 | er = remote->rawIncidences(); |
1875 | remRem = er.count(); | 1877 | remRem = er.count(); |
1876 | inR = er.first(); | 1878 | inR = er.first(); |
1877 | QDateTime dt; | 1879 | QDateTime dt; |
1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1880 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1881 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1880 | while ( inR ) { | 1882 | while ( inR ) { |
1881 | if ( inR->typeID() == todoID ) { | 1883 | if ( inR->typeID() == todoID ) { |
1882 | Todo * t = (Todo*)inR; | 1884 | Todo * t = (Todo*)inR; |
1883 | if ( t->hasDueDate() ) | 1885 | if ( t->hasDueDate() ) |
1884 | dt = t->dtDue(); | 1886 | dt = t->dtDue(); |
1885 | else | 1887 | else |
1886 | dt = cur.addSecs( 62 ); | 1888 | dt = cur.addSecs( 62 ); |
1887 | } | 1889 | } |
1888 | else if (inR->typeID() == eventID ) { | 1890 | else if (inR->typeID() == eventID ) { |
1889 | bool ok; | 1891 | bool ok; |
1890 | dt = inR->getNextOccurence( cur, &ok ); | 1892 | dt = inR->getNextOccurence( cur, &ok ); |
1891 | if ( !ok ) | 1893 | if ( !ok ) |
1892 | dt = cur.addSecs( -62 ); | 1894 | dt = cur.addSecs( -62 ); |
1893 | } | 1895 | } |
1894 | else | 1896 | else |
1895 | dt = inR->dtStart(); | 1897 | dt = inR->dtStart(); |
1896 | if ( dt < cur || dt > end ) { | 1898 | if ( dt < cur || dt > end ) { |
1897 | remote->deleteIncidence( inR ); | 1899 | remote->deleteIncidence( inR ); |
1898 | ++delFut; | 1900 | ++delFut; |
1899 | } | 1901 | } |
1900 | inR = er.next(); | 1902 | inR = er.next(); |
1901 | } | 1903 | } |
1902 | } | 1904 | } |
1903 | bar.hide(); | 1905 | bar.hide(); |
1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1906 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1905 | eventLSync->setReadOnly( false ); | 1907 | if ( mMultiResourceSync ) { |
1906 | eventLSync->setDtStart( mLastCalendarSync ); | 1908 | remote->removeSyncInfo( "" ); //all |
1907 | eventRSync->setDtStart( mLastCalendarSync ); | 1909 | |
1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1910 | } else { |
1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1911 | eventLSync->setReadOnly( false ); |
1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1912 | eventLSync->setDtStart( mLastCalendarSync ); |
1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1913 | eventRSync->setDtStart( mLastCalendarSync ); |
1912 | eventLSync->setReadOnly( true ); | 1914 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1915 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | ||
1916 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | ||
1917 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | ||
1918 | eventLSync->setReadOnly( true ); | ||
1919 | } | ||
1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1920 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1921 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... |
1915 | remote->addEvent( eventRSync ); | 1922 | remote->addEvent( eventRSync ); |
1916 | else | 1923 | else |
1917 | delete eventRSync; | 1924 | delete eventRSync; |
1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1925 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1919 | QString mes; | 1926 | QString mes; |
1920 | 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 ); | 1927 | 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 ); |
1921 | QString delmess; | 1928 | QString delmess; |
1922 | if ( delFut ) { | 1929 | if ( delFut ) { |
1923 | 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); | 1930 | 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); |
1924 | mes += delmess; | 1931 | mes += delmess; |
1925 | } | 1932 | } |
1926 | mes = i18n("Local calendar changed!\n") +mes; | 1933 | mes = i18n("Local calendar changed!\n") +mes; |
1927 | mCalendar->checkAlarmForIncidence( 0, true ); | 1934 | mCalendar->checkAlarmForIncidence( 0, true ); |
1928 | qDebug( mes ); | 1935 | qDebug( mes ); |
1929 | if ( mSyncManager->mShowSyncSummary ) { | 1936 | if ( mSyncManager->mShowSyncSummary ) { |
1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1937 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1938 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1932 | qDebug("KO: WB cancelled "); | 1939 | qDebug("KO: WB cancelled "); |
1933 | mSyncManager->mWriteBackFile = false; | 1940 | mSyncManager->mWriteBackFile = false; |
1934 | return syncOK; | 1941 | return syncOK; |
1935 | } | 1942 | } |
1936 | } | 1943 | } |
1937 | return syncOK; | 1944 | return syncOK; |
1938 | } | 1945 | } |
1939 | 1946 | ||
1940 | void CalendarView::setSyncDevice( QString s ) | 1947 | void CalendarView::setSyncDevice( QString s ) |
1941 | { | 1948 | { |
1942 | mCurrentSyncDevice= s; | 1949 | mCurrentSyncDevice= s; |
1943 | } | 1950 | } |
1944 | void CalendarView::setSyncName( QString s ) | 1951 | void CalendarView::setSyncName( QString s ) |
1945 | { | 1952 | { |
1946 | mCurrentSyncName= s; | 1953 | mCurrentSyncName= s; |
1947 | } | 1954 | } |
1948 | bool CalendarView::syncCalendar(QString filename, int mode) | 1955 | bool CalendarView::syncCalendar(QString filename, int mode) |
1949 | { | 1956 | { |
1950 | //qDebug("syncCalendar %s ", filename.latin1()); | 1957 | //qDebug("syncCalendar %s ", filename.latin1()); |
1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1958 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1952 | CalendarLocal* calendar = new CalendarLocal(); | 1959 | CalendarLocal* calendar = new CalendarLocal(); |
1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1960 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1954 | FileStorage* storage = new FileStorage( calendar ); | 1961 | FileStorage* storage = new FileStorage( calendar ); |
1955 | bool syncOK = false; | 1962 | bool syncOK = false; |
1956 | storage->setFileName( filename ); | 1963 | storage->setFileName( filename ); |
1957 | // qDebug("loading ... "); | 1964 | // qDebug("loading ... "); |
1958 | if ( storage->load() ) { | 1965 | if ( storage->load() ) { |
1959 | getEventViewerDialog()->setSyncMode( true ); | 1966 | getEventViewerDialog()->setSyncMode( true ); |
1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1967 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1961 | getEventViewerDialog()->setSyncMode( false ); | 1968 | getEventViewerDialog()->setSyncMode( false ); |
1962 | if ( syncOK ) { | 1969 | if ( syncOK ) { |
1963 | if ( mSyncManager->mWriteBackFile ) | 1970 | if ( mSyncManager->mWriteBackFile ) |
1964 | { | 1971 | { |
1965 | storage->setSaveFormat( new ICalFormat() ); | 1972 | storage->setSaveFormat( new ICalFormat() ); |
1966 | storage->save(); | 1973 | storage->save(); |
1967 | } | 1974 | } |
1968 | } | 1975 | } |
1969 | setModified( true ); | 1976 | setModified( true ); |
1970 | } | 1977 | } |
1971 | delete storage; | 1978 | delete storage; |
1972 | delete calendar; | 1979 | delete calendar; |
1973 | if ( syncOK ) | 1980 | if ( syncOK ) |
1974 | updateView(); | 1981 | updateView(); |
1975 | return syncOK; | 1982 | return syncOK; |
1976 | } | 1983 | } |
1977 | 1984 | ||
1978 | void CalendarView::syncExternal( int mode ) | 1985 | void CalendarView::syncExternal( int mode ) |
1979 | { | 1986 | { |
1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1987 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1981 | qApp->processEvents(); | 1988 | qApp->processEvents(); |
1982 | CalendarLocal* calendar = new CalendarLocal(); | 1989 | CalendarLocal* calendar = new CalendarLocal(); |
1983 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1990 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1984 | bool syncOK = false; | 1991 | bool syncOK = false; |
1985 | bool loadSuccess = false; | 1992 | bool loadSuccess = false; |
1986 | PhoneFormat* phoneFormat = 0; | 1993 | PhoneFormat* phoneFormat = 0; |
1987 | emit tempDisableBR(true); | 1994 | emit tempDisableBR(true); |
1988 | #ifndef DESKTOP_VERSION | 1995 | #ifndef DESKTOP_VERSION |
1989 | SharpFormat* sharpFormat = 0; | 1996 | SharpFormat* sharpFormat = 0; |
1990 | if ( mode == 0 ) { // sharp | 1997 | if ( mode == 0 ) { // sharp |
1991 | sharpFormat = new SharpFormat () ; | 1998 | sharpFormat = new SharpFormat () ; |
1992 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1999 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1993 | 2000 | ||
1994 | } else | 2001 | } else |
1995 | #endif | 2002 | #endif |
1996 | if ( mode == 1 ) { // phone | 2003 | if ( mode == 1 ) { // phone |
1997 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 2004 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1998 | mSyncManager->mPhoneDevice, | 2005 | mSyncManager->mPhoneDevice, |
1999 | mSyncManager->mPhoneConnection, | 2006 | mSyncManager->mPhoneConnection, |
2000 | mSyncManager->mPhoneModel); | 2007 | mSyncManager->mPhoneModel); |
2001 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2008 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2002 | 2009 | ||
2003 | } else { | 2010 | } else { |
2004 | emit tempDisableBR(false); | 2011 | emit tempDisableBR(false); |
2005 | return; | 2012 | return; |
2006 | } | 2013 | } |
2007 | if ( loadSuccess ) { | 2014 | if ( loadSuccess ) { |
2008 | getEventViewerDialog()->setSyncMode( true ); | 2015 | getEventViewerDialog()->setSyncMode( true ); |
2009 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2016 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2010 | getEventViewerDialog()->setSyncMode( false ); | 2017 | getEventViewerDialog()->setSyncMode( false ); |
2011 | qApp->processEvents(); | 2018 | qApp->processEvents(); |
2012 | if ( syncOK ) { | 2019 | if ( syncOK ) { |
2013 | if ( mSyncManager->mWriteBackFile ) | 2020 | if ( mSyncManager->mWriteBackFile ) |
2014 | { | 2021 | { |
2015 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2022 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2016 | Incidence* inc = iL.first(); | 2023 | Incidence* inc = iL.first(); |
2017 | if ( phoneFormat ) { | 2024 | if ( phoneFormat ) { |
2018 | while ( inc ) { | 2025 | while ( inc ) { |
2019 | inc->removeID(mCurrentSyncDevice); | 2026 | inc->removeID(mCurrentSyncDevice); |
2020 | inc = iL.next(); | 2027 | inc = iL.next(); |
2021 | } | 2028 | } |
2022 | } | 2029 | } |
2023 | #ifndef DESKTOP_VERSION | 2030 | #ifndef DESKTOP_VERSION |
2024 | if ( sharpFormat ) | 2031 | if ( sharpFormat ) |
2025 | sharpFormat->save(calendar); | 2032 | sharpFormat->save(calendar); |
2026 | #endif | 2033 | #endif |
2027 | if ( phoneFormat ) | 2034 | if ( phoneFormat ) |
2028 | phoneFormat->save(calendar); | 2035 | phoneFormat->save(calendar); |
2029 | iL = calendar->rawIncidences(); | 2036 | iL = calendar->rawIncidences(); |
2030 | inc = iL.first(); | 2037 | inc = iL.first(); |
2031 | Incidence* loc; | 2038 | Incidence* loc; |
2032 | while ( inc ) { | 2039 | while ( inc ) { |
2033 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2040 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2034 | loc = mCalendar->incidence(inc->uid() ); | 2041 | loc = mCalendar->incidence(inc->uid() ); |
2035 | if ( loc ) { | 2042 | if ( loc ) { |
2036 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2043 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2037 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2044 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2038 | } | 2045 | } |
2039 | } | 2046 | } |
2040 | inc = iL.next(); | 2047 | inc = iL.next(); |
2041 | } | 2048 | } |
2042 | Incidence* lse = getLastSyncEvent(); | 2049 | Incidence* lse = getLastSyncEvent(); |
2043 | if ( lse ) { | 2050 | if ( lse ) { |
2044 | lse->setReadOnly( false ); | 2051 | lse->setReadOnly( false ); |
2045 | lse->setDescription( "" ); | 2052 | lse->setDescription( "" ); |
2046 | lse->setReadOnly( true ); | 2053 | lse->setReadOnly( true ); |
2047 | } | 2054 | } |
2048 | } | 2055 | } |
2049 | } else { | 2056 | } else { |
2050 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2057 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2051 | } | 2058 | } |
2052 | setModified( true ); | 2059 | setModified( true ); |
2053 | } else { | 2060 | } else { |
2054 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2061 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2055 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2062 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2056 | question, i18n("Ok")) ; | 2063 | question, i18n("Ok")) ; |
2057 | 2064 | ||
2058 | } | 2065 | } |
2059 | delete calendar; | 2066 | delete calendar; |
2060 | updateView(); | 2067 | updateView(); |
2061 | emit tempDisableBR(false); | 2068 | emit tempDisableBR(false); |
2062 | return ;//syncOK; | 2069 | return ;//syncOK; |
2063 | 2070 | ||
2064 | } | 2071 | } |
2065 | 2072 | ||
2066 | bool CalendarView::importBday() | 2073 | bool CalendarView::importBday() |
2067 | { | 2074 | { |
2068 | #ifndef KORG_NOKABC | 2075 | #ifndef KORG_NOKABC |
2069 | 2076 | ||
2070 | #ifdef DESKTOP_VERSION | 2077 | #ifdef DESKTOP_VERSION |
2071 | int curCal = mCalendar->defaultCalendar(); | 2078 | int curCal = mCalendar->defaultCalendar(); |
2072 | int bd = mCalEditView->getBirtdayID(); | 2079 | int bd = mCalEditView->getBirtdayID(); |
2073 | if ( bd == 0 ) | 2080 | if ( bd == 0 ) |
2074 | return false; | 2081 | return false; |
2075 | mCalendar->setDefaultCalendar( bd ); | 2082 | mCalendar->setDefaultCalendar( bd ); |
2076 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2083 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2077 | KABC::AddressBook::Iterator it; | 2084 | KABC::AddressBook::Iterator it; |
2078 | int count = 0; | 2085 | int count = 0; |
2079 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2086 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2080 | ++count; | 2087 | ++count; |
2081 | } | 2088 | } |
2082 | QProgressBar bar(count,0 ); | 2089 | QProgressBar bar(count,0 ); |
2083 | int w = 300; | 2090 | int w = 300; |
2084 | if ( QApplication::desktop()->width() < 320 ) | 2091 | if ( QApplication::desktop()->width() < 320 ) |
2085 | w = 220; | 2092 | w = 220; |
2086 | int h = bar.sizeHint().height() ; | 2093 | int h = bar.sizeHint().height() ; |
2087 | int dw = QApplication::desktop()->width(); | 2094 | int dw = QApplication::desktop()->width(); |
2088 | int dh = QApplication::desktop()->height(); | 2095 | int dh = QApplication::desktop()->height(); |
2089 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2096 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2090 | bar.show(); | 2097 | bar.show(); |
2091 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2098 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2092 | qApp->processEvents(); | 2099 | qApp->processEvents(); |
2093 | count = 0; | 2100 | count = 0; |
2094 | int addCount = 0; | 2101 | int addCount = 0; |
2095 | KCal::Attendee* a = 0; | 2102 | KCal::Attendee* a = 0; |
2096 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2103 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2097 | if ( ! bar.isVisible() ) | 2104 | if ( ! bar.isVisible() ) |
2098 | return false; | 2105 | return false; |
2099 | bar.setProgress( count++ ); | 2106 | bar.setProgress( count++ ); |
2100 | qApp->processEvents(); | 2107 | qApp->processEvents(); |
2101 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2108 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2102 | if ( (*it).birthday().date().isValid() ){ | 2109 | if ( (*it).birthday().date().isValid() ){ |
2103 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2110 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2104 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2111 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2105 | ++addCount; | 2112 | ++addCount; |
2106 | } | 2113 | } |
2107 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2114 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2108 | if ( anni.isValid() ){ | 2115 | if ( anni.isValid() ){ |
2109 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2116 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2110 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2117 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2111 | ++addCount; | 2118 | ++addCount; |
2112 | } | 2119 | } |
2113 | } | 2120 | } |
2114 | mCalendar->setDefaultCalendar( curCal ); | 2121 | mCalendar->setDefaultCalendar( curCal ); |
2115 | updateView(); | 2122 | updateView(); |
2116 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2123 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2117 | #else //DESKTOP_VERSION | 2124 | #else //DESKTOP_VERSION |
2118 | 2125 | ||
2119 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2126 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2120 | // the result should now arrive through method insertBirthdays | 2127 | // the result should now arrive through method insertBirthdays |
2121 | 2128 | ||
2122 | #endif //DESKTOP_VERSION | 2129 | #endif //DESKTOP_VERSION |
2123 | 2130 | ||
2124 | #endif //KORG_NOKABC | 2131 | #endif //KORG_NOKABC |
2125 | 2132 | ||
2126 | 2133 | ||
2127 | return true; | 2134 | return true; |
2128 | } | 2135 | } |
2129 | 2136 | ||
2130 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2137 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2131 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2138 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2132 | const QStringList& anniversaryList, const QStringList& realNameList, | 2139 | const QStringList& anniversaryList, const QStringList& realNameList, |
2133 | const QStringList& emailList, const QStringList& assembledNameList, | 2140 | const QStringList& emailList, const QStringList& assembledNameList, |
2134 | const QStringList& uidList) | 2141 | const QStringList& uidList) |
2135 | { | 2142 | { |
2136 | 2143 | ||
2137 | //qDebug("KO::CalendarView::insertBirthdays"); | 2144 | //qDebug("KO::CalendarView::insertBirthdays"); |
2138 | if (uid == this->name()) | 2145 | if (uid == this->name()) |
2139 | { | 2146 | { |
2140 | int curCal = mCalendar->defaultCalendar(); | 2147 | int curCal = mCalendar->defaultCalendar(); |
2141 | int bd = mCalEditView->getBirtdayID(); | 2148 | int bd = mCalEditView->getBirtdayID(); |
2142 | if ( bd == 0 ) | 2149 | if ( bd == 0 ) |
2143 | return; | 2150 | return; |
2144 | mCalendar->setDefaultCalendar( bd ); | 2151 | mCalendar->setDefaultCalendar( bd ); |
2145 | 2152 | ||
2146 | 2153 | ||
2147 | int count = birthdayList.count(); | 2154 | int count = birthdayList.count(); |
2148 | int addCount = 0; | 2155 | int addCount = 0; |
2149 | KCal::Attendee* a = 0; | 2156 | KCal::Attendee* a = 0; |
2150 | 2157 | ||
2151 | //qDebug("CalView 1 %i", count); | 2158 | //qDebug("CalView 1 %i", count); |
2152 | 2159 | ||
2153 | QProgressBar bar(count,0 ); | 2160 | QProgressBar bar(count,0 ); |
2154 | int w = 300; | 2161 | int w = 300; |
2155 | if ( QApplication::desktop()->width() < 320 ) | 2162 | if ( QApplication::desktop()->width() < 320 ) |
2156 | w = 220; | 2163 | w = 220; |
2157 | int h = bar.sizeHint().height() ; | 2164 | int h = bar.sizeHint().height() ; |
2158 | int dw = QApplication::desktop()->width(); | 2165 | int dw = QApplication::desktop()->width(); |
2159 | int dh = QApplication::desktop()->height(); | 2166 | int dh = QApplication::desktop()->height(); |
2160 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2167 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2161 | bar.show(); | 2168 | bar.show(); |
2162 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2169 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2163 | qApp->processEvents(); | 2170 | qApp->processEvents(); |
2164 | 2171 | ||
2165 | QDate birthday; | 2172 | QDate birthday; |
2166 | QDate anniversary; | 2173 | QDate anniversary; |
2167 | QString realName; | 2174 | QString realName; |
2168 | QString email; | 2175 | QString email; |
2169 | QString assembledName; | 2176 | QString assembledName; |
2170 | QString uid; | 2177 | QString uid; |
2171 | bool ok = true; | 2178 | bool ok = true; |
2172 | for ( int i = 0; i < count; i++) | 2179 | for ( int i = 0; i < count; i++) |
2173 | { | 2180 | { |
2174 | if ( ! bar.isVisible() ) | 2181 | if ( ! bar.isVisible() ) |
2175 | return; | 2182 | return; |
2176 | bar.setProgress( i ); | 2183 | bar.setProgress( i ); |
2177 | qApp->processEvents(); | 2184 | qApp->processEvents(); |
2178 | 2185 | ||
2179 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2186 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2180 | if (!ok) { | 2187 | if (!ok) { |
2181 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2188 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2182 | } | 2189 | } |
2183 | 2190 | ||
2184 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2191 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2185 | if (!ok) { | 2192 | if (!ok) { |
2186 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2193 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2187 | } | 2194 | } |
2188 | realName = realNameList[i]; | 2195 | realName = realNameList[i]; |
2189 | email = emailList[i]; | 2196 | email = emailList[i]; |
2190 | assembledName = assembledNameList[i]; | 2197 | assembledName = assembledNameList[i]; |
2191 | uid = uidList[i]; | 2198 | uid = uidList[i]; |
2192 | //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() ); | 2199 | //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() ); |
2193 | 2200 | ||
2194 | if ( birthday.isValid() ){ | 2201 | if ( birthday.isValid() ){ |
2195 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2202 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2196 | KCal::Attendee::ReqParticipant,uid) ; | 2203 | KCal::Attendee::ReqParticipant,uid) ; |
2197 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2204 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2198 | ++addCount; | 2205 | ++addCount; |
2199 | } | 2206 | } |
2200 | 2207 | ||
2201 | if ( anniversary.isValid() ){ | 2208 | if ( anniversary.isValid() ){ |
2202 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2209 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2203 | KCal::Attendee::ReqParticipant,uid) ; | 2210 | KCal::Attendee::ReqParticipant,uid) ; |
2204 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2211 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2205 | ++addCount; | 2212 | ++addCount; |
2206 | } | 2213 | } |
2207 | } | 2214 | } |
2208 | 2215 | ||
2209 | mCalendar->setDefaultCalendar( curCal ); | 2216 | mCalendar->setDefaultCalendar( curCal ); |
2210 | updateView(); | 2217 | updateView(); |
2211 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2218 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2212 | 2219 | ||
2213 | } | 2220 | } |
2214 | 2221 | ||
2215 | } | 2222 | } |
2216 | 2223 | ||
2217 | 2224 | ||
2218 | 2225 | ||
2219 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2226 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2220 | { | 2227 | { |
2221 | //qDebug("addAnni "); | 2228 | //qDebug("addAnni "); |
2222 | Event * ev = new Event(); | 2229 | Event * ev = new Event(); |
2223 | ev->setOrganizer(KOPrefs::instance()->email()); | 2230 | ev->setOrganizer(KOPrefs::instance()->email()); |
2224 | if ( a ) { | 2231 | if ( a ) { |
2225 | ev->addAttendee( a ); | 2232 | ev->addAttendee( a ); |
2226 | } | 2233 | } |
2227 | QString kind; | 2234 | QString kind; |
2228 | if ( birthday ) { | 2235 | if ( birthday ) { |
2229 | kind = i18n( "Birthday" ); | 2236 | kind = i18n( "Birthday" ); |
2230 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2237 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2231 | } | 2238 | } |
2232 | else { | 2239 | else { |
2233 | kind = i18n( "Anniversary" ); | 2240 | kind = i18n( "Anniversary" ); |
2234 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2241 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2235 | } | 2242 | } |
2236 | ev->setCategories( kind ); | 2243 | ev->setCategories( kind ); |
2237 | ev->setDtStart( QDateTime(date) ); | 2244 | ev->setDtStart( QDateTime(date) ); |
2238 | ev->setDtEnd( QDateTime(date) ); | 2245 | ev->setDtEnd( QDateTime(date) ); |
2239 | ev->setFloats( true ); | 2246 | ev->setFloats( true ); |
2240 | Recurrence * rec = ev->recurrence(); | 2247 | Recurrence * rec = ev->recurrence(); |
2241 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2248 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2242 | rec->addYearlyNum( date.month() ); | 2249 | rec->addYearlyNum( date.month() ); |
2243 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2250 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2244 | delete ev; | 2251 | delete ev; |
2245 | return false; | 2252 | return false; |
2246 | } | 2253 | } |
2247 | return true; | 2254 | return true; |
2248 | 2255 | ||
2249 | } | 2256 | } |
2250 | bool CalendarView::importQtopia( const QString &categories, | 2257 | bool CalendarView::importQtopia( const QString &categories, |
2251 | const QString &datebook, | 2258 | const QString &datebook, |
2252 | const QString &todolist ) | 2259 | const QString &todolist ) |
2253 | { | 2260 | { |
2254 | 2261 | ||
2255 | QtopiaFormat qtopiaFormat; | 2262 | QtopiaFormat qtopiaFormat; |
2256 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2263 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2257 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2264 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2258 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2265 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2259 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2266 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2260 | 2267 | ||
2261 | updateView(); | 2268 | updateView(); |
2262 | return true; | 2269 | return true; |
2263 | 2270 | ||
2264 | #if 0 | 2271 | #if 0 |
2265 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2272 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2266 | mCurrentSyncDevice = "qtopia-XML"; | 2273 | mCurrentSyncDevice = "qtopia-XML"; |
2267 | if ( mSyncManager->mAskForPreferences ) | 2274 | if ( mSyncManager->mAskForPreferences ) |
2268 | edit_sync_options(); | 2275 | edit_sync_options(); |
2269 | qApp->processEvents(); | 2276 | qApp->processEvents(); |
2270 | CalendarLocal* calendar = new CalendarLocal(); | 2277 | CalendarLocal* calendar = new CalendarLocal(); |
2271 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2278 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2272 | bool syncOK = false; | 2279 | bool syncOK = false; |
2273 | QtopiaFormat qtopiaFormat; | 2280 | QtopiaFormat qtopiaFormat; |
2274 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2281 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2275 | bool loadOk = true; | 2282 | bool loadOk = true; |
2276 | if ( !categories.isEmpty() ) | 2283 | if ( !categories.isEmpty() ) |
2277 | loadOk = qtopiaFormat.load( calendar, categories ); | 2284 | loadOk = qtopiaFormat.load( calendar, categories ); |
2278 | if ( loadOk && !datebook.isEmpty() ) | 2285 | if ( loadOk && !datebook.isEmpty() ) |
2279 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2286 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2280 | if ( loadOk && !todolist.isEmpty() ) | 2287 | if ( loadOk && !todolist.isEmpty() ) |
2281 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2288 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2282 | 2289 | ||
2283 | if ( loadOk ) { | 2290 | if ( loadOk ) { |
2284 | getEventViewerDialog()->setSyncMode( true ); | 2291 | getEventViewerDialog()->setSyncMode( true ); |
2285 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2292 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2286 | getEventViewerDialog()->setSyncMode( false ); | 2293 | getEventViewerDialog()->setSyncMode( false ); |
2287 | qApp->processEvents(); | 2294 | qApp->processEvents(); |
2288 | if ( syncOK ) { | 2295 | if ( syncOK ) { |
2289 | if ( mSyncManager->mWriteBackFile ) | 2296 | if ( mSyncManager->mWriteBackFile ) |
2290 | { | 2297 | { |
2291 | // write back XML file | 2298 | // write back XML file |
2292 | 2299 | ||
2293 | } | 2300 | } |
2294 | setModified( true ); | 2301 | setModified( true ); |
2295 | } | 2302 | } |
2296 | } else { | 2303 | } else { |
2297 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2304 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2298 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2305 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2299 | question, i18n("Ok")) ; | 2306 | question, i18n("Ok")) ; |
2300 | } | 2307 | } |
2301 | delete calendar; | 2308 | delete calendar; |
2302 | updateView(); | 2309 | updateView(); |
2303 | return syncOK; | 2310 | return syncOK; |
2304 | 2311 | ||
2305 | 2312 | ||
2306 | #endif | 2313 | #endif |
2307 | 2314 | ||
2308 | } | 2315 | } |
2309 | 2316 | ||
2310 | void CalendarView::setSyncEventsReadOnly() | 2317 | void CalendarView::setSyncEventsReadOnly() |
2311 | { | 2318 | { |
2312 | mCalendar->setSyncEventsReadOnly(); | 2319 | mCalendar->setSyncEventsReadOnly(); |
2313 | } | 2320 | } |
2314 | 2321 | ||
2315 | bool CalendarView::loadCalendars() | 2322 | bool CalendarView::loadCalendars() |
2316 | { | 2323 | { |
2317 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2324 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2318 | KopiCalendarFile * cal = calendars.first(); | 2325 | KopiCalendarFile * cal = calendars.first(); |
2319 | mCalendar->setDefaultCalendar( 1 ); | 2326 | mCalendar->setDefaultCalendar( 1 ); |
2320 | openCalendar( MainWindow::defaultFileName(), false ); | 2327 | openCalendar( MainWindow::defaultFileName(), false ); |
2321 | cal = calendars.next(); | 2328 | cal = calendars.next(); |
2322 | while ( cal ) { | 2329 | while ( cal ) { |
2323 | addCalendar( cal ); | 2330 | addCalendar( cal ); |
2324 | cal = calendars.next(); | 2331 | cal = calendars.next(); |
2325 | } | 2332 | } |
2326 | restoreCalendarSettings(); | 2333 | restoreCalendarSettings(); |
2327 | return true; | 2334 | return true; |
2328 | } | 2335 | } |
2329 | bool CalendarView::restoreCalendarSettings() | 2336 | bool CalendarView::restoreCalendarSettings() |
2330 | { | 2337 | { |
2331 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2338 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2332 | KopiCalendarFile * cal = calendars.first(); | 2339 | KopiCalendarFile * cal = calendars.first(); |
2333 | while ( cal ) { | 2340 | while ( cal ) { |
2334 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2341 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2335 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2342 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2336 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2343 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2337 | if ( cal->isStandard ) | 2344 | if ( cal->isStandard ) |
2338 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2345 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2339 | cal = calendars.next(); | 2346 | cal = calendars.next(); |
2340 | } | 2347 | } |
2341 | setSyncEventsReadOnly(); | 2348 | setSyncEventsReadOnly(); |
2342 | mCalendar->reInitAlarmSettings(); | 2349 | mCalendar->reInitAlarmSettings(); |
2343 | updateUnmanagedViews(); | 2350 | updateUnmanagedViews(); |
2344 | updateView(); | 2351 | updateView(); |
2345 | return true; | 2352 | return true; |
2346 | } | 2353 | } |
2347 | void CalendarView::addCalendarId( int id ) | 2354 | void CalendarView::addCalendarId( int id ) |
2348 | { | 2355 | { |
2349 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2356 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2350 | if ( cal ) | 2357 | if ( cal ) |
2351 | addCalendar( cal ); | 2358 | addCalendar( cal ); |
2352 | } | 2359 | } |
2353 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2360 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2354 | { | 2361 | { |
2355 | cal->mErrorOnLoad = false; | 2362 | cal->mErrorOnLoad = false; |
2356 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2363 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2357 | cal->mLoadDt = QDateTime::currentDateTime(); | 2364 | cal->mLoadDt = QDateTime::currentDateTime(); |
2358 | return true; | 2365 | return true; |
2359 | } | 2366 | } |
2360 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2367 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2361 | cal->mErrorOnLoad = true; | 2368 | cal->mErrorOnLoad = true; |
2362 | return false; | 2369 | return false; |
2363 | } | 2370 | } |
2364 | bool CalendarView::openCalendar(QString filename, bool merge) | 2371 | bool CalendarView::openCalendar(QString filename, bool merge) |
2365 | { | 2372 | { |
2366 | 2373 | ||
2367 | if (filename.isEmpty()) { | 2374 | if (filename.isEmpty()) { |
2368 | return false; | 2375 | return false; |
2369 | } | 2376 | } |
2370 | 2377 | ||
2371 | if (!QFile::exists(filename)) { | 2378 | if (!QFile::exists(filename)) { |
2372 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2379 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2373 | return false; | 2380 | return false; |
2374 | } | 2381 | } |
2375 | 2382 | ||
2376 | globalFlagBlockAgenda = 1; | 2383 | globalFlagBlockAgenda = 1; |
2377 | clearAllViews(); | 2384 | clearAllViews(); |
2378 | if (!merge) { | 2385 | if (!merge) { |
2379 | mViewManager->setDocumentId( filename ); | 2386 | mViewManager->setDocumentId( filename ); |
2380 | mCalendar->close(); | 2387 | mCalendar->close(); |
2381 | } | 2388 | } |
2382 | mStorage->setFileName( filename ); | 2389 | mStorage->setFileName( filename ); |
2383 | 2390 | ||
2384 | if ( mStorage->load() ) { | 2391 | if ( mStorage->load() ) { |
2385 | if ( merge ) ;//setModified( true ); | 2392 | if ( merge ) ;//setModified( true ); |
2386 | else { | 2393 | else { |
2387 | //setModified( true ); | 2394 | //setModified( true ); |
2388 | mViewManager->setDocumentId( filename ); | 2395 | mViewManager->setDocumentId( filename ); |
2389 | mDialogManager->setDocumentId( filename ); | 2396 | mDialogManager->setDocumentId( filename ); |
2390 | mTodoList->setDocumentId( filename ); | 2397 | mTodoList->setDocumentId( filename ); |
2391 | } | 2398 | } |
2392 | globalFlagBlockAgenda = 2; | 2399 | globalFlagBlockAgenda = 2; |
2393 | // if ( getLastSyncEvent() ) | 2400 | // if ( getLastSyncEvent() ) |
2394 | // getLastSyncEvent()->setReadOnly( true ); | 2401 | // getLastSyncEvent()->setReadOnly( true ); |
2395 | mCalendar->reInitAlarmSettings(); | 2402 | mCalendar->reInitAlarmSettings(); |
2396 | setSyncEventsReadOnly(); | 2403 | setSyncEventsReadOnly(); |
2397 | //updateUnmanagedViews(); | 2404 | //updateUnmanagedViews(); |
2398 | //updateView(); | 2405 | //updateView(); |
2399 | if ( filename != MainWindow::defaultFileName() ) { | 2406 | if ( filename != MainWindow::defaultFileName() ) { |
2400 | saveCalendar( MainWindow::defaultFileName() ); | 2407 | saveCalendar( MainWindow::defaultFileName() ); |
2401 | } else { | 2408 | } else { |
2402 | QFileInfo finf ( MainWindow::defaultFileName()); | 2409 | QFileInfo finf ( MainWindow::defaultFileName()); |
2403 | if ( finf.exists() ) { | 2410 | if ( finf.exists() ) { |
2404 | setLoadedFileVersion( finf.lastModified () ); | 2411 | setLoadedFileVersion( finf.lastModified () ); |
2405 | } | 2412 | } |
2406 | } | 2413 | } |
2407 | return true; | 2414 | return true; |
2408 | } else { | 2415 | } else { |
2409 | // while failing to load, the calendar object could | 2416 | // while failing to load, the calendar object could |
2410 | // have become partially populated. Clear it out. | 2417 | // have become partially populated. Clear it out. |
2411 | if ( !merge ) { | 2418 | if ( !merge ) { |
2412 | mCalendar->close(); | 2419 | mCalendar->close(); |
2413 | mViewManager->setDocumentId( filename ); | 2420 | mViewManager->setDocumentId( filename ); |
2414 | mDialogManager->setDocumentId( filename ); | 2421 | mDialogManager->setDocumentId( filename ); |
2415 | mTodoList->setDocumentId( filename ); | 2422 | mTodoList->setDocumentId( filename ); |
2416 | } | 2423 | } |
2417 | 2424 | ||
2418 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2425 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2419 | 2426 | ||
2420 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2427 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2421 | globalFlagBlockAgenda = 2; | 2428 | globalFlagBlockAgenda = 2; |
2422 | mCalendar->reInitAlarmSettings(); | 2429 | mCalendar->reInitAlarmSettings(); |
2423 | setSyncEventsReadOnly(); | 2430 | setSyncEventsReadOnly(); |
2424 | updateUnmanagedViews(); | 2431 | updateUnmanagedViews(); |
2425 | updateView(); | 2432 | updateView(); |
2426 | } | 2433 | } |
2427 | return false; | 2434 | return false; |
2428 | } | 2435 | } |
2429 | void CalendarView::mergeFile( QString fn ) | 2436 | void CalendarView::mergeFile( QString fn ) |
2430 | { | 2437 | { |
2431 | clearAllViews(); | 2438 | clearAllViews(); |
2432 | mCalendar->mergeCalendarFile( fn ); | 2439 | mCalendar->mergeCalendarFile( fn ); |
2433 | mCalendar->reInitAlarmSettings(); | 2440 | mCalendar->reInitAlarmSettings(); |
2434 | setSyncEventsReadOnly(); | 2441 | setSyncEventsReadOnly(); |
2435 | updateUnmanagedViews(); | 2442 | updateUnmanagedViews(); |
2436 | updateView(); | 2443 | updateView(); |
2437 | } | 2444 | } |
2445 | void CalendarView::mergeFileResource( QString fn ,QString resource ) | ||
2446 | { | ||
2447 | |||
2448 | if ( resource == "ALL" ) { | ||
2449 | mergeFile( fn ); | ||
2450 | return; | ||
2451 | } | ||
2452 | |||
2453 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
2454 | if ( !exclusiveResource ) { | ||
2455 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); | ||
2456 | return; | ||
2457 | } | ||
2458 | clearAllViews(); | ||
2459 | mCalendar->setCalendarRemove( exclusiveResource ); | ||
2460 | int def = mCalendar->defaultCalendar(); | ||
2461 | mCalendar->setDefaultCalendar(exclusiveResource); | ||
2462 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { | ||
2463 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); | ||
2464 | } | ||
2465 | mCalendar->setDefaultCalendar( def ); | ||
2466 | mCalendar->reInitAlarmSettings(); | ||
2467 | setSyncEventsReadOnly(); | ||
2468 | updateUnmanagedViews(); | ||
2469 | updateView(); | ||
2470 | } | ||
2438 | void CalendarView::showOpenError() | 2471 | void CalendarView::showOpenError() |
2439 | { | 2472 | { |
2440 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2473 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2441 | } | 2474 | } |
2442 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2475 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2443 | { | 2476 | { |
2444 | loadedFileVersion = dt; | 2477 | loadedFileVersion = dt; |
2445 | } | 2478 | } |
2446 | bool CalendarView::checkFileChanged(QString fn) | 2479 | bool CalendarView::checkFileChanged(QString fn) |
2447 | { | 2480 | { |
2448 | QFileInfo finf ( fn ); | 2481 | QFileInfo finf ( fn ); |
2449 | if ( !finf.exists() ) | 2482 | if ( !finf.exists() ) |
2450 | return true; | 2483 | return true; |
2451 | QDateTime dt = finf.lastModified (); | 2484 | QDateTime dt = finf.lastModified (); |
2452 | if ( dt <= loadedFileVersion ) | 2485 | if ( dt <= loadedFileVersion ) |
2453 | return false; | 2486 | return false; |
2454 | return true; | 2487 | return true; |
2455 | 2488 | ||
2456 | } | 2489 | } |
2457 | void CalendarView::watchSavedFile() | 2490 | void CalendarView::watchSavedFile() |
2458 | { | 2491 | { |
2459 | QFileInfo finf ( MainWindow::defaultFileName()); | 2492 | QFileInfo finf ( MainWindow::defaultFileName()); |
2460 | if ( !finf.exists() ) | 2493 | if ( !finf.exists() ) |
2461 | return; | 2494 | return; |
2462 | QDateTime dt = finf.lastModified (); | 2495 | QDateTime dt = finf.lastModified (); |
2463 | if ( dt < loadedFileVersion ) { | 2496 | if ( dt < loadedFileVersion ) { |
2464 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2497 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2465 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2498 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2466 | return; | 2499 | return; |
2467 | } | 2500 | } |
2468 | loadedFileVersion = dt; | 2501 | loadedFileVersion = dt; |
2469 | } | 2502 | } |
2470 | bool CalendarView::checkAllFileVersions() | 2503 | bool CalendarView::checkAllFileVersions() |
2471 | { | 2504 | { |
2472 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2505 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2473 | KopiCalendarFile * cal = calendars.first(); | 2506 | KopiCalendarFile * cal = calendars.first(); |
2474 | mCalendar->setDefaultCalendar( 1 ); | 2507 | mCalendar->setDefaultCalendar( 1 ); |
2475 | mCalendar->setDefaultCalendarEnabledOnly(); | 2508 | mCalendar->setDefaultCalendarEnabledOnly(); |
2476 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2509 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2477 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2510 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2478 | restoreCalendarSettings(); | 2511 | restoreCalendarSettings(); |
2479 | return false; | 2512 | return false; |
2480 | } | 2513 | } |
2481 | } | 2514 | } |
2482 | cal = calendars.next(); | 2515 | cal = calendars.next(); |
2483 | QDateTime storeTemp = loadedFileVersion; | 2516 | QDateTime storeTemp = loadedFileVersion; |
2484 | while ( cal ) { | 2517 | while ( cal ) { |
2485 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2518 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2486 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2519 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2487 | mCalendar->setDefaultCalendarEnabledOnly(); | 2520 | mCalendar->setDefaultCalendarEnabledOnly(); |
2488 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2521 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2489 | if ( !checkFileVersion(cal->mFileName )) { | 2522 | if ( !checkFileVersion(cal->mFileName )) { |
2490 | loadedFileVersion = storeTemp; | 2523 | loadedFileVersion = storeTemp; |
2491 | restoreCalendarSettings(); | 2524 | restoreCalendarSettings(); |
2492 | return false; | 2525 | return false; |
2493 | } | 2526 | } |
2494 | } | 2527 | } |
2495 | cal = calendars.next(); | 2528 | cal = calendars.next(); |
2496 | } | 2529 | } |
2497 | loadedFileVersion = storeTemp; | 2530 | loadedFileVersion = storeTemp; |
2498 | return true; | 2531 | return true; |
2499 | } | 2532 | } |
2500 | bool CalendarView::checkFileVersion(QString fn) | 2533 | bool CalendarView::checkFileVersion(QString fn) |
2501 | { | 2534 | { |
2502 | QFileInfo finf ( fn ); | 2535 | QFileInfo finf ( fn ); |
2503 | if ( !finf.exists() ) | 2536 | if ( !finf.exists() ) |
2504 | return true; | 2537 | return true; |
2505 | QDateTime dt = finf.lastModified (); | 2538 | QDateTime dt = finf.lastModified (); |
2506 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2539 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2507 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2540 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2508 | if ( dt <= loadedFileVersion ) | 2541 | if ( dt <= loadedFileVersion ) |
2509 | return true; | 2542 | return true; |
2510 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2543 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2511 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2544 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2512 | i18n("Sync+save")); | 2545 | i18n("Sync+save")); |
2513 | 2546 | ||
2514 | if ( km == KMessageBox::Cancel ) | 2547 | if ( km == KMessageBox::Cancel ) |
2515 | return false; | 2548 | return false; |
2516 | if ( km == KMessageBox::Yes ) | 2549 | if ( km == KMessageBox::Yes ) |
2517 | return true; | 2550 | return true; |
2518 | 2551 | ||
2519 | setSyncDevice("deleteaftersync" ); | 2552 | setSyncDevice("deleteaftersync" ); |
2520 | mSyncManager->mAskForPreferences = true; | 2553 | mSyncManager->mAskForPreferences = true; |
2521 | mSyncManager->mSyncAlgoPrefs = 3; | 2554 | mSyncManager->mSyncAlgoPrefs = 3; |
2522 | mSyncManager->mWriteBackFile = false; | 2555 | mSyncManager->mWriteBackFile = false; |
2523 | mSyncManager->mWriteBackExistingOnly = false; | 2556 | mSyncManager->mWriteBackExistingOnly = false; |
2524 | mSyncManager->mShowSyncSummary = false; | 2557 | mSyncManager->mShowSyncSummary = false; |
2558 | mMultiResourceSync = false; | ||
2525 | syncCalendar( fn, 3 ); | 2559 | syncCalendar( fn, 3 ); |
2526 | Event * e = getLastSyncEvent(); | 2560 | Event * e = getLastSyncEvent(); |
2527 | if ( e ) | 2561 | if ( e ) |
2528 | mCalendar->deleteEvent( e ); | 2562 | mCalendar->deleteEvent( e ); |
2529 | return true; | 2563 | return true; |
2530 | } | 2564 | } |
2531 | bool CalendarView::saveCalendars() | 2565 | bool CalendarView::saveCalendars() |
2532 | { | 2566 | { |
2533 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2567 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2534 | KopiCalendarFile * cal = calendars.first(); | 2568 | KopiCalendarFile * cal = calendars.first(); |
2535 | mCalendar->setDefaultCalendar( 1 ); | 2569 | mCalendar->setDefaultCalendar( 1 ); |
2536 | mCalendar->setDefaultCalendarEnabledOnly(); | 2570 | mCalendar->setDefaultCalendarEnabledOnly(); |
2537 | QString saveError; | 2571 | QString saveError; |
2538 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2572 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2539 | saveError = cal->mName +"\n"; | 2573 | saveError = cal->mName +"\n"; |
2540 | cal = calendars.next(); | 2574 | cal = calendars.next(); |
2541 | while ( cal ) { | 2575 | while ( cal ) { |
2542 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2576 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2543 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2577 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2544 | mCalendar->setDefaultCalendarEnabledOnly(); | 2578 | mCalendar->setDefaultCalendarEnabledOnly(); |
2545 | if ( saveCalendar( cal->mFileName ) ) | 2579 | if ( saveCalendar( cal->mFileName ) ) |
2546 | cal->mLoadDt = QDateTime::currentDateTime(); | 2580 | cal->mLoadDt = QDateTime::currentDateTime(); |
2547 | else | 2581 | else |
2548 | saveError += cal->mName + "\n"; | 2582 | saveError += cal->mName + "\n"; |
2549 | } | 2583 | } |
2550 | cal = calendars.next(); | 2584 | cal = calendars.next(); |
2551 | } | 2585 | } |
2552 | restoreCalendarSettings(); | 2586 | restoreCalendarSettings(); |
2553 | //saveError = "test error"; | 2587 | //saveError = "test error"; |
2554 | if ( !saveError.isEmpty() ) { | 2588 | if ( !saveError.isEmpty() ) { |
2555 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2589 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2556 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2590 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2557 | return false; | 2591 | return false; |
2558 | } | 2592 | } |
2559 | return true; | 2593 | return true; |
2560 | } | 2594 | } |
2595 | bool CalendarView::saveCalendarResource(QString filename, QString resource) | ||
2596 | { | ||
2597 | if ( resource == "ALL" ) | ||
2598 | return saveCalendar( filename ); | ||
2599 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
2600 | if ( !exclusiveResource ) { | ||
2601 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); | ||
2602 | return false; | ||
2603 | } | ||
2604 | mCalendar->setDefaultCalendar( exclusiveResource ); | ||
2605 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2606 | mCalendar->setSyncEventsEnabled(); | ||
2607 | bool res = saveCalendar( filename ); | ||
2608 | restoreCalendarSettings(); | ||
2609 | return res; | ||
2610 | |||
2611 | } | ||
2561 | bool CalendarView::saveCalendar( QString filename ) | 2612 | bool CalendarView::saveCalendar( QString filename ) |
2562 | { | 2613 | { |
2563 | 2614 | ||
2564 | // Store back all unsaved data into calendar object | 2615 | // Store back all unsaved data into calendar object |
2565 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2616 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2566 | if ( mViewManager->currentView() ) | 2617 | if ( mViewManager->currentView() ) |
2567 | mViewManager->currentView()->flushView(); | 2618 | mViewManager->currentView()->flushView(); |
2568 | 2619 | ||
2569 | 2620 | ||
2570 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2621 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2571 | mStorage->setSaveFormat( new ICalFormat() ); | 2622 | mStorage->setSaveFormat( new ICalFormat() ); |
2572 | mStorage->setFileName( filename ); | 2623 | mStorage->setFileName( filename ); |
2573 | bool success; | 2624 | bool success; |
2574 | success = mStorage->save(); | 2625 | success = mStorage->save(); |
2575 | if ( !success ) { | 2626 | if ( !success ) { |
2576 | return false; | 2627 | return false; |
2577 | } | 2628 | } |
2578 | if ( filename == MainWindow::defaultFileName() ) { | 2629 | if ( filename == MainWindow::defaultFileName() ) { |
2579 | setLoadedFileVersion( lfv ); | 2630 | setLoadedFileVersion( lfv ); |
2580 | watchSavedFile(); | 2631 | watchSavedFile(); |
2581 | } | 2632 | } |
2582 | return true; | 2633 | return true; |
2583 | } | 2634 | } |
2584 | 2635 | ||
2585 | void CalendarView::closeCalendar() | 2636 | void CalendarView::closeCalendar() |
2586 | { | 2637 | { |
2587 | 2638 | ||
2588 | // child windows no longer valid | 2639 | // child windows no longer valid |
2589 | clearAllViews(); | 2640 | clearAllViews(); |
2590 | emit closingDown(); | 2641 | emit closingDown(); |
2591 | 2642 | ||
2592 | mCalendar->close(); | 2643 | mCalendar->close(); |
2593 | setModified(false); | 2644 | setModified(false); |
2594 | updateView(); | 2645 | updateView(); |
2595 | } | 2646 | } |
2596 | 2647 | ||
2597 | void CalendarView::archiveCalendar() | 2648 | void CalendarView::archiveCalendar() |
2598 | { | 2649 | { |
2599 | mDialogManager->showArchiveDialog(); | 2650 | mDialogManager->showArchiveDialog(); |
2600 | } | 2651 | } |
2601 | 2652 | ||
2602 | 2653 | ||
2603 | void CalendarView::readSettings() | 2654 | void CalendarView::readSettings() |
2604 | { | 2655 | { |
2605 | 2656 | ||
2606 | 2657 | ||
2607 | // mViewManager->showAgendaView(); | 2658 | // mViewManager->showAgendaView(); |
2608 | QString str; | 2659 | QString str; |
2609 | //qDebug("CalendarView::readSettings() "); | 2660 | //qDebug("CalendarView::readSettings() "); |
2610 | // read settings from the KConfig, supplying reasonable | 2661 | // read settings from the KConfig, supplying reasonable |
2611 | // defaults where none are to be found | 2662 | // defaults where none are to be found |
2612 | KConfig *config = KOGlobals::config(); | 2663 | KConfig *config = KOGlobals::config(); |
2613 | #ifndef KORG_NOSPLITTER | 2664 | #ifndef KORG_NOSPLITTER |
2614 | config->setGroup("KOrganizer Geometry"); | 2665 | config->setGroup("KOrganizer Geometry"); |
2615 | 2666 | ||
2616 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2667 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2617 | if (sizes.count() != 2) { | 2668 | if (sizes.count() != 2) { |
2618 | sizes << mDateNavigator->minimumSizeHint().width(); | 2669 | sizes << mDateNavigator->minimumSizeHint().width(); |
2619 | sizes << 300; | 2670 | sizes << 300; |
2620 | } | 2671 | } |
2621 | mPanner->setSizes(sizes); | 2672 | mPanner->setSizes(sizes); |
2622 | 2673 | ||
2623 | sizes = config->readIntListEntry("Separator2"); | 2674 | sizes = config->readIntListEntry("Separator2"); |
2624 | if ( ( mResourceView && sizes.count() == 4 ) || | 2675 | if ( ( mResourceView && sizes.count() == 4 ) || |
2625 | ( !mResourceView && sizes.count() == 3 ) ) { | 2676 | ( !mResourceView && sizes.count() == 3 ) ) { |
2626 | mLeftSplitter->setSizes(sizes); | 2677 | mLeftSplitter->setSizes(sizes); |
2627 | } | 2678 | } |
2628 | #endif | 2679 | #endif |
2629 | globalFlagBlockAgenda = 1; | 2680 | globalFlagBlockAgenda = 1; |
2630 | mViewManager->showAgendaView(); | 2681 | mViewManager->showAgendaView(); |
2631 | //mViewManager->readSettings( config ); | 2682 | //mViewManager->readSettings( config ); |
2632 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2683 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2633 | readFilterSettings(config); | 2684 | readFilterSettings(config); |
2634 | 2685 | ||
2635 | #ifdef DESKTOP_VERSION | 2686 | #ifdef DESKTOP_VERSION |
2636 | config->setGroup("WidgetLayout"); | 2687 | config->setGroup("WidgetLayout"); |
2637 | QStringList list; | 2688 | QStringList list; |
2638 | list = config->readListEntry("MainLayout"); | 2689 | list = config->readListEntry("MainLayout"); |
2639 | int x,y,w,h; | 2690 | int x,y,w,h; |
2640 | if ( ! list.isEmpty() ) { | 2691 | if ( ! list.isEmpty() ) { |
2641 | x = list[0].toInt(); | 2692 | x = list[0].toInt(); |
2642 | y = list[1].toInt(); | 2693 | y = list[1].toInt(); |
2643 | w = list[2].toInt(); | 2694 | w = list[2].toInt(); |
2644 | h = list[3].toInt(); | 2695 | h = list[3].toInt(); |
2645 | KApplication::testCoords( &x,&y,&w,&h ); | 2696 | KApplication::testCoords( &x,&y,&w,&h ); |
2646 | topLevelWidget()->setGeometry(x,y,w,h); | 2697 | topLevelWidget()->setGeometry(x,y,w,h); |
2647 | 2698 | ||
2648 | } else { | 2699 | } else { |
2649 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2700 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2650 | } | 2701 | } |
2651 | list = config->readListEntry("EditEventLayout"); | 2702 | list = config->readListEntry("EditEventLayout"); |
2652 | if ( ! list.isEmpty() ) { | 2703 | if ( ! list.isEmpty() ) { |
2653 | x = list[0].toInt(); | 2704 | x = list[0].toInt(); |
2654 | y = list[1].toInt(); | 2705 | y = list[1].toInt(); |
2655 | w = list[2].toInt(); | 2706 | w = list[2].toInt(); |
2656 | h = list[3].toInt(); | 2707 | h = list[3].toInt(); |
2657 | KApplication::testCoords( &x,&y,&w,&h ); | 2708 | KApplication::testCoords( &x,&y,&w,&h ); |
2658 | mEventEditor->setGeometry(x,y,w,h); | 2709 | mEventEditor->setGeometry(x,y,w,h); |
2659 | 2710 | ||
2660 | } | 2711 | } |
2661 | list = config->readListEntry("EditTodoLayout"); | 2712 | list = config->readListEntry("EditTodoLayout"); |
2662 | if ( ! list.isEmpty() ) { | 2713 | if ( ! list.isEmpty() ) { |
2663 | x = list[0].toInt(); | 2714 | x = list[0].toInt(); |
2664 | y = list[1].toInt(); | 2715 | y = list[1].toInt(); |
2665 | w = list[2].toInt(); | 2716 | w = list[2].toInt(); |
2666 | h = list[3].toInt(); | 2717 | h = list[3].toInt(); |
2667 | KApplication::testCoords( &x,&y,&w,&h ); | 2718 | KApplication::testCoords( &x,&y,&w,&h ); |
2668 | mTodoEditor->setGeometry(x,y,w,h); | 2719 | mTodoEditor->setGeometry(x,y,w,h); |
2669 | 2720 | ||
2670 | } | 2721 | } |
2671 | list = config->readListEntry("ViewerLayout"); | 2722 | list = config->readListEntry("ViewerLayout"); |
2672 | if ( ! list.isEmpty() ) { | 2723 | if ( ! list.isEmpty() ) { |
2673 | x = list[0].toInt(); | 2724 | x = list[0].toInt(); |
2674 | y = list[1].toInt(); | 2725 | y = list[1].toInt(); |
2675 | w = list[2].toInt(); | 2726 | w = list[2].toInt(); |
2676 | h = list[3].toInt(); | 2727 | h = list[3].toInt(); |
2677 | KApplication::testCoords( &x,&y,&w,&h ); | 2728 | KApplication::testCoords( &x,&y,&w,&h ); |
2678 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2729 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2679 | } | 2730 | } |
2680 | #endif | 2731 | #endif |
2681 | config->setGroup( "Views" ); | 2732 | config->setGroup( "Views" ); |
2682 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2733 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2683 | 2734 | ||
2684 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2735 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2685 | 2736 | ||
2686 | int resetval = 0; | 2737 | int resetval = 0; |
2687 | int maxVal = 0; | 2738 | int maxVal = 0; |
2688 | if (sizes.count() != 3) { | 2739 | if (sizes.count() != 3) { |
2689 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2740 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2690 | resetval = mDateNavigator->sizeHint().width()+2; | 2741 | resetval = mDateNavigator->sizeHint().width()+2; |
2691 | } else { | 2742 | } else { |
2692 | resetval = mDateNavigator->sizeHint().height()+2; | 2743 | resetval = mDateNavigator->sizeHint().height()+2; |
2693 | } | 2744 | } |
2694 | } | 2745 | } |
2695 | if ( resetval ) { | 2746 | if ( resetval ) { |
2696 | sizes.clear(); | 2747 | sizes.clear(); |
2697 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2748 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2698 | maxVal = QApplication::desktop()->width() -10; | 2749 | maxVal = QApplication::desktop()->width() -10; |
2699 | } else { | 2750 | } else { |
2700 | maxVal = QApplication::desktop()->height()-10; | 2751 | maxVal = QApplication::desktop()->height()-10; |
2701 | } | 2752 | } |
2702 | sizes << resetval; | 2753 | sizes << resetval; |
2703 | if ( maxVal < resetval + resetval) | 2754 | if ( maxVal < resetval + resetval) |
2704 | resetval = maxVal - resetval; | 2755 | resetval = maxVal - resetval; |
2705 | sizes << resetval; | 2756 | sizes << resetval; |
2706 | sizes << 100; | 2757 | sizes << 100; |
2707 | } | 2758 | } |
2708 | mLeftFrame->setSizes(sizes); | 2759 | mLeftFrame->setSizes(sizes); |
2709 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2760 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2710 | resetval = 0; | 2761 | resetval = 0; |
2711 | maxVal = 0; | 2762 | maxVal = 0; |
2712 | if (sizes.count() != 2) { | 2763 | if (sizes.count() != 2) { |
2713 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2764 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2714 | resetval = mDateNavigator->sizeHint().width()+2; | 2765 | resetval = mDateNavigator->sizeHint().width()+2; |
2715 | } else { | 2766 | } else { |
2716 | resetval = mDateNavigator->sizeHint().height()+2; | 2767 | resetval = mDateNavigator->sizeHint().height()+2; |
2717 | } | 2768 | } |
2718 | } | 2769 | } |
2719 | if ( resetval ) { | 2770 | if ( resetval ) { |
2720 | sizes.clear(); | 2771 | sizes.clear(); |
2721 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2772 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2722 | maxVal = QApplication::desktop()->width() -10; | 2773 | maxVal = QApplication::desktop()->width() -10; |
2723 | } else { | 2774 | } else { |
2724 | maxVal = QApplication::desktop()->height()-10; | 2775 | maxVal = QApplication::desktop()->height()-10; |
2725 | } | 2776 | } |
2726 | sizes << resetval; | 2777 | sizes << resetval; |
2727 | if ( maxVal < resetval + resetval) | 2778 | if ( maxVal < resetval + resetval) |
2728 | resetval = maxVal - resetval; | 2779 | resetval = maxVal - resetval; |
2729 | sizes << resetval; | 2780 | sizes << resetval; |
2730 | } | 2781 | } |
2731 | mMainFrame->setSizes(sizes); | 2782 | mMainFrame->setSizes(sizes); |
2732 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2783 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2733 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2784 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2734 | else mNavigator->selectDates( dateCount ); | 2785 | else mNavigator->selectDates( dateCount ); |
2735 | // mViewManager->readSettings( config ); | 2786 | // mViewManager->readSettings( config ); |
2736 | updateConfig(); | 2787 | updateConfig(); |
2737 | globalFlagBlockAgenda = 2; | 2788 | globalFlagBlockAgenda = 2; |
2738 | mViewManager->readSettings( config ); | 2789 | mViewManager->readSettings( config ); |
2739 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2790 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2740 | } | 2791 | } |
2741 | 2792 | ||
2742 | void CalendarView::checkSuspendAlarm() | 2793 | void CalendarView::checkSuspendAlarm() |
2743 | { | 2794 | { |
2744 | if ( mSuspendTimer->isActive() ) { | 2795 | if ( mSuspendTimer->isActive() ) { |
2745 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2796 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2746 | } | 2797 | } |
2747 | } | 2798 | } |
2748 | void CalendarView::writeSettings() | 2799 | void CalendarView::writeSettings() |
2749 | { | 2800 | { |
2750 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2801 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2751 | 2802 | ||
2752 | KConfig *config = KOGlobals::config(); | 2803 | KConfig *config = KOGlobals::config(); |
2753 | 2804 | ||
2754 | mViewManager->writeSettings( config ); | 2805 | mViewManager->writeSettings( config ); |
2755 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2806 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2756 | mDialogManager->writeSettings( config ); | 2807 | mDialogManager->writeSettings( config ); |
2757 | //KOPrefs::instance()->usrWriteConfig(); | 2808 | //KOPrefs::instance()->usrWriteConfig(); |
2758 | KOPrefs::instance()->writeConfig(); | 2809 | KOPrefs::instance()->writeConfig(); |
2759 | 2810 | ||
2760 | writeFilterSettings(config); | 2811 | writeFilterSettings(config); |
2761 | config->setGroup( "AppRun" ); | 2812 | config->setGroup( "AppRun" ); |
2762 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2813 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2763 | int days = dt.daysTo( QDate::currentDate() ); | 2814 | int days = dt.daysTo( QDate::currentDate() ); |
2764 | dt = dt.addDays( days ); | 2815 | dt = dt.addDays( days ); |
2765 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2816 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2766 | config->writeEntry( "LatestProgramStopDays", days ); | 2817 | config->writeEntry( "LatestProgramStopDays", days ); |
2767 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2818 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2768 | //qDebug("KO: Writing stop time: %d ", secs); | 2819 | //qDebug("KO: Writing stop time: %d ", secs); |
2769 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2820 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2770 | //QDateTime latest = dt.addSecs ( secs ); | 2821 | //QDateTime latest = dt.addSecs ( secs ); |
2771 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2822 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2772 | config->setGroup( "Views" ); | 2823 | config->setGroup( "Views" ); |
2773 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2824 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2774 | 2825 | ||
2775 | #if 0 | 2826 | #if 0 |
2776 | qDebug("********************* "); | 2827 | qDebug("********************* "); |
2777 | qDebug("Testcode secsto "); | 2828 | qDebug("Testcode secsto "); |
2778 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2829 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2779 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2830 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2780 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2831 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2781 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2832 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2782 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2833 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2783 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2834 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2784 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2835 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2785 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2836 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2786 | qDebug("********************* testcode end"); | 2837 | qDebug("********************* testcode end"); |
2787 | 2838 | ||
2788 | #endif | 2839 | #endif |
2789 | 2840 | ||
2790 | QValueList<int> listINT = mLeftFrame->sizes(); | 2841 | QValueList<int> listINT = mLeftFrame->sizes(); |
2791 | config->writeEntry("Left Splitter Frame",listINT); | 2842 | config->writeEntry("Left Splitter Frame",listINT); |
2792 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2843 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2793 | config->writeEntry("Main Splitter Frame",listINT2); | 2844 | config->writeEntry("Main Splitter Frame",listINT2); |
2794 | #ifdef DESKTOP_VERSION | 2845 | #ifdef DESKTOP_VERSION |
2795 | config->setGroup("WidgetLayout"); | 2846 | config->setGroup("WidgetLayout"); |
2796 | QStringList list ;//= config->readListEntry("MainLayout"); | 2847 | QStringList list ;//= config->readListEntry("MainLayout"); |
2797 | int x,y,w,h; | 2848 | int x,y,w,h; |
2798 | QWidget* wid; | 2849 | QWidget* wid; |
2799 | wid = topLevelWidget(); | 2850 | wid = topLevelWidget(); |
2800 | x = wid->geometry().x(); | 2851 | x = wid->geometry().x(); |
2801 | y = wid->geometry().y(); | 2852 | y = wid->geometry().y(); |
2802 | w = wid->width(); | 2853 | w = wid->width(); |
2803 | h = wid->height(); | 2854 | h = wid->height(); |
2804 | list.clear(); | 2855 | list.clear(); |
2805 | list << QString::number( x ); | 2856 | list << QString::number( x ); |
2806 | list << QString::number( y ); | 2857 | list << QString::number( y ); |
2807 | list << QString::number( w ); | 2858 | list << QString::number( w ); |
2808 | list << QString::number( h ); | 2859 | list << QString::number( h ); |
2809 | config->writeEntry("MainLayout",list ); | 2860 | config->writeEntry("MainLayout",list ); |
2810 | 2861 | ||
2811 | wid = mEventEditor; | 2862 | wid = mEventEditor; |
2812 | x = wid->geometry().x(); | 2863 | x = wid->geometry().x(); |
2813 | y = wid->geometry().y(); | 2864 | y = wid->geometry().y(); |
2814 | w = wid->width(); | 2865 | w = wid->width(); |
2815 | h = wid->height(); | 2866 | h = wid->height(); |
2816 | list.clear(); | 2867 | list.clear(); |
2817 | list << QString::number( x ); | 2868 | list << QString::number( x ); |
2818 | list << QString::number( y ); | 2869 | list << QString::number( y ); |
2819 | list << QString::number( w ); | 2870 | list << QString::number( w ); |
2820 | list << QString::number( h ); | 2871 | list << QString::number( h ); |
2821 | config->writeEntry("EditEventLayout",list ); | 2872 | config->writeEntry("EditEventLayout",list ); |
2822 | 2873 | ||
2823 | wid = mTodoEditor; | 2874 | wid = mTodoEditor; |
2824 | x = wid->geometry().x(); | 2875 | x = wid->geometry().x(); |
2825 | y = wid->geometry().y(); | 2876 | y = wid->geometry().y(); |
2826 | w = wid->width(); | 2877 | w = wid->width(); |
2827 | h = wid->height(); | 2878 | h = wid->height(); |
2828 | list.clear(); | 2879 | list.clear(); |
2829 | list << QString::number( x ); | 2880 | list << QString::number( x ); |
2830 | list << QString::number( y ); | 2881 | list << QString::number( y ); |
2831 | list << QString::number( w ); | 2882 | list << QString::number( w ); |
2832 | list << QString::number( h ); | 2883 | list << QString::number( h ); |
2833 | config->writeEntry("EditTodoLayout",list ); | 2884 | config->writeEntry("EditTodoLayout",list ); |
2834 | wid = getEventViewerDialog(); | 2885 | wid = getEventViewerDialog(); |
2835 | x = wid->geometry().x(); | 2886 | x = wid->geometry().x(); |
2836 | y = wid->geometry().y(); | 2887 | y = wid->geometry().y(); |
2837 | w = wid->width(); | 2888 | w = wid->width(); |
2838 | h = wid->height(); | 2889 | h = wid->height(); |
2839 | list.clear(); | 2890 | list.clear(); |
2840 | list << QString::number( x ); | 2891 | list << QString::number( x ); |
2841 | list << QString::number( y ); | 2892 | list << QString::number( y ); |
2842 | list << QString::number( w ); | 2893 | list << QString::number( w ); |
2843 | list << QString::number( h ); | 2894 | list << QString::number( h ); |
2844 | config->writeEntry("ViewerLayout",list ); | 2895 | config->writeEntry("ViewerLayout",list ); |
2845 | wid = mDialogManager->getSearchDialog(); | 2896 | wid = mDialogManager->getSearchDialog(); |
2846 | if ( wid ) { | 2897 | if ( wid ) { |
2847 | x = wid->geometry().x(); | 2898 | x = wid->geometry().x(); |
2848 | y = wid->geometry().y(); | 2899 | y = wid->geometry().y(); |
2849 | w = wid->width(); | 2900 | w = wid->width(); |
2850 | h = wid->height(); | 2901 | h = wid->height(); |
2851 | list.clear(); | 2902 | list.clear(); |
2852 | list << QString::number( x ); | 2903 | list << QString::number( x ); |
2853 | list << QString::number( y ); | 2904 | list << QString::number( y ); |
2854 | list << QString::number( w ); | 2905 | list << QString::number( w ); |
2855 | list << QString::number( h ); | 2906 | list << QString::number( h ); |
2856 | config->writeEntry("SearchLayout",list ); | 2907 | config->writeEntry("SearchLayout",list ); |
2857 | } | 2908 | } |
2858 | #endif | 2909 | #endif |
2859 | 2910 | ||
2860 | 2911 | ||
2861 | config->sync(); | 2912 | config->sync(); |
2862 | } | 2913 | } |
2863 | 2914 | ||
2864 | void CalendarView::readFilterSettings(KConfig *config) | 2915 | void CalendarView::readFilterSettings(KConfig *config) |
2865 | { | 2916 | { |
2866 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2917 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2867 | 2918 | ||
2868 | mFilters.clear(); | 2919 | mFilters.clear(); |
2869 | 2920 | ||
2870 | config->setGroup("General"); | 2921 | config->setGroup("General"); |
2871 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2922 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2872 | 2923 | ||
2873 | QStringList::ConstIterator it = filterList.begin(); | 2924 | QStringList::ConstIterator it = filterList.begin(); |
2874 | QStringList::ConstIterator end = filterList.end(); | 2925 | QStringList::ConstIterator end = filterList.end(); |
2875 | while(it != end) { | 2926 | while(it != end) { |
2876 | // kdDebug() << " filter: " << (*it) << endl; | 2927 | // kdDebug() << " filter: " << (*it) << endl; |
2877 | 2928 | ||
2878 | CalFilter *filter; | 2929 | CalFilter *filter; |
2879 | filter = new CalFilter(*it); | 2930 | filter = new CalFilter(*it); |
2880 | config->setGroup("Filter_" + (*it).utf8()); | 2931 | config->setGroup("Filter_" + (*it).utf8()); |
2881 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2932 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2882 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2933 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2883 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2934 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2884 | mFilters.append(filter); | 2935 | mFilters.append(filter); |
2885 | 2936 | ||
2886 | ++it; | 2937 | ++it; |
2887 | } | 2938 | } |
2888 | 2939 | ||
2889 | if (mFilters.count() == 0) { | 2940 | if (mFilters.count() == 0) { |
2890 | CalFilter *filter = new CalFilter(i18n("Default")); | 2941 | CalFilter *filter = new CalFilter(i18n("Default")); |
2891 | mFilters.append(filter); | 2942 | mFilters.append(filter); |
2892 | } | 2943 | } |
2893 | mFilterView->updateFilters(); | 2944 | mFilterView->updateFilters(); |
2894 | config->setGroup("FilterView"); | 2945 | config->setGroup("FilterView"); |
2895 | 2946 | ||
2896 | mFilterView->blockSignals(true); | 2947 | mFilterView->blockSignals(true); |
2897 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2948 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2898 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2949 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2899 | mFilterView->blockSignals(false); | 2950 | mFilterView->blockSignals(false); |
2900 | // We do it manually to avoid it being done twice by the above calls | 2951 | // We do it manually to avoid it being done twice by the above calls |
2901 | updateFilter(); | 2952 | updateFilter(); |
2902 | } | 2953 | } |
2903 | 2954 | ||
2904 | void CalendarView::writeFilterSettings(KConfig *config) | 2955 | void CalendarView::writeFilterSettings(KConfig *config) |
2905 | { | 2956 | { |
2906 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2957 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2907 | 2958 | ||
2908 | QStringList filterList; | 2959 | QStringList filterList; |
2909 | 2960 | ||
2910 | CalFilter *filter = mFilters.first(); | 2961 | CalFilter *filter = mFilters.first(); |
2911 | while(filter) { | 2962 | while(filter) { |
2912 | // kdDebug() << " fn: " << filter->name() << endl; | 2963 | // kdDebug() << " fn: " << filter->name() << endl; |
2913 | filterList << filter->name(); | 2964 | filterList << filter->name(); |
2914 | config->setGroup("Filter_" + filter->name().utf8()); | 2965 | config->setGroup("Filter_" + filter->name().utf8()); |
2915 | config->writeEntry("Criteria",filter->criteria()); | 2966 | config->writeEntry("Criteria",filter->criteria()); |
2916 | config->writeEntry("CategoryList",filter->categoryList()); | 2967 | config->writeEntry("CategoryList",filter->categoryList()); |
2917 | filter = mFilters.next(); | 2968 | filter = mFilters.next(); |
2918 | } | 2969 | } |
2919 | config->setGroup("General"); | 2970 | config->setGroup("General"); |
2920 | config->writeEntry("CalendarFilters",filterList); | 2971 | config->writeEntry("CalendarFilters",filterList); |
2921 | 2972 | ||
2922 | config->setGroup("FilterView"); | 2973 | config->setGroup("FilterView"); |
2923 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2974 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2924 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2975 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2925 | } | 2976 | } |
2926 | 2977 | ||
2927 | 2978 | ||
2928 | void CalendarView::goToday() | 2979 | void CalendarView::goToday() |
2929 | { | 2980 | { |
2930 | if ( mViewManager->currentView()->isMonthView() ) | 2981 | if ( mViewManager->currentView()->isMonthView() ) |
2931 | mNavigator->selectTodayMonth(); | 2982 | mNavigator->selectTodayMonth(); |
2932 | else | 2983 | else |
2933 | mNavigator->selectToday(); | 2984 | mNavigator->selectToday(); |
2934 | } | 2985 | } |
2935 | 2986 | ||
2936 | void CalendarView::goNext() | 2987 | void CalendarView::goNext() |
2937 | { | 2988 | { |
2938 | mNavigator->selectNext(); | 2989 | mNavigator->selectNext(); |
2939 | } | 2990 | } |
2940 | 2991 | ||
2941 | void CalendarView::goPrevious() | 2992 | void CalendarView::goPrevious() |
2942 | { | 2993 | { |
2943 | mNavigator->selectPrevious(); | 2994 | mNavigator->selectPrevious(); |
2944 | } | 2995 | } |
@@ -4651,539 +4702,543 @@ void CalendarView::editFilters() | |||
4651 | { | 4702 | { |
4652 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4703 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4653 | 4704 | ||
4654 | CalFilter *filter = mFilters.first(); | 4705 | CalFilter *filter = mFilters.first(); |
4655 | while(filter) { | 4706 | while(filter) { |
4656 | filter = mFilters.next(); | 4707 | filter = mFilters.next(); |
4657 | } | 4708 | } |
4658 | 4709 | ||
4659 | mDialogManager->showFilterEditDialog(&mFilters); | 4710 | mDialogManager->showFilterEditDialog(&mFilters); |
4660 | updateFilter(); | 4711 | updateFilter(); |
4661 | } | 4712 | } |
4662 | void CalendarView::toggleFilter() | 4713 | void CalendarView::toggleFilter() |
4663 | { | 4714 | { |
4664 | if ( mLeftFrame->isHidden() ) { | 4715 | if ( mLeftFrame->isHidden() ) { |
4665 | toggleExpand(); | 4716 | toggleExpand(); |
4666 | showFilter( true ); | 4717 | showFilter( true ); |
4667 | } else | 4718 | } else |
4668 | showFilter(! mCalEditView->isVisible()); | 4719 | showFilter(! mCalEditView->isVisible()); |
4669 | } | 4720 | } |
4670 | 4721 | ||
4671 | KOFilterView *CalendarView::filterView() | 4722 | KOFilterView *CalendarView::filterView() |
4672 | { | 4723 | { |
4673 | return mFilterView; | 4724 | return mFilterView; |
4674 | } | 4725 | } |
4675 | void CalendarView::selectFilter( int fil ) | 4726 | void CalendarView::selectFilter( int fil ) |
4676 | { | 4727 | { |
4677 | mFilterView->setSelectedFilter( fil ); | 4728 | mFilterView->setSelectedFilter( fil ); |
4678 | updateUnmanagedViews(); | 4729 | updateUnmanagedViews(); |
4679 | } | 4730 | } |
4680 | void CalendarView::showFilter(bool visible) | 4731 | void CalendarView::showFilter(bool visible) |
4681 | { | 4732 | { |
4682 | #if 1 | 4733 | #if 1 |
4683 | if (visible) { | 4734 | if (visible) { |
4684 | mCalEditView->readConfig(); | 4735 | mCalEditView->readConfig(); |
4685 | mCalEditView->show(); | 4736 | mCalEditView->show(); |
4686 | QValueList<int> sizes; | 4737 | QValueList<int> sizes; |
4687 | sizes = mLeftFrame->sizes(); | 4738 | sizes = mLeftFrame->sizes(); |
4688 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4739 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4689 | sizes.clear(); | 4740 | sizes.clear(); |
4690 | sizes << 100; | 4741 | sizes << 100; |
4691 | sizes << 0; | 4742 | sizes << 0; |
4692 | sizes << 0; | 4743 | sizes << 0; |
4693 | sizes << 100; | 4744 | sizes << 100; |
4694 | mLeftFrame->setSizes(sizes); | 4745 | mLeftFrame->setSizes(sizes); |
4695 | } | 4746 | } |
4696 | #if 0 | 4747 | #if 0 |
4697 | sizes = mLeftFrame->sizes(); | 4748 | sizes = mLeftFrame->sizes(); |
4698 | int ccc = 0; | 4749 | int ccc = 0; |
4699 | while ( ccc < sizes.count()) { | 4750 | while ( ccc < sizes.count()) { |
4700 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4751 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4701 | ++ccc; | 4752 | ++ccc; |
4702 | } | 4753 | } |
4703 | #endif | 4754 | #endif |
4704 | 4755 | ||
4705 | } | 4756 | } |
4706 | else { | 4757 | else { |
4707 | mCalEditView->hide(); | 4758 | mCalEditView->hide(); |
4708 | } | 4759 | } |
4709 | #else | 4760 | #else |
4710 | if (visible) mFilterView->show(); | 4761 | if (visible) mFilterView->show(); |
4711 | else mFilterView->hide(); | 4762 | else mFilterView->hide(); |
4712 | #endif | 4763 | #endif |
4713 | } | 4764 | } |
4714 | void CalendarView::toggleFilerEnabled( ) | 4765 | void CalendarView::toggleFilerEnabled( ) |
4715 | { | 4766 | { |
4716 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4767 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4717 | if ( !mFilterView->filtersEnabled() ) | 4768 | if ( !mFilterView->filtersEnabled() ) |
4718 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4769 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4719 | updateUnmanagedViews(); | 4770 | updateUnmanagedViews(); |
4720 | 4771 | ||
4721 | } | 4772 | } |
4722 | void CalendarView::updateFilter() | 4773 | void CalendarView::updateFilter() |
4723 | { | 4774 | { |
4724 | CalFilter *filter = mFilterView->selectedFilter(); | 4775 | CalFilter *filter = mFilterView->selectedFilter(); |
4725 | if (filter) { | 4776 | if (filter) { |
4726 | QString mess; | 4777 | QString mess; |
4727 | if (mFilterView->filtersEnabled()) { | 4778 | if (mFilterView->filtersEnabled()) { |
4728 | mess = i18n("Filter selected: ")+filter->name(); | 4779 | mess = i18n("Filter selected: ")+filter->name(); |
4729 | filter->setEnabled(true); | 4780 | filter->setEnabled(true); |
4730 | } | 4781 | } |
4731 | else filter->setEnabled(false); | 4782 | else filter->setEnabled(false); |
4732 | mCalendar->setFilter(filter); | 4783 | mCalendar->setFilter(filter); |
4733 | updateView(); | 4784 | updateView(); |
4734 | if ( !mess.isEmpty() ) | 4785 | if ( !mess.isEmpty() ) |
4735 | topLevelWidget()->setCaption( mess ); | 4786 | topLevelWidget()->setCaption( mess ); |
4736 | 4787 | ||
4737 | } | 4788 | } |
4738 | emit filtersUpdated(); | 4789 | emit filtersUpdated(); |
4739 | } | 4790 | } |
4740 | 4791 | ||
4741 | void CalendarView::filterEdited() | 4792 | void CalendarView::filterEdited() |
4742 | { | 4793 | { |
4743 | mFilterView->updateFilters(); | 4794 | mFilterView->updateFilters(); |
4744 | updateFilter(); | 4795 | updateFilter(); |
4745 | writeSettings(); | 4796 | writeSettings(); |
4746 | } | 4797 | } |
4747 | 4798 | ||
4748 | 4799 | ||
4749 | void CalendarView::takeOverEvent() | 4800 | void CalendarView::takeOverEvent() |
4750 | { | 4801 | { |
4751 | Incidence *incidence = currentSelection(); | 4802 | Incidence *incidence = currentSelection(); |
4752 | 4803 | ||
4753 | if (!incidence) return; | 4804 | if (!incidence) return; |
4754 | 4805 | ||
4755 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4806 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4756 | incidence->recreate(); | 4807 | incidence->recreate(); |
4757 | incidence->setReadOnly(false); | 4808 | incidence->setReadOnly(false); |
4758 | 4809 | ||
4759 | updateView(); | 4810 | updateView(); |
4760 | } | 4811 | } |
4761 | 4812 | ||
4762 | void CalendarView::takeOverCalendar() | 4813 | void CalendarView::takeOverCalendar() |
4763 | { | 4814 | { |
4764 | // TODO: Create Calendar::allIncidences() function and use it here | 4815 | // TODO: Create Calendar::allIncidences() function and use it here |
4765 | 4816 | ||
4766 | clearAllViews(); | 4817 | clearAllViews(); |
4767 | QPtrList<Event> events = mCalendar->events(); | 4818 | QPtrList<Event> events = mCalendar->events(); |
4768 | for(uint i=0; i<events.count(); ++i) { | 4819 | for(uint i=0; i<events.count(); ++i) { |
4769 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4820 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4770 | events.at(i)->recreate(); | 4821 | events.at(i)->recreate(); |
4771 | events.at(i)->setReadOnly(false); | 4822 | events.at(i)->setReadOnly(false); |
4772 | } | 4823 | } |
4773 | 4824 | ||
4774 | QPtrList<Todo> todos = mCalendar->todos(); | 4825 | QPtrList<Todo> todos = mCalendar->todos(); |
4775 | for(uint i=0; i<todos.count(); ++i) { | 4826 | for(uint i=0; i<todos.count(); ++i) { |
4776 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4827 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4777 | todos.at(i)->recreate(); | 4828 | todos.at(i)->recreate(); |
4778 | todos.at(i)->setReadOnly(false); | 4829 | todos.at(i)->setReadOnly(false); |
4779 | } | 4830 | } |
4780 | 4831 | ||
4781 | QPtrList<Journal> journals = mCalendar->journals(); | 4832 | QPtrList<Journal> journals = mCalendar->journals(); |
4782 | for(uint i=0; i<journals.count(); ++i) { | 4833 | for(uint i=0; i<journals.count(); ++i) { |
4783 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4834 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4784 | journals.at(i)->recreate(); | 4835 | journals.at(i)->recreate(); |
4785 | journals.at(i)->setReadOnly(false); | 4836 | journals.at(i)->setReadOnly(false); |
4786 | } | 4837 | } |
4787 | 4838 | ||
4788 | updateView(); | 4839 | updateView(); |
4789 | } | 4840 | } |
4790 | 4841 | ||
4791 | void CalendarView::showIntro() | 4842 | void CalendarView::showIntro() |
4792 | { | 4843 | { |
4793 | kdDebug() << "To be implemented." << endl; | 4844 | kdDebug() << "To be implemented." << endl; |
4794 | } | 4845 | } |
4795 | 4846 | ||
4796 | QWidgetStack *CalendarView::viewStack() | 4847 | QWidgetStack *CalendarView::viewStack() |
4797 | { | 4848 | { |
4798 | return mRightFrame; | 4849 | return mRightFrame; |
4799 | } | 4850 | } |
4800 | 4851 | ||
4801 | QWidget *CalendarView::leftFrame() | 4852 | QWidget *CalendarView::leftFrame() |
4802 | { | 4853 | { |
4803 | return ( QWidget *)mLeftFrame; | 4854 | return ( QWidget *)mLeftFrame; |
4804 | } | 4855 | } |
4805 | 4856 | ||
4806 | DateNavigator *CalendarView::dateNavigator() | 4857 | DateNavigator *CalendarView::dateNavigator() |
4807 | { | 4858 | { |
4808 | return mNavigator; | 4859 | return mNavigator; |
4809 | } | 4860 | } |
4810 | 4861 | ||
4811 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4862 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4812 | { | 4863 | { |
4813 | return mDateNavigator->navigatorView(); | 4864 | return mDateNavigator->navigatorView(); |
4814 | } | 4865 | } |
4815 | void CalendarView::toggleDateNavigatorWidget() | 4866 | void CalendarView::toggleDateNavigatorWidget() |
4816 | { | 4867 | { |
4817 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4868 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4818 | 4869 | ||
4819 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4870 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4820 | mDateNavigator->hide(); | 4871 | mDateNavigator->hide(); |
4821 | else | 4872 | else |
4822 | mDateNavigator->show(); | 4873 | mDateNavigator->show(); |
4823 | } | 4874 | } |
4824 | void CalendarView::addView(KOrg::BaseView *view) | 4875 | void CalendarView::addView(KOrg::BaseView *view) |
4825 | { | 4876 | { |
4826 | mViewManager->addView(view); | 4877 | mViewManager->addView(view); |
4827 | } | 4878 | } |
4828 | 4879 | ||
4829 | void CalendarView::showView(KOrg::BaseView *view) | 4880 | void CalendarView::showView(KOrg::BaseView *view) |
4830 | { | 4881 | { |
4831 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4882 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4832 | } | 4883 | } |
4833 | 4884 | ||
4834 | Incidence *CalendarView::currentSelection() | 4885 | Incidence *CalendarView::currentSelection() |
4835 | { | 4886 | { |
4836 | return mViewManager->currentSelection(); | 4887 | return mViewManager->currentSelection(); |
4837 | } | 4888 | } |
4838 | void CalendarView::toggleAllDaySize() | 4889 | void CalendarView::toggleAllDaySize() |
4839 | { | 4890 | { |
4840 | /* | 4891 | /* |
4841 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4892 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4842 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4893 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4843 | else | 4894 | else |
4844 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4895 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4845 | */ | 4896 | */ |
4846 | viewManager()->agendaView()->toggleAllDay(); | 4897 | viewManager()->agendaView()->toggleAllDay(); |
4847 | } | 4898 | } |
4848 | void CalendarView::toggleExpand() | 4899 | void CalendarView::toggleExpand() |
4849 | { | 4900 | { |
4850 | // if ( mLeftFrame->isHidden() ) { | 4901 | // if ( mLeftFrame->isHidden() ) { |
4851 | // mLeftFrame->show(); | 4902 | // mLeftFrame->show(); |
4852 | // emit calendarViewExpanded( false ); | 4903 | // emit calendarViewExpanded( false ); |
4853 | // } else { | 4904 | // } else { |
4854 | // mLeftFrame->hide(); | 4905 | // mLeftFrame->hide(); |
4855 | // emit calendarViewExpanded( true ); | 4906 | // emit calendarViewExpanded( true ); |
4856 | // } | 4907 | // } |
4857 | //qDebug(" CalendarView::toggleExpand()"); | 4908 | //qDebug(" CalendarView::toggleExpand()"); |
4858 | globalFlagBlockAgenda = 1; | 4909 | globalFlagBlockAgenda = 1; |
4859 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4910 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4860 | globalFlagBlockAgenda = 5; | 4911 | globalFlagBlockAgenda = 5; |
4861 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4912 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4862 | //mViewManager->showView( 0, true ); | 4913 | //mViewManager->showView( 0, true ); |
4863 | } | 4914 | } |
4864 | 4915 | ||
4865 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4916 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4866 | { | 4917 | { |
4867 | setModified( modified ); | 4918 | setModified( modified ); |
4868 | } | 4919 | } |
4869 | 4920 | ||
4870 | Todo *CalendarView::selectedTodo() | 4921 | Todo *CalendarView::selectedTodo() |
4871 | { | 4922 | { |
4872 | Incidence *incidence = currentSelection(); | 4923 | Incidence *incidence = currentSelection(); |
4873 | if ( incidence && incidence->typeID() == todoID ) { | 4924 | if ( incidence && incidence->typeID() == todoID ) { |
4874 | return static_cast<Todo *>( incidence ); | 4925 | return static_cast<Todo *>( incidence ); |
4875 | } | 4926 | } |
4876 | 4927 | ||
4877 | incidence = mTodoList->selectedIncidences().first(); | 4928 | incidence = mTodoList->selectedIncidences().first(); |
4878 | if ( incidence && incidence->typeID() == todoID ) { | 4929 | if ( incidence && incidence->typeID() == todoID ) { |
4879 | return static_cast<Todo *>( incidence ); | 4930 | return static_cast<Todo *>( incidence ); |
4880 | } | 4931 | } |
4881 | 4932 | ||
4882 | return 0; | 4933 | return 0; |
4883 | } | 4934 | } |
4884 | 4935 | ||
4885 | void CalendarView::showIncidence() | 4936 | void CalendarView::showIncidence() |
4886 | { | 4937 | { |
4887 | mViewerCallerIsSearchDialog = false; | 4938 | mViewerCallerIsSearchDialog = false; |
4888 | Incidence *incidence = currentSelection(); | 4939 | Incidence *incidence = currentSelection(); |
4889 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4940 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4890 | if ( incidence ) { | 4941 | if ( incidence ) { |
4891 | ShowIncidenceVisitor v; | 4942 | ShowIncidenceVisitor v; |
4892 | v.act( incidence, this ); | 4943 | v.act( incidence, this ); |
4893 | } | 4944 | } |
4894 | } | 4945 | } |
4895 | void CalendarView::editIncidenceDescription() | 4946 | void CalendarView::editIncidenceDescription() |
4896 | { | 4947 | { |
4897 | mFlagEditDescription = true; | 4948 | mFlagEditDescription = true; |
4898 | editIncidence(); | 4949 | editIncidence(); |
4899 | mFlagEditDescription = false; | 4950 | mFlagEditDescription = false; |
4900 | } | 4951 | } |
4901 | void CalendarView::editIncidence() | 4952 | void CalendarView::editIncidence() |
4902 | { | 4953 | { |
4903 | // qDebug("editIncidence() "); | 4954 | // qDebug("editIncidence() "); |
4904 | Incidence *incidence = currentSelection(); | 4955 | Incidence *incidence = currentSelection(); |
4905 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4956 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4906 | if ( incidence ) { | 4957 | if ( incidence ) { |
4907 | EditIncidenceVisitor v; | 4958 | EditIncidenceVisitor v; |
4908 | v.act( incidence, this ); | 4959 | v.act( incidence, this ); |
4909 | } | 4960 | } |
4910 | } | 4961 | } |
4911 | 4962 | ||
4912 | void CalendarView::deleteIncidence() | 4963 | void CalendarView::deleteIncidence() |
4913 | { | 4964 | { |
4914 | Incidence *incidence = currentSelection(); | 4965 | Incidence *incidence = currentSelection(); |
4915 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4966 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4916 | if ( incidence ) { | 4967 | if ( incidence ) { |
4917 | deleteIncidence(incidence); | 4968 | deleteIncidence(incidence); |
4918 | } | 4969 | } |
4919 | } | 4970 | } |
4920 | void CalendarView::showIncidence(QString uid) | 4971 | void CalendarView::showIncidence(QString uid) |
4921 | { | 4972 | { |
4922 | Incidence *inc = mCalendar->incidence( uid ); | 4973 | Incidence *inc = mCalendar->incidence( uid ); |
4923 | if ( inc ) | 4974 | if ( inc ) |
4924 | showIncidence( inc ); | 4975 | showIncidence( inc ); |
4925 | } | 4976 | } |
4926 | void CalendarView::showIncidence(Incidence *incidence) | 4977 | void CalendarView::showIncidence(Incidence *incidence) |
4927 | { | 4978 | { |
4928 | mViewerCallerIsSearchDialog = false; | 4979 | mViewerCallerIsSearchDialog = false; |
4929 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4980 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4930 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4981 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4931 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4982 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4932 | mViewerCallerIsSearchDialog = true; | 4983 | mViewerCallerIsSearchDialog = true; |
4933 | } | 4984 | } |
4934 | } | 4985 | } |
4935 | if ( incidence ) { | 4986 | if ( incidence ) { |
4936 | ShowIncidenceVisitor v; | 4987 | ShowIncidenceVisitor v; |
4937 | v.act( incidence, this ); | 4988 | v.act( incidence, this ); |
4938 | } | 4989 | } |
4939 | } | 4990 | } |
4940 | 4991 | ||
4941 | void CalendarView::editIncidence(Incidence *incidence) | 4992 | void CalendarView::editIncidence(Incidence *incidence) |
4942 | { | 4993 | { |
4943 | if ( incidence ) { | 4994 | if ( incidence ) { |
4944 | 4995 | ||
4945 | EditIncidenceVisitor v; | 4996 | EditIncidenceVisitor v; |
4946 | v.act( incidence, this ); | 4997 | v.act( incidence, this ); |
4947 | 4998 | ||
4948 | } | 4999 | } |
4949 | } | 5000 | } |
4950 | 5001 | ||
4951 | void CalendarView::deleteIncidence(Incidence *incidence) | 5002 | void CalendarView::deleteIncidence(Incidence *incidence) |
4952 | { | 5003 | { |
4953 | //qDebug(" CalendarView::deleteIncidence "); | 5004 | //qDebug(" CalendarView::deleteIncidence "); |
4954 | if ( incidence == 0 ) { | 5005 | if ( incidence == 0 ) { |
4955 | updateView(); | 5006 | updateView(); |
4956 | emit updateSearchDialog(); | 5007 | emit updateSearchDialog(); |
4957 | return; | 5008 | return; |
4958 | } | 5009 | } |
4959 | if ( incidence ) { | 5010 | if ( incidence ) { |
4960 | DeleteIncidenceVisitor v; | 5011 | DeleteIncidenceVisitor v; |
4961 | v.act( incidence, this ); | 5012 | v.act( incidence, this ); |
4962 | } | 5013 | } |
4963 | } | 5014 | } |
4964 | 5015 | ||
4965 | 5016 | ||
4966 | void CalendarView::lookForOutgoingMessages() | 5017 | void CalendarView::lookForOutgoingMessages() |
4967 | { | 5018 | { |
4968 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 5019 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4969 | ogd->loadMessages(); | 5020 | ogd->loadMessages(); |
4970 | } | 5021 | } |
4971 | 5022 | ||
4972 | void CalendarView::lookForIncomingMessages() | 5023 | void CalendarView::lookForIncomingMessages() |
4973 | { | 5024 | { |
4974 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 5025 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4975 | icd->retrieve(); | 5026 | icd->retrieve(); |
4976 | } | 5027 | } |
4977 | 5028 | ||
4978 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 5029 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4979 | { | 5030 | { |
4980 | bool deleteTodo = true; | 5031 | bool deleteTodo = true; |
4981 | QPtrList<Incidence> subTodos; | 5032 | QPtrList<Incidence> subTodos; |
4982 | Incidence *aTodo; | 5033 | Incidence *aTodo; |
4983 | subTodos = t->relations(); | 5034 | subTodos = t->relations(); |
4984 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 5035 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4985 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 5036 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4986 | deleteTodo = false; | 5037 | deleteTodo = false; |
4987 | } | 5038 | } |
4988 | if ( deleteTodo ) { | 5039 | if ( deleteTodo ) { |
4989 | if ( t->isCompleted() && !t->doesRecur()) { | 5040 | if ( t->isCompleted() && !t->doesRecur()) { |
4990 | checkExternalId( t ); | 5041 | checkExternalId( t ); |
4991 | mCalendar->deleteTodo( t ); | 5042 | mCalendar->deleteTodo( t ); |
4992 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 5043 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4993 | } | 5044 | } |
4994 | else | 5045 | else |
4995 | deleteTodo = false; | 5046 | deleteTodo = false; |
4996 | } | 5047 | } |
4997 | return deleteTodo; | 5048 | return deleteTodo; |
4998 | 5049 | ||
4999 | } | 5050 | } |
5000 | void CalendarView::purgeCompleted() | 5051 | void CalendarView::purgeCompleted() |
5001 | { | 5052 | { |
5002 | int result = KMessageBox::warningContinueCancel(this, | 5053 | int result = KMessageBox::warningContinueCancel(this, |
5003 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5054 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5004 | 5055 | ||
5005 | if (result == KMessageBox::Continue) { | 5056 | if (result == KMessageBox::Continue) { |
5006 | 5057 | ||
5007 | QPtrList<Todo> todoCal; | 5058 | QPtrList<Todo> todoCal; |
5008 | QPtrList<Todo> rootTodos; | 5059 | QPtrList<Todo> rootTodos; |
5009 | //QPtrList<Incidence> rel; | 5060 | //QPtrList<Incidence> rel; |
5010 | Todo *aTodo; | 5061 | Todo *aTodo; |
5011 | todoCal = calendar()->todos(); | 5062 | todoCal = calendar()->todos(); |
5012 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5063 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5013 | if ( !aTodo->relatedTo() ) | 5064 | if ( !aTodo->relatedTo() ) |
5014 | rootTodos.append( aTodo ); | 5065 | rootTodos.append( aTodo ); |
5015 | } | 5066 | } |
5016 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5067 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5017 | removeCompletedSubTodos( aTodo ); | 5068 | removeCompletedSubTodos( aTodo ); |
5018 | } | 5069 | } |
5019 | 5070 | ||
5020 | updateView(); | 5071 | updateView(); |
5021 | } | 5072 | } |
5022 | } | 5073 | } |
5023 | 5074 | ||
5024 | void CalendarView::slotCalendarChanged() | 5075 | void CalendarView::slotCalendarChanged() |
5025 | { | 5076 | { |
5026 | ; | 5077 | ; |
5027 | } | 5078 | } |
5028 | 5079 | ||
5029 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5080 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5030 | { | 5081 | { |
5031 | //qDebug("CalendarView::keyPressEvent "); | 5082 | //qDebug("CalendarView::keyPressEvent "); |
5032 | e->ignore(); | 5083 | e->ignore(); |
5033 | } | 5084 | } |
5034 | 5085 | ||
5086 | void CalendarView::multiResourceSyncStart( bool start ) | ||
5087 | { | ||
5088 | mMultiResourceSync = start; | ||
5035 | 5089 | ||
5090 | } | ||
5036 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 5091 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5037 | { | 5092 | { |
5038 | 5093 | ||
5039 | if ( manager != mSyncManager) | 5094 | if ( manager != mSyncManager) |
5040 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5095 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5041 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5096 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5042 | qDebug("KO: SyncKDE request detected!"); | 5097 | qDebug("KO: SyncKDE request detected!"); |
5043 | } | 5098 | } |
5044 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5099 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5045 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5100 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5046 | if ( !resource.isEmpty() ) { | 5101 | if ( !resource.isEmpty() ) { |
5047 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 5102 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
5048 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | 5103 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); |
5049 | 5104 | ||
5050 | if ( !exclusiveSyncResource ) { | 5105 | if ( !exclusiveSyncResource ) { |
5051 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | 5106 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); |
5052 | return false; | 5107 | return false; |
5053 | } | 5108 | } |
5054 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | 5109 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); |
5055 | mCalendar->setDefaultCalendarEnabledOnly(); | 5110 | mCalendar->setDefaultCalendarEnabledOnly(); |
5056 | } | 5111 | } |
5057 | bool result = syncCalendar( filename, mode ); | 5112 | bool result = syncCalendar( filename, mode ); |
5058 | if ( !resource.isEmpty() ) | 5113 | if ( !resource.isEmpty() ) |
5059 | restoreCalendarSettings(); | 5114 | restoreCalendarSettings(); |
5060 | return result; | 5115 | return result; |
5061 | } | 5116 | } |
5062 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5117 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5063 | { | 5118 | { |
5064 | //mSyncManager = manager; | 5119 | //mSyncManager = manager; |
5065 | if ( manager != mSyncManager) | 5120 | if ( manager != mSyncManager) |
5066 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5121 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5067 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5122 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5068 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5123 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5069 | if ( resource == "sharp" ) | 5124 | if ( resource == "sharp" ) |
5070 | syncExternal( 0 ); | 5125 | syncExternal( 0 ); |
5071 | if ( resource == "phone" ) | 5126 | if ( resource == "phone" ) |
5072 | syncExternal( 1 ); | 5127 | syncExternal( 1 ); |
5073 | // pending setmodified | 5128 | // pending setmodified |
5074 | return true; | 5129 | return true; |
5075 | } | 5130 | } |
5076 | void CalendarView::setSyncManager(KSyncManager* manager) | 5131 | void CalendarView::setSyncManager(KSyncManager* manager) |
5077 | { | 5132 | { |
5078 | mSyncManager = manager; | 5133 | mSyncManager = manager; |
5079 | } | 5134 | } |
5080 | 5135 | ||
5081 | void CalendarView::removeSyncInfo( QString syncProfile) | 5136 | void CalendarView::removeSyncInfo( QString syncProfile) |
5082 | { | 5137 | { |
5083 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5138 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5084 | mCalendar->removeSyncInfo( syncProfile ); | 5139 | mCalendar->removeSyncInfo( syncProfile ); |
5085 | 5140 | ||
5086 | } | 5141 | } |
5087 | 5142 | ||
5088 | void CalendarView::undo_delete() | 5143 | void CalendarView::undo_delete() |
5089 | { | 5144 | { |
5090 | //qDebug("undo_delete() "); | 5145 | //qDebug("undo_delete() "); |
5091 | Incidence* undo = mCalendar->undoIncidence(); | 5146 | Incidence* undo = mCalendar->undoIncidence(); |
5092 | if ( !undo ) { | 5147 | if ( !undo ) { |
5093 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5148 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5094 | i18n("KO/Pi")); | 5149 | i18n("KO/Pi")); |
5095 | return; | 5150 | return; |
5096 | } | 5151 | } |
5097 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5152 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5098 | i18n("\nAre you sure you want\nto restore this?"), | 5153 | i18n("\nAre you sure you want\nto restore this?"), |
5099 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5154 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5100 | mCalendar->undoDeleteIncidence(); | 5155 | mCalendar->undoDeleteIncidence(); |
5101 | updateView(); | 5156 | updateView(); |
5102 | } | 5157 | } |
5103 | } | 5158 | } |
5104 | 5159 | ||
5105 | void CalendarView::slotViewerClosed() | 5160 | void CalendarView::slotViewerClosed() |
5106 | { | 5161 | { |
5107 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5162 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5108 | } | 5163 | } |
5109 | 5164 | ||
5110 | void CalendarView::resetFocus() | 5165 | void CalendarView::resetFocus() |
5111 | { | 5166 | { |
5112 | if ( mViewerCallerIsSearchDialog ) { | 5167 | if ( mViewerCallerIsSearchDialog ) { |
5113 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5168 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5114 | mDialogManager->getSearchDialog()->raise(); | 5169 | mDialogManager->getSearchDialog()->raise(); |
5115 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5170 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5116 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5171 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5117 | } else | 5172 | } else |
5118 | mViewerCallerIsSearchDialog = false; | 5173 | mViewerCallerIsSearchDialog = false; |
5119 | } | 5174 | } |
5120 | if ( !mViewerCallerIsSearchDialog ) { | 5175 | if ( !mViewerCallerIsSearchDialog ) { |
5121 | //mViewManager->currentView()->setFocus(); | 5176 | //mViewManager->currentView()->setFocus(); |
5122 | //qDebug("sssssssssssssssset focus "); | 5177 | //qDebug("sssssssssssssssset focus "); |
5123 | topLevelWidget()->raise(); | 5178 | topLevelWidget()->raise(); |
5124 | setActiveWindow(); | 5179 | setActiveWindow(); |
5125 | //setFocus(); | 5180 | //setFocus(); |
5126 | } | 5181 | } |
5127 | mViewerCallerIsSearchDialog = false; | 5182 | mViewerCallerIsSearchDialog = false; |
5128 | } | 5183 | } |
5129 | 5184 | ||
5130 | void CalendarView::showNextAlarms() | 5185 | void CalendarView::showNextAlarms() |
5131 | { | 5186 | { |
5132 | QString message; | 5187 | QString message; |
5133 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5188 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5134 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5189 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5135 | QString sum = mCalendar->nextSummary(); | 5190 | QString sum = mCalendar->nextSummary(); |
5136 | QDateTime nextA = mNextAlarmDateTime; | 5191 | QDateTime nextA = mNextAlarmDateTime; |
5137 | QDateTime cur = QDateTime::currentDateTime(); | 5192 | QDateTime cur = QDateTime::currentDateTime(); |
5138 | int secs = cur.secsTo( nextA ); | 5193 | int secs = cur.secsTo( nextA ); |
5139 | int min = secs /60; | 5194 | int min = secs /60; |
5140 | int hours = min /60; | 5195 | int hours = min /60; |
5141 | min = min % 60; | 5196 | min = min % 60; |
5142 | int days = hours /24; | 5197 | int days = hours /24; |
5143 | hours = hours % 24; | 5198 | hours = hours % 24; |
5144 | 5199 | ||
5145 | //message = i18n("The next alarm is in:\n"); | 5200 | //message = i18n("The next alarm is in:\n"); |
5146 | if ( days > 1 ) | 5201 | if ( days > 1 ) |
5147 | message += i18n("%1 days\n").arg( days ); | 5202 | message += i18n("%1 days\n").arg( days ); |
5148 | else if ( days == 1 ) | 5203 | else if ( days == 1 ) |
5149 | message += i18n("1 day\n"); | 5204 | message += i18n("1 day\n"); |
5150 | if ( hours > 1 ) | 5205 | if ( hours > 1 ) |
5151 | message += i18n("%1 hours\n").arg( hours ); | 5206 | message += i18n("%1 hours\n").arg( hours ); |
5152 | else if ( hours == 1 ) | 5207 | else if ( hours == 1 ) |
5153 | message += i18n("1 hour\n"); | 5208 | message += i18n("1 hour\n"); |
5154 | if ( min > 1 ) | 5209 | if ( min > 1 ) |
5155 | message += i18n("%1 minutes\n").arg( min ); | 5210 | message += i18n("%1 minutes\n").arg( min ); |
5156 | else if ( min == 1 ) | 5211 | else if ( min == 1 ) |
5157 | message += i18n("1 minute\n"); | 5212 | message += i18n("1 minute\n"); |
5158 | if ( message.isEmpty() ) | 5213 | if ( message.isEmpty() ) |
5159 | message = i18n("The next alarm is in\nless than one minute!"); | 5214 | message = i18n("The next alarm is in\nless than one minute!"); |
5160 | else | 5215 | else |
5161 | message = i18n("The next alarm is in:\n") + message; | 5216 | message = i18n("The next alarm is in:\n") + message; |
5162 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5217 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5163 | } else { | 5218 | } else { |
5164 | message = i18n("There is no next alarm."); | 5219 | message = i18n("There is no next alarm."); |
5165 | 5220 | ||
5166 | } | 5221 | } |
5167 | #ifdef DESKTOP_VERSION | 5222 | #ifdef DESKTOP_VERSION |
5168 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5223 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5169 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5224 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5170 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5225 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5171 | } | 5226 | } |
5172 | 5227 | ||
5173 | #endif | 5228 | #endif |
5174 | KMessageBox::information( this, message); | 5229 | KMessageBox::information( this, message); |
5175 | } | 5230 | } |
5176 | 5231 | ||
5177 | void CalendarView::displayCalendarInfo( int id ) | 5232 | void CalendarView::displayCalendarInfo( int id ) |
5178 | { | 5233 | { |
5179 | int e, t,j; | 5234 | int e, t,j; |
5180 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 5235 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
5181 | QString name = kkf->mName; | 5236 | QString name = kkf->mName; |
5182 | mCalendar->getIncidenceCount( id, e, t, j ); | 5237 | mCalendar->getIncidenceCount( id, e, t, j ); |
5183 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 5238 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
5184 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); | 5239 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); |
5185 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); | 5240 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); |
5186 | KMessageBox::information( this, mess ); | 5241 | KMessageBox::information( this, mess ); |
5187 | 5242 | ||
5188 | 5243 | ||
5189 | } | 5244 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index f85b6a3..60b1276 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,675 +1,679 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <qscrollbar.h> | 33 | #include <qscrollbar.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qtopia/ir.h> | 35 | #include <qtopia/ir.h> |
36 | #else | 36 | #else |
37 | #define Ir char | 37 | #define Ir char |
38 | #endif | 38 | #endif |
39 | #include <libkcal/calendar.h> | 39 | #include <libkcal/calendar.h> |
40 | #include <libkcal/scheduler.h> | 40 | #include <libkcal/scheduler.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <KDGanttMinimizeSplitter.h> | 43 | #include <KDGanttMinimizeSplitter.h> |
44 | 44 | ||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | 141 | void mergeFile( QString fn ); |
142 | void mergeFileResource( QString fn ,QString res); | ||
142 | 143 | ||
143 | signals: | 144 | signals: |
144 | void save (); | 145 | void save (); |
145 | void saveStopTimer (); | 146 | void saveStopTimer (); |
146 | void tempDisableBR(bool); | 147 | void tempDisableBR(bool); |
147 | /** This todo has been modified */ | 148 | /** This todo has been modified */ |
148 | void todoModified(Todo *, int); | 149 | void todoModified(Todo *, int); |
149 | 150 | ||
150 | /** when change is made to options dialog, the topwidget will catch this | 151 | /** when change is made to options dialog, the topwidget will catch this |
151 | * and emit this signal which notifies all widgets which have registered | 152 | * and emit this signal which notifies all widgets which have registered |
152 | * for notification to update their settings. */ | 153 | * for notification to update their settings. */ |
153 | void configChanged(); | 154 | void configChanged(); |
154 | /** emitted when the topwidget is closing down, so that any attached | 155 | /** emitted when the topwidget is closing down, so that any attached |
155 | child windows can also close. */ | 156 | child windows can also close. */ |
156 | void closingDown(); | 157 | void closingDown(); |
157 | /** emitted right before we die */ | 158 | /** emitted right before we die */ |
158 | void closed(QWidget *); | 159 | void closed(QWidget *); |
159 | 160 | ||
160 | /** Emitted when state of modified flag changes */ | 161 | /** Emitted when state of modified flag changes */ |
161 | void modifiedChanged(bool); | 162 | void modifiedChanged(bool); |
162 | void signalmodified(); | 163 | void signalmodified(); |
163 | 164 | ||
164 | /** Emitted when state of read-only flag changes */ | 165 | /** Emitted when state of read-only flag changes */ |
165 | void readOnlyChanged(bool); | 166 | void readOnlyChanged(bool); |
166 | 167 | ||
167 | /** Emitted when the unit of navigation changes */ | 168 | /** Emitted when the unit of navigation changes */ |
168 | void changeNavStringPrev(const QString &); | 169 | void changeNavStringPrev(const QString &); |
169 | void changeNavStringNext(const QString &); | 170 | void changeNavStringNext(const QString &); |
170 | 171 | ||
171 | /** Emitted when state of events selection has changed and user is organizer*/ | 172 | /** Emitted when state of events selection has changed and user is organizer*/ |
172 | void organizerEventsSelected(bool); | 173 | void organizerEventsSelected(bool); |
173 | /** Emitted when state of events selection has changed and user is attendee*/ | 174 | /** Emitted when state of events selection has changed and user is attendee*/ |
174 | void groupEventsSelected(bool); | 175 | void groupEventsSelected(bool); |
175 | /** | 176 | /** |
176 | Emitted when an incidence gets selected. If the selection is cleared the | 177 | Emitted when an incidence gets selected. If the selection is cleared the |
177 | signal is emitted with 0 as argument. | 178 | signal is emitted with 0 as argument. |
178 | */ | 179 | */ |
179 | void incidenceSelected( Incidence * ); | 180 | void incidenceSelected( Incidence * ); |
180 | /** Emitted, when a todoitem is selected or deselected. */ | 181 | /** Emitted, when a todoitem is selected or deselected. */ |
181 | void todoSelected( bool ); | 182 | void todoSelected( bool ); |
182 | 183 | ||
183 | /** | 184 | /** |
184 | Emitted, when clipboard content changes. Parameter indicates if paste | 185 | Emitted, when clipboard content changes. Parameter indicates if paste |
185 | is possible or not. | 186 | is possible or not. |
186 | */ | 187 | */ |
187 | void pasteEnabled(bool); | 188 | void pasteEnabled(bool); |
188 | 189 | ||
189 | /** Emitted, when the number of incoming messages has changed. */ | 190 | /** Emitted, when the number of incoming messages has changed. */ |
190 | void numIncomingChanged(int); | 191 | void numIncomingChanged(int); |
191 | 192 | ||
192 | /** Emitted, when the number of outgoing messages has changed. */ | 193 | /** Emitted, when the number of outgoing messages has changed. */ |
193 | void numOutgoingChanged(int); | 194 | void numOutgoingChanged(int); |
194 | 195 | ||
195 | /** Send status message, which can e.g. be displayed in the status bar. */ | 196 | /** Send status message, which can e.g. be displayed in the status bar. */ |
196 | void statusMessage(const QString &); | 197 | void statusMessage(const QString &); |
197 | 198 | ||
198 | void calendarViewExpanded( bool ); | 199 | void calendarViewExpanded( bool ); |
199 | void updateSearchDialog(); | 200 | void updateSearchDialog(); |
200 | void filtersUpdated(); | 201 | void filtersUpdated(); |
201 | 202 | ||
202 | 203 | ||
203 | public slots: | 204 | public slots: |
205 | void multiResourceSyncStart( bool ); | ||
204 | void displayCalendarInfo( int id ); | 206 | void displayCalendarInfo( int id ); |
205 | void nextConflict( bool all, bool allday ); | 207 | void nextConflict( bool all, bool allday ); |
206 | void conflictAll(); | 208 | void conflictAll(); |
207 | void conflictAllday(); | 209 | void conflictAllday(); |
208 | void conflictNotAll(); | 210 | void conflictNotAll(); |
209 | void setCalReadOnly( int id, bool readO ); | 211 | void setCalReadOnly( int id, bool readO ); |
210 | void checkAlarms(); | 212 | void checkAlarms(); |
211 | void checkFiles(); | 213 | void checkFiles(); |
212 | void slotprintSelInc(); | 214 | void slotprintSelInc(); |
213 | void showNextAlarms(); | 215 | void showNextAlarms(); |
214 | void showOpenError(); | 216 | void showOpenError(); |
215 | void watchSavedFile(); | 217 | void watchSavedFile(); |
216 | void recheckTimerAlarm(); | 218 | void recheckTimerAlarm(); |
217 | void checkNextTimerAlarm(); | 219 | void checkNextTimerAlarm(); |
218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 220 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 221 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 222 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
221 | 223 | ||
222 | /** options dialog made a changed to the configuration. we catch this | 224 | /** options dialog made a changed to the configuration. we catch this |
223 | * and notify all widgets which need to update their configuration. */ | 225 | * and notify all widgets which need to update their configuration. */ |
224 | void updateConfig(); | 226 | void updateConfig(); |
225 | 227 | ||
226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 228 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
227 | const QStringList& anniversaryList, const QStringList& realNameList, | 229 | const QStringList& anniversaryList, const QStringList& realNameList, |
228 | const QStringList& emailList, const QStringList& assembledNameList, | 230 | const QStringList& emailList, const QStringList& assembledNameList, |
229 | const QStringList& uidList); | 231 | const QStringList& uidList); |
230 | 232 | ||
231 | /** | 233 | /** |
232 | Load calendar from file \a filename. If \a merge is true, load | 234 | Load calendar from file \a filename. If \a merge is true, load |
233 | calendar into existing one, if it is false, clear calendar, before | 235 | calendar into existing one, if it is false, clear calendar, before |
234 | loading. Return true, if calendar could be successfully loaded. | 236 | loading. Return true, if calendar could be successfully loaded. |
235 | */ | 237 | */ |
236 | bool openCalendar(QString filename, bool merge=false); | 238 | bool openCalendar(QString filename, bool merge=false); |
237 | bool loadCalendars(); | 239 | bool loadCalendars(); |
238 | bool saveCalendars(); | 240 | bool saveCalendars(); |
239 | bool restoreCalendarSettings(); | 241 | bool restoreCalendarSettings(); |
240 | bool addCalendar( KopiCalendarFile * ); | 242 | bool addCalendar( KopiCalendarFile * ); |
241 | void addCalendarId( int id ); | 243 | void addCalendarId( int id ); |
242 | bool syncCalendar(QString filename,int mode = 0 ); | 244 | bool syncCalendar(QString filename,int mode = 0 ); |
243 | 245 | ||
244 | /** | 246 | /** |
245 | Save calendar data to file. Return true if calendar could be | 247 | Save calendar data to file. Return true if calendar could be |
246 | successfully saved. | 248 | successfully saved. |
247 | */ | 249 | */ |
248 | bool saveCalendar(QString filename); | 250 | bool saveCalendar(QString filename); |
251 | bool saveCalendarResource(QString filename, QString resource); | ||
249 | 252 | ||
250 | /** | 253 | /** |
251 | Close calendar. Clear calendar data and reset views to display an empty | 254 | Close calendar. Clear calendar data and reset views to display an empty |
252 | calendar. | 255 | calendar. |
253 | */ | 256 | */ |
254 | void closeCalendar(); | 257 | void closeCalendar(); |
255 | 258 | ||
256 | /** Archive old events of calendar */ | 259 | /** Archive old events of calendar */ |
257 | void archiveCalendar(); | 260 | void archiveCalendar(); |
258 | 261 | ||
259 | void showIncidence(); | 262 | void showIncidence(); |
260 | void editIncidence(); | 263 | void editIncidence(); |
261 | void editIncidenceDescription(); | 264 | void editIncidenceDescription(); |
262 | void deleteIncidence(); | 265 | void deleteIncidence(); |
263 | void cloneIncidence(); | 266 | void cloneIncidence(); |
264 | void moveIncidence(); | 267 | void moveIncidence(); |
265 | void beamIncidence(); | 268 | void beamIncidence(); |
266 | void toggleCancelIncidence(); | 269 | void toggleCancelIncidence(); |
267 | 270 | ||
268 | /** create an editeventwin with supplied date/time, and if bool is true, | 271 | /** create an editeventwin with supplied date/time, and if bool is true, |
269 | * make the event take all day. */ | 272 | * make the event take all day. */ |
270 | void newEvent(QDateTime, QDateTime, bool allDay ); | 273 | void newEvent(QDateTime, QDateTime, bool allDay ); |
271 | void newEvent(QDateTime, QDateTime); | 274 | void newEvent(QDateTime, QDateTime); |
272 | void newEvent(QDateTime fh); | 275 | void newEvent(QDateTime fh); |
273 | void newEvent(QDate dt); | 276 | void newEvent(QDate dt); |
274 | /** create new event without having a date hint. Takes current date as | 277 | /** create new event without having a date hint. Takes current date as |
275 | default hint. */ | 278 | default hint. */ |
276 | void newEvent(); | 279 | void newEvent(); |
277 | void newFloatingEvent(); | 280 | void newFloatingEvent(); |
278 | 281 | ||
279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 282 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
280 | void showIncidence(Incidence *); | 283 | void showIncidence(Incidence *); |
281 | void showIncidence(QString uid); | 284 | void showIncidence(QString uid); |
282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 285 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
283 | void editIncidence(Incidence *); | 286 | void editIncidence(Incidence *); |
284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 287 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
285 | void deleteIncidence(Incidence *); | 288 | void deleteIncidence(Incidence *); |
286 | void cloneIncidence(Incidence *); | 289 | void cloneIncidence(Incidence *); |
287 | void cancelIncidence(Incidence *); | 290 | void cancelIncidence(Incidence *); |
288 | /** Create an editor for the supplied event. */ | 291 | /** Create an editor for the supplied event. */ |
289 | void editEvent(Event *); | 292 | void editEvent(Event *); |
290 | /** Delete the supplied event. */ | 293 | /** Delete the supplied event. */ |
291 | void deleteEvent(Event *); | 294 | void deleteEvent(Event *); |
292 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 295 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
293 | found. */ | 296 | found. */ |
294 | bool deleteEvent(const QString &uid); | 297 | bool deleteEvent(const QString &uid); |
295 | /** Create a read-only viewer dialog for the supplied event. */ | 298 | /** Create a read-only viewer dialog for the supplied event. */ |
296 | void showEvent(Event *); | 299 | void showEvent(Event *); |
297 | 300 | ||
298 | void editJournal(Journal *); | 301 | void editJournal(Journal *); |
299 | void showJournal(Journal *); | 302 | void showJournal(Journal *); |
300 | void deleteJournal(Journal *); | 303 | void deleteJournal(Journal *); |
301 | /** Create an editor dialog for a todo */ | 304 | /** Create an editor dialog for a todo */ |
302 | void editTodo(Todo *); | 305 | void editTodo(Todo *); |
303 | /** Create a read-only viewer dialog for the supplied todo */ | 306 | /** Create a read-only viewer dialog for the supplied todo */ |
304 | void showTodo(Todo *); | 307 | void showTodo(Todo *); |
305 | /** create new todo */ | 308 | /** create new todo */ |
306 | void newTodo(); | 309 | void newTodo(); |
307 | void newTodoDateTime(QDateTime, bool allday); | 310 | void newTodoDateTime(QDateTime, bool allday); |
308 | /** create new todo with a parent todo */ | 311 | /** create new todo with a parent todo */ |
309 | void newSubTodo(); | 312 | void newSubTodo(); |
310 | /** create new todo with a parent todo */ | 313 | /** create new todo with a parent todo */ |
311 | void newSubTodo(Todo *); | 314 | void newSubTodo(Todo *); |
312 | /** Delete todo */ | 315 | /** Delete todo */ |
313 | void deleteTodo(Todo *); | 316 | void deleteTodo(Todo *); |
314 | 317 | ||
315 | 318 | ||
316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 319 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
317 | * emitted as result. */ | 320 | * emitted as result. */ |
318 | void checkClipboard(); | 321 | void checkClipboard(); |
319 | 322 | ||
320 | /** using the KConfig associated with the kapp variable, read in the | 323 | /** using the KConfig associated with the kapp variable, read in the |
321 | * settings from the config file. | 324 | * settings from the config file. |
322 | */ | 325 | */ |
323 | void readSettings(); | 326 | void readSettings(); |
324 | 327 | ||
325 | /** write current state to config file. */ | 328 | /** write current state to config file. */ |
326 | void writeSettings(); | 329 | void writeSettings(); |
327 | 330 | ||
328 | /** read settings for calendar filters */ | 331 | /** read settings for calendar filters */ |
329 | void readFilterSettings(KConfig *config); | 332 | void readFilterSettings(KConfig *config); |
330 | 333 | ||
331 | /** write settings for calendar filters */ | 334 | /** write settings for calendar filters */ |
332 | void writeFilterSettings(KConfig *config); | 335 | void writeFilterSettings(KConfig *config); |
333 | 336 | ||
334 | /** passes on the message that an event has changed to the currently | 337 | /** passes on the message that an event has changed to the currently |
335 | * activated view so that it can make appropriate display changes. */ | 338 | * activated view so that it can make appropriate display changes. */ |
336 | void changeEventDisplay(Event *, int); | 339 | void changeEventDisplay(Event *, int); |
337 | void changeIncidenceDisplay(Incidence *, int); | 340 | void changeIncidenceDisplay(Incidence *, int); |
338 | void changeTodoDisplay(Todo *, int); | 341 | void changeTodoDisplay(Todo *, int); |
339 | 342 | ||
340 | void eventAdded(Event *); | 343 | void eventAdded(Event *); |
341 | void eventChanged(Event *); | 344 | void eventChanged(Event *); |
342 | void eventToBeDeleted(Event *); | 345 | void eventToBeDeleted(Event *); |
343 | void eventDeleted(); | 346 | void eventDeleted(); |
344 | 347 | ||
345 | void todoAdded(Todo *); | 348 | void todoAdded(Todo *); |
346 | void todoChanged(Todo *); | 349 | void todoChanged(Todo *); |
347 | void todoToBeDeleted(Todo *); | 350 | void todoToBeDeleted(Todo *); |
348 | void todoDeleted(); | 351 | void todoDeleted(); |
349 | 352 | ||
350 | void updateView(const QDate &start, const QDate &end); | 353 | void updateView(const QDate &start, const QDate &end); |
351 | void updateView(); | 354 | void updateView(); |
352 | void clearAllViews(); | 355 | void clearAllViews(); |
353 | 356 | ||
354 | /** Full update of visible todo views */ | 357 | /** Full update of visible todo views */ |
355 | void updateTodoViews(); | 358 | void updateTodoViews(); |
356 | 359 | ||
357 | void updateUnmanagedViews(); | 360 | void updateUnmanagedViews(); |
358 | 361 | ||
359 | /** cut the current appointment to the clipboard */ | 362 | /** cut the current appointment to the clipboard */ |
360 | void edit_cut(); | 363 | void edit_cut(); |
361 | 364 | ||
362 | /** copy the current appointment(s) to the clipboard */ | 365 | /** copy the current appointment(s) to the clipboard */ |
363 | void edit_copy(); | 366 | void edit_copy(); |
364 | 367 | ||
365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 368 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
366 | void edit_paste(); | 369 | void edit_paste(); |
367 | 370 | ||
368 | /** edit viewing and configuration options. */ | 371 | /** edit viewing and configuration options. */ |
369 | void edit_options(); | 372 | void edit_options(); |
370 | void edit_global_options(); | 373 | void edit_global_options(); |
371 | /** | 374 | /** |
372 | Functions for printing, previewing a print, and setting up printing | 375 | Functions for printing, previewing a print, and setting up printing |
373 | parameters. | 376 | parameters. |
374 | */ | 377 | */ |
375 | void print(); | 378 | void print(); |
376 | void printSetup(); | 379 | void printSetup(); |
377 | void printPreview(); | 380 | void printPreview(); |
378 | 381 | ||
379 | /** Export as iCalendar file */ | 382 | /** Export as iCalendar file */ |
380 | bool exportICalendar(); | 383 | bool exportICalendar(); |
381 | bool exportICalendar( QString fn ); | 384 | bool exportICalendar( QString fn ); |
382 | 385 | ||
383 | /** Export as vCalendar file */ | 386 | /** Export as vCalendar file */ |
384 | bool exportVCalendar( QString fn); | 387 | bool exportVCalendar( QString fn); |
385 | 388 | ||
386 | /** pop up a dialog to show an existing appointment. */ | 389 | /** pop up a dialog to show an existing appointment. */ |
387 | void appointment_show(); | 390 | void appointment_show(); |
388 | /** | 391 | /** |
389 | * pop up an Appointment Dialog to edit an existing appointment.Get | 392 | * pop up an Appointment Dialog to edit an existing appointment.Get |
390 | * information on the appointment from the list of unique IDs that is | 393 | * information on the appointment from the list of unique IDs that is |
391 | * currently in the View, called currIds. | 394 | * currently in the View, called currIds. |
392 | */ | 395 | */ |
393 | void appointment_edit(); | 396 | void appointment_edit(); |
394 | /** | 397 | /** |
395 | * pop up dialog confirming deletion of currently selected event in the | 398 | * pop up dialog confirming deletion of currently selected event in the |
396 | * View. | 399 | * View. |
397 | */ | 400 | */ |
398 | void appointment_delete(); | 401 | void appointment_delete(); |
399 | 402 | ||
400 | /** mails the currently selected event to a particular user as a vCalendar | 403 | /** mails the currently selected event to a particular user as a vCalendar |
401 | attachment. */ | 404 | attachment. */ |
402 | void action_mail(); | 405 | void action_mail(); |
403 | 406 | ||
404 | /* frees a subtodo from it's relation */ | 407 | /* frees a subtodo from it's relation */ |
405 | void todo_unsub( Todo * ); | 408 | void todo_unsub( Todo * ); |
406 | void todo_resub( Todo * parent, Todo * sub ); | 409 | void todo_resub( Todo * parent, Todo * sub ); |
407 | 410 | ||
408 | /** Take ownership of selected event. */ | 411 | /** Take ownership of selected event. */ |
409 | void takeOverEvent(); | 412 | void takeOverEvent(); |
410 | 413 | ||
411 | /** Take ownership of all events in calendar. */ | 414 | /** Take ownership of all events in calendar. */ |
412 | void takeOverCalendar(); | 415 | void takeOverCalendar(); |
413 | 416 | ||
414 | /** query whether or not the calendar is "dirty". */ | 417 | /** query whether or not the calendar is "dirty". */ |
415 | bool isModified(); | 418 | bool isModified(); |
416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 419 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
417 | void setModified(bool modified=true); | 420 | void setModified(bool modified=true); |
418 | 421 | ||
419 | /** query if the calendar is read-only. */ | 422 | /** query if the calendar is read-only. */ |
420 | bool isReadOnly(); | 423 | bool isReadOnly(); |
421 | /** set state of calendar to read-only */ | 424 | /** set state of calendar to read-only */ |
422 | void setReadOnly(bool readOnly=true); | 425 | void setReadOnly(bool readOnly=true); |
423 | 426 | ||
424 | void eventUpdated(Incidence *); | 427 | void eventUpdated(Incidence *); |
425 | 428 | ||
426 | /* iTIP scheduling actions */ | 429 | /* iTIP scheduling actions */ |
427 | void schedule_publish(Incidence *incidence = 0); | 430 | void schedule_publish(Incidence *incidence = 0); |
428 | void schedule_request(Incidence *incidence = 0); | 431 | void schedule_request(Incidence *incidence = 0); |
429 | void schedule_refresh(Incidence *incidence = 0); | 432 | void schedule_refresh(Incidence *incidence = 0); |
430 | void schedule_cancel(Incidence *incidence = 0); | 433 | void schedule_cancel(Incidence *incidence = 0); |
431 | void schedule_add(Incidence *incidence = 0); | 434 | void schedule_add(Incidence *incidence = 0); |
432 | void schedule_reply(Incidence *incidence = 0); | 435 | void schedule_reply(Incidence *incidence = 0); |
433 | void schedule_counter(Incidence *incidence = 0); | 436 | void schedule_counter(Incidence *incidence = 0); |
434 | void schedule_declinecounter(Incidence *incidence = 0); | 437 | void schedule_declinecounter(Incidence *incidence = 0); |
435 | void schedule_publish_freebusy(int daysToPublish = 30); | 438 | void schedule_publish_freebusy(int daysToPublish = 30); |
436 | 439 | ||
437 | void openAddressbook(); | 440 | void openAddressbook(); |
438 | 441 | ||
439 | void editFilters(); | 442 | void editFilters(); |
440 | void toggleFilerEnabled(); | 443 | void toggleFilerEnabled(); |
441 | QPtrList<CalFilter> filters(); | 444 | QPtrList<CalFilter> filters(); |
442 | void toggleFilter(); | 445 | void toggleFilter(); |
443 | void showFilter(bool visible); | 446 | void showFilter(bool visible); |
444 | void updateFilter(); | 447 | void updateFilter(); |
445 | void filterEdited(); | 448 | void filterEdited(); |
446 | void selectFilter( int ); | 449 | void selectFilter( int ); |
447 | KOFilterView *filterView(); | 450 | KOFilterView *filterView(); |
448 | 451 | ||
449 | void showIntro(); | 452 | void showIntro(); |
450 | 453 | ||
451 | /** Move the curdatepient view date to today */ | 454 | /** Move the curdatepient view date to today */ |
452 | void goToday(); | 455 | void goToday(); |
453 | 456 | ||
454 | /** Move to the next date(s) in the current view */ | 457 | /** Move to the next date(s) in the current view */ |
455 | void goNext(); | 458 | void goNext(); |
456 | 459 | ||
457 | /** Move to the previous date(s) in the current view */ | 460 | /** Move to the previous date(s) in the current view */ |
458 | void goPrevious(); | 461 | void goPrevious(); |
459 | /** Move to the next date(s) in the current view */ | 462 | /** Move to the next date(s) in the current view */ |
460 | void goNextMonth(); | 463 | void goNextMonth(); |
461 | 464 | ||
462 | /** Move to the previous date(s) in the current view */ | 465 | /** Move to the previous date(s) in the current view */ |
463 | void goPreviousMonth(); | 466 | void goPreviousMonth(); |
464 | 467 | ||
465 | void toggleExpand(); | 468 | void toggleExpand(); |
466 | void toggleDateNavigatorWidget(); | 469 | void toggleDateNavigatorWidget(); |
467 | void toggleAllDaySize(); | 470 | void toggleAllDaySize(); |
468 | 471 | ||
469 | /** Look for new messages in the inbox */ | 472 | /** Look for new messages in the inbox */ |
470 | void lookForIncomingMessages(); | 473 | void lookForIncomingMessages(); |
471 | /** Look for new messages in the outbox */ | 474 | /** Look for new messages in the outbox */ |
472 | void lookForOutgoingMessages(); | 475 | void lookForOutgoingMessages(); |
473 | 476 | ||
474 | void processMainViewSelection( Incidence * ); | 477 | void processMainViewSelection( Incidence * ); |
475 | void processTodoListSelection( Incidence * ); | 478 | void processTodoListSelection( Incidence * ); |
476 | 479 | ||
477 | void processIncidenceSelection( Incidence * ); | 480 | void processIncidenceSelection( Incidence * ); |
478 | 481 | ||
479 | void purgeCompleted(); | 482 | void purgeCompleted(); |
480 | bool removeCompletedSubTodos( Todo* ); | 483 | bool removeCompletedSubTodos( Todo* ); |
481 | void slotCalendarChanged(); | 484 | void slotCalendarChanged(); |
482 | bool importBday(); | 485 | bool importBday(); |
483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 486 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
484 | bool importQtopia( const QString &categoriesFile, | 487 | bool importQtopia( const QString &categoriesFile, |
485 | const QString &datebookFile, | 488 | const QString &datebookFile, |
486 | const QString &tasklistFile ); | 489 | const QString &tasklistFile ); |
487 | void syncExternal( int mode ); | 490 | void syncExternal( int mode ); |
488 | void slotSelectPickerDate( QDate ) ; | 491 | void slotSelectPickerDate( QDate ) ; |
489 | void showDatePicker() ; | 492 | void showDatePicker() ; |
490 | void showDatePickerPopup() ; | 493 | void showDatePickerPopup() ; |
491 | void moveIncidence(Incidence *) ; | 494 | void moveIncidence(Incidence *) ; |
492 | void beamIncidence(Incidence *) ; | 495 | void beamIncidence(Incidence *) ; |
493 | void beamCalendar() ; | 496 | void beamCalendar() ; |
494 | void beamFilteredCalendar() ; | 497 | void beamFilteredCalendar() ; |
495 | void beamIncidenceList(QPtrList<Incidence>) ; | 498 | void beamIncidenceList(QPtrList<Incidence>) ; |
496 | void manageCategories(); | 499 | void manageCategories(); |
497 | void editCategories(); | 500 | void editCategories(); |
498 | int addCategories(); | 501 | int addCategories(); |
499 | void removeCategories(); | 502 | void removeCategories(); |
500 | void setSyncDevice( QString ); | 503 | void setSyncDevice( QString ); |
501 | void setSyncName( QString ); | 504 | void setSyncName( QString ); |
502 | void showDay( QDate ); | 505 | void showDay( QDate ); |
503 | void undo_delete(); | 506 | void undo_delete(); |
504 | protected slots: | 507 | protected slots: |
505 | void resetFocus(); | 508 | void resetFocus(); |
506 | void scrollBarValue(int); | 509 | void scrollBarValue(int); |
507 | void slotViewerClosed(); | 510 | void slotViewerClosed(); |
508 | void timerAlarm(); | 511 | void timerAlarm(); |
509 | void suspendAlarm(); | 512 | void suspendAlarm(); |
510 | void beamDone( Ir *ir ); | 513 | void beamDone( Ir *ir ); |
511 | /** Select a view or adapt the current view to display the specified dates. */ | 514 | /** Select a view or adapt the current view to display the specified dates. */ |
512 | void showDates( const KCal::DateList & ); | 515 | void showDates( const KCal::DateList & ); |
513 | void selectWeekNum ( int ); | 516 | void selectWeekNum ( int ); |
514 | void checkConflictForEvent(); | 517 | void checkConflictForEvent(); |
515 | 518 | ||
516 | public: | 519 | public: |
517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); | 520 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); |
518 | // show a standard warning | 521 | // show a standard warning |
519 | // returns KMsgBox::yesNoCancel() | 522 | // returns KMsgBox::yesNoCancel() |
520 | int msgCalModified(); | 523 | int msgCalModified(); |
521 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); | 524 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); |
522 | 525 | ||
523 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 526 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
524 | virtual void removeSyncInfo( QString syncProfile); | 527 | virtual void removeSyncInfo( QString syncProfile); |
525 | void setSyncManager(KSyncManager* manager); | 528 | void setSyncManager(KSyncManager* manager); |
526 | void setLoadedFileVersion(QDateTime); | 529 | void setLoadedFileVersion(QDateTime); |
527 | bool checkFileVersion(QString fn); | 530 | bool checkFileVersion(QString fn); |
528 | bool checkAllFileVersions(); | 531 | bool checkAllFileVersions(); |
529 | bool checkFileChanged(QString fn); | 532 | bool checkFileChanged(QString fn); |
530 | Event* getLastSyncEvent(); | 533 | Event* getLastSyncEvent(); |
531 | /** Adapt navigation units correpsonding to step size of navigation of the | 534 | /** Adapt navigation units correpsonding to step size of navigation of the |
532 | * current view. | 535 | * current view. |
533 | */ | 536 | */ |
534 | void adaptNavigationUnits(); | 537 | void adaptNavigationUnits(); |
535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 538 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 539 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
537 | //Attendee* getYourAttendee(Event *event); | 540 | //Attendee* getYourAttendee(Event *event); |
538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 541 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
539 | void setScrollBarStep(int val ); | 542 | void setScrollBarStep(int val ); |
540 | 543 | ||
541 | protected: | 544 | protected: |
545 | bool mMultiResourceSync; | ||
542 | Event *mConflictingEvent; | 546 | Event *mConflictingEvent; |
543 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 547 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
544 | 548 | ||
545 | // returns KMsgBox::OKCandel() | 549 | // returns KMsgBox::OKCandel() |
546 | int msgItemDelete(const QString name); | 550 | int msgItemDelete(const QString name); |
547 | void showEventEditor(); | 551 | void showEventEditor(); |
548 | void showTodoEditor(); | 552 | void showTodoEditor(); |
549 | Todo *selectedTodo(); | 553 | Todo *selectedTodo(); |
550 | private: | 554 | private: |
551 | #ifdef DESKTOP_VERSION | 555 | #ifdef DESKTOP_VERSION |
552 | QScrollBar * mDateScrollBar; | 556 | QScrollBar * mDateScrollBar; |
553 | #endif | 557 | #endif |
554 | bool flag_blockConflict; | 558 | bool flag_blockConflict; |
555 | bool flag_blockScrollBar; | 559 | bool flag_blockScrollBar; |
556 | bool flag_checkFileFirsttime; | 560 | bool flag_checkFileFirsttime; |
557 | bool flag_clearallviewsEventDisplay; | 561 | bool flag_clearallviewsEventDisplay; |
558 | bool flag_clearallviewsupdateView; | 562 | bool flag_clearallviewsupdateView; |
559 | QDateTime mNextAlarmDateTime; | 563 | QDateTime mNextAlarmDateTime; |
560 | bool mViewerCallerIsSearchDialog; | 564 | bool mViewerCallerIsSearchDialog; |
561 | bool mBlockShowDates; | 565 | bool mBlockShowDates; |
562 | KSyncManager* mSyncManager; | 566 | KSyncManager* mSyncManager; |
563 | AlarmDialog * mAlarmDialog; | 567 | AlarmDialog * mAlarmDialog; |
564 | QString mAlarmNotification; | 568 | QString mAlarmNotification; |
565 | QString mSuspendAlarmNotification; | 569 | QString mSuspendAlarmNotification; |
566 | QTimer* mSuspendTimer; | 570 | QTimer* mSuspendTimer; |
567 | QTimer* mAlarmTimer; | 571 | QTimer* mAlarmTimer; |
568 | QTimer* mRecheckAlarmTimer; | 572 | QTimer* mRecheckAlarmTimer; |
569 | void computeAlarm( QString ); | 573 | void computeAlarm( QString ); |
570 | void startAlarm( QString, QString ); | 574 | void startAlarm( QString, QString ); |
571 | void setSyncEventsReadOnly(); | 575 | void setSyncEventsReadOnly(); |
572 | 576 | ||
573 | QDateTime loadedFileVersion; | 577 | QDateTime loadedFileVersion; |
574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 578 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
575 | void checkExternalId( Incidence * inc ); | 579 | void checkExternalId( Incidence * inc ); |
576 | int mGlobalSyncMode; | 580 | int mGlobalSyncMode; |
577 | QString mCurrentSyncDevice; | 581 | QString mCurrentSyncDevice; |
578 | QString mCurrentSyncName; | 582 | QString mCurrentSyncName; |
579 | void init(); | 583 | void init(); |
580 | int mDatePickerMode; | 584 | int mDatePickerMode; |
581 | bool mFlagEditDescription; | 585 | bool mFlagEditDescription; |
582 | QDateTime mLastCalendarSync; | 586 | QDateTime mLastCalendarSync; |
583 | void createPrinter(); | 587 | void createPrinter(); |
584 | 588 | ||
585 | void calendarModified( bool, Calendar * ); | 589 | void calendarModified( bool, Calendar * ); |
586 | 590 | ||
587 | CalPrinter *mCalPrinter; | 591 | CalPrinter *mCalPrinter; |
588 | 592 | ||
589 | QSplitter *mPanner; | 593 | QSplitter *mPanner; |
590 | QSplitter *mLeftSplitter; | 594 | QSplitter *mLeftSplitter; |
591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 595 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
592 | QWidgetStack *mRightFrame; | 596 | QWidgetStack *mRightFrame; |
593 | 597 | ||
594 | KDatePicker* mDatePicker; | 598 | KDatePicker* mDatePicker; |
595 | QVBox* mDateFrame; | 599 | QVBox* mDateFrame; |
596 | 600 | ||
597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 601 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
598 | 602 | ||
599 | KOFilterView *mFilterView; | 603 | KOFilterView *mFilterView; |
600 | KOCalEditView *mCalEditView; | 604 | KOCalEditView *mCalEditView; |
601 | 605 | ||
602 | ResourceView *mResourceView; | 606 | ResourceView *mResourceView; |
603 | 607 | ||
604 | // calendar object for this viewing instance | 608 | // calendar object for this viewing instance |
605 | Calendar *mCalendar; | 609 | Calendar *mCalendar; |
606 | 610 | ||
607 | CalendarResourceManager *mResourceManager; | 611 | CalendarResourceManager *mResourceManager; |
608 | 612 | ||
609 | FileStorage *mStorage; | 613 | FileStorage *mStorage; |
610 | 614 | ||
611 | DateNavigator *mNavigator; | 615 | DateNavigator *mNavigator; |
612 | 616 | ||
613 | KOViewManager *mViewManager; | 617 | KOViewManager *mViewManager; |
614 | KODialogManager *mDialogManager; | 618 | KODialogManager *mDialogManager; |
615 | 619 | ||
616 | // Calendar filters | 620 | // Calendar filters |
617 | QPtrList<CalFilter> mFilters; | 621 | QPtrList<CalFilter> mFilters; |
618 | 622 | ||
619 | // various housekeeping variables. | 623 | // various housekeeping variables. |
620 | bool mModified; // flag indicating if calendar is modified | 624 | bool mModified; // flag indicating if calendar is modified |
621 | bool mReadOnly; // flag indicating if calendar is read-only | 625 | bool mReadOnly; // flag indicating if calendar is read-only |
622 | QDate mSaveSingleDate; | 626 | QDate mSaveSingleDate; |
623 | 627 | ||
624 | Incidence *mSelectedIncidence; | 628 | Incidence *mSelectedIncidence; |
625 | Incidence *mMoveIncidence; | 629 | Incidence *mMoveIncidence; |
626 | QDate mMoveIncidenceOldDate; | 630 | QDate mMoveIncidenceOldDate; |
627 | KOTodoView *mTodoList; | 631 | KOTodoView *mTodoList; |
628 | KOEventEditor * mEventEditor; | 632 | KOEventEditor * mEventEditor; |
629 | KOTodoEditor * mTodoEditor; | 633 | KOTodoEditor * mTodoEditor; |
630 | KOEventViewerDialog * mEventViewerDialog; | 634 | KOEventViewerDialog * mEventViewerDialog; |
631 | void keyPressEvent ( QKeyEvent *e) ; | 635 | void keyPressEvent ( QKeyEvent *e) ; |
632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 636 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
633 | }; | 637 | }; |
634 | 638 | ||
635 | 639 | ||
636 | class CalendarViewVisitor : public Incidence::Visitor | 640 | class CalendarViewVisitor : public Incidence::Visitor |
637 | { | 641 | { |
638 | public: | 642 | public: |
639 | CalendarViewVisitor() : mView( 0 ) {} | 643 | CalendarViewVisitor() : mView( 0 ) {} |
640 | 644 | ||
641 | bool act( Incidence *incidence, CalendarView *view ) | 645 | bool act( Incidence *incidence, CalendarView *view ) |
642 | { | 646 | { |
643 | mView = view; | 647 | mView = view; |
644 | return incidence->accept( *this ); | 648 | return incidence->accept( *this ); |
645 | } | 649 | } |
646 | 650 | ||
647 | protected: | 651 | protected: |
648 | CalendarView *mView; | 652 | CalendarView *mView; |
649 | }; | 653 | }; |
650 | 654 | ||
651 | class ShowIncidenceVisitor : public CalendarViewVisitor | 655 | class ShowIncidenceVisitor : public CalendarViewVisitor |
652 | { | 656 | { |
653 | protected: | 657 | protected: |
654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 658 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 659 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 660 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
657 | }; | 661 | }; |
658 | 662 | ||
659 | class EditIncidenceVisitor : public CalendarViewVisitor | 663 | class EditIncidenceVisitor : public CalendarViewVisitor |
660 | { | 664 | { |
661 | protected: | 665 | protected: |
662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 666 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 667 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 668 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
665 | }; | 669 | }; |
666 | 670 | ||
667 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 671 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
668 | { | 672 | { |
669 | protected: | 673 | protected: |
670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 674 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 675 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 676 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
673 | }; | 677 | }; |
674 | 678 | ||
675 | #endif | 679 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 66bb19b..69ccde1 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,762 +1,764 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qtopia/alarmserver.h> | 27 | #include <qtopia/alarmserver.h> |
28 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
29 | //#include <unistd.h> // for sleep | 29 | //#include <unistd.h> // for sleep |
30 | #else | 30 | #else |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <resource.h> | 33 | //#include <resource.h> |
34 | 34 | ||
35 | #endif | 35 | #endif |
36 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
37 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
38 | #include <libkcal/phoneformat.h> | 38 | #include <libkcal/phoneformat.h> |
39 | #include <libkdepim/ksyncprofile.h> | 39 | #include <libkdepim/ksyncprofile.h> |
40 | #include <libkdepim/phoneaccess.h> | 40 | #include <libkdepim/phoneaccess.h> |
41 | #include <libkcal/kincidenceformatter.h> | 41 | #include <libkcal/kincidenceformatter.h> |
42 | #include <libkdepim/kpimglobalprefs.h> | 42 | #include <libkdepim/kpimglobalprefs.h> |
43 | 43 | ||
44 | #include "calendarview.h" | 44 | #include "calendarview.h" |
45 | #include "koviewmanager.h" | 45 | #include "koviewmanager.h" |
46 | #include "datenavigator.h" | 46 | #include "datenavigator.h" |
47 | #include "koagendaview.h" | 47 | #include "koagendaview.h" |
48 | #include "kojournalview.h" | 48 | #include "kojournalview.h" |
49 | #include "koagenda.h" | 49 | #include "koagenda.h" |
50 | #include "kodialogmanager.h" | 50 | #include "kodialogmanager.h" |
51 | #include "kdialogbase.h" | 51 | #include "kdialogbase.h" |
52 | #include "kapplication.h" | 52 | #include "kapplication.h" |
53 | #include "kofilterview.h" | 53 | #include "kofilterview.h" |
54 | #include "kstandarddirs.h" | 54 | #include "kstandarddirs.h" |
55 | #include "koprefs.h" | 55 | #include "koprefs.h" |
56 | #include "kfiledialog.h" | 56 | #include "kfiledialog.h" |
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #include "kglobal.h" | 58 | #include "kglobal.h" |
59 | #include "ktoolbar.h" | 59 | #include "ktoolbar.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "externalapphandler.h" | 62 | #include "externalapphandler.h" |
63 | #include <kglobalsettings.h> | 63 | #include <kglobalsettings.h> |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
70 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
71 | #endif | 71 | #endif |
72 | #endif | 72 | #endif |
73 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
74 | 74 | ||
75 | 75 | ||
76 | class KOex2phonePrefs : public QDialog | 76 | class KOex2phonePrefs : public QDialog |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
80 | QDialog( parent, name, true ) | 80 | QDialog( parent, name, true ) |
81 | { | 81 | { |
82 | setCaption( i18n("Export to phone options") ); | 82 | setCaption( i18n("Export to phone options") ); |
83 | QVBoxLayout* lay = new QVBoxLayout( this ); | 83 | QVBoxLayout* lay = new QVBoxLayout( this ); |
84 | lay->setSpacing( 3 ); | 84 | lay->setSpacing( 3 ); |
85 | lay->setMargin( 3 ); | 85 | lay->setMargin( 3 ); |
86 | QLabel *lab; | 86 | QLabel *lab; |
87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
88 | lab->setAlignment (AlignHCenter ); | 88 | lab->setAlignment (AlignHCenter ); |
89 | QHBox* temphb; | 89 | QHBox* temphb; |
90 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
91 | new QLabel( i18n("I/O device: "), temphb ); | 91 | new QLabel( i18n("I/O device: "), temphb ); |
92 | mPhoneDevice = new QLineEdit( temphb); | 92 | mPhoneDevice = new QLineEdit( temphb); |
93 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
94 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
95 | new QLabel( i18n("Connection: "), temphb ); | 95 | new QLabel( i18n("Connection: "), temphb ); |
96 | mPhoneConnection = new QLineEdit( temphb); | 96 | mPhoneConnection = new QLineEdit( temphb); |
97 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
98 | temphb = new QHBox( this ); | 98 | temphb = new QHBox( this ); |
99 | new QLabel( i18n("Model(opt.): "), temphb ); | 99 | new QLabel( i18n("Model(opt.): "), temphb ); |
100 | mPhoneModel = new QLineEdit( temphb); | 100 | mPhoneModel = new QLineEdit( temphb); |
101 | lay->addWidget( temphb ); | 101 | lay->addWidget( temphb ); |
102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
103 | mWriteBackFuture->setChecked( true ); | 103 | mWriteBackFuture->setChecked( true ); |
104 | lay->addWidget( mWriteBackFuture ); | 104 | lay->addWidget( mWriteBackFuture ); |
105 | temphb = new QHBox( this ); | 105 | temphb = new QHBox( this ); |
106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
108 | mWriteBackFutureWeeks->setValue( 8 ); | 108 | mWriteBackFutureWeeks->setValue( 8 ); |
109 | lay->addWidget( temphb ); | 109 | lay->addWidget( temphb ); |
110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
111 | lab->setAlignment (AlignHCenter ); | 111 | lab->setAlignment (AlignHCenter ); |
112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
113 | lay->addWidget( ok ); | 113 | lay->addWidget( ok ); |
114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
115 | lay->addWidget( cancel ); | 115 | lay->addWidget( cancel ); |
116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
118 | resize( 220, 240 ); | 118 | resize( 220, 240 ); |
119 | qApp->processEvents(); | 119 | qApp->processEvents(); |
120 | int dw = QApplication::desktop()->width(); | 120 | int dw = QApplication::desktop()->width(); |
121 | int dh = QApplication::desktop()->height(); | 121 | int dh = QApplication::desktop()->height(); |
122 | move( (dw-width())/2, (dh - height() )/2 ); | 122 | move( (dw-width())/2, (dh - height() )/2 ); |
123 | } | 123 | } |
124 | 124 | ||
125 | public: | 125 | public: |
126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
127 | QCheckBox* mWriteBackFuture; | 127 | QCheckBox* mWriteBackFuture; |
128 | QSpinBox* mWriteBackFutureWeeks; | 128 | QSpinBox* mWriteBackFutureWeeks; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | QPixmap* sgListViewCompletedPix[6]; | 131 | QPixmap* sgListViewCompletedPix[6]; |
132 | QPixmap* sgListViewJournalPix; | 132 | QPixmap* sgListViewJournalPix; |
133 | 133 | ||
134 | 134 | ||
135 | int globalFlagBlockStartup; | 135 | int globalFlagBlockStartup; |
136 | MainWindow::MainWindow( QWidget *parent, const char *name ) : | 136 | MainWindow::MainWindow( QWidget *parent, const char *name ) : |
137 | QMainWindow( parent, name ) | 137 | QMainWindow( parent, name ) |
138 | { | 138 | { |
139 | sgListViewCompletedPix[5] = &listviewPix; | 139 | sgListViewCompletedPix[5] = &listviewPix; |
140 | sgListViewCompletedPix[0] = &listviewPix0; | 140 | sgListViewCompletedPix[0] = &listviewPix0; |
141 | sgListViewCompletedPix[1] = &listviewPix20; | 141 | sgListViewCompletedPix[1] = &listviewPix20; |
142 | sgListViewCompletedPix[2] = &listviewPix40; | 142 | sgListViewCompletedPix[2] = &listviewPix40; |
143 | sgListViewCompletedPix[3] = &listviewPix60; | 143 | sgListViewCompletedPix[3] = &listviewPix60; |
144 | sgListViewCompletedPix[4] = &listviewPix80; | 144 | sgListViewCompletedPix[4] = &listviewPix80; |
145 | //int size = 12; | 145 | //int size = 12; |
146 | { | 146 | { |
147 | sgListViewCompletedPix[5]->resize( 11, 11 ); | 147 | sgListViewCompletedPix[5]->resize( 11, 11 ); |
148 | sgListViewCompletedPix[5]->fill( Qt::white ); | 148 | sgListViewCompletedPix[5]->fill( Qt::white ); |
149 | QPainter p ( sgListViewCompletedPix[5] ); | 149 | QPainter p ( sgListViewCompletedPix[5] ); |
150 | p.drawRect( 0,0,11,11); | 150 | p.drawRect( 0,0,11,11); |
151 | p.drawLine ( 2, 5, 4 , 7 ) ; | 151 | p.drawLine ( 2, 5, 4 , 7 ) ; |
152 | p.drawLine ( 4 , 7 , 8, 3) ; | 152 | p.drawLine ( 4 , 7 , 8, 3) ; |
153 | int iii = 0; | 153 | int iii = 0; |
154 | for ( iii = 0; iii < 5; ++iii ) { | 154 | for ( iii = 0; iii < 5; ++iii ) { |
155 | sgListViewCompletedPix[iii]->resize( 11, 11 ); | 155 | sgListViewCompletedPix[iii]->resize( 11, 11 ); |
156 | sgListViewCompletedPix[iii]->fill( Qt::white ); | 156 | sgListViewCompletedPix[iii]->fill( Qt::white ); |
157 | QPainter p ( sgListViewCompletedPix[iii] ); | 157 | QPainter p ( sgListViewCompletedPix[iii] ); |
158 | p.drawRect( 0,0,11,11); | 158 | p.drawRect( 0,0,11,11); |
159 | if ( iii ) | 159 | if ( iii ) |
160 | p.fillRect( 1,1,iii*2,9,Qt::gray ); | 160 | p.fillRect( 1,1,iii*2,9,Qt::gray ); |
161 | } | 161 | } |
162 | sgListViewJournalPix = &journalPix; | 162 | sgListViewJournalPix = &journalPix; |
163 | sgListViewJournalPix->resize( 11, 11 ); | 163 | sgListViewJournalPix->resize( 11, 11 ); |
164 | sgListViewJournalPix->fill( Qt::white ); | 164 | sgListViewJournalPix->fill( Qt::white ); |
165 | { | 165 | { |
166 | QPainter p ( sgListViewJournalPix ); | 166 | QPainter p ( sgListViewJournalPix ); |
167 | p.drawRect( 0,0,11,11); | 167 | p.drawRect( 0,0,11,11); |
168 | p.drawLine( 2,3,5,3); | 168 | p.drawLine( 2,3,5,3); |
169 | p.drawLine( 2,5,8,5); | 169 | p.drawLine( 2,5,8,5); |
170 | p.drawLine( 2,7,6,7); | 170 | p.drawLine( 2,7,6,7); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | mAutoSaveDisabled = false; | 173 | mAutoSaveDisabled = false; |
174 | mClosed = false; | 174 | mClosed = false; |
175 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 175 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
176 | QString confFile = locateLocal("config","korganizerrc"); | 176 | QString confFile = locateLocal("config","korganizerrc"); |
177 | QFileInfo finf ( confFile ); | 177 | QFileInfo finf ( confFile ); |
178 | bool showWarning = !finf.exists(); | 178 | bool showWarning = !finf.exists(); |
179 | setIcon(SmallIcon( "ko24" ) ); | 179 | setIcon(SmallIcon( "ko24" ) ); |
180 | mBlockAtStartup = true; | 180 | mBlockAtStartup = true; |
181 | mFlagKeyPressed = false; | 181 | mFlagKeyPressed = false; |
182 | setCaption("KO/Pi"); | 182 | setCaption("KO/Pi"); |
183 | KOPrefs *p = KOPrefs::instance(); | 183 | KOPrefs *p = KOPrefs::instance(); |
184 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 184 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
185 | p->mCurrentDisplayedView = 0; | 185 | p->mCurrentDisplayedView = 0; |
186 | if ( p->mHourSize > 22 ) | 186 | if ( p->mHourSize > 22 ) |
187 | p->mHourSize = 22; | 187 | p->mHourSize = 22; |
188 | QMainWindow::ToolBarDock tbd; | 188 | QMainWindow::ToolBarDock tbd; |
189 | if ( p->mToolBarHor ) { | 189 | if ( p->mToolBarHor ) { |
190 | if ( p->mToolBarUp ) | 190 | if ( p->mToolBarUp ) |
191 | tbd = Bottom; | 191 | tbd = Bottom; |
192 | else | 192 | else |
193 | tbd = Top; | 193 | tbd = Top; |
194 | } | 194 | } |
195 | else { | 195 | else { |
196 | if ( p->mToolBarUp ) | 196 | if ( p->mToolBarUp ) |
197 | tbd = Right; | 197 | tbd = Right; |
198 | else | 198 | else |
199 | tbd = Left; | 199 | tbd = Left; |
200 | } | 200 | } |
201 | if ( KOPrefs::instance()->mUseAppColors ) | 201 | if ( KOPrefs::instance()->mUseAppColors ) |
202 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 202 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
203 | globalFlagBlockStartup = 1; | 203 | globalFlagBlockStartup = 1; |
204 | iconToolBar = new QPEToolBar( this ); | 204 | iconToolBar = new QPEToolBar( this ); |
205 | addToolBar (iconToolBar , tbd ); | 205 | addToolBar (iconToolBar , tbd ); |
206 | 206 | ||
207 | #ifdef DESKTOP_VERSION | 207 | #ifdef DESKTOP_VERSION |
208 | if ( KOPrefs::instance()->mShowIconFilter ) | 208 | if ( KOPrefs::instance()->mShowIconFilter ) |
209 | #else | 209 | #else |
210 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) | 210 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) |
211 | #endif | 211 | #endif |
212 | 212 | ||
213 | { | 213 | { |
214 | if ( p->mToolBarHorF ) { | 214 | if ( p->mToolBarHorF ) { |
215 | if ( p->mToolBarUpF ) | 215 | if ( p->mToolBarUpF ) |
216 | tbd = Bottom; | 216 | tbd = Bottom; |
217 | else | 217 | else |
218 | tbd = Top; | 218 | tbd = Top; |
219 | } | 219 | } |
220 | else { | 220 | else { |
221 | if ( p->mToolBarUpF ) | 221 | if ( p->mToolBarUpF ) |
222 | tbd = Right; | 222 | tbd = Right; |
223 | else | 223 | else |
224 | tbd = Left; | 224 | tbd = Left; |
225 | } | 225 | } |
226 | filterToolBar = new QPEToolBar ( this ); | 226 | filterToolBar = new QPEToolBar ( this ); |
227 | filterMenubar = new KMenuBar( 0 ); | 227 | filterMenubar = new KMenuBar( 0 ); |
228 | QFontMetrics fm ( filterMenubar->font() ); | 228 | QFontMetrics fm ( filterMenubar->font() ); |
229 | #ifndef DESKTOP_VERSION | 229 | #ifndef DESKTOP_VERSION |
230 | filterToolBar->setFocusPolicy( NoFocus ); | 230 | filterToolBar->setFocusPolicy( NoFocus ); |
231 | filterMenubar->setFocusPolicy( NoFocus ); | 231 | filterMenubar->setFocusPolicy( NoFocus ); |
232 | #endif | 232 | #endif |
233 | filterPopupMenu = new QPopupMenu( this ); | 233 | filterPopupMenu = new QPopupMenu( this ); |
234 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 234 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
235 | QString addTest = "A"; | 235 | QString addTest = "A"; |
236 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 236 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
237 | #ifdef DESKTOP_VERSION | 237 | #ifdef DESKTOP_VERSION |
238 | addTest = "AAAAAABBBCCCx"; | 238 | addTest = "AAAAAABBBCCCx"; |
239 | #else | 239 | #else |
240 | addTest = "AAAAAx"; | 240 | addTest = "AAAAAx"; |
241 | #endif | 241 | #endif |
242 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 242 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
243 | addToolBar (filterToolBar , tbd ); | 243 | addToolBar (filterToolBar , tbd ); |
244 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 244 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
245 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 245 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
246 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 246 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
247 | filterToolBar->hide(); | 247 | filterToolBar->hide(); |
248 | } else { | 248 | } else { |
249 | filterToolBar = 0; | 249 | filterToolBar = 0; |
250 | filterMenubar = 0; | 250 | filterMenubar = 0; |
251 | filterPopupMenu = 0; | 251 | filterPopupMenu = 0; |
252 | } | 252 | } |
253 | if ( p->mShowIconOnetoolbar ) { | 253 | if ( p->mShowIconOnetoolbar ) { |
254 | viewToolBar = iconToolBar ; | 254 | viewToolBar = iconToolBar ; |
255 | navigatorToolBar = iconToolBar ; | 255 | navigatorToolBar = iconToolBar ; |
256 | } else { | 256 | } else { |
257 | #ifndef DESKTOP_VERSION | 257 | #ifndef DESKTOP_VERSION |
258 | setToolBarsMovable( false ); | 258 | setToolBarsMovable( false ); |
259 | #endif | 259 | #endif |
260 | if ( p->mToolBarHorV ) { | 260 | if ( p->mToolBarHorV ) { |
261 | if ( p->mToolBarUpV ) | 261 | if ( p->mToolBarUpV ) |
262 | tbd = Bottom; | 262 | tbd = Bottom; |
263 | else | 263 | else |
264 | tbd = Top; | 264 | tbd = Top; |
265 | } | 265 | } |
266 | else { | 266 | else { |
267 | if ( p->mToolBarUpV ) | 267 | if ( p->mToolBarUpV ) |
268 | tbd = Right; | 268 | tbd = Right; |
269 | else | 269 | else |
270 | tbd = Left; | 270 | tbd = Left; |
271 | } | 271 | } |
272 | viewToolBar = new QPEToolBar( this ); | 272 | viewToolBar = new QPEToolBar( this ); |
273 | addToolBar (viewToolBar , tbd ); | 273 | addToolBar (viewToolBar , tbd ); |
274 | if ( p->mToolBarHorN ) { | 274 | if ( p->mToolBarHorN ) { |
275 | if ( p->mToolBarUpN ) | 275 | if ( p->mToolBarUpN ) |
276 | tbd = Bottom; | 276 | tbd = Bottom; |
277 | else | 277 | else |
278 | tbd = Top; | 278 | tbd = Top; |
279 | } | 279 | } |
280 | else { | 280 | else { |
281 | if ( p->mToolBarUpN ) | 281 | if ( p->mToolBarUpN ) |
282 | tbd = Right; | 282 | tbd = Right; |
283 | else | 283 | else |
284 | tbd = Left; | 284 | tbd = Left; |
285 | } | 285 | } |
286 | navigatorToolBar = new QPEToolBar( this ); | 286 | navigatorToolBar = new QPEToolBar( this ); |
287 | addToolBar (navigatorToolBar , tbd ); | 287 | addToolBar (navigatorToolBar , tbd ); |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | 291 | ||
292 | mCalendarModifiedFlag = false; | 292 | mCalendarModifiedFlag = false; |
293 | // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 293 | // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
294 | //splash->setAlignment ( AlignCenter ); | 294 | //splash->setAlignment ( AlignCenter ); |
295 | //setCentralWidget( splash ); | 295 | //setCentralWidget( splash ); |
296 | #ifndef DESKTOP_VERSION | 296 | #ifndef DESKTOP_VERSION |
297 | //showMaximized(); | 297 | //showMaximized(); |
298 | #endif | 298 | #endif |
299 | 299 | ||
300 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 300 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
301 | setDefaultPreferences(); | 301 | setDefaultPreferences(); |
302 | mCalendar = new CalendarLocal(); | 302 | mCalendar = new CalendarLocal(); |
303 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 303 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
304 | setCentralWidget( mView ); | 304 | setCentralWidget( mView ); |
305 | //mView->hide(); | 305 | //mView->hide(); |
306 | //mView->resize(splash->size() ); | 306 | //mView->resize(splash->size() ); |
307 | initActions(); | 307 | initActions(); |
308 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 308 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
309 | mSyncManager->setBlockSave(false); | 309 | mSyncManager->setBlockSave(false); |
310 | mView->setSyncManager(mSyncManager); | 310 | mView->setSyncManager(mSyncManager); |
311 | #ifndef DESKTOP_VERSION | 311 | #ifndef DESKTOP_VERSION |
312 | iconToolBar->show(); | 312 | iconToolBar->show(); |
313 | qApp->processEvents(); | 313 | qApp->processEvents(); |
314 | #endif | 314 | #endif |
315 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 315 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
316 | int vh = height() ; | 316 | int vh = height() ; |
317 | int vw = width(); | 317 | int vw = width(); |
318 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 318 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
319 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 319 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
320 | vh -= iconToolBar->height(); | 320 | vh -= iconToolBar->height(); |
321 | } else { | 321 | } else { |
322 | vw -= iconToolBar->height(); | 322 | vw -= iconToolBar->height(); |
323 | } | 323 | } |
324 | //mView->setMaximumSize( splash->size() ); | 324 | //mView->setMaximumSize( splash->size() ); |
325 | //mView->resize( splash->size() ); | 325 | //mView->resize( splash->size() ); |
326 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 326 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
327 | mView->readSettings(); | 327 | mView->readSettings(); |
328 | bool newFile = false; | 328 | bool newFile = false; |
329 | if( !QFile::exists( defaultFileName() ) ) { | 329 | if( !QFile::exists( defaultFileName() ) ) { |
330 | QFileInfo finfo ( defaultFileName() ); | 330 | QFileInfo finfo ( defaultFileName() ); |
331 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 331 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
332 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 332 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
333 | finfo.setFile( oldFile ); | 333 | finfo.setFile( oldFile ); |
334 | if (finfo.exists() ) { | 334 | if (finfo.exists() ) { |
335 | KMessageBox::information( this, message); | 335 | KMessageBox::information( this, message); |
336 | mView->openCalendar( oldFile ); | 336 | mView->openCalendar( oldFile ); |
337 | qApp->processEvents(); | 337 | qApp->processEvents(); |
338 | } else { | 338 | } else { |
339 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 339 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
340 | finfo.setFile( oldFile ); | 340 | finfo.setFile( oldFile ); |
341 | if (finfo.exists() ) { | 341 | if (finfo.exists() ) { |
342 | KMessageBox::information( this, message); | 342 | KMessageBox::information( this, message); |
343 | mView->openCalendar( oldFile ); | 343 | mView->openCalendar( oldFile ); |
344 | qApp->processEvents(); | 344 | qApp->processEvents(); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | mView->saveCalendar( defaultFileName() ); | 347 | mView->saveCalendar( defaultFileName() ); |
348 | newFile = true; | 348 | newFile = true; |
349 | } | 349 | } |
350 | 350 | ||
351 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); | 351 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); |
352 | //mView->loadCalendars(); | 352 | //mView->loadCalendars(); |
353 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 353 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
354 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 354 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
355 | 355 | ||
356 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 356 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
357 | KOPrefs::instance()->setAllDefaults(); | 357 | KOPrefs::instance()->setAllDefaults(); |
358 | } | 358 | } |
359 | 359 | ||
360 | 360 | ||
361 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 361 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
362 | SLOT( disableBR(bool) ) ); | 362 | SLOT( disableBR(bool) ) ); |
363 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 363 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
364 | setCentralWidget( mView ); | 364 | setCentralWidget( mView ); |
365 | globalFlagBlockStartup = 0; | 365 | globalFlagBlockStartup = 0; |
366 | //mView->show(); | 366 | //mView->show(); |
367 | //delete splash; | 367 | //delete splash; |
368 | if ( newFile ) | 368 | if ( newFile ) |
369 | mView->updateConfig(); | 369 | mView->updateConfig(); |
370 | // qApp->processEvents(); | 370 | // qApp->processEvents(); |
371 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 371 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
372 | //fillSyncMenu(); | 372 | //fillSyncMenu(); |
373 | 373 | ||
374 | 374 | ||
375 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 375 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
376 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 376 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
377 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 377 | connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); |
378 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 378 | connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) ); |
379 | connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) ); | ||
380 | |||
379 | mSyncManager->setDefaultFileName( sentSyncFile()); | 381 | mSyncManager->setDefaultFileName( sentSyncFile()); |
380 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 382 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
381 | mSyncManager->fillSyncMenu(); | 383 | mSyncManager->fillSyncMenu(); |
382 | 384 | ||
383 | 385 | ||
384 | 386 | ||
385 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 387 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
386 | if ( showWarning ) { | 388 | if ( showWarning ) { |
387 | KMessageBox::information( this, | 389 | KMessageBox::information( this, |
388 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 390 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
389 | //qApp->processEvents(); | 391 | //qApp->processEvents(); |
390 | mView->dialogManager()->showSyncOptions(); | 392 | mView->dialogManager()->showSyncOptions(); |
391 | } | 393 | } |
392 | 394 | ||
393 | //US listen for result adressed from Ka/Pi | 395 | //US listen for result adressed from Ka/Pi |
394 | 396 | ||
395 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
396 | infrared = 0; | 398 | infrared = 0; |
397 | #endif | 399 | #endif |
398 | updateFilterToolbar(); | 400 | updateFilterToolbar(); |
399 | updateWeek( mView->startDate() ); | 401 | updateWeek( mView->startDate() ); |
400 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 402 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
401 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 403 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
402 | mBRdisabled = false; | 404 | mBRdisabled = false; |
403 | //toggleBeamReceive(); | 405 | //toggleBeamReceive(); |
404 | 406 | ||
405 | setCaption(i18n("Loading calendar files ... please wait" )); | 407 | setCaption(i18n("Loading calendar files ... please wait" )); |
406 | mSaveDelay = 0; | 408 | mSaveDelay = 0; |
407 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); | 409 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); |
408 | } | 410 | } |
409 | MainWindow::~MainWindow() | 411 | MainWindow::~MainWindow() |
410 | { | 412 | { |
411 | //qDebug("MainWindow::~MainWindow() "); | 413 | //qDebug("MainWindow::~MainWindow() "); |
412 | //save toolbar location | 414 | //save toolbar location |
413 | delete mCalendar; | 415 | delete mCalendar; |
414 | delete mSyncManager; | 416 | delete mSyncManager; |
415 | #ifndef DESKTOP_VERSION | 417 | #ifndef DESKTOP_VERSION |
416 | if ( infrared ) | 418 | if ( infrared ) |
417 | delete infrared; | 419 | delete infrared; |
418 | #endif | 420 | #endif |
419 | 421 | ||
420 | 422 | ||
421 | } | 423 | } |
422 | 424 | ||
423 | void MainWindow::loadDataAfterStart() | 425 | void MainWindow::loadDataAfterStart() |
424 | { | 426 | { |
425 | qDebug("KO: Start loading files..." ); | 427 | qDebug("KO: Start loading files..." ); |
426 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 428 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
427 | mView->loadCalendars(); | 429 | mView->loadCalendars(); |
428 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 430 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
429 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 431 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
430 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 432 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
431 | mView->setModified( false ); | 433 | mView->setModified( false ); |
432 | mBlockAtStartup = false; | 434 | mBlockAtStartup = false; |
433 | mView->setModified( false ); | 435 | mView->setModified( false ); |
434 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 436 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
435 | processIncidenceSelection( 0 ); | 437 | processIncidenceSelection( 0 ); |
436 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 438 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
437 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 439 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
438 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 440 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
439 | SLOT( slotModifiedChanged( bool ) ) ); | 441 | SLOT( slotModifiedChanged( bool ) ) ); |
440 | #ifndef DESKTOP_VERSION | 442 | #ifndef DESKTOP_VERSION |
441 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 443 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
442 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); | 444 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); |
443 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); | 445 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); |
444 | if ( !mCStringMess.isEmpty() ) | 446 | if ( !mCStringMess.isEmpty() ) |
445 | recieve( mCStringMess, mByteData ); | 447 | recieve( mCStringMess, mByteData ); |
446 | #endif | 448 | #endif |
447 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 449 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
448 | } | 450 | } |
449 | 451 | ||
450 | void MainWindow::slotResetFocus() | 452 | void MainWindow::slotResetFocus() |
451 | { | 453 | { |
452 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); | 454 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); |
453 | mFocusLoop = 3; | 455 | mFocusLoop = 3; |
454 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 456 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
455 | } | 457 | } |
456 | void MainWindow::slotResetFocusLoop() | 458 | void MainWindow::slotResetFocusLoop() |
457 | { | 459 | { |
458 | --mFocusLoop; | 460 | --mFocusLoop; |
459 | QWidget* fw = mView->viewManager()->currentView(); | 461 | QWidget* fw = mView->viewManager()->currentView(); |
460 | if ( fw ) { | 462 | if ( fw ) { |
461 | //qDebug("loop "); | 463 | //qDebug("loop "); |
462 | fw->setFocus(); | 464 | fw->setFocus(); |
463 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) | 465 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) |
464 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 466 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
465 | } | 467 | } |
466 | 468 | ||
467 | } | 469 | } |
468 | void MainWindow::disableBR(bool b) | 470 | void MainWindow::disableBR(bool b) |
469 | { | 471 | { |
470 | #ifndef DESKTOP_VERSION | 472 | #ifndef DESKTOP_VERSION |
471 | if ( b ) { | 473 | if ( b ) { |
472 | if ( infrared ) { | 474 | if ( infrared ) { |
473 | toggleBeamReceive(); | 475 | toggleBeamReceive(); |
474 | mBRdisabled = true; | 476 | mBRdisabled = true; |
475 | } | 477 | } |
476 | mBRdisabled = true; | 478 | mBRdisabled = true; |
477 | } else { | 479 | } else { |
478 | if ( mBRdisabled ) { | 480 | if ( mBRdisabled ) { |
479 | mBRdisabled = false; | 481 | mBRdisabled = false; |
480 | //makes no sense,because other cal ap is probably running | 482 | //makes no sense,because other cal ap is probably running |
481 | // toggleBeamReceive(); | 483 | // toggleBeamReceive(); |
482 | } | 484 | } |
483 | } | 485 | } |
484 | #endif | 486 | #endif |
485 | 487 | ||
486 | } | 488 | } |
487 | bool MainWindow::beamReceiveEnabled() | 489 | bool MainWindow::beamReceiveEnabled() |
488 | { | 490 | { |
489 | #ifndef DESKTOP_VERSION | 491 | #ifndef DESKTOP_VERSION |
490 | return ( infrared != 0 ); | 492 | return ( infrared != 0 ); |
491 | #endif | 493 | #endif |
492 | return false; | 494 | return false; |
493 | } | 495 | } |
494 | 496 | ||
495 | void MainWindow::toggleBeamReceive() | 497 | void MainWindow::toggleBeamReceive() |
496 | { | 498 | { |
497 | if ( mBRdisabled ) | 499 | if ( mBRdisabled ) |
498 | return; | 500 | return; |
499 | #ifndef DESKTOP_VERSION | 501 | #ifndef DESKTOP_VERSION |
500 | if ( infrared ) { | 502 | if ( infrared ) { |
501 | qDebug("KO: Disable BeamReceive "); | 503 | qDebug("KO: Disable BeamReceive "); |
502 | delete infrared; | 504 | delete infrared; |
503 | infrared = 0; | 505 | infrared = 0; |
504 | brAction->setOn(false); | 506 | brAction->setOn(false); |
505 | return; | 507 | return; |
506 | } | 508 | } |
507 | qDebug("KO: Enable BeamReceive "); | 509 | qDebug("KO: Enable BeamReceive "); |
508 | brAction->setOn(true); | 510 | brAction->setOn(true); |
509 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 511 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
510 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 512 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
511 | #endif | 513 | #endif |
512 | } | 514 | } |
513 | void MainWindow::showMaximized () | 515 | void MainWindow::showMaximized () |
514 | { | 516 | { |
515 | #ifndef DESKTOP_VERSION | 517 | #ifndef DESKTOP_VERSION |
516 | if ( ! globalFlagBlockStartup ) | 518 | if ( ! globalFlagBlockStartup ) |
517 | if ( mClosed ) | 519 | if ( mClosed ) |
518 | mView->goToday(); | 520 | mView->goToday(); |
519 | #endif | 521 | #endif |
520 | QWidget::showMaximized () ; | 522 | QWidget::showMaximized () ; |
521 | mClosed = false; | 523 | mClosed = false; |
522 | } | 524 | } |
523 | 525 | ||
524 | bool MainWindow::askForQuitOnSaveError() | 526 | bool MainWindow::askForQuitOnSaveError() |
525 | { | 527 | { |
526 | bool retval = false; | 528 | bool retval = false; |
527 | switch( QMessageBox::information( this, "KO/Pi", | 529 | switch( QMessageBox::information( this, "KO/Pi", |
528 | i18n("Error saving data") + "!\n" + | 530 | i18n("Error saving data") + "!\n" + |
529 | i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + | 531 | i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + |
530 | i18n("Do you really want\nto close KO/Pi?"), | 532 | i18n("Do you really want\nto close KO/Pi?"), |
531 | i18n(" Yes, close "), i18n("No"), | 533 | i18n(" Yes, close "), i18n("No"), |
532 | 0, 1 ) ) { | 534 | 0, 1 ) ) { |
533 | case 0: | 535 | case 0: |
534 | retval = true; | 536 | retval = true; |
535 | break; | 537 | break; |
536 | default: | 538 | default: |
537 | break; | 539 | break; |
538 | } | 540 | } |
539 | return retval; | 541 | return retval; |
540 | } | 542 | } |
541 | bool MainWindow::checkAutosave() | 543 | bool MainWindow::checkAutosave() |
542 | { | 544 | { |
543 | bool savedata = true; | 545 | bool savedata = true; |
544 | if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { | 546 | if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { |
545 | switch( QMessageBox::information( this, "KO/Pi", | 547 | switch( QMessageBox::information( this, "KO/Pi", |
546 | i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), | 548 | i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), |
547 | i18n("Yes, Save!"), i18n("No"), | 549 | i18n("Yes, Save!"), i18n("No"), |
548 | 0, 0 ) ) { | 550 | 0, 0 ) ) { |
549 | case 1: | 551 | case 1: |
550 | case 2: | 552 | case 2: |
551 | savedata = false; | 553 | savedata = false; |
552 | break; | 554 | break; |
553 | default: | 555 | default: |
554 | break; | 556 | break; |
555 | } | 557 | } |
556 | } | 558 | } |
557 | return savedata; | 559 | return savedata; |
558 | } | 560 | } |
559 | void MainWindow::closeEvent( QCloseEvent* ce ) | 561 | void MainWindow::closeEvent( QCloseEvent* ce ) |
560 | { | 562 | { |
561 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 563 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
562 | if ( checkAutosave() ) { | 564 | if ( checkAutosave() ) { |
563 | saveOnClose(); | 565 | saveOnClose(); |
564 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { | 566 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { |
565 | ce->ignore(); | 567 | ce->ignore(); |
566 | return; | 568 | return; |
567 | } | 569 | } |
568 | } | 570 | } |
569 | mClosed = true; | 571 | mClosed = true; |
570 | ce->accept(); | 572 | ce->accept(); |
571 | return; | 573 | return; |
572 | 574 | ||
573 | } | 575 | } |
574 | 576 | ||
575 | switch( QMessageBox::information( this, "KO/Pi", | 577 | switch( QMessageBox::information( this, "KO/Pi", |
576 | i18n("Do you really want\nto close KO/Pi?"), | 578 | i18n("Do you really want\nto close KO/Pi?"), |
577 | i18n("Close"), i18n("No"), | 579 | i18n("Close"), i18n("No"), |
578 | 0, 0 ) ) { | 580 | 0, 0 ) ) { |
579 | case 0: | 581 | case 0: |
580 | if ( checkAutosave() ) { | 582 | if ( checkAutosave() ) { |
581 | saveOnClose(); | 583 | saveOnClose(); |
582 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { | 584 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { |
583 | ce->ignore(); | 585 | ce->ignore(); |
584 | return; | 586 | return; |
585 | } | 587 | } |
586 | } | 588 | } |
587 | mClosed = true; | 589 | mClosed = true; |
588 | ce->accept(); | 590 | ce->accept(); |
589 | break; | 591 | break; |
590 | case 1: | 592 | case 1: |
591 | ce->ignore(); | 593 | ce->ignore(); |
592 | break; | 594 | break; |
593 | case 2: | 595 | case 2: |
594 | 596 | ||
595 | default: | 597 | default: |
596 | break; | 598 | break; |
597 | } | 599 | } |
598 | 600 | ||
599 | 601 | ||
600 | } | 602 | } |
601 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) | 603 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) |
602 | { | 604 | { |
603 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | 605 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); |
604 | mCStringMess = cmsg; | 606 | mCStringMess = cmsg; |
605 | mByteData = data; | 607 | mByteData = data; |
606 | } | 608 | } |
607 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 609 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
608 | { | 610 | { |
609 | QDataStream stream( data, IO_ReadOnly ); | 611 | QDataStream stream( data, IO_ReadOnly ); |
610 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 612 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
611 | //QString datamess; | 613 | //QString datamess; |
612 | //qDebug("message "); | 614 | //qDebug("message "); |
613 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 615 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
614 | 616 | ||
615 | if ( cmsg == "setDocument(QString)" ) { | 617 | if ( cmsg == "setDocument(QString)" ) { |
616 | QDataStream stream( data, IO_ReadOnly ); | 618 | QDataStream stream( data, IO_ReadOnly ); |
617 | QString fileName; | 619 | QString fileName; |
618 | stream >> fileName; | 620 | stream >> fileName; |
619 | //qDebug("filename %s ", fileName.latin1()); | 621 | //qDebug("filename %s ", fileName.latin1()); |
620 | showMaximized(); | 622 | showMaximized(); |
621 | raise(); | 623 | raise(); |
622 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 624 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
623 | mSyncManager->slotSyncMenu( 1002 ); | 625 | mSyncManager->slotSyncMenu( 1002 ); |
624 | return; | 626 | return; |
625 | } | 627 | } |
626 | 628 | ||
627 | if ( cmsg == "-writeFile" ) { | 629 | if ( cmsg == "-writeFile" ) { |
628 | // I made from the "-writeFile" an "-writeAlarm" | 630 | // I made from the "-writeFile" an "-writeAlarm" |
629 | mView->viewManager()->showWhatsNextView(); | 631 | mView->viewManager()->showWhatsNextView(); |
630 | mCalendar->checkAlarmForIncidence( 0, true); | 632 | mCalendar->checkAlarmForIncidence( 0, true); |
631 | showMaximized(); | 633 | showMaximized(); |
632 | raise(); | 634 | raise(); |
633 | return; | 635 | return; |
634 | 636 | ||
635 | } | 637 | } |
636 | if ( cmsg == "-writeFileSilent" ) { | 638 | if ( cmsg == "-writeFileSilent" ) { |
637 | // I made from the "-writeFile" an "-writeAlarm" | 639 | // I made from the "-writeFile" an "-writeAlarm" |
638 | // mView->viewManager()->showWhatsNextView(); | 640 | // mView->viewManager()->showWhatsNextView(); |
639 | mCalendar->checkAlarmForIncidence( 0, true); | 641 | mCalendar->checkAlarmForIncidence( 0, true); |
640 | //showMaximized(); | 642 | //showMaximized(); |
641 | //raise(); | 643 | //raise(); |
642 | //hide(); | 644 | //hide(); |
643 | return; | 645 | return; |
644 | } | 646 | } |
645 | if ( cmsg == "-newCountdown" ) { | 647 | if ( cmsg == "-newCountdown" ) { |
646 | qDebug("newCountdown "); | 648 | qDebug("newCountdown "); |
647 | 649 | ||
648 | } | 650 | } |
649 | QString msg ; | 651 | QString msg ; |
650 | QString allmsg = cmsg; | 652 | QString allmsg = cmsg; |
651 | while ( allmsg.length() > 0 ) { | 653 | while ( allmsg.length() > 0 ) { |
652 | int nextC = allmsg.find( "-", 1 ); | 654 | int nextC = allmsg.find( "-", 1 ); |
653 | if ( nextC == -1 ) { | 655 | if ( nextC == -1 ) { |
654 | msg = allmsg; | 656 | msg = allmsg; |
655 | allmsg = ""; | 657 | allmsg = ""; |
656 | } else{ | 658 | } else{ |
657 | msg = allmsg.left( nextC ); | 659 | msg = allmsg.left( nextC ); |
658 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 660 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
659 | } | 661 | } |
660 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 662 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
661 | if ( msg == "-newEvent" ) { | 663 | if ( msg == "-newEvent" ) { |
662 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); | 664 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); |
663 | } | 665 | } |
664 | if ( msg == "-newTodo" ) { | 666 | if ( msg == "-newTodo" ) { |
665 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); | 667 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); |
666 | } | 668 | } |
667 | if ( msg == "-showWN" ) { | 669 | if ( msg == "-showWN" ) { |
668 | mView->viewManager()->showWhatsNextView(); | 670 | mView->viewManager()->showWhatsNextView(); |
669 | } | 671 | } |
670 | if ( msg == "-showList" ) { | 672 | if ( msg == "-showList" ) { |
671 | mView->viewManager()->showListView(); | 673 | mView->viewManager()->showListView(); |
672 | } | 674 | } |
673 | else if ( msg == "-showDay" ) { | 675 | else if ( msg == "-showDay" ) { |
674 | mView->viewManager()->showDayView(); | 676 | mView->viewManager()->showDayView(); |
675 | } | 677 | } |
676 | else if ( msg == "-showWWeek" ) { | 678 | else if ( msg == "-showWWeek" ) { |
677 | mView->viewManager()->showWorkWeekView(); | 679 | mView->viewManager()->showWorkWeekView(); |
678 | } | 680 | } |
679 | else if ( msg == "-ringSync" ) { | 681 | else if ( msg == "-ringSync" ) { |
680 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); | 682 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); |
681 | } | 683 | } |
682 | else if ( msg == "-showWeek" ) { | 684 | else if ( msg == "-showWeek" ) { |
683 | mView->viewManager()->showWeekView(); | 685 | mView->viewManager()->showWeekView(); |
684 | } | 686 | } |
685 | else if ( msg == "-showTodo" ) { | 687 | else if ( msg == "-showTodo" ) { |
686 | mView->viewManager()->showTodoView(); | 688 | mView->viewManager()->showTodoView(); |
687 | } | 689 | } |
688 | else if ( msg == "-showJournal" ) { | 690 | else if ( msg == "-showJournal" ) { |
689 | mView->dateNavigator()->selectDates( 1 ); | 691 | mView->dateNavigator()->selectDates( 1 ); |
690 | mView->dateNavigator()->selectToday(); | 692 | mView->dateNavigator()->selectToday(); |
691 | mView->viewManager()->showJournalView(); | 693 | mView->viewManager()->showJournalView(); |
692 | } | 694 | } |
693 | else if ( msg == "-showKO" ) { | 695 | else if ( msg == "-showKO" ) { |
694 | mView->viewManager()->showNextXView(); | 696 | mView->viewManager()->showNextXView(); |
695 | } | 697 | } |
696 | else if ( msg == "-showWNext" ) { | 698 | else if ( msg == "-showWNext" ) { |
697 | mView->viewManager()->showWhatsNextView(); | 699 | mView->viewManager()->showWhatsNextView(); |
698 | } | 700 | } |
699 | else if ( msg == "nextView()" ) { | 701 | else if ( msg == "nextView()" ) { |
700 | mView->viewManager()->showNextView(); | 702 | mView->viewManager()->showNextView(); |
701 | } | 703 | } |
702 | else if ( msg == "-showNextXView" ) { | 704 | else if ( msg == "-showNextXView" ) { |
703 | mView->viewManager()->showNextXView(); | 705 | mView->viewManager()->showNextXView(); |
704 | } | 706 | } |
705 | 707 | ||
706 | 708 | ||
707 | } | 709 | } |
708 | 710 | ||
709 | showMaximized(); | 711 | showMaximized(); |
710 | raise(); | 712 | raise(); |
711 | } | 713 | } |
712 | void MainWindow::startMultiSync() | 714 | void MainWindow::startMultiSync() |
713 | { | 715 | { |
714 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 716 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
715 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), | 717 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), |
716 | question, | 718 | question, |
717 | i18n("Yes"), i18n("No"), | 719 | i18n("Yes"), i18n("No"), |
718 | 0, 0 ) != 0 ) { | 720 | 0, 0 ) != 0 ) { |
719 | setCaption(i18n("Aborted! Nothing synced!")); | 721 | setCaption(i18n("Aborted! Nothing synced!")); |
720 | return; | 722 | return; |
721 | } | 723 | } |
722 | mSyncManager->multiSync( false ); | 724 | mSyncManager->multiSync( false ); |
723 | #ifndef DESKTOP_VERSION | 725 | #ifndef DESKTOP_VERSION |
724 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); | 726 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); |
725 | #endif | 727 | #endif |
726 | } | 728 | } |
727 | QPixmap MainWindow::loadPixmap( QString name ) | 729 | QPixmap MainWindow::loadPixmap( QString name ) |
728 | { | 730 | { |
729 | return SmallIcon( name ); | 731 | return SmallIcon( name ); |
730 | 732 | ||
731 | } | 733 | } |
732 | void MainWindow::setUsesBigPixmaps ( bool b ) | 734 | void MainWindow::setUsesBigPixmaps ( bool b ) |
733 | { | 735 | { |
734 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); | 736 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); |
735 | if ( b ) | 737 | if ( b ) |
736 | qDebug("KO: BigPixmaps are not supported "); | 738 | qDebug("KO: BigPixmaps are not supported "); |
737 | } | 739 | } |
738 | void MainWindow::initActions() | 740 | void MainWindow::initActions() |
739 | { | 741 | { |
740 | //KOPrefs::instance()->mShowFullMenu | 742 | //KOPrefs::instance()->mShowFullMenu |
741 | iconToolBar->clear(); | 743 | iconToolBar->clear(); |
742 | KOPrefs *p = KOPrefs::instance(); | 744 | KOPrefs *p = KOPrefs::instance(); |
743 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 745 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
744 | 746 | ||
745 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 747 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
746 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 748 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
747 | mCurrentItemMenu = new QPopupMenu ( this ); | 749 | mCurrentItemMenu = new QPopupMenu ( this ); |
748 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); | 750 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); |
749 | QPopupMenu *importMenu = new QPopupMenu( this ); | 751 | QPopupMenu *importMenu = new QPopupMenu( this ); |
750 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 752 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
751 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 753 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
752 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 754 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
753 | selectFilterMenu = new QPopupMenu( this ); | 755 | selectFilterMenu = new QPopupMenu( this ); |
754 | selectFilterMenu->setCheckable( true ); | 756 | selectFilterMenu->setCheckable( true ); |
755 | syncMenu = new QPopupMenu( this ); | 757 | syncMenu = new QPopupMenu( this ); |
756 | configureAgendaMenu = new QPopupMenu( this ); | 758 | configureAgendaMenu = new QPopupMenu( this ); |
757 | configureToolBarMenu = new QPopupMenu( this ); | 759 | configureToolBarMenu = new QPopupMenu( this ); |
758 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 760 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
759 | QIconSet icon; | 761 | QIconSet icon; |
760 | int pixWid = 22, pixHei = 22; | 762 | int pixWid = 22, pixHei = 22; |
761 | QString pathString = ""; | 763 | QString pathString = ""; |
762 | if ( !p->mToolBarMiniIcons ) { | 764 | if ( !p->mToolBarMiniIcons ) { |
@@ -2323,499 +2325,499 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) | |||
2323 | default: | 2325 | default: |
2324 | e->ignore(); | 2326 | e->ignore(); |
2325 | } | 2327 | } |
2326 | if ( pro > 0 ) { | 2328 | if ( pro > 0 ) { |
2327 | selectFilter( pro+1 ); | 2329 | selectFilter( pro+1 ); |
2328 | } | 2330 | } |
2329 | if ( showSelectedDates ) { | 2331 | if ( showSelectedDates ) { |
2330 | ;// setCaptionToDates(); | 2332 | ;// setCaptionToDates(); |
2331 | } | 2333 | } |
2332 | 2334 | ||
2333 | } | 2335 | } |
2334 | void MainWindow::fillFilterMenuTB() | 2336 | void MainWindow::fillFilterMenuTB() |
2335 | { | 2337 | { |
2336 | selectFilterMenuTB->clear(); | 2338 | selectFilterMenuTB->clear(); |
2337 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2339 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2338 | selectFilterMenuTB->insertSeparator(); | 2340 | selectFilterMenuTB->insertSeparator(); |
2339 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2341 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2340 | 2342 | ||
2341 | selectFilterMenuTB->insertSeparator(); | 2343 | selectFilterMenuTB->insertSeparator(); |
2342 | QPtrList<CalFilter> fili = mView->filters(); | 2344 | QPtrList<CalFilter> fili = mView->filters(); |
2343 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2345 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2344 | CalFilter *filter = fili.first(); | 2346 | CalFilter *filter = fili.first(); |
2345 | int iii = 2; | 2347 | int iii = 2; |
2346 | bool checkitem = mView->filterView()->filtersEnabled(); | 2348 | bool checkitem = mView->filterView()->filtersEnabled(); |
2347 | while(filter) { | 2349 | while(filter) { |
2348 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2350 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2349 | if ( filter == curfilter) | 2351 | if ( filter == curfilter) |
2350 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2352 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2351 | filter = fili.next(); | 2353 | filter = fili.next(); |
2352 | ++iii; | 2354 | ++iii; |
2353 | } | 2355 | } |
2354 | if ( !checkitem ) | 2356 | if ( !checkitem ) |
2355 | selectFilterMenuTB->setItemChecked( 1, true ); | 2357 | selectFilterMenuTB->setItemChecked( 1, true ); |
2356 | 2358 | ||
2357 | int x = 0; | 2359 | int x = 0; |
2358 | int y = iconToolBar->height(); | 2360 | int y = iconToolBar->height(); |
2359 | int dX = 0; | 2361 | int dX = 0; |
2360 | int dY = 0; | 2362 | int dY = 0; |
2361 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2363 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2362 | if ( iconToolBar->y() > height()/2 ) { | 2364 | if ( iconToolBar->y() > height()/2 ) { |
2363 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2365 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2364 | y = 0; | 2366 | y = 0; |
2365 | } | 2367 | } |
2366 | } else { | 2368 | } else { |
2367 | if ( iconToolBar->x() > width()/2 ) { // right side | 2369 | if ( iconToolBar->x() > width()/2 ) { // right side |
2368 | x=0; | 2370 | x=0; |
2369 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2371 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2370 | y = 0; | 2372 | y = 0; |
2371 | } else { | 2373 | } else { |
2372 | x= iconToolBar->width(); | 2374 | x= iconToolBar->width(); |
2373 | y = 0; | 2375 | y = 0; |
2374 | } | 2376 | } |
2375 | } | 2377 | } |
2376 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2378 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2377 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2379 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2378 | } | 2380 | } |
2379 | void MainWindow::fillFilterMenu() | 2381 | void MainWindow::fillFilterMenu() |
2380 | { | 2382 | { |
2381 | selectFilterMenu->clear(); | 2383 | selectFilterMenu->clear(); |
2382 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2384 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2383 | selectFilterMenu->insertSeparator(); | 2385 | selectFilterMenu->insertSeparator(); |
2384 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2386 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2385 | 2387 | ||
2386 | selectFilterMenu->insertSeparator(); | 2388 | selectFilterMenu->insertSeparator(); |
2387 | QPtrList<CalFilter> fili = mView->filters(); | 2389 | QPtrList<CalFilter> fili = mView->filters(); |
2388 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2390 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2389 | CalFilter *filter = fili.first(); | 2391 | CalFilter *filter = fili.first(); |
2390 | int iii = 2; | 2392 | int iii = 2; |
2391 | bool checkitem = mView->filterView()->filtersEnabled(); | 2393 | bool checkitem = mView->filterView()->filtersEnabled(); |
2392 | while(filter) { | 2394 | while(filter) { |
2393 | selectFilterMenu->insertItem( filter->name(), iii ); | 2395 | selectFilterMenu->insertItem( filter->name(), iii ); |
2394 | if ( filter == curfilter) | 2396 | if ( filter == curfilter) |
2395 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2397 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2396 | filter = fili.next(); | 2398 | filter = fili.next(); |
2397 | ++iii; | 2399 | ++iii; |
2398 | } | 2400 | } |
2399 | if ( !checkitem ) | 2401 | if ( !checkitem ) |
2400 | selectFilterMenu->setItemChecked( 1, true ); | 2402 | selectFilterMenu->setItemChecked( 1, true ); |
2401 | } | 2403 | } |
2402 | void MainWindow::fillFilterMenuPopup() | 2404 | void MainWindow::fillFilterMenuPopup() |
2403 | { | 2405 | { |
2404 | filterPopupMenu->clear(); | 2406 | filterPopupMenu->clear(); |
2405 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2407 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2406 | 2408 | ||
2407 | filterPopupMenu->insertSeparator(); | 2409 | filterPopupMenu->insertSeparator(); |
2408 | QPtrList<CalFilter> fili = mView->filters(); | 2410 | QPtrList<CalFilter> fili = mView->filters(); |
2409 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2411 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2410 | CalFilter *filter = fili.first(); | 2412 | CalFilter *filter = fili.first(); |
2411 | int iii = 1; | 2413 | int iii = 1; |
2412 | bool checkitem = mView->filterView()->filtersEnabled(); | 2414 | bool checkitem = mView->filterView()->filtersEnabled(); |
2413 | while(filter) { | 2415 | while(filter) { |
2414 | filterPopupMenu->insertItem( filter->name(), iii ); | 2416 | filterPopupMenu->insertItem( filter->name(), iii ); |
2415 | if ( filter == curfilter) | 2417 | if ( filter == curfilter) |
2416 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2418 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2417 | filter = fili.next(); | 2419 | filter = fili.next(); |
2418 | ++iii; | 2420 | ++iii; |
2419 | } | 2421 | } |
2420 | if ( !checkitem ) | 2422 | if ( !checkitem ) |
2421 | filterPopupMenu->setItemChecked( 0, true ); | 2423 | filterPopupMenu->setItemChecked( 0, true ); |
2422 | } | 2424 | } |
2423 | void MainWindow::selectFilter( int fil ) | 2425 | void MainWindow::selectFilter( int fil ) |
2424 | { | 2426 | { |
2425 | 2427 | ||
2426 | if ( fil == 0 ) { | 2428 | if ( fil == 0 ) { |
2427 | mView->editFilters( ); | 2429 | mView->editFilters( ); |
2428 | } else if ( fil == 1 ){ | 2430 | } else if ( fil == 1 ){ |
2429 | if ( mView->filterView()->filtersEnabled() ) | 2431 | if ( mView->filterView()->filtersEnabled() ) |
2430 | mView->toggleFilerEnabled( ); | 2432 | mView->toggleFilerEnabled( ); |
2431 | } else { | 2433 | } else { |
2432 | if ( !mView->filterView()->filtersEnabled() ) { | 2434 | if ( !mView->filterView()->filtersEnabled() ) { |
2433 | mView->filterView()->blockSignals( true ); | 2435 | mView->filterView()->blockSignals( true ); |
2434 | mView->toggleFilerEnabled( ); | 2436 | mView->toggleFilerEnabled( ); |
2435 | mView->filterView()->blockSignals( false ); | 2437 | mView->filterView()->blockSignals( false ); |
2436 | } | 2438 | } |
2437 | mView->selectFilter( fil-2 ); | 2439 | mView->selectFilter( fil-2 ); |
2438 | } | 2440 | } |
2439 | } | 2441 | } |
2440 | void MainWindow::updateFilterToolbar() | 2442 | void MainWindow::updateFilterToolbar() |
2441 | { | 2443 | { |
2442 | if ( filterMenubar ) { | 2444 | if ( filterMenubar ) { |
2443 | if ( !mView->filterView()->filtersEnabled() ) { | 2445 | if ( !mView->filterView()->filtersEnabled() ) { |
2444 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2446 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2445 | } else { | 2447 | } else { |
2446 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2448 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2447 | if ( curfilter ) { | 2449 | if ( curfilter ) { |
2448 | QString name = curfilter->name(); | 2450 | QString name = curfilter->name(); |
2449 | if ( name.length() > 12 ) | 2451 | if ( name.length() > 12 ) |
2450 | name = name.left(10)+"..."; | 2452 | name = name.left(10)+"..."; |
2451 | filterMenubar->changeItem( 0, name ); | 2453 | filterMenubar->changeItem( 0, name ); |
2452 | } | 2454 | } |
2453 | } | 2455 | } |
2454 | } | 2456 | } |
2455 | } | 2457 | } |
2456 | void MainWindow::selectFilterPopup( int fil ) | 2458 | void MainWindow::selectFilterPopup( int fil ) |
2457 | { | 2459 | { |
2458 | selectFilter( fil + 1 ); | 2460 | selectFilter( fil + 1 ); |
2459 | 2461 | ||
2460 | } | 2462 | } |
2461 | void MainWindow::configureToolBar( int item ) | 2463 | void MainWindow::configureToolBar( int item ) |
2462 | { | 2464 | { |
2463 | 2465 | ||
2464 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2466 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2465 | KOPrefs *p = KOPrefs::instance(); | 2467 | KOPrefs *p = KOPrefs::instance(); |
2466 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2468 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2467 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2469 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2468 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2470 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2469 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2471 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2470 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2472 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2471 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2473 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2472 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2474 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2473 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2475 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2474 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2476 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2475 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2477 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2476 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2478 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2477 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2479 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2478 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2480 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2479 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2481 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2480 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2482 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2481 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2483 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2482 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2484 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2483 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2485 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2484 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2486 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2485 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2487 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2486 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2488 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2487 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2489 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2488 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2490 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2489 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2491 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2490 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2492 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2491 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2493 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2492 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2494 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2493 | // initActions(); | 2495 | // initActions(); |
2494 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2496 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2495 | } | 2497 | } |
2496 | void MainWindow::setCaption ( const QString & c ) | 2498 | void MainWindow::setCaption ( const QString & c ) |
2497 | { | 2499 | { |
2498 | QString cap = c; | 2500 | QString cap = c; |
2499 | cap.replace( QRegExp("\n"), " " ); | 2501 | cap.replace( QRegExp("\n"), " " ); |
2500 | cap = cap.stripWhiteSpace(); | 2502 | cap = cap.stripWhiteSpace(); |
2501 | if ( cap.isEmpty() ) | 2503 | if ( cap.isEmpty() ) |
2502 | cap = "KO/Pi"; | 2504 | cap = "KO/Pi"; |
2503 | QWidget::setCaption( cap ); | 2505 | QWidget::setCaption( cap ); |
2504 | } | 2506 | } |
2505 | void MainWindow::setCaptionToDates() | 2507 | void MainWindow::setCaptionToDates() |
2506 | { | 2508 | { |
2507 | QString selDates; | 2509 | QString selDates; |
2508 | QDate date = mView->startDate(); | 2510 | QDate date = mView->startDate(); |
2509 | if ( ! date.isValid() ) { | 2511 | if ( ! date.isValid() ) { |
2510 | setCaption(""); | 2512 | setCaption(""); |
2511 | return; | 2513 | return; |
2512 | } | 2514 | } |
2513 | selDates = KGlobal::locale()->formatDate( date, true); | 2515 | selDates = KGlobal::locale()->formatDate( date, true); |
2514 | if (mView->startDate() < mView->endDate() ) | 2516 | if (mView->startDate() < mView->endDate() ) |
2515 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2517 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2516 | else { | 2518 | else { |
2517 | QString addString; | 2519 | QString addString; |
2518 | if ( date == QDateTime::currentDateTime().date() ) | 2520 | if ( date == QDateTime::currentDateTime().date() ) |
2519 | addString = i18n("Today"); | 2521 | addString = i18n("Today"); |
2520 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2522 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2521 | addString = i18n("Tomorrow"); | 2523 | addString = i18n("Tomorrow"); |
2522 | if ( !addString.isEmpty() ) | 2524 | if ( !addString.isEmpty() ) |
2523 | selDates = addString+", "+selDates ; | 2525 | selDates = addString+", "+selDates ; |
2524 | } | 2526 | } |
2525 | setCaption( i18n("Dates: ") + selDates ); | 2527 | setCaption( i18n("Dates: ") + selDates ); |
2526 | 2528 | ||
2527 | } | 2529 | } |
2528 | void MainWindow::showConfigureAgenda( ) | 2530 | void MainWindow::showConfigureAgenda( ) |
2529 | { | 2531 | { |
2530 | int iii; | 2532 | int iii; |
2531 | for ( iii = 1;iii<= 10 ;++iii ){ | 2533 | for ( iii = 1;iii<= 10 ;++iii ){ |
2532 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2534 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2533 | } | 2535 | } |
2534 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2536 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2535 | } | 2537 | } |
2536 | void MainWindow::configureAgenda( int item ) | 2538 | void MainWindow::configureAgenda( int item ) |
2537 | { | 2539 | { |
2538 | if ( KOPrefs::instance()->mHourSize == item ) | 2540 | if ( KOPrefs::instance()->mHourSize == item ) |
2539 | return; | 2541 | return; |
2540 | KOPrefs::instance()->mHourSize=item; | 2542 | KOPrefs::instance()->mHourSize=item; |
2541 | mView->viewManager()->agendaView()->updateConfig(); | 2543 | mView->viewManager()->agendaView()->updateConfig(); |
2542 | } | 2544 | } |
2543 | 2545 | ||
2544 | void MainWindow::saveCalendar() | 2546 | void MainWindow::saveCalendar() |
2545 | { | 2547 | { |
2546 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2548 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2547 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2549 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2548 | bupDir = KGlobalSettings::backupDataDir(); | 2550 | bupDir = KGlobalSettings::backupDataDir(); |
2549 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2551 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2550 | QString bupHint; | 2552 | QString bupHint; |
2551 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2553 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2552 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); | 2554 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); |
2553 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; | 2555 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; |
2554 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2556 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2555 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2557 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2556 | save(); | 2558 | save(); |
2557 | #ifndef DESKTOP_VERSION | 2559 | #ifndef DESKTOP_VERSION |
2558 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 2560 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
2559 | #endif | 2561 | #endif |
2560 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2562 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2561 | backupAllFiles(); | 2563 | backupAllFiles(); |
2562 | #ifndef DESKTOP_VERSION | 2564 | #ifndef DESKTOP_VERSION |
2563 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | 2565 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); |
2564 | #endif | 2566 | #endif |
2565 | } | 2567 | } |
2566 | void MainWindow::loadCalendar() | 2568 | void MainWindow::loadCalendar() |
2567 | { | 2569 | { |
2568 | 2570 | ||
2569 | 2571 | ||
2570 | #if 0 | 2572 | #if 0 |
2571 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2573 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2572 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2574 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2573 | 2575 | ||
2574 | if ( fn == "" ) | 2576 | if ( fn == "" ) |
2575 | return; | 2577 | return; |
2576 | QFileInfo info; | 2578 | QFileInfo info; |
2577 | info.setFile( fn ); | 2579 | info.setFile( fn ); |
2578 | QString mess; | 2580 | QString mess; |
2579 | bool loadbup = true; | 2581 | bool loadbup = true; |
2580 | if ( info. exists() ) { | 2582 | if ( info. exists() ) { |
2581 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2583 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2582 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2584 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2583 | mess, | 2585 | mess, |
2584 | i18n("Load!"), i18n("Cancel"), 0, | 2586 | i18n("Load!"), i18n("Cancel"), 0, |
2585 | 0, 1 ); | 2587 | 0, 1 ); |
2586 | if ( result != 0 ) { | 2588 | if ( result != 0 ) { |
2587 | loadbup = false; | 2589 | loadbup = false; |
2588 | } | 2590 | } |
2589 | } else { | 2591 | } else { |
2590 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2592 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2591 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2593 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2592 | 0, 1 ); | 2594 | 0, 1 ); |
2593 | 2595 | ||
2594 | return; | 2596 | return; |
2595 | } | 2597 | } |
2596 | if ( loadbup ) { | 2598 | if ( loadbup ) { |
2597 | mView->openCalendar( fn ); | 2599 | mView->openCalendar( fn ); |
2598 | KOPrefs::instance()->mLastLoadFile = fn; | 2600 | KOPrefs::instance()->mLastLoadFile = fn; |
2599 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2601 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2600 | setCaption(mess); | 2602 | setCaption(mess); |
2601 | } | 2603 | } |
2602 | #endif | 2604 | #endif |
2603 | 2605 | ||
2604 | } | 2606 | } |
2605 | void MainWindow::quickImportIcal() | 2607 | void MainWindow::quickImportIcal() |
2606 | { | 2608 | { |
2607 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2609 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2608 | } | 2610 | } |
2609 | void MainWindow::importFile( QString fn, bool quick ) | 2611 | void MainWindow::importFile( QString fn, bool quick ) |
2610 | { | 2612 | { |
2611 | QFileInfo info; | 2613 | QFileInfo info; |
2612 | info.setFile( fn ); | 2614 | info.setFile( fn ); |
2613 | QString mess; | 2615 | QString mess; |
2614 | if ( !info. exists() ) { | 2616 | if ( !info. exists() ) { |
2615 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2617 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2616 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2618 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2617 | mess ); | 2619 | mess ); |
2618 | return; | 2620 | return; |
2619 | } | 2621 | } |
2620 | int result = 0; | 2622 | int result = 0; |
2621 | if ( !quick ) { | 2623 | if ( !quick ) { |
2622 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2624 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2623 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2625 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2624 | mess, | 2626 | mess, |
2625 | "Import", "Cancel", 0, | 2627 | "Import", "Cancel", 0, |
2626 | 0, 1 ); | 2628 | 0, 1 ); |
2627 | } | 2629 | } |
2628 | if ( result == 0 ) { | 2630 | if ( result == 0 ) { |
2629 | if ( mView->openCalendar( fn, true )) { | 2631 | if ( mView->openCalendar( fn, true )) { |
2630 | KOPrefs::instance()->mLastImportFile = fn; | 2632 | KOPrefs::instance()->mLastImportFile = fn; |
2631 | setCaption(i18n("Imported file successfully")); | 2633 | setCaption(i18n("Imported file successfully")); |
2632 | } else { | 2634 | } else { |
2633 | setCaption(i18n("Error importing file")); | 2635 | setCaption(i18n("Error importing file")); |
2634 | } | 2636 | } |
2635 | mView->updateView(); | 2637 | mView->updateView(); |
2636 | } | 2638 | } |
2637 | } | 2639 | } |
2638 | 2640 | ||
2639 | void MainWindow::importIcal() | 2641 | void MainWindow::importIcal() |
2640 | { | 2642 | { |
2641 | 2643 | ||
2642 | QString fn =KOPrefs::instance()->mLastImportFile; | 2644 | QString fn =KOPrefs::instance()->mLastImportFile; |
2643 | 2645 | ||
2644 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2646 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2645 | if ( fn == "" ) | 2647 | if ( fn == "" ) |
2646 | return; | 2648 | return; |
2647 | importFile( fn, true ); | 2649 | importFile( fn, true ); |
2648 | 2650 | ||
2649 | } | 2651 | } |
2650 | void MainWindow::exportCalendar( bool iCalFormat ) | 2652 | void MainWindow::exportCalendar( bool iCalFormat ) |
2651 | { | 2653 | { |
2652 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2654 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2653 | if ( iCalFormat ) { | 2655 | if ( iCalFormat ) { |
2654 | fn = QDir::homeDirPath()+"/kopiexport.ics"; | 2656 | fn = QDir::homeDirPath()+"/kopiexport.ics"; |
2655 | fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); | 2657 | fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); |
2656 | } | 2658 | } |
2657 | else | 2659 | else |
2658 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2660 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2659 | if ( fn == "" ) | 2661 | if ( fn == "" ) |
2660 | return; | 2662 | return; |
2661 | QFileInfo info; | 2663 | QFileInfo info; |
2662 | info.setFile( fn ); | 2664 | info.setFile( fn ); |
2663 | QString mes; | 2665 | QString mes; |
2664 | bool createbup = true; | 2666 | bool createbup = true; |
2665 | if ( info. exists() ) { | 2667 | if ( info. exists() ) { |
2666 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2668 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2667 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2669 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2668 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2670 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2669 | 0, 1 ); | 2671 | 0, 1 ); |
2670 | if ( result != 0 ) { | 2672 | if ( result != 0 ) { |
2671 | createbup = false; | 2673 | createbup = false; |
2672 | } | 2674 | } |
2673 | } | 2675 | } |
2674 | if ( createbup ) { | 2676 | if ( createbup ) { |
2675 | bool success = false; | 2677 | bool success = false; |
2676 | if ( iCalFormat ) | 2678 | if ( iCalFormat ) |
2677 | success = mView->exportICalendar( fn ); | 2679 | success = mView->exportICalendar( fn ); |
2678 | else | 2680 | else |
2679 | success = mView->exportVCalendar( fn ); | 2681 | success = mView->exportVCalendar( fn ); |
2680 | if ( success ) { | 2682 | if ( success ) { |
2681 | if ( fn.length() > 20 ) | 2683 | if ( fn.length() > 20 ) |
2682 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2684 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2683 | else | 2685 | else |
2684 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2686 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2685 | setCaption(mes); | 2687 | setCaption(mes); |
2686 | } | 2688 | } |
2687 | } | 2689 | } |
2688 | 2690 | ||
2689 | } | 2691 | } |
2690 | void MainWindow::exportICalendar() | 2692 | void MainWindow::exportICalendar() |
2691 | { | 2693 | { |
2692 | exportCalendar( true ); | 2694 | exportCalendar( true ); |
2693 | } | 2695 | } |
2694 | void MainWindow::exportVCalendar() | 2696 | void MainWindow::exportVCalendar() |
2695 | { | 2697 | { |
2696 | exportCalendar( false ); | 2698 | exportCalendar( false ); |
2697 | } | 2699 | } |
2698 | QString MainWindow::sentSyncFile() | 2700 | QString MainWindow::sentSyncFile() |
2699 | { | 2701 | { |
2700 | #ifdef DESKTOP_VERSION | 2702 | #ifdef DESKTOP_VERSION |
2701 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); | 2703 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); |
2702 | #else | 2704 | #else |
2703 | return QString( "/tmp/copysynccal.ics" ); | 2705 | return QString( "/tmp/copysynccal.ics" ); |
2704 | #endif | 2706 | #endif |
2705 | } | 2707 | } |
2706 | 2708 | ||
2707 | void MainWindow::syncFileRequest() | 2709 | void MainWindow::syncFileRequest(const QString& resource) |
2708 | { | 2710 | { |
2709 | while ( mSyncManager->blockSave() ) { | 2711 | while ( mSyncManager->blockSave() ) { |
2710 | qApp->processEvents(); | 2712 | qApp->processEvents(); |
2711 | } | 2713 | } |
2712 | mSyncManager->setBlockSave(true); | 2714 | mSyncManager->setBlockSave(true); |
2713 | 2715 | ||
2714 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2716 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2715 | mSyncManager->slotSyncMenu( 999 ); | 2717 | mSyncManager->slotSyncMenu( 999 ); |
2716 | } | 2718 | } |
2717 | 2719 | ||
2718 | setCaption(i18n("Saving Data to temp file ..." )); | 2720 | setCaption(i18n("Saving Data to temp file ..." )); |
2719 | mView->saveCalendar( sentSyncFile() ); | 2721 | mView->saveCalendarResource( sentSyncFile(), resource ); |
2720 | setCaption(i18n("Data saved to temp file!" )); | 2722 | setCaption(i18n("Data saved to temp file!" )); |
2721 | mSyncManager->setBlockSave( false ); | 2723 | mSyncManager->setBlockSave( false ); |
2722 | 2724 | ||
2723 | } | 2725 | } |
2724 | void MainWindow::getFile( bool success ) | 2726 | void MainWindow::getFile( bool success ,const QString& resource) |
2725 | { | 2727 | { |
2726 | if ( ! success ) { | 2728 | if ( ! success ) { |
2727 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2729 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2728 | return; | 2730 | return; |
2729 | } | 2731 | } |
2730 | mView->mergeFile( sentSyncFile() ); | 2732 | mView->mergeFileResource( sentSyncFile(), resource); |
2731 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2733 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2732 | mSyncManager->slotSyncMenu( 999 ); | 2734 | mSyncManager->slotSyncMenu( 999 ); |
2733 | } | 2735 | } |
2734 | setCaption( i18n("Pi-Sync successful!") ); | 2736 | setCaption( i18n("Pi-Sync successful!") ); |
2735 | } | 2737 | } |
2736 | void MainWindow::printListView() | 2738 | void MainWindow::printListView() |
2737 | { | 2739 | { |
2738 | 2740 | ||
2739 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); | 2741 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); |
2740 | 2742 | ||
2741 | KMessageBox::information( this, message); | 2743 | KMessageBox::information( this, message); |
2742 | } | 2744 | } |
2743 | void MainWindow::printSel( ) | 2745 | void MainWindow::printSel( ) |
2744 | { | 2746 | { |
2745 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2747 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2746 | } | 2748 | } |
2747 | 2749 | ||
2748 | void MainWindow::printCal() | 2750 | void MainWindow::printCal() |
2749 | { | 2751 | { |
2750 | mView->print();//mCp->showDialog(); | 2752 | mView->print();//mCp->showDialog(); |
2751 | } | 2753 | } |
2752 | 2754 | ||
2753 | 2755 | ||
2754 | #include "libkdepim/kdatepicker.h" | 2756 | #include "libkdepim/kdatepicker.h" |
2755 | #include <kdatetbl.h> | 2757 | #include <kdatetbl.h> |
2756 | 2758 | ||
2757 | void MainWindow::weekAction() | 2759 | void MainWindow::weekAction() |
2758 | { | 2760 | { |
2759 | int month; | 2761 | int month; |
2760 | KPopupFrame* popup = new KPopupFrame(this); | 2762 | KPopupFrame* popup = new KPopupFrame(this); |
2761 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2763 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2762 | // ----- | 2764 | // ----- |
2763 | picker->resize(picker->sizeHint()); | 2765 | picker->resize(picker->sizeHint()); |
2764 | popup->setMainWidget(picker); | 2766 | popup->setMainWidget(picker); |
2765 | picker->setFocus(); | 2767 | picker->setFocus(); |
2766 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2768 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2767 | int x = 0; | 2769 | int x = 0; |
2768 | int y = iconToolBar->height(); | 2770 | int y = iconToolBar->height(); |
2769 | int dX = 0; | 2771 | int dX = 0; |
2770 | int dY = 0; | 2772 | int dY = 0; |
2771 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2773 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2772 | if ( iconToolBar->y() > height()/2 ) { | 2774 | if ( iconToolBar->y() > height()/2 ) { |
2773 | dY = picker->sizeHint().height()+8; | 2775 | dY = picker->sizeHint().height()+8; |
2774 | y = 0; | 2776 | y = 0; |
2775 | } | 2777 | } |
2776 | } else { | 2778 | } else { |
2777 | if ( iconToolBar->x() > width()/2 ) { // right side | 2779 | if ( iconToolBar->x() > width()/2 ) { // right side |
2778 | x=0; | 2780 | x=0; |
2779 | dX= picker->sizeHint().width()+8; | 2781 | dX= picker->sizeHint().width()+8; |
2780 | y = 0; | 2782 | y = 0; |
2781 | } else { | 2783 | } else { |
2782 | x= iconToolBar->width(); | 2784 | x= iconToolBar->width(); |
2783 | y = 0; | 2785 | y = 0; |
2784 | } | 2786 | } |
2785 | } | 2787 | } |
2786 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2788 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2787 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2789 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2788 | { | 2790 | { |
2789 | month = picker->getResult(); | 2791 | month = picker->getResult(); |
2790 | emit selectWeek ( month ); | 2792 | emit selectWeek ( month ); |
2791 | //qDebug("weekSelected %d ", month); | 2793 | //qDebug("weekSelected %d ", month); |
2792 | } | 2794 | } |
2793 | delete popup; | 2795 | delete popup; |
2794 | } | 2796 | } |
2795 | 2797 | ||
2796 | void MainWindow::hideEvent ( QHideEvent * ) | 2798 | void MainWindow::hideEvent ( QHideEvent * ) |
2797 | { | 2799 | { |
2798 | QString message; | 2800 | QString message; |
2799 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2801 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2800 | if ( nextA.isValid() ) { | 2802 | if ( nextA.isValid() ) { |
2801 | QString sum = mCalendar->nextSummary(); | 2803 | QString sum = mCalendar->nextSummary(); |
2802 | 2804 | ||
2803 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); | 2805 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); |
2804 | setCaption( message ); | 2806 | setCaption( message ); |
2805 | } | 2807 | } |
2806 | } | 2808 | } |
2807 | 2809 | ||
2808 | void MainWindow::resizeEvent( QResizeEvent* e) | 2810 | void MainWindow::resizeEvent( QResizeEvent* e) |
2809 | { | 2811 | { |
2810 | #ifndef DESKTOP_VERSION | 2812 | #ifndef DESKTOP_VERSION |
2811 | if ( filterToolBar ) { | 2813 | if ( filterToolBar ) { |
2812 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2814 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2813 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2815 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2814 | filterToolBar->hide(); | 2816 | filterToolBar->hide(); |
2815 | else | 2817 | else |
2816 | filterToolBar->show(); | 2818 | filterToolBar->show(); |
2817 | } | 2819 | } |
2818 | } | 2820 | } |
2819 | #endif | 2821 | #endif |
2820 | QMainWindow::resizeEvent( e); | 2822 | QMainWindow::resizeEvent( e); |
2821 | } | 2823 | } |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index d8018b6..a533d8b 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,191 +1,191 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qmenubar.h> | 8 | #include <qmenubar.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qregexp.h> | 10 | #include <qregexp.h> |
11 | 11 | ||
12 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
13 | #include <ksyncmanager.h> | 13 | #include <ksyncmanager.h> |
14 | #include <kpopupmenu.h> | 14 | #include <kpopupmenu.h> |
15 | #ifndef DESKTOP_VERSION | 15 | #ifndef DESKTOP_VERSION |
16 | #include <qcopchannel_qws.h> | 16 | #include <qcopchannel_qws.h> |
17 | #endif | 17 | #endif |
18 | class QAction; | 18 | class QAction; |
19 | class CalendarView; | 19 | class CalendarView; |
20 | class KSyncProfile; | 20 | class KSyncProfile; |
21 | #ifdef DESKTOP_VERSION | 21 | #ifdef DESKTOP_VERSION |
22 | 22 | ||
23 | #define QPEToolBar QToolBar | 23 | #define QPEToolBar QToolBar |
24 | #endif | 24 | #endif |
25 | class QPEToolBar; | 25 | class QPEToolBar; |
26 | 26 | ||
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | class CalendarLocal; | 29 | class CalendarLocal; |
30 | } | 30 | } |
31 | 31 | ||
32 | using namespace KCal; | 32 | using namespace KCal; |
33 | 33 | ||
34 | class MainWindow : public QMainWindow | 34 | class MainWindow : public QMainWindow |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | MainWindow( QWidget *parent = 0, const char *name = 0 ); | 38 | MainWindow( QWidget *parent = 0, const char *name = 0 ); |
39 | ~MainWindow(); | 39 | ~MainWindow(); |
40 | bool beamReceiveEnabled(); | 40 | bool beamReceiveEnabled(); |
41 | static QString defaultFileName(); | 41 | static QString defaultFileName(); |
42 | static QString syncFileName(); | 42 | static QString syncFileName(); |
43 | static QString resourcePath(); | 43 | static QString resourcePath(); |
44 | public slots: | 44 | public slots: |
45 | void setUsesBigPixmaps ( bool ); | 45 | void setUsesBigPixmaps ( bool ); |
46 | void setCaption ( const QString & ); | 46 | void setCaption ( const QString & ); |
47 | void updateWeekNum(const KCal::DateList &); | 47 | void updateWeekNum(const KCal::DateList &); |
48 | void updateWeek(QDate); | 48 | void updateWeek(QDate); |
49 | void updateFilterToolbar(); | 49 | void updateFilterToolbar(); |
50 | virtual void showMaximized (); | 50 | virtual void showMaximized (); |
51 | void configureAgenda( int ); | 51 | void configureAgenda( int ); |
52 | void recieve( const QCString& msg, const QByteArray& data ); | 52 | void recieve( const QCString& msg, const QByteArray& data ); |
53 | void receiveStart( const QCString& msg, const QByteArray& data ); | 53 | void receiveStart( const QCString& msg, const QByteArray& data ); |
54 | protected slots: | 54 | protected slots: |
55 | void autoSaveWarning(); | 55 | void autoSaveWarning(); |
56 | void loadDataAfterStart(); | 56 | void loadDataAfterStart(); |
57 | void calHint(); | 57 | void calHint(); |
58 | void startMultiSync(); | 58 | void startMultiSync(); |
59 | void setCaptionToDates(); | 59 | void setCaptionToDates(); |
60 | void weekAction(); | 60 | void weekAction(); |
61 | void about(); | 61 | void about(); |
62 | void licence(); | 62 | void licence(); |
63 | void faq(); | 63 | void faq(); |
64 | void usertrans(); | 64 | void usertrans(); |
65 | void features(); | 65 | void features(); |
66 | void synchowto(); | 66 | void synchowto(); |
67 | void storagehowto(); | 67 | void storagehowto(); |
68 | void timetrackinghowto(); | 68 | void timetrackinghowto(); |
69 | void kdesynchowto(); | 69 | void kdesynchowto(); |
70 | void multisynchowto(); | 70 | void multisynchowto(); |
71 | void whatsNew(); | 71 | void whatsNew(); |
72 | void keyBindings(); | 72 | void keyBindings(); |
73 | void aboutAutoSaving();; | 73 | void aboutAutoSaving();; |
74 | void aboutKnownBugs(); | 74 | void aboutKnownBugs(); |
75 | 75 | ||
76 | void processIncidenceSelection( Incidence * ); | 76 | void processIncidenceSelection( Incidence * ); |
77 | 77 | ||
78 | void importQtopia(); | 78 | void importQtopia(); |
79 | void importBday(); | 79 | void importBday(); |
80 | void importOL(); | 80 | void importOL(); |
81 | void importIcal(); | 81 | void importIcal(); |
82 | void importFile( QString, bool ); | 82 | void importFile( QString, bool ); |
83 | void quickImportIcal(); | 83 | void quickImportIcal(); |
84 | 84 | ||
85 | void slotModifiedChanged( bool ); | 85 | void slotModifiedChanged( bool ); |
86 | 86 | ||
87 | void save(); | 87 | void save(); |
88 | void backupAllFiles(); | 88 | void backupAllFiles(); |
89 | void saveStopTimer(); | 89 | void saveStopTimer(); |
90 | void configureToolBar( int ); | 90 | void configureToolBar( int ); |
91 | void printSel(); | 91 | void printSel(); |
92 | void printCal(); | 92 | void printCal(); |
93 | void printListView(); | 93 | void printListView(); |
94 | void saveCalendar(); | 94 | void saveCalendar(); |
95 | void loadCalendar(); | 95 | void loadCalendar(); |
96 | void exportVCalendar(); | 96 | void exportVCalendar(); |
97 | void exportICalendar(); | 97 | void exportICalendar(); |
98 | void exportCalendar( bool ); | 98 | void exportCalendar( bool ); |
99 | void fillFilterMenu(); | 99 | void fillFilterMenu(); |
100 | void fillFilterMenuTB(); | 100 | void fillFilterMenuTB(); |
101 | void selectFilter( int ); | 101 | void selectFilter( int ); |
102 | void fillFilterMenuPopup(); | 102 | void fillFilterMenuPopup(); |
103 | void selectFilterPopup( int ); | 103 | void selectFilterPopup( int ); |
104 | void exportToPhone( int ); | 104 | void exportToPhone( int ); |
105 | void toggleBeamReceive(); | 105 | void toggleBeamReceive(); |
106 | void disableBR(bool); | 106 | void disableBR(bool); |
107 | signals: | 107 | signals: |
108 | void selectWeek ( int ); | 108 | void selectWeek ( int ); |
109 | private slots: | 109 | private slots: |
110 | void slotResetFocus(); | 110 | void slotResetFocus(); |
111 | void slotResetFocusLoop(); | 111 | void slotResetFocusLoop(); |
112 | void showConfigureAgenda(); | 112 | void showConfigureAgenda(); |
113 | void getFile( bool ); | 113 | void getFile( bool ,const QString &); |
114 | void syncFileRequest(); | 114 | void syncFileRequest(const QString &); |
115 | 115 | ||
116 | protected: | 116 | protected: |
117 | int mFocusLoop; | 117 | int mFocusLoop; |
118 | void hideEvent ( QHideEvent * ); | 118 | void hideEvent ( QHideEvent * ); |
119 | QString sentSyncFile(); | 119 | QString sentSyncFile(); |
120 | void displayText( QString, QString); | 120 | void displayText( QString, QString); |
121 | void enableIncidenceActions( bool ); | 121 | void enableIncidenceActions( bool ); |
122 | bool askForQuitOnSaveError(); | 122 | bool askForQuitOnSaveError(); |
123 | 123 | ||
124 | private: | 124 | private: |
125 | bool mAutoSaveDisabled; | 125 | bool mAutoSaveDisabled; |
126 | bool checkAutosave(); | 126 | bool checkAutosave(); |
127 | QCString mCStringMess; | 127 | QCString mCStringMess; |
128 | QByteArray mByteData; | 128 | QByteArray mByteData; |
129 | 129 | ||
130 | //void setMenuBar( QMenuBar * ); | 130 | //void setMenuBar( QMenuBar * ); |
131 | bool mBRdisabled; | 131 | bool mBRdisabled; |
132 | #ifndef DESKTOP_VERSION | 132 | #ifndef DESKTOP_VERSION |
133 | QCopChannel* infrared; | 133 | QCopChannel* infrared; |
134 | #endif | 134 | #endif |
135 | QAction* brAction; | 135 | QAction* brAction; |
136 | KSyncManager* mSyncManager; | 136 | KSyncManager* mSyncManager; |
137 | bool mClosed; | 137 | bool mClosed; |
138 | void saveOnClose(); | 138 | void saveOnClose(); |
139 | bool mFlagKeyPressed; | 139 | bool mFlagKeyPressed; |
140 | bool mBlockAtStartup; | 140 | bool mBlockAtStartup; |
141 | KMenuBar *menuBar1; | 141 | KMenuBar *menuBar1; |
142 | QPEToolBar *iconToolBar; | 142 | QPEToolBar *iconToolBar; |
143 | QPEToolBar *viewToolBar; | 143 | QPEToolBar *viewToolBar; |
144 | QPEToolBar *navigatorToolBar; | 144 | QPEToolBar *navigatorToolBar; |
145 | QPEToolBar *filterToolBar; | 145 | QPEToolBar *filterToolBar; |
146 | KMenuBar *filterMenubar; | 146 | KMenuBar *filterMenubar; |
147 | QPopupMenu * filterPopupMenu; | 147 | QPopupMenu * filterPopupMenu; |
148 | QPopupMenu * mCurrentItemMenu; | 148 | QPopupMenu * mCurrentItemMenu; |
149 | void initActions(); | 149 | void initActions(); |
150 | void setDefaultPreferences(); | 150 | void setDefaultPreferences(); |
151 | void resizeEvent( QResizeEvent* e); | 151 | void resizeEvent( QResizeEvent* e); |
152 | void keyPressEvent ( QKeyEvent * ) ; | 152 | void keyPressEvent ( QKeyEvent * ) ; |
153 | void keyReleaseEvent ( QKeyEvent * ) ; | 153 | void keyReleaseEvent ( QKeyEvent * ) ; |
154 | QPopupMenu *configureToolBarMenu; | 154 | QPopupMenu *configureToolBarMenu; |
155 | QPopupMenu *selectFilterMenu; | 155 | QPopupMenu *selectFilterMenu; |
156 | QPopupMenu *selectFilterMenuTB; | 156 | QPopupMenu *selectFilterMenuTB; |
157 | QPopupMenu *configureAgendaMenu, *syncMenu; | 157 | QPopupMenu *configureAgendaMenu, *syncMenu; |
158 | CalendarLocal *mCalendar; | 158 | CalendarLocal *mCalendar; |
159 | CalendarView *mView; | 159 | CalendarView *mView; |
160 | QAction *mNewSubTodoAction; | 160 | QAction *mNewSubTodoAction; |
161 | QAction *mWeekAction; | 161 | QAction *mWeekAction; |
162 | QFont mWeekFont; | 162 | QFont mWeekFont; |
163 | QPixmap mWeekPixmap; | 163 | QPixmap mWeekPixmap; |
164 | QColor mWeekBgColor; | 164 | QColor mWeekBgColor; |
165 | 165 | ||
166 | QAction *mShowAction; | 166 | QAction *mShowAction; |
167 | QAction *mEditAction; | 167 | QAction *mEditAction; |
168 | QAction *mDeleteAction; | 168 | QAction *mDeleteAction; |
169 | QAction *mCloneAction; | 169 | QAction *mCloneAction; |
170 | QAction *mMoveAction; | 170 | QAction *mMoveAction; |
171 | QAction *mBeamAction; | 171 | QAction *mBeamAction; |
172 | QAction *mCancelAction; | 172 | QAction *mCancelAction; |
173 | QAction *mPrintSelAction; | 173 | QAction *mPrintSelAction; |
174 | 174 | ||
175 | QAction *mToggleNav; | 175 | QAction *mToggleNav; |
176 | QAction *mToggleFilter; | 176 | QAction *mToggleFilter; |
177 | QAction *mToggleAllday; | 177 | QAction *mToggleAllday; |
178 | QAction *actionFilterMenuTB; | 178 | QAction *actionFilterMenuTB; |
179 | 179 | ||
180 | void closeEvent( QCloseEvent* ce ); | 180 | void closeEvent( QCloseEvent* ce ); |
181 | QTimer mSaveTimer; | 181 | QTimer mSaveTimer; |
182 | QDateTime mSaveTimerStart; | 182 | QDateTime mSaveTimerStart; |
183 | int mSaveDelay; | 183 | int mSaveDelay; |
184 | //bool mBlockSaveFlag; | 184 | //bool mBlockSaveFlag; |
185 | bool mCalendarModifiedFlag; | 185 | bool mCalendarModifiedFlag; |
186 | QPixmap loadPixmap( QString ); | 186 | QPixmap loadPixmap( QString ); |
187 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; | 187 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; |
188 | }; | 188 | }; |
189 | 189 | ||
190 | 190 | ||
191 | #endif | 191 | #endif |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 4b8b3ff..0a94914 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,382 +1,383 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | virtual void addCalendar( Calendar* ) = 0; | 77 | virtual void addCalendar( Calendar* ) = 0; |
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual bool mergeCalendarFile( QString name ) = 0; | 79 | virtual bool mergeCalendarFile( QString name ) = 0; |
80 | virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; | 80 | virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; |
81 | virtual void setSyncEventsReadOnly() = 0; | 81 | virtual void setSyncEventsReadOnly() = 0; |
82 | virtual void setSyncEventsEnabled() = 0; | ||
82 | virtual void stopAllTodos() = 0; | 83 | virtual void stopAllTodos() = 0; |
83 | virtual void clearUndo( Incidence * newUndo ); | 84 | virtual void clearUndo( Incidence * newUndo ); |
84 | 85 | ||
85 | /** | 86 | /** |
86 | Sync changes in memory to persistant storage. | 87 | Sync changes in memory to persistant storage. |
87 | */ | 88 | */ |
88 | virtual void save() = 0; | 89 | virtual void save() = 0; |
89 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 90 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
90 | virtual void removeSyncInfo( QString syncProfile) = 0; | 91 | virtual void removeSyncInfo( QString syncProfile) = 0; |
91 | virtual bool isSaving() { return false; } | 92 | virtual bool isSaving() { return false; } |
92 | 93 | ||
93 | /** | 94 | /** |
94 | Return the owner of the calendar's full name. | 95 | Return the owner of the calendar's full name. |
95 | */ | 96 | */ |
96 | const QString &getOwner() const; | 97 | const QString &getOwner() const; |
97 | /** | 98 | /** |
98 | Set the owner of the calendar. Should be owner's full name. | 99 | Set the owner of the calendar. Should be owner's full name. |
99 | */ | 100 | */ |
100 | void setOwner( const QString &os ); | 101 | void setOwner( const QString &os ); |
101 | /** | 102 | /** |
102 | Return the email address of the calendar owner. | 103 | Return the email address of the calendar owner. |
103 | */ | 104 | */ |
104 | const QString &getEmail(); | 105 | const QString &getEmail(); |
105 | /** | 106 | /** |
106 | Set the email address of the calendar owner. | 107 | Set the email address of the calendar owner. |
107 | */ | 108 | */ |
108 | void setEmail( const QString & ); | 109 | void setEmail( const QString & ); |
109 | 110 | ||
110 | /** | 111 | /** |
111 | Set time zone from a timezone string (e.g. -2:00) | 112 | Set time zone from a timezone string (e.g. -2:00) |
112 | */ | 113 | */ |
113 | void setTimeZone( const QString &tz ); | 114 | void setTimeZone( const QString &tz ); |
114 | /** | 115 | /** |
115 | Set time zone from a minutes value (e.g. -60) | 116 | Set time zone from a minutes value (e.g. -60) |
116 | */ | 117 | */ |
117 | void setTimeZone( int tz ); | 118 | void setTimeZone( int tz ); |
118 | /** | 119 | /** |
119 | Return time zone as offest in minutes. | 120 | Return time zone as offest in minutes. |
120 | */ | 121 | */ |
121 | int getTimeZone() const; | 122 | int getTimeZone() const; |
122 | /** | 123 | /** |
123 | Compute an ISO 8601 format string from the time zone. | 124 | Compute an ISO 8601 format string from the time zone. |
124 | */ | 125 | */ |
125 | QString getTimeZoneStr() const; | 126 | QString getTimeZoneStr() const; |
126 | /** | 127 | /** |
127 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 128 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
128 | values). | 129 | values). |
129 | */ | 130 | */ |
130 | void setTimeZoneId( const QString & ); | 131 | void setTimeZoneId( const QString & ); |
131 | /** | 132 | /** |
132 | Return time zone id. | 133 | Return time zone id. |
133 | */ | 134 | */ |
134 | QString timeZoneId() const; | 135 | QString timeZoneId() const; |
135 | /** | 136 | /** |
136 | Use local time, not UTC or a time zone. | 137 | Use local time, not UTC or a time zone. |
137 | */ | 138 | */ |
138 | void setLocalTime(); | 139 | void setLocalTime(); |
139 | /** | 140 | /** |
140 | Return whether local time is being used. | 141 | Return whether local time is being used. |
141 | */ | 142 | */ |
142 | bool isLocalTime() const; | 143 | bool isLocalTime() const; |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Add an incidence to calendar. | 146 | Add an incidence to calendar. |
146 | 147 | ||
147 | @return true on success, false on error. | 148 | @return true on success, false on error. |
148 | */ | 149 | */ |
149 | virtual bool addIncidence( Incidence * ); | 150 | virtual bool addIncidence( Incidence * ); |
150 | 151 | ||
151 | // Adds an incidence and all relatedto incidences to the cal | 152 | // Adds an incidence and all relatedto incidences to the cal |
152 | void addIncidenceBranch( Incidence * ); | 153 | void addIncidenceBranch( Incidence * ); |
153 | /** | 154 | /** |
154 | Return filtered list of all incidences of this calendar. | 155 | Return filtered list of all incidences of this calendar. |
155 | */ | 156 | */ |
156 | virtual QPtrList<Incidence> incidences(); | 157 | virtual QPtrList<Incidence> incidences(); |
157 | 158 | ||
158 | /** | 159 | /** |
159 | Return unfiltered list of all incidences of this calendar. | 160 | Return unfiltered list of all incidences of this calendar. |
160 | */ | 161 | */ |
161 | virtual QPtrList<Incidence> rawIncidences(); | 162 | virtual QPtrList<Incidence> rawIncidences(); |
162 | 163 | ||
163 | /** | 164 | /** |
164 | Adds a Event to this calendar object. | 165 | Adds a Event to this calendar object. |
165 | @param anEvent a pointer to the event to add | 166 | @param anEvent a pointer to the event to add |
166 | 167 | ||
167 | @return true on success, false on error. | 168 | @return true on success, false on error. |
168 | */ | 169 | */ |
169 | virtual bool addEventNoDup( Event *event ) = 0; | 170 | virtual bool addEventNoDup( Event *event ) = 0; |
170 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 171 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
171 | virtual bool addEvent( Event *anEvent ) = 0; | 172 | virtual bool addEvent( Event *anEvent ) = 0; |
172 | /** | 173 | /** |
173 | Delete event from calendar. | 174 | Delete event from calendar. |
174 | */ | 175 | */ |
175 | virtual void deleteEvent( Event * ) = 0; | 176 | virtual void deleteEvent( Event * ) = 0; |
176 | /** | 177 | /** |
177 | Retrieves an event on the basis of the unique string ID. | 178 | Retrieves an event on the basis of the unique string ID. |
178 | */ | 179 | */ |
179 | virtual Event *event( const QString &UniqueStr ) = 0; | 180 | virtual Event *event( const QString &UniqueStr ) = 0; |
180 | virtual Event *event( QString, QString ) = 0; | 181 | virtual Event *event( QString, QString ) = 0; |
181 | /** | 182 | /** |
182 | Builds and then returns a list of all events that match for the | 183 | Builds and then returns a list of all events that match for the |
183 | date specified. useful for dayView, etc. etc. | 184 | date specified. useful for dayView, etc. etc. |
184 | The calendar filter is applied. | 185 | The calendar filter is applied. |
185 | */ | 186 | */ |
186 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 187 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
187 | /** | 188 | /** |
188 | Get events, which occur on the given date. | 189 | Get events, which occur on the given date. |
189 | The calendar filter is applied. | 190 | The calendar filter is applied. |
190 | */ | 191 | */ |
191 | QPtrList<Event> events( const QDateTime &qdt ); | 192 | QPtrList<Event> events( const QDateTime &qdt ); |
192 | /** | 193 | /** |
193 | Get events in a range of dates. If inclusive is set to true, only events | 194 | Get events in a range of dates. If inclusive is set to true, only events |
194 | are returned, which are completely included in the range. | 195 | are returned, which are completely included in the range. |
195 | The calendar filter is applied. | 196 | The calendar filter is applied. |
196 | */ | 197 | */ |
197 | QPtrList<Event> events( const QDate &start, const QDate &end, | 198 | QPtrList<Event> events( const QDate &start, const QDate &end, |
198 | bool inclusive = false); | 199 | bool inclusive = false); |
199 | /** | 200 | /** |
200 | Return filtered list of all events in calendar. | 201 | Return filtered list of all events in calendar. |
201 | */ | 202 | */ |
202 | virtual QPtrList<Event> events(); | 203 | virtual QPtrList<Event> events(); |
203 | /** | 204 | /** |
204 | Return unfiltered list of all events in calendar. | 205 | Return unfiltered list of all events in calendar. |
205 | */ | 206 | */ |
206 | virtual QPtrList<Event> rawEvents() = 0; | 207 | virtual QPtrList<Event> rawEvents() = 0; |
207 | 208 | ||
208 | /** | 209 | /** |
209 | Add a todo to the todolist. | 210 | Add a todo to the todolist. |
210 | 211 | ||
211 | @return true on success, false on error. | 212 | @return true on success, false on error. |
212 | */ | 213 | */ |
213 | virtual bool addTodo( Todo *todo ) = 0; | 214 | virtual bool addTodo( Todo *todo ) = 0; |
214 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 215 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
215 | /** | 216 | /** |
216 | Remove a todo from the todolist. | 217 | Remove a todo from the todolist. |
217 | */ | 218 | */ |
218 | virtual void deleteTodo( Todo * ) = 0; | 219 | virtual void deleteTodo( Todo * ) = 0; |
219 | virtual void deleteJournal( Journal * ) = 0; | 220 | virtual void deleteJournal( Journal * ) = 0; |
220 | /** | 221 | /** |
221 | Return filterd list of todos. | 222 | Return filterd list of todos. |
222 | */ | 223 | */ |
223 | virtual QPtrList<Todo> todos(); | 224 | virtual QPtrList<Todo> todos(); |
224 | /** | 225 | /** |
225 | Searches todolist for an event with this unique string identifier, | 226 | Searches todolist for an event with this unique string identifier, |
226 | returns a pointer or null. | 227 | returns a pointer or null. |
227 | */ | 228 | */ |
228 | virtual Todo *todo( const QString &uid ) = 0; | 229 | virtual Todo *todo( const QString &uid ) = 0; |
229 | virtual Todo *todo( QString, QString ) = 0; | 230 | virtual Todo *todo( QString, QString ) = 0; |
230 | /** | 231 | /** |
231 | Returns list of todos due on the specified date. | 232 | Returns list of todos due on the specified date. |
232 | */ | 233 | */ |
233 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 234 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
234 | /** | 235 | /** |
235 | Return unfiltered list of todos. | 236 | Return unfiltered list of todos. |
236 | */ | 237 | */ |
237 | virtual QPtrList<Todo> rawTodos() = 0; | 238 | virtual QPtrList<Todo> rawTodos() = 0; |
238 | 239 | ||
239 | /** | 240 | /** |
240 | Add a Journal entry to calendar. | 241 | Add a Journal entry to calendar. |
241 | 242 | ||
242 | @return true on success, false on error. | 243 | @return true on success, false on error. |
243 | */ | 244 | */ |
244 | virtual bool addJournal( Journal * ) = 0; | 245 | virtual bool addJournal( Journal * ) = 0; |
245 | /** | 246 | /** |
246 | Return Journal for given date. | 247 | Return Journal for given date. |
247 | */ | 248 | */ |
248 | virtual Journal *journal( const QDate & ) = 0; | 249 | virtual Journal *journal( const QDate & ) = 0; |
249 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; | 250 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; |
250 | /** | 251 | /** |
251 | Return Journal with given UID. | 252 | Return Journal with given UID. |
252 | */ | 253 | */ |
253 | virtual Journal *journal( const QString &UID ) = 0; | 254 | virtual Journal *journal( const QString &UID ) = 0; |
254 | /** | 255 | /** |
255 | Return list of all Journal entries. | 256 | Return list of all Journal entries. |
256 | */ | 257 | */ |
257 | virtual QPtrList<Journal> journals() = 0; | 258 | virtual QPtrList<Journal> journals() = 0; |
258 | 259 | ||
259 | /** | 260 | /** |
260 | Searches all incidence types for an incidence with this unique | 261 | Searches all incidence types for an incidence with this unique |
261 | string identifier, returns a pointer or null. | 262 | string identifier, returns a pointer or null. |
262 | */ | 263 | */ |
263 | Incidence* incidence( const QString&UID ); | 264 | Incidence* incidence( const QString&UID ); |
264 | 265 | ||
265 | /** | 266 | /** |
266 | Setup relations for an incidence. | 267 | Setup relations for an incidence. |
267 | */ | 268 | */ |
268 | virtual void setupRelations( Incidence * ); | 269 | virtual void setupRelations( Incidence * ); |
269 | /** | 270 | /** |
270 | Remove all relations to an incidence | 271 | Remove all relations to an incidence |
271 | */ | 272 | */ |
272 | virtual void removeRelations( Incidence * ); | 273 | virtual void removeRelations( Incidence * ); |
273 | 274 | ||
274 | /** | 275 | /** |
275 | Set calendar filter, which filters events for the events() functions. | 276 | Set calendar filter, which filters events for the events() functions. |
276 | The Filter object is owned by the caller. | 277 | The Filter object is owned by the caller. |
277 | */ | 278 | */ |
278 | void setFilter( CalFilter * ); | 279 | void setFilter( CalFilter * ); |
279 | /** | 280 | /** |
280 | Return calendar filter. | 281 | Return calendar filter. |
281 | */ | 282 | */ |
282 | CalFilter *filter(); | 283 | CalFilter *filter(); |
283 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 284 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
284 | virtual QString nextSummary( ) const = 0; | 285 | virtual QString nextSummary( ) const = 0; |
285 | virtual void reInitAlarmSettings() = 0; | 286 | virtual void reInitAlarmSettings() = 0; |
286 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 287 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
287 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 288 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
288 | /** | 289 | /** |
289 | Return all alarms, which ocur in the given time interval. | 290 | Return all alarms, which ocur in the given time interval. |
290 | */ | 291 | */ |
291 | virtual Alarm::List alarms( const QDateTime &from, | 292 | virtual Alarm::List alarms( const QDateTime &from, |
292 | const QDateTime &to ) = 0; | 293 | const QDateTime &to ) = 0; |
293 | 294 | ||
294 | class Observer { | 295 | class Observer { |
295 | public: | 296 | public: |
296 | virtual void calendarModified( bool, Calendar * ) = 0; | 297 | virtual void calendarModified( bool, Calendar * ) = 0; |
297 | }; | 298 | }; |
298 | 299 | ||
299 | void registerObserver( Observer * ); | 300 | void registerObserver( Observer * ); |
300 | 301 | ||
301 | void setModified( bool ); | 302 | void setModified( bool ); |
302 | 303 | ||
303 | /** | 304 | /** |
304 | Set product id returned by loadedProductId(). This function is only | 305 | Set product id returned by loadedProductId(). This function is only |
305 | useful for the calendar loading code. | 306 | useful for the calendar loading code. |
306 | */ | 307 | */ |
307 | void setLoadedProductId( const QString & ); | 308 | void setLoadedProductId( const QString & ); |
308 | /** | 309 | /** |
309 | Return product id taken from file that has been loaded. Returns | 310 | Return product id taken from file that has been loaded. Returns |
310 | QString::null, if no calendar has been loaded. | 311 | QString::null, if no calendar has been loaded. |
311 | */ | 312 | */ |
312 | QString loadedProductId(); | 313 | QString loadedProductId(); |
313 | int defaultCalendar(); | 314 | int defaultCalendar(); |
314 | void setDontDeleteIncidencesOnClose (); | 315 | void setDontDeleteIncidencesOnClose (); |
315 | public slots: | 316 | public slots: |
316 | void setDefaultCalendar( int ); | 317 | void setDefaultCalendar( int ); |
317 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 318 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
318 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 319 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
319 | virtual void setReadOnly( int id, bool enable ) = 0; | 320 | virtual void setReadOnly( int id, bool enable ) = 0; |
320 | virtual void setDefaultCalendarEnabledOnly() = 0; | 321 | virtual void setDefaultCalendarEnabledOnly() = 0; |
321 | virtual void setCalendarRemove( int id ) = 0; | 322 | virtual void setCalendarRemove( int id ) = 0; |
322 | virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0; | 323 | virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0; |
323 | 324 | ||
324 | signals: | 325 | signals: |
325 | void calendarChanged(); | 326 | void calendarChanged(); |
326 | void calendarSaved(); | 327 | void calendarSaved(); |
327 | void calendarLoaded(); | 328 | void calendarLoaded(); |
328 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 329 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
329 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 330 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
330 | 331 | ||
331 | protected: | 332 | protected: |
332 | /** | 333 | /** |
333 | Get unfiltered events, which occur on the given date. | 334 | Get unfiltered events, which occur on the given date. |
334 | */ | 335 | */ |
335 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 336 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
336 | /** | 337 | /** |
337 | Get unfiltered events, which occur on the given date. | 338 | Get unfiltered events, which occur on the given date. |
338 | */ | 339 | */ |
339 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 340 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
340 | bool sorted = false ) = 0; | 341 | bool sorted = false ) = 0; |
341 | /** | 342 | /** |
342 | Get events in a range of dates. If inclusive is set to true, only events | 343 | Get events in a range of dates. If inclusive is set to true, only events |
343 | are returned, which are completely included in the range. | 344 | are returned, which are completely included in the range. |
344 | */ | 345 | */ |
345 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 346 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
346 | bool inclusive = false ) = 0; | 347 | bool inclusive = false ) = 0; |
347 | 348 | ||
348 | Incidence *mNextAlarmIncidence; | 349 | Incidence *mNextAlarmIncidence; |
349 | Incidence *mUndoIncidence; | 350 | Incidence *mUndoIncidence; |
350 | int mDefaultCalendar; | 351 | int mDefaultCalendar; |
351 | bool mDeleteIncidencesOnClose; | 352 | bool mDeleteIncidencesOnClose; |
352 | 353 | ||
353 | private: | 354 | private: |
354 | void init(); | 355 | void init(); |
355 | 356 | ||
356 | QString mOwner; // who the calendar belongs to | 357 | QString mOwner; // who the calendar belongs to |
357 | QString mOwnerEmail; // email address of the owner | 358 | QString mOwnerEmail; // email address of the owner |
358 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 359 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
359 | bool mLocalTime; // use local time, not UTC or a time zone | 360 | bool mLocalTime; // use local time, not UTC or a time zone |
360 | 361 | ||
361 | 362 | ||
362 | CalFilter *mFilter; | 363 | CalFilter *mFilter; |
363 | CalFilter *mDefaultFilter; | 364 | CalFilter *mDefaultFilter; |
364 | 365 | ||
365 | 366 | ||
366 | QString mTimeZoneId; | 367 | QString mTimeZoneId; |
367 | 368 | ||
368 | Observer *mObserver; | 369 | Observer *mObserver; |
369 | bool mNewObserver; | 370 | bool mNewObserver; |
370 | 371 | ||
371 | bool mModified; | 372 | bool mModified; |
372 | 373 | ||
373 | QString mLoadedProductId; | 374 | QString mLoadedProductId; |
374 | 375 | ||
375 | // This list is used to put together related todos | 376 | // This list is used to put together related todos |
376 | QDict<Incidence> mOrphans; | 377 | QDict<Incidence> mOrphans; |
377 | QDict<Incidence> mOrphanUids; | 378 | QDict<Incidence> mOrphanUids; |
378 | }; | 379 | }; |
379 | 380 | ||
380 | } | 381 | } |
381 | 382 | ||
382 | #endif | 383 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 0ddfeca..45e3128 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,566 +1,578 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | registerObserver( 0 ); | 68 | registerObserver( 0 ); |
69 | if ( mDeleteIncidencesOnClose ) | 69 | if ( mDeleteIncidencesOnClose ) |
70 | close(); | 70 | close(); |
71 | } | 71 | } |
72 | bool CalendarLocal::mergeCalendarFile( QString name ) | 72 | bool CalendarLocal::mergeCalendarFile( QString name ) |
73 | { | 73 | { |
74 | CalendarLocal calendar( timeZoneId() ); | 74 | CalendarLocal calendar( timeZoneId() ); |
75 | calendar.setDefaultCalendar( 1 ); | 75 | calendar.setDefaultCalendar( 1 ); |
76 | if ( calendar.load( name ) ) { | 76 | if ( calendar.load( name ) ) { |
77 | mergeCalendar( &calendar ); | 77 | mergeCalendar( &calendar ); |
78 | return true; | 78 | return true; |
79 | } | 79 | } |
80 | return false; | 80 | return false; |
81 | } | 81 | } |
82 | 82 | ||
83 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) | 83 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) |
84 | { | 84 | { |
85 | Todo *todo;; | 85 | Todo *todo;; |
86 | Incidence *retVal = 0; | 86 | Incidence *retVal = 0; |
87 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 87 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
88 | if ( todo->uid() == uid ) { | 88 | if ( todo->uid() == uid ) { |
89 | if ( doNotCheckDuplicates ) return todo; | 89 | if ( doNotCheckDuplicates ) return todo; |
90 | if ( retVal ) { | 90 | if ( retVal ) { |
91 | if ( retVal->calID() > todo->calID() ) { | 91 | if ( retVal->calID() > todo->calID() ) { |
92 | retVal = todo; | 92 | retVal = todo; |
93 | } | 93 | } |
94 | } else { | 94 | } else { |
95 | retVal = todo; | 95 | retVal = todo; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | } | 98 | } |
99 | if ( retVal ) return retVal; | 99 | if ( retVal ) return retVal; |
100 | Event *event; | 100 | Event *event; |
101 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 101 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
102 | if ( event->uid() == uid ) { | 102 | if ( event->uid() == uid ) { |
103 | if ( doNotCheckDuplicates ) return event; | 103 | if ( doNotCheckDuplicates ) return event; |
104 | if ( retVal ) { | 104 | if ( retVal ) { |
105 | if ( retVal->calID() > event->calID() ) { | 105 | if ( retVal->calID() > event->calID() ) { |
106 | retVal = event; | 106 | retVal = event; |
107 | } | 107 | } |
108 | } else { | 108 | } else { |
109 | retVal = event; | 109 | retVal = event; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | if ( retVal ) return retVal; | 113 | if ( retVal ) return retVal; |
114 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 114 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
115 | if ( it->uid() == uid ) { | 115 | if ( it->uid() == uid ) { |
116 | if ( doNotCheckDuplicates ) return it; | 116 | if ( doNotCheckDuplicates ) return it; |
117 | if ( retVal ) { | 117 | if ( retVal ) { |
118 | if ( retVal->calID() > it->calID() ) { | 118 | if ( retVal->calID() > it->calID() ) { |
119 | retVal = it; | 119 | retVal = it; |
120 | } | 120 | } |
121 | } else { | 121 | } else { |
122 | retVal = it; | 122 | retVal = it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | return retVal; | 125 | return retVal; |
126 | } | 126 | } |
127 | 127 | ||
128 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | 128 | bool CalendarLocal::mergeCalendar( Calendar* remote ) |
129 | { | 129 | { |
130 | // 1 look for raw inc in local | 130 | // 1 look for raw inc in local |
131 | // if inc not in remote, delete in local | 131 | // if inc not in remote, delete in local |
132 | // 2 look for raw inc in remote | 132 | // 2 look for raw inc in remote |
133 | // if inc in local, replace it | 133 | // if inc in local, replace it |
134 | // if not in local, add it to default calendar | 134 | // if not in local, add it to default calendar |
135 | QPtrList<Incidence> localInc = rawIncidences(); | 135 | QPtrList<Incidence> localInc = rawIncidences(); |
136 | Incidence* inL = localInc.first(); | 136 | Incidence* inL = localInc.first(); |
137 | while ( inL ) { | 137 | while ( inL ) { |
138 | if ( ! inL->isReadOnly () ) | 138 | if ( ! inL->isReadOnly () ) |
139 | if ( !remote->incidenceForUid( inL->uid(), true )) | 139 | if ( !remote->incidenceForUid( inL->uid(), true )) |
140 | deleteIncidence( inL ); | 140 | deleteIncidence( inL ); |
141 | inL = localInc.next(); | 141 | inL = localInc.next(); |
142 | } | 142 | } |
143 | QPtrList<Incidence> er = remote->rawIncidences(); | 143 | QPtrList<Incidence> er = remote->rawIncidences(); |
144 | Incidence* inR = er.first(); | 144 | Incidence* inR = er.first(); |
145 | while ( inR ) { | 145 | while ( inR ) { |
146 | inL = incidenceForUid( inR->uid(),false ); | 146 | inL = incidenceForUid( inR->uid(),false ); |
147 | if ( inL ) { | 147 | if ( inL ) { |
148 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { | 148 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { |
149 | int calID = inL->calID(); | 149 | int calID = inL->calID(); |
150 | deleteIncidence( inL ); | 150 | deleteIncidence( inL ); |
151 | inL = inR->clone(); | 151 | inL = inR->clone(); |
152 | inL->setCalID( calID ); | 152 | inL->setCalID( calID ); |
153 | addIncidence( inL ); | 153 | addIncidence( inL ); |
154 | } | 154 | } |
155 | } else { | 155 | } else { |
156 | inL = inR->clone(); | 156 | inL = inR->clone(); |
157 | inL->setCalID( 0 );// add to default cal | 157 | inL->setCalID( 0 );// add to default cal |
158 | addIncidence( inL ); | 158 | addIncidence( inL ); |
159 | } | 159 | } |
160 | inR = er.next(); | 160 | inR = er.next(); |
161 | } | 161 | } |
162 | return true; | 162 | return true; |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 166 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
167 | { | 167 | { |
168 | CalendarLocal calendar( timeZoneId() ); | 168 | CalendarLocal calendar( timeZoneId() ); |
169 | calendar.setDefaultCalendar( id ); | 169 | calendar.setDefaultCalendar( id ); |
170 | if ( calendar.load( name ) ) { | 170 | if ( calendar.load( name ) ) { |
171 | addCalendar( &calendar ); | 171 | addCalendar( &calendar ); |
172 | return true; | 172 | return true; |
173 | } | 173 | } |
174 | return false; | 174 | return false; |
175 | } | 175 | } |
176 | void CalendarLocal::setSyncEventsReadOnly() | 176 | void CalendarLocal::setSyncEventsEnabled() |
177 | { | 177 | { |
178 | Event * ev; | 178 | Event * ev; |
179 | ev = mEventList.first(); | 179 | ev = mEventList.first(); |
180 | while ( ev ) { | 180 | while ( ev ) { |
181 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 181 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
182 | ev->setReadOnly( true ); | 182 | ev->setCalEnabled( true ); |
183 | ev = mEventList.next(); | ||
184 | } | ||
185 | } | ||
186 | void CalendarLocal::setSyncEventsReadOnly() | ||
187 | { | ||
188 | Event * ev; | ||
189 | ev = mEventList.first(); | ||
190 | while ( ev ) { | ||
191 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { | ||
192 | ev->setReadOnly( true ); | ||
193 | ev->setCalID( 1 ); | ||
194 | } | ||
183 | ev = mEventList.next(); | 195 | ev = mEventList.next(); |
184 | } | 196 | } |
185 | } | 197 | } |
186 | void CalendarLocal::addCalendar( Calendar* cal ) | 198 | void CalendarLocal::addCalendar( Calendar* cal ) |
187 | { | 199 | { |
188 | cal->setDontDeleteIncidencesOnClose(); | 200 | cal->setDontDeleteIncidencesOnClose(); |
189 | { | 201 | { |
190 | QPtrList<Event> EventList = cal->rawEvents(); | 202 | QPtrList<Event> EventList = cal->rawEvents(); |
191 | Event * ev = EventList.first(); | 203 | Event * ev = EventList.first(); |
192 | while ( ev ) { | 204 | while ( ev ) { |
193 | ev->unRegisterObserver( cal ); | 205 | ev->unRegisterObserver( cal ); |
194 | ev->registerObserver( this ); | 206 | ev->registerObserver( this ); |
195 | mEventList.append( ev ); | 207 | mEventList.append( ev ); |
196 | ev = EventList.next(); | 208 | ev = EventList.next(); |
197 | } | 209 | } |
198 | } | 210 | } |
199 | { | 211 | { |
200 | 212 | ||
201 | QPtrList<Todo> TodoList = cal->rawTodos(); | 213 | QPtrList<Todo> TodoList = cal->rawTodos(); |
202 | Todo * ev = TodoList.first(); | 214 | Todo * ev = TodoList.first(); |
203 | while ( ev ) { | 215 | while ( ev ) { |
204 | QString rel = ev->relatedToUid(); | 216 | QString rel = ev->relatedToUid(); |
205 | if ( !rel.isEmpty() ){ | 217 | if ( !rel.isEmpty() ){ |
206 | ev->setRelatedTo ( 0 ); | 218 | ev->setRelatedTo ( 0 ); |
207 | ev->setRelatedToUid( rel ); | 219 | ev->setRelatedToUid( rel ); |
208 | } | 220 | } |
209 | ev = TodoList.next(); | 221 | ev = TodoList.next(); |
210 | } | 222 | } |
211 | //TodoList = cal->rawTodos(); | 223 | //TodoList = cal->rawTodos(); |
212 | ev = TodoList.first(); | 224 | ev = TodoList.first(); |
213 | while ( ev ) { | 225 | while ( ev ) { |
214 | ev->unRegisterObserver( cal ); | 226 | ev->unRegisterObserver( cal ); |
215 | ev->registerObserver( this ); | 227 | ev->registerObserver( this ); |
216 | mTodoList.append( ev ); | 228 | mTodoList.append( ev ); |
217 | setupRelations( ev ); | 229 | setupRelations( ev ); |
218 | ev = TodoList.next(); | 230 | ev = TodoList.next(); |
219 | } | 231 | } |
220 | } | 232 | } |
221 | { | 233 | { |
222 | QPtrList<Journal> JournalList = cal->journals(); | 234 | QPtrList<Journal> JournalList = cal->journals(); |
223 | Journal * ev = JournalList.first(); | 235 | Journal * ev = JournalList.first(); |
224 | while ( ev ) { | 236 | while ( ev ) { |
225 | ev->unRegisterObserver( cal ); | 237 | ev->unRegisterObserver( cal ); |
226 | ev->registerObserver( this ); | 238 | ev->registerObserver( this ); |
227 | mJournalList.append( ev ); | 239 | mJournalList.append( ev ); |
228 | ev = JournalList.next(); | 240 | ev = JournalList.next(); |
229 | } | 241 | } |
230 | } | 242 | } |
231 | setModified( true ); | 243 | setModified( true ); |
232 | } | 244 | } |
233 | bool CalendarLocal::load( const QString &fileName ) | 245 | bool CalendarLocal::load( const QString &fileName ) |
234 | { | 246 | { |
235 | FileStorage storage( this, fileName ); | 247 | FileStorage storage( this, fileName ); |
236 | return storage.load(); | 248 | return storage.load(); |
237 | } | 249 | } |
238 | 250 | ||
239 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 251 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
240 | { | 252 | { |
241 | FileStorage storage( this, fileName, format ); | 253 | FileStorage storage( this, fileName, format ); |
242 | return storage.save(); | 254 | return storage.save(); |
243 | } | 255 | } |
244 | 256 | ||
245 | void CalendarLocal::stopAllTodos() | 257 | void CalendarLocal::stopAllTodos() |
246 | { | 258 | { |
247 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 259 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
248 | it->setRunning( false ); | 260 | it->setRunning( false ); |
249 | 261 | ||
250 | } | 262 | } |
251 | void CalendarLocal::close() | 263 | void CalendarLocal::close() |
252 | { | 264 | { |
253 | 265 | ||
254 | Todo * i; | 266 | Todo * i; |
255 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 267 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
256 | 268 | ||
257 | mEventList.setAutoDelete( true ); | 269 | mEventList.setAutoDelete( true ); |
258 | mTodoList.setAutoDelete( true ); | 270 | mTodoList.setAutoDelete( true ); |
259 | mJournalList.setAutoDelete( true ); | 271 | mJournalList.setAutoDelete( true ); |
260 | 272 | ||
261 | mEventList.clear(); | 273 | mEventList.clear(); |
262 | mTodoList.clear(); | 274 | mTodoList.clear(); |
263 | mJournalList.clear(); | 275 | mJournalList.clear(); |
264 | 276 | ||
265 | mEventList.setAutoDelete( false ); | 277 | mEventList.setAutoDelete( false ); |
266 | mTodoList.setAutoDelete( false ); | 278 | mTodoList.setAutoDelete( false ); |
267 | mJournalList.setAutoDelete( false ); | 279 | mJournalList.setAutoDelete( false ); |
268 | 280 | ||
269 | setModified( false ); | 281 | setModified( false ); |
270 | } | 282 | } |
271 | 283 | ||
272 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 284 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
273 | { | 285 | { |
274 | QString cat; | 286 | QString cat; |
275 | bool isBirthday = true; | 287 | bool isBirthday = true; |
276 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 288 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
277 | isBirthday = false; | 289 | isBirthday = false; |
278 | cat = i18n( "Anniversary" ); | 290 | cat = i18n( "Anniversary" ); |
279 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 291 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
280 | isBirthday = true; | 292 | isBirthday = true; |
281 | cat = i18n( "Birthday" ); | 293 | cat = i18n( "Birthday" ); |
282 | } else { | 294 | } else { |
283 | qDebug("addAnniversaryNoDup called without fitting category! "); | 295 | qDebug("addAnniversaryNoDup called without fitting category! "); |
284 | return false; | 296 | return false; |
285 | } | 297 | } |
286 | Event * eve; | 298 | Event * eve; |
287 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 299 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
288 | if ( !(eve->categories().contains( cat ) )) | 300 | if ( !(eve->categories().contains( cat ) )) |
289 | continue; | 301 | continue; |
290 | // now we have an event with fitting category | 302 | // now we have an event with fitting category |
291 | if ( eve->dtStart().date() != event->dtStart().date() ) | 303 | if ( eve->dtStart().date() != event->dtStart().date() ) |
292 | continue; | 304 | continue; |
293 | // now we have an event with fitting category+date | 305 | // now we have an event with fitting category+date |
294 | if ( eve->summary() != event->summary() ) | 306 | if ( eve->summary() != event->summary() ) |
295 | continue; | 307 | continue; |
296 | // now we have an event with fitting category+date+summary | 308 | // now we have an event with fitting category+date+summary |
297 | return false; | 309 | return false; |
298 | } | 310 | } |
299 | return addEvent( event ); | 311 | return addEvent( event ); |
300 | 312 | ||
301 | } | 313 | } |
302 | bool CalendarLocal::addEventNoDup( Event *event ) | 314 | bool CalendarLocal::addEventNoDup( Event *event ) |
303 | { | 315 | { |
304 | Event * eve; | 316 | Event * eve; |
305 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 317 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
306 | if ( *eve == *event ) { | 318 | if ( *eve == *event ) { |
307 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 319 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
308 | return false; | 320 | return false; |
309 | } | 321 | } |
310 | } | 322 | } |
311 | return addEvent( event ); | 323 | return addEvent( event ); |
312 | } | 324 | } |
313 | 325 | ||
314 | bool CalendarLocal::addEvent( Event *event ) | 326 | bool CalendarLocal::addEvent( Event *event ) |
315 | { | 327 | { |
316 | insertEvent( event ); | 328 | insertEvent( event ); |
317 | 329 | ||
318 | event->registerObserver( this ); | 330 | event->registerObserver( this ); |
319 | 331 | ||
320 | setModified( true ); | 332 | setModified( true ); |
321 | if ( event->calID() == 0 ) | 333 | if ( event->calID() == 0 ) |
322 | event->setCalID( mDefaultCalendar ); | 334 | event->setCalID( mDefaultCalendar ); |
323 | event->setCalEnabled( true ); | 335 | event->setCalEnabled( true ); |
324 | 336 | ||
325 | return true; | 337 | return true; |
326 | } | 338 | } |
327 | 339 | ||
328 | void CalendarLocal::deleteEvent( Event *event ) | 340 | void CalendarLocal::deleteEvent( Event *event ) |
329 | { | 341 | { |
330 | clearUndo(event); | 342 | clearUndo(event); |
331 | if ( mEventList.removeRef( event ) ) { | 343 | if ( mEventList.removeRef( event ) ) { |
332 | setModified( true ); | 344 | setModified( true ); |
333 | } | 345 | } |
334 | } | 346 | } |
335 | 347 | ||
336 | 348 | ||
337 | Event *CalendarLocal::event( const QString &uid ) | 349 | Event *CalendarLocal::event( const QString &uid ) |
338 | { | 350 | { |
339 | Event *event; | 351 | Event *event; |
340 | Event *retVal = 0; | 352 | Event *retVal = 0; |
341 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 353 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
342 | if ( event->calEnabled() && event->uid() == uid ) { | 354 | if ( event->calEnabled() && event->uid() == uid ) { |
343 | if ( retVal ) { | 355 | if ( retVal ) { |
344 | if ( retVal->calID() > event->calID() ) { | 356 | if ( retVal->calID() > event->calID() ) { |
345 | retVal = event; | 357 | retVal = event; |
346 | } | 358 | } |
347 | } else { | 359 | } else { |
348 | retVal = event; | 360 | retVal = event; |
349 | } | 361 | } |
350 | } | 362 | } |
351 | } | 363 | } |
352 | return retVal; | 364 | return retVal; |
353 | } | 365 | } |
354 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 366 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
355 | { | 367 | { |
356 | Todo * eve; | 368 | Todo * eve; |
357 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 369 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
358 | if ( *eve == *todo ) { | 370 | if ( *eve == *todo ) { |
359 | //qDebug("duplicate todo found! not inserted! "); | 371 | //qDebug("duplicate todo found! not inserted! "); |
360 | return false; | 372 | return false; |
361 | } | 373 | } |
362 | } | 374 | } |
363 | return addTodo( todo ); | 375 | return addTodo( todo ); |
364 | } | 376 | } |
365 | bool CalendarLocal::addTodo( Todo *todo ) | 377 | bool CalendarLocal::addTodo( Todo *todo ) |
366 | { | 378 | { |
367 | mTodoList.append( todo ); | 379 | mTodoList.append( todo ); |
368 | 380 | ||
369 | todo->registerObserver( this ); | 381 | todo->registerObserver( this ); |
370 | 382 | ||
371 | // Set up subtask relations | 383 | // Set up subtask relations |
372 | setupRelations( todo ); | 384 | setupRelations( todo ); |
373 | 385 | ||
374 | setModified( true ); | 386 | setModified( true ); |
375 | if ( todo->calID() == 0 ) | 387 | if ( todo->calID() == 0 ) |
376 | todo->setCalID( mDefaultCalendar ); | 388 | todo->setCalID( mDefaultCalendar ); |
377 | todo->setCalEnabled( true ); | 389 | todo->setCalEnabled( true ); |
378 | return true; | 390 | return true; |
379 | } | 391 | } |
380 | 392 | ||
381 | void CalendarLocal::deleteTodo( Todo *todo ) | 393 | void CalendarLocal::deleteTodo( Todo *todo ) |
382 | { | 394 | { |
383 | // Handle orphaned children | 395 | // Handle orphaned children |
384 | removeRelations( todo ); | 396 | removeRelations( todo ); |
385 | clearUndo(todo); | 397 | clearUndo(todo); |
386 | 398 | ||
387 | if ( mTodoList.removeRef( todo ) ) { | 399 | if ( mTodoList.removeRef( todo ) ) { |
388 | setModified( true ); | 400 | setModified( true ); |
389 | } | 401 | } |
390 | } | 402 | } |
391 | 403 | ||
392 | QPtrList<Todo> CalendarLocal::rawTodos() | 404 | QPtrList<Todo> CalendarLocal::rawTodos() |
393 | { | 405 | { |
394 | QPtrList<Todo> el; | 406 | QPtrList<Todo> el; |
395 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 407 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
396 | if ( it->calEnabled() ) el.append( it ); | 408 | if ( it->calEnabled() ) el.append( it ); |
397 | return el; | 409 | return el; |
398 | } | 410 | } |
399 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 411 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
400 | { | 412 | { |
401 | Todo *todo; | 413 | Todo *todo; |
402 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 414 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
403 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 415 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
404 | } | 416 | } |
405 | 417 | ||
406 | return 0; | 418 | return 0; |
407 | } | 419 | } |
408 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 420 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
409 | { | 421 | { |
410 | QPtrList<Incidence> all = rawIncidences() ; | 422 | QPtrList<Incidence> all = rawIncidences() ; |
411 | Incidence *inc; | 423 | Incidence *inc; |
412 | for ( inc = all.first(); inc; inc = all.next() ) { | 424 | for ( inc = all.first(); inc; inc = all.next() ) { |
413 | inc->removeID( syncProfile ); | 425 | inc->removeID( syncProfile ); |
414 | } | 426 | } |
415 | if ( syncProfile.isEmpty() ) { | 427 | if ( syncProfile.isEmpty() ) { |
416 | QPtrList<Event> el; | 428 | QPtrList<Event> el; |
417 | Event *todo; | 429 | Event *todo; |
418 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 430 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
419 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 431 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
420 | el.append( todo ); | 432 | el.append( todo ); |
421 | } | 433 | } |
422 | for ( todo = el.first(); todo; todo = el.next() ) { | 434 | for ( todo = el.first(); todo; todo = el.next() ) { |
423 | deleteIncidence ( todo ); | 435 | deleteIncidence ( todo ); |
424 | } | 436 | } |
425 | } else { | 437 | } else { |
426 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 438 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
427 | if ( lse ) | 439 | if ( lse ) |
428 | deleteIncidence ( lse ); | 440 | deleteIncidence ( lse ); |
429 | } | 441 | } |
430 | } | 442 | } |
431 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 443 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
432 | { | 444 | { |
433 | QPtrList<Event> el; | 445 | QPtrList<Event> el; |
434 | Event *todo; | 446 | Event *todo; |
435 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 447 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
436 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 448 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
437 | if ( todo->summary().left(3) == "E: " ) | 449 | if ( todo->summary().left(3) == "E: " ) |
438 | el.append( todo ); | 450 | el.append( todo ); |
439 | } | 451 | } |
440 | 452 | ||
441 | return el; | 453 | return el; |
442 | 454 | ||
443 | } | 455 | } |
444 | Event *CalendarLocal::event( QString syncProf, QString id ) | 456 | Event *CalendarLocal::event( QString syncProf, QString id ) |
445 | { | 457 | { |
446 | Event *todo; | 458 | Event *todo; |
447 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 459 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
448 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 460 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
449 | } | 461 | } |
450 | 462 | ||
451 | return 0; | 463 | return 0; |
452 | } | 464 | } |
453 | Todo *CalendarLocal::todo( const QString &uid ) | 465 | Todo *CalendarLocal::todo( const QString &uid ) |
454 | { | 466 | { |
455 | Todo *todo; | 467 | Todo *todo; |
456 | Todo *retVal = 0; | 468 | Todo *retVal = 0; |
457 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 469 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
458 | if ( todo->calEnabled() && todo->uid() == uid ) { | 470 | if ( todo->calEnabled() && todo->uid() == uid ) { |
459 | if ( retVal ) { | 471 | if ( retVal ) { |
460 | if ( retVal->calID() > todo->calID() ) { | 472 | if ( retVal->calID() > todo->calID() ) { |
461 | retVal = todo; | 473 | retVal = todo; |
462 | } | 474 | } |
463 | } else { | 475 | } else { |
464 | retVal = todo; | 476 | retVal = todo; |
465 | } | 477 | } |
466 | } | 478 | } |
467 | } | 479 | } |
468 | return retVal; | 480 | return retVal; |
469 | } | 481 | } |
470 | void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals) | 482 | void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals) |
471 | { | 483 | { |
472 | events = 0; | 484 | events = 0; |
473 | todos = 0; | 485 | todos = 0; |
474 | journals = 0; | 486 | journals = 0; |
475 | { | 487 | { |
476 | Todo *todo; | 488 | Todo *todo; |
477 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 489 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
478 | if ( todo->calID() == calId ) | 490 | if ( todo->calID() == calId ) |
479 | ++todos; | 491 | ++todos; |
480 | } | 492 | } |
481 | } | 493 | } |
482 | { | 494 | { |
483 | Event *todo; | 495 | Event *todo; |
484 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 496 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
485 | if ( todo->calID() == calId ) | 497 | if ( todo->calID() == calId ) |
486 | ++events; | 498 | ++events; |
487 | 499 | ||
488 | } | 500 | } |
489 | } | 501 | } |
490 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 502 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
491 | if ( it->calID() == calId ) ++journals; | 503 | if ( it->calID() == calId ) ++journals; |
492 | 504 | ||
493 | } | 505 | } |
494 | QString CalendarLocal::nextSummary() const | 506 | QString CalendarLocal::nextSummary() const |
495 | { | 507 | { |
496 | return mNextSummary; | 508 | return mNextSummary; |
497 | } | 509 | } |
498 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 510 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
499 | { | 511 | { |
500 | return mNextAlarmEventDateTime; | 512 | return mNextAlarmEventDateTime; |
501 | } | 513 | } |
502 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 514 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
503 | { | 515 | { |
504 | //mNextAlarmIncidence | 516 | //mNextAlarmIncidence |
505 | //mNextAlarmDateTime | 517 | //mNextAlarmDateTime |
506 | //return mNextSummary; | 518 | //return mNextSummary; |
507 | //return mNextAlarmEventDateTime; | 519 | //return mNextAlarmEventDateTime; |
508 | bool newNextAlarm = false; | 520 | bool newNextAlarm = false; |
509 | bool computeNextAlarm = false; | 521 | bool computeNextAlarm = false; |
510 | bool ok; | 522 | bool ok; |
511 | int offset; | 523 | int offset; |
512 | QDateTime nextA; | 524 | QDateTime nextA; |
513 | // QString nextSum; | 525 | // QString nextSum; |
514 | //QDateTime nextEvent; | 526 | //QDateTime nextEvent; |
515 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 527 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
516 | computeNextAlarm = true; | 528 | computeNextAlarm = true; |
517 | } else { | 529 | } else { |
518 | if ( ! deleted ) { | 530 | if ( ! deleted ) { |
519 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 531 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
520 | if ( ok ) { | 532 | if ( ok ) { |
521 | if ( nextA < mNextAlarmDateTime ) { | 533 | if ( nextA < mNextAlarmDateTime ) { |
522 | deRegisterAlarm(); | 534 | deRegisterAlarm(); |
523 | mNextAlarmDateTime = nextA; | 535 | mNextAlarmDateTime = nextA; |
524 | mNextSummary = incidence->summary(); | 536 | mNextSummary = incidence->summary(); |
525 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 537 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
526 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 538 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
527 | newNextAlarm = true; | 539 | newNextAlarm = true; |
528 | mNextAlarmIncidence = incidence; | 540 | mNextAlarmIncidence = incidence; |
529 | } else { | 541 | } else { |
530 | if ( incidence == mNextAlarmIncidence ) { | 542 | if ( incidence == mNextAlarmIncidence ) { |
531 | computeNextAlarm = true; | 543 | computeNextAlarm = true; |
532 | } | 544 | } |
533 | } | 545 | } |
534 | } else { | 546 | } else { |
535 | if ( mNextAlarmIncidence == incidence ) { | 547 | if ( mNextAlarmIncidence == incidence ) { |
536 | computeNextAlarm = true; | 548 | computeNextAlarm = true; |
537 | } | 549 | } |
538 | } | 550 | } |
539 | } else { // deleted | 551 | } else { // deleted |
540 | if ( incidence == mNextAlarmIncidence ) { | 552 | if ( incidence == mNextAlarmIncidence ) { |
541 | computeNextAlarm = true; | 553 | computeNextAlarm = true; |
542 | } | 554 | } |
543 | } | 555 | } |
544 | } | 556 | } |
545 | if ( computeNextAlarm ) { | 557 | if ( computeNextAlarm ) { |
546 | deRegisterAlarm(); | 558 | deRegisterAlarm(); |
547 | nextA = nextAlarm( 1000 ); | 559 | nextA = nextAlarm( 1000 ); |
548 | if (! mNextAlarmIncidence ) { | 560 | if (! mNextAlarmIncidence ) { |
549 | return; | 561 | return; |
550 | } | 562 | } |
551 | newNextAlarm = true; | 563 | newNextAlarm = true; |
552 | } | 564 | } |
553 | if ( newNextAlarm ) | 565 | if ( newNextAlarm ) |
554 | registerAlarm(); | 566 | registerAlarm(); |
555 | } | 567 | } |
556 | QString CalendarLocal:: getAlarmNotification() | 568 | QString CalendarLocal:: getAlarmNotification() |
557 | { | 569 | { |
558 | QString ret; | 570 | QString ret; |
559 | // this should not happen | 571 | // this should not happen |
560 | if (! mNextAlarmIncidence ) | 572 | if (! mNextAlarmIncidence ) |
561 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 573 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
562 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 574 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
563 | if ( alarm->type() == Alarm::Procedure ) { | 575 | if ( alarm->type() == Alarm::Procedure ) { |
564 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 576 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
565 | } else { | 577 | } else { |
566 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 578 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index ca0bd98..eb7bf34 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,231 +1,232 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | bool mergeCalendarFile( QString name ); | 48 | bool mergeCalendarFile( QString name ); |
49 | bool mergeCalendar( Calendar* cal ); | 49 | bool mergeCalendar( Calendar* cal ); |
50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); | 50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); |
51 | void setSyncEventsReadOnly(); | 51 | void setSyncEventsReadOnly(); |
52 | void setSyncEventsEnabled(); | ||
52 | void stopAllTodos(); | 53 | void stopAllTodos(); |
53 | /** | 54 | /** |
54 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 55 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
55 | calendar. Any information already present is lost. | 56 | calendar. Any information already present is lost. |
56 | @return true, if successfull, false on error. | 57 | @return true, if successfull, false on error. |
57 | @param fileName the name of the calendar on disk. | 58 | @param fileName the name of the calendar on disk. |
58 | */ | 59 | */ |
59 | bool load( const QString &fileName ); | 60 | bool load( const QString &fileName ); |
60 | /** | 61 | /** |
61 | Writes out the calendar to disk in the specified \a format. | 62 | Writes out the calendar to disk in the specified \a format. |
62 | CalendarLocal takes ownership of the CalFormat object. | 63 | CalendarLocal takes ownership of the CalFormat object. |
63 | @return true, if successfull, false on error. | 64 | @return true, if successfull, false on error. |
64 | @param fileName the name of the file | 65 | @param fileName the name of the file |
65 | */ | 66 | */ |
66 | bool save( const QString &fileName, CalFormat *format = 0 ); | 67 | bool save( const QString &fileName, CalFormat *format = 0 ); |
67 | 68 | ||
68 | /** | 69 | /** |
69 | Clears out the current calendar, freeing all used memory etc. etc. | 70 | Clears out the current calendar, freeing all used memory etc. etc. |
70 | */ | 71 | */ |
71 | void close(); | 72 | void close(); |
72 | 73 | ||
73 | void save() {} | 74 | void save() {} |
74 | 75 | ||
75 | /** | 76 | /** |
76 | Add Event to calendar. | 77 | Add Event to calendar. |
77 | */ | 78 | */ |
78 | void removeSyncInfo( QString syncProfile); | 79 | void removeSyncInfo( QString syncProfile); |
79 | bool addAnniversaryNoDup( Event *event ); | 80 | bool addAnniversaryNoDup( Event *event ); |
80 | bool addEventNoDup( Event *event ); | 81 | bool addEventNoDup( Event *event ); |
81 | bool addEvent( Event *event ); | 82 | bool addEvent( Event *event ); |
82 | /** | 83 | /** |
83 | Deletes an event from this calendar. | 84 | Deletes an event from this calendar. |
84 | */ | 85 | */ |
85 | void deleteEvent( Event *event ); | 86 | void deleteEvent( Event *event ); |
86 | 87 | ||
87 | /** | 88 | /** |
88 | Retrieves an event on the basis of the unique string ID. | 89 | Retrieves an event on the basis of the unique string ID. |
89 | */ | 90 | */ |
90 | Event *event( const QString &uid ); | 91 | Event *event( const QString &uid ); |
91 | /** | 92 | /** |
92 | Return unfiltered list of all events in calendar. | 93 | Return unfiltered list of all events in calendar. |
93 | */ | 94 | */ |
94 | QPtrList<Event> rawEvents(); | 95 | QPtrList<Event> rawEvents(); |
95 | QPtrList<Event> getExternLastSyncEvents(); | 96 | QPtrList<Event> getExternLastSyncEvents(); |
96 | /** | 97 | /** |
97 | Add a todo to the todolist. | 98 | Add a todo to the todolist. |
98 | */ | 99 | */ |
99 | bool addTodo( Todo *todo ); | 100 | bool addTodo( Todo *todo ); |
100 | bool addTodoNoDup( Todo *todo ); | 101 | bool addTodoNoDup( Todo *todo ); |
101 | /** | 102 | /** |
102 | Remove a todo from the todolist. | 103 | Remove a todo from the todolist. |
103 | */ | 104 | */ |
104 | void deleteTodo( Todo * ); | 105 | void deleteTodo( Todo * ); |
105 | /** | 106 | /** |
106 | Searches todolist for an event with this unique string identifier, | 107 | Searches todolist for an event with this unique string identifier, |
107 | returns a pointer or null. | 108 | returns a pointer or null. |
108 | */ | 109 | */ |
109 | Todo *todo( const QString &uid ); | 110 | Todo *todo( const QString &uid ); |
110 | /** | 111 | /** |
111 | Return list of all todos. | 112 | Return list of all todos. |
112 | */ | 113 | */ |
113 | QPtrList<Todo> rawTodos(); | 114 | QPtrList<Todo> rawTodos(); |
114 | /** | 115 | /** |
115 | Returns list of todos due on the specified date. | 116 | Returns list of todos due on the specified date. |
116 | */ | 117 | */ |
117 | QPtrList<Todo> todos( const QDate &date ); | 118 | QPtrList<Todo> todos( const QDate &date ); |
118 | /** | 119 | /** |
119 | Return list of all todos. | 120 | Return list of all todos. |
120 | 121 | ||
121 | Workaround because compiler does not recognize function of base class. | 122 | Workaround because compiler does not recognize function of base class. |
122 | */ | 123 | */ |
123 | QPtrList<Todo> todos() { return Calendar::todos(); } | 124 | QPtrList<Todo> todos() { return Calendar::todos(); } |
124 | 125 | ||
125 | /** | 126 | /** |
126 | Add a Journal entry to calendar. | 127 | Add a Journal entry to calendar. |
127 | */ | 128 | */ |
128 | bool addJournal( Journal * ); | 129 | bool addJournal( Journal * ); |
129 | /** | 130 | /** |
130 | Remove a Journal from the calendar. | 131 | Remove a Journal from the calendar. |
131 | */ | 132 | */ |
132 | void deleteJournal( Journal * ); | 133 | void deleteJournal( Journal * ); |
133 | /** | 134 | /** |
134 | Return Journal for given date. | 135 | Return Journal for given date. |
135 | */ | 136 | */ |
136 | Journal *journal( const QDate & ); | 137 | Journal *journal( const QDate & ); |
137 | QPtrList<Journal> journals4Date( const QDate & ); | 138 | QPtrList<Journal> journals4Date( const QDate & ); |
138 | /** | 139 | /** |
139 | Return Journal with given UID. | 140 | Return Journal with given UID. |
140 | */ | 141 | */ |
141 | Journal *journal( const QString &uid ); | 142 | Journal *journal( const QString &uid ); |
142 | /** | 143 | /** |
143 | Return list of all Journals stored in calendar. | 144 | Return list of all Journals stored in calendar. |
144 | */ | 145 | */ |
145 | QPtrList<Journal> journals(); | 146 | QPtrList<Journal> journals(); |
146 | 147 | ||
147 | /** | 148 | /** |
148 | Return all alarms, which ocur in the given time interval. | 149 | Return all alarms, which ocur in the given time interval. |
149 | */ | 150 | */ |
150 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 151 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
151 | 152 | ||
152 | /** | 153 | /** |
153 | Return all alarms, which ocur before given date. | 154 | Return all alarms, which ocur before given date. |
154 | */ | 155 | */ |
155 | Alarm::List alarmsTo( const QDateTime &to ); | 156 | Alarm::List alarmsTo( const QDateTime &to ); |
156 | 157 | ||
157 | QDateTime nextAlarm( int daysTo ) ; | 158 | QDateTime nextAlarm( int daysTo ) ; |
158 | QDateTime nextAlarmEventDateTime() const; | 159 | QDateTime nextAlarmEventDateTime() const; |
159 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 160 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
160 | void registerAlarm(); | 161 | void registerAlarm(); |
161 | void deRegisterAlarm(); | 162 | void deRegisterAlarm(); |
162 | QString getAlarmNotification(); | 163 | QString getAlarmNotification(); |
163 | QString nextSummary() const ; | 164 | QString nextSummary() const ; |
164 | /** | 165 | /** |
165 | This method should be called whenever a Event is modified directly | 166 | This method should be called whenever a Event is modified directly |
166 | via it's pointer. It makes sure that the calendar is internally | 167 | via it's pointer. It makes sure that the calendar is internally |
167 | consistent. | 168 | consistent. |
168 | */ | 169 | */ |
169 | void update( IncidenceBase *incidence ); | 170 | void update( IncidenceBase *incidence ); |
170 | 171 | ||
171 | /** | 172 | /** |
172 | Builds and then returns a list of all events that match for the | 173 | Builds and then returns a list of all events that match for the |
173 | date specified. useful for dayView, etc. etc. | 174 | date specified. useful for dayView, etc. etc. |
174 | */ | 175 | */ |
175 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 176 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
176 | /** | 177 | /** |
177 | Get unfiltered events for date \a qdt. | 178 | Get unfiltered events for date \a qdt. |
178 | */ | 179 | */ |
179 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 180 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
180 | /** | 181 | /** |
181 | Get unfiltered events in a range of dates. If inclusive is set to true, | 182 | Get unfiltered events in a range of dates. If inclusive is set to true, |
182 | only events are returned, which are completely included in the range. | 183 | only events are returned, which are completely included in the range. |
183 | */ | 184 | */ |
184 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 185 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
185 | bool inclusive = false ); | 186 | bool inclusive = false ); |
186 | Todo *todo( QString, QString ); | 187 | Todo *todo( QString, QString ); |
187 | Event *event( QString, QString ); | 188 | Event *event( QString, QString ); |
188 | void getIncidenceCount( int calId, int& events, int & todos, int & journals); | 189 | void getIncidenceCount( int calId, int& events, int & todos, int & journals); |
189 | 190 | ||
190 | public slots: | 191 | public slots: |
191 | void setCalendarEnabled( int id, bool enable ); | 192 | void setCalendarEnabled( int id, bool enable ); |
192 | void setAlarmEnabled( int id, bool enable ); | 193 | void setAlarmEnabled( int id, bool enable ); |
193 | void setReadOnly( int id, bool enable ); | 194 | void setReadOnly( int id, bool enable ); |
194 | void setDefaultCalendarEnabledOnly(); | 195 | void setDefaultCalendarEnabledOnly(); |
195 | void setCalendarRemove( int id ); | 196 | void setCalendarRemove( int id ); |
196 | 197 | ||
197 | protected: | 198 | protected: |
198 | 199 | ||
199 | // Event* mNextAlarmEvent; | 200 | // Event* mNextAlarmEvent; |
200 | QString mNextSummary; | 201 | QString mNextSummary; |
201 | QString mNextAlarmEventDateTimeString; | 202 | QString mNextAlarmEventDateTimeString; |
202 | QString mLastAlarmNotificationString; | 203 | QString mLastAlarmNotificationString; |
203 | QDateTime mNextAlarmEventDateTime; | 204 | QDateTime mNextAlarmEventDateTime; |
204 | QDateTime mNextAlarmDateTime; | 205 | QDateTime mNextAlarmDateTime; |
205 | void reInitAlarmSettings(); | 206 | void reInitAlarmSettings(); |
206 | 207 | ||
207 | /** Notification function of IncidenceBase::Observer. */ | 208 | /** Notification function of IncidenceBase::Observer. */ |
208 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 209 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
209 | 210 | ||
210 | /** inserts an event into its "proper place" in the calendar. */ | 211 | /** inserts an event into its "proper place" in the calendar. */ |
211 | void insertEvent( Event *event ); | 212 | void insertEvent( Event *event ); |
212 | 213 | ||
213 | /** Append alarms of incidence in interval to list of alarms. */ | 214 | /** Append alarms of incidence in interval to list of alarms. */ |
214 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 215 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
215 | const QDateTime &from, const QDateTime &to ); | 216 | const QDateTime &from, const QDateTime &to ); |
216 | 217 | ||
217 | /** Append alarms of recurring events in interval to list of alarms. */ | 218 | /** Append alarms of recurring events in interval to list of alarms. */ |
218 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 219 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
219 | const QDateTime &from, const QDateTime &to ); | 220 | const QDateTime &from, const QDateTime &to ); |
220 | 221 | ||
221 | private: | 222 | private: |
222 | void init(); | 223 | void init(); |
223 | 224 | ||
224 | QPtrList<Event> mEventList; | 225 | QPtrList<Event> mEventList; |
225 | QPtrList<Todo> mTodoList; | 226 | QPtrList<Todo> mTodoList; |
226 | QPtrList<Journal> mJournalList; | 227 | QPtrList<Journal> mJournalList; |
227 | }; | 228 | }; |
228 | 229 | ||
229 | } | 230 | } |
230 | 231 | ||
231 | #endif | 232 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index a64eb34..719d80b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1751 +1,1763 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qapplication.h> | 52 | #include <qapplication.h> |
53 | 53 | ||
54 | #include <klocale.h> | 54 | #include <klocale.h> |
55 | #include <kglobal.h> | 55 | #include <kglobal.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | 58 | ||
59 | QDateTime KSyncManager::mRequestedSyncEvent; | 59 | QDateTime KSyncManager::mRequestedSyncEvent; |
60 | 60 | ||
61 | 61 | ||
62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
64 | { | 64 | { |
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | KSyncManager::~KSyncManager() | 73 | KSyncManager::~KSyncManager() |
74 | { | 74 | { |
75 | delete bar; | 75 | delete bar; |
76 | } | 76 | } |
77 | 77 | ||
78 | void KSyncManager::setDefaultFileName( QString s) | 78 | void KSyncManager::setDefaultFileName( QString s) |
79 | { | 79 | { |
80 | mDefFileName = s ; | 80 | mDefFileName = s ; |
81 | if ( mPrefs->mPassiveSyncAutoStart ) | 81 | if ( mPrefs->mPassiveSyncAutoStart ) |
82 | enableQuick( false ); | 82 | enableQuick( false ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KSyncManager::fillSyncMenu() | 85 | void KSyncManager::fillSyncMenu() |
86 | { | 86 | { |
87 | if ( mSyncMenu->count() ) | 87 | if ( mSyncMenu->count() ) |
88 | mSyncMenu->clear(); | 88 | mSyncMenu->clear(); |
89 | 89 | ||
90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
91 | mSyncMenu->insertSeparator(); | 91 | mSyncMenu->insertSeparator(); |
92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
95 | clearMenu->insertSeparator(); | 95 | clearMenu->insertSeparator(); |
96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
97 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
98 | if ( mServerSocket == 0 ) { | 98 | if ( mServerSocket == 0 ) { |
99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
100 | } else { | 100 | } else { |
101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
102 | } | 102 | } |
103 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
105 | mSyncMenu->insertSeparator(); | 105 | mSyncMenu->insertSeparator(); |
106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
107 | config.setGroup("General"); | 107 | config.setGroup("General"); |
108 | QStringList prof = config.readListEntry("SyncProfileNames"); | 108 | QStringList prof = config.readListEntry("SyncProfileNames"); |
109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
110 | if ( prof.count() < 2 ) { | 110 | if ( prof.count() < 2 ) { |
111 | prof.clear(); | 111 | prof.clear(); |
112 | QString externalName; | 112 | QString externalName; |
113 | #ifdef DESKTOP_VERSION | 113 | #ifdef DESKTOP_VERSION |
114 | #ifdef _WIN32_ | 114 | #ifdef _WIN32_ |
115 | externalName = "OutLook(not_implemented)"; | 115 | externalName = "OutLook(not_implemented)"; |
116 | #else | 116 | #else |
117 | externalName = "KDE_Desktop"; | 117 | externalName = "KDE_Desktop"; |
118 | #endif | 118 | #endif |
119 | #else | 119 | #else |
120 | externalName = "Sharp_DTM"; | 120 | externalName = "Sharp_DTM"; |
121 | #endif | 121 | #endif |
122 | prof << externalName; | 122 | prof << externalName; |
123 | prof << i18n("Local_file"); | 123 | prof << i18n("Local_file"); |
124 | prof << i18n("Last_file"); | 124 | prof << i18n("Last_file"); |
125 | KSyncProfile* temp = new KSyncProfile (); | 125 | KSyncProfile* temp = new KSyncProfile (); |
126 | temp->setName( prof[0] ); | 126 | temp->setName( prof[0] ); |
127 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
128 | temp->setName( prof[1] ); | 128 | temp->setName( prof[1] ); |
129 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
130 | temp->setName( prof[2] ); | 130 | temp->setName( prof[2] ); |
131 | temp->writeConfig(&config); | 131 | temp->writeConfig(&config); |
132 | config.setGroup("General"); | 132 | config.setGroup("General"); |
133 | config.writeEntry("SyncProfileNames",prof); | 133 | config.writeEntry("SyncProfileNames",prof); |
134 | config.writeEntry("ExternSyncProfiles",externalName); | 134 | config.writeEntry("ExternSyncProfiles",externalName); |
135 | config.sync(); | 135 | config.sync(); |
136 | delete temp; | 136 | delete temp; |
137 | } | 137 | } |
138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
139 | mSyncProfileNames = prof; | 139 | mSyncProfileNames = prof; |
140 | unsigned int i; | 140 | unsigned int i; |
141 | for ( i = 0; i < prof.count(); ++i ) { | 141 | for ( i = 0; i < prof.count(); ++i ) { |
142 | QString insertText = prof[i]; | 142 | QString insertText = prof[i]; |
143 | if ( i == 0 ) { | 143 | if ( i == 0 ) { |
144 | #ifdef DESKTOP_VERSION | 144 | #ifdef DESKTOP_VERSION |
145 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
146 | insertText = "OutLook(not_implemented)"; | 146 | insertText = "OutLook(not_implemented)"; |
147 | #else | 147 | #else |
148 | insertText = "KDE_Desktop"; | 148 | insertText = "KDE_Desktop"; |
149 | #endif | 149 | #endif |
150 | #else | 150 | #else |
151 | insertText = "Sharp_DTM"; | 151 | insertText = "Sharp_DTM"; |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | mSyncMenu->insertItem( insertText, 1000+i ); | 154 | mSyncMenu->insertItem( insertText, 1000+i ); |
155 | clearMenu->insertItem( insertText, 1000+i ); | 155 | clearMenu->insertItem( insertText, 1000+i ); |
156 | if ( i == 2 ) | 156 | if ( i == 2 ) |
157 | mSyncMenu->insertSeparator(); | 157 | mSyncMenu->insertSeparator(); |
158 | } | 158 | } |
159 | QDir app_dir; | 159 | QDir app_dir; |
160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
161 | if ( mTargetApp == PWMPI) { | 161 | if ( mTargetApp == PWMPI) { |
162 | mSyncMenu->removeItem( 1000 ); | 162 | mSyncMenu->removeItem( 1000 ); |
163 | clearMenu->removeItem( 1000 ); | 163 | clearMenu->removeItem( 1000 ); |
164 | } | 164 | } |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
167 | mSyncMenu->removeItem( 1000 ); | 167 | mSyncMenu->removeItem( 1000 ); |
168 | clearMenu->removeItem( 1000 ); | 168 | clearMenu->removeItem( 1000 ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mSyncMenu->removeItem( 1002 ); | 171 | mSyncMenu->removeItem( 1002 ); |
172 | clearMenu->removeItem( 1002 ); | 172 | clearMenu->removeItem( 1002 ); |
173 | } | 173 | } |
174 | void KSyncManager::slotClearMenu( int action ) | 174 | void KSyncManager::slotClearMenu( int action ) |
175 | { | 175 | { |
176 | QString syncDevice; | 176 | QString syncDevice; |
177 | if ( action > 999 ) { | 177 | if ( action > 999 ) { |
178 | syncDevice = mSyncProfileNames[action - 1000] ; | 178 | syncDevice = mSyncProfileNames[action - 1000] ; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | int result = 0; | 183 | int result = 0; |
184 | QString sd; | 184 | QString sd; |
185 | if ( syncDevice.isEmpty() ) | 185 | if ( syncDevice.isEmpty() ) |
186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
187 | else | 187 | else |
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | mCurrentResourceLocal = ""; | 199 | mCurrentResourceLocal = ""; |
200 | emit multiResourceSyncStart( false ); | ||
200 | if ( action == 5000 ) | 201 | if ( action == 5000 ) |
201 | return; | 202 | return; |
202 | mSyncWithDesktop = false; | 203 | mSyncWithDesktop = false; |
203 | if ( action == 0 ) { | 204 | if ( action == 0 ) { |
204 | 205 | ||
205 | // seems to be a Qt2 event handling bug | 206 | // seems to be a Qt2 event handling bug |
206 | // syncmenu.clear causes a segfault at first time | 207 | // syncmenu.clear causes a segfault at first time |
207 | // when we call it after the main event loop, it is ok | 208 | // when we call it after the main event loop, it is ok |
208 | // same behaviour when calling OM/Pi via QCOP for the first time | 209 | // same behaviour when calling OM/Pi via QCOP for the first time |
209 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
210 | //confSync(); | 211 | //confSync(); |
211 | 212 | ||
212 | return; | 213 | return; |
213 | } | 214 | } |
214 | if ( action == 1 ) { | 215 | if ( action == 1 ) { |
215 | multiSync( true ); | 216 | multiSync( true ); |
216 | return; | 217 | return; |
217 | } | 218 | } |
218 | if ( action == 2 ) { | 219 | if ( action == 2 ) { |
219 | enableQuick(); | 220 | enableQuick(); |
220 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
221 | return; | 222 | return; |
222 | } | 223 | } |
223 | if ( action == 3 ) { | 224 | if ( action == 3 ) { |
224 | delete mServerSocket; | 225 | delete mServerSocket; |
225 | mServerSocket = 0; | 226 | mServerSocket = 0; |
226 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
227 | return; | 228 | return; |
228 | } | 229 | } |
229 | 230 | ||
230 | if (blockSave()) | 231 | if (blockSave()) |
231 | return; | 232 | return; |
232 | 233 | ||
233 | setBlockSave(true); | 234 | setBlockSave(true); |
234 | bool silent = false; | 235 | bool silent = false; |
235 | if ( action == 999 ) { | 236 | if ( action == 999 ) { |
236 | //special mode for silent syncing | 237 | //special mode for silent syncing |
237 | action = 1000; | 238 | action = 1000; |
238 | silent = true; | 239 | silent = true; |
239 | } | 240 | } |
240 | 241 | ||
241 | mCurrentSyncProfile = action - 1000 ; | 242 | mCurrentSyncProfile = action - 1000 ; |
242 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
243 | mCurrentSyncName = mLocalMachineName ; | 244 | mCurrentSyncName = mLocalMachineName ; |
244 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
245 | KSyncProfile* temp = new KSyncProfile (); | 246 | KSyncProfile* temp = new KSyncProfile (); |
246 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
247 | temp->readConfig(&config); | 248 | temp->readConfig(&config); |
248 | if (silent) { | 249 | if (silent) { |
249 | mAskForPreferences = false; | 250 | mAskForPreferences = false; |
250 | mShowSyncSummary = false; | 251 | mShowSyncSummary = false; |
251 | mWriteBackFile = true; | 252 | mWriteBackFile = true; |
252 | mSyncAlgoPrefs = 2;// take newest | 253 | mSyncAlgoPrefs = 2;// take newest |
253 | } | 254 | } |
254 | else { | 255 | else { |
255 | mAskForPreferences = temp->getAskForPreferences(); | 256 | mAskForPreferences = temp->getAskForPreferences(); |
256 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
257 | mWriteBackFile = temp->getWriteBackFile(); | 258 | mWriteBackFile = temp->getWriteBackFile(); |
258 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 259 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
259 | } | 260 | } |
260 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
261 | mIsKapiFile = temp->getIsKapiFile(); | 262 | mIsKapiFile = temp->getIsKapiFile(); |
262 | mWriteBackInFuture = 0; | 263 | mWriteBackInFuture = 0; |
263 | if ( temp->getWriteBackFuture() ) { | 264 | if ( temp->getWriteBackFuture() ) { |
264 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
265 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
266 | } | 267 | } |
267 | mFilterInCal = temp->getFilterInCal(); | 268 | mFilterInCal = temp->getFilterInCal(); |
268 | mFilterOutCal = temp->getFilterOutCal(); | 269 | mFilterOutCal = temp->getFilterOutCal(); |
269 | mFilterInAB = temp->getFilterInAB(); | 270 | mFilterInAB = temp->getFilterInAB(); |
270 | mFilterOutAB = temp->getFilterOutAB(); | 271 | mFilterOutAB = temp->getFilterOutAB(); |
271 | 272 | ||
272 | if ( action == 1000 ) { | 273 | if ( action == 1000 ) { |
273 | mIsKapiFile = false; | 274 | mIsKapiFile = false; |
274 | #ifdef DESKTOP_VERSION | 275 | #ifdef DESKTOP_VERSION |
275 | syncKDE(); | 276 | syncKDE(); |
276 | #else | 277 | #else |
277 | syncSharp(); | 278 | syncSharp(); |
278 | #endif | 279 | #endif |
279 | 280 | ||
280 | } else if ( action == 1001 ) { | 281 | } else if ( action == 1001 ) { |
281 | syncLocalFile(); | 282 | syncLocalFile(); |
282 | 283 | ||
283 | } else if ( action == 1002 ) { | 284 | } else if ( action == 1002 ) { |
284 | mWriteBackFile = false; | 285 | mWriteBackFile = false; |
285 | mAskForPreferences = false; | 286 | mAskForPreferences = false; |
286 | mShowSyncSummary = false; | 287 | mShowSyncSummary = false; |
287 | mSyncAlgoPrefs = 3; | 288 | mSyncAlgoPrefs = 3; |
288 | quickSyncLocalFile(); | 289 | quickSyncLocalFile(); |
289 | 290 | ||
290 | } else if ( action >= 1003 ) { | 291 | } else if ( action >= 1003 ) { |
291 | if ( temp->getIsLocalFileSync() ) { | 292 | if ( temp->getIsLocalFileSync() ) { |
292 | switch(mTargetApp) | 293 | switch(mTargetApp) |
293 | { | 294 | { |
294 | case (KAPI): | 295 | case (KAPI): |
295 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
296 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
297 | break; | 298 | break; |
298 | case (KOPI): | 299 | case (KOPI): |
299 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
300 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
301 | break; | 302 | break; |
302 | case (PWMPI): | 303 | case (PWMPI): |
303 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
304 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
305 | break; | 306 | break; |
306 | default: | 307 | default: |
307 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
308 | break; | 309 | break; |
309 | 310 | ||
310 | } | 311 | } |
311 | } else { | 312 | } else { |
312 | if ( temp->getIsPhoneSync() ) { | 313 | if ( temp->getIsPhoneSync() ) { |
313 | mPhoneDevice = temp->getPhoneDevice( ) ; | 314 | mPhoneDevice = temp->getPhoneDevice( ) ; |
314 | mPhoneConnection = temp->getPhoneConnection( ); | 315 | mPhoneConnection = temp->getPhoneConnection( ); |
315 | mPhoneModel = temp->getPhoneModel( ); | 316 | mPhoneModel = temp->getPhoneModel( ); |
316 | syncPhone(); | 317 | syncPhone(); |
317 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { | 318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { |
318 | mSpecificResources.clear(); | 319 | mSpecificResources.clear(); |
319 | if ( mTargetApp == KAPI ) { | 320 | if ( mTargetApp == KAPI ) { |
320 | mPassWordPiSync = temp->getRemotePwAB(); | 321 | mPassWordPiSync = temp->getRemotePwAB(); |
321 | mActiveSyncPort = temp->getRemotePortAB(); | 322 | mActiveSyncPort = temp->getRemotePortAB(); |
322 | mActiveSyncIP = temp->getRemoteIPAB(); | 323 | mActiveSyncIP = temp->getRemoteIPAB(); |
323 | } else if ( mTargetApp == KOPI ) { | 324 | } else if ( mTargetApp == KOPI ) { |
324 | if ( temp->getIsPiSyncSpec() ) | 325 | if ( temp->getIsPiSyncSpec() ) |
325 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); | 326 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); |
326 | mPassWordPiSync = temp->getRemotePw(); | 327 | mPassWordPiSync = temp->getRemotePw(); |
327 | mActiveSyncPort = temp->getRemotePort(); | 328 | mActiveSyncPort = temp->getRemotePort(); |
328 | mActiveSyncIP = temp->getRemoteIP(); | 329 | mActiveSyncIP = temp->getRemoteIP(); |
329 | } else { | 330 | } else { |
330 | mPassWordPiSync = temp->getRemotePwPWM(); | 331 | mPassWordPiSync = temp->getRemotePwPWM(); |
331 | mActiveSyncPort = temp->getRemotePortPWM(); | 332 | mActiveSyncPort = temp->getRemotePortPWM(); |
332 | mActiveSyncIP = temp->getRemoteIPPWM(); | 333 | mActiveSyncIP = temp->getRemoteIPPWM(); |
333 | } | 334 | } |
334 | syncPi(); | 335 | syncPi(); |
335 | while ( !mPisyncFinished ) { | 336 | while ( !mPisyncFinished ) { |
336 | //qDebug("waiting "); | 337 | //qDebug("waiting "); |
337 | qApp->processEvents(); | 338 | qApp->processEvents(); |
338 | } | 339 | } |
339 | } else | 340 | } else |
340 | syncRemote( temp ); | 341 | syncRemote( temp ); |
341 | 342 | ||
342 | } | 343 | } |
343 | } | 344 | } |
344 | delete temp; | 345 | delete temp; |
345 | setBlockSave(false); | 346 | setBlockSave(false); |
346 | } | 347 | } |
347 | 348 | ||
348 | void KSyncManager::enableQuick( bool ask ) | 349 | void KSyncManager::enableQuick( bool ask ) |
349 | { | 350 | { |
350 | bool autoStart; | 351 | bool autoStart; |
351 | bool changed = false; | 352 | bool changed = false; |
352 | if ( ask ) { | 353 | if ( ask ) { |
353 | QDialog dia ( 0, "input-dialog", true ); | 354 | QDialog dia ( 0, "input-dialog", true ); |
354 | QLineEdit lab ( &dia ); | 355 | QLineEdit lab ( &dia ); |
355 | QVBoxLayout lay( &dia ); | 356 | QVBoxLayout lay( &dia ); |
356 | lab.setText( mPrefs->mPassiveSyncPort ); | 357 | lab.setText( mPrefs->mPassiveSyncPort ); |
357 | lay.setMargin(7); | 358 | lay.setMargin(7); |
358 | lay.setSpacing(7); | 359 | lay.setSpacing(7); |
359 | int po = 9197+mTargetApp; | 360 | int po = 9197+mTargetApp; |
360 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 361 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
361 | lay.addWidget( &label); | 362 | lay.addWidget( &label); |
362 | lay.addWidget( &lab); | 363 | lay.addWidget( &lab); |
363 | 364 | ||
364 | QLineEdit lepw ( &dia ); | 365 | QLineEdit lepw ( &dia ); |
365 | lepw.setText( mPrefs->mPassiveSyncPw ); | 366 | lepw.setText( mPrefs->mPassiveSyncPw ); |
366 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 367 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
367 | lay.addWidget( &label2); | 368 | lay.addWidget( &label2); |
368 | lay.addWidget( &lepw); | 369 | lay.addWidget( &lepw); |
369 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 370 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
370 | lay.addWidget( &autostart); | 371 | lay.addWidget( &autostart); |
371 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 372 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
372 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
373 | #ifdef _WIN32_ | 374 | #ifdef _WIN32_ |
374 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 375 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
375 | syncdesktop.hide();// not implemented! | 376 | syncdesktop.hide();// not implemented! |
376 | #else | 377 | #else |
377 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 378 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
378 | #endif | 379 | #endif |
379 | lay.addWidget( &syncdesktop); | 380 | lay.addWidget( &syncdesktop); |
380 | #else | 381 | #else |
381 | mPrefs->mPassiveSyncWithDesktop = false; | 382 | mPrefs->mPassiveSyncWithDesktop = false; |
382 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 383 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
383 | syncdesktop.hide(); | 384 | syncdesktop.hide(); |
384 | #endif | 385 | #endif |
385 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 386 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
386 | 387 | ||
387 | QPushButton pb ( "OK", &dia); | 388 | QPushButton pb ( "OK", &dia); |
388 | lay.addWidget( &pb ); | 389 | lay.addWidget( &pb ); |
389 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 390 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
390 | dia.resize( 230,120 ); | 391 | dia.resize( 230,120 ); |
391 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 392 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
392 | dia.show(); | 393 | dia.show(); |
393 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
394 | int dw = QApplication::desktop()->width(); | 395 | int dw = QApplication::desktop()->width(); |
395 | int dh = QApplication::desktop()->height(); | 396 | int dh = QApplication::desktop()->height(); |
396 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 397 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
397 | #endif | 398 | #endif |
398 | if ( ! dia.exec() ) | 399 | if ( ! dia.exec() ) |
399 | return; | 400 | return; |
400 | dia.hide(); | 401 | dia.hide(); |
401 | qApp->processEvents(); | 402 | qApp->processEvents(); |
402 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 403 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
403 | changed = true; | 404 | changed = true; |
404 | mPrefs->mPassiveSyncPw = lepw.text(); | 405 | mPrefs->mPassiveSyncPw = lepw.text(); |
405 | } | 406 | } |
406 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 407 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
407 | mPrefs->mPassiveSyncPort = lab.text(); | 408 | mPrefs->mPassiveSyncPort = lab.text(); |
408 | changed = true; | 409 | changed = true; |
409 | } | 410 | } |
410 | autoStart = autostart.isChecked(); | 411 | autoStart = autostart.isChecked(); |
411 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 412 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
412 | changed = true; | 413 | changed = true; |
413 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 414 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
414 | } | 415 | } |
415 | } | 416 | } |
416 | else | 417 | else |
417 | autoStart = mPrefs->mPassiveSyncAutoStart; | 418 | autoStart = mPrefs->mPassiveSyncAutoStart; |
418 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 419 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
419 | changed = true; | 420 | changed = true; |
420 | bool ok; | 421 | bool ok; |
421 | mPrefs->mPassiveSyncAutoStart = false; | 422 | mPrefs->mPassiveSyncAutoStart = false; |
422 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 423 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
423 | qDebug("%d ", port_t); | 424 | qDebug("%d ", port_t); |
424 | if ( ! ok || port_t > 65535 ) { | 425 | if ( ! ok || port_t > 65535 ) { |
425 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 426 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
426 | return; | 427 | return; |
427 | } | 428 | } |
428 | Q_UINT16 port = port_t; | 429 | Q_UINT16 port = port_t; |
429 | //qDebug("port %d ", port); | 430 | //qDebug("port %d ", port); |
430 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 431 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
431 | mServerSocket->setFileName( defaultFileName() );//bbb | 432 | mServerSocket->setFileName( defaultFileName() );//bbb |
432 | if ( !mServerSocket->ok() ) { | 433 | if ( !mServerSocket->ok() ) { |
433 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 434 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
434 | delete mServerSocket; | 435 | delete mServerSocket; |
435 | mServerSocket = 0; | 436 | mServerSocket = 0; |
436 | return; | 437 | return; |
437 | } | 438 | } |
438 | mPrefs->mPassiveSyncAutoStart = autoStart; | 439 | mPrefs->mPassiveSyncAutoStart = autoStart; |
439 | if ( changed ) { | 440 | if ( changed ) { |
440 | mPrefs->writeConfig(); | 441 | mPrefs->writeConfig(); |
441 | } | 442 | } |
442 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 443 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
443 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 444 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
445 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); | ||
446 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); | ||
444 | } | 447 | } |
445 | void KSyncManager::displayErrorPort() | 448 | void KSyncManager::displayErrorPort() |
446 | { | 449 | { |
447 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); | 450 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); |
448 | } | 451 | } |
449 | void KSyncManager::syncLocalFile() | 452 | void KSyncManager::syncLocalFile() |
450 | { | 453 | { |
451 | 454 | ||
452 | QString fn =mPrefs->mLastSyncedLocalFile; | 455 | QString fn =mPrefs->mLastSyncedLocalFile; |
453 | QString ext; | 456 | QString ext; |
454 | 457 | ||
455 | switch(mTargetApp) | 458 | switch(mTargetApp) |
456 | { | 459 | { |
457 | case (KAPI): | 460 | case (KAPI): |
458 | ext = "(*.vcf)"; | 461 | ext = "(*.vcf)"; |
459 | break; | 462 | break; |
460 | case (KOPI): | 463 | case (KOPI): |
461 | ext = "(*.ics/*.vcs)"; | 464 | ext = "(*.ics/*.vcs)"; |
462 | break; | 465 | break; |
463 | case (PWMPI): | 466 | case (PWMPI): |
464 | ext = "(*.pwm)"; | 467 | ext = "(*.pwm)"; |
465 | break; | 468 | break; |
466 | default: | 469 | default: |
467 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 470 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
468 | break; | 471 | break; |
469 | 472 | ||
470 | } | 473 | } |
471 | 474 | ||
472 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 475 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
473 | if ( fn == "" ) | 476 | if ( fn == "" ) |
474 | return; | 477 | return; |
475 | if ( syncWithFile( fn, false ) ) { | 478 | if ( syncWithFile( fn, false ) ) { |
476 | qDebug("KSM::syncLocalFile() successful "); | 479 | qDebug("KSM::syncLocalFile() successful "); |
477 | } | 480 | } |
478 | 481 | ||
479 | } | 482 | } |
480 | 483 | ||
481 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 484 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
482 | { | 485 | { |
483 | bool ret = false; | 486 | bool ret = false; |
484 | QFileInfo info; | 487 | QFileInfo info; |
485 | info.setFile( fn ); | 488 | info.setFile( fn ); |
486 | QString mess; | 489 | QString mess; |
487 | if ( !info. exists() ) { | 490 | if ( !info. exists() ) { |
488 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 491 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
489 | QMessageBox::warning( mParent, i18n("Warning!"), | 492 | QMessageBox::warning( mParent, i18n("Warning!"), |
490 | mess ); | 493 | mess ); |
491 | return ret; | 494 | return ret; |
492 | } | 495 | } |
493 | int result = 0; | 496 | int result = 0; |
494 | if ( !quick ) { | 497 | if ( !quick ) { |
495 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 498 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
496 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 499 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
497 | mess, | 500 | mess, |
498 | i18n("Sync"), i18n("Cancel"), 0, | 501 | i18n("Sync"), i18n("Cancel"), 0, |
499 | 0, 1 ); | 502 | 0, 1 ); |
500 | if ( result ) | 503 | if ( result ) |
501 | return false; | 504 | return false; |
502 | } | 505 | } |
503 | if ( mAskForPreferences ) | 506 | if ( mAskForPreferences ) |
504 | if ( !edit_sync_options()) { | 507 | if ( !edit_sync_options()) { |
505 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 508 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
506 | return false; | 509 | return false; |
507 | } | 510 | } |
508 | if ( result == 0 ) { | 511 | if ( result == 0 ) { |
509 | //qDebug("Now sycing ... "); | 512 | //qDebug("Now sycing ... "); |
510 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) | 513 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) |
511 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 514 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
512 | else | 515 | else |
513 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 516 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
514 | if ( ! quick ) | 517 | if ( ! quick ) |
515 | mPrefs->mLastSyncedLocalFile = fn; | 518 | mPrefs->mLastSyncedLocalFile = fn; |
516 | } | 519 | } |
517 | return ret; | 520 | return ret; |
518 | } | 521 | } |
519 | 522 | ||
520 | void KSyncManager::quickSyncLocalFile() | 523 | void KSyncManager::quickSyncLocalFile() |
521 | { | 524 | { |
522 | 525 | ||
523 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 526 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
524 | qDebug("KSM::quick syncLocalFile() successful "); | 527 | qDebug("KSM::quick syncLocalFile() successful "); |
525 | 528 | ||
526 | } | 529 | } |
527 | } | 530 | } |
528 | 531 | ||
529 | void KSyncManager::multiSync( bool askforPrefs ) | 532 | void KSyncManager::multiSync( bool askforPrefs ) |
530 | { | 533 | { |
531 | if (blockSave()) | 534 | if (blockSave()) |
532 | return; | 535 | return; |
533 | setBlockSave(true); | 536 | setBlockSave(true); |
534 | mCurrentResourceLocal = ""; | 537 | mCurrentResourceLocal = ""; |
535 | if ( askforPrefs ) { | 538 | if ( askforPrefs ) { |
536 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 539 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
537 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 540 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
538 | question, | 541 | question, |
539 | i18n("Yes"), i18n("No"), | 542 | i18n("Yes"), i18n("No"), |
540 | 0, 0 ) != 0 ) { | 543 | 0, 0 ) != 0 ) { |
541 | setBlockSave(false); | 544 | setBlockSave(false); |
542 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 545 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
543 | return; | 546 | return; |
544 | } | 547 | } |
545 | } | 548 | } |
546 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 549 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
547 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 550 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
548 | if ( askforPrefs ) { | 551 | if ( askforPrefs ) { |
549 | if ( !edit_sync_options()) { | 552 | if ( !edit_sync_options()) { |
550 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 553 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
551 | return; | 554 | return; |
552 | } | 555 | } |
553 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 556 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
554 | } | 557 | } |
555 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 558 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
556 | qApp->processEvents(); | 559 | qApp->processEvents(); |
557 | int num = ringSync() ; | 560 | int num = ringSync() ; |
558 | if ( num > 1 ) | 561 | if ( num > 1 ) |
559 | ringSync(); | 562 | ringSync(); |
560 | setBlockSave(false); | 563 | setBlockSave(false); |
561 | if ( num ) | 564 | if ( num ) |
562 | emit save(); | 565 | emit save(); |
563 | if ( num ) | 566 | if ( num ) |
564 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 567 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
565 | else | 568 | else |
566 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 569 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
567 | return; | 570 | return; |
568 | } | 571 | } |
569 | 572 | ||
570 | int KSyncManager::ringSync() | 573 | int KSyncManager::ringSync() |
571 | { | 574 | { |
572 | 575 | emit multiResourceSyncStart( false ); | |
573 | int syncedProfiles = 0; | 576 | int syncedProfiles = 0; |
574 | unsigned int i; | 577 | unsigned int i; |
575 | QTime timer; | 578 | QTime timer; |
576 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 579 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
577 | QStringList syncProfileNames = mSyncProfileNames; | 580 | QStringList syncProfileNames = mSyncProfileNames; |
578 | KSyncProfile* temp = new KSyncProfile (); | 581 | KSyncProfile* temp = new KSyncProfile (); |
579 | mAskForPreferences = false; | 582 | mAskForPreferences = false; |
580 | mCurrentResourceLocal = ""; | 583 | mCurrentResourceLocal = ""; |
581 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 584 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
582 | mCurrentSyncProfile = i; | 585 | mCurrentSyncProfile = i; |
583 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 586 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
584 | temp->readConfig(&config); | 587 | temp->readConfig(&config); |
585 | 588 | ||
586 | bool includeInRingSync = false; | 589 | bool includeInRingSync = false; |
587 | switch(mTargetApp) | 590 | switch(mTargetApp) |
588 | { | 591 | { |
589 | case (KAPI): | 592 | case (KAPI): |
590 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 593 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
591 | break; | 594 | break; |
592 | case (KOPI): | 595 | case (KOPI): |
593 | includeInRingSync = temp->getIncludeInRingSync(); | 596 | includeInRingSync = temp->getIncludeInRingSync(); |
594 | break; | 597 | break; |
595 | case (PWMPI): | 598 | case (PWMPI): |
596 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 599 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
597 | break; | 600 | break; |
598 | default: | 601 | default: |
599 | qDebug("KSM::ringSync: invalid apptype selected"); | 602 | qDebug("KSM::ringSync: invalid apptype selected"); |
600 | break; | 603 | break; |
601 | 604 | ||
602 | } | 605 | } |
603 | 606 | ||
604 | 607 | ||
605 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 608 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
606 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 609 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
607 | ++syncedProfiles; | 610 | ++syncedProfiles; |
608 | mSyncWithDesktop = false; | 611 | mSyncWithDesktop = false; |
609 | // mAskForPreferences = temp->getAskForPreferences(); | 612 | // mAskForPreferences = temp->getAskForPreferences(); |
610 | mWriteBackFile = temp->getWriteBackFile(); | 613 | mWriteBackFile = temp->getWriteBackFile(); |
611 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 614 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
612 | mIsKapiFile = temp->getIsKapiFile(); | 615 | mIsKapiFile = temp->getIsKapiFile(); |
613 | mWriteBackInFuture = 0; | 616 | mWriteBackInFuture = 0; |
614 | if ( temp->getWriteBackFuture() ) { | 617 | if ( temp->getWriteBackFuture() ) { |
615 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 618 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
616 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 619 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
617 | } | 620 | } |
618 | mFilterInCal = temp->getFilterInCal(); | 621 | mFilterInCal = temp->getFilterInCal(); |
619 | mFilterOutCal = temp->getFilterOutCal(); | 622 | mFilterOutCal = temp->getFilterOutCal(); |
620 | mFilterInAB = temp->getFilterInAB(); | 623 | mFilterInAB = temp->getFilterInAB(); |
621 | mFilterOutAB = temp->getFilterOutAB(); | 624 | mFilterOutAB = temp->getFilterOutAB(); |
622 | mShowSyncSummary = false; | 625 | mShowSyncSummary = false; |
623 | mCurrentSyncDevice = syncProfileNames[i] ; | 626 | mCurrentSyncDevice = syncProfileNames[i] ; |
624 | mCurrentSyncName = mLocalMachineName; | 627 | mCurrentSyncName = mLocalMachineName; |
625 | if ( i == 0 ) { | 628 | if ( i == 0 ) { |
626 | mIsKapiFile = false; | 629 | mIsKapiFile = false; |
627 | #ifdef DESKTOP_VERSION | 630 | #ifdef DESKTOP_VERSION |
628 | syncKDE(); | 631 | syncKDE(); |
629 | #else | 632 | #else |
630 | syncSharp(); | 633 | syncSharp(); |
631 | #endif | 634 | #endif |
632 | } else { | 635 | } else { |
633 | if ( temp->getIsLocalFileSync() ) { | 636 | if ( temp->getIsLocalFileSync() ) { |
634 | switch(mTargetApp) | 637 | switch(mTargetApp) |
635 | { | 638 | { |
636 | case (KAPI): | 639 | case (KAPI): |
637 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 640 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
638 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 641 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
639 | break; | 642 | break; |
640 | case (KOPI): | 643 | case (KOPI): |
641 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 644 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
642 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 645 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
643 | break; | 646 | break; |
644 | case (PWMPI): | 647 | case (PWMPI): |
645 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 648 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
646 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 649 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
647 | break; | 650 | break; |
648 | default: | 651 | default: |
649 | qDebug("KSM: invalid apptype selected"); | 652 | qDebug("KSM: invalid apptype selected"); |
650 | break; | 653 | break; |
651 | } | 654 | } |
652 | } else { | 655 | } else { |
653 | if ( temp->getIsPhoneSync() ) { | 656 | if ( temp->getIsPhoneSync() ) { |
654 | mPhoneDevice = temp->getPhoneDevice( ) ; | 657 | mPhoneDevice = temp->getPhoneDevice( ) ; |
655 | mPhoneConnection = temp->getPhoneConnection( ); | 658 | mPhoneConnection = temp->getPhoneConnection( ); |
656 | mPhoneModel = temp->getPhoneModel( ); | 659 | mPhoneModel = temp->getPhoneModel( ); |
657 | syncPhone(); | 660 | syncPhone(); |
658 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { | 661 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { |
659 | mSpecificResources.clear(); | 662 | mSpecificResources.clear(); |
660 | if ( mTargetApp == KAPI ) { | 663 | if ( mTargetApp == KAPI ) { |
661 | mPassWordPiSync = temp->getRemotePwAB(); | 664 | mPassWordPiSync = temp->getRemotePwAB(); |
662 | mActiveSyncPort = temp->getRemotePortAB(); | 665 | mActiveSyncPort = temp->getRemotePortAB(); |
663 | mActiveSyncIP = temp->getRemoteIPAB(); | 666 | mActiveSyncIP = temp->getRemoteIPAB(); |
664 | } else if ( mTargetApp == KOPI ) { | 667 | } else if ( mTargetApp == KOPI ) { |
665 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); | 668 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); |
666 | mPassWordPiSync = temp->getRemotePw(); | 669 | mPassWordPiSync = temp->getRemotePw(); |
667 | mActiveSyncPort = temp->getRemotePort(); | 670 | mActiveSyncPort = temp->getRemotePort(); |
668 | mActiveSyncIP = temp->getRemoteIP(); | 671 | mActiveSyncIP = temp->getRemoteIP(); |
669 | } else { | 672 | } else { |
670 | mPassWordPiSync = temp->getRemotePwPWM(); | 673 | mPassWordPiSync = temp->getRemotePwPWM(); |
671 | mActiveSyncPort = temp->getRemotePortPWM(); | 674 | mActiveSyncPort = temp->getRemotePortPWM(); |
672 | mActiveSyncIP = temp->getRemoteIPPWM(); | 675 | mActiveSyncIP = temp->getRemoteIPPWM(); |
673 | } | 676 | } |
674 | syncPi(); | 677 | syncPi(); |
675 | while ( !mPisyncFinished ) { | 678 | while ( !mPisyncFinished ) { |
676 | //qDebug("waiting "); | 679 | //qDebug("waiting "); |
677 | qApp->processEvents(); | 680 | qApp->processEvents(); |
678 | } | 681 | } |
679 | timer.start(); | 682 | timer.start(); |
680 | while ( timer.elapsed () < 2000 ) { | 683 | while ( timer.elapsed () < 2000 ) { |
681 | qApp->processEvents(); | 684 | qApp->processEvents(); |
682 | } | 685 | } |
683 | } else | 686 | } else |
684 | syncRemote( temp, false ); | 687 | syncRemote( temp, false ); |
685 | 688 | ||
686 | } | 689 | } |
687 | } | 690 | } |
688 | timer.start(); | 691 | timer.start(); |
689 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 692 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
690 | while ( timer.elapsed () < 2000 ) { | 693 | while ( timer.elapsed () < 2000 ) { |
691 | qApp->processEvents(); | 694 | qApp->processEvents(); |
692 | #ifndef _WIN32_ | 695 | #ifndef _WIN32_ |
693 | sleep (1); | 696 | sleep (1); |
694 | #endif | 697 | #endif |
695 | } | 698 | } |
696 | 699 | ||
697 | } | 700 | } |
698 | 701 | ||
699 | } | 702 | } |
700 | delete temp; | 703 | delete temp; |
701 | return syncedProfiles; | 704 | return syncedProfiles; |
702 | } | 705 | } |
703 | 706 | ||
704 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 707 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
705 | { | 708 | { |
706 | QString question; | 709 | QString question; |
707 | if ( ask ) { | 710 | if ( ask ) { |
708 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 711 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
709 | if ( QMessageBox::information( mParent, i18n("Sync"), | 712 | if ( QMessageBox::information( mParent, i18n("Sync"), |
710 | question, | 713 | question, |
711 | i18n("Yes"), i18n("No"), | 714 | i18n("Yes"), i18n("No"), |
712 | 0, 0 ) != 0 ) | 715 | 0, 0 ) != 0 ) |
713 | return; | 716 | return; |
714 | } | 717 | } |
715 | 718 | ||
716 | QString preCommand; | 719 | QString preCommand; |
717 | QString localTempFile; | 720 | QString localTempFile; |
718 | QString postCommand; | 721 | QString postCommand; |
719 | 722 | ||
720 | switch(mTargetApp) | 723 | switch(mTargetApp) |
721 | { | 724 | { |
722 | case (KAPI): | 725 | case (KAPI): |
723 | preCommand = prof->getPreSyncCommandAB(); | 726 | preCommand = prof->getPreSyncCommandAB(); |
724 | postCommand = prof->getPostSyncCommandAB(); | 727 | postCommand = prof->getPostSyncCommandAB(); |
725 | localTempFile = prof->getLocalTempFileAB(); | 728 | localTempFile = prof->getLocalTempFileAB(); |
726 | break; | 729 | break; |
727 | case (KOPI): | 730 | case (KOPI): |
728 | preCommand = prof->getPreSyncCommand(); | 731 | preCommand = prof->getPreSyncCommand(); |
729 | postCommand = prof->getPostSyncCommand(); | 732 | postCommand = prof->getPostSyncCommand(); |
730 | localTempFile = prof->getLocalTempFile(); | 733 | localTempFile = prof->getLocalTempFile(); |
731 | break; | 734 | break; |
732 | case (PWMPI): | 735 | case (PWMPI): |
733 | preCommand = prof->getPreSyncCommandPWM(); | 736 | preCommand = prof->getPreSyncCommandPWM(); |
734 | postCommand = prof->getPostSyncCommandPWM(); | 737 | postCommand = prof->getPostSyncCommandPWM(); |
735 | localTempFile = prof->getLocalTempFilePWM(); | 738 | localTempFile = prof->getLocalTempFilePWM(); |
736 | break; | 739 | break; |
737 | default: | 740 | default: |
738 | qDebug("KSM::syncRemote: invalid apptype selected"); | 741 | qDebug("KSM::syncRemote: invalid apptype selected"); |
739 | break; | 742 | break; |
740 | } | 743 | } |
741 | 744 | ||
742 | 745 | ||
743 | int fi; | 746 | int fi; |
744 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 747 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
745 | QString pwd = getPassword(); | 748 | QString pwd = getPassword(); |
746 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 749 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
747 | 750 | ||
748 | } | 751 | } |
749 | int maxlen = 30; | 752 | int maxlen = 30; |
750 | if ( QApplication::desktop()->width() > 320 ) | 753 | if ( QApplication::desktop()->width() > 320 ) |
751 | maxlen += 25; | 754 | maxlen += 25; |
752 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 755 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
753 | int fileSize = 0; | 756 | int fileSize = 0; |
754 | int result = system ( preCommand ); | 757 | int result = system ( preCommand ); |
755 | // 0 : okay | 758 | // 0 : okay |
756 | // 256: no such file or dir | 759 | // 256: no such file or dir |
757 | // | 760 | // |
758 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); | 761 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
759 | if ( result != 0 ) { | 762 | if ( result != 0 ) { |
760 | unsigned int len = maxlen; | 763 | unsigned int len = maxlen; |
761 | while ( len < preCommand.length() ) { | 764 | while ( len < preCommand.length() ) { |
762 | preCommand.insert( len , "\n" ); | 765 | preCommand.insert( len , "\n" ); |
763 | len += maxlen +2; | 766 | len += maxlen +2; |
764 | } | 767 | } |
765 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 768 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
766 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 769 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
767 | question, | 770 | question, |
768 | i18n("Okay!")) ; | 771 | i18n("Okay!")) ; |
769 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 772 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
770 | return; | 773 | return; |
771 | } | 774 | } |
772 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 775 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
773 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 776 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
774 | 777 | ||
775 | if ( syncWithFile( localTempFile, true ) ) { | 778 | if ( syncWithFile( localTempFile, true ) ) { |
776 | 779 | ||
777 | if ( mWriteBackFile ) { | 780 | if ( mWriteBackFile ) { |
778 | int fi; | 781 | int fi; |
779 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 782 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
780 | QString pwd = getPassword(); | 783 | QString pwd = getPassword(); |
781 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 784 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
782 | 785 | ||
783 | } | 786 | } |
784 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 787 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
785 | result = system ( postCommand ); | 788 | result = system ( postCommand ); |
786 | qDebug("KSM::Sync:Writing back file result: %d ", result); | 789 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
787 | if ( result != 0 ) { | 790 | if ( result != 0 ) { |
788 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 791 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
789 | return; | 792 | return; |
790 | } else { | 793 | } else { |
791 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 794 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
792 | } | 795 | } |
793 | } | 796 | } |
794 | } | 797 | } |
795 | return; | 798 | return; |
796 | } | 799 | } |
797 | bool KSyncManager::edit_pisync_options() | 800 | bool KSyncManager::edit_pisync_options() |
798 | { | 801 | { |
799 | QDialog dia( mParent, "dia", true ); | 802 | QDialog dia( mParent, "dia", true ); |
800 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 803 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
801 | QVBoxLayout lay ( &dia ); | 804 | QVBoxLayout lay ( &dia ); |
802 | lay.setSpacing( 5 ); | 805 | lay.setSpacing( 5 ); |
803 | lay.setMargin( 3 ); | 806 | lay.setMargin( 3 ); |
804 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 807 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
805 | lay.addWidget( &lab1 ); | 808 | lay.addWidget( &lab1 ); |
806 | QLineEdit le1 (&dia ); | 809 | QLineEdit le1 (&dia ); |
807 | lay.addWidget( &le1 ); | 810 | lay.addWidget( &le1 ); |
808 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 811 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
809 | lay.addWidget( &lab2 ); | 812 | lay.addWidget( &lab2 ); |
810 | QLineEdit le2 (&dia ); | 813 | QLineEdit le2 (&dia ); |
811 | lay.addWidget( &le2 ); | 814 | lay.addWidget( &le2 ); |
812 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); | 815 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); |
813 | lay.addWidget( &lab3 ); | 816 | lay.addWidget( &lab3 ); |
814 | QLineEdit le3 (&dia ); | 817 | QLineEdit le3 (&dia ); |
815 | lay.addWidget( &le3 ); | 818 | lay.addWidget( &le3 ); |
816 | QPushButton pb ( "OK", &dia); | 819 | QPushButton pb ( "OK", &dia); |
817 | lay.addWidget( &pb ); | 820 | lay.addWidget( &pb ); |
818 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 821 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
819 | le1.setText( mPassWordPiSync ); | 822 | le1.setText( mPassWordPiSync ); |
820 | le2.setText( mActiveSyncIP ); | 823 | le2.setText( mActiveSyncIP ); |
821 | le3.setText( mActiveSyncPort ); | 824 | le3.setText( mActiveSyncPort ); |
822 | if ( dia.exec() ) { | 825 | if ( dia.exec() ) { |
823 | mPassWordPiSync = le1.text(); | 826 | mPassWordPiSync = le1.text(); |
824 | mActiveSyncPort = le3.text(); | 827 | mActiveSyncPort = le3.text(); |
825 | mActiveSyncIP = le2.text(); | 828 | mActiveSyncIP = le2.text(); |
826 | return true; | 829 | return true; |
827 | } | 830 | } |
828 | return false; | 831 | return false; |
829 | } | 832 | } |
830 | bool KSyncManager::edit_sync_options() | 833 | bool KSyncManager::edit_sync_options() |
831 | { | 834 | { |
832 | 835 | ||
833 | QDialog dia( mParent, "dia", true ); | 836 | QDialog dia( mParent, "dia", true ); |
834 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 837 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
835 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 838 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
836 | QVBoxLayout lay ( &dia ); | 839 | QVBoxLayout lay ( &dia ); |
837 | lay.setSpacing( 2 ); | 840 | lay.setSpacing( 2 ); |
838 | lay.setMargin( 3 ); | 841 | lay.setMargin( 3 ); |
839 | lay.addWidget(&gr); | 842 | lay.addWidget(&gr); |
840 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 843 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
841 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 844 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
842 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 845 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
843 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 846 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
844 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 847 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
845 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 848 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
846 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 849 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
847 | QPushButton pb ( "OK", &dia); | 850 | QPushButton pb ( "OK", &dia); |
848 | lay.addWidget( &pb ); | 851 | lay.addWidget( &pb ); |
849 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 852 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
850 | switch ( mSyncAlgoPrefs ) { | 853 | switch ( mSyncAlgoPrefs ) { |
851 | case 0: | 854 | case 0: |
852 | loc.setChecked( true); | 855 | loc.setChecked( true); |
853 | break; | 856 | break; |
854 | case 1: | 857 | case 1: |
855 | rem.setChecked( true ); | 858 | rem.setChecked( true ); |
856 | break; | 859 | break; |
857 | case 2: | 860 | case 2: |
858 | newest.setChecked( true); | 861 | newest.setChecked( true); |
859 | break; | 862 | break; |
860 | case 3: | 863 | case 3: |
861 | ask.setChecked( true); | 864 | ask.setChecked( true); |
862 | break; | 865 | break; |
863 | case 4: | 866 | case 4: |
864 | f_loc.setChecked( true); | 867 | f_loc.setChecked( true); |
865 | break; | 868 | break; |
866 | case 5: | 869 | case 5: |
867 | f_rem.setChecked( true); | 870 | f_rem.setChecked( true); |
868 | break; | 871 | break; |
869 | case 6: | 872 | case 6: |
870 | // both.setChecked( true); | 873 | // both.setChecked( true); |
871 | break; | 874 | break; |
872 | default: | 875 | default: |
873 | break; | 876 | break; |
874 | } | 877 | } |
875 | if ( dia.exec() ) { | 878 | if ( dia.exec() ) { |
876 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 879 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
877 | return true; | 880 | return true; |
878 | } | 881 | } |
879 | return false; | 882 | return false; |
880 | } | 883 | } |
881 | 884 | ||
882 | QString KSyncManager::getPassword( ) | 885 | QString KSyncManager::getPassword( ) |
883 | { | 886 | { |
884 | QString retfile = ""; | 887 | QString retfile = ""; |
885 | QDialog dia ( mParent, "input-dialog", true ); | 888 | QDialog dia ( mParent, "input-dialog", true ); |
886 | QLineEdit lab ( &dia ); | 889 | QLineEdit lab ( &dia ); |
887 | lab.setEchoMode( QLineEdit::Password ); | 890 | lab.setEchoMode( QLineEdit::Password ); |
888 | QVBoxLayout lay( &dia ); | 891 | QVBoxLayout lay( &dia ); |
889 | lay.setMargin(7); | 892 | lay.setMargin(7); |
890 | lay.setSpacing(7); | 893 | lay.setSpacing(7); |
891 | lay.addWidget( &lab); | 894 | lay.addWidget( &lab); |
892 | dia.setFixedSize( 230,50 ); | 895 | dia.setFixedSize( 230,50 ); |
893 | dia.setCaption( i18n("Enter password") ); | 896 | dia.setCaption( i18n("Enter password") ); |
894 | QPushButton pb ( "OK", &dia); | 897 | QPushButton pb ( "OK", &dia); |
895 | lay.addWidget( &pb ); | 898 | lay.addWidget( &pb ); |
896 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 899 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
897 | dia.show(); | 900 | dia.show(); |
898 | int res = dia.exec(); | 901 | int res = dia.exec(); |
899 | if ( res ) | 902 | if ( res ) |
900 | retfile = lab.text(); | 903 | retfile = lab.text(); |
901 | dia.hide(); | 904 | dia.hide(); |
902 | qApp->processEvents(); | 905 | qApp->processEvents(); |
903 | return retfile; | 906 | return retfile; |
904 | 907 | ||
905 | } | 908 | } |
906 | 909 | ||
907 | 910 | ||
908 | void KSyncManager::confSync() | 911 | void KSyncManager::confSync() |
909 | { | 912 | { |
910 | static KSyncPrefsDialog* sp = 0; | 913 | static KSyncPrefsDialog* sp = 0; |
911 | if ( ! sp ) { | 914 | if ( ! sp ) { |
912 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 915 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
913 | } | 916 | } |
914 | sp->usrReadConfig(); | 917 | sp->usrReadConfig(); |
915 | #ifndef DESKTOP_VERSION | 918 | #ifndef DESKTOP_VERSION |
916 | sp->showMaximized(); | 919 | sp->showMaximized(); |
917 | #else | 920 | #else |
918 | sp->show(); | 921 | sp->show(); |
919 | #endif | 922 | #endif |
920 | sp->exec(); | 923 | sp->exec(); |
921 | QStringList oldSyncProfileNames = mSyncProfileNames; | 924 | QStringList oldSyncProfileNames = mSyncProfileNames; |
922 | mSyncProfileNames = sp->getSyncProfileNames(); | 925 | mSyncProfileNames = sp->getSyncProfileNames(); |
923 | mLocalMachineName = sp->getLocalMachineName (); | 926 | mLocalMachineName = sp->getLocalMachineName (); |
924 | int ii; | 927 | int ii; |
925 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 928 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
926 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 929 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
927 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 930 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
928 | } | 931 | } |
929 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 932 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
930 | } | 933 | } |
931 | void KSyncManager::syncKDE() | 934 | void KSyncManager::syncKDE() |
932 | { | 935 | { |
933 | mSyncWithDesktop = true; | 936 | mSyncWithDesktop = true; |
934 | emit save(); | 937 | emit save(); |
935 | switch(mTargetApp) | 938 | switch(mTargetApp) |
936 | { | 939 | { |
937 | case (KAPI): | 940 | case (KAPI): |
938 | { | 941 | { |
939 | #ifdef DESKTOP_VERSION | 942 | #ifdef DESKTOP_VERSION |
940 | QString command = "kdeabdump33"; | 943 | QString command = "kdeabdump33"; |
941 | QString commandfile = "kdeabdump33"; | 944 | QString commandfile = "kdeabdump33"; |
942 | QString commandpath = qApp->applicationDirPath () + "/"; | 945 | QString commandpath = qApp->applicationDirPath () + "/"; |
943 | #else | 946 | #else |
944 | QString command = "kdeabdump33"; | 947 | QString command = "kdeabdump33"; |
945 | QString commandfile = "kdeabdump33"; | 948 | QString commandfile = "kdeabdump33"; |
946 | QString commandpath = QDir::homeDirPath ()+"/"; | 949 | QString commandpath = QDir::homeDirPath ()+"/"; |
947 | #endif | 950 | #endif |
948 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 951 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
949 | command = commandfile; | 952 | command = commandfile; |
950 | else | 953 | else |
951 | command = commandpath+commandfile; | 954 | command = commandpath+commandfile; |
952 | 955 | ||
953 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 956 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
954 | int result = system ( command.latin1()); | 957 | int result = system ( command.latin1()); |
955 | qDebug("AB dump 33 command call result: %d ", result); | 958 | qDebug("AB dump 33 command call result: %d ", result); |
956 | if ( result != 0 ) { | 959 | if ( result != 0 ) { |
957 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 960 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
958 | commandfile = "kdeabdump34"; | 961 | commandfile = "kdeabdump34"; |
959 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 962 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
960 | command = commandfile; | 963 | command = commandfile; |
961 | else | 964 | else |
962 | command = commandpath+commandfile; | 965 | command = commandpath+commandfile; |
963 | result = system ( command.latin1()); | 966 | result = system ( command.latin1()); |
964 | qDebug("AB dump 34 command call result: %d ", result); | 967 | qDebug("AB dump 34 command call result: %d ", result); |
965 | if ( result != 0 ) { | 968 | if ( result != 0 ) { |
966 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 969 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
967 | return; | 970 | return; |
968 | } | 971 | } |
969 | } | 972 | } |
970 | if ( syncWithFile( fileName,true ) ) { | 973 | if ( syncWithFile( fileName,true ) ) { |
971 | if ( mWriteBackFile ) { | 974 | if ( mWriteBackFile ) { |
972 | command += " --read"; | 975 | command += " --read"; |
973 | system ( command.latin1()); | 976 | system ( command.latin1()); |
974 | } | 977 | } |
975 | } | 978 | } |
976 | 979 | ||
977 | } | 980 | } |
978 | break; | 981 | break; |
979 | case (KOPI): | 982 | case (KOPI): |
980 | { | 983 | { |
981 | #ifdef DESKTOP_VERSION | 984 | #ifdef DESKTOP_VERSION |
982 | QString command = "kdecaldump33"; | 985 | QString command = "kdecaldump33"; |
983 | QString commandfile = "kdecaldump33"; | 986 | QString commandfile = "kdecaldump33"; |
984 | QString commandpath = qApp->applicationDirPath () + "/"; | 987 | QString commandpath = qApp->applicationDirPath () + "/"; |
985 | #else | 988 | #else |
986 | QString command = "kdecaldump33"; | 989 | QString command = "kdecaldump33"; |
987 | QString commandfile = "kdecaldump33"; | 990 | QString commandfile = "kdecaldump33"; |
988 | QString commandpath = QDir::homeDirPath ()+"/"; | 991 | QString commandpath = QDir::homeDirPath ()+"/"; |
989 | #endif | 992 | #endif |
990 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 993 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
991 | command = commandfile; | 994 | command = commandfile; |
992 | else | 995 | else |
993 | command = commandpath+commandfile; | 996 | command = commandpath+commandfile; |
994 | 997 | ||
995 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 998 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
996 | int result = system ( command.latin1()); | 999 | int result = system ( command.latin1()); |
997 | qDebug("Cal dump 33 command call result result: %d ", result); | 1000 | qDebug("Cal dump 33 command call result result: %d ", result); |
998 | if ( result != 0 ) { | 1001 | if ( result != 0 ) { |
999 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 1002 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
1000 | commandfile = "kdecaldump34"; | 1003 | commandfile = "kdecaldump34"; |
1001 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1004 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
1002 | command = commandfile; | 1005 | command = commandfile; |
1003 | else | 1006 | else |
1004 | command = commandpath+commandfile; | 1007 | command = commandpath+commandfile; |
1005 | result = system ( command.latin1()); | 1008 | result = system ( command.latin1()); |
1006 | qDebug("Cal dump 34 command call result result: %d ", result); | 1009 | qDebug("Cal dump 34 command call result result: %d ", result); |
1007 | if ( result != 0 ) { | 1010 | if ( result != 0 ) { |
1008 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1011 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
1009 | return; | 1012 | return; |
1010 | } | 1013 | } |
1011 | } | 1014 | } |
1012 | if ( syncWithFile( fileName,true ) ) { | 1015 | if ( syncWithFile( fileName,true ) ) { |
1013 | if ( mWriteBackFile ) { | 1016 | if ( mWriteBackFile ) { |
1014 | command += " --read"; | 1017 | command += " --read"; |
1015 | system ( command.latin1()); | 1018 | system ( command.latin1()); |
1016 | } | 1019 | } |
1017 | } | 1020 | } |
1018 | 1021 | ||
1019 | } | 1022 | } |
1020 | break; | 1023 | break; |
1021 | case (PWMPI): | 1024 | case (PWMPI): |
1022 | 1025 | ||
1023 | break; | 1026 | break; |
1024 | default: | 1027 | default: |
1025 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 1028 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
1026 | break; | 1029 | break; |
1027 | 1030 | ||
1028 | } | 1031 | } |
1029 | } | 1032 | } |
1030 | 1033 | ||
1031 | void KSyncManager::syncSharp() | 1034 | void KSyncManager::syncSharp() |
1032 | { | 1035 | { |
1033 | 1036 | ||
1034 | if ( ! syncExternalApplication("sharp") ) | 1037 | if ( ! syncExternalApplication("sharp") ) |
1035 | qDebug("KSM::ERROR sync sharp "); | 1038 | qDebug("KSM::ERROR sync sharp "); |
1036 | } | 1039 | } |
1037 | 1040 | ||
1038 | bool KSyncManager::syncExternalApplication(QString resource) | 1041 | bool KSyncManager::syncExternalApplication(QString resource) |
1039 | { | 1042 | { |
1040 | 1043 | ||
1041 | emit save(); | 1044 | emit save(); |
1042 | 1045 | ||
1043 | if ( mAskForPreferences ) | 1046 | if ( mAskForPreferences ) |
1044 | if ( !edit_sync_options()) { | 1047 | if ( !edit_sync_options()) { |
1045 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1048 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1046 | return false; | 1049 | return false; |
1047 | } | 1050 | } |
1048 | 1051 | ||
1049 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1052 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1050 | 1053 | ||
1051 | bool syncOK = mImplementation->syncExternal(this, resource); | 1054 | bool syncOK = mImplementation->syncExternal(this, resource); |
1052 | 1055 | ||
1053 | return syncOK; | 1056 | return syncOK; |
1054 | 1057 | ||
1055 | } | 1058 | } |
1056 | 1059 | ||
1057 | void KSyncManager::syncPhone() | 1060 | void KSyncManager::syncPhone() |
1058 | { | 1061 | { |
1059 | 1062 | ||
1060 | syncExternalApplication("phone"); | 1063 | syncExternalApplication("phone"); |
1061 | 1064 | ||
1062 | } | 1065 | } |
1063 | 1066 | ||
1064 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1067 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1065 | { | 1068 | { |
1066 | if (!bar->isVisible()) | 1069 | if (!bar->isVisible()) |
1067 | { | 1070 | { |
1068 | int w = 300; | 1071 | int w = 300; |
1069 | if ( QApplication::desktop()->width() < 320 ) | 1072 | if ( QApplication::desktop()->width() < 320 ) |
1070 | w = 220; | 1073 | w = 220; |
1071 | int h = bar->sizeHint().height() ; | 1074 | int h = bar->sizeHint().height() ; |
1072 | int dw = QApplication::desktop()->width(); | 1075 | int dw = QApplication::desktop()->width(); |
1073 | int dh = QApplication::desktop()->height(); | 1076 | int dh = QApplication::desktop()->height(); |
1074 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1077 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1075 | bar->setCaption (caption); | 1078 | bar->setCaption (caption); |
1076 | bar->setTotalSteps ( total ) ; | 1079 | bar->setTotalSteps ( total ) ; |
1077 | bar->show(); | 1080 | bar->show(); |
1078 | } | 1081 | } |
1079 | bar->raise(); | 1082 | bar->raise(); |
1080 | bar->setProgress( percentage ); | 1083 | bar->setProgress( percentage ); |
1081 | qApp->processEvents(); | 1084 | qApp->processEvents(); |
1082 | } | 1085 | } |
1083 | 1086 | ||
1084 | void KSyncManager::hideProgressBar() | 1087 | void KSyncManager::hideProgressBar() |
1085 | { | 1088 | { |
1086 | bar->hide(); | 1089 | bar->hide(); |
1087 | qApp->processEvents(); | 1090 | qApp->processEvents(); |
1088 | } | 1091 | } |
1089 | 1092 | ||
1090 | bool KSyncManager::isProgressBarCanceled() | 1093 | bool KSyncManager::isProgressBarCanceled() |
1091 | { | 1094 | { |
1092 | return !bar->isVisible(); | 1095 | return !bar->isVisible(); |
1093 | } | 1096 | } |
1094 | 1097 | ||
1095 | QString KSyncManager::syncFileName() | 1098 | QString KSyncManager::syncFileName() |
1096 | { | 1099 | { |
1097 | 1100 | ||
1098 | QString fn = "tempfile"; | 1101 | QString fn = "tempfile"; |
1099 | switch(mTargetApp) | 1102 | switch(mTargetApp) |
1100 | { | 1103 | { |
1101 | case (KAPI): | 1104 | case (KAPI): |
1102 | fn = "tempsyncab.vcf"; | 1105 | fn = "tempsyncab.vcf"; |
1103 | break; | 1106 | break; |
1104 | case (KOPI): | 1107 | case (KOPI): |
1105 | fn = "tempsynccal.ics"; | 1108 | fn = "tempsynccal.ics"; |
1106 | break; | 1109 | break; |
1107 | case (PWMPI): | 1110 | case (PWMPI): |
1108 | fn = "tempsyncpw.pwm"; | 1111 | fn = "tempsyncpw.pwm"; |
1109 | break; | 1112 | break; |
1110 | default: | 1113 | default: |
1111 | break; | 1114 | break; |
1112 | } | 1115 | } |
1113 | #ifdef DESKTOP_VERSION | 1116 | #ifdef DESKTOP_VERSION |
1114 | return locateLocal( "tmp", fn ); | 1117 | return locateLocal( "tmp", fn ); |
1115 | #else | 1118 | #else |
1116 | return (QString( "/tmp/" )+ fn ); | 1119 | return (QString( "/tmp/" )+ fn ); |
1117 | #endif | 1120 | #endif |
1118 | } | 1121 | } |
1119 | 1122 | ||
1120 | void KSyncManager::syncPi() | 1123 | void KSyncManager::syncPi() |
1121 | { | 1124 | { |
1122 | mIsKapiFile = true; | 1125 | mIsKapiFile = true; |
1123 | mPisyncFinished = false; | 1126 | mPisyncFinished = false; |
1124 | qApp->processEvents(); | 1127 | qApp->processEvents(); |
1125 | if ( mAskForPreferences ) | 1128 | if ( mAskForPreferences ) |
1126 | if ( !edit_pisync_options()) { | 1129 | if ( !edit_pisync_options()) { |
1127 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1130 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1128 | mPisyncFinished = true; | 1131 | mPisyncFinished = true; |
1129 | return; | 1132 | return; |
1130 | } | 1133 | } |
1131 | bool ok; | 1134 | bool ok; |
1132 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1135 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1133 | if ( ! ok ) { | 1136 | if ( ! ok ) { |
1134 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1137 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1135 | mPisyncFinished = true; | 1138 | mPisyncFinished = true; |
1136 | return; | 1139 | return; |
1137 | } | 1140 | } |
1138 | mCurrentResourceLocal = ""; | 1141 | mCurrentResourceLocal = ""; |
1139 | mCurrentResourceRemote = ""; | 1142 | mCurrentResourceRemote = ""; |
1140 | if ( mSpecificResources.count() ) { | 1143 | if ( mSpecificResources.count() ) { |
1141 | int startLocal = 0; | 1144 | int startLocal = 0; |
1142 | int startRemote = mSpecificResources.count()/2; | 1145 | int startRemote = mSpecificResources.count()/2; |
1146 | emit multiResourceSyncStart( true ); | ||
1143 | while ( startLocal < mSpecificResources.count()/2 ) { | 1147 | while ( startLocal < mSpecificResources.count()/2 ) { |
1148 | if ( startLocal+1 >= mSpecificResources.count()/2 ) | ||
1149 | emit multiResourceSyncStart( false ); | ||
1144 | mPisyncFinished = false; | 1150 | mPisyncFinished = false; |
1145 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | 1151 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; |
1146 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | 1152 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; |
1147 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1153 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1148 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1154 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1149 | commandSocket->readFile( syncFileName() ); | 1155 | commandSocket->readFile( syncFileName() ); |
1150 | while ( !mPisyncFinished ) { | 1156 | while ( !mPisyncFinished ) { |
1151 | //qDebug("waiting "); | 1157 | //qDebug("waiting "); |
1152 | qApp->processEvents(); | 1158 | qApp->processEvents(); |
1153 | } | 1159 | } |
1154 | ++startLocal; | 1160 | ++startLocal; |
1155 | } | 1161 | } |
1156 | } else { | 1162 | } else { |
1157 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1163 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1158 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1164 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1159 | commandSocket->readFile( syncFileName() ); | 1165 | commandSocket->readFile( syncFileName() ); |
1160 | } | 1166 | } |
1161 | } | 1167 | } |
1162 | 1168 | ||
1163 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1169 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1164 | { | 1170 | { |
1165 | //enum { success, errorW, errorR, quiet }; | 1171 | //enum { success, errorW, errorR, quiet }; |
1166 | 1172 | ||
1167 | 1173 | ||
1168 | 1174 | ||
1169 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1175 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1170 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1176 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1171 | if ( state == KCommandSocket::errorPW ) | 1177 | if ( state == KCommandSocket::errorPW ) |
1172 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1178 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1173 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1179 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1174 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1180 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1175 | else if ( state == KCommandSocket::errorCA ) | 1181 | else if ( state == KCommandSocket::errorCA ) |
1176 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1182 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1177 | else if ( state == KCommandSocket::errorFI ) | 1183 | else if ( state == KCommandSocket::errorFI ) |
1178 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1184 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1179 | else if ( state == KCommandSocket::errorED ) | 1185 | else if ( state == KCommandSocket::errorED ) |
1180 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1186 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1181 | else if ( state == KCommandSocket::errorUN ) | 1187 | else if ( state == KCommandSocket::errorUN ) |
1182 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1188 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1183 | delete s; | 1189 | delete s; |
1184 | if ( state == KCommandSocket::errorR ) { | 1190 | if ( state == KCommandSocket::errorR ) { |
1185 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1191 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1186 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1192 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1187 | commandSocket->sendStop(); | 1193 | commandSocket->sendStop(); |
1188 | } | 1194 | } |
1189 | mPisyncFinished = true; | 1195 | mPisyncFinished = true; |
1190 | return; | 1196 | return; |
1191 | 1197 | ||
1192 | } else if ( state == KCommandSocket::errorW ) { | 1198 | } else if ( state == KCommandSocket::errorW ) { |
1193 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1199 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1194 | mPisyncFinished = true; | 1200 | mPisyncFinished = true; |
1195 | 1201 | ||
1196 | } else if ( state == KCommandSocket::successR ) { | 1202 | } else if ( state == KCommandSocket::successR ) { |
1197 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1203 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1198 | 1204 | ||
1199 | } else if ( state == KCommandSocket::successW ) { | 1205 | } else if ( state == KCommandSocket::successW ) { |
1200 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1206 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1201 | mPisyncFinished = true; | 1207 | mPisyncFinished = true; |
1202 | } else if ( state == KCommandSocket::quiet ){ | 1208 | } else if ( state == KCommandSocket::quiet ){ |
1203 | qDebug("KSS: quiet "); | 1209 | qDebug("KSS: quiet "); |
1204 | mPisyncFinished = true; | 1210 | mPisyncFinished = true; |
1205 | } else { | 1211 | } else { |
1206 | qDebug("KSS: Error: unknown state: %d ", state); | 1212 | qDebug("KSS: Error: unknown state: %d ", state); |
1207 | mPisyncFinished = true; | 1213 | mPisyncFinished = true; |
1208 | } | 1214 | } |
1209 | 1215 | ||
1210 | delete s; | 1216 | delete s; |
1211 | } | 1217 | } |
1212 | 1218 | ||
1213 | void KSyncManager::readFileFromSocket() | 1219 | void KSyncManager::readFileFromSocket() |
1214 | { | 1220 | { |
1215 | QString fileName = syncFileName(); | 1221 | QString fileName = syncFileName(); |
1216 | bool syncOK = true; | 1222 | bool syncOK = true; |
1217 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1223 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1218 | if ( ! syncWithFile( fileName , true ) ) { | 1224 | if ( ! syncWithFile( fileName , true ) ) { |
1219 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1225 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1220 | syncOK = false; | 1226 | syncOK = false; |
1221 | } | 1227 | } |
1222 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); | 1228 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); |
1223 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1229 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1224 | if ( mWriteBackFile && syncOK ) { | 1230 | if ( mWriteBackFile && syncOK ) { |
1225 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); | 1231 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); |
1226 | commandSocket->writeFile( fileName ); | 1232 | commandSocket->writeFile( fileName ); |
1227 | } | 1233 | } |
1228 | else { | 1234 | else { |
1229 | commandSocket->sendStop(); | 1235 | commandSocket->sendStop(); |
1230 | if ( syncOK ) | 1236 | if ( syncOK ) |
1231 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1237 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1232 | mPisyncFinished = true; | 1238 | mPisyncFinished = true; |
1233 | } | 1239 | } |
1234 | } | 1240 | } |
1235 | 1241 | ||
1236 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1242 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1237 | { | 1243 | { |
1238 | mPassWord = pw; | 1244 | mPassWord = pw; |
1239 | mSocket = 0; | 1245 | mSocket = 0; |
1240 | mSyncActionDialog = 0; | 1246 | mSyncActionDialog = 0; |
1241 | blockRC = false; | 1247 | blockRC = false; |
1242 | mErrorMessage = 0; | 1248 | mErrorMessage = 0; |
1243 | } | 1249 | } |
1244 | 1250 | ||
1245 | void KServerSocket::newConnection ( int socket ) | 1251 | void KServerSocket::newConnection ( int socket ) |
1246 | { | 1252 | { |
1247 | // qDebug("KServerSocket:New connection %d ", socket); | 1253 | // qDebug("KServerSocket:New connection %d ", socket); |
1248 | if ( mSocket ) { | 1254 | if ( mSocket ) { |
1249 | qDebug("KSS::newConnection Socket deleted! "); | 1255 | qDebug("KSS::newConnection Socket deleted! "); |
1250 | delete mSocket; | 1256 | delete mSocket; |
1251 | mSocket = 0; | 1257 | mSocket = 0; |
1252 | } | 1258 | } |
1253 | mSocket = new QSocket( this ); | 1259 | mSocket = new QSocket( this ); |
1254 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1260 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1255 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1261 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1256 | mSocket->setSocket( socket ); | 1262 | mSocket->setSocket( socket ); |
1257 | } | 1263 | } |
1258 | 1264 | ||
1259 | void KServerSocket::discardClient() | 1265 | void KServerSocket::discardClient() |
1260 | { | 1266 | { |
1261 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1267 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1262 | } | 1268 | } |
1263 | void KServerSocket::deleteSocket() | 1269 | void KServerSocket::deleteSocket() |
1264 | { | 1270 | { |
1265 | qDebug("KSS::deleteSocket"); | 1271 | qDebug("KSS::deleteSocket"); |
1266 | if ( mSocket ) { | 1272 | if ( mSocket ) { |
1267 | delete mSocket; | 1273 | delete mSocket; |
1268 | mSocket = 0; | 1274 | mSocket = 0; |
1269 | } | 1275 | } |
1270 | if ( mErrorMessage ) | 1276 | if ( mErrorMessage ) |
1271 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); | 1277 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); |
1272 | } | 1278 | } |
1273 | void KServerSocket::readClient() | 1279 | void KServerSocket::readClient() |
1274 | { | 1280 | { |
1275 | if ( blockRC ) | 1281 | if ( blockRC ) |
1276 | return; | 1282 | return; |
1277 | if ( mSocket == 0 ) { | 1283 | if ( mSocket == 0 ) { |
1278 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1284 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1279 | return; | 1285 | return; |
1280 | } | 1286 | } |
1281 | if ( mErrorMessage ) { | 1287 | if ( mErrorMessage ) { |
1282 | mErrorMessage = 999; | 1288 | mErrorMessage = 999; |
1283 | error_connect("ERROR_ED\r\n\r\n"); | 1289 | error_connect("ERROR_ED\r\n\r\n"); |
1284 | return; | 1290 | return; |
1285 | } | 1291 | } |
1292 | mResource = ""; | ||
1286 | mErrorMessage = 0; | 1293 | mErrorMessage = 0; |
1287 | //qDebug("KServerSocket::readClient()"); | 1294 | //qDebug("KServerSocket::readClient()"); |
1288 | if ( mSocket->canReadLine() ) { | 1295 | if ( mSocket->canReadLine() ) { |
1289 | QString line = mSocket->readLine(); | 1296 | QString line = mSocket->readLine(); |
1290 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1297 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1291 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1298 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1292 | if ( tokens[0] == "GET" ) { | 1299 | if ( tokens[0] == "GET" ) { |
1293 | if ( tokens[1] == mPassWord ) { | 1300 | if ( tokens[1] == mPassWord ) { |
1294 | //emit sendFile( mSocket ); | 1301 | //emit sendFile( mSocket ); |
1295 | bool ok = false; | 1302 | bool ok = false; |
1296 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1303 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1297 | if ( ok ) { | 1304 | if ( ok ) { |
1298 | KSyncManager::mRequestedSyncEvent = dt; | 1305 | KSyncManager::mRequestedSyncEvent = dt; |
1299 | } | 1306 | } |
1300 | else | 1307 | else |
1301 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1308 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1309 | mResource =tokens[3]; | ||
1302 | send_file(); | 1310 | send_file(); |
1303 | } | 1311 | } |
1304 | else { | 1312 | else { |
1305 | mErrorMessage = 1; | 1313 | mErrorMessage = 1; |
1306 | error_connect("ERROR_PW\r\n\r\n"); | 1314 | error_connect("ERROR_PW\r\n\r\n"); |
1307 | } | 1315 | } |
1308 | } | 1316 | } |
1309 | if ( tokens[0] == "PUT" ) { | 1317 | if ( tokens[0] == "PUT" ) { |
1310 | if ( tokens[1] == mPassWord ) { | 1318 | if ( tokens[1] == mPassWord ) { |
1311 | //emit getFile( mSocket ); | 1319 | //emit getFile( mSocket ); |
1312 | blockRC = true; | 1320 | blockRC = true; |
1321 | mResource =tokens[2]; | ||
1313 | get_file(); | 1322 | get_file(); |
1314 | } | 1323 | } |
1315 | else { | 1324 | else { |
1316 | mErrorMessage = 2; | 1325 | mErrorMessage = 2; |
1317 | error_connect("ERROR_PW\r\n\r\n"); | 1326 | error_connect("ERROR_PW\r\n\r\n"); |
1318 | end_connect(); | 1327 | end_connect(); |
1319 | } | 1328 | } |
1320 | } | 1329 | } |
1321 | if ( tokens[0] == "STOP" ) { | 1330 | if ( tokens[0] == "STOP" ) { |
1322 | //emit endConnect(); | 1331 | //emit endConnect(); |
1323 | end_connect(); | 1332 | end_connect(); |
1324 | } | 1333 | } |
1325 | } | 1334 | } |
1326 | } | 1335 | } |
1327 | void KServerSocket::displayErrorMessage() | 1336 | void KServerSocket::displayErrorMessage() |
1328 | { | 1337 | { |
1329 | if ( mErrorMessage == 1 ) { | 1338 | if ( mErrorMessage == 1 ) { |
1330 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1339 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1331 | mErrorMessage = 0; | 1340 | mErrorMessage = 0; |
1332 | } | 1341 | } |
1333 | else if ( mErrorMessage == 2 ) { | 1342 | else if ( mErrorMessage == 2 ) { |
1334 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1343 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1335 | mErrorMessage = 0; | 1344 | mErrorMessage = 0; |
1336 | } | 1345 | } |
1337 | } | 1346 | } |
1338 | void KServerSocket::error_connect( QString errmess ) | 1347 | void KServerSocket::error_connect( QString errmess ) |
1339 | { | 1348 | { |
1340 | QTextStream os( mSocket ); | 1349 | QTextStream os( mSocket ); |
1341 | os.setEncoding( QTextStream::Latin1 ); | 1350 | os.setEncoding( QTextStream::Latin1 ); |
1342 | os << errmess ; | 1351 | os << errmess ; |
1343 | mSocket->close(); | 1352 | mSocket->close(); |
1344 | if ( mSocket->state() == QSocket::Idle ) { | 1353 | if ( mSocket->state() == QSocket::Idle ) { |
1345 | QTimer::singleShot( 0, this , SLOT ( discardClient())); | 1354 | QTimer::singleShot( 0, this , SLOT ( discardClient())); |
1346 | } | 1355 | } |
1347 | } | 1356 | } |
1348 | void KServerSocket::end_connect() | 1357 | void KServerSocket::end_connect() |
1349 | { | 1358 | { |
1350 | delete mSyncActionDialog; | 1359 | delete mSyncActionDialog; |
1351 | mSyncActionDialog = 0; | 1360 | mSyncActionDialog = 0; |
1352 | } | 1361 | } |
1353 | void KServerSocket::send_file() | 1362 | void KServerSocket::send_file() |
1354 | { | 1363 | { |
1355 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1364 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1356 | if ( mSyncActionDialog ) | 1365 | if ( mSyncActionDialog ) |
1357 | delete mSyncActionDialog; | 1366 | delete mSyncActionDialog; |
1358 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1367 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1359 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1368 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1360 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1369 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1361 | label->setAlignment ( Qt::AlignHCenter ); | 1370 | label->setAlignment ( Qt::AlignHCenter ); |
1362 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1371 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1363 | lay->addWidget( label); | 1372 | lay->addWidget( label); |
1364 | lay->setMargin(7); | 1373 | lay->setMargin(7); |
1365 | lay->setSpacing(7); | 1374 | lay->setSpacing(7); |
1366 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1375 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1367 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1376 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1368 | //secs = 333; | 1377 | //secs = 333; |
1369 | if ( secs < 0 ) | 1378 | if ( secs < 0 ) |
1370 | secs = secs * (-1); | 1379 | secs = secs * (-1); |
1371 | if ( secs > 30 ) | 1380 | if ( secs > 30 ) |
1372 | //if ( true ) | 1381 | //if ( true ) |
1373 | { | 1382 | { |
1374 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1383 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1375 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1384 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1376 | label->setAlignment ( Qt::AlignHCenter ); | 1385 | label->setAlignment ( Qt::AlignHCenter ); |
1377 | lay->addWidget( label); | 1386 | lay->addWidget( label); |
1378 | if ( secs > 180 ) | 1387 | if ( secs > 180 ) |
1379 | { | 1388 | { |
1380 | if ( secs > 300 ) { | 1389 | if ( secs > 300 ) { |
1381 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1390 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1382 | qDebug("KSS::Sync cancelled ,cs"); | 1391 | qDebug("KSS::Sync cancelled ,cs"); |
1383 | mErrorMessage = 0; | 1392 | mErrorMessage = 0; |
1384 | end_connect(); | 1393 | end_connect(); |
1385 | error_connect("ERROR_CA\r\n\r\n"); | 1394 | error_connect("ERROR_CA\r\n\r\n"); |
1386 | return ; | 1395 | return ; |
1387 | } | 1396 | } |
1388 | } | 1397 | } |
1389 | QFont f = label->font(); | 1398 | QFont f = label->font(); |
1390 | f.setPointSize ( f.pointSize() *2 ); | 1399 | f.setPointSize ( f.pointSize() *2 ); |
1391 | f. setBold (true ); | 1400 | f. setBold (true ); |
1392 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1401 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1393 | label->setFont( f ); | 1402 | label->setFont( f ); |
1394 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1403 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1395 | label->setText( warning ); | 1404 | label->setText( warning ); |
1396 | label->setAlignment ( Qt::AlignHCenter ); | 1405 | label->setAlignment ( Qt::AlignHCenter ); |
1397 | lay->addWidget( label); | 1406 | lay->addWidget( label); |
1398 | mSyncActionDialog->setFixedSize( 230, 300); | 1407 | mSyncActionDialog->setFixedSize( 230, 300); |
1399 | } else { | 1408 | } else { |
1400 | mSyncActionDialog->setFixedSize( 230, 200); | 1409 | mSyncActionDialog->setFixedSize( 230, 200); |
1401 | } | 1410 | } |
1402 | } else { | 1411 | } else { |
1403 | mSyncActionDialog->setFixedSize( 230, 120); | 1412 | mSyncActionDialog->setFixedSize( 230, 120); |
1404 | } | 1413 | } |
1405 | } else | 1414 | } else |
1406 | mSyncActionDialog->setFixedSize( 230, 120); | 1415 | mSyncActionDialog->setFixedSize( 230, 120); |
1407 | mSyncActionDialog->show(); | 1416 | mSyncActionDialog->show(); |
1408 | mSyncActionDialog->raise(); | 1417 | mSyncActionDialog->raise(); |
1418 | emit request_file(mResource); | ||
1409 | emit request_file(); | 1419 | emit request_file(); |
1410 | qApp->processEvents(); | 1420 | qApp->processEvents(); |
1411 | QString fileName = mFileName; | 1421 | QString fileName = mFileName; |
1412 | QFile file( fileName ); | 1422 | QFile file( fileName ); |
1413 | if (!file.open( IO_ReadOnly ) ) { | 1423 | if (!file.open( IO_ReadOnly ) ) { |
1414 | mErrorMessage = 0; | 1424 | mErrorMessage = 0; |
1415 | end_connect(); | 1425 | end_connect(); |
1416 | error_connect("ERROR_FI\r\n\r\n"); | 1426 | error_connect("ERROR_FI\r\n\r\n"); |
1417 | return ; | 1427 | return ; |
1418 | } | 1428 | } |
1419 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1429 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1420 | QTextStream ts( &file ); | 1430 | QTextStream ts( &file ); |
1421 | ts.setEncoding( QTextStream::Latin1 ); | 1431 | ts.setEncoding( QTextStream::Latin1 ); |
1422 | 1432 | ||
1423 | QTextStream os( mSocket ); | 1433 | QTextStream os( mSocket ); |
1424 | os.setEncoding( QTextStream::Latin1 ); | 1434 | os.setEncoding( QTextStream::Latin1 ); |
1425 | while ( ! ts.atEnd() ) { | 1435 | while ( ! ts.atEnd() ) { |
1426 | os << ts.readLine() << "\r\n"; | 1436 | os << ts.readLine() << "\r\n"; |
1427 | } | 1437 | } |
1428 | os << "\r\n"; | 1438 | os << "\r\n"; |
1429 | //os << ts.read(); | 1439 | //os << ts.read(); |
1430 | file.close(); | 1440 | file.close(); |
1431 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1441 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1432 | mSocket->close(); | 1442 | mSocket->close(); |
1433 | if ( mSocket->state() == QSocket::Idle ) | 1443 | if ( mSocket->state() == QSocket::Idle ) |
1434 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1444 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1435 | } | 1445 | } |
1436 | void KServerSocket::get_file() | 1446 | void KServerSocket::get_file() |
1437 | { | 1447 | { |
1438 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1448 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1439 | 1449 | ||
1440 | piTime.start(); | 1450 | piTime.start(); |
1441 | piFileString = ""; | 1451 | piFileString = ""; |
1442 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1452 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1443 | } | 1453 | } |
1444 | 1454 | ||
1445 | 1455 | ||
1446 | void KServerSocket::readBackFileFromSocket() | 1456 | void KServerSocket::readBackFileFromSocket() |
1447 | { | 1457 | { |
1448 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1458 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1449 | while ( mSocket->canReadLine () ) { | 1459 | while ( mSocket->canReadLine () ) { |
1450 | piTime.restart(); | 1460 | piTime.restart(); |
1451 | QString line = mSocket->readLine (); | 1461 | QString line = mSocket->readLine (); |
1452 | piFileString += line; | 1462 | piFileString += line; |
1453 | //qDebug("readline: %s ", line.latin1()); | 1463 | //qDebug("readline: %s ", line.latin1()); |
1454 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1464 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1455 | 1465 | ||
1456 | } | 1466 | } |
1457 | if ( piTime.elapsed () < 3000 ) { | 1467 | if ( piTime.elapsed () < 3000 ) { |
1458 | // wait for more | 1468 | // wait for more |
1459 | //qDebug("waitformore "); | 1469 | //qDebug("waitformore "); |
1460 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1470 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1461 | return; | 1471 | return; |
1462 | } | 1472 | } |
1463 | QString fileName = mFileName; | 1473 | QString fileName = mFileName; |
1464 | QFile file ( fileName ); | 1474 | QFile file ( fileName ); |
1465 | if (!file.open( IO_WriteOnly ) ) { | 1475 | if (!file.open( IO_WriteOnly ) ) { |
1466 | delete mSyncActionDialog; | 1476 | delete mSyncActionDialog; |
1467 | mSyncActionDialog = 0; | 1477 | mSyncActionDialog = 0; |
1468 | qDebug("KSS:Error open read back file "); | 1478 | qDebug("KSS:Error open read back file "); |
1469 | piFileString = ""; | 1479 | piFileString = ""; |
1470 | emit file_received( false ); | 1480 | emit file_received( false, mResource); |
1481 | emit file_received( false); | ||
1471 | blockRC = false; | 1482 | blockRC = false; |
1472 | return ; | 1483 | return ; |
1473 | 1484 | ||
1474 | } | 1485 | } |
1475 | 1486 | ||
1476 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1487 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1477 | QTextStream ts ( &file ); | 1488 | QTextStream ts ( &file ); |
1478 | ts.setEncoding( QTextStream::Latin1 ); | 1489 | ts.setEncoding( QTextStream::Latin1 ); |
1479 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1490 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1480 | ts << piFileString; | 1491 | ts << piFileString; |
1481 | mSocket->close(); | 1492 | mSocket->close(); |
1482 | if ( mSocket->state() == QSocket::Idle ) | 1493 | if ( mSocket->state() == QSocket::Idle ) |
1483 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1494 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1484 | file.close(); | 1495 | file.close(); |
1485 | piFileString = ""; | 1496 | piFileString = ""; |
1486 | emit file_received( true ); | 1497 | emit file_received( true, mResource ); |
1498 | emit file_received( true); | ||
1487 | delete mSyncActionDialog; | 1499 | delete mSyncActionDialog; |
1488 | mSyncActionDialog = 0; | 1500 | mSyncActionDialog = 0; |
1489 | blockRC = false; | 1501 | blockRC = false; |
1490 | 1502 | ||
1491 | } | 1503 | } |
1492 | 1504 | ||
1493 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) | 1505 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) |
1494 | { | 1506 | { |
1495 | mRemoteResource = remres; | 1507 | mRemoteResource = remres; |
1496 | if ( mRemoteResource.isEmpty() ) | 1508 | if ( mRemoteResource.isEmpty() ) |
1497 | mRemoteResource = "ALL"; | 1509 | mRemoteResource = "ALL"; |
1498 | mPassWord = password; | 1510 | mPassWord = password; |
1499 | mSocket = 0; | 1511 | mSocket = 0; |
1500 | mFirst = false; | 1512 | mFirst = false; |
1501 | mFirstLine = true; | 1513 | mFirstLine = true; |
1502 | mPort = port; | 1514 | mPort = port; |
1503 | mHost = host; | 1515 | mHost = host; |
1504 | tlw = cap; | 1516 | tlw = cap; |
1505 | mRetVal = quiet; | 1517 | mRetVal = quiet; |
1506 | mTimerSocket = new QTimer ( this ); | 1518 | mTimerSocket = new QTimer ( this ); |
1507 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); | 1519 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); |
1508 | mConnectProgress.setCaption( i18n("Pi-Sync") ); | 1520 | mConnectProgress.setCaption( i18n("Pi-Sync") ); |
1509 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); | 1521 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); |
1510 | mConnectCount = -1; | 1522 | mConnectCount = -1; |
1511 | } | 1523 | } |
1512 | void KCommandSocket::sendFileRequest() | 1524 | void KCommandSocket::sendFileRequest() |
1513 | { | 1525 | { |
1514 | if ( tlw ) | 1526 | if ( tlw ) |
1515 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); | 1527 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); |
1516 | mConnectProgress.hide(); | 1528 | mConnectProgress.hide(); |
1517 | mConnectCount = 300;mConnectMax = 300; | 1529 | mConnectCount = 300;mConnectMax = 300; |
1518 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); | 1530 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); |
1519 | mTimerSocket->start( 100, true ); | 1531 | mTimerSocket->start( 100, true ); |
1520 | QTextStream os( mSocket ); | 1532 | QTextStream os( mSocket ); |
1521 | os.setEncoding( QTextStream::Latin1 ); | 1533 | os.setEncoding( QTextStream::Latin1 ); |
1522 | 1534 | ||
1523 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1535 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1524 | os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n"; | 1536 | os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n"; |
1525 | } | 1537 | } |
1526 | 1538 | ||
1527 | void KCommandSocket::readFile( QString fn ) | 1539 | void KCommandSocket::readFile( QString fn ) |
1528 | { | 1540 | { |
1529 | if ( !mSocket ) { | 1541 | if ( !mSocket ) { |
1530 | mSocket = new QSocket( this ); | 1542 | mSocket = new QSocket( this ); |
1531 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1543 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1532 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1544 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1533 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); | 1545 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); |
1534 | } | 1546 | } |
1535 | mFileString = ""; | 1547 | mFileString = ""; |
1536 | mFileName = fn; | 1548 | mFileName = fn; |
1537 | mFirst = true; | 1549 | mFirst = true; |
1538 | if ( tlw ) | 1550 | if ( tlw ) |
1539 | tlw->setCaption( i18n("Trying to connect to remote...") ); | 1551 | tlw->setCaption( i18n("Trying to connect to remote...") ); |
1540 | mConnectCount = 30;mConnectMax = 30; | 1552 | mConnectCount = 30;mConnectMax = 30; |
1541 | mTimerSocket->start( 1000, true ); | 1553 | mTimerSocket->start( 1000, true ); |
1542 | mSocket->connectToHost( mHost, mPort ); | 1554 | mSocket->connectToHost( mHost, mPort ); |
1543 | qDebug("KSS: Waiting for connection"); | 1555 | qDebug("KSS: Waiting for connection"); |
1544 | } | 1556 | } |
1545 | void KCommandSocket::updateConnectDialog() | 1557 | void KCommandSocket::updateConnectDialog() |
1546 | { | 1558 | { |
1547 | 1559 | ||
1548 | if ( mConnectCount == mConnectMax ) { | 1560 | if ( mConnectCount == mConnectMax ) { |
1549 | //qDebug("MAXX %d", mConnectMax); | 1561 | //qDebug("MAXX %d", mConnectMax); |
1550 | mConnectProgress.setTotalSteps ( 30 ); | 1562 | mConnectProgress.setTotalSteps ( 30 ); |
1551 | mConnectProgress.show(); | 1563 | mConnectProgress.show(); |
1552 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); | 1564 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); |
1553 | } | 1565 | } |
1554 | //qDebug("updateConnectDialog() %d", mConnectCount); | 1566 | //qDebug("updateConnectDialog() %d", mConnectCount); |
1555 | mConnectProgress.raise(); | 1567 | mConnectProgress.raise(); |
1556 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); | 1568 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); |
1557 | --mConnectCount; | 1569 | --mConnectCount; |
1558 | if ( mConnectCount > 0 ) | 1570 | if ( mConnectCount > 0 ) |
1559 | mTimerSocket->start( 1000, true ); | 1571 | mTimerSocket->start( 1000, true ); |
1560 | else | 1572 | else |
1561 | deleteSocket(); | 1573 | deleteSocket(); |
1562 | 1574 | ||
1563 | } | 1575 | } |
1564 | void KCommandSocket::writeFile( QString fileName ) | 1576 | void KCommandSocket::writeFile( QString fileName ) |
1565 | { | 1577 | { |
1566 | if ( !mSocket ) { | 1578 | if ( !mSocket ) { |
1567 | mSocket = new QSocket( this ); | 1579 | mSocket = new QSocket( this ); |
1568 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1580 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1569 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1581 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1570 | } | 1582 | } |
1571 | mFileName = fileName ; | 1583 | mFileName = fileName ; |
1572 | mConnectCount = 30;mConnectMax = 30; | 1584 | mConnectCount = 30;mConnectMax = 30; |
1573 | mTimerSocket->start( 1000, true ); | 1585 | mTimerSocket->start( 1000, true ); |
1574 | mSocket->connectToHost( mHost, mPort ); | 1586 | mSocket->connectToHost( mHost, mPort ); |
1575 | } | 1587 | } |
1576 | void KCommandSocket::writeFileToSocket() | 1588 | void KCommandSocket::writeFileToSocket() |
1577 | { | 1589 | { |
1578 | mTimerSocket->stop(); | 1590 | mTimerSocket->stop(); |
1579 | QFile file2( mFileName ); | 1591 | QFile file2( mFileName ); |
1580 | if (!file2.open( IO_ReadOnly ) ) { | 1592 | if (!file2.open( IO_ReadOnly ) ) { |
1581 | mConnectProgress.hide(); | 1593 | mConnectProgress.hide(); |
1582 | mConnectCount = -1; | 1594 | mConnectCount = -1; |
1583 | mRetVal= errorW; | 1595 | mRetVal= errorW; |
1584 | mSocket->close(); | 1596 | mSocket->close(); |
1585 | if ( mSocket->state() == QSocket::Idle ) | 1597 | if ( mSocket->state() == QSocket::Idle ) |
1586 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1598 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1587 | return ; | 1599 | return ; |
1588 | } | 1600 | } |
1589 | mConnectProgress.setTotalSteps ( file2.size() ); | 1601 | mConnectProgress.setTotalSteps ( file2.size() ); |
1590 | mConnectProgress.show(); | 1602 | mConnectProgress.show(); |
1591 | int count = 0; | 1603 | int count = 0; |
1592 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); | 1604 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); |
1593 | mConnectProgress.setProgress( count ); | 1605 | mConnectProgress.setProgress( count ); |
1594 | mConnectProgress.blockSignals( true ); | 1606 | mConnectProgress.blockSignals( true ); |
1595 | QTextStream ts2( &file2 ); | 1607 | QTextStream ts2( &file2 ); |
1596 | ts2.setEncoding( QTextStream::Latin1 ); | 1608 | ts2.setEncoding( QTextStream::Latin1 ); |
1597 | QTextStream os2( mSocket ); | 1609 | QTextStream os2( mSocket ); |
1598 | os2.setEncoding( QTextStream::Latin1 ); | 1610 | os2.setEncoding( QTextStream::Latin1 ); |
1599 | os2 << "PUT " << mPassWord << "\r\n\r\n";; | 1611 | os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";; |
1600 | int byteCount = 0; | 1612 | int byteCount = 0; |
1601 | int byteMax = file2.size()/53; | 1613 | int byteMax = file2.size()/53; |
1602 | while ( ! ts2.atEnd() ) { | 1614 | while ( ! ts2.atEnd() ) { |
1603 | qApp->processEvents(); | 1615 | qApp->processEvents(); |
1604 | if ( byteCount > byteMax ) { | 1616 | if ( byteCount > byteMax ) { |
1605 | byteCount = 0; | 1617 | byteCount = 0; |
1606 | mConnectProgress.setProgress( count ); | 1618 | mConnectProgress.setProgress( count ); |
1607 | } | 1619 | } |
1608 | QString temp = ts2.readLine(); | 1620 | QString temp = ts2.readLine(); |
1609 | count += temp.length(); | 1621 | count += temp.length(); |
1610 | byteCount += temp.length(); | 1622 | byteCount += temp.length(); |
1611 | os2 << temp << "\r\n"; | 1623 | os2 << temp << "\r\n"; |
1612 | } | 1624 | } |
1613 | file2.close(); | 1625 | file2.close(); |
1614 | mConnectProgress.hide(); | 1626 | mConnectProgress.hide(); |
1615 | mConnectCount = -1; | 1627 | mConnectCount = -1; |
1616 | os2 << "\r\n"; | 1628 | os2 << "\r\n"; |
1617 | mRetVal= successW; | 1629 | mRetVal= successW; |
1618 | mSocket->close(); | 1630 | mSocket->close(); |
1619 | if ( mSocket->state() == QSocket::Idle ) | 1631 | if ( mSocket->state() == QSocket::Idle ) |
1620 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1632 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1621 | mConnectProgress.blockSignals( false ); | 1633 | mConnectProgress.blockSignals( false ); |
1622 | } | 1634 | } |
1623 | void KCommandSocket::sendStop() | 1635 | void KCommandSocket::sendStop() |
1624 | { | 1636 | { |
1625 | if ( !mSocket ) { | 1637 | if ( !mSocket ) { |
1626 | mSocket = new QSocket( this ); | 1638 | mSocket = new QSocket( this ); |
1627 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1639 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1628 | } | 1640 | } |
1629 | mSocket->connectToHost( mHost, mPort ); | 1641 | mSocket->connectToHost( mHost, mPort ); |
1630 | QTextStream os2( mSocket ); | 1642 | QTextStream os2( mSocket ); |
1631 | os2.setEncoding( QTextStream::Latin1 ); | 1643 | os2.setEncoding( QTextStream::Latin1 ); |
1632 | os2 << "STOP\r\n\r\n"; | 1644 | os2 << "STOP\r\n\r\n"; |
1633 | mSocket->close(); | 1645 | mSocket->close(); |
1634 | if ( mSocket->state() == QSocket::Idle ) | 1646 | if ( mSocket->state() == QSocket::Idle ) |
1635 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1647 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1636 | } | 1648 | } |
1637 | 1649 | ||
1638 | void KCommandSocket::startReadFileFromSocket() | 1650 | void KCommandSocket::startReadFileFromSocket() |
1639 | { | 1651 | { |
1640 | if ( ! mFirst ) | 1652 | if ( ! mFirst ) |
1641 | return; | 1653 | return; |
1642 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); | 1654 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); |
1643 | mFirst = false; | 1655 | mFirst = false; |
1644 | mFileString = ""; | 1656 | mFileString = ""; |
1645 | mTime.start(); | 1657 | mTime.start(); |
1646 | mFirstLine = true; | 1658 | mFirstLine = true; |
1647 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1659 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1648 | 1660 | ||
1649 | } | 1661 | } |
1650 | void KCommandSocket::readFileFromSocket() | 1662 | void KCommandSocket::readFileFromSocket() |
1651 | { | 1663 | { |
1652 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1664 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1653 | while ( mSocket->canReadLine () ) { | 1665 | while ( mSocket->canReadLine () ) { |
1654 | mTime.restart(); | 1666 | mTime.restart(); |
1655 | QString line = mSocket->readLine (); | 1667 | QString line = mSocket->readLine (); |
1656 | if ( mFirstLine ) { | 1668 | if ( mFirstLine ) { |
1657 | mFirstLine = false; | 1669 | mFirstLine = false; |
1658 | if ( line.left( 6 ) == "ERROR_" ) { | 1670 | if ( line.left( 6 ) == "ERROR_" ) { |
1659 | mTimerSocket->stop(); | 1671 | mTimerSocket->stop(); |
1660 | mConnectCount = -1; | 1672 | mConnectCount = -1; |
1661 | if ( line.left( 8 ) == "ERROR_PW" ) { | 1673 | if ( line.left( 8 ) == "ERROR_PW" ) { |
1662 | mRetVal = errorPW; | 1674 | mRetVal = errorPW; |
1663 | deleteSocket(); | 1675 | deleteSocket(); |
1664 | return ; | 1676 | return ; |
1665 | } | 1677 | } |
1666 | if ( line.left( 8 ) == "ERROR_CA" ) { | 1678 | if ( line.left( 8 ) == "ERROR_CA" ) { |
1667 | mRetVal = errorCA; | 1679 | mRetVal = errorCA; |
1668 | deleteSocket(); | 1680 | deleteSocket(); |
1669 | return ; | 1681 | return ; |
1670 | } | 1682 | } |
1671 | if ( line.left( 8 ) == "ERROR_FI" ) { | 1683 | if ( line.left( 8 ) == "ERROR_FI" ) { |
1672 | mRetVal = errorFI; | 1684 | mRetVal = errorFI; |
1673 | deleteSocket(); | 1685 | deleteSocket(); |
1674 | return ; | 1686 | return ; |
1675 | } | 1687 | } |
1676 | if ( line.left( 8 ) == "ERROR_ED" ) { | 1688 | if ( line.left( 8 ) == "ERROR_ED" ) { |
1677 | mRetVal = errorED; | 1689 | mRetVal = errorED; |
1678 | deleteSocket(); | 1690 | deleteSocket(); |
1679 | return ; | 1691 | return ; |
1680 | } | 1692 | } |
1681 | mRetVal = errorUN; | 1693 | mRetVal = errorUN; |
1682 | deleteSocket(); | 1694 | deleteSocket(); |
1683 | return ; | 1695 | return ; |
1684 | } | 1696 | } |
1685 | } | 1697 | } |
1686 | mFileString += line; | 1698 | mFileString += line; |
1687 | //qDebug("readline: %s ", line.latin1()); | 1699 | //qDebug("readline: %s ", line.latin1()); |
1688 | } | 1700 | } |
1689 | if ( mTime.elapsed () < 3000 ) { | 1701 | if ( mTime.elapsed () < 3000 ) { |
1690 | // wait for more | 1702 | // wait for more |
1691 | //qDebug("waitformore "); | 1703 | //qDebug("waitformore "); |
1692 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1704 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1693 | return; | 1705 | return; |
1694 | } | 1706 | } |
1695 | mTimerSocket->stop(); | 1707 | mTimerSocket->stop(); |
1696 | mConnectCount = -1; | 1708 | mConnectCount = -1; |
1697 | mConnectProgress.hide(); | 1709 | mConnectProgress.hide(); |
1698 | QString fileName = mFileName; | 1710 | QString fileName = mFileName; |
1699 | QFile file ( fileName ); | 1711 | QFile file ( fileName ); |
1700 | if (!file.open( IO_WriteOnly ) ) { | 1712 | if (!file.open( IO_WriteOnly ) ) { |
1701 | mFileString = ""; | 1713 | mFileString = ""; |
1702 | mRetVal = errorR; | 1714 | mRetVal = errorR; |
1703 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1715 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1704 | deleteSocket(); | 1716 | deleteSocket(); |
1705 | return ; | 1717 | return ; |
1706 | 1718 | ||
1707 | } | 1719 | } |
1708 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1720 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1709 | QTextStream ts ( &file ); | 1721 | QTextStream ts ( &file ); |
1710 | ts.setEncoding( QTextStream::Latin1 ); | 1722 | ts.setEncoding( QTextStream::Latin1 ); |
1711 | ts << mFileString; | 1723 | ts << mFileString; |
1712 | file.close(); | 1724 | file.close(); |
1713 | mFileString = ""; | 1725 | mFileString = ""; |
1714 | mRetVal = successR; | 1726 | mRetVal = successR; |
1715 | mSocket->close(); | 1727 | mSocket->close(); |
1716 | // if state is not idle, deleteSocket(); is called via | 1728 | // if state is not idle, deleteSocket(); is called via |
1717 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1729 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1718 | if ( mSocket->state() == QSocket::Idle ) | 1730 | if ( mSocket->state() == QSocket::Idle ) |
1719 | deleteSocket(); | 1731 | deleteSocket(); |
1720 | } | 1732 | } |
1721 | 1733 | ||
1722 | void KCommandSocket::deleteSocket() | 1734 | void KCommandSocket::deleteSocket() |
1723 | { | 1735 | { |
1724 | //qDebug("KCommandSocket::deleteSocket() "); | 1736 | //qDebug("KCommandSocket::deleteSocket() "); |
1725 | mConnectProgress.hide(); | 1737 | mConnectProgress.hide(); |
1726 | 1738 | ||
1727 | if ( mConnectCount >= 0 ) { | 1739 | if ( mConnectCount >= 0 ) { |
1728 | mTimerSocket->stop(); | 1740 | mTimerSocket->stop(); |
1729 | mRetVal = errorTO; | 1741 | mRetVal = errorTO; |
1730 | qDebug("KCS::Connection to remote host timed out"); | 1742 | qDebug("KCS::Connection to remote host timed out"); |
1731 | if ( mSocket ) { | 1743 | if ( mSocket ) { |
1732 | mSocket->close(); | 1744 | mSocket->close(); |
1733 | //if ( mSocket->state() == QSocket::Idle ) | 1745 | //if ( mSocket->state() == QSocket::Idle ) |
1734 | // deleteSocket(); | 1746 | // deleteSocket(); |
1735 | delete mSocket; | 1747 | delete mSocket; |
1736 | mSocket = 0; | 1748 | mSocket = 0; |
1737 | } | 1749 | } |
1738 | if ( mConnectCount == 0 ) | 1750 | if ( mConnectCount == 0 ) |
1739 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); | 1751 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); |
1740 | else if ( tlw ) | 1752 | else if ( tlw ) |
1741 | tlw->setCaption( i18n("Connection to remote host cancelled!") ); | 1753 | tlw->setCaption( i18n("Connection to remote host cancelled!") ); |
1742 | emit commandFinished( this, mRetVal ); | 1754 | emit commandFinished( this, mRetVal ); |
1743 | return; | 1755 | return; |
1744 | } | 1756 | } |
1745 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1757 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1746 | if ( mSocket) | 1758 | if ( mSocket) |
1747 | delete mSocket; | 1759 | delete mSocket; |
1748 | mSocket = 0; | 1760 | mSocket = 0; |
1749 | qDebug("commandFinished "); | 1761 | qDebug("commandFinished "); |
1750 | emit commandFinished( this, mRetVal ); | 1762 | emit commandFinished( this, mRetVal ); |
1751 | } | 1763 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index f4654ce..53c611d 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,241 +1,247 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qprogressdialog.h> | 32 | #include <qprogressdialog.h> |
33 | #include <kdialog.h> | 33 | #include <kdialog.h> |
34 | 34 | ||
35 | class QPopupMenu; | 35 | class QPopupMenu; |
36 | class KSyncProfile; | 36 | class KSyncProfile; |
37 | class KPimPrefs; | 37 | class KPimPrefs; |
38 | class QWidget; | 38 | class QWidget; |
39 | class KSyncManager; | 39 | class KSyncManager; |
40 | class KSyncInterface; | 40 | class KSyncInterface; |
41 | class QProgressBar; | 41 | class QProgressBar; |
42 | 42 | ||
43 | 43 | ||
44 | class KServerSocket : public QServerSocket | 44 | class KServerSocket : public QServerSocket |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | 47 | ||
48 | public: | 48 | public: |
49 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 49 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
50 | 50 | ||
51 | void newConnection ( int socket ) ; | 51 | void newConnection ( int socket ) ; |
52 | void setFileName( QString fn ) {mFileName = fn;}; | 52 | void setFileName( QString fn ) {mFileName = fn;}; |
53 | signals: | 53 | signals: |
54 | void file_received( bool ); | 54 | void file_received( bool ); |
55 | void request_file(); | 55 | void request_file(); |
56 | void file_received( bool, const QString &); | ||
57 | void request_file(const QString &); | ||
56 | void saveFile(); | 58 | void saveFile(); |
57 | void endConnect(); | 59 | void endConnect(); |
58 | private slots: | 60 | private slots: |
59 | void discardClient(); | 61 | void discardClient(); |
60 | void deleteSocket(); | 62 | void deleteSocket(); |
61 | void readClient(); | 63 | void readClient(); |
62 | void displayErrorMessage(); | 64 | void displayErrorMessage(); |
63 | void readBackFileFromSocket(); | 65 | void readBackFileFromSocket(); |
64 | private : | 66 | private : |
67 | QString mResource; | ||
65 | int mErrorMessage; | 68 | int mErrorMessage; |
66 | bool blockRC; | 69 | bool blockRC; |
67 | void send_file(); | 70 | void send_file(); |
68 | void get_file(); | 71 | void get_file(); |
69 | void end_connect(); | 72 | void end_connect(); |
70 | void error_connect( QString ); | 73 | void error_connect( QString ); |
71 | QDialog* mSyncActionDialog; | 74 | QDialog* mSyncActionDialog; |
72 | QSocket* mSocket; | 75 | QSocket* mSocket; |
73 | QString mPassWord; | 76 | QString mPassWord; |
74 | QString mFileName; | 77 | QString mFileName; |
75 | QTime piTime; | 78 | QTime piTime; |
76 | QString piFileString; | 79 | QString piFileString; |
77 | }; | 80 | }; |
78 | 81 | ||
79 | class KCommandSocket : public QObject | 82 | class KCommandSocket : public QObject |
80 | { | 83 | { |
81 | Q_OBJECT | 84 | Q_OBJECT |
82 | public: | 85 | public: |
83 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; | 86 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; |
84 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); | 87 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); |
85 | void readFile( QString ); | 88 | void readFile( QString ); |
86 | void writeFile( QString ); | 89 | void writeFile( QString ); |
87 | void sendStop(); | 90 | void sendStop(); |
88 | 91 | ||
89 | private slots : | 92 | private slots : |
90 | void sendFileRequest(); | 93 | void sendFileRequest(); |
91 | void updateConnectDialog(); | 94 | void updateConnectDialog(); |
92 | 95 | ||
93 | signals: | 96 | signals: |
94 | void commandFinished( KCommandSocket*, int ); | 97 | void commandFinished( KCommandSocket*, int ); |
95 | private slots: | 98 | private slots: |
96 | void startReadFileFromSocket(); | 99 | void startReadFileFromSocket(); |
97 | void readFileFromSocket(); | 100 | void readFileFromSocket(); |
98 | void deleteSocket(); | 101 | void deleteSocket(); |
99 | void writeFileToSocket(); | 102 | void writeFileToSocket(); |
100 | private : | 103 | private : |
101 | QString mRemoteResource; | 104 | QString mRemoteResource; |
102 | int mConnectCount; | 105 | int mConnectCount; |
103 | int mConnectMax; | 106 | int mConnectMax; |
104 | KProgressDialog mConnectProgress; | 107 | KProgressDialog mConnectProgress; |
105 | QWidget* tlw; | 108 | QWidget* tlw; |
106 | QSocket* mSocket; | 109 | QSocket* mSocket; |
107 | QString mPassWord; | 110 | QString mPassWord; |
108 | Q_UINT16 mPort; | 111 | Q_UINT16 mPort; |
109 | QString mHost; | 112 | QString mHost; |
110 | QString mFileName; | 113 | QString mFileName; |
111 | QTimer* mTimerSocket; | 114 | QTimer* mTimerSocket; |
112 | int mRetVal; | 115 | int mRetVal; |
113 | QTime mTime; | 116 | QTime mTime; |
114 | QString mFileString; | 117 | QString mFileString; |
115 | bool mFirst; | 118 | bool mFirst; |
116 | bool mFirstLine; | 119 | bool mFirstLine; |
117 | }; | 120 | }; |
118 | 121 | ||
119 | 122 | ||
120 | class KSyncManager : public QObject | 123 | class KSyncManager : public QObject |
121 | { | 124 | { |
122 | Q_OBJECT | 125 | Q_OBJECT |
123 | 126 | ||
124 | public: | 127 | public: |
125 | enum TargetApp { | 128 | enum TargetApp { |
126 | KOPI = 0, | 129 | KOPI = 0, |
127 | KAPI = 1, | 130 | KAPI = 1, |
128 | PWMPI = 2 }; | 131 | PWMPI = 2 }; |
129 | 132 | ||
130 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 133 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
131 | ~KSyncManager() ; | 134 | ~KSyncManager() ; |
132 | 135 | ||
133 | void multiSync( bool askforPrefs ); | 136 | void multiSync( bool askforPrefs ); |
134 | bool blockSave() { return mBlockSaveFlag; } | 137 | bool blockSave() { return mBlockSaveFlag; } |
135 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 138 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
136 | void setDefaultFileName( QString s) ; | 139 | void setDefaultFileName( QString s) ; |
137 | QString defaultFileName() { return mDefFileName ;} | 140 | QString defaultFileName() { return mDefFileName ;} |
138 | QString syncFileName(); | 141 | QString syncFileName(); |
139 | void enableQuick( bool ask = true); | 142 | void enableQuick( bool ask = true); |
140 | 143 | ||
141 | bool syncWithDesktop () { return mSyncWithDesktop;} | 144 | bool syncWithDesktop () { return mSyncWithDesktop;} |
142 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 145 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
143 | QString getCurrentSyncName() { return mCurrentSyncName; } | 146 | QString getCurrentSyncName() { return mCurrentSyncName; } |
144 | 147 | ||
145 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 148 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
146 | void hideProgressBar(); | 149 | void hideProgressBar(); |
147 | bool isProgressBarCanceled(); | 150 | bool isProgressBarCanceled(); |
148 | 151 | ||
149 | // sync stuff | 152 | // sync stuff |
150 | QString mLocalMachineName; | 153 | QString mLocalMachineName; |
151 | QStringList mExternSyncProfiles; | 154 | QStringList mExternSyncProfiles; |
152 | QStringList mSyncProfileNames; | 155 | QStringList mSyncProfileNames; |
153 | bool mAskForPreferences; | 156 | bool mAskForPreferences; |
154 | bool mShowSyncSummary; | 157 | bool mShowSyncSummary; |
155 | bool mIsKapiFile; | 158 | bool mIsKapiFile; |
156 | bool mWriteBackExistingOnly; | 159 | bool mWriteBackExistingOnly; |
157 | int mSyncAlgoPrefs; | 160 | int mSyncAlgoPrefs; |
158 | bool mWriteBackFile; | 161 | bool mWriteBackFile; |
159 | int mWriteBackInFuture; | 162 | int mWriteBackInFuture; |
160 | int mWriteBackInPast; | 163 | int mWriteBackInPast; |
161 | QString mPhoneDevice; | 164 | QString mPhoneDevice; |
162 | QString mPhoneConnection; | 165 | QString mPhoneConnection; |
163 | QString mPhoneModel; | 166 | QString mPhoneModel; |
164 | QString mPassWordPiSync; | 167 | QString mPassWordPiSync; |
165 | QString mActiveSyncPort; | 168 | QString mActiveSyncPort; |
166 | QString mActiveSyncIP ; | 169 | QString mActiveSyncIP ; |
167 | QString mFilterInCal; | 170 | QString mFilterInCal; |
168 | QString mFilterOutCal; | 171 | QString mFilterOutCal; |
169 | QString mFilterInAB; | 172 | QString mFilterInAB; |
170 | QString mFilterOutAB; | 173 | QString mFilterOutAB; |
171 | static QDateTime mRequestedSyncEvent; | 174 | static QDateTime mRequestedSyncEvent; |
172 | 175 | ||
173 | signals: | 176 | signals: |
174 | void save(); | 177 | void save(); |
175 | void request_file(); | 178 | void request_file(); |
176 | void getFile( bool ); | 179 | void getFile( bool ); |
180 | void getFile( bool, const QString &); | ||
181 | void request_file(const QString &); | ||
182 | void multiResourceSyncStart( bool ); | ||
177 | 183 | ||
178 | public slots: | 184 | public slots: |
179 | void slotSyncMenu( int ); | 185 | void slotSyncMenu( int ); |
180 | void slotClearMenu( int action ); | 186 | void slotClearMenu( int action ); |
181 | void deleteCommandSocket(KCommandSocket*s, int state); | 187 | void deleteCommandSocket(KCommandSocket*s, int state); |
182 | void readFileFromSocket(); | 188 | void readFileFromSocket(); |
183 | void fillSyncMenu(); | 189 | void fillSyncMenu(); |
184 | 190 | ||
185 | private: | 191 | private: |
186 | void syncPi(); | 192 | void syncPi(); |
187 | KServerSocket * mServerSocket; | 193 | KServerSocket * mServerSocket; |
188 | KPimPrefs* mPrefs; | 194 | KPimPrefs* mPrefs; |
189 | QString mDefFileName; | 195 | QString mDefFileName; |
190 | QString mCurrentSyncDevice; | 196 | QString mCurrentSyncDevice; |
191 | QString mCurrentSyncName; | 197 | QString mCurrentSyncName; |
192 | void quickSyncLocalFile(); | 198 | void quickSyncLocalFile(); |
193 | bool syncWithFile( QString fn , bool quick ); | 199 | bool syncWithFile( QString fn , bool quick ); |
194 | void syncLocalFile(); | 200 | void syncLocalFile(); |
195 | void syncPhone(); | 201 | void syncPhone(); |
196 | void syncSharp(); | 202 | void syncSharp(); |
197 | void syncKDE(); | 203 | void syncKDE(); |
198 | bool syncExternalApplication(QString); | 204 | bool syncExternalApplication(QString); |
199 | int mCurrentSyncProfile ; | 205 | int mCurrentSyncProfile ; |
200 | void syncRemote( KSyncProfile* prof, bool ask = true); | 206 | void syncRemote( KSyncProfile* prof, bool ask = true); |
201 | bool edit_sync_options(); | 207 | bool edit_sync_options(); |
202 | bool edit_pisync_options(); | 208 | bool edit_pisync_options(); |
203 | int ringSync(); | 209 | int ringSync(); |
204 | QString getPassword( ); | 210 | QString getPassword( ); |
205 | bool mPisyncFinished; | 211 | bool mPisyncFinished; |
206 | QStringList mSpecificResources; | 212 | QStringList mSpecificResources; |
207 | QString mCurrentResourceLocal; | 213 | QString mCurrentResourceLocal; |
208 | QString mCurrentResourceRemote; | 214 | QString mCurrentResourceRemote; |
209 | bool mBlockSaveFlag; | 215 | bool mBlockSaveFlag; |
210 | QWidget* mParent; | 216 | QWidget* mParent; |
211 | KSyncInterface* mImplementation; | 217 | KSyncInterface* mImplementation; |
212 | TargetApp mTargetApp; | 218 | TargetApp mTargetApp; |
213 | QPopupMenu* mSyncMenu; | 219 | QPopupMenu* mSyncMenu; |
214 | QProgressBar* bar; | 220 | QProgressBar* bar; |
215 | bool mSyncWithDesktop; | 221 | bool mSyncWithDesktop; |
216 | 222 | ||
217 | private slots: | 223 | private slots: |
218 | void displayErrorPort(); | 224 | void displayErrorPort(); |
219 | void confSync(); | 225 | void confSync(); |
220 | 226 | ||
221 | 227 | ||
222 | }; | 228 | }; |
223 | 229 | ||
224 | 230 | ||
225 | class KSyncInterface | 231 | class KSyncInterface |
226 | { | 232 | { |
227 | public : | 233 | public : |
228 | virtual void removeSyncInfo( QString syncProfile) = 0; | 234 | virtual void removeSyncInfo( QString syncProfile) = 0; |
229 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; | 235 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; |
230 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 236 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
231 | { | 237 | { |
232 | // empty implementation, because some syncable applications do not | 238 | // empty implementation, because some syncable applications do not |
233 | // have an external(sharpdtm) syncmode, like pwmanager. | 239 | // have an external(sharpdtm) syncmode, like pwmanager. |
234 | return false; | 240 | return false; |
235 | } | 241 | } |
236 | 242 | ||
237 | 243 | ||
238 | }; | 244 | }; |
239 | 245 | ||
240 | 246 | ||
241 | #endif | 247 | #endif |