author | zautrix <zautrix> | 2005-09-17 22:07:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-17 22:07:21 (UTC) |
commit | 64199073c047a30f3cff85fe6ee30691ff0db2f7 (patch) (unidiff) | |
tree | 5ff49088999f2c02fb2a40760b881c02f50cfc35 | |
parent | e228113016abd6f75824633da9520c1ec1763f23 (diff) | |
download | kdepimpi-64199073c047a30f3cff85fe6ee30691ff0db2f7.zip kdepimpi-64199073c047a30f3cff85fe6ee30691ff0db2f7.tar.gz kdepimpi-64199073c047a30f3cff85fe6ee30691ff0db2f7.tar.bz2 |
savetimer
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 22 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 |
3 files changed, 23 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 14094bb..79fb727 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,5157 +1,5157 @@ | |||
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 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy (NoFocus ); | 370 | setFocusPolicy (NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | mConflictingEvent = 0; | 373 | mConflictingEvent = 0; |
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | //qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | 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); | 837 | 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); |
838 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
839 | } | 839 | } |
840 | static bool firstTime = true; | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | 841 | if ( firstTime ) { |
842 | firstTime = false; | 842 | firstTime = false; |
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
847 | { | 847 | { |
848 | KConfig *config = KOGlobals::config(); | 848 | KConfig *config = KOGlobals::config(); |
849 | config->setGroup( "AppRun" ); | 849 | config->setGroup( "AppRun" ); |
850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
851 | int daysto = dt.daysTo( QDate::currentDate() ); | 851 | int daysto = dt.daysTo( QDate::currentDate() ); |
852 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 852 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
853 | dt = dt.addDays( days ); | 853 | dt = dt.addDays( days ); |
854 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 854 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
855 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 855 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
856 | //qDebug("KO: Reading program stop %d ", secs); | 856 | //qDebug("KO: Reading program stop %d ", secs); |
857 | //secs -= ( 3600 * 24*3 ); // debug only | 857 | //secs -= ( 3600 * 24*3 ); // debug only |
858 | QDateTime latest = dt.addSecs ( secs ); | 858 | QDateTime latest = dt.addSecs ( secs ); |
859 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 859 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
860 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 860 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
861 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 861 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
862 | QPtrList<Incidence> al; | 862 | QPtrList<Incidence> al; |
863 | Incidence* inL = el.first(); | 863 | Incidence* inL = el.first(); |
864 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 864 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
865 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 865 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
866 | while ( inL ) { | 866 | while ( inL ) { |
867 | bool ok = false; | 867 | bool ok = false; |
868 | int offset = 0; | 868 | int offset = 0; |
869 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 869 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
870 | if ( ok ) { | 870 | if ( ok ) { |
871 | //qDebug("OK %s",next.toString().latin1()); | 871 | //qDebug("OK %s",next.toString().latin1()); |
872 | if ( next < cur ) { | 872 | if ( next < cur ) { |
873 | al.append( inL ); | 873 | al.append( inL ); |
874 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 874 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
875 | } | 875 | } |
876 | } | 876 | } |
877 | inL = el.next(); | 877 | inL = el.next(); |
878 | } | 878 | } |
879 | if ( al.count() ) { | 879 | if ( al.count() ) { |
880 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 880 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
881 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 881 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
882 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 882 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
883 | lay->setSpacing( 0 ); | 883 | lay->setSpacing( 0 ); |
884 | lay->setMargin( 0 ); | 884 | lay->setMargin( 0 ); |
885 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 885 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
886 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 886 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
887 | lay->addWidget( matb ); | 887 | lay->addWidget( matb ); |
888 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 888 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
889 | int wid = 210; | 889 | int wid = 210; |
890 | int x = QApplication::desktop()->width() - wid - 7; | 890 | int x = QApplication::desktop()->width() - wid - 7; |
891 | int y = QApplication::desktop()->height() - wid - 70; | 891 | int y = QApplication::desktop()->height() - wid - 70; |
892 | dia->setGeometry ( x,y,wid,wid); | 892 | dia->setGeometry ( x,y,wid,wid); |
893 | } else { | 893 | } else { |
894 | int si = 220; | 894 | int si = 220; |
895 | if ( QApplication::desktop()->width() > 470 ) | 895 | if ( QApplication::desktop()->width() > 470 ) |
896 | si = 400; | 896 | si = 400; |
897 | dia->resize(si,si/2); | 897 | dia->resize(si,si/2); |
898 | } | 898 | } |
899 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 899 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
900 | dia->show(); | 900 | dia->show(); |
901 | 901 | ||
902 | } | 902 | } |
903 | #if 0 | 903 | #if 0 |
904 | // for creating timetracker test data | 904 | // for creating timetracker test data |
905 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 905 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
906 | Todo * nt; | 906 | Todo * nt; |
907 | mCalendar->close(); | 907 | mCalendar->close(); |
908 | { | 908 | { |
909 | Todo * root1 = new Todo; | 909 | Todo * root1 = new Todo; |
910 | mCalendar->addTodo( root1 ); | 910 | mCalendar->addTodo( root1 ); |
911 | root1->setSummary( "Project1"); | 911 | root1->setSummary( "Project1"); |
912 | root1->setPriority( 1 ); | 912 | root1->setPriority( 1 ); |
913 | root1->setCategories( QString( "Cat_Pro1") ); | 913 | root1->setCategories( QString( "Cat_Pro1") ); |
914 | root1->setDescription( "This is a test description of a root Project" ); | 914 | root1->setDescription( "This is a test description of a root Project" ); |
915 | root1->setPercentComplete( 20 ); | 915 | root1->setPercentComplete( 20 ); |
916 | updateView(); | 916 | updateView(); |
917 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 917 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
918 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 918 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
919 | 919 | ||
920 | nt = new Todo; | 920 | nt = new Todo; |
921 | mCalendar->addTodo( nt ); | 921 | mCalendar->addTodo( nt ); |
922 | nt->setSummary( "Planning Project1"); | 922 | nt->setSummary( "Planning Project1"); |
923 | nt->setPriority( 1 ); | 923 | nt->setPriority( 1 ); |
924 | nt->setDescription( "This is a test description of Planning Project1" ); | 924 | nt->setDescription( "This is a test description of Planning Project1" ); |
925 | nt->setPercentComplete( 20 ); | 925 | nt->setPercentComplete( 20 ); |
926 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); | 926 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); |
927 | 927 | ||
928 | 928 | ||
929 | Todo * sub1 = nt; | 929 | Todo * sub1 = nt; |
930 | sub1->setRelatedTo( root1 ); | 930 | sub1->setRelatedTo( root1 ); |
931 | 931 | ||
932 | nt = new Todo; | 932 | nt = new Todo; |
933 | mCalendar->addTodo( nt ); | 933 | mCalendar->addTodo( nt ); |
934 | nt->setSummary( "Planning Project1: Lutz"); | 934 | nt->setSummary( "Planning Project1: Lutz"); |
935 | nt->setPriority( 1 ); | 935 | nt->setPriority( 1 ); |
936 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 936 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
937 | nt->setPercentComplete( 20 ); | 937 | nt->setPercentComplete( 20 ); |
938 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); | 938 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); |
939 | Todo * workLutz11 = nt; | 939 | Todo * workLutz11 = nt; |
940 | workLutz11->setRelatedTo( sub1 ); | 940 | workLutz11->setRelatedTo( sub1 ); |
941 | 941 | ||
942 | nt = new Todo; | 942 | nt = new Todo; |
943 | mCalendar->addTodo( nt ); | 943 | mCalendar->addTodo( nt ); |
944 | nt->setSummary( "Planning Project1: Norbert"); | 944 | nt->setSummary( "Planning Project1: Norbert"); |
945 | nt->setPriority( 1 ); | 945 | nt->setPriority( 1 ); |
946 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 946 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
947 | nt->setPercentComplete( 20 ); | 947 | nt->setPercentComplete( 20 ); |
948 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); | 948 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); |
949 | Todo * workNorbert11 = nt; | 949 | Todo * workNorbert11 = nt; |
950 | workNorbert11->setRelatedTo( sub1 ); | 950 | workNorbert11->setRelatedTo( sub1 ); |
951 | 951 | ||
952 | nt = new Todo; | 952 | nt = new Todo; |
953 | mCalendar->addTodo( nt ); | 953 | mCalendar->addTodo( nt ); |
954 | nt->setSummary( "Work on 1"); | 954 | nt->setSummary( "Work on 1"); |
955 | nt->setPriority( 1 ); | 955 | nt->setPriority( 1 ); |
956 | nt->setDescription( "This is a test description of Work Project_1" ); | 956 | nt->setDescription( "This is a test description of Work Project_1" ); |
957 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 957 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
958 | nt->setPercentComplete( 20 ); | 958 | nt->setPercentComplete( 20 ); |
959 | 959 | ||
960 | Todo * sub2 = nt; | 960 | Todo * sub2 = nt; |
961 | sub2->setRelatedTo( root1 ); | 961 | sub2->setRelatedTo( root1 ); |
962 | 962 | ||
963 | 963 | ||
964 | nt = new Todo; | 964 | nt = new Todo; |
965 | mCalendar->addTodo( nt ); | 965 | mCalendar->addTodo( nt ); |
966 | nt->setSummary( "Work on 1: Lutz"); | 966 | nt->setSummary( "Work on 1: Lutz"); |
967 | nt->setPriority( 1 ); | 967 | nt->setPriority( 1 ); |
968 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 968 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
969 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 969 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
970 | nt->setPercentComplete( 20 ); | 970 | nt->setPercentComplete( 20 ); |
971 | Todo * workLutz12 = nt; | 971 | Todo * workLutz12 = nt; |
972 | workLutz12->setRelatedTo( sub2 ); | 972 | workLutz12->setRelatedTo( sub2 ); |
973 | 973 | ||
974 | nt = new Todo; | 974 | nt = new Todo; |
975 | mCalendar->addTodo( nt ); | 975 | mCalendar->addTodo( nt ); |
976 | nt->setSummary( "Work on 1: Norbert"); | 976 | nt->setSummary( "Work on 1: Norbert"); |
977 | nt->setPriority( 1 ); | 977 | nt->setPriority( 1 ); |
978 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 978 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
979 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 979 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
980 | nt->setPercentComplete( 20 ); | 980 | nt->setPercentComplete( 20 ); |
981 | Todo * workNorbert12 = nt; | 981 | Todo * workNorbert12 = nt; |
982 | workNorbert12->setRelatedTo( sub2 ); | 982 | workNorbert12->setRelatedTo( sub2 ); |
983 | 983 | ||
984 | int secLenRunning = 7200; | 984 | int secLenRunning = 7200; |
985 | int secLenPausing = 3600 * 3; | 985 | int secLenPausing = 3600 * 3; |
986 | int dayInterval = 1; | 986 | int dayInterval = 1; |
987 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 987 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
988 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 988 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
989 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 989 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
990 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 990 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
991 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 991 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
992 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 992 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
993 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 993 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
994 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 994 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
995 | 995 | ||
996 | } | 996 | } |
997 | 997 | ||
998 | { | 998 | { |
999 | Todo * root1 = new Todo; | 999 | Todo * root1 = new Todo; |
1000 | mCalendar->addTodo( root1 ); | 1000 | mCalendar->addTodo( root1 ); |
1001 | root1->setSummary( "Project2"); | 1001 | root1->setSummary( "Project2"); |
1002 | root1->setPriority( 1 ); | 1002 | root1->setPriority( 1 ); |
1003 | root1->setDescription( "This is a test description of a root Project 2" ); | 1003 | root1->setDescription( "This is a test description of a root Project 2" ); |
1004 | root1->setPercentComplete( 20 ); | 1004 | root1->setPercentComplete( 20 ); |
1005 | root1->setCategories( QString( "Cat_Pro2") ); | 1005 | root1->setCategories( QString( "Cat_Pro2") ); |
1006 | updateView(); | 1006 | updateView(); |
1007 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1007 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1008 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1008 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1009 | int secLenRunning = 7200; | 1009 | int secLenRunning = 7200; |
1010 | int secLenPausing = 3600 * 3; | 1010 | int secLenPausing = 3600 * 3; |
1011 | int dayInterval = 1; | 1011 | int dayInterval = 1; |
1012 | 1012 | ||
1013 | nt = new Todo; | 1013 | nt = new Todo; |
1014 | mCalendar->addTodo( nt ); | 1014 | mCalendar->addTodo( nt ); |
1015 | nt->setSummary( "Planning Project2"); | 1015 | nt->setSummary( "Planning Project2"); |
1016 | nt->setPriority( 1 ); | 1016 | nt->setPriority( 1 ); |
1017 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1017 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1018 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1018 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1019 | nt->setPercentComplete( 20 ); | 1019 | nt->setPercentComplete( 20 ); |
1020 | 1020 | ||
1021 | 1021 | ||
1022 | Todo * sub1 = nt; | 1022 | Todo * sub1 = nt; |
1023 | sub1->setRelatedTo( root1 ); | 1023 | sub1->setRelatedTo( root1 ); |
1024 | 1024 | ||
1025 | nt = new Todo; | 1025 | nt = new Todo; |
1026 | mCalendar->addTodo( nt ); | 1026 | mCalendar->addTodo( nt ); |
1027 | nt->setSummary( "Planning Project2: Lutz"); | 1027 | nt->setSummary( "Planning Project2: Lutz"); |
1028 | nt->setPriority( 1 ); | 1028 | nt->setPriority( 1 ); |
1029 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1029 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1030 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1030 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1031 | nt->setPercentComplete( 20 ); | 1031 | nt->setPercentComplete( 20 ); |
1032 | Todo * workLutz11 = nt; | 1032 | Todo * workLutz11 = nt; |
1033 | workLutz11->setRelatedTo( sub1 ); | 1033 | workLutz11->setRelatedTo( sub1 ); |
1034 | 1034 | ||
1035 | nt = new Todo; | 1035 | nt = new Todo; |
1036 | mCalendar->addTodo( nt ); | 1036 | mCalendar->addTodo( nt ); |
1037 | nt->setSummary( "Planning Project2: Norbert"); | 1037 | nt->setSummary( "Planning Project2: Norbert"); |
1038 | nt->setPriority( 1 ); | 1038 | nt->setPriority( 1 ); |
1039 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1039 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1040 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1040 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1041 | nt->setPercentComplete( 20 ); | 1041 | nt->setPercentComplete( 20 ); |
1042 | Todo * workNorbert11 = nt; | 1042 | Todo * workNorbert11 = nt; |
1043 | workNorbert11->setRelatedTo( sub1 ); | 1043 | workNorbert11->setRelatedTo( sub1 ); |
1044 | 1044 | ||
1045 | nt = new Todo; | 1045 | nt = new Todo; |
1046 | mCalendar->addTodo( nt ); | 1046 | mCalendar->addTodo( nt ); |
1047 | nt->setSummary( "Work on 2"); | 1047 | nt->setSummary( "Work on 2"); |
1048 | nt->setPriority( 1 ); | 1048 | nt->setPriority( 1 ); |
1049 | nt->setDescription( "This is a test description of Work Project_2" ); | 1049 | nt->setDescription( "This is a test description of Work Project_2" ); |
1050 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1050 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1051 | nt->setPercentComplete( 20 ); | 1051 | nt->setPercentComplete( 20 ); |
1052 | 1052 | ||
1053 | Todo * sub2 = nt; | 1053 | Todo * sub2 = nt; |
1054 | sub2->setRelatedTo( root1 ); | 1054 | sub2->setRelatedTo( root1 ); |
1055 | 1055 | ||
1056 | 1056 | ||
1057 | nt = new Todo; | 1057 | nt = new Todo; |
1058 | mCalendar->addTodo( nt ); | 1058 | mCalendar->addTodo( nt ); |
1059 | nt->setSummary( "Work on 2: Lutz"); | 1059 | nt->setSummary( "Work on 2: Lutz"); |
1060 | nt->setPriority( 1 ); | 1060 | nt->setPriority( 1 ); |
1061 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1061 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1062 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1062 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1063 | nt->setPercentComplete( 20 ); | 1063 | nt->setPercentComplete( 20 ); |
1064 | Todo * workLutz12 = nt; | 1064 | Todo * workLutz12 = nt; |
1065 | workLutz12->setRelatedTo( sub2 ); | 1065 | workLutz12->setRelatedTo( sub2 ); |
1066 | 1066 | ||
1067 | nt = new Todo; | 1067 | nt = new Todo; |
1068 | mCalendar->addTodo( nt ); | 1068 | mCalendar->addTodo( nt ); |
1069 | nt->setSummary( "Work on 2: Norbert"); | 1069 | nt->setSummary( "Work on 2: Norbert"); |
1070 | nt->setPriority( 1 ); | 1070 | nt->setPriority( 1 ); |
1071 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1071 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1072 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1072 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1073 | nt->setPercentComplete( 20 ); | 1073 | nt->setPercentComplete( 20 ); |
1074 | Todo * workNorbert12 = nt; | 1074 | Todo * workNorbert12 = nt; |
1075 | workNorbert12->setRelatedTo( sub2 ); | 1075 | workNorbert12->setRelatedTo( sub2 ); |
1076 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1076 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1077 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1077 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1078 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1078 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1079 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1079 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1080 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1080 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1081 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1081 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1082 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1082 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1083 | } | 1083 | } |
1084 | updateView(); | 1084 | updateView(); |
1085 | #endif | 1085 | #endif |
1086 | 1086 | ||
1087 | } | 1087 | } |
1088 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1088 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1089 | { | 1089 | { |
1090 | static int ccc = 0; | 1090 | static int ccc = 0; |
1091 | ++ccc; | 1091 | ++ccc; |
1092 | QDateTime t_start = start; | 1092 | QDateTime t_start = start; |
1093 | runT->setPriority( 5 ); | 1093 | runT->setPriority( 5 ); |
1094 | runT->setPercentComplete( 0 ); | 1094 | runT->setPercentComplete( 0 ); |
1095 | int count = 0; | 1095 | int count = 0; |
1096 | int prio = 5; | 1096 | int prio = 5; |
1097 | int complete = 0; | 1097 | int complete = 0; |
1098 | while ( t_start < end ) { | 1098 | while ( t_start < end ) { |
1099 | ++count; | 1099 | ++count; |
1100 | if ( count > ccc ) { | 1100 | if ( count > ccc ) { |
1101 | count = 0; | 1101 | count = 0; |
1102 | --prio; | 1102 | --prio; |
1103 | if ( prio == 0 ) prio = 5; | 1103 | if ( prio == 0 ) prio = 5; |
1104 | complete += 20; | 1104 | complete += 20; |
1105 | if ( complete > 100 ) complete = 0; | 1105 | if ( complete > 100 ) complete = 0; |
1106 | runT->setPriority( prio ); | 1106 | runT->setPriority( prio ); |
1107 | runT->setPercentComplete( complete ); | 1107 | runT->setPercentComplete( complete ); |
1108 | } | 1108 | } |
1109 | runT->setRunning( true ); | 1109 | runT->setRunning( true ); |
1110 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1110 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1111 | if ( dayInterval ) | 1111 | if ( dayInterval ) |
1112 | t_start = t_start.addDays( dayInterval ); | 1112 | t_start = t_start.addDays( dayInterval ); |
1113 | else { | 1113 | else { |
1114 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1114 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void CalendarView::showDay( QDate d ) | 1119 | void CalendarView::showDay( QDate d ) |
1120 | { | 1120 | { |
1121 | dateNavigator()->blockSignals( true ); | 1121 | dateNavigator()->blockSignals( true ); |
1122 | dateNavigator()->selectDate( d ); | 1122 | dateNavigator()->selectDate( d ); |
1123 | dateNavigator()->blockSignals( false ); | 1123 | dateNavigator()->blockSignals( false ); |
1124 | mViewManager->showDayView(); | 1124 | mViewManager->showDayView(); |
1125 | //dateNavigator()->selectDate( d ); | 1125 | //dateNavigator()->selectDate( d ); |
1126 | } | 1126 | } |
1127 | void CalendarView::timerAlarm() | 1127 | void CalendarView::timerAlarm() |
1128 | { | 1128 | { |
1129 | //qDebug("CalendarView::timerAlarm() "); | 1129 | //qDebug("CalendarView::timerAlarm() "); |
1130 | computeAlarm(mAlarmNotification ); | 1130 | computeAlarm(mAlarmNotification ); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | void CalendarView::suspendAlarm() | 1133 | void CalendarView::suspendAlarm() |
1134 | { | 1134 | { |
1135 | //qDebug(" CalendarView::suspendAlarm() "); | 1135 | //qDebug(" CalendarView::suspendAlarm() "); |
1136 | computeAlarm(mSuspendAlarmNotification ); | 1136 | computeAlarm(mSuspendAlarmNotification ); |
1137 | 1137 | ||
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | void CalendarView::startAlarm( QString mess , QString filename) | 1140 | void CalendarView::startAlarm( QString mess , QString filename) |
1141 | { | 1141 | { |
1142 | 1142 | ||
1143 | topLevelWidget()->showNormal(); | 1143 | topLevelWidget()->showNormal(); |
1144 | topLevelWidget()->setActiveWindow(); | 1144 | topLevelWidget()->setActiveWindow(); |
1145 | topLevelWidget()->raise(); | 1145 | topLevelWidget()->raise(); |
1146 | 1146 | ||
1147 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1147 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1148 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1148 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1149 | 1149 | ||
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | void CalendarView::checkNextTimerAlarm() | 1152 | void CalendarView::checkNextTimerAlarm() |
1153 | { | 1153 | { |
1154 | mCalendar->checkAlarmForIncidence( 0, true ); | 1154 | mCalendar->checkAlarmForIncidence( 0, true ); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void CalendarView::computeAlarm( QString msg ) | 1157 | void CalendarView::computeAlarm( QString msg ) |
1158 | { | 1158 | { |
1159 | 1159 | ||
1160 | QString mess = msg; | 1160 | QString mess = msg; |
1161 | QString mAlarmMessage = mess.mid( 9 ); | 1161 | QString mAlarmMessage = mess.mid( 9 ); |
1162 | QString filename = MainWindow::resourcePath(); | 1162 | QString filename = MainWindow::resourcePath(); |
1163 | filename += "koalarm.wav"; | 1163 | filename += "koalarm.wav"; |
1164 | QString tempfilename; | 1164 | QString tempfilename; |
1165 | if ( mess.left( 13 ) == "suspend_alarm") { | 1165 | if ( mess.left( 13 ) == "suspend_alarm") { |
1166 | bool error = false; | 1166 | bool error = false; |
1167 | int len = mess.mid( 13 ).find("+++"); | 1167 | int len = mess.mid( 13 ).find("+++"); |
1168 | if ( len < 2 ) | 1168 | if ( len < 2 ) |
1169 | error = true; | 1169 | error = true; |
1170 | else { | 1170 | else { |
1171 | tempfilename = mess.mid( 13, len ); | 1171 | tempfilename = mess.mid( 13, len ); |
1172 | if ( !QFile::exists( tempfilename ) ) | 1172 | if ( !QFile::exists( tempfilename ) ) |
1173 | error = true; | 1173 | error = true; |
1174 | } | 1174 | } |
1175 | if ( ! error ) { | 1175 | if ( ! error ) { |
1176 | filename = tempfilename; | 1176 | filename = tempfilename; |
1177 | } | 1177 | } |
1178 | mAlarmMessage = mess.mid( 13+len+3 ); | 1178 | mAlarmMessage = mess.mid( 13+len+3 ); |
1179 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1179 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1180 | startAlarm( mAlarmMessage, filename); | 1180 | startAlarm( mAlarmMessage, filename); |
1181 | return; | 1181 | return; |
1182 | } | 1182 | } |
1183 | if ( mess.left( 11 ) == "timer_alarm") { | 1183 | if ( mess.left( 11 ) == "timer_alarm") { |
1184 | //mTimerTime = 0; | 1184 | //mTimerTime = 0; |
1185 | startAlarm( mess.mid( 11 ), filename ); | 1185 | startAlarm( mess.mid( 11 ), filename ); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | if ( mess.left( 10 ) == "proc_alarm") { | 1188 | if ( mess.left( 10 ) == "proc_alarm") { |
1189 | bool error = false; | 1189 | bool error = false; |
1190 | int len = mess.mid( 10 ).find("+++"); | 1190 | int len = mess.mid( 10 ).find("+++"); |
1191 | if ( len < 2 ) | 1191 | if ( len < 2 ) |
1192 | error = true; | 1192 | error = true; |
1193 | else { | 1193 | else { |
1194 | tempfilename = mess.mid( 10, len ); | 1194 | tempfilename = mess.mid( 10, len ); |
1195 | if ( !QFile::exists( tempfilename ) ) | 1195 | if ( !QFile::exists( tempfilename ) ) |
1196 | error = true; | 1196 | error = true; |
1197 | } | 1197 | } |
1198 | if ( error ) { | 1198 | if ( error ) { |
1199 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1199 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1200 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1200 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1201 | } else { | 1201 | } else { |
1202 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1202 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1203 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1203 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1204 | #ifndef _WIN32_ | 1204 | #ifndef _WIN32_ |
1205 | if ( vfork () == 0 ) { | 1205 | if ( vfork () == 0 ) { |
1206 | execl ( tempfilename.latin1(), 0 ); | 1206 | execl ( tempfilename.latin1(), 0 ); |
1207 | return; | 1207 | return; |
1208 | } | 1208 | } |
1209 | #else | 1209 | #else |
1210 | QProcess* p = new QProcess(); | 1210 | QProcess* p = new QProcess(); |
1211 | p->addArgument( tempfilename.latin1() ); | 1211 | p->addArgument( tempfilename.latin1() ); |
1212 | p->start(); | 1212 | p->start(); |
1213 | return; | 1213 | return; |
1214 | #endif | 1214 | #endif |
1215 | 1215 | ||
1216 | return; | 1216 | return; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1219 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1220 | } | 1220 | } |
1221 | if ( mess.left( 11 ) == "audio_alarm") { | 1221 | if ( mess.left( 11 ) == "audio_alarm") { |
1222 | bool error = false; | 1222 | bool error = false; |
1223 | int len = mess.mid( 11 ).find("+++"); | 1223 | int len = mess.mid( 11 ).find("+++"); |
1224 | if ( len < 2 ) | 1224 | if ( len < 2 ) |
1225 | error = true; | 1225 | error = true; |
1226 | else { | 1226 | else { |
1227 | tempfilename = mess.mid( 11, len ); | 1227 | tempfilename = mess.mid( 11, len ); |
1228 | if ( !QFile::exists( tempfilename ) ) | 1228 | if ( !QFile::exists( tempfilename ) ) |
1229 | error = true; | 1229 | error = true; |
1230 | } | 1230 | } |
1231 | if ( ! error ) { | 1231 | if ( ! error ) { |
1232 | filename = tempfilename; | 1232 | filename = tempfilename; |
1233 | } | 1233 | } |
1234 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1234 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1235 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1235 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1236 | } | 1236 | } |
1237 | if ( mess.left( 9 ) == "cal_alarm") { | 1237 | if ( mess.left( 9 ) == "cal_alarm") { |
1238 | mAlarmMessage = mess.mid( 9 ) ; | 1238 | mAlarmMessage = mess.mid( 9 ) ; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | startAlarm( mAlarmMessage, filename ); | 1241 | startAlarm( mAlarmMessage, filename ); |
1242 | 1242 | ||
1243 | 1243 | ||
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1246 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1247 | { | 1247 | { |
1248 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1248 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1249 | 1249 | ||
1250 | mSuspendAlarmNotification = noti; | 1250 | mSuspendAlarmNotification = noti; |
1251 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1251 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1252 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1252 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1253 | mSuspendTimer->start( ms , true ); | 1253 | mSuspendTimer->start( ms , true ); |
1254 | #ifdef DESKTOP_VERSION | 1254 | #ifdef DESKTOP_VERSION |
1255 | if ( QApplication::desktop()->width() < 1024 ) { | 1255 | if ( QApplication::desktop()->width() < 1024 ) { |
1256 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1256 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1257 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1257 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1258 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1258 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1259 | QFile file( fn ); | 1259 | QFile file( fn ); |
1260 | if (!file.open( IO_WriteOnly ) ) { | 1260 | if (!file.open( IO_WriteOnly ) ) { |
1261 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1261 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1262 | } else { | 1262 | } else { |
1263 | QTextStream ts( &file ); | 1263 | QTextStream ts( &file ); |
1264 | ts << mess; | 1264 | ts << mess; |
1265 | file.close(); | 1265 | file.close(); |
1266 | } | 1266 | } |
1267 | } | 1267 | } |
1268 | #endif | 1268 | #endif |
1269 | 1269 | ||
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1272 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1273 | { | 1273 | { |
1274 | mNextAlarmDateTime = qdt; | 1274 | mNextAlarmDateTime = qdt; |
1275 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1275 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1276 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1276 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1277 | #ifndef DESKTOP_VERSION | 1277 | #ifndef DESKTOP_VERSION |
1278 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1278 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1279 | #endif | 1279 | #endif |
1280 | return; | 1280 | return; |
1281 | } | 1281 | } |
1282 | #ifdef DESKTOP_VERSION | 1282 | #ifdef DESKTOP_VERSION |
1283 | if ( QApplication::desktop()->width() < 1024 ) { | 1283 | if ( QApplication::desktop()->width() < 1024 ) { |
1284 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1284 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1285 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1285 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1286 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1286 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1287 | QFile file( fn ); | 1287 | QFile file( fn ); |
1288 | if (!file.open( IO_WriteOnly ) ) { | 1288 | if (!file.open( IO_WriteOnly ) ) { |
1289 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1289 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1290 | } else { | 1290 | } else { |
1291 | QTextStream ts( &file ); | 1291 | QTextStream ts( &file ); |
1292 | ts << mess; | 1292 | ts << mess; |
1293 | file.close(); | 1293 | file.close(); |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | #endif | 1296 | #endif |
1297 | int maxSec; | 1297 | int maxSec; |
1298 | //maxSec = 5; //testing only | 1298 | //maxSec = 5; //testing only |
1299 | maxSec = 86400+3600; // one day+1hour | 1299 | maxSec = 86400+3600; // one day+1hour |
1300 | mAlarmNotification = noti; | 1300 | mAlarmNotification = noti; |
1301 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1301 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1302 | if ( sec > maxSec ) { | 1302 | if ( sec > maxSec ) { |
1303 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1303 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1304 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1304 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1305 | return; | 1305 | return; |
1306 | } else { | 1306 | } else { |
1307 | mRecheckAlarmTimer->stop(); | 1307 | mRecheckAlarmTimer->stop(); |
1308 | } | 1308 | } |
1309 | //qDebug("Alarm timer started with secs: %d ", sec); | 1309 | //qDebug("Alarm timer started with secs: %d ", sec); |
1310 | mAlarmTimer->start( sec * 1000 , true ); | 1310 | mAlarmTimer->start( sec * 1000 , true ); |
1311 | 1311 | ||
1312 | } | 1312 | } |
1313 | // called by mRecheckAlarmTimer to get next alarm | 1313 | // called by mRecheckAlarmTimer to get next alarm |
1314 | // we need this, because a QTimer has only a max range of 25 days | 1314 | // we need this, because a QTimer has only a max range of 25 days |
1315 | void CalendarView::recheckTimerAlarm() | 1315 | void CalendarView::recheckTimerAlarm() |
1316 | { | 1316 | { |
1317 | mAlarmTimer->stop(); | 1317 | mAlarmTimer->stop(); |
1318 | mRecheckAlarmTimer->stop(); | 1318 | mRecheckAlarmTimer->stop(); |
1319 | mCalendar->checkAlarmForIncidence( 0, true ); | 1319 | mCalendar->checkAlarmForIncidence( 0, true ); |
1320 | } | 1320 | } |
1321 | #ifndef DESKTOP_VERSION | 1321 | #ifndef DESKTOP_VERSION |
1322 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1322 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1323 | #else | 1323 | #else |
1324 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1324 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1325 | #endif | 1325 | #endif |
1326 | { | 1326 | { |
1327 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1327 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1328 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1328 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1329 | #ifndef DESKTOP_VERSION | 1329 | #ifndef DESKTOP_VERSION |
1330 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1330 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1331 | #endif | 1331 | #endif |
1332 | return; | 1332 | return; |
1333 | } | 1333 | } |
1334 | mAlarmTimer->stop(); | 1334 | mAlarmTimer->stop(); |
1335 | } | 1335 | } |
1336 | void CalendarView::selectWeekNum ( int num ) | 1336 | void CalendarView::selectWeekNum ( int num ) |
1337 | { | 1337 | { |
1338 | dateNavigator()->blockSignals( true ); | 1338 | dateNavigator()->blockSignals( true ); |
1339 | dateNavigator()->selectWeek( num ); | 1339 | dateNavigator()->selectWeek( num ); |
1340 | dateNavigator()->blockSignals( false ); | 1340 | dateNavigator()->blockSignals( false ); |
1341 | mViewManager->showWeekView(); | 1341 | mViewManager->showWeekView(); |
1342 | } | 1342 | } |
1343 | KOViewManager *CalendarView::viewManager() | 1343 | KOViewManager *CalendarView::viewManager() |
1344 | { | 1344 | { |
1345 | return mViewManager; | 1345 | return mViewManager; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | KODialogManager *CalendarView::dialogManager() | 1348 | KODialogManager *CalendarView::dialogManager() |
1349 | { | 1349 | { |
1350 | return mDialogManager; | 1350 | return mDialogManager; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | QDate CalendarView::startDate() | 1353 | QDate CalendarView::startDate() |
1354 | { | 1354 | { |
1355 | DateList dates = mNavigator->selectedDates(); | 1355 | DateList dates = mNavigator->selectedDates(); |
1356 | 1356 | ||
1357 | return dates.first(); | 1357 | return dates.first(); |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | QDate CalendarView::endDate() | 1360 | QDate CalendarView::endDate() |
1361 | { | 1361 | { |
1362 | DateList dates = mNavigator->selectedDates(); | 1362 | DateList dates = mNavigator->selectedDates(); |
1363 | 1363 | ||
1364 | return dates.last(); | 1364 | return dates.last(); |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | 1367 | ||
1368 | void CalendarView::createPrinter() | 1368 | void CalendarView::createPrinter() |
1369 | { | 1369 | { |
1370 | #ifndef KORG_NOPRINTER | 1370 | #ifndef KORG_NOPRINTER |
1371 | if (!mCalPrinter) { | 1371 | if (!mCalPrinter) { |
1372 | mCalPrinter = new CalPrinter(this, mCalendar); | 1372 | mCalPrinter = new CalPrinter(this, mCalendar); |
1373 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1373 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1374 | } | 1374 | } |
1375 | #endif | 1375 | #endif |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | 1378 | ||
1379 | //KOPrefs::instance()->mWriteBackFile | 1379 | //KOPrefs::instance()->mWriteBackFile |
1380 | //KOPrefs::instance()->mWriteBackExistingOnly | 1380 | //KOPrefs::instance()->mWriteBackExistingOnly |
1381 | 1381 | ||
1382 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1382 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1383 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1383 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1384 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1384 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1385 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1385 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1386 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1386 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1387 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1387 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1388 | 1388 | ||
1389 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1389 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1390 | { | 1390 | { |
1391 | 1391 | ||
1392 | // 0 equal | 1392 | // 0 equal |
1393 | // 1 take local | 1393 | // 1 take local |
1394 | // 2 take remote | 1394 | // 2 take remote |
1395 | // 3 cancel | 1395 | // 3 cancel |
1396 | QDateTime lastSync = mLastCalendarSync; | 1396 | QDateTime lastSync = mLastCalendarSync; |
1397 | QDateTime localMod = local->lastModified(); | 1397 | QDateTime localMod = local->lastModified(); |
1398 | QDateTime remoteMod = remote->lastModified(); | 1398 | QDateTime remoteMod = remote->lastModified(); |
1399 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1399 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1400 | bool remCh, locCh; | 1400 | bool remCh, locCh; |
1401 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1401 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1402 | //if ( remCh ) | 1402 | //if ( remCh ) |
1403 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1403 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1404 | locCh = ( localMod > mLastCalendarSync ); | 1404 | locCh = ( localMod > mLastCalendarSync ); |
1405 | if ( !remCh && ! locCh ) { | 1405 | if ( !remCh && ! locCh ) { |
1406 | //qDebug("both not changed "); | 1406 | //qDebug("both not changed "); |
1407 | lastSync = localMod.addDays(1); | 1407 | lastSync = localMod.addDays(1); |
1408 | if ( mode <= SYNC_PREF_ASK ) | 1408 | if ( mode <= SYNC_PREF_ASK ) |
1409 | return 0; | 1409 | return 0; |
1410 | } else { | 1410 | } else { |
1411 | if ( locCh ) { | 1411 | if ( locCh ) { |
1412 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1412 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1413 | lastSync = localMod.addDays( -1 ); | 1413 | lastSync = localMod.addDays( -1 ); |
1414 | if ( !remCh ) | 1414 | if ( !remCh ) |
1415 | remoteMod = ( lastSync.addDays( -1 ) ); | 1415 | remoteMod = ( lastSync.addDays( -1 ) ); |
1416 | } else { | 1416 | } else { |
1417 | //qDebug(" not loc changed "); | 1417 | //qDebug(" not loc changed "); |
1418 | lastSync = localMod.addDays( 1 ); | 1418 | lastSync = localMod.addDays( 1 ); |
1419 | if ( remCh ) | 1419 | if ( remCh ) |
1420 | remoteMod =( lastSync.addDays( 1 ) ); | 1420 | remoteMod =( lastSync.addDays( 1 ) ); |
1421 | 1421 | ||
1422 | } | 1422 | } |
1423 | } | 1423 | } |
1424 | full = true; | 1424 | full = true; |
1425 | if ( mode < SYNC_PREF_ASK ) | 1425 | if ( mode < SYNC_PREF_ASK ) |
1426 | mode = SYNC_PREF_ASK; | 1426 | mode = SYNC_PREF_ASK; |
1427 | } else { | 1427 | } else { |
1428 | if ( localMod == remoteMod ) | 1428 | if ( localMod == remoteMod ) |
1429 | // if ( local->revision() == remote->revision() ) | 1429 | // if ( local->revision() == remote->revision() ) |
1430 | return 0; | 1430 | return 0; |
1431 | 1431 | ||
1432 | } | 1432 | } |
1433 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1433 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1434 | 1434 | ||
1435 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1435 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1436 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1436 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1437 | //full = true; //debug only | 1437 | //full = true; //debug only |
1438 | if ( full ) { | 1438 | if ( full ) { |
1439 | bool equ = false; | 1439 | bool equ = false; |
1440 | if ( local->typeID() == eventID ) { | 1440 | if ( local->typeID() == eventID ) { |
1441 | equ = (*((Event*) local) == *((Event*) remote)); | 1441 | equ = (*((Event*) local) == *((Event*) remote)); |
1442 | } | 1442 | } |
1443 | else if ( local->typeID() == todoID ) | 1443 | else if ( local->typeID() == todoID ) |
1444 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1444 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1445 | else if ( local->typeID() == journalID ) | 1445 | else if ( local->typeID() == journalID ) |
1446 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1446 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1447 | if ( equ ) { | 1447 | if ( equ ) { |
1448 | //qDebug("equal "); | 1448 | //qDebug("equal "); |
1449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1450 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1450 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1451 | } | 1451 | } |
1452 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1452 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1453 | return 0; | 1453 | return 0; |
1454 | 1454 | ||
1455 | }//else //debug only | 1455 | }//else //debug only |
1456 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1456 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1457 | } | 1457 | } |
1458 | int result; | 1458 | int result; |
1459 | bool localIsNew; | 1459 | bool localIsNew; |
1460 | //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() ); | 1460 | //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() ); |
1461 | 1461 | ||
1462 | 1462 | ||
1463 | // ************************************************ | 1463 | // ************************************************ |
1464 | // ************************************************ | 1464 | // ************************************************ |
1465 | // ************************************************ | 1465 | // ************************************************ |
1466 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1466 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1467 | // BUT remoteMod != localMod | 1467 | // BUT remoteMod != localMod |
1468 | 1468 | ||
1469 | 1469 | ||
1470 | if ( full && mode < SYNC_PREF_NEWEST ) | 1470 | if ( full && mode < SYNC_PREF_NEWEST ) |
1471 | mode = SYNC_PREF_ASK; | 1471 | mode = SYNC_PREF_ASK; |
1472 | 1472 | ||
1473 | switch( mode ) { | 1473 | switch( mode ) { |
1474 | case SYNC_PREF_LOCAL: | 1474 | case SYNC_PREF_LOCAL: |
1475 | if ( lastSync > remoteMod ) | 1475 | if ( lastSync > remoteMod ) |
1476 | return 1; | 1476 | return 1; |
1477 | if ( lastSync > localMod ) | 1477 | if ( lastSync > localMod ) |
1478 | return 2; | 1478 | return 2; |
1479 | return 1; | 1479 | return 1; |
1480 | break; | 1480 | break; |
1481 | case SYNC_PREF_REMOTE: | 1481 | case SYNC_PREF_REMOTE: |
1482 | if ( lastSync > localMod ) | 1482 | if ( lastSync > localMod ) |
1483 | return 2; | 1483 | return 2; |
1484 | if ( lastSync > remoteMod ) | 1484 | if ( lastSync > remoteMod ) |
1485 | return 1; | 1485 | return 1; |
1486 | return 2; | 1486 | return 2; |
1487 | break; | 1487 | break; |
1488 | case SYNC_PREF_NEWEST: | 1488 | case SYNC_PREF_NEWEST: |
1489 | if ( localMod >= remoteMod ) | 1489 | if ( localMod >= remoteMod ) |
1490 | return 1; | 1490 | return 1; |
1491 | else | 1491 | else |
1492 | return 2; | 1492 | return 2; |
1493 | break; | 1493 | break; |
1494 | case SYNC_PREF_ASK: | 1494 | case SYNC_PREF_ASK: |
1495 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1495 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1496 | if ( lastSync > remoteMod && lastSync > localMod) | 1496 | if ( lastSync > remoteMod && lastSync > localMod) |
1497 | return 0; | 1497 | return 0; |
1498 | if ( lastSync > remoteMod ) | 1498 | if ( lastSync > remoteMod ) |
1499 | return 1; | 1499 | return 1; |
1500 | if ( lastSync > localMod ) | 1500 | if ( lastSync > localMod ) |
1501 | return 2; | 1501 | return 2; |
1502 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1502 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1503 | localIsNew = localMod >= remoteMod; | 1503 | localIsNew = localMod >= remoteMod; |
1504 | if ( localIsNew ) | 1504 | if ( localIsNew ) |
1505 | getEventViewerDialog()->setColorMode( 1 ); | 1505 | getEventViewerDialog()->setColorMode( 1 ); |
1506 | else | 1506 | else |
1507 | getEventViewerDialog()->setColorMode( 2 ); | 1507 | getEventViewerDialog()->setColorMode( 2 ); |
1508 | getEventViewerDialog()->setIncidence(local); | 1508 | getEventViewerDialog()->setIncidence(local); |
1509 | if ( localIsNew ) | 1509 | if ( localIsNew ) |
1510 | getEventViewerDialog()->setColorMode( 2 ); | 1510 | getEventViewerDialog()->setColorMode( 2 ); |
1511 | else | 1511 | else |
1512 | getEventViewerDialog()->setColorMode( 1 ); | 1512 | getEventViewerDialog()->setColorMode( 1 ); |
1513 | getEventViewerDialog()->addIncidence(remote); | 1513 | getEventViewerDialog()->addIncidence(remote); |
1514 | getEventViewerDialog()->setColorMode( 0 ); | 1514 | getEventViewerDialog()->setColorMode( 0 ); |
1515 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1515 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1516 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1516 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1517 | getEventViewerDialog()->showMe(); | 1517 | getEventViewerDialog()->showMe(); |
1518 | result = getEventViewerDialog()->executeS( localIsNew ); | 1518 | result = getEventViewerDialog()->executeS( localIsNew ); |
1519 | return result; | 1519 | return result; |
1520 | 1520 | ||
1521 | break; | 1521 | break; |
1522 | case SYNC_PREF_FORCE_LOCAL: | 1522 | case SYNC_PREF_FORCE_LOCAL: |
1523 | return 1; | 1523 | return 1; |
1524 | break; | 1524 | break; |
1525 | case SYNC_PREF_FORCE_REMOTE: | 1525 | case SYNC_PREF_FORCE_REMOTE: |
1526 | return 2; | 1526 | return 2; |
1527 | break; | 1527 | break; |
1528 | 1528 | ||
1529 | default: | 1529 | default: |
1530 | // SYNC_PREF_TAKE_BOTH not implemented | 1530 | // SYNC_PREF_TAKE_BOTH not implemented |
1531 | break; | 1531 | break; |
1532 | } | 1532 | } |
1533 | return 0; | 1533 | return 0; |
1534 | } | 1534 | } |
1535 | Event* CalendarView::getLastSyncEvent() | 1535 | Event* CalendarView::getLastSyncEvent() |
1536 | { | 1536 | { |
1537 | Event* lse; | 1537 | Event* lse; |
1538 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1538 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1539 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1539 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1540 | if (!lse) { | 1540 | if (!lse) { |
1541 | lse = new Event(); | 1541 | lse = new Event(); |
1542 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1542 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1543 | QString sum = ""; | 1543 | QString sum = ""; |
1544 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1544 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1545 | sum = "E: "; | 1545 | sum = "E: "; |
1546 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1546 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1547 | lse->setDtStart( mLastCalendarSync ); | 1547 | lse->setDtStart( mLastCalendarSync ); |
1548 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1548 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1549 | lse->setCategories( i18n("SyncEvent") ); | 1549 | lse->setCategories( i18n("SyncEvent") ); |
1550 | lse->setReadOnly( true ); | 1550 | lse->setReadOnly( true ); |
1551 | mCalendar->addEvent( lse ); | 1551 | mCalendar->addEvent( lse ); |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | return lse; | 1554 | return lse; |
1555 | 1555 | ||
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | // we check, if the to delete event has a id for a profile | 1558 | // we check, if the to delete event has a id for a profile |
1559 | // if yes, we set this id in the profile to delete | 1559 | // if yes, we set this id in the profile to delete |
1560 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1560 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1561 | { | 1561 | { |
1562 | if ( lastSync.count() == 0 ) { | 1562 | if ( lastSync.count() == 0 ) { |
1563 | //qDebug(" lastSync.count() == 0"); | 1563 | //qDebug(" lastSync.count() == 0"); |
1564 | return; | 1564 | return; |
1565 | } | 1565 | } |
1566 | if ( toDelete->typeID() == journalID ) | 1566 | if ( toDelete->typeID() == journalID ) |
1567 | return; | 1567 | return; |
1568 | 1568 | ||
1569 | Event* eve = lastSync.first(); | 1569 | Event* eve = lastSync.first(); |
1570 | 1570 | ||
1571 | while ( eve ) { | 1571 | while ( eve ) { |
1572 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1572 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1573 | if ( !id.isEmpty() ) { | 1573 | if ( !id.isEmpty() ) { |
1574 | QString des = eve->description(); | 1574 | QString des = eve->description(); |
1575 | QString pref = "e"; | 1575 | QString pref = "e"; |
1576 | if ( toDelete->typeID() == todoID ) | 1576 | if ( toDelete->typeID() == todoID ) |
1577 | pref = "t"; | 1577 | pref = "t"; |
1578 | des += pref+ id + ","; | 1578 | des += pref+ id + ","; |
1579 | eve->setReadOnly( false ); | 1579 | eve->setReadOnly( false ); |
1580 | eve->setDescription( des ); | 1580 | eve->setDescription( des ); |
1581 | //qDebug("setdes %s ", des.latin1()); | 1581 | //qDebug("setdes %s ", des.latin1()); |
1582 | eve->setReadOnly( true ); | 1582 | eve->setReadOnly( true ); |
1583 | } | 1583 | } |
1584 | eve = lastSync.next(); | 1584 | eve = lastSync.next(); |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | } | 1587 | } |
1588 | void CalendarView::checkExternalId( Incidence * inc ) | 1588 | void CalendarView::checkExternalId( Incidence * inc ) |
1589 | { | 1589 | { |
1590 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1590 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1591 | checkExternSyncEvent( lastSync, inc ); | 1591 | checkExternSyncEvent( lastSync, inc ); |
1592 | 1592 | ||
1593 | } | 1593 | } |
1594 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1594 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1595 | { | 1595 | { |
1596 | bool syncOK = true; | 1596 | bool syncOK = true; |
1597 | int addedEvent = 0; | 1597 | int addedEvent = 0; |
1598 | int addedEventR = 0; | 1598 | int addedEventR = 0; |
1599 | int deletedEventR = 0; | 1599 | int deletedEventR = 0; |
1600 | int deletedEventL = 0; | 1600 | int deletedEventL = 0; |
1601 | int changedLocal = 0; | 1601 | int changedLocal = 0; |
1602 | int changedRemote = 0; | 1602 | int changedRemote = 0; |
1603 | int filteredIN = 0; | 1603 | int filteredIN = 0; |
1604 | int filteredOUT = 0; | 1604 | int filteredOUT = 0; |
1605 | //QPtrList<Event> el = local->rawEvents(); | 1605 | //QPtrList<Event> el = local->rawEvents(); |
1606 | Event* eventR; | 1606 | Event* eventR; |
1607 | QString uid; | 1607 | QString uid; |
1608 | int take; | 1608 | int take; |
1609 | Event* eventRSync; | 1609 | Event* eventRSync; |
1610 | Event* eventLSync; | 1610 | Event* eventLSync; |
1611 | clearAllViews(); | 1611 | clearAllViews(); |
1612 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1612 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1613 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1613 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1614 | bool fullDateRange = false; | 1614 | bool fullDateRange = false; |
1615 | local->resetTempSyncStat(); | 1615 | local->resetTempSyncStat(); |
1616 | mLastCalendarSync = QDateTime::currentDateTime(); | 1616 | mLastCalendarSync = QDateTime::currentDateTime(); |
1617 | if ( mSyncManager->syncWithDesktop() ) { | 1617 | if ( mSyncManager->syncWithDesktop() ) { |
1618 | remote->resetPilotStat(1); | 1618 | remote->resetPilotStat(1); |
1619 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1619 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1620 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1620 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1621 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1621 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1622 | } else { | 1622 | } else { |
1623 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1623 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1624 | } | 1624 | } |
1625 | } | 1625 | } |
1626 | QDateTime modifiedCalendar = mLastCalendarSync; | 1626 | QDateTime modifiedCalendar = mLastCalendarSync; |
1627 | eventLSync = getLastSyncEvent(); | 1627 | eventLSync = getLastSyncEvent(); |
1628 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1628 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1629 | if ( eventR ) { | 1629 | if ( eventR ) { |
1630 | qDebug("last-syncEvent on remote found "); | 1630 | qDebug("last-syncEvent on remote found "); |
1631 | eventRSync = (Event*) eventR->clone(); | 1631 | eventRSync = (Event*) eventR->clone(); |
1632 | remote->deleteEvent(eventR ); | 1632 | remote->deleteEvent(eventR ); |
1633 | 1633 | ||
1634 | } else { | 1634 | } else { |
1635 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1635 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1636 | eventRSync = (Event*)eventLSync->clone(); | 1636 | eventRSync = (Event*)eventLSync->clone(); |
1637 | } else { | 1637 | } else { |
1638 | fullDateRange = true; | 1638 | fullDateRange = true; |
1639 | eventRSync = new Event(); | 1639 | eventRSync = new Event(); |
1640 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1640 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1641 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1641 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1642 | eventRSync->setDtStart( mLastCalendarSync ); | 1642 | eventRSync->setDtStart( mLastCalendarSync ); |
1643 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1643 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1644 | eventRSync->setCategories( i18n("SyncEvent") ); | 1644 | eventRSync->setCategories( i18n("SyncEvent") ); |
1645 | } | 1645 | } |
1646 | } | 1646 | } |
1647 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1647 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1648 | fullDateRange = true; | 1648 | fullDateRange = true; |
1649 | 1649 | ||
1650 | if ( ! fullDateRange ) { | 1650 | if ( ! fullDateRange ) { |
1651 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1651 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1652 | 1652 | ||
1653 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1653 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1654 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1654 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1655 | fullDateRange = true; | 1655 | fullDateRange = true; |
1656 | } | 1656 | } |
1657 | } | 1657 | } |
1658 | if ( mSyncManager->syncWithDesktop() ) { | 1658 | if ( mSyncManager->syncWithDesktop() ) { |
1659 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1659 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1660 | } | 1660 | } |
1661 | if ( fullDateRange ) | 1661 | if ( fullDateRange ) |
1662 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1662 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1663 | else | 1663 | else |
1664 | mLastCalendarSync = eventLSync->dtStart(); | 1664 | mLastCalendarSync = eventLSync->dtStart(); |
1665 | // for resyncing if own file has changed | 1665 | // for resyncing if own file has changed |
1666 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1666 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1667 | mLastCalendarSync = loadedFileVersion; | 1667 | mLastCalendarSync = loadedFileVersion; |
1668 | //qDebug("setting mLastCalendarSync "); | 1668 | //qDebug("setting mLastCalendarSync "); |
1669 | } | 1669 | } |
1670 | //qDebug("*************************** "); | 1670 | //qDebug("*************************** "); |
1671 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1671 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1672 | QPtrList<Incidence> er = remote->rawIncidences(); | 1672 | QPtrList<Incidence> er = remote->rawIncidences(); |
1673 | Incidence* inR = er.first(); | 1673 | Incidence* inR = er.first(); |
1674 | Incidence* inL; | 1674 | Incidence* inL; |
1675 | QProgressBar bar( er.count(),0 ); | 1675 | QProgressBar bar( er.count(),0 ); |
1676 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1676 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1677 | 1677 | ||
1678 | // ************** setting up filter ************* | 1678 | // ************** setting up filter ************* |
1679 | CalFilter *filterIN = 0; | 1679 | CalFilter *filterIN = 0; |
1680 | CalFilter *filterOUT = 0; | 1680 | CalFilter *filterOUT = 0; |
1681 | CalFilter *filter = mFilters.first(); | 1681 | CalFilter *filter = mFilters.first(); |
1682 | while(filter) { | 1682 | while(filter) { |
1683 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1683 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1684 | filterIN = filter; | 1684 | filterIN = filter; |
1685 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1685 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1686 | filterOUT = filter; | 1686 | filterOUT = filter; |
1687 | filter = mFilters.next(); | 1687 | filter = mFilters.next(); |
1688 | } | 1688 | } |
1689 | int w = 300; | 1689 | int w = 300; |
1690 | if ( QApplication::desktop()->width() < 320 ) | 1690 | if ( QApplication::desktop()->width() < 320 ) |
1691 | w = 220; | 1691 | w = 220; |
1692 | int h = bar.sizeHint().height() ; | 1692 | int h = bar.sizeHint().height() ; |
1693 | int dw = QApplication::desktop()->width(); | 1693 | int dw = QApplication::desktop()->width(); |
1694 | int dh = QApplication::desktop()->height(); | 1694 | int dh = QApplication::desktop()->height(); |
1695 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1695 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1696 | bar.show(); | 1696 | bar.show(); |
1697 | int modulo = (er.count()/10)+1; | 1697 | int modulo = (er.count()/10)+1; |
1698 | int incCounter = 0; | 1698 | int incCounter = 0; |
1699 | while ( inR ) { | 1699 | while ( inR ) { |
1700 | if ( ! bar.isVisible() ) | 1700 | if ( ! bar.isVisible() ) |
1701 | return false; | 1701 | return false; |
1702 | if ( incCounter % modulo == 0 ) | 1702 | if ( incCounter % modulo == 0 ) |
1703 | bar.setProgress( incCounter ); | 1703 | bar.setProgress( incCounter ); |
1704 | ++incCounter; | 1704 | ++incCounter; |
1705 | uid = inR->uid(); | 1705 | uid = inR->uid(); |
1706 | bool skipIncidence = false; | 1706 | bool skipIncidence = false; |
1707 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1707 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1708 | skipIncidence = true; | 1708 | skipIncidence = true; |
1709 | QString idS; | 1709 | QString idS; |
1710 | qApp->processEvents(); | 1710 | qApp->processEvents(); |
1711 | if ( !skipIncidence ) { | 1711 | if ( !skipIncidence ) { |
1712 | inL = local->incidenceForUid( uid , false ); | 1712 | inL = local->incidenceForUid( uid , false ); |
1713 | if ( inL ) { // maybe conflict - same uid in both calendars | 1713 | if ( inL ) { // maybe conflict - same uid in both calendars |
1714 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1714 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1715 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1715 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1716 | if ( take == 3 ) | 1716 | if ( take == 3 ) |
1717 | return false; | 1717 | return false; |
1718 | if ( take == 1 ) {// take local ********************** | 1718 | if ( take == 1 ) {// take local ********************** |
1719 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1719 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1720 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1720 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1721 | else | 1721 | else |
1722 | idS = inR->IDStr(); | 1722 | idS = inR->IDStr(); |
1723 | int calID = inR->calID(); | 1723 | int calID = inR->calID(); |
1724 | remote->deleteIncidence( inR ); | 1724 | remote->deleteIncidence( inR ); |
1725 | inR = inL->clone(); | 1725 | inR = inL->clone(); |
1726 | inR->setCalID( calID ); | 1726 | inR->setCalID( calID ); |
1727 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1727 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1728 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1728 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1729 | inR->setIDStr( idS ); | 1729 | inR->setIDStr( idS ); |
1730 | remote->addIncidence( inR ); | 1730 | remote->addIncidence( inR ); |
1731 | if ( mSyncManager->syncWithDesktop() ) | 1731 | if ( mSyncManager->syncWithDesktop() ) |
1732 | inR->setPilotId( 2 ); | 1732 | inR->setPilotId( 2 ); |
1733 | ++changedRemote; | 1733 | ++changedRemote; |
1734 | } else {// take remote ********************** | 1734 | } else {// take remote ********************** |
1735 | if ( !inL->isReadOnly() ) { | 1735 | if ( !inL->isReadOnly() ) { |
1736 | idS = inL->IDStr(); | 1736 | idS = inL->IDStr(); |
1737 | int pid = inL->pilotId(); | 1737 | int pid = inL->pilotId(); |
1738 | int calID = inL->calID(); | 1738 | int calID = inL->calID(); |
1739 | local->deleteIncidence( inL ); | 1739 | local->deleteIncidence( inL ); |
1740 | inL = inR->clone(); | 1740 | inL = inR->clone(); |
1741 | inL->setCalID( calID ); | 1741 | inL->setCalID( calID ); |
1742 | if ( mSyncManager->syncWithDesktop() ) | 1742 | if ( mSyncManager->syncWithDesktop() ) |
1743 | inL->setPilotId( pid ); | 1743 | inL->setPilotId( pid ); |
1744 | inL->setIDStr( idS ); | 1744 | inL->setIDStr( idS ); |
1745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1746 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1746 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1747 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1747 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1748 | } | 1748 | } |
1749 | local->addIncidence( inL ); | 1749 | local->addIncidence( inL ); |
1750 | ++changedLocal; | 1750 | ++changedLocal; |
1751 | } | 1751 | } |
1752 | } | 1752 | } |
1753 | } | 1753 | } |
1754 | } else { // no conflict ********** add or delete remote | 1754 | } else { // no conflict ********** add or delete remote |
1755 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1755 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1756 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1756 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1757 | QString des = eventLSync->description(); | 1757 | QString des = eventLSync->description(); |
1758 | QString pref = "e"; | 1758 | QString pref = "e"; |
1759 | if ( inR->typeID() == todoID ) | 1759 | if ( inR->typeID() == todoID ) |
1760 | pref = "t"; | 1760 | pref = "t"; |
1761 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1761 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1762 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1762 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1763 | //remote->deleteIncidence( inR ); | 1763 | //remote->deleteIncidence( inR ); |
1764 | ++deletedEventR; | 1764 | ++deletedEventR; |
1765 | } else { | 1765 | } else { |
1766 | inR->setLastModified( modifiedCalendar ); | 1766 | inR->setLastModified( modifiedCalendar ); |
1767 | inL = inR->clone(); | 1767 | inL = inR->clone(); |
1768 | inL->setIDStr( ":" ); | 1768 | inL->setIDStr( ":" ); |
1769 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1769 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1770 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1770 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1771 | 1771 | ||
1772 | inL->setCalID( 0 );// add to default cal | 1772 | inL->setCalID( 0 );// add to default cal |
1773 | local->addIncidence( inL ); | 1773 | local->addIncidence( inL ); |
1774 | ++addedEvent; | 1774 | ++addedEvent; |
1775 | 1775 | ||
1776 | } | 1776 | } |
1777 | } else { | 1777 | } else { |
1778 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1778 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1779 | inR->setLastModified( modifiedCalendar ); | 1779 | inR->setLastModified( modifiedCalendar ); |
1780 | inL = inR->clone(); | 1780 | inL = inR->clone(); |
1781 | inL->setIDStr( ":" ); | 1781 | inL->setIDStr( ":" ); |
1782 | inL->setCalID( 0 );// add to default cal | 1782 | inL->setCalID( 0 );// add to default cal |
1783 | local->addIncidence( inL ); | 1783 | local->addIncidence( inL ); |
1784 | ++addedEvent; | 1784 | ++addedEvent; |
1785 | 1785 | ||
1786 | } else { | 1786 | } else { |
1787 | checkExternSyncEvent(eventRSyncSharp, inR); | 1787 | checkExternSyncEvent(eventRSyncSharp, inR); |
1788 | remote->deleteIncidence( inR ); | 1788 | remote->deleteIncidence( inR ); |
1789 | ++deletedEventR; | 1789 | ++deletedEventR; |
1790 | } | 1790 | } |
1791 | } | 1791 | } |
1792 | } else { | 1792 | } else { |
1793 | ++filteredIN; | 1793 | ++filteredIN; |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | } | 1796 | } |
1797 | inR = er.next(); | 1797 | inR = er.next(); |
1798 | } | 1798 | } |
1799 | QPtrList<Incidence> el = local->rawIncidences(); | 1799 | QPtrList<Incidence> el = local->rawIncidences(); |
1800 | inL = el.first(); | 1800 | inL = el.first(); |
1801 | modulo = (el.count()/10)+1; | 1801 | modulo = (el.count()/10)+1; |
1802 | bar.setCaption (i18n("Add / remove events") ); | 1802 | bar.setCaption (i18n("Add / remove events") ); |
1803 | bar.setTotalSteps ( el.count() ) ; | 1803 | bar.setTotalSteps ( el.count() ) ; |
1804 | bar.show(); | 1804 | bar.show(); |
1805 | incCounter = 0; | 1805 | incCounter = 0; |
1806 | 1806 | ||
1807 | while ( inL ) { | 1807 | while ( inL ) { |
1808 | 1808 | ||
1809 | qApp->processEvents(); | 1809 | qApp->processEvents(); |
1810 | if ( ! bar.isVisible() ) | 1810 | if ( ! bar.isVisible() ) |
1811 | return false; | 1811 | return false; |
1812 | if ( incCounter % modulo == 0 ) | 1812 | if ( incCounter % modulo == 0 ) |
1813 | bar.setProgress( incCounter ); | 1813 | bar.setProgress( incCounter ); |
1814 | ++incCounter; | 1814 | ++incCounter; |
1815 | uid = inL->uid(); | 1815 | uid = inL->uid(); |
1816 | bool skipIncidence = false; | 1816 | bool skipIncidence = false; |
1817 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1817 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1818 | skipIncidence = true; | 1818 | skipIncidence = true; |
1819 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1819 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1820 | skipIncidence = true; | 1820 | skipIncidence = true; |
1821 | if ( !skipIncidence ) { | 1821 | if ( !skipIncidence ) { |
1822 | inR = remote->incidenceForUid( uid , true ); | 1822 | inR = remote->incidenceForUid( uid , true ); |
1823 | if ( ! inR ) { | 1823 | if ( ! inR ) { |
1824 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1824 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1825 | // no conflict ********** add or delete local | 1825 | // no conflict ********** add or delete local |
1826 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1826 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1827 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1827 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1828 | checkExternSyncEvent(eventLSyncSharp, inL); | 1828 | checkExternSyncEvent(eventLSyncSharp, inL); |
1829 | local->deleteIncidence( inL ); | 1829 | local->deleteIncidence( inL ); |
1830 | ++deletedEventL; | 1830 | ++deletedEventL; |
1831 | } else { | 1831 | } else { |
1832 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1832 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1833 | inL->removeID(mCurrentSyncDevice ); | 1833 | inL->removeID(mCurrentSyncDevice ); |
1834 | ++addedEventR; | 1834 | ++addedEventR; |
1835 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1835 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1836 | inL->setLastModified( modifiedCalendar ); | 1836 | inL->setLastModified( modifiedCalendar ); |
1837 | inR = inL->clone(); | 1837 | inR = inL->clone(); |
1838 | inR->setIDStr( ":" ); | 1838 | inR->setIDStr( ":" ); |
1839 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1839 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1840 | inR->setCalID( 0 );// add to default cal | 1840 | inR->setCalID( 0 );// add to default cal |
1841 | remote->addIncidence( inR ); | 1841 | remote->addIncidence( inR ); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | } else { | 1844 | } else { |
1845 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1845 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1846 | checkExternSyncEvent(eventLSyncSharp, inL); | 1846 | checkExternSyncEvent(eventLSyncSharp, inL); |
1847 | local->deleteIncidence( inL ); | 1847 | local->deleteIncidence( inL ); |
1848 | ++deletedEventL; | 1848 | ++deletedEventL; |
1849 | } else { | 1849 | } else { |
1850 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1850 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1851 | ++addedEventR; | 1851 | ++addedEventR; |
1852 | inL->setLastModified( modifiedCalendar ); | 1852 | inL->setLastModified( modifiedCalendar ); |
1853 | inR = inL->clone(); | 1853 | inR = inL->clone(); |
1854 | inR->setIDStr( ":" ); | 1854 | inR->setIDStr( ":" ); |
1855 | inR->setCalID( 0 );// add to default cal | 1855 | inR->setCalID( 0 );// add to default cal |
1856 | remote->addIncidence( inR ); | 1856 | remote->addIncidence( inR ); |
1857 | } | 1857 | } |
1858 | } | 1858 | } |
1859 | } | 1859 | } |
1860 | } else { | 1860 | } else { |
1861 | ++filteredOUT; | 1861 | ++filteredOUT; |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } | 1864 | } |
1865 | inL = el.next(); | 1865 | inL = el.next(); |
1866 | } | 1866 | } |
1867 | int delFut = 0; | 1867 | int delFut = 0; |
1868 | int remRem = 0; | 1868 | int remRem = 0; |
1869 | if ( mSyncManager->mWriteBackInFuture ) { | 1869 | if ( mSyncManager->mWriteBackInFuture ) { |
1870 | er = remote->rawIncidences(); | 1870 | er = remote->rawIncidences(); |
1871 | remRem = er.count(); | 1871 | remRem = er.count(); |
1872 | inR = er.first(); | 1872 | inR = er.first(); |
1873 | QDateTime dt; | 1873 | QDateTime dt; |
1874 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1874 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1875 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1875 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1876 | while ( inR ) { | 1876 | while ( inR ) { |
1877 | if ( inR->typeID() == todoID ) { | 1877 | if ( inR->typeID() == todoID ) { |
1878 | Todo * t = (Todo*)inR; | 1878 | Todo * t = (Todo*)inR; |
1879 | if ( t->hasDueDate() ) | 1879 | if ( t->hasDueDate() ) |
1880 | dt = t->dtDue(); | 1880 | dt = t->dtDue(); |
1881 | else | 1881 | else |
1882 | dt = cur.addSecs( 62 ); | 1882 | dt = cur.addSecs( 62 ); |
1883 | } | 1883 | } |
1884 | else if (inR->typeID() == eventID ) { | 1884 | else if (inR->typeID() == eventID ) { |
1885 | bool ok; | 1885 | bool ok; |
1886 | dt = inR->getNextOccurence( cur, &ok ); | 1886 | dt = inR->getNextOccurence( cur, &ok ); |
1887 | if ( !ok ) | 1887 | if ( !ok ) |
1888 | dt = cur.addSecs( -62 ); | 1888 | dt = cur.addSecs( -62 ); |
1889 | } | 1889 | } |
1890 | else | 1890 | else |
1891 | dt = inR->dtStart(); | 1891 | dt = inR->dtStart(); |
1892 | if ( dt < cur || dt > end ) { | 1892 | if ( dt < cur || dt > end ) { |
1893 | remote->deleteIncidence( inR ); | 1893 | remote->deleteIncidence( inR ); |
1894 | ++delFut; | 1894 | ++delFut; |
1895 | } | 1895 | } |
1896 | inR = er.next(); | 1896 | inR = er.next(); |
1897 | } | 1897 | } |
1898 | } | 1898 | } |
1899 | bar.hide(); | 1899 | bar.hide(); |
1900 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1900 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1901 | eventLSync->setReadOnly( false ); | 1901 | eventLSync->setReadOnly( false ); |
1902 | eventLSync->setDtStart( mLastCalendarSync ); | 1902 | eventLSync->setDtStart( mLastCalendarSync ); |
1903 | eventRSync->setDtStart( mLastCalendarSync ); | 1903 | eventRSync->setDtStart( mLastCalendarSync ); |
1904 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1904 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1905 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1905 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1906 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1906 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1907 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1907 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1908 | eventLSync->setReadOnly( true ); | 1908 | eventLSync->setReadOnly( true ); |
1909 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1909 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1910 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1910 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1911 | remote->addEvent( eventRSync ); | 1911 | remote->addEvent( eventRSync ); |
1912 | else | 1912 | else |
1913 | delete eventRSync; | 1913 | delete eventRSync; |
1914 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1914 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1915 | QString mes; | 1915 | QString mes; |
1916 | 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 ); | 1916 | 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 ); |
1917 | QString delmess; | 1917 | QString delmess; |
1918 | if ( delFut ) { | 1918 | if ( delFut ) { |
1919 | 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); | 1919 | 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); |
1920 | mes += delmess; | 1920 | mes += delmess; |
1921 | } | 1921 | } |
1922 | mes = i18n("Local calendar changed!\n") +mes; | 1922 | mes = i18n("Local calendar changed!\n") +mes; |
1923 | mCalendar->checkAlarmForIncidence( 0, true ); | 1923 | mCalendar->checkAlarmForIncidence( 0, true ); |
1924 | qDebug( mes ); | 1924 | qDebug( mes ); |
1925 | if ( mSyncManager->mShowSyncSummary ) { | 1925 | if ( mSyncManager->mShowSyncSummary ) { |
1926 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1926 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1927 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1927 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1928 | qDebug("KO: WB cancelled "); | 1928 | qDebug("KO: WB cancelled "); |
1929 | mSyncManager->mWriteBackFile = false; | 1929 | mSyncManager->mWriteBackFile = false; |
1930 | return syncOK; | 1930 | return syncOK; |
1931 | } | 1931 | } |
1932 | } | 1932 | } |
1933 | return syncOK; | 1933 | return syncOK; |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | void CalendarView::setSyncDevice( QString s ) | 1936 | void CalendarView::setSyncDevice( QString s ) |
1937 | { | 1937 | { |
1938 | mCurrentSyncDevice= s; | 1938 | mCurrentSyncDevice= s; |
1939 | } | 1939 | } |
1940 | void CalendarView::setSyncName( QString s ) | 1940 | void CalendarView::setSyncName( QString s ) |
1941 | { | 1941 | { |
1942 | mCurrentSyncName= s; | 1942 | mCurrentSyncName= s; |
1943 | } | 1943 | } |
1944 | bool CalendarView::syncCalendar(QString filename, int mode) | 1944 | bool CalendarView::syncCalendar(QString filename, int mode) |
1945 | { | 1945 | { |
1946 | //qDebug("syncCalendar %s ", filename.latin1()); | 1946 | //qDebug("syncCalendar %s ", filename.latin1()); |
1947 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1947 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1948 | CalendarLocal* calendar = new CalendarLocal(); | 1948 | CalendarLocal* calendar = new CalendarLocal(); |
1949 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1949 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1950 | FileStorage* storage = new FileStorage( calendar ); | 1950 | FileStorage* storage = new FileStorage( calendar ); |
1951 | bool syncOK = false; | 1951 | bool syncOK = false; |
1952 | storage->setFileName( filename ); | 1952 | storage->setFileName( filename ); |
1953 | // qDebug("loading ... "); | 1953 | // qDebug("loading ... "); |
1954 | if ( storage->load() ) { | 1954 | if ( storage->load() ) { |
1955 | getEventViewerDialog()->setSyncMode( true ); | 1955 | getEventViewerDialog()->setSyncMode( true ); |
1956 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1956 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1957 | getEventViewerDialog()->setSyncMode( false ); | 1957 | getEventViewerDialog()->setSyncMode( false ); |
1958 | if ( syncOK ) { | 1958 | if ( syncOK ) { |
1959 | if ( mSyncManager->mWriteBackFile ) | 1959 | if ( mSyncManager->mWriteBackFile ) |
1960 | { | 1960 | { |
1961 | storage->setSaveFormat( new ICalFormat() ); | 1961 | storage->setSaveFormat( new ICalFormat() ); |
1962 | storage->save(); | 1962 | storage->save(); |
1963 | } | 1963 | } |
1964 | } | 1964 | } |
1965 | setModified( true ); | 1965 | setModified( true ); |
1966 | } | 1966 | } |
1967 | delete storage; | 1967 | delete storage; |
1968 | delete calendar; | 1968 | delete calendar; |
1969 | if ( syncOK ) | 1969 | if ( syncOK ) |
1970 | updateView(); | 1970 | updateView(); |
1971 | return syncOK; | 1971 | return syncOK; |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | void CalendarView::syncExternal( int mode ) | 1974 | void CalendarView::syncExternal( int mode ) |
1975 | { | 1975 | { |
1976 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1976 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1977 | 1977 | ||
1978 | qApp->processEvents(); | 1978 | qApp->processEvents(); |
1979 | CalendarLocal* calendar = new CalendarLocal(); | 1979 | CalendarLocal* calendar = new CalendarLocal(); |
1980 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1980 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1981 | bool syncOK = false; | 1981 | bool syncOK = false; |
1982 | bool loadSuccess = false; | 1982 | bool loadSuccess = false; |
1983 | PhoneFormat* phoneFormat = 0; | 1983 | PhoneFormat* phoneFormat = 0; |
1984 | emit tempDisableBR(true); | 1984 | emit tempDisableBR(true); |
1985 | #ifndef DESKTOP_VERSION | 1985 | #ifndef DESKTOP_VERSION |
1986 | SharpFormat* sharpFormat = 0; | 1986 | SharpFormat* sharpFormat = 0; |
1987 | if ( mode == 0 ) { // sharp | 1987 | if ( mode == 0 ) { // sharp |
1988 | sharpFormat = new SharpFormat () ; | 1988 | sharpFormat = new SharpFormat () ; |
1989 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1989 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1990 | 1990 | ||
1991 | } else | 1991 | } else |
1992 | #endif | 1992 | #endif |
1993 | if ( mode == 1 ) { // phone | 1993 | if ( mode == 1 ) { // phone |
1994 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1994 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1995 | mSyncManager->mPhoneDevice, | 1995 | mSyncManager->mPhoneDevice, |
1996 | mSyncManager->mPhoneConnection, | 1996 | mSyncManager->mPhoneConnection, |
1997 | mSyncManager->mPhoneModel); | 1997 | mSyncManager->mPhoneModel); |
1998 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1998 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1999 | 1999 | ||
2000 | } else { | 2000 | } else { |
2001 | emit tempDisableBR(false); | 2001 | emit tempDisableBR(false); |
2002 | return; | 2002 | return; |
2003 | } | 2003 | } |
2004 | if ( loadSuccess ) { | 2004 | if ( loadSuccess ) { |
2005 | getEventViewerDialog()->setSyncMode( true ); | 2005 | getEventViewerDialog()->setSyncMode( true ); |
2006 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2006 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2007 | getEventViewerDialog()->setSyncMode( false ); | 2007 | getEventViewerDialog()->setSyncMode( false ); |
2008 | qApp->processEvents(); | 2008 | qApp->processEvents(); |
2009 | if ( syncOK ) { | 2009 | if ( syncOK ) { |
2010 | if ( mSyncManager->mWriteBackFile ) | 2010 | if ( mSyncManager->mWriteBackFile ) |
2011 | { | 2011 | { |
2012 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2012 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2013 | Incidence* inc = iL.first(); | 2013 | Incidence* inc = iL.first(); |
2014 | if ( phoneFormat ) { | 2014 | if ( phoneFormat ) { |
2015 | while ( inc ) { | 2015 | while ( inc ) { |
2016 | inc->removeID(mCurrentSyncDevice); | 2016 | inc->removeID(mCurrentSyncDevice); |
2017 | inc = iL.next(); | 2017 | inc = iL.next(); |
2018 | } | 2018 | } |
2019 | } | 2019 | } |
2020 | #ifndef DESKTOP_VERSION | 2020 | #ifndef DESKTOP_VERSION |
2021 | if ( sharpFormat ) | 2021 | if ( sharpFormat ) |
2022 | sharpFormat->save(calendar); | 2022 | sharpFormat->save(calendar); |
2023 | #endif | 2023 | #endif |
2024 | if ( phoneFormat ) | 2024 | if ( phoneFormat ) |
2025 | phoneFormat->save(calendar); | 2025 | phoneFormat->save(calendar); |
2026 | iL = calendar->rawIncidences(); | 2026 | iL = calendar->rawIncidences(); |
2027 | inc = iL.first(); | 2027 | inc = iL.first(); |
2028 | Incidence* loc; | 2028 | Incidence* loc; |
2029 | while ( inc ) { | 2029 | while ( inc ) { |
2030 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2030 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2031 | loc = mCalendar->incidence(inc->uid() ); | 2031 | loc = mCalendar->incidence(inc->uid() ); |
2032 | if ( loc ) { | 2032 | if ( loc ) { |
2033 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2033 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2034 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2034 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2035 | } | 2035 | } |
2036 | } | 2036 | } |
2037 | inc = iL.next(); | 2037 | inc = iL.next(); |
2038 | } | 2038 | } |
2039 | Incidence* lse = getLastSyncEvent(); | 2039 | Incidence* lse = getLastSyncEvent(); |
2040 | if ( lse ) { | 2040 | if ( lse ) { |
2041 | lse->setReadOnly( false ); | 2041 | lse->setReadOnly( false ); |
2042 | lse->setDescription( "" ); | 2042 | lse->setDescription( "" ); |
2043 | lse->setReadOnly( true ); | 2043 | lse->setReadOnly( true ); |
2044 | } | 2044 | } |
2045 | } | 2045 | } |
2046 | } else { | 2046 | } else { |
2047 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2047 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2048 | } | 2048 | } |
2049 | setModified( true ); | 2049 | setModified( true ); |
2050 | } else { | 2050 | } else { |
2051 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2051 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2052 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2052 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2053 | question, i18n("Ok")) ; | 2053 | question, i18n("Ok")) ; |
2054 | 2054 | ||
2055 | } | 2055 | } |
2056 | delete calendar; | 2056 | delete calendar; |
2057 | updateView(); | 2057 | updateView(); |
2058 | emit tempDisableBR(false); | 2058 | emit tempDisableBR(false); |
2059 | return ;//syncOK; | 2059 | return ;//syncOK; |
2060 | 2060 | ||
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | bool CalendarView::importBday() | 2063 | bool CalendarView::importBday() |
2064 | { | 2064 | { |
2065 | #ifndef KORG_NOKABC | 2065 | #ifndef KORG_NOKABC |
2066 | 2066 | ||
2067 | #ifdef DESKTOP_VERSION | 2067 | #ifdef DESKTOP_VERSION |
2068 | int curCal = mCalendar->defaultCalendar(); | 2068 | int curCal = mCalendar->defaultCalendar(); |
2069 | int bd = mCalEditView->getBirtdayID(); | 2069 | int bd = mCalEditView->getBirtdayID(); |
2070 | if ( bd == 0 ) | 2070 | if ( bd == 0 ) |
2071 | return false; | 2071 | return false; |
2072 | mCalendar->setDefaultCalendar( bd ); | 2072 | mCalendar->setDefaultCalendar( bd ); |
2073 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2073 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2074 | KABC::AddressBook::Iterator it; | 2074 | KABC::AddressBook::Iterator it; |
2075 | int count = 0; | 2075 | int count = 0; |
2076 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2076 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2077 | ++count; | 2077 | ++count; |
2078 | } | 2078 | } |
2079 | QProgressBar bar(count,0 ); | 2079 | QProgressBar bar(count,0 ); |
2080 | int w = 300; | 2080 | int w = 300; |
2081 | if ( QApplication::desktop()->width() < 320 ) | 2081 | if ( QApplication::desktop()->width() < 320 ) |
2082 | w = 220; | 2082 | w = 220; |
2083 | int h = bar.sizeHint().height() ; | 2083 | int h = bar.sizeHint().height() ; |
2084 | int dw = QApplication::desktop()->width(); | 2084 | int dw = QApplication::desktop()->width(); |
2085 | int dh = QApplication::desktop()->height(); | 2085 | int dh = QApplication::desktop()->height(); |
2086 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2086 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2087 | bar.show(); | 2087 | bar.show(); |
2088 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2088 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2089 | qApp->processEvents(); | 2089 | qApp->processEvents(); |
2090 | count = 0; | 2090 | count = 0; |
2091 | int addCount = 0; | 2091 | int addCount = 0; |
2092 | KCal::Attendee* a = 0; | 2092 | KCal::Attendee* a = 0; |
2093 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2093 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2094 | if ( ! bar.isVisible() ) | 2094 | if ( ! bar.isVisible() ) |
2095 | return false; | 2095 | return false; |
2096 | bar.setProgress( count++ ); | 2096 | bar.setProgress( count++ ); |
2097 | qApp->processEvents(); | 2097 | qApp->processEvents(); |
2098 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2098 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2099 | if ( (*it).birthday().date().isValid() ){ | 2099 | if ( (*it).birthday().date().isValid() ){ |
2100 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2100 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2101 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2101 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2102 | ++addCount; | 2102 | ++addCount; |
2103 | } | 2103 | } |
2104 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2104 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2105 | if ( anni.isValid() ){ | 2105 | if ( anni.isValid() ){ |
2106 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2106 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2107 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2107 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2108 | ++addCount; | 2108 | ++addCount; |
2109 | } | 2109 | } |
2110 | } | 2110 | } |
2111 | mCalendar->setDefaultCalendar( curCal ); | 2111 | mCalendar->setDefaultCalendar( curCal ); |
2112 | updateView(); | 2112 | updateView(); |
2113 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2113 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2114 | #else //DESKTOP_VERSION | 2114 | #else //DESKTOP_VERSION |
2115 | 2115 | ||
2116 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2116 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2117 | // the result should now arrive through method insertBirthdays | 2117 | // the result should now arrive through method insertBirthdays |
2118 | 2118 | ||
2119 | #endif //DESKTOP_VERSION | 2119 | #endif //DESKTOP_VERSION |
2120 | 2120 | ||
2121 | #endif //KORG_NOKABC | 2121 | #endif //KORG_NOKABC |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | return true; | 2124 | return true; |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2127 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2128 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2128 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2129 | const QStringList& anniversaryList, const QStringList& realNameList, | 2129 | const QStringList& anniversaryList, const QStringList& realNameList, |
2130 | const QStringList& emailList, const QStringList& assembledNameList, | 2130 | const QStringList& emailList, const QStringList& assembledNameList, |
2131 | const QStringList& uidList) | 2131 | const QStringList& uidList) |
2132 | { | 2132 | { |
2133 | 2133 | ||
2134 | //qDebug("KO::CalendarView::insertBirthdays"); | 2134 | //qDebug("KO::CalendarView::insertBirthdays"); |
2135 | if (uid == this->name()) | 2135 | if (uid == this->name()) |
2136 | { | 2136 | { |
2137 | int curCal = mCalendar->defaultCalendar(); | 2137 | int curCal = mCalendar->defaultCalendar(); |
2138 | int bd = mCalEditView->getBirtdayID(); | 2138 | int bd = mCalEditView->getBirtdayID(); |
2139 | if ( bd == 0 ) | 2139 | if ( bd == 0 ) |
2140 | return; | 2140 | return; |
2141 | mCalendar->setDefaultCalendar( bd ); | 2141 | mCalendar->setDefaultCalendar( bd ); |
2142 | 2142 | ||
2143 | 2143 | ||
2144 | int count = birthdayList.count(); | 2144 | int count = birthdayList.count(); |
2145 | int addCount = 0; | 2145 | int addCount = 0; |
2146 | KCal::Attendee* a = 0; | 2146 | KCal::Attendee* a = 0; |
2147 | 2147 | ||
2148 | //qDebug("CalView 1 %i", count); | 2148 | //qDebug("CalView 1 %i", count); |
2149 | 2149 | ||
2150 | QProgressBar bar(count,0 ); | 2150 | QProgressBar bar(count,0 ); |
2151 | int w = 300; | 2151 | int w = 300; |
2152 | if ( QApplication::desktop()->width() < 320 ) | 2152 | if ( QApplication::desktop()->width() < 320 ) |
2153 | w = 220; | 2153 | w = 220; |
2154 | int h = bar.sizeHint().height() ; | 2154 | int h = bar.sizeHint().height() ; |
2155 | int dw = QApplication::desktop()->width(); | 2155 | int dw = QApplication::desktop()->width(); |
2156 | int dh = QApplication::desktop()->height(); | 2156 | int dh = QApplication::desktop()->height(); |
2157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2158 | bar.show(); | 2158 | bar.show(); |
2159 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2159 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2160 | qApp->processEvents(); | 2160 | qApp->processEvents(); |
2161 | 2161 | ||
2162 | QDate birthday; | 2162 | QDate birthday; |
2163 | QDate anniversary; | 2163 | QDate anniversary; |
2164 | QString realName; | 2164 | QString realName; |
2165 | QString email; | 2165 | QString email; |
2166 | QString assembledName; | 2166 | QString assembledName; |
2167 | QString uid; | 2167 | QString uid; |
2168 | bool ok = true; | 2168 | bool ok = true; |
2169 | for ( int i = 0; i < count; i++) | 2169 | for ( int i = 0; i < count; i++) |
2170 | { | 2170 | { |
2171 | if ( ! bar.isVisible() ) | 2171 | if ( ! bar.isVisible() ) |
2172 | return; | 2172 | return; |
2173 | bar.setProgress( i ); | 2173 | bar.setProgress( i ); |
2174 | qApp->processEvents(); | 2174 | qApp->processEvents(); |
2175 | 2175 | ||
2176 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2176 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2177 | if (!ok) { | 2177 | if (!ok) { |
2178 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2178 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2181 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2182 | if (!ok) { | 2182 | if (!ok) { |
2183 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2183 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2184 | } | 2184 | } |
2185 | realName = realNameList[i]; | 2185 | realName = realNameList[i]; |
2186 | email = emailList[i]; | 2186 | email = emailList[i]; |
2187 | assembledName = assembledNameList[i]; | 2187 | assembledName = assembledNameList[i]; |
2188 | uid = uidList[i]; | 2188 | uid = uidList[i]; |
2189 | //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() ); | 2189 | //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() ); |
2190 | 2190 | ||
2191 | if ( birthday.isValid() ){ | 2191 | if ( birthday.isValid() ){ |
2192 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2192 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2193 | KCal::Attendee::ReqParticipant,uid) ; | 2193 | KCal::Attendee::ReqParticipant,uid) ; |
2194 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2194 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2195 | ++addCount; | 2195 | ++addCount; |
2196 | } | 2196 | } |
2197 | 2197 | ||
2198 | if ( anniversary.isValid() ){ | 2198 | if ( anniversary.isValid() ){ |
2199 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2199 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2200 | KCal::Attendee::ReqParticipant,uid) ; | 2200 | KCal::Attendee::ReqParticipant,uid) ; |
2201 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2201 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2202 | ++addCount; | 2202 | ++addCount; |
2203 | } | 2203 | } |
2204 | } | 2204 | } |
2205 | 2205 | ||
2206 | mCalendar->setDefaultCalendar( curCal ); | 2206 | mCalendar->setDefaultCalendar( curCal ); |
2207 | updateView(); | 2207 | updateView(); |
2208 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2208 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2209 | 2209 | ||
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | 2214 | ||
2215 | 2215 | ||
2216 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2216 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2217 | { | 2217 | { |
2218 | //qDebug("addAnni "); | 2218 | //qDebug("addAnni "); |
2219 | Event * ev = new Event(); | 2219 | Event * ev = new Event(); |
2220 | ev->setOrganizer(KOPrefs::instance()->email()); | 2220 | ev->setOrganizer(KOPrefs::instance()->email()); |
2221 | if ( a ) { | 2221 | if ( a ) { |
2222 | ev->addAttendee( a ); | 2222 | ev->addAttendee( a ); |
2223 | } | 2223 | } |
2224 | QString kind; | 2224 | QString kind; |
2225 | if ( birthday ) { | 2225 | if ( birthday ) { |
2226 | kind = i18n( "Birthday" ); | 2226 | kind = i18n( "Birthday" ); |
2227 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2227 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2228 | } | 2228 | } |
2229 | else { | 2229 | else { |
2230 | kind = i18n( "Anniversary" ); | 2230 | kind = i18n( "Anniversary" ); |
2231 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2231 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2232 | } | 2232 | } |
2233 | ev->setCategories( kind ); | 2233 | ev->setCategories( kind ); |
2234 | ev->setDtStart( QDateTime(date) ); | 2234 | ev->setDtStart( QDateTime(date) ); |
2235 | ev->setDtEnd( QDateTime(date) ); | 2235 | ev->setDtEnd( QDateTime(date) ); |
2236 | ev->setFloats( true ); | 2236 | ev->setFloats( true ); |
2237 | Recurrence * rec = ev->recurrence(); | 2237 | Recurrence * rec = ev->recurrence(); |
2238 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2238 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2239 | rec->addYearlyNum( date.month() ); | 2239 | rec->addYearlyNum( date.month() ); |
2240 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2240 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2241 | delete ev; | 2241 | delete ev; |
2242 | return false; | 2242 | return false; |
2243 | } | 2243 | } |
2244 | return true; | 2244 | return true; |
2245 | 2245 | ||
2246 | } | 2246 | } |
2247 | bool CalendarView::importQtopia( const QString &categories, | 2247 | bool CalendarView::importQtopia( const QString &categories, |
2248 | const QString &datebook, | 2248 | const QString &datebook, |
2249 | const QString &todolist ) | 2249 | const QString &todolist ) |
2250 | { | 2250 | { |
2251 | 2251 | ||
2252 | QtopiaFormat qtopiaFormat; | 2252 | QtopiaFormat qtopiaFormat; |
2253 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2253 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2254 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2254 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2255 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2255 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2256 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2256 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2257 | 2257 | ||
2258 | updateView(); | 2258 | updateView(); |
2259 | return true; | 2259 | return true; |
2260 | 2260 | ||
2261 | #if 0 | 2261 | #if 0 |
2262 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2262 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2263 | mCurrentSyncDevice = "qtopia-XML"; | 2263 | mCurrentSyncDevice = "qtopia-XML"; |
2264 | if ( mSyncManager->mAskForPreferences ) | 2264 | if ( mSyncManager->mAskForPreferences ) |
2265 | edit_sync_options(); | 2265 | edit_sync_options(); |
2266 | qApp->processEvents(); | 2266 | qApp->processEvents(); |
2267 | CalendarLocal* calendar = new CalendarLocal(); | 2267 | CalendarLocal* calendar = new CalendarLocal(); |
2268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2269 | bool syncOK = false; | 2269 | bool syncOK = false; |
2270 | QtopiaFormat qtopiaFormat; | 2270 | QtopiaFormat qtopiaFormat; |
2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2272 | bool loadOk = true; | 2272 | bool loadOk = true; |
2273 | if ( !categories.isEmpty() ) | 2273 | if ( !categories.isEmpty() ) |
2274 | loadOk = qtopiaFormat.load( calendar, categories ); | 2274 | loadOk = qtopiaFormat.load( calendar, categories ); |
2275 | if ( loadOk && !datebook.isEmpty() ) | 2275 | if ( loadOk && !datebook.isEmpty() ) |
2276 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2276 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2277 | if ( loadOk && !todolist.isEmpty() ) | 2277 | if ( loadOk && !todolist.isEmpty() ) |
2278 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2278 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2279 | 2279 | ||
2280 | if ( loadOk ) { | 2280 | if ( loadOk ) { |
2281 | getEventViewerDialog()->setSyncMode( true ); | 2281 | getEventViewerDialog()->setSyncMode( true ); |
2282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2283 | getEventViewerDialog()->setSyncMode( false ); | 2283 | getEventViewerDialog()->setSyncMode( false ); |
2284 | qApp->processEvents(); | 2284 | qApp->processEvents(); |
2285 | if ( syncOK ) { | 2285 | if ( syncOK ) { |
2286 | if ( mSyncManager->mWriteBackFile ) | 2286 | if ( mSyncManager->mWriteBackFile ) |
2287 | { | 2287 | { |
2288 | // write back XML file | 2288 | // write back XML file |
2289 | 2289 | ||
2290 | } | 2290 | } |
2291 | setModified( true ); | 2291 | setModified( true ); |
2292 | } | 2292 | } |
2293 | } else { | 2293 | } else { |
2294 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2294 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2295 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2295 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2296 | question, i18n("Ok")) ; | 2296 | question, i18n("Ok")) ; |
2297 | } | 2297 | } |
2298 | delete calendar; | 2298 | delete calendar; |
2299 | updateView(); | 2299 | updateView(); |
2300 | return syncOK; | 2300 | return syncOK; |
2301 | 2301 | ||
2302 | 2302 | ||
2303 | #endif | 2303 | #endif |
2304 | 2304 | ||
2305 | } | 2305 | } |
2306 | 2306 | ||
2307 | void CalendarView::setSyncEventsReadOnly() | 2307 | void CalendarView::setSyncEventsReadOnly() |
2308 | { | 2308 | { |
2309 | mCalendar->setSyncEventsReadOnly(); | 2309 | mCalendar->setSyncEventsReadOnly(); |
2310 | } | 2310 | } |
2311 | 2311 | ||
2312 | bool CalendarView::loadCalendars() | 2312 | bool CalendarView::loadCalendars() |
2313 | { | 2313 | { |
2314 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2314 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2315 | KopiCalendarFile * cal = calendars.first(); | 2315 | KopiCalendarFile * cal = calendars.first(); |
2316 | mCalendar->setDefaultCalendar( 1 ); | 2316 | mCalendar->setDefaultCalendar( 1 ); |
2317 | openCalendar( MainWindow::defaultFileName(), false ); | 2317 | openCalendar( MainWindow::defaultFileName(), false ); |
2318 | cal = calendars.next(); | 2318 | cal = calendars.next(); |
2319 | while ( cal ) { | 2319 | while ( cal ) { |
2320 | addCalendar( cal ); | 2320 | addCalendar( cal ); |
2321 | cal = calendars.next(); | 2321 | cal = calendars.next(); |
2322 | } | 2322 | } |
2323 | restoreCalendarSettings(); | 2323 | restoreCalendarSettings(); |
2324 | return true; | 2324 | return true; |
2325 | } | 2325 | } |
2326 | bool CalendarView::restoreCalendarSettings() | 2326 | bool CalendarView::restoreCalendarSettings() |
2327 | { | 2327 | { |
2328 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2328 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2329 | KopiCalendarFile * cal = calendars.first(); | 2329 | KopiCalendarFile * cal = calendars.first(); |
2330 | while ( cal ) { | 2330 | while ( cal ) { |
2331 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2331 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2332 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2332 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2333 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2333 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2334 | if ( cal->isStandard ) | 2334 | if ( cal->isStandard ) |
2335 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2335 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2336 | cal = calendars.next(); | 2336 | cal = calendars.next(); |
2337 | } | 2337 | } |
2338 | setSyncEventsReadOnly(); | 2338 | setSyncEventsReadOnly(); |
2339 | mCalendar->reInitAlarmSettings(); | 2339 | mCalendar->reInitAlarmSettings(); |
2340 | updateUnmanagedViews(); | 2340 | updateUnmanagedViews(); |
2341 | updateView(); | 2341 | updateView(); |
2342 | return true; | 2342 | return true; |
2343 | } | 2343 | } |
2344 | void CalendarView::addCalendarId( int id ) | 2344 | void CalendarView::addCalendarId( int id ) |
2345 | { | 2345 | { |
2346 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2346 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2347 | if ( cal ) | 2347 | if ( cal ) |
2348 | addCalendar( cal ); | 2348 | addCalendar( cal ); |
2349 | } | 2349 | } |
2350 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2350 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2351 | { | 2351 | { |
2352 | cal->mErrorOnLoad = false; | 2352 | cal->mErrorOnLoad = false; |
2353 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2353 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2354 | cal->mLoadDt = QDateTime::currentDateTime(); | 2354 | cal->mLoadDt = QDateTime::currentDateTime(); |
2355 | return true; | 2355 | return true; |
2356 | } | 2356 | } |
2357 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2357 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2358 | cal->mErrorOnLoad = true; | 2358 | cal->mErrorOnLoad = true; |
2359 | return false; | 2359 | return false; |
2360 | } | 2360 | } |
2361 | bool CalendarView::openCalendar(QString filename, bool merge) | 2361 | bool CalendarView::openCalendar(QString filename, bool merge) |
2362 | { | 2362 | { |
2363 | 2363 | ||
2364 | if (filename.isEmpty()) { | 2364 | if (filename.isEmpty()) { |
2365 | return false; | 2365 | return false; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | if (!QFile::exists(filename)) { | 2368 | if (!QFile::exists(filename)) { |
2369 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2369 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2370 | return false; | 2370 | return false; |
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | globalFlagBlockAgenda = 1; | 2373 | globalFlagBlockAgenda = 1; |
2374 | clearAllViews(); | 2374 | clearAllViews(); |
2375 | if (!merge) { | 2375 | if (!merge) { |
2376 | mViewManager->setDocumentId( filename ); | 2376 | mViewManager->setDocumentId( filename ); |
2377 | mCalendar->close(); | 2377 | mCalendar->close(); |
2378 | } | 2378 | } |
2379 | mStorage->setFileName( filename ); | 2379 | mStorage->setFileName( filename ); |
2380 | 2380 | ||
2381 | if ( mStorage->load() ) { | 2381 | if ( mStorage->load() ) { |
2382 | if ( merge ) ;//setModified( true ); | 2382 | if ( merge ) ;//setModified( true ); |
2383 | else { | 2383 | else { |
2384 | //setModified( true ); | 2384 | //setModified( true ); |
2385 | mViewManager->setDocumentId( filename ); | 2385 | mViewManager->setDocumentId( filename ); |
2386 | mDialogManager->setDocumentId( filename ); | 2386 | mDialogManager->setDocumentId( filename ); |
2387 | mTodoList->setDocumentId( filename ); | 2387 | mTodoList->setDocumentId( filename ); |
2388 | } | 2388 | } |
2389 | globalFlagBlockAgenda = 2; | 2389 | globalFlagBlockAgenda = 2; |
2390 | // if ( getLastSyncEvent() ) | 2390 | // if ( getLastSyncEvent() ) |
2391 | // getLastSyncEvent()->setReadOnly( true ); | 2391 | // getLastSyncEvent()->setReadOnly( true ); |
2392 | mCalendar->reInitAlarmSettings(); | 2392 | mCalendar->reInitAlarmSettings(); |
2393 | setSyncEventsReadOnly(); | 2393 | setSyncEventsReadOnly(); |
2394 | //updateUnmanagedViews(); | 2394 | //updateUnmanagedViews(); |
2395 | //updateView(); | 2395 | //updateView(); |
2396 | if ( filename != MainWindow::defaultFileName() ) { | 2396 | if ( filename != MainWindow::defaultFileName() ) { |
2397 | saveCalendar( MainWindow::defaultFileName() ); | 2397 | saveCalendar( MainWindow::defaultFileName() ); |
2398 | } else { | 2398 | } else { |
2399 | QFileInfo finf ( MainWindow::defaultFileName()); | 2399 | QFileInfo finf ( MainWindow::defaultFileName()); |
2400 | if ( finf.exists() ) { | 2400 | if ( finf.exists() ) { |
2401 | setLoadedFileVersion( finf.lastModified () ); | 2401 | setLoadedFileVersion( finf.lastModified () ); |
2402 | } | 2402 | } |
2403 | } | 2403 | } |
2404 | return true; | 2404 | return true; |
2405 | } else { | 2405 | } else { |
2406 | // while failing to load, the calendar object could | 2406 | // while failing to load, the calendar object could |
2407 | // have become partially populated. Clear it out. | 2407 | // have become partially populated. Clear it out. |
2408 | if ( !merge ) { | 2408 | if ( !merge ) { |
2409 | mCalendar->close(); | 2409 | mCalendar->close(); |
2410 | mViewManager->setDocumentId( filename ); | 2410 | mViewManager->setDocumentId( filename ); |
2411 | mDialogManager->setDocumentId( filename ); | 2411 | mDialogManager->setDocumentId( filename ); |
2412 | mTodoList->setDocumentId( filename ); | 2412 | mTodoList->setDocumentId( filename ); |
2413 | } | 2413 | } |
2414 | 2414 | ||
2415 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2415 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2416 | 2416 | ||
2417 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2417 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2418 | globalFlagBlockAgenda = 2; | 2418 | globalFlagBlockAgenda = 2; |
2419 | mCalendar->reInitAlarmSettings(); | 2419 | mCalendar->reInitAlarmSettings(); |
2420 | setSyncEventsReadOnly(); | 2420 | setSyncEventsReadOnly(); |
2421 | updateUnmanagedViews(); | 2421 | updateUnmanagedViews(); |
2422 | updateView(); | 2422 | updateView(); |
2423 | } | 2423 | } |
2424 | return false; | 2424 | return false; |
2425 | } | 2425 | } |
2426 | void CalendarView::mergeFile( QString fn ) | 2426 | void CalendarView::mergeFile( QString fn ) |
2427 | { | 2427 | { |
2428 | clearAllViews(); | 2428 | clearAllViews(); |
2429 | mCalendar->mergeCalendarFile( fn ); | 2429 | mCalendar->mergeCalendarFile( fn ); |
2430 | mCalendar->reInitAlarmSettings(); | 2430 | mCalendar->reInitAlarmSettings(); |
2431 | setSyncEventsReadOnly(); | 2431 | setSyncEventsReadOnly(); |
2432 | updateUnmanagedViews(); | 2432 | updateUnmanagedViews(); |
2433 | updateView(); | 2433 | updateView(); |
2434 | } | 2434 | } |
2435 | void CalendarView::showOpenError() | 2435 | void CalendarView::showOpenError() |
2436 | { | 2436 | { |
2437 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2437 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2438 | } | 2438 | } |
2439 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2439 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2440 | { | 2440 | { |
2441 | loadedFileVersion = dt; | 2441 | loadedFileVersion = dt; |
2442 | } | 2442 | } |
2443 | bool CalendarView::checkFileChanged(QString fn) | 2443 | bool CalendarView::checkFileChanged(QString fn) |
2444 | { | 2444 | { |
2445 | QFileInfo finf ( fn ); | 2445 | QFileInfo finf ( fn ); |
2446 | if ( !finf.exists() ) | 2446 | if ( !finf.exists() ) |
2447 | return true; | 2447 | return true; |
2448 | QDateTime dt = finf.lastModified (); | 2448 | QDateTime dt = finf.lastModified (); |
2449 | if ( dt <= loadedFileVersion ) | 2449 | if ( dt <= loadedFileVersion ) |
2450 | return false; | 2450 | return false; |
2451 | return true; | 2451 | return true; |
2452 | 2452 | ||
2453 | } | 2453 | } |
2454 | void CalendarView::watchSavedFile() | 2454 | void CalendarView::watchSavedFile() |
2455 | { | 2455 | { |
2456 | QFileInfo finf ( MainWindow::defaultFileName()); | 2456 | QFileInfo finf ( MainWindow::defaultFileName()); |
2457 | if ( !finf.exists() ) | 2457 | if ( !finf.exists() ) |
2458 | return; | 2458 | return; |
2459 | QDateTime dt = finf.lastModified (); | 2459 | QDateTime dt = finf.lastModified (); |
2460 | if ( dt < loadedFileVersion ) { | 2460 | if ( dt < loadedFileVersion ) { |
2461 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2461 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2462 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2462 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2463 | return; | 2463 | return; |
2464 | } | 2464 | } |
2465 | loadedFileVersion = dt; | 2465 | loadedFileVersion = dt; |
2466 | } | 2466 | } |
2467 | bool CalendarView::checkAllFileVersions() | 2467 | bool CalendarView::checkAllFileVersions() |
2468 | { | 2468 | { |
2469 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2469 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2470 | KopiCalendarFile * cal = calendars.first(); | 2470 | KopiCalendarFile * cal = calendars.first(); |
2471 | mCalendar->setDefaultCalendar( 1 ); | 2471 | mCalendar->setDefaultCalendar( 1 ); |
2472 | mCalendar->setDefaultCalendarEnabledOnly(); | 2472 | mCalendar->setDefaultCalendarEnabledOnly(); |
2473 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2473 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2474 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2474 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2475 | restoreCalendarSettings(); | 2475 | restoreCalendarSettings(); |
2476 | return false; | 2476 | return false; |
2477 | } | 2477 | } |
2478 | } | 2478 | } |
2479 | cal = calendars.next(); | 2479 | cal = calendars.next(); |
2480 | QDateTime storeTemp = loadedFileVersion; | 2480 | QDateTime storeTemp = loadedFileVersion; |
2481 | while ( cal ) { | 2481 | while ( cal ) { |
2482 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2482 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2483 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2483 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2484 | mCalendar->setDefaultCalendarEnabledOnly(); | 2484 | mCalendar->setDefaultCalendarEnabledOnly(); |
2485 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2485 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2486 | if ( !checkFileVersion(cal->mFileName )) { | 2486 | if ( !checkFileVersion(cal->mFileName )) { |
2487 | loadedFileVersion = storeTemp; | 2487 | loadedFileVersion = storeTemp; |
2488 | restoreCalendarSettings(); | 2488 | restoreCalendarSettings(); |
2489 | return false; | 2489 | return false; |
2490 | } | 2490 | } |
2491 | } | 2491 | } |
2492 | cal = calendars.next(); | 2492 | cal = calendars.next(); |
2493 | } | 2493 | } |
2494 | loadedFileVersion = storeTemp; | 2494 | loadedFileVersion = storeTemp; |
2495 | return true; | 2495 | return true; |
2496 | } | 2496 | } |
2497 | bool CalendarView::checkFileVersion(QString fn) | 2497 | bool CalendarView::checkFileVersion(QString fn) |
2498 | { | 2498 | { |
2499 | QFileInfo finf ( fn ); | 2499 | QFileInfo finf ( fn ); |
2500 | if ( !finf.exists() ) | 2500 | if ( !finf.exists() ) |
2501 | return true; | 2501 | return true; |
2502 | QDateTime dt = finf.lastModified (); | 2502 | QDateTime dt = finf.lastModified (); |
2503 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2503 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2504 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2504 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2505 | if ( dt <= loadedFileVersion ) | 2505 | if ( dt <= loadedFileVersion ) |
2506 | return true; | 2506 | return true; |
2507 | 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)) , | 2507 | 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)) , |
2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2509 | i18n("Sync+save")); | 2509 | i18n("Sync+save")); |
2510 | 2510 | ||
2511 | if ( km == KMessageBox::Cancel ) | 2511 | if ( km == KMessageBox::Cancel ) |
2512 | return false; | 2512 | return false; |
2513 | if ( km == KMessageBox::Yes ) | 2513 | if ( km == KMessageBox::Yes ) |
2514 | return true; | 2514 | return true; |
2515 | 2515 | ||
2516 | setSyncDevice("deleteaftersync" ); | 2516 | setSyncDevice("deleteaftersync" ); |
2517 | mSyncManager->mAskForPreferences = true; | 2517 | mSyncManager->mAskForPreferences = true; |
2518 | mSyncManager->mSyncAlgoPrefs = 3; | 2518 | mSyncManager->mSyncAlgoPrefs = 3; |
2519 | mSyncManager->mWriteBackFile = false; | 2519 | mSyncManager->mWriteBackFile = false; |
2520 | mSyncManager->mWriteBackExistingOnly = false; | 2520 | mSyncManager->mWriteBackExistingOnly = false; |
2521 | mSyncManager->mShowSyncSummary = false; | 2521 | mSyncManager->mShowSyncSummary = false; |
2522 | syncCalendar( fn, 3 ); | 2522 | syncCalendar( fn, 3 ); |
2523 | Event * e = getLastSyncEvent(); | 2523 | Event * e = getLastSyncEvent(); |
2524 | if ( e ) | 2524 | if ( e ) |
2525 | mCalendar->deleteEvent( e ); | 2525 | mCalendar->deleteEvent( e ); |
2526 | return true; | 2526 | return true; |
2527 | } | 2527 | } |
2528 | bool CalendarView::saveCalendars() | 2528 | bool CalendarView::saveCalendars() |
2529 | { | 2529 | { |
2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2531 | KopiCalendarFile * cal = calendars.first(); | 2531 | KopiCalendarFile * cal = calendars.first(); |
2532 | mCalendar->setDefaultCalendar( 1 ); | 2532 | mCalendar->setDefaultCalendar( 1 ); |
2533 | mCalendar->setDefaultCalendarEnabledOnly(); | 2533 | mCalendar->setDefaultCalendarEnabledOnly(); |
2534 | QString saveError; | 2534 | QString saveError; |
2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2536 | saveError = cal->mName +"\n"; | 2536 | saveError = cal->mName +"\n"; |
2537 | cal = calendars.next(); | 2537 | cal = calendars.next(); |
2538 | while ( cal ) { | 2538 | while ( cal ) { |
2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2541 | mCalendar->setDefaultCalendarEnabledOnly(); | 2541 | mCalendar->setDefaultCalendarEnabledOnly(); |
2542 | if ( saveCalendar( cal->mFileName ) ) | 2542 | if ( saveCalendar( cal->mFileName ) ) |
2543 | cal->mLoadDt = QDateTime::currentDateTime(); | 2543 | cal->mLoadDt = QDateTime::currentDateTime(); |
2544 | else | 2544 | else |
2545 | saveError += cal->mName + "\n"; | 2545 | saveError += cal->mName + "\n"; |
2546 | } | 2546 | } |
2547 | cal = calendars.next(); | 2547 | cal = calendars.next(); |
2548 | } | 2548 | } |
2549 | restoreCalendarSettings(); | 2549 | restoreCalendarSettings(); |
2550 | if ( !saveError.isEmpty() ) { | 2550 | if ( !saveError.isEmpty() ) { |
2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2553 | return false; | 2553 | return false; |
2554 | } | 2554 | } |
2555 | return true; | 2555 | return true; |
2556 | } | 2556 | } |
2557 | bool CalendarView::saveCalendar( QString filename ) | 2557 | bool CalendarView::saveCalendar( QString filename ) |
2558 | { | 2558 | { |
2559 | 2559 | ||
2560 | // Store back all unsaved data into calendar object | 2560 | // Store back all unsaved data into calendar object |
2561 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2561 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2562 | if ( mViewManager->currentView() ) | 2562 | if ( mViewManager->currentView() ) |
2563 | mViewManager->currentView()->flushView(); | 2563 | mViewManager->currentView()->flushView(); |
2564 | 2564 | ||
2565 | 2565 | ||
2566 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2566 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2567 | mStorage->setSaveFormat( new ICalFormat() ); | 2567 | mStorage->setSaveFormat( new ICalFormat() ); |
2568 | mStorage->setFileName( filename ); | 2568 | mStorage->setFileName( filename ); |
2569 | bool success; | 2569 | bool success; |
2570 | success = mStorage->save(); | 2570 | success = mStorage->save(); |
2571 | if ( !success ) { | 2571 | if ( !success ) { |
2572 | return false; | 2572 | return false; |
2573 | } | 2573 | } |
2574 | if ( filename == MainWindow::defaultFileName() ) { | 2574 | if ( filename == MainWindow::defaultFileName() ) { |
2575 | setLoadedFileVersion( lfv ); | 2575 | setLoadedFileVersion( lfv ); |
2576 | watchSavedFile(); | 2576 | watchSavedFile(); |
2577 | } | 2577 | } |
2578 | return true; | 2578 | return true; |
2579 | } | 2579 | } |
2580 | 2580 | ||
2581 | void CalendarView::closeCalendar() | 2581 | void CalendarView::closeCalendar() |
2582 | { | 2582 | { |
2583 | 2583 | ||
2584 | // child windows no longer valid | 2584 | // child windows no longer valid |
2585 | clearAllViews(); | 2585 | clearAllViews(); |
2586 | emit closingDown(); | 2586 | emit closingDown(); |
2587 | 2587 | ||
2588 | mCalendar->close(); | 2588 | mCalendar->close(); |
2589 | setModified(false); | 2589 | setModified(false); |
2590 | updateView(); | 2590 | updateView(); |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | void CalendarView::archiveCalendar() | 2593 | void CalendarView::archiveCalendar() |
2594 | { | 2594 | { |
2595 | mDialogManager->showArchiveDialog(); | 2595 | mDialogManager->showArchiveDialog(); |
2596 | } | 2596 | } |
2597 | 2597 | ||
2598 | 2598 | ||
2599 | void CalendarView::readSettings() | 2599 | void CalendarView::readSettings() |
2600 | { | 2600 | { |
2601 | 2601 | ||
2602 | 2602 | ||
2603 | // mViewManager->showAgendaView(); | 2603 | // mViewManager->showAgendaView(); |
2604 | QString str; | 2604 | QString str; |
2605 | //qDebug("CalendarView::readSettings() "); | 2605 | //qDebug("CalendarView::readSettings() "); |
2606 | // read settings from the KConfig, supplying reasonable | 2606 | // read settings from the KConfig, supplying reasonable |
2607 | // defaults where none are to be found | 2607 | // defaults where none are to be found |
2608 | KConfig *config = KOGlobals::config(); | 2608 | KConfig *config = KOGlobals::config(); |
2609 | #ifndef KORG_NOSPLITTER | 2609 | #ifndef KORG_NOSPLITTER |
2610 | config->setGroup("KOrganizer Geometry"); | 2610 | config->setGroup("KOrganizer Geometry"); |
2611 | 2611 | ||
2612 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2612 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2613 | if (sizes.count() != 2) { | 2613 | if (sizes.count() != 2) { |
2614 | sizes << mDateNavigator->minimumSizeHint().width(); | 2614 | sizes << mDateNavigator->minimumSizeHint().width(); |
2615 | sizes << 300; | 2615 | sizes << 300; |
2616 | } | 2616 | } |
2617 | mPanner->setSizes(sizes); | 2617 | mPanner->setSizes(sizes); |
2618 | 2618 | ||
2619 | sizes = config->readIntListEntry("Separator2"); | 2619 | sizes = config->readIntListEntry("Separator2"); |
2620 | if ( ( mResourceView && sizes.count() == 4 ) || | 2620 | if ( ( mResourceView && sizes.count() == 4 ) || |
2621 | ( !mResourceView && sizes.count() == 3 ) ) { | 2621 | ( !mResourceView && sizes.count() == 3 ) ) { |
2622 | mLeftSplitter->setSizes(sizes); | 2622 | mLeftSplitter->setSizes(sizes); |
2623 | } | 2623 | } |
2624 | #endif | 2624 | #endif |
2625 | globalFlagBlockAgenda = 1; | 2625 | globalFlagBlockAgenda = 1; |
2626 | mViewManager->showAgendaView(); | 2626 | mViewManager->showAgendaView(); |
2627 | //mViewManager->readSettings( config ); | 2627 | //mViewManager->readSettings( config ); |
2628 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2628 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2629 | readFilterSettings(config); | 2629 | readFilterSettings(config); |
2630 | 2630 | ||
2631 | #ifdef DESKTOP_VERSION | 2631 | #ifdef DESKTOP_VERSION |
2632 | config->setGroup("WidgetLayout"); | 2632 | config->setGroup("WidgetLayout"); |
2633 | QStringList list; | 2633 | QStringList list; |
2634 | list = config->readListEntry("MainLayout"); | 2634 | list = config->readListEntry("MainLayout"); |
2635 | int x,y,w,h; | 2635 | int x,y,w,h; |
2636 | if ( ! list.isEmpty() ) { | 2636 | if ( ! list.isEmpty() ) { |
2637 | x = list[0].toInt(); | 2637 | x = list[0].toInt(); |
2638 | y = list[1].toInt(); | 2638 | y = list[1].toInt(); |
2639 | w = list[2].toInt(); | 2639 | w = list[2].toInt(); |
2640 | h = list[3].toInt(); | 2640 | h = list[3].toInt(); |
2641 | KApplication::testCoords( &x,&y,&w,&h ); | 2641 | KApplication::testCoords( &x,&y,&w,&h ); |
2642 | topLevelWidget()->setGeometry(x,y,w,h); | 2642 | topLevelWidget()->setGeometry(x,y,w,h); |
2643 | 2643 | ||
2644 | } else { | 2644 | } else { |
2645 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2645 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2646 | } | 2646 | } |
2647 | list = config->readListEntry("EditEventLayout"); | 2647 | list = config->readListEntry("EditEventLayout"); |
2648 | if ( ! list.isEmpty() ) { | 2648 | if ( ! list.isEmpty() ) { |
2649 | x = list[0].toInt(); | 2649 | x = list[0].toInt(); |
2650 | y = list[1].toInt(); | 2650 | y = list[1].toInt(); |
2651 | w = list[2].toInt(); | 2651 | w = list[2].toInt(); |
2652 | h = list[3].toInt(); | 2652 | h = list[3].toInt(); |
2653 | KApplication::testCoords( &x,&y,&w,&h ); | 2653 | KApplication::testCoords( &x,&y,&w,&h ); |
2654 | mEventEditor->setGeometry(x,y,w,h); | 2654 | mEventEditor->setGeometry(x,y,w,h); |
2655 | 2655 | ||
2656 | } | 2656 | } |
2657 | list = config->readListEntry("EditTodoLayout"); | 2657 | list = config->readListEntry("EditTodoLayout"); |
2658 | if ( ! list.isEmpty() ) { | 2658 | if ( ! list.isEmpty() ) { |
2659 | x = list[0].toInt(); | 2659 | x = list[0].toInt(); |
2660 | y = list[1].toInt(); | 2660 | y = list[1].toInt(); |
2661 | w = list[2].toInt(); | 2661 | w = list[2].toInt(); |
2662 | h = list[3].toInt(); | 2662 | h = list[3].toInt(); |
2663 | KApplication::testCoords( &x,&y,&w,&h ); | 2663 | KApplication::testCoords( &x,&y,&w,&h ); |
2664 | mTodoEditor->setGeometry(x,y,w,h); | 2664 | mTodoEditor->setGeometry(x,y,w,h); |
2665 | 2665 | ||
2666 | } | 2666 | } |
2667 | list = config->readListEntry("ViewerLayout"); | 2667 | list = config->readListEntry("ViewerLayout"); |
2668 | if ( ! list.isEmpty() ) { | 2668 | if ( ! list.isEmpty() ) { |
2669 | x = list[0].toInt(); | 2669 | x = list[0].toInt(); |
2670 | y = list[1].toInt(); | 2670 | y = list[1].toInt(); |
2671 | w = list[2].toInt(); | 2671 | w = list[2].toInt(); |
2672 | h = list[3].toInt(); | 2672 | h = list[3].toInt(); |
2673 | KApplication::testCoords( &x,&y,&w,&h ); | 2673 | KApplication::testCoords( &x,&y,&w,&h ); |
2674 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2674 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2675 | } | 2675 | } |
2676 | #endif | 2676 | #endif |
2677 | config->setGroup( "Views" ); | 2677 | config->setGroup( "Views" ); |
2678 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2678 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2679 | 2679 | ||
2680 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2680 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2681 | 2681 | ||
2682 | int resetval = 0; | 2682 | int resetval = 0; |
2683 | int maxVal = 0; | 2683 | int maxVal = 0; |
2684 | if (sizes.count() != 3) { | 2684 | if (sizes.count() != 3) { |
2685 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2685 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2686 | resetval = mDateNavigator->sizeHint().width()+2; | 2686 | resetval = mDateNavigator->sizeHint().width()+2; |
2687 | } else { | 2687 | } else { |
2688 | resetval = mDateNavigator->sizeHint().height()+2; | 2688 | resetval = mDateNavigator->sizeHint().height()+2; |
2689 | } | 2689 | } |
2690 | } | 2690 | } |
2691 | if ( resetval ) { | 2691 | if ( resetval ) { |
2692 | sizes.clear(); | 2692 | sizes.clear(); |
2693 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2693 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2694 | maxVal = QApplication::desktop()->width() -10; | 2694 | maxVal = QApplication::desktop()->width() -10; |
2695 | } else { | 2695 | } else { |
2696 | maxVal = QApplication::desktop()->height()-10; | 2696 | maxVal = QApplication::desktop()->height()-10; |
2697 | } | 2697 | } |
2698 | sizes << resetval; | 2698 | sizes << resetval; |
2699 | if ( maxVal < resetval + resetval) | 2699 | if ( maxVal < resetval + resetval) |
2700 | resetval = maxVal - resetval; | 2700 | resetval = maxVal - resetval; |
2701 | sizes << resetval; | 2701 | sizes << resetval; |
2702 | sizes << 100; | 2702 | sizes << 100; |
2703 | } | 2703 | } |
2704 | mLeftFrame->setSizes(sizes); | 2704 | mLeftFrame->setSizes(sizes); |
2705 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2705 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2706 | resetval = 0; | 2706 | resetval = 0; |
2707 | maxVal = 0; | 2707 | maxVal = 0; |
2708 | if (sizes.count() != 2) { | 2708 | if (sizes.count() != 2) { |
2709 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2709 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2710 | resetval = mDateNavigator->sizeHint().width()+2; | 2710 | resetval = mDateNavigator->sizeHint().width()+2; |
2711 | } else { | 2711 | } else { |
2712 | resetval = mDateNavigator->sizeHint().height()+2; | 2712 | resetval = mDateNavigator->sizeHint().height()+2; |
2713 | } | 2713 | } |
2714 | } | 2714 | } |
2715 | if ( resetval ) { | 2715 | if ( resetval ) { |
2716 | sizes.clear(); | 2716 | sizes.clear(); |
2717 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2717 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2718 | maxVal = QApplication::desktop()->width() -10; | 2718 | maxVal = QApplication::desktop()->width() -10; |
2719 | } else { | 2719 | } else { |
2720 | maxVal = QApplication::desktop()->height()-10; | 2720 | maxVal = QApplication::desktop()->height()-10; |
2721 | } | 2721 | } |
2722 | sizes << resetval; | 2722 | sizes << resetval; |
2723 | if ( maxVal < resetval + resetval) | 2723 | if ( maxVal < resetval + resetval) |
2724 | resetval = maxVal - resetval; | 2724 | resetval = maxVal - resetval; |
2725 | sizes << resetval; | 2725 | sizes << resetval; |
2726 | } | 2726 | } |
2727 | mMainFrame->setSizes(sizes); | 2727 | mMainFrame->setSizes(sizes); |
2728 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2728 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2729 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2729 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2730 | else mNavigator->selectDates( dateCount ); | 2730 | else mNavigator->selectDates( dateCount ); |
2731 | // mViewManager->readSettings( config ); | 2731 | // mViewManager->readSettings( config ); |
2732 | updateConfig(); | 2732 | updateConfig(); |
2733 | globalFlagBlockAgenda = 2; | 2733 | globalFlagBlockAgenda = 2; |
2734 | mViewManager->readSettings( config ); | 2734 | mViewManager->readSettings( config ); |
2735 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2735 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2736 | } | 2736 | } |
2737 | 2737 | ||
2738 | void CalendarView::checkSuspendAlarm() | 2738 | void CalendarView::checkSuspendAlarm() |
2739 | { | 2739 | { |
2740 | if ( mSuspendTimer->isActive() ) { | 2740 | if ( mSuspendTimer->isActive() ) { |
2741 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2741 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2742 | } | 2742 | } |
2743 | } | 2743 | } |
2744 | void CalendarView::writeSettings() | 2744 | void CalendarView::writeSettings() |
2745 | { | 2745 | { |
2746 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2746 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2747 | 2747 | ||
2748 | KConfig *config = KOGlobals::config(); | 2748 | KConfig *config = KOGlobals::config(); |
2749 | 2749 | ||
2750 | mViewManager->writeSettings( config ); | 2750 | mViewManager->writeSettings( config ); |
2751 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2751 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2752 | mDialogManager->writeSettings( config ); | 2752 | mDialogManager->writeSettings( config ); |
2753 | //KOPrefs::instance()->usrWriteConfig(); | 2753 | //KOPrefs::instance()->usrWriteConfig(); |
2754 | KOPrefs::instance()->writeConfig(); | 2754 | KOPrefs::instance()->writeConfig(); |
2755 | 2755 | ||
2756 | writeFilterSettings(config); | 2756 | writeFilterSettings(config); |
2757 | config->setGroup( "AppRun" ); | 2757 | config->setGroup( "AppRun" ); |
2758 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2758 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2759 | int days = dt.daysTo( QDate::currentDate() ); | 2759 | int days = dt.daysTo( QDate::currentDate() ); |
2760 | dt = dt.addDays( days ); | 2760 | dt = dt.addDays( days ); |
2761 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2761 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2762 | config->writeEntry( "LatestProgramStopDays", days ); | 2762 | config->writeEntry( "LatestProgramStopDays", days ); |
2763 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2763 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2764 | //qDebug("KO: Writing stop time: %d ", secs); | 2764 | //qDebug("KO: Writing stop time: %d ", secs); |
2765 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2765 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2766 | //QDateTime latest = dt.addSecs ( secs ); | 2766 | //QDateTime latest = dt.addSecs ( secs ); |
2767 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2767 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2768 | config->setGroup( "Views" ); | 2768 | config->setGroup( "Views" ); |
2769 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2769 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2770 | 2770 | ||
2771 | #if 0 | 2771 | #if 0 |
2772 | qDebug("********************* "); | 2772 | qDebug("********************* "); |
2773 | qDebug("Testcode secsto "); | 2773 | qDebug("Testcode secsto "); |
2774 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2774 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2775 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2775 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2776 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2776 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2777 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2777 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2778 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2778 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2779 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2779 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2780 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2780 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2781 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2781 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2782 | qDebug("********************* testcode end"); | 2782 | qDebug("********************* testcode end"); |
2783 | 2783 | ||
2784 | #endif | 2784 | #endif |
2785 | 2785 | ||
2786 | QValueList<int> listINT = mLeftFrame->sizes(); | 2786 | QValueList<int> listINT = mLeftFrame->sizes(); |
2787 | config->writeEntry("Left Splitter Frame",listINT); | 2787 | config->writeEntry("Left Splitter Frame",listINT); |
2788 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2788 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2789 | config->writeEntry("Main Splitter Frame",listINT2); | 2789 | config->writeEntry("Main Splitter Frame",listINT2); |
2790 | #ifdef DESKTOP_VERSION | 2790 | #ifdef DESKTOP_VERSION |
2791 | config->setGroup("WidgetLayout"); | 2791 | config->setGroup("WidgetLayout"); |
2792 | QStringList list ;//= config->readListEntry("MainLayout"); | 2792 | QStringList list ;//= config->readListEntry("MainLayout"); |
2793 | int x,y,w,h; | 2793 | int x,y,w,h; |
2794 | QWidget* wid; | 2794 | QWidget* wid; |
2795 | wid = topLevelWidget(); | 2795 | wid = topLevelWidget(); |
2796 | x = wid->geometry().x(); | 2796 | x = wid->geometry().x(); |
2797 | y = wid->geometry().y(); | 2797 | y = wid->geometry().y(); |
2798 | w = wid->width(); | 2798 | w = wid->width(); |
2799 | h = wid->height(); | 2799 | h = wid->height(); |
2800 | list.clear(); | 2800 | list.clear(); |
2801 | list << QString::number( x ); | 2801 | list << QString::number( x ); |
2802 | list << QString::number( y ); | 2802 | list << QString::number( y ); |
2803 | list << QString::number( w ); | 2803 | list << QString::number( w ); |
2804 | list << QString::number( h ); | 2804 | list << QString::number( h ); |
2805 | config->writeEntry("MainLayout",list ); | 2805 | config->writeEntry("MainLayout",list ); |
2806 | 2806 | ||
2807 | wid = mEventEditor; | 2807 | wid = mEventEditor; |
2808 | x = wid->geometry().x(); | 2808 | x = wid->geometry().x(); |
2809 | y = wid->geometry().y(); | 2809 | y = wid->geometry().y(); |
2810 | w = wid->width(); | 2810 | w = wid->width(); |
2811 | h = wid->height(); | 2811 | h = wid->height(); |
2812 | list.clear(); | 2812 | list.clear(); |
2813 | list << QString::number( x ); | 2813 | list << QString::number( x ); |
2814 | list << QString::number( y ); | 2814 | list << QString::number( y ); |
2815 | list << QString::number( w ); | 2815 | list << QString::number( w ); |
2816 | list << QString::number( h ); | 2816 | list << QString::number( h ); |
2817 | config->writeEntry("EditEventLayout",list ); | 2817 | config->writeEntry("EditEventLayout",list ); |
2818 | 2818 | ||
2819 | wid = mTodoEditor; | 2819 | wid = mTodoEditor; |
2820 | x = wid->geometry().x(); | 2820 | x = wid->geometry().x(); |
2821 | y = wid->geometry().y(); | 2821 | y = wid->geometry().y(); |
2822 | w = wid->width(); | 2822 | w = wid->width(); |
2823 | h = wid->height(); | 2823 | h = wid->height(); |
2824 | list.clear(); | 2824 | list.clear(); |
2825 | list << QString::number( x ); | 2825 | list << QString::number( x ); |
2826 | list << QString::number( y ); | 2826 | list << QString::number( y ); |
2827 | list << QString::number( w ); | 2827 | list << QString::number( w ); |
2828 | list << QString::number( h ); | 2828 | list << QString::number( h ); |
2829 | config->writeEntry("EditTodoLayout",list ); | 2829 | config->writeEntry("EditTodoLayout",list ); |
2830 | wid = getEventViewerDialog(); | 2830 | wid = getEventViewerDialog(); |
2831 | x = wid->geometry().x(); | 2831 | x = wid->geometry().x(); |
2832 | y = wid->geometry().y(); | 2832 | y = wid->geometry().y(); |
2833 | w = wid->width(); | 2833 | w = wid->width(); |
2834 | h = wid->height(); | 2834 | h = wid->height(); |
2835 | list.clear(); | 2835 | list.clear(); |
2836 | list << QString::number( x ); | 2836 | list << QString::number( x ); |
2837 | list << QString::number( y ); | 2837 | list << QString::number( y ); |
2838 | list << QString::number( w ); | 2838 | list << QString::number( w ); |
2839 | list << QString::number( h ); | 2839 | list << QString::number( h ); |
2840 | config->writeEntry("ViewerLayout",list ); | 2840 | config->writeEntry("ViewerLayout",list ); |
2841 | wid = mDialogManager->getSearchDialog(); | 2841 | wid = mDialogManager->getSearchDialog(); |
2842 | if ( wid ) { | 2842 | if ( wid ) { |
2843 | x = wid->geometry().x(); | 2843 | x = wid->geometry().x(); |
2844 | y = wid->geometry().y(); | 2844 | y = wid->geometry().y(); |
2845 | w = wid->width(); | 2845 | w = wid->width(); |
2846 | h = wid->height(); | 2846 | h = wid->height(); |
2847 | list.clear(); | 2847 | list.clear(); |
2848 | list << QString::number( x ); | 2848 | list << QString::number( x ); |
2849 | list << QString::number( y ); | 2849 | list << QString::number( y ); |
2850 | list << QString::number( w ); | 2850 | list << QString::number( w ); |
2851 | list << QString::number( h ); | 2851 | list << QString::number( h ); |
2852 | config->writeEntry("SearchLayout",list ); | 2852 | config->writeEntry("SearchLayout",list ); |
2853 | } | 2853 | } |
2854 | #endif | 2854 | #endif |
2855 | 2855 | ||
2856 | 2856 | ||
2857 | config->sync(); | 2857 | config->sync(); |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | void CalendarView::readFilterSettings(KConfig *config) | 2860 | void CalendarView::readFilterSettings(KConfig *config) |
2861 | { | 2861 | { |
2862 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2862 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2863 | 2863 | ||
2864 | mFilters.clear(); | 2864 | mFilters.clear(); |
2865 | 2865 | ||
2866 | config->setGroup("General"); | 2866 | config->setGroup("General"); |
2867 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2867 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2868 | 2868 | ||
2869 | QStringList::ConstIterator it = filterList.begin(); | 2869 | QStringList::ConstIterator it = filterList.begin(); |
2870 | QStringList::ConstIterator end = filterList.end(); | 2870 | QStringList::ConstIterator end = filterList.end(); |
2871 | while(it != end) { | 2871 | while(it != end) { |
2872 | // kdDebug() << " filter: " << (*it) << endl; | 2872 | // kdDebug() << " filter: " << (*it) << endl; |
2873 | 2873 | ||
2874 | CalFilter *filter; | 2874 | CalFilter *filter; |
2875 | filter = new CalFilter(*it); | 2875 | filter = new CalFilter(*it); |
2876 | config->setGroup("Filter_" + (*it).utf8()); | 2876 | config->setGroup("Filter_" + (*it).utf8()); |
2877 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2877 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2878 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2878 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2879 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2879 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2880 | mFilters.append(filter); | 2880 | mFilters.append(filter); |
2881 | 2881 | ||
2882 | ++it; | 2882 | ++it; |
2883 | } | 2883 | } |
2884 | 2884 | ||
2885 | if (mFilters.count() == 0) { | 2885 | if (mFilters.count() == 0) { |
2886 | CalFilter *filter = new CalFilter(i18n("Default")); | 2886 | CalFilter *filter = new CalFilter(i18n("Default")); |
2887 | mFilters.append(filter); | 2887 | mFilters.append(filter); |
2888 | } | 2888 | } |
2889 | mFilterView->updateFilters(); | 2889 | mFilterView->updateFilters(); |
2890 | config->setGroup("FilterView"); | 2890 | config->setGroup("FilterView"); |
2891 | 2891 | ||
2892 | mFilterView->blockSignals(true); | 2892 | mFilterView->blockSignals(true); |
2893 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2893 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2894 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2894 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2895 | mFilterView->blockSignals(false); | 2895 | mFilterView->blockSignals(false); |
2896 | // We do it manually to avoid it being done twice by the above calls | 2896 | // We do it manually to avoid it being done twice by the above calls |
2897 | updateFilter(); | 2897 | updateFilter(); |
2898 | } | 2898 | } |
2899 | 2899 | ||
2900 | void CalendarView::writeFilterSettings(KConfig *config) | 2900 | void CalendarView::writeFilterSettings(KConfig *config) |
2901 | { | 2901 | { |
2902 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2902 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2903 | 2903 | ||
2904 | QStringList filterList; | 2904 | QStringList filterList; |
2905 | 2905 | ||
2906 | CalFilter *filter = mFilters.first(); | 2906 | CalFilter *filter = mFilters.first(); |
2907 | while(filter) { | 2907 | while(filter) { |
2908 | // kdDebug() << " fn: " << filter->name() << endl; | 2908 | // kdDebug() << " fn: " << filter->name() << endl; |
2909 | filterList << filter->name(); | 2909 | filterList << filter->name(); |
2910 | config->setGroup("Filter_" + filter->name().utf8()); | 2910 | config->setGroup("Filter_" + filter->name().utf8()); |
2911 | config->writeEntry("Criteria",filter->criteria()); | 2911 | config->writeEntry("Criteria",filter->criteria()); |
2912 | config->writeEntry("CategoryList",filter->categoryList()); | 2912 | config->writeEntry("CategoryList",filter->categoryList()); |
2913 | filter = mFilters.next(); | 2913 | filter = mFilters.next(); |
2914 | } | 2914 | } |
2915 | config->setGroup("General"); | 2915 | config->setGroup("General"); |
2916 | config->writeEntry("CalendarFilters",filterList); | 2916 | config->writeEntry("CalendarFilters",filterList); |
2917 | 2917 | ||
2918 | config->setGroup("FilterView"); | 2918 | config->setGroup("FilterView"); |
2919 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2919 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2920 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2920 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2921 | } | 2921 | } |
2922 | 2922 | ||
2923 | 2923 | ||
2924 | void CalendarView::goToday() | 2924 | void CalendarView::goToday() |
2925 | { | 2925 | { |
2926 | if ( mViewManager->currentView()->isMonthView() ) | 2926 | if ( mViewManager->currentView()->isMonthView() ) |
2927 | mNavigator->selectTodayMonth(); | 2927 | mNavigator->selectTodayMonth(); |
2928 | else | 2928 | else |
2929 | mNavigator->selectToday(); | 2929 | mNavigator->selectToday(); |
2930 | } | 2930 | } |
2931 | 2931 | ||
2932 | void CalendarView::goNext() | 2932 | void CalendarView::goNext() |
2933 | { | 2933 | { |
2934 | mNavigator->selectNext(); | 2934 | mNavigator->selectNext(); |
2935 | } | 2935 | } |
2936 | 2936 | ||
2937 | void CalendarView::goPrevious() | 2937 | void CalendarView::goPrevious() |
2938 | { | 2938 | { |
2939 | mNavigator->selectPrevious(); | 2939 | mNavigator->selectPrevious(); |
2940 | } | 2940 | } |
2941 | void CalendarView::goNextMonth() | 2941 | void CalendarView::goNextMonth() |
2942 | { | 2942 | { |
2943 | mNavigator->selectNextMonth(); | 2943 | mNavigator->selectNextMonth(); |
2944 | } | 2944 | } |
2945 | 2945 | ||
2946 | void CalendarView::goPreviousMonth() | 2946 | void CalendarView::goPreviousMonth() |
2947 | { | 2947 | { |
2948 | mNavigator->selectPreviousMonth(); | 2948 | mNavigator->selectPreviousMonth(); |
2949 | } | 2949 | } |
2950 | 2950 | ||
2951 | void CalendarView::updateConfig() | 2951 | void CalendarView::updateConfig() |
2952 | { | 2952 | { |
2953 | if ( KOPrefs::instance()->mUseAppColors ) | 2953 | if ( KOPrefs::instance()->mUseAppColors ) |
2954 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2954 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2955 | emit configChanged(); | 2955 | emit configChanged(); |
2956 | mTodoList->updateConfig(); | 2956 | mTodoList->updateConfig(); |
2957 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2957 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2958 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2958 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2959 | // To make the "fill window" configurations work | 2959 | // To make the "fill window" configurations work |
2960 | //mViewManager->raiseCurrentView(); | 2960 | //mViewManager->raiseCurrentView(); |
2961 | } | 2961 | } |
2962 | 2962 | ||
2963 | 2963 | ||
2964 | void CalendarView::eventChanged(Event *event) | 2964 | void CalendarView::eventChanged(Event *event) |
2965 | { | 2965 | { |
2966 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2966 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2967 | //updateUnmanagedViews(); | 2967 | //updateUnmanagedViews(); |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | void CalendarView::eventAdded(Event *event) | 2970 | void CalendarView::eventAdded(Event *event) |
2971 | { | 2971 | { |
2972 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2972 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2973 | } | 2973 | } |
2974 | 2974 | ||
2975 | void CalendarView::eventToBeDeleted(Event *) | 2975 | void CalendarView::eventToBeDeleted(Event *) |
2976 | { | 2976 | { |
2977 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2977 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | void CalendarView::eventDeleted() | 2980 | void CalendarView::eventDeleted() |
2981 | { | 2981 | { |
2982 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2982 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2983 | } | 2983 | } |
2984 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2984 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2985 | { | 2985 | { |
2986 | changeIncidenceDisplay((Incidence *)which, action); | 2986 | changeIncidenceDisplay((Incidence *)which, action); |
2987 | mDateNavigator->updateView(); //LR | 2987 | mDateNavigator->updateView(); //LR |
2988 | //mDialogManager->updateSearchDialog(); | 2988 | //mDialogManager->updateSearchDialog(); |
2989 | 2989 | ||
2990 | if (which) { | 2990 | if (which) { |
2991 | mViewManager->updateWNview(); | 2991 | mViewManager->updateWNview(); |
2992 | //mTodoList->updateView(); | 2992 | //mTodoList->updateView(); |
2993 | } | 2993 | } |
2994 | 2994 | ||
2995 | } | 2995 | } |
2996 | 2996 | ||
2997 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2997 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2998 | { | 2998 | { |
2999 | updateUnmanagedViews(); | 2999 | updateUnmanagedViews(); |
3000 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3000 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
3001 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 3001 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
3002 | mCalendar->checkAlarmForIncidence( 0, true ); | 3002 | mCalendar->checkAlarmForIncidence( 0, true ); |
3003 | if ( mEventViewerDialog ) | 3003 | if ( mEventViewerDialog ) |
3004 | mEventViewerDialog->hide(); | 3004 | mEventViewerDialog->hide(); |
3005 | } | 3005 | } |
3006 | else | 3006 | else |
3007 | mCalendar->checkAlarmForIncidence( which , false ); | 3007 | mCalendar->checkAlarmForIncidence( which , false ); |
3008 | } | 3008 | } |
3009 | 3009 | ||
3010 | // most of the changeEventDisplays() right now just call the view's | 3010 | // most of the changeEventDisplays() right now just call the view's |
3011 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 3011 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
3012 | void CalendarView::changeEventDisplay(Event *which, int action) | 3012 | void CalendarView::changeEventDisplay(Event *which, int action) |
3013 | { | 3013 | { |
3014 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 3014 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
3015 | changeIncidenceDisplay((Incidence *)which, action); | 3015 | changeIncidenceDisplay((Incidence *)which, action); |
3016 | static bool clearallviews = false; | 3016 | static bool clearallviews = false; |
3017 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3017 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3018 | if ( clearallviews ) { | 3018 | if ( clearallviews ) { |
3019 | clearAllViews(); | 3019 | clearAllViews(); |
3020 | clearallviews = false; | 3020 | clearallviews = false; |
3021 | } | 3021 | } |
3022 | return; | 3022 | return; |
3023 | } | 3023 | } |
3024 | clearallviews = true; | 3024 | clearallviews = true; |
3025 | mDateNavigator->updateView(); | 3025 | mDateNavigator->updateView(); |
3026 | //mDialogManager->updateSearchDialog(); | 3026 | //mDialogManager->updateSearchDialog(); |
3027 | if (which) { | 3027 | if (which) { |
3028 | // If there is an event view visible update the display | 3028 | // If there is an event view visible update the display |
3029 | mViewManager->currentView()->changeEventDisplay(which,action); | 3029 | mViewManager->currentView()->changeEventDisplay(which,action); |
3030 | // TODO: check, if update needed | 3030 | // TODO: check, if update needed |
3031 | // if (which->getTodoStatus()) { | 3031 | // if (which->getTodoStatus()) { |
3032 | mTodoList->updateView(); | 3032 | mTodoList->updateView(); |
3033 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { | 3033 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { |
3034 | mConflictingEvent = which ; | 3034 | mConflictingEvent = which ; |
3035 | int time = 1000; | 3035 | int time = 1000; |
3036 | #ifdef DESKTOP_VERSION | 3036 | #ifdef DESKTOP_VERSION |
3037 | time = 500; | 3037 | time = 500; |
3038 | #endif | 3038 | #endif |
3039 | bool checkC = false; | 3039 | bool checkC = false; |
3040 | if ( mConflictingEvent->doesFloat() ) { | 3040 | if ( mConflictingEvent->doesFloat() ) { |
3041 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay | 3041 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay |
3042 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3042 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3043 | } else { | 3043 | } else { |
3044 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay | 3044 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay |
3045 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3045 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3046 | } | 3046 | } |
3047 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) | 3047 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) |
3048 | checkC = false; | 3048 | checkC = false; |
3049 | if ( checkC ) | 3049 | if ( checkC ) |
3050 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 3050 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
3051 | } | 3051 | } |
3052 | // } | 3052 | // } |
3053 | } else { | 3053 | } else { |
3054 | mViewManager->currentView()->updateView(); | 3054 | mViewManager->currentView()->updateView(); |
3055 | } | 3055 | } |
3056 | } | 3056 | } |
3057 | void CalendarView::checkConflictForEvent() | 3057 | void CalendarView::checkConflictForEvent() |
3058 | { | 3058 | { |
3059 | 3059 | ||
3060 | if (!KOPrefs::instance()->mConfirm) | 3060 | if (!KOPrefs::instance()->mConfirm) |
3061 | return; | 3061 | return; |
3062 | if ( ! mConflictingEvent ) return; | 3062 | if ( ! mConflictingEvent ) return; |
3063 | Event * conflictingEvent = mConflictingEvent; | 3063 | Event * conflictingEvent = mConflictingEvent; |
3064 | mConflictingEvent = 0; | 3064 | mConflictingEvent = 0; |
3065 | QDateTime current = QDateTime::currentDateTime(); | 3065 | QDateTime current = QDateTime::currentDateTime(); |
3066 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 3066 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
3067 | return; | 3067 | return; |
3068 | } | 3068 | } |
3069 | CalFilter *filterIN = 0; | 3069 | CalFilter *filterIN = 0; |
3070 | CalFilter *filterALL = 0; | 3070 | CalFilter *filterALL = 0; |
3071 | CalFilter *filter = mFilters.first(); | 3071 | CalFilter *filter = mFilters.first(); |
3072 | while(filter) { | 3072 | while(filter) { |
3073 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) | 3073 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) |
3074 | filterIN = filter; | 3074 | filterIN = filter; |
3075 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) | 3075 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) |
3076 | filterALL = filter; | 3076 | filterALL = filter; |
3077 | filter = mFilters.next(); | 3077 | filter = mFilters.next(); |
3078 | } | 3078 | } |
3079 | if ( filterIN ) { | 3079 | if ( filterIN ) { |
3080 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { | 3080 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { |
3081 | return; | 3081 | return; |
3082 | } | 3082 | } |
3083 | } | 3083 | } |
3084 | QPtrList<Event> testlist = mCalendar->events(); | 3084 | QPtrList<Event> testlist = mCalendar->events(); |
3085 | Event * test = testlist.first(); | 3085 | Event * test = testlist.first(); |
3086 | QDateTime conflict; | 3086 | QDateTime conflict; |
3087 | QDateTime retVal; | 3087 | QDateTime retVal; |
3088 | bool found = false; | 3088 | bool found = false; |
3089 | Event * cE = 0; | 3089 | Event * cE = 0; |
3090 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; | 3090 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; |
3091 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3091 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3092 | if ( !conflictingEvent->doesFloat() ) { | 3092 | if ( !conflictingEvent->doesFloat() ) { |
3093 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; | 3093 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; |
3094 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3094 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3095 | } | 3095 | } |
3096 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 3096 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
3097 | while ( test ) { | 3097 | while ( test ) { |
3098 | qApp->processEvents(); | 3098 | qApp->processEvents(); |
3099 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); | 3099 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); |
3100 | 3100 | ||
3101 | if ( !skip ) { | 3101 | if ( !skip ) { |
3102 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) | 3102 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) |
3103 | skip = true; | 3103 | skip = true; |
3104 | } | 3104 | } |
3105 | if ( !skip ) { | 3105 | if ( !skip ) { |
3106 | if ( filterALL ) { | 3106 | if ( filterALL ) { |
3107 | if ( !filterALL->filterCalendarItem( test ) ) { | 3107 | if ( !filterALL->filterCalendarItem( test ) ) { |
3108 | skip = true; | 3108 | skip = true; |
3109 | } | 3109 | } |
3110 | } | 3110 | } |
3111 | if ( !skip ) { | 3111 | if ( !skip ) { |
3112 | if ( found ) | 3112 | if ( found ) |
3113 | skip = !test->matchTime( ¤t, &conflict ); | 3113 | skip = !test->matchTime( ¤t, &conflict ); |
3114 | else | 3114 | else |
3115 | skip = !test->matchTime( ¤t, 0 ); | 3115 | skip = !test->matchTime( ¤t, 0 ); |
3116 | if ( !skip ) { | 3116 | if ( !skip ) { |
3117 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 3117 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
3118 | if ( ! found ) { | 3118 | if ( ! found ) { |
3119 | conflict = retVal; | 3119 | conflict = retVal; |
3120 | cE = test; | 3120 | cE = test; |
3121 | } else { | 3121 | } else { |
3122 | if ( retVal < conflict ) { | 3122 | if ( retVal < conflict ) { |
3123 | conflict = retVal; | 3123 | conflict = retVal; |
3124 | cE = test; | 3124 | cE = test; |
3125 | } | 3125 | } |
3126 | } | 3126 | } |
3127 | found = true; | 3127 | found = true; |
3128 | } | 3128 | } |
3129 | } | 3129 | } |
3130 | } | 3130 | } |
3131 | } | 3131 | } |
3132 | test = testlist.next(); | 3132 | test = testlist.next(); |
3133 | } | 3133 | } |
3134 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 3134 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
3135 | if ( found ) { | 3135 | if ( found ) { |
3136 | 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()) ) ; | 3136 | 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()) ) ; |
3137 | qApp->processEvents(); | 3137 | qApp->processEvents(); |
3138 | int km = KMessageBox::warningContinueCancel(this,mess, | 3138 | int km = KMessageBox::warningContinueCancel(this,mess, |
3139 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); | 3139 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); |
3140 | if ( km != KMessageBox::Continue ) { | 3140 | if ( km != KMessageBox::Continue ) { |
3141 | return; | 3141 | return; |
3142 | } | 3142 | } |
3143 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 3143 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
3144 | mViewManager->showDayView(); | 3144 | mViewManager->showDayView(); |
3145 | mNavigator->slotDaySelect( conflict.date() ); | 3145 | mNavigator->slotDaySelect( conflict.date() ); |
3146 | int hour = conflict.time().hour(); | 3146 | int hour = conflict.time().hour(); |
3147 | mViewManager->agendaView()->setStartHour( hour ); | 3147 | mViewManager->agendaView()->setStartHour( hour ); |
3148 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 3148 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
3149 | } else | 3149 | } else |
3150 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 3150 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
3151 | return; | 3151 | return; |
3152 | 3152 | ||
3153 | } | 3153 | } |
3154 | 3154 | ||
3155 | void CalendarView::updateTodoViews() | 3155 | void CalendarView::updateTodoViews() |
3156 | { | 3156 | { |
3157 | mTodoList->updateView(); | 3157 | mTodoList->updateView(); |
3158 | mViewManager->currentView()->updateView(); | 3158 | mViewManager->currentView()->updateView(); |
3159 | 3159 | ||
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | 3162 | ||
3163 | 3163 | ||
3164 | void CalendarView::clearAllViews() | 3164 | void CalendarView::clearAllViews() |
3165 | { | 3165 | { |
3166 | mTodoList->clearList(); | 3166 | mTodoList->clearList(); |
3167 | mViewManager->clearAllViews(); | 3167 | mViewManager->clearAllViews(); |
3168 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 3168 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
3169 | if ( sd ) { | 3169 | if ( sd ) { |
3170 | KOListView* kol = sd->listview(); | 3170 | KOListView* kol = sd->listview(); |
3171 | if ( kol ) | 3171 | if ( kol ) |
3172 | kol->clearList(); | 3172 | kol->clearList(); |
3173 | } | 3173 | } |
3174 | } | 3174 | } |
3175 | void CalendarView::updateView() | 3175 | void CalendarView::updateView() |
3176 | { | 3176 | { |
3177 | static bool clearallviews = false; | 3177 | static bool clearallviews = false; |
3178 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3178 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3179 | if ( clearallviews ) { | 3179 | if ( clearallviews ) { |
3180 | clearAllViews(); | 3180 | clearAllViews(); |
3181 | clearallviews = false; | 3181 | clearallviews = false; |
3182 | } | 3182 | } |
3183 | return; | 3183 | return; |
3184 | } | 3184 | } |
3185 | clearallviews = true; | 3185 | clearallviews = true; |
3186 | DateList tmpList = mNavigator->selectedDates(); | 3186 | DateList tmpList = mNavigator->selectedDates(); |
3187 | 3187 | ||
3188 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 3188 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
3189 | mTodoList->updateView(); | 3189 | mTodoList->updateView(); |
3190 | // We assume that the navigator only selects consecutive days. | 3190 | // We assume that the navigator only selects consecutive days. |
3191 | updateView( tmpList.first(), tmpList.last() ); | 3191 | updateView( tmpList.first(), tmpList.last() ); |
3192 | } | 3192 | } |
3193 | 3193 | ||
3194 | void CalendarView::updateUnmanagedViews() | 3194 | void CalendarView::updateUnmanagedViews() |
3195 | { | 3195 | { |
3196 | mDateNavigator->updateDayMatrix(); | 3196 | mDateNavigator->updateDayMatrix(); |
3197 | } | 3197 | } |
3198 | 3198 | ||
3199 | int CalendarView::msgItemDelete(const QString name) | 3199 | int CalendarView::msgItemDelete(const QString name) |
3200 | { | 3200 | { |
3201 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 3201 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
3202 | i18n("This item will be\npermanently deleted."), | 3202 | i18n("This item will be\npermanently deleted."), |
3203 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 3203 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
3204 | } | 3204 | } |
3205 | 3205 | ||
3206 | 3206 | ||
3207 | void CalendarView::edit_cut() | 3207 | void CalendarView::edit_cut() |
3208 | { | 3208 | { |
3209 | Event *anEvent=0; | 3209 | Event *anEvent=0; |
3210 | 3210 | ||
3211 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3211 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3212 | 3212 | ||
3213 | if (mViewManager->currentView()->isEventView()) { | 3213 | if (mViewManager->currentView()->isEventView()) { |
3214 | if ( incidence && incidence->typeID() == eventID ) { | 3214 | if ( incidence && incidence->typeID() == eventID ) { |
3215 | anEvent = static_cast<Event *>(incidence); | 3215 | anEvent = static_cast<Event *>(incidence); |
3216 | } | 3216 | } |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | if (!anEvent) { | 3219 | if (!anEvent) { |
3220 | KNotifyClient::beep(); | 3220 | KNotifyClient::beep(); |
3221 | return; | 3221 | return; |
3222 | } | 3222 | } |
3223 | DndFactory factory( mCalendar ); | 3223 | DndFactory factory( mCalendar ); |
3224 | factory.cutIncidence(anEvent); | 3224 | factory.cutIncidence(anEvent); |
3225 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3225 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3226 | } | 3226 | } |
3227 | 3227 | ||
3228 | void CalendarView::edit_copy() | 3228 | void CalendarView::edit_copy() |
3229 | { | 3229 | { |
3230 | Event *anEvent=0; | 3230 | Event *anEvent=0; |
3231 | 3231 | ||
3232 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3232 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3233 | 3233 | ||
3234 | if (mViewManager->currentView()->isEventView()) { | 3234 | if (mViewManager->currentView()->isEventView()) { |
3235 | if ( incidence && incidence->typeID() == eventID ) { | 3235 | if ( incidence && incidence->typeID() == eventID ) { |
3236 | anEvent = static_cast<Event *>(incidence); | 3236 | anEvent = static_cast<Event *>(incidence); |
3237 | } | 3237 | } |
3238 | } | 3238 | } |
3239 | 3239 | ||
3240 | if (!anEvent) { | 3240 | if (!anEvent) { |
3241 | KNotifyClient::beep(); | 3241 | KNotifyClient::beep(); |
3242 | return; | 3242 | return; |
3243 | } | 3243 | } |
3244 | DndFactory factory( mCalendar ); | 3244 | DndFactory factory( mCalendar ); |
3245 | factory.copyIncidence(anEvent); | 3245 | factory.copyIncidence(anEvent); |
3246 | } | 3246 | } |
3247 | 3247 | ||
3248 | void CalendarView::edit_paste() | 3248 | void CalendarView::edit_paste() |
3249 | { | 3249 | { |
3250 | QDate date = mNavigator->selectedDates().first(); | 3250 | QDate date = mNavigator->selectedDates().first(); |
3251 | 3251 | ||
3252 | DndFactory factory( mCalendar ); | 3252 | DndFactory factory( mCalendar ); |
3253 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 3253 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
3254 | 3254 | ||
3255 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 3255 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
3256 | } | 3256 | } |
3257 | void CalendarView::edit_global_options() | 3257 | void CalendarView::edit_global_options() |
3258 | { | 3258 | { |
3259 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 3259 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
3260 | emit save(); | 3260 | emit save(); |
3261 | emit saveStopTimer(); | 3261 | emit saveStopTimer(); |
3262 | mDialogManager->showGlobalOptionsDialog(); | 3262 | mDialogManager->showGlobalOptionsDialog(); |
3263 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 3263 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
3264 | emit saveStopTimer(); | 3264 | emit saveStopTimer(); |
3265 | 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!"), | 3265 | 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!"), |
3266 | i18n("Timezone settings"),i18n("Reload"))) { | 3266 | i18n("Timezone settings"),i18n("Reload"))) { |
3267 | qDebug("KO: TZ reload cancelled "); | 3267 | qDebug("KO: TZ reload cancelled "); |
3268 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3268 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3269 | return; | 3269 | return; |
3270 | } | 3270 | } |
3271 | qDebug("KO: Timezone change "); | 3271 | qDebug("KO: Timezone change "); |
3272 | loadCalendars(); | 3272 | loadCalendars(); |
3273 | setModified(true); | 3273 | setModified(true); |
3274 | } | 3274 | } |
3275 | else | 3275 | else |
3276 | qDebug("KO: No tz change "); | 3276 | qDebug("KO: No tz change "); |
3277 | } | 3277 | } |
3278 | void CalendarView::edit_options() | 3278 | void CalendarView::edit_options() |
3279 | { | 3279 | { |
3280 | mDialogManager->showOptionsDialog(); | 3280 | mDialogManager->showOptionsDialog(); |
3281 | } | 3281 | } |
3282 | 3282 | ||
3283 | 3283 | ||
3284 | void CalendarView::slotSelectPickerDate( QDate d) | 3284 | void CalendarView::slotSelectPickerDate( QDate d) |
3285 | { | 3285 | { |
3286 | mDateFrame->hide(); | 3286 | mDateFrame->hide(); |
3287 | if ( mDatePickerMode == 1 ) { | 3287 | if ( mDatePickerMode == 1 ) { |
3288 | mNavigator->slotDaySelect( d ); | 3288 | mNavigator->slotDaySelect( d ); |
3289 | } else if ( mDatePickerMode == 2 ) { | 3289 | } else if ( mDatePickerMode == 2 ) { |
3290 | if ( mMoveIncidence->typeID() == todoID ) { | 3290 | if ( mMoveIncidence->typeID() == todoID ) { |
3291 | Todo * to = (Todo *) mMoveIncidence; | 3291 | Todo * to = (Todo *) mMoveIncidence; |
3292 | QTime tim; | 3292 | QTime tim; |
3293 | int len = 0; | 3293 | int len = 0; |
3294 | if ( to->hasStartDate() && to->hasDueDate() ) | 3294 | if ( to->hasStartDate() && to->hasDueDate() ) |
3295 | len = to->dtStart().secsTo( to->dtDue()); | 3295 | len = to->dtStart().secsTo( to->dtDue()); |
3296 | if ( to->hasDueDate() ) | 3296 | if ( to->hasDueDate() ) |
3297 | tim = to->dtDue().time(); | 3297 | tim = to->dtDue().time(); |
3298 | else { | 3298 | else { |
3299 | tim = QTime ( 0,0,0 ); | 3299 | tim = QTime ( 0,0,0 ); |
3300 | to->setFloats( true ); | 3300 | to->setFloats( true ); |
3301 | to->setHasDueDate( true ); | 3301 | to->setHasDueDate( true ); |
3302 | } | 3302 | } |
3303 | QDateTime dt ( d,tim ); | 3303 | QDateTime dt ( d,tim ); |
3304 | to->setDtDue( dt ); | 3304 | to->setDtDue( dt ); |
3305 | 3305 | ||
3306 | if ( to->hasStartDate() ) { | 3306 | if ( to->hasStartDate() ) { |
3307 | if ( len>0 ) | 3307 | if ( len>0 ) |
3308 | to->setDtStart(to->dtDue().addSecs( -len )); | 3308 | to->setDtStart(to->dtDue().addSecs( -len )); |
3309 | else | 3309 | else |
3310 | if (to->dtStart() > to->dtDue() ) | 3310 | if (to->dtStart() > to->dtDue() ) |
3311 | to->setDtStart(to->dtDue().addDays( -3 )); | 3311 | to->setDtStart(to->dtDue().addDays( -3 )); |
3312 | } | 3312 | } |
3313 | 3313 | ||
3314 | todoChanged( to ); | 3314 | todoChanged( to ); |
3315 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3315 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3316 | if ( mMoveIncidence->doesRecur() ) { | 3316 | if ( mMoveIncidence->doesRecur() ) { |
3317 | #if 0 | 3317 | #if 0 |
3318 | // PENDING implement this | 3318 | // PENDING implement this |
3319 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3319 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3320 | mCalendar()->addIncidence( newInc ); | 3320 | mCalendar()->addIncidence( newInc ); |
3321 | if ( mMoveIncidence->typeID() == todoID ) | 3321 | if ( mMoveIncidence->typeID() == todoID ) |
3322 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3322 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3323 | else | 3323 | else |
3324 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3324 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3325 | mMoveIncidence = newInc; | 3325 | mMoveIncidence = newInc; |
3326 | 3326 | ||
3327 | #endif | 3327 | #endif |
3328 | } | 3328 | } |
3329 | QTime tim = mMoveIncidence->dtStart().time(); | 3329 | QTime tim = mMoveIncidence->dtStart().time(); |
3330 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3330 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3331 | QDateTime dt ( d,tim ); | 3331 | QDateTime dt ( d,tim ); |
3332 | mMoveIncidence->setDtStart( dt ); | 3332 | mMoveIncidence->setDtStart( dt ); |
3333 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3333 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3334 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3334 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3335 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3335 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3336 | QTime tim = mMoveIncidence->dtStart().time(); | 3336 | QTime tim = mMoveIncidence->dtStart().time(); |
3337 | QDateTime dt ( d,tim ); | 3337 | QDateTime dt ( d,tim ); |
3338 | mMoveIncidence->setDtStart( dt ); | 3338 | mMoveIncidence->setDtStart( dt ); |
3339 | updateView(); | 3339 | updateView(); |
3340 | } | 3340 | } |
3341 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3341 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3342 | } | 3342 | } |
3343 | } | 3343 | } |
3344 | 3344 | ||
3345 | void CalendarView::removeCategories() | 3345 | void CalendarView::removeCategories() |
3346 | { | 3346 | { |
3347 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3347 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3348 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3348 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3349 | QStringList catIncList; | 3349 | QStringList catIncList; |
3350 | QStringList newCatList; | 3350 | QStringList newCatList; |
3351 | Incidence* inc = incList.first(); | 3351 | Incidence* inc = incList.first(); |
3352 | uint i; | 3352 | uint i; |
3353 | while ( inc ) { | 3353 | while ( inc ) { |
3354 | newCatList.clear(); | 3354 | newCatList.clear(); |
3355 | catIncList = inc->categories() ; | 3355 | catIncList = inc->categories() ; |
3356 | for( i = 0; i< catIncList.count(); ++i ) { | 3356 | for( i = 0; i< catIncList.count(); ++i ) { |
3357 | if ( catList.contains (catIncList[i])) | 3357 | if ( catList.contains (catIncList[i])) |
3358 | newCatList.append( catIncList[i] ); | 3358 | newCatList.append( catIncList[i] ); |
3359 | } | 3359 | } |
3360 | newCatList.sort(); | 3360 | newCatList.sort(); |
3361 | inc->setCategories( newCatList.join(",") ); | 3361 | inc->setCategories( newCatList.join(",") ); |
3362 | inc = incList.next(); | 3362 | inc = incList.next(); |
3363 | } | 3363 | } |
3364 | } | 3364 | } |
3365 | 3365 | ||
3366 | int CalendarView::addCategories() | 3366 | int CalendarView::addCategories() |
3367 | { | 3367 | { |
3368 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3368 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3369 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3369 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3370 | QStringList catIncList; | 3370 | QStringList catIncList; |
3371 | Incidence* inc = incList.first(); | 3371 | Incidence* inc = incList.first(); |
3372 | uint i; | 3372 | uint i; |
3373 | int count = 0; | 3373 | int count = 0; |
3374 | while ( inc ) { | 3374 | while ( inc ) { |
3375 | catIncList = inc->categories() ; | 3375 | catIncList = inc->categories() ; |
3376 | for( i = 0; i< catIncList.count(); ++i ) { | 3376 | for( i = 0; i< catIncList.count(); ++i ) { |
3377 | if ( !catList.contains (catIncList[i])) { | 3377 | if ( !catList.contains (catIncList[i])) { |
3378 | catList.append( catIncList[i] ); | 3378 | catList.append( catIncList[i] ); |
3379 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3379 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3380 | ++count; | 3380 | ++count; |
3381 | } | 3381 | } |
3382 | } | 3382 | } |
3383 | inc = incList.next(); | 3383 | inc = incList.next(); |
3384 | } | 3384 | } |
3385 | catList.sort(); | 3385 | catList.sort(); |
3386 | KOPrefs::instance()->mCustomCategories = catList; | 3386 | KOPrefs::instance()->mCustomCategories = catList; |
3387 | return count; | 3387 | return count; |
3388 | } | 3388 | } |
3389 | 3389 | ||
3390 | void CalendarView::editCategories() | 3390 | void CalendarView::editCategories() |
3391 | { | 3391 | { |
3392 | qDebug("CalendarView::editCategories() "); | 3392 | qDebug("CalendarView::editCategories() "); |
3393 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3393 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3394 | ced.exec(); | 3394 | ced.exec(); |
3395 | } | 3395 | } |
3396 | void CalendarView::manageCategories() | 3396 | void CalendarView::manageCategories() |
3397 | { | 3397 | { |
3398 | KOCatPrefs* cp = new KOCatPrefs(); | 3398 | KOCatPrefs* cp = new KOCatPrefs(); |
3399 | cp->show(); | 3399 | cp->show(); |
3400 | int w =cp->sizeHint().width() ; | 3400 | int w =cp->sizeHint().width() ; |
3401 | int h = cp->sizeHint().height() ; | 3401 | int h = cp->sizeHint().height() ; |
3402 | int dw = QApplication::desktop()->width(); | 3402 | int dw = QApplication::desktop()->width(); |
3403 | int dh = QApplication::desktop()->height(); | 3403 | int dh = QApplication::desktop()->height(); |
3404 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3404 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3405 | if ( !cp->exec() ) { | 3405 | if ( !cp->exec() ) { |
3406 | delete cp; | 3406 | delete cp; |
3407 | return; | 3407 | return; |
3408 | } | 3408 | } |
3409 | int count = 0; | 3409 | int count = 0; |
3410 | if ( cp->addCat() ) { | 3410 | if ( cp->addCat() ) { |
3411 | count = addCategories(); | 3411 | count = addCategories(); |
3412 | if ( count ) { | 3412 | if ( count ) { |
3413 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3413 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3414 | writeSettings(); | 3414 | writeSettings(); |
3415 | } else | 3415 | } else |
3416 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3416 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3417 | } else { | 3417 | } else { |
3418 | removeCategories(); | 3418 | removeCategories(); |
3419 | updateView(); | 3419 | updateView(); |
3420 | } | 3420 | } |
3421 | delete cp; | 3421 | delete cp; |
3422 | } | 3422 | } |
3423 | 3423 | ||
3424 | void CalendarView::beamIncidence(Incidence * Inc) | 3424 | void CalendarView::beamIncidence(Incidence * Inc) |
3425 | { | 3425 | { |
3426 | QPtrList<Incidence> delSel ; | 3426 | QPtrList<Incidence> delSel ; |
3427 | delSel.append(Inc); | 3427 | delSel.append(Inc); |
3428 | beamIncidenceList( delSel ); | 3428 | beamIncidenceList( delSel ); |
3429 | } | 3429 | } |
3430 | void CalendarView::beamCalendar() | 3430 | void CalendarView::beamCalendar() |
3431 | { | 3431 | { |
3432 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3432 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3433 | //qDebug("beamCalendar() "); | 3433 | //qDebug("beamCalendar() "); |
3434 | beamIncidenceList( delSel ); | 3434 | beamIncidenceList( delSel ); |
3435 | } | 3435 | } |
3436 | void CalendarView::beamFilteredCalendar() | 3436 | void CalendarView::beamFilteredCalendar() |
3437 | { | 3437 | { |
3438 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3438 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3439 | //qDebug("beamFilteredCalendar() "); | 3439 | //qDebug("beamFilteredCalendar() "); |
3440 | beamIncidenceList( delSel ); | 3440 | beamIncidenceList( delSel ); |
3441 | } | 3441 | } |
3442 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3442 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3443 | { | 3443 | { |
3444 | 3444 | ||
3445 | KOBeamPrefs beamDialog; | 3445 | KOBeamPrefs beamDialog; |
3446 | if ( beamDialog.exec () == QDialog::Rejected ) | 3446 | if ( beamDialog.exec () == QDialog::Rejected ) |
3447 | return; | 3447 | return; |
3448 | #ifdef DESKTOP_VERSION | 3448 | #ifdef DESKTOP_VERSION |
3449 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3449 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3450 | #else | 3450 | #else |
3451 | QString fn = "/tmp/kopibeamfile"; | 3451 | QString fn = "/tmp/kopibeamfile"; |
3452 | #endif | 3452 | #endif |
3453 | QString mes; | 3453 | QString mes; |
3454 | bool createbup = true; | 3454 | bool createbup = true; |
3455 | if ( createbup ) { | 3455 | if ( createbup ) { |
3456 | QString description = "\n"; | 3456 | QString description = "\n"; |
3457 | CalendarLocal* cal = new CalendarLocal(); | 3457 | CalendarLocal* cal = new CalendarLocal(); |
3458 | if ( beamDialog.beamLocal() ) | 3458 | if ( beamDialog.beamLocal() ) |
3459 | cal->setLocalTime(); | 3459 | cal->setLocalTime(); |
3460 | else | 3460 | else |
3461 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3461 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3462 | Incidence *incidence = delSel.first(); | 3462 | Incidence *incidence = delSel.first(); |
3463 | bool addText = false; | 3463 | bool addText = false; |
3464 | if ( delSel.count() < 10 ) | 3464 | if ( delSel.count() < 10 ) |
3465 | addText = true; | 3465 | addText = true; |
3466 | else { | 3466 | else { |
3467 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3467 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3468 | } | 3468 | } |
3469 | while ( incidence ) { | 3469 | while ( incidence ) { |
3470 | Incidence *in = incidence->clone(); | 3470 | Incidence *in = incidence->clone(); |
3471 | if ( ! in->summary().isEmpty() ) { | 3471 | if ( ! in->summary().isEmpty() ) { |
3472 | in->setDescription(""); | 3472 | in->setDescription(""); |
3473 | } else { | 3473 | } else { |
3474 | in->setSummary( in->description().left(20)); | 3474 | in->setSummary( in->description().left(20)); |
3475 | in->setDescription(""); | 3475 | in->setDescription(""); |
3476 | } | 3476 | } |
3477 | if ( addText ) | 3477 | if ( addText ) |
3478 | description += in->summary() + "\n"; | 3478 | description += in->summary() + "\n"; |
3479 | cal->addIncidence( in ); | 3479 | cal->addIncidence( in ); |
3480 | incidence = delSel.next(); | 3480 | incidence = delSel.next(); |
3481 | } | 3481 | } |
3482 | if ( beamDialog.beamVcal() ) { | 3482 | if ( beamDialog.beamVcal() ) { |
3483 | fn += ".vcs"; | 3483 | fn += ".vcs"; |
3484 | FileStorage storage( cal, fn, new VCalFormat ); | 3484 | FileStorage storage( cal, fn, new VCalFormat ); |
3485 | storage.save(); | 3485 | storage.save(); |
3486 | } else { | 3486 | } else { |
3487 | fn += ".ics"; | 3487 | fn += ".ics"; |
3488 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3488 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3489 | storage.save(); | 3489 | storage.save(); |
3490 | } | 3490 | } |
3491 | delete cal; | 3491 | delete cal; |
3492 | mes = i18n("KO/Pi: Ready for beaming"); | 3492 | mes = i18n("KO/Pi: Ready for beaming"); |
3493 | topLevelWidget()->setCaption(mes); | 3493 | topLevelWidget()->setCaption(mes); |
3494 | KApplication::convert2latin1( fn ); | 3494 | KApplication::convert2latin1( fn ); |
3495 | #ifndef DESKTOP_VERSION | 3495 | #ifndef DESKTOP_VERSION |
3496 | Ir *ir = new Ir( this ); | 3496 | Ir *ir = new Ir( this ); |
3497 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3497 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3498 | ir->send( fn, description, "text/x-vCalendar" ); | 3498 | ir->send( fn, description, "text/x-vCalendar" ); |
3499 | #endif | 3499 | #endif |
3500 | } | 3500 | } |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | #ifndef DESKTOP_VERSION | 3503 | #ifndef DESKTOP_VERSION |
3504 | void CalendarView::beamDone( Ir *ir ) | 3504 | void CalendarView::beamDone( Ir *ir ) |
3505 | { | 3505 | { |
3506 | delete ir; | 3506 | delete ir; |
3507 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3507 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3508 | topLevelWidget()->raise(); | 3508 | topLevelWidget()->raise(); |
3509 | } | 3509 | } |
3510 | #else | 3510 | #else |
3511 | void CalendarView::beamDone( Ir *){;} | 3511 | void CalendarView::beamDone( Ir *){;} |
3512 | #endif | 3512 | #endif |
3513 | void CalendarView::moveIncidence(Incidence * inc ) | 3513 | void CalendarView::moveIncidence(Incidence * inc ) |
3514 | { | 3514 | { |
3515 | if ( !inc ) return; | 3515 | if ( !inc ) return; |
3516 | showDatePickerPopup(); | 3516 | showDatePickerPopup(); |
3517 | mDatePickerMode = 2; | 3517 | mDatePickerMode = 2; |
3518 | mMoveIncidence = inc ; | 3518 | mMoveIncidence = inc ; |
3519 | QDate da; | 3519 | QDate da; |
3520 | if ( mMoveIncidence->typeID() == todoID ) { | 3520 | if ( mMoveIncidence->typeID() == todoID ) { |
3521 | Todo * to = (Todo *) mMoveIncidence; | 3521 | Todo * to = (Todo *) mMoveIncidence; |
3522 | if ( to->hasDueDate() ) | 3522 | if ( to->hasDueDate() ) |
3523 | da = to->dtDue().date(); | 3523 | da = to->dtDue().date(); |
3524 | else | 3524 | else |
3525 | da = QDate::currentDate(); | 3525 | da = QDate::currentDate(); |
3526 | } else { | 3526 | } else { |
3527 | da = mMoveIncidence->dtStart().date(); | 3527 | da = mMoveIncidence->dtStart().date(); |
3528 | } | 3528 | } |
3529 | //PENDING set date for recurring incidence to date of recurrence | 3529 | //PENDING set date for recurring incidence to date of recurrence |
3530 | //mMoveIncidenceOldDate; | 3530 | //mMoveIncidenceOldDate; |
3531 | mDatePicker->setDate( da ); | 3531 | mDatePicker->setDate( da ); |
3532 | } | 3532 | } |
3533 | void CalendarView::showDatePickerPopup() | 3533 | void CalendarView::showDatePickerPopup() |
3534 | { | 3534 | { |
3535 | if ( mDateFrame->isVisible() ) | 3535 | if ( mDateFrame->isVisible() ) |
3536 | mDateFrame->hide(); | 3536 | mDateFrame->hide(); |
3537 | else { | 3537 | else { |
3538 | int offX = 0, offY = 0; | 3538 | int offX = 0, offY = 0; |
3539 | #ifdef DESKTOP_VERSION | 3539 | #ifdef DESKTOP_VERSION |
3540 | int w =mDatePicker->sizeHint().width() ; | 3540 | int w =mDatePicker->sizeHint().width() ; |
3541 | int h = mDatePicker->sizeHint().height() ; | 3541 | int h = mDatePicker->sizeHint().height() ; |
3542 | int dw = topLevelWidget()->width(); | 3542 | int dw = topLevelWidget()->width(); |
3543 | int dh = topLevelWidget()->height(); | 3543 | int dh = topLevelWidget()->height(); |
3544 | offX = topLevelWidget()->x(); | 3544 | offX = topLevelWidget()->x(); |
3545 | offY = topLevelWidget()->y(); | 3545 | offY = topLevelWidget()->y(); |
3546 | #else | 3546 | #else |
3547 | int w =mDatePicker->sizeHint().width() ; | 3547 | int w =mDatePicker->sizeHint().width() ; |
3548 | int h = mDatePicker->sizeHint().height() ; | 3548 | int h = mDatePicker->sizeHint().height() ; |
3549 | int dw = QApplication::desktop()->width(); | 3549 | int dw = QApplication::desktop()->width(); |
3550 | int dh = QApplication::desktop()->height(); | 3550 | int dh = QApplication::desktop()->height(); |
3551 | #endif | 3551 | #endif |
3552 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3552 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3553 | mDateFrame->show(); | 3553 | mDateFrame->show(); |
3554 | } | 3554 | } |
3555 | } | 3555 | } |
3556 | void CalendarView::showDatePicker( ) | 3556 | void CalendarView::showDatePicker( ) |
3557 | { | 3557 | { |
3558 | showDatePickerPopup(); | 3558 | showDatePickerPopup(); |
3559 | mDatePickerMode = 1; | 3559 | mDatePickerMode = 1; |
3560 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3560 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3561 | } | 3561 | } |
3562 | 3562 | ||
3563 | void CalendarView::showEventEditor() | 3563 | void CalendarView::showEventEditor() |
3564 | { | 3564 | { |
3565 | #ifdef DESKTOP_VERSION | 3565 | #ifdef DESKTOP_VERSION |
3566 | int x,y,w,h; | 3566 | int x,y,w,h; |
3567 | x = mEventEditor->geometry().x(); | 3567 | x = mEventEditor->geometry().x(); |
3568 | y = mEventEditor->geometry().y(); | 3568 | y = mEventEditor->geometry().y(); |
3569 | w = mEventEditor->width(); | 3569 | w = mEventEditor->width(); |
3570 | h = mEventEditor->height(); | 3570 | h = mEventEditor->height(); |
3571 | mEventEditor->show(); | 3571 | mEventEditor->show(); |
3572 | mEventEditor->setGeometry(x,y,w,h); | 3572 | mEventEditor->setGeometry(x,y,w,h); |
3573 | #else | 3573 | #else |
3574 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3574 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3575 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3575 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3576 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3576 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3577 | qApp->processEvents(); | 3577 | qApp->processEvents(); |
3578 | delete mEventEditor; | 3578 | delete mEventEditor; |
3579 | mEventEditor = mDialogManager->getEventEditor(); | 3579 | mEventEditor = mDialogManager->getEventEditor(); |
3580 | topLevelWidget()->setCaption( i18n("") ); | 3580 | topLevelWidget()->setCaption( i18n("") ); |
3581 | } | 3581 | } |
3582 | mEventEditor->showMaximized(); | 3582 | mEventEditor->showMaximized(); |
3583 | #endif | 3583 | #endif |
3584 | } | 3584 | } |
3585 | void CalendarView::showTodoEditor() | 3585 | void CalendarView::showTodoEditor() |
3586 | { | 3586 | { |
3587 | #ifdef DESKTOP_VERSION | 3587 | #ifdef DESKTOP_VERSION |
3588 | int x,y,w,h; | 3588 | int x,y,w,h; |
3589 | x = mTodoEditor->geometry().x(); | 3589 | x = mTodoEditor->geometry().x(); |
3590 | y = mTodoEditor->geometry().y(); | 3590 | y = mTodoEditor->geometry().y(); |
3591 | w = mTodoEditor->width(); | 3591 | w = mTodoEditor->width(); |
3592 | h = mTodoEditor->height(); | 3592 | h = mTodoEditor->height(); |
3593 | mTodoEditor->show(); | 3593 | mTodoEditor->show(); |
3594 | mTodoEditor->setGeometry(x,y,w,h); | 3594 | mTodoEditor->setGeometry(x,y,w,h); |
3595 | #else | 3595 | #else |
3596 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3596 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3597 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3597 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3598 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3598 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3599 | qApp->processEvents(); | 3599 | qApp->processEvents(); |
3600 | delete mTodoEditor; | 3600 | delete mTodoEditor; |
3601 | mTodoEditor = mDialogManager->getTodoEditor(); | 3601 | mTodoEditor = mDialogManager->getTodoEditor(); |
3602 | topLevelWidget()->setCaption( i18n("") ); | 3602 | topLevelWidget()->setCaption( i18n("") ); |
3603 | } | 3603 | } |
3604 | mTodoEditor->showMaximized(); | 3604 | mTodoEditor->showMaximized(); |
3605 | #endif | 3605 | #endif |
3606 | } | 3606 | } |
3607 | 3607 | ||
3608 | void CalendarView::cloneIncidence() | 3608 | void CalendarView::cloneIncidence() |
3609 | { | 3609 | { |
3610 | Incidence *incidence = currentSelection(); | 3610 | Incidence *incidence = currentSelection(); |
3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3612 | if ( incidence ) { | 3612 | if ( incidence ) { |
3613 | cloneIncidence(incidence); | 3613 | cloneIncidence(incidence); |
3614 | } | 3614 | } |
3615 | } | 3615 | } |
3616 | void CalendarView::moveIncidence() | 3616 | void CalendarView::moveIncidence() |
3617 | { | 3617 | { |
3618 | Incidence *incidence = currentSelection(); | 3618 | Incidence *incidence = currentSelection(); |
3619 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3619 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3620 | if ( incidence ) { | 3620 | if ( incidence ) { |
3621 | moveIncidence(incidence); | 3621 | moveIncidence(incidence); |
3622 | } | 3622 | } |
3623 | } | 3623 | } |
3624 | void CalendarView::beamIncidence() | 3624 | void CalendarView::beamIncidence() |
3625 | { | 3625 | { |
3626 | Incidence *incidence = currentSelection(); | 3626 | Incidence *incidence = currentSelection(); |
3627 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3627 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3628 | if ( incidence ) { | 3628 | if ( incidence ) { |
3629 | beamIncidence(incidence); | 3629 | beamIncidence(incidence); |
3630 | } | 3630 | } |
3631 | } | 3631 | } |
3632 | void CalendarView::toggleCancelIncidence() | 3632 | void CalendarView::toggleCancelIncidence() |
3633 | { | 3633 | { |
3634 | Incidence *incidence = currentSelection(); | 3634 | Incidence *incidence = currentSelection(); |
3635 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3635 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3636 | if ( incidence ) { | 3636 | if ( incidence ) { |
3637 | cancelIncidence(incidence); | 3637 | cancelIncidence(incidence); |
3638 | } | 3638 | } |
3639 | } | 3639 | } |
3640 | 3640 | ||
3641 | 3641 | ||
3642 | void CalendarView::cancelIncidence(Incidence * inc ) | 3642 | void CalendarView::cancelIncidence(Incidence * inc ) |
3643 | { | 3643 | { |
3644 | inc->setCancelled( ! inc->cancelled() ); | 3644 | inc->setCancelled( ! inc->cancelled() ); |
3645 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3645 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3646 | updateView(); | 3646 | updateView(); |
3647 | } | 3647 | } |
3648 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3648 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3649 | { | 3649 | { |
3650 | Incidence * newInc = orgInc->clone(); | 3650 | Incidence * newInc = orgInc->clone(); |
3651 | newInc->recreate(); | 3651 | newInc->recreate(); |
3652 | 3652 | ||
3653 | if ( newInc->typeID() == todoID ) { | 3653 | if ( newInc->typeID() == todoID ) { |
3654 | Todo* t = (Todo*) newInc; | 3654 | Todo* t = (Todo*) newInc; |
3655 | bool cloneSub = false; | 3655 | bool cloneSub = false; |
3656 | if ( orgInc->relations().count() ) { | 3656 | if ( orgInc->relations().count() ) { |
3657 | int result = KMessageBox::warningYesNoCancel(this, | 3657 | int result = KMessageBox::warningYesNoCancel(this, |
3658 | 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 ) ), | 3658 | 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 ) ), |
3659 | i18n("Todo has subtodos"), | 3659 | i18n("Todo has subtodos"), |
3660 | i18n("Yes"), | 3660 | i18n("Yes"), |
3661 | i18n("No")); | 3661 | i18n("No")); |
3662 | 3662 | ||
3663 | if ( result == KMessageBox::Cancel ) { | 3663 | if ( result == KMessageBox::Cancel ) { |
3664 | delete t; | 3664 | delete t; |
3665 | return; | 3665 | return; |
3666 | } | 3666 | } |
3667 | if (result == KMessageBox::Yes) cloneSub = true; | 3667 | if (result == KMessageBox::Yes) cloneSub = true; |
3668 | } | 3668 | } |
3669 | showTodoEditor(); | 3669 | showTodoEditor(); |
3670 | mTodoEditor->editTodo( t ); | 3670 | mTodoEditor->editTodo( t ); |
3671 | if ( mTodoEditor->exec() ) { | 3671 | if ( mTodoEditor->exec() ) { |
3672 | if ( cloneSub ) { | 3672 | if ( cloneSub ) { |
3673 | orgInc->cloneRelations( t ); | 3673 | orgInc->cloneRelations( t ); |
3674 | mCalendar->addIncidenceBranch( t ); | 3674 | mCalendar->addIncidenceBranch( t ); |
3675 | updateView(); | 3675 | updateView(); |
3676 | 3676 | ||
3677 | } else { | 3677 | } else { |
3678 | mCalendar->addTodo( t ); | 3678 | mCalendar->addTodo( t ); |
3679 | updateView(); | 3679 | updateView(); |
3680 | } | 3680 | } |
3681 | } else { | 3681 | } else { |
3682 | delete t; | 3682 | delete t; |
3683 | } | 3683 | } |
3684 | } | 3684 | } |
3685 | else if ( newInc->typeID() == eventID ) { | 3685 | else if ( newInc->typeID() == eventID ) { |
3686 | Event* e = (Event*) newInc; | 3686 | Event* e = (Event*) newInc; |
3687 | showEventEditor(); | 3687 | showEventEditor(); |
3688 | mEventEditor->editEvent( e ); | 3688 | mEventEditor->editEvent( e ); |
3689 | if ( mEventEditor->exec() ) { | 3689 | if ( mEventEditor->exec() ) { |
3690 | mCalendar->addEvent( e ); | 3690 | mCalendar->addEvent( e ); |
3691 | updateView(); | 3691 | updateView(); |
3692 | } else { | 3692 | } else { |
3693 | delete e; | 3693 | delete e; |
3694 | } | 3694 | } |
3695 | } else if ( newInc->typeID() == journalID ) { | 3695 | } else if ( newInc->typeID() == journalID ) { |
3696 | mCalendar->addJournal( (Journal*) newInc ); | 3696 | mCalendar->addJournal( (Journal*) newInc ); |
3697 | editJournal( (Journal*) newInc ); | 3697 | editJournal( (Journal*) newInc ); |
3698 | } | 3698 | } |
3699 | setActiveWindow(); | 3699 | setActiveWindow(); |
3700 | } | 3700 | } |
3701 | 3701 | ||
3702 | void CalendarView::newEvent() | 3702 | void CalendarView::newEvent() |
3703 | { | 3703 | { |
3704 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3704 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3705 | KOAgendaView *aView = mViewManager->agendaView(); | 3705 | KOAgendaView *aView = mViewManager->agendaView(); |
3706 | if (aView) { | 3706 | if (aView) { |
3707 | if (aView->selectionStart().isValid()) { | 3707 | if (aView->selectionStart().isValid()) { |
3708 | if (aView->selectedIsAllDay()) { | 3708 | if (aView->selectedIsAllDay()) { |
3709 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3709 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3710 | } else { | 3710 | } else { |
3711 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3711 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3712 | } | 3712 | } |
3713 | return; | 3713 | return; |
3714 | } | 3714 | } |
3715 | } | 3715 | } |
3716 | 3716 | ||
3717 | QDate date = mNavigator->selectedDates().first(); | 3717 | QDate date = mNavigator->selectedDates().first(); |
3718 | #if 0 | 3718 | #if 0 |
3719 | QDateTime current = QDateTime::currentDateTime(); | 3719 | QDateTime current = QDateTime::currentDateTime(); |
3720 | if ( date <= current.date() ) { | 3720 | if ( date <= current.date() ) { |
3721 | int hour = current.time().hour() +1; | 3721 | int hour = current.time().hour() +1; |
3722 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3722 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3723 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3723 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3724 | } else | 3724 | } else |
3725 | #endif | 3725 | #endif |
3726 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3726 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3727 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3727 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3728 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3728 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3729 | } | 3729 | } |
3730 | 3730 | ||
3731 | void CalendarView::newEvent(QDateTime fh) | 3731 | void CalendarView::newEvent(QDateTime fh) |
3732 | { | 3732 | { |
3733 | newEvent(fh, | 3733 | newEvent(fh, |
3734 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3734 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3735 | } | 3735 | } |
3736 | 3736 | ||
3737 | void CalendarView::newEvent(QDate dt) | 3737 | void CalendarView::newEvent(QDate dt) |
3738 | { | 3738 | { |
3739 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3739 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3740 | QDateTime(dt, QTime(0,0,0)), true); | 3740 | QDateTime(dt, QTime(0,0,0)), true); |
3741 | } | 3741 | } |
3742 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3742 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3743 | { | 3743 | { |
3744 | newEvent(fromHint, toHint, false); | 3744 | newEvent(fromHint, toHint, false); |
3745 | } | 3745 | } |
3746 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3746 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3747 | { | 3747 | { |
3748 | 3748 | ||
3749 | showEventEditor(); | 3749 | showEventEditor(); |
3750 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3750 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3751 | if ( mFilterView->filtersEnabled() ) { | 3751 | if ( mFilterView->filtersEnabled() ) { |
3752 | CalFilter *filter = mFilterView->selectedFilter(); | 3752 | CalFilter *filter = mFilterView->selectedFilter(); |
3753 | if (filter && filter->showCategories()) { | 3753 | if (filter && filter->showCategories()) { |
3754 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3754 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3755 | } | 3755 | } |
3756 | if ( filter ) | 3756 | if ( filter ) |
3757 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3757 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3758 | } | 3758 | } |
3759 | mEventEditor->exec(); | 3759 | mEventEditor->exec(); |
3760 | setActiveWindow(); | 3760 | setActiveWindow(); |
3761 | } | 3761 | } |
3762 | void CalendarView::todoAdded(Todo * t) | 3762 | void CalendarView::todoAdded(Todo * t) |
3763 | { | 3763 | { |
3764 | 3764 | ||
3765 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3765 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3766 | updateTodoViews(); | 3766 | updateTodoViews(); |
3767 | } | 3767 | } |
3768 | void CalendarView::todoChanged(Todo * t) | 3768 | void CalendarView::todoChanged(Todo * t) |
3769 | { | 3769 | { |
3770 | emit todoModified( t, 4 ); | 3770 | emit todoModified( t, 4 ); |
3771 | // updateTodoViews(); | 3771 | // updateTodoViews(); |
3772 | } | 3772 | } |
3773 | void CalendarView::todoToBeDeleted(Todo *) | 3773 | void CalendarView::todoToBeDeleted(Todo *) |
3774 | { | 3774 | { |
3775 | //qDebug("todoToBeDeleted(Todo *) "); | 3775 | //qDebug("todoToBeDeleted(Todo *) "); |
3776 | updateTodoViews(); | 3776 | updateTodoViews(); |
3777 | } | 3777 | } |
3778 | void CalendarView::todoDeleted() | 3778 | void CalendarView::todoDeleted() |
3779 | { | 3779 | { |
3780 | //qDebug(" todoDeleted()"); | 3780 | //qDebug(" todoDeleted()"); |
3781 | updateTodoViews(); | 3781 | updateTodoViews(); |
3782 | } | 3782 | } |
3783 | 3783 | ||
3784 | 3784 | ||
3785 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3785 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3786 | { | 3786 | { |
3787 | showTodoEditor(); | 3787 | showTodoEditor(); |
3788 | mTodoEditor->newTodo(dt,0,allday); | 3788 | mTodoEditor->newTodo(dt,0,allday); |
3789 | if ( mFilterView->filtersEnabled() ) { | 3789 | if ( mFilterView->filtersEnabled() ) { |
3790 | CalFilter *filter = mFilterView->selectedFilter(); | 3790 | CalFilter *filter = mFilterView->selectedFilter(); |
3791 | if (filter && filter->showCategories()) { | 3791 | if (filter && filter->showCategories()) { |
3792 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3792 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3793 | } | 3793 | } |
3794 | if ( filter ) | 3794 | if ( filter ) |
3795 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3795 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3796 | } | 3796 | } |
3797 | mTodoEditor->exec(); | 3797 | mTodoEditor->exec(); |
3798 | setActiveWindow(); | 3798 | setActiveWindow(); |
3799 | } | 3799 | } |
3800 | 3800 | ||
3801 | void CalendarView::newTodo() | 3801 | void CalendarView::newTodo() |
3802 | { | 3802 | { |
3803 | newTodoDateTime( QDateTime(),true ); | 3803 | newTodoDateTime( QDateTime(),true ); |
3804 | } | 3804 | } |
3805 | 3805 | ||
3806 | void CalendarView::newSubTodo() | 3806 | void CalendarView::newSubTodo() |
3807 | { | 3807 | { |
3808 | Todo *todo = selectedTodo(); | 3808 | Todo *todo = selectedTodo(); |
3809 | if ( todo ) newSubTodo( todo ); | 3809 | if ( todo ) newSubTodo( todo ); |
3810 | } | 3810 | } |
3811 | 3811 | ||
3812 | void CalendarView::newSubTodo(Todo *parentEvent) | 3812 | void CalendarView::newSubTodo(Todo *parentEvent) |
3813 | { | 3813 | { |
3814 | 3814 | ||
3815 | showTodoEditor(); | 3815 | showTodoEditor(); |
3816 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3816 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3817 | mTodoEditor->exec(); | 3817 | mTodoEditor->exec(); |
3818 | setActiveWindow(); | 3818 | setActiveWindow(); |
3819 | } | 3819 | } |
3820 | 3820 | ||
3821 | void CalendarView::newFloatingEvent() | 3821 | void CalendarView::newFloatingEvent() |
3822 | { | 3822 | { |
3823 | DateList tmpList = mNavigator->selectedDates(); | 3823 | DateList tmpList = mNavigator->selectedDates(); |
3824 | QDate date = tmpList.first(); | 3824 | QDate date = tmpList.first(); |
3825 | 3825 | ||
3826 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3826 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3827 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3827 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3828 | } | 3828 | } |
3829 | 3829 | ||
3830 | 3830 | ||
3831 | void CalendarView::editEvent( Event *event ) | 3831 | void CalendarView::editEvent( Event *event ) |
3832 | { | 3832 | { |
3833 | 3833 | ||
3834 | if ( !event ) return; | 3834 | if ( !event ) return; |
3835 | if ( event->isReadOnly() ) { | 3835 | if ( event->isReadOnly() ) { |
3836 | showEvent( event ); | 3836 | showEvent( event ); |
3837 | return; | 3837 | return; |
3838 | } | 3838 | } |
3839 | showEventEditor(); | 3839 | showEventEditor(); |
3840 | mEventEditor->editEvent( event , mFlagEditDescription); | 3840 | mEventEditor->editEvent( event , mFlagEditDescription); |
3841 | mEventEditor->exec(); | 3841 | mEventEditor->exec(); |
3842 | setActiveWindow(); | 3842 | setActiveWindow(); |
3843 | 3843 | ||
3844 | } | 3844 | } |
3845 | void CalendarView::editJournal( Journal *jour ) | 3845 | void CalendarView::editJournal( Journal *jour ) |
3846 | { | 3846 | { |
3847 | if ( !jour ) return; | 3847 | if ( !jour ) return; |
3848 | mDialogManager->hideSearchDialog(); | 3848 | mDialogManager->hideSearchDialog(); |
3849 | mViewManager->showJournalView(); | 3849 | mViewManager->showJournalView(); |
3850 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3850 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3851 | } | 3851 | } |
3852 | void CalendarView::editTodo( Todo *todo ) | 3852 | void CalendarView::editTodo( Todo *todo ) |
3853 | { | 3853 | { |
3854 | if ( !todo ) return; | 3854 | if ( !todo ) return; |
3855 | 3855 | ||
3856 | if ( todo->isReadOnly() ) { | 3856 | if ( todo->isReadOnly() ) { |
3857 | showTodo( todo ); | 3857 | showTodo( todo ); |
3858 | return; | 3858 | return; |
3859 | } | 3859 | } |
3860 | showTodoEditor(); | 3860 | showTodoEditor(); |
3861 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3861 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3862 | mTodoEditor->exec(); | 3862 | mTodoEditor->exec(); |
3863 | setActiveWindow(); | 3863 | setActiveWindow(); |
3864 | 3864 | ||
3865 | } | 3865 | } |
3866 | 3866 | ||
3867 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3867 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3868 | { | 3868 | { |
3869 | if ( !mEventViewerDialog ) { | 3869 | if ( !mEventViewerDialog ) { |
3870 | mEventViewerDialog = new KOEventViewerDialog(0); | 3870 | mEventViewerDialog = new KOEventViewerDialog(0); |
3871 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3871 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3872 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3872 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3873 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3873 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3874 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3874 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3875 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3875 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3876 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3876 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3877 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3877 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3878 | this, SLOT( slotViewerClosed() ) ); | 3878 | this, SLOT( slotViewerClosed() ) ); |
3879 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3879 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3880 | this, SLOT( todoChanged(Todo *) ) ); | 3880 | this, SLOT( todoChanged(Todo *) ) ); |
3881 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3881 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3882 | mEventViewerDialog->resize( 640, 480 ); | 3882 | mEventViewerDialog->resize( 640, 480 ); |
3883 | 3883 | ||
3884 | } | 3884 | } |
3885 | return mEventViewerDialog; | 3885 | return mEventViewerDialog; |
3886 | } | 3886 | } |
3887 | void CalendarView::showEvent(Event *event) | 3887 | void CalendarView::showEvent(Event *event) |
3888 | { | 3888 | { |
3889 | getEventViewerDialog()->setEvent(event); | 3889 | getEventViewerDialog()->setEvent(event); |
3890 | getEventViewerDialog()->showMe(); | 3890 | getEventViewerDialog()->showMe(); |
3891 | } | 3891 | } |
3892 | 3892 | ||
3893 | void CalendarView::showTodo(Todo *event) | 3893 | void CalendarView::showTodo(Todo *event) |
3894 | { | 3894 | { |
3895 | getEventViewerDialog()->setTodo(event); | 3895 | getEventViewerDialog()->setTodo(event); |
3896 | getEventViewerDialog()->showMe(); | 3896 | getEventViewerDialog()->showMe(); |
3897 | } | 3897 | } |
3898 | void CalendarView::showJournal( Journal *jour ) | 3898 | void CalendarView::showJournal( Journal *jour ) |
3899 | { | 3899 | { |
3900 | getEventViewerDialog()->setJournal(jour); | 3900 | getEventViewerDialog()->setJournal(jour); |
3901 | getEventViewerDialog()->showMe(); | 3901 | getEventViewerDialog()->showMe(); |
3902 | 3902 | ||
3903 | } | 3903 | } |
3904 | // void CalendarView::todoModified (Todo *event, int changed) | 3904 | // void CalendarView::todoModified (Todo *event, int changed) |
3905 | // { | 3905 | // { |
3906 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3906 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3907 | // // kdDebug() << "Todo modified and open" << endl; | 3907 | // // kdDebug() << "Todo modified and open" << endl; |
3908 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3908 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3909 | // // temp->modified (changed); | 3909 | // // temp->modified (changed); |
3910 | 3910 | ||
3911 | // // } | 3911 | // // } |
3912 | 3912 | ||
3913 | // mViewManager->updateView(); | 3913 | // mViewManager->updateView(); |
3914 | // } | 3914 | // } |
3915 | 3915 | ||
3916 | void CalendarView::appointment_show() | 3916 | void CalendarView::appointment_show() |
3917 | { | 3917 | { |
3918 | Event *anEvent = 0; | 3918 | Event *anEvent = 0; |
3919 | 3919 | ||
3920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3921 | 3921 | ||
3922 | if (mViewManager->currentView()->isEventView()) { | 3922 | if (mViewManager->currentView()->isEventView()) { |
3923 | if ( incidence && incidence->typeID() == eventID ) { | 3923 | if ( incidence && incidence->typeID() == eventID ) { |
3924 | anEvent = static_cast<Event *>(incidence); | 3924 | anEvent = static_cast<Event *>(incidence); |
3925 | } | 3925 | } |
3926 | } | 3926 | } |
3927 | 3927 | ||
3928 | if (!anEvent) { | 3928 | if (!anEvent) { |
3929 | KNotifyClient::beep(); | 3929 | KNotifyClient::beep(); |
3930 | return; | 3930 | return; |
3931 | } | 3931 | } |
3932 | 3932 | ||
3933 | showEvent(anEvent); | 3933 | showEvent(anEvent); |
3934 | } | 3934 | } |
3935 | 3935 | ||
3936 | void CalendarView::appointment_edit() | 3936 | void CalendarView::appointment_edit() |
3937 | { | 3937 | { |
3938 | Event *anEvent = 0; | 3938 | Event *anEvent = 0; |
3939 | 3939 | ||
3940 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3940 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3941 | 3941 | ||
3942 | if (mViewManager->currentView()->isEventView()) { | 3942 | if (mViewManager->currentView()->isEventView()) { |
3943 | if ( incidence && incidence->typeID() == eventID ) { | 3943 | if ( incidence && incidence->typeID() == eventID ) { |
3944 | anEvent = static_cast<Event *>(incidence); | 3944 | anEvent = static_cast<Event *>(incidence); |
3945 | } | 3945 | } |
3946 | } | 3946 | } |
3947 | 3947 | ||
3948 | if (!anEvent) { | 3948 | if (!anEvent) { |
3949 | KNotifyClient::beep(); | 3949 | KNotifyClient::beep(); |
3950 | return; | 3950 | return; |
3951 | } | 3951 | } |
3952 | 3952 | ||
3953 | editEvent(anEvent); | 3953 | editEvent(anEvent); |
3954 | } | 3954 | } |
3955 | 3955 | ||
3956 | void CalendarView::appointment_delete() | 3956 | void CalendarView::appointment_delete() |
3957 | { | 3957 | { |
3958 | Event *anEvent = 0; | 3958 | Event *anEvent = 0; |
3959 | 3959 | ||
3960 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3960 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3961 | 3961 | ||
3962 | if (mViewManager->currentView()->isEventView()) { | 3962 | if (mViewManager->currentView()->isEventView()) { |
3963 | if ( incidence && incidence->typeID() == eventID ) { | 3963 | if ( incidence && incidence->typeID() == eventID ) { |
3964 | anEvent = static_cast<Event *>(incidence); | 3964 | anEvent = static_cast<Event *>(incidence); |
3965 | } | 3965 | } |
3966 | } | 3966 | } |
3967 | 3967 | ||
3968 | if (!anEvent) { | 3968 | if (!anEvent) { |
3969 | KNotifyClient::beep(); | 3969 | KNotifyClient::beep(); |
3970 | return; | 3970 | return; |
3971 | } | 3971 | } |
3972 | 3972 | ||
3973 | deleteEvent(anEvent); | 3973 | deleteEvent(anEvent); |
3974 | } | 3974 | } |
3975 | 3975 | ||
3976 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3976 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3977 | { | 3977 | { |
3978 | if (!sub) return; | 3978 | if (!sub) return; |
3979 | if ( sub->relatedTo() == parent ) | 3979 | if ( sub->relatedTo() == parent ) |
3980 | return; | 3980 | return; |
3981 | sub->setRelatedTo(parent); | 3981 | sub->setRelatedTo(parent); |
3982 | sub->updated(); | 3982 | sub->updated(); |
3983 | setModified(true); | 3983 | setModified(true); |
3984 | updateView(); | 3984 | updateView(); |
3985 | } | 3985 | } |
3986 | void CalendarView::todo_unsub(Todo *anTodo ) | 3986 | void CalendarView::todo_unsub(Todo *anTodo ) |
3987 | { | 3987 | { |
3988 | todo_resub( 0, anTodo ); | 3988 | todo_resub( 0, anTodo ); |
3989 | } | 3989 | } |
3990 | 3990 | ||
3991 | void CalendarView::deleteTodo(Todo *todo) | 3991 | void CalendarView::deleteTodo(Todo *todo) |
3992 | { | 3992 | { |
3993 | if (!todo) { | 3993 | if (!todo) { |
3994 | KNotifyClient::beep(); | 3994 | KNotifyClient::beep(); |
3995 | return; | 3995 | return; |
3996 | } | 3996 | } |
3997 | if (KOPrefs::instance()->mConfirm) { | 3997 | if (KOPrefs::instance()->mConfirm) { |
3998 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3998 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3999 | if (!todo->relations().isEmpty()) { | 3999 | if (!todo->relations().isEmpty()) { |
4000 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 4000 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
4001 | 4001 | ||
4002 | } | 4002 | } |
4003 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 4003 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
4004 | case KMessageBox::Continue: // OK | 4004 | case KMessageBox::Continue: // OK |
4005 | bool deleteT = false; | 4005 | bool deleteT = false; |
4006 | if (!todo->relations().isEmpty()) { | 4006 | if (!todo->relations().isEmpty()) { |
4007 | deleteT = removeCompletedSubTodos( todo ); | 4007 | deleteT = removeCompletedSubTodos( todo ); |
4008 | } | 4008 | } |
4009 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 4009 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
4010 | if ( !deleteT ) { | 4010 | if ( !deleteT ) { |
4011 | checkExternalId( todo ); | 4011 | checkExternalId( todo ); |
4012 | calendar()->deleteTodo(todo); | 4012 | calendar()->deleteTodo(todo); |
4013 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4013 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4014 | updateView(); | 4014 | updateView(); |
4015 | } | 4015 | } |
4016 | break; | 4016 | break; |
4017 | } // switch | 4017 | } // switch |
4018 | } else { | 4018 | } else { |
4019 | checkExternalId( todo ); | 4019 | checkExternalId( todo ); |
4020 | mCalendar->deleteTodo(todo); | 4020 | mCalendar->deleteTodo(todo); |
4021 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4021 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4022 | updateView(); | 4022 | updateView(); |
4023 | } | 4023 | } |
4024 | 4024 | ||
4025 | emit updateSearchDialog(); | 4025 | emit updateSearchDialog(); |
4026 | } | 4026 | } |
4027 | void CalendarView::deleteJournal(Journal *jour) | 4027 | void CalendarView::deleteJournal(Journal *jour) |
4028 | { | 4028 | { |
4029 | if (!jour) { | 4029 | if (!jour) { |
4030 | KNotifyClient::beep(); | 4030 | KNotifyClient::beep(); |
4031 | return; | 4031 | return; |
4032 | } | 4032 | } |
4033 | if (KOPrefs::instance()->mConfirm) { | 4033 | if (KOPrefs::instance()->mConfirm) { |
4034 | 4034 | ||
4035 | QString des; | 4035 | QString des; |
4036 | if ( !jour->summary().isEmpty() ) { | 4036 | if ( !jour->summary().isEmpty() ) { |
4037 | des = jour->summary(); | 4037 | des = jour->summary(); |
4038 | } else { | 4038 | } else { |
4039 | des = jour->description().left(30); | 4039 | des = jour->description().left(30); |
4040 | des = des.simplifyWhiteSpace (); | 4040 | des = des.simplifyWhiteSpace (); |
4041 | des.replace (QRegExp ("\\n"),"" ); | 4041 | des.replace (QRegExp ("\\n"),"" ); |
4042 | des.replace (QRegExp ("\\r"),"" ); | 4042 | des.replace (QRegExp ("\\r"),"" ); |
4043 | } | 4043 | } |
4044 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4044 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4045 | case KMessageBox::Continue: // OK | 4045 | case KMessageBox::Continue: // OK |
4046 | calendar()->deleteJournal(jour); | 4046 | calendar()->deleteJournal(jour); |
4047 | updateView(); | 4047 | updateView(); |
4048 | break; | 4048 | break; |
4049 | } // switch | 4049 | } // switch |
4050 | } else { | 4050 | } else { |
4051 | calendar()->deleteJournal(jour);; | 4051 | calendar()->deleteJournal(jour);; |
4052 | updateView(); | 4052 | updateView(); |
4053 | } | 4053 | } |
4054 | emit updateSearchDialog(); | 4054 | emit updateSearchDialog(); |
4055 | } | 4055 | } |
4056 | 4056 | ||
4057 | void CalendarView::deleteEvent(Event *anEvent) | 4057 | void CalendarView::deleteEvent(Event *anEvent) |
4058 | { | 4058 | { |
4059 | if (!anEvent) { | 4059 | if (!anEvent) { |
4060 | KNotifyClient::beep(); | 4060 | KNotifyClient::beep(); |
4061 | return; | 4061 | return; |
4062 | } | 4062 | } |
4063 | 4063 | ||
4064 | if (anEvent->doesRecur()) { | 4064 | if (anEvent->doesRecur()) { |
4065 | QDate itemDate = mViewManager->currentSelectionDate(); | 4065 | QDate itemDate = mViewManager->currentSelectionDate(); |
4066 | int km; | 4066 | int km; |
4067 | if (!itemDate.isValid()) { | 4067 | if (!itemDate.isValid()) { |
4068 | //kdDebug() << "Date Not Valid" << endl; | 4068 | //kdDebug() << "Date Not Valid" << endl; |
4069 | if (KOPrefs::instance()->mConfirm) { | 4069 | if (KOPrefs::instance()->mConfirm) { |
4070 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4070 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4071 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4071 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4072 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4072 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4073 | if ( km == KMessageBox::Continue ) | 4073 | if ( km == KMessageBox::Continue ) |
4074 | km = KMessageBox::No; // No = all below | 4074 | km = KMessageBox::No; // No = all below |
4075 | } else | 4075 | } else |
4076 | km = KMessageBox::No; | 4076 | km = KMessageBox::No; |
4077 | } else { | 4077 | } else { |
4078 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4078 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4079 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4079 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4080 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4080 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4081 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4081 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4082 | i18n("All")); | 4082 | i18n("All")); |
4083 | } | 4083 | } |
4084 | switch(km) { | 4084 | switch(km) { |
4085 | 4085 | ||
4086 | case KMessageBox::No: // Continue // all | 4086 | case KMessageBox::No: // Continue // all |
4087 | //qDebug("KMessageBox::No "); | 4087 | //qDebug("KMessageBox::No "); |
4088 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4088 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4089 | schedule(Scheduler::Cancel,anEvent); | 4089 | schedule(Scheduler::Cancel,anEvent); |
4090 | 4090 | ||
4091 | checkExternalId( anEvent); | 4091 | checkExternalId( anEvent); |
4092 | mCalendar->deleteEvent(anEvent); | 4092 | mCalendar->deleteEvent(anEvent); |
4093 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4093 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4094 | break; | 4094 | break; |
4095 | 4095 | ||
4096 | // Disabled because it does not work | 4096 | // Disabled because it does not work |
4097 | //#if 0 | 4097 | //#if 0 |
4098 | case KMessageBox::Yes: // just this one | 4098 | case KMessageBox::Yes: // just this one |
4099 | //QDate qd = mNavigator->selectedDates().first(); | 4099 | //QDate qd = mNavigator->selectedDates().first(); |
4100 | //if (!qd.isValid()) { | 4100 | //if (!qd.isValid()) { |
4101 | // kdDebug() << "no date selected, or invalid date" << endl; | 4101 | // kdDebug() << "no date selected, or invalid date" << endl; |
4102 | // KNotifyClient::beep(); | 4102 | // KNotifyClient::beep(); |
4103 | // return; | 4103 | // return; |
4104 | //} | 4104 | //} |
4105 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4105 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4106 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4106 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4107 | anEvent->addExDate(itemDate); | 4107 | anEvent->addExDate(itemDate); |
4108 | int duration = anEvent->recurrence()->duration(); | 4108 | int duration = anEvent->recurrence()->duration(); |
4109 | if ( duration > 0 ) { | 4109 | if ( duration > 0 ) { |
4110 | anEvent->recurrence()->setDuration( duration - 1 ); | 4110 | anEvent->recurrence()->setDuration( duration - 1 ); |
4111 | } | 4111 | } |
4112 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4112 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4113 | } | 4113 | } |
4114 | break; | 4114 | break; |
4115 | //#endif | 4115 | //#endif |
4116 | } // switch | 4116 | } // switch |
4117 | } else { | 4117 | } else { |
4118 | if (KOPrefs::instance()->mConfirm) { | 4118 | if (KOPrefs::instance()->mConfirm) { |
4119 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4119 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4120 | i18n("\nAre you sure you want\nto delete this event?"), | 4120 | i18n("\nAre you sure you want\nto delete this event?"), |
4121 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4121 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4122 | case KMessageBox::Continue: // OK | 4122 | case KMessageBox::Continue: // OK |
4123 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4123 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4124 | schedule(Scheduler::Cancel,anEvent); | 4124 | schedule(Scheduler::Cancel,anEvent); |
4125 | checkExternalId( anEvent); | 4125 | checkExternalId( anEvent); |
4126 | mCalendar->deleteEvent(anEvent); | 4126 | mCalendar->deleteEvent(anEvent); |
4127 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4127 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4128 | break; | 4128 | break; |
4129 | } // switch | 4129 | } // switch |
4130 | } else { | 4130 | } else { |
4131 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4131 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4132 | schedule(Scheduler::Cancel,anEvent); | 4132 | schedule(Scheduler::Cancel,anEvent); |
4133 | checkExternalId( anEvent); | 4133 | checkExternalId( anEvent); |
4134 | mCalendar->deleteEvent(anEvent); | 4134 | mCalendar->deleteEvent(anEvent); |
4135 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4135 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4136 | } | 4136 | } |
4137 | } // if-else | 4137 | } // if-else |
4138 | emit updateSearchDialog(); | 4138 | emit updateSearchDialog(); |
4139 | } | 4139 | } |
4140 | 4140 | ||
4141 | bool CalendarView::deleteEvent(const QString &uid) | 4141 | bool CalendarView::deleteEvent(const QString &uid) |
4142 | { | 4142 | { |
4143 | Event *ev = mCalendar->event(uid); | 4143 | Event *ev = mCalendar->event(uid); |
4144 | if (ev) { | 4144 | if (ev) { |
4145 | deleteEvent(ev); | 4145 | deleteEvent(ev); |
4146 | return true; | 4146 | return true; |
4147 | } else { | 4147 | } else { |
4148 | return false; | 4148 | return false; |
4149 | } | 4149 | } |
4150 | } | 4150 | } |
4151 | 4151 | ||
4152 | /*****************************************************************************/ | 4152 | /*****************************************************************************/ |
4153 | 4153 | ||
4154 | void CalendarView::action_mail() | 4154 | void CalendarView::action_mail() |
4155 | { | 4155 | { |
4156 | #ifndef KORG_NOMAIL | 4156 | #ifndef KORG_NOMAIL |
4157 | KOMailClient mailClient; | 4157 | KOMailClient mailClient; |
4158 | 4158 | ||
4159 | Incidence *incidence = currentSelection(); | 4159 | Incidence *incidence = currentSelection(); |
4160 | 4160 | ||
4161 | if (!incidence) { | 4161 | if (!incidence) { |
4162 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4162 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4163 | return; | 4163 | return; |
4164 | } | 4164 | } |
4165 | if(incidence->attendeeCount() == 0 ) { | 4165 | if(incidence->attendeeCount() == 0 ) { |
4166 | KMessageBox::sorry(this, | 4166 | KMessageBox::sorry(this, |
4167 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4167 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4168 | return; | 4168 | return; |
4169 | } | 4169 | } |
4170 | 4170 | ||
4171 | CalendarLocal cal_tmp; | 4171 | CalendarLocal cal_tmp; |
4172 | Event *event = 0; | 4172 | Event *event = 0; |
4173 | Event *ev = 0; | 4173 | Event *ev = 0; |
4174 | if ( incidence && incidence->typeID() == eventID ) { | 4174 | if ( incidence && incidence->typeID() == eventID ) { |
4175 | event = static_cast<Event *>(incidence); | 4175 | event = static_cast<Event *>(incidence); |
4176 | ev = new Event(*event); | 4176 | ev = new Event(*event); |
4177 | cal_tmp.addEvent(ev); | 4177 | cal_tmp.addEvent(ev); |
4178 | } | 4178 | } |
4179 | ICalFormat mForm(); | 4179 | ICalFormat mForm(); |
4180 | QString attachment = mForm.toString( &cal_tmp ); | 4180 | QString attachment = mForm.toString( &cal_tmp ); |
4181 | if (ev) delete(ev); | 4181 | if (ev) delete(ev); |
4182 | 4182 | ||
4183 | mailClient.mailAttendees(currentSelection(), attachment); | 4183 | mailClient.mailAttendees(currentSelection(), attachment); |
4184 | 4184 | ||
4185 | #endif | 4185 | #endif |
4186 | 4186 | ||
4187 | #if 0 | 4187 | #if 0 |
4188 | Event *anEvent = 0; | 4188 | Event *anEvent = 0; |
4189 | if (mViewManager->currentView()->isEventView()) { | 4189 | if (mViewManager->currentView()->isEventView()) { |
4190 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4190 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4191 | } | 4191 | } |
4192 | 4192 | ||
4193 | if (!anEvent) { | 4193 | if (!anEvent) { |
4194 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4194 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4195 | return; | 4195 | return; |
4196 | } | 4196 | } |
4197 | if(anEvent->attendeeCount() == 0 ) { | 4197 | if(anEvent->attendeeCount() == 0 ) { |
4198 | KMessageBox::sorry(this, | 4198 | KMessageBox::sorry(this, |
4199 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4199 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4200 | return; | 4200 | return; |
4201 | } | 4201 | } |
4202 | 4202 | ||
4203 | mailobject.emailEvent(anEvent); | 4203 | mailobject.emailEvent(anEvent); |
4204 | #endif | 4204 | #endif |
4205 | } | 4205 | } |
4206 | 4206 | ||
4207 | 4207 | ||
4208 | void CalendarView::schedule_publish(Incidence *incidence) | 4208 | void CalendarView::schedule_publish(Incidence *incidence) |
4209 | { | 4209 | { |
4210 | Event *event = 0; | 4210 | Event *event = 0; |
4211 | Todo *todo = 0; | 4211 | Todo *todo = 0; |
4212 | 4212 | ||
4213 | if (incidence == 0) { | 4213 | if (incidence == 0) { |
4214 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4214 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4215 | if (incidence == 0) { | 4215 | if (incidence == 0) { |
4216 | incidence = mTodoList->selectedIncidences().first(); | 4216 | incidence = mTodoList->selectedIncidences().first(); |
4217 | } | 4217 | } |
4218 | } | 4218 | } |
4219 | if ( incidence && incidence->typeID() == eventID ) { | 4219 | if ( incidence && incidence->typeID() == eventID ) { |
4220 | event = static_cast<Event *>(incidence); | 4220 | event = static_cast<Event *>(incidence); |
4221 | } else { | 4221 | } else { |
4222 | if ( incidence && incidence->typeID() == todoID ) { | 4222 | if ( incidence && incidence->typeID() == todoID ) { |
4223 | todo = static_cast<Todo *>(incidence); | 4223 | todo = static_cast<Todo *>(incidence); |
4224 | } | 4224 | } |
4225 | } | 4225 | } |
4226 | 4226 | ||
4227 | if (!event && !todo) { | 4227 | if (!event && !todo) { |
4228 | KMessageBox::sorry(this,i18n("No event selected.")); | 4228 | KMessageBox::sorry(this,i18n("No event selected.")); |
4229 | return; | 4229 | return; |
4230 | } | 4230 | } |
4231 | 4231 | ||
4232 | PublishDialog *publishdlg = new PublishDialog(); | 4232 | PublishDialog *publishdlg = new PublishDialog(); |
4233 | if (incidence->attendeeCount()>0) { | 4233 | if (incidence->attendeeCount()>0) { |
4234 | QPtrList<Attendee> attendees = incidence->attendees(); | 4234 | QPtrList<Attendee> attendees = incidence->attendees(); |
4235 | attendees.first(); | 4235 | attendees.first(); |
4236 | while ( attendees.current()!=0 ) { | 4236 | while ( attendees.current()!=0 ) { |
4237 | publishdlg->addAttendee(attendees.current()); | 4237 | publishdlg->addAttendee(attendees.current()); |
4238 | attendees.next(); | 4238 | attendees.next(); |
4239 | } | 4239 | } |
4240 | } | 4240 | } |
4241 | bool send = true; | 4241 | bool send = true; |
4242 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4242 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4243 | if ( publishdlg->exec() != QDialog::Accepted ) | 4243 | if ( publishdlg->exec() != QDialog::Accepted ) |
4244 | send = false; | 4244 | send = false; |
4245 | } | 4245 | } |
4246 | if ( send ) { | 4246 | if ( send ) { |
4247 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4247 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4248 | if ( event ) { | 4248 | if ( event ) { |
4249 | Event *ev = new Event(*event); | 4249 | Event *ev = new Event(*event); |
4250 | ev->registerObserver(0); | 4250 | ev->registerObserver(0); |
4251 | ev->clearAttendees(); | 4251 | ev->clearAttendees(); |
4252 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4252 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4253 | delete(ev); | 4253 | delete(ev); |
4254 | } | 4254 | } |
4255 | } else { | 4255 | } else { |
4256 | if ( todo ) { | 4256 | if ( todo ) { |
4257 | Todo *ev = new Todo(*todo); | 4257 | Todo *ev = new Todo(*todo); |
4258 | ev->registerObserver(0); | 4258 | ev->registerObserver(0); |
4259 | ev->clearAttendees(); | 4259 | ev->clearAttendees(); |
4260 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4260 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4261 | delete(ev); | 4261 | delete(ev); |
4262 | } | 4262 | } |
4263 | } | 4263 | } |
4264 | } | 4264 | } |
4265 | } | 4265 | } |
4266 | delete publishdlg; | 4266 | delete publishdlg; |
4267 | } | 4267 | } |
4268 | 4268 | ||
4269 | void CalendarView::schedule_request(Incidence *incidence) | 4269 | void CalendarView::schedule_request(Incidence *incidence) |
4270 | { | 4270 | { |
4271 | schedule(Scheduler::Request,incidence); | 4271 | schedule(Scheduler::Request,incidence); |
4272 | } | 4272 | } |
4273 | 4273 | ||
4274 | void CalendarView::schedule_refresh(Incidence *incidence) | 4274 | void CalendarView::schedule_refresh(Incidence *incidence) |
4275 | { | 4275 | { |
4276 | schedule(Scheduler::Refresh,incidence); | 4276 | schedule(Scheduler::Refresh,incidence); |
4277 | } | 4277 | } |
4278 | 4278 | ||
4279 | void CalendarView::schedule_cancel(Incidence *incidence) | 4279 | void CalendarView::schedule_cancel(Incidence *incidence) |
4280 | { | 4280 | { |
4281 | schedule(Scheduler::Cancel,incidence); | 4281 | schedule(Scheduler::Cancel,incidence); |
4282 | } | 4282 | } |
4283 | 4283 | ||
4284 | void CalendarView::schedule_add(Incidence *incidence) | 4284 | void CalendarView::schedule_add(Incidence *incidence) |
4285 | { | 4285 | { |
4286 | schedule(Scheduler::Add,incidence); | 4286 | schedule(Scheduler::Add,incidence); |
4287 | } | 4287 | } |
4288 | 4288 | ||
4289 | void CalendarView::schedule_reply(Incidence *incidence) | 4289 | void CalendarView::schedule_reply(Incidence *incidence) |
4290 | { | 4290 | { |
4291 | schedule(Scheduler::Reply,incidence); | 4291 | schedule(Scheduler::Reply,incidence); |
4292 | } | 4292 | } |
4293 | 4293 | ||
4294 | void CalendarView::schedule_counter(Incidence *incidence) | 4294 | void CalendarView::schedule_counter(Incidence *incidence) |
4295 | { | 4295 | { |
4296 | schedule(Scheduler::Counter,incidence); | 4296 | schedule(Scheduler::Counter,incidence); |
4297 | } | 4297 | } |
4298 | 4298 | ||
4299 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4299 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4300 | { | 4300 | { |
4301 | schedule(Scheduler::Declinecounter,incidence); | 4301 | schedule(Scheduler::Declinecounter,incidence); |
4302 | } | 4302 | } |
4303 | 4303 | ||
4304 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4304 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4305 | { | 4305 | { |
4306 | QDateTime start = QDateTime::currentDateTime(); | 4306 | QDateTime start = QDateTime::currentDateTime(); |
4307 | QDateTime end = start.addDays(daysToPublish); | 4307 | QDateTime end = start.addDays(daysToPublish); |
4308 | 4308 | ||
4309 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4309 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4310 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4310 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4311 | 4311 | ||
4312 | 4312 | ||
4313 | PublishDialog *publishdlg = new PublishDialog(); | 4313 | PublishDialog *publishdlg = new PublishDialog(); |
4314 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4314 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4315 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4315 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4316 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4316 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4317 | delete(freebusy); | 4317 | delete(freebusy); |
4318 | } | 4318 | } |
4319 | } | 4319 | } |
4320 | delete publishdlg; | 4320 | delete publishdlg; |
4321 | } | 4321 | } |
4322 | 4322 | ||
4323 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4323 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4324 | { | 4324 | { |
4325 | Event *event = 0; | 4325 | Event *event = 0; |
4326 | Todo *todo = 0; | 4326 | Todo *todo = 0; |
4327 | 4327 | ||
4328 | if (incidence == 0) { | 4328 | if (incidence == 0) { |
4329 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4329 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4330 | if (incidence == 0) { | 4330 | if (incidence == 0) { |
4331 | incidence = mTodoList->selectedIncidences().first(); | 4331 | incidence = mTodoList->selectedIncidences().first(); |
4332 | } | 4332 | } |
4333 | } | 4333 | } |
4334 | if ( incidence && incidence->typeID() == eventID ) { | 4334 | if ( incidence && incidence->typeID() == eventID ) { |
4335 | event = static_cast<Event *>(incidence); | 4335 | event = static_cast<Event *>(incidence); |
4336 | } | 4336 | } |
4337 | if ( incidence && incidence->typeID() == todoID ) { | 4337 | if ( incidence && incidence->typeID() == todoID ) { |
4338 | todo = static_cast<Todo *>(incidence); | 4338 | todo = static_cast<Todo *>(incidence); |
4339 | } | 4339 | } |
4340 | 4340 | ||
4341 | if (!event && !todo) { | 4341 | if (!event && !todo) { |
4342 | KMessageBox::sorry(this,i18n("No event selected.")); | 4342 | KMessageBox::sorry(this,i18n("No event selected.")); |
4343 | return; | 4343 | return; |
4344 | } | 4344 | } |
4345 | 4345 | ||
4346 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4346 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4347 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4347 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4348 | return; | 4348 | return; |
4349 | } | 4349 | } |
4350 | 4350 | ||
4351 | Event *ev = 0; | 4351 | Event *ev = 0; |
4352 | if (event) ev = new Event(*event); | 4352 | if (event) ev = new Event(*event); |
4353 | Todo *to = 0; | 4353 | Todo *to = 0; |
4354 | if (todo) to = new Todo(*todo); | 4354 | if (todo) to = new Todo(*todo); |
4355 | 4355 | ||
4356 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4356 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4357 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4357 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4358 | if (!me) { | 4358 | if (!me) { |
4359 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4359 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4360 | return; | 4360 | return; |
4361 | } | 4361 | } |
4362 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4362 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4363 | StatusDialog *statdlg = new StatusDialog(this); | 4363 | StatusDialog *statdlg = new StatusDialog(this); |
4364 | if (!statdlg->exec()==QDialog::Accepted) return; | 4364 | if (!statdlg->exec()==QDialog::Accepted) return; |
4365 | me->setStatus( statdlg->status() ); | 4365 | me->setStatus( statdlg->status() ); |
4366 | delete(statdlg); | 4366 | delete(statdlg); |
4367 | } | 4367 | } |
4368 | Attendee *menew = new Attendee(*me); | 4368 | Attendee *menew = new Attendee(*me); |
4369 | if (ev) { | 4369 | if (ev) { |
4370 | ev->clearAttendees(); | 4370 | ev->clearAttendees(); |
4371 | ev->addAttendee(menew,false); | 4371 | ev->addAttendee(menew,false); |
4372 | } else { | 4372 | } else { |
4373 | if (to) { | 4373 | if (to) { |
4374 | todo->clearAttendees(); | 4374 | todo->clearAttendees(); |
4375 | todo->addAttendee(menew,false); | 4375 | todo->addAttendee(menew,false); |
4376 | } | 4376 | } |
4377 | } | 4377 | } |
4378 | } | 4378 | } |
4379 | 4379 | ||
4380 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4380 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4381 | if (ev) { | 4381 | if (ev) { |
4382 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4382 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4383 | } else { | 4383 | } else { |
4384 | if (to) { | 4384 | if (to) { |
4385 | if ( !dlg->addMessage(to,method) ) delete(to); | 4385 | if ( !dlg->addMessage(to,method) ) delete(to); |
4386 | } | 4386 | } |
4387 | } | 4387 | } |
4388 | } | 4388 | } |
4389 | 4389 | ||
4390 | void CalendarView::openAddressbook() | 4390 | void CalendarView::openAddressbook() |
4391 | { | 4391 | { |
4392 | KRun::runCommand("kaddressbook"); | 4392 | KRun::runCommand("kaddressbook"); |
4393 | } | 4393 | } |
4394 | 4394 | ||
4395 | void CalendarView::setModified(bool modified) | 4395 | void CalendarView::setModified(bool modified) |
4396 | { | 4396 | { |
4397 | //qDebug("CalendarView::setModified %d ", modified); | 4397 | //qDebug("CalendarView::setModified %d ", modified); |
4398 | if ( modified ) | 4398 | if ( modified ) |
4399 | emit signalmodified(); | 4399 | emit signalmodified(); |
4400 | mModified = modified; | 4400 | mModified = modified; |
4401 | if ( mModified ) | 4401 | if ( mModified ) |
4402 | emit modifiedChanged(mModified); | 4402 | emit modifiedChanged(mModified); |
4403 | 4403 | ||
4404 | } | 4404 | } |
4405 | 4405 | ||
4406 | bool CalendarView::isReadOnly() | 4406 | bool CalendarView::isReadOnly() |
4407 | { | 4407 | { |
4408 | return mReadOnly; | 4408 | return mReadOnly; |
4409 | } | 4409 | } |
4410 | 4410 | ||
4411 | void CalendarView::setReadOnly(bool readOnly) | 4411 | void CalendarView::setReadOnly(bool readOnly) |
4412 | { | 4412 | { |
4413 | if (mReadOnly != readOnly) { | 4413 | if (mReadOnly != readOnly) { |
4414 | mReadOnly = readOnly; | 4414 | mReadOnly = readOnly; |
4415 | emit readOnlyChanged(mReadOnly); | 4415 | emit readOnlyChanged(mReadOnly); |
4416 | } | 4416 | } |
4417 | } | 4417 | } |
4418 | 4418 | ||
4419 | bool CalendarView::isModified() | 4419 | bool CalendarView::isModified() |
4420 | { | 4420 | { |
4421 | return mModified; | 4421 | return mModified; |
4422 | } | 4422 | } |
4423 | void CalendarView::slotprintSelInc() | 4423 | void CalendarView::slotprintSelInc() |
4424 | { | 4424 | { |
4425 | if ( currentSelection() == 0 ) { | 4425 | if ( currentSelection() == 0 ) { |
4426 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4426 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4427 | return; | 4427 | return; |
4428 | } | 4428 | } |
4429 | showIncidence(); | 4429 | showIncidence(); |
4430 | getEventViewerDialog()->print(); | 4430 | getEventViewerDialog()->print(); |
4431 | 4431 | ||
4432 | } | 4432 | } |
4433 | void CalendarView::printSetup() | 4433 | void CalendarView::printSetup() |
4434 | { | 4434 | { |
4435 | #ifndef KORG_NOPRINTER | 4435 | #ifndef KORG_NOPRINTER |
4436 | createPrinter(); | 4436 | createPrinter(); |
4437 | 4437 | ||
4438 | mCalPrinter->setupPrinter(); | 4438 | mCalPrinter->setupPrinter(); |
4439 | #endif | 4439 | #endif |
4440 | } | 4440 | } |
4441 | 4441 | ||
4442 | void CalendarView::print() | 4442 | void CalendarView::print() |
4443 | { | 4443 | { |
4444 | #ifndef KORG_NOPRINTER | 4444 | #ifndef KORG_NOPRINTER |
4445 | createPrinter(); | 4445 | createPrinter(); |
4446 | 4446 | ||
4447 | DateList tmpDateList = mNavigator->selectedDates(); | 4447 | DateList tmpDateList = mNavigator->selectedDates(); |
4448 | mCalPrinter->print(CalPrinter::Month, | 4448 | mCalPrinter->print(CalPrinter::Month, |
4449 | tmpDateList.first(), tmpDateList.last()); | 4449 | tmpDateList.first(), tmpDateList.last()); |
4450 | #endif | 4450 | #endif |
4451 | } | 4451 | } |
4452 | 4452 | ||
4453 | void CalendarView::printPreview() | 4453 | void CalendarView::printPreview() |
4454 | { | 4454 | { |
4455 | #ifndef KORG_NOPRINTER | 4455 | #ifndef KORG_NOPRINTER |
4456 | kdDebug() << "CalendarView::printPreview()" << endl; | 4456 | kdDebug() << "CalendarView::printPreview()" << endl; |
4457 | 4457 | ||
4458 | createPrinter(); | 4458 | createPrinter(); |
4459 | 4459 | ||
4460 | DateList tmpDateList = mNavigator->selectedDates(); | 4460 | DateList tmpDateList = mNavigator->selectedDates(); |
4461 | 4461 | ||
4462 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4462 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4463 | tmpDateList.last()); | 4463 | tmpDateList.last()); |
4464 | #endif | 4464 | #endif |
4465 | } | 4465 | } |
4466 | 4466 | ||
4467 | void CalendarView::exportICalendar() | 4467 | void CalendarView::exportICalendar() |
4468 | { | 4468 | { |
4469 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4469 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4470 | 4470 | ||
4471 | // Force correct extension | 4471 | // Force correct extension |
4472 | if (filename.right(4) != ".ics") filename += ".ics"; | 4472 | if (filename.right(4) != ".ics") filename += ".ics"; |
4473 | 4473 | ||
4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4475 | storage.save(); | 4475 | storage.save(); |
4476 | } | 4476 | } |
4477 | 4477 | ||
4478 | bool CalendarView::exportVCalendar( QString filename ) | 4478 | bool CalendarView::exportVCalendar( QString filename ) |
4479 | { | 4479 | { |
4480 | if (mCalendar->journals().count() > 0) { | 4480 | if (mCalendar->journals().count() > 0) { |
4481 | int result = KMessageBox::warningContinueCancel(this, | 4481 | int result = KMessageBox::warningContinueCancel(this, |
4482 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4482 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4483 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4483 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4484 | true); | 4484 | true); |
4485 | if (result != KMessageBox::Continue) return false; | 4485 | if (result != KMessageBox::Continue) return false; |
4486 | } | 4486 | } |
4487 | 4487 | ||
4488 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4488 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4489 | 4489 | ||
4490 | // Force correct extension | 4490 | // Force correct extension |
4491 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4491 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4492 | 4492 | ||
4493 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4493 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4494 | return storage.save(); | 4494 | return storage.save(); |
4495 | 4495 | ||
4496 | } | 4496 | } |
4497 | 4497 | ||
4498 | void CalendarView::eventUpdated(Incidence *) | 4498 | void CalendarView::eventUpdated(Incidence *) |
4499 | { | 4499 | { |
4500 | setModified(); | 4500 | setModified(); |
4501 | // Don't call updateView here. The code, which has caused the update of the | 4501 | // Don't call updateView here. The code, which has caused the update of the |
4502 | // event is responsible for updating the view. | 4502 | // event is responsible for updating the view. |
4503 | // updateView(); | 4503 | // updateView(); |
4504 | } | 4504 | } |
4505 | 4505 | ||
4506 | void CalendarView::adaptNavigationUnits() | 4506 | void CalendarView::adaptNavigationUnits() |
4507 | { | 4507 | { |
4508 | if (mViewManager->currentView()->isEventView()) { | 4508 | if (mViewManager->currentView()->isEventView()) { |
4509 | int days = mViewManager->currentView()->currentDateCount(); | 4509 | int days = mViewManager->currentView()->currentDateCount(); |
4510 | if (days == 1) { | 4510 | if (days == 1) { |
4511 | emit changeNavStringPrev(i18n("&Previous Day")); | 4511 | emit changeNavStringPrev(i18n("&Previous Day")); |
4512 | emit changeNavStringNext(i18n("&Next Day")); | 4512 | emit changeNavStringNext(i18n("&Next Day")); |
4513 | } else { | 4513 | } else { |
4514 | emit changeNavStringPrev(i18n("&Previous Week")); | 4514 | emit changeNavStringPrev(i18n("&Previous Week")); |
4515 | emit changeNavStringNext(i18n("&Next Week")); | 4515 | emit changeNavStringNext(i18n("&Next Week")); |
4516 | } | 4516 | } |
4517 | } | 4517 | } |
4518 | } | 4518 | } |
4519 | 4519 | ||
4520 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4520 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4521 | { | 4521 | { |
4522 | if ( incidence ) mTodoList->clearSelection(); | 4522 | if ( incidence ) mTodoList->clearSelection(); |
4523 | processIncidenceSelection( incidence ); | 4523 | processIncidenceSelection( incidence ); |
4524 | } | 4524 | } |
4525 | 4525 | ||
4526 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4526 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4527 | { | 4527 | { |
4528 | if ( incidence && mViewManager->currentView() ) { | 4528 | if ( incidence && mViewManager->currentView() ) { |
4529 | mViewManager->currentView()->clearSelection(); | 4529 | mViewManager->currentView()->clearSelection(); |
4530 | } | 4530 | } |
4531 | processIncidenceSelection( incidence ); | 4531 | processIncidenceSelection( incidence ); |
4532 | } | 4532 | } |
4533 | 4533 | ||
4534 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4534 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4535 | { | 4535 | { |
4536 | emit incidenceSelected( incidence ); | 4536 | emit incidenceSelected( incidence ); |
4537 | if ( incidence == mSelectedIncidence ) return; | 4537 | if ( incidence == mSelectedIncidence ) return; |
4538 | mSelectedIncidence = incidence; | 4538 | mSelectedIncidence = incidence; |
4539 | 4539 | ||
4540 | if ( incidence && incidence->typeID() == eventID ) { | 4540 | if ( incidence && incidence->typeID() == eventID ) { |
4541 | Event *event = static_cast<Event *>( incidence ); | 4541 | Event *event = static_cast<Event *>( incidence ); |
4542 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4542 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4543 | emit organizerEventsSelected( true ); | 4543 | emit organizerEventsSelected( true ); |
4544 | } else { | 4544 | } else { |
4545 | emit organizerEventsSelected(false); | 4545 | emit organizerEventsSelected(false); |
4546 | } | 4546 | } |
4547 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4547 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4548 | KOPrefs::instance()->email() ) ) { | 4548 | KOPrefs::instance()->email() ) ) { |
4549 | emit groupEventsSelected( true ); | 4549 | emit groupEventsSelected( true ); |
4550 | } else { | 4550 | } else { |
4551 | emit groupEventsSelected(false); | 4551 | emit groupEventsSelected(false); |
4552 | } | 4552 | } |
4553 | return; | 4553 | return; |
4554 | } else { | 4554 | } else { |
4555 | if ( incidence && incidence->typeID() == todoID ) { | 4555 | if ( incidence && incidence->typeID() == todoID ) { |
4556 | emit todoSelected( true ); | 4556 | emit todoSelected( true ); |
4557 | Todo *event = static_cast<Todo *>( incidence ); | 4557 | Todo *event = static_cast<Todo *>( incidence ); |
4558 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4558 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4559 | emit organizerEventsSelected( true ); | 4559 | emit organizerEventsSelected( true ); |
4560 | } else { | 4560 | } else { |
4561 | emit organizerEventsSelected(false); | 4561 | emit organizerEventsSelected(false); |
4562 | } | 4562 | } |
4563 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4563 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4564 | KOPrefs::instance()->email() ) ) { | 4564 | KOPrefs::instance()->email() ) ) { |
4565 | emit groupEventsSelected( true ); | 4565 | emit groupEventsSelected( true ); |
4566 | } else { | 4566 | } else { |
4567 | emit groupEventsSelected(false); | 4567 | emit groupEventsSelected(false); |
4568 | } | 4568 | } |
4569 | return; | 4569 | return; |
4570 | } else { | 4570 | } else { |
4571 | emit todoSelected( false ); | 4571 | emit todoSelected( false ); |
4572 | emit organizerEventsSelected(false); | 4572 | emit organizerEventsSelected(false); |
4573 | emit groupEventsSelected(false); | 4573 | emit groupEventsSelected(false); |
4574 | } | 4574 | } |
4575 | return; | 4575 | return; |
4576 | } | 4576 | } |
4577 | 4577 | ||
4578 | /* if ( incidence && incidence->typeID() == todoID ) { | 4578 | /* if ( incidence && incidence->typeID() == todoID ) { |
4579 | emit todoSelected( true ); | 4579 | emit todoSelected( true ); |
4580 | } else { | 4580 | } else { |
4581 | emit todoSelected( false ); | 4581 | emit todoSelected( false ); |
4582 | }*/ | 4582 | }*/ |
4583 | } | 4583 | } |
4584 | 4584 | ||
4585 | 4585 | ||
4586 | void CalendarView::checkClipboard() | 4586 | void CalendarView::checkClipboard() |
4587 | { | 4587 | { |
4588 | #ifndef KORG_NODND | 4588 | #ifndef KORG_NODND |
4589 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4589 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4590 | emit pasteEnabled(true); | 4590 | emit pasteEnabled(true); |
4591 | } else { | 4591 | } else { |
4592 | emit pasteEnabled(false); | 4592 | emit pasteEnabled(false); |
4593 | } | 4593 | } |
4594 | #endif | 4594 | #endif |
4595 | } | 4595 | } |
4596 | 4596 | ||
4597 | void CalendarView::showDates(const DateList &selectedDates) | 4597 | void CalendarView::showDates(const DateList &selectedDates) |
4598 | { | 4598 | { |
4599 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4599 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4600 | 4600 | ||
4601 | 4601 | ||
4602 | if ( !mBlockShowDates ) { | 4602 | if ( !mBlockShowDates ) { |
4603 | if ( mViewManager->currentView() ) { | 4603 | if ( mViewManager->currentView() ) { |
4604 | updateView( selectedDates.first(), selectedDates.last() ); | 4604 | updateView( selectedDates.first(), selectedDates.last() ); |
4605 | } else { | 4605 | } else { |
4606 | mViewManager->showAgendaView(); | 4606 | mViewManager->showAgendaView(); |
4607 | } | 4607 | } |
4608 | } | 4608 | } |
4609 | 4609 | ||
4610 | QDate date = selectedDates.first(); | 4610 | QDate date = selectedDates.first(); |
4611 | if ( ! date.isValid() ) { | 4611 | if ( ! date.isValid() ) { |
4612 | topLevelWidget()->setCaption(""); | 4612 | topLevelWidget()->setCaption(""); |
4613 | return; | 4613 | return; |
4614 | } | 4614 | } |
4615 | 4615 | ||
4616 | QString selDates; | 4616 | QString selDates; |
4617 | selDates = KGlobal::locale()->formatDate( date, true); | 4617 | selDates = KGlobal::locale()->formatDate( date, true); |
4618 | if (selectedDates.first() < selectedDates.last() ) | 4618 | if (selectedDates.first() < selectedDates.last() ) |
4619 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4619 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4620 | else { | 4620 | else { |
4621 | QString addString; | 4621 | QString addString; |
4622 | if ( date == QDateTime::currentDateTime().date() ) | 4622 | if ( date == QDateTime::currentDateTime().date() ) |
4623 | addString = i18n("Today"); | 4623 | addString = i18n("Today"); |
4624 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4624 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4625 | addString = i18n("Tomorrow"); | 4625 | addString = i18n("Tomorrow"); |
4626 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4626 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4627 | addString = i18n("Yesterday"); | 4627 | addString = i18n("Yesterday"); |
4628 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4628 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4629 | addString = i18n("Day before yesterday"); | 4629 | addString = i18n("Day before yesterday"); |
4630 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4630 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4631 | addString = i18n("Day after tomorrow"); | 4631 | addString = i18n("Day after tomorrow"); |
4632 | if ( !addString.isEmpty() ) { | 4632 | if ( !addString.isEmpty() ) { |
4633 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4633 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4634 | return; | 4634 | return; |
4635 | } | 4635 | } |
4636 | } | 4636 | } |
4637 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4637 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4638 | 4638 | ||
4639 | } | 4639 | } |
4640 | 4640 | ||
4641 | QPtrList<CalFilter> CalendarView::filters() | 4641 | QPtrList<CalFilter> CalendarView::filters() |
4642 | { | 4642 | { |
4643 | return mFilters; | 4643 | return mFilters; |
4644 | 4644 | ||
4645 | } | 4645 | } |
4646 | void CalendarView::editFilters() | 4646 | void CalendarView::editFilters() |
4647 | { | 4647 | { |
4648 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4648 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4649 | 4649 | ||
4650 | CalFilter *filter = mFilters.first(); | 4650 | CalFilter *filter = mFilters.first(); |
4651 | while(filter) { | 4651 | while(filter) { |
4652 | filter = mFilters.next(); | 4652 | filter = mFilters.next(); |
4653 | } | 4653 | } |
4654 | 4654 | ||
4655 | mDialogManager->showFilterEditDialog(&mFilters); | 4655 | mDialogManager->showFilterEditDialog(&mFilters); |
4656 | updateFilter(); | 4656 | updateFilter(); |
4657 | } | 4657 | } |
4658 | void CalendarView::toggleFilter() | 4658 | void CalendarView::toggleFilter() |
4659 | { | 4659 | { |
4660 | if ( mLeftFrame->isHidden() ) { | 4660 | if ( mLeftFrame->isHidden() ) { |
4661 | toggleExpand(); | 4661 | toggleExpand(); |
4662 | showFilter( true ); | 4662 | showFilter( true ); |
4663 | } else | 4663 | } else |
4664 | showFilter(! mCalEditView->isVisible()); | 4664 | showFilter(! mCalEditView->isVisible()); |
4665 | } | 4665 | } |
4666 | 4666 | ||
4667 | KOFilterView *CalendarView::filterView() | 4667 | KOFilterView *CalendarView::filterView() |
4668 | { | 4668 | { |
4669 | return mFilterView; | 4669 | return mFilterView; |
4670 | } | 4670 | } |
4671 | void CalendarView::selectFilter( int fil ) | 4671 | void CalendarView::selectFilter( int fil ) |
4672 | { | 4672 | { |
4673 | mFilterView->setSelectedFilter( fil ); | 4673 | mFilterView->setSelectedFilter( fil ); |
4674 | updateUnmanagedViews(); | 4674 | updateUnmanagedViews(); |
4675 | } | 4675 | } |
4676 | void CalendarView::showFilter(bool visible) | 4676 | void CalendarView::showFilter(bool visible) |
4677 | { | 4677 | { |
4678 | #if 1 | 4678 | #if 1 |
4679 | if (visible) { | 4679 | if (visible) { |
4680 | mCalEditView->readConfig(); | 4680 | mCalEditView->readConfig(); |
4681 | mCalEditView->show(); | 4681 | mCalEditView->show(); |
4682 | QValueList<int> sizes; | 4682 | QValueList<int> sizes; |
4683 | sizes = mLeftFrame->sizes(); | 4683 | sizes = mLeftFrame->sizes(); |
4684 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4684 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4685 | sizes.clear(); | 4685 | sizes.clear(); |
4686 | sizes << 100; | 4686 | sizes << 100; |
4687 | sizes << 0; | 4687 | sizes << 0; |
4688 | sizes << 0; | 4688 | sizes << 0; |
4689 | sizes << 100; | 4689 | sizes << 100; |
4690 | mLeftFrame->setSizes(sizes); | 4690 | mLeftFrame->setSizes(sizes); |
4691 | } | 4691 | } |
4692 | #if 0 | 4692 | #if 0 |
4693 | sizes = mLeftFrame->sizes(); | 4693 | sizes = mLeftFrame->sizes(); |
4694 | int ccc = 0; | 4694 | int ccc = 0; |
4695 | while ( ccc < sizes.count()) { | 4695 | while ( ccc < sizes.count()) { |
4696 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4696 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4697 | ++ccc; | 4697 | ++ccc; |
4698 | } | 4698 | } |
4699 | #endif | 4699 | #endif |
4700 | 4700 | ||
4701 | } | 4701 | } |
4702 | else { | 4702 | else { |
4703 | mCalEditView->hide(); | 4703 | mCalEditView->hide(); |
4704 | } | 4704 | } |
4705 | #else | 4705 | #else |
4706 | if (visible) mFilterView->show(); | 4706 | if (visible) mFilterView->show(); |
4707 | else mFilterView->hide(); | 4707 | else mFilterView->hide(); |
4708 | #endif | 4708 | #endif |
4709 | } | 4709 | } |
4710 | void CalendarView::toggleFilerEnabled( ) | 4710 | void CalendarView::toggleFilerEnabled( ) |
4711 | { | 4711 | { |
4712 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4712 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4713 | if ( !mFilterView->filtersEnabled() ) | 4713 | if ( !mFilterView->filtersEnabled() ) |
4714 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4714 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4715 | updateUnmanagedViews(); | 4715 | updateUnmanagedViews(); |
4716 | 4716 | ||
4717 | } | 4717 | } |
4718 | void CalendarView::updateFilter() | 4718 | void CalendarView::updateFilter() |
4719 | { | 4719 | { |
4720 | CalFilter *filter = mFilterView->selectedFilter(); | 4720 | CalFilter *filter = mFilterView->selectedFilter(); |
4721 | if (filter) { | 4721 | if (filter) { |
4722 | QString mess; | 4722 | QString mess; |
4723 | if (mFilterView->filtersEnabled()) { | 4723 | if (mFilterView->filtersEnabled()) { |
4724 | mess = i18n("Filter selected: ")+filter->name(); | 4724 | mess = i18n("Filter selected: ")+filter->name(); |
4725 | filter->setEnabled(true); | 4725 | filter->setEnabled(true); |
4726 | } | 4726 | } |
4727 | else filter->setEnabled(false); | 4727 | else filter->setEnabled(false); |
4728 | mCalendar->setFilter(filter); | 4728 | mCalendar->setFilter(filter); |
4729 | updateView(); | 4729 | updateView(); |
4730 | if ( !mess.isEmpty() ) | 4730 | if ( !mess.isEmpty() ) |
4731 | topLevelWidget()->setCaption( mess ); | 4731 | topLevelWidget()->setCaption( mess ); |
4732 | 4732 | ||
4733 | } | 4733 | } |
4734 | emit filtersUpdated(); | 4734 | emit filtersUpdated(); |
4735 | } | 4735 | } |
4736 | 4736 | ||
4737 | void CalendarView::filterEdited() | 4737 | void CalendarView::filterEdited() |
4738 | { | 4738 | { |
4739 | mFilterView->updateFilters(); | 4739 | mFilterView->updateFilters(); |
4740 | updateFilter(); | 4740 | updateFilter(); |
4741 | writeSettings(); | 4741 | writeSettings(); |
4742 | } | 4742 | } |
4743 | 4743 | ||
4744 | 4744 | ||
4745 | void CalendarView::takeOverEvent() | 4745 | void CalendarView::takeOverEvent() |
4746 | { | 4746 | { |
4747 | Incidence *incidence = currentSelection(); | 4747 | Incidence *incidence = currentSelection(); |
4748 | 4748 | ||
4749 | if (!incidence) return; | 4749 | if (!incidence) return; |
4750 | 4750 | ||
4751 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4751 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4752 | incidence->recreate(); | 4752 | incidence->recreate(); |
4753 | incidence->setReadOnly(false); | 4753 | incidence->setReadOnly(false); |
4754 | 4754 | ||
4755 | updateView(); | 4755 | updateView(); |
4756 | } | 4756 | } |
4757 | 4757 | ||
4758 | void CalendarView::takeOverCalendar() | 4758 | void CalendarView::takeOverCalendar() |
4759 | { | 4759 | { |
4760 | // TODO: Create Calendar::allIncidences() function and use it here | 4760 | // TODO: Create Calendar::allIncidences() function and use it here |
4761 | 4761 | ||
4762 | clearAllViews(); | 4762 | clearAllViews(); |
4763 | QPtrList<Event> events = mCalendar->events(); | 4763 | QPtrList<Event> events = mCalendar->events(); |
4764 | for(uint i=0; i<events.count(); ++i) { | 4764 | for(uint i=0; i<events.count(); ++i) { |
4765 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4765 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4766 | events.at(i)->recreate(); | 4766 | events.at(i)->recreate(); |
4767 | events.at(i)->setReadOnly(false); | 4767 | events.at(i)->setReadOnly(false); |
4768 | } | 4768 | } |
4769 | 4769 | ||
4770 | QPtrList<Todo> todos = mCalendar->todos(); | 4770 | QPtrList<Todo> todos = mCalendar->todos(); |
4771 | for(uint i=0; i<todos.count(); ++i) { | 4771 | for(uint i=0; i<todos.count(); ++i) { |
4772 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4772 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4773 | todos.at(i)->recreate(); | 4773 | todos.at(i)->recreate(); |
4774 | todos.at(i)->setReadOnly(false); | 4774 | todos.at(i)->setReadOnly(false); |
4775 | } | 4775 | } |
4776 | 4776 | ||
4777 | QPtrList<Journal> journals = mCalendar->journals(); | 4777 | QPtrList<Journal> journals = mCalendar->journals(); |
4778 | for(uint i=0; i<journals.count(); ++i) { | 4778 | for(uint i=0; i<journals.count(); ++i) { |
4779 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4779 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4780 | journals.at(i)->recreate(); | 4780 | journals.at(i)->recreate(); |
4781 | journals.at(i)->setReadOnly(false); | 4781 | journals.at(i)->setReadOnly(false); |
4782 | } | 4782 | } |
4783 | 4783 | ||
4784 | updateView(); | 4784 | updateView(); |
4785 | } | 4785 | } |
4786 | 4786 | ||
4787 | void CalendarView::showIntro() | 4787 | void CalendarView::showIntro() |
4788 | { | 4788 | { |
4789 | kdDebug() << "To be implemented." << endl; | 4789 | kdDebug() << "To be implemented." << endl; |
4790 | } | 4790 | } |
4791 | 4791 | ||
4792 | QWidgetStack *CalendarView::viewStack() | 4792 | QWidgetStack *CalendarView::viewStack() |
4793 | { | 4793 | { |
4794 | return mRightFrame; | 4794 | return mRightFrame; |
4795 | } | 4795 | } |
4796 | 4796 | ||
4797 | QWidget *CalendarView::leftFrame() | 4797 | QWidget *CalendarView::leftFrame() |
4798 | { | 4798 | { |
4799 | return ( QWidget *)mLeftFrame; | 4799 | return ( QWidget *)mLeftFrame; |
4800 | } | 4800 | } |
4801 | 4801 | ||
4802 | DateNavigator *CalendarView::dateNavigator() | 4802 | DateNavigator *CalendarView::dateNavigator() |
4803 | { | 4803 | { |
4804 | return mNavigator; | 4804 | return mNavigator; |
4805 | } | 4805 | } |
4806 | 4806 | ||
4807 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4807 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4808 | { | 4808 | { |
4809 | return mDateNavigator->navigatorView(); | 4809 | return mDateNavigator->navigatorView(); |
4810 | } | 4810 | } |
4811 | void CalendarView::toggleDateNavigatorWidget() | 4811 | void CalendarView::toggleDateNavigatorWidget() |
4812 | { | 4812 | { |
4813 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4813 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4814 | 4814 | ||
4815 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4815 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4816 | mDateNavigator->hide(); | 4816 | mDateNavigator->hide(); |
4817 | else | 4817 | else |
4818 | mDateNavigator->show(); | 4818 | mDateNavigator->show(); |
4819 | } | 4819 | } |
4820 | void CalendarView::addView(KOrg::BaseView *view) | 4820 | void CalendarView::addView(KOrg::BaseView *view) |
4821 | { | 4821 | { |
4822 | mViewManager->addView(view); | 4822 | mViewManager->addView(view); |
4823 | } | 4823 | } |
4824 | 4824 | ||
4825 | void CalendarView::showView(KOrg::BaseView *view) | 4825 | void CalendarView::showView(KOrg::BaseView *view) |
4826 | { | 4826 | { |
4827 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4827 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4828 | } | 4828 | } |
4829 | 4829 | ||
4830 | Incidence *CalendarView::currentSelection() | 4830 | Incidence *CalendarView::currentSelection() |
4831 | { | 4831 | { |
4832 | return mViewManager->currentSelection(); | 4832 | return mViewManager->currentSelection(); |
4833 | } | 4833 | } |
4834 | void CalendarView::toggleAllDaySize() | 4834 | void CalendarView::toggleAllDaySize() |
4835 | { | 4835 | { |
4836 | /* | 4836 | /* |
4837 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4837 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4838 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4838 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4839 | else | 4839 | else |
4840 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4840 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4841 | */ | 4841 | */ |
4842 | viewManager()->agendaView()->toggleAllDay(); | 4842 | viewManager()->agendaView()->toggleAllDay(); |
4843 | } | 4843 | } |
4844 | void CalendarView::toggleExpand() | 4844 | void CalendarView::toggleExpand() |
4845 | { | 4845 | { |
4846 | // if ( mLeftFrame->isHidden() ) { | 4846 | // if ( mLeftFrame->isHidden() ) { |
4847 | // mLeftFrame->show(); | 4847 | // mLeftFrame->show(); |
4848 | // emit calendarViewExpanded( false ); | 4848 | // emit calendarViewExpanded( false ); |
4849 | // } else { | 4849 | // } else { |
4850 | // mLeftFrame->hide(); | 4850 | // mLeftFrame->hide(); |
4851 | // emit calendarViewExpanded( true ); | 4851 | // emit calendarViewExpanded( true ); |
4852 | // } | 4852 | // } |
4853 | //qDebug(" CalendarView::toggleExpand()"); | 4853 | //qDebug(" CalendarView::toggleExpand()"); |
4854 | globalFlagBlockAgenda = 1; | 4854 | globalFlagBlockAgenda = 1; |
4855 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4855 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4856 | globalFlagBlockAgenda = 5; | 4856 | globalFlagBlockAgenda = 5; |
4857 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4857 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4858 | //mViewManager->showView( 0, true ); | 4858 | //mViewManager->showView( 0, true ); |
4859 | } | 4859 | } |
4860 | 4860 | ||
4861 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4861 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4862 | { | 4862 | { |
4863 | setModified( modified ); | 4863 | setModified( modified ); |
4864 | } | 4864 | } |
4865 | 4865 | ||
4866 | Todo *CalendarView::selectedTodo() | 4866 | Todo *CalendarView::selectedTodo() |
4867 | { | 4867 | { |
4868 | Incidence *incidence = currentSelection(); | 4868 | Incidence *incidence = currentSelection(); |
4869 | if ( incidence && incidence->typeID() == todoID ) { | 4869 | if ( incidence && incidence->typeID() == todoID ) { |
4870 | return static_cast<Todo *>( incidence ); | 4870 | return static_cast<Todo *>( incidence ); |
4871 | } | 4871 | } |
4872 | 4872 | ||
4873 | incidence = mTodoList->selectedIncidences().first(); | 4873 | incidence = mTodoList->selectedIncidences().first(); |
4874 | if ( incidence && incidence->typeID() == todoID ) { | 4874 | if ( incidence && incidence->typeID() == todoID ) { |
4875 | return static_cast<Todo *>( incidence ); | 4875 | return static_cast<Todo *>( incidence ); |
4876 | } | 4876 | } |
4877 | 4877 | ||
4878 | return 0; | 4878 | return 0; |
4879 | } | 4879 | } |
4880 | 4880 | ||
4881 | void CalendarView::showIncidence() | 4881 | void CalendarView::showIncidence() |
4882 | { | 4882 | { |
4883 | mViewerCallerIsSearchDialog = false; | 4883 | mViewerCallerIsSearchDialog = false; |
4884 | Incidence *incidence = currentSelection(); | 4884 | Incidence *incidence = currentSelection(); |
4885 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4885 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4886 | if ( incidence ) { | 4886 | if ( incidence ) { |
4887 | ShowIncidenceVisitor v; | 4887 | ShowIncidenceVisitor v; |
4888 | v.act( incidence, this ); | 4888 | v.act( incidence, this ); |
4889 | } | 4889 | } |
4890 | } | 4890 | } |
4891 | void CalendarView::editIncidenceDescription() | 4891 | void CalendarView::editIncidenceDescription() |
4892 | { | 4892 | { |
4893 | mFlagEditDescription = true; | 4893 | mFlagEditDescription = true; |
4894 | editIncidence(); | 4894 | editIncidence(); |
4895 | mFlagEditDescription = false; | 4895 | mFlagEditDescription = false; |
4896 | } | 4896 | } |
4897 | void CalendarView::editIncidence() | 4897 | void CalendarView::editIncidence() |
4898 | { | 4898 | { |
4899 | // qDebug("editIncidence() "); | 4899 | // qDebug("editIncidence() "); |
4900 | Incidence *incidence = currentSelection(); | 4900 | Incidence *incidence = currentSelection(); |
4901 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4901 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4902 | if ( incidence ) { | 4902 | if ( incidence ) { |
4903 | EditIncidenceVisitor v; | 4903 | EditIncidenceVisitor v; |
4904 | v.act( incidence, this ); | 4904 | v.act( incidence, this ); |
4905 | } | 4905 | } |
4906 | } | 4906 | } |
4907 | 4907 | ||
4908 | void CalendarView::deleteIncidence() | 4908 | void CalendarView::deleteIncidence() |
4909 | { | 4909 | { |
4910 | Incidence *incidence = currentSelection(); | 4910 | Incidence *incidence = currentSelection(); |
4911 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4911 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4912 | if ( incidence ) { | 4912 | if ( incidence ) { |
4913 | deleteIncidence(incidence); | 4913 | deleteIncidence(incidence); |
4914 | } | 4914 | } |
4915 | } | 4915 | } |
4916 | void CalendarView::showIncidence(QString uid) | 4916 | void CalendarView::showIncidence(QString uid) |
4917 | { | 4917 | { |
4918 | Incidence *inc = mCalendar->incidence( uid ); | 4918 | Incidence *inc = mCalendar->incidence( uid ); |
4919 | if ( inc ) | 4919 | if ( inc ) |
4920 | showIncidence( inc ); | 4920 | showIncidence( inc ); |
4921 | } | 4921 | } |
4922 | void CalendarView::showIncidence(Incidence *incidence) | 4922 | void CalendarView::showIncidence(Incidence *incidence) |
4923 | { | 4923 | { |
4924 | mViewerCallerIsSearchDialog = false; | 4924 | mViewerCallerIsSearchDialog = false; |
4925 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4925 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4926 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4926 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4927 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4927 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4928 | mViewerCallerIsSearchDialog = true; | 4928 | mViewerCallerIsSearchDialog = true; |
4929 | } | 4929 | } |
4930 | } | 4930 | } |
4931 | if ( incidence ) { | 4931 | if ( incidence ) { |
4932 | ShowIncidenceVisitor v; | 4932 | ShowIncidenceVisitor v; |
4933 | v.act( incidence, this ); | 4933 | v.act( incidence, this ); |
4934 | } | 4934 | } |
4935 | } | 4935 | } |
4936 | 4936 | ||
4937 | void CalendarView::editIncidence(Incidence *incidence) | 4937 | void CalendarView::editIncidence(Incidence *incidence) |
4938 | { | 4938 | { |
4939 | if ( incidence ) { | 4939 | if ( incidence ) { |
4940 | 4940 | ||
4941 | EditIncidenceVisitor v; | 4941 | EditIncidenceVisitor v; |
4942 | v.act( incidence, this ); | 4942 | v.act( incidence, this ); |
4943 | 4943 | ||
4944 | } | 4944 | } |
4945 | } | 4945 | } |
4946 | 4946 | ||
4947 | void CalendarView::deleteIncidence(Incidence *incidence) | 4947 | void CalendarView::deleteIncidence(Incidence *incidence) |
4948 | { | 4948 | { |
4949 | //qDebug(" CalendarView::deleteIncidence "); | 4949 | //qDebug(" CalendarView::deleteIncidence "); |
4950 | if ( incidence == 0 ) { | 4950 | if ( incidence == 0 ) { |
4951 | updateView(); | 4951 | updateView(); |
4952 | emit updateSearchDialog(); | 4952 | emit updateSearchDialog(); |
4953 | return; | 4953 | return; |
4954 | } | 4954 | } |
4955 | if ( incidence ) { | 4955 | if ( incidence ) { |
4956 | DeleteIncidenceVisitor v; | 4956 | DeleteIncidenceVisitor v; |
4957 | v.act( incidence, this ); | 4957 | v.act( incidence, this ); |
4958 | } | 4958 | } |
4959 | } | 4959 | } |
4960 | 4960 | ||
4961 | 4961 | ||
4962 | void CalendarView::lookForOutgoingMessages() | 4962 | void CalendarView::lookForOutgoingMessages() |
4963 | { | 4963 | { |
4964 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4964 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4965 | ogd->loadMessages(); | 4965 | ogd->loadMessages(); |
4966 | } | 4966 | } |
4967 | 4967 | ||
4968 | void CalendarView::lookForIncomingMessages() | 4968 | void CalendarView::lookForIncomingMessages() |
4969 | { | 4969 | { |
4970 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4970 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4971 | icd->retrieve(); | 4971 | icd->retrieve(); |
4972 | } | 4972 | } |
4973 | 4973 | ||
4974 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4974 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4975 | { | 4975 | { |
4976 | bool deleteTodo = true; | 4976 | bool deleteTodo = true; |
4977 | QPtrList<Incidence> subTodos; | 4977 | QPtrList<Incidence> subTodos; |
4978 | Incidence *aTodo; | 4978 | Incidence *aTodo; |
4979 | subTodos = t->relations(); | 4979 | subTodos = t->relations(); |
4980 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4980 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4981 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4981 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4982 | deleteTodo = false; | 4982 | deleteTodo = false; |
4983 | } | 4983 | } |
4984 | if ( deleteTodo ) { | 4984 | if ( deleteTodo ) { |
4985 | if ( t->isCompleted() && !t->doesRecur()) { | 4985 | if ( t->isCompleted() && !t->doesRecur()) { |
4986 | checkExternalId( t ); | 4986 | checkExternalId( t ); |
4987 | mCalendar->deleteTodo( t ); | 4987 | mCalendar->deleteTodo( t ); |
4988 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4988 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4989 | } | 4989 | } |
4990 | else | 4990 | else |
4991 | deleteTodo = false; | 4991 | deleteTodo = false; |
4992 | } | 4992 | } |
4993 | return deleteTodo; | 4993 | return deleteTodo; |
4994 | 4994 | ||
4995 | } | 4995 | } |
4996 | void CalendarView::purgeCompleted() | 4996 | void CalendarView::purgeCompleted() |
4997 | { | 4997 | { |
4998 | int result = KMessageBox::warningContinueCancel(this, | 4998 | int result = KMessageBox::warningContinueCancel(this, |
4999 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4999 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5000 | 5000 | ||
5001 | if (result == KMessageBox::Continue) { | 5001 | if (result == KMessageBox::Continue) { |
5002 | 5002 | ||
5003 | QPtrList<Todo> todoCal; | 5003 | QPtrList<Todo> todoCal; |
5004 | QPtrList<Todo> rootTodos; | 5004 | QPtrList<Todo> rootTodos; |
5005 | //QPtrList<Incidence> rel; | 5005 | //QPtrList<Incidence> rel; |
5006 | Todo *aTodo; | 5006 | Todo *aTodo; |
5007 | todoCal = calendar()->todos(); | 5007 | todoCal = calendar()->todos(); |
5008 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5008 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5009 | if ( !aTodo->relatedTo() ) | 5009 | if ( !aTodo->relatedTo() ) |
5010 | rootTodos.append( aTodo ); | 5010 | rootTodos.append( aTodo ); |
5011 | } | 5011 | } |
5012 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5012 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5013 | removeCompletedSubTodos( aTodo ); | 5013 | removeCompletedSubTodos( aTodo ); |
5014 | } | 5014 | } |
5015 | 5015 | ||
5016 | updateView(); | 5016 | updateView(); |
5017 | } | 5017 | } |
5018 | } | 5018 | } |
5019 | 5019 | ||
5020 | void CalendarView::slotCalendarChanged() | 5020 | void CalendarView::slotCalendarChanged() |
5021 | { | 5021 | { |
5022 | ; | 5022 | ; |
5023 | } | 5023 | } |
5024 | 5024 | ||
5025 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5025 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5026 | { | 5026 | { |
5027 | //qDebug("CalendarView::keyPressEvent "); | 5027 | //qDebug("CalendarView::keyPressEvent "); |
5028 | e->ignore(); | 5028 | e->ignore(); |
5029 | } | 5029 | } |
5030 | 5030 | ||
5031 | 5031 | ||
5032 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 5032 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
5033 | { | 5033 | { |
5034 | 5034 | ||
5035 | if ( manager != mSyncManager) | 5035 | if ( manager != mSyncManager) |
5036 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5036 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5037 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5037 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5038 | qDebug("KO: SyncKDE request detected!"); | 5038 | qDebug("KO: SyncKDE request detected!"); |
5039 | } | 5039 | } |
5040 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5040 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5041 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5041 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5042 | return syncCalendar( filename, mode ); | 5042 | return syncCalendar( filename, mode ); |
5043 | } | 5043 | } |
5044 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5044 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5045 | { | 5045 | { |
5046 | //mSyncManager = manager; | 5046 | //mSyncManager = manager; |
5047 | if ( manager != mSyncManager) | 5047 | if ( manager != mSyncManager) |
5048 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5048 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5049 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5049 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5050 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5050 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5051 | if ( resource == "sharp" ) | 5051 | if ( resource == "sharp" ) |
5052 | syncExternal( 0 ); | 5052 | syncExternal( 0 ); |
5053 | if ( resource == "phone" ) | 5053 | if ( resource == "phone" ) |
5054 | syncExternal( 1 ); | 5054 | syncExternal( 1 ); |
5055 | // pending setmodified | 5055 | // pending setmodified |
5056 | return true; | 5056 | return true; |
5057 | } | 5057 | } |
5058 | void CalendarView::setSyncManager(KSyncManager* manager) | 5058 | void CalendarView::setSyncManager(KSyncManager* manager) |
5059 | { | 5059 | { |
5060 | mSyncManager = manager; | 5060 | mSyncManager = manager; |
5061 | } | 5061 | } |
5062 | 5062 | ||
5063 | void CalendarView::removeSyncInfo( QString syncProfile) | 5063 | void CalendarView::removeSyncInfo( QString syncProfile) |
5064 | { | 5064 | { |
5065 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5065 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5066 | mCalendar->removeSyncInfo( syncProfile ); | 5066 | mCalendar->removeSyncInfo( syncProfile ); |
5067 | 5067 | ||
5068 | } | 5068 | } |
5069 | 5069 | ||
5070 | void CalendarView::undo_delete() | 5070 | void CalendarView::undo_delete() |
5071 | { | 5071 | { |
5072 | //qDebug("undo_delete() "); | 5072 | //qDebug("undo_delete() "); |
5073 | Incidence* undo = mCalendar->undoIncidence(); | 5073 | Incidence* undo = mCalendar->undoIncidence(); |
5074 | if ( !undo ) { | 5074 | if ( !undo ) { |
5075 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5075 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5076 | i18n("KO/Pi")); | 5076 | i18n("KO/Pi")); |
5077 | return; | 5077 | return; |
5078 | } | 5078 | } |
5079 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5079 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5080 | i18n("\nAre you sure you want\nto restore this?"), | 5080 | i18n("\nAre you sure you want\nto restore this?"), |
5081 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5081 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5082 | mCalendar->undoDeleteIncidence(); | 5082 | mCalendar->undoDeleteIncidence(); |
5083 | updateView(); | 5083 | updateView(); |
5084 | } | 5084 | } |
5085 | } | 5085 | } |
5086 | 5086 | ||
5087 | void CalendarView::slotViewerClosed() | 5087 | void CalendarView::slotViewerClosed() |
5088 | { | 5088 | { |
5089 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5089 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5090 | } | 5090 | } |
5091 | 5091 | ||
5092 | void CalendarView::resetFocus() | 5092 | void CalendarView::resetFocus() |
5093 | { | 5093 | { |
5094 | if ( mViewerCallerIsSearchDialog ) { | 5094 | if ( mViewerCallerIsSearchDialog ) { |
5095 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5095 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5096 | mDialogManager->getSearchDialog()->raise(); | 5096 | mDialogManager->getSearchDialog()->raise(); |
5097 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5097 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5098 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5098 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5099 | } else | 5099 | } else |
5100 | mViewerCallerIsSearchDialog = false; | 5100 | mViewerCallerIsSearchDialog = false; |
5101 | } | 5101 | } |
5102 | if ( !mViewerCallerIsSearchDialog ) { | 5102 | if ( !mViewerCallerIsSearchDialog ) { |
5103 | //mViewManager->currentView()->setFocus(); | 5103 | //mViewManager->currentView()->setFocus(); |
5104 | //qDebug("sssssssssssssssset focus "); | 5104 | //qDebug("sssssssssssssssset focus "); |
5105 | topLevelWidget()->raise(); | 5105 | topLevelWidget()->raise(); |
5106 | setActiveWindow(); | 5106 | setActiveWindow(); |
5107 | //setFocus(); | 5107 | //setFocus(); |
5108 | } | 5108 | } |
5109 | mViewerCallerIsSearchDialog = false; | 5109 | mViewerCallerIsSearchDialog = false; |
5110 | } | 5110 | } |
5111 | 5111 | ||
5112 | void CalendarView::showNextAlarms() | 5112 | void CalendarView::showNextAlarms() |
5113 | { | 5113 | { |
5114 | QString message; | 5114 | QString message; |
5115 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5115 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5116 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5116 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5117 | QString sum = mCalendar->nextSummary(); | 5117 | QString sum = mCalendar->nextSummary(); |
5118 | QDateTime nextA = mNextAlarmDateTime; | 5118 | QDateTime nextA = mNextAlarmDateTime; |
5119 | QDateTime cur = QDateTime::currentDateTime(); | 5119 | QDateTime cur = QDateTime::currentDateTime(); |
5120 | int secs = cur.secsTo( nextA ); | 5120 | int secs = cur.secsTo( nextA ); |
5121 | int min = secs /60; | 5121 | int min = secs /60; |
5122 | int hours = min /60; | 5122 | int hours = min /60; |
5123 | min = min % 60; | 5123 | min = min % 60; |
5124 | int days = hours /24; | 5124 | int days = hours /24; |
5125 | hours = hours % 24; | 5125 | hours = hours % 24; |
5126 | 5126 | ||
5127 | //message = i18n("The next alarm is in:\n"); | 5127 | //message = i18n("The next alarm is in:\n"); |
5128 | if ( days > 1 ) | 5128 | if ( days > 1 ) |
5129 | message += i18n("%1 days\n").arg( days ); | 5129 | message += i18n("%1 days\n").arg( days ); |
5130 | else if ( days == 1 ) | 5130 | else if ( days == 1 ) |
5131 | message += i18n("1 day\n"); | 5131 | message += i18n("1 day\n"); |
5132 | if ( hours > 1 ) | 5132 | if ( hours > 1 ) |
5133 | message += i18n("%1 hours\n").arg( hours ); | 5133 | message += i18n("%1 hours\n").arg( hours ); |
5134 | else if ( hours == 1 ) | 5134 | else if ( hours == 1 ) |
5135 | message += i18n("1 hour\n"); | 5135 | message += i18n("1 hour\n"); |
5136 | if ( min > 1 ) | 5136 | if ( min > 1 ) |
5137 | message += i18n("%1 minutes\n").arg( min ); | 5137 | message += i18n("%1 minutes\n").arg( min ); |
5138 | else if ( min == 1 ) | 5138 | else if ( min == 1 ) |
5139 | message += i18n("1 minute\n"); | 5139 | message += i18n("1 minute\n"); |
5140 | if ( message.isEmpty() ) | 5140 | if ( message.isEmpty() ) |
5141 | message = i18n("The next alarm is in\nless than one minute!"); | 5141 | message = i18n("The next alarm is in\nless than one minute!"); |
5142 | else | 5142 | else |
5143 | message = i18n("The next alarm is in:\n") + message; | 5143 | message = i18n("The next alarm is in:\n") + message; |
5144 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5144 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5145 | } else { | 5145 | } else { |
5146 | message = i18n("There is no next alarm."); | 5146 | message = i18n("There is no next alarm."); |
5147 | 5147 | ||
5148 | } | 5148 | } |
5149 | #ifdef DESKTOP_VERSION | 5149 | #ifdef DESKTOP_VERSION |
5150 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5150 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5151 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5151 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5152 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5152 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5153 | } | 5153 | } |
5154 | 5154 | ||
5155 | #endif | 5155 | #endif |
5156 | KMessageBox::information( this, message); | 5156 | KMessageBox::information( this, message); |
5157 | } | 5157 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 70baf5c..2af605f 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2717 +1,2733 @@ | |||
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 | mClosed = false; | 173 | mClosed = false; |
174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
175 | QString confFile = locateLocal("config","korganizerrc"); | 175 | QString confFile = locateLocal("config","korganizerrc"); |
176 | QFileInfo finf ( confFile ); | 176 | QFileInfo finf ( confFile ); |
177 | bool showWarning = !finf.exists(); | 177 | bool showWarning = !finf.exists(); |
178 | setIcon(SmallIcon( "ko24" ) ); | 178 | setIcon(SmallIcon( "ko24" ) ); |
179 | mBlockAtStartup = true; | 179 | mBlockAtStartup = true; |
180 | mFlagKeyPressed = false; | 180 | mFlagKeyPressed = false; |
181 | setCaption("KO/Pi"); | 181 | setCaption("KO/Pi"); |
182 | KOPrefs *p = KOPrefs::instance(); | 182 | KOPrefs *p = KOPrefs::instance(); |
183 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 183 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
184 | p->mCurrentDisplayedView = 0; | 184 | p->mCurrentDisplayedView = 0; |
185 | if ( p->mHourSize > 22 ) | 185 | if ( p->mHourSize > 22 ) |
186 | p->mHourSize = 22; | 186 | p->mHourSize = 22; |
187 | QMainWindow::ToolBarDock tbd; | 187 | QMainWindow::ToolBarDock tbd; |
188 | if ( p->mToolBarHor ) { | 188 | if ( p->mToolBarHor ) { |
189 | if ( p->mToolBarUp ) | 189 | if ( p->mToolBarUp ) |
190 | tbd = Bottom; | 190 | tbd = Bottom; |
191 | else | 191 | else |
192 | tbd = Top; | 192 | tbd = Top; |
193 | } | 193 | } |
194 | else { | 194 | else { |
195 | if ( p->mToolBarUp ) | 195 | if ( p->mToolBarUp ) |
196 | tbd = Right; | 196 | tbd = Right; |
197 | else | 197 | else |
198 | tbd = Left; | 198 | tbd = Left; |
199 | } | 199 | } |
200 | if ( KOPrefs::instance()->mUseAppColors ) | 200 | if ( KOPrefs::instance()->mUseAppColors ) |
201 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 201 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
202 | globalFlagBlockStartup = 1; | 202 | globalFlagBlockStartup = 1; |
203 | iconToolBar = new QPEToolBar( this ); | 203 | iconToolBar = new QPEToolBar( this ); |
204 | addToolBar (iconToolBar , tbd ); | 204 | addToolBar (iconToolBar , tbd ); |
205 | 205 | ||
206 | #ifdef DESKTOP_VERSION | 206 | #ifdef DESKTOP_VERSION |
207 | if ( KOPrefs::instance()->mShowIconFilter ) | 207 | if ( KOPrefs::instance()->mShowIconFilter ) |
208 | #else | 208 | #else |
209 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) | 209 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | { | 212 | { |
213 | if ( p->mToolBarHorF ) { | 213 | if ( p->mToolBarHorF ) { |
214 | if ( p->mToolBarUpF ) | 214 | if ( p->mToolBarUpF ) |
215 | tbd = Bottom; | 215 | tbd = Bottom; |
216 | else | 216 | else |
217 | tbd = Top; | 217 | tbd = Top; |
218 | } | 218 | } |
219 | else { | 219 | else { |
220 | if ( p->mToolBarUpF ) | 220 | if ( p->mToolBarUpF ) |
221 | tbd = Right; | 221 | tbd = Right; |
222 | else | 222 | else |
223 | tbd = Left; | 223 | tbd = Left; |
224 | } | 224 | } |
225 | filterToolBar = new QPEToolBar ( this ); | 225 | filterToolBar = new QPEToolBar ( this ); |
226 | filterMenubar = new KMenuBar( 0 ); | 226 | filterMenubar = new KMenuBar( 0 ); |
227 | QFontMetrics fm ( filterMenubar->font() ); | 227 | QFontMetrics fm ( filterMenubar->font() ); |
228 | #ifndef DESKTOP_VERSION | 228 | #ifndef DESKTOP_VERSION |
229 | filterToolBar->setFocusPolicy( NoFocus ); | 229 | filterToolBar->setFocusPolicy( NoFocus ); |
230 | filterMenubar->setFocusPolicy( NoFocus ); | 230 | filterMenubar->setFocusPolicy( NoFocus ); |
231 | #endif | 231 | #endif |
232 | filterPopupMenu = new QPopupMenu( this ); | 232 | filterPopupMenu = new QPopupMenu( this ); |
233 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 233 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
234 | QString addTest = "A"; | 234 | QString addTest = "A"; |
235 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 235 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
236 | #ifdef DESKTOP_VERSION | 236 | #ifdef DESKTOP_VERSION |
237 | addTest = "AAAAAABBBCCCx"; | 237 | addTest = "AAAAAABBBCCCx"; |
238 | #else | 238 | #else |
239 | addTest = "AAAAAx"; | 239 | addTest = "AAAAAx"; |
240 | #endif | 240 | #endif |
241 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 241 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
242 | addToolBar (filterToolBar , tbd ); | 242 | addToolBar (filterToolBar , tbd ); |
243 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 243 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
244 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 244 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
245 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 245 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
246 | filterToolBar->hide(); | 246 | filterToolBar->hide(); |
247 | } else { | 247 | } else { |
248 | filterToolBar = 0; | 248 | filterToolBar = 0; |
249 | filterMenubar = 0; | 249 | filterMenubar = 0; |
250 | filterPopupMenu = 0; | 250 | filterPopupMenu = 0; |
251 | } | 251 | } |
252 | if ( p->mShowIconOnetoolbar ) { | 252 | if ( p->mShowIconOnetoolbar ) { |
253 | viewToolBar = iconToolBar ; | 253 | viewToolBar = iconToolBar ; |
254 | navigatorToolBar = iconToolBar ; | 254 | navigatorToolBar = iconToolBar ; |
255 | } else { | 255 | } else { |
256 | #ifndef DESKTOP_VERSION | 256 | #ifndef DESKTOP_VERSION |
257 | setToolBarsMovable( false ); | 257 | setToolBarsMovable( false ); |
258 | #endif | 258 | #endif |
259 | if ( p->mToolBarHorV ) { | 259 | if ( p->mToolBarHorV ) { |
260 | if ( p->mToolBarUpV ) | 260 | if ( p->mToolBarUpV ) |
261 | tbd = Bottom; | 261 | tbd = Bottom; |
262 | else | 262 | else |
263 | tbd = Top; | 263 | tbd = Top; |
264 | } | 264 | } |
265 | else { | 265 | else { |
266 | if ( p->mToolBarUpV ) | 266 | if ( p->mToolBarUpV ) |
267 | tbd = Right; | 267 | tbd = Right; |
268 | else | 268 | else |
269 | tbd = Left; | 269 | tbd = Left; |
270 | } | 270 | } |
271 | viewToolBar = new QPEToolBar( this ); | 271 | viewToolBar = new QPEToolBar( this ); |
272 | addToolBar (viewToolBar , tbd ); | 272 | addToolBar (viewToolBar , tbd ); |
273 | if ( p->mToolBarHorN ) { | 273 | if ( p->mToolBarHorN ) { |
274 | if ( p->mToolBarUpN ) | 274 | if ( p->mToolBarUpN ) |
275 | tbd = Bottom; | 275 | tbd = Bottom; |
276 | else | 276 | else |
277 | tbd = Top; | 277 | tbd = Top; |
278 | } | 278 | } |
279 | else { | 279 | else { |
280 | if ( p->mToolBarUpN ) | 280 | if ( p->mToolBarUpN ) |
281 | tbd = Right; | 281 | tbd = Right; |
282 | else | 282 | else |
283 | tbd = Left; | 283 | tbd = Left; |
284 | } | 284 | } |
285 | navigatorToolBar = new QPEToolBar( this ); | 285 | navigatorToolBar = new QPEToolBar( this ); |
286 | addToolBar (navigatorToolBar , tbd ); | 286 | addToolBar (navigatorToolBar , tbd ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | 290 | ||
291 | mCalendarModifiedFlag = false; | 291 | mCalendarModifiedFlag = false; |
292 | // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 292 | // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
293 | //splash->setAlignment ( AlignCenter ); | 293 | //splash->setAlignment ( AlignCenter ); |
294 | //setCentralWidget( splash ); | 294 | //setCentralWidget( splash ); |
295 | #ifndef DESKTOP_VERSION | 295 | #ifndef DESKTOP_VERSION |
296 | //showMaximized(); | 296 | //showMaximized(); |
297 | #endif | 297 | #endif |
298 | 298 | ||
299 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 299 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
300 | setDefaultPreferences(); | 300 | setDefaultPreferences(); |
301 | mCalendar = new CalendarLocal(); | 301 | mCalendar = new CalendarLocal(); |
302 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 302 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
303 | setCentralWidget( mView ); | 303 | setCentralWidget( mView ); |
304 | //mView->hide(); | 304 | //mView->hide(); |
305 | //mView->resize(splash->size() ); | 305 | //mView->resize(splash->size() ); |
306 | initActions(); | 306 | initActions(); |
307 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 307 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
308 | mSyncManager->setBlockSave(false); | 308 | mSyncManager->setBlockSave(false); |
309 | mView->setSyncManager(mSyncManager); | 309 | mView->setSyncManager(mSyncManager); |
310 | #ifndef DESKTOP_VERSION | 310 | #ifndef DESKTOP_VERSION |
311 | iconToolBar->show(); | 311 | iconToolBar->show(); |
312 | qApp->processEvents(); | 312 | qApp->processEvents(); |
313 | #endif | 313 | #endif |
314 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 314 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
315 | int vh = height() ; | 315 | int vh = height() ; |
316 | int vw = width(); | 316 | int vw = width(); |
317 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 317 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
318 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 318 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
319 | vh -= iconToolBar->height(); | 319 | vh -= iconToolBar->height(); |
320 | } else { | 320 | } else { |
321 | vw -= iconToolBar->height(); | 321 | vw -= iconToolBar->height(); |
322 | } | 322 | } |
323 | //mView->setMaximumSize( splash->size() ); | 323 | //mView->setMaximumSize( splash->size() ); |
324 | //mView->resize( splash->size() ); | 324 | //mView->resize( splash->size() ); |
325 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 325 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
326 | mView->readSettings(); | 326 | mView->readSettings(); |
327 | bool newFile = false; | 327 | bool newFile = false; |
328 | if( !QFile::exists( defaultFileName() ) ) { | 328 | if( !QFile::exists( defaultFileName() ) ) { |
329 | QFileInfo finfo ( defaultFileName() ); | 329 | QFileInfo finfo ( defaultFileName() ); |
330 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 330 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
331 | 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"; | 331 | 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 | finfo.setFile( oldFile ); | 332 | finfo.setFile( oldFile ); |
333 | if (finfo.exists() ) { | 333 | if (finfo.exists() ) { |
334 | KMessageBox::information( this, message); | 334 | KMessageBox::information( this, message); |
335 | mView->openCalendar( oldFile ); | 335 | mView->openCalendar( oldFile ); |
336 | qApp->processEvents(); | 336 | qApp->processEvents(); |
337 | } else { | 337 | } else { |
338 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 338 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
339 | finfo.setFile( oldFile ); | 339 | finfo.setFile( oldFile ); |
340 | if (finfo.exists() ) { | 340 | if (finfo.exists() ) { |
341 | KMessageBox::information( this, message); | 341 | KMessageBox::information( this, message); |
342 | mView->openCalendar( oldFile ); | 342 | mView->openCalendar( oldFile ); |
343 | qApp->processEvents(); | 343 | qApp->processEvents(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | mView->saveCalendar( defaultFileName() ); | 346 | mView->saveCalendar( defaultFileName() ); |
347 | newFile = true; | 347 | newFile = true; |
348 | } | 348 | } |
349 | 349 | ||
350 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); | 350 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); |
351 | //mView->loadCalendars(); | 351 | //mView->loadCalendars(); |
352 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 352 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
353 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 353 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
354 | 354 | ||
355 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 355 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
356 | KOPrefs::instance()->setAllDefaults(); | 356 | KOPrefs::instance()->setAllDefaults(); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 360 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
361 | SLOT( disableBR(bool) ) ); | 361 | SLOT( disableBR(bool) ) ); |
362 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 362 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
363 | setCentralWidget( mView ); | 363 | setCentralWidget( mView ); |
364 | globalFlagBlockStartup = 0; | 364 | globalFlagBlockStartup = 0; |
365 | //mView->show(); | 365 | //mView->show(); |
366 | //delete splash; | 366 | //delete splash; |
367 | if ( newFile ) | 367 | if ( newFile ) |
368 | mView->updateConfig(); | 368 | mView->updateConfig(); |
369 | // qApp->processEvents(); | 369 | // qApp->processEvents(); |
370 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 370 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
371 | //fillSyncMenu(); | 371 | //fillSyncMenu(); |
372 | 372 | ||
373 | 373 | ||
374 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 374 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
375 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 375 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
376 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 376 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
377 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 377 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
378 | mSyncManager->setDefaultFileName( sentSyncFile()); | 378 | mSyncManager->setDefaultFileName( sentSyncFile()); |
379 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 379 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
380 | mSyncManager->fillSyncMenu(); | 380 | mSyncManager->fillSyncMenu(); |
381 | 381 | ||
382 | 382 | ||
383 | 383 | ||
384 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 384 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
385 | if ( showWarning ) { | 385 | if ( showWarning ) { |
386 | KMessageBox::information( this, | 386 | KMessageBox::information( this, |
387 | "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"); | 387 | "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"); |
388 | qApp->processEvents(); | 388 | qApp->processEvents(); |
389 | mView->dialogManager()->showSyncOptions(); | 389 | mView->dialogManager()->showSyncOptions(); |
390 | } | 390 | } |
391 | 391 | ||
392 | //US listen for result adressed from Ka/Pi | 392 | //US listen for result adressed from Ka/Pi |
393 | 393 | ||
394 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
395 | infrared = 0; | 395 | infrared = 0; |
396 | #endif | 396 | #endif |
397 | updateFilterToolbar(); | 397 | updateFilterToolbar(); |
398 | updateWeek( mView->startDate() ); | 398 | updateWeek( mView->startDate() ); |
399 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 399 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
400 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 400 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
401 | mBRdisabled = false; | 401 | mBRdisabled = false; |
402 | //toggleBeamReceive(); | 402 | //toggleBeamReceive(); |
403 | 403 | ||
404 | setCaption(i18n("Loading calendar files ... please wait" )); | 404 | setCaption(i18n("Loading calendar files ... please wait" )); |
405 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); | 405 | mSaveDelay = 0; |
406 | QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); | ||
406 | } | 407 | } |
407 | MainWindow::~MainWindow() | 408 | MainWindow::~MainWindow() |
408 | { | 409 | { |
409 | //qDebug("MainWindow::~MainWindow() "); | 410 | //qDebug("MainWindow::~MainWindow() "); |
410 | //save toolbar location | 411 | //save toolbar location |
411 | delete mCalendar; | 412 | delete mCalendar; |
412 | delete mSyncManager; | 413 | delete mSyncManager; |
413 | #ifndef DESKTOP_VERSION | 414 | #ifndef DESKTOP_VERSION |
414 | if ( infrared ) | 415 | if ( infrared ) |
415 | delete infrared; | 416 | delete infrared; |
416 | #endif | 417 | #endif |
417 | 418 | ||
418 | 419 | ||
419 | } | 420 | } |
420 | 421 | ||
421 | void MainWindow::loadDataAfterStart() | 422 | void MainWindow::loadDataAfterStart() |
422 | { | 423 | { |
423 | 424 | ||
424 | qDebug("KO: Start loading files..." ); | 425 | qDebug("KO: Start loading files..." ); |
425 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 426 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
426 | mView->loadCalendars(); | 427 | mView->loadCalendars(); |
427 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 428 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
428 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 429 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
429 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 430 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
430 | mView->setModified( false ); | 431 | mView->setModified( false ); |
431 | mBlockAtStartup = false; | 432 | mBlockAtStartup = false; |
432 | mView->setModified( false ); | 433 | mView->setModified( false ); |
433 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 434 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
434 | processIncidenceSelection( 0 ); | 435 | processIncidenceSelection( 0 ); |
435 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 436 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
436 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 437 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
437 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 438 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
438 | SLOT( slotModifiedChanged( bool ) ) ); | 439 | SLOT( slotModifiedChanged( bool ) ) ); |
439 | 440 | ||
440 | #ifndef DESKTOP_VERSION | 441 | #ifndef DESKTOP_VERSION |
441 | 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 & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
442 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); | 443 | 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& ))); | 444 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); |
444 | if ( !mCStringMess.isEmpty() ) | 445 | if ( !mCStringMess.isEmpty() ) |
445 | recieve( mCStringMess, mByteData ); | 446 | recieve( mCStringMess, mByteData ); |
446 | #endif | 447 | #endif |
447 | 448 | ||
448 | 449 | ||
449 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 450 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
450 | } | 451 | } |
451 | 452 | ||
452 | void MainWindow::slotResetFocus() | 453 | void MainWindow::slotResetFocus() |
453 | { | 454 | { |
454 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); | 455 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); |
455 | mFocusLoop = 3; | 456 | mFocusLoop = 3; |
456 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 457 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
457 | } | 458 | } |
458 | void MainWindow::slotResetFocusLoop() | 459 | void MainWindow::slotResetFocusLoop() |
459 | { | 460 | { |
460 | --mFocusLoop; | 461 | --mFocusLoop; |
461 | QWidget* fw = mView->viewManager()->currentView(); | 462 | QWidget* fw = mView->viewManager()->currentView(); |
462 | if ( fw ) { | 463 | if ( fw ) { |
463 | //qDebug("loop "); | 464 | //qDebug("loop "); |
464 | fw->setFocus(); | 465 | fw->setFocus(); |
465 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) | 466 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) |
466 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 467 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
467 | } | 468 | } |
468 | 469 | ||
469 | } | 470 | } |
470 | void MainWindow::disableBR(bool b) | 471 | void MainWindow::disableBR(bool b) |
471 | { | 472 | { |
472 | #ifndef DESKTOP_VERSION | 473 | #ifndef DESKTOP_VERSION |
473 | if ( b ) { | 474 | if ( b ) { |
474 | if ( infrared ) { | 475 | if ( infrared ) { |
475 | toggleBeamReceive(); | 476 | toggleBeamReceive(); |
476 | mBRdisabled = true; | 477 | mBRdisabled = true; |
477 | } | 478 | } |
478 | mBRdisabled = true; | 479 | mBRdisabled = true; |
479 | } else { | 480 | } else { |
480 | if ( mBRdisabled ) { | 481 | if ( mBRdisabled ) { |
481 | mBRdisabled = false; | 482 | mBRdisabled = false; |
482 | //makes no sense,because other cal ap is probably running | 483 | //makes no sense,because other cal ap is probably running |
483 | // toggleBeamReceive(); | 484 | // toggleBeamReceive(); |
484 | } | 485 | } |
485 | } | 486 | } |
486 | #endif | 487 | #endif |
487 | 488 | ||
488 | } | 489 | } |
489 | bool MainWindow::beamReceiveEnabled() | 490 | bool MainWindow::beamReceiveEnabled() |
490 | { | 491 | { |
491 | #ifndef DESKTOP_VERSION | 492 | #ifndef DESKTOP_VERSION |
492 | return ( infrared != 0 ); | 493 | return ( infrared != 0 ); |
493 | #endif | 494 | #endif |
494 | return false; | 495 | return false; |
495 | } | 496 | } |
496 | 497 | ||
497 | void MainWindow::toggleBeamReceive() | 498 | void MainWindow::toggleBeamReceive() |
498 | { | 499 | { |
499 | if ( mBRdisabled ) | 500 | if ( mBRdisabled ) |
500 | return; | 501 | return; |
501 | #ifndef DESKTOP_VERSION | 502 | #ifndef DESKTOP_VERSION |
502 | if ( infrared ) { | 503 | if ( infrared ) { |
503 | qDebug("KO: Disable BeamReceive "); | 504 | qDebug("KO: Disable BeamReceive "); |
504 | delete infrared; | 505 | delete infrared; |
505 | infrared = 0; | 506 | infrared = 0; |
506 | brAction->setOn(false); | 507 | brAction->setOn(false); |
507 | return; | 508 | return; |
508 | } | 509 | } |
509 | qDebug("KO: Enable BeamReceive "); | 510 | qDebug("KO: Enable BeamReceive "); |
510 | brAction->setOn(true); | 511 | brAction->setOn(true); |
511 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 512 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
512 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 513 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
513 | #endif | 514 | #endif |
514 | } | 515 | } |
515 | void MainWindow::showMaximized () | 516 | void MainWindow::showMaximized () |
516 | { | 517 | { |
517 | #ifndef DESKTOP_VERSION | 518 | #ifndef DESKTOP_VERSION |
518 | if ( ! globalFlagBlockStartup ) | 519 | if ( ! globalFlagBlockStartup ) |
519 | if ( mClosed ) | 520 | if ( mClosed ) |
520 | mView->goToday(); | 521 | mView->goToday(); |
521 | #endif | 522 | #endif |
522 | QWidget::showMaximized () ; | 523 | QWidget::showMaximized () ; |
523 | mClosed = false; | 524 | mClosed = false; |
524 | } | 525 | } |
525 | void MainWindow::closeEvent( QCloseEvent* ce ) | 526 | void MainWindow::closeEvent( QCloseEvent* ce ) |
526 | { | 527 | { |
527 | 528 | ||
528 | 529 | ||
529 | 530 | ||
530 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 531 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
531 | saveOnClose(); | 532 | saveOnClose(); |
532 | if ( mCalendarModifiedFlag ) { | 533 | if ( mCalendarModifiedFlag ) { |
533 | ce->ignore(); | 534 | ce->ignore(); |
534 | return; | 535 | return; |
535 | } | 536 | } |
536 | mClosed = true; | 537 | mClosed = true; |
537 | ce->accept(); | 538 | ce->accept(); |
538 | return; | 539 | return; |
539 | 540 | ||
540 | } | 541 | } |
541 | 542 | ||
542 | switch( QMessageBox::information( this, "KO/Pi", | 543 | switch( QMessageBox::information( this, "KO/Pi", |
543 | i18n("Do you really want\nto close KO/Pi?"), | 544 | i18n("Do you really want\nto close KO/Pi?"), |
544 | i18n("Close"), i18n("No"), | 545 | i18n("Close"), i18n("No"), |
545 | 0, 0 ) ) { | 546 | 0, 0 ) ) { |
546 | case 0: | 547 | case 0: |
547 | saveOnClose(); | 548 | saveOnClose(); |
548 | if ( mCalendarModifiedFlag ) { | 549 | if ( mCalendarModifiedFlag ) { |
549 | ce->ignore(); | 550 | ce->ignore(); |
550 | return; | 551 | return; |
551 | } | 552 | } |
552 | mClosed = true; | 553 | mClosed = true; |
553 | ce->accept(); | 554 | ce->accept(); |
554 | break; | 555 | break; |
555 | case 1: | 556 | case 1: |
556 | ce->ignore(); | 557 | ce->ignore(); |
557 | break; | 558 | break; |
558 | case 2: | 559 | case 2: |
559 | 560 | ||
560 | default: | 561 | default: |
561 | break; | 562 | break; |
562 | } | 563 | } |
563 | 564 | ||
564 | 565 | ||
565 | } | 566 | } |
566 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) | 567 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) |
567 | { | 568 | { |
568 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | 569 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); |
569 | mCStringMess = cmsg; | 570 | mCStringMess = cmsg; |
570 | mByteData = data; | 571 | mByteData = data; |
571 | } | 572 | } |
572 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 573 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
573 | { | 574 | { |
574 | QDataStream stream( data, IO_ReadOnly ); | 575 | QDataStream stream( data, IO_ReadOnly ); |
575 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 576 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
576 | //QString datamess; | 577 | //QString datamess; |
577 | //qDebug("message "); | 578 | //qDebug("message "); |
578 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 579 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
579 | 580 | ||
580 | if ( cmsg == "setDocument(QString)" ) { | 581 | if ( cmsg == "setDocument(QString)" ) { |
581 | QDataStream stream( data, IO_ReadOnly ); | 582 | QDataStream stream( data, IO_ReadOnly ); |
582 | QString fileName; | 583 | QString fileName; |
583 | stream >> fileName; | 584 | stream >> fileName; |
584 | //qDebug("filename %s ", fileName.latin1()); | 585 | //qDebug("filename %s ", fileName.latin1()); |
585 | showMaximized(); | 586 | showMaximized(); |
586 | raise(); | 587 | raise(); |
587 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 588 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
588 | mSyncManager->slotSyncMenu( 1002 ); | 589 | mSyncManager->slotSyncMenu( 1002 ); |
589 | return; | 590 | return; |
590 | } | 591 | } |
591 | 592 | ||
592 | if ( cmsg == "-writeFile" ) { | 593 | if ( cmsg == "-writeFile" ) { |
593 | // I made from the "-writeFile" an "-writeAlarm" | 594 | // I made from the "-writeFile" an "-writeAlarm" |
594 | mView->viewManager()->showWhatsNextView(); | 595 | mView->viewManager()->showWhatsNextView(); |
595 | mCalendar->checkAlarmForIncidence( 0, true); | 596 | mCalendar->checkAlarmForIncidence( 0, true); |
596 | showMaximized(); | 597 | showMaximized(); |
597 | raise(); | 598 | raise(); |
598 | return; | 599 | return; |
599 | 600 | ||
600 | } | 601 | } |
601 | if ( cmsg == "-writeFileSilent" ) { | 602 | if ( cmsg == "-writeFileSilent" ) { |
602 | // I made from the "-writeFile" an "-writeAlarm" | 603 | // I made from the "-writeFile" an "-writeAlarm" |
603 | // mView->viewManager()->showWhatsNextView(); | 604 | // mView->viewManager()->showWhatsNextView(); |
604 | mCalendar->checkAlarmForIncidence( 0, true); | 605 | mCalendar->checkAlarmForIncidence( 0, true); |
605 | //showMaximized(); | 606 | //showMaximized(); |
606 | //raise(); | 607 | //raise(); |
607 | hide(); | 608 | hide(); |
608 | return; | 609 | return; |
609 | } | 610 | } |
610 | if ( cmsg == "-newCountdown" ) { | 611 | if ( cmsg == "-newCountdown" ) { |
611 | qDebug("newCountdown "); | 612 | qDebug("newCountdown "); |
612 | 613 | ||
613 | } | 614 | } |
614 | QString msg ; | 615 | QString msg ; |
615 | QString allmsg = cmsg; | 616 | QString allmsg = cmsg; |
616 | while ( allmsg.length() > 0 ) { | 617 | while ( allmsg.length() > 0 ) { |
617 | int nextC = allmsg.find( "-", 1 ); | 618 | int nextC = allmsg.find( "-", 1 ); |
618 | if ( nextC == -1 ) { | 619 | if ( nextC == -1 ) { |
619 | msg = allmsg; | 620 | msg = allmsg; |
620 | allmsg = ""; | 621 | allmsg = ""; |
621 | } else{ | 622 | } else{ |
622 | msg = allmsg.left( nextC ); | 623 | msg = allmsg.left( nextC ); |
623 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 624 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
624 | } | 625 | } |
625 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 626 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
626 | if ( msg == "-newEvent" ) { | 627 | if ( msg == "-newEvent" ) { |
627 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); | 628 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); |
628 | } | 629 | } |
629 | if ( msg == "-newTodo" ) { | 630 | if ( msg == "-newTodo" ) { |
630 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); | 631 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); |
631 | } | 632 | } |
632 | if ( msg == "-showWN" ) { | 633 | if ( msg == "-showWN" ) { |
633 | mView->viewManager()->showWhatsNextView(); | 634 | mView->viewManager()->showWhatsNextView(); |
634 | } | 635 | } |
635 | if ( msg == "-showTodo" ) { | 636 | if ( msg == "-showTodo" ) { |
636 | mView->viewManager()->showTodoView(); | 637 | mView->viewManager()->showTodoView(); |
637 | } | 638 | } |
638 | if ( msg == "-showList" ) { | 639 | if ( msg == "-showList" ) { |
639 | mView->viewManager()->showListView(); | 640 | mView->viewManager()->showListView(); |
640 | } | 641 | } |
641 | else if ( msg == "-showDay" ) { | 642 | else if ( msg == "-showDay" ) { |
642 | mView->viewManager()->showDayView(); | 643 | mView->viewManager()->showDayView(); |
643 | } | 644 | } |
644 | else if ( msg == "-showWWeek" ) { | 645 | else if ( msg == "-showWWeek" ) { |
645 | mView->viewManager()->showWorkWeekView(); | 646 | mView->viewManager()->showWorkWeekView(); |
646 | } | 647 | } |
647 | else if ( msg == "-ringSync" ) { | 648 | else if ( msg == "-ringSync" ) { |
648 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); | 649 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); |
649 | } | 650 | } |
650 | else if ( msg == "-showWeek" ) { | 651 | else if ( msg == "-showWeek" ) { |
651 | mView->viewManager()->showWeekView(); | 652 | mView->viewManager()->showWeekView(); |
652 | } | 653 | } |
653 | else if ( msg == "-showTodo" ) { | 654 | else if ( msg == "-showTodo" ) { |
654 | mView->viewManager()->showTodoView(); | 655 | mView->viewManager()->showTodoView(); |
655 | } | 656 | } |
656 | else if ( msg == "-showJournal" ) { | 657 | else if ( msg == "-showJournal" ) { |
657 | mView->dateNavigator()->selectDates( 1 ); | 658 | mView->dateNavigator()->selectDates( 1 ); |
658 | mView->dateNavigator()->selectToday(); | 659 | mView->dateNavigator()->selectToday(); |
659 | mView->viewManager()->showJournalView(); | 660 | mView->viewManager()->showJournalView(); |
660 | } | 661 | } |
661 | else if ( msg == "-showKO" ) { | 662 | else if ( msg == "-showKO" ) { |
662 | mView->viewManager()->showNextXView(); | 663 | mView->viewManager()->showNextXView(); |
663 | } | 664 | } |
664 | else if ( msg == "-showWNext" ) { | 665 | else if ( msg == "-showWNext" ) { |
665 | mView->viewManager()->showWhatsNextView(); | 666 | mView->viewManager()->showWhatsNextView(); |
666 | } | 667 | } |
667 | else if ( msg == "nextView()" ) { | 668 | else if ( msg == "nextView()" ) { |
668 | mView->viewManager()->showNextView(); | 669 | mView->viewManager()->showNextView(); |
669 | } | 670 | } |
670 | else if ( msg == "-showNextXView" ) { | 671 | else if ( msg == "-showNextXView" ) { |
671 | mView->viewManager()->showNextXView(); | 672 | mView->viewManager()->showNextXView(); |
672 | } | 673 | } |
673 | 674 | ||
674 | 675 | ||
675 | } | 676 | } |
676 | 677 | ||
677 | showMaximized(); | 678 | showMaximized(); |
678 | raise(); | 679 | raise(); |
679 | } | 680 | } |
680 | void MainWindow::startMultiSync() | 681 | void MainWindow::startMultiSync() |
681 | { | 682 | { |
682 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 683 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
683 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), | 684 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), |
684 | question, | 685 | question, |
685 | i18n("Yes"), i18n("No"), | 686 | i18n("Yes"), i18n("No"), |
686 | 0, 0 ) != 0 ) { | 687 | 0, 0 ) != 0 ) { |
687 | setCaption(i18n("Aborted! Nothing synced!")); | 688 | setCaption(i18n("Aborted! Nothing synced!")); |
688 | return; | 689 | return; |
689 | } | 690 | } |
690 | mSyncManager->multiSync( false ); | 691 | mSyncManager->multiSync( false ); |
691 | #ifndef DESKTOP_VERSION | 692 | #ifndef DESKTOP_VERSION |
692 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); | 693 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); |
693 | #endif | 694 | #endif |
694 | } | 695 | } |
695 | QPixmap MainWindow::loadPixmap( QString name ) | 696 | QPixmap MainWindow::loadPixmap( QString name ) |
696 | { | 697 | { |
697 | return SmallIcon( name ); | 698 | return SmallIcon( name ); |
698 | 699 | ||
699 | } | 700 | } |
700 | void MainWindow::setUsesBigPixmaps ( bool b ) | 701 | void MainWindow::setUsesBigPixmaps ( bool b ) |
701 | { | 702 | { |
702 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); | 703 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); |
703 | if ( b ) | 704 | if ( b ) |
704 | qDebug("KO: BigPixmaps are not supported "); | 705 | qDebug("KO: BigPixmaps are not supported "); |
705 | } | 706 | } |
706 | void MainWindow::initActions() | 707 | void MainWindow::initActions() |
707 | { | 708 | { |
708 | //KOPrefs::instance()->mShowFullMenu | 709 | //KOPrefs::instance()->mShowFullMenu |
709 | iconToolBar->clear(); | 710 | iconToolBar->clear(); |
710 | KOPrefs *p = KOPrefs::instance(); | 711 | KOPrefs *p = KOPrefs::instance(); |
711 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 712 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
712 | 713 | ||
713 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 714 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
714 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 715 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
715 | mCurrentItemMenu = new QPopupMenu ( this ); | 716 | mCurrentItemMenu = new QPopupMenu ( this ); |
716 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); | 717 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); |
717 | QPopupMenu *importMenu = new QPopupMenu( this ); | 718 | QPopupMenu *importMenu = new QPopupMenu( this ); |
718 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 719 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
719 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 720 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
720 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 721 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
721 | selectFilterMenu = new QPopupMenu( this ); | 722 | selectFilterMenu = new QPopupMenu( this ); |
722 | selectFilterMenu->setCheckable( true ); | 723 | selectFilterMenu->setCheckable( true ); |
723 | syncMenu = new QPopupMenu( this ); | 724 | syncMenu = new QPopupMenu( this ); |
724 | configureAgendaMenu = new QPopupMenu( this ); | 725 | configureAgendaMenu = new QPopupMenu( this ); |
725 | configureToolBarMenu = new QPopupMenu( this ); | 726 | configureToolBarMenu = new QPopupMenu( this ); |
726 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 727 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
727 | QIconSet icon; | 728 | QIconSet icon; |
728 | int pixWid = 22, pixHei = 22; | 729 | int pixWid = 22, pixHei = 22; |
729 | QString pathString = ""; | 730 | QString pathString = ""; |
730 | if ( !p->mToolBarMiniIcons ) { | 731 | if ( !p->mToolBarMiniIcons ) { |
731 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { | 732 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { |
732 | pathString += "icons16/"; | 733 | pathString += "icons16/"; |
733 | pixWid = 18; pixHei = 16; | 734 | pixWid = 18; pixHei = 16; |
734 | } | 735 | } |
735 | } else { | 736 | } else { |
736 | pathString += "iconsmini/"; | 737 | pathString += "iconsmini/"; |
737 | pixWid = 18; pixHei = 16; | 738 | pixWid = 18; pixHei = 16; |
738 | } | 739 | } |
739 | 740 | ||
740 | if ( KOPrefs::instance()->mShowFullMenu ) { | 741 | if ( KOPrefs::instance()->mShowFullMenu ) { |
741 | menuBar1 = new KMenuBar( this );//menuBar(); | 742 | menuBar1 = new KMenuBar( this );//menuBar(); |
742 | //setMenuBar( menuBar1 ); | 743 | //setMenuBar( menuBar1 ); |
743 | menuBar1->show(); | 744 | menuBar1->show(); |
744 | menuBar1->insertItem( i18n("File"), importMenu ); | 745 | menuBar1->insertItem( i18n("File"), importMenu ); |
745 | menuBar1->insertItem( i18n("View"), viewMenu ); | 746 | menuBar1->insertItem( i18n("View"), viewMenu ); |
746 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); | 747 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); |
747 | menuBar1->insertItem( i18n("Action"), actionMenu ); | 748 | menuBar1->insertItem( i18n("Action"), actionMenu ); |
748 | #ifdef DESKTOP_VERSION | 749 | #ifdef DESKTOP_VERSION |
749 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 750 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
750 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 751 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
751 | #else | 752 | #else |
752 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 753 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
753 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 754 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
754 | #endif | 755 | #endif |
755 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 756 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
756 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 757 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
757 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 758 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
758 | } else { | 759 | } else { |
759 | menuBar1 = new KMenuBar( iconToolBar ); | 760 | menuBar1 = new KMenuBar( iconToolBar ); |
760 | QPopupMenu *menuBar = new QPopupMenu( this ); | 761 | QPopupMenu *menuBar = new QPopupMenu( this ); |
761 | icon = loadPixmap( pathString + "z_menu" ); | 762 | icon = loadPixmap( pathString + "z_menu" ); |
762 | menuBar1->insertItem( icon.pixmap(), menuBar); | 763 | menuBar1->insertItem( icon.pixmap(), menuBar); |
763 | //menuBar1->insertItem( i18n("ME"), menuBar); | 764 | //menuBar1->insertItem( i18n("ME"), menuBar); |
764 | menuBar->insertItem( i18n("File"), importMenu ); | 765 | menuBar->insertItem( i18n("File"), importMenu ); |
765 | menuBar->insertItem( i18n("View"), viewMenu ); | 766 | menuBar->insertItem( i18n("View"), viewMenu ); |
766 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); | 767 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); |
767 | menuBar->insertItem( i18n("Action"), actionMenu ); | 768 | menuBar->insertItem( i18n("Action"), actionMenu ); |
768 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 769 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
769 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 770 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
770 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 771 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
771 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 772 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
772 | menuBar->insertItem( i18n("Help"), helpMenu ); | 773 | menuBar->insertItem( i18n("Help"), helpMenu ); |
773 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 774 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
774 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 775 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
775 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); | 776 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); |
776 | } | 777 | } |
777 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 778 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
778 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 779 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
779 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 780 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
780 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 781 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
781 | 782 | ||
782 | 783 | ||
783 | mWeekBgColor = iconToolBar->backgroundColor(); | 784 | mWeekBgColor = iconToolBar->backgroundColor(); |
784 | mWeekPixmap.resize( pixWid , pixHei ); | 785 | mWeekPixmap.resize( pixWid , pixHei ); |
785 | mWeekPixmap.fill( mWeekBgColor ); | 786 | mWeekPixmap.fill( mWeekBgColor ); |
786 | icon = mWeekPixmap; | 787 | icon = mWeekPixmap; |
787 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 788 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
788 | if ( p-> mShowIconWeekNum ) | 789 | if ( p-> mShowIconWeekNum ) |
789 | mWeekAction->addTo( iconToolBar ); | 790 | mWeekAction->addTo( iconToolBar ); |
790 | mWeekFont = font(); | 791 | mWeekFont = font(); |
791 | 792 | ||
792 | int fontPoint = mWeekFont.pointSize(); | 793 | int fontPoint = mWeekFont.pointSize(); |
793 | QFontMetrics f( mWeekFont ); | 794 | QFontMetrics f( mWeekFont ); |
794 | int fontWid = f.width( "30" ); | 795 | int fontWid = f.width( "30" ); |
795 | while ( fontWid > pixWid ) { | 796 | while ( fontWid > pixWid ) { |
796 | --fontPoint; | 797 | --fontPoint; |
797 | mWeekFont.setPointSize( fontPoint ); | 798 | mWeekFont.setPointSize( fontPoint ); |
798 | QFontMetrics f( mWeekFont ); | 799 | QFontMetrics f( mWeekFont ); |
799 | fontWid = f.width( "30" ); | 800 | fontWid = f.width( "30" ); |
800 | //qDebug("dec-- "); | 801 | //qDebug("dec-- "); |
801 | } | 802 | } |
802 | 803 | ||
803 | connect( mWeekAction, SIGNAL( activated() ), | 804 | connect( mWeekAction, SIGNAL( activated() ), |
804 | this, SLOT( weekAction() ) ); | 805 | this, SLOT( weekAction() ) ); |
805 | 806 | ||
806 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 807 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
807 | if ( p->mShowIconFilterview ) { | 808 | if ( p->mShowIconFilterview ) { |
808 | icon = loadPixmap( pathString + "filter" ); | 809 | icon = loadPixmap( pathString + "filter" ); |
809 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); | 810 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); |
810 | connect( actionFilterMenuTB, SIGNAL( activated() ), | 811 | connect( actionFilterMenuTB, SIGNAL( activated() ), |
811 | this, SLOT( fillFilterMenuTB() ) ); | 812 | this, SLOT( fillFilterMenuTB() ) ); |
812 | actionFilterMenuTB->addTo( iconToolBar ); | 813 | actionFilterMenuTB->addTo( iconToolBar ); |
813 | selectFilterMenuTB = new QPopupMenu( this ); | 814 | selectFilterMenuTB = new QPopupMenu( this ); |
814 | selectFilterMenuTB->setCheckable( true ); | 815 | selectFilterMenuTB->setCheckable( true ); |
815 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 816 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
816 | } | 817 | } |
817 | 818 | ||
818 | //#endif | 819 | //#endif |
819 | // ****************** | 820 | // ****************** |
820 | QAction *action; | 821 | QAction *action; |
821 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 822 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
822 | configureToolBarMenu->setCheckable( true ); | 823 | configureToolBarMenu->setCheckable( true ); |
823 | 824 | ||
824 | 825 | ||
825 | configureAgendaMenu->setCheckable( true ); | 826 | configureAgendaMenu->setCheckable( true ); |
826 | int iii ; | 827 | int iii ; |
827 | for ( iii = 1;iii<= 10 ;++iii ){ | 828 | for ( iii = 1;iii<= 10 ;++iii ){ |
828 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 829 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
829 | } | 830 | } |
830 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 831 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
831 | 832 | ||
832 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 833 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
833 | this, SLOT( showConfigureAgenda( ) ) ); | 834 | this, SLOT( showConfigureAgenda( ) ) ); |
834 | icon = loadPixmap( pathString + "today" ); | 835 | icon = loadPixmap( pathString + "today" ); |
835 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 836 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
836 | today_action->addTo( actionMenu ); | 837 | today_action->addTo( actionMenu ); |
837 | connect( today_action, SIGNAL( activated() ), | 838 | connect( today_action, SIGNAL( activated() ), |
838 | mView, SLOT( goToday() ) ); | 839 | mView, SLOT( goToday() ) ); |
839 | 840 | ||
840 | icon = loadPixmap( pathString + "picker" ); | 841 | icon = loadPixmap( pathString + "picker" ); |
841 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); | 842 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); |
842 | dPickerAction->addTo( actionMenu ); | 843 | dPickerAction->addTo( actionMenu ); |
843 | connect( dPickerAction, SIGNAL( activated() ), | 844 | connect( dPickerAction, SIGNAL( activated() ), |
844 | mView, SLOT( showDatePicker() ) ); | 845 | mView, SLOT( showDatePicker() ) ); |
845 | 846 | ||
846 | icon = loadPixmap( pathString + "search" ); | 847 | icon = loadPixmap( pathString + "search" ); |
847 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 848 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
848 | search_action->addTo( actionMenu ); | 849 | search_action->addTo( actionMenu ); |
849 | connect( search_action, SIGNAL( activated() ), | 850 | connect( search_action, SIGNAL( activated() ), |
850 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 851 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
851 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); | 852 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); |
852 | 853 | ||
853 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); | 854 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); |
854 | action->addTo( nextConflictMenu ); | 855 | action->addTo( nextConflictMenu ); |
855 | connect( action, SIGNAL( activated() ), | 856 | connect( action, SIGNAL( activated() ), |
856 | mView, SLOT( conflictAll() ) ); | 857 | mView, SLOT( conflictAll() ) ); |
857 | 858 | ||
858 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); | 859 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); |
859 | action->addTo( nextConflictMenu ); | 860 | action->addTo( nextConflictMenu ); |
860 | connect( action, SIGNAL( activated() ), | 861 | connect( action, SIGNAL( activated() ), |
861 | mView, SLOT( conflictAllday() ) ); | 862 | mView, SLOT( conflictAllday() ) ); |
862 | 863 | ||
863 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); | 864 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); |
864 | action->addTo( nextConflictMenu ); | 865 | action->addTo( nextConflictMenu ); |
865 | connect( action, SIGNAL( activated() ), | 866 | connect( action, SIGNAL( activated() ), |
866 | mView, SLOT( conflictNotAll() ) ); | 867 | mView, SLOT( conflictNotAll() ) ); |
867 | 868 | ||
868 | actionMenu->insertSeparator(); | 869 | actionMenu->insertSeparator(); |
869 | 870 | ||
870 | icon = loadPixmap( pathString + "newevent" ); | 871 | icon = loadPixmap( pathString + "newevent" ); |
871 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 872 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
872 | ne_action->addTo( mCurrentItemMenu ); | 873 | ne_action->addTo( mCurrentItemMenu ); |
873 | connect( ne_action, SIGNAL( activated() ), | 874 | connect( ne_action, SIGNAL( activated() ), |
874 | mView, SLOT( newEvent() ) ); | 875 | mView, SLOT( newEvent() ) ); |
875 | icon = loadPixmap( pathString + "newtodo" ); | 876 | icon = loadPixmap( pathString + "newtodo" ); |
876 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 877 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
877 | nt_action->addTo( mCurrentItemMenu ); | 878 | nt_action->addTo( mCurrentItemMenu ); |
878 | connect( nt_action, SIGNAL( activated() ), | 879 | connect( nt_action, SIGNAL( activated() ), |
879 | mView, SLOT( newTodo() ) ); | 880 | mView, SLOT( newTodo() ) ); |
880 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 881 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
881 | this ); | 882 | this ); |
882 | mNewSubTodoAction->addTo( mCurrentItemMenu ); | 883 | mNewSubTodoAction->addTo( mCurrentItemMenu ); |
883 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 884 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
884 | mView, SLOT( newSubTodo() ) ); | 885 | mView, SLOT( newSubTodo() ) ); |
885 | 886 | ||
886 | mCurrentItemMenu->insertSeparator(); | 887 | mCurrentItemMenu->insertSeparator(); |
887 | icon = loadPixmap( pathString + "newevent" ); | 888 | icon = loadPixmap( pathString + "newevent" ); |
888 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 889 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
889 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 890 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
890 | configureToolBarMenu->insertSeparator(); | 891 | configureToolBarMenu->insertSeparator(); |
891 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 892 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
892 | configureToolBarMenu->insertSeparator(); | 893 | configureToolBarMenu->insertSeparator(); |
893 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 894 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
894 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 895 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
895 | icon = loadPixmap( pathString + "newtodo" ); | 896 | icon = loadPixmap( pathString + "newtodo" ); |
896 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 897 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
897 | 898 | ||
898 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); | 899 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); |
899 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); | 900 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); |
900 | mShowAction->addTo( mCurrentItemMenu ); | 901 | mShowAction->addTo( mCurrentItemMenu ); |
901 | connect( mShowAction, SIGNAL( activated() ), | 902 | connect( mShowAction, SIGNAL( activated() ), |
902 | mView, SLOT( showIncidence() ) ); | 903 | mView, SLOT( showIncidence() ) ); |
903 | 904 | ||
904 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 905 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
905 | mEditAction->addTo( mCurrentItemMenu ); | 906 | mEditAction->addTo( mCurrentItemMenu ); |
906 | connect( mEditAction, SIGNAL( activated() ), | 907 | connect( mEditAction, SIGNAL( activated() ), |
907 | mView, SLOT( editIncidence() ) ); | 908 | mView, SLOT( editIncidence() ) ); |
908 | 909 | ||
909 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 910 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
910 | mDeleteAction->addTo( mCurrentItemMenu ); | 911 | mDeleteAction->addTo( mCurrentItemMenu ); |
911 | connect( mDeleteAction, SIGNAL( activated() ), | 912 | connect( mDeleteAction, SIGNAL( activated() ), |
912 | mView, SLOT( deleteIncidence() ) ); | 913 | mView, SLOT( deleteIncidence() ) ); |
913 | 914 | ||
914 | 915 | ||
915 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 916 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
916 | mCloneAction->addTo( mCurrentItemMenu ); | 917 | mCloneAction->addTo( mCurrentItemMenu ); |
917 | connect( mCloneAction, SIGNAL( activated() ), | 918 | connect( mCloneAction, SIGNAL( activated() ), |
918 | mView, SLOT( cloneIncidence() ) ); | 919 | mView, SLOT( cloneIncidence() ) ); |
919 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 920 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
920 | mMoveAction->addTo( mCurrentItemMenu ); | 921 | mMoveAction->addTo( mCurrentItemMenu ); |
921 | connect( mMoveAction, SIGNAL( activated() ), | 922 | connect( mMoveAction, SIGNAL( activated() ), |
922 | mView, SLOT( moveIncidence() ) ); | 923 | mView, SLOT( moveIncidence() ) ); |
923 | #ifndef DESKTOP_VERSION | 924 | #ifndef DESKTOP_VERSION |
924 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 925 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
925 | mBeamAction->addTo(mCurrentItemMenu ); | 926 | mBeamAction->addTo(mCurrentItemMenu ); |
926 | connect( mBeamAction, SIGNAL( activated() ), | 927 | connect( mBeamAction, SIGNAL( activated() ), |
927 | mView, SLOT( beamIncidence() ) ); | 928 | mView, SLOT( beamIncidence() ) ); |
928 | #endif | 929 | #endif |
929 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 930 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
930 | mCancelAction->addTo( mCurrentItemMenu ); | 931 | mCancelAction->addTo( mCurrentItemMenu ); |
931 | connect( mCancelAction, SIGNAL( activated() ), | 932 | connect( mCancelAction, SIGNAL( activated() ), |
932 | mView, SLOT( toggleCancelIncidence() ) ); | 933 | mView, SLOT( toggleCancelIncidence() ) ); |
933 | 934 | ||
934 | 935 | ||
935 | mCurrentItemMenu->insertSeparator(); | 936 | mCurrentItemMenu->insertSeparator(); |
936 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 937 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
937 | action->addTo( mCurrentItemMenu ); | 938 | action->addTo( mCurrentItemMenu ); |
938 | connect( action, SIGNAL( activated() ), | 939 | connect( action, SIGNAL( activated() ), |
939 | mView, SLOT( undo_delete() ) ); | 940 | mView, SLOT( undo_delete() ) ); |
940 | 941 | ||
941 | // *********************** | 942 | // *********************** |
942 | if ( KOPrefs::instance()->mVerticalScreen ) { | 943 | if ( KOPrefs::instance()->mVerticalScreen ) { |
943 | icon = SmallIcon( "1updownarrow" ); | 944 | icon = SmallIcon( "1updownarrow" ); |
944 | } else { | 945 | } else { |
945 | icon = SmallIcon("1leftrightarrow" ); | 946 | icon = SmallIcon("1leftrightarrow" ); |
946 | } | 947 | } |
947 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); | 948 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); |
948 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); | 949 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); |
949 | FSaction->addTo( viewMenu ); | 950 | FSaction->addTo( viewMenu ); |
950 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); | 951 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); |
951 | 952 | ||
952 | 953 | ||
953 | icon = loadPixmap( pathString + "filter" ); | 954 | icon = loadPixmap( pathString + "filter" ); |
954 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); | 955 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); |
955 | icon = loadPixmap( pathString + "configure" ); | 956 | icon = loadPixmap( pathString + "configure" ); |
956 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); | 957 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); |
957 | action->addTo( viewMenu ); | 958 | action->addTo( viewMenu ); |
958 | connect( action, SIGNAL( activated() ), | 959 | connect( action, SIGNAL( activated() ), |
959 | mView, SLOT( toggleFilter() ) ); | 960 | mView, SLOT( toggleFilter() ) ); |
960 | mToggleFilter = action; | 961 | mToggleFilter = action; |
961 | icon = loadPixmap( pathString + "navi" ); | 962 | icon = loadPixmap( pathString + "navi" ); |
962 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | 963 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); |
963 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 964 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
964 | action->addTo( viewMenu ); | 965 | action->addTo( viewMenu ); |
965 | connect( action, SIGNAL( activated() ), | 966 | connect( action, SIGNAL( activated() ), |
966 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 967 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
967 | mToggleNav = action ; | 968 | mToggleNav = action ; |
968 | icon = loadPixmap( pathString + "allday" ); | 969 | icon = loadPixmap( pathString + "allday" ); |
969 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); | 970 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); |
970 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 971 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
971 | action->addTo( viewMenu ); | 972 | action->addTo( viewMenu ); |
972 | connect( action, SIGNAL( activated() ), | 973 | connect( action, SIGNAL( activated() ), |
973 | mView, SLOT( toggleAllDaySize() ) ); | 974 | mView, SLOT( toggleAllDaySize() ) ); |
974 | mToggleAllday = action; | 975 | mToggleAllday = action; |
975 | 976 | ||
976 | 977 | ||
977 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 978 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
978 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 979 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
979 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 980 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
980 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 981 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
981 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 982 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
982 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 983 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
983 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 984 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
984 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); | 985 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); |
985 | 986 | ||
986 | 987 | ||
987 | dPickerAction->addTo( iconToolBar ); | 988 | dPickerAction->addTo( iconToolBar ); |
988 | viewMenu->insertSeparator(); | 989 | viewMenu->insertSeparator(); |
989 | 990 | ||
990 | if ( p-> mShowIconToggleFull ) | 991 | if ( p-> mShowIconToggleFull ) |
991 | FSaction->addTo( iconToolBar ); | 992 | FSaction->addTo( iconToolBar ); |
992 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); | 993 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); |
993 | 994 | ||
994 | //******************** | 995 | //******************** |
995 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); | 996 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); |
996 | 997 | ||
997 | 998 | ||
998 | icon = loadPixmap( pathString + "whatsnext" ); | 999 | icon = loadPixmap( pathString + "whatsnext" ); |
999 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 1000 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
1000 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 1001 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
1001 | whatsnext_action->addTo( viewMenu ); | 1002 | whatsnext_action->addTo( viewMenu ); |
1002 | connect( whatsnext_action, SIGNAL( activated() ), | 1003 | connect( whatsnext_action, SIGNAL( activated() ), |
1003 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 1004 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
1004 | 1005 | ||
1005 | icon = loadPixmap( pathString + "xdays" ); | 1006 | icon = loadPixmap( pathString + "xdays" ); |
1006 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 1007 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
1007 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 1008 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
1008 | xdays_action->addTo( viewMenu ); | 1009 | xdays_action->addTo( viewMenu ); |
1009 | connect( xdays_action, SIGNAL( activated() ), | 1010 | connect( xdays_action, SIGNAL( activated() ), |
1010 | mView->viewManager(), SLOT( showNextXView() ) ); | 1011 | mView->viewManager(), SLOT( showNextXView() ) ); |
1011 | 1012 | ||
1012 | 1013 | ||
1013 | icon = loadPixmap( pathString + "journal" ); | 1014 | icon = loadPixmap( pathString + "journal" ); |
1014 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 1015 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
1015 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 1016 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
1016 | viewjournal_action->addTo( viewMenu ); | 1017 | viewjournal_action->addTo( viewMenu ); |
1017 | connect( viewjournal_action, SIGNAL( activated() ), | 1018 | connect( viewjournal_action, SIGNAL( activated() ), |
1018 | mView->viewManager(), SLOT( showJournalView() ) ); | 1019 | mView->viewManager(), SLOT( showJournalView() ) ); |
1019 | 1020 | ||
1020 | 1021 | ||
1021 | icon = loadPixmap( pathString + "day" ); | 1022 | icon = loadPixmap( pathString + "day" ); |
1022 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 1023 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
1023 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 1024 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
1024 | day1_action->addTo( viewMenu ); | 1025 | day1_action->addTo( viewMenu ); |
1025 | // action->addTo( toolBar ); | 1026 | // action->addTo( toolBar ); |
1026 | connect( day1_action, SIGNAL( activated() ), | 1027 | connect( day1_action, SIGNAL( activated() ), |
1027 | mView->viewManager(), SLOT( showDayView() ) ); | 1028 | mView->viewManager(), SLOT( showDayView() ) ); |
1028 | 1029 | ||
1029 | icon = loadPixmap( pathString + "workweek" ); | 1030 | icon = loadPixmap( pathString + "workweek" ); |
1030 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 1031 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
1031 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 1032 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
1032 | day5_action->addTo( viewMenu ); | 1033 | day5_action->addTo( viewMenu ); |
1033 | connect( day5_action, SIGNAL( activated() ), | 1034 | connect( day5_action, SIGNAL( activated() ), |
1034 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 1035 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
1035 | 1036 | ||
1036 | icon = loadPixmap( pathString + "week" ); | 1037 | icon = loadPixmap( pathString + "week" ); |
1037 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 1038 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
1038 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 1039 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
1039 | day7_action->addTo( viewMenu ); | 1040 | day7_action->addTo( viewMenu ); |
1040 | connect( day7_action, SIGNAL( activated() ), | 1041 | connect( day7_action, SIGNAL( activated() ), |
1041 | mView->viewManager(), SLOT( showWeekView() ) ); | 1042 | mView->viewManager(), SLOT( showWeekView() ) ); |
1042 | 1043 | ||
1043 | icon = loadPixmap( pathString + "workweek2" ); | 1044 | icon = loadPixmap( pathString + "workweek2" ); |
1044 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 1045 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
1045 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 1046 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
1046 | day6_action->addTo( viewMenu ); | 1047 | day6_action->addTo( viewMenu ); |
1047 | connect( day6_action, SIGNAL( activated() ), | 1048 | connect( day6_action, SIGNAL( activated() ), |
1048 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 1049 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
1049 | 1050 | ||
1050 | icon = loadPixmap( pathString + "month" ); | 1051 | icon = loadPixmap( pathString + "month" ); |
1051 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 1052 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
1052 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 1053 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
1053 | month_action->addTo( viewMenu ); | 1054 | month_action->addTo( viewMenu ); |
1054 | connect( month_action, SIGNAL( activated() ), | 1055 | connect( month_action, SIGNAL( activated() ), |
1055 | mView->viewManager(), SLOT( showMonthView() ) ); | 1056 | mView->viewManager(), SLOT( showMonthView() ) ); |
1056 | 1057 | ||
1057 | icon = loadPixmap( pathString + "list" ); | 1058 | icon = loadPixmap( pathString + "list" ); |
1058 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 1059 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
1059 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 1060 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
1060 | showlist_action->addTo( viewMenu ); | 1061 | showlist_action->addTo( viewMenu ); |
1061 | connect( showlist_action, SIGNAL( activated() ), | 1062 | connect( showlist_action, SIGNAL( activated() ), |
1062 | mView->viewManager(), SLOT( showListView() ) ); | 1063 | mView->viewManager(), SLOT( showListView() ) ); |
1063 | 1064 | ||
1064 | icon = loadPixmap( pathString + "todo" ); | 1065 | icon = loadPixmap( pathString + "todo" ); |
1065 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 1066 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
1066 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 1067 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
1067 | todoview_action->addTo( viewMenu ); | 1068 | todoview_action->addTo( viewMenu ); |
1068 | connect( todoview_action, SIGNAL( activated() ), | 1069 | connect( todoview_action, SIGNAL( activated() ), |
1069 | mView->viewManager(), SLOT( showTodoView() ) ); | 1070 | mView->viewManager(), SLOT( showTodoView() ) ); |
1070 | 1071 | ||
1071 | 1072 | ||
1072 | 1073 | ||
1073 | #if 0 | 1074 | #if 0 |
1074 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 1075 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
1075 | action->addTo( viewMenu ); | 1076 | action->addTo( viewMenu ); |
1076 | connect( action, SIGNAL( activated() ), | 1077 | connect( action, SIGNAL( activated() ), |
1077 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 1078 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
1078 | #endif | 1079 | #endif |
1079 | 1080 | ||
1080 | 1081 | ||
1081 | 1082 | ||
1082 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, | 1083 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, |
1083 | this ); | 1084 | this ); |
1084 | action->addTo( actionMenu ); | 1085 | action->addTo( actionMenu ); |
1085 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 1086 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
1086 | 1087 | ||
1087 | 1088 | ||
1088 | icon = loadPixmap( pathString + "search" ); | 1089 | icon = loadPixmap( pathString + "search" ); |
1089 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 1090 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
1090 | 1091 | ||
1091 | 1092 | ||
1092 | 1093 | ||
1093 | actionMenu->insertSeparator(); | 1094 | actionMenu->insertSeparator(); |
1094 | action = new QAction( "manage cat", i18n("Edit category list..."), 0, | 1095 | action = new QAction( "manage cat", i18n("Edit category list..."), 0, |
1095 | this ); | 1096 | this ); |
1096 | action->addTo( actionMenu ); | 1097 | action->addTo( actionMenu ); |
1097 | connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); | 1098 | connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); |
1098 | 1099 | ||
1099 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1100 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1100 | this ); | 1101 | this ); |
1101 | action->addTo( actionMenu ); | 1102 | action->addTo( actionMenu ); |
1102 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1103 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1103 | 1104 | ||
1104 | 1105 | ||
1105 | actionMenu->insertSeparator(); | 1106 | actionMenu->insertSeparator(); |
1106 | icon = loadPixmap( pathString + "configure" ); | 1107 | icon = loadPixmap( pathString + "configure" ); |
1107 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); | 1108 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); |
1108 | action->addTo( actionMenu ); | 1109 | action->addTo( actionMenu ); |
1109 | connect( action, SIGNAL( activated() ), | 1110 | connect( action, SIGNAL( activated() ), |
1110 | mView, SLOT( edit_options() ) ); | 1111 | mView, SLOT( edit_options() ) ); |
1111 | action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); | 1112 | action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); |
1112 | action->addTo( actionMenu ); | 1113 | action->addTo( actionMenu ); |
1113 | connect( action, SIGNAL( activated() ), | 1114 | connect( action, SIGNAL( activated() ), |
1114 | this, SLOT( calHint() ) ); | 1115 | this, SLOT( calHint() ) ); |
1115 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); | 1116 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); |
1116 | action->addTo( actionMenu ); | 1117 | action->addTo( actionMenu ); |
1117 | connect( action, SIGNAL( activated() ), | 1118 | connect( action, SIGNAL( activated() ), |
1118 | mView, SLOT( edit_global_options() ) ); | 1119 | mView, SLOT( edit_global_options() ) ); |
1119 | if ( KOPrefs::instance()->mShowFullMenu ) { | 1120 | if ( KOPrefs::instance()->mShowFullMenu ) { |
1120 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 1121 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
1121 | 1122 | ||
1122 | } | 1123 | } |
1123 | // actionMenu->insertSeparator(); | 1124 | // actionMenu->insertSeparator(); |
1124 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 1125 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
1125 | this ); | 1126 | this ); |
1126 | action->addTo( importMenu_X ); | 1127 | action->addTo( importMenu_X ); |
1127 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 1128 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
1128 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 1129 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
1129 | this ); | 1130 | this ); |
1130 | action->addTo( importMenu_X ); | 1131 | action->addTo( importMenu_X ); |
1131 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 1132 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
1132 | importMenu_X->insertSeparator(); | 1133 | importMenu_X->insertSeparator(); |
1133 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 1134 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
1134 | this ); | 1135 | this ); |
1135 | action->addTo( importMenu_X ); | 1136 | action->addTo( importMenu_X ); |
1136 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 1137 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
1137 | //#ifndef DESKTOP_VERSION | 1138 | //#ifndef DESKTOP_VERSION |
1138 | importMenu_X->insertSeparator(); | 1139 | importMenu_X->insertSeparator(); |
1139 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 1140 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
1140 | this ); | 1141 | this ); |
1141 | action->addTo( importMenu_X ); | 1142 | action->addTo( importMenu_X ); |
1142 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 1143 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
1143 | //#else | 1144 | //#else |
1144 | #ifdef _OL_IMPORT_ | 1145 | #ifdef _OL_IMPORT_ |
1145 | importMenu_X->insertSeparator(); | 1146 | importMenu_X->insertSeparator(); |
1146 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 1147 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
1147 | this ); | 1148 | this ); |
1148 | action->addTo( importMenu_X ); | 1149 | action->addTo( importMenu_X ); |
1149 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 1150 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
1150 | #endif | 1151 | #endif |
1151 | //#endif | 1152 | //#endif |
1152 | 1153 | ||
1153 | //importMenu->insertSeparator(); | 1154 | //importMenu->insertSeparator(); |
1154 | #if 0 | 1155 | #if 0 |
1155 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 1156 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
1156 | this ); | 1157 | this ); |
1157 | action->addTo( importMenu ); | 1158 | action->addTo( importMenu ); |
1158 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 1159 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
1159 | #endif | 1160 | #endif |
1160 | action = new QAction( "save_cal", i18n("Save Backup..."), 0, | 1161 | action = new QAction( "save_cal", i18n("Save Backup..."), 0, |
1161 | this ); | 1162 | this ); |
1162 | action->addTo( importMenu ); | 1163 | action->addTo( importMenu ); |
1163 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 1164 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
1164 | importMenu->insertSeparator(); | 1165 | importMenu->insertSeparator(); |
1165 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 1166 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
1166 | //importMenu->insertSeparator(); | 1167 | //importMenu->insertSeparator(); |
1167 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 1168 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
1168 | this ); | 1169 | this ); |
1169 | action->addTo( exportMenu_X ); | 1170 | action->addTo( exportMenu_X ); |
1170 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 1171 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
1171 | 1172 | ||
1172 | 1173 | ||
1173 | //LR | 1174 | //LR |
1174 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 1175 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
1175 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1176 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1176 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1177 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1177 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 1178 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
1178 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 1179 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
1179 | 1180 | ||
1180 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 1181 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
1181 | mPrintSelAction = 0; | 1182 | mPrintSelAction = 0; |
1182 | #ifndef DESKTOP_VERSION | 1183 | #ifndef DESKTOP_VERSION |
1183 | //importMenu->insertSeparator(); | 1184 | //importMenu->insertSeparator(); |
1184 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 1185 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
1185 | this ); | 1186 | this ); |
1186 | brAction->addTo( beamMenu_X ); | 1187 | brAction->addTo( beamMenu_X ); |
1187 | brAction->setToggleAction (true ) ; | 1188 | brAction->setToggleAction (true ) ; |
1188 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 1189 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
1189 | 1190 | ||
1190 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 1191 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
1191 | this ); | 1192 | this ); |
1192 | action->addTo( beamMenu_X ); | 1193 | action->addTo( beamMenu_X ); |
1193 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 1194 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
1194 | 1195 | ||
1195 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 1196 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
1196 | this ); | 1197 | this ); |
1197 | action->addTo( beamMenu_X ); | 1198 | action->addTo( beamMenu_X ); |
1198 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 1199 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
1199 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 1200 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
1200 | #else | 1201 | #else |
1201 | //importMenu->insertSeparator(); | 1202 | //importMenu->insertSeparator(); |
1202 | icon = loadPixmap( pathString + "print" ); | 1203 | icon = loadPixmap( pathString + "print" ); |
1203 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 1204 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
1204 | action->addTo( beamMenu_X ); | 1205 | action->addTo( beamMenu_X ); |
1205 | connect( action, SIGNAL( activated() ), | 1206 | connect( action, SIGNAL( activated() ), |
1206 | this, SLOT( printCal() ) ); | 1207 | this, SLOT( printCal() ) ); |
1207 | 1208 | ||
1208 | icon = loadPixmap( pathString + "week" ); | 1209 | icon = loadPixmap( pathString + "week" ); |
1209 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 1210 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
1210 | action->addTo( beamMenu_X ); | 1211 | action->addTo( beamMenu_X ); |
1211 | connect( action, SIGNAL( activated() ), | 1212 | connect( action, SIGNAL( activated() ), |
1212 | this, SLOT( printSel() ) ); | 1213 | this, SLOT( printSel() ) ); |
1213 | icon = loadPixmap( pathString + "whatsnext" ); | 1214 | icon = loadPixmap( pathString + "whatsnext" ); |
1214 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 1215 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
1215 | action->addTo( beamMenu_X ); | 1216 | action->addTo( beamMenu_X ); |
1216 | connect( action, SIGNAL( activated() ), | 1217 | connect( action, SIGNAL( activated() ), |
1217 | mView->viewManager(), SLOT( slotprintWNV() ) ); | 1218 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1218 | 1219 | ||
1219 | 1220 | ||
1220 | icon = loadPixmap( pathString + "list" ); | 1221 | icon = loadPixmap( pathString + "list" ); |
1221 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); | 1222 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); |
1222 | action->addTo( beamMenu_X ); | 1223 | action->addTo( beamMenu_X ); |
1223 | connect( action, SIGNAL( activated() ), | 1224 | connect( action, SIGNAL( activated() ), |
1224 | this, SLOT( printListView() ) ); | 1225 | this, SLOT( printListView() ) ); |
1225 | 1226 | ||
1226 | icon = loadPixmap( pathString + "newevent" ); | 1227 | icon = loadPixmap( pathString + "newevent" ); |
1227 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | 1228 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); |
1228 | action->addTo( beamMenu_X ); | 1229 | action->addTo( beamMenu_X ); |
1229 | connect( action, SIGNAL( activated() ), | 1230 | connect( action, SIGNAL( activated() ), |
1230 | mView, SLOT( slotprintSelInc() ) ); | 1231 | mView, SLOT( slotprintSelInc() ) ); |
1231 | mPrintSelAction = action; | 1232 | mPrintSelAction = action; |
1232 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1233 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
1233 | #endif | 1234 | #endif |
1234 | 1235 | ||
1235 | importMenu->insertSeparator(); | 1236 | importMenu->insertSeparator(); |
1236 | action = new QAction( "beam all", i18n("Save"), 0, | 1237 | action = new QAction( "beam all", i18n("Save"), 0, |
1237 | this ); | 1238 | this ); |
1238 | action->addTo( importMenu ); | 1239 | action->addTo( importMenu ); |
1239 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1240 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1240 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1241 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1241 | this ); | 1242 | this ); |
1242 | action->addTo( importMenu ); | 1243 | action->addTo( importMenu ); |
1243 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1244 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1244 | 1245 | ||
1245 | //menuBar->insertItem( "Configure",configureMenu ); | 1246 | //menuBar->insertItem( "Configure",configureMenu ); |
1246 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1247 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1247 | icon = loadPixmap( "korganizer/korganizer" ); | 1248 | icon = loadPixmap( "korganizer/korganizer" ); |
1248 | 1249 | ||
1249 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1250 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1250 | action->addTo( helpMenu ); | 1251 | action->addTo( helpMenu ); |
1251 | connect( action, SIGNAL( activated() ), | 1252 | connect( action, SIGNAL( activated() ), |
1252 | SLOT( whatsNew() ) ); | 1253 | SLOT( whatsNew() ) ); |
1253 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1254 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1254 | action->addTo( helpMenu ); | 1255 | action->addTo( helpMenu ); |
1255 | connect( action, SIGNAL( activated() ), | 1256 | connect( action, SIGNAL( activated() ), |
1256 | SLOT( features() ) ); | 1257 | SLOT( features() ) ); |
1257 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1258 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1258 | action->addTo( helpMenu ); | 1259 | action->addTo( helpMenu ); |
1259 | connect( action, SIGNAL( activated() ), | 1260 | connect( action, SIGNAL( activated() ), |
1260 | SLOT( keyBindings() ) ); | 1261 | SLOT( keyBindings() ) ); |
1261 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); | 1262 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); |
1262 | action->addTo( helpMenu ); | 1263 | action->addTo( helpMenu ); |
1263 | connect( action, SIGNAL( activated() ), | 1264 | connect( action, SIGNAL( activated() ), |
1264 | SLOT( storagehowto() ) ); | 1265 | SLOT( storagehowto() ) ); |
1265 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); | 1266 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); |
1266 | action->addTo( helpMenu ); | 1267 | action->addTo( helpMenu ); |
1267 | connect( action, SIGNAL( activated() ), | 1268 | connect( action, SIGNAL( activated() ), |
1268 | SLOT( timetrackinghowto() ) ); | 1269 | SLOT( timetrackinghowto() ) ); |
1269 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1270 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1270 | action->addTo( helpMenu ); | 1271 | action->addTo( helpMenu ); |
1271 | connect( action, SIGNAL( activated() ), | 1272 | connect( action, SIGNAL( activated() ), |
1272 | SLOT( synchowto() ) ); | 1273 | SLOT( synchowto() ) ); |
1273 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1274 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1274 | action->addTo( helpMenu ); | 1275 | action->addTo( helpMenu ); |
1275 | connect( action, SIGNAL( activated() ), | 1276 | connect( action, SIGNAL( activated() ), |
1276 | SLOT( kdesynchowto() ) ); | 1277 | SLOT( kdesynchowto() ) ); |
1277 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1278 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1278 | action->addTo( helpMenu ); | 1279 | action->addTo( helpMenu ); |
1279 | connect( action, SIGNAL( activated() ), | 1280 | connect( action, SIGNAL( activated() ), |
1280 | SLOT( multisynchowto() ) ); | 1281 | SLOT( multisynchowto() ) ); |
1281 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1282 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1282 | action->addTo( helpMenu ); | 1283 | action->addTo( helpMenu ); |
1283 | connect( action, SIGNAL( activated() ), | 1284 | connect( action, SIGNAL( activated() ), |
1284 | SLOT( aboutAutoSaving() ) ); | 1285 | SLOT( aboutAutoSaving() ) ); |
1285 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1286 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1286 | action->addTo( helpMenu ); | 1287 | action->addTo( helpMenu ); |
1287 | connect( action, SIGNAL( activated() ), | 1288 | connect( action, SIGNAL( activated() ), |
1288 | SLOT( aboutKnownBugs() ) ); | 1289 | SLOT( aboutKnownBugs() ) ); |
1289 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1290 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1290 | action->addTo( helpMenu ); | 1291 | action->addTo( helpMenu ); |
1291 | connect( action, SIGNAL( activated() ), | 1292 | connect( action, SIGNAL( activated() ), |
1292 | SLOT( usertrans() ) ); | 1293 | SLOT( usertrans() ) ); |
1293 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1294 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1294 | action->addTo( helpMenu ); | 1295 | action->addTo( helpMenu ); |
1295 | connect( action, SIGNAL( activated() ), | 1296 | connect( action, SIGNAL( activated() ), |
1296 | SLOT( faq() ) ); | 1297 | SLOT( faq() ) ); |
1297 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1298 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1298 | action->addTo( helpMenu ); | 1299 | action->addTo( helpMenu ); |
1299 | connect( action, SIGNAL( activated() ), | 1300 | connect( action, SIGNAL( activated() ), |
1300 | SLOT( licence() ) ); | 1301 | SLOT( licence() ) ); |
1301 | action = new QAction( "about", i18n("About..."), 0, this ); | 1302 | action = new QAction( "about", i18n("About..."), 0, this ); |
1302 | action->addTo( helpMenu ); | 1303 | action->addTo( helpMenu ); |
1303 | connect( action, SIGNAL( activated() ), | 1304 | connect( action, SIGNAL( activated() ), |
1304 | SLOT( about() ) ); | 1305 | SLOT( about() ) ); |
1305 | //menuBar->insertSeparator(); | 1306 | //menuBar->insertSeparator(); |
1306 | 1307 | ||
1307 | // ****************************************************** | 1308 | // ****************************************************** |
1308 | // menubar icons | 1309 | // menubar icons |
1309 | 1310 | ||
1310 | 1311 | ||
1311 | 1312 | ||
1312 | //menuBar->insertItem( iconToolBar ); | 1313 | //menuBar->insertItem( iconToolBar ); |
1313 | //xdays_action | 1314 | //xdays_action |
1314 | if (p-> mShowIconNewEvent) | 1315 | if (p-> mShowIconNewEvent) |
1315 | ne_action->addTo( iconToolBar ); | 1316 | ne_action->addTo( iconToolBar ); |
1316 | if (p->mShowIconNewTodo ) | 1317 | if (p->mShowIconNewTodo ) |
1317 | nt_action->addTo( iconToolBar ); | 1318 | nt_action->addTo( iconToolBar ); |
1318 | if (p-> mShowIconSearch) | 1319 | if (p-> mShowIconSearch) |
1319 | search_action->addTo( iconToolBar ); | 1320 | search_action->addTo( iconToolBar ); |
1320 | if (p-> mShowIconWhatsThis) | 1321 | if (p-> mShowIconWhatsThis) |
1321 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1322 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1322 | if (p-> mShowIconNext) | 1323 | if (p-> mShowIconNext) |
1323 | whatsnext_action->addTo( viewToolBar ); | 1324 | whatsnext_action->addTo( viewToolBar ); |
1324 | if (p-> mShowIconNextDays) | 1325 | if (p-> mShowIconNextDays) |
1325 | xdays_action->addTo( viewToolBar ); | 1326 | xdays_action->addTo( viewToolBar ); |
1326 | if (p-> mShowIconJournal) | 1327 | if (p-> mShowIconJournal) |
1327 | viewjournal_action->addTo( viewToolBar ); | 1328 | viewjournal_action->addTo( viewToolBar ); |
1328 | if (p-> mShowIconDay1) | 1329 | if (p-> mShowIconDay1) |
1329 | day1_action->addTo( viewToolBar ); | 1330 | day1_action->addTo( viewToolBar ); |
1330 | if (p-> mShowIconDay5) | 1331 | if (p-> mShowIconDay5) |
1331 | day5_action->addTo( viewToolBar ); | 1332 | day5_action->addTo( viewToolBar ); |
1332 | if (p-> mShowIconDay7) | 1333 | if (p-> mShowIconDay7) |
1333 | day7_action->addTo( viewToolBar ); | 1334 | day7_action->addTo( viewToolBar ); |
1334 | if (p-> mShowIconDay6) | 1335 | if (p-> mShowIconDay6) |
1335 | day6_action->addTo( viewToolBar ); | 1336 | day6_action->addTo( viewToolBar ); |
1336 | if (p-> mShowIconMonth) | 1337 | if (p-> mShowIconMonth) |
1337 | month_action->addTo( viewToolBar ); | 1338 | month_action->addTo( viewToolBar ); |
1338 | if (p-> mShowIconList) | 1339 | if (p-> mShowIconList) |
1339 | showlist_action->addTo( viewToolBar ); | 1340 | showlist_action->addTo( viewToolBar ); |
1340 | if (p-> mShowIconTodoview) | 1341 | if (p-> mShowIconTodoview) |
1341 | todoview_action->addTo( viewToolBar ); | 1342 | todoview_action->addTo( viewToolBar ); |
1342 | 1343 | ||
1343 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1344 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1344 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1345 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1345 | if (p-> mShowIconBackFast) { | 1346 | if (p-> mShowIconBackFast) { |
1346 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1347 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1347 | connect( action, SIGNAL( activated() ), | 1348 | connect( action, SIGNAL( activated() ), |
1348 | mView, SLOT( goPreviousMonth() ) ); | 1349 | mView, SLOT( goPreviousMonth() ) ); |
1349 | action->addTo( navigatorToolBar ); | 1350 | action->addTo( navigatorToolBar ); |
1350 | } | 1351 | } |
1351 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1352 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1352 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1353 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1353 | if (p-> mShowIconBack) { | 1354 | if (p-> mShowIconBack) { |
1354 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1355 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1355 | connect( action, SIGNAL( activated() ), | 1356 | connect( action, SIGNAL( activated() ), |
1356 | mView, SLOT( goPrevious() ) ); | 1357 | mView, SLOT( goPrevious() ) ); |
1357 | action->addTo( navigatorToolBar ); | 1358 | action->addTo( navigatorToolBar ); |
1358 | } | 1359 | } |
1359 | icon = loadPixmap( pathString + "today" ); | 1360 | icon = loadPixmap( pathString + "today" ); |
1360 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1361 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1361 | if (p-> mShowIconToday) | 1362 | if (p-> mShowIconToday) |
1362 | today_action->addTo( navigatorToolBar ); | 1363 | today_action->addTo( navigatorToolBar ); |
1363 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1364 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1364 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1365 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1365 | if (p-> mShowIconForward) { | 1366 | if (p-> mShowIconForward) { |
1366 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1367 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1367 | connect( action, SIGNAL( activated() ), | 1368 | connect( action, SIGNAL( activated() ), |
1368 | mView, SLOT( goNext() ) ); | 1369 | mView, SLOT( goNext() ) ); |
1369 | action->addTo( navigatorToolBar ); | 1370 | action->addTo( navigatorToolBar ); |
1370 | } | 1371 | } |
1371 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1372 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1372 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1373 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1373 | if (p-> mShowIconForwardFast) { | 1374 | if (p-> mShowIconForwardFast) { |
1374 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1375 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1375 | connect( action, SIGNAL( activated() ), | 1376 | connect( action, SIGNAL( activated() ), |
1376 | mView, SLOT( goNextMonth() ) ); | 1377 | mView, SLOT( goNextMonth() ) ); |
1377 | action->addTo( navigatorToolBar ); | 1378 | action->addTo( navigatorToolBar ); |
1378 | } | 1379 | } |
1379 | 1380 | ||
1380 | 1381 | ||
1381 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1382 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1382 | 1383 | ||
1383 | 1384 | ||
1384 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); | 1385 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); |
1385 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); | 1386 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); |
1386 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); | 1387 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); |
1387 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); | 1388 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); |
1388 | 1389 | ||
1389 | if (p-> mShowIconNewEvent) | 1390 | if (p-> mShowIconNewEvent) |
1390 | configureToolBarMenu->setItemChecked( 10, true ); | 1391 | configureToolBarMenu->setItemChecked( 10, true ); |
1391 | if (p->mShowIconNewTodo ) | 1392 | if (p->mShowIconNewTodo ) |
1392 | configureToolBarMenu->setItemChecked( 20, true ); | 1393 | configureToolBarMenu->setItemChecked( 20, true ); |
1393 | if (p-> mShowIconSearch) | 1394 | if (p-> mShowIconSearch) |
1394 | configureToolBarMenu->setItemChecked( 120, true ); | 1395 | configureToolBarMenu->setItemChecked( 120, true ); |
1395 | if (p-> mShowIconList) | 1396 | if (p-> mShowIconList) |
1396 | configureToolBarMenu->setItemChecked( 30, true ); | 1397 | configureToolBarMenu->setItemChecked( 30, true ); |
1397 | if (p-> mShowIconDay1) | 1398 | if (p-> mShowIconDay1) |
1398 | configureToolBarMenu->setItemChecked( 40, true ); | 1399 | configureToolBarMenu->setItemChecked( 40, true ); |
1399 | if (p-> mShowIconDay5) | 1400 | if (p-> mShowIconDay5) |
1400 | configureToolBarMenu->setItemChecked( 50, true ); | 1401 | configureToolBarMenu->setItemChecked( 50, true ); |
1401 | if (p-> mShowIconDay6) | 1402 | if (p-> mShowIconDay6) |
1402 | configureToolBarMenu->setItemChecked( 75, true ); | 1403 | configureToolBarMenu->setItemChecked( 75, true ); |
1403 | if (p-> mShowIconDay7) | 1404 | if (p-> mShowIconDay7) |
1404 | configureToolBarMenu->setItemChecked( 60, true ); | 1405 | configureToolBarMenu->setItemChecked( 60, true ); |
1405 | if (p-> mShowIconMonth) | 1406 | if (p-> mShowIconMonth) |
1406 | configureToolBarMenu->setItemChecked( 70, true ); | 1407 | configureToolBarMenu->setItemChecked( 70, true ); |
1407 | if (p-> mShowIconTodoview) | 1408 | if (p-> mShowIconTodoview) |
1408 | configureToolBarMenu->setItemChecked( 80, true ); | 1409 | configureToolBarMenu->setItemChecked( 80, true ); |
1409 | if (p-> mShowIconBackFast) | 1410 | if (p-> mShowIconBackFast) |
1410 | configureToolBarMenu->setItemChecked( 200, true ); | 1411 | configureToolBarMenu->setItemChecked( 200, true ); |
1411 | if (p-> mShowIconBack) | 1412 | if (p-> mShowIconBack) |
1412 | configureToolBarMenu->setItemChecked( 210, true ); | 1413 | configureToolBarMenu->setItemChecked( 210, true ); |
1413 | if (p-> mShowIconToday) | 1414 | if (p-> mShowIconToday) |
1414 | configureToolBarMenu->setItemChecked( 130, true ); | 1415 | configureToolBarMenu->setItemChecked( 130, true ); |
1415 | if (p-> mShowIconForward) | 1416 | if (p-> mShowIconForward) |
1416 | configureToolBarMenu->setItemChecked( 220, true ); | 1417 | configureToolBarMenu->setItemChecked( 220, true ); |
1417 | if (p-> mShowIconForwardFast) | 1418 | if (p-> mShowIconForwardFast) |
1418 | configureToolBarMenu->setItemChecked( 230, true ); | 1419 | configureToolBarMenu->setItemChecked( 230, true ); |
1419 | if (p-> mShowIconNextDays) | 1420 | if (p-> mShowIconNextDays) |
1420 | configureToolBarMenu->setItemChecked( 100, true ); | 1421 | configureToolBarMenu->setItemChecked( 100, true ); |
1421 | if (p-> mShowIconNext) | 1422 | if (p-> mShowIconNext) |
1422 | configureToolBarMenu->setItemChecked( 110, true ); | 1423 | configureToolBarMenu->setItemChecked( 110, true ); |
1423 | if (p-> mShowIconJournal) | 1424 | if (p-> mShowIconJournal) |
1424 | configureToolBarMenu->setItemChecked( 90, true ); | 1425 | configureToolBarMenu->setItemChecked( 90, true ); |
1425 | if (p-> mShowIconWhatsThis) | 1426 | if (p-> mShowIconWhatsThis) |
1426 | configureToolBarMenu->setItemChecked( 300, true ); | 1427 | configureToolBarMenu->setItemChecked( 300, true ); |
1427 | if (p-> mShowIconWeekNum) | 1428 | if (p-> mShowIconWeekNum) |
1428 | configureToolBarMenu->setItemChecked( 400, true ); | 1429 | configureToolBarMenu->setItemChecked( 400, true ); |
1429 | if (!p-> mShowIconStretch) { | 1430 | if (!p-> mShowIconStretch) { |
1430 | QLabel* dummy = new QLabel( iconToolBar ); | 1431 | QLabel* dummy = new QLabel( iconToolBar ); |
1431 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1432 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1432 | dummy->setMinimumWidth( 0 ); | 1433 | dummy->setMinimumWidth( 0 ); |
1433 | iconToolBar->setStretchableWidget ( dummy ) ; | 1434 | iconToolBar->setStretchableWidget ( dummy ) ; |
1434 | } | 1435 | } |
1435 | else { | 1436 | else { |
1436 | iconToolBar->setHorizontalStretchable (true ); | 1437 | iconToolBar->setHorizontalStretchable (true ); |
1437 | viewToolBar->setHorizontalStretchable (true ); | 1438 | viewToolBar->setHorizontalStretchable (true ); |
1438 | navigatorToolBar->setHorizontalStretchable (true ); | 1439 | navigatorToolBar->setHorizontalStretchable (true ); |
1439 | iconToolBar->setVerticalStretchable (true ); | 1440 | iconToolBar->setVerticalStretchable (true ); |
1440 | viewToolBar->setVerticalStretchable (true ); | 1441 | viewToolBar->setVerticalStretchable (true ); |
1441 | navigatorToolBar->setVerticalStretchable (true ); | 1442 | navigatorToolBar->setVerticalStretchable (true ); |
1442 | configureToolBarMenu->setItemChecked( 5, true ); | 1443 | configureToolBarMenu->setItemChecked( 5, true ); |
1443 | } | 1444 | } |
1444 | if (p-> mShowIconFilter) | 1445 | if (p-> mShowIconFilter) |
1445 | configureToolBarMenu->setItemChecked( 7, true ); | 1446 | configureToolBarMenu->setItemChecked( 7, true ); |
1446 | if (p-> mShowIconOnetoolbar) | 1447 | if (p-> mShowIconOnetoolbar) |
1447 | configureToolBarMenu->setItemChecked( 6, true ); | 1448 | configureToolBarMenu->setItemChecked( 6, true ); |
1448 | 1449 | ||
1449 | 1450 | ||
1450 | if ( filterMenubar ) { | 1451 | if ( filterMenubar ) { |
1451 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); | 1452 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); |
1452 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); | 1453 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); |
1453 | } | 1454 | } |
1454 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1455 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1455 | configureAgenda( p->mHourSize ); | 1456 | configureAgenda( p->mHourSize ); |
1456 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1457 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1457 | } | 1458 | } |
1458 | void MainWindow::calHint() | 1459 | void MainWindow::calHint() |
1459 | { | 1460 | { |
1460 | 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>."); | 1461 | 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>."); |
1461 | 1462 | ||
1462 | KMessageBox::information( this, message); | 1463 | KMessageBox::information( this, message); |
1463 | } | 1464 | } |
1464 | void MainWindow::exportToPhone( int mode ) | 1465 | void MainWindow::exportToPhone( int mode ) |
1465 | { | 1466 | { |
1466 | 1467 | ||
1467 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1468 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1468 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1469 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1469 | KOex2phonePrefs ex2phone; | 1470 | KOex2phonePrefs ex2phone; |
1470 | 1471 | ||
1471 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1472 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1472 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1473 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1473 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1474 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1474 | if ( mode == 1 ) | 1475 | if ( mode == 1 ) |
1475 | ex2phone.setCaption(i18n("Export complete calendar")); | 1476 | ex2phone.setCaption(i18n("Export complete calendar")); |
1476 | if ( mode == 2 ) | 1477 | if ( mode == 2 ) |
1477 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1478 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1478 | 1479 | ||
1479 | if ( !ex2phone.exec() ) { | 1480 | if ( !ex2phone.exec() ) { |
1480 | return; | 1481 | return; |
1481 | } | 1482 | } |
1482 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1483 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1483 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1484 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1484 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1485 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1485 | 1486 | ||
1486 | int inFuture = 0; | 1487 | int inFuture = 0; |
1487 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1488 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1488 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1489 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1489 | QPtrList<Incidence> delSel; | 1490 | QPtrList<Incidence> delSel; |
1490 | if ( mode == 1 ) | 1491 | if ( mode == 1 ) |
1491 | delSel = mCalendar->rawIncidences(); | 1492 | delSel = mCalendar->rawIncidences(); |
1492 | if ( mode == 2 ) | 1493 | if ( mode == 2 ) |
1493 | delSel = mCalendar->incidences(); | 1494 | delSel = mCalendar->incidences(); |
1494 | CalendarLocal* cal = new CalendarLocal(); | 1495 | CalendarLocal* cal = new CalendarLocal(); |
1495 | cal->setLocalTime(); | 1496 | cal->setLocalTime(); |
1496 | Incidence *incidence = delSel.first(); | 1497 | Incidence *incidence = delSel.first(); |
1497 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1498 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1498 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1499 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1499 | while ( incidence ) { | 1500 | while ( incidence ) { |
1500 | if ( incidence->typeID() != journalID ) { | 1501 | if ( incidence->typeID() != journalID ) { |
1501 | bool add = true; | 1502 | bool add = true; |
1502 | if ( inFuture ) { | 1503 | if ( inFuture ) { |
1503 | QDateTime dt; | 1504 | QDateTime dt; |
1504 | if ( incidence->typeID() == todoID ) { | 1505 | if ( incidence->typeID() == todoID ) { |
1505 | Todo * t = (Todo*)incidence; | 1506 | Todo * t = (Todo*)incidence; |
1506 | if ( t->hasDueDate() ) | 1507 | if ( t->hasDueDate() ) |
1507 | dt = t->dtDue(); | 1508 | dt = t->dtDue(); |
1508 | else | 1509 | else |
1509 | dt = cur.addSecs( 62 ); | 1510 | dt = cur.addSecs( 62 ); |
1510 | } | 1511 | } |
1511 | else { | 1512 | else { |
1512 | bool ok; | 1513 | bool ok; |
1513 | dt = incidence->getNextOccurence( cur, &ok ); | 1514 | dt = incidence->getNextOccurence( cur, &ok ); |
1514 | if ( !ok ) | 1515 | if ( !ok ) |
1515 | dt = cur.addSecs( -62 ); | 1516 | dt = cur.addSecs( -62 ); |
1516 | } | 1517 | } |
1517 | if ( dt < cur || dt > end ) { | 1518 | if ( dt < cur || dt > end ) { |
1518 | add = false; | 1519 | add = false; |
1519 | } | 1520 | } |
1520 | } | 1521 | } |
1521 | if ( add ) { | 1522 | if ( add ) { |
1522 | Incidence *in = incidence->clone(); | 1523 | Incidence *in = incidence->clone(); |
1523 | cal->addIncidence( in ); | 1524 | cal->addIncidence( in ); |
1524 | } | 1525 | } |
1525 | } | 1526 | } |
1526 | incidence = delSel.next(); | 1527 | incidence = delSel.next(); |
1527 | } | 1528 | } |
1528 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1529 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1529 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1530 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1530 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1531 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1531 | 1532 | ||
1532 | setCaption( i18n("Writing to phone...")); | 1533 | setCaption( i18n("Writing to phone...")); |
1533 | if ( PhoneFormat::writeToPhone( cal ) ) | 1534 | if ( PhoneFormat::writeToPhone( cal ) ) |
1534 | setCaption( i18n("Export to phone successful!")); | 1535 | setCaption( i18n("Export to phone successful!")); |
1535 | else | 1536 | else |
1536 | setCaption( i18n("Error exporting to phone!")); | 1537 | setCaption( i18n("Error exporting to phone!")); |
1537 | delete cal; | 1538 | delete cal; |
1538 | } | 1539 | } |
1539 | 1540 | ||
1540 | 1541 | ||
1541 | void MainWindow::setDefaultPreferences() | 1542 | void MainWindow::setDefaultPreferences() |
1542 | { | 1543 | { |
1543 | KOPrefs *p = KOPrefs::instance(); | 1544 | KOPrefs *p = KOPrefs::instance(); |
1544 | 1545 | ||
1545 | p->mCompactDialogs = true; | 1546 | p->mCompactDialogs = true; |
1546 | p->mConfirm = true; | 1547 | p->mConfirm = true; |
1547 | // p->mEnableQuickTodo = false; | 1548 | // p->mEnableQuickTodo = false; |
1548 | 1549 | ||
1549 | } | 1550 | } |
1550 | 1551 | ||
1551 | QString MainWindow::resourcePath() | 1552 | QString MainWindow::resourcePath() |
1552 | { | 1553 | { |
1553 | return KGlobal::iconLoader()->iconPath(); | 1554 | return KGlobal::iconLoader()->iconPath(); |
1554 | } | 1555 | } |
1555 | 1556 | ||
1556 | void MainWindow::displayText( QString text ,QString cap ) | 1557 | void MainWindow::displayText( QString text ,QString cap ) |
1557 | { | 1558 | { |
1558 | QDialog dia( this, "name", true ); ; | 1559 | QDialog dia( this, "name", true ); ; |
1559 | dia.setCaption( cap ); | 1560 | dia.setCaption( cap ); |
1560 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1561 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1561 | lay->setSpacing( 3 ); | 1562 | lay->setSpacing( 3 ); |
1562 | lay->setMargin( 3 ); | 1563 | lay->setMargin( 3 ); |
1563 | QTextBrowser tb ( &dia ); | 1564 | QTextBrowser tb ( &dia ); |
1564 | lay->addWidget( &tb ); | 1565 | lay->addWidget( &tb ); |
1565 | tb.setText( text ); | 1566 | tb.setText( text ); |
1566 | #ifdef DESKTOP_VERSION | 1567 | #ifdef DESKTOP_VERSION |
1567 | dia.resize( 640, 480); | 1568 | dia.resize( 640, 480); |
1568 | #else | 1569 | #else |
1569 | dia.showMaximized(); | 1570 | dia.showMaximized(); |
1570 | #endif | 1571 | #endif |
1571 | dia.exec(); | 1572 | dia.exec(); |
1572 | } | 1573 | } |
1573 | 1574 | ||
1574 | void MainWindow::features() | 1575 | void MainWindow::features() |
1575 | { | 1576 | { |
1576 | 1577 | ||
1577 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1578 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1578 | } | 1579 | } |
1579 | 1580 | ||
1580 | void MainWindow::usertrans() | 1581 | void MainWindow::usertrans() |
1581 | { | 1582 | { |
1582 | 1583 | ||
1583 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1584 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1584 | } | 1585 | } |
1585 | 1586 | ||
1586 | void MainWindow::storagehowto() | 1587 | void MainWindow::storagehowto() |
1587 | { | 1588 | { |
1588 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 1589 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
1589 | } | 1590 | } |
1590 | void MainWindow::timetrackinghowto() | 1591 | void MainWindow::timetrackinghowto() |
1591 | { | 1592 | { |
1592 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); | 1593 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); |
1593 | } | 1594 | } |
1594 | void MainWindow::kdesynchowto() | 1595 | void MainWindow::kdesynchowto() |
1595 | { | 1596 | { |
1596 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1597 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1597 | } | 1598 | } |
1598 | void MainWindow::multisynchowto() | 1599 | void MainWindow::multisynchowto() |
1599 | { | 1600 | { |
1600 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1601 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1601 | } | 1602 | } |
1602 | void MainWindow::synchowto() | 1603 | void MainWindow::synchowto() |
1603 | { | 1604 | { |
1604 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1605 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1605 | } | 1606 | } |
1606 | void MainWindow::faq() | 1607 | void MainWindow::faq() |
1607 | { | 1608 | { |
1608 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1609 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1609 | 1610 | ||
1610 | } | 1611 | } |
1611 | void MainWindow::whatsNew() | 1612 | void MainWindow::whatsNew() |
1612 | { | 1613 | { |
1613 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1614 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1614 | 1615 | ||
1615 | } | 1616 | } |
1616 | void MainWindow::licence() | 1617 | void MainWindow::licence() |
1617 | { | 1618 | { |
1618 | KApplication::showLicence(); | 1619 | KApplication::showLicence(); |
1619 | 1620 | ||
1620 | } | 1621 | } |
1621 | void MainWindow::about() | 1622 | void MainWindow::about() |
1622 | { | 1623 | { |
1623 | QString version; | 1624 | QString version; |
1624 | #include <../version> | 1625 | #include <../version> |
1625 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1626 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1626 | i18n("KOrganizer/Platform-independent\n") + | 1627 | i18n("KOrganizer/Platform-independent\n") + |
1627 | "(KO/Pi) " + version + " - " + | 1628 | "(KO/Pi) " + version + " - " + |
1628 | 1629 | ||
1629 | #ifdef DESKTOP_VERSION | 1630 | #ifdef DESKTOP_VERSION |
1630 | i18n("Desktop Edition\n") + | 1631 | i18n("Desktop Edition\n") + |
1631 | #else | 1632 | #else |
1632 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1633 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1633 | #endif | 1634 | #endif |
1634 | 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!") ); | 1635 | 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!") ); |
1635 | } | 1636 | } |
1636 | void MainWindow::keyBindings() | 1637 | void MainWindow::keyBindings() |
1637 | { | 1638 | { |
1638 | QString cap = i18n("KO/Pi Keys + Colors"); | 1639 | QString cap = i18n("KO/Pi Keys + Colors"); |
1639 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1640 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1640 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1641 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1641 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1642 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1642 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1643 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1643 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1644 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1644 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1645 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1645 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ | 1646 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ |
1646 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1647 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1647 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1648 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1648 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1649 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
1649 | i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ | 1650 | i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ |
1650 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1651 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1651 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1652 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1652 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1653 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1653 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1654 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1654 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1655 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1655 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1656 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1656 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ | 1657 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ |
1657 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1658 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1658 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1659 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1659 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1660 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1660 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1661 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1661 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1662 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1662 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1663 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1663 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1664 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1664 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1665 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1665 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1666 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1666 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1667 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1667 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1668 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1668 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1669 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1669 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1670 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1670 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1671 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1671 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1672 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1672 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1673 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1673 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1674 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1674 | i18n("<p><h3>In list view:</h3></p>\n") + | 1675 | i18n("<p><h3>In list view:</h3></p>\n") + |
1675 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1676 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1676 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1677 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1677 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1678 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1678 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1679 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1679 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1680 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1680 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1681 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1681 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1682 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1682 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1683 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1683 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1684 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1684 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1685 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1685 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1686 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1686 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1687 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1687 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1688 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1688 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1689 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1689 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1690 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1690 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1691 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1691 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1692 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1692 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1693 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1693 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1694 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1694 | displayText( text, cap); | 1695 | displayText( text, cap); |
1695 | } | 1696 | } |
1696 | void MainWindow::aboutAutoSaving() | 1697 | void MainWindow::aboutAutoSaving() |
1697 | { | 1698 | { |
1698 | 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"); | 1699 | 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"); |
1699 | 1700 | ||
1700 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1701 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1701 | 1702 | ||
1702 | } | 1703 | } |
1703 | void MainWindow::aboutKnownBugs() | 1704 | void MainWindow::aboutKnownBugs() |
1704 | { | 1705 | { |
1705 | QMessageBox* msg; | 1706 | QMessageBox* msg; |
1706 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1707 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1707 | 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")+ | 1708 | 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")+ |
1708 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1709 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1709 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1710 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1710 | i18n("\nor report them in the bugtracker on\n") + | 1711 | i18n("\nor report them in the bugtracker on\n") + |
1711 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1712 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1712 | QMessageBox::NoIcon, | 1713 | QMessageBox::NoIcon, |
1713 | QMessageBox::Ok, | 1714 | QMessageBox::Ok, |
1714 | QMessageBox::NoButton, | 1715 | QMessageBox::NoButton, |
1715 | QMessageBox::NoButton); | 1716 | QMessageBox::NoButton); |
1716 | msg->exec(); | 1717 | msg->exec(); |
1717 | delete msg; | 1718 | delete msg; |
1718 | 1719 | ||
1719 | } | 1720 | } |
1720 | 1721 | ||
1721 | QString MainWindow::defaultFileName() | 1722 | QString MainWindow::defaultFileName() |
1722 | { | 1723 | { |
1723 | return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 1724 | return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
1724 | } | 1725 | } |
1725 | QString MainWindow::syncFileName() | 1726 | QString MainWindow::syncFileName() |
1726 | { | 1727 | { |
1727 | #ifdef DESKTOP_VERSION | 1728 | #ifdef DESKTOP_VERSION |
1728 | return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); | 1729 | return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); |
1729 | #else | 1730 | #else |
1730 | return QString( "/tmp/synccalendar.ics" ); | 1731 | return QString( "/tmp/synccalendar.ics" ); |
1731 | #endif | 1732 | #endif |
1732 | } | 1733 | } |
1733 | #include "koglobals.h" | 1734 | #include "koglobals.h" |
1734 | #include <kcalendarsystem.h> | 1735 | #include <kcalendarsystem.h> |
1735 | void MainWindow::updateWeek(QDate seda) | 1736 | void MainWindow::updateWeek(QDate seda) |
1736 | { | 1737 | { |
1737 | int weekNum = KGlobal::locale()->weekNum ( seda ); | 1738 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1738 | mWeekPixmap.fill( mWeekBgColor ); | 1739 | mWeekPixmap.fill( mWeekBgColor ); |
1739 | QPainter p ( &mWeekPixmap ); | 1740 | QPainter p ( &mWeekPixmap ); |
1740 | p.setFont( mWeekFont ); | 1741 | p.setFont( mWeekFont ); |
1741 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1742 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1742 | p.end(); | 1743 | p.end(); |
1743 | QIconSet icon3 ( mWeekPixmap ); | 1744 | QIconSet icon3 ( mWeekPixmap ); |
1744 | mWeekAction->setIconSet ( icon3 ); | 1745 | mWeekAction->setIconSet ( icon3 ); |
1745 | 1746 | ||
1746 | } | 1747 | } |
1747 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1748 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1748 | { | 1749 | { |
1749 | updateWeek( selectedDates.first() ); | 1750 | updateWeek( selectedDates.first() ); |
1750 | } | 1751 | } |
1751 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1752 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1752 | { | 1753 | { |
1753 | if ( !incidence ) { | 1754 | if ( !incidence ) { |
1754 | mShowAction->setMenuText( i18n("Show") ); | 1755 | mShowAction->setMenuText( i18n("Show") ); |
1755 | enableIncidenceActions( false ); | 1756 | enableIncidenceActions( false ); |
1756 | mNewSubTodoAction->setEnabled( false ); | 1757 | mNewSubTodoAction->setEnabled( false ); |
1757 | setCaptionToDates(); | 1758 | setCaptionToDates(); |
1758 | return; | 1759 | return; |
1759 | } | 1760 | } |
1760 | QString startString = ""; | 1761 | QString startString = ""; |
1761 | if ( incidence->typeID() != todoID ) { | 1762 | if ( incidence->typeID() != todoID ) { |
1762 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1763 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1763 | if ( incidence->doesFloat() ) { | 1764 | if ( incidence->doesFloat() ) { |
1764 | startString += ": "+incidence->dtStartDateStr( true ); | 1765 | startString += ": "+incidence->dtStartDateStr( true ); |
1765 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1766 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1766 | } else { | 1767 | } else { |
1767 | startString = ": "+incidence->dtStartStr(true); | 1768 | startString = ": "+incidence->dtStartStr(true); |
1768 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1769 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1769 | } | 1770 | } |
1770 | } else { | 1771 | } else { |
1771 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1772 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1772 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1773 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1773 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1774 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1774 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { | 1775 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { |
1775 | bool ok; | 1776 | bool ok; |
1776 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1777 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1777 | if ( ok ) { | 1778 | if ( ok ) { |
1778 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1779 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1779 | startString += i18n(" (%1 y.)"). arg( years ); | 1780 | startString += i18n(" (%1 y.)"). arg( years ); |
1780 | } | 1781 | } |
1781 | } | 1782 | } |
1782 | else | 1783 | else |
1783 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1784 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1784 | } | 1785 | } |
1785 | } | 1786 | } |
1786 | else { | 1787 | else { |
1787 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) | 1788 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) |
1788 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); | 1789 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); |
1789 | else | 1790 | else |
1790 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1791 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1791 | } | 1792 | } |
1792 | if ( !incidence->location().isEmpty() ) | 1793 | if ( !incidence->location().isEmpty() ) |
1793 | startString += " (" +incidence->location()+")"; | 1794 | startString += " (" +incidence->location()+")"; |
1794 | setCaption( incidence->summary()+startString); | 1795 | setCaption( incidence->summary()+startString); |
1795 | enableIncidenceActions( true ); | 1796 | enableIncidenceActions( true ); |
1796 | if ( incidence->typeID() == eventID ) { | 1797 | if ( incidence->typeID() == eventID ) { |
1797 | mShowAction->setMenuText( i18n("Show Event") ); | 1798 | mShowAction->setMenuText( i18n("Show Event") ); |
1798 | mNewSubTodoAction->setEnabled( false ); | 1799 | mNewSubTodoAction->setEnabled( false ); |
1799 | } else if ( incidence->typeID() == todoID ) { | 1800 | } else if ( incidence->typeID() == todoID ) { |
1800 | mShowAction->setMenuText( i18n("Show Todo") ); | 1801 | mShowAction->setMenuText( i18n("Show Todo") ); |
1801 | mNewSubTodoAction->setEnabled( true ); | 1802 | mNewSubTodoAction->setEnabled( true ); |
1802 | } else { | 1803 | } else { |
1803 | mShowAction->setMenuText( i18n("Show") ); | 1804 | mShowAction->setMenuText( i18n("Show") ); |
1804 | mNewSubTodoAction->setEnabled( false ); | 1805 | mNewSubTodoAction->setEnabled( false ); |
1805 | } | 1806 | } |
1806 | #ifdef DESKTOP_VERSION | 1807 | #ifdef DESKTOP_VERSION |
1807 | static QPixmap jP = SmallIcon( "journal" ); | 1808 | static QPixmap jP = SmallIcon( "journal" ); |
1808 | static QPixmap eP = SmallIcon( "newevent" ); | 1809 | static QPixmap eP = SmallIcon( "newevent" ); |
1809 | static QPixmap tP = SmallIcon( "newtodo" ); | 1810 | static QPixmap tP = SmallIcon( "newtodo" ); |
1810 | QIconSet icon; | 1811 | QIconSet icon; |
1811 | if ( incidence->typeID() == todoID ) | 1812 | if ( incidence->typeID() == todoID ) |
1812 | icon = QIconSet ( tP ); | 1813 | icon = QIconSet ( tP ); |
1813 | else if ( incidence->typeID() == eventID ) | 1814 | else if ( incidence->typeID() == eventID ) |
1814 | icon = QIconSet ( eP ); | 1815 | icon = QIconSet ( eP ); |
1815 | else if ( incidence->typeID() == journalID ) | 1816 | else if ( incidence->typeID() == journalID ) |
1816 | icon = QIconSet ( jP ); | 1817 | icon = QIconSet ( jP ); |
1817 | mPrintSelAction->setIconSet ( icon ); | 1818 | mPrintSelAction->setIconSet ( icon ); |
1818 | #endif | 1819 | #endif |
1819 | } | 1820 | } |
1820 | 1821 | ||
1821 | void MainWindow::enableIncidenceActions( bool enabled ) | 1822 | void MainWindow::enableIncidenceActions( bool enabled ) |
1822 | { | 1823 | { |
1823 | mShowAction->setEnabled( enabled ); | 1824 | mShowAction->setEnabled( enabled ); |
1824 | mEditAction->setEnabled( enabled ); | 1825 | mEditAction->setEnabled( enabled ); |
1825 | mDeleteAction->setEnabled( enabled ); | 1826 | mDeleteAction->setEnabled( enabled ); |
1826 | 1827 | ||
1827 | mCloneAction->setEnabled( enabled ); | 1828 | mCloneAction->setEnabled( enabled ); |
1828 | mMoveAction->setEnabled( enabled ); | 1829 | mMoveAction->setEnabled( enabled ); |
1829 | #ifndef DESKTOP_VERSION | 1830 | #ifndef DESKTOP_VERSION |
1830 | mBeamAction->setEnabled( enabled ); | 1831 | mBeamAction->setEnabled( enabled ); |
1831 | #else | 1832 | #else |
1832 | mPrintSelAction->setEnabled( enabled ); | 1833 | mPrintSelAction->setEnabled( enabled ); |
1833 | #endif | 1834 | #endif |
1834 | mCancelAction->setEnabled( enabled ); | 1835 | mCancelAction->setEnabled( enabled ); |
1835 | } | 1836 | } |
1836 | 1837 | ||
1837 | void MainWindow::importOL() | 1838 | void MainWindow::importOL() |
1838 | { | 1839 | { |
1839 | #ifdef _OL_IMPORT_ | 1840 | #ifdef _OL_IMPORT_ |
1840 | mView->clearAllViews(); | 1841 | mView->clearAllViews(); |
1841 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1842 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1842 | id->exec(); | 1843 | id->exec(); |
1843 | delete id; | 1844 | delete id; |
1844 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1845 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1845 | mView->updateView(); | 1846 | mView->updateView(); |
1846 | #endif | 1847 | #endif |
1847 | } | 1848 | } |
1848 | void MainWindow::importBday() | 1849 | void MainWindow::importBday() |
1849 | { | 1850 | { |
1850 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), | 1851 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), |
1851 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1852 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1852 | i18n("Import!"), i18n("Cancel"), 0, | 1853 | i18n("Import!"), i18n("Cancel"), 0, |
1853 | 0, 1 ); | 1854 | 0, 1 ); |
1854 | if ( result == 0 ) { | 1855 | if ( result == 0 ) { |
1855 | mView->importBday(); | 1856 | mView->importBday(); |
1856 | 1857 | ||
1857 | } | 1858 | } |
1858 | 1859 | ||
1859 | 1860 | ||
1860 | } | 1861 | } |
1861 | void MainWindow::importQtopia() | 1862 | void MainWindow::importQtopia() |
1862 | { | 1863 | { |
1863 | //#ifndef DESKTOP_VERSION | 1864 | //#ifndef DESKTOP_VERSION |
1864 | 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"); | 1865 | 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"); |
1865 | #ifdef DESKTOP_VERSION | 1866 | #ifdef DESKTOP_VERSION |
1866 | 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"); | 1867 | 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"); |
1867 | #endif | 1868 | #endif |
1868 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1869 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1869 | i18n("Import!"), i18n("Cancel"), 0, | 1870 | i18n("Import!"), i18n("Cancel"), 0, |
1870 | 0, 1 ); | 1871 | 0, 1 ); |
1871 | if ( result == 0 ) { | 1872 | if ( result == 0 ) { |
1872 | #ifndef DESKTOP_VERSION | 1873 | #ifndef DESKTOP_VERSION |
1873 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1874 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1874 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1875 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1875 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1876 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1876 | #else | 1877 | #else |
1877 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1878 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1878 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1879 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1879 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1880 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1880 | #endif | 1881 | #endif |
1881 | mView->importQtopia( categories, datebook, todolist ); | 1882 | mView->importQtopia( categories, datebook, todolist ); |
1882 | } | 1883 | } |
1883 | mView->calendar()->reInitAlarmSettings(); | 1884 | mView->calendar()->reInitAlarmSettings(); |
1884 | #if 0 | 1885 | #if 0 |
1885 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1886 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1886 | i18n("Not supported \non desktop!\n"), | 1887 | i18n("Not supported \non desktop!\n"), |
1887 | i18n("Ok"), i18n("Cancel"), 0, | 1888 | i18n("Ok"), i18n("Cancel"), 0, |
1888 | 0, 1 ); | 1889 | 0, 1 ); |
1889 | 1890 | ||
1890 | #endif | 1891 | #endif |
1891 | } | 1892 | } |
1892 | 1893 | ||
1893 | void MainWindow::saveOnClose() | 1894 | void MainWindow::saveOnClose() |
1894 | { | 1895 | { |
1895 | KOPrefs *p = KOPrefs::instance(); | 1896 | KOPrefs *p = KOPrefs::instance(); |
1896 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1897 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1897 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1898 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1898 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1899 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1899 | if ( filterToolBar ) { | 1900 | if ( filterToolBar ) { |
1900 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1901 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1901 | } | 1902 | } |
1902 | #ifdef DESKTOP_VERSION | 1903 | #ifdef DESKTOP_VERSION |
1903 | 1904 | ||
1904 | QPoint myP; | 1905 | QPoint myP; |
1905 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1906 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1906 | if ( p->mToolBarHor ) | 1907 | if ( p->mToolBarHor ) |
1907 | p->mToolBarUp = myP.y() > height()/2; | 1908 | p->mToolBarUp = myP.y() > height()/2; |
1908 | else | 1909 | else |
1909 | p->mToolBarUp = myP.x() > width()/2; | 1910 | p->mToolBarUp = myP.x() > width()/2; |
1910 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1911 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1911 | if ( p->mToolBarHorV ) | 1912 | if ( p->mToolBarHorV ) |
1912 | p->mToolBarUpV = myP.y() > height()/2; | 1913 | p->mToolBarUpV = myP.y() > height()/2; |
1913 | else | 1914 | else |
1914 | p->mToolBarUpV = myP.x() > width()/2 ; | 1915 | p->mToolBarUpV = myP.x() > width()/2 ; |
1915 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1916 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1916 | if ( p->mToolBarHorN ) | 1917 | if ( p->mToolBarHorN ) |
1917 | p->mToolBarUpN = myP.y() > height()/2; | 1918 | p->mToolBarUpN = myP.y() > height()/2; |
1918 | else | 1919 | else |
1919 | p->mToolBarUpN = myP.x() > width()/2 ; | 1920 | p->mToolBarUpN = myP.x() > width()/2 ; |
1920 | if ( filterToolBar ) { | 1921 | if ( filterToolBar ) { |
1921 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1922 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1922 | if ( p->mToolBarHorF ) | 1923 | if ( p->mToolBarHorF ) |
1923 | p->mToolBarUpF = myP.y() > height()/2; | 1924 | p->mToolBarUpF = myP.y() > height()/2; |
1924 | else | 1925 | else |
1925 | p->mToolBarUpF = myP.x() > width()/2 ; | 1926 | p->mToolBarUpF = myP.x() > width()/2 ; |
1926 | } | 1927 | } |
1927 | #else | 1928 | #else |
1928 | if ( p->mToolBarHor ) | 1929 | if ( p->mToolBarHor ) |
1929 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1930 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1930 | else | 1931 | else |
1931 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1932 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1932 | if ( p->mToolBarHorV ) | 1933 | if ( p->mToolBarHorV ) |
1933 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1934 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1934 | else | 1935 | else |
1935 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1936 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1936 | 1937 | ||
1937 | if ( p->mToolBarHorN ) | 1938 | if ( p->mToolBarHorN ) |
1938 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1939 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1939 | else | 1940 | else |
1940 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1941 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1941 | if ( filterToolBar ) { | 1942 | if ( filterToolBar ) { |
1942 | if ( p->mToolBarHorF ) | 1943 | if ( p->mToolBarHorF ) |
1943 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1944 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1944 | else | 1945 | else |
1945 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1946 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1946 | } | 1947 | } |
1947 | #endif | 1948 | #endif |
1948 | save(); | 1949 | save(); |
1949 | mView->writeSettings(); | 1950 | mView->writeSettings(); |
1950 | mView->checkSuspendAlarm(); | 1951 | mView->checkSuspendAlarm(); |
1951 | } | 1952 | } |
1952 | void MainWindow::slotModifiedChanged( bool ) | 1953 | void MainWindow::slotModifiedChanged( bool ) |
1953 | { | 1954 | { |
1954 | if ( mBlockAtStartup ) | 1955 | if ( mBlockAtStartup ) |
1955 | return; | 1956 | return; |
1956 | 1957 | ||
1957 | int msec; | 1958 | int msec; |
1958 | if ( mCalendarModifiedFlag ) { | 1959 | if ( mCalendarModifiedFlag ) { |
1959 | //qDebug(" MainWindow timer is running "); | 1960 | //qDebug(" MainWindow timer is running "); |
1960 | return; | 1961 | return; |
1961 | } | 1962 | } |
1962 | // we store the changes after 1 minute, | 1963 | // we store the changes after 1 minute, |
1963 | // and for safety reasons after 10 minutes again | 1964 | // and for safety reasons after 10 minutes again |
1964 | if ( !mSyncManager->blockSave() ) | 1965 | if ( !mSyncManager->blockSave() ) |
1965 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1966 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1966 | else | 1967 | else |
1967 | msec = 1000 * 600; | 1968 | msec = 1000 * 600; |
1968 | mSaveTimer.start( msec, true ); // 1 minute | 1969 | mSaveTimer.start( msec, true ); // 1 minute |
1970 | mSaveTime.restart(); | ||
1971 | mSaveDelay = msec/1000; | ||
1969 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1972 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1970 | mCalendarModifiedFlag = true; | 1973 | mCalendarModifiedFlag = true; |
1971 | } | 1974 | } |
1972 | void MainWindow::saveStopTimer() | 1975 | void MainWindow::saveStopTimer() |
1973 | { | 1976 | { |
1974 | mSaveTimer.stop(); | 1977 | mSaveTimer.stop(); |
1975 | } | 1978 | } |
1976 | void MainWindow::backupAllFiles() | 1979 | void MainWindow::backupAllFiles() |
1977 | { | 1980 | { |
1978 | QDate reference ( 2000,1,1); | 1981 | QDate reference ( 2000,1,1); |
1979 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1982 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1980 | setCaption(i18n("Creating backup ... please wait ..." )); | 1983 | setCaption(i18n("Creating backup ... please wait ..." )); |
1981 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1984 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1982 | // we need the file path, the backup dir and the number of bups as param | 1985 | // we need the file path, the backup dir and the number of bups as param |
1983 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1986 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1984 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1987 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1985 | bupDir = KGlobalSettings::backupDataDir(); | 1988 | bupDir = KGlobalSettings::backupDataDir(); |
1986 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1989 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1987 | if ( retval == 0 ) { | 1990 | if ( retval == 0 ) { |
1988 | setCaption(i18n("Backup cancelled" )); | 1991 | setCaption(i18n("Backup cancelled" )); |
1989 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1992 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1990 | // retval == 0 : backup skipped for today, try again tomorrow | 1993 | // retval == 0 : backup skipped for today, try again tomorrow |
1991 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1994 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1992 | } else if ( retval == 1 ){ | 1995 | } else if ( retval == 1 ){ |
1993 | qDebug("KO: Backup created."); | 1996 | qDebug("KO: Backup created."); |
1994 | // backup ok | 1997 | // backup ok |
1995 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1998 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1996 | KopiCalendarFile * cal = calendars.first(); | 1999 | KopiCalendarFile * cal = calendars.first(); |
1997 | cal = calendars.next(); | 2000 | cal = calendars.next(); |
1998 | while ( cal ) { | 2001 | while ( cal ) { |
1999 | if ( !cal->mErrorOnLoad ) { | 2002 | if ( !cal->mErrorOnLoad ) { |
2000 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2003 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2001 | } | 2004 | } |
2002 | cal = calendars.next(); | 2005 | cal = calendars.next(); |
2003 | } | 2006 | } |
2004 | KOPrefs::instance()->mLastBackupDate = daysTo; | 2007 | KOPrefs::instance()->mLastBackupDate = daysTo; |
2005 | setCaption(i18n("Backup succesfully finished" )); | 2008 | setCaption(i18n("Backup succesfully finished" )); |
2006 | } else if ( retval == 2 ){ | 2009 | } else if ( retval == 2 ){ |
2007 | setCaption(i18n("Backup globally disabled" )); | 2010 | setCaption(i18n("Backup globally disabled" )); |
2008 | qDebug("KO: Backup globally cancelled."); | 2011 | qDebug("KO: Backup globally cancelled."); |
2009 | // backup globally cancelled | 2012 | // backup globally cancelled |
2010 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2013 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2011 | } | 2014 | } |
2012 | // retval == 3: do nothing, try again later | 2015 | // retval == 3: do nothing, try again later |
2013 | } | 2016 | } |
2014 | void MainWindow::save() | 2017 | void MainWindow::save() |
2015 | { | 2018 | { |
2019 | if ( mSaveDelay ) { | ||
2020 | if ( mSaveDelay + 60 < mSaveTime.elapsed()/1000 ) { | ||
2021 | qDebug("KO: Save delay %d. Elapsed save time %d ", mSaveDelay, mSaveTime.elapsed()/1000 ); | ||
2022 | qDebug("KO: Restarting save timer"); | ||
2023 | int msec = 10000; | ||
2024 | mSaveTimer.start( msec, true ); // 1 minute | ||
2025 | mSaveTime.restart(); | ||
2026 | mSaveDelay = msec/1000; | ||
2027 | return; | ||
2028 | } | ||
2029 | } | ||
2016 | 2030 | ||
2017 | if ( mView->viewManager()->journalView() ) | 2031 | if ( mView->viewManager()->journalView() ) |
2018 | mView->viewManager()->journalView()->checkModified(); | 2032 | mView->viewManager()->journalView()->checkModified(); |
2019 | if ( !mCalendarModifiedFlag ) { | 2033 | if ( !mCalendarModifiedFlag ) { |
2020 | qDebug("KO: Calendar not modified. Nothing saved."); | 2034 | qDebug("KO: Calendar not modified. Nothing saved."); |
2021 | return; | 2035 | return; |
2022 | } | 2036 | } |
2023 | if ( mSyncManager->blockSave() ) { | 2037 | if ( mSyncManager->blockSave() ) { |
2024 | slotModifiedChanged( true ); | 2038 | slotModifiedChanged( true ); |
2025 | return; | 2039 | return; |
2026 | } | 2040 | } |
2041 | mSaveDelay = 0; | ||
2027 | mSyncManager->setBlockSave(true); | 2042 | mSyncManager->setBlockSave(true); |
2028 | if ( mView->checkAllFileVersions() ) { | 2043 | if ( mView->checkAllFileVersions() ) { |
2029 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2044 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
2030 | QDate reference ( 2000,1,1); | 2045 | QDate reference ( 2000,1,1); |
2031 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2046 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2032 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2047 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
2033 | backupAllFiles(); | 2048 | backupAllFiles(); |
2034 | } | 2049 | } |
2035 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2050 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2036 | } | 2051 | } |
2037 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 2052 | QTime neededSaveTime; |
2053 | neededSaveTime.start(); | ||
2038 | if ( !isMinimized () ) | 2054 | if ( !isMinimized () ) |
2039 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2055 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2040 | qDebug("KO: Start saving data to file!"); | 2056 | qDebug("KO: Start saving data to file!"); |
2041 | if ( mView->saveCalendars() ) | 2057 | if ( mView->saveCalendars() ) |
2042 | mCalendarModifiedFlag = false; | 2058 | mCalendarModifiedFlag = false; |
2043 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 2059 | int msNeeded = neededSaveTime.elapsed(); |
2044 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2060 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2045 | QString savemes; | 2061 | QString savemes; |
2046 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2062 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2047 | if ( !isMinimized () ) | 2063 | if ( !isMinimized () ) |
2048 | setCaption(savemes); | 2064 | setCaption(savemes); |
2049 | else | 2065 | else |
2050 | qDebug(savemes); | 2066 | qDebug(savemes); |
2051 | } else { | 2067 | } else { |
2052 | setCaption(i18n("Saving cancelled!")); | 2068 | setCaption(i18n("Saving cancelled!")); |
2053 | mCalendarModifiedFlag = false; | 2069 | mCalendarModifiedFlag = false; |
2054 | slotModifiedChanged( true ); | 2070 | slotModifiedChanged( true ); |
2055 | } | 2071 | } |
2056 | mSyncManager->setBlockSave( false ); | 2072 | mSyncManager->setBlockSave( false ); |
2057 | } | 2073 | } |
2058 | 2074 | ||
2059 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 2075 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
2060 | { | 2076 | { |
2061 | if ( !e->isAutoRepeat() ) { | 2077 | if ( !e->isAutoRepeat() ) { |
2062 | mFlagKeyPressed = false; | 2078 | mFlagKeyPressed = false; |
2063 | } | 2079 | } |
2064 | } | 2080 | } |
2065 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 2081 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
2066 | { | 2082 | { |
2067 | qApp->processEvents(); | 2083 | qApp->processEvents(); |
2068 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2084 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2069 | e->ignore(); | 2085 | e->ignore(); |
2070 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 2086 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
2071 | return; | 2087 | return; |
2072 | } | 2088 | } |
2073 | if (! e->isAutoRepeat() ) | 2089 | if (! e->isAutoRepeat() ) |
2074 | mFlagKeyPressed = true; | 2090 | mFlagKeyPressed = true; |
2075 | KOPrefs *p = KOPrefs::instance(); | 2091 | KOPrefs *p = KOPrefs::instance(); |
2076 | bool showSelectedDates = false; | 2092 | bool showSelectedDates = false; |
2077 | int size; | 2093 | int size; |
2078 | int pro = 0; | 2094 | int pro = 0; |
2079 | //qDebug("MainWindow::keyPressEvent "); | 2095 | //qDebug("MainWindow::keyPressEvent "); |
2080 | switch ( e->key() ) { | 2096 | switch ( e->key() ) { |
2081 | case Qt::Key_Right: | 2097 | case Qt::Key_Right: |
2082 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2098 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2083 | mView->goNextMonth(); | 2099 | mView->goNextMonth(); |
2084 | else | 2100 | else |
2085 | mView->goNext(); | 2101 | mView->goNext(); |
2086 | showSelectedDates = true; | 2102 | showSelectedDates = true; |
2087 | break; | 2103 | break; |
2088 | case Qt::Key_Left: | 2104 | case Qt::Key_Left: |
2089 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2105 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2090 | mView->goPreviousMonth(); | 2106 | mView->goPreviousMonth(); |
2091 | else | 2107 | else |
2092 | mView->goPrevious(); | 2108 | mView->goPrevious(); |
2093 | showSelectedDates = true; | 2109 | showSelectedDates = true; |
2094 | break; | 2110 | break; |
2095 | case Qt::Key_Down: | 2111 | case Qt::Key_Down: |
2096 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 2112 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
2097 | break; | 2113 | break; |
2098 | case Qt::Key_Up: | 2114 | case Qt::Key_Up: |
2099 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 2115 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
2100 | break; | 2116 | break; |
2101 | case Qt::Key_K: | 2117 | case Qt::Key_K: |
2102 | mView->viewManager()->showMonthViewWeek(); | 2118 | mView->viewManager()->showMonthViewWeek(); |
2103 | break; | 2119 | break; |
2104 | case Qt::Key_I: | 2120 | case Qt::Key_I: |
2105 | mView->showIncidence(); | 2121 | mView->showIncidence(); |
2106 | break; | 2122 | break; |
2107 | case Qt::Key_Delete: | 2123 | case Qt::Key_Delete: |
2108 | case Qt::Key_Backspace: | 2124 | case Qt::Key_Backspace: |
2109 | mView->deleteIncidence(); | 2125 | mView->deleteIncidence(); |
2110 | break; | 2126 | break; |
2111 | case Qt::Key_D: | 2127 | case Qt::Key_D: |
2112 | mView->viewManager()->showDayView(); | 2128 | mView->viewManager()->showDayView(); |
2113 | showSelectedDates = true; | 2129 | showSelectedDates = true; |
2114 | break; | 2130 | break; |
2115 | case Qt::Key_O: | 2131 | case Qt::Key_O: |
2116 | mView->toggleFilerEnabled( ); | 2132 | mView->toggleFilerEnabled( ); |
2117 | break; | 2133 | break; |
2118 | case Qt::Key_0: | 2134 | case Qt::Key_0: |
2119 | case Qt::Key_1: | 2135 | case Qt::Key_1: |
2120 | case Qt::Key_2: | 2136 | case Qt::Key_2: |
2121 | case Qt::Key_3: | 2137 | case Qt::Key_3: |
2122 | case Qt::Key_4: | 2138 | case Qt::Key_4: |
2123 | case Qt::Key_5: | 2139 | case Qt::Key_5: |
2124 | case Qt::Key_6: | 2140 | case Qt::Key_6: |
2125 | case Qt::Key_7: | 2141 | case Qt::Key_7: |
2126 | case Qt::Key_8: | 2142 | case Qt::Key_8: |
2127 | case Qt::Key_9: | 2143 | case Qt::Key_9: |
2128 | pro = e->key()-48; | 2144 | pro = e->key()-48; |
2129 | if ( pro == 0 ) | 2145 | if ( pro == 0 ) |
2130 | pro = 10; | 2146 | pro = 10; |
2131 | if ( e->state() == Qt::ControlButton) | 2147 | if ( e->state() == Qt::ControlButton) |
2132 | pro += 10; | 2148 | pro += 10; |
2133 | break; | 2149 | break; |
2134 | case Qt::Key_M: | 2150 | case Qt::Key_M: |
2135 | mView->viewManager()->showMonthView(); | 2151 | mView->viewManager()->showMonthView(); |
2136 | showSelectedDates = true; | 2152 | showSelectedDates = true; |
2137 | break; | 2153 | break; |
2138 | case Qt::Key_Insert: | 2154 | case Qt::Key_Insert: |
2139 | mView->newEvent(); | 2155 | mView->newEvent(); |
2140 | break; | 2156 | break; |
2141 | case Qt::Key_S : | 2157 | case Qt::Key_S : |
2142 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2158 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2143 | mView->newSubTodo(); | 2159 | mView->newSubTodo(); |
2144 | else | 2160 | else |
2145 | mView->dialogManager()->showSearchDialog(); | 2161 | mView->dialogManager()->showSearchDialog(); |
2146 | break; | 2162 | break; |
2147 | case Qt::Key_Y : | 2163 | case Qt::Key_Y : |
2148 | case Qt::Key_Z : | 2164 | case Qt::Key_Z : |
2149 | mView->viewManager()->showWorkWeekView(); | 2165 | mView->viewManager()->showWorkWeekView(); |
2150 | showSelectedDates = true; | 2166 | showSelectedDates = true; |
2151 | break; | 2167 | break; |
2152 | case Qt::Key_U : | 2168 | case Qt::Key_U : |
2153 | mView->viewManager()->showWeekView(); | 2169 | mView->viewManager()->showWeekView(); |
2154 | showSelectedDates = true; | 2170 | showSelectedDates = true; |
2155 | break; | 2171 | break; |
2156 | case Qt::Key_H : | 2172 | case Qt::Key_H : |
2157 | keyBindings(); | 2173 | keyBindings(); |
2158 | break; | 2174 | break; |
2159 | case Qt::Key_W: | 2175 | case Qt::Key_W: |
2160 | mView->viewManager()->showWhatsNextView(); | 2176 | mView->viewManager()->showWhatsNextView(); |
2161 | break; | 2177 | break; |
2162 | case Qt::Key_L: | 2178 | case Qt::Key_L: |
2163 | mView->viewManager()->showListView(); | 2179 | mView->viewManager()->showListView(); |
2164 | break; | 2180 | break; |
2165 | case Qt::Key_N: | 2181 | case Qt::Key_N: |
2166 | mView->viewManager()->showNextView(); | 2182 | mView->viewManager()->showNextView(); |
2167 | break; | 2183 | break; |
2168 | case Qt::Key_V: | 2184 | case Qt::Key_V: |
2169 | mView->viewManager()->showTodoView(); | 2185 | mView->viewManager()->showTodoView(); |
2170 | break; | 2186 | break; |
2171 | case Qt::Key_C: | 2187 | case Qt::Key_C: |
2172 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 2188 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
2173 | break; | 2189 | break; |
2174 | case Qt::Key_P: | 2190 | case Qt::Key_P: |
2175 | mView->showDatePicker( ); | 2191 | mView->showDatePicker( ); |
2176 | break; | 2192 | break; |
2177 | case Qt::Key_F: | 2193 | case Qt::Key_F: |
2178 | mView->editFilters(); | 2194 | mView->editFilters(); |
2179 | break; | 2195 | break; |
2180 | case Qt::Key_R: | 2196 | case Qt::Key_R: |
2181 | mView->toggleFilter(); | 2197 | mView->toggleFilter(); |
2182 | break; | 2198 | break; |
2183 | case Qt::Key_X: | 2199 | case Qt::Key_X: |
2184 | if ( e->state() == Qt::ControlButton ) | 2200 | if ( e->state() == Qt::ControlButton ) |
2185 | mView->toggleDateNavigatorWidget(); | 2201 | mView->toggleDateNavigatorWidget(); |
2186 | else { | 2202 | else { |
2187 | mView->viewManager()->showNextXView(); | 2203 | mView->viewManager()->showNextXView(); |
2188 | showSelectedDates = true; | 2204 | showSelectedDates = true; |
2189 | } | 2205 | } |
2190 | break; | 2206 | break; |
2191 | case Qt::Key_Space: | 2207 | case Qt::Key_Space: |
2192 | mView->toggleExpand(); | 2208 | mView->toggleExpand(); |
2193 | break; | 2209 | break; |
2194 | case Qt::Key_A: | 2210 | case Qt::Key_A: |
2195 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2211 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2196 | mView->showNextAlarms(); | 2212 | mView->showNextAlarms(); |
2197 | else | 2213 | else |
2198 | mView->toggleAllDaySize(); | 2214 | mView->toggleAllDaySize(); |
2199 | break; | 2215 | break; |
2200 | case Qt::Key_T: | 2216 | case Qt::Key_T: |
2201 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2217 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2202 | mView->newTodo(); | 2218 | mView->newTodo(); |
2203 | else { | 2219 | else { |
2204 | mView->goToday(); | 2220 | mView->goToday(); |
2205 | showSelectedDates = true; | 2221 | showSelectedDates = true; |
2206 | } | 2222 | } |
2207 | break; | 2223 | break; |
2208 | case Qt::Key_Q: | 2224 | case Qt::Key_Q: |
2209 | if ( e->state() == Qt::ControlButton ) | 2225 | if ( e->state() == Qt::ControlButton ) |
2210 | mView->conflictNotAll(); | 2226 | mView->conflictNotAll(); |
2211 | else if ( e->state() == Qt::ShiftButton ) | 2227 | else if ( e->state() == Qt::ShiftButton ) |
2212 | mView->conflictAllday(); | 2228 | mView->conflictAllday(); |
2213 | else | 2229 | else |
2214 | mView->conflictAll(); | 2230 | mView->conflictAll(); |
2215 | break; | 2231 | break; |
2216 | case Qt::Key_J: | 2232 | case Qt::Key_J: |
2217 | mView->viewManager()->showJournalView(); | 2233 | mView->viewManager()->showJournalView(); |
2218 | break; | 2234 | break; |
2219 | case Qt::Key_B: | 2235 | case Qt::Key_B: |
2220 | mView->editIncidenceDescription();; | 2236 | mView->editIncidenceDescription();; |
2221 | break; | 2237 | break; |
2222 | // case Qt::Key_Return: | 2238 | // case Qt::Key_Return: |
2223 | case Qt::Key_E: | 2239 | case Qt::Key_E: |
2224 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2240 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2225 | mView->newEvent(); | 2241 | mView->newEvent(); |
2226 | else | 2242 | else |
2227 | mView->editIncidence(); | 2243 | mView->editIncidence(); |
2228 | break; | 2244 | break; |
2229 | case Qt::Key_Plus: | 2245 | case Qt::Key_Plus: |
2230 | size = p->mHourSize +2; | 2246 | size = p->mHourSize +2; |
2231 | if ( size <= 22 ) | 2247 | if ( size <= 22 ) |
2232 | configureAgenda( size ); | 2248 | configureAgenda( size ); |
2233 | break; | 2249 | break; |
2234 | case Qt::Key_Minus: | 2250 | case Qt::Key_Minus: |
2235 | size = p->mHourSize - 2; | 2251 | size = p->mHourSize - 2; |
2236 | if ( size >= 4 ) | 2252 | if ( size >= 4 ) |
2237 | configureAgenda( size ); | 2253 | configureAgenda( size ); |
2238 | break; | 2254 | break; |
2239 | 2255 | ||
2240 | 2256 | ||
2241 | default: | 2257 | default: |
2242 | e->ignore(); | 2258 | e->ignore(); |
2243 | } | 2259 | } |
2244 | if ( pro > 0 ) { | 2260 | if ( pro > 0 ) { |
2245 | selectFilter( pro+1 ); | 2261 | selectFilter( pro+1 ); |
2246 | } | 2262 | } |
2247 | if ( showSelectedDates ) { | 2263 | if ( showSelectedDates ) { |
2248 | ;// setCaptionToDates(); | 2264 | ;// setCaptionToDates(); |
2249 | } | 2265 | } |
2250 | 2266 | ||
2251 | } | 2267 | } |
2252 | void MainWindow::fillFilterMenuTB() | 2268 | void MainWindow::fillFilterMenuTB() |
2253 | { | 2269 | { |
2254 | selectFilterMenuTB->clear(); | 2270 | selectFilterMenuTB->clear(); |
2255 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2271 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2256 | selectFilterMenuTB->insertSeparator(); | 2272 | selectFilterMenuTB->insertSeparator(); |
2257 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2273 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2258 | 2274 | ||
2259 | selectFilterMenuTB->insertSeparator(); | 2275 | selectFilterMenuTB->insertSeparator(); |
2260 | QPtrList<CalFilter> fili = mView->filters(); | 2276 | QPtrList<CalFilter> fili = mView->filters(); |
2261 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2277 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2262 | CalFilter *filter = fili.first(); | 2278 | CalFilter *filter = fili.first(); |
2263 | int iii = 2; | 2279 | int iii = 2; |
2264 | bool checkitem = mView->filterView()->filtersEnabled(); | 2280 | bool checkitem = mView->filterView()->filtersEnabled(); |
2265 | while(filter) { | 2281 | while(filter) { |
2266 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2282 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2267 | if ( filter == curfilter) | 2283 | if ( filter == curfilter) |
2268 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2284 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2269 | filter = fili.next(); | 2285 | filter = fili.next(); |
2270 | ++iii; | 2286 | ++iii; |
2271 | } | 2287 | } |
2272 | if ( !checkitem ) | 2288 | if ( !checkitem ) |
2273 | selectFilterMenuTB->setItemChecked( 1, true ); | 2289 | selectFilterMenuTB->setItemChecked( 1, true ); |
2274 | 2290 | ||
2275 | int x = 0; | 2291 | int x = 0; |
2276 | int y = iconToolBar->height(); | 2292 | int y = iconToolBar->height(); |
2277 | int dX = 0; | 2293 | int dX = 0; |
2278 | int dY = 0; | 2294 | int dY = 0; |
2279 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2295 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2280 | if ( iconToolBar->y() > height()/2 ) { | 2296 | if ( iconToolBar->y() > height()/2 ) { |
2281 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2297 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2282 | y = 0; | 2298 | y = 0; |
2283 | } | 2299 | } |
2284 | } else { | 2300 | } else { |
2285 | if ( iconToolBar->x() > width()/2 ) { // right side | 2301 | if ( iconToolBar->x() > width()/2 ) { // right side |
2286 | x=0; | 2302 | x=0; |
2287 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2303 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2288 | y = 0; | 2304 | y = 0; |
2289 | } else { | 2305 | } else { |
2290 | x= iconToolBar->width(); | 2306 | x= iconToolBar->width(); |
2291 | y = 0; | 2307 | y = 0; |
2292 | } | 2308 | } |
2293 | } | 2309 | } |
2294 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2310 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2295 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2311 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2296 | } | 2312 | } |
2297 | void MainWindow::fillFilterMenu() | 2313 | void MainWindow::fillFilterMenu() |
2298 | { | 2314 | { |
2299 | selectFilterMenu->clear(); | 2315 | selectFilterMenu->clear(); |
2300 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2316 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2301 | selectFilterMenu->insertSeparator(); | 2317 | selectFilterMenu->insertSeparator(); |
2302 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2318 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2303 | 2319 | ||
2304 | selectFilterMenu->insertSeparator(); | 2320 | selectFilterMenu->insertSeparator(); |
2305 | QPtrList<CalFilter> fili = mView->filters(); | 2321 | QPtrList<CalFilter> fili = mView->filters(); |
2306 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2322 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2307 | CalFilter *filter = fili.first(); | 2323 | CalFilter *filter = fili.first(); |
2308 | int iii = 2; | 2324 | int iii = 2; |
2309 | bool checkitem = mView->filterView()->filtersEnabled(); | 2325 | bool checkitem = mView->filterView()->filtersEnabled(); |
2310 | while(filter) { | 2326 | while(filter) { |
2311 | selectFilterMenu->insertItem( filter->name(), iii ); | 2327 | selectFilterMenu->insertItem( filter->name(), iii ); |
2312 | if ( filter == curfilter) | 2328 | if ( filter == curfilter) |
2313 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2329 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2314 | filter = fili.next(); | 2330 | filter = fili.next(); |
2315 | ++iii; | 2331 | ++iii; |
2316 | } | 2332 | } |
2317 | if ( !checkitem ) | 2333 | if ( !checkitem ) |
2318 | selectFilterMenu->setItemChecked( 1, true ); | 2334 | selectFilterMenu->setItemChecked( 1, true ); |
2319 | } | 2335 | } |
2320 | void MainWindow::fillFilterMenuPopup() | 2336 | void MainWindow::fillFilterMenuPopup() |
2321 | { | 2337 | { |
2322 | filterPopupMenu->clear(); | 2338 | filterPopupMenu->clear(); |
2323 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2339 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2324 | 2340 | ||
2325 | filterPopupMenu->insertSeparator(); | 2341 | filterPopupMenu->insertSeparator(); |
2326 | QPtrList<CalFilter> fili = mView->filters(); | 2342 | QPtrList<CalFilter> fili = mView->filters(); |
2327 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2343 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2328 | CalFilter *filter = fili.first(); | 2344 | CalFilter *filter = fili.first(); |
2329 | int iii = 1; | 2345 | int iii = 1; |
2330 | bool checkitem = mView->filterView()->filtersEnabled(); | 2346 | bool checkitem = mView->filterView()->filtersEnabled(); |
2331 | while(filter) { | 2347 | while(filter) { |
2332 | filterPopupMenu->insertItem( filter->name(), iii ); | 2348 | filterPopupMenu->insertItem( filter->name(), iii ); |
2333 | if ( filter == curfilter) | 2349 | if ( filter == curfilter) |
2334 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2350 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2335 | filter = fili.next(); | 2351 | filter = fili.next(); |
2336 | ++iii; | 2352 | ++iii; |
2337 | } | 2353 | } |
2338 | if ( !checkitem ) | 2354 | if ( !checkitem ) |
2339 | filterPopupMenu->setItemChecked( 0, true ); | 2355 | filterPopupMenu->setItemChecked( 0, true ); |
2340 | } | 2356 | } |
2341 | void MainWindow::selectFilter( int fil ) | 2357 | void MainWindow::selectFilter( int fil ) |
2342 | { | 2358 | { |
2343 | 2359 | ||
2344 | if ( fil == 0 ) { | 2360 | if ( fil == 0 ) { |
2345 | mView->editFilters( ); | 2361 | mView->editFilters( ); |
2346 | } else if ( fil == 1 ){ | 2362 | } else if ( fil == 1 ){ |
2347 | if ( mView->filterView()->filtersEnabled() ) | 2363 | if ( mView->filterView()->filtersEnabled() ) |
2348 | mView->toggleFilerEnabled( ); | 2364 | mView->toggleFilerEnabled( ); |
2349 | } else { | 2365 | } else { |
2350 | if ( !mView->filterView()->filtersEnabled() ) { | 2366 | if ( !mView->filterView()->filtersEnabled() ) { |
2351 | mView->filterView()->blockSignals( true ); | 2367 | mView->filterView()->blockSignals( true ); |
2352 | mView->toggleFilerEnabled( ); | 2368 | mView->toggleFilerEnabled( ); |
2353 | mView->filterView()->blockSignals( false ); | 2369 | mView->filterView()->blockSignals( false ); |
2354 | } | 2370 | } |
2355 | mView->selectFilter( fil-2 ); | 2371 | mView->selectFilter( fil-2 ); |
2356 | } | 2372 | } |
2357 | } | 2373 | } |
2358 | void MainWindow::updateFilterToolbar() | 2374 | void MainWindow::updateFilterToolbar() |
2359 | { | 2375 | { |
2360 | if ( filterMenubar ) { | 2376 | if ( filterMenubar ) { |
2361 | if ( !mView->filterView()->filtersEnabled() ) { | 2377 | if ( !mView->filterView()->filtersEnabled() ) { |
2362 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2378 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2363 | } else { | 2379 | } else { |
2364 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2380 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2365 | if ( curfilter ) { | 2381 | if ( curfilter ) { |
2366 | QString name = curfilter->name(); | 2382 | QString name = curfilter->name(); |
2367 | if ( name.length() > 12 ) | 2383 | if ( name.length() > 12 ) |
2368 | name = name.left(10)+"..."; | 2384 | name = name.left(10)+"..."; |
2369 | filterMenubar->changeItem( 0, name ); | 2385 | filterMenubar->changeItem( 0, name ); |
2370 | } | 2386 | } |
2371 | } | 2387 | } |
2372 | } | 2388 | } |
2373 | } | 2389 | } |
2374 | void MainWindow::selectFilterPopup( int fil ) | 2390 | void MainWindow::selectFilterPopup( int fil ) |
2375 | { | 2391 | { |
2376 | selectFilter( fil + 1 ); | 2392 | selectFilter( fil + 1 ); |
2377 | 2393 | ||
2378 | } | 2394 | } |
2379 | void MainWindow::configureToolBar( int item ) | 2395 | void MainWindow::configureToolBar( int item ) |
2380 | { | 2396 | { |
2381 | 2397 | ||
2382 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2398 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2383 | KOPrefs *p = KOPrefs::instance(); | 2399 | KOPrefs *p = KOPrefs::instance(); |
2384 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2400 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2385 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2401 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2386 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2402 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2387 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2403 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2388 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2404 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2389 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2405 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2390 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2406 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2391 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2407 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2392 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2408 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2393 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2409 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2394 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2410 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2395 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2411 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2396 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2412 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2397 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2413 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2398 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2414 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2399 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2415 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2400 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2416 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2401 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2417 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2402 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2418 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2403 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2419 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2404 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2420 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2405 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2421 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2406 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2422 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2407 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2423 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2408 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2424 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2409 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2425 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2410 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2426 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2411 | // initActions(); | 2427 | // initActions(); |
2412 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2428 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2413 | } | 2429 | } |
2414 | void MainWindow::setCaption ( const QString & c ) | 2430 | void MainWindow::setCaption ( const QString & c ) |
2415 | { | 2431 | { |
2416 | QString cap = c; | 2432 | QString cap = c; |
2417 | cap.replace( QRegExp("\n"), " " ); | 2433 | cap.replace( QRegExp("\n"), " " ); |
2418 | cap = cap.stripWhiteSpace(); | 2434 | cap = cap.stripWhiteSpace(); |
2419 | if ( cap.isEmpty() ) | 2435 | if ( cap.isEmpty() ) |
2420 | cap = "KO/Pi"; | 2436 | cap = "KO/Pi"; |
2421 | QWidget::setCaption( cap ); | 2437 | QWidget::setCaption( cap ); |
2422 | } | 2438 | } |
2423 | void MainWindow::setCaptionToDates() | 2439 | void MainWindow::setCaptionToDates() |
2424 | { | 2440 | { |
2425 | QString selDates; | 2441 | QString selDates; |
2426 | QDate date = mView->startDate(); | 2442 | QDate date = mView->startDate(); |
2427 | if ( ! date.isValid() ) { | 2443 | if ( ! date.isValid() ) { |
2428 | setCaption(""); | 2444 | setCaption(""); |
2429 | return; | 2445 | return; |
2430 | } | 2446 | } |
2431 | selDates = KGlobal::locale()->formatDate( date, true); | 2447 | selDates = KGlobal::locale()->formatDate( date, true); |
2432 | if (mView->startDate() < mView->endDate() ) | 2448 | if (mView->startDate() < mView->endDate() ) |
2433 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2449 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2434 | else { | 2450 | else { |
2435 | QString addString; | 2451 | QString addString; |
2436 | if ( date == QDateTime::currentDateTime().date() ) | 2452 | if ( date == QDateTime::currentDateTime().date() ) |
2437 | addString = i18n("Today"); | 2453 | addString = i18n("Today"); |
2438 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2454 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2439 | addString = i18n("Tomorrow"); | 2455 | addString = i18n("Tomorrow"); |
2440 | if ( !addString.isEmpty() ) | 2456 | if ( !addString.isEmpty() ) |
2441 | selDates = addString+", "+selDates ; | 2457 | selDates = addString+", "+selDates ; |
2442 | } | 2458 | } |
2443 | setCaption( i18n("Dates: ") + selDates ); | 2459 | setCaption( i18n("Dates: ") + selDates ); |
2444 | 2460 | ||
2445 | } | 2461 | } |
2446 | void MainWindow::showConfigureAgenda( ) | 2462 | void MainWindow::showConfigureAgenda( ) |
2447 | { | 2463 | { |
2448 | int iii; | 2464 | int iii; |
2449 | for ( iii = 1;iii<= 10 ;++iii ){ | 2465 | for ( iii = 1;iii<= 10 ;++iii ){ |
2450 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2466 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2451 | } | 2467 | } |
2452 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2468 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2453 | } | 2469 | } |
2454 | void MainWindow::configureAgenda( int item ) | 2470 | void MainWindow::configureAgenda( int item ) |
2455 | { | 2471 | { |
2456 | if ( KOPrefs::instance()->mHourSize == item ) | 2472 | if ( KOPrefs::instance()->mHourSize == item ) |
2457 | return; | 2473 | return; |
2458 | KOPrefs::instance()->mHourSize=item; | 2474 | KOPrefs::instance()->mHourSize=item; |
2459 | mView->viewManager()->agendaView()->updateConfig(); | 2475 | mView->viewManager()->agendaView()->updateConfig(); |
2460 | } | 2476 | } |
2461 | 2477 | ||
2462 | void MainWindow::saveCalendar() | 2478 | void MainWindow::saveCalendar() |
2463 | { | 2479 | { |
2464 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2480 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2465 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2481 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2466 | bupDir = KGlobalSettings::backupDataDir(); | 2482 | bupDir = KGlobalSettings::backupDataDir(); |
2467 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2483 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2468 | QString bupHint; | 2484 | QString bupHint; |
2469 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2485 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2470 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); | 2486 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); |
2471 | 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; | 2487 | 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; |
2472 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2488 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2473 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2489 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2474 | save(); | 2490 | save(); |
2475 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2491 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2476 | backupAllFiles(); | 2492 | backupAllFiles(); |
2477 | } | 2493 | } |
2478 | void MainWindow::loadCalendar() | 2494 | void MainWindow::loadCalendar() |
2479 | { | 2495 | { |
2480 | 2496 | ||
2481 | 2497 | ||
2482 | #if 0 | 2498 | #if 0 |
2483 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2499 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2484 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2500 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2485 | 2501 | ||
2486 | if ( fn == "" ) | 2502 | if ( fn == "" ) |
2487 | return; | 2503 | return; |
2488 | QFileInfo info; | 2504 | QFileInfo info; |
2489 | info.setFile( fn ); | 2505 | info.setFile( fn ); |
2490 | QString mess; | 2506 | QString mess; |
2491 | bool loadbup = true; | 2507 | bool loadbup = true; |
2492 | if ( info. exists() ) { | 2508 | if ( info. exists() ) { |
2493 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2509 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2494 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2510 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2495 | mess, | 2511 | mess, |
2496 | i18n("Load!"), i18n("Cancel"), 0, | 2512 | i18n("Load!"), i18n("Cancel"), 0, |
2497 | 0, 1 ); | 2513 | 0, 1 ); |
2498 | if ( result != 0 ) { | 2514 | if ( result != 0 ) { |
2499 | loadbup = false; | 2515 | loadbup = false; |
2500 | } | 2516 | } |
2501 | } else { | 2517 | } else { |
2502 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2518 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2503 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2519 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2504 | 0, 1 ); | 2520 | 0, 1 ); |
2505 | 2521 | ||
2506 | return; | 2522 | return; |
2507 | } | 2523 | } |
2508 | if ( loadbup ) { | 2524 | if ( loadbup ) { |
2509 | mView->openCalendar( fn ); | 2525 | mView->openCalendar( fn ); |
2510 | KOPrefs::instance()->mLastLoadFile = fn; | 2526 | KOPrefs::instance()->mLastLoadFile = fn; |
2511 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2527 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2512 | setCaption(mess); | 2528 | setCaption(mess); |
2513 | } | 2529 | } |
2514 | #endif | 2530 | #endif |
2515 | 2531 | ||
2516 | } | 2532 | } |
2517 | void MainWindow::quickImportIcal() | 2533 | void MainWindow::quickImportIcal() |
2518 | { | 2534 | { |
2519 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2535 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2520 | } | 2536 | } |
2521 | void MainWindow::importFile( QString fn, bool quick ) | 2537 | void MainWindow::importFile( QString fn, bool quick ) |
2522 | { | 2538 | { |
2523 | QFileInfo info; | 2539 | QFileInfo info; |
2524 | info.setFile( fn ); | 2540 | info.setFile( fn ); |
2525 | QString mess; | 2541 | QString mess; |
2526 | if ( !info. exists() ) { | 2542 | if ( !info. exists() ) { |
2527 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2543 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2528 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2544 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2529 | mess ); | 2545 | mess ); |
2530 | return; | 2546 | return; |
2531 | } | 2547 | } |
2532 | int result = 0; | 2548 | int result = 0; |
2533 | if ( !quick ) { | 2549 | if ( !quick ) { |
2534 | 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 )); | 2550 | 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 )); |
2535 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2551 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2536 | mess, | 2552 | mess, |
2537 | "Import", "Cancel", 0, | 2553 | "Import", "Cancel", 0, |
2538 | 0, 1 ); | 2554 | 0, 1 ); |
2539 | } | 2555 | } |
2540 | if ( result == 0 ) { | 2556 | if ( result == 0 ) { |
2541 | if ( mView->openCalendar( fn, true )) { | 2557 | if ( mView->openCalendar( fn, true )) { |
2542 | KOPrefs::instance()->mLastImportFile = fn; | 2558 | KOPrefs::instance()->mLastImportFile = fn; |
2543 | setCaption(i18n("Imported file successfully")); | 2559 | setCaption(i18n("Imported file successfully")); |
2544 | } else { | 2560 | } else { |
2545 | setCaption(i18n("Error importing file")); | 2561 | setCaption(i18n("Error importing file")); |
2546 | } | 2562 | } |
2547 | mView->updateView(); | 2563 | mView->updateView(); |
2548 | } | 2564 | } |
2549 | } | 2565 | } |
2550 | 2566 | ||
2551 | void MainWindow::importIcal() | 2567 | void MainWindow::importIcal() |
2552 | { | 2568 | { |
2553 | 2569 | ||
2554 | QString fn =KOPrefs::instance()->mLastImportFile; | 2570 | QString fn =KOPrefs::instance()->mLastImportFile; |
2555 | 2571 | ||
2556 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2572 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2557 | if ( fn == "" ) | 2573 | if ( fn == "" ) |
2558 | return; | 2574 | return; |
2559 | importFile( fn, true ); | 2575 | importFile( fn, true ); |
2560 | 2576 | ||
2561 | } | 2577 | } |
2562 | 2578 | ||
2563 | void MainWindow::exportVCalendar() | 2579 | void MainWindow::exportVCalendar() |
2564 | { | 2580 | { |
2565 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2581 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2566 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2582 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2567 | if ( fn == "" ) | 2583 | if ( fn == "" ) |
2568 | return; | 2584 | return; |
2569 | QFileInfo info; | 2585 | QFileInfo info; |
2570 | info.setFile( fn ); | 2586 | info.setFile( fn ); |
2571 | QString mes; | 2587 | QString mes; |
2572 | bool createbup = true; | 2588 | bool createbup = true; |
2573 | if ( info. exists() ) { | 2589 | if ( info. exists() ) { |
2574 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2590 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2575 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2591 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2576 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2592 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2577 | 0, 1 ); | 2593 | 0, 1 ); |
2578 | if ( result != 0 ) { | 2594 | if ( result != 0 ) { |
2579 | createbup = false; | 2595 | createbup = false; |
2580 | } | 2596 | } |
2581 | } | 2597 | } |
2582 | if ( createbup ) { | 2598 | if ( createbup ) { |
2583 | if ( mView->exportVCalendar( fn ) ) { | 2599 | if ( mView->exportVCalendar( fn ) ) { |
2584 | KOPrefs::instance()->mLastVcalFile = fn; | 2600 | KOPrefs::instance()->mLastVcalFile = fn; |
2585 | if ( fn.length() > 20 ) | 2601 | if ( fn.length() > 20 ) |
2586 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2602 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2587 | else | 2603 | else |
2588 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2604 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2589 | setCaption(mes); | 2605 | setCaption(mes); |
2590 | } | 2606 | } |
2591 | } | 2607 | } |
2592 | 2608 | ||
2593 | } | 2609 | } |
2594 | QString MainWindow::sentSyncFile() | 2610 | QString MainWindow::sentSyncFile() |
2595 | { | 2611 | { |
2596 | #ifdef DESKTOP_VERSION | 2612 | #ifdef DESKTOP_VERSION |
2597 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); | 2613 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); |
2598 | #else | 2614 | #else |
2599 | return QString( "/tmp/copysynccal.ics" ); | 2615 | return QString( "/tmp/copysynccal.ics" ); |
2600 | #endif | 2616 | #endif |
2601 | } | 2617 | } |
2602 | 2618 | ||
2603 | void MainWindow::syncFileRequest() | 2619 | void MainWindow::syncFileRequest() |
2604 | { | 2620 | { |
2605 | while ( mSyncManager->blockSave() ) { | 2621 | while ( mSyncManager->blockSave() ) { |
2606 | qApp->processEvents(); | 2622 | qApp->processEvents(); |
2607 | } | 2623 | } |
2608 | mSyncManager->setBlockSave(true); | 2624 | mSyncManager->setBlockSave(true); |
2609 | 2625 | ||
2610 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2626 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2611 | mSyncManager->slotSyncMenu( 999 ); | 2627 | mSyncManager->slotSyncMenu( 999 ); |
2612 | } | 2628 | } |
2613 | 2629 | ||
2614 | setCaption(i18n("Saving Data to temp file ..." )); | 2630 | setCaption(i18n("Saving Data to temp file ..." )); |
2615 | mView->saveCalendar( sentSyncFile() ); | 2631 | mView->saveCalendar( sentSyncFile() ); |
2616 | setCaption(i18n("Data saved to temp file!" )); | 2632 | setCaption(i18n("Data saved to temp file!" )); |
2617 | mSyncManager->setBlockSave( false ); | 2633 | mSyncManager->setBlockSave( false ); |
2618 | 2634 | ||
2619 | } | 2635 | } |
2620 | void MainWindow::getFile( bool success ) | 2636 | void MainWindow::getFile( bool success ) |
2621 | { | 2637 | { |
2622 | if ( ! success ) { | 2638 | if ( ! success ) { |
2623 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2639 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2624 | return; | 2640 | return; |
2625 | } | 2641 | } |
2626 | mView->mergeFile( sentSyncFile() ); | 2642 | mView->mergeFile( sentSyncFile() ); |
2627 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2643 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2628 | mSyncManager->slotSyncMenu( 999 ); | 2644 | mSyncManager->slotSyncMenu( 999 ); |
2629 | } | 2645 | } |
2630 | setCaption( i18n("Pi-Sync successful!") ); | 2646 | setCaption( i18n("Pi-Sync successful!") ); |
2631 | } | 2647 | } |
2632 | void MainWindow::printListView() | 2648 | void MainWindow::printListView() |
2633 | { | 2649 | { |
2634 | 2650 | ||
2635 | 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."); | 2651 | 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."); |
2636 | 2652 | ||
2637 | KMessageBox::information( this, message); | 2653 | KMessageBox::information( this, message); |
2638 | } | 2654 | } |
2639 | void MainWindow::printSel( ) | 2655 | void MainWindow::printSel( ) |
2640 | { | 2656 | { |
2641 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2657 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2642 | } | 2658 | } |
2643 | 2659 | ||
2644 | void MainWindow::printCal() | 2660 | void MainWindow::printCal() |
2645 | { | 2661 | { |
2646 | mView->print();//mCp->showDialog(); | 2662 | mView->print();//mCp->showDialog(); |
2647 | } | 2663 | } |
2648 | 2664 | ||
2649 | 2665 | ||
2650 | #include "libkdepim/kdatepicker.h" | 2666 | #include "libkdepim/kdatepicker.h" |
2651 | #include <kdatetbl.h> | 2667 | #include <kdatetbl.h> |
2652 | 2668 | ||
2653 | void MainWindow::weekAction() | 2669 | void MainWindow::weekAction() |
2654 | { | 2670 | { |
2655 | int month; | 2671 | int month; |
2656 | KPopupFrame* popup = new KPopupFrame(this); | 2672 | KPopupFrame* popup = new KPopupFrame(this); |
2657 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2673 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2658 | // ----- | 2674 | // ----- |
2659 | picker->resize(picker->sizeHint()); | 2675 | picker->resize(picker->sizeHint()); |
2660 | popup->setMainWidget(picker); | 2676 | popup->setMainWidget(picker); |
2661 | picker->setFocus(); | 2677 | picker->setFocus(); |
2662 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2678 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2663 | int x = 0; | 2679 | int x = 0; |
2664 | int y = iconToolBar->height(); | 2680 | int y = iconToolBar->height(); |
2665 | int dX = 0; | 2681 | int dX = 0; |
2666 | int dY = 0; | 2682 | int dY = 0; |
2667 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2683 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2668 | if ( iconToolBar->y() > height()/2 ) { | 2684 | if ( iconToolBar->y() > height()/2 ) { |
2669 | dY = picker->sizeHint().height()+8; | 2685 | dY = picker->sizeHint().height()+8; |
2670 | y = 0; | 2686 | y = 0; |
2671 | } | 2687 | } |
2672 | } else { | 2688 | } else { |
2673 | if ( iconToolBar->x() > width()/2 ) { // right side | 2689 | if ( iconToolBar->x() > width()/2 ) { // right side |
2674 | x=0; | 2690 | x=0; |
2675 | dX= picker->sizeHint().width()+8; | 2691 | dX= picker->sizeHint().width()+8; |
2676 | y = 0; | 2692 | y = 0; |
2677 | } else { | 2693 | } else { |
2678 | x= iconToolBar->width(); | 2694 | x= iconToolBar->width(); |
2679 | y = 0; | 2695 | y = 0; |
2680 | } | 2696 | } |
2681 | } | 2697 | } |
2682 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2698 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2683 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2699 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2684 | { | 2700 | { |
2685 | month = picker->getResult(); | 2701 | month = picker->getResult(); |
2686 | emit selectWeek ( month ); | 2702 | emit selectWeek ( month ); |
2687 | //qDebug("weekSelected %d ", month); | 2703 | //qDebug("weekSelected %d ", month); |
2688 | } | 2704 | } |
2689 | delete popup; | 2705 | delete popup; |
2690 | } | 2706 | } |
2691 | 2707 | ||
2692 | void MainWindow::hideEvent ( QHideEvent * ) | 2708 | void MainWindow::hideEvent ( QHideEvent * ) |
2693 | { | 2709 | { |
2694 | QString message; | 2710 | QString message; |
2695 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2711 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2696 | if ( nextA.isValid() ) { | 2712 | if ( nextA.isValid() ) { |
2697 | QString sum = mCalendar->nextSummary(); | 2713 | QString sum = mCalendar->nextSummary(); |
2698 | 2714 | ||
2699 | 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)); | 2715 | 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)); |
2700 | setCaption( message ); | 2716 | setCaption( message ); |
2701 | } | 2717 | } |
2702 | } | 2718 | } |
2703 | 2719 | ||
2704 | void MainWindow::resizeEvent( QResizeEvent* e) | 2720 | void MainWindow::resizeEvent( QResizeEvent* e) |
2705 | { | 2721 | { |
2706 | #ifndef DESKTOP_VERSION | 2722 | #ifndef DESKTOP_VERSION |
2707 | if ( filterToolBar ) { | 2723 | if ( filterToolBar ) { |
2708 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2724 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2709 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2725 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2710 | filterToolBar->hide(); | 2726 | filterToolBar->hide(); |
2711 | else | 2727 | else |
2712 | filterToolBar->show(); | 2728 | filterToolBar->show(); |
2713 | } | 2729 | } |
2714 | } | 2730 | } |
2715 | #endif | 2731 | #endif |
2716 | QMainWindow::resizeEvent( e); | 2732 | QMainWindow::resizeEvent( e); |
2717 | } | 2733 | } |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index fdcf7c4..657c0a8 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,184 +1,186 @@ | |||
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 loadDataAfterStart(); | 55 | void loadDataAfterStart(); |
56 | void calHint(); | 56 | void calHint(); |
57 | void startMultiSync(); | 57 | void startMultiSync(); |
58 | void setCaptionToDates(); | 58 | void setCaptionToDates(); |
59 | void weekAction(); | 59 | void weekAction(); |
60 | void about(); | 60 | void about(); |
61 | void licence(); | 61 | void licence(); |
62 | void faq(); | 62 | void faq(); |
63 | void usertrans(); | 63 | void usertrans(); |
64 | void features(); | 64 | void features(); |
65 | void synchowto(); | 65 | void synchowto(); |
66 | void storagehowto(); | 66 | void storagehowto(); |
67 | void timetrackinghowto(); | 67 | void timetrackinghowto(); |
68 | void kdesynchowto(); | 68 | void kdesynchowto(); |
69 | void multisynchowto(); | 69 | void multisynchowto(); |
70 | void whatsNew(); | 70 | void whatsNew(); |
71 | void keyBindings(); | 71 | void keyBindings(); |
72 | void aboutAutoSaving();; | 72 | void aboutAutoSaving();; |
73 | void aboutKnownBugs(); | 73 | void aboutKnownBugs(); |
74 | 74 | ||
75 | void processIncidenceSelection( Incidence * ); | 75 | void processIncidenceSelection( Incidence * ); |
76 | 76 | ||
77 | void importQtopia(); | 77 | void importQtopia(); |
78 | void importBday(); | 78 | void importBday(); |
79 | void importOL(); | 79 | void importOL(); |
80 | void importIcal(); | 80 | void importIcal(); |
81 | void importFile( QString, bool ); | 81 | void importFile( QString, bool ); |
82 | void quickImportIcal(); | 82 | void quickImportIcal(); |
83 | 83 | ||
84 | void slotModifiedChanged( bool ); | 84 | void slotModifiedChanged( bool ); |
85 | 85 | ||
86 | void save(); | 86 | void save(); |
87 | void backupAllFiles(); | 87 | void backupAllFiles(); |
88 | void saveStopTimer(); | 88 | void saveStopTimer(); |
89 | void configureToolBar( int ); | 89 | void configureToolBar( int ); |
90 | void printSel(); | 90 | void printSel(); |
91 | void printCal(); | 91 | void printCal(); |
92 | void printListView(); | 92 | void printListView(); |
93 | void saveCalendar(); | 93 | void saveCalendar(); |
94 | void loadCalendar(); | 94 | void loadCalendar(); |
95 | void exportVCalendar(); | 95 | void exportVCalendar(); |
96 | void fillFilterMenu(); | 96 | void fillFilterMenu(); |
97 | void fillFilterMenuTB(); | 97 | void fillFilterMenuTB(); |
98 | void selectFilter( int ); | 98 | void selectFilter( int ); |
99 | void fillFilterMenuPopup(); | 99 | void fillFilterMenuPopup(); |
100 | void selectFilterPopup( int ); | 100 | void selectFilterPopup( int ); |
101 | void exportToPhone( int ); | 101 | void exportToPhone( int ); |
102 | void toggleBeamReceive(); | 102 | void toggleBeamReceive(); |
103 | void disableBR(bool); | 103 | void disableBR(bool); |
104 | signals: | 104 | signals: |
105 | void selectWeek ( int ); | 105 | void selectWeek ( int ); |
106 | private slots: | 106 | private slots: |
107 | void slotResetFocus(); | 107 | void slotResetFocus(); |
108 | void slotResetFocusLoop(); | 108 | void slotResetFocusLoop(); |
109 | void showConfigureAgenda(); | 109 | void showConfigureAgenda(); |
110 | void getFile( bool ); | 110 | void getFile( bool ); |
111 | void syncFileRequest(); | 111 | void syncFileRequest(); |
112 | 112 | ||
113 | protected: | 113 | protected: |
114 | int mFocusLoop; | 114 | int mFocusLoop; |
115 | void hideEvent ( QHideEvent * ); | 115 | void hideEvent ( QHideEvent * ); |
116 | QString sentSyncFile(); | 116 | QString sentSyncFile(); |
117 | void displayText( QString, QString); | 117 | void displayText( QString, QString); |
118 | void enableIncidenceActions( bool ); | 118 | void enableIncidenceActions( bool ); |
119 | 119 | ||
120 | private: | 120 | private: |
121 | 121 | ||
122 | QCString mCStringMess; | 122 | QCString mCStringMess; |
123 | QByteArray mByteData; | 123 | QByteArray mByteData; |
124 | 124 | ||
125 | //void setMenuBar( QMenuBar * ); | 125 | //void setMenuBar( QMenuBar * ); |
126 | bool mBRdisabled; | 126 | bool mBRdisabled; |
127 | #ifndef DESKTOP_VERSION | 127 | #ifndef DESKTOP_VERSION |
128 | QCopChannel* infrared; | 128 | QCopChannel* infrared; |
129 | #endif | 129 | #endif |
130 | QAction* brAction; | 130 | QAction* brAction; |
131 | KSyncManager* mSyncManager; | 131 | KSyncManager* mSyncManager; |
132 | bool mClosed; | 132 | bool mClosed; |
133 | void saveOnClose(); | 133 | void saveOnClose(); |
134 | bool mFlagKeyPressed; | 134 | bool mFlagKeyPressed; |
135 | bool mBlockAtStartup; | 135 | bool mBlockAtStartup; |
136 | KMenuBar *menuBar1; | 136 | KMenuBar *menuBar1; |
137 | QPEToolBar *iconToolBar; | 137 | QPEToolBar *iconToolBar; |
138 | QPEToolBar *viewToolBar; | 138 | QPEToolBar *viewToolBar; |
139 | QPEToolBar *navigatorToolBar; | 139 | QPEToolBar *navigatorToolBar; |
140 | QPEToolBar *filterToolBar; | 140 | QPEToolBar *filterToolBar; |
141 | KMenuBar *filterMenubar; | 141 | KMenuBar *filterMenubar; |
142 | QPopupMenu * filterPopupMenu; | 142 | QPopupMenu * filterPopupMenu; |
143 | QPopupMenu * mCurrentItemMenu; | 143 | QPopupMenu * mCurrentItemMenu; |
144 | void initActions(); | 144 | void initActions(); |
145 | void setDefaultPreferences(); | 145 | void setDefaultPreferences(); |
146 | void resizeEvent( QResizeEvent* e); | 146 | void resizeEvent( QResizeEvent* e); |
147 | void keyPressEvent ( QKeyEvent * ) ; | 147 | void keyPressEvent ( QKeyEvent * ) ; |
148 | void keyReleaseEvent ( QKeyEvent * ) ; | 148 | void keyReleaseEvent ( QKeyEvent * ) ; |
149 | QPopupMenu *configureToolBarMenu; | 149 | QPopupMenu *configureToolBarMenu; |
150 | QPopupMenu *selectFilterMenu; | 150 | QPopupMenu *selectFilterMenu; |
151 | QPopupMenu *selectFilterMenuTB; | 151 | QPopupMenu *selectFilterMenuTB; |
152 | QPopupMenu *configureAgendaMenu, *syncMenu; | 152 | QPopupMenu *configureAgendaMenu, *syncMenu; |
153 | CalendarLocal *mCalendar; | 153 | CalendarLocal *mCalendar; |
154 | CalendarView *mView; | 154 | CalendarView *mView; |
155 | QAction *mNewSubTodoAction; | 155 | QAction *mNewSubTodoAction; |
156 | QAction *mWeekAction; | 156 | QAction *mWeekAction; |
157 | QFont mWeekFont; | 157 | QFont mWeekFont; |
158 | QPixmap mWeekPixmap; | 158 | QPixmap mWeekPixmap; |
159 | QColor mWeekBgColor; | 159 | QColor mWeekBgColor; |
160 | 160 | ||
161 | QAction *mShowAction; | 161 | QAction *mShowAction; |
162 | QAction *mEditAction; | 162 | QAction *mEditAction; |
163 | QAction *mDeleteAction; | 163 | QAction *mDeleteAction; |
164 | QAction *mCloneAction; | 164 | QAction *mCloneAction; |
165 | QAction *mMoveAction; | 165 | QAction *mMoveAction; |
166 | QAction *mBeamAction; | 166 | QAction *mBeamAction; |
167 | QAction *mCancelAction; | 167 | QAction *mCancelAction; |
168 | QAction *mPrintSelAction; | 168 | QAction *mPrintSelAction; |
169 | 169 | ||
170 | QAction *mToggleNav; | 170 | QAction *mToggleNav; |
171 | QAction *mToggleFilter; | 171 | QAction *mToggleFilter; |
172 | QAction *mToggleAllday; | 172 | QAction *mToggleAllday; |
173 | QAction *actionFilterMenuTB; | 173 | QAction *actionFilterMenuTB; |
174 | 174 | ||
175 | void closeEvent( QCloseEvent* ce ); | 175 | void closeEvent( QCloseEvent* ce ); |
176 | QTimer mSaveTimer; | 176 | QTimer mSaveTimer; |
177 | QTime mSaveTime; | ||
178 | int mSaveDelay; | ||
177 | //bool mBlockSaveFlag; | 179 | //bool mBlockSaveFlag; |
178 | bool mCalendarModifiedFlag; | 180 | bool mCalendarModifiedFlag; |
179 | QPixmap loadPixmap( QString ); | 181 | QPixmap loadPixmap( QString ); |
180 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; | 182 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; |
181 | }; | 183 | }; |
182 | 184 | ||
183 | 185 | ||
184 | #endif | 186 | #endif |