author | zautrix <zautrix> | 2005-11-25 17:41:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 17:41:25 (UTC) |
commit | 279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (unidiff) | |
tree | 43ab776cd108874819e7c6e73070a7d989a9078f | |
parent | 794a5204686ad9bfc16172b01db35f1f3b7683e5 (diff) | |
download | kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.zip kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.gz kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.bz2 |
sync
-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,5189 +1,5244 @@ | |||
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 "); |
753 | flag_blockConflict = false; | 754 | flag_blockConflict = false; |
754 | return; | 755 | return; |
755 | } | 756 | } |
756 | 757 | ||
757 | void CalendarView::conflictAll() | 758 | void CalendarView::conflictAll() |
758 | { | 759 | { |
759 | nextConflict ( true, true ); | 760 | nextConflict ( true, true ); |
760 | } | 761 | } |
761 | void CalendarView::conflictAllday() | 762 | void CalendarView::conflictAllday() |
762 | { | 763 | { |
763 | nextConflict ( false, true ); | 764 | nextConflict ( false, true ); |
764 | } | 765 | } |
765 | void CalendarView::conflictNotAll() | 766 | void CalendarView::conflictNotAll() |
766 | { | 767 | { |
767 | nextConflict ( false, false ); | 768 | nextConflict ( false, false ); |
768 | } | 769 | } |
769 | 770 | ||
770 | void CalendarView::setCalReadOnly( int id, bool readO ) | 771 | void CalendarView::setCalReadOnly( int id, bool readO ) |
771 | { | 772 | { |
772 | if ( readO ) { | 773 | if ( readO ) { |
773 | emit save(); | 774 | emit save(); |
774 | } | 775 | } |
775 | mCalendar->setReadOnly( id, readO ); | 776 | mCalendar->setReadOnly( id, readO ); |
776 | } | 777 | } |
777 | void CalendarView::setScrollBarStep(int val ) | 778 | void CalendarView::setScrollBarStep(int val ) |
778 | { | 779 | { |
779 | #ifdef DESKTOP_VERSION | 780 | #ifdef DESKTOP_VERSION |
780 | mDateScrollBar->setLineStep ( val ); | 781 | mDateScrollBar->setLineStep ( val ); |
781 | #endif | 782 | #endif |
782 | } | 783 | } |
783 | void CalendarView::scrollBarValue(int val ) | 784 | void CalendarView::scrollBarValue(int val ) |
784 | { | 785 | { |
785 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
786 | if ( QApplication::desktop()->width() < 800 ) return; | 787 | if ( QApplication::desktop()->width() < 800 ) return; |
787 | if ( flag_blockScrollBar ) return; | 788 | if ( flag_blockScrollBar ) return; |
788 | flag_blockScrollBar = true; | 789 | flag_blockScrollBar = true; |
789 | int count = mNavigator->selectedDates().count(); | 790 | int count = mNavigator->selectedDates().count(); |
790 | int day = mNavigator->selectedDates().first().dayOfYear(); | 791 | int day = mNavigator->selectedDates().first().dayOfYear(); |
791 | int stepdays = val; | 792 | int stepdays = val; |
792 | if ( mDateScrollBar->lineStep () <= count ) { | 793 | if ( mDateScrollBar->lineStep () <= count ) { |
793 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 794 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
794 | //qDebug("VAL %d ",val ); | 795 | //qDebug("VAL %d ",val ); |
795 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 796 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
796 | stepdays = day+stepdays; | 797 | stepdays = day+stepdays; |
797 | if ( stepdays < 0 ) stepdays = 0; | 798 | if ( stepdays < 0 ) stepdays = 0; |
798 | } | 799 | } |
799 | if ( stepdays == day ) { | 800 | if ( stepdays == day ) { |
800 | flag_blockScrollBar = false; | 801 | flag_blockScrollBar = false; |
801 | return; | 802 | return; |
802 | } | 803 | } |
803 | int year = mNavigator->selectedDates().first().year(); | 804 | int year = mNavigator->selectedDates().first().year(); |
804 | QDate d ( year,1,1 ); | 805 | QDate d ( year,1,1 ); |
805 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 806 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
806 | flag_blockScrollBar = false; | 807 | flag_blockScrollBar = false; |
807 | #endif | 808 | #endif |
808 | 809 | ||
809 | } | 810 | } |
810 | void CalendarView::updateView(const QDate &start, const QDate &end) | 811 | void CalendarView::updateView(const QDate &start, const QDate &end) |
811 | { | 812 | { |
812 | #ifdef DESKTOP_VERSION | 813 | #ifdef DESKTOP_VERSION |
813 | if ( ! mDateScrollBar->draggingSlider () ) { | 814 | if ( ! mDateScrollBar->draggingSlider () ) { |
814 | int dof = start.dayOfYear(); | 815 | int dof = start.dayOfYear(); |
815 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 816 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
816 | if ( dof != mDateScrollBar->value() ) { | 817 | if ( dof != mDateScrollBar->value() ) { |
817 | mDateScrollBar->blockSignals( true ); | 818 | mDateScrollBar->blockSignals( true ); |
818 | mDateScrollBar->setValue( start.dayOfYear()); | 819 | mDateScrollBar->setValue( start.dayOfYear()); |
819 | mDateScrollBar->blockSignals( false ); | 820 | mDateScrollBar->blockSignals( false ); |
820 | } | 821 | } |
821 | } | 822 | } |
822 | #endif | 823 | #endif |
823 | mTodoList->updateView(); | 824 | mTodoList->updateView(); |
824 | mViewManager->updateView(start, end); | 825 | mViewManager->updateView(start, end); |
825 | //mDateNavigator->updateView(); | 826 | //mDateNavigator->updateView(); |
826 | } | 827 | } |
827 | 828 | ||
828 | 829 | ||
829 | 830 | ||
830 | void CalendarView::checkFiles() | 831 | void CalendarView::checkFiles() |
831 | { | 832 | { |
832 | QString message; | 833 | QString message; |
833 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 834 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
834 | KopiCalendarFile * cal = calendars.first(); | 835 | KopiCalendarFile * cal = calendars.first(); |
835 | while ( cal ) { | 836 | while ( cal ) { |
836 | if ( cal->mErrorOnLoad ) { | 837 | if ( cal->mErrorOnLoad ) { |
837 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 838 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
838 | } | 839 | } |
839 | cal = calendars.next(); | 840 | cal = calendars.next(); |
840 | } | 841 | } |
841 | if ( !message.isEmpty() ) { | 842 | if ( !message.isEmpty() ) { |
842 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 843 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
843 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); | 844 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
844 | } | 845 | } |
845 | if ( flag_checkFileFirsttime ) { | 846 | if ( flag_checkFileFirsttime ) { |
846 | flag_checkFileFirsttime = false; | 847 | flag_checkFileFirsttime = false; |
847 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 848 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
848 | } | 849 | } |
849 | } | 850 | } |
850 | void CalendarView::checkAlarms() | 851 | void CalendarView::checkAlarms() |
851 | { | 852 | { |
852 | KConfig *config = KOGlobals::config(); | 853 | KConfig *config = KOGlobals::config(); |
853 | config->setGroup( "AppRun" ); | 854 | config->setGroup( "AppRun" ); |
854 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 855 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
855 | int daysto = dt.daysTo( QDate::currentDate() ); | 856 | int daysto = dt.daysTo( QDate::currentDate() ); |
856 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 857 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
857 | dt = dt.addDays( days ); | 858 | dt = dt.addDays( days ); |
858 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 859 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
859 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 860 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
860 | //qDebug("KO: Reading program stop %d ", secs); | 861 | //qDebug("KO: Reading program stop %d ", secs); |
861 | //secs -= ( 3600 * 24*3 ); // debug only | 862 | //secs -= ( 3600 * 24*3 ); // debug only |
862 | QDateTime latest = dt.addSecs ( secs ); | 863 | QDateTime latest = dt.addSecs ( secs ); |
863 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 864 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
864 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 865 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
865 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 866 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
866 | QPtrList<Incidence> al; | 867 | QPtrList<Incidence> al; |
867 | Incidence* inL = el.first(); | 868 | Incidence* inL = el.first(); |
868 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 869 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
869 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 870 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
870 | while ( inL ) { | 871 | while ( inL ) { |
871 | bool ok = false; | 872 | bool ok = false; |
872 | int offset = 0; | 873 | int offset = 0; |
873 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 874 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
874 | if ( ok ) { | 875 | if ( ok ) { |
875 | //qDebug("OK %s",next.toString().latin1()); | 876 | //qDebug("OK %s",next.toString().latin1()); |
876 | if ( next < cur ) { | 877 | if ( next < cur ) { |
877 | al.append( inL ); | 878 | al.append( inL ); |
878 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 879 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
879 | } | 880 | } |
880 | } | 881 | } |
881 | inL = el.next(); | 882 | inL = el.next(); |
882 | } | 883 | } |
883 | if ( al.count() ) { | 884 | if ( al.count() ) { |
884 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 885 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
885 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 886 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
886 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 887 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
887 | lay->setSpacing( 0 ); | 888 | lay->setSpacing( 0 ); |
888 | lay->setMargin( 0 ); | 889 | lay->setMargin( 0 ); |
889 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 890 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
890 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 891 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
891 | lay->addWidget( matb ); | 892 | lay->addWidget( matb ); |
892 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 893 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
893 | int wid = 210; | 894 | int wid = 210; |
894 | int x = QApplication::desktop()->width() - wid - 7; | 895 | int x = QApplication::desktop()->width() - wid - 7; |
895 | int y = QApplication::desktop()->height() - wid - 70; | 896 | int y = QApplication::desktop()->height() - wid - 70; |
896 | dia->setGeometry ( x,y,wid,wid); | 897 | dia->setGeometry ( x,y,wid,wid); |
897 | } else { | 898 | } else { |
898 | int si = 220; | 899 | int si = 220; |
899 | if ( QApplication::desktop()->width() > 470 ) | 900 | if ( QApplication::desktop()->width() > 470 ) |
900 | si = 400; | 901 | si = 400; |
901 | dia->resize(si,si/2); | 902 | dia->resize(si,si/2); |
902 | } | 903 | } |
903 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 904 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
904 | dia->show(); | 905 | dia->show(); |
905 | 906 | ||
906 | } | 907 | } |
907 | #if 0 | 908 | #if 0 |
908 | // for creating timetracker test data | 909 | // for creating timetracker test data |
909 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 910 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
910 | Todo * nt; | 911 | Todo * nt; |
911 | mCalendar->close(); | 912 | mCalendar->close(); |
912 | { | 913 | { |
913 | Todo * root1 = new Todo; | 914 | Todo * root1 = new Todo; |
914 | mCalendar->addTodo( root1 ); | 915 | mCalendar->addTodo( root1 ); |
915 | root1->setSummary( "Project1"); | 916 | root1->setSummary( "Project1"); |
916 | root1->setPriority( 1 ); | 917 | root1->setPriority( 1 ); |
917 | root1->setCategories( QString( "Cat_Pro1") ); | 918 | root1->setCategories( QString( "Cat_Pro1") ); |
918 | root1->setDescription( "This is a test description of a root Project" ); | 919 | root1->setDescription( "This is a test description of a root Project" ); |
919 | root1->setPercentComplete( 20 ); | 920 | root1->setPercentComplete( 20 ); |
920 | updateView(); | 921 | updateView(); |
921 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 922 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
922 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 923 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
923 | 924 | ||
924 | nt = new Todo; | 925 | nt = new Todo; |
925 | mCalendar->addTodo( nt ); | 926 | mCalendar->addTodo( nt ); |
926 | nt->setSummary( "Planning Project1"); | 927 | nt->setSummary( "Planning Project1"); |
927 | nt->setPriority( 1 ); | 928 | nt->setPriority( 1 ); |
928 | nt->setDescription( "This is a test description of Planning Project1" ); | 929 | nt->setDescription( "This is a test description of Planning Project1" ); |
929 | nt->setPercentComplete( 20 ); | 930 | nt->setPercentComplete( 20 ); |
930 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); | 931 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); |
931 | 932 | ||
932 | 933 | ||
933 | Todo * sub1 = nt; | 934 | Todo * sub1 = nt; |
934 | sub1->setRelatedTo( root1 ); | 935 | sub1->setRelatedTo( root1 ); |
935 | 936 | ||
936 | nt = new Todo; | 937 | nt = new Todo; |
937 | mCalendar->addTodo( nt ); | 938 | mCalendar->addTodo( nt ); |
938 | nt->setSummary( "Planning Project1: Lutz"); | 939 | nt->setSummary( "Planning Project1: Lutz"); |
939 | nt->setPriority( 1 ); | 940 | nt->setPriority( 1 ); |
940 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 941 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
941 | nt->setPercentComplete( 20 ); | 942 | nt->setPercentComplete( 20 ); |
942 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); | 943 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); |
943 | Todo * workLutz11 = nt; | 944 | Todo * workLutz11 = nt; |
944 | workLutz11->setRelatedTo( sub1 ); | 945 | workLutz11->setRelatedTo( sub1 ); |
945 | 946 | ||
946 | nt = new Todo; | 947 | nt = new Todo; |
947 | mCalendar->addTodo( nt ); | 948 | mCalendar->addTodo( nt ); |
948 | nt->setSummary( "Planning Project1: Norbert"); | 949 | nt->setSummary( "Planning Project1: Norbert"); |
949 | nt->setPriority( 1 ); | 950 | nt->setPriority( 1 ); |
950 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 951 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
951 | nt->setPercentComplete( 20 ); | 952 | nt->setPercentComplete( 20 ); |
952 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); | 953 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); |
953 | Todo * workNorbert11 = nt; | 954 | Todo * workNorbert11 = nt; |
954 | workNorbert11->setRelatedTo( sub1 ); | 955 | workNorbert11->setRelatedTo( sub1 ); |
955 | 956 | ||
956 | nt = new Todo; | 957 | nt = new Todo; |
957 | mCalendar->addTodo( nt ); | 958 | mCalendar->addTodo( nt ); |
958 | nt->setSummary( "Work on 1"); | 959 | nt->setSummary( "Work on 1"); |
959 | nt->setPriority( 1 ); | 960 | nt->setPriority( 1 ); |
960 | nt->setDescription( "This is a test description of Work Project_1" ); | 961 | nt->setDescription( "This is a test description of Work Project_1" ); |
961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 962 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
962 | nt->setPercentComplete( 20 ); | 963 | nt->setPercentComplete( 20 ); |
963 | 964 | ||
964 | Todo * sub2 = nt; | 965 | Todo * sub2 = nt; |
965 | sub2->setRelatedTo( root1 ); | 966 | sub2->setRelatedTo( root1 ); |
966 | 967 | ||
967 | 968 | ||
968 | nt = new Todo; | 969 | nt = new Todo; |
969 | mCalendar->addTodo( nt ); | 970 | mCalendar->addTodo( nt ); |
970 | nt->setSummary( "Work on 1: Lutz"); | 971 | nt->setSummary( "Work on 1: Lutz"); |
971 | nt->setPriority( 1 ); | 972 | nt->setPriority( 1 ); |
972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 973 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 974 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
974 | nt->setPercentComplete( 20 ); | 975 | nt->setPercentComplete( 20 ); |
975 | Todo * workLutz12 = nt; | 976 | Todo * workLutz12 = nt; |
976 | workLutz12->setRelatedTo( sub2 ); | 977 | workLutz12->setRelatedTo( sub2 ); |
977 | 978 | ||
978 | nt = new Todo; | 979 | nt = new Todo; |
979 | mCalendar->addTodo( nt ); | 980 | mCalendar->addTodo( nt ); |
980 | nt->setSummary( "Work on 1: Norbert"); | 981 | nt->setSummary( "Work on 1: Norbert"); |
981 | nt->setPriority( 1 ); | 982 | nt->setPriority( 1 ); |
982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 983 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 984 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
984 | nt->setPercentComplete( 20 ); | 985 | nt->setPercentComplete( 20 ); |
985 | Todo * workNorbert12 = nt; | 986 | Todo * workNorbert12 = nt; |
986 | workNorbert12->setRelatedTo( sub2 ); | 987 | workNorbert12->setRelatedTo( sub2 ); |
987 | 988 | ||
988 | int secLenRunning = 7200; | 989 | int secLenRunning = 7200; |
989 | int secLenPausing = 3600 * 3; | 990 | int secLenPausing = 3600 * 3; |
990 | int dayInterval = 1; | 991 | int dayInterval = 1; |
991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 992 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 993 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 994 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 995 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 996 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 997 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 998 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 999 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
999 | 1000 | ||
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | { | 1003 | { |
1003 | Todo * root1 = new Todo; | 1004 | Todo * root1 = new Todo; |
1004 | mCalendar->addTodo( root1 ); | 1005 | mCalendar->addTodo( root1 ); |
1005 | root1->setSummary( "Project2"); | 1006 | root1->setSummary( "Project2"); |
1006 | root1->setPriority( 1 ); | 1007 | root1->setPriority( 1 ); |
1007 | root1->setDescription( "This is a test description of a root Project 2" ); | 1008 | root1->setDescription( "This is a test description of a root Project 2" ); |
1008 | root1->setPercentComplete( 20 ); | 1009 | root1->setPercentComplete( 20 ); |
1009 | root1->setCategories( QString( "Cat_Pro2") ); | 1010 | root1->setCategories( QString( "Cat_Pro2") ); |
1010 | updateView(); | 1011 | updateView(); |
1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1012 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1013 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1013 | int secLenRunning = 7200; | 1014 | int secLenRunning = 7200; |
1014 | int secLenPausing = 3600 * 3; | 1015 | int secLenPausing = 3600 * 3; |
1015 | int dayInterval = 1; | 1016 | int dayInterval = 1; |
1016 | 1017 | ||
1017 | nt = new Todo; | 1018 | nt = new Todo; |
1018 | mCalendar->addTodo( nt ); | 1019 | mCalendar->addTodo( nt ); |
1019 | nt->setSummary( "Planning Project2"); | 1020 | nt->setSummary( "Planning Project2"); |
1020 | nt->setPriority( 1 ); | 1021 | nt->setPriority( 1 ); |
1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1022 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1023 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1023 | nt->setPercentComplete( 20 ); | 1024 | nt->setPercentComplete( 20 ); |
1024 | 1025 | ||
1025 | 1026 | ||
1026 | Todo * sub1 = nt; | 1027 | Todo * sub1 = nt; |
1027 | sub1->setRelatedTo( root1 ); | 1028 | sub1->setRelatedTo( root1 ); |
1028 | 1029 | ||
1029 | nt = new Todo; | 1030 | nt = new Todo; |
1030 | mCalendar->addTodo( nt ); | 1031 | mCalendar->addTodo( nt ); |
1031 | nt->setSummary( "Planning Project2: Lutz"); | 1032 | nt->setSummary( "Planning Project2: Lutz"); |
1032 | nt->setPriority( 1 ); | 1033 | nt->setPriority( 1 ); |
1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1034 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1035 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1035 | nt->setPercentComplete( 20 ); | 1036 | nt->setPercentComplete( 20 ); |
1036 | Todo * workLutz11 = nt; | 1037 | Todo * workLutz11 = nt; |
1037 | workLutz11->setRelatedTo( sub1 ); | 1038 | workLutz11->setRelatedTo( sub1 ); |
1038 | 1039 | ||
1039 | nt = new Todo; | 1040 | nt = new Todo; |
1040 | mCalendar->addTodo( nt ); | 1041 | mCalendar->addTodo( nt ); |
1041 | nt->setSummary( "Planning Project2: Norbert"); | 1042 | nt->setSummary( "Planning Project2: Norbert"); |
1042 | nt->setPriority( 1 ); | 1043 | nt->setPriority( 1 ); |
1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1044 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1045 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1045 | nt->setPercentComplete( 20 ); | 1046 | nt->setPercentComplete( 20 ); |
1046 | Todo * workNorbert11 = nt; | 1047 | Todo * workNorbert11 = nt; |
1047 | workNorbert11->setRelatedTo( sub1 ); | 1048 | workNorbert11->setRelatedTo( sub1 ); |
1048 | 1049 | ||
1049 | nt = new Todo; | 1050 | nt = new Todo; |
1050 | mCalendar->addTodo( nt ); | 1051 | mCalendar->addTodo( nt ); |
1051 | nt->setSummary( "Work on 2"); | 1052 | nt->setSummary( "Work on 2"); |
1052 | nt->setPriority( 1 ); | 1053 | nt->setPriority( 1 ); |
1053 | nt->setDescription( "This is a test description of Work Project_2" ); | 1054 | nt->setDescription( "This is a test description of Work Project_2" ); |
1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1055 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1055 | nt->setPercentComplete( 20 ); | 1056 | nt->setPercentComplete( 20 ); |
1056 | 1057 | ||
1057 | Todo * sub2 = nt; | 1058 | Todo * sub2 = nt; |
1058 | sub2->setRelatedTo( root1 ); | 1059 | sub2->setRelatedTo( root1 ); |
1059 | 1060 | ||
1060 | 1061 | ||
1061 | nt = new Todo; | 1062 | nt = new Todo; |
1062 | mCalendar->addTodo( nt ); | 1063 | mCalendar->addTodo( nt ); |
1063 | nt->setSummary( "Work on 2: Lutz"); | 1064 | nt->setSummary( "Work on 2: Lutz"); |
1064 | nt->setPriority( 1 ); | 1065 | nt->setPriority( 1 ); |
1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1066 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1067 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1067 | nt->setPercentComplete( 20 ); | 1068 | nt->setPercentComplete( 20 ); |
1068 | Todo * workLutz12 = nt; | 1069 | Todo * workLutz12 = nt; |
1069 | workLutz12->setRelatedTo( sub2 ); | 1070 | workLutz12->setRelatedTo( sub2 ); |
1070 | 1071 | ||
1071 | nt = new Todo; | 1072 | nt = new Todo; |
1072 | mCalendar->addTodo( nt ); | 1073 | mCalendar->addTodo( nt ); |
1073 | nt->setSummary( "Work on 2: Norbert"); | 1074 | nt->setSummary( "Work on 2: Norbert"); |
1074 | nt->setPriority( 1 ); | 1075 | nt->setPriority( 1 ); |
1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1076 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1077 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1077 | nt->setPercentComplete( 20 ); | 1078 | nt->setPercentComplete( 20 ); |
1078 | Todo * workNorbert12 = nt; | 1079 | Todo * workNorbert12 = nt; |
1079 | workNorbert12->setRelatedTo( sub2 ); | 1080 | workNorbert12->setRelatedTo( sub2 ); |
1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1081 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1082 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1083 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1084 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1085 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1086 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1087 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1087 | } | 1088 | } |
1088 | updateView(); | 1089 | updateView(); |
1089 | #endif | 1090 | #endif |
1090 | 1091 | ||
1091 | } | 1092 | } |
1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1093 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1093 | { | 1094 | { |
1094 | static int ccc = 0; | 1095 | static int ccc = 0; |
1095 | ++ccc; | 1096 | ++ccc; |
1096 | QDateTime t_start = start; | 1097 | QDateTime t_start = start; |
1097 | runT->setPriority( 5 ); | 1098 | runT->setPriority( 5 ); |
1098 | runT->setPercentComplete( 0 ); | 1099 | runT->setPercentComplete( 0 ); |
1099 | int count = 0; | 1100 | int count = 0; |
1100 | int prio = 5; | 1101 | int prio = 5; |
1101 | int complete = 0; | 1102 | int complete = 0; |
1102 | while ( t_start < end ) { | 1103 | while ( t_start < end ) { |
1103 | ++count; | 1104 | ++count; |
1104 | if ( count > ccc ) { | 1105 | if ( count > ccc ) { |
1105 | count = 0; | 1106 | count = 0; |
1106 | --prio; | 1107 | --prio; |
1107 | if ( prio == 0 ) prio = 5; | 1108 | if ( prio == 0 ) prio = 5; |
1108 | complete += 20; | 1109 | complete += 20; |
1109 | if ( complete > 100 ) complete = 0; | 1110 | if ( complete > 100 ) complete = 0; |
1110 | runT->setPriority( prio ); | 1111 | runT->setPriority( prio ); |
1111 | runT->setPercentComplete( complete ); | 1112 | runT->setPercentComplete( complete ); |
1112 | } | 1113 | } |
1113 | runT->setRunning( true ); | 1114 | runT->setRunning( true ); |
1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1115 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1115 | if ( dayInterval ) | 1116 | if ( dayInterval ) |
1116 | t_start = t_start.addDays( dayInterval ); | 1117 | t_start = t_start.addDays( dayInterval ); |
1117 | else { | 1118 | else { |
1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1119 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1119 | } | 1120 | } |
1120 | } | 1121 | } |
1121 | } | 1122 | } |
1122 | 1123 | ||
1123 | void CalendarView::showDay( QDate d ) | 1124 | void CalendarView::showDay( QDate d ) |
1124 | { | 1125 | { |
1125 | dateNavigator()->blockSignals( true ); | 1126 | dateNavigator()->blockSignals( true ); |
1126 | dateNavigator()->selectDate( d ); | 1127 | dateNavigator()->selectDate( d ); |
1127 | dateNavigator()->blockSignals( false ); | 1128 | dateNavigator()->blockSignals( false ); |
1128 | mViewManager->showDayView(); | 1129 | mViewManager->showDayView(); |
1129 | //dateNavigator()->selectDate( d ); | 1130 | //dateNavigator()->selectDate( d ); |
1130 | } | 1131 | } |
1131 | void CalendarView::timerAlarm() | 1132 | void CalendarView::timerAlarm() |
1132 | { | 1133 | { |
1133 | //qDebug("CalendarView::timerAlarm() "); | 1134 | //qDebug("CalendarView::timerAlarm() "); |
1134 | computeAlarm(mAlarmNotification ); | 1135 | computeAlarm(mAlarmNotification ); |
1135 | } | 1136 | } |
1136 | 1137 | ||
1137 | void CalendarView::suspendAlarm() | 1138 | void CalendarView::suspendAlarm() |
1138 | { | 1139 | { |
1139 | //qDebug(" CalendarView::suspendAlarm() "); | 1140 | //qDebug(" CalendarView::suspendAlarm() "); |
1140 | computeAlarm(mSuspendAlarmNotification ); | 1141 | computeAlarm(mSuspendAlarmNotification ); |
1141 | 1142 | ||
1142 | } | 1143 | } |
1143 | 1144 | ||
1144 | void CalendarView::startAlarm( QString mess , QString filename) | 1145 | void CalendarView::startAlarm( QString mess , QString filename) |
1145 | { | 1146 | { |
1146 | 1147 | ||
1147 | topLevelWidget()->showNormal(); | 1148 | topLevelWidget()->showNormal(); |
1148 | topLevelWidget()->setActiveWindow(); | 1149 | topLevelWidget()->setActiveWindow(); |
1149 | topLevelWidget()->raise(); | 1150 | topLevelWidget()->raise(); |
1150 | 1151 | ||
1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1152 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1153 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1153 | 1154 | ||
1154 | } | 1155 | } |
1155 | 1156 | ||
1156 | void CalendarView::checkNextTimerAlarm() | 1157 | void CalendarView::checkNextTimerAlarm() |
1157 | { | 1158 | { |
1158 | mCalendar->checkAlarmForIncidence( 0, true ); | 1159 | mCalendar->checkAlarmForIncidence( 0, true ); |
1159 | } | 1160 | } |
1160 | 1161 | ||
1161 | void CalendarView::computeAlarm( QString msg ) | 1162 | void CalendarView::computeAlarm( QString msg ) |
1162 | { | 1163 | { |
1163 | 1164 | ||
1164 | QString mess = msg; | 1165 | QString mess = msg; |
1165 | QString mAlarmMessage = mess.mid( 9 ); | 1166 | QString mAlarmMessage = mess.mid( 9 ); |
1166 | QString filename = MainWindow::resourcePath(); | 1167 | QString filename = MainWindow::resourcePath(); |
1167 | filename += "koalarm.wav"; | 1168 | filename += "koalarm.wav"; |
1168 | QString tempfilename; | 1169 | QString tempfilename; |
1169 | if ( mess.left( 13 ) == "suspend_alarm") { | 1170 | if ( mess.left( 13 ) == "suspend_alarm") { |
1170 | bool error = false; | 1171 | bool error = false; |
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 | } |
2945 | void CalendarView::goNextMonth() | 2996 | void CalendarView::goNextMonth() |
2946 | { | 2997 | { |
2947 | mNavigator->selectNextMonth(); | 2998 | mNavigator->selectNextMonth(); |
2948 | } | 2999 | } |
2949 | 3000 | ||
2950 | void CalendarView::goPreviousMonth() | 3001 | void CalendarView::goPreviousMonth() |
2951 | { | 3002 | { |
2952 | mNavigator->selectPreviousMonth(); | 3003 | mNavigator->selectPreviousMonth(); |
2953 | } | 3004 | } |
2954 | 3005 | ||
2955 | void CalendarView::updateConfig() | 3006 | void CalendarView::updateConfig() |
2956 | { | 3007 | { |
2957 | if ( KOPrefs::instance()->mUseAppColors ) | 3008 | if ( KOPrefs::instance()->mUseAppColors ) |
2958 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 3009 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2959 | emit configChanged(); | 3010 | emit configChanged(); |
2960 | mTodoList->updateConfig(); | 3011 | mTodoList->updateConfig(); |
2961 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 3012 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2962 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3013 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2963 | // To make the "fill window" configurations work | 3014 | // To make the "fill window" configurations work |
2964 | //mViewManager->raiseCurrentView(); | 3015 | //mViewManager->raiseCurrentView(); |
2965 | } | 3016 | } |
2966 | 3017 | ||
2967 | 3018 | ||
2968 | void CalendarView::eventChanged(Event *event) | 3019 | void CalendarView::eventChanged(Event *event) |
2969 | { | 3020 | { |
2970 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 3021 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2971 | //updateUnmanagedViews(); | 3022 | //updateUnmanagedViews(); |
2972 | } | 3023 | } |
2973 | 3024 | ||
2974 | void CalendarView::eventAdded(Event *event) | 3025 | void CalendarView::eventAdded(Event *event) |
2975 | { | 3026 | { |
2976 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 3027 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2977 | } | 3028 | } |
2978 | 3029 | ||
2979 | void CalendarView::eventToBeDeleted(Event *) | 3030 | void CalendarView::eventToBeDeleted(Event *) |
2980 | { | 3031 | { |
2981 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 3032 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2982 | } | 3033 | } |
2983 | 3034 | ||
2984 | void CalendarView::eventDeleted() | 3035 | void CalendarView::eventDeleted() |
2985 | { | 3036 | { |
2986 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 3037 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2987 | } | 3038 | } |
2988 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 3039 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2989 | { | 3040 | { |
2990 | changeIncidenceDisplay((Incidence *)which, action); | 3041 | changeIncidenceDisplay((Incidence *)which, action); |
2991 | mDateNavigator->updateView(); //LR | 3042 | mDateNavigator->updateView(); //LR |
2992 | //mDialogManager->updateSearchDialog(); | 3043 | //mDialogManager->updateSearchDialog(); |
2993 | 3044 | ||
2994 | if (which) { | 3045 | if (which) { |
2995 | mViewManager->updateWNview(); | 3046 | mViewManager->updateWNview(); |
2996 | //mTodoList->updateView(); | 3047 | //mTodoList->updateView(); |
2997 | } | 3048 | } |
2998 | 3049 | ||
2999 | } | 3050 | } |
3000 | 3051 | ||
3001 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 3052 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
3002 | { | 3053 | { |
3003 | updateUnmanagedViews(); | 3054 | updateUnmanagedViews(); |
3004 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3055 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
3005 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 3056 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
3006 | mCalendar->checkAlarmForIncidence( 0, true ); | 3057 | mCalendar->checkAlarmForIncidence( 0, true ); |
3007 | if ( mEventViewerDialog ) | 3058 | if ( mEventViewerDialog ) |
3008 | mEventViewerDialog->hide(); | 3059 | mEventViewerDialog->hide(); |
3009 | } | 3060 | } |
3010 | else | 3061 | else |
3011 | mCalendar->checkAlarmForIncidence( which , false ); | 3062 | mCalendar->checkAlarmForIncidence( which , false ); |
3012 | } | 3063 | } |
3013 | 3064 | ||
3014 | // most of the changeEventDisplays() right now just call the view's | 3065 | // most of the changeEventDisplays() right now just call the view's |
3015 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 3066 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
3016 | void CalendarView::changeEventDisplay(Event *which, int action) | 3067 | void CalendarView::changeEventDisplay(Event *which, int action) |
3017 | { | 3068 | { |
3018 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 3069 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
3019 | changeIncidenceDisplay((Incidence *)which, action); | 3070 | changeIncidenceDisplay((Incidence *)which, action); |
3020 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3071 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3021 | if ( flag_clearallviewsEventDisplay ) { | 3072 | if ( flag_clearallviewsEventDisplay ) { |
3022 | clearAllViews(); | 3073 | clearAllViews(); |
3023 | flag_clearallviewsEventDisplay = false; | 3074 | flag_clearallviewsEventDisplay = false; |
3024 | } | 3075 | } |
3025 | return; | 3076 | return; |
3026 | } | 3077 | } |
3027 | flag_clearallviewsEventDisplay = true; | 3078 | flag_clearallviewsEventDisplay = true; |
3028 | mDateNavigator->updateView(); | 3079 | mDateNavigator->updateView(); |
3029 | //mDialogManager->updateSearchDialog(); | 3080 | //mDialogManager->updateSearchDialog(); |
3030 | if (which) { | 3081 | if (which) { |
3031 | // If there is an event view visible update the display | 3082 | // If there is an event view visible update the display |
3032 | mViewManager->currentView()->changeEventDisplay(which,action); | 3083 | mViewManager->currentView()->changeEventDisplay(which,action); |
3033 | // TODO: check, if update needed | 3084 | // TODO: check, if update needed |
3034 | // if (which->getTodoStatus()) { | 3085 | // if (which->getTodoStatus()) { |
3035 | mTodoList->updateView(); | 3086 | mTodoList->updateView(); |
3036 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { | 3087 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { |
3037 | mConflictingEvent = which ; | 3088 | mConflictingEvent = which ; |
3038 | int time = 1000; | 3089 | int time = 1000; |
3039 | #ifdef DESKTOP_VERSION | 3090 | #ifdef DESKTOP_VERSION |
3040 | time = 500; | 3091 | time = 500; |
3041 | #endif | 3092 | #endif |
3042 | bool checkC = false; | 3093 | bool checkC = false; |
3043 | if ( mConflictingEvent->doesFloat() ) { | 3094 | if ( mConflictingEvent->doesFloat() ) { |
3044 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay | 3095 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay |
3045 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3096 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3046 | } else { | 3097 | } else { |
3047 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay | 3098 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay |
3048 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3099 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3049 | } | 3100 | } |
3050 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) | 3101 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) |
3051 | checkC = false; | 3102 | checkC = false; |
3052 | if ( checkC ) | 3103 | if ( checkC ) |
3053 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 3104 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
3054 | } | 3105 | } |
3055 | // } | 3106 | // } |
3056 | } else { | 3107 | } else { |
3057 | mViewManager->currentView()->updateView(); | 3108 | mViewManager->currentView()->updateView(); |
3058 | } | 3109 | } |
3059 | } | 3110 | } |
3060 | void CalendarView::checkConflictForEvent() | 3111 | void CalendarView::checkConflictForEvent() |
3061 | { | 3112 | { |
3062 | 3113 | ||
3063 | if (!KOPrefs::instance()->mConfirm) | 3114 | if (!KOPrefs::instance()->mConfirm) |
3064 | return; | 3115 | return; |
3065 | if ( ! mConflictingEvent ) return; | 3116 | if ( ! mConflictingEvent ) return; |
3066 | Event * conflictingEvent = mConflictingEvent; | 3117 | Event * conflictingEvent = mConflictingEvent; |
3067 | mConflictingEvent = 0; | 3118 | mConflictingEvent = 0; |
3068 | QDateTime current = QDateTime::currentDateTime(); | 3119 | QDateTime current = QDateTime::currentDateTime(); |
3069 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 3120 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
3070 | return; | 3121 | return; |
3071 | } | 3122 | } |
3072 | CalFilter *filterIN = 0; | 3123 | CalFilter *filterIN = 0; |
3073 | CalFilter *filterALL = 0; | 3124 | CalFilter *filterALL = 0; |
3074 | CalFilter *filter = mFilters.first(); | 3125 | CalFilter *filter = mFilters.first(); |
3075 | while(filter) { | 3126 | while(filter) { |
3076 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) | 3127 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) |
3077 | filterIN = filter; | 3128 | filterIN = filter; |
3078 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) | 3129 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) |
3079 | filterALL = filter; | 3130 | filterALL = filter; |
3080 | filter = mFilters.next(); | 3131 | filter = mFilters.next(); |
3081 | } | 3132 | } |
3082 | if ( filterIN ) { | 3133 | if ( filterIN ) { |
3083 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { | 3134 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { |
3084 | return; | 3135 | return; |
3085 | } | 3136 | } |
3086 | } | 3137 | } |
3087 | QPtrList<Event> testlist = mCalendar->events(); | 3138 | QPtrList<Event> testlist = mCalendar->events(); |
3088 | Event * test = testlist.first(); | 3139 | Event * test = testlist.first(); |
3089 | QDateTime conflict; | 3140 | QDateTime conflict; |
3090 | QDateTime retVal; | 3141 | QDateTime retVal; |
3091 | bool found = false; | 3142 | bool found = false; |
3092 | Event * cE = 0; | 3143 | Event * cE = 0; |
3093 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; | 3144 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; |
3094 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3145 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3095 | if ( !conflictingEvent->doesFloat() ) { | 3146 | if ( !conflictingEvent->doesFloat() ) { |
3096 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; | 3147 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; |
3097 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3148 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3098 | } | 3149 | } |
3099 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 3150 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
3100 | while ( test ) { | 3151 | while ( test ) { |
3101 | qApp->processEvents(); | 3152 | qApp->processEvents(); |
3102 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); | 3153 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); |
3103 | 3154 | ||
3104 | if ( !skip ) { | 3155 | if ( !skip ) { |
3105 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) | 3156 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) |
3106 | skip = true; | 3157 | skip = true; |
3107 | } | 3158 | } |
3108 | if ( !skip ) { | 3159 | if ( !skip ) { |
3109 | if ( filterALL ) { | 3160 | if ( filterALL ) { |
3110 | if ( !filterALL->filterCalendarItem( test ) ) { | 3161 | if ( !filterALL->filterCalendarItem( test ) ) { |
3111 | skip = true; | 3162 | skip = true; |
3112 | } | 3163 | } |
3113 | } | 3164 | } |
3114 | if ( !skip ) { | 3165 | if ( !skip ) { |
3115 | if ( found ) | 3166 | if ( found ) |
3116 | skip = !test->matchTime( ¤t, &conflict ); | 3167 | skip = !test->matchTime( ¤t, &conflict ); |
3117 | else | 3168 | else |
3118 | skip = !test->matchTime( ¤t, 0 ); | 3169 | skip = !test->matchTime( ¤t, 0 ); |
3119 | if ( !skip ) { | 3170 | if ( !skip ) { |
3120 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 3171 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
3121 | if ( ! found ) { | 3172 | if ( ! found ) { |
3122 | conflict = retVal; | 3173 | conflict = retVal; |
3123 | cE = test; | 3174 | cE = test; |
3124 | } else { | 3175 | } else { |
3125 | if ( retVal < conflict ) { | 3176 | if ( retVal < conflict ) { |
3126 | conflict = retVal; | 3177 | conflict = retVal; |
3127 | cE = test; | 3178 | cE = test; |
3128 | } | 3179 | } |
3129 | } | 3180 | } |
3130 | found = true; | 3181 | found = true; |
3131 | } | 3182 | } |
3132 | } | 3183 | } |
3133 | } | 3184 | } |
3134 | } | 3185 | } |
3135 | test = testlist.next(); | 3186 | test = testlist.next(); |
3136 | } | 3187 | } |
3137 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 3188 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
3138 | if ( found ) { | 3189 | if ( found ) { |
3139 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 3190 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
3140 | qApp->processEvents(); | 3191 | qApp->processEvents(); |
3141 | int km = KMessageBox::warningContinueCancel(this,mess, | 3192 | int km = KMessageBox::warningContinueCancel(this,mess, |
3142 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); | 3193 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); |
3143 | if ( km != KMessageBox::Continue ) { | 3194 | if ( km != KMessageBox::Continue ) { |
3144 | return; | 3195 | return; |
3145 | } | 3196 | } |
3146 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 3197 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
3147 | mViewManager->showDayView(); | 3198 | mViewManager->showDayView(); |
3148 | mNavigator->slotDaySelect( conflict.date() ); | 3199 | mNavigator->slotDaySelect( conflict.date() ); |
3149 | int hour = conflict.time().hour(); | 3200 | int hour = conflict.time().hour(); |
3150 | mViewManager->agendaView()->setStartHour( hour ); | 3201 | mViewManager->agendaView()->setStartHour( hour ); |
3151 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 3202 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
3152 | } else | 3203 | } else |
3153 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 3204 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
3154 | return; | 3205 | return; |
3155 | 3206 | ||
3156 | } | 3207 | } |
3157 | 3208 | ||
3158 | void CalendarView::updateTodoViews() | 3209 | void CalendarView::updateTodoViews() |
3159 | { | 3210 | { |
3160 | mTodoList->updateView(); | 3211 | mTodoList->updateView(); |
3161 | mViewManager->currentView()->updateView(); | 3212 | mViewManager->currentView()->updateView(); |
3162 | 3213 | ||
3163 | } | 3214 | } |
3164 | 3215 | ||
3165 | 3216 | ||
3166 | 3217 | ||
3167 | void CalendarView::clearAllViews() | 3218 | void CalendarView::clearAllViews() |
3168 | { | 3219 | { |
3169 | mTodoList->clearList(); | 3220 | mTodoList->clearList(); |
3170 | mViewManager->clearAllViews(); | 3221 | mViewManager->clearAllViews(); |
3171 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 3222 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
3172 | if ( sd ) { | 3223 | if ( sd ) { |
3173 | KOListView* kol = sd->listview(); | 3224 | KOListView* kol = sd->listview(); |
3174 | if ( kol ) | 3225 | if ( kol ) |
3175 | kol->clearList(); | 3226 | kol->clearList(); |
3176 | } | 3227 | } |
3177 | } | 3228 | } |
3178 | void CalendarView::updateView() | 3229 | void CalendarView::updateView() |
3179 | { | 3230 | { |
3180 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3231 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3181 | if ( flag_clearallviewsupdateView ) { | 3232 | if ( flag_clearallviewsupdateView ) { |
3182 | clearAllViews(); | 3233 | clearAllViews(); |
3183 | flag_clearallviewsupdateView = false; | 3234 | flag_clearallviewsupdateView = false; |
3184 | } | 3235 | } |
3185 | return; | 3236 | return; |
3186 | } | 3237 | } |
3187 | flag_clearallviewsupdateView = true; | 3238 | flag_clearallviewsupdateView = true; |
3188 | DateList tmpList = mNavigator->selectedDates(); | 3239 | DateList tmpList = mNavigator->selectedDates(); |
3189 | 3240 | ||
3190 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 3241 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
3191 | mTodoList->updateView(); | 3242 | mTodoList->updateView(); |
3192 | // We assume that the navigator only selects consecutive days. | 3243 | // We assume that the navigator only selects consecutive days. |
3193 | updateView( tmpList.first(), tmpList.last() ); | 3244 | updateView( tmpList.first(), tmpList.last() ); |
3194 | } | 3245 | } |
3195 | 3246 | ||
3196 | void CalendarView::updateUnmanagedViews() | 3247 | void CalendarView::updateUnmanagedViews() |
3197 | { | 3248 | { |
3198 | mDateNavigator->updateDayMatrix(); | 3249 | mDateNavigator->updateDayMatrix(); |
3199 | } | 3250 | } |
3200 | 3251 | ||
3201 | int CalendarView::msgItemDelete(const QString name) | 3252 | int CalendarView::msgItemDelete(const QString name) |
3202 | { | 3253 | { |
3203 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 3254 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
3204 | i18n("This item will be\npermanently deleted."), | 3255 | i18n("This item will be\npermanently deleted."), |
3205 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 3256 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
3206 | } | 3257 | } |
3207 | 3258 | ||
3208 | 3259 | ||
3209 | void CalendarView::edit_cut() | 3260 | void CalendarView::edit_cut() |
3210 | { | 3261 | { |
3211 | Event *anEvent=0; | 3262 | Event *anEvent=0; |
3212 | 3263 | ||
3213 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3264 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3214 | 3265 | ||
3215 | if (mViewManager->currentView()->isEventView()) { | 3266 | if (mViewManager->currentView()->isEventView()) { |
3216 | if ( incidence && incidence->typeID() == eventID ) { | 3267 | if ( incidence && incidence->typeID() == eventID ) { |
3217 | anEvent = static_cast<Event *>(incidence); | 3268 | anEvent = static_cast<Event *>(incidence); |
3218 | } | 3269 | } |
3219 | } | 3270 | } |
3220 | 3271 | ||
3221 | if (!anEvent) { | 3272 | if (!anEvent) { |
3222 | KNotifyClient::beep(); | 3273 | KNotifyClient::beep(); |
3223 | return; | 3274 | return; |
3224 | } | 3275 | } |
3225 | DndFactory factory( mCalendar ); | 3276 | DndFactory factory( mCalendar ); |
3226 | factory.cutIncidence(anEvent); | 3277 | factory.cutIncidence(anEvent); |
3227 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3278 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3228 | } | 3279 | } |
3229 | 3280 | ||
3230 | void CalendarView::edit_copy() | 3281 | void CalendarView::edit_copy() |
3231 | { | 3282 | { |
3232 | Event *anEvent=0; | 3283 | Event *anEvent=0; |
3233 | 3284 | ||
3234 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3285 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3235 | 3286 | ||
3236 | if (mViewManager->currentView()->isEventView()) { | 3287 | if (mViewManager->currentView()->isEventView()) { |
3237 | if ( incidence && incidence->typeID() == eventID ) { | 3288 | if ( incidence && incidence->typeID() == eventID ) { |
3238 | anEvent = static_cast<Event *>(incidence); | 3289 | anEvent = static_cast<Event *>(incidence); |
3239 | } | 3290 | } |
3240 | } | 3291 | } |
3241 | 3292 | ||
3242 | if (!anEvent) { | 3293 | if (!anEvent) { |
3243 | KNotifyClient::beep(); | 3294 | KNotifyClient::beep(); |
3244 | return; | 3295 | return; |
3245 | } | 3296 | } |
3246 | DndFactory factory( mCalendar ); | 3297 | DndFactory factory( mCalendar ); |
3247 | factory.copyIncidence(anEvent); | 3298 | factory.copyIncidence(anEvent); |
3248 | } | 3299 | } |
3249 | 3300 | ||
3250 | void CalendarView::edit_paste() | 3301 | void CalendarView::edit_paste() |
3251 | { | 3302 | { |
3252 | QDate date = mNavigator->selectedDates().first(); | 3303 | QDate date = mNavigator->selectedDates().first(); |
3253 | 3304 | ||
3254 | DndFactory factory( mCalendar ); | 3305 | DndFactory factory( mCalendar ); |
3255 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 3306 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
3256 | 3307 | ||
3257 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 3308 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
3258 | } | 3309 | } |
3259 | void CalendarView::edit_global_options() | 3310 | void CalendarView::edit_global_options() |
3260 | { | 3311 | { |
3261 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 3312 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
3262 | emit save(); | 3313 | emit save(); |
3263 | emit saveStopTimer(); | 3314 | emit saveStopTimer(); |
3264 | mDialogManager->showGlobalOptionsDialog(); | 3315 | mDialogManager->showGlobalOptionsDialog(); |
3265 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 3316 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
3266 | emit saveStopTimer(); | 3317 | emit saveStopTimer(); |
3267 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 3318 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
3268 | i18n("Timezone settings"),i18n("Reload"))) { | 3319 | i18n("Timezone settings"),i18n("Reload"))) { |
3269 | qDebug("KO: TZ reload cancelled "); | 3320 | qDebug("KO: TZ reload cancelled "); |
3270 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3321 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3271 | return; | 3322 | return; |
3272 | } | 3323 | } |
3273 | qDebug("KO: Timezone change "); | 3324 | qDebug("KO: Timezone change "); |
3274 | loadCalendars(); | 3325 | loadCalendars(); |
3275 | setModified(true); | 3326 | setModified(true); |
3276 | } | 3327 | } |
3277 | else | 3328 | else |
3278 | qDebug("KO: No tz change "); | 3329 | qDebug("KO: No tz change "); |
3279 | } | 3330 | } |
3280 | void CalendarView::edit_options() | 3331 | void CalendarView::edit_options() |
3281 | { | 3332 | { |
3282 | mDialogManager->showOptionsDialog(); | 3333 | mDialogManager->showOptionsDialog(); |
3283 | } | 3334 | } |
3284 | 3335 | ||
3285 | 3336 | ||
3286 | void CalendarView::slotSelectPickerDate( QDate d) | 3337 | void CalendarView::slotSelectPickerDate( QDate d) |
3287 | { | 3338 | { |
3288 | mDateFrame->hide(); | 3339 | mDateFrame->hide(); |
3289 | if ( mDatePickerMode == 1 ) { | 3340 | if ( mDatePickerMode == 1 ) { |
3290 | mNavigator->slotDaySelect( d ); | 3341 | mNavigator->slotDaySelect( d ); |
3291 | } else if ( mDatePickerMode == 2 ) { | 3342 | } else if ( mDatePickerMode == 2 ) { |
3292 | if ( mMoveIncidence->typeID() == todoID ) { | 3343 | if ( mMoveIncidence->typeID() == todoID ) { |
3293 | Todo * to = (Todo *) mMoveIncidence; | 3344 | Todo * to = (Todo *) mMoveIncidence; |
3294 | QTime tim; | 3345 | QTime tim; |
3295 | int len = 0; | 3346 | int len = 0; |
3296 | if ( to->hasStartDate() && to->hasDueDate() ) | 3347 | if ( to->hasStartDate() && to->hasDueDate() ) |
3297 | len = to->dtStart().secsTo( to->dtDue()); | 3348 | len = to->dtStart().secsTo( to->dtDue()); |
3298 | if ( to->hasDueDate() ) | 3349 | if ( to->hasDueDate() ) |
3299 | tim = to->dtDue().time(); | 3350 | tim = to->dtDue().time(); |
3300 | else { | 3351 | else { |
3301 | tim = QTime ( 0,0,0 ); | 3352 | tim = QTime ( 0,0,0 ); |
3302 | to->setFloats( true ); | 3353 | to->setFloats( true ); |
3303 | to->setHasDueDate( true ); | 3354 | to->setHasDueDate( true ); |
3304 | } | 3355 | } |
3305 | QDateTime dt ( d,tim ); | 3356 | QDateTime dt ( d,tim ); |
3306 | to->setDtDue( dt ); | 3357 | to->setDtDue( dt ); |
3307 | 3358 | ||
3308 | if ( to->hasStartDate() ) { | 3359 | if ( to->hasStartDate() ) { |
3309 | if ( len>0 ) | 3360 | if ( len>0 ) |
3310 | to->setDtStart(to->dtDue().addSecs( -len )); | 3361 | to->setDtStart(to->dtDue().addSecs( -len )); |
3311 | else | 3362 | else |
3312 | if (to->dtStart() > to->dtDue() ) | 3363 | if (to->dtStart() > to->dtDue() ) |
3313 | to->setDtStart(to->dtDue().addDays( -3 )); | 3364 | to->setDtStart(to->dtDue().addDays( -3 )); |
3314 | } | 3365 | } |
3315 | 3366 | ||
3316 | todoChanged( to ); | 3367 | todoChanged( to ); |
3317 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3368 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3318 | if ( mMoveIncidence->doesRecur() ) { | 3369 | if ( mMoveIncidence->doesRecur() ) { |
3319 | #if 0 | 3370 | #if 0 |
3320 | // PENDING implement this | 3371 | // PENDING implement this |
3321 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3372 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3322 | mCalendar()->addIncidence( newInc ); | 3373 | mCalendar()->addIncidence( newInc ); |
3323 | if ( mMoveIncidence->typeID() == todoID ) | 3374 | if ( mMoveIncidence->typeID() == todoID ) |
3324 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3375 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3325 | else | 3376 | else |
3326 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3377 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3327 | mMoveIncidence = newInc; | 3378 | mMoveIncidence = newInc; |
3328 | 3379 | ||
3329 | #endif | 3380 | #endif |
3330 | } | 3381 | } |
3331 | QTime tim = mMoveIncidence->dtStart().time(); | 3382 | QTime tim = mMoveIncidence->dtStart().time(); |
3332 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3383 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3333 | QDateTime dt ( d,tim ); | 3384 | QDateTime dt ( d,tim ); |
3334 | mMoveIncidence->setDtStart( dt ); | 3385 | mMoveIncidence->setDtStart( dt ); |
3335 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3386 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3336 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3387 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3337 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3388 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3338 | QTime tim = mMoveIncidence->dtStart().time(); | 3389 | QTime tim = mMoveIncidence->dtStart().time(); |
3339 | QDateTime dt ( d,tim ); | 3390 | QDateTime dt ( d,tim ); |
3340 | mMoveIncidence->setDtStart( dt ); | 3391 | mMoveIncidence->setDtStart( dt ); |
3341 | updateView(); | 3392 | updateView(); |
3342 | } | 3393 | } |
3343 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3394 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3344 | } | 3395 | } |
3345 | } | 3396 | } |
3346 | 3397 | ||
3347 | void CalendarView::removeCategories() | 3398 | void CalendarView::removeCategories() |
3348 | { | 3399 | { |
3349 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3400 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3350 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3401 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3351 | QStringList catIncList; | 3402 | QStringList catIncList; |
3352 | QStringList newCatList; | 3403 | QStringList newCatList; |
3353 | Incidence* inc = incList.first(); | 3404 | Incidence* inc = incList.first(); |
3354 | uint i; | 3405 | uint i; |
3355 | while ( inc ) { | 3406 | while ( inc ) { |
3356 | newCatList.clear(); | 3407 | newCatList.clear(); |
3357 | catIncList = inc->categories() ; | 3408 | catIncList = inc->categories() ; |
3358 | for( i = 0; i< catIncList.count(); ++i ) { | 3409 | for( i = 0; i< catIncList.count(); ++i ) { |
3359 | if ( catList.contains (catIncList[i])) | 3410 | if ( catList.contains (catIncList[i])) |
3360 | newCatList.append( catIncList[i] ); | 3411 | newCatList.append( catIncList[i] ); |
3361 | } | 3412 | } |
3362 | newCatList.sort(); | 3413 | newCatList.sort(); |
3363 | inc->setCategories( newCatList.join(",") ); | 3414 | inc->setCategories( newCatList.join(",") ); |
3364 | inc = incList.next(); | 3415 | inc = incList.next(); |
3365 | } | 3416 | } |
3366 | } | 3417 | } |
3367 | 3418 | ||
3368 | int CalendarView::addCategories() | 3419 | int CalendarView::addCategories() |
3369 | { | 3420 | { |
3370 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3421 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3371 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3422 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3372 | QStringList catIncList; | 3423 | QStringList catIncList; |
3373 | Incidence* inc = incList.first(); | 3424 | Incidence* inc = incList.first(); |
3374 | uint i; | 3425 | uint i; |
3375 | int count = 0; | 3426 | int count = 0; |
3376 | while ( inc ) { | 3427 | while ( inc ) { |
3377 | catIncList = inc->categories() ; | 3428 | catIncList = inc->categories() ; |
3378 | for( i = 0; i< catIncList.count(); ++i ) { | 3429 | for( i = 0; i< catIncList.count(); ++i ) { |
3379 | if ( !catList.contains (catIncList[i])) { | 3430 | if ( !catList.contains (catIncList[i])) { |
3380 | catList.append( catIncList[i] ); | 3431 | catList.append( catIncList[i] ); |
3381 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3432 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3382 | ++count; | 3433 | ++count; |
3383 | } | 3434 | } |
3384 | } | 3435 | } |
3385 | inc = incList.next(); | 3436 | inc = incList.next(); |
3386 | } | 3437 | } |
3387 | catList.sort(); | 3438 | catList.sort(); |
3388 | KOPrefs::instance()->mCustomCategories = catList; | 3439 | KOPrefs::instance()->mCustomCategories = catList; |
3389 | return count; | 3440 | return count; |
3390 | } | 3441 | } |
3391 | 3442 | ||
3392 | void CalendarView::editCategories() | 3443 | void CalendarView::editCategories() |
3393 | { | 3444 | { |
3394 | qDebug("CalendarView::editCategories() "); | 3445 | qDebug("CalendarView::editCategories() "); |
3395 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3446 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3396 | ced.exec(); | 3447 | ced.exec(); |
3397 | } | 3448 | } |
3398 | void CalendarView::manageCategories() | 3449 | void CalendarView::manageCategories() |
3399 | { | 3450 | { |
3400 | KOCatPrefs* cp = new KOCatPrefs(); | 3451 | KOCatPrefs* cp = new KOCatPrefs(); |
3401 | cp->show(); | 3452 | cp->show(); |
3402 | int w =cp->sizeHint().width() ; | 3453 | int w =cp->sizeHint().width() ; |
3403 | int h = cp->sizeHint().height() ; | 3454 | int h = cp->sizeHint().height() ; |
3404 | int dw = QApplication::desktop()->width(); | 3455 | int dw = QApplication::desktop()->width(); |
3405 | int dh = QApplication::desktop()->height(); | 3456 | int dh = QApplication::desktop()->height(); |
3406 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3457 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3407 | if ( !cp->exec() ) { | 3458 | if ( !cp->exec() ) { |
3408 | delete cp; | 3459 | delete cp; |
3409 | return; | 3460 | return; |
3410 | } | 3461 | } |
3411 | int count = 0; | 3462 | int count = 0; |
3412 | if ( cp->addCat() ) { | 3463 | if ( cp->addCat() ) { |
3413 | count = addCategories(); | 3464 | count = addCategories(); |
3414 | if ( count ) { | 3465 | if ( count ) { |
3415 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3466 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3416 | writeSettings(); | 3467 | writeSettings(); |
3417 | } else | 3468 | } else |
3418 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3469 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3419 | } else { | 3470 | } else { |
3420 | removeCategories(); | 3471 | removeCategories(); |
3421 | updateView(); | 3472 | updateView(); |
3422 | } | 3473 | } |
3423 | delete cp; | 3474 | delete cp; |
3424 | } | 3475 | } |
3425 | 3476 | ||
3426 | void CalendarView::beamIncidence(Incidence * Inc) | 3477 | void CalendarView::beamIncidence(Incidence * Inc) |
3427 | { | 3478 | { |
3428 | QPtrList<Incidence> delSel ; | 3479 | QPtrList<Incidence> delSel ; |
3429 | delSel.append(Inc); | 3480 | delSel.append(Inc); |
3430 | beamIncidenceList( delSel ); | 3481 | beamIncidenceList( delSel ); |
3431 | } | 3482 | } |
3432 | void CalendarView::beamCalendar() | 3483 | void CalendarView::beamCalendar() |
3433 | { | 3484 | { |
3434 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3485 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3435 | //qDebug("beamCalendar() "); | 3486 | //qDebug("beamCalendar() "); |
3436 | beamIncidenceList( delSel ); | 3487 | beamIncidenceList( delSel ); |
3437 | } | 3488 | } |
3438 | void CalendarView::beamFilteredCalendar() | 3489 | void CalendarView::beamFilteredCalendar() |
3439 | { | 3490 | { |
3440 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3491 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3441 | //qDebug("beamFilteredCalendar() "); | 3492 | //qDebug("beamFilteredCalendar() "); |
3442 | beamIncidenceList( delSel ); | 3493 | beamIncidenceList( delSel ); |
3443 | } | 3494 | } |
3444 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3495 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3445 | { | 3496 | { |
3446 | 3497 | ||
3447 | KOBeamPrefs beamDialog; | 3498 | KOBeamPrefs beamDialog; |
3448 | if ( beamDialog.exec () == QDialog::Rejected ) | 3499 | if ( beamDialog.exec () == QDialog::Rejected ) |
3449 | return; | 3500 | return; |
3450 | #ifdef DESKTOP_VERSION | 3501 | #ifdef DESKTOP_VERSION |
3451 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3502 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3452 | #else | 3503 | #else |
3453 | QString fn = "/tmp/kopibeamfile"; | 3504 | QString fn = "/tmp/kopibeamfile"; |
3454 | #endif | 3505 | #endif |
3455 | QString mes; | 3506 | QString mes; |
3456 | bool createbup = true; | 3507 | bool createbup = true; |
3457 | if ( createbup ) { | 3508 | if ( createbup ) { |
3458 | QString description = "\n"; | 3509 | QString description = "\n"; |
3459 | CalendarLocal* cal = new CalendarLocal(); | 3510 | CalendarLocal* cal = new CalendarLocal(); |
3460 | if ( beamDialog.beamLocal() ) | 3511 | if ( beamDialog.beamLocal() ) |
3461 | cal->setLocalTime(); | 3512 | cal->setLocalTime(); |
3462 | else | 3513 | else |
3463 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3514 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3464 | Incidence *incidence = delSel.first(); | 3515 | Incidence *incidence = delSel.first(); |
3465 | bool addText = false; | 3516 | bool addText = false; |
3466 | if ( delSel.count() < 10 ) | 3517 | if ( delSel.count() < 10 ) |
3467 | addText = true; | 3518 | addText = true; |
3468 | else { | 3519 | else { |
3469 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3520 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3470 | } | 3521 | } |
3471 | while ( incidence ) { | 3522 | while ( incidence ) { |
3472 | Incidence *in = incidence->clone(); | 3523 | Incidence *in = incidence->clone(); |
3473 | if ( ! in->summary().isEmpty() ) { | 3524 | if ( ! in->summary().isEmpty() ) { |
3474 | in->setDescription(""); | 3525 | in->setDescription(""); |
3475 | } else { | 3526 | } else { |
3476 | in->setSummary( in->description().left(20)); | 3527 | in->setSummary( in->description().left(20)); |
3477 | in->setDescription(""); | 3528 | in->setDescription(""); |
3478 | } | 3529 | } |
3479 | if ( addText ) | 3530 | if ( addText ) |
3480 | description += in->summary() + "\n"; | 3531 | description += in->summary() + "\n"; |
3481 | cal->addIncidence( in ); | 3532 | cal->addIncidence( in ); |
3482 | incidence = delSel.next(); | 3533 | incidence = delSel.next(); |
3483 | } | 3534 | } |
3484 | if ( beamDialog.beamVcal() ) { | 3535 | if ( beamDialog.beamVcal() ) { |
3485 | fn += ".vcs"; | 3536 | fn += ".vcs"; |
3486 | FileStorage storage( cal, fn, new VCalFormat ); | 3537 | FileStorage storage( cal, fn, new VCalFormat ); |
3487 | storage.save(); | 3538 | storage.save(); |
3488 | } else { | 3539 | } else { |
3489 | fn += ".ics"; | 3540 | fn += ".ics"; |
3490 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3541 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3491 | storage.save(); | 3542 | storage.save(); |
3492 | } | 3543 | } |
3493 | delete cal; | 3544 | delete cal; |
3494 | mes = i18n("KO/Pi: Ready for beaming"); | 3545 | mes = i18n("KO/Pi: Ready for beaming"); |
3495 | topLevelWidget()->setCaption(mes); | 3546 | topLevelWidget()->setCaption(mes); |
3496 | KApplication::convert2latin1( fn ); | 3547 | KApplication::convert2latin1( fn ); |
3497 | #ifndef DESKTOP_VERSION | 3548 | #ifndef DESKTOP_VERSION |
3498 | Ir *ir = new Ir( this ); | 3549 | Ir *ir = new Ir( this ); |
3499 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3550 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3500 | ir->send( fn, description, "text/x-vCalendar" ); | 3551 | ir->send( fn, description, "text/x-vCalendar" ); |
3501 | #endif | 3552 | #endif |
3502 | } | 3553 | } |
3503 | } | 3554 | } |
3504 | 3555 | ||
3505 | #ifndef DESKTOP_VERSION | 3556 | #ifndef DESKTOP_VERSION |
3506 | void CalendarView::beamDone( Ir *ir ) | 3557 | void CalendarView::beamDone( Ir *ir ) |
3507 | { | 3558 | { |
3508 | delete ir; | 3559 | delete ir; |
3509 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3560 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3510 | topLevelWidget()->raise(); | 3561 | topLevelWidget()->raise(); |
3511 | } | 3562 | } |
3512 | #else | 3563 | #else |
3513 | void CalendarView::beamDone( Ir *){;} | 3564 | void CalendarView::beamDone( Ir *){;} |
3514 | #endif | 3565 | #endif |
3515 | void CalendarView::moveIncidence(Incidence * inc ) | 3566 | void CalendarView::moveIncidence(Incidence * inc ) |
3516 | { | 3567 | { |
3517 | if ( !inc ) return; | 3568 | if ( !inc ) return; |
3518 | showDatePickerPopup(); | 3569 | showDatePickerPopup(); |
3519 | mDatePickerMode = 2; | 3570 | mDatePickerMode = 2; |
3520 | mMoveIncidence = inc ; | 3571 | mMoveIncidence = inc ; |
3521 | QDate da; | 3572 | QDate da; |
3522 | if ( mMoveIncidence->typeID() == todoID ) { | 3573 | if ( mMoveIncidence->typeID() == todoID ) { |
3523 | Todo * to = (Todo *) mMoveIncidence; | 3574 | Todo * to = (Todo *) mMoveIncidence; |
3524 | if ( to->hasDueDate() ) | 3575 | if ( to->hasDueDate() ) |
3525 | da = to->dtDue().date(); | 3576 | da = to->dtDue().date(); |
3526 | else | 3577 | else |
3527 | da = QDate::currentDate(); | 3578 | da = QDate::currentDate(); |
3528 | } else { | 3579 | } else { |
3529 | da = mMoveIncidence->dtStart().date(); | 3580 | da = mMoveIncidence->dtStart().date(); |
3530 | } | 3581 | } |
3531 | //PENDING set date for recurring incidence to date of recurrence | 3582 | //PENDING set date for recurring incidence to date of recurrence |
3532 | //mMoveIncidenceOldDate; | 3583 | //mMoveIncidenceOldDate; |
3533 | mDatePicker->setDate( da ); | 3584 | mDatePicker->setDate( da ); |
3534 | } | 3585 | } |
3535 | void CalendarView::showDatePickerPopup() | 3586 | void CalendarView::showDatePickerPopup() |
3536 | { | 3587 | { |
3537 | if ( mDateFrame->isVisible() ) | 3588 | if ( mDateFrame->isVisible() ) |
3538 | mDateFrame->hide(); | 3589 | mDateFrame->hide(); |
3539 | else { | 3590 | else { |
3540 | int offX = 0, offY = 0; | 3591 | int offX = 0, offY = 0; |
3541 | #ifdef DESKTOP_VERSION | 3592 | #ifdef DESKTOP_VERSION |
3542 | int w =mDatePicker->sizeHint().width() ; | 3593 | int w =mDatePicker->sizeHint().width() ; |
3543 | int h = mDatePicker->sizeHint().height() ; | 3594 | int h = mDatePicker->sizeHint().height() ; |
3544 | int dw = topLevelWidget()->width(); | 3595 | int dw = topLevelWidget()->width(); |
3545 | int dh = topLevelWidget()->height(); | 3596 | int dh = topLevelWidget()->height(); |
3546 | offX = topLevelWidget()->x(); | 3597 | offX = topLevelWidget()->x(); |
3547 | offY = topLevelWidget()->y(); | 3598 | offY = topLevelWidget()->y(); |
3548 | #else | 3599 | #else |
3549 | int w =mDatePicker->sizeHint().width() ; | 3600 | int w =mDatePicker->sizeHint().width() ; |
3550 | int h = mDatePicker->sizeHint().height() ; | 3601 | int h = mDatePicker->sizeHint().height() ; |
3551 | int dw = QApplication::desktop()->width(); | 3602 | int dw = QApplication::desktop()->width(); |
3552 | int dh = QApplication::desktop()->height(); | 3603 | int dh = QApplication::desktop()->height(); |
3553 | #endif | 3604 | #endif |
3554 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3605 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3555 | mDateFrame->show(); | 3606 | mDateFrame->show(); |
3556 | } | 3607 | } |
3557 | } | 3608 | } |
3558 | void CalendarView::showDatePicker( ) | 3609 | void CalendarView::showDatePicker( ) |
3559 | { | 3610 | { |
3560 | showDatePickerPopup(); | 3611 | showDatePickerPopup(); |
3561 | mDatePickerMode = 1; | 3612 | mDatePickerMode = 1; |
3562 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3613 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3563 | } | 3614 | } |
3564 | 3615 | ||
3565 | void CalendarView::showEventEditor() | 3616 | void CalendarView::showEventEditor() |
3566 | { | 3617 | { |
3567 | #ifdef DESKTOP_VERSION | 3618 | #ifdef DESKTOP_VERSION |
3568 | int x,y,w,h; | 3619 | int x,y,w,h; |
3569 | x = mEventEditor->geometry().x(); | 3620 | x = mEventEditor->geometry().x(); |
3570 | y = mEventEditor->geometry().y(); | 3621 | y = mEventEditor->geometry().y(); |
3571 | w = mEventEditor->width(); | 3622 | w = mEventEditor->width(); |
3572 | h = mEventEditor->height(); | 3623 | h = mEventEditor->height(); |
3573 | mEventEditor->show(); | 3624 | mEventEditor->show(); |
3574 | mEventEditor->setGeometry(x,y,w,h); | 3625 | mEventEditor->setGeometry(x,y,w,h); |
3575 | #else | 3626 | #else |
3576 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3627 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3577 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3628 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3578 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3629 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3579 | qApp->processEvents(); | 3630 | qApp->processEvents(); |
3580 | delete mEventEditor; | 3631 | delete mEventEditor; |
3581 | mEventEditor = mDialogManager->getEventEditor(); | 3632 | mEventEditor = mDialogManager->getEventEditor(); |
3582 | topLevelWidget()->setCaption( i18n("") ); | 3633 | topLevelWidget()->setCaption( i18n("") ); |
3583 | } | 3634 | } |
3584 | mEventEditor->showMaximized(); | 3635 | mEventEditor->showMaximized(); |
3585 | #endif | 3636 | #endif |
3586 | } | 3637 | } |
3587 | void CalendarView::showTodoEditor() | 3638 | void CalendarView::showTodoEditor() |
3588 | { | 3639 | { |
3589 | #ifdef DESKTOP_VERSION | 3640 | #ifdef DESKTOP_VERSION |
3590 | int x,y,w,h; | 3641 | int x,y,w,h; |
3591 | x = mTodoEditor->geometry().x(); | 3642 | x = mTodoEditor->geometry().x(); |
3592 | y = mTodoEditor->geometry().y(); | 3643 | y = mTodoEditor->geometry().y(); |
3593 | w = mTodoEditor->width(); | 3644 | w = mTodoEditor->width(); |
3594 | h = mTodoEditor->height(); | 3645 | h = mTodoEditor->height(); |
3595 | mTodoEditor->show(); | 3646 | mTodoEditor->show(); |
3596 | mTodoEditor->setGeometry(x,y,w,h); | 3647 | mTodoEditor->setGeometry(x,y,w,h); |
3597 | #else | 3648 | #else |
3598 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3649 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3599 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3650 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3600 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3651 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3601 | qApp->processEvents(); | 3652 | qApp->processEvents(); |
3602 | delete mTodoEditor; | 3653 | delete mTodoEditor; |
3603 | mTodoEditor = mDialogManager->getTodoEditor(); | 3654 | mTodoEditor = mDialogManager->getTodoEditor(); |
3604 | topLevelWidget()->setCaption( i18n("") ); | 3655 | topLevelWidget()->setCaption( i18n("") ); |
3605 | } | 3656 | } |
3606 | mTodoEditor->showMaximized(); | 3657 | mTodoEditor->showMaximized(); |
3607 | #endif | 3658 | #endif |
3608 | } | 3659 | } |
3609 | 3660 | ||
3610 | void CalendarView::cloneIncidence() | 3661 | void CalendarView::cloneIncidence() |
3611 | { | 3662 | { |
3612 | Incidence *incidence = currentSelection(); | 3663 | Incidence *incidence = currentSelection(); |
3613 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3664 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3614 | if ( incidence ) { | 3665 | if ( incidence ) { |
3615 | cloneIncidence(incidence); | 3666 | cloneIncidence(incidence); |
3616 | } | 3667 | } |
3617 | } | 3668 | } |
3618 | void CalendarView::moveIncidence() | 3669 | void CalendarView::moveIncidence() |
3619 | { | 3670 | { |
3620 | Incidence *incidence = currentSelection(); | 3671 | Incidence *incidence = currentSelection(); |
3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3672 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3622 | if ( incidence ) { | 3673 | if ( incidence ) { |
3623 | moveIncidence(incidence); | 3674 | moveIncidence(incidence); |
3624 | } | 3675 | } |
3625 | } | 3676 | } |
3626 | void CalendarView::beamIncidence() | 3677 | void CalendarView::beamIncidence() |
3627 | { | 3678 | { |
3628 | Incidence *incidence = currentSelection(); | 3679 | Incidence *incidence = currentSelection(); |
3629 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3680 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3630 | if ( incidence ) { | 3681 | if ( incidence ) { |
3631 | beamIncidence(incidence); | 3682 | beamIncidence(incidence); |
3632 | } | 3683 | } |
3633 | } | 3684 | } |
3634 | void CalendarView::toggleCancelIncidence() | 3685 | void CalendarView::toggleCancelIncidence() |
3635 | { | 3686 | { |
3636 | Incidence *incidence = currentSelection(); | 3687 | Incidence *incidence = currentSelection(); |
3637 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3688 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3638 | if ( incidence ) { | 3689 | if ( incidence ) { |
3639 | cancelIncidence(incidence); | 3690 | cancelIncidence(incidence); |
3640 | } | 3691 | } |
3641 | } | 3692 | } |
3642 | 3693 | ||
3643 | 3694 | ||
3644 | void CalendarView::cancelIncidence(Incidence * inc ) | 3695 | void CalendarView::cancelIncidence(Incidence * inc ) |
3645 | { | 3696 | { |
3646 | inc->setCancelled( ! inc->cancelled() ); | 3697 | inc->setCancelled( ! inc->cancelled() ); |
3647 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3698 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3648 | updateView(); | 3699 | updateView(); |
3649 | } | 3700 | } |
3650 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3701 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3651 | { | 3702 | { |
3652 | Incidence * newInc = orgInc->clone(); | 3703 | Incidence * newInc = orgInc->clone(); |
3653 | newInc->recreate(); | 3704 | newInc->recreate(); |
3654 | 3705 | ||
3655 | if ( newInc->typeID() == todoID ) { | 3706 | if ( newInc->typeID() == todoID ) { |
3656 | Todo* t = (Todo*) newInc; | 3707 | Todo* t = (Todo*) newInc; |
3657 | bool cloneSub = false; | 3708 | bool cloneSub = false; |
3658 | if ( orgInc->relations().count() ) { | 3709 | if ( orgInc->relations().count() ) { |
3659 | int result = KMessageBox::warningYesNoCancel(this, | 3710 | int result = KMessageBox::warningYesNoCancel(this, |
3660 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3711 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3661 | i18n("Todo has subtodos"), | 3712 | i18n("Todo has subtodos"), |
3662 | i18n("Yes"), | 3713 | i18n("Yes"), |
3663 | i18n("No")); | 3714 | i18n("No")); |
3664 | 3715 | ||
3665 | if ( result == KMessageBox::Cancel ) { | 3716 | if ( result == KMessageBox::Cancel ) { |
3666 | delete t; | 3717 | delete t; |
3667 | return; | 3718 | return; |
3668 | } | 3719 | } |
3669 | if (result == KMessageBox::Yes) cloneSub = true; | 3720 | if (result == KMessageBox::Yes) cloneSub = true; |
3670 | } | 3721 | } |
3671 | showTodoEditor(); | 3722 | showTodoEditor(); |
3672 | mTodoEditor->editTodo( t ); | 3723 | mTodoEditor->editTodo( t ); |
3673 | if ( mTodoEditor->exec() ) { | 3724 | if ( mTodoEditor->exec() ) { |
3674 | if ( cloneSub ) { | 3725 | if ( cloneSub ) { |
3675 | orgInc->cloneRelations( t ); | 3726 | orgInc->cloneRelations( t ); |
3676 | mCalendar->addIncidenceBranch( t ); | 3727 | mCalendar->addIncidenceBranch( t ); |
3677 | updateView(); | 3728 | updateView(); |
3678 | 3729 | ||
3679 | } else { | 3730 | } else { |
3680 | mCalendar->addTodo( t ); | 3731 | mCalendar->addTodo( t ); |
3681 | updateView(); | 3732 | updateView(); |
3682 | } | 3733 | } |
3683 | } else { | 3734 | } else { |
3684 | delete t; | 3735 | delete t; |
3685 | } | 3736 | } |
3686 | } | 3737 | } |
3687 | else if ( newInc->typeID() == eventID ) { | 3738 | else if ( newInc->typeID() == eventID ) { |
3688 | Event* e = (Event*) newInc; | 3739 | Event* e = (Event*) newInc; |
3689 | showEventEditor(); | 3740 | showEventEditor(); |
3690 | mEventEditor->editEvent( e ); | 3741 | mEventEditor->editEvent( e ); |
3691 | if ( mEventEditor->exec() ) { | 3742 | if ( mEventEditor->exec() ) { |
3692 | mCalendar->addEvent( e ); | 3743 | mCalendar->addEvent( e ); |
3693 | updateView(); | 3744 | updateView(); |
3694 | } else { | 3745 | } else { |
3695 | delete e; | 3746 | delete e; |
3696 | } | 3747 | } |
3697 | } else if ( newInc->typeID() == journalID ) { | 3748 | } else if ( newInc->typeID() == journalID ) { |
3698 | mCalendar->addJournal( (Journal*) newInc ); | 3749 | mCalendar->addJournal( (Journal*) newInc ); |
3699 | editJournal( (Journal*) newInc ); | 3750 | editJournal( (Journal*) newInc ); |
3700 | } | 3751 | } |
3701 | setActiveWindow(); | 3752 | setActiveWindow(); |
3702 | } | 3753 | } |
3703 | 3754 | ||
3704 | void CalendarView::newEvent() | 3755 | void CalendarView::newEvent() |
3705 | { | 3756 | { |
3706 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3757 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3707 | KOAgendaView *aView = mViewManager->agendaView(); | 3758 | KOAgendaView *aView = mViewManager->agendaView(); |
3708 | if (aView) { | 3759 | if (aView) { |
3709 | if (aView->selectionStart().isValid()) { | 3760 | if (aView->selectionStart().isValid()) { |
3710 | if (aView->selectedIsAllDay()) { | 3761 | if (aView->selectedIsAllDay()) { |
3711 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3762 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3712 | } else { | 3763 | } else { |
3713 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3764 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3714 | } | 3765 | } |
3715 | return; | 3766 | return; |
3716 | } | 3767 | } |
3717 | } | 3768 | } |
3718 | 3769 | ||
3719 | QDate date = mNavigator->selectedDates().first(); | 3770 | QDate date = mNavigator->selectedDates().first(); |
3720 | #if 0 | 3771 | #if 0 |
3721 | QDateTime current = QDateTime::currentDateTime(); | 3772 | QDateTime current = QDateTime::currentDateTime(); |
3722 | if ( date <= current.date() ) { | 3773 | if ( date <= current.date() ) { |
3723 | int hour = current.time().hour() +1; | 3774 | int hour = current.time().hour() +1; |
3724 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3775 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3725 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3776 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3726 | } else | 3777 | } else |
3727 | #endif | 3778 | #endif |
3728 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3779 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3729 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3780 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3730 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3781 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3731 | } | 3782 | } |
3732 | 3783 | ||
3733 | void CalendarView::newEvent(QDateTime fh) | 3784 | void CalendarView::newEvent(QDateTime fh) |
3734 | { | 3785 | { |
3735 | newEvent(fh, | 3786 | newEvent(fh, |
3736 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3787 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3737 | } | 3788 | } |
3738 | 3789 | ||
3739 | void CalendarView::newEvent(QDate dt) | 3790 | void CalendarView::newEvent(QDate dt) |
3740 | { | 3791 | { |
3741 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3792 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3742 | QDateTime(dt, QTime(0,0,0)), true); | 3793 | QDateTime(dt, QTime(0,0,0)), true); |
3743 | } | 3794 | } |
3744 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3795 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3745 | { | 3796 | { |
3746 | newEvent(fromHint, toHint, false); | 3797 | newEvent(fromHint, toHint, false); |
3747 | } | 3798 | } |
3748 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3799 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3749 | { | 3800 | { |
3750 | 3801 | ||
3751 | showEventEditor(); | 3802 | showEventEditor(); |
3752 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3803 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3753 | if ( mFilterView->filtersEnabled() ) { | 3804 | if ( mFilterView->filtersEnabled() ) { |
3754 | CalFilter *filter = mFilterView->selectedFilter(); | 3805 | CalFilter *filter = mFilterView->selectedFilter(); |
3755 | if (filter && filter->showCategories()) { | 3806 | if (filter && filter->showCategories()) { |
3756 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3807 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3757 | } | 3808 | } |
3758 | if ( filter ) | 3809 | if ( filter ) |
3759 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3810 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3760 | } | 3811 | } |
3761 | mEventEditor->exec(); | 3812 | mEventEditor->exec(); |
3762 | setActiveWindow(); | 3813 | setActiveWindow(); |
3763 | } | 3814 | } |
3764 | void CalendarView::todoAdded(Todo * t) | 3815 | void CalendarView::todoAdded(Todo * t) |
3765 | { | 3816 | { |
3766 | 3817 | ||
3767 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3818 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3768 | updateTodoViews(); | 3819 | updateTodoViews(); |
3769 | } | 3820 | } |
3770 | void CalendarView::todoChanged(Todo * t) | 3821 | void CalendarView::todoChanged(Todo * t) |
3771 | { | 3822 | { |
3772 | emit todoModified( t, 4 ); | 3823 | emit todoModified( t, 4 ); |
3773 | // updateTodoViews(); | 3824 | // updateTodoViews(); |
3774 | } | 3825 | } |
3775 | void CalendarView::todoToBeDeleted(Todo *) | 3826 | void CalendarView::todoToBeDeleted(Todo *) |
3776 | { | 3827 | { |
3777 | //qDebug("todoToBeDeleted(Todo *) "); | 3828 | //qDebug("todoToBeDeleted(Todo *) "); |
3778 | updateTodoViews(); | 3829 | updateTodoViews(); |
3779 | } | 3830 | } |
3780 | void CalendarView::todoDeleted() | 3831 | void CalendarView::todoDeleted() |
3781 | { | 3832 | { |
3782 | //qDebug(" todoDeleted()"); | 3833 | //qDebug(" todoDeleted()"); |
3783 | updateTodoViews(); | 3834 | updateTodoViews(); |
3784 | } | 3835 | } |
3785 | 3836 | ||
3786 | 3837 | ||
3787 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3838 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3788 | { | 3839 | { |
3789 | showTodoEditor(); | 3840 | showTodoEditor(); |
3790 | mTodoEditor->newTodo(dt,0,allday); | 3841 | mTodoEditor->newTodo(dt,0,allday); |
3791 | if ( mFilterView->filtersEnabled() ) { | 3842 | if ( mFilterView->filtersEnabled() ) { |
3792 | CalFilter *filter = mFilterView->selectedFilter(); | 3843 | CalFilter *filter = mFilterView->selectedFilter(); |
3793 | if (filter && filter->showCategories()) { | 3844 | if (filter && filter->showCategories()) { |
3794 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3845 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3795 | } | 3846 | } |
3796 | if ( filter ) | 3847 | if ( filter ) |
3797 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3848 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3798 | } | 3849 | } |
3799 | mTodoEditor->exec(); | 3850 | mTodoEditor->exec(); |
3800 | setActiveWindow(); | 3851 | setActiveWindow(); |
3801 | } | 3852 | } |
3802 | 3853 | ||
3803 | void CalendarView::newTodo() | 3854 | void CalendarView::newTodo() |
3804 | { | 3855 | { |
3805 | newTodoDateTime( QDateTime(),true ); | 3856 | newTodoDateTime( QDateTime(),true ); |
3806 | } | 3857 | } |
3807 | 3858 | ||
3808 | void CalendarView::newSubTodo() | 3859 | void CalendarView::newSubTodo() |
3809 | { | 3860 | { |
3810 | Todo *todo = selectedTodo(); | 3861 | Todo *todo = selectedTodo(); |
3811 | if ( todo ) newSubTodo( todo ); | 3862 | if ( todo ) newSubTodo( todo ); |
3812 | } | 3863 | } |
3813 | 3864 | ||
3814 | void CalendarView::newSubTodo(Todo *parentEvent) | 3865 | void CalendarView::newSubTodo(Todo *parentEvent) |
3815 | { | 3866 | { |
3816 | 3867 | ||
3817 | showTodoEditor(); | 3868 | showTodoEditor(); |
3818 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3869 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3819 | mTodoEditor->exec(); | 3870 | mTodoEditor->exec(); |
3820 | setActiveWindow(); | 3871 | setActiveWindow(); |
3821 | } | 3872 | } |
3822 | 3873 | ||
3823 | void CalendarView::newFloatingEvent() | 3874 | void CalendarView::newFloatingEvent() |
3824 | { | 3875 | { |
3825 | DateList tmpList = mNavigator->selectedDates(); | 3876 | DateList tmpList = mNavigator->selectedDates(); |
3826 | QDate date = tmpList.first(); | 3877 | QDate date = tmpList.first(); |
3827 | 3878 | ||
3828 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3879 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3829 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3880 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3830 | } | 3881 | } |
3831 | 3882 | ||
3832 | 3883 | ||
3833 | void CalendarView::editEvent( Event *event ) | 3884 | void CalendarView::editEvent( Event *event ) |
3834 | { | 3885 | { |
3835 | 3886 | ||
3836 | if ( !event ) return; | 3887 | if ( !event ) return; |
3837 | if ( event->isReadOnly() ) { | 3888 | if ( event->isReadOnly() ) { |
3838 | showEvent( event ); | 3889 | showEvent( event ); |
3839 | return; | 3890 | return; |
3840 | } | 3891 | } |
3841 | showEventEditor(); | 3892 | showEventEditor(); |
3842 | mEventEditor->editEvent( event , mFlagEditDescription); | 3893 | mEventEditor->editEvent( event , mFlagEditDescription); |
3843 | mEventEditor->exec(); | 3894 | mEventEditor->exec(); |
3844 | setActiveWindow(); | 3895 | setActiveWindow(); |
3845 | 3896 | ||
3846 | } | 3897 | } |
3847 | void CalendarView::editJournal( Journal *jour ) | 3898 | void CalendarView::editJournal( Journal *jour ) |
3848 | { | 3899 | { |
3849 | if ( !jour ) return; | 3900 | if ( !jour ) return; |
3850 | mDialogManager->hideSearchDialog(); | 3901 | mDialogManager->hideSearchDialog(); |
3851 | mViewManager->showJournalView(); | 3902 | mViewManager->showJournalView(); |
3852 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3903 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3853 | } | 3904 | } |
3854 | void CalendarView::editTodo( Todo *todo ) | 3905 | void CalendarView::editTodo( Todo *todo ) |
3855 | { | 3906 | { |
3856 | if ( !todo ) return; | 3907 | if ( !todo ) return; |
3857 | 3908 | ||
3858 | if ( todo->isReadOnly() ) { | 3909 | if ( todo->isReadOnly() ) { |
3859 | showTodo( todo ); | 3910 | showTodo( todo ); |
3860 | return; | 3911 | return; |
3861 | } | 3912 | } |
3862 | showTodoEditor(); | 3913 | showTodoEditor(); |
3863 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3914 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3864 | mTodoEditor->exec(); | 3915 | mTodoEditor->exec(); |
3865 | setActiveWindow(); | 3916 | setActiveWindow(); |
3866 | 3917 | ||
3867 | } | 3918 | } |
3868 | 3919 | ||
3869 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3920 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3870 | { | 3921 | { |
3871 | if ( !mEventViewerDialog ) { | 3922 | if ( !mEventViewerDialog ) { |
3872 | mEventViewerDialog = new KOEventViewerDialog(0); | 3923 | mEventViewerDialog = new KOEventViewerDialog(0); |
3873 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3924 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3874 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3925 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3875 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3926 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3876 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3927 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3877 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3928 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3878 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3929 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3879 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3930 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3880 | this, SLOT( slotViewerClosed() ) ); | 3931 | this, SLOT( slotViewerClosed() ) ); |
3881 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3932 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3882 | this, SLOT( todoChanged(Todo *) ) ); | 3933 | this, SLOT( todoChanged(Todo *) ) ); |
3883 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3934 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3884 | mEventViewerDialog->resize( 640, 480 ); | 3935 | mEventViewerDialog->resize( 640, 480 ); |
3885 | 3936 | ||
3886 | } | 3937 | } |
3887 | return mEventViewerDialog; | 3938 | return mEventViewerDialog; |
3888 | } | 3939 | } |
3889 | void CalendarView::showEvent(Event *event) | 3940 | void CalendarView::showEvent(Event *event) |
3890 | { | 3941 | { |
3891 | getEventViewerDialog()->setEvent(event); | 3942 | getEventViewerDialog()->setEvent(event); |
3892 | getEventViewerDialog()->showMe(); | 3943 | getEventViewerDialog()->showMe(); |
3893 | } | 3944 | } |
3894 | 3945 | ||
3895 | void CalendarView::showTodo(Todo *event) | 3946 | void CalendarView::showTodo(Todo *event) |
3896 | { | 3947 | { |
3897 | getEventViewerDialog()->setTodo(event); | 3948 | getEventViewerDialog()->setTodo(event); |
3898 | getEventViewerDialog()->showMe(); | 3949 | getEventViewerDialog()->showMe(); |
3899 | } | 3950 | } |
3900 | void CalendarView::showJournal( Journal *jour ) | 3951 | void CalendarView::showJournal( Journal *jour ) |
3901 | { | 3952 | { |
3902 | getEventViewerDialog()->setJournal(jour); | 3953 | getEventViewerDialog()->setJournal(jour); |
3903 | getEventViewerDialog()->showMe(); | 3954 | getEventViewerDialog()->showMe(); |
3904 | 3955 | ||
3905 | } | 3956 | } |
3906 | // void CalendarView::todoModified (Todo *event, int changed) | 3957 | // void CalendarView::todoModified (Todo *event, int changed) |
3907 | // { | 3958 | // { |
3908 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3959 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3909 | // // kdDebug() << "Todo modified and open" << endl; | 3960 | // // kdDebug() << "Todo modified and open" << endl; |
3910 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3961 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3911 | // // temp->modified (changed); | 3962 | // // temp->modified (changed); |
3912 | 3963 | ||
3913 | // // } | 3964 | // // } |
3914 | 3965 | ||
3915 | // mViewManager->updateView(); | 3966 | // mViewManager->updateView(); |
3916 | // } | 3967 | // } |
3917 | 3968 | ||
3918 | void CalendarView::appointment_show() | 3969 | void CalendarView::appointment_show() |
3919 | { | 3970 | { |
3920 | Event *anEvent = 0; | 3971 | Event *anEvent = 0; |
3921 | 3972 | ||
3922 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3973 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3923 | 3974 | ||
3924 | if (mViewManager->currentView()->isEventView()) { | 3975 | if (mViewManager->currentView()->isEventView()) { |
3925 | if ( incidence && incidence->typeID() == eventID ) { | 3976 | if ( incidence && incidence->typeID() == eventID ) { |
3926 | anEvent = static_cast<Event *>(incidence); | 3977 | anEvent = static_cast<Event *>(incidence); |
3927 | } | 3978 | } |
3928 | } | 3979 | } |
3929 | 3980 | ||
3930 | if (!anEvent) { | 3981 | if (!anEvent) { |
3931 | KNotifyClient::beep(); | 3982 | KNotifyClient::beep(); |
3932 | return; | 3983 | return; |
3933 | } | 3984 | } |
3934 | 3985 | ||
3935 | showEvent(anEvent); | 3986 | showEvent(anEvent); |
3936 | } | 3987 | } |
3937 | 3988 | ||
3938 | void CalendarView::appointment_edit() | 3989 | void CalendarView::appointment_edit() |
3939 | { | 3990 | { |
3940 | Event *anEvent = 0; | 3991 | Event *anEvent = 0; |
3941 | 3992 | ||
3942 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3993 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3943 | 3994 | ||
3944 | if (mViewManager->currentView()->isEventView()) { | 3995 | if (mViewManager->currentView()->isEventView()) { |
3945 | if ( incidence && incidence->typeID() == eventID ) { | 3996 | if ( incidence && incidence->typeID() == eventID ) { |
3946 | anEvent = static_cast<Event *>(incidence); | 3997 | anEvent = static_cast<Event *>(incidence); |
3947 | } | 3998 | } |
3948 | } | 3999 | } |
3949 | 4000 | ||
3950 | if (!anEvent) { | 4001 | if (!anEvent) { |
3951 | KNotifyClient::beep(); | 4002 | KNotifyClient::beep(); |
3952 | return; | 4003 | return; |
3953 | } | 4004 | } |
3954 | 4005 | ||
3955 | editEvent(anEvent); | 4006 | editEvent(anEvent); |
3956 | } | 4007 | } |
3957 | 4008 | ||
3958 | void CalendarView::appointment_delete() | 4009 | void CalendarView::appointment_delete() |
3959 | { | 4010 | { |
3960 | Event *anEvent = 0; | 4011 | Event *anEvent = 0; |
3961 | 4012 | ||
3962 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 4013 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3963 | 4014 | ||
3964 | if (mViewManager->currentView()->isEventView()) { | 4015 | if (mViewManager->currentView()->isEventView()) { |
3965 | if ( incidence && incidence->typeID() == eventID ) { | 4016 | if ( incidence && incidence->typeID() == eventID ) { |
3966 | anEvent = static_cast<Event *>(incidence); | 4017 | anEvent = static_cast<Event *>(incidence); |
3967 | } | 4018 | } |
3968 | } | 4019 | } |
3969 | 4020 | ||
3970 | if (!anEvent) { | 4021 | if (!anEvent) { |
3971 | KNotifyClient::beep(); | 4022 | KNotifyClient::beep(); |
3972 | return; | 4023 | return; |
3973 | } | 4024 | } |
3974 | 4025 | ||
3975 | deleteEvent(anEvent); | 4026 | deleteEvent(anEvent); |
3976 | } | 4027 | } |
3977 | 4028 | ||
3978 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 4029 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3979 | { | 4030 | { |
3980 | if (!sub) return; | 4031 | if (!sub) return; |
3981 | if ( sub->relatedTo() == parent ) | 4032 | if ( sub->relatedTo() == parent ) |
3982 | return; | 4033 | return; |
3983 | sub->setRelatedTo(parent); | 4034 | sub->setRelatedTo(parent); |
3984 | sub->updated(); | 4035 | sub->updated(); |
3985 | setModified(true); | 4036 | setModified(true); |
3986 | updateView(); | 4037 | updateView(); |
3987 | } | 4038 | } |
3988 | void CalendarView::todo_unsub(Todo *anTodo ) | 4039 | void CalendarView::todo_unsub(Todo *anTodo ) |
3989 | { | 4040 | { |
3990 | todo_resub( 0, anTodo ); | 4041 | todo_resub( 0, anTodo ); |
3991 | } | 4042 | } |
3992 | 4043 | ||
3993 | void CalendarView::deleteTodo(Todo *todo) | 4044 | void CalendarView::deleteTodo(Todo *todo) |
3994 | { | 4045 | { |
3995 | if (!todo) { | 4046 | if (!todo) { |
3996 | KNotifyClient::beep(); | 4047 | KNotifyClient::beep(); |
3997 | return; | 4048 | return; |
3998 | } | 4049 | } |
3999 | if (KOPrefs::instance()->mConfirm) { | 4050 | if (KOPrefs::instance()->mConfirm) { |
4000 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 4051 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
4001 | if (!todo->relations().isEmpty()) { | 4052 | if (!todo->relations().isEmpty()) { |
4002 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 4053 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
4003 | 4054 | ||
4004 | } | 4055 | } |
4005 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 4056 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
4006 | case KMessageBox::Continue: // OK | 4057 | case KMessageBox::Continue: // OK |
4007 | bool deleteT = false; | 4058 | bool deleteT = false; |
4008 | if (!todo->relations().isEmpty()) { | 4059 | if (!todo->relations().isEmpty()) { |
4009 | deleteT = removeCompletedSubTodos( todo ); | 4060 | deleteT = removeCompletedSubTodos( todo ); |
4010 | } | 4061 | } |
4011 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 4062 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
4012 | if ( !deleteT ) { | 4063 | if ( !deleteT ) { |
4013 | checkExternalId( todo ); | 4064 | checkExternalId( todo ); |
4014 | calendar()->deleteTodo(todo); | 4065 | calendar()->deleteTodo(todo); |
4015 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4066 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4016 | } | 4067 | } |
4017 | updateView(); | 4068 | updateView(); |
4018 | break; | 4069 | break; |
4019 | } // switch | 4070 | } // switch |
4020 | } else { | 4071 | } else { |
4021 | checkExternalId( todo ); | 4072 | checkExternalId( todo ); |
4022 | mCalendar->deleteTodo(todo); | 4073 | mCalendar->deleteTodo(todo); |
4023 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4074 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4024 | updateView(); | 4075 | updateView(); |
4025 | } | 4076 | } |
4026 | 4077 | ||
4027 | emit updateSearchDialog(); | 4078 | emit updateSearchDialog(); |
4028 | } | 4079 | } |
4029 | void CalendarView::deleteJournal(Journal *jour) | 4080 | void CalendarView::deleteJournal(Journal *jour) |
4030 | { | 4081 | { |
4031 | if (!jour) { | 4082 | if (!jour) { |
4032 | KNotifyClient::beep(); | 4083 | KNotifyClient::beep(); |
4033 | return; | 4084 | return; |
4034 | } | 4085 | } |
4035 | if (KOPrefs::instance()->mConfirm) { | 4086 | if (KOPrefs::instance()->mConfirm) { |
4036 | 4087 | ||
4037 | QString des; | 4088 | QString des; |
4038 | if ( !jour->summary().isEmpty() ) { | 4089 | if ( !jour->summary().isEmpty() ) { |
4039 | des = jour->summary(); | 4090 | des = jour->summary(); |
4040 | } else { | 4091 | } else { |
4041 | des = jour->description().left(30); | 4092 | des = jour->description().left(30); |
4042 | des = des.simplifyWhiteSpace (); | 4093 | des = des.simplifyWhiteSpace (); |
4043 | des.replace (QRegExp ("\\n"),"" ); | 4094 | des.replace (QRegExp ("\\n"),"" ); |
4044 | des.replace (QRegExp ("\\r"),"" ); | 4095 | des.replace (QRegExp ("\\r"),"" ); |
4045 | } | 4096 | } |
4046 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4097 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4047 | case KMessageBox::Continue: // OK | 4098 | case KMessageBox::Continue: // OK |
4048 | calendar()->deleteJournal(jour); | 4099 | calendar()->deleteJournal(jour); |
4049 | updateView(); | 4100 | updateView(); |
4050 | break; | 4101 | break; |
4051 | } // switch | 4102 | } // switch |
4052 | } else { | 4103 | } else { |
4053 | calendar()->deleteJournal(jour);; | 4104 | calendar()->deleteJournal(jour);; |
4054 | updateView(); | 4105 | updateView(); |
4055 | } | 4106 | } |
4056 | emit updateSearchDialog(); | 4107 | emit updateSearchDialog(); |
4057 | } | 4108 | } |
4058 | 4109 | ||
4059 | void CalendarView::deleteEvent(Event *anEvent) | 4110 | void CalendarView::deleteEvent(Event *anEvent) |
4060 | { | 4111 | { |
4061 | if (!anEvent) { | 4112 | if (!anEvent) { |
4062 | KNotifyClient::beep(); | 4113 | KNotifyClient::beep(); |
4063 | return; | 4114 | return; |
4064 | } | 4115 | } |
4065 | 4116 | ||
4066 | if (anEvent->doesRecur()) { | 4117 | if (anEvent->doesRecur()) { |
4067 | QDate itemDate = mViewManager->currentSelectionDate(); | 4118 | QDate itemDate = mViewManager->currentSelectionDate(); |
4068 | int km; | 4119 | int km; |
4069 | if (!itemDate.isValid()) { | 4120 | if (!itemDate.isValid()) { |
4070 | //kdDebug() << "Date Not Valid" << endl; | 4121 | //kdDebug() << "Date Not Valid" << endl; |
4071 | if (KOPrefs::instance()->mConfirm) { | 4122 | if (KOPrefs::instance()->mConfirm) { |
4072 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4123 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4073 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4124 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4074 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4125 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4075 | if ( km == KMessageBox::Continue ) | 4126 | if ( km == KMessageBox::Continue ) |
4076 | km = KMessageBox::No; // No = all below | 4127 | km = KMessageBox::No; // No = all below |
4077 | } else | 4128 | } else |
4078 | km = KMessageBox::No; | 4129 | km = KMessageBox::No; |
4079 | } else { | 4130 | } else { |
4080 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4131 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4081 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4132 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4082 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4133 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4083 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4134 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4084 | i18n("All")); | 4135 | i18n("All")); |
4085 | } | 4136 | } |
4086 | switch(km) { | 4137 | switch(km) { |
4087 | 4138 | ||
4088 | case KMessageBox::No: // Continue // all | 4139 | case KMessageBox::No: // Continue // all |
4089 | //qDebug("KMessageBox::No "); | 4140 | //qDebug("KMessageBox::No "); |
4090 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4141 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4091 | schedule(Scheduler::Cancel,anEvent); | 4142 | schedule(Scheduler::Cancel,anEvent); |
4092 | 4143 | ||
4093 | checkExternalId( anEvent); | 4144 | checkExternalId( anEvent); |
4094 | mCalendar->deleteEvent(anEvent); | 4145 | mCalendar->deleteEvent(anEvent); |
4095 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4146 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4096 | break; | 4147 | break; |
4097 | 4148 | ||
4098 | // Disabled because it does not work | 4149 | // Disabled because it does not work |
4099 | //#if 0 | 4150 | //#if 0 |
4100 | case KMessageBox::Yes: // just this one | 4151 | case KMessageBox::Yes: // just this one |
4101 | //QDate qd = mNavigator->selectedDates().first(); | 4152 | //QDate qd = mNavigator->selectedDates().first(); |
4102 | //if (!qd.isValid()) { | 4153 | //if (!qd.isValid()) { |
4103 | // kdDebug() << "no date selected, or invalid date" << endl; | 4154 | // kdDebug() << "no date selected, or invalid date" << endl; |
4104 | // KNotifyClient::beep(); | 4155 | // KNotifyClient::beep(); |
4105 | // return; | 4156 | // return; |
4106 | //} | 4157 | //} |
4107 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4158 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4108 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4159 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4109 | anEvent->addExDate(itemDate); | 4160 | anEvent->addExDate(itemDate); |
4110 | int duration = anEvent->recurrence()->duration(); | 4161 | int duration = anEvent->recurrence()->duration(); |
4111 | if ( duration > 0 ) { | 4162 | if ( duration > 0 ) { |
4112 | anEvent->recurrence()->setDuration( duration - 1 ); | 4163 | anEvent->recurrence()->setDuration( duration - 1 ); |
4113 | } | 4164 | } |
4114 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4165 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4115 | } | 4166 | } |
4116 | break; | 4167 | break; |
4117 | //#endif | 4168 | //#endif |
4118 | } // switch | 4169 | } // switch |
4119 | } else { | 4170 | } else { |
4120 | if (KOPrefs::instance()->mConfirm) { | 4171 | if (KOPrefs::instance()->mConfirm) { |
4121 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4172 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4122 | i18n("\nAre you sure you want\nto delete this event?"), | 4173 | i18n("\nAre you sure you want\nto delete this event?"), |
4123 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4174 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4124 | case KMessageBox::Continue: // OK | 4175 | case KMessageBox::Continue: // OK |
4125 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4176 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4126 | schedule(Scheduler::Cancel,anEvent); | 4177 | schedule(Scheduler::Cancel,anEvent); |
4127 | checkExternalId( anEvent); | 4178 | checkExternalId( anEvent); |
4128 | mCalendar->deleteEvent(anEvent); | 4179 | mCalendar->deleteEvent(anEvent); |
4129 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4180 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4130 | break; | 4181 | break; |
4131 | } // switch | 4182 | } // switch |
4132 | } else { | 4183 | } else { |
4133 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4184 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4134 | schedule(Scheduler::Cancel,anEvent); | 4185 | schedule(Scheduler::Cancel,anEvent); |
4135 | checkExternalId( anEvent); | 4186 | checkExternalId( anEvent); |
4136 | mCalendar->deleteEvent(anEvent); | 4187 | mCalendar->deleteEvent(anEvent); |
4137 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4188 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4138 | } | 4189 | } |
4139 | } // if-else | 4190 | } // if-else |
4140 | emit updateSearchDialog(); | 4191 | emit updateSearchDialog(); |
4141 | } | 4192 | } |
4142 | 4193 | ||
4143 | bool CalendarView::deleteEvent(const QString &uid) | 4194 | bool CalendarView::deleteEvent(const QString &uid) |
4144 | { | 4195 | { |
4145 | Event *ev = mCalendar->event(uid); | 4196 | Event *ev = mCalendar->event(uid); |
4146 | if (ev) { | 4197 | if (ev) { |
4147 | deleteEvent(ev); | 4198 | deleteEvent(ev); |
4148 | return true; | 4199 | return true; |
4149 | } else { | 4200 | } else { |
4150 | return false; | 4201 | return false; |
4151 | } | 4202 | } |
4152 | } | 4203 | } |
4153 | 4204 | ||
4154 | /*****************************************************************************/ | 4205 | /*****************************************************************************/ |
4155 | 4206 | ||
4156 | void CalendarView::action_mail() | 4207 | void CalendarView::action_mail() |
4157 | { | 4208 | { |
4158 | #ifndef KORG_NOMAIL | 4209 | #ifndef KORG_NOMAIL |
4159 | KOMailClient mailClient; | 4210 | KOMailClient mailClient; |
4160 | 4211 | ||
4161 | Incidence *incidence = currentSelection(); | 4212 | Incidence *incidence = currentSelection(); |
4162 | 4213 | ||
4163 | if (!incidence) { | 4214 | if (!incidence) { |
4164 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4215 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4165 | return; | 4216 | return; |
4166 | } | 4217 | } |
4167 | if(incidence->attendeeCount() == 0 ) { | 4218 | if(incidence->attendeeCount() == 0 ) { |
4168 | KMessageBox::sorry(this, | 4219 | KMessageBox::sorry(this, |
4169 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4220 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4170 | return; | 4221 | return; |
4171 | } | 4222 | } |
4172 | 4223 | ||
4173 | CalendarLocal cal_tmp; | 4224 | CalendarLocal cal_tmp; |
4174 | Event *event = 0; | 4225 | Event *event = 0; |
4175 | Event *ev = 0; | 4226 | Event *ev = 0; |
4176 | if ( incidence && incidence->typeID() == eventID ) { | 4227 | if ( incidence && incidence->typeID() == eventID ) { |
4177 | event = static_cast<Event *>(incidence); | 4228 | event = static_cast<Event *>(incidence); |
4178 | ev = new Event(*event); | 4229 | ev = new Event(*event); |
4179 | cal_tmp.addEvent(ev); | 4230 | cal_tmp.addEvent(ev); |
4180 | } | 4231 | } |
4181 | ICalFormat mForm(); | 4232 | ICalFormat mForm(); |
4182 | QString attachment = mForm.toString( &cal_tmp ); | 4233 | QString attachment = mForm.toString( &cal_tmp ); |
4183 | if (ev) delete(ev); | 4234 | if (ev) delete(ev); |
4184 | 4235 | ||
4185 | mailClient.mailAttendees(currentSelection(), attachment); | 4236 | mailClient.mailAttendees(currentSelection(), attachment); |
4186 | 4237 | ||
4187 | #endif | 4238 | #endif |
4188 | 4239 | ||
4189 | #if 0 | 4240 | #if 0 |
4190 | Event *anEvent = 0; | 4241 | Event *anEvent = 0; |
4191 | if (mViewManager->currentView()->isEventView()) { | 4242 | if (mViewManager->currentView()->isEventView()) { |
4192 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4243 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4193 | } | 4244 | } |
4194 | 4245 | ||
4195 | if (!anEvent) { | 4246 | if (!anEvent) { |
4196 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4247 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4197 | return; | 4248 | return; |
4198 | } | 4249 | } |
4199 | if(anEvent->attendeeCount() == 0 ) { | 4250 | if(anEvent->attendeeCount() == 0 ) { |
4200 | KMessageBox::sorry(this, | 4251 | KMessageBox::sorry(this, |
4201 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4252 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4202 | return; | 4253 | return; |
4203 | } | 4254 | } |
4204 | 4255 | ||
4205 | mailobject.emailEvent(anEvent); | 4256 | mailobject.emailEvent(anEvent); |
4206 | #endif | 4257 | #endif |
4207 | } | 4258 | } |
4208 | 4259 | ||
4209 | 4260 | ||
4210 | void CalendarView::schedule_publish(Incidence *incidence) | 4261 | void CalendarView::schedule_publish(Incidence *incidence) |
4211 | { | 4262 | { |
4212 | Event *event = 0; | 4263 | Event *event = 0; |
4213 | Todo *todo = 0; | 4264 | Todo *todo = 0; |
4214 | 4265 | ||
4215 | if (incidence == 0) { | 4266 | if (incidence == 0) { |
4216 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4267 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4217 | if (incidence == 0) { | 4268 | if (incidence == 0) { |
4218 | incidence = mTodoList->selectedIncidences().first(); | 4269 | incidence = mTodoList->selectedIncidences().first(); |
4219 | } | 4270 | } |
4220 | } | 4271 | } |
4221 | if ( incidence && incidence->typeID() == eventID ) { | 4272 | if ( incidence && incidence->typeID() == eventID ) { |
4222 | event = static_cast<Event *>(incidence); | 4273 | event = static_cast<Event *>(incidence); |
4223 | } else { | 4274 | } else { |
4224 | if ( incidence && incidence->typeID() == todoID ) { | 4275 | if ( incidence && incidence->typeID() == todoID ) { |
4225 | todo = static_cast<Todo *>(incidence); | 4276 | todo = static_cast<Todo *>(incidence); |
4226 | } | 4277 | } |
4227 | } | 4278 | } |
4228 | 4279 | ||
4229 | if (!event && !todo) { | 4280 | if (!event && !todo) { |
4230 | KMessageBox::sorry(this,i18n("No event selected.")); | 4281 | KMessageBox::sorry(this,i18n("No event selected.")); |
4231 | return; | 4282 | return; |
4232 | } | 4283 | } |
4233 | 4284 | ||
4234 | PublishDialog *publishdlg = new PublishDialog(); | 4285 | PublishDialog *publishdlg = new PublishDialog(); |
4235 | if (incidence->attendeeCount()>0) { | 4286 | if (incidence->attendeeCount()>0) { |
4236 | QPtrList<Attendee> attendees = incidence->attendees(); | 4287 | QPtrList<Attendee> attendees = incidence->attendees(); |
4237 | attendees.first(); | 4288 | attendees.first(); |
4238 | while ( attendees.current()!=0 ) { | 4289 | while ( attendees.current()!=0 ) { |
4239 | publishdlg->addAttendee(attendees.current()); | 4290 | publishdlg->addAttendee(attendees.current()); |
4240 | attendees.next(); | 4291 | attendees.next(); |
4241 | } | 4292 | } |
4242 | } | 4293 | } |
4243 | bool send = true; | 4294 | bool send = true; |
4244 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4295 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4245 | if ( publishdlg->exec() != QDialog::Accepted ) | 4296 | if ( publishdlg->exec() != QDialog::Accepted ) |
4246 | send = false; | 4297 | send = false; |
4247 | } | 4298 | } |
4248 | if ( send ) { | 4299 | if ( send ) { |
4249 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4300 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4250 | if ( event ) { | 4301 | if ( event ) { |
4251 | Event *ev = new Event(*event); | 4302 | Event *ev = new Event(*event); |
4252 | ev->registerObserver(0); | 4303 | ev->registerObserver(0); |
4253 | ev->clearAttendees(); | 4304 | ev->clearAttendees(); |
4254 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4305 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4255 | delete(ev); | 4306 | delete(ev); |
4256 | } | 4307 | } |
4257 | } else { | 4308 | } else { |
4258 | if ( todo ) { | 4309 | if ( todo ) { |
4259 | Todo *ev = new Todo(*todo); | 4310 | Todo *ev = new Todo(*todo); |
4260 | ev->registerObserver(0); | 4311 | ev->registerObserver(0); |
4261 | ev->clearAttendees(); | 4312 | ev->clearAttendees(); |
4262 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4313 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4263 | delete(ev); | 4314 | delete(ev); |
4264 | } | 4315 | } |
4265 | } | 4316 | } |
4266 | } | 4317 | } |
4267 | } | 4318 | } |
4268 | delete publishdlg; | 4319 | delete publishdlg; |
4269 | } | 4320 | } |
4270 | 4321 | ||
4271 | void CalendarView::schedule_request(Incidence *incidence) | 4322 | void CalendarView::schedule_request(Incidence *incidence) |
4272 | { | 4323 | { |
4273 | schedule(Scheduler::Request,incidence); | 4324 | schedule(Scheduler::Request,incidence); |
4274 | } | 4325 | } |
4275 | 4326 | ||
4276 | void CalendarView::schedule_refresh(Incidence *incidence) | 4327 | void CalendarView::schedule_refresh(Incidence *incidence) |
4277 | { | 4328 | { |
4278 | schedule(Scheduler::Refresh,incidence); | 4329 | schedule(Scheduler::Refresh,incidence); |
4279 | } | 4330 | } |
4280 | 4331 | ||
4281 | void CalendarView::schedule_cancel(Incidence *incidence) | 4332 | void CalendarView::schedule_cancel(Incidence *incidence) |
4282 | { | 4333 | { |
4283 | schedule(Scheduler::Cancel,incidence); | 4334 | schedule(Scheduler::Cancel,incidence); |
4284 | } | 4335 | } |
4285 | 4336 | ||
4286 | void CalendarView::schedule_add(Incidence *incidence) | 4337 | void CalendarView::schedule_add(Incidence *incidence) |
4287 | { | 4338 | { |
4288 | schedule(Scheduler::Add,incidence); | 4339 | schedule(Scheduler::Add,incidence); |
4289 | } | 4340 | } |
4290 | 4341 | ||
4291 | void CalendarView::schedule_reply(Incidence *incidence) | 4342 | void CalendarView::schedule_reply(Incidence *incidence) |
4292 | { | 4343 | { |
4293 | schedule(Scheduler::Reply,incidence); | 4344 | schedule(Scheduler::Reply,incidence); |
4294 | } | 4345 | } |
4295 | 4346 | ||
4296 | void CalendarView::schedule_counter(Incidence *incidence) | 4347 | void CalendarView::schedule_counter(Incidence *incidence) |
4297 | { | 4348 | { |
4298 | schedule(Scheduler::Counter,incidence); | 4349 | schedule(Scheduler::Counter,incidence); |
4299 | } | 4350 | } |
4300 | 4351 | ||
4301 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4352 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4302 | { | 4353 | { |
4303 | schedule(Scheduler::Declinecounter,incidence); | 4354 | schedule(Scheduler::Declinecounter,incidence); |
4304 | } | 4355 | } |
4305 | 4356 | ||
4306 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4357 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4307 | { | 4358 | { |
4308 | QDateTime start = QDateTime::currentDateTime(); | 4359 | QDateTime start = QDateTime::currentDateTime(); |
4309 | QDateTime end = start.addDays(daysToPublish); | 4360 | QDateTime end = start.addDays(daysToPublish); |
4310 | 4361 | ||
4311 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4362 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4312 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4363 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4313 | 4364 | ||
4314 | 4365 | ||
4315 | PublishDialog *publishdlg = new PublishDialog(); | 4366 | PublishDialog *publishdlg = new PublishDialog(); |
4316 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4367 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4317 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4368 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4318 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4369 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4319 | delete(freebusy); | 4370 | delete(freebusy); |
4320 | } | 4371 | } |
4321 | } | 4372 | } |
4322 | delete publishdlg; | 4373 | delete publishdlg; |
4323 | } | 4374 | } |
4324 | 4375 | ||
4325 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4376 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4326 | { | 4377 | { |
4327 | Event *event = 0; | 4378 | Event *event = 0; |
4328 | Todo *todo = 0; | 4379 | Todo *todo = 0; |
4329 | 4380 | ||
4330 | if (incidence == 0) { | 4381 | if (incidence == 0) { |
4331 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4382 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4332 | if (incidence == 0) { | 4383 | if (incidence == 0) { |
4333 | incidence = mTodoList->selectedIncidences().first(); | 4384 | incidence = mTodoList->selectedIncidences().first(); |
4334 | } | 4385 | } |
4335 | } | 4386 | } |
4336 | if ( incidence && incidence->typeID() == eventID ) { | 4387 | if ( incidence && incidence->typeID() == eventID ) { |
4337 | event = static_cast<Event *>(incidence); | 4388 | event = static_cast<Event *>(incidence); |
4338 | } | 4389 | } |
4339 | if ( incidence && incidence->typeID() == todoID ) { | 4390 | if ( incidence && incidence->typeID() == todoID ) { |
4340 | todo = static_cast<Todo *>(incidence); | 4391 | todo = static_cast<Todo *>(incidence); |
4341 | } | 4392 | } |
4342 | 4393 | ||
4343 | if (!event && !todo) { | 4394 | if (!event && !todo) { |
4344 | KMessageBox::sorry(this,i18n("No event selected.")); | 4395 | KMessageBox::sorry(this,i18n("No event selected.")); |
4345 | return; | 4396 | return; |
4346 | } | 4397 | } |
4347 | 4398 | ||
4348 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4399 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4349 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4400 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4350 | return; | 4401 | return; |
4351 | } | 4402 | } |
4352 | 4403 | ||
4353 | Event *ev = 0; | 4404 | Event *ev = 0; |
4354 | if (event) ev = new Event(*event); | 4405 | if (event) ev = new Event(*event); |
4355 | Todo *to = 0; | 4406 | Todo *to = 0; |
4356 | if (todo) to = new Todo(*todo); | 4407 | if (todo) to = new Todo(*todo); |
4357 | 4408 | ||
4358 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4409 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4359 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4410 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4360 | if (!me) { | 4411 | if (!me) { |
4361 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4412 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4362 | return; | 4413 | return; |
4363 | } | 4414 | } |
4364 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4415 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4365 | StatusDialog *statdlg = new StatusDialog(this); | 4416 | StatusDialog *statdlg = new StatusDialog(this); |
4366 | if (!statdlg->exec()==QDialog::Accepted) return; | 4417 | if (!statdlg->exec()==QDialog::Accepted) return; |
4367 | me->setStatus( statdlg->status() ); | 4418 | me->setStatus( statdlg->status() ); |
4368 | delete(statdlg); | 4419 | delete(statdlg); |
4369 | } | 4420 | } |
4370 | Attendee *menew = new Attendee(*me); | 4421 | Attendee *menew = new Attendee(*me); |
4371 | if (ev) { | 4422 | if (ev) { |
4372 | ev->clearAttendees(); | 4423 | ev->clearAttendees(); |
4373 | ev->addAttendee(menew,false); | 4424 | ev->addAttendee(menew,false); |
4374 | } else { | 4425 | } else { |
4375 | if (to) { | 4426 | if (to) { |
4376 | todo->clearAttendees(); | 4427 | todo->clearAttendees(); |
4377 | todo->addAttendee(menew,false); | 4428 | todo->addAttendee(menew,false); |
4378 | } | 4429 | } |
4379 | } | 4430 | } |
4380 | } | 4431 | } |
4381 | 4432 | ||
4382 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4433 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4383 | if (ev) { | 4434 | if (ev) { |
4384 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4435 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4385 | } else { | 4436 | } else { |
4386 | if (to) { | 4437 | if (to) { |
4387 | if ( !dlg->addMessage(to,method) ) delete(to); | 4438 | if ( !dlg->addMessage(to,method) ) delete(to); |
4388 | } | 4439 | } |
4389 | } | 4440 | } |
4390 | } | 4441 | } |
4391 | 4442 | ||
4392 | void CalendarView::openAddressbook() | 4443 | void CalendarView::openAddressbook() |
4393 | { | 4444 | { |
4394 | KRun::runCommand("kaddressbook"); | 4445 | KRun::runCommand("kaddressbook"); |
4395 | } | 4446 | } |
4396 | 4447 | ||
4397 | void CalendarView::setModified(bool modified) | 4448 | void CalendarView::setModified(bool modified) |
4398 | { | 4449 | { |
4399 | //qDebug("CalendarView::setModified %d ", modified); | 4450 | //qDebug("CalendarView::setModified %d ", modified); |
4400 | if ( modified ) | 4451 | if ( modified ) |
4401 | emit signalmodified(); | 4452 | emit signalmodified(); |
4402 | mModified = modified; | 4453 | mModified = modified; |
4403 | if ( mModified ) | 4454 | if ( mModified ) |
4404 | emit modifiedChanged(mModified); | 4455 | emit modifiedChanged(mModified); |
4405 | 4456 | ||
4406 | } | 4457 | } |
4407 | 4458 | ||
4408 | bool CalendarView::isReadOnly() | 4459 | bool CalendarView::isReadOnly() |
4409 | { | 4460 | { |
4410 | return mReadOnly; | 4461 | return mReadOnly; |
4411 | } | 4462 | } |
4412 | 4463 | ||
4413 | void CalendarView::setReadOnly(bool readOnly) | 4464 | void CalendarView::setReadOnly(bool readOnly) |
4414 | { | 4465 | { |
4415 | if (mReadOnly != readOnly) { | 4466 | if (mReadOnly != readOnly) { |
4416 | mReadOnly = readOnly; | 4467 | mReadOnly = readOnly; |
4417 | emit readOnlyChanged(mReadOnly); | 4468 | emit readOnlyChanged(mReadOnly); |
4418 | } | 4469 | } |
4419 | } | 4470 | } |
4420 | 4471 | ||
4421 | bool CalendarView::isModified() | 4472 | bool CalendarView::isModified() |
4422 | { | 4473 | { |
4423 | return mModified; | 4474 | return mModified; |
4424 | } | 4475 | } |
4425 | void CalendarView::slotprintSelInc() | 4476 | void CalendarView::slotprintSelInc() |
4426 | { | 4477 | { |
4427 | if ( currentSelection() == 0 ) { | 4478 | if ( currentSelection() == 0 ) { |
4428 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4479 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4429 | return; | 4480 | return; |
4430 | } | 4481 | } |
4431 | showIncidence(); | 4482 | showIncidence(); |
4432 | getEventViewerDialog()->print(); | 4483 | getEventViewerDialog()->print(); |
4433 | 4484 | ||
4434 | } | 4485 | } |
4435 | void CalendarView::printSetup() | 4486 | void CalendarView::printSetup() |
4436 | { | 4487 | { |
4437 | #ifndef KORG_NOPRINTER | 4488 | #ifndef KORG_NOPRINTER |
4438 | createPrinter(); | 4489 | createPrinter(); |
4439 | 4490 | ||
4440 | mCalPrinter->setupPrinter(); | 4491 | mCalPrinter->setupPrinter(); |
4441 | #endif | 4492 | #endif |
4442 | } | 4493 | } |
4443 | 4494 | ||
4444 | void CalendarView::print() | 4495 | void CalendarView::print() |
4445 | { | 4496 | { |
4446 | #ifndef KORG_NOPRINTER | 4497 | #ifndef KORG_NOPRINTER |
4447 | createPrinter(); | 4498 | createPrinter(); |
4448 | 4499 | ||
4449 | DateList tmpDateList = mNavigator->selectedDates(); | 4500 | DateList tmpDateList = mNavigator->selectedDates(); |
4450 | mCalPrinter->print(CalPrinter::Month, | 4501 | mCalPrinter->print(CalPrinter::Month, |
4451 | tmpDateList.first(), tmpDateList.last()); | 4502 | tmpDateList.first(), tmpDateList.last()); |
4452 | #endif | 4503 | #endif |
4453 | } | 4504 | } |
4454 | 4505 | ||
4455 | void CalendarView::printPreview() | 4506 | void CalendarView::printPreview() |
4456 | { | 4507 | { |
4457 | #ifndef KORG_NOPRINTER | 4508 | #ifndef KORG_NOPRINTER |
4458 | kdDebug() << "CalendarView::printPreview()" << endl; | 4509 | kdDebug() << "CalendarView::printPreview()" << endl; |
4459 | 4510 | ||
4460 | createPrinter(); | 4511 | createPrinter(); |
4461 | 4512 | ||
4462 | DateList tmpDateList = mNavigator->selectedDates(); | 4513 | DateList tmpDateList = mNavigator->selectedDates(); |
4463 | 4514 | ||
4464 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4515 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4465 | tmpDateList.last()); | 4516 | tmpDateList.last()); |
4466 | #endif | 4517 | #endif |
4467 | } | 4518 | } |
4468 | bool CalendarView::exportICalendar( QString filename ) | 4519 | bool CalendarView::exportICalendar( QString filename ) |
4469 | { | 4520 | { |
4470 | // Force correct extension | 4521 | // Force correct extension |
4471 | if (filename.right(4) != ".ics") filename += ".ics"; | 4522 | if (filename.right(4) != ".ics") filename += ".ics"; |
4472 | 4523 | ||
4473 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4524 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4474 | return storage.save(); | 4525 | return storage.save(); |
4475 | } | 4526 | } |
4476 | 4527 | ||
4477 | bool CalendarView::exportICalendar() | 4528 | bool CalendarView::exportICalendar() |
4478 | { | 4529 | { |
4479 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); | 4530 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); |
4480 | } | 4531 | } |
4481 | 4532 | ||
4482 | bool CalendarView::exportVCalendar( QString filename ) | 4533 | bool CalendarView::exportVCalendar( QString filename ) |
4483 | { | 4534 | { |
4484 | if (mCalendar->journals().count() > 0) { | 4535 | if (mCalendar->journals().count() > 0) { |
4485 | int result = KMessageBox::warningContinueCancel(this, | 4536 | int result = KMessageBox::warningContinueCancel(this, |
4486 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4537 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4487 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4538 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4488 | true); | 4539 | true); |
4489 | if (result != KMessageBox::Continue) return false; | 4540 | if (result != KMessageBox::Continue) return false; |
4490 | } | 4541 | } |
4491 | 4542 | ||
4492 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4543 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4493 | 4544 | ||
4494 | // Force correct extension | 4545 | // Force correct extension |
4495 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4546 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4496 | 4547 | ||
4497 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4548 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4498 | return storage.save(); | 4549 | return storage.save(); |
4499 | 4550 | ||
4500 | } | 4551 | } |
4501 | 4552 | ||
4502 | void CalendarView::eventUpdated(Incidence *) | 4553 | void CalendarView::eventUpdated(Incidence *) |
4503 | { | 4554 | { |
4504 | setModified(); | 4555 | setModified(); |
4505 | // Don't call updateView here. The code, which has caused the update of the | 4556 | // Don't call updateView here. The code, which has caused the update of the |
4506 | // event is responsible for updating the view. | 4557 | // event is responsible for updating the view. |
4507 | // updateView(); | 4558 | // updateView(); |
4508 | } | 4559 | } |
4509 | 4560 | ||
4510 | void CalendarView::adaptNavigationUnits() | 4561 | void CalendarView::adaptNavigationUnits() |
4511 | { | 4562 | { |
4512 | if (mViewManager->currentView()->isEventView()) { | 4563 | if (mViewManager->currentView()->isEventView()) { |
4513 | int days = mViewManager->currentView()->currentDateCount(); | 4564 | int days = mViewManager->currentView()->currentDateCount(); |
4514 | if (days == 1) { | 4565 | if (days == 1) { |
4515 | emit changeNavStringPrev(i18n("&Previous Day")); | 4566 | emit changeNavStringPrev(i18n("&Previous Day")); |
4516 | emit changeNavStringNext(i18n("&Next Day")); | 4567 | emit changeNavStringNext(i18n("&Next Day")); |
4517 | } else { | 4568 | } else { |
4518 | emit changeNavStringPrev(i18n("&Previous Week")); | 4569 | emit changeNavStringPrev(i18n("&Previous Week")); |
4519 | emit changeNavStringNext(i18n("&Next Week")); | 4570 | emit changeNavStringNext(i18n("&Next Week")); |
4520 | } | 4571 | } |
4521 | } | 4572 | } |
4522 | } | 4573 | } |
4523 | 4574 | ||
4524 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4575 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4525 | { | 4576 | { |
4526 | if ( incidence ) mTodoList->clearSelection(); | 4577 | if ( incidence ) mTodoList->clearSelection(); |
4527 | processIncidenceSelection( incidence ); | 4578 | processIncidenceSelection( incidence ); |
4528 | } | 4579 | } |
4529 | 4580 | ||
4530 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4581 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4531 | { | 4582 | { |
4532 | if ( incidence && mViewManager->currentView() ) { | 4583 | if ( incidence && mViewManager->currentView() ) { |
4533 | mViewManager->currentView()->clearSelection(); | 4584 | mViewManager->currentView()->clearSelection(); |
4534 | } | 4585 | } |
4535 | processIncidenceSelection( incidence ); | 4586 | processIncidenceSelection( incidence ); |
4536 | } | 4587 | } |
4537 | 4588 | ||
4538 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4589 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4539 | { | 4590 | { |
4540 | emit incidenceSelected( incidence ); | 4591 | emit incidenceSelected( incidence ); |
4541 | if ( incidence == mSelectedIncidence ) return; | 4592 | if ( incidence == mSelectedIncidence ) return; |
4542 | mSelectedIncidence = incidence; | 4593 | mSelectedIncidence = incidence; |
4543 | 4594 | ||
4544 | if ( incidence && incidence->typeID() == eventID ) { | 4595 | if ( incidence && incidence->typeID() == eventID ) { |
4545 | Event *event = static_cast<Event *>( incidence ); | 4596 | Event *event = static_cast<Event *>( incidence ); |
4546 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4597 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4547 | emit organizerEventsSelected( true ); | 4598 | emit organizerEventsSelected( true ); |
4548 | } else { | 4599 | } else { |
4549 | emit organizerEventsSelected(false); | 4600 | emit organizerEventsSelected(false); |
4550 | } | 4601 | } |
4551 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4602 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4552 | KOPrefs::instance()->email() ) ) { | 4603 | KOPrefs::instance()->email() ) ) { |
4553 | emit groupEventsSelected( true ); | 4604 | emit groupEventsSelected( true ); |
4554 | } else { | 4605 | } else { |
4555 | emit groupEventsSelected(false); | 4606 | emit groupEventsSelected(false); |
4556 | } | 4607 | } |
4557 | return; | 4608 | return; |
4558 | } else { | 4609 | } else { |
4559 | if ( incidence && incidence->typeID() == todoID ) { | 4610 | if ( incidence && incidence->typeID() == todoID ) { |
4560 | emit todoSelected( true ); | 4611 | emit todoSelected( true ); |
4561 | Todo *event = static_cast<Todo *>( incidence ); | 4612 | Todo *event = static_cast<Todo *>( incidence ); |
4562 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4613 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4563 | emit organizerEventsSelected( true ); | 4614 | emit organizerEventsSelected( true ); |
4564 | } else { | 4615 | } else { |
4565 | emit organizerEventsSelected(false); | 4616 | emit organizerEventsSelected(false); |
4566 | } | 4617 | } |
4567 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4618 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4568 | KOPrefs::instance()->email() ) ) { | 4619 | KOPrefs::instance()->email() ) ) { |
4569 | emit groupEventsSelected( true ); | 4620 | emit groupEventsSelected( true ); |
4570 | } else { | 4621 | } else { |
4571 | emit groupEventsSelected(false); | 4622 | emit groupEventsSelected(false); |
4572 | } | 4623 | } |
4573 | return; | 4624 | return; |
4574 | } else { | 4625 | } else { |
4575 | emit todoSelected( false ); | 4626 | emit todoSelected( false ); |
4576 | emit organizerEventsSelected(false); | 4627 | emit organizerEventsSelected(false); |
4577 | emit groupEventsSelected(false); | 4628 | emit groupEventsSelected(false); |
4578 | } | 4629 | } |
4579 | return; | 4630 | return; |
4580 | } | 4631 | } |
4581 | 4632 | ||
4582 | /* if ( incidence && incidence->typeID() == todoID ) { | 4633 | /* if ( incidence && incidence->typeID() == todoID ) { |
4583 | emit todoSelected( true ); | 4634 | emit todoSelected( true ); |
4584 | } else { | 4635 | } else { |
4585 | emit todoSelected( false ); | 4636 | emit todoSelected( false ); |
4586 | }*/ | 4637 | }*/ |
4587 | } | 4638 | } |
4588 | 4639 | ||
4589 | 4640 | ||
4590 | void CalendarView::checkClipboard() | 4641 | void CalendarView::checkClipboard() |
4591 | { | 4642 | { |
4592 | #ifndef KORG_NODND | 4643 | #ifndef KORG_NODND |
4593 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4644 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4594 | emit pasteEnabled(true); | 4645 | emit pasteEnabled(true); |
4595 | } else { | 4646 | } else { |
4596 | emit pasteEnabled(false); | 4647 | emit pasteEnabled(false); |
4597 | } | 4648 | } |
4598 | #endif | 4649 | #endif |
4599 | } | 4650 | } |
4600 | 4651 | ||
4601 | void CalendarView::showDates(const DateList &selectedDates) | 4652 | void CalendarView::showDates(const DateList &selectedDates) |
4602 | { | 4653 | { |
4603 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4654 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4604 | 4655 | ||
4605 | 4656 | ||
4606 | if ( !mBlockShowDates ) { | 4657 | if ( !mBlockShowDates ) { |
4607 | if ( mViewManager->currentView() ) { | 4658 | if ( mViewManager->currentView() ) { |
4608 | updateView( selectedDates.first(), selectedDates.last() ); | 4659 | updateView( selectedDates.first(), selectedDates.last() ); |
4609 | } else { | 4660 | } else { |
4610 | mViewManager->showAgendaView(); | 4661 | mViewManager->showAgendaView(); |
4611 | } | 4662 | } |
4612 | } | 4663 | } |
4613 | 4664 | ||
4614 | QDate date = selectedDates.first(); | 4665 | QDate date = selectedDates.first(); |
4615 | if ( ! date.isValid() ) { | 4666 | if ( ! date.isValid() ) { |
4616 | topLevelWidget()->setCaption(""); | 4667 | topLevelWidget()->setCaption(""); |
4617 | return; | 4668 | return; |
4618 | } | 4669 | } |
4619 | 4670 | ||
4620 | QString selDates; | 4671 | QString selDates; |
4621 | selDates = KGlobal::locale()->formatDate( date, true); | 4672 | selDates = KGlobal::locale()->formatDate( date, true); |
4622 | if (selectedDates.first() < selectedDates.last() ) | 4673 | if (selectedDates.first() < selectedDates.last() ) |
4623 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4674 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4624 | else { | 4675 | else { |
4625 | QString addString; | 4676 | QString addString; |
4626 | if ( date == QDateTime::currentDateTime().date() ) | 4677 | if ( date == QDateTime::currentDateTime().date() ) |
4627 | addString = i18n("Today"); | 4678 | addString = i18n("Today"); |
4628 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4679 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4629 | addString = i18n("Tomorrow"); | 4680 | addString = i18n("Tomorrow"); |
4630 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4681 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4631 | addString = i18n("Yesterday"); | 4682 | addString = i18n("Yesterday"); |
4632 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4683 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4633 | addString = i18n("Day before yesterday"); | 4684 | addString = i18n("Day before yesterday"); |
4634 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4685 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4635 | addString = i18n("Day after tomorrow"); | 4686 | addString = i18n("Day after tomorrow"); |
4636 | if ( !addString.isEmpty() ) { | 4687 | if ( !addString.isEmpty() ) { |
4637 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4688 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4638 | return; | 4689 | return; |
4639 | } | 4690 | } |
4640 | } | 4691 | } |
4641 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4692 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4642 | 4693 | ||
4643 | } | 4694 | } |
4644 | 4695 | ||
4645 | QPtrList<CalFilter> CalendarView::filters() | 4696 | QPtrList<CalFilter> CalendarView::filters() |
4646 | { | 4697 | { |
4647 | return mFilters; | 4698 | return mFilters; |
4648 | 4699 | ||
4649 | } | 4700 | } |
4650 | void CalendarView::editFilters() | 4701 | 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,2821 +1,2823 @@ | |||
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 ) { |
763 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { | 765 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { |
764 | pathString += "icons16/"; | 766 | pathString += "icons16/"; |
765 | pixWid = 18; pixHei = 16; | 767 | pixWid = 18; pixHei = 16; |
766 | } | 768 | } |
767 | } else { | 769 | } else { |
768 | pathString += "iconsmini/"; | 770 | pathString += "iconsmini/"; |
769 | pixWid = 18; pixHei = 16; | 771 | pixWid = 18; pixHei = 16; |
770 | } | 772 | } |
771 | 773 | ||
772 | if ( KOPrefs::instance()->mShowFullMenu ) { | 774 | if ( KOPrefs::instance()->mShowFullMenu ) { |
773 | menuBar1 = new KMenuBar( this );//menuBar(); | 775 | menuBar1 = new KMenuBar( this );//menuBar(); |
774 | //setMenuBar( menuBar1 ); | 776 | //setMenuBar( menuBar1 ); |
775 | menuBar1->show(); | 777 | menuBar1->show(); |
776 | menuBar1->insertItem( i18n("File"), importMenu ); | 778 | menuBar1->insertItem( i18n("File"), importMenu ); |
777 | menuBar1->insertItem( i18n("View"), viewMenu ); | 779 | menuBar1->insertItem( i18n("View"), viewMenu ); |
778 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); | 780 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); |
779 | menuBar1->insertItem( i18n("Action"), actionMenu ); | 781 | menuBar1->insertItem( i18n("Action"), actionMenu ); |
780 | #ifdef DESKTOP_VERSION | 782 | #ifdef DESKTOP_VERSION |
781 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 783 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
782 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 784 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
783 | #else | 785 | #else |
784 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 786 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
785 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 787 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
786 | #endif | 788 | #endif |
787 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 789 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
788 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 790 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
789 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 791 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
790 | } else { | 792 | } else { |
791 | menuBar1 = new KMenuBar( iconToolBar ); | 793 | menuBar1 = new KMenuBar( iconToolBar ); |
792 | QPopupMenu *menuBar = new QPopupMenu( this ); | 794 | QPopupMenu *menuBar = new QPopupMenu( this ); |
793 | icon = loadPixmap( pathString + "z_menu" ); | 795 | icon = loadPixmap( pathString + "z_menu" ); |
794 | menuBar1->insertItem( icon.pixmap(), menuBar); | 796 | menuBar1->insertItem( icon.pixmap(), menuBar); |
795 | //menuBar1->insertItem( i18n("ME"), menuBar); | 797 | //menuBar1->insertItem( i18n("ME"), menuBar); |
796 | menuBar->insertItem( i18n("File"), importMenu ); | 798 | menuBar->insertItem( i18n("File"), importMenu ); |
797 | menuBar->insertItem( i18n("View"), viewMenu ); | 799 | menuBar->insertItem( i18n("View"), viewMenu ); |
798 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); | 800 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); |
799 | menuBar->insertItem( i18n("Action"), actionMenu ); | 801 | menuBar->insertItem( i18n("Action"), actionMenu ); |
800 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 802 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
801 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 803 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
802 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 804 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
803 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 805 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
804 | menuBar->insertItem( i18n("Help"), helpMenu ); | 806 | menuBar->insertItem( i18n("Help"), helpMenu ); |
805 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 807 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
806 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 808 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
807 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); | 809 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); |
808 | } | 810 | } |
809 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 811 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
810 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 812 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
811 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 813 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
812 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 814 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
813 | 815 | ||
814 | 816 | ||
815 | mWeekBgColor = iconToolBar->backgroundColor(); | 817 | mWeekBgColor = iconToolBar->backgroundColor(); |
816 | mWeekPixmap.resize( pixWid , pixHei ); | 818 | mWeekPixmap.resize( pixWid , pixHei ); |
817 | mWeekPixmap.fill( mWeekBgColor ); | 819 | mWeekPixmap.fill( mWeekBgColor ); |
818 | icon = mWeekPixmap; | 820 | icon = mWeekPixmap; |
819 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 821 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
820 | if ( p-> mShowIconWeekNum ) | 822 | if ( p-> mShowIconWeekNum ) |
821 | mWeekAction->addTo( iconToolBar ); | 823 | mWeekAction->addTo( iconToolBar ); |
822 | mWeekFont = font(); | 824 | mWeekFont = font(); |
823 | 825 | ||
824 | int fontPoint = mWeekFont.pointSize(); | 826 | int fontPoint = mWeekFont.pointSize(); |
825 | QFontMetrics f( mWeekFont ); | 827 | QFontMetrics f( mWeekFont ); |
826 | int fontWid = f.width( "30" ); | 828 | int fontWid = f.width( "30" ); |
827 | while ( fontWid > pixWid ) { | 829 | while ( fontWid > pixWid ) { |
828 | --fontPoint; | 830 | --fontPoint; |
829 | mWeekFont.setPointSize( fontPoint ); | 831 | mWeekFont.setPointSize( fontPoint ); |
830 | QFontMetrics f( mWeekFont ); | 832 | QFontMetrics f( mWeekFont ); |
831 | fontWid = f.width( "30" ); | 833 | fontWid = f.width( "30" ); |
832 | //qDebug("dec-- "); | 834 | //qDebug("dec-- "); |
833 | } | 835 | } |
834 | 836 | ||
835 | connect( mWeekAction, SIGNAL( activated() ), | 837 | connect( mWeekAction, SIGNAL( activated() ), |
836 | this, SLOT( weekAction() ) ); | 838 | this, SLOT( weekAction() ) ); |
837 | 839 | ||
838 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 840 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
839 | if ( p->mShowIconFilterview ) { | 841 | if ( p->mShowIconFilterview ) { |
840 | icon = loadPixmap( pathString + "filter" ); | 842 | icon = loadPixmap( pathString + "filter" ); |
841 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); | 843 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); |
842 | connect( actionFilterMenuTB, SIGNAL( activated() ), | 844 | connect( actionFilterMenuTB, SIGNAL( activated() ), |
843 | this, SLOT( fillFilterMenuTB() ) ); | 845 | this, SLOT( fillFilterMenuTB() ) ); |
844 | actionFilterMenuTB->addTo( iconToolBar ); | 846 | actionFilterMenuTB->addTo( iconToolBar ); |
845 | selectFilterMenuTB = new QPopupMenu( this ); | 847 | selectFilterMenuTB = new QPopupMenu( this ); |
846 | selectFilterMenuTB->setCheckable( true ); | 848 | selectFilterMenuTB->setCheckable( true ); |
847 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 849 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
848 | } | 850 | } |
849 | 851 | ||
850 | //#endif | 852 | //#endif |
851 | // ****************** | 853 | // ****************** |
852 | QAction *action; | 854 | QAction *action; |
853 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 855 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
854 | configureToolBarMenu->setCheckable( true ); | 856 | configureToolBarMenu->setCheckable( true ); |
855 | 857 | ||
856 | 858 | ||
857 | configureAgendaMenu->setCheckable( true ); | 859 | configureAgendaMenu->setCheckable( true ); |
858 | int iii ; | 860 | int iii ; |
859 | for ( iii = 1;iii<= 10 ;++iii ){ | 861 | for ( iii = 1;iii<= 10 ;++iii ){ |
860 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 862 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
861 | } | 863 | } |
862 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 864 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
863 | 865 | ||
864 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 866 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
865 | this, SLOT( showConfigureAgenda( ) ) ); | 867 | this, SLOT( showConfigureAgenda( ) ) ); |
866 | icon = loadPixmap( pathString + "today" ); | 868 | icon = loadPixmap( pathString + "today" ); |
867 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 869 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
868 | today_action->addTo( actionMenu ); | 870 | today_action->addTo( actionMenu ); |
869 | connect( today_action, SIGNAL( activated() ), | 871 | connect( today_action, SIGNAL( activated() ), |
870 | mView, SLOT( goToday() ) ); | 872 | mView, SLOT( goToday() ) ); |
871 | 873 | ||
872 | icon = loadPixmap( pathString + "picker" ); | 874 | icon = loadPixmap( pathString + "picker" ); |
873 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); | 875 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); |
874 | dPickerAction->addTo( actionMenu ); | 876 | dPickerAction->addTo( actionMenu ); |
875 | connect( dPickerAction, SIGNAL( activated() ), | 877 | connect( dPickerAction, SIGNAL( activated() ), |
876 | mView, SLOT( showDatePicker() ) ); | 878 | mView, SLOT( showDatePicker() ) ); |
877 | 879 | ||
878 | icon = loadPixmap( pathString + "search" ); | 880 | icon = loadPixmap( pathString + "search" ); |
879 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 881 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
880 | search_action->addTo( actionMenu ); | 882 | search_action->addTo( actionMenu ); |
881 | connect( search_action, SIGNAL( activated() ), | 883 | connect( search_action, SIGNAL( activated() ), |
882 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 884 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
883 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); | 885 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); |
884 | 886 | ||
885 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); | 887 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); |
886 | action->addTo( nextConflictMenu ); | 888 | action->addTo( nextConflictMenu ); |
887 | connect( action, SIGNAL( activated() ), | 889 | connect( action, SIGNAL( activated() ), |
888 | mView, SLOT( conflictAll() ) ); | 890 | mView, SLOT( conflictAll() ) ); |
889 | 891 | ||
890 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); | 892 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); |
891 | action->addTo( nextConflictMenu ); | 893 | action->addTo( nextConflictMenu ); |
892 | connect( action, SIGNAL( activated() ), | 894 | connect( action, SIGNAL( activated() ), |
893 | mView, SLOT( conflictAllday() ) ); | 895 | mView, SLOT( conflictAllday() ) ); |
894 | 896 | ||
895 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); | 897 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); |
896 | action->addTo( nextConflictMenu ); | 898 | action->addTo( nextConflictMenu ); |
897 | connect( action, SIGNAL( activated() ), | 899 | connect( action, SIGNAL( activated() ), |
898 | mView, SLOT( conflictNotAll() ) ); | 900 | mView, SLOT( conflictNotAll() ) ); |
899 | 901 | ||
900 | actionMenu->insertSeparator(); | 902 | actionMenu->insertSeparator(); |
901 | 903 | ||
902 | icon = loadPixmap( pathString + "newevent" ); | 904 | icon = loadPixmap( pathString + "newevent" ); |
903 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 905 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
904 | ne_action->addTo( mCurrentItemMenu ); | 906 | ne_action->addTo( mCurrentItemMenu ); |
905 | connect( ne_action, SIGNAL( activated() ), | 907 | connect( ne_action, SIGNAL( activated() ), |
906 | mView, SLOT( newEvent() ) ); | 908 | mView, SLOT( newEvent() ) ); |
907 | icon = loadPixmap( pathString + "newtodo" ); | 909 | icon = loadPixmap( pathString + "newtodo" ); |
908 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 910 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
909 | nt_action->addTo( mCurrentItemMenu ); | 911 | nt_action->addTo( mCurrentItemMenu ); |
910 | connect( nt_action, SIGNAL( activated() ), | 912 | connect( nt_action, SIGNAL( activated() ), |
911 | mView, SLOT( newTodo() ) ); | 913 | mView, SLOT( newTodo() ) ); |
912 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 914 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
913 | this ); | 915 | this ); |
914 | mNewSubTodoAction->addTo( mCurrentItemMenu ); | 916 | mNewSubTodoAction->addTo( mCurrentItemMenu ); |
915 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 917 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
916 | mView, SLOT( newSubTodo() ) ); | 918 | mView, SLOT( newSubTodo() ) ); |
917 | 919 | ||
918 | mCurrentItemMenu->insertSeparator(); | 920 | mCurrentItemMenu->insertSeparator(); |
919 | icon = loadPixmap( pathString + "newevent" ); | 921 | icon = loadPixmap( pathString + "newevent" ); |
920 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 922 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
921 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 923 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
922 | configureToolBarMenu->insertSeparator(); | 924 | configureToolBarMenu->insertSeparator(); |
923 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 925 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
924 | configureToolBarMenu->insertSeparator(); | 926 | configureToolBarMenu->insertSeparator(); |
925 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 927 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
926 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 928 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
927 | icon = loadPixmap( pathString + "newtodo" ); | 929 | icon = loadPixmap( pathString + "newtodo" ); |
928 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 930 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
929 | 931 | ||
930 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); | 932 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); |
931 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); | 933 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); |
932 | mShowAction->addTo( mCurrentItemMenu ); | 934 | mShowAction->addTo( mCurrentItemMenu ); |
933 | connect( mShowAction, SIGNAL( activated() ), | 935 | connect( mShowAction, SIGNAL( activated() ), |
934 | mView, SLOT( showIncidence() ) ); | 936 | mView, SLOT( showIncidence() ) ); |
935 | 937 | ||
936 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 938 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
937 | mEditAction->addTo( mCurrentItemMenu ); | 939 | mEditAction->addTo( mCurrentItemMenu ); |
938 | connect( mEditAction, SIGNAL( activated() ), | 940 | connect( mEditAction, SIGNAL( activated() ), |
939 | mView, SLOT( editIncidence() ) ); | 941 | mView, SLOT( editIncidence() ) ); |
940 | 942 | ||
941 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 943 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
942 | mDeleteAction->addTo( mCurrentItemMenu ); | 944 | mDeleteAction->addTo( mCurrentItemMenu ); |
943 | connect( mDeleteAction, SIGNAL( activated() ), | 945 | connect( mDeleteAction, SIGNAL( activated() ), |
944 | mView, SLOT( deleteIncidence() ) ); | 946 | mView, SLOT( deleteIncidence() ) ); |
945 | 947 | ||
946 | 948 | ||
947 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 949 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
948 | mCloneAction->addTo( mCurrentItemMenu ); | 950 | mCloneAction->addTo( mCurrentItemMenu ); |
949 | connect( mCloneAction, SIGNAL( activated() ), | 951 | connect( mCloneAction, SIGNAL( activated() ), |
950 | mView, SLOT( cloneIncidence() ) ); | 952 | mView, SLOT( cloneIncidence() ) ); |
951 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 953 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
952 | mMoveAction->addTo( mCurrentItemMenu ); | 954 | mMoveAction->addTo( mCurrentItemMenu ); |
953 | connect( mMoveAction, SIGNAL( activated() ), | 955 | connect( mMoveAction, SIGNAL( activated() ), |
954 | mView, SLOT( moveIncidence() ) ); | 956 | mView, SLOT( moveIncidence() ) ); |
955 | #ifndef DESKTOP_VERSION | 957 | #ifndef DESKTOP_VERSION |
956 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 958 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
957 | mBeamAction->addTo(mCurrentItemMenu ); | 959 | mBeamAction->addTo(mCurrentItemMenu ); |
958 | connect( mBeamAction, SIGNAL( activated() ), | 960 | connect( mBeamAction, SIGNAL( activated() ), |
959 | mView, SLOT( beamIncidence() ) ); | 961 | mView, SLOT( beamIncidence() ) ); |
960 | #endif | 962 | #endif |
961 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 963 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
962 | mCancelAction->addTo( mCurrentItemMenu ); | 964 | mCancelAction->addTo( mCurrentItemMenu ); |
963 | connect( mCancelAction, SIGNAL( activated() ), | 965 | connect( mCancelAction, SIGNAL( activated() ), |
964 | mView, SLOT( toggleCancelIncidence() ) ); | 966 | mView, SLOT( toggleCancelIncidence() ) ); |
965 | 967 | ||
966 | 968 | ||
967 | mCurrentItemMenu->insertSeparator(); | 969 | mCurrentItemMenu->insertSeparator(); |
968 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 970 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
969 | action->addTo( mCurrentItemMenu ); | 971 | action->addTo( mCurrentItemMenu ); |
970 | connect( action, SIGNAL( activated() ), | 972 | connect( action, SIGNAL( activated() ), |
971 | mView, SLOT( undo_delete() ) ); | 973 | mView, SLOT( undo_delete() ) ); |
972 | 974 | ||
973 | // *********************** | 975 | // *********************** |
974 | if ( KOPrefs::instance()->mVerticalScreen ) { | 976 | if ( KOPrefs::instance()->mVerticalScreen ) { |
975 | icon = SmallIcon( "1updownarrow" ); | 977 | icon = SmallIcon( "1updownarrow" ); |
976 | } else { | 978 | } else { |
977 | icon = SmallIcon("1leftrightarrow" ); | 979 | icon = SmallIcon("1leftrightarrow" ); |
978 | } | 980 | } |
979 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); | 981 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); |
980 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); | 982 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); |
981 | FSaction->addTo( viewMenu ); | 983 | FSaction->addTo( viewMenu ); |
982 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); | 984 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); |
983 | 985 | ||
984 | 986 | ||
985 | icon = loadPixmap( pathString + "filter" ); | 987 | icon = loadPixmap( pathString + "filter" ); |
986 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); | 988 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); |
987 | icon = loadPixmap( pathString + "configure" ); | 989 | icon = loadPixmap( pathString + "configure" ); |
988 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); | 990 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); |
989 | action->addTo( viewMenu ); | 991 | action->addTo( viewMenu ); |
990 | connect( action, SIGNAL( activated() ), | 992 | connect( action, SIGNAL( activated() ), |
991 | mView, SLOT( toggleFilter() ) ); | 993 | mView, SLOT( toggleFilter() ) ); |
992 | mToggleFilter = action; | 994 | mToggleFilter = action; |
993 | icon = loadPixmap( pathString + "navi" ); | 995 | icon = loadPixmap( pathString + "navi" ); |
994 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | 996 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); |
995 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 997 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
996 | action->addTo( viewMenu ); | 998 | action->addTo( viewMenu ); |
997 | connect( action, SIGNAL( activated() ), | 999 | connect( action, SIGNAL( activated() ), |
998 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 1000 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
999 | mToggleNav = action ; | 1001 | mToggleNav = action ; |
1000 | icon = loadPixmap( pathString + "allday" ); | 1002 | icon = loadPixmap( pathString + "allday" ); |
1001 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); | 1003 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); |
1002 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 1004 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
1003 | action->addTo( viewMenu ); | 1005 | action->addTo( viewMenu ); |
1004 | connect( action, SIGNAL( activated() ), | 1006 | connect( action, SIGNAL( activated() ), |
1005 | mView, SLOT( toggleAllDaySize() ) ); | 1007 | mView, SLOT( toggleAllDaySize() ) ); |
1006 | mToggleAllday = action; | 1008 | mToggleAllday = action; |
1007 | 1009 | ||
1008 | 1010 | ||
1009 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 1011 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
1010 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 1012 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
1011 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 1013 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
1012 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 1014 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
1013 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 1015 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
1014 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 1016 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
1015 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 1017 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
1016 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); | 1018 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); |
1017 | 1019 | ||
1018 | 1020 | ||
1019 | dPickerAction->addTo( iconToolBar ); | 1021 | dPickerAction->addTo( iconToolBar ); |
1020 | viewMenu->insertSeparator(); | 1022 | viewMenu->insertSeparator(); |
1021 | 1023 | ||
1022 | if ( p-> mShowIconToggleFull ) | 1024 | if ( p-> mShowIconToggleFull ) |
1023 | FSaction->addTo( iconToolBar ); | 1025 | FSaction->addTo( iconToolBar ); |
1024 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); | 1026 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); |
1025 | 1027 | ||
1026 | //******************** | 1028 | //******************** |
1027 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); | 1029 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); |
1028 | 1030 | ||
1029 | 1031 | ||
1030 | icon = loadPixmap( pathString + "whatsnext" ); | 1032 | icon = loadPixmap( pathString + "whatsnext" ); |
1031 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 1033 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
1032 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 1034 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
1033 | whatsnext_action->addTo( viewMenu ); | 1035 | whatsnext_action->addTo( viewMenu ); |
1034 | connect( whatsnext_action, SIGNAL( activated() ), | 1036 | connect( whatsnext_action, SIGNAL( activated() ), |
1035 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 1037 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
1036 | 1038 | ||
1037 | icon = loadPixmap( pathString + "xdays" ); | 1039 | icon = loadPixmap( pathString + "xdays" ); |
1038 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 1040 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
1039 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 1041 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
1040 | xdays_action->addTo( viewMenu ); | 1042 | xdays_action->addTo( viewMenu ); |
1041 | connect( xdays_action, SIGNAL( activated() ), | 1043 | connect( xdays_action, SIGNAL( activated() ), |
1042 | mView->viewManager(), SLOT( showNextXView() ) ); | 1044 | mView->viewManager(), SLOT( showNextXView() ) ); |
1043 | 1045 | ||
1044 | 1046 | ||
1045 | icon = loadPixmap( pathString + "journal" ); | 1047 | icon = loadPixmap( pathString + "journal" ); |
1046 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 1048 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
1047 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 1049 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
1048 | viewjournal_action->addTo( viewMenu ); | 1050 | viewjournal_action->addTo( viewMenu ); |
1049 | connect( viewjournal_action, SIGNAL( activated() ), | 1051 | connect( viewjournal_action, SIGNAL( activated() ), |
1050 | mView->viewManager(), SLOT( showJournalView() ) ); | 1052 | mView->viewManager(), SLOT( showJournalView() ) ); |
1051 | 1053 | ||
1052 | 1054 | ||
1053 | icon = loadPixmap( pathString + "day" ); | 1055 | icon = loadPixmap( pathString + "day" ); |
1054 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 1056 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
1055 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 1057 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
1056 | day1_action->addTo( viewMenu ); | 1058 | day1_action->addTo( viewMenu ); |
1057 | // action->addTo( toolBar ); | 1059 | // action->addTo( toolBar ); |
1058 | connect( day1_action, SIGNAL( activated() ), | 1060 | connect( day1_action, SIGNAL( activated() ), |
1059 | mView->viewManager(), SLOT( showDayView() ) ); | 1061 | mView->viewManager(), SLOT( showDayView() ) ); |
1060 | 1062 | ||
1061 | icon = loadPixmap( pathString + "workweek" ); | 1063 | icon = loadPixmap( pathString + "workweek" ); |
1062 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 1064 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
1063 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 1065 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
1064 | day5_action->addTo( viewMenu ); | 1066 | day5_action->addTo( viewMenu ); |
1065 | connect( day5_action, SIGNAL( activated() ), | 1067 | connect( day5_action, SIGNAL( activated() ), |
1066 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 1068 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
1067 | 1069 | ||
1068 | icon = loadPixmap( pathString + "week" ); | 1070 | icon = loadPixmap( pathString + "week" ); |
1069 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 1071 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
1070 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 1072 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
1071 | day7_action->addTo( viewMenu ); | 1073 | day7_action->addTo( viewMenu ); |
1072 | connect( day7_action, SIGNAL( activated() ), | 1074 | connect( day7_action, SIGNAL( activated() ), |
1073 | mView->viewManager(), SLOT( showWeekView() ) ); | 1075 | mView->viewManager(), SLOT( showWeekView() ) ); |
1074 | 1076 | ||
1075 | icon = loadPixmap( pathString + "workweek2" ); | 1077 | icon = loadPixmap( pathString + "workweek2" ); |
1076 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 1078 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
1077 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 1079 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
1078 | day6_action->addTo( viewMenu ); | 1080 | day6_action->addTo( viewMenu ); |
1079 | connect( day6_action, SIGNAL( activated() ), | 1081 | connect( day6_action, SIGNAL( activated() ), |
1080 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 1082 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
1081 | 1083 | ||
1082 | icon = loadPixmap( pathString + "month" ); | 1084 | icon = loadPixmap( pathString + "month" ); |
1083 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 1085 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
1084 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 1086 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
1085 | month_action->addTo( viewMenu ); | 1087 | month_action->addTo( viewMenu ); |
1086 | connect( month_action, SIGNAL( activated() ), | 1088 | connect( month_action, SIGNAL( activated() ), |
1087 | mView->viewManager(), SLOT( showMonthView() ) ); | 1089 | mView->viewManager(), SLOT( showMonthView() ) ); |
1088 | 1090 | ||
1089 | icon = loadPixmap( pathString + "list" ); | 1091 | icon = loadPixmap( pathString + "list" ); |
1090 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 1092 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
1091 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 1093 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
1092 | showlist_action->addTo( viewMenu ); | 1094 | showlist_action->addTo( viewMenu ); |
1093 | connect( showlist_action, SIGNAL( activated() ), | 1095 | connect( showlist_action, SIGNAL( activated() ), |
1094 | mView->viewManager(), SLOT( showListView() ) ); | 1096 | mView->viewManager(), SLOT( showListView() ) ); |
1095 | 1097 | ||
1096 | icon = loadPixmap( pathString + "todo" ); | 1098 | icon = loadPixmap( pathString + "todo" ); |
1097 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 1099 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
1098 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 1100 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
1099 | todoview_action->addTo( viewMenu ); | 1101 | todoview_action->addTo( viewMenu ); |
1100 | connect( todoview_action, SIGNAL( activated() ), | 1102 | connect( todoview_action, SIGNAL( activated() ), |
1101 | mView->viewManager(), SLOT( showTodoView() ) ); | 1103 | mView->viewManager(), SLOT( showTodoView() ) ); |
1102 | 1104 | ||
1103 | 1105 | ||
1104 | 1106 | ||
1105 | #if 0 | 1107 | #if 0 |
1106 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 1108 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
1107 | action->addTo( viewMenu ); | 1109 | action->addTo( viewMenu ); |
1108 | connect( action, SIGNAL( activated() ), | 1110 | connect( action, SIGNAL( activated() ), |
1109 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 1111 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
1110 | #endif | 1112 | #endif |
1111 | 1113 | ||
1112 | 1114 | ||
1113 | 1115 | ||
1114 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, | 1116 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, |
1115 | this ); | 1117 | this ); |
1116 | action->addTo( actionMenu ); | 1118 | action->addTo( actionMenu ); |
1117 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 1119 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
1118 | 1120 | ||
1119 | 1121 | ||
1120 | icon = loadPixmap( pathString + "search" ); | 1122 | icon = loadPixmap( pathString + "search" ); |
1121 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 1123 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
1122 | 1124 | ||
1123 | 1125 | ||
1124 | 1126 | ||
1125 | actionMenu->insertSeparator(); | 1127 | actionMenu->insertSeparator(); |
1126 | action = new QAction( "manage cat", i18n("Edit category list..."), 0, | 1128 | action = new QAction( "manage cat", i18n("Edit category list..."), 0, |
1127 | this ); | 1129 | this ); |
1128 | action->addTo( actionMenu ); | 1130 | action->addTo( actionMenu ); |
1129 | connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); | 1131 | connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); |
1130 | 1132 | ||
1131 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1133 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1132 | this ); | 1134 | this ); |
1133 | action->addTo( actionMenu ); | 1135 | action->addTo( actionMenu ); |
1134 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1136 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1135 | 1137 | ||
1136 | 1138 | ||
1137 | actionMenu->insertSeparator(); | 1139 | actionMenu->insertSeparator(); |
1138 | icon = loadPixmap( pathString + "configure" ); | 1140 | icon = loadPixmap( pathString + "configure" ); |
1139 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); | 1141 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); |
1140 | action->addTo( actionMenu ); | 1142 | action->addTo( actionMenu ); |
1141 | connect( action, SIGNAL( activated() ), | 1143 | connect( action, SIGNAL( activated() ), |
1142 | mView, SLOT( edit_options() ) ); | 1144 | mView, SLOT( edit_options() ) ); |
1143 | action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); | 1145 | action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); |
1144 | action->addTo( actionMenu ); | 1146 | action->addTo( actionMenu ); |
1145 | connect( action, SIGNAL( activated() ), | 1147 | connect( action, SIGNAL( activated() ), |
1146 | this, SLOT( calHint() ) ); | 1148 | this, SLOT( calHint() ) ); |
1147 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); | 1149 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); |
1148 | action->addTo( actionMenu ); | 1150 | action->addTo( actionMenu ); |
1149 | connect( action, SIGNAL( activated() ), | 1151 | connect( action, SIGNAL( activated() ), |
1150 | mView, SLOT( edit_global_options() ) ); | 1152 | mView, SLOT( edit_global_options() ) ); |
1151 | if ( KOPrefs::instance()->mShowFullMenu ) { | 1153 | if ( KOPrefs::instance()->mShowFullMenu ) { |
1152 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 1154 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
1153 | 1155 | ||
1154 | } | 1156 | } |
1155 | // actionMenu->insertSeparator(); | 1157 | // actionMenu->insertSeparator(); |
1156 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 1158 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
1157 | this ); | 1159 | this ); |
1158 | action->addTo( importMenu_X ); | 1160 | action->addTo( importMenu_X ); |
1159 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 1161 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
1160 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 1162 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
1161 | this ); | 1163 | this ); |
1162 | action->addTo( importMenu_X ); | 1164 | action->addTo( importMenu_X ); |
1163 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 1165 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
1164 | importMenu_X->insertSeparator(); | 1166 | importMenu_X->insertSeparator(); |
1165 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 1167 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
1166 | this ); | 1168 | this ); |
1167 | action->addTo( importMenu_X ); | 1169 | action->addTo( importMenu_X ); |
1168 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 1170 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
1169 | //#ifndef DESKTOP_VERSION | 1171 | //#ifndef DESKTOP_VERSION |
1170 | importMenu_X->insertSeparator(); | 1172 | importMenu_X->insertSeparator(); |
1171 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 1173 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
1172 | this ); | 1174 | this ); |
1173 | action->addTo( importMenu_X ); | 1175 | action->addTo( importMenu_X ); |
1174 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 1176 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
1175 | //#else | 1177 | //#else |
1176 | #ifdef _OL_IMPORT_ | 1178 | #ifdef _OL_IMPORT_ |
1177 | importMenu_X->insertSeparator(); | 1179 | importMenu_X->insertSeparator(); |
1178 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 1180 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
1179 | this ); | 1181 | this ); |
1180 | action->addTo( importMenu_X ); | 1182 | action->addTo( importMenu_X ); |
1181 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 1183 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
1182 | #endif | 1184 | #endif |
1183 | //#endif | 1185 | //#endif |
1184 | 1186 | ||
1185 | //importMenu->insertSeparator(); | 1187 | //importMenu->insertSeparator(); |
1186 | #if 0 | 1188 | #if 0 |
1187 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 1189 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
1188 | this ); | 1190 | this ); |
1189 | action->addTo( importMenu ); | 1191 | action->addTo( importMenu ); |
1190 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 1192 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
1191 | #endif | 1193 | #endif |
1192 | action = new QAction( "save_cal", i18n("Save Backup..."), 0, | 1194 | action = new QAction( "save_cal", i18n("Save Backup..."), 0, |
1193 | this ); | 1195 | this ); |
1194 | action->addTo( importMenu ); | 1196 | action->addTo( importMenu ); |
1195 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 1197 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
1196 | importMenu->insertSeparator(); | 1198 | importMenu->insertSeparator(); |
1197 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 1199 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
1198 | //importMenu->insertSeparator(); | 1200 | //importMenu->insertSeparator(); |
1199 | action = new QAction( "export ical", i18n("Export All Data"), 0, | 1201 | action = new QAction( "export ical", i18n("Export All Data"), 0, |
1200 | this ); | 1202 | this ); |
1201 | action->addTo( exportMenu_X ); | 1203 | action->addTo( exportMenu_X ); |
1202 | connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) ); | 1204 | connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) ); |
1203 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 1205 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
1204 | this ); | 1206 | this ); |
1205 | action->addTo( exportMenu_X ); | 1207 | action->addTo( exportMenu_X ); |
1206 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 1208 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
1207 | 1209 | ||
1208 | 1210 | ||
1209 | //LR | 1211 | //LR |
1210 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 1212 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
1211 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1213 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1212 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1214 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1213 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 1215 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
1214 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 1216 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
1215 | 1217 | ||
1216 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 1218 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
1217 | mPrintSelAction = 0; | 1219 | mPrintSelAction = 0; |
1218 | #ifndef DESKTOP_VERSION | 1220 | #ifndef DESKTOP_VERSION |
1219 | //importMenu->insertSeparator(); | 1221 | //importMenu->insertSeparator(); |
1220 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 1222 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
1221 | this ); | 1223 | this ); |
1222 | brAction->addTo( beamMenu_X ); | 1224 | brAction->addTo( beamMenu_X ); |
1223 | brAction->setToggleAction (true ) ; | 1225 | brAction->setToggleAction (true ) ; |
1224 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 1226 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
1225 | 1227 | ||
1226 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 1228 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
1227 | this ); | 1229 | this ); |
1228 | action->addTo( beamMenu_X ); | 1230 | action->addTo( beamMenu_X ); |
1229 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 1231 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
1230 | 1232 | ||
1231 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 1233 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
1232 | this ); | 1234 | this ); |
1233 | action->addTo( beamMenu_X ); | 1235 | action->addTo( beamMenu_X ); |
1234 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 1236 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
1235 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 1237 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
1236 | #else | 1238 | #else |
1237 | //importMenu->insertSeparator(); | 1239 | //importMenu->insertSeparator(); |
1238 | icon = loadPixmap( pathString + "print" ); | 1240 | icon = loadPixmap( pathString + "print" ); |
1239 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 1241 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
1240 | action->addTo( beamMenu_X ); | 1242 | action->addTo( beamMenu_X ); |
1241 | connect( action, SIGNAL( activated() ), | 1243 | connect( action, SIGNAL( activated() ), |
1242 | this, SLOT( printCal() ) ); | 1244 | this, SLOT( printCal() ) ); |
1243 | 1245 | ||
1244 | icon = loadPixmap( pathString + "week" ); | 1246 | icon = loadPixmap( pathString + "week" ); |
1245 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 1247 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
1246 | action->addTo( beamMenu_X ); | 1248 | action->addTo( beamMenu_X ); |
1247 | connect( action, SIGNAL( activated() ), | 1249 | connect( action, SIGNAL( activated() ), |
1248 | this, SLOT( printSel() ) ); | 1250 | this, SLOT( printSel() ) ); |
1249 | icon = loadPixmap( pathString + "whatsnext" ); | 1251 | icon = loadPixmap( pathString + "whatsnext" ); |
1250 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 1252 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
1251 | action->addTo( beamMenu_X ); | 1253 | action->addTo( beamMenu_X ); |
1252 | connect( action, SIGNAL( activated() ), | 1254 | connect( action, SIGNAL( activated() ), |
1253 | mView->viewManager(), SLOT( slotprintWNV() ) ); | 1255 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1254 | 1256 | ||
1255 | 1257 | ||
1256 | icon = loadPixmap( pathString + "list" ); | 1258 | icon = loadPixmap( pathString + "list" ); |
1257 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); | 1259 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); |
1258 | action->addTo( beamMenu_X ); | 1260 | action->addTo( beamMenu_X ); |
1259 | connect( action, SIGNAL( activated() ), | 1261 | connect( action, SIGNAL( activated() ), |
1260 | this, SLOT( printListView() ) ); | 1262 | this, SLOT( printListView() ) ); |
1261 | 1263 | ||
1262 | icon = loadPixmap( pathString + "newevent" ); | 1264 | icon = loadPixmap( pathString + "newevent" ); |
1263 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | 1265 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); |
1264 | action->addTo( beamMenu_X ); | 1266 | action->addTo( beamMenu_X ); |
1265 | connect( action, SIGNAL( activated() ), | 1267 | connect( action, SIGNAL( activated() ), |
1266 | mView, SLOT( slotprintSelInc() ) ); | 1268 | mView, SLOT( slotprintSelInc() ) ); |
1267 | mPrintSelAction = action; | 1269 | mPrintSelAction = action; |
1268 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1270 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
1269 | #endif | 1271 | #endif |
1270 | 1272 | ||
1271 | importMenu->insertSeparator(); | 1273 | importMenu->insertSeparator(); |
1272 | action = new QAction( "beam all", i18n("Save"), 0, | 1274 | action = new QAction( "beam all", i18n("Save"), 0, |
1273 | this ); | 1275 | this ); |
1274 | action->addTo( importMenu ); | 1276 | action->addTo( importMenu ); |
1275 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1277 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1276 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1278 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1277 | this ); | 1279 | this ); |
1278 | action->addTo( importMenu ); | 1280 | action->addTo( importMenu ); |
1279 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1281 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1280 | 1282 | ||
1281 | //menuBar->insertItem( "Configure",configureMenu ); | 1283 | //menuBar->insertItem( "Configure",configureMenu ); |
1282 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1284 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1283 | icon = loadPixmap( "korganizer/korganizer" ); | 1285 | icon = loadPixmap( "korganizer/korganizer" ); |
1284 | 1286 | ||
1285 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1287 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1286 | action->addTo( helpMenu ); | 1288 | action->addTo( helpMenu ); |
1287 | connect( action, SIGNAL( activated() ), | 1289 | connect( action, SIGNAL( activated() ), |
1288 | SLOT( whatsNew() ) ); | 1290 | SLOT( whatsNew() ) ); |
1289 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1291 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1290 | action->addTo( helpMenu ); | 1292 | action->addTo( helpMenu ); |
1291 | connect( action, SIGNAL( activated() ), | 1293 | connect( action, SIGNAL( activated() ), |
1292 | SLOT( features() ) ); | 1294 | SLOT( features() ) ); |
1293 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1295 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1294 | action->addTo( helpMenu ); | 1296 | action->addTo( helpMenu ); |
1295 | connect( action, SIGNAL( activated() ), | 1297 | connect( action, SIGNAL( activated() ), |
1296 | SLOT( keyBindings() ) ); | 1298 | SLOT( keyBindings() ) ); |
1297 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); | 1299 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); |
1298 | action->addTo( helpMenu ); | 1300 | action->addTo( helpMenu ); |
1299 | connect( action, SIGNAL( activated() ), | 1301 | connect( action, SIGNAL( activated() ), |
1300 | SLOT( storagehowto() ) ); | 1302 | SLOT( storagehowto() ) ); |
1301 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); | 1303 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); |
1302 | action->addTo( helpMenu ); | 1304 | action->addTo( helpMenu ); |
1303 | connect( action, SIGNAL( activated() ), | 1305 | connect( action, SIGNAL( activated() ), |
1304 | SLOT( timetrackinghowto() ) ); | 1306 | SLOT( timetrackinghowto() ) ); |
1305 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1307 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1306 | action->addTo( helpMenu ); | 1308 | action->addTo( helpMenu ); |
1307 | connect( action, SIGNAL( activated() ), | 1309 | connect( action, SIGNAL( activated() ), |
1308 | SLOT( synchowto() ) ); | 1310 | SLOT( synchowto() ) ); |
1309 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1311 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1310 | action->addTo( helpMenu ); | 1312 | action->addTo( helpMenu ); |
1311 | connect( action, SIGNAL( activated() ), | 1313 | connect( action, SIGNAL( activated() ), |
1312 | SLOT( kdesynchowto() ) ); | 1314 | SLOT( kdesynchowto() ) ); |
1313 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1315 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1314 | action->addTo( helpMenu ); | 1316 | action->addTo( helpMenu ); |
1315 | connect( action, SIGNAL( activated() ), | 1317 | connect( action, SIGNAL( activated() ), |
1316 | SLOT( multisynchowto() ) ); | 1318 | SLOT( multisynchowto() ) ); |
1317 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1319 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1318 | action->addTo( helpMenu ); | 1320 | action->addTo( helpMenu ); |
1319 | connect( action, SIGNAL( activated() ), | 1321 | connect( action, SIGNAL( activated() ), |
1320 | SLOT( aboutAutoSaving() ) ); | 1322 | SLOT( aboutAutoSaving() ) ); |
1321 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1323 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1322 | action->addTo( helpMenu ); | 1324 | action->addTo( helpMenu ); |
1323 | connect( action, SIGNAL( activated() ), | 1325 | connect( action, SIGNAL( activated() ), |
1324 | SLOT( aboutKnownBugs() ) ); | 1326 | SLOT( aboutKnownBugs() ) ); |
1325 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1327 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1326 | action->addTo( helpMenu ); | 1328 | action->addTo( helpMenu ); |
1327 | connect( action, SIGNAL( activated() ), | 1329 | connect( action, SIGNAL( activated() ), |
1328 | SLOT( usertrans() ) ); | 1330 | SLOT( usertrans() ) ); |
1329 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1331 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1330 | action->addTo( helpMenu ); | 1332 | action->addTo( helpMenu ); |
1331 | connect( action, SIGNAL( activated() ), | 1333 | connect( action, SIGNAL( activated() ), |
1332 | SLOT( faq() ) ); | 1334 | SLOT( faq() ) ); |
1333 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1335 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1334 | action->addTo( helpMenu ); | 1336 | action->addTo( helpMenu ); |
1335 | connect( action, SIGNAL( activated() ), | 1337 | connect( action, SIGNAL( activated() ), |
1336 | SLOT( licence() ) ); | 1338 | SLOT( licence() ) ); |
1337 | action = new QAction( "about", i18n("About..."), 0, this ); | 1339 | action = new QAction( "about", i18n("About..."), 0, this ); |
1338 | action->addTo( helpMenu ); | 1340 | action->addTo( helpMenu ); |
1339 | connect( action, SIGNAL( activated() ), | 1341 | connect( action, SIGNAL( activated() ), |
1340 | SLOT( about() ) ); | 1342 | SLOT( about() ) ); |
1341 | //menuBar->insertSeparator(); | 1343 | //menuBar->insertSeparator(); |
1342 | 1344 | ||
1343 | // ****************************************************** | 1345 | // ****************************************************** |
1344 | // menubar icons | 1346 | // menubar icons |
1345 | 1347 | ||
1346 | 1348 | ||
1347 | 1349 | ||
1348 | //menuBar->insertItem( iconToolBar ); | 1350 | //menuBar->insertItem( iconToolBar ); |
1349 | //xdays_action | 1351 | //xdays_action |
1350 | if (p-> mShowIconNewEvent) | 1352 | if (p-> mShowIconNewEvent) |
1351 | ne_action->addTo( iconToolBar ); | 1353 | ne_action->addTo( iconToolBar ); |
1352 | if (p->mShowIconNewTodo ) | 1354 | if (p->mShowIconNewTodo ) |
1353 | nt_action->addTo( iconToolBar ); | 1355 | nt_action->addTo( iconToolBar ); |
1354 | if (p-> mShowIconSearch) | 1356 | if (p-> mShowIconSearch) |
1355 | search_action->addTo( iconToolBar ); | 1357 | search_action->addTo( iconToolBar ); |
1356 | if (p-> mShowIconWhatsThis) | 1358 | if (p-> mShowIconWhatsThis) |
1357 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1359 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1358 | if (p-> mShowIconNext) | 1360 | if (p-> mShowIconNext) |
1359 | whatsnext_action->addTo( viewToolBar ); | 1361 | whatsnext_action->addTo( viewToolBar ); |
1360 | if (p-> mShowIconNextDays) | 1362 | if (p-> mShowIconNextDays) |
1361 | xdays_action->addTo( viewToolBar ); | 1363 | xdays_action->addTo( viewToolBar ); |
1362 | if (p-> mShowIconJournal) | 1364 | if (p-> mShowIconJournal) |
1363 | viewjournal_action->addTo( viewToolBar ); | 1365 | viewjournal_action->addTo( viewToolBar ); |
1364 | if (p-> mShowIconDay1) | 1366 | if (p-> mShowIconDay1) |
1365 | day1_action->addTo( viewToolBar ); | 1367 | day1_action->addTo( viewToolBar ); |
1366 | if (p-> mShowIconDay5) | 1368 | if (p-> mShowIconDay5) |
1367 | day5_action->addTo( viewToolBar ); | 1369 | day5_action->addTo( viewToolBar ); |
1368 | if (p-> mShowIconDay7) | 1370 | if (p-> mShowIconDay7) |
1369 | day7_action->addTo( viewToolBar ); | 1371 | day7_action->addTo( viewToolBar ); |
1370 | if (p-> mShowIconDay6) | 1372 | if (p-> mShowIconDay6) |
1371 | day6_action->addTo( viewToolBar ); | 1373 | day6_action->addTo( viewToolBar ); |
1372 | if (p-> mShowIconMonth) | 1374 | if (p-> mShowIconMonth) |
1373 | month_action->addTo( viewToolBar ); | 1375 | month_action->addTo( viewToolBar ); |
1374 | if (p-> mShowIconList) | 1376 | if (p-> mShowIconList) |
1375 | showlist_action->addTo( viewToolBar ); | 1377 | showlist_action->addTo( viewToolBar ); |
1376 | if (p-> mShowIconTodoview) | 1378 | if (p-> mShowIconTodoview) |
1377 | todoview_action->addTo( viewToolBar ); | 1379 | todoview_action->addTo( viewToolBar ); |
1378 | 1380 | ||
1379 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1381 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1380 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1382 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1381 | if (p-> mShowIconBackFast) { | 1383 | if (p-> mShowIconBackFast) { |
1382 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1384 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1383 | connect( action, SIGNAL( activated() ), | 1385 | connect( action, SIGNAL( activated() ), |
1384 | mView, SLOT( goPreviousMonth() ) ); | 1386 | mView, SLOT( goPreviousMonth() ) ); |
1385 | action->addTo( navigatorToolBar ); | 1387 | action->addTo( navigatorToolBar ); |
1386 | } | 1388 | } |
1387 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1389 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1388 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1390 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1389 | if (p-> mShowIconBack) { | 1391 | if (p-> mShowIconBack) { |
1390 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1392 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1391 | connect( action, SIGNAL( activated() ), | 1393 | connect( action, SIGNAL( activated() ), |
1392 | mView, SLOT( goPrevious() ) ); | 1394 | mView, SLOT( goPrevious() ) ); |
1393 | action->addTo( navigatorToolBar ); | 1395 | action->addTo( navigatorToolBar ); |
1394 | } | 1396 | } |
1395 | icon = loadPixmap( pathString + "today" ); | 1397 | icon = loadPixmap( pathString + "today" ); |
1396 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1398 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1397 | if (p-> mShowIconToday) | 1399 | if (p-> mShowIconToday) |
1398 | today_action->addTo( navigatorToolBar ); | 1400 | today_action->addTo( navigatorToolBar ); |
1399 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1401 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1400 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1402 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1401 | if (p-> mShowIconForward) { | 1403 | if (p-> mShowIconForward) { |
1402 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1404 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1403 | connect( action, SIGNAL( activated() ), | 1405 | connect( action, SIGNAL( activated() ), |
1404 | mView, SLOT( goNext() ) ); | 1406 | mView, SLOT( goNext() ) ); |
1405 | action->addTo( navigatorToolBar ); | 1407 | action->addTo( navigatorToolBar ); |
1406 | } | 1408 | } |
1407 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1409 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1408 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1410 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1409 | if (p-> mShowIconForwardFast) { | 1411 | if (p-> mShowIconForwardFast) { |
1410 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1412 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1411 | connect( action, SIGNAL( activated() ), | 1413 | connect( action, SIGNAL( activated() ), |
1412 | mView, SLOT( goNextMonth() ) ); | 1414 | mView, SLOT( goNextMonth() ) ); |
1413 | action->addTo( navigatorToolBar ); | 1415 | action->addTo( navigatorToolBar ); |
1414 | } | 1416 | } |
1415 | 1417 | ||
1416 | 1418 | ||
1417 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1419 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1418 | 1420 | ||
1419 | 1421 | ||
1420 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); | 1422 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); |
1421 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); | 1423 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); |
1422 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); | 1424 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); |
1423 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); | 1425 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); |
1424 | 1426 | ||
1425 | if (p-> mShowIconNewEvent) | 1427 | if (p-> mShowIconNewEvent) |
1426 | configureToolBarMenu->setItemChecked( 10, true ); | 1428 | configureToolBarMenu->setItemChecked( 10, true ); |
1427 | if (p->mShowIconNewTodo ) | 1429 | if (p->mShowIconNewTodo ) |
1428 | configureToolBarMenu->setItemChecked( 20, true ); | 1430 | configureToolBarMenu->setItemChecked( 20, true ); |
1429 | if (p-> mShowIconSearch) | 1431 | if (p-> mShowIconSearch) |
1430 | configureToolBarMenu->setItemChecked( 120, true ); | 1432 | configureToolBarMenu->setItemChecked( 120, true ); |
1431 | if (p-> mShowIconList) | 1433 | if (p-> mShowIconList) |
1432 | configureToolBarMenu->setItemChecked( 30, true ); | 1434 | configureToolBarMenu->setItemChecked( 30, true ); |
1433 | if (p-> mShowIconDay1) | 1435 | if (p-> mShowIconDay1) |
1434 | configureToolBarMenu->setItemChecked( 40, true ); | 1436 | configureToolBarMenu->setItemChecked( 40, true ); |
1435 | if (p-> mShowIconDay5) | 1437 | if (p-> mShowIconDay5) |
1436 | configureToolBarMenu->setItemChecked( 50, true ); | 1438 | configureToolBarMenu->setItemChecked( 50, true ); |
1437 | if (p-> mShowIconDay6) | 1439 | if (p-> mShowIconDay6) |
1438 | configureToolBarMenu->setItemChecked( 75, true ); | 1440 | configureToolBarMenu->setItemChecked( 75, true ); |
1439 | if (p-> mShowIconDay7) | 1441 | if (p-> mShowIconDay7) |
1440 | configureToolBarMenu->setItemChecked( 60, true ); | 1442 | configureToolBarMenu->setItemChecked( 60, true ); |
1441 | if (p-> mShowIconMonth) | 1443 | if (p-> mShowIconMonth) |
1442 | configureToolBarMenu->setItemChecked( 70, true ); | 1444 | configureToolBarMenu->setItemChecked( 70, true ); |
1443 | if (p-> mShowIconTodoview) | 1445 | if (p-> mShowIconTodoview) |
1444 | configureToolBarMenu->setItemChecked( 80, true ); | 1446 | configureToolBarMenu->setItemChecked( 80, true ); |
1445 | if (p-> mShowIconBackFast) | 1447 | if (p-> mShowIconBackFast) |
1446 | configureToolBarMenu->setItemChecked( 200, true ); | 1448 | configureToolBarMenu->setItemChecked( 200, true ); |
1447 | if (p-> mShowIconBack) | 1449 | if (p-> mShowIconBack) |
1448 | configureToolBarMenu->setItemChecked( 210, true ); | 1450 | configureToolBarMenu->setItemChecked( 210, true ); |
1449 | if (p-> mShowIconToday) | 1451 | if (p-> mShowIconToday) |
1450 | configureToolBarMenu->setItemChecked( 130, true ); | 1452 | configureToolBarMenu->setItemChecked( 130, true ); |
1451 | if (p-> mShowIconForward) | 1453 | if (p-> mShowIconForward) |
1452 | configureToolBarMenu->setItemChecked( 220, true ); | 1454 | configureToolBarMenu->setItemChecked( 220, true ); |
1453 | if (p-> mShowIconForwardFast) | 1455 | if (p-> mShowIconForwardFast) |
1454 | configureToolBarMenu->setItemChecked( 230, true ); | 1456 | configureToolBarMenu->setItemChecked( 230, true ); |
1455 | if (p-> mShowIconNextDays) | 1457 | if (p-> mShowIconNextDays) |
1456 | configureToolBarMenu->setItemChecked( 100, true ); | 1458 | configureToolBarMenu->setItemChecked( 100, true ); |
1457 | if (p-> mShowIconNext) | 1459 | if (p-> mShowIconNext) |
1458 | configureToolBarMenu->setItemChecked( 110, true ); | 1460 | configureToolBarMenu->setItemChecked( 110, true ); |
1459 | if (p-> mShowIconJournal) | 1461 | if (p-> mShowIconJournal) |
1460 | configureToolBarMenu->setItemChecked( 90, true ); | 1462 | configureToolBarMenu->setItemChecked( 90, true ); |
1461 | if (p-> mShowIconWhatsThis) | 1463 | if (p-> mShowIconWhatsThis) |
1462 | configureToolBarMenu->setItemChecked( 300, true ); | 1464 | configureToolBarMenu->setItemChecked( 300, true ); |
1463 | if (p-> mShowIconWeekNum) | 1465 | if (p-> mShowIconWeekNum) |
1464 | configureToolBarMenu->setItemChecked( 400, true ); | 1466 | configureToolBarMenu->setItemChecked( 400, true ); |
1465 | if (!p-> mShowIconStretch) { | 1467 | if (!p-> mShowIconStretch) { |
1466 | QLabel* dummy = new QLabel( iconToolBar ); | 1468 | QLabel* dummy = new QLabel( iconToolBar ); |
1467 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1469 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1468 | dummy->setMinimumWidth( 0 ); | 1470 | dummy->setMinimumWidth( 0 ); |
1469 | iconToolBar->setStretchableWidget ( dummy ) ; | 1471 | iconToolBar->setStretchableWidget ( dummy ) ; |
1470 | } | 1472 | } |
1471 | else { | 1473 | else { |
1472 | iconToolBar->setHorizontalStretchable (true ); | 1474 | iconToolBar->setHorizontalStretchable (true ); |
1473 | viewToolBar->setHorizontalStretchable (true ); | 1475 | viewToolBar->setHorizontalStretchable (true ); |
1474 | navigatorToolBar->setHorizontalStretchable (true ); | 1476 | navigatorToolBar->setHorizontalStretchable (true ); |
1475 | iconToolBar->setVerticalStretchable (true ); | 1477 | iconToolBar->setVerticalStretchable (true ); |
1476 | viewToolBar->setVerticalStretchable (true ); | 1478 | viewToolBar->setVerticalStretchable (true ); |
1477 | navigatorToolBar->setVerticalStretchable (true ); | 1479 | navigatorToolBar->setVerticalStretchable (true ); |
1478 | configureToolBarMenu->setItemChecked( 5, true ); | 1480 | configureToolBarMenu->setItemChecked( 5, true ); |
1479 | } | 1481 | } |
1480 | if (p-> mShowIconFilter) | 1482 | if (p-> mShowIconFilter) |
1481 | configureToolBarMenu->setItemChecked( 7, true ); | 1483 | configureToolBarMenu->setItemChecked( 7, true ); |
1482 | if (p-> mShowIconOnetoolbar) | 1484 | if (p-> mShowIconOnetoolbar) |
1483 | configureToolBarMenu->setItemChecked( 6, true ); | 1485 | configureToolBarMenu->setItemChecked( 6, true ); |
1484 | 1486 | ||
1485 | 1487 | ||
1486 | if ( filterMenubar ) { | 1488 | if ( filterMenubar ) { |
1487 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); | 1489 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); |
1488 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); | 1490 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); |
1489 | } | 1491 | } |
1490 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1492 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1491 | configureAgenda( p->mHourSize ); | 1493 | configureAgenda( p->mHourSize ); |
1492 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1494 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1493 | } | 1495 | } |
1494 | void MainWindow::calHint() | 1496 | void MainWindow::calHint() |
1495 | { | 1497 | { |
1496 | QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); | 1498 | QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); |
1497 | 1499 | ||
1498 | KMessageBox::information( this, message); | 1500 | KMessageBox::information( this, message); |
1499 | } | 1501 | } |
1500 | void MainWindow::exportToPhone( int mode ) | 1502 | void MainWindow::exportToPhone( int mode ) |
1501 | { | 1503 | { |
1502 | 1504 | ||
1503 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1505 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1504 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1506 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1505 | KOex2phonePrefs ex2phone; | 1507 | KOex2phonePrefs ex2phone; |
1506 | 1508 | ||
1507 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1509 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1508 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1510 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1509 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1511 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1510 | if ( mode == 1 ) | 1512 | if ( mode == 1 ) |
1511 | ex2phone.setCaption(i18n("Export complete calendar")); | 1513 | ex2phone.setCaption(i18n("Export complete calendar")); |
1512 | if ( mode == 2 ) | 1514 | if ( mode == 2 ) |
1513 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1515 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1514 | 1516 | ||
1515 | if ( !ex2phone.exec() ) { | 1517 | if ( !ex2phone.exec() ) { |
1516 | return; | 1518 | return; |
1517 | } | 1519 | } |
1518 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1520 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1519 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1521 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1520 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1522 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1521 | 1523 | ||
1522 | int inFuture = 0; | 1524 | int inFuture = 0; |
1523 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1525 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1524 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1526 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1525 | QPtrList<Incidence> delSel; | 1527 | QPtrList<Incidence> delSel; |
1526 | if ( mode == 1 ) | 1528 | if ( mode == 1 ) |
1527 | delSel = mCalendar->rawIncidences(); | 1529 | delSel = mCalendar->rawIncidences(); |
1528 | if ( mode == 2 ) | 1530 | if ( mode == 2 ) |
1529 | delSel = mCalendar->incidences(); | 1531 | delSel = mCalendar->incidences(); |
1530 | CalendarLocal* cal = new CalendarLocal(); | 1532 | CalendarLocal* cal = new CalendarLocal(); |
1531 | cal->setLocalTime(); | 1533 | cal->setLocalTime(); |
1532 | Incidence *incidence = delSel.first(); | 1534 | Incidence *incidence = delSel.first(); |
1533 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1535 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1534 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1536 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1535 | while ( incidence ) { | 1537 | while ( incidence ) { |
1536 | if ( incidence->typeID() != journalID ) { | 1538 | if ( incidence->typeID() != journalID ) { |
1537 | bool add = true; | 1539 | bool add = true; |
1538 | if ( inFuture ) { | 1540 | if ( inFuture ) { |
1539 | QDateTime dt; | 1541 | QDateTime dt; |
1540 | if ( incidence->typeID() == todoID ) { | 1542 | if ( incidence->typeID() == todoID ) { |
1541 | Todo * t = (Todo*)incidence; | 1543 | Todo * t = (Todo*)incidence; |
1542 | if ( t->hasDueDate() ) | 1544 | if ( t->hasDueDate() ) |
1543 | dt = t->dtDue(); | 1545 | dt = t->dtDue(); |
1544 | else | 1546 | else |
1545 | dt = cur.addSecs( 62 ); | 1547 | dt = cur.addSecs( 62 ); |
1546 | } | 1548 | } |
1547 | else { | 1549 | else { |
1548 | bool ok; | 1550 | bool ok; |
1549 | dt = incidence->getNextOccurence( cur, &ok ); | 1551 | dt = incidence->getNextOccurence( cur, &ok ); |
1550 | if ( !ok ) | 1552 | if ( !ok ) |
1551 | dt = cur.addSecs( -62 ); | 1553 | dt = cur.addSecs( -62 ); |
1552 | } | 1554 | } |
1553 | if ( dt < cur || dt > end ) { | 1555 | if ( dt < cur || dt > end ) { |
1554 | add = false; | 1556 | add = false; |
1555 | } | 1557 | } |
1556 | } | 1558 | } |
1557 | if ( add ) { | 1559 | if ( add ) { |
1558 | Incidence *in = incidence->clone(); | 1560 | Incidence *in = incidence->clone(); |
1559 | cal->addIncidence( in ); | 1561 | cal->addIncidence( in ); |
1560 | } | 1562 | } |
1561 | } | 1563 | } |
1562 | incidence = delSel.next(); | 1564 | incidence = delSel.next(); |
1563 | } | 1565 | } |
1564 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1566 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1565 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1567 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1566 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1568 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1567 | 1569 | ||
1568 | setCaption( i18n("Writing to phone...")); | 1570 | setCaption( i18n("Writing to phone...")); |
1569 | if ( PhoneFormat::writeToPhone( cal ) ) | 1571 | if ( PhoneFormat::writeToPhone( cal ) ) |
1570 | setCaption( i18n("Export to phone successful!")); | 1572 | setCaption( i18n("Export to phone successful!")); |
1571 | else | 1573 | else |
1572 | setCaption( i18n("Error exporting to phone!")); | 1574 | setCaption( i18n("Error exporting to phone!")); |
1573 | delete cal; | 1575 | delete cal; |
1574 | } | 1576 | } |
1575 | 1577 | ||
1576 | 1578 | ||
1577 | void MainWindow::setDefaultPreferences() | 1579 | void MainWindow::setDefaultPreferences() |
1578 | { | 1580 | { |
1579 | KOPrefs *p = KOPrefs::instance(); | 1581 | KOPrefs *p = KOPrefs::instance(); |
1580 | 1582 | ||
1581 | p->mCompactDialogs = true; | 1583 | p->mCompactDialogs = true; |
1582 | p->mConfirm = true; | 1584 | p->mConfirm = true; |
1583 | // p->mEnableQuickTodo = false; | 1585 | // p->mEnableQuickTodo = false; |
1584 | 1586 | ||
1585 | } | 1587 | } |
1586 | 1588 | ||
1587 | QString MainWindow::resourcePath() | 1589 | QString MainWindow::resourcePath() |
1588 | { | 1590 | { |
1589 | return KGlobal::iconLoader()->iconPath(); | 1591 | return KGlobal::iconLoader()->iconPath(); |
1590 | } | 1592 | } |
1591 | 1593 | ||
1592 | void MainWindow::displayText( QString text ,QString cap ) | 1594 | void MainWindow::displayText( QString text ,QString cap ) |
1593 | { | 1595 | { |
1594 | QDialog dia( this, "name", true ); ; | 1596 | QDialog dia( this, "name", true ); ; |
1595 | dia.setCaption( cap ); | 1597 | dia.setCaption( cap ); |
1596 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1598 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1597 | lay->setSpacing( 3 ); | 1599 | lay->setSpacing( 3 ); |
1598 | lay->setMargin( 3 ); | 1600 | lay->setMargin( 3 ); |
1599 | QTextBrowser tb ( &dia ); | 1601 | QTextBrowser tb ( &dia ); |
1600 | lay->addWidget( &tb ); | 1602 | lay->addWidget( &tb ); |
1601 | tb.setText( text ); | 1603 | tb.setText( text ); |
1602 | #ifdef DESKTOP_VERSION | 1604 | #ifdef DESKTOP_VERSION |
1603 | dia.resize( 640, 480); | 1605 | dia.resize( 640, 480); |
1604 | #else | 1606 | #else |
1605 | dia.showMaximized(); | 1607 | dia.showMaximized(); |
1606 | #endif | 1608 | #endif |
1607 | dia.exec(); | 1609 | dia.exec(); |
1608 | } | 1610 | } |
1609 | 1611 | ||
1610 | void MainWindow::features() | 1612 | void MainWindow::features() |
1611 | { | 1613 | { |
1612 | 1614 | ||
1613 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1615 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1614 | } | 1616 | } |
1615 | 1617 | ||
1616 | void MainWindow::usertrans() | 1618 | void MainWindow::usertrans() |
1617 | { | 1619 | { |
1618 | 1620 | ||
1619 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1621 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1620 | } | 1622 | } |
1621 | 1623 | ||
1622 | void MainWindow::storagehowto() | 1624 | void MainWindow::storagehowto() |
1623 | { | 1625 | { |
1624 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 1626 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
1625 | } | 1627 | } |
1626 | void MainWindow::timetrackinghowto() | 1628 | void MainWindow::timetrackinghowto() |
1627 | { | 1629 | { |
1628 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); | 1630 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); |
1629 | } | 1631 | } |
1630 | void MainWindow::kdesynchowto() | 1632 | void MainWindow::kdesynchowto() |
1631 | { | 1633 | { |
1632 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1634 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1633 | } | 1635 | } |
1634 | void MainWindow::multisynchowto() | 1636 | void MainWindow::multisynchowto() |
1635 | { | 1637 | { |
1636 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1638 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1637 | } | 1639 | } |
1638 | void MainWindow::synchowto() | 1640 | void MainWindow::synchowto() |
1639 | { | 1641 | { |
1640 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1642 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1641 | } | 1643 | } |
1642 | void MainWindow::faq() | 1644 | void MainWindow::faq() |
1643 | { | 1645 | { |
1644 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1646 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1645 | 1647 | ||
1646 | } | 1648 | } |
1647 | void MainWindow::whatsNew() | 1649 | void MainWindow::whatsNew() |
1648 | { | 1650 | { |
1649 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1651 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1650 | 1652 | ||
1651 | } | 1653 | } |
1652 | void MainWindow::licence() | 1654 | void MainWindow::licence() |
1653 | { | 1655 | { |
1654 | KApplication::showLicence(); | 1656 | KApplication::showLicence(); |
1655 | 1657 | ||
1656 | } | 1658 | } |
1657 | void MainWindow::about() | 1659 | void MainWindow::about() |
1658 | { | 1660 | { |
1659 | QString version; | 1661 | QString version; |
1660 | #include <../version> | 1662 | #include <../version> |
1661 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1663 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1662 | i18n("KOrganizer/Platform-independent\n") + | 1664 | i18n("KOrganizer/Platform-independent\n") + |
1663 | "(KO/Pi) " + version + " - " + | 1665 | "(KO/Pi) " + version + " - " + |
1664 | 1666 | ||
1665 | #ifdef DESKTOP_VERSION | 1667 | #ifdef DESKTOP_VERSION |
1666 | i18n("Desktop Edition\n") + | 1668 | i18n("Desktop Edition\n") + |
1667 | #else | 1669 | #else |
1668 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1670 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1669 | #endif | 1671 | #endif |
1670 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); | 1672 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); |
1671 | } | 1673 | } |
1672 | void MainWindow::keyBindings() | 1674 | void MainWindow::keyBindings() |
1673 | { | 1675 | { |
1674 | QString cap = i18n("KO/Pi Keys + Colors"); | 1676 | QString cap = i18n("KO/Pi Keys + Colors"); |
1675 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1677 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1676 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1678 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1677 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1679 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1678 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1680 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1679 | i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") + | 1681 | i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") + |
1680 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1682 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1681 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1683 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1682 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ | 1684 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ |
1683 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1685 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1684 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1686 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1685 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1687 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
1686 | i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ | 1688 | i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ |
1687 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1689 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1688 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1690 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1689 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1691 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1690 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1692 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1691 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1693 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1692 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1694 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1693 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ | 1695 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ |
1694 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1696 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1695 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1697 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1696 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1698 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1697 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1699 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1698 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1700 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1699 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1701 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1700 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1702 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1701 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1703 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1702 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1704 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1703 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1705 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1704 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1706 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1705 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1707 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1706 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1708 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1707 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1709 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1708 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1710 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1709 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1711 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1710 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1712 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1711 | i18n("<p><h3>In list view:</h3></p>\n") + | 1713 | i18n("<p><h3>In list view:</h3></p>\n") + |
1712 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1714 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1713 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1715 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1714 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1716 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1715 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1717 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1716 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1718 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1717 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1719 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1718 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1720 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1719 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1721 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1720 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1722 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1721 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1723 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1722 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1724 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1723 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1725 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1724 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1726 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1725 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1727 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1726 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1728 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1727 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1729 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1728 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1730 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1729 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1731 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1730 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1732 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1731 | displayText( text, cap); | 1733 | displayText( text, cap); |
1732 | } | 1734 | } |
1733 | void MainWindow::aboutAutoSaving() | 1735 | void MainWindow::aboutAutoSaving() |
1734 | { | 1736 | { |
1735 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); | 1737 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); |
1736 | 1738 | ||
1737 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1739 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1738 | 1740 | ||
1739 | } | 1741 | } |
1740 | void MainWindow::aboutKnownBugs() | 1742 | void MainWindow::aboutKnownBugs() |
1741 | { | 1743 | { |
1742 | QMessageBox* msg; | 1744 | QMessageBox* msg; |
1743 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1745 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1744 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1746 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1745 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1747 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1746 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1748 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1747 | i18n("\nor report them in the bugtracker on\n") + | 1749 | i18n("\nor report them in the bugtracker on\n") + |
1748 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1750 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1749 | QMessageBox::NoIcon, | 1751 | QMessageBox::NoIcon, |
1750 | QMessageBox::Ok, | 1752 | QMessageBox::Ok, |
1751 | QMessageBox::NoButton, | 1753 | QMessageBox::NoButton, |
1752 | QMessageBox::NoButton); | 1754 | QMessageBox::NoButton); |
1753 | msg->exec(); | 1755 | msg->exec(); |
1754 | delete msg; | 1756 | delete msg; |
1755 | 1757 | ||
1756 | } | 1758 | } |
1757 | 1759 | ||
1758 | QString MainWindow::defaultFileName() | 1760 | QString MainWindow::defaultFileName() |
1759 | { | 1761 | { |
1760 | return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 1762 | return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
1761 | } | 1763 | } |
1762 | QString MainWindow::syncFileName() | 1764 | QString MainWindow::syncFileName() |
1763 | { | 1765 | { |
1764 | #ifdef DESKTOP_VERSION | 1766 | #ifdef DESKTOP_VERSION |
1765 | return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); | 1767 | return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); |
1766 | #else | 1768 | #else |
1767 | return QString( "/tmp/synccalendar.ics" ); | 1769 | return QString( "/tmp/synccalendar.ics" ); |
1768 | #endif | 1770 | #endif |
1769 | } | 1771 | } |
1770 | #include "koglobals.h" | 1772 | #include "koglobals.h" |
1771 | #include <kcalendarsystem.h> | 1773 | #include <kcalendarsystem.h> |
1772 | void MainWindow::updateWeek(QDate seda) | 1774 | void MainWindow::updateWeek(QDate seda) |
1773 | { | 1775 | { |
1774 | int weekNum = KGlobal::locale()->weekNum ( seda ); | 1776 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1775 | mWeekPixmap.fill( mWeekBgColor ); | 1777 | mWeekPixmap.fill( mWeekBgColor ); |
1776 | QPainter p ( &mWeekPixmap ); | 1778 | QPainter p ( &mWeekPixmap ); |
1777 | p.setFont( mWeekFont ); | 1779 | p.setFont( mWeekFont ); |
1778 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1780 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1779 | p.end(); | 1781 | p.end(); |
1780 | QIconSet icon3 ( mWeekPixmap ); | 1782 | QIconSet icon3 ( mWeekPixmap ); |
1781 | mWeekAction->setIconSet ( icon3 ); | 1783 | mWeekAction->setIconSet ( icon3 ); |
1782 | 1784 | ||
1783 | } | 1785 | } |
1784 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1786 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1785 | { | 1787 | { |
1786 | updateWeek( selectedDates.first() ); | 1788 | updateWeek( selectedDates.first() ); |
1787 | } | 1789 | } |
1788 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1790 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1789 | { | 1791 | { |
1790 | if ( !incidence ) { | 1792 | if ( !incidence ) { |
1791 | mShowAction->setMenuText( i18n("Show") ); | 1793 | mShowAction->setMenuText( i18n("Show") ); |
1792 | enableIncidenceActions( false ); | 1794 | enableIncidenceActions( false ); |
1793 | mNewSubTodoAction->setEnabled( false ); | 1795 | mNewSubTodoAction->setEnabled( false ); |
1794 | setCaptionToDates(); | 1796 | setCaptionToDates(); |
1795 | return; | 1797 | return; |
1796 | } | 1798 | } |
1797 | QString startString = ""; | 1799 | QString startString = ""; |
1798 | if ( incidence->typeID() != todoID ) { | 1800 | if ( incidence->typeID() != todoID ) { |
1799 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1801 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1800 | if ( incidence->doesFloat() ) { | 1802 | if ( incidence->doesFloat() ) { |
1801 | startString += ": "+incidence->dtStartDateStr( true ); | 1803 | startString += ": "+incidence->dtStartDateStr( true ); |
1802 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1804 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1803 | } else { | 1805 | } else { |
1804 | startString = ": "+incidence->dtStartStr(true); | 1806 | startString = ": "+incidence->dtStartStr(true); |
1805 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1807 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1806 | } | 1808 | } |
1807 | } else { | 1809 | } else { |
1808 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1810 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1809 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1811 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1810 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1812 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1811 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { | 1813 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { |
1812 | bool ok; | 1814 | bool ok; |
1813 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1815 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1814 | if ( ok ) { | 1816 | if ( ok ) { |
1815 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1817 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1816 | startString += i18n(" (%1 y.)"). arg( years ); | 1818 | startString += i18n(" (%1 y.)"). arg( years ); |
1817 | } | 1819 | } |
1818 | } | 1820 | } |
1819 | else | 1821 | else |
1820 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1822 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1821 | } | 1823 | } |
1822 | } | 1824 | } |
1823 | else { | 1825 | else { |
1824 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) | 1826 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) |
1825 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); | 1827 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); |
1826 | else | 1828 | else |
1827 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1829 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1828 | } | 1830 | } |
1829 | if ( !incidence->location().isEmpty() ) | 1831 | if ( !incidence->location().isEmpty() ) |
1830 | startString += " (" +incidence->location()+")"; | 1832 | startString += " (" +incidence->location()+")"; |
1831 | setCaption( incidence->summary()+startString); | 1833 | setCaption( incidence->summary()+startString); |
1832 | enableIncidenceActions( true ); | 1834 | enableIncidenceActions( true ); |
1833 | if ( incidence->typeID() == eventID ) { | 1835 | if ( incidence->typeID() == eventID ) { |
1834 | mShowAction->setMenuText( i18n("Show Event") ); | 1836 | mShowAction->setMenuText( i18n("Show Event") ); |
1835 | mNewSubTodoAction->setEnabled( false ); | 1837 | mNewSubTodoAction->setEnabled( false ); |
1836 | } else if ( incidence->typeID() == todoID ) { | 1838 | } else if ( incidence->typeID() == todoID ) { |
1837 | mShowAction->setMenuText( i18n("Show Todo") ); | 1839 | mShowAction->setMenuText( i18n("Show Todo") ); |
1838 | mNewSubTodoAction->setEnabled( true ); | 1840 | mNewSubTodoAction->setEnabled( true ); |
1839 | } else { | 1841 | } else { |
1840 | mShowAction->setMenuText( i18n("Show") ); | 1842 | mShowAction->setMenuText( i18n("Show") ); |
1841 | mNewSubTodoAction->setEnabled( false ); | 1843 | mNewSubTodoAction->setEnabled( false ); |
1842 | } | 1844 | } |
1843 | #ifdef DESKTOP_VERSION | 1845 | #ifdef DESKTOP_VERSION |
1844 | static QPixmap jP = SmallIcon( "journal" ); | 1846 | static QPixmap jP = SmallIcon( "journal" ); |
1845 | static QPixmap eP = SmallIcon( "newevent" ); | 1847 | static QPixmap eP = SmallIcon( "newevent" ); |
1846 | static QPixmap tP = SmallIcon( "newtodo" ); | 1848 | static QPixmap tP = SmallIcon( "newtodo" ); |
1847 | QIconSet icon; | 1849 | QIconSet icon; |
1848 | if ( incidence->typeID() == todoID ) | 1850 | if ( incidence->typeID() == todoID ) |
1849 | icon = QIconSet ( tP ); | 1851 | icon = QIconSet ( tP ); |
1850 | else if ( incidence->typeID() == eventID ) | 1852 | else if ( incidence->typeID() == eventID ) |
1851 | icon = QIconSet ( eP ); | 1853 | icon = QIconSet ( eP ); |
1852 | else if ( incidence->typeID() == journalID ) | 1854 | else if ( incidence->typeID() == journalID ) |
1853 | icon = QIconSet ( jP ); | 1855 | icon = QIconSet ( jP ); |
1854 | mPrintSelAction->setIconSet ( icon ); | 1856 | mPrintSelAction->setIconSet ( icon ); |
1855 | #endif | 1857 | #endif |
1856 | } | 1858 | } |
1857 | 1859 | ||
1858 | void MainWindow::enableIncidenceActions( bool enabled ) | 1860 | void MainWindow::enableIncidenceActions( bool enabled ) |
1859 | { | 1861 | { |
1860 | mShowAction->setEnabled( enabled ); | 1862 | mShowAction->setEnabled( enabled ); |
1861 | mEditAction->setEnabled( enabled ); | 1863 | mEditAction->setEnabled( enabled ); |
1862 | mDeleteAction->setEnabled( enabled ); | 1864 | mDeleteAction->setEnabled( enabled ); |
1863 | 1865 | ||
1864 | mCloneAction->setEnabled( enabled ); | 1866 | mCloneAction->setEnabled( enabled ); |
1865 | mMoveAction->setEnabled( enabled ); | 1867 | mMoveAction->setEnabled( enabled ); |
1866 | #ifndef DESKTOP_VERSION | 1868 | #ifndef DESKTOP_VERSION |
1867 | mBeamAction->setEnabled( enabled ); | 1869 | mBeamAction->setEnabled( enabled ); |
1868 | #else | 1870 | #else |
1869 | mPrintSelAction->setEnabled( enabled ); | 1871 | mPrintSelAction->setEnabled( enabled ); |
1870 | #endif | 1872 | #endif |
1871 | mCancelAction->setEnabled( enabled ); | 1873 | mCancelAction->setEnabled( enabled ); |
1872 | } | 1874 | } |
1873 | 1875 | ||
1874 | void MainWindow::importOL() | 1876 | void MainWindow::importOL() |
1875 | { | 1877 | { |
1876 | #ifdef _OL_IMPORT_ | 1878 | #ifdef _OL_IMPORT_ |
1877 | mView->clearAllViews(); | 1879 | mView->clearAllViews(); |
1878 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1880 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1879 | id->exec(); | 1881 | id->exec(); |
1880 | delete id; | 1882 | delete id; |
1881 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1883 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1882 | mView->updateView(); | 1884 | mView->updateView(); |
1883 | #endif | 1885 | #endif |
1884 | } | 1886 | } |
1885 | void MainWindow::importBday() | 1887 | void MainWindow::importBday() |
1886 | { | 1888 | { |
1887 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), | 1889 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), |
1888 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1890 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1889 | i18n("Import!"), i18n("Cancel"), 0, | 1891 | i18n("Import!"), i18n("Cancel"), 0, |
1890 | 0, 1 ); | 1892 | 0, 1 ); |
1891 | if ( result == 0 ) { | 1893 | if ( result == 0 ) { |
1892 | mView->importBday(); | 1894 | mView->importBday(); |
1893 | 1895 | ||
1894 | } | 1896 | } |
1895 | 1897 | ||
1896 | 1898 | ||
1897 | } | 1899 | } |
1898 | void MainWindow::importQtopia() | 1900 | void MainWindow::importQtopia() |
1899 | { | 1901 | { |
1900 | //#ifndef DESKTOP_VERSION | 1902 | //#ifndef DESKTOP_VERSION |
1901 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); | 1903 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); |
1902 | #ifdef DESKTOP_VERSION | 1904 | #ifdef DESKTOP_VERSION |
1903 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); | 1905 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); |
1904 | #endif | 1906 | #endif |
1905 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1907 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1906 | i18n("Import!"), i18n("Cancel"), 0, | 1908 | i18n("Import!"), i18n("Cancel"), 0, |
1907 | 0, 1 ); | 1909 | 0, 1 ); |
1908 | if ( result == 0 ) { | 1910 | if ( result == 0 ) { |
1909 | #ifndef DESKTOP_VERSION | 1911 | #ifndef DESKTOP_VERSION |
1910 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1912 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1911 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1913 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1912 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1914 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1913 | #else | 1915 | #else |
1914 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1916 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1915 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1917 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1916 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1918 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1917 | #endif | 1919 | #endif |
1918 | mView->importQtopia( categories, datebook, todolist ); | 1920 | mView->importQtopia( categories, datebook, todolist ); |
1919 | } | 1921 | } |
1920 | mView->calendar()->reInitAlarmSettings(); | 1922 | mView->calendar()->reInitAlarmSettings(); |
1921 | #if 0 | 1923 | #if 0 |
1922 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1924 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1923 | i18n("Not supported \non desktop!\n"), | 1925 | i18n("Not supported \non desktop!\n"), |
1924 | i18n("Ok"), i18n("Cancel"), 0, | 1926 | i18n("Ok"), i18n("Cancel"), 0, |
1925 | 0, 1 ); | 1927 | 0, 1 ); |
1926 | 1928 | ||
1927 | #endif | 1929 | #endif |
1928 | } | 1930 | } |
1929 | 1931 | ||
1930 | void MainWindow::saveOnClose() | 1932 | void MainWindow::saveOnClose() |
1931 | { | 1933 | { |
1932 | KOPrefs *p = KOPrefs::instance(); | 1934 | KOPrefs *p = KOPrefs::instance(); |
1933 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1935 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1934 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1936 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1935 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1937 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1936 | if ( filterToolBar ) { | 1938 | if ( filterToolBar ) { |
1937 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1939 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1938 | } | 1940 | } |
1939 | #ifdef DESKTOP_VERSION | 1941 | #ifdef DESKTOP_VERSION |
1940 | 1942 | ||
1941 | QPoint myP; | 1943 | QPoint myP; |
1942 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1944 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1943 | if ( p->mToolBarHor ) | 1945 | if ( p->mToolBarHor ) |
1944 | p->mToolBarUp = myP.y() > height()/2; | 1946 | p->mToolBarUp = myP.y() > height()/2; |
1945 | else | 1947 | else |
1946 | p->mToolBarUp = myP.x() > width()/2; | 1948 | p->mToolBarUp = myP.x() > width()/2; |
1947 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1949 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1948 | if ( p->mToolBarHorV ) | 1950 | if ( p->mToolBarHorV ) |
1949 | p->mToolBarUpV = myP.y() > height()/2; | 1951 | p->mToolBarUpV = myP.y() > height()/2; |
1950 | else | 1952 | else |
1951 | p->mToolBarUpV = myP.x() > width()/2 ; | 1953 | p->mToolBarUpV = myP.x() > width()/2 ; |
1952 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1954 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1953 | if ( p->mToolBarHorN ) | 1955 | if ( p->mToolBarHorN ) |
1954 | p->mToolBarUpN = myP.y() > height()/2; | 1956 | p->mToolBarUpN = myP.y() > height()/2; |
1955 | else | 1957 | else |
1956 | p->mToolBarUpN = myP.x() > width()/2 ; | 1958 | p->mToolBarUpN = myP.x() > width()/2 ; |
1957 | if ( filterToolBar ) { | 1959 | if ( filterToolBar ) { |
1958 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1960 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1959 | if ( p->mToolBarHorF ) | 1961 | if ( p->mToolBarHorF ) |
1960 | p->mToolBarUpF = myP.y() > height()/2; | 1962 | p->mToolBarUpF = myP.y() > height()/2; |
1961 | else | 1963 | else |
1962 | p->mToolBarUpF = myP.x() > width()/2 ; | 1964 | p->mToolBarUpF = myP.x() > width()/2 ; |
1963 | } | 1965 | } |
1964 | #else | 1966 | #else |
1965 | if ( p->mToolBarHor ) | 1967 | if ( p->mToolBarHor ) |
1966 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1968 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1967 | else | 1969 | else |
1968 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1970 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1969 | if ( p->mToolBarHorV ) | 1971 | if ( p->mToolBarHorV ) |
1970 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1972 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1971 | else | 1973 | else |
1972 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1974 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1973 | 1975 | ||
1974 | if ( p->mToolBarHorN ) | 1976 | if ( p->mToolBarHorN ) |
1975 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1977 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1976 | else | 1978 | else |
1977 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1979 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1978 | if ( filterToolBar ) { | 1980 | if ( filterToolBar ) { |
1979 | if ( p->mToolBarHorF ) | 1981 | if ( p->mToolBarHorF ) |
1980 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1982 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1981 | else | 1983 | else |
1982 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1984 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1983 | } | 1985 | } |
1984 | #endif | 1986 | #endif |
1985 | save(); | 1987 | save(); |
1986 | mView->writeSettings(); | 1988 | mView->writeSettings(); |
1987 | mView->checkSuspendAlarm(); | 1989 | mView->checkSuspendAlarm(); |
1988 | } | 1990 | } |
1989 | void MainWindow::slotModifiedChanged( bool ) | 1991 | void MainWindow::slotModifiedChanged( bool ) |
1990 | { | 1992 | { |
1991 | if ( mBlockAtStartup ) | 1993 | if ( mBlockAtStartup ) |
1992 | return; | 1994 | return; |
1993 | 1995 | ||
1994 | int msec; | 1996 | int msec; |
1995 | if ( mAutoSaveDisabled ) { | 1997 | if ( mAutoSaveDisabled ) { |
1996 | QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) ); | 1998 | QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) ); |
1997 | qDebug("KO: Autosave disabled (data change deteced)!"); | 1999 | qDebug("KO: Autosave disabled (data change deteced)!"); |
1998 | } | 2000 | } |
1999 | if ( mCalendarModifiedFlag ) { | 2001 | if ( mCalendarModifiedFlag ) { |
2000 | //qDebug(" MainWindow timer is running "); | 2002 | //qDebug(" MainWindow timer is running "); |
2001 | return; | 2003 | return; |
2002 | } | 2004 | } |
2003 | mCalendarModifiedFlag = true; | 2005 | mCalendarModifiedFlag = true; |
2004 | if ( mAutoSaveDisabled ) { | 2006 | if ( mAutoSaveDisabled ) { |
2005 | return; | 2007 | return; |
2006 | } | 2008 | } |
2007 | // we store the changes after 1 minute, | 2009 | // we store the changes after 1 minute, |
2008 | // and for safety reasons after 10 minutes again | 2010 | // and for safety reasons after 10 minutes again |
2009 | if ( !mSyncManager->blockSave() ) | 2011 | if ( !mSyncManager->blockSave() ) |
2010 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 2012 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
2011 | else | 2013 | else |
2012 | msec = 1000 * 600; | 2014 | msec = 1000 * 600; |
2013 | mSaveTimer.start( msec, true ); // 1 minute | 2015 | mSaveTimer.start( msec, true ); // 1 minute |
2014 | mSaveTimerStart = QDateTime::currentDateTime(); | 2016 | mSaveTimerStart = QDateTime::currentDateTime(); |
2015 | mSaveDelay = msec/1000; | 2017 | mSaveDelay = msec/1000; |
2016 | qDebug("KO: Saving File in %d secs!", msec/1000); | 2018 | qDebug("KO: Saving File in %d secs!", msec/1000); |
2017 | } | 2019 | } |
2018 | void MainWindow::autoSaveWarning() | 2020 | void MainWindow::autoSaveWarning() |
2019 | { | 2021 | { |
2020 | setCaption(i18n("Autosave disabled!" )); | 2022 | setCaption(i18n("Autosave disabled!" )); |
2021 | } | 2023 | } |
2022 | void MainWindow::saveStopTimer() | 2024 | void MainWindow::saveStopTimer() |
2023 | { | 2025 | { |
2024 | mSaveTimer.stop(); | 2026 | mSaveTimer.stop(); |
2025 | mSaveDelay = 0; | 2027 | mSaveDelay = 0; |
2026 | } | 2028 | } |
2027 | void MainWindow::backupAllFiles() | 2029 | void MainWindow::backupAllFiles() |
2028 | { | 2030 | { |
2029 | QDate reference ( 2000,1,1); | 2031 | QDate reference ( 2000,1,1); |
2030 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2032 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2031 | setCaption(i18n("Creating backup ... please wait ..." )); | 2033 | setCaption(i18n("Creating backup ... please wait ..." )); |
2032 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 2034 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
2033 | // we need the file path, the backup dir and the number of bups as param | 2035 | // we need the file path, the backup dir and the number of bups as param |
2034 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2036 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2035 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2037 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2036 | bupDir = KGlobalSettings::backupDataDir(); | 2038 | bupDir = KGlobalSettings::backupDataDir(); |
2037 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2039 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2038 | if ( retval == 0 ) { | 2040 | if ( retval == 0 ) { |
2039 | setCaption(i18n("Backup cancelled" )); | 2041 | setCaption(i18n("Backup cancelled" )); |
2040 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 2042 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
2041 | // retval == 0 : backup skipped for today, try again tomorrow | 2043 | // retval == 0 : backup skipped for today, try again tomorrow |
2042 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 2044 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
2043 | } else if ( retval == 1 ){ | 2045 | } else if ( retval == 1 ){ |
2044 | qDebug("KO: Backup created."); | 2046 | qDebug("KO: Backup created."); |
2045 | // backup ok | 2047 | // backup ok |
2046 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2047 | KopiCalendarFile * cal = calendars.first(); | 2049 | KopiCalendarFile * cal = calendars.first(); |
2048 | cal = calendars.next(); | 2050 | cal = calendars.next(); |
2049 | while ( cal ) { | 2051 | while ( cal ) { |
2050 | if ( !cal->mErrorOnLoad ) { | 2052 | if ( !cal->mErrorOnLoad ) { |
2051 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2053 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2052 | } | 2054 | } |
2053 | cal = calendars.next(); | 2055 | cal = calendars.next(); |
2054 | } | 2056 | } |
2055 | KOPrefs::instance()->mLastBackupDate = daysTo; | 2057 | KOPrefs::instance()->mLastBackupDate = daysTo; |
2056 | setCaption(i18n("Backup succesfully finished" )); | 2058 | setCaption(i18n("Backup succesfully finished" )); |
2057 | } else if ( retval == 2 ){ | 2059 | } else if ( retval == 2 ){ |
2058 | setCaption(i18n("Backup globally disabled" )); | 2060 | setCaption(i18n("Backup globally disabled" )); |
2059 | qDebug("KO: Backup globally cancelled."); | 2061 | qDebug("KO: Backup globally cancelled."); |
2060 | // backup globally cancelled | 2062 | // backup globally cancelled |
2061 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2063 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2062 | } | 2064 | } |
2063 | // retval == 3: do nothing, try again later | 2065 | // retval == 3: do nothing, try again later |
2064 | } | 2066 | } |
2065 | void MainWindow::save() | 2067 | void MainWindow::save() |
2066 | { | 2068 | { |
2067 | if ( mSaveDelay ) { | 2069 | if ( mSaveDelay ) { |
2068 | int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); | 2070 | int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); |
2069 | if ( mSaveDelay < elapsed ) { | 2071 | if ( mSaveDelay < elapsed ) { |
2070 | qDebug("KO: Pending save after wakeup from suspend detected."); | 2072 | qDebug("KO: Pending save after wakeup from suspend detected."); |
2071 | qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); | 2073 | qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); |
2072 | qDebug("KO: Restarting save timer to save in 10 sec."); | 2074 | qDebug("KO: Restarting save timer to save in 10 sec."); |
2073 | int msec = 10000; | 2075 | int msec = 10000; |
2074 | mSaveTimer.start( msec, true ); | 2076 | mSaveTimer.start( msec, true ); |
2075 | mSaveTimerStart = QDateTime::currentDateTime(); | 2077 | mSaveTimerStart = QDateTime::currentDateTime(); |
2076 | mSaveDelay = msec/1000; | 2078 | mSaveDelay = msec/1000; |
2077 | return; | 2079 | return; |
2078 | } | 2080 | } |
2079 | } | 2081 | } |
2080 | if ( mView->viewManager()->journalView() ) | 2082 | if ( mView->viewManager()->journalView() ) |
2081 | mView->viewManager()->journalView()->checkModified(); | 2083 | mView->viewManager()->journalView()->checkModified(); |
2082 | if ( !mCalendarModifiedFlag ) { | 2084 | if ( !mCalendarModifiedFlag ) { |
2083 | qDebug("KO: Calendar not modified. Nothing saved."); | 2085 | qDebug("KO: Calendar not modified. Nothing saved."); |
2084 | return; | 2086 | return; |
2085 | } | 2087 | } |
2086 | if ( mSyncManager->blockSave() ) { | 2088 | if ( mSyncManager->blockSave() ) { |
2087 | slotModifiedChanged( true ); | 2089 | slotModifiedChanged( true ); |
2088 | return; | 2090 | return; |
2089 | } | 2091 | } |
2090 | #ifndef DESKTOP_VERSION | 2092 | #ifndef DESKTOP_VERSION |
2091 | // QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 2093 | // QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
2092 | #endif | 2094 | #endif |
2093 | mSaveDelay = 0; | 2095 | mSaveDelay = 0; |
2094 | mSyncManager->setBlockSave(true); | 2096 | mSyncManager->setBlockSave(true); |
2095 | if ( mView->checkAllFileVersions() ) { | 2097 | if ( mView->checkAllFileVersions() ) { |
2096 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2098 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
2097 | QDate reference ( 2000,1,1); | 2099 | QDate reference ( 2000,1,1); |
2098 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2100 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2099 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2101 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
2100 | backupAllFiles(); | 2102 | backupAllFiles(); |
2101 | } | 2103 | } |
2102 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2104 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2103 | } | 2105 | } |
2104 | QTime neededSaveTime; | 2106 | QTime neededSaveTime; |
2105 | neededSaveTime.start(); | 2107 | neededSaveTime.start(); |
2106 | if ( !isMinimized () ) | 2108 | if ( !isMinimized () ) |
2107 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2109 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2108 | qDebug("KO: Start saving data to file!"); | 2110 | qDebug("KO: Start saving data to file!"); |
2109 | if ( mView->saveCalendars() ) | 2111 | if ( mView->saveCalendars() ) |
2110 | mCalendarModifiedFlag = false; | 2112 | mCalendarModifiedFlag = false; |
2111 | int msNeeded = neededSaveTime.elapsed(); | 2113 | int msNeeded = neededSaveTime.elapsed(); |
2112 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2114 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2113 | QString savemes; | 2115 | QString savemes; |
2114 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2116 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2115 | if ( !isMinimized () ) | 2117 | if ( !isMinimized () ) |
2116 | setCaption(savemes); | 2118 | setCaption(savemes); |
2117 | else | 2119 | else |
2118 | qDebug(savemes); | 2120 | qDebug(savemes); |
2119 | } else { | 2121 | } else { |
2120 | setCaption(i18n("Saving cancelled!")); | 2122 | setCaption(i18n("Saving cancelled!")); |
2121 | mCalendarModifiedFlag = false; | 2123 | mCalendarModifiedFlag = false; |
2122 | slotModifiedChanged( true ); | 2124 | slotModifiedChanged( true ); |
2123 | } | 2125 | } |
2124 | mSyncManager->setBlockSave( false ); | 2126 | mSyncManager->setBlockSave( false ); |
2125 | #ifndef DESKTOP_VERSION | 2127 | #ifndef DESKTOP_VERSION |
2126 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | 2128 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); |
2127 | #endif | 2129 | #endif |
2128 | } | 2130 | } |
2129 | 2131 | ||
2130 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 2132 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
2131 | { | 2133 | { |
2132 | if ( !e->isAutoRepeat() ) { | 2134 | if ( !e->isAutoRepeat() ) { |
2133 | mFlagKeyPressed = false; | 2135 | mFlagKeyPressed = false; |
2134 | } | 2136 | } |
2135 | } | 2137 | } |
2136 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 2138 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
2137 | { | 2139 | { |
2138 | qApp->processEvents(); | 2140 | qApp->processEvents(); |
2139 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2141 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2140 | e->ignore(); | 2142 | e->ignore(); |
2141 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 2143 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
2142 | return; | 2144 | return; |
2143 | } | 2145 | } |
2144 | if (! e->isAutoRepeat() ) | 2146 | if (! e->isAutoRepeat() ) |
2145 | mFlagKeyPressed = true; | 2147 | mFlagKeyPressed = true; |
2146 | KOPrefs *p = KOPrefs::instance(); | 2148 | KOPrefs *p = KOPrefs::instance(); |
2147 | bool showSelectedDates = false; | 2149 | bool showSelectedDates = false; |
2148 | int size; | 2150 | int size; |
2149 | int pro = 0; | 2151 | int pro = 0; |
2150 | //qDebug("MainWindow::keyPressEvent "); | 2152 | //qDebug("MainWindow::keyPressEvent "); |
2151 | switch ( e->key() ) { | 2153 | switch ( e->key() ) { |
2152 | case Qt::Key_Right: | 2154 | case Qt::Key_Right: |
2153 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2155 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2154 | mView->goNextMonth(); | 2156 | mView->goNextMonth(); |
2155 | else | 2157 | else |
2156 | mView->goNext(); | 2158 | mView->goNext(); |
2157 | showSelectedDates = true; | 2159 | showSelectedDates = true; |
2158 | break; | 2160 | break; |
2159 | case Qt::Key_Left: | 2161 | case Qt::Key_Left: |
2160 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2162 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2161 | mView->goPreviousMonth(); | 2163 | mView->goPreviousMonth(); |
2162 | else | 2164 | else |
2163 | mView->goPrevious(); | 2165 | mView->goPrevious(); |
2164 | showSelectedDates = true; | 2166 | showSelectedDates = true; |
2165 | break; | 2167 | break; |
2166 | case Qt::Key_Down: | 2168 | case Qt::Key_Down: |
2167 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 2169 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
2168 | break; | 2170 | break; |
2169 | case Qt::Key_Up: | 2171 | case Qt::Key_Up: |
2170 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 2172 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
2171 | break; | 2173 | break; |
2172 | case Qt::Key_K: | 2174 | case Qt::Key_K: |
2173 | mView->viewManager()->showMonthViewWeek(); | 2175 | mView->viewManager()->showMonthViewWeek(); |
2174 | break; | 2176 | break; |
2175 | case Qt::Key_I: | 2177 | case Qt::Key_I: |
2176 | mView->showIncidence(); | 2178 | mView->showIncidence(); |
2177 | break; | 2179 | break; |
2178 | case Qt::Key_Delete: | 2180 | case Qt::Key_Delete: |
2179 | case Qt::Key_Backspace: | 2181 | case Qt::Key_Backspace: |
2180 | mView->deleteIncidence(); | 2182 | mView->deleteIncidence(); |
2181 | break; | 2183 | break; |
2182 | case Qt::Key_D: | 2184 | case Qt::Key_D: |
2183 | mView->viewManager()->showDayView(); | 2185 | mView->viewManager()->showDayView(); |
2184 | showSelectedDates = true; | 2186 | showSelectedDates = true; |
2185 | break; | 2187 | break; |
2186 | case Qt::Key_O: | 2188 | case Qt::Key_O: |
2187 | mView->toggleFilerEnabled( ); | 2189 | mView->toggleFilerEnabled( ); |
2188 | break; | 2190 | break; |
2189 | case Qt::Key_0: | 2191 | case Qt::Key_0: |
2190 | case Qt::Key_1: | 2192 | case Qt::Key_1: |
2191 | case Qt::Key_2: | 2193 | case Qt::Key_2: |
2192 | case Qt::Key_3: | 2194 | case Qt::Key_3: |
2193 | case Qt::Key_4: | 2195 | case Qt::Key_4: |
2194 | case Qt::Key_5: | 2196 | case Qt::Key_5: |
2195 | case Qt::Key_6: | 2197 | case Qt::Key_6: |
2196 | case Qt::Key_7: | 2198 | case Qt::Key_7: |
2197 | case Qt::Key_8: | 2199 | case Qt::Key_8: |
2198 | case Qt::Key_9: | 2200 | case Qt::Key_9: |
2199 | pro = e->key()-48; | 2201 | pro = e->key()-48; |
2200 | if ( pro == 0 ) | 2202 | if ( pro == 0 ) |
2201 | pro = 10; | 2203 | pro = 10; |
2202 | if ( e->state() == Qt::ControlButton) | 2204 | if ( e->state() == Qt::ControlButton) |
2203 | pro += 10; | 2205 | pro += 10; |
2204 | break; | 2206 | break; |
2205 | case Qt::Key_M: | 2207 | case Qt::Key_M: |
2206 | mView->viewManager()->showMonthView(); | 2208 | mView->viewManager()->showMonthView(); |
2207 | showSelectedDates = true; | 2209 | showSelectedDates = true; |
2208 | break; | 2210 | break; |
2209 | case Qt::Key_Insert: | 2211 | case Qt::Key_Insert: |
2210 | mView->newEvent(); | 2212 | mView->newEvent(); |
2211 | break; | 2213 | break; |
2212 | case Qt::Key_S : | 2214 | case Qt::Key_S : |
2213 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2215 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2214 | mView->newSubTodo(); | 2216 | mView->newSubTodo(); |
2215 | else | 2217 | else |
2216 | mView->dialogManager()->showSearchDialog(); | 2218 | mView->dialogManager()->showSearchDialog(); |
2217 | break; | 2219 | break; |
2218 | case Qt::Key_Y : | 2220 | case Qt::Key_Y : |
2219 | case Qt::Key_Z : | 2221 | case Qt::Key_Z : |
2220 | mView->viewManager()->showWorkWeekView(); | 2222 | mView->viewManager()->showWorkWeekView(); |
2221 | showSelectedDates = true; | 2223 | showSelectedDates = true; |
2222 | break; | 2224 | break; |
2223 | case Qt::Key_U : | 2225 | case Qt::Key_U : |
2224 | mView->viewManager()->showWeekView(); | 2226 | mView->viewManager()->showWeekView(); |
2225 | showSelectedDates = true; | 2227 | showSelectedDates = true; |
2226 | break; | 2228 | break; |
2227 | case Qt::Key_H : | 2229 | case Qt::Key_H : |
2228 | keyBindings(); | 2230 | keyBindings(); |
2229 | break; | 2231 | break; |
2230 | case Qt::Key_W: | 2232 | case Qt::Key_W: |
2231 | mView->viewManager()->showWhatsNextView(); | 2233 | mView->viewManager()->showWhatsNextView(); |
2232 | break; | 2234 | break; |
2233 | case Qt::Key_L: | 2235 | case Qt::Key_L: |
2234 | mView->viewManager()->showListView(); | 2236 | mView->viewManager()->showListView(); |
2235 | break; | 2237 | break; |
2236 | case Qt::Key_N: | 2238 | case Qt::Key_N: |
2237 | mView->viewManager()->showNextView(); | 2239 | mView->viewManager()->showNextView(); |
2238 | break; | 2240 | break; |
2239 | case Qt::Key_V: | 2241 | case Qt::Key_V: |
2240 | mView->viewManager()->showTodoView(); | 2242 | mView->viewManager()->showTodoView(); |
2241 | break; | 2243 | break; |
2242 | case Qt::Key_C: | 2244 | case Qt::Key_C: |
2243 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { | 2245 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { |
2244 | if ( mAutoSaveDisabled ) { | 2246 | if ( mAutoSaveDisabled ) { |
2245 | mAutoSaveDisabled = false; | 2247 | mAutoSaveDisabled = false; |
2246 | setCaption(i18n("Autosave enabled!" )); | 2248 | setCaption(i18n("Autosave enabled!" )); |
2247 | return; | 2249 | return; |
2248 | } else { | 2250 | } else { |
2249 | mAutoSaveDisabled = true; | 2251 | mAutoSaveDisabled = true; |
2250 | saveStopTimer(); | 2252 | saveStopTimer(); |
2251 | setCaption(i18n("Autosave disabled! Save timer stopped!" )); | 2253 | setCaption(i18n("Autosave disabled! Save timer stopped!" )); |
2252 | } | 2254 | } |
2253 | } else | 2255 | } else |
2254 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 2256 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
2255 | break; | 2257 | break; |
2256 | case Qt::Key_P: | 2258 | case Qt::Key_P: |
2257 | mView->showDatePicker( ); | 2259 | mView->showDatePicker( ); |
2258 | break; | 2260 | break; |
2259 | case Qt::Key_F: | 2261 | case Qt::Key_F: |
2260 | mView->editFilters(); | 2262 | mView->editFilters(); |
2261 | break; | 2263 | break; |
2262 | case Qt::Key_R: | 2264 | case Qt::Key_R: |
2263 | mView->toggleFilter(); | 2265 | mView->toggleFilter(); |
2264 | break; | 2266 | break; |
2265 | case Qt::Key_X: | 2267 | case Qt::Key_X: |
2266 | if ( e->state() == Qt::ControlButton ) | 2268 | if ( e->state() == Qt::ControlButton ) |
2267 | mView->toggleDateNavigatorWidget(); | 2269 | mView->toggleDateNavigatorWidget(); |
2268 | else { | 2270 | else { |
2269 | mView->viewManager()->showNextXView(); | 2271 | mView->viewManager()->showNextXView(); |
2270 | showSelectedDates = true; | 2272 | showSelectedDates = true; |
2271 | } | 2273 | } |
2272 | break; | 2274 | break; |
2273 | case Qt::Key_Space: | 2275 | case Qt::Key_Space: |
2274 | mView->toggleExpand(); | 2276 | mView->toggleExpand(); |
2275 | break; | 2277 | break; |
2276 | case Qt::Key_A: | 2278 | case Qt::Key_A: |
2277 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2279 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2278 | mView->showNextAlarms(); | 2280 | mView->showNextAlarms(); |
2279 | else | 2281 | else |
2280 | mView->toggleAllDaySize(); | 2282 | mView->toggleAllDaySize(); |
2281 | break; | 2283 | break; |
2282 | case Qt::Key_T: | 2284 | case Qt::Key_T: |
2283 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2285 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2284 | mView->newTodo(); | 2286 | mView->newTodo(); |
2285 | else { | 2287 | else { |
2286 | mView->goToday(); | 2288 | mView->goToday(); |
2287 | showSelectedDates = true; | 2289 | showSelectedDates = true; |
2288 | } | 2290 | } |
2289 | break; | 2291 | break; |
2290 | case Qt::Key_Q: | 2292 | case Qt::Key_Q: |
2291 | if ( e->state() == Qt::ControlButton ) | 2293 | if ( e->state() == Qt::ControlButton ) |
2292 | mView->conflictNotAll(); | 2294 | mView->conflictNotAll(); |
2293 | else if ( e->state() == Qt::ShiftButton ) | 2295 | else if ( e->state() == Qt::ShiftButton ) |
2294 | mView->conflictAllday(); | 2296 | mView->conflictAllday(); |
2295 | else | 2297 | else |
2296 | mView->conflictAll(); | 2298 | mView->conflictAll(); |
2297 | break; | 2299 | break; |
2298 | case Qt::Key_J: | 2300 | case Qt::Key_J: |
2299 | mView->viewManager()->showJournalView(); | 2301 | mView->viewManager()->showJournalView(); |
2300 | break; | 2302 | break; |
2301 | case Qt::Key_B: | 2303 | case Qt::Key_B: |
2302 | mView->editIncidenceDescription();; | 2304 | mView->editIncidenceDescription();; |
2303 | break; | 2305 | break; |
2304 | // case Qt::Key_Return: | 2306 | // case Qt::Key_Return: |
2305 | case Qt::Key_E: | 2307 | case Qt::Key_E: |
2306 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2308 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2307 | mView->newEvent(); | 2309 | mView->newEvent(); |
2308 | else | 2310 | else |
2309 | mView->editIncidence(); | 2311 | mView->editIncidence(); |
2310 | break; | 2312 | break; |
2311 | case Qt::Key_Plus: | 2313 | case Qt::Key_Plus: |
2312 | size = p->mHourSize +2; | 2314 | size = p->mHourSize +2; |
2313 | if ( size <= 22 ) | 2315 | if ( size <= 22 ) |
2314 | configureAgenda( size ); | 2316 | configureAgenda( size ); |
2315 | break; | 2317 | break; |
2316 | case Qt::Key_Minus: | 2318 | case Qt::Key_Minus: |
2317 | size = p->mHourSize - 2; | 2319 | size = p->mHourSize - 2; |
2318 | if ( size >= 4 ) | 2320 | if ( size >= 4 ) |
2319 | configureAgenda( size ); | 2321 | configureAgenda( size ); |
2320 | break; | 2322 | break; |
2321 | 2323 | ||
2322 | 2324 | ||
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,1044 +1,1056 @@ | |||
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() +"+++"; |
567 | } | 579 | } |
568 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 580 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
569 | if ( mNextSummary.length() > 25 ) | 581 | if ( mNextSummary.length() > 25 ) |
570 | ret += "\n" + mNextSummary.mid(25, 25 ); | 582 | ret += "\n" + mNextSummary.mid(25, 25 ); |
571 | ret+= "\n"+mNextAlarmEventDateTimeString; | 583 | ret+= "\n"+mNextAlarmEventDateTimeString; |
572 | return ret; | 584 | return ret; |
573 | } | 585 | } |
574 | void CalendarLocal::registerAlarm() | 586 | void CalendarLocal::registerAlarm() |
575 | { | 587 | { |
576 | mLastAlarmNotificationString = getAlarmNotification(); | 588 | mLastAlarmNotificationString = getAlarmNotification(); |
577 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 589 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
578 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 590 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
579 | // #ifndef DESKTOP_VERSION | 591 | // #ifndef DESKTOP_VERSION |
580 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 592 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
581 | // #endif | 593 | // #endif |
582 | } | 594 | } |
583 | void CalendarLocal::deRegisterAlarm() | 595 | void CalendarLocal::deRegisterAlarm() |
584 | { | 596 | { |
585 | if ( mLastAlarmNotificationString.isNull() ) | 597 | if ( mLastAlarmNotificationString.isNull() ) |
586 | return; | 598 | return; |
587 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 599 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
588 | 600 | ||
589 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 601 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
590 | mNextAlarmEventDateTime = QDateTime(); | 602 | mNextAlarmEventDateTime = QDateTime(); |
591 | // #ifndef DESKTOP_VERSION | 603 | // #ifndef DESKTOP_VERSION |
592 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 604 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
593 | // #endif | 605 | // #endif |
594 | } | 606 | } |
595 | 607 | ||
596 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 608 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
597 | { | 609 | { |
598 | QPtrList<Todo> todos; | 610 | QPtrList<Todo> todos; |
599 | 611 | ||
600 | Todo *todo; | 612 | Todo *todo; |
601 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 613 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
602 | if ( !todo->calEnabled() ) continue; | 614 | if ( !todo->calEnabled() ) continue; |
603 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 615 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
604 | todos.append( todo ); | 616 | todos.append( todo ); |
605 | } | 617 | } |
606 | } | 618 | } |
607 | 619 | ||
608 | filter()->apply( &todos ); | 620 | filter()->apply( &todos ); |
609 | return todos; | 621 | return todos; |
610 | } | 622 | } |
611 | void CalendarLocal::reInitAlarmSettings() | 623 | void CalendarLocal::reInitAlarmSettings() |
612 | { | 624 | { |
613 | if ( !mNextAlarmIncidence ) { | 625 | if ( !mNextAlarmIncidence ) { |
614 | nextAlarm( 1000 ); | 626 | nextAlarm( 1000 ); |
615 | } | 627 | } |
616 | deRegisterAlarm(); | 628 | deRegisterAlarm(); |
617 | mNextAlarmIncidence = 0; | 629 | mNextAlarmIncidence = 0; |
618 | checkAlarmForIncidence( 0, false ); | 630 | checkAlarmForIncidence( 0, false ); |
619 | 631 | ||
620 | } | 632 | } |
621 | 633 | ||
622 | 634 | ||
623 | 635 | ||
624 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 636 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
625 | { | 637 | { |
626 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 638 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
627 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 639 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
628 | QDateTime next; | 640 | QDateTime next; |
629 | Event *e; | 641 | Event *e; |
630 | bool ok; | 642 | bool ok; |
631 | bool found = false; | 643 | bool found = false; |
632 | int offset; | 644 | int offset; |
633 | mNextAlarmIncidence = 0; | 645 | mNextAlarmIncidence = 0; |
634 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 646 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
635 | if ( !e->calEnabled() ) continue; | 647 | if ( !e->calEnabled() ) continue; |
636 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 648 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
637 | if ( ok ) { | 649 | if ( ok ) { |
638 | if ( next < nextA ) { | 650 | if ( next < nextA ) { |
639 | nextA = next; | 651 | nextA = next; |
640 | found = true; | 652 | found = true; |
641 | mNextSummary = e->summary(); | 653 | mNextSummary = e->summary(); |
642 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 654 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
643 | mNextAlarmIncidence = (Incidence *) e; | 655 | mNextAlarmIncidence = (Incidence *) e; |
644 | } | 656 | } |
645 | } | 657 | } |
646 | } | 658 | } |
647 | Todo *t; | 659 | Todo *t; |
648 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 660 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
649 | if ( !t->calEnabled() ) continue; | 661 | if ( !t->calEnabled() ) continue; |
650 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 662 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
651 | if ( ok ) { | 663 | if ( ok ) { |
652 | if ( next < nextA ) { | 664 | if ( next < nextA ) { |
653 | nextA = next; | 665 | nextA = next; |
654 | found = true; | 666 | found = true; |
655 | mNextSummary = t->summary(); | 667 | mNextSummary = t->summary(); |
656 | mNextAlarmEventDateTime = next.addSecs(offset ); | 668 | mNextAlarmEventDateTime = next.addSecs(offset ); |
657 | mNextAlarmIncidence = (Incidence *) t; | 669 | mNextAlarmIncidence = (Incidence *) t; |
658 | } | 670 | } |
659 | } | 671 | } |
660 | } | 672 | } |
661 | if ( mNextAlarmIncidence ) { | 673 | if ( mNextAlarmIncidence ) { |
662 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 674 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
663 | mNextAlarmDateTime = nextA; | 675 | mNextAlarmDateTime = nextA; |
664 | } | 676 | } |
665 | return nextA; | 677 | return nextA; |
666 | } | 678 | } |
667 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 679 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
668 | { | 680 | { |
669 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 681 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
670 | } | 682 | } |
671 | 683 | ||
672 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 684 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
673 | { | 685 | { |
674 | 686 | ||
675 | Alarm::List alarms; | 687 | Alarm::List alarms; |
676 | 688 | ||
677 | Event *e; | 689 | Event *e; |
678 | 690 | ||
679 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 691 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
680 | if ( !e->calEnabled() ) continue; | 692 | if ( !e->calEnabled() ) continue; |
681 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 693 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
682 | else appendAlarms( alarms, e, from, to ); | 694 | else appendAlarms( alarms, e, from, to ); |
683 | } | 695 | } |
684 | 696 | ||
685 | Todo *t; | 697 | Todo *t; |
686 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 698 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
687 | if ( !t->calEnabled() ) continue; | 699 | if ( !t->calEnabled() ) continue; |
688 | appendAlarms( alarms, t, from, to ); | 700 | appendAlarms( alarms, t, from, to ); |
689 | } | 701 | } |
690 | 702 | ||
691 | return alarms; | 703 | return alarms; |
692 | } | 704 | } |
693 | 705 | ||
694 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 706 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
695 | const QDateTime &from, const QDateTime &to ) | 707 | const QDateTime &from, const QDateTime &to ) |
696 | { | 708 | { |
697 | QPtrList<Alarm> alarmList = incidence->alarms(); | 709 | QPtrList<Alarm> alarmList = incidence->alarms(); |
698 | Alarm *alarm; | 710 | Alarm *alarm; |
699 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 711 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
700 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 712 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
701 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 713 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
702 | if ( alarm->enabled() ) { | 714 | if ( alarm->enabled() ) { |
703 | if ( alarm->time() >= from && alarm->time() <= to ) { | 715 | if ( alarm->time() >= from && alarm->time() <= to ) { |
704 | alarms.append( alarm ); | 716 | alarms.append( alarm ); |
705 | } | 717 | } |
706 | } | 718 | } |
707 | } | 719 | } |
708 | } | 720 | } |
709 | 721 | ||
710 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 722 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
711 | Incidence *incidence, | 723 | Incidence *incidence, |
712 | const QDateTime &from, | 724 | const QDateTime &from, |
713 | const QDateTime &to ) | 725 | const QDateTime &to ) |
714 | { | 726 | { |
715 | 727 | ||
716 | QPtrList<Alarm> alarmList = incidence->alarms(); | 728 | QPtrList<Alarm> alarmList = incidence->alarms(); |
717 | Alarm *alarm; | 729 | Alarm *alarm; |
718 | QDateTime qdt; | 730 | QDateTime qdt; |
719 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 731 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
720 | if (incidence->recursOn(from.date())) { | 732 | if (incidence->recursOn(from.date())) { |
721 | qdt.setTime(alarm->time().time()); | 733 | qdt.setTime(alarm->time().time()); |
722 | qdt.setDate(from.date()); | 734 | qdt.setDate(from.date()); |
723 | } | 735 | } |
724 | else qdt = alarm->time(); | 736 | else qdt = alarm->time(); |
725 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 737 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
726 | if ( alarm->enabled() ) { | 738 | if ( alarm->enabled() ) { |
727 | if ( qdt >= from && qdt <= to ) { | 739 | if ( qdt >= from && qdt <= to ) { |
728 | alarms.append( alarm ); | 740 | alarms.append( alarm ); |
729 | } | 741 | } |
730 | } | 742 | } |
731 | } | 743 | } |
732 | } | 744 | } |
733 | 745 | ||
734 | 746 | ||
735 | /****************************** PROTECTED METHODS ****************************/ | 747 | /****************************** PROTECTED METHODS ****************************/ |
736 | 748 | ||
737 | // after changes are made to an event, this should be called. | 749 | // after changes are made to an event, this should be called. |
738 | void CalendarLocal::update( IncidenceBase *incidence ) | 750 | void CalendarLocal::update( IncidenceBase *incidence ) |
739 | { | 751 | { |
740 | incidence->setSyncStatus( Event::SYNCMOD ); | 752 | incidence->setSyncStatus( Event::SYNCMOD ); |
741 | incidence->setLastModified( QDateTime::currentDateTime() ); | 753 | incidence->setLastModified( QDateTime::currentDateTime() ); |
742 | // we should probably update the revision number here, | 754 | // we should probably update the revision number here, |
743 | // or internally in the Event itself when certain things change. | 755 | // or internally in the Event itself when certain things change. |
744 | // need to verify with ical documentation. | 756 | // need to verify with ical documentation. |
745 | 757 | ||
746 | setModified( true ); | 758 | setModified( true ); |
747 | } | 759 | } |
748 | 760 | ||
749 | void CalendarLocal::insertEvent( Event *event ) | 761 | void CalendarLocal::insertEvent( Event *event ) |
750 | { | 762 | { |
751 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 763 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
752 | } | 764 | } |
753 | 765 | ||
754 | 766 | ||
755 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 767 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
756 | { | 768 | { |
757 | QPtrList<Event> eventList; | 769 | QPtrList<Event> eventList; |
758 | 770 | ||
759 | Event *event; | 771 | Event *event; |
760 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 772 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
761 | if ( !event->calEnabled() ) continue; | 773 | if ( !event->calEnabled() ) continue; |
762 | if ( event->doesRecur() ) { | 774 | if ( event->doesRecur() ) { |
763 | if ( event->isMultiDay() ) { | 775 | if ( event->isMultiDay() ) { |
764 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 776 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
765 | int i; | 777 | int i; |
766 | for ( i = 0; i <= extraDays; i++ ) { | 778 | for ( i = 0; i <= extraDays; i++ ) { |
767 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 779 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
768 | eventList.append( event ); | 780 | eventList.append( event ); |
769 | break; | 781 | break; |
770 | } | 782 | } |
771 | } | 783 | } |
772 | } else { | 784 | } else { |
773 | if ( event->recursOn( qd ) ) | 785 | if ( event->recursOn( qd ) ) |
774 | eventList.append( event ); | 786 | eventList.append( event ); |
775 | } | 787 | } |
776 | } else { | 788 | } else { |
777 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 789 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
778 | eventList.append( event ); | 790 | eventList.append( event ); |
779 | } | 791 | } |
780 | } | 792 | } |
781 | } | 793 | } |
782 | 794 | ||
783 | if ( !sorted ) { | 795 | if ( !sorted ) { |
784 | return eventList; | 796 | return eventList; |
785 | } | 797 | } |
786 | 798 | ||
787 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 799 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
788 | // now, we have to sort it based on dtStart.time() | 800 | // now, we have to sort it based on dtStart.time() |
789 | QPtrList<Event> eventListSorted; | 801 | QPtrList<Event> eventListSorted; |
790 | Event *sortEvent; | 802 | Event *sortEvent; |
791 | for ( event = eventList.first(); event; event = eventList.next() ) { | 803 | for ( event = eventList.first(); event; event = eventList.next() ) { |
792 | sortEvent = eventListSorted.first(); | 804 | sortEvent = eventListSorted.first(); |
793 | int i = 0; | 805 | int i = 0; |
794 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 806 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
795 | { | 807 | { |
796 | i++; | 808 | i++; |
797 | sortEvent = eventListSorted.next(); | 809 | sortEvent = eventListSorted.next(); |
798 | } | 810 | } |
799 | eventListSorted.insert( i, event ); | 811 | eventListSorted.insert( i, event ); |
800 | } | 812 | } |
801 | return eventListSorted; | 813 | return eventListSorted; |
802 | } | 814 | } |
803 | 815 | ||
804 | 816 | ||
805 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 817 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
806 | bool inclusive ) | 818 | bool inclusive ) |
807 | { | 819 | { |
808 | Event *event = 0; | 820 | Event *event = 0; |
809 | 821 | ||
810 | QPtrList<Event> eventList; | 822 | QPtrList<Event> eventList; |
811 | 823 | ||
812 | // Get non-recurring events | 824 | // Get non-recurring events |
813 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 825 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
814 | if ( !event->calEnabled() ) continue; | 826 | if ( !event->calEnabled() ) continue; |
815 | if ( event->doesRecur() ) { | 827 | if ( event->doesRecur() ) { |
816 | QDate rStart = event->dtStart().date(); | 828 | QDate rStart = event->dtStart().date(); |
817 | bool found = false; | 829 | bool found = false; |
818 | if ( inclusive ) { | 830 | if ( inclusive ) { |
819 | if ( rStart >= start && rStart <= end ) { | 831 | if ( rStart >= start && rStart <= end ) { |
820 | // Start date of event is in range. Now check for end date. | 832 | // Start date of event is in range. Now check for end date. |
821 | // if duration is negative, event recurs forever, so do not include it. | 833 | // if duration is negative, event recurs forever, so do not include it. |
822 | if ( event->recurrence()->duration() == 0 ) { // End date set | 834 | if ( event->recurrence()->duration() == 0 ) { // End date set |
823 | QDate rEnd = event->recurrence()->endDate(); | 835 | QDate rEnd = event->recurrence()->endDate(); |
824 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 836 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
825 | found = true; | 837 | found = true; |
826 | } | 838 | } |
827 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 839 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
828 | // TODO: Calculate end date from duration. Should be done in Event | 840 | // TODO: Calculate end date from duration. Should be done in Event |
829 | // For now exclude all events with a duration. | 841 | // For now exclude all events with a duration. |
830 | } | 842 | } |
831 | } | 843 | } |
832 | } else { | 844 | } else { |
833 | bool founOne; | 845 | bool founOne; |
834 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 846 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
835 | if ( founOne ) { | 847 | if ( founOne ) { |
836 | if ( next <= end ) { | 848 | if ( next <= end ) { |
837 | found = true; | 849 | found = true; |
838 | } | 850 | } |
839 | } | 851 | } |
840 | 852 | ||
841 | /* | 853 | /* |
842 | // crap !!! | 854 | // crap !!! |
843 | if ( rStart <= end ) { // Start date not after range | 855 | if ( rStart <= end ) { // Start date not after range |
844 | if ( rStart >= start ) { // Start date within range | 856 | if ( rStart >= start ) { // Start date within range |
845 | found = true; | 857 | found = true; |
846 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 858 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
847 | found = true; | 859 | found = true; |
848 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 860 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
849 | QDate rEnd = event->recurrence()->endDate(); | 861 | QDate rEnd = event->recurrence()->endDate(); |
850 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 862 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
851 | found = true; | 863 | found = true; |
852 | } | 864 | } |
853 | } else { // Duration set | 865 | } else { // Duration set |
854 | // TODO: Calculate end date from duration. Should be done in Event | 866 | // TODO: Calculate end date from duration. Should be done in Event |
855 | // For now include all events with a duration. | 867 | // For now include all events with a duration. |
856 | found = true; | 868 | found = true; |
857 | } | 869 | } |
858 | } | 870 | } |
859 | */ | 871 | */ |
860 | 872 | ||
861 | } | 873 | } |
862 | 874 | ||
863 | if ( found ) eventList.append( event ); | 875 | if ( found ) eventList.append( event ); |
864 | } else { | 876 | } else { |
865 | QDate s = event->dtStart().date(); | 877 | QDate s = event->dtStart().date(); |
866 | QDate e = event->dtEnd().date(); | 878 | QDate e = event->dtEnd().date(); |
867 | 879 | ||
868 | if ( inclusive ) { | 880 | if ( inclusive ) { |
869 | if ( s >= start && e <= end ) { | 881 | if ( s >= start && e <= end ) { |
870 | eventList.append( event ); | 882 | eventList.append( event ); |
871 | } | 883 | } |
872 | } else { | 884 | } else { |
873 | if ( ( e >= start && s <= end ) ) { | 885 | if ( ( e >= start && s <= end ) ) { |
874 | eventList.append( event ); | 886 | eventList.append( event ); |
875 | } | 887 | } |
876 | } | 888 | } |
877 | } | 889 | } |
878 | } | 890 | } |
879 | 891 | ||
880 | return eventList; | 892 | return eventList; |
881 | } | 893 | } |
882 | 894 | ||
883 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 895 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
884 | { | 896 | { |
885 | return rawEventsForDate( qdt.date() ); | 897 | return rawEventsForDate( qdt.date() ); |
886 | } | 898 | } |
887 | 899 | ||
888 | QPtrList<Event> CalendarLocal::rawEvents() | 900 | QPtrList<Event> CalendarLocal::rawEvents() |
889 | { | 901 | { |
890 | QPtrList<Event> el; | 902 | QPtrList<Event> el; |
891 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 903 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
892 | if ( it->calEnabled() ) el.append( it ); | 904 | if ( it->calEnabled() ) el.append( it ); |
893 | return el; | 905 | return el; |
894 | } | 906 | } |
895 | 907 | ||
896 | bool CalendarLocal::addJournal(Journal *journal) | 908 | bool CalendarLocal::addJournal(Journal *journal) |
897 | { | 909 | { |
898 | mJournalList.append(journal); | 910 | mJournalList.append(journal); |
899 | 911 | ||
900 | journal->registerObserver( this ); | 912 | journal->registerObserver( this ); |
901 | 913 | ||
902 | setModified( true ); | 914 | setModified( true ); |
903 | if ( journal->calID() == 0 ) | 915 | if ( journal->calID() == 0 ) |
904 | journal->setCalID( mDefaultCalendar ); | 916 | journal->setCalID( mDefaultCalendar ); |
905 | journal->setCalEnabled( true ); | 917 | journal->setCalEnabled( true ); |
906 | return true; | 918 | return true; |
907 | } | 919 | } |
908 | 920 | ||
909 | void CalendarLocal::deleteJournal( Journal *journal ) | 921 | void CalendarLocal::deleteJournal( Journal *journal ) |
910 | { | 922 | { |
911 | clearUndo(journal); | 923 | clearUndo(journal); |
912 | if ( mJournalList.removeRef(journal) ) { | 924 | if ( mJournalList.removeRef(journal) ) { |
913 | setModified( true ); | 925 | setModified( true ); |
914 | } | 926 | } |
915 | } | 927 | } |
916 | 928 | ||
917 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | 929 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) |
918 | { | 930 | { |
919 | QPtrList<Journal> el; | 931 | QPtrList<Journal> el; |
920 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 932 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
921 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); | 933 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); |
922 | return el; | 934 | return el; |
923 | } | 935 | } |
924 | Journal *CalendarLocal::journal( const QDate &date ) | 936 | Journal *CalendarLocal::journal( const QDate &date ) |
925 | { | 937 | { |
926 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 938 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
927 | 939 | ||
928 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 940 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
929 | if ( it->calEnabled() && it->dtStart().date() == date ) | 941 | if ( it->calEnabled() && it->dtStart().date() == date ) |
930 | return it; | 942 | return it; |
931 | 943 | ||
932 | return 0; | 944 | return 0; |
933 | } | 945 | } |
934 | 946 | ||
935 | Journal *CalendarLocal::journal( const QString &uid ) | 947 | Journal *CalendarLocal::journal( const QString &uid ) |
936 | { | 948 | { |
937 | Journal * retVal = 0; | 949 | Journal * retVal = 0; |
938 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 950 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
939 | if ( it->calEnabled() && it->uid() == uid ) { | 951 | if ( it->calEnabled() && it->uid() == uid ) { |
940 | if ( retVal ) { | 952 | if ( retVal ) { |
941 | if ( retVal->calID() > it->calID() ) { | 953 | if ( retVal->calID() > it->calID() ) { |
942 | retVal = it; | 954 | retVal = it; |
943 | } | 955 | } |
944 | } else { | 956 | } else { |
945 | retVal = it; | 957 | retVal = it; |
946 | } | 958 | } |
947 | } | 959 | } |
948 | return retVal; | 960 | return retVal; |
949 | } | 961 | } |
950 | 962 | ||
951 | QPtrList<Journal> CalendarLocal::journals() | 963 | QPtrList<Journal> CalendarLocal::journals() |
952 | { | 964 | { |
953 | QPtrList<Journal> el; | 965 | QPtrList<Journal> el; |
954 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 966 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
955 | if ( it->calEnabled() ) el.append( it ); | 967 | if ( it->calEnabled() ) el.append( it ); |
956 | return el; | 968 | return el; |
957 | } | 969 | } |
958 | void CalendarLocal::setCalendarRemove( int id ) | 970 | void CalendarLocal::setCalendarRemove( int id ) |
959 | { | 971 | { |
960 | 972 | ||
961 | { | 973 | { |
962 | QPtrList<Event> EventList = mEventList; | 974 | QPtrList<Event> EventList = mEventList; |
963 | Event * ev = EventList.first(); | 975 | Event * ev = EventList.first(); |
964 | while ( ev ) { | 976 | while ( ev ) { |
965 | if ( ev->calID() == id ) | 977 | if ( ev->calID() == id ) |
966 | deleteEvent( ev ); | 978 | deleteEvent( ev ); |
967 | ev = EventList.next(); | 979 | ev = EventList.next(); |
968 | } | 980 | } |
969 | } | 981 | } |
970 | { | 982 | { |
971 | 983 | ||
972 | QPtrList<Todo> TodoList = mTodoList; | 984 | QPtrList<Todo> TodoList = mTodoList; |
973 | Todo * ev = TodoList.first(); | 985 | Todo * ev = TodoList.first(); |
974 | while ( ev ) { | 986 | while ( ev ) { |
975 | if ( ev->calID() == id ) | 987 | if ( ev->calID() == id ) |
976 | deleteTodo( ev ); | 988 | deleteTodo( ev ); |
977 | ev = TodoList.next(); | 989 | ev = TodoList.next(); |
978 | } | 990 | } |
979 | } | 991 | } |
980 | { | 992 | { |
981 | QPtrList<Journal> JournalList = mJournalList; | 993 | QPtrList<Journal> JournalList = mJournalList; |
982 | Journal * ev = JournalList.first(); | 994 | Journal * ev = JournalList.first(); |
983 | while ( ev ) { | 995 | while ( ev ) { |
984 | if ( ev->calID() == id ) | 996 | if ( ev->calID() == id ) |
985 | deleteJournal( ev ); | 997 | deleteJournal( ev ); |
986 | ev = JournalList.next(); | 998 | ev = JournalList.next(); |
987 | } | 999 | } |
988 | } | 1000 | } |
989 | 1001 | ||
990 | clearUndo(0); | 1002 | clearUndo(0); |
991 | 1003 | ||
992 | } | 1004 | } |
993 | 1005 | ||
994 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 1006 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
995 | { | 1007 | { |
996 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1008 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
997 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1009 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
998 | 1010 | ||
999 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1011 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1000 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1012 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1001 | 1013 | ||
1002 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1014 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1003 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1015 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1004 | 1016 | ||
1005 | } | 1017 | } |
1006 | 1018 | ||
1007 | void CalendarLocal::setReadOnly( int id, bool enable ) | 1019 | void CalendarLocal::setReadOnly( int id, bool enable ) |
1008 | { | 1020 | { |
1009 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1021 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1010 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1022 | if ( it->calID() == id ) it->setReadOnly( enable ); |
1011 | 1023 | ||
1012 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1024 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1013 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1025 | if ( it->calID() == id ) it->setReadOnly( enable ); |
1014 | 1026 | ||
1015 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1027 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1016 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1028 | if ( it->calID() == id ) it->setReadOnly( enable ); |
1017 | 1029 | ||
1018 | } | 1030 | } |
1019 | 1031 | ||
1020 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 1032 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
1021 | { | 1033 | { |
1022 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1034 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1023 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1035 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1024 | 1036 | ||
1025 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1037 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1026 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1038 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1027 | 1039 | ||
1028 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1040 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1029 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1041 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1030 | reInitAlarmSettings(); | 1042 | reInitAlarmSettings(); |
1031 | 1043 | ||
1032 | } | 1044 | } |
1033 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 1045 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
1034 | { | 1046 | { |
1035 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1047 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1036 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 1048 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
1037 | 1049 | ||
1038 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1050 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1039 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1051 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1040 | 1052 | ||
1041 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1053 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1042 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1054 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1043 | 1055 | ||
1044 | } | 1056 | } |
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 |