-rw-r--r-- | korganizer/calendarview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 18 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 19 | ||||
-rw-r--r-- | microkde/kglobal.cpp | 7 |
5 files changed, 26 insertions, 30 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index eac2f29..d25f632 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4519 +1,4523 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); | 464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); |
465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
466 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 466 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
467 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 467 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
468 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 468 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
469 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 469 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
470 | mTodoList->setNavigator( mNavigator ); | 470 | mTodoList->setNavigator( mNavigator ); |
471 | #if 0 | 471 | #if 0 |
472 | if ( QApplication::desktop()->width() < 480 ) { | 472 | if ( QApplication::desktop()->width() < 480 ) { |
473 | leftFrameLayout->addWidget(mFilterView); | 473 | leftFrameLayout->addWidget(mFilterView); |
474 | leftFrameLayout->addWidget(mTodoList, 2 ); | 474 | leftFrameLayout->addWidget(mTodoList, 2 ); |
475 | 475 | ||
476 | } else { | 476 | } else { |
477 | leftFrameLayout->addWidget(mTodoList,2 ); | 477 | leftFrameLayout->addWidget(mTodoList,2 ); |
478 | leftFrameLayout->addWidget(mFilterView ); | 478 | leftFrameLayout->addWidget(mFilterView ); |
479 | } | 479 | } |
480 | #endif | 480 | #endif |
481 | mFilterView->hide(); | 481 | mFilterView->hide(); |
482 | mCalEditView->hide(); | 482 | mCalEditView->hide(); |
483 | QWidget *rightBox = new QWidget( mMainFrame ); | 483 | QWidget *rightBox = new QWidget( mMainFrame ); |
484 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 484 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
485 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 485 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
486 | mRightFrame = new QWidgetStack( rightBox ); | 486 | mRightFrame = new QWidgetStack( rightBox ); |
487 | rightLayout->addWidget( mRightFrame, 10 ); | 487 | rightLayout->addWidget( mRightFrame, 10 ); |
488 | 488 | ||
489 | //mLeftFrame = (QWidget *)leftFrame; | 489 | //mLeftFrame = (QWidget *)leftFrame; |
490 | if ( KOPrefs::instance()->mVerticalScreen ) { | 490 | if ( KOPrefs::instance()->mVerticalScreen ) { |
491 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 491 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
492 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 492 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
493 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 493 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
494 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 494 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
495 | } else { | 495 | } else { |
496 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 496 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
497 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 497 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
498 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 498 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
499 | } | 499 | } |
500 | if ( !KOPrefs::instance()->mShowDateNavigator) | 500 | if ( !KOPrefs::instance()->mShowDateNavigator) |
501 | mDateNavigator->hide(); | 501 | mDateNavigator->hide(); |
502 | //qDebug("Calendarview Size %d %d ", width(), height()); | 502 | //qDebug("Calendarview Size %d %d ", width(), height()); |
503 | #endif | 503 | #endif |
504 | 504 | ||
505 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 505 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
506 | SLOT( showDates( const KCal::DateList & ) ) ); | 506 | SLOT( showDates( const KCal::DateList & ) ) ); |
507 | 507 | ||
508 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 508 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
509 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 509 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
510 | 510 | ||
511 | 511 | ||
512 | 512 | ||
513 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 513 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
514 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 514 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
515 | 515 | ||
516 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 516 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
517 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 517 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
518 | 518 | ||
519 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 519 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
520 | mNavigator, SLOT( selectPreviousYear() ) ); | 520 | mNavigator, SLOT( selectPreviousYear() ) ); |
521 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 521 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
522 | mNavigator, SLOT( selectNextYear() ) ); | 522 | mNavigator, SLOT( selectNextYear() ) ); |
523 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 523 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
524 | mNavigator, SLOT( selectPreviousMonth() ) ); | 524 | mNavigator, SLOT( selectPreviousMonth() ) ); |
525 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 525 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
526 | mNavigator, SLOT( selectNextMonth() ) ); | 526 | mNavigator, SLOT( selectNextMonth() ) ); |
527 | 527 | ||
528 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 528 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
529 | mNavigator, SLOT( selectPrevious() ) ); | 529 | mNavigator, SLOT( selectPrevious() ) ); |
530 | connect( mDateNavigator, SIGNAL( goNext() ), | 530 | connect( mDateNavigator, SIGNAL( goNext() ), |
531 | mNavigator, SLOT( selectNext() ) ); | 531 | mNavigator, SLOT( selectNext() ) ); |
532 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 532 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
533 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 533 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
534 | 534 | ||
535 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 535 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
536 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 536 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
537 | #if 0 | 537 | #if 0 |
538 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 538 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
539 | SLOT( incidenceAdded( Incidence *) ) ); | 539 | SLOT( incidenceAdded( Incidence *) ) ); |
540 | #endif | 540 | #endif |
541 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 541 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
542 | 542 | ||
543 | connect( this, SIGNAL( configChanged() ), | 543 | connect( this, SIGNAL( configChanged() ), |
544 | mDateNavigator, SLOT( updateConfig() ) ); | 544 | mDateNavigator, SLOT( updateConfig() ) ); |
545 | 545 | ||
546 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 546 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
547 | SLOT( newTodo() ) ); | 547 | SLOT( newTodo() ) ); |
548 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 548 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
549 | SLOT( newSubTodo( Todo * ) ) ); | 549 | SLOT( newSubTodo( Todo * ) ) ); |
550 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 550 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
551 | SLOT( editTodo( Todo * ) ) ); | 551 | SLOT( editTodo( Todo * ) ) ); |
552 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 552 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
553 | SLOT( showTodo( Todo *) ) ); | 553 | SLOT( showTodo( Todo *) ) ); |
554 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 554 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
555 | SLOT( deleteTodo( Todo *) ) ); | 555 | SLOT( deleteTodo( Todo *) ) ); |
556 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 556 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
557 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 557 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
558 | SLOT( purgeCompleted() ) ); | 558 | SLOT( purgeCompleted() ) ); |
559 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 559 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
560 | SIGNAL( todoModified( Todo *, int ) ) ); | 560 | SIGNAL( todoModified( Todo *, int ) ) ); |
561 | 561 | ||
562 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 562 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
563 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 563 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
564 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 564 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
565 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 565 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
566 | 566 | ||
567 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 567 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
568 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 568 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
569 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 569 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
570 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 570 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
571 | 571 | ||
572 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 572 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
573 | this, SLOT ( todo_unsub( Todo * ) ) ); | 573 | this, SLOT ( todo_unsub( Todo * ) ) ); |
574 | 574 | ||
575 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 575 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
576 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 576 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
577 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 577 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
578 | SLOT( updateTodo( Todo *, int ) ) ); | 578 | SLOT( updateTodo( Todo *, int ) ) ); |
579 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 579 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
580 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 580 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
581 | 581 | ||
582 | 582 | ||
583 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 583 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
584 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 584 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
585 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 585 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
586 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 586 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
587 | 587 | ||
588 | 588 | ||
589 | 589 | ||
590 | 590 | ||
591 | 591 | ||
592 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 592 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
593 | SLOT(checkClipboard())); | 593 | SLOT(checkClipboard())); |
594 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 594 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
595 | SLOT( processTodoListSelection( Incidence * ) ) ); | 595 | SLOT( processTodoListSelection( Incidence * ) ) ); |
596 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 596 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
597 | 597 | ||
598 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 598 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
599 | 599 | ||
600 | mDateFrame = new QVBox(0,0,WType_Popup); | 600 | mDateFrame = new QVBox(0,0,WType_Popup); |
601 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 601 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
602 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 602 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
603 | mDateFrame->setLineWidth(3); | 603 | mDateFrame->setLineWidth(3); |
604 | mDateFrame->hide(); | 604 | mDateFrame->hide(); |
605 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 605 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
606 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 606 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
607 | 607 | ||
608 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 608 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
609 | 609 | ||
610 | mEventEditor = mDialogManager->getEventEditor(); | 610 | mEventEditor = mDialogManager->getEventEditor(); |
611 | mTodoEditor = mDialogManager->getTodoEditor(); | 611 | mTodoEditor = mDialogManager->getTodoEditor(); |
612 | 612 | ||
613 | mFlagEditDescription = false; | 613 | mFlagEditDescription = false; |
614 | 614 | ||
615 | mSuspendTimer = new QTimer( this ); | 615 | mSuspendTimer = new QTimer( this ); |
616 | mAlarmTimer = new QTimer( this ); | 616 | mAlarmTimer = new QTimer( this ); |
617 | mRecheckAlarmTimer = new QTimer( this ); | 617 | mRecheckAlarmTimer = new QTimer( this ); |
618 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 618 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
619 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 619 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
620 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 620 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
621 | mAlarmDialog = new AlarmDialog( this ); | 621 | mAlarmDialog = new AlarmDialog( this ); |
622 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 622 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
623 | mAlarmDialog->setServerNotification( false ); | 623 | mAlarmDialog->setServerNotification( false ); |
624 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 624 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
625 | 625 | ||
626 | 626 | ||
627 | #ifndef DESKTOP_VERSION | 627 | #ifndef DESKTOP_VERSION |
628 | //US listen for arriving address resultsets | 628 | //US listen for arriving address resultsets |
629 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 629 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
630 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 630 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
631 | #endif | 631 | #endif |
632 | mDateNavigator->setCalendar( mCalendar ); | 632 | mDateNavigator->setCalendar( mCalendar ); |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | CalendarView::~CalendarView() | 636 | CalendarView::~CalendarView() |
637 | { | 637 | { |
638 | // kdDebug() << "~CalendarView()" << endl; | 638 | // kdDebug() << "~CalendarView()" << endl; |
639 | //qDebug("CalendarView::~CalendarView() "); | 639 | //qDebug("CalendarView::~CalendarView() "); |
640 | delete mDialogManager; | 640 | delete mDialogManager; |
641 | delete mViewManager; | 641 | delete mViewManager; |
642 | delete mStorage; | 642 | delete mStorage; |
643 | delete mDateFrame ; | 643 | delete mDateFrame ; |
644 | delete beamDialog; | 644 | delete beamDialog; |
645 | delete mEventViewerDialog; | 645 | delete mEventViewerDialog; |
646 | //kdDebug() << "~CalendarView() done" << endl; | 646 | //kdDebug() << "~CalendarView() done" << endl; |
647 | } | 647 | } |
648 | void CalendarView::checkAlarms() | 648 | void CalendarView::checkAlarms() |
649 | { | 649 | { |
650 | KConfig *config = KOGlobals::config(); | 650 | KConfig *config = KOGlobals::config(); |
651 | config->setGroup( "AppRun" ); | 651 | config->setGroup( "AppRun" ); |
652 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 652 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
653 | int daysto = dt.daysTo( QDate::currentDate() ); | 653 | int daysto = dt.daysTo( QDate::currentDate() ); |
654 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 654 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
655 | dt = dt.addDays( days ); | 655 | dt = dt.addDays( days ); |
656 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 656 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
657 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 657 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
658 | //qDebug("KO: Reading program stop %d ", secs); | 658 | //qDebug("KO: Reading program stop %d ", secs); |
659 | //secs -= ( 3600 * 24*3 ); // debug only | 659 | //secs -= ( 3600 * 24*3 ); // debug only |
660 | QDateTime latest = dt.addSecs ( secs ); | 660 | QDateTime latest = dt.addSecs ( secs ); |
661 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 661 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
662 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 662 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
663 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 663 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
664 | QPtrList<Incidence> al; | 664 | QPtrList<Incidence> al; |
665 | Incidence* inL = el.first(); | 665 | Incidence* inL = el.first(); |
666 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 666 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
667 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 667 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
668 | while ( inL ) { | 668 | while ( inL ) { |
669 | bool ok = false; | 669 | bool ok = false; |
670 | int offset = 0; | 670 | int offset = 0; |
671 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 671 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
672 | if ( ok ) { | 672 | if ( ok ) { |
673 | //qDebug("OK %s",next.toString().latin1()); | 673 | //qDebug("OK %s",next.toString().latin1()); |
674 | if ( next < cur ) { | 674 | if ( next < cur ) { |
675 | al.append( inL ); | 675 | al.append( inL ); |
676 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 676 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
677 | } | 677 | } |
678 | } | 678 | } |
679 | inL = el.next(); | 679 | inL = el.next(); |
680 | } | 680 | } |
681 | if ( al.count() ) { | 681 | if ( al.count() ) { |
682 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 682 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
683 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 683 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
684 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 684 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
685 | lay->setSpacing( 0 ); | 685 | lay->setSpacing( 0 ); |
686 | lay->setMargin( 0 ); | 686 | lay->setMargin( 0 ); |
687 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 687 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
688 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 688 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
689 | lay->addWidget( matb ); | 689 | lay->addWidget( matb ); |
690 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 690 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
691 | int wid = 210; | 691 | int wid = 210; |
692 | int x = QApplication::desktop()->width() - wid - 7; | 692 | int x = QApplication::desktop()->width() - wid - 7; |
693 | int y = QApplication::desktop()->height() - wid - 70; | 693 | int y = QApplication::desktop()->height() - wid - 70; |
694 | dia->setGeometry ( x,y,wid,wid); | 694 | dia->setGeometry ( x,y,wid,wid); |
695 | } else { | 695 | } else { |
696 | int si = 220; | 696 | int si = 220; |
697 | if ( QApplication::desktop()->width() > 470 ) | 697 | if ( QApplication::desktop()->width() > 470 ) |
698 | si = 400; | 698 | si = 400; |
699 | dia->resize(si,si/2); | 699 | dia->resize(si,si/2); |
700 | } | 700 | } |
701 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 701 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
702 | dia->show(); | 702 | dia->show(); |
703 | 703 | ||
704 | } | 704 | } |
705 | } | 705 | } |
706 | void CalendarView::showDay( QDate d ) | 706 | void CalendarView::showDay( QDate d ) |
707 | { | 707 | { |
708 | dateNavigator()->blockSignals( true ); | 708 | dateNavigator()->blockSignals( true ); |
709 | dateNavigator()->selectDate( d ); | 709 | dateNavigator()->selectDate( d ); |
710 | dateNavigator()->blockSignals( false ); | 710 | dateNavigator()->blockSignals( false ); |
711 | mViewManager->showDayView(); | 711 | mViewManager->showDayView(); |
712 | //dateNavigator()->selectDate( d ); | 712 | //dateNavigator()->selectDate( d ); |
713 | } | 713 | } |
714 | void CalendarView::timerAlarm() | 714 | void CalendarView::timerAlarm() |
715 | { | 715 | { |
716 | //qDebug("CalendarView::timerAlarm() "); | 716 | //qDebug("CalendarView::timerAlarm() "); |
717 | computeAlarm(mAlarmNotification ); | 717 | computeAlarm(mAlarmNotification ); |
718 | } | 718 | } |
719 | 719 | ||
720 | void CalendarView::suspendAlarm() | 720 | void CalendarView::suspendAlarm() |
721 | { | 721 | { |
722 | //qDebug(" CalendarView::suspendAlarm() "); | 722 | //qDebug(" CalendarView::suspendAlarm() "); |
723 | computeAlarm(mSuspendAlarmNotification ); | 723 | computeAlarm(mSuspendAlarmNotification ); |
724 | 724 | ||
725 | } | 725 | } |
726 | 726 | ||
727 | void CalendarView::startAlarm( QString mess , QString filename) | 727 | void CalendarView::startAlarm( QString mess , QString filename) |
728 | { | 728 | { |
729 | 729 | ||
730 | topLevelWidget()->showNormal(); | 730 | topLevelWidget()->showNormal(); |
731 | topLevelWidget()->setActiveWindow(); | 731 | topLevelWidget()->setActiveWindow(); |
732 | topLevelWidget()->raise(); | 732 | topLevelWidget()->raise(); |
733 | 733 | ||
734 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 734 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
735 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 735 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
736 | 736 | ||
737 | } | 737 | } |
738 | 738 | ||
739 | void CalendarView::checkNextTimerAlarm() | 739 | void CalendarView::checkNextTimerAlarm() |
740 | { | 740 | { |
741 | mCalendar->checkAlarmForIncidence( 0, true ); | 741 | mCalendar->checkAlarmForIncidence( 0, true ); |
742 | } | 742 | } |
743 | 743 | ||
744 | void CalendarView::computeAlarm( QString msg ) | 744 | void CalendarView::computeAlarm( QString msg ) |
745 | { | 745 | { |
746 | 746 | ||
747 | QString mess = msg; | 747 | QString mess = msg; |
748 | QString mAlarmMessage = mess.mid( 9 ); | 748 | QString mAlarmMessage = mess.mid( 9 ); |
749 | QString filename = MainWindow::resourcePath(); | 749 | QString filename = MainWindow::resourcePath(); |
750 | filename += "koalarm.wav"; | 750 | filename += "koalarm.wav"; |
751 | QString tempfilename; | 751 | QString tempfilename; |
752 | if ( mess.left( 13 ) == "suspend_alarm") { | 752 | if ( mess.left( 13 ) == "suspend_alarm") { |
753 | bool error = false; | 753 | bool error = false; |
754 | int len = mess.mid( 13 ).find("+++"); | 754 | int len = mess.mid( 13 ).find("+++"); |
755 | if ( len < 2 ) | 755 | if ( len < 2 ) |
756 | error = true; | 756 | error = true; |
757 | else { | 757 | else { |
758 | tempfilename = mess.mid( 13, len ); | 758 | tempfilename = mess.mid( 13, len ); |
759 | if ( !QFile::exists( tempfilename ) ) | 759 | if ( !QFile::exists( tempfilename ) ) |
760 | error = true; | 760 | error = true; |
761 | } | 761 | } |
762 | if ( ! error ) { | 762 | if ( ! error ) { |
763 | filename = tempfilename; | 763 | filename = tempfilename; |
764 | } | 764 | } |
765 | mAlarmMessage = mess.mid( 13+len+3 ); | 765 | mAlarmMessage = mess.mid( 13+len+3 ); |
766 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 766 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
767 | startAlarm( mAlarmMessage, filename); | 767 | startAlarm( mAlarmMessage, filename); |
768 | return; | 768 | return; |
769 | } | 769 | } |
770 | if ( mess.left( 11 ) == "timer_alarm") { | 770 | if ( mess.left( 11 ) == "timer_alarm") { |
771 | //mTimerTime = 0; | 771 | //mTimerTime = 0; |
772 | startAlarm( mess.mid( 11 ), filename ); | 772 | startAlarm( mess.mid( 11 ), filename ); |
773 | return; | 773 | return; |
774 | } | 774 | } |
775 | if ( mess.left( 10 ) == "proc_alarm") { | 775 | if ( mess.left( 10 ) == "proc_alarm") { |
776 | bool error = false; | 776 | bool error = false; |
777 | int len = mess.mid( 10 ).find("+++"); | 777 | int len = mess.mid( 10 ).find("+++"); |
778 | if ( len < 2 ) | 778 | if ( len < 2 ) |
779 | error = true; | 779 | error = true; |
780 | else { | 780 | else { |
781 | tempfilename = mess.mid( 10, len ); | 781 | tempfilename = mess.mid( 10, len ); |
782 | if ( !QFile::exists( tempfilename ) ) | 782 | if ( !QFile::exists( tempfilename ) ) |
783 | error = true; | 783 | error = true; |
784 | } | 784 | } |
785 | if ( error ) { | 785 | if ( error ) { |
786 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 786 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
787 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 787 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
788 | } else { | 788 | } else { |
789 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 789 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
790 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 790 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
791 | #ifndef _WIN32_ | 791 | #ifndef _WIN32_ |
792 | if ( vfork () == 0 ) { | 792 | if ( vfork () == 0 ) { |
793 | execl ( tempfilename.latin1(), 0 ); | 793 | execl ( tempfilename.latin1(), 0 ); |
794 | return; | 794 | return; |
795 | } | 795 | } |
796 | #else | 796 | #else |
797 | QProcess* p = new QProcess(); | 797 | QProcess* p = new QProcess(); |
798 | p->addArgument( tempfilename.latin1() ); | 798 | p->addArgument( tempfilename.latin1() ); |
799 | p->start(); | 799 | p->start(); |
800 | return; | 800 | return; |
801 | #endif | 801 | #endif |
802 | 802 | ||
803 | return; | 803 | return; |
804 | } | 804 | } |
805 | 805 | ||
806 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 806 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
807 | } | 807 | } |
808 | if ( mess.left( 11 ) == "audio_alarm") { | 808 | if ( mess.left( 11 ) == "audio_alarm") { |
809 | bool error = false; | 809 | bool error = false; |
810 | int len = mess.mid( 11 ).find("+++"); | 810 | int len = mess.mid( 11 ).find("+++"); |
811 | if ( len < 2 ) | 811 | if ( len < 2 ) |
812 | error = true; | 812 | error = true; |
813 | else { | 813 | else { |
814 | tempfilename = mess.mid( 11, len ); | 814 | tempfilename = mess.mid( 11, len ); |
815 | if ( !QFile::exists( tempfilename ) ) | 815 | if ( !QFile::exists( tempfilename ) ) |
816 | error = true; | 816 | error = true; |
817 | } | 817 | } |
818 | if ( ! error ) { | 818 | if ( ! error ) { |
819 | filename = tempfilename; | 819 | filename = tempfilename; |
820 | } | 820 | } |
821 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 821 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
822 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 822 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
823 | } | 823 | } |
824 | if ( mess.left( 9 ) == "cal_alarm") { | 824 | if ( mess.left( 9 ) == "cal_alarm") { |
825 | mAlarmMessage = mess.mid( 9 ) ; | 825 | mAlarmMessage = mess.mid( 9 ) ; |
826 | } | 826 | } |
827 | 827 | ||
828 | startAlarm( mAlarmMessage, filename ); | 828 | startAlarm( mAlarmMessage, filename ); |
829 | 829 | ||
830 | 830 | ||
831 | } | 831 | } |
832 | 832 | ||
833 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 833 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
834 | { | 834 | { |
835 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 835 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
836 | 836 | ||
837 | mSuspendAlarmNotification = noti; | 837 | mSuspendAlarmNotification = noti; |
838 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 838 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
839 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 839 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
840 | mSuspendTimer->start( ms , true ); | 840 | mSuspendTimer->start( ms , true ); |
841 | 841 | ||
842 | } | 842 | } |
843 | 843 | ||
844 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 844 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
845 | { | 845 | { |
846 | mNextAlarmDateTime = qdt; | 846 | mNextAlarmDateTime = qdt; |
847 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 847 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
848 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 848 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
849 | #ifndef DESKTOP_VERSION | 849 | #ifndef DESKTOP_VERSION |
850 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 850 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
851 | #endif | 851 | #endif |
852 | return; | 852 | return; |
853 | } | 853 | } |
854 | int maxSec; | 854 | int maxSec; |
855 | //maxSec = 5; //testing only | 855 | //maxSec = 5; //testing only |
856 | maxSec = 86400+3600; // one day+1hour | 856 | maxSec = 86400+3600; // one day+1hour |
857 | mAlarmNotification = noti; | 857 | mAlarmNotification = noti; |
858 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 858 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
859 | if ( sec > maxSec ) { | 859 | if ( sec > maxSec ) { |
860 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 860 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
861 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 861 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
862 | return; | 862 | return; |
863 | } else { | 863 | } else { |
864 | mRecheckAlarmTimer->stop(); | 864 | mRecheckAlarmTimer->stop(); |
865 | } | 865 | } |
866 | //qDebug("Alarm timer started with secs: %d ", sec); | 866 | //qDebug("Alarm timer started with secs: %d ", sec); |
867 | mAlarmTimer->start( sec *1000 , true ); | 867 | mAlarmTimer->start( sec *1000 , true ); |
868 | 868 | ||
869 | } | 869 | } |
870 | // called by mRecheckAlarmTimer to get next alarm | 870 | // called by mRecheckAlarmTimer to get next alarm |
871 | // we need this, because a QTimer has only a max range of 25 days | 871 | // we need this, because a QTimer has only a max range of 25 days |
872 | void CalendarView::recheckTimerAlarm() | 872 | void CalendarView::recheckTimerAlarm() |
873 | { | 873 | { |
874 | mAlarmTimer->stop(); | 874 | mAlarmTimer->stop(); |
875 | mRecheckAlarmTimer->stop(); | 875 | mRecheckAlarmTimer->stop(); |
876 | mCalendar->checkAlarmForIncidence( 0, true ); | 876 | mCalendar->checkAlarmForIncidence( 0, true ); |
877 | } | 877 | } |
878 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 878 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
879 | { | 879 | { |
880 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 880 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
881 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 881 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
882 | #ifndef DESKTOP_VERSION | 882 | #ifndef DESKTOP_VERSION |
883 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 883 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
884 | #endif | 884 | #endif |
885 | return; | 885 | return; |
886 | } | 886 | } |
887 | mAlarmTimer->stop(); | 887 | mAlarmTimer->stop(); |
888 | } | 888 | } |
889 | void CalendarView::selectWeekNum ( int num ) | 889 | void CalendarView::selectWeekNum ( int num ) |
890 | { | 890 | { |
891 | dateNavigator()->blockSignals( true ); | 891 | dateNavigator()->blockSignals( true ); |
892 | dateNavigator()->selectWeek( num ); | 892 | dateNavigator()->selectWeek( num ); |
893 | dateNavigator()->blockSignals( false ); | 893 | dateNavigator()->blockSignals( false ); |
894 | mViewManager->showWeekView(); | 894 | mViewManager->showWeekView(); |
895 | } | 895 | } |
896 | KOViewManager *CalendarView::viewManager() | 896 | KOViewManager *CalendarView::viewManager() |
897 | { | 897 | { |
898 | return mViewManager; | 898 | return mViewManager; |
899 | } | 899 | } |
900 | 900 | ||
901 | KODialogManager *CalendarView::dialogManager() | 901 | KODialogManager *CalendarView::dialogManager() |
902 | { | 902 | { |
903 | return mDialogManager; | 903 | return mDialogManager; |
904 | } | 904 | } |
905 | 905 | ||
906 | QDate CalendarView::startDate() | 906 | QDate CalendarView::startDate() |
907 | { | 907 | { |
908 | DateList dates = mNavigator->selectedDates(); | 908 | DateList dates = mNavigator->selectedDates(); |
909 | 909 | ||
910 | return dates.first(); | 910 | return dates.first(); |
911 | } | 911 | } |
912 | 912 | ||
913 | QDate CalendarView::endDate() | 913 | QDate CalendarView::endDate() |
914 | { | 914 | { |
915 | DateList dates = mNavigator->selectedDates(); | 915 | DateList dates = mNavigator->selectedDates(); |
916 | 916 | ||
917 | return dates.last(); | 917 | return dates.last(); |
918 | } | 918 | } |
919 | 919 | ||
920 | 920 | ||
921 | void CalendarView::createPrinter() | 921 | void CalendarView::createPrinter() |
922 | { | 922 | { |
923 | #ifndef KORG_NOPRINTER | 923 | #ifndef KORG_NOPRINTER |
924 | if (!mCalPrinter) { | 924 | if (!mCalPrinter) { |
925 | mCalPrinter = new CalPrinter(this, mCalendar); | 925 | mCalPrinter = new CalPrinter(this, mCalendar); |
926 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 926 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
927 | } | 927 | } |
928 | #endif | 928 | #endif |
929 | } | 929 | } |
930 | 930 | ||
931 | 931 | ||
932 | //KOPrefs::instance()->mWriteBackFile | 932 | //KOPrefs::instance()->mWriteBackFile |
933 | //KOPrefs::instance()->mWriteBackExistingOnly | 933 | //KOPrefs::instance()->mWriteBackExistingOnly |
934 | 934 | ||
935 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 935 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
936 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 936 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
937 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 937 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
938 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 938 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
939 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 939 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
940 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 940 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
941 | 941 | ||
942 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 942 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
943 | { | 943 | { |
944 | 944 | ||
945 | // 0 equal | 945 | // 0 equal |
946 | // 1 take local | 946 | // 1 take local |
947 | // 2 take remote | 947 | // 2 take remote |
948 | // 3 cancel | 948 | // 3 cancel |
949 | QDateTime lastSync = mLastCalendarSync; | 949 | QDateTime lastSync = mLastCalendarSync; |
950 | QDateTime localMod = local->lastModified(); | 950 | QDateTime localMod = local->lastModified(); |
951 | QDateTime remoteMod = remote->lastModified(); | 951 | QDateTime remoteMod = remote->lastModified(); |
952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
953 | bool remCh, locCh; | 953 | bool remCh, locCh; |
954 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 954 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
955 | //if ( remCh ) | 955 | //if ( remCh ) |
956 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 956 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
957 | locCh = ( localMod > mLastCalendarSync ); | 957 | locCh = ( localMod > mLastCalendarSync ); |
958 | if ( !remCh && ! locCh ) { | 958 | if ( !remCh && ! locCh ) { |
959 | //qDebug("both not changed "); | 959 | //qDebug("both not changed "); |
960 | lastSync = localMod.addDays(1); | 960 | lastSync = localMod.addDays(1); |
961 | if ( mode <= SYNC_PREF_ASK ) | 961 | if ( mode <= SYNC_PREF_ASK ) |
962 | return 0; | 962 | return 0; |
963 | } else { | 963 | } else { |
964 | if ( locCh ) { | 964 | if ( locCh ) { |
965 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 965 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
966 | lastSync = localMod.addDays( -1 ); | 966 | lastSync = localMod.addDays( -1 ); |
967 | if ( !remCh ) | 967 | if ( !remCh ) |
968 | remoteMod = ( lastSync.addDays( -1 ) ); | 968 | remoteMod = ( lastSync.addDays( -1 ) ); |
969 | } else { | 969 | } else { |
970 | //qDebug(" not loc changed "); | 970 | //qDebug(" not loc changed "); |
971 | lastSync = localMod.addDays( 1 ); | 971 | lastSync = localMod.addDays( 1 ); |
972 | if ( remCh ) | 972 | if ( remCh ) |
973 | remoteMod =( lastSync.addDays( 1 ) ); | 973 | remoteMod =( lastSync.addDays( 1 ) ); |
974 | 974 | ||
975 | } | 975 | } |
976 | } | 976 | } |
977 | full = true; | 977 | full = true; |
978 | if ( mode < SYNC_PREF_ASK ) | 978 | if ( mode < SYNC_PREF_ASK ) |
979 | mode = SYNC_PREF_ASK; | 979 | mode = SYNC_PREF_ASK; |
980 | } else { | 980 | } else { |
981 | if ( localMod == remoteMod ) | 981 | if ( localMod == remoteMod ) |
982 | // if ( local->revision() == remote->revision() ) | 982 | // if ( local->revision() == remote->revision() ) |
983 | return 0; | 983 | return 0; |
984 | 984 | ||
985 | } | 985 | } |
986 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 986 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
987 | 987 | ||
988 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 988 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
989 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 989 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
990 | //full = true; //debug only | 990 | //full = true; //debug only |
991 | if ( full ) { | 991 | if ( full ) { |
992 | bool equ = false; | 992 | bool equ = false; |
993 | if ( local->typeID() == eventID ) { | 993 | if ( local->typeID() == eventID ) { |
994 | equ = (*((Event*) local) == *((Event*) remote)); | 994 | equ = (*((Event*) local) == *((Event*) remote)); |
995 | } | 995 | } |
996 | else if ( local->typeID() == todoID ) | 996 | else if ( local->typeID() == todoID ) |
997 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 997 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
998 | else if ( local->typeID() == journalID ) | 998 | else if ( local->typeID() == journalID ) |
999 | equ = (*((Journal*) local) == *((Journal*) remote)); | 999 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1000 | if ( equ ) { | 1000 | if ( equ ) { |
1001 | //qDebug("equal "); | 1001 | //qDebug("equal "); |
1002 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1002 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1003 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1003 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1004 | } | 1004 | } |
1005 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1005 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1006 | return 0; | 1006 | return 0; |
1007 | 1007 | ||
1008 | }//else //debug only | 1008 | }//else //debug only |
1009 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1009 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1010 | } | 1010 | } |
1011 | int result; | 1011 | int result; |
1012 | bool localIsNew; | 1012 | bool localIsNew; |
1013 | //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() ); | 1013 | //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() ); |
1014 | 1014 | ||
1015 | 1015 | ||
1016 | // ************************************************ | 1016 | // ************************************************ |
1017 | // ************************************************ | 1017 | // ************************************************ |
1018 | // ************************************************ | 1018 | // ************************************************ |
1019 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1019 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1020 | // BUT remoteMod != localMod | 1020 | // BUT remoteMod != localMod |
1021 | 1021 | ||
1022 | 1022 | ||
1023 | if ( full && mode < SYNC_PREF_NEWEST ) | 1023 | if ( full && mode < SYNC_PREF_NEWEST ) |
1024 | mode = SYNC_PREF_ASK; | 1024 | mode = SYNC_PREF_ASK; |
1025 | 1025 | ||
1026 | switch( mode ) { | 1026 | switch( mode ) { |
1027 | case SYNC_PREF_LOCAL: | 1027 | case SYNC_PREF_LOCAL: |
1028 | if ( lastSync > remoteMod ) | 1028 | if ( lastSync > remoteMod ) |
1029 | return 1; | 1029 | return 1; |
1030 | if ( lastSync > localMod ) | 1030 | if ( lastSync > localMod ) |
1031 | return 2; | 1031 | return 2; |
1032 | return 1; | 1032 | return 1; |
1033 | break; | 1033 | break; |
1034 | case SYNC_PREF_REMOTE: | 1034 | case SYNC_PREF_REMOTE: |
1035 | if ( lastSync > localMod ) | 1035 | if ( lastSync > localMod ) |
1036 | return 2; | 1036 | return 2; |
1037 | if ( lastSync > remoteMod ) | 1037 | if ( lastSync > remoteMod ) |
1038 | return 1; | 1038 | return 1; |
1039 | return 2; | 1039 | return 2; |
1040 | break; | 1040 | break; |
1041 | case SYNC_PREF_NEWEST: | 1041 | case SYNC_PREF_NEWEST: |
1042 | if ( localMod >= remoteMod ) | 1042 | if ( localMod >= remoteMod ) |
1043 | return 1; | 1043 | return 1; |
1044 | else | 1044 | else |
1045 | return 2; | 1045 | return 2; |
1046 | break; | 1046 | break; |
1047 | case SYNC_PREF_ASK: | 1047 | case SYNC_PREF_ASK: |
1048 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1048 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1049 | if ( lastSync > remoteMod && lastSync > localMod) | 1049 | if ( lastSync > remoteMod && lastSync > localMod) |
1050 | return 0; | 1050 | return 0; |
1051 | if ( lastSync > remoteMod ) | 1051 | if ( lastSync > remoteMod ) |
1052 | return 1; | 1052 | return 1; |
1053 | if ( lastSync > localMod ) | 1053 | if ( lastSync > localMod ) |
1054 | return 2; | 1054 | return 2; |
1055 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1055 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1056 | localIsNew = localMod >= remoteMod; | 1056 | localIsNew = localMod >= remoteMod; |
1057 | if ( localIsNew ) | 1057 | if ( localIsNew ) |
1058 | getEventViewerDialog()->setColorMode( 1 ); | 1058 | getEventViewerDialog()->setColorMode( 1 ); |
1059 | else | 1059 | else |
1060 | getEventViewerDialog()->setColorMode( 2 ); | 1060 | getEventViewerDialog()->setColorMode( 2 ); |
1061 | getEventViewerDialog()->setIncidence(local); | 1061 | getEventViewerDialog()->setIncidence(local); |
1062 | if ( localIsNew ) | 1062 | if ( localIsNew ) |
1063 | getEventViewerDialog()->setColorMode( 2 ); | 1063 | getEventViewerDialog()->setColorMode( 2 ); |
1064 | else | 1064 | else |
1065 | getEventViewerDialog()->setColorMode( 1 ); | 1065 | getEventViewerDialog()->setColorMode( 1 ); |
1066 | getEventViewerDialog()->addIncidence(remote); | 1066 | getEventViewerDialog()->addIncidence(remote); |
1067 | getEventViewerDialog()->setColorMode( 0 ); | 1067 | getEventViewerDialog()->setColorMode( 0 ); |
1068 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1068 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1069 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1069 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1070 | getEventViewerDialog()->showMe(); | 1070 | getEventViewerDialog()->showMe(); |
1071 | result = getEventViewerDialog()->executeS( localIsNew ); | 1071 | result = getEventViewerDialog()->executeS( localIsNew ); |
1072 | return result; | 1072 | return result; |
1073 | 1073 | ||
1074 | break; | 1074 | break; |
1075 | case SYNC_PREF_FORCE_LOCAL: | 1075 | case SYNC_PREF_FORCE_LOCAL: |
1076 | return 1; | 1076 | return 1; |
1077 | break; | 1077 | break; |
1078 | case SYNC_PREF_FORCE_REMOTE: | 1078 | case SYNC_PREF_FORCE_REMOTE: |
1079 | return 2; | 1079 | return 2; |
1080 | break; | 1080 | break; |
1081 | 1081 | ||
1082 | default: | 1082 | default: |
1083 | // SYNC_PREF_TAKE_BOTH not implemented | 1083 | // SYNC_PREF_TAKE_BOTH not implemented |
1084 | break; | 1084 | break; |
1085 | } | 1085 | } |
1086 | return 0; | 1086 | return 0; |
1087 | } | 1087 | } |
1088 | Event* CalendarView::getLastSyncEvent() | 1088 | Event* CalendarView::getLastSyncEvent() |
1089 | { | 1089 | { |
1090 | Event* lse; | 1090 | Event* lse; |
1091 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1091 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1092 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1092 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1093 | if (!lse) { | 1093 | if (!lse) { |
1094 | lse = new Event(); | 1094 | lse = new Event(); |
1095 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1095 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1096 | QString sum = ""; | 1096 | QString sum = ""; |
1097 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1097 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1098 | sum = "E: "; | 1098 | sum = "E: "; |
1099 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1099 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1100 | lse->setDtStart( mLastCalendarSync ); | 1100 | lse->setDtStart( mLastCalendarSync ); |
1101 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1101 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1102 | lse->setCategories( i18n("SyncEvent") ); | 1102 | lse->setCategories( i18n("SyncEvent") ); |
1103 | lse->setReadOnly( true ); | 1103 | lse->setReadOnly( true ); |
1104 | mCalendar->addEvent( lse ); | 1104 | mCalendar->addEvent( lse ); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | return lse; | 1107 | return lse; |
1108 | 1108 | ||
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | // we check, if the to delete event has a id for a profile | 1111 | // we check, if the to delete event has a id for a profile |
1112 | // if yes, we set this id in the profile to delete | 1112 | // if yes, we set this id in the profile to delete |
1113 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1113 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1114 | { | 1114 | { |
1115 | if ( lastSync.count() == 0 ) { | 1115 | if ( lastSync.count() == 0 ) { |
1116 | //qDebug(" lastSync.count() == 0"); | 1116 | //qDebug(" lastSync.count() == 0"); |
1117 | return; | 1117 | return; |
1118 | } | 1118 | } |
1119 | if ( toDelete->typeID() == journalID ) | 1119 | if ( toDelete->typeID() == journalID ) |
1120 | return; | 1120 | return; |
1121 | 1121 | ||
1122 | Event* eve = lastSync.first(); | 1122 | Event* eve = lastSync.first(); |
1123 | 1123 | ||
1124 | while ( eve ) { | 1124 | while ( eve ) { |
1125 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1125 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1126 | if ( !id.isEmpty() ) { | 1126 | if ( !id.isEmpty() ) { |
1127 | QString des = eve->description(); | 1127 | QString des = eve->description(); |
1128 | QString pref = "e"; | 1128 | QString pref = "e"; |
1129 | if ( toDelete->typeID() == todoID ) | 1129 | if ( toDelete->typeID() == todoID ) |
1130 | pref = "t"; | 1130 | pref = "t"; |
1131 | des += pref+ id + ","; | 1131 | des += pref+ id + ","; |
1132 | eve->setReadOnly( false ); | 1132 | eve->setReadOnly( false ); |
1133 | eve->setDescription( des ); | 1133 | eve->setDescription( des ); |
1134 | //qDebug("setdes %s ", des.latin1()); | 1134 | //qDebug("setdes %s ", des.latin1()); |
1135 | eve->setReadOnly( true ); | 1135 | eve->setReadOnly( true ); |
1136 | } | 1136 | } |
1137 | eve = lastSync.next(); | 1137 | eve = lastSync.next(); |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | } | 1140 | } |
1141 | void CalendarView::checkExternalId( Incidence * inc ) | 1141 | void CalendarView::checkExternalId( Incidence * inc ) |
1142 | { | 1142 | { |
1143 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1143 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1144 | checkExternSyncEvent( lastSync, inc ); | 1144 | checkExternSyncEvent( lastSync, inc ); |
1145 | 1145 | ||
1146 | } | 1146 | } |
1147 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1147 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1148 | { | 1148 | { |
1149 | bool syncOK = true; | 1149 | bool syncOK = true; |
1150 | int addedEvent = 0; | 1150 | int addedEvent = 0; |
1151 | int addedEventR = 0; | 1151 | int addedEventR = 0; |
1152 | int deletedEventR = 0; | 1152 | int deletedEventR = 0; |
1153 | int deletedEventL = 0; | 1153 | int deletedEventL = 0; |
1154 | int changedLocal = 0; | 1154 | int changedLocal = 0; |
1155 | int changedRemote = 0; | 1155 | int changedRemote = 0; |
1156 | int filteredIN = 0; | 1156 | int filteredIN = 0; |
1157 | int filteredOUT = 0; | 1157 | int filteredOUT = 0; |
1158 | //QPtrList<Event> el = local->rawEvents(); | 1158 | //QPtrList<Event> el = local->rawEvents(); |
1159 | Event* eventR; | 1159 | Event* eventR; |
1160 | QString uid; | 1160 | QString uid; |
1161 | int take; | 1161 | int take; |
1162 | Event* eventL; | 1162 | Event* eventL; |
1163 | Event* eventRSync; | 1163 | Event* eventRSync; |
1164 | Event* eventLSync; | 1164 | Event* eventLSync; |
1165 | clearAllViews(); | 1165 | clearAllViews(); |
1166 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1166 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1167 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1167 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1168 | bool fullDateRange = false; | 1168 | bool fullDateRange = false; |
1169 | local->resetTempSyncStat(); | 1169 | local->resetTempSyncStat(); |
1170 | mLastCalendarSync = QDateTime::currentDateTime(); | 1170 | mLastCalendarSync = QDateTime::currentDateTime(); |
1171 | if ( mSyncManager->syncWithDesktop() ) { | 1171 | if ( mSyncManager->syncWithDesktop() ) { |
1172 | remote->resetPilotStat(1); | 1172 | remote->resetPilotStat(1); |
1173 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1173 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1174 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1174 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1175 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1175 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1176 | } else { | 1176 | } else { |
1177 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1177 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | QDateTime modifiedCalendar = mLastCalendarSync; | 1180 | QDateTime modifiedCalendar = mLastCalendarSync; |
1181 | eventLSync = getLastSyncEvent(); | 1181 | eventLSync = getLastSyncEvent(); |
1182 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1182 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1183 | if ( eventR ) { | 1183 | if ( eventR ) { |
1184 | eventRSync = (Event*) eventR->clone(); | 1184 | eventRSync = (Event*) eventR->clone(); |
1185 | remote->deleteEvent(eventR ); | 1185 | remote->deleteEvent(eventR ); |
1186 | 1186 | ||
1187 | } else { | 1187 | } else { |
1188 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1188 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1189 | eventRSync = (Event*)eventLSync->clone(); | 1189 | eventRSync = (Event*)eventLSync->clone(); |
1190 | } else { | 1190 | } else { |
1191 | fullDateRange = true; | 1191 | fullDateRange = true; |
1192 | eventRSync = new Event(); | 1192 | eventRSync = new Event(); |
1193 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1193 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1194 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1194 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1195 | eventRSync->setDtStart( mLastCalendarSync ); | 1195 | eventRSync->setDtStart( mLastCalendarSync ); |
1196 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1196 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1197 | eventRSync->setCategories( i18n("SyncEvent") ); | 1197 | eventRSync->setCategories( i18n("SyncEvent") ); |
1198 | } | 1198 | } |
1199 | } | 1199 | } |
1200 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1200 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1201 | fullDateRange = true; | 1201 | fullDateRange = true; |
1202 | 1202 | ||
1203 | if ( ! fullDateRange ) { | 1203 | if ( ! fullDateRange ) { |
1204 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1204 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1205 | 1205 | ||
1206 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1206 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1207 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1207 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1208 | fullDateRange = true; | 1208 | fullDateRange = true; |
1209 | } | 1209 | } |
1210 | } | 1210 | } |
1211 | if ( mSyncManager->syncWithDesktop() ) { | 1211 | if ( mSyncManager->syncWithDesktop() ) { |
1212 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1212 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1213 | } | 1213 | } |
1214 | if ( fullDateRange ) | 1214 | if ( fullDateRange ) |
1215 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1215 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1216 | else | 1216 | else |
1217 | mLastCalendarSync = eventLSync->dtStart(); | 1217 | mLastCalendarSync = eventLSync->dtStart(); |
1218 | // for resyncing if own file has changed | 1218 | // for resyncing if own file has changed |
1219 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1219 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1220 | mLastCalendarSync = loadedFileVersion; | 1220 | mLastCalendarSync = loadedFileVersion; |
1221 | //qDebug("setting mLastCalendarSync "); | 1221 | //qDebug("setting mLastCalendarSync "); |
1222 | } | 1222 | } |
1223 | //qDebug("*************************** "); | 1223 | //qDebug("*************************** "); |
1224 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1224 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1225 | QPtrList<Incidence> er = remote->rawIncidences(); | 1225 | QPtrList<Incidence> er = remote->rawIncidences(); |
1226 | Incidence* inR = er.first(); | 1226 | Incidence* inR = er.first(); |
1227 | Incidence* inL; | 1227 | Incidence* inL; |
1228 | QProgressBar bar( er.count(),0 ); | 1228 | QProgressBar bar( er.count(),0 ); |
1229 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1229 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1230 | 1230 | ||
1231 | // ************** setting up filter ************* | 1231 | // ************** setting up filter ************* |
1232 | CalFilter *filterIN = 0; | 1232 | CalFilter *filterIN = 0; |
1233 | CalFilter *filterOUT = 0; | 1233 | CalFilter *filterOUT = 0; |
1234 | CalFilter *filter = mFilters.first(); | 1234 | CalFilter *filter = mFilters.first(); |
1235 | while(filter) { | 1235 | while(filter) { |
1236 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1236 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1237 | filterIN = filter; | 1237 | filterIN = filter; |
1238 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1238 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1239 | filterOUT = filter; | 1239 | filterOUT = filter; |
1240 | filter = mFilters.next(); | 1240 | filter = mFilters.next(); |
1241 | } | 1241 | } |
1242 | int w = 300; | 1242 | int w = 300; |
1243 | if ( QApplication::desktop()->width() < 320 ) | 1243 | if ( QApplication::desktop()->width() < 320 ) |
1244 | w = 220; | 1244 | w = 220; |
1245 | int h = bar.sizeHint().height() ; | 1245 | int h = bar.sizeHint().height() ; |
1246 | int dw = QApplication::desktop()->width(); | 1246 | int dw = QApplication::desktop()->width(); |
1247 | int dh = QApplication::desktop()->height(); | 1247 | int dh = QApplication::desktop()->height(); |
1248 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1248 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1249 | bar.show(); | 1249 | bar.show(); |
1250 | int modulo = (er.count()/10)+1; | 1250 | int modulo = (er.count()/10)+1; |
1251 | int incCounter = 0; | 1251 | int incCounter = 0; |
1252 | while ( inR ) { | 1252 | while ( inR ) { |
1253 | if ( ! bar.isVisible() ) | 1253 | if ( ! bar.isVisible() ) |
1254 | return false; | 1254 | return false; |
1255 | if ( incCounter % modulo == 0 ) | 1255 | if ( incCounter % modulo == 0 ) |
1256 | bar.setProgress( incCounter ); | 1256 | bar.setProgress( incCounter ); |
1257 | ++incCounter; | 1257 | ++incCounter; |
1258 | uid = inR->uid(); | 1258 | uid = inR->uid(); |
1259 | bool skipIncidence = false; | 1259 | bool skipIncidence = false; |
1260 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1260 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1261 | skipIncidence = true; | 1261 | skipIncidence = true; |
1262 | QString idS; | 1262 | QString idS; |
1263 | qApp->processEvents(); | 1263 | qApp->processEvents(); |
1264 | if ( !skipIncidence ) { | 1264 | if ( !skipIncidence ) { |
1265 | inL = local->incidence( uid ); | 1265 | inL = local->incidence( uid ); |
1266 | if ( inL ) { // maybe conflict - same uid in both calendars | 1266 | if ( inL ) { // maybe conflict - same uid in both calendars |
1267 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1267 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1268 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1268 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1269 | if ( take == 3 ) | 1269 | if ( take == 3 ) |
1270 | return false; | 1270 | return false; |
1271 | if ( take == 1 ) {// take local ********************** | 1271 | if ( take == 1 ) {// take local ********************** |
1272 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1272 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1273 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1273 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1274 | else | 1274 | else |
1275 | idS = inR->IDStr(); | 1275 | idS = inR->IDStr(); |
1276 | remote->deleteIncidence( inR ); | 1276 | remote->deleteIncidence( inR ); |
1277 | inR = inL->clone(); | 1277 | inR = inL->clone(); |
1278 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1278 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1279 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1279 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1280 | inR->setIDStr( idS ); | 1280 | inR->setIDStr( idS ); |
1281 | remote->addIncidence( inR ); | 1281 | remote->addIncidence( inR ); |
1282 | if ( mSyncManager->syncWithDesktop() ) | 1282 | if ( mSyncManager->syncWithDesktop() ) |
1283 | inR->setPilotId( 2 ); | 1283 | inR->setPilotId( 2 ); |
1284 | ++changedRemote; | 1284 | ++changedRemote; |
1285 | } else {// take remote ********************** | 1285 | } else {// take remote ********************** |
1286 | idS = inL->IDStr(); | 1286 | idS = inL->IDStr(); |
1287 | int pid = inL->pilotId(); | 1287 | int pid = inL->pilotId(); |
1288 | local->deleteIncidence( inL ); | 1288 | local->deleteIncidence( inL ); |
1289 | inL = inR->clone(); | 1289 | inL = inR->clone(); |
1290 | if ( mSyncManager->syncWithDesktop() ) | 1290 | if ( mSyncManager->syncWithDesktop() ) |
1291 | inL->setPilotId( pid ); | 1291 | inL->setPilotId( pid ); |
1292 | inL->setIDStr( idS ); | 1292 | inL->setIDStr( idS ); |
1293 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1293 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1294 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1294 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1295 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1295 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1296 | } | 1296 | } |
1297 | local->addIncidence( inL ); | 1297 | local->addIncidence( inL ); |
1298 | ++changedLocal; | 1298 | ++changedLocal; |
1299 | } | 1299 | } |
1300 | } | 1300 | } |
1301 | } else { // no conflict ********** add or delete remote | 1301 | } else { // no conflict ********** add or delete remote |
1302 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1302 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1303 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1303 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1304 | QString des = eventLSync->description(); | 1304 | QString des = eventLSync->description(); |
1305 | QString pref = "e"; | 1305 | QString pref = "e"; |
1306 | if ( inR->typeID() == todoID ) | 1306 | if ( inR->typeID() == todoID ) |
1307 | pref = "t"; | 1307 | pref = "t"; |
1308 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1308 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1309 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1309 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1310 | //remote->deleteIncidence( inR ); | 1310 | //remote->deleteIncidence( inR ); |
1311 | ++deletedEventR; | 1311 | ++deletedEventR; |
1312 | } else { | 1312 | } else { |
1313 | inR->setLastModified( modifiedCalendar ); | 1313 | inR->setLastModified( modifiedCalendar ); |
1314 | inL = inR->clone(); | 1314 | inL = inR->clone(); |
1315 | inL->setIDStr( ":" ); | 1315 | inL->setIDStr( ":" ); |
1316 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1316 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1317 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1317 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1318 | local->addIncidence( inL ); | 1318 | local->addIncidence( inL ); |
1319 | ++addedEvent; | 1319 | ++addedEvent; |
1320 | 1320 | ||
1321 | } | 1321 | } |
1322 | } else { | 1322 | } else { |
1323 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1323 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1324 | inR->setLastModified( modifiedCalendar ); | 1324 | inR->setLastModified( modifiedCalendar ); |
1325 | inL = inR->clone(); | 1325 | inL = inR->clone(); |
1326 | inL->setIDStr( ":" ); | 1326 | inL->setIDStr( ":" ); |
1327 | local->addIncidence( inL ); | 1327 | local->addIncidence( inL ); |
1328 | ++addedEvent; | 1328 | ++addedEvent; |
1329 | 1329 | ||
1330 | } else { | 1330 | } else { |
1331 | checkExternSyncEvent(eventRSyncSharp, inR); | 1331 | checkExternSyncEvent(eventRSyncSharp, inR); |
1332 | remote->deleteIncidence( inR ); | 1332 | remote->deleteIncidence( inR ); |
1333 | ++deletedEventR; | 1333 | ++deletedEventR; |
1334 | } | 1334 | } |
1335 | } | 1335 | } |
1336 | } else { | 1336 | } else { |
1337 | ++filteredIN; | 1337 | ++filteredIN; |
1338 | } | 1338 | } |
1339 | } | 1339 | } |
1340 | } | 1340 | } |
1341 | inR = er.next(); | 1341 | inR = er.next(); |
1342 | } | 1342 | } |
1343 | QPtrList<Incidence> el = local->rawIncidences(); | 1343 | QPtrList<Incidence> el = local->rawIncidences(); |
1344 | inL = el.first(); | 1344 | inL = el.first(); |
1345 | modulo = (el.count()/10)+1; | 1345 | modulo = (el.count()/10)+1; |
1346 | bar.setCaption (i18n("Add / remove events") ); | 1346 | bar.setCaption (i18n("Add / remove events") ); |
1347 | bar.setTotalSteps ( el.count() ) ; | 1347 | bar.setTotalSteps ( el.count() ) ; |
1348 | bar.show(); | 1348 | bar.show(); |
1349 | incCounter = 0; | 1349 | incCounter = 0; |
1350 | 1350 | ||
1351 | while ( inL ) { | 1351 | while ( inL ) { |
1352 | 1352 | ||
1353 | qApp->processEvents(); | 1353 | qApp->processEvents(); |
1354 | if ( ! bar.isVisible() ) | 1354 | if ( ! bar.isVisible() ) |
1355 | return false; | 1355 | return false; |
1356 | if ( incCounter % modulo == 0 ) | 1356 | if ( incCounter % modulo == 0 ) |
1357 | bar.setProgress( incCounter ); | 1357 | bar.setProgress( incCounter ); |
1358 | ++incCounter; | 1358 | ++incCounter; |
1359 | uid = inL->uid(); | 1359 | uid = inL->uid(); |
1360 | bool skipIncidence = false; | 1360 | bool skipIncidence = false; |
1361 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1361 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1362 | skipIncidence = true; | 1362 | skipIncidence = true; |
1363 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1363 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1364 | skipIncidence = true; | 1364 | skipIncidence = true; |
1365 | if ( !skipIncidence ) { | 1365 | if ( !skipIncidence ) { |
1366 | inR = remote->incidence( uid ); | 1366 | inR = remote->incidence( uid ); |
1367 | if ( ! inR ) { | 1367 | if ( ! inR ) { |
1368 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1368 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1369 | // no conflict ********** add or delete local | 1369 | // no conflict ********** add or delete local |
1370 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1370 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1371 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1371 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1372 | checkExternSyncEvent(eventLSyncSharp, inL); | 1372 | checkExternSyncEvent(eventLSyncSharp, inL); |
1373 | local->deleteIncidence( inL ); | 1373 | local->deleteIncidence( inL ); |
1374 | ++deletedEventL; | 1374 | ++deletedEventL; |
1375 | } else { | 1375 | } else { |
1376 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1376 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1377 | inL->removeID(mCurrentSyncDevice ); | 1377 | inL->removeID(mCurrentSyncDevice ); |
1378 | ++addedEventR; | 1378 | ++addedEventR; |
1379 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1379 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1380 | inL->setLastModified( modifiedCalendar ); | 1380 | inL->setLastModified( modifiedCalendar ); |
1381 | inR = inL->clone(); | 1381 | inR = inL->clone(); |
1382 | inR->setIDStr( ":" ); | 1382 | inR->setIDStr( ":" ); |
1383 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1383 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1384 | remote->addIncidence( inR ); | 1384 | remote->addIncidence( inR ); |
1385 | } | 1385 | } |
1386 | } | 1386 | } |
1387 | } else { | 1387 | } else { |
1388 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1388 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1389 | checkExternSyncEvent(eventLSyncSharp, inL); | 1389 | checkExternSyncEvent(eventLSyncSharp, inL); |
1390 | local->deleteIncidence( inL ); | 1390 | local->deleteIncidence( inL ); |
1391 | ++deletedEventL; | 1391 | ++deletedEventL; |
1392 | } else { | 1392 | } else { |
1393 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1393 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1394 | ++addedEventR; | 1394 | ++addedEventR; |
1395 | inL->setLastModified( modifiedCalendar ); | 1395 | inL->setLastModified( modifiedCalendar ); |
1396 | inR = inL->clone(); | 1396 | inR = inL->clone(); |
1397 | inR->setIDStr( ":" ); | 1397 | inR->setIDStr( ":" ); |
1398 | remote->addIncidence( inR ); | 1398 | remote->addIncidence( inR ); |
1399 | } | 1399 | } |
1400 | } | 1400 | } |
1401 | } | 1401 | } |
1402 | } else { | 1402 | } else { |
1403 | ++filteredOUT; | 1403 | ++filteredOUT; |
1404 | } | 1404 | } |
1405 | } | 1405 | } |
1406 | } | 1406 | } |
1407 | inL = el.next(); | 1407 | inL = el.next(); |
1408 | } | 1408 | } |
1409 | int delFut = 0; | 1409 | int delFut = 0; |
1410 | int remRem = 0; | 1410 | int remRem = 0; |
1411 | if ( mSyncManager->mWriteBackInFuture ) { | 1411 | if ( mSyncManager->mWriteBackInFuture ) { |
1412 | er = remote->rawIncidences(); | 1412 | er = remote->rawIncidences(); |
1413 | remRem = er.count(); | 1413 | remRem = er.count(); |
1414 | inR = er.first(); | 1414 | inR = er.first(); |
1415 | QDateTime dt; | 1415 | QDateTime dt; |
1416 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1416 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1417 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1417 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1418 | while ( inR ) { | 1418 | while ( inR ) { |
1419 | if ( inR->typeID() == todoID ) { | 1419 | if ( inR->typeID() == todoID ) { |
1420 | Todo * t = (Todo*)inR; | 1420 | Todo * t = (Todo*)inR; |
1421 | if ( t->hasDueDate() ) | 1421 | if ( t->hasDueDate() ) |
1422 | dt = t->dtDue(); | 1422 | dt = t->dtDue(); |
1423 | else | 1423 | else |
1424 | dt = cur.addSecs( 62 ); | 1424 | dt = cur.addSecs( 62 ); |
1425 | } | 1425 | } |
1426 | else if (inR->typeID() == eventID ) { | 1426 | else if (inR->typeID() == eventID ) { |
1427 | bool ok; | 1427 | bool ok; |
1428 | dt = inR->getNextOccurence( cur, &ok ); | 1428 | dt = inR->getNextOccurence( cur, &ok ); |
1429 | if ( !ok ) | 1429 | if ( !ok ) |
1430 | dt = cur.addSecs( -62 ); | 1430 | dt = cur.addSecs( -62 ); |
1431 | } | 1431 | } |
1432 | else | 1432 | else |
1433 | dt = inR->dtStart(); | 1433 | dt = inR->dtStart(); |
1434 | if ( dt < cur || dt > end ) { | 1434 | if ( dt < cur || dt > end ) { |
1435 | remote->deleteIncidence( inR ); | 1435 | remote->deleteIncidence( inR ); |
1436 | ++delFut; | 1436 | ++delFut; |
1437 | } | 1437 | } |
1438 | inR = er.next(); | 1438 | inR = er.next(); |
1439 | } | 1439 | } |
1440 | } | 1440 | } |
1441 | bar.hide(); | 1441 | bar.hide(); |
1442 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1442 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1443 | eventLSync->setReadOnly( false ); | 1443 | eventLSync->setReadOnly( false ); |
1444 | eventLSync->setDtStart( mLastCalendarSync ); | 1444 | eventLSync->setDtStart( mLastCalendarSync ); |
1445 | eventRSync->setDtStart( mLastCalendarSync ); | 1445 | eventRSync->setDtStart( mLastCalendarSync ); |
1446 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1446 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1447 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1447 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1448 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1448 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1449 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1449 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1450 | eventLSync->setReadOnly( true ); | 1450 | eventLSync->setReadOnly( true ); |
1451 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1451 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1452 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1452 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1453 | remote->addEvent( eventRSync ); | 1453 | remote->addEvent( eventRSync ); |
1454 | else | 1454 | else |
1455 | delete eventRSync; | 1455 | delete eventRSync; |
1456 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1456 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1457 | QString mes; | 1457 | QString mes; |
1458 | 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 ); | 1458 | 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 ); |
1459 | QString delmess; | 1459 | QString delmess; |
1460 | if ( delFut ) { | 1460 | if ( delFut ) { |
1461 | 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); | 1461 | 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); |
1462 | mes += delmess; | 1462 | mes += delmess; |
1463 | } | 1463 | } |
1464 | mes = i18n("Local calendar changed!\n") +mes; | 1464 | mes = i18n("Local calendar changed!\n") +mes; |
1465 | mCalendar->checkAlarmForIncidence( 0, true ); | 1465 | mCalendar->checkAlarmForIncidence( 0, true ); |
1466 | qDebug( mes ); | 1466 | qDebug( mes ); |
1467 | if ( mSyncManager->mShowSyncSummary ) { | 1467 | if ( mSyncManager->mShowSyncSummary ) { |
1468 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1468 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1469 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1469 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1470 | qDebug("KO: WB cancelled "); | 1470 | qDebug("KO: WB cancelled "); |
1471 | mSyncManager->mWriteBackFile = false; | 1471 | mSyncManager->mWriteBackFile = false; |
1472 | return syncOK; | 1472 | return syncOK; |
1473 | } | 1473 | } |
1474 | } | 1474 | } |
1475 | return syncOK; | 1475 | return syncOK; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | void CalendarView::setSyncDevice( QString s ) | 1478 | void CalendarView::setSyncDevice( QString s ) |
1479 | { | 1479 | { |
1480 | mCurrentSyncDevice= s; | 1480 | mCurrentSyncDevice= s; |
1481 | } | 1481 | } |
1482 | void CalendarView::setSyncName( QString s ) | 1482 | void CalendarView::setSyncName( QString s ) |
1483 | { | 1483 | { |
1484 | mCurrentSyncName= s; | 1484 | mCurrentSyncName= s; |
1485 | } | 1485 | } |
1486 | bool CalendarView::syncCalendar(QString filename, int mode) | 1486 | bool CalendarView::syncCalendar(QString filename, int mode) |
1487 | { | 1487 | { |
1488 | //qDebug("syncCalendar %s ", filename.latin1()); | 1488 | //qDebug("syncCalendar %s ", filename.latin1()); |
1489 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1489 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1490 | CalendarLocal* calendar = new CalendarLocal(); | 1490 | CalendarLocal* calendar = new CalendarLocal(); |
1491 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1491 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1492 | FileStorage* storage = new FileStorage( calendar ); | 1492 | FileStorage* storage = new FileStorage( calendar ); |
1493 | bool syncOK = false; | 1493 | bool syncOK = false; |
1494 | storage->setFileName( filename ); | 1494 | storage->setFileName( filename ); |
1495 | // qDebug("loading ... "); | 1495 | // qDebug("loading ... "); |
1496 | if ( storage->load() ) { | 1496 | if ( storage->load() ) { |
1497 | getEventViewerDialog()->setSyncMode( true ); | 1497 | getEventViewerDialog()->setSyncMode( true ); |
1498 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1498 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1499 | getEventViewerDialog()->setSyncMode( false ); | 1499 | getEventViewerDialog()->setSyncMode( false ); |
1500 | if ( syncOK ) { | 1500 | if ( syncOK ) { |
1501 | if ( mSyncManager->mWriteBackFile ) | 1501 | if ( mSyncManager->mWriteBackFile ) |
1502 | { | 1502 | { |
1503 | storage->setSaveFormat( new ICalFormat() ); | 1503 | storage->setSaveFormat( new ICalFormat() ); |
1504 | storage->save(); | 1504 | storage->save(); |
1505 | } | 1505 | } |
1506 | } | 1506 | } |
1507 | setModified( true ); | 1507 | setModified( true ); |
1508 | } | 1508 | } |
1509 | delete storage; | 1509 | delete storage; |
1510 | delete calendar; | 1510 | delete calendar; |
1511 | if ( syncOK ) | 1511 | if ( syncOK ) |
1512 | updateView(); | 1512 | updateView(); |
1513 | return syncOK; | 1513 | return syncOK; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | void CalendarView::syncExternal( int mode ) | 1516 | void CalendarView::syncExternal( int mode ) |
1517 | { | 1517 | { |
1518 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1518 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1519 | 1519 | ||
1520 | qApp->processEvents(); | 1520 | qApp->processEvents(); |
1521 | CalendarLocal* calendar = new CalendarLocal(); | 1521 | CalendarLocal* calendar = new CalendarLocal(); |
1522 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1522 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1523 | bool syncOK = false; | 1523 | bool syncOK = false; |
1524 | bool loadSuccess = false; | 1524 | bool loadSuccess = false; |
1525 | PhoneFormat* phoneFormat = 0; | 1525 | PhoneFormat* phoneFormat = 0; |
1526 | emit tempDisableBR(true); | 1526 | emit tempDisableBR(true); |
1527 | #ifndef DESKTOP_VERSION | 1527 | #ifndef DESKTOP_VERSION |
1528 | SharpFormat* sharpFormat = 0; | 1528 | SharpFormat* sharpFormat = 0; |
1529 | if ( mode == 0 ) { // sharp | 1529 | if ( mode == 0 ) { // sharp |
1530 | sharpFormat = new SharpFormat () ; | 1530 | sharpFormat = new SharpFormat () ; |
1531 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1531 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1532 | 1532 | ||
1533 | } else | 1533 | } else |
1534 | #endif | 1534 | #endif |
1535 | if ( mode == 1 ) { // phone | 1535 | if ( mode == 1 ) { // phone |
1536 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1536 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1537 | mSyncManager->mPhoneDevice, | 1537 | mSyncManager->mPhoneDevice, |
1538 | mSyncManager->mPhoneConnection, | 1538 | mSyncManager->mPhoneConnection, |
1539 | mSyncManager->mPhoneModel); | 1539 | mSyncManager->mPhoneModel); |
1540 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1540 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1541 | 1541 | ||
1542 | } else { | 1542 | } else { |
1543 | emit tempDisableBR(false); | 1543 | emit tempDisableBR(false); |
1544 | return; | 1544 | return; |
1545 | } | 1545 | } |
1546 | if ( loadSuccess ) { | 1546 | if ( loadSuccess ) { |
1547 | getEventViewerDialog()->setSyncMode( true ); | 1547 | getEventViewerDialog()->setSyncMode( true ); |
1548 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1548 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1549 | getEventViewerDialog()->setSyncMode( false ); | 1549 | getEventViewerDialog()->setSyncMode( false ); |
1550 | qApp->processEvents(); | 1550 | qApp->processEvents(); |
1551 | if ( syncOK ) { | 1551 | if ( syncOK ) { |
1552 | if ( mSyncManager->mWriteBackFile ) | 1552 | if ( mSyncManager->mWriteBackFile ) |
1553 | { | 1553 | { |
1554 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1554 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1555 | Incidence* inc = iL.first(); | 1555 | Incidence* inc = iL.first(); |
1556 | if ( phoneFormat ) { | 1556 | if ( phoneFormat ) { |
1557 | while ( inc ) { | 1557 | while ( inc ) { |
1558 | inc->removeID(mCurrentSyncDevice); | 1558 | inc->removeID(mCurrentSyncDevice); |
1559 | inc = iL.next(); | 1559 | inc = iL.next(); |
1560 | } | 1560 | } |
1561 | } | 1561 | } |
1562 | #ifndef DESKTOP_VERSION | 1562 | #ifndef DESKTOP_VERSION |
1563 | if ( sharpFormat ) | 1563 | if ( sharpFormat ) |
1564 | sharpFormat->save(calendar); | 1564 | sharpFormat->save(calendar); |
1565 | #endif | 1565 | #endif |
1566 | if ( phoneFormat ) | 1566 | if ( phoneFormat ) |
1567 | phoneFormat->save(calendar); | 1567 | phoneFormat->save(calendar); |
1568 | iL = calendar->rawIncidences(); | 1568 | iL = calendar->rawIncidences(); |
1569 | inc = iL.first(); | 1569 | inc = iL.first(); |
1570 | Incidence* loc; | 1570 | Incidence* loc; |
1571 | while ( inc ) { | 1571 | while ( inc ) { |
1572 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1572 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1573 | loc = mCalendar->incidence(inc->uid() ); | 1573 | loc = mCalendar->incidence(inc->uid() ); |
1574 | if ( loc ) { | 1574 | if ( loc ) { |
1575 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1575 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1576 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1576 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1577 | } | 1577 | } |
1578 | } | 1578 | } |
1579 | inc = iL.next(); | 1579 | inc = iL.next(); |
1580 | } | 1580 | } |
1581 | Incidence* lse = getLastSyncEvent(); | 1581 | Incidence* lse = getLastSyncEvent(); |
1582 | if ( lse ) { | 1582 | if ( lse ) { |
1583 | lse->setReadOnly( false ); | 1583 | lse->setReadOnly( false ); |
1584 | lse->setDescription( "" ); | 1584 | lse->setDescription( "" ); |
1585 | lse->setReadOnly( true ); | 1585 | lse->setReadOnly( true ); |
1586 | } | 1586 | } |
1587 | } | 1587 | } |
1588 | } else { | 1588 | } else { |
1589 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1589 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1590 | } | 1590 | } |
1591 | setModified( true ); | 1591 | setModified( true ); |
1592 | } else { | 1592 | } else { |
1593 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1593 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1594 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1594 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1595 | question, i18n("Ok")) ; | 1595 | question, i18n("Ok")) ; |
1596 | 1596 | ||
1597 | } | 1597 | } |
1598 | delete calendar; | 1598 | delete calendar; |
1599 | updateView(); | 1599 | updateView(); |
1600 | emit tempDisableBR(false); | 1600 | emit tempDisableBR(false); |
1601 | return ;//syncOK; | 1601 | return ;//syncOK; |
1602 | 1602 | ||
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | bool CalendarView::importBday() | 1605 | bool CalendarView::importBday() |
1606 | { | 1606 | { |
1607 | #ifndef KORG_NOKABC | 1607 | #ifndef KORG_NOKABC |
1608 | 1608 | ||
1609 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1610 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1610 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1611 | KABC::AddressBook::Iterator it; | 1611 | KABC::AddressBook::Iterator it; |
1612 | int count = 0; | 1612 | int count = 0; |
1613 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1613 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1614 | ++count; | 1614 | ++count; |
1615 | } | 1615 | } |
1616 | QProgressBar bar(count,0 ); | 1616 | QProgressBar bar(count,0 ); |
1617 | int w = 300; | 1617 | int w = 300; |
1618 | if ( QApplication::desktop()->width() < 320 ) | 1618 | if ( QApplication::desktop()->width() < 320 ) |
1619 | w = 220; | 1619 | w = 220; |
1620 | int h = bar.sizeHint().height() ; | 1620 | int h = bar.sizeHint().height() ; |
1621 | int dw = QApplication::desktop()->width(); | 1621 | int dw = QApplication::desktop()->width(); |
1622 | int dh = QApplication::desktop()->height(); | 1622 | int dh = QApplication::desktop()->height(); |
1623 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1623 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1624 | bar.show(); | 1624 | bar.show(); |
1625 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1625 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1626 | qApp->processEvents(); | 1626 | qApp->processEvents(); |
1627 | count = 0; | 1627 | count = 0; |
1628 | int addCount = 0; | 1628 | int addCount = 0; |
1629 | KCal::Attendee* a = 0; | 1629 | KCal::Attendee* a = 0; |
1630 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1630 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1631 | if ( ! bar.isVisible() ) | 1631 | if ( ! bar.isVisible() ) |
1632 | return false; | 1632 | return false; |
1633 | bar.setProgress( count++ ); | 1633 | bar.setProgress( count++ ); |
1634 | qApp->processEvents(); | 1634 | qApp->processEvents(); |
1635 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1635 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1636 | if ( (*it).birthday().date().isValid() ){ | 1636 | if ( (*it).birthday().date().isValid() ){ |
1637 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1637 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1638 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1638 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1639 | ++addCount; | 1639 | ++addCount; |
1640 | } | 1640 | } |
1641 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1641 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1642 | if ( anni.isValid() ){ | 1642 | if ( anni.isValid() ){ |
1643 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1643 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1644 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1644 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1645 | ++addCount; | 1645 | ++addCount; |
1646 | } | 1646 | } |
1647 | } | 1647 | } |
1648 | updateView(); | 1648 | updateView(); |
1649 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1649 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1650 | #else //DESKTOP_VERSION | 1650 | #else //DESKTOP_VERSION |
1651 | 1651 | ||
1652 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1652 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1653 | // the result should now arrive through method insertBirthdays | 1653 | // the result should now arrive through method insertBirthdays |
1654 | 1654 | ||
1655 | #endif //DESKTOP_VERSION | 1655 | #endif //DESKTOP_VERSION |
1656 | 1656 | ||
1657 | #endif //KORG_NOKABC | 1657 | #endif //KORG_NOKABC |
1658 | 1658 | ||
1659 | 1659 | ||
1660 | return true; | 1660 | return true; |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1663 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1664 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1664 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1665 | const QStringList& anniversaryList, const QStringList& realNameList, | 1665 | const QStringList& anniversaryList, const QStringList& realNameList, |
1666 | const QStringList& emailList, const QStringList& assembledNameList, | 1666 | const QStringList& emailList, const QStringList& assembledNameList, |
1667 | const QStringList& uidList) | 1667 | const QStringList& uidList) |
1668 | { | 1668 | { |
1669 | //qDebug("KO::CalendarView::insertBirthdays"); | 1669 | //qDebug("KO::CalendarView::insertBirthdays"); |
1670 | if (uid == this->name()) | 1670 | if (uid == this->name()) |
1671 | { | 1671 | { |
1672 | int count = birthdayList.count(); | 1672 | int count = birthdayList.count(); |
1673 | int addCount = 0; | 1673 | int addCount = 0; |
1674 | KCal::Attendee* a = 0; | 1674 | KCal::Attendee* a = 0; |
1675 | 1675 | ||
1676 | //qDebug("CalView 1 %i", count); | 1676 | //qDebug("CalView 1 %i", count); |
1677 | 1677 | ||
1678 | QProgressBar bar(count,0 ); | 1678 | QProgressBar bar(count,0 ); |
1679 | int w = 300; | 1679 | int w = 300; |
1680 | if ( QApplication::desktop()->width() < 320 ) | 1680 | if ( QApplication::desktop()->width() < 320 ) |
1681 | w = 220; | 1681 | w = 220; |
1682 | int h = bar.sizeHint().height() ; | 1682 | int h = bar.sizeHint().height() ; |
1683 | int dw = QApplication::desktop()->width(); | 1683 | int dw = QApplication::desktop()->width(); |
1684 | int dh = QApplication::desktop()->height(); | 1684 | int dh = QApplication::desktop()->height(); |
1685 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1685 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1686 | bar.show(); | 1686 | bar.show(); |
1687 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1687 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1688 | qApp->processEvents(); | 1688 | qApp->processEvents(); |
1689 | 1689 | ||
1690 | QDate birthday; | 1690 | QDate birthday; |
1691 | QDate anniversary; | 1691 | QDate anniversary; |
1692 | QString realName; | 1692 | QString realName; |
1693 | QString email; | 1693 | QString email; |
1694 | QString assembledName; | 1694 | QString assembledName; |
1695 | QString uid; | 1695 | QString uid; |
1696 | bool ok = true; | 1696 | bool ok = true; |
1697 | for ( int i = 0; i < count; i++) | 1697 | for ( int i = 0; i < count; i++) |
1698 | { | 1698 | { |
1699 | if ( ! bar.isVisible() ) | 1699 | if ( ! bar.isVisible() ) |
1700 | return; | 1700 | return; |
1701 | bar.setProgress( i ); | 1701 | bar.setProgress( i ); |
1702 | qApp->processEvents(); | 1702 | qApp->processEvents(); |
1703 | 1703 | ||
1704 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1704 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1705 | if (!ok) { | 1705 | if (!ok) { |
1706 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1706 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1707 | } | 1707 | } |
1708 | 1708 | ||
1709 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1709 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1710 | if (!ok) { | 1710 | if (!ok) { |
1711 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1711 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1712 | } | 1712 | } |
1713 | realName = realNameList[i]; | 1713 | realName = realNameList[i]; |
1714 | email = emailList[i]; | 1714 | email = emailList[i]; |
1715 | assembledName = assembledNameList[i]; | 1715 | assembledName = assembledNameList[i]; |
1716 | uid = uidList[i]; | 1716 | uid = uidList[i]; |
1717 | //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() ); | 1717 | //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() ); |
1718 | 1718 | ||
1719 | if ( birthday.isValid() ){ | 1719 | if ( birthday.isValid() ){ |
1720 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1720 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1721 | KCal::Attendee::ReqParticipant,uid) ; | 1721 | KCal::Attendee::ReqParticipant,uid) ; |
1722 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1722 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1723 | ++addCount; | 1723 | ++addCount; |
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | if ( anniversary.isValid() ){ | 1726 | if ( anniversary.isValid() ){ |
1727 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1727 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1728 | KCal::Attendee::ReqParticipant,uid) ; | 1728 | KCal::Attendee::ReqParticipant,uid) ; |
1729 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1729 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1730 | ++addCount; | 1730 | ++addCount; |
1731 | } | 1731 | } |
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | updateView(); | 1734 | updateView(); |
1735 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1735 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1736 | 1736 | ||
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | 1741 | ||
1742 | 1742 | ||
1743 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1743 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1744 | { | 1744 | { |
1745 | //qDebug("addAnni "); | 1745 | //qDebug("addAnni "); |
1746 | Event * ev = new Event(); | 1746 | Event * ev = new Event(); |
1747 | ev->setOrganizer(KOPrefs::instance()->email()); | 1747 | ev->setOrganizer(KOPrefs::instance()->email()); |
1748 | if ( a ) { | 1748 | if ( a ) { |
1749 | ev->addAttendee( a ); | 1749 | ev->addAttendee( a ); |
1750 | } | 1750 | } |
1751 | QString kind; | 1751 | QString kind; |
1752 | if ( birthday ) { | 1752 | if ( birthday ) { |
1753 | kind = i18n( "Birthday" ); | 1753 | kind = i18n( "Birthday" ); |
1754 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1754 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1755 | } | 1755 | } |
1756 | else { | 1756 | else { |
1757 | kind = i18n( "Anniversary" ); | 1757 | kind = i18n( "Anniversary" ); |
1758 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1758 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1759 | } | 1759 | } |
1760 | ev->setCategories( kind ); | 1760 | ev->setCategories( kind ); |
1761 | ev->setDtStart( QDateTime(date) ); | 1761 | ev->setDtStart( QDateTime(date) ); |
1762 | ev->setDtEnd( QDateTime(date) ); | 1762 | ev->setDtEnd( QDateTime(date) ); |
1763 | ev->setFloats( true ); | 1763 | ev->setFloats( true ); |
1764 | Recurrence * rec = ev->recurrence(); | 1764 | Recurrence * rec = ev->recurrence(); |
1765 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1765 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1766 | rec->addYearlyNum( date.month() ); | 1766 | rec->addYearlyNum( date.month() ); |
1767 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1767 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1768 | delete ev; | 1768 | delete ev; |
1769 | return false; | 1769 | return false; |
1770 | } | 1770 | } |
1771 | return true; | 1771 | return true; |
1772 | 1772 | ||
1773 | } | 1773 | } |
1774 | bool CalendarView::importQtopia( const QString &categories, | 1774 | bool CalendarView::importQtopia( const QString &categories, |
1775 | const QString &datebook, | 1775 | const QString &datebook, |
1776 | const QString &todolist ) | 1776 | const QString &todolist ) |
1777 | { | 1777 | { |
1778 | 1778 | ||
1779 | QtopiaFormat qtopiaFormat; | 1779 | QtopiaFormat qtopiaFormat; |
1780 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1780 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1781 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1781 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1782 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1782 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1783 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1783 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1784 | 1784 | ||
1785 | updateView(); | 1785 | updateView(); |
1786 | return true; | 1786 | return true; |
1787 | 1787 | ||
1788 | #if 0 | 1788 | #if 0 |
1789 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1789 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1790 | mCurrentSyncDevice = "qtopia-XML"; | 1790 | mCurrentSyncDevice = "qtopia-XML"; |
1791 | if ( mSyncManager->mAskForPreferences ) | 1791 | if ( mSyncManager->mAskForPreferences ) |
1792 | edit_sync_options(); | 1792 | edit_sync_options(); |
1793 | qApp->processEvents(); | 1793 | qApp->processEvents(); |
1794 | CalendarLocal* calendar = new CalendarLocal(); | 1794 | CalendarLocal* calendar = new CalendarLocal(); |
1795 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1795 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1796 | bool syncOK = false; | 1796 | bool syncOK = false; |
1797 | QtopiaFormat qtopiaFormat; | 1797 | QtopiaFormat qtopiaFormat; |
1798 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1798 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1799 | bool loadOk = true; | 1799 | bool loadOk = true; |
1800 | if ( !categories.isEmpty() ) | 1800 | if ( !categories.isEmpty() ) |
1801 | loadOk = qtopiaFormat.load( calendar, categories ); | 1801 | loadOk = qtopiaFormat.load( calendar, categories ); |
1802 | if ( loadOk && !datebook.isEmpty() ) | 1802 | if ( loadOk && !datebook.isEmpty() ) |
1803 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1803 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1804 | if ( loadOk && !todolist.isEmpty() ) | 1804 | if ( loadOk && !todolist.isEmpty() ) |
1805 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1805 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1806 | 1806 | ||
1807 | if ( loadOk ) { | 1807 | if ( loadOk ) { |
1808 | getEventViewerDialog()->setSyncMode( true ); | 1808 | getEventViewerDialog()->setSyncMode( true ); |
1809 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1809 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1810 | getEventViewerDialog()->setSyncMode( false ); | 1810 | getEventViewerDialog()->setSyncMode( false ); |
1811 | qApp->processEvents(); | 1811 | qApp->processEvents(); |
1812 | if ( syncOK ) { | 1812 | if ( syncOK ) { |
1813 | if ( mSyncManager->mWriteBackFile ) | 1813 | if ( mSyncManager->mWriteBackFile ) |
1814 | { | 1814 | { |
1815 | // write back XML file | 1815 | // write back XML file |
1816 | 1816 | ||
1817 | } | 1817 | } |
1818 | setModified( true ); | 1818 | setModified( true ); |
1819 | } | 1819 | } |
1820 | } else { | 1820 | } else { |
1821 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1821 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1822 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1822 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1823 | question, i18n("Ok")) ; | 1823 | question, i18n("Ok")) ; |
1824 | } | 1824 | } |
1825 | delete calendar; | 1825 | delete calendar; |
1826 | updateView(); | 1826 | updateView(); |
1827 | return syncOK; | 1827 | return syncOK; |
1828 | 1828 | ||
1829 | 1829 | ||
1830 | #endif | 1830 | #endif |
1831 | 1831 | ||
1832 | } | 1832 | } |
1833 | 1833 | ||
1834 | void CalendarView::setSyncEventsReadOnly() | 1834 | void CalendarView::setSyncEventsReadOnly() |
1835 | { | 1835 | { |
1836 | mCalendar->setSyncEventsReadOnly(); | 1836 | mCalendar->setSyncEventsReadOnly(); |
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | bool CalendarView::loadCalendars() | 1839 | bool CalendarView::loadCalendars() |
1840 | { | 1840 | { |
1841 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1841 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1842 | KopiCalendarFile * cal = calendars.first(); | 1842 | KopiCalendarFile * cal = calendars.first(); |
1843 | mCalendar->setDefaultCalendar( 1 ); | 1843 | mCalendar->setDefaultCalendar( 1 ); |
1844 | openCalendar( MainWindow::defaultFileName(), false ); | 1844 | openCalendar( MainWindow::defaultFileName(), false ); |
1845 | cal = calendars.next(); | 1845 | cal = calendars.next(); |
1846 | while ( cal ) { | 1846 | while ( cal ) { |
1847 | addCalendar( cal ); | 1847 | addCalendar( cal ); |
1848 | cal = calendars.next(); | 1848 | cal = calendars.next(); |
1849 | } | 1849 | } |
1850 | restoreCalendarSettings(); | 1850 | restoreCalendarSettings(); |
1851 | return true; | 1851 | return true; |
1852 | } | 1852 | } |
1853 | bool CalendarView::restoreCalendarSettings() | 1853 | bool CalendarView::restoreCalendarSettings() |
1854 | { | 1854 | { |
1855 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1855 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1856 | KopiCalendarFile * cal = calendars.first(); | 1856 | KopiCalendarFile * cal = calendars.first(); |
1857 | while ( cal ) { | 1857 | while ( cal ) { |
1858 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1858 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1859 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1859 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1860 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1860 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1861 | if ( cal->isStandard ) | 1861 | if ( cal->isStandard ) |
1862 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1862 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1863 | cal = calendars.next(); | 1863 | cal = calendars.next(); |
1864 | } | 1864 | } |
1865 | setSyncEventsReadOnly(); | 1865 | setSyncEventsReadOnly(); |
1866 | mCalendar->reInitAlarmSettings(); | 1866 | mCalendar->reInitAlarmSettings(); |
1867 | updateUnmanagedViews(); | 1867 | updateUnmanagedViews(); |
1868 | updateView(); | 1868 | updateView(); |
1869 | return true; | 1869 | return true; |
1870 | } | 1870 | } |
1871 | void CalendarView::addCalendarId( int id ) | 1871 | void CalendarView::addCalendarId( int id ) |
1872 | { | 1872 | { |
1873 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1873 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1874 | addCalendar( cal ); | 1874 | addCalendar( cal ); |
1875 | } | 1875 | } |
1876 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1876 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1877 | { | 1877 | { |
1878 | cal->mErrorOnLoad = false; | 1878 | cal->mErrorOnLoad = false; |
1879 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 1879 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1880 | cal->mLoadDt = QDateTime::currentDateTime(); | 1880 | cal->mLoadDt = QDateTime::currentDateTime(); |
1881 | return true; | 1881 | return true; |
1882 | } | 1882 | } |
1883 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1883 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1884 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1884 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1885 | cal->mErrorOnLoad = true; | 1885 | cal->mErrorOnLoad = true; |
1886 | return false; | 1886 | return false; |
1887 | } | 1887 | } |
1888 | bool CalendarView::openCalendar(QString filename, bool merge) | 1888 | bool CalendarView::openCalendar(QString filename, bool merge) |
1889 | { | 1889 | { |
1890 | 1890 | ||
1891 | if (filename.isEmpty()) { | 1891 | if (filename.isEmpty()) { |
1892 | return false; | 1892 | return false; |
1893 | } | 1893 | } |
1894 | 1894 | ||
1895 | if (!QFile::exists(filename)) { | 1895 | if (!QFile::exists(filename)) { |
1896 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1896 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1897 | return false; | 1897 | return false; |
1898 | } | 1898 | } |
1899 | 1899 | ||
1900 | globalFlagBlockAgenda = 1; | 1900 | globalFlagBlockAgenda = 1; |
1901 | clearAllViews(); | 1901 | clearAllViews(); |
1902 | if (!merge) { | 1902 | if (!merge) { |
1903 | mViewManager->setDocumentId( filename ); | 1903 | mViewManager->setDocumentId( filename ); |
1904 | mCalendar->close(); | 1904 | mCalendar->close(); |
1905 | } | 1905 | } |
1906 | mStorage->setFileName( filename ); | 1906 | mStorage->setFileName( filename ); |
1907 | 1907 | ||
1908 | if ( mStorage->load() ) { | 1908 | if ( mStorage->load() ) { |
1909 | if ( merge ) ;//setModified( true ); | 1909 | if ( merge ) ;//setModified( true ); |
1910 | else { | 1910 | else { |
1911 | //setModified( true ); | 1911 | //setModified( true ); |
1912 | mViewManager->setDocumentId( filename ); | 1912 | mViewManager->setDocumentId( filename ); |
1913 | mDialogManager->setDocumentId( filename ); | 1913 | mDialogManager->setDocumentId( filename ); |
1914 | mTodoList->setDocumentId( filename ); | 1914 | mTodoList->setDocumentId( filename ); |
1915 | } | 1915 | } |
1916 | globalFlagBlockAgenda = 2; | 1916 | globalFlagBlockAgenda = 2; |
1917 | // if ( getLastSyncEvent() ) | 1917 | // if ( getLastSyncEvent() ) |
1918 | // getLastSyncEvent()->setReadOnly( true ); | 1918 | // getLastSyncEvent()->setReadOnly( true ); |
1919 | mCalendar->reInitAlarmSettings(); | 1919 | mCalendar->reInitAlarmSettings(); |
1920 | setSyncEventsReadOnly(); | 1920 | setSyncEventsReadOnly(); |
1921 | updateUnmanagedViews(); | 1921 | updateUnmanagedViews(); |
1922 | updateView(); | 1922 | updateView(); |
1923 | if ( filename != MainWindow::defaultFileName() ) { | 1923 | if ( filename != MainWindow::defaultFileName() ) { |
1924 | saveCalendar( MainWindow::defaultFileName() ); | 1924 | saveCalendar( MainWindow::defaultFileName() ); |
1925 | } else { | 1925 | } else { |
1926 | QFileInfo finf ( MainWindow::defaultFileName()); | 1926 | QFileInfo finf ( MainWindow::defaultFileName()); |
1927 | if ( finf.exists() ) { | 1927 | if ( finf.exists() ) { |
1928 | setLoadedFileVersion( finf.lastModified () ); | 1928 | setLoadedFileVersion( finf.lastModified () ); |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | return true; | 1931 | return true; |
1932 | } else { | 1932 | } else { |
1933 | // while failing to load, the calendar object could | 1933 | // while failing to load, the calendar object could |
1934 | // have become partially populated. Clear it out. | 1934 | // have become partially populated. Clear it out. |
1935 | if ( !merge ) { | 1935 | if ( !merge ) { |
1936 | mCalendar->close(); | 1936 | mCalendar->close(); |
1937 | mViewManager->setDocumentId( filename ); | 1937 | mViewManager->setDocumentId( filename ); |
1938 | mDialogManager->setDocumentId( filename ); | 1938 | mDialogManager->setDocumentId( filename ); |
1939 | mTodoList->setDocumentId( filename ); | 1939 | mTodoList->setDocumentId( filename ); |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1942 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1943 | 1943 | ||
1944 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1944 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1945 | globalFlagBlockAgenda = 2; | 1945 | globalFlagBlockAgenda = 2; |
1946 | mCalendar->reInitAlarmSettings(); | 1946 | mCalendar->reInitAlarmSettings(); |
1947 | setSyncEventsReadOnly(); | 1947 | setSyncEventsReadOnly(); |
1948 | updateUnmanagedViews(); | 1948 | updateUnmanagedViews(); |
1949 | updateView(); | 1949 | updateView(); |
1950 | } | 1950 | } |
1951 | return false; | 1951 | return false; |
1952 | } | 1952 | } |
1953 | void CalendarView::showOpenError() | 1953 | void CalendarView::showOpenError() |
1954 | { | 1954 | { |
1955 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1955 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1956 | } | 1956 | } |
1957 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1957 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1958 | { | 1958 | { |
1959 | loadedFileVersion = dt; | 1959 | loadedFileVersion = dt; |
1960 | } | 1960 | } |
1961 | bool CalendarView::checkFileChanged(QString fn) | 1961 | bool CalendarView::checkFileChanged(QString fn) |
1962 | { | 1962 | { |
1963 | QFileInfo finf ( fn ); | 1963 | QFileInfo finf ( fn ); |
1964 | if ( !finf.exists() ) | 1964 | if ( !finf.exists() ) |
1965 | return true; | 1965 | return true; |
1966 | QDateTime dt = finf.lastModified (); | 1966 | QDateTime dt = finf.lastModified (); |
1967 | if ( dt <= loadedFileVersion ) | 1967 | if ( dt <= loadedFileVersion ) |
1968 | return false; | 1968 | return false; |
1969 | return true; | 1969 | return true; |
1970 | 1970 | ||
1971 | } | 1971 | } |
1972 | void CalendarView::watchSavedFile() | 1972 | void CalendarView::watchSavedFile() |
1973 | { | 1973 | { |
1974 | QFileInfo finf ( MainWindow::defaultFileName()); | 1974 | QFileInfo finf ( MainWindow::defaultFileName()); |
1975 | if ( !finf.exists() ) | 1975 | if ( !finf.exists() ) |
1976 | return; | 1976 | return; |
1977 | QDateTime dt = finf.lastModified (); | 1977 | QDateTime dt = finf.lastModified (); |
1978 | if ( dt < loadedFileVersion ) { | 1978 | if ( dt < loadedFileVersion ) { |
1979 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1979 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1980 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1980 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1981 | return; | 1981 | return; |
1982 | } | 1982 | } |
1983 | loadedFileVersion = dt; | 1983 | loadedFileVersion = dt; |
1984 | } | 1984 | } |
1985 | bool CalendarView::checkAllFileVersions() | 1985 | bool CalendarView::checkAllFileVersions() |
1986 | { | 1986 | { |
1987 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1987 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1988 | KopiCalendarFile * cal = calendars.first(); | 1988 | KopiCalendarFile * cal = calendars.first(); |
1989 | mCalendar->setDefaultCalendar( 1 ); | 1989 | mCalendar->setDefaultCalendar( 1 ); |
1990 | mCalendar->setDefaultCalendarEnabledOnly(); | 1990 | mCalendar->setDefaultCalendarEnabledOnly(); |
1991 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 1991 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
1992 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 1992 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
1993 | restoreCalendarSettings(); | 1993 | restoreCalendarSettings(); |
1994 | return false; | 1994 | return false; |
1995 | } | 1995 | } |
1996 | } | 1996 | } |
1997 | cal = calendars.next(); | 1997 | cal = calendars.next(); |
1998 | QDateTime storeTemp = loadedFileVersion; | 1998 | QDateTime storeTemp = loadedFileVersion; |
1999 | while ( cal ) { | 1999 | while ( cal ) { |
2000 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2000 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2001 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2001 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2002 | mCalendar->setDefaultCalendarEnabledOnly(); | 2002 | mCalendar->setDefaultCalendarEnabledOnly(); |
2003 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2003 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2004 | if ( !checkFileVersion(cal->mFileName )) { | 2004 | if ( !checkFileVersion(cal->mFileName )) { |
2005 | loadedFileVersion = storeTemp; | 2005 | loadedFileVersion = storeTemp; |
2006 | restoreCalendarSettings(); | 2006 | restoreCalendarSettings(); |
2007 | return false; | 2007 | return false; |
2008 | } | 2008 | } |
2009 | } | 2009 | } |
2010 | cal = calendars.next(); | 2010 | cal = calendars.next(); |
2011 | } | 2011 | } |
2012 | loadedFileVersion = storeTemp; | 2012 | loadedFileVersion = storeTemp; |
2013 | return true; | 2013 | return true; |
2014 | } | 2014 | } |
2015 | bool CalendarView::checkFileVersion(QString fn) | 2015 | bool CalendarView::checkFileVersion(QString fn) |
2016 | { | 2016 | { |
2017 | QFileInfo finf ( fn ); | 2017 | QFileInfo finf ( fn ); |
2018 | if ( !finf.exists() ) | 2018 | if ( !finf.exists() ) |
2019 | return true; | 2019 | return true; |
2020 | QDateTime dt = finf.lastModified (); | 2020 | QDateTime dt = finf.lastModified (); |
2021 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2021 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2022 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2022 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2023 | if ( dt <= loadedFileVersion ) | 2023 | if ( dt <= loadedFileVersion ) |
2024 | return true; | 2024 | return true; |
2025 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on 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(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2025 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on 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(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2026 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2026 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2027 | i18n("Sync+save")); | 2027 | i18n("Sync+save")); |
2028 | 2028 | ||
2029 | if ( km == KMessageBox::Cancel ) | 2029 | if ( km == KMessageBox::Cancel ) |
2030 | return false; | 2030 | return false; |
2031 | if ( km == KMessageBox::Yes ) | 2031 | if ( km == KMessageBox::Yes ) |
2032 | return true; | 2032 | return true; |
2033 | 2033 | ||
2034 | setSyncDevice("deleteaftersync" ); | 2034 | setSyncDevice("deleteaftersync" ); |
2035 | mSyncManager->mAskForPreferences = true; | 2035 | mSyncManager->mAskForPreferences = true; |
2036 | mSyncManager->mSyncAlgoPrefs = 3; | 2036 | mSyncManager->mSyncAlgoPrefs = 3; |
2037 | mSyncManager->mWriteBackFile = false; | 2037 | mSyncManager->mWriteBackFile = false; |
2038 | mSyncManager->mWriteBackExistingOnly = false; | 2038 | mSyncManager->mWriteBackExistingOnly = false; |
2039 | mSyncManager->mShowSyncSummary = false; | 2039 | mSyncManager->mShowSyncSummary = false; |
2040 | syncCalendar( fn, 3 ); | 2040 | syncCalendar( fn, 3 ); |
2041 | Event * e = getLastSyncEvent(); | 2041 | Event * e = getLastSyncEvent(); |
2042 | if ( e ) | 2042 | if ( e ) |
2043 | mCalendar->deleteEvent( e ); | 2043 | mCalendar->deleteEvent( e ); |
2044 | return true; | 2044 | return true; |
2045 | } | 2045 | } |
2046 | bool CalendarView::saveCalendars() | 2046 | bool CalendarView::saveCalendars() |
2047 | { | 2047 | { |
2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2049 | KopiCalendarFile * cal = calendars.first(); | 2049 | KopiCalendarFile * cal = calendars.first(); |
2050 | mCalendar->setDefaultCalendar( 1 ); | 2050 | mCalendar->setDefaultCalendar( 1 ); |
2051 | mCalendar->setDefaultCalendarEnabledOnly(); | 2051 | mCalendar->setDefaultCalendarEnabledOnly(); |
2052 | saveCalendar( MainWindow::defaultFileName() ); | 2052 | saveCalendar( MainWindow::defaultFileName() ); |
2053 | cal = calendars.next(); | 2053 | cal = calendars.next(); |
2054 | while ( cal ) { | 2054 | while ( cal ) { |
2055 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2055 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2056 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2056 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2057 | mCalendar->setDefaultCalendarEnabledOnly(); | 2057 | mCalendar->setDefaultCalendarEnabledOnly(); |
2058 | if ( saveCalendar( cal->mFileName ) ) | 2058 | if ( saveCalendar( cal->mFileName ) ) |
2059 | cal->mLoadDt = QDateTime::currentDateTime(); | 2059 | cal->mLoadDt = QDateTime::currentDateTime(); |
2060 | } | 2060 | } |
2061 | cal = calendars.next(); | 2061 | cal = calendars.next(); |
2062 | } | 2062 | } |
2063 | restoreCalendarSettings(); | 2063 | restoreCalendarSettings(); |
2064 | return true; | 2064 | return true; |
2065 | } | 2065 | } |
2066 | bool CalendarView::saveCalendar( QString filename ) | 2066 | bool CalendarView::saveCalendar( QString filename ) |
2067 | { | 2067 | { |
2068 | 2068 | ||
2069 | // Store back all unsaved data into calendar object | 2069 | // Store back all unsaved data into calendar object |
2070 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2070 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2071 | if ( mViewManager->currentView() ) | 2071 | if ( mViewManager->currentView() ) |
2072 | mViewManager->currentView()->flushView(); | 2072 | mViewManager->currentView()->flushView(); |
2073 | 2073 | ||
2074 | 2074 | ||
2075 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2075 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2076 | mStorage->setSaveFormat( new ICalFormat() ); | 2076 | mStorage->setSaveFormat( new ICalFormat() ); |
2077 | mStorage->setFileName( filename ); | 2077 | mStorage->setFileName( filename ); |
2078 | bool success; | 2078 | bool success; |
2079 | success = mStorage->save(); | 2079 | success = mStorage->save(); |
2080 | if ( !success ) { | 2080 | if ( !success ) { |
2081 | return false; | 2081 | return false; |
2082 | } | 2082 | } |
2083 | if ( filename == MainWindow::defaultFileName() ) { | 2083 | if ( filename == MainWindow::defaultFileName() ) { |
2084 | setLoadedFileVersion( lfv ); | 2084 | setLoadedFileVersion( lfv ); |
2085 | watchSavedFile(); | 2085 | watchSavedFile(); |
2086 | } | 2086 | } |
2087 | return true; | 2087 | return true; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | void CalendarView::closeCalendar() | 2090 | void CalendarView::closeCalendar() |
2091 | { | 2091 | { |
2092 | 2092 | ||
2093 | // child windows no longer valid | 2093 | // child windows no longer valid |
2094 | clearAllViews(); | 2094 | clearAllViews(); |
2095 | emit closingDown(); | 2095 | emit closingDown(); |
2096 | 2096 | ||
2097 | mCalendar->close(); | 2097 | mCalendar->close(); |
2098 | setModified(false); | 2098 | setModified(false); |
2099 | updateView(); | 2099 | updateView(); |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | void CalendarView::archiveCalendar() | 2102 | void CalendarView::archiveCalendar() |
2103 | { | 2103 | { |
2104 | mDialogManager->showArchiveDialog(); | 2104 | mDialogManager->showArchiveDialog(); |
2105 | } | 2105 | } |
2106 | 2106 | ||
2107 | 2107 | ||
2108 | void CalendarView::readSettings() | 2108 | void CalendarView::readSettings() |
2109 | { | 2109 | { |
2110 | 2110 | ||
2111 | 2111 | ||
2112 | // mViewManager->showAgendaView(); | 2112 | // mViewManager->showAgendaView(); |
2113 | QString str; | 2113 | QString str; |
2114 | //qDebug("CalendarView::readSettings() "); | 2114 | //qDebug("CalendarView::readSettings() "); |
2115 | // read settings from the KConfig, supplying reasonable | 2115 | // read settings from the KConfig, supplying reasonable |
2116 | // defaults where none are to be found | 2116 | // defaults where none are to be found |
2117 | KConfig *config = KOGlobals::config(); | 2117 | KConfig *config = KOGlobals::config(); |
2118 | #ifndef KORG_NOSPLITTER | 2118 | #ifndef KORG_NOSPLITTER |
2119 | config->setGroup("KOrganizer Geometry"); | 2119 | config->setGroup("KOrganizer Geometry"); |
2120 | 2120 | ||
2121 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2121 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2122 | if (sizes.count() != 2) { | 2122 | if (sizes.count() != 2) { |
2123 | sizes << mDateNavigator->minimumSizeHint().width(); | 2123 | sizes << mDateNavigator->minimumSizeHint().width(); |
2124 | sizes << 300; | 2124 | sizes << 300; |
2125 | } | 2125 | } |
2126 | mPanner->setSizes(sizes); | 2126 | mPanner->setSizes(sizes); |
2127 | 2127 | ||
2128 | sizes = config->readIntListEntry("Separator2"); | 2128 | sizes = config->readIntListEntry("Separator2"); |
2129 | if ( ( mResourceView && sizes.count() == 4 ) || | 2129 | if ( ( mResourceView && sizes.count() == 4 ) || |
2130 | ( !mResourceView && sizes.count() == 3 ) ) { | 2130 | ( !mResourceView && sizes.count() == 3 ) ) { |
2131 | mLeftSplitter->setSizes(sizes); | 2131 | mLeftSplitter->setSizes(sizes); |
2132 | } | 2132 | } |
2133 | #endif | 2133 | #endif |
2134 | globalFlagBlockAgenda = 1; | 2134 | globalFlagBlockAgenda = 1; |
2135 | mViewManager->showAgendaView(); | 2135 | mViewManager->showAgendaView(); |
2136 | //mViewManager->readSettings( config ); | 2136 | //mViewManager->readSettings( config ); |
2137 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2137 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2138 | readFilterSettings(config); | 2138 | readFilterSettings(config); |
2139 | 2139 | ||
2140 | #ifdef DESKTOP_VERSION | 2140 | #ifdef DESKTOP_VERSION |
2141 | config->setGroup("WidgetLayout"); | 2141 | config->setGroup("WidgetLayout"); |
2142 | QStringList list; | 2142 | QStringList list; |
2143 | list = config->readListEntry("MainLayout"); | 2143 | list = config->readListEntry("MainLayout"); |
2144 | int x,y,w,h; | 2144 | int x,y,w,h; |
2145 | if ( ! list.isEmpty() ) { | 2145 | if ( ! list.isEmpty() ) { |
2146 | x = list[0].toInt(); | 2146 | x = list[0].toInt(); |
2147 | y = list[1].toInt(); | 2147 | y = list[1].toInt(); |
2148 | w = list[2].toInt(); | 2148 | w = list[2].toInt(); |
2149 | h = list[3].toInt(); | 2149 | h = list[3].toInt(); |
2150 | KApplication::testCoords( &x,&y,&w,&h ); | 2150 | KApplication::testCoords( &x,&y,&w,&h ); |
2151 | topLevelWidget()->setGeometry(x,y,w,h); | 2151 | topLevelWidget()->setGeometry(x,y,w,h); |
2152 | 2152 | ||
2153 | } else { | 2153 | } else { |
2154 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2154 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2155 | } | 2155 | } |
2156 | list = config->readListEntry("EditEventLayout"); | 2156 | list = config->readListEntry("EditEventLayout"); |
2157 | if ( ! list.isEmpty() ) { | 2157 | if ( ! list.isEmpty() ) { |
2158 | x = list[0].toInt(); | 2158 | x = list[0].toInt(); |
2159 | y = list[1].toInt(); | 2159 | y = list[1].toInt(); |
2160 | w = list[2].toInt(); | 2160 | w = list[2].toInt(); |
2161 | h = list[3].toInt(); | 2161 | h = list[3].toInt(); |
2162 | KApplication::testCoords( &x,&y,&w,&h ); | 2162 | KApplication::testCoords( &x,&y,&w,&h ); |
2163 | mEventEditor->setGeometry(x,y,w,h); | 2163 | mEventEditor->setGeometry(x,y,w,h); |
2164 | 2164 | ||
2165 | } | 2165 | } |
2166 | list = config->readListEntry("EditTodoLayout"); | 2166 | list = config->readListEntry("EditTodoLayout"); |
2167 | if ( ! list.isEmpty() ) { | 2167 | if ( ! list.isEmpty() ) { |
2168 | x = list[0].toInt(); | 2168 | x = list[0].toInt(); |
2169 | y = list[1].toInt(); | 2169 | y = list[1].toInt(); |
2170 | w = list[2].toInt(); | 2170 | w = list[2].toInt(); |
2171 | h = list[3].toInt(); | 2171 | h = list[3].toInt(); |
2172 | KApplication::testCoords( &x,&y,&w,&h ); | 2172 | KApplication::testCoords( &x,&y,&w,&h ); |
2173 | mTodoEditor->setGeometry(x,y,w,h); | 2173 | mTodoEditor->setGeometry(x,y,w,h); |
2174 | 2174 | ||
2175 | } | 2175 | } |
2176 | list = config->readListEntry("ViewerLayout"); | 2176 | list = config->readListEntry("ViewerLayout"); |
2177 | if ( ! list.isEmpty() ) { | 2177 | if ( ! list.isEmpty() ) { |
2178 | x = list[0].toInt(); | 2178 | x = list[0].toInt(); |
2179 | y = list[1].toInt(); | 2179 | y = list[1].toInt(); |
2180 | w = list[2].toInt(); | 2180 | w = list[2].toInt(); |
2181 | h = list[3].toInt(); | 2181 | h = list[3].toInt(); |
2182 | KApplication::testCoords( &x,&y,&w,&h ); | 2182 | KApplication::testCoords( &x,&y,&w,&h ); |
2183 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2183 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2184 | } | 2184 | } |
2185 | #endif | 2185 | #endif |
2186 | config->setGroup( "Views" ); | 2186 | config->setGroup( "Views" ); |
2187 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2187 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2188 | 2188 | ||
2189 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2189 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2190 | 2190 | ||
2191 | int resetval = 0; | 2191 | int resetval = 0; |
2192 | int maxVal = 0; | 2192 | int maxVal = 0; |
2193 | if (sizes.count() != 3) { | 2193 | if (sizes.count() != 3) { |
2194 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2194 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2195 | resetval = mDateNavigator->sizeHint().width()+2; | 2195 | resetval = mDateNavigator->sizeHint().width()+2; |
2196 | } else { | 2196 | } else { |
2197 | resetval = mDateNavigator->sizeHint().height()+2; | 2197 | resetval = mDateNavigator->sizeHint().height()+2; |
2198 | } | 2198 | } |
2199 | } | 2199 | } |
2200 | if ( resetval ) { | 2200 | if ( resetval ) { |
2201 | sizes.clear(); | 2201 | sizes.clear(); |
2202 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2202 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2203 | maxVal = QApplication::desktop()->width() -10; | 2203 | maxVal = QApplication::desktop()->width() -10; |
2204 | } else { | 2204 | } else { |
2205 | maxVal = QApplication::desktop()->height()-10; | 2205 | maxVal = QApplication::desktop()->height()-10; |
2206 | } | 2206 | } |
2207 | sizes << resetval; | 2207 | sizes << resetval; |
2208 | if ( maxVal < resetval + resetval) | 2208 | if ( maxVal < resetval + resetval) |
2209 | resetval = maxVal - resetval; | 2209 | resetval = maxVal - resetval; |
2210 | sizes << resetval; | 2210 | sizes << resetval; |
2211 | sizes << 100; | 2211 | sizes << 100; |
2212 | } | 2212 | } |
2213 | mLeftFrame->setSizes(sizes); | 2213 | mLeftFrame->setSizes(sizes); |
2214 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2214 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2215 | resetval = 0; | 2215 | resetval = 0; |
2216 | maxVal = 0; | 2216 | maxVal = 0; |
2217 | if (sizes.count() != 2) { | 2217 | if (sizes.count() != 2) { |
2218 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2218 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2219 | resetval = mDateNavigator->sizeHint().width()+2; | 2219 | resetval = mDateNavigator->sizeHint().width()+2; |
2220 | } else { | 2220 | } else { |
2221 | resetval = mDateNavigator->sizeHint().height()+2; | 2221 | resetval = mDateNavigator->sizeHint().height()+2; |
2222 | } | 2222 | } |
2223 | } | 2223 | } |
2224 | if ( resetval ) { | 2224 | if ( resetval ) { |
2225 | sizes.clear(); | 2225 | sizes.clear(); |
2226 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2226 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2227 | maxVal = QApplication::desktop()->width() -10; | 2227 | maxVal = QApplication::desktop()->width() -10; |
2228 | } else { | 2228 | } else { |
2229 | maxVal = QApplication::desktop()->height()-10; | 2229 | maxVal = QApplication::desktop()->height()-10; |
2230 | } | 2230 | } |
2231 | sizes << resetval; | 2231 | sizes << resetval; |
2232 | if ( maxVal < resetval + resetval) | 2232 | if ( maxVal < resetval + resetval) |
2233 | resetval = maxVal - resetval; | 2233 | resetval = maxVal - resetval; |
2234 | sizes << resetval; | 2234 | sizes << resetval; |
2235 | } | 2235 | } |
2236 | mMainFrame->setSizes(sizes); | 2236 | mMainFrame->setSizes(sizes); |
2237 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2237 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2238 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2238 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2239 | else mNavigator->selectDates( dateCount ); | 2239 | else mNavigator->selectDates( dateCount ); |
2240 | // mViewManager->readSettings( config ); | 2240 | // mViewManager->readSettings( config ); |
2241 | updateConfig(); | 2241 | updateConfig(); |
2242 | globalFlagBlockAgenda = 2; | 2242 | globalFlagBlockAgenda = 2; |
2243 | mViewManager->readSettings( config ); | 2243 | mViewManager->readSettings( config ); |
2244 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2244 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2245 | } | 2245 | } |
2246 | 2246 | ||
2247 | 2247 | ||
2248 | void CalendarView::writeSettings() | 2248 | void CalendarView::writeSettings() |
2249 | { | 2249 | { |
2250 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2250 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2251 | 2251 | ||
2252 | KConfig *config = KOGlobals::config(); | 2252 | KConfig *config = KOGlobals::config(); |
2253 | 2253 | ||
2254 | mViewManager->writeSettings( config ); | 2254 | mViewManager->writeSettings( config ); |
2255 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2255 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2256 | mDialogManager->writeSettings( config ); | 2256 | mDialogManager->writeSettings( config ); |
2257 | //KOPrefs::instance()->usrWriteConfig(); | 2257 | //KOPrefs::instance()->usrWriteConfig(); |
2258 | KOPrefs::instance()->writeConfig(); | 2258 | KOPrefs::instance()->writeConfig(); |
2259 | 2259 | ||
2260 | writeFilterSettings(config); | 2260 | writeFilterSettings(config); |
2261 | config->setGroup( "AppRun" ); | 2261 | config->setGroup( "AppRun" ); |
2262 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2262 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2263 | int days = dt.daysTo( QDate::currentDate() ); | 2263 | int days = dt.daysTo( QDate::currentDate() ); |
2264 | dt = dt.addDays( days ); | 2264 | dt = dt.addDays( days ); |
2265 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2265 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2266 | config->writeEntry( "LatestProgramStopDays", days ); | 2266 | config->writeEntry( "LatestProgramStopDays", days ); |
2267 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2267 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2268 | //qDebug("KO: Writing stop time: %d ", secs); | 2268 | //qDebug("KO: Writing stop time: %d ", secs); |
2269 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2269 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2270 | //QDateTime latest = dt.addSecs ( secs ); | 2270 | //QDateTime latest = dt.addSecs ( secs ); |
2271 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2271 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2272 | config->setGroup( "Views" ); | 2272 | config->setGroup( "Views" ); |
2273 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2273 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2274 | 2274 | ||
2275 | #if 0 | 2275 | #if 0 |
2276 | qDebug("********************* "); | 2276 | qDebug("********************* "); |
2277 | qDebug("Testcode secsto "); | 2277 | qDebug("Testcode secsto "); |
2278 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2278 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2279 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2279 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2280 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2280 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2281 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2281 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2282 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2282 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2283 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2283 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2284 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2284 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2285 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2285 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2286 | qDebug("********************* testcode end"); | 2286 | qDebug("********************* testcode end"); |
2287 | 2287 | ||
2288 | #endif | 2288 | #endif |
2289 | 2289 | ||
2290 | QValueList<int> listINT = mLeftFrame->sizes(); | 2290 | QValueList<int> listINT = mLeftFrame->sizes(); |
2291 | config->writeEntry("Left Splitter Frame",listINT); | 2291 | config->writeEntry("Left Splitter Frame",listINT); |
2292 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2292 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2293 | config->writeEntry("Main Splitter Frame",listINT2); | 2293 | config->writeEntry("Main Splitter Frame",listINT2); |
2294 | #ifdef DESKTOP_VERSION | 2294 | #ifdef DESKTOP_VERSION |
2295 | config->setGroup("WidgetLayout"); | 2295 | config->setGroup("WidgetLayout"); |
2296 | QStringList list ;//= config->readListEntry("MainLayout"); | 2296 | QStringList list ;//= config->readListEntry("MainLayout"); |
2297 | int x,y,w,h; | 2297 | int x,y,w,h; |
2298 | QWidget* wid; | 2298 | QWidget* wid; |
2299 | wid = topLevelWidget(); | 2299 | wid = topLevelWidget(); |
2300 | x = wid->geometry().x(); | 2300 | x = wid->geometry().x(); |
2301 | y = wid->geometry().y(); | 2301 | y = wid->geometry().y(); |
2302 | w = wid->width(); | 2302 | w = wid->width(); |
2303 | h = wid->height(); | 2303 | h = wid->height(); |
2304 | list.clear(); | 2304 | list.clear(); |
2305 | list << QString::number( x ); | 2305 | list << QString::number( x ); |
2306 | list << QString::number( y ); | 2306 | list << QString::number( y ); |
2307 | list << QString::number( w ); | 2307 | list << QString::number( w ); |
2308 | list << QString::number( h ); | 2308 | list << QString::number( h ); |
2309 | config->writeEntry("MainLayout",list ); | 2309 | config->writeEntry("MainLayout",list ); |
2310 | 2310 | ||
2311 | wid = mEventEditor; | 2311 | wid = mEventEditor; |
2312 | x = wid->geometry().x(); | 2312 | x = wid->geometry().x(); |
2313 | y = wid->geometry().y(); | 2313 | y = wid->geometry().y(); |
2314 | w = wid->width(); | 2314 | w = wid->width(); |
2315 | h = wid->height(); | 2315 | h = wid->height(); |
2316 | list.clear(); | 2316 | list.clear(); |
2317 | list << QString::number( x ); | 2317 | list << QString::number( x ); |
2318 | list << QString::number( y ); | 2318 | list << QString::number( y ); |
2319 | list << QString::number( w ); | 2319 | list << QString::number( w ); |
2320 | list << QString::number( h ); | 2320 | list << QString::number( h ); |
2321 | config->writeEntry("EditEventLayout",list ); | 2321 | config->writeEntry("EditEventLayout",list ); |
2322 | 2322 | ||
2323 | wid = mTodoEditor; | 2323 | wid = mTodoEditor; |
2324 | x = wid->geometry().x(); | 2324 | x = wid->geometry().x(); |
2325 | y = wid->geometry().y(); | 2325 | y = wid->geometry().y(); |
2326 | w = wid->width(); | 2326 | w = wid->width(); |
2327 | h = wid->height(); | 2327 | h = wid->height(); |
2328 | list.clear(); | 2328 | list.clear(); |
2329 | list << QString::number( x ); | 2329 | list << QString::number( x ); |
2330 | list << QString::number( y ); | 2330 | list << QString::number( y ); |
2331 | list << QString::number( w ); | 2331 | list << QString::number( w ); |
2332 | list << QString::number( h ); | 2332 | list << QString::number( h ); |
2333 | config->writeEntry("EditTodoLayout",list ); | 2333 | config->writeEntry("EditTodoLayout",list ); |
2334 | wid = getEventViewerDialog(); | 2334 | wid = getEventViewerDialog(); |
2335 | x = wid->geometry().x(); | 2335 | x = wid->geometry().x(); |
2336 | y = wid->geometry().y(); | 2336 | y = wid->geometry().y(); |
2337 | w = wid->width(); | 2337 | w = wid->width(); |
2338 | h = wid->height(); | 2338 | h = wid->height(); |
2339 | list.clear(); | 2339 | list.clear(); |
2340 | list << QString::number( x ); | 2340 | list << QString::number( x ); |
2341 | list << QString::number( y ); | 2341 | list << QString::number( y ); |
2342 | list << QString::number( w ); | 2342 | list << QString::number( w ); |
2343 | list << QString::number( h ); | 2343 | list << QString::number( h ); |
2344 | config->writeEntry("ViewerLayout",list ); | 2344 | config->writeEntry("ViewerLayout",list ); |
2345 | wid = mDialogManager->getSearchDialog(); | 2345 | wid = mDialogManager->getSearchDialog(); |
2346 | if ( wid ) { | 2346 | if ( wid ) { |
2347 | x = wid->geometry().x(); | 2347 | x = wid->geometry().x(); |
2348 | y = wid->geometry().y(); | 2348 | y = wid->geometry().y(); |
2349 | w = wid->width(); | 2349 | w = wid->width(); |
2350 | h = wid->height(); | 2350 | h = wid->height(); |
2351 | list.clear(); | 2351 | list.clear(); |
2352 | list << QString::number( x ); | 2352 | list << QString::number( x ); |
2353 | list << QString::number( y ); | 2353 | list << QString::number( y ); |
2354 | list << QString::number( w ); | 2354 | list << QString::number( w ); |
2355 | list << QString::number( h ); | 2355 | list << QString::number( h ); |
2356 | config->writeEntry("SearchLayout",list ); | 2356 | config->writeEntry("SearchLayout",list ); |
2357 | } | 2357 | } |
2358 | #endif | 2358 | #endif |
2359 | 2359 | ||
2360 | 2360 | ||
2361 | config->sync(); | 2361 | config->sync(); |
2362 | } | 2362 | } |
2363 | 2363 | ||
2364 | void CalendarView::readFilterSettings(KConfig *config) | 2364 | void CalendarView::readFilterSettings(KConfig *config) |
2365 | { | 2365 | { |
2366 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2366 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2367 | 2367 | ||
2368 | mFilters.clear(); | 2368 | mFilters.clear(); |
2369 | 2369 | ||
2370 | config->setGroup("General"); | 2370 | config->setGroup("General"); |
2371 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2371 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2372 | 2372 | ||
2373 | QStringList::ConstIterator it = filterList.begin(); | 2373 | QStringList::ConstIterator it = filterList.begin(); |
2374 | QStringList::ConstIterator end = filterList.end(); | 2374 | QStringList::ConstIterator end = filterList.end(); |
2375 | while(it != end) { | 2375 | while(it != end) { |
2376 | // kdDebug() << " filter: " << (*it) << endl; | 2376 | // kdDebug() << " filter: " << (*it) << endl; |
2377 | 2377 | ||
2378 | CalFilter *filter; | 2378 | CalFilter *filter; |
2379 | filter = new CalFilter(*it); | 2379 | filter = new CalFilter(*it); |
2380 | config->setGroup("Filter_" + (*it).utf8()); | 2380 | config->setGroup("Filter_" + (*it).utf8()); |
2381 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2381 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2382 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2382 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2383 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2383 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2384 | mFilters.append(filter); | 2384 | mFilters.append(filter); |
2385 | 2385 | ||
2386 | ++it; | 2386 | ++it; |
2387 | } | 2387 | } |
2388 | 2388 | ||
2389 | if (mFilters.count() == 0) { | 2389 | if (mFilters.count() == 0) { |
2390 | CalFilter *filter = new CalFilter(i18n("Default")); | 2390 | CalFilter *filter = new CalFilter(i18n("Default")); |
2391 | mFilters.append(filter); | 2391 | mFilters.append(filter); |
2392 | } | 2392 | } |
2393 | mFilterView->updateFilters(); | 2393 | mFilterView->updateFilters(); |
2394 | config->setGroup("FilterView"); | 2394 | config->setGroup("FilterView"); |
2395 | 2395 | ||
2396 | mFilterView->blockSignals(true); | 2396 | mFilterView->blockSignals(true); |
2397 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2397 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2398 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2398 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2399 | mFilterView->blockSignals(false); | 2399 | mFilterView->blockSignals(false); |
2400 | // We do it manually to avoid it being done twice by the above calls | 2400 | // We do it manually to avoid it being done twice by the above calls |
2401 | updateFilter(); | 2401 | updateFilter(); |
2402 | } | 2402 | } |
2403 | 2403 | ||
2404 | void CalendarView::writeFilterSettings(KConfig *config) | 2404 | void CalendarView::writeFilterSettings(KConfig *config) |
2405 | { | 2405 | { |
2406 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2406 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2407 | 2407 | ||
2408 | QStringList filterList; | 2408 | QStringList filterList; |
2409 | 2409 | ||
2410 | CalFilter *filter = mFilters.first(); | 2410 | CalFilter *filter = mFilters.first(); |
2411 | while(filter) { | 2411 | while(filter) { |
2412 | // kdDebug() << " fn: " << filter->name() << endl; | 2412 | // kdDebug() << " fn: " << filter->name() << endl; |
2413 | filterList << filter->name(); | 2413 | filterList << filter->name(); |
2414 | config->setGroup("Filter_" + filter->name().utf8()); | 2414 | config->setGroup("Filter_" + filter->name().utf8()); |
2415 | config->writeEntry("Criteria",filter->criteria()); | 2415 | config->writeEntry("Criteria",filter->criteria()); |
2416 | config->writeEntry("CategoryList",filter->categoryList()); | 2416 | config->writeEntry("CategoryList",filter->categoryList()); |
2417 | filter = mFilters.next(); | 2417 | filter = mFilters.next(); |
2418 | } | 2418 | } |
2419 | config->setGroup("General"); | 2419 | config->setGroup("General"); |
2420 | config->writeEntry("CalendarFilters",filterList); | 2420 | config->writeEntry("CalendarFilters",filterList); |
2421 | 2421 | ||
2422 | config->setGroup("FilterView"); | 2422 | config->setGroup("FilterView"); |
2423 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2423 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2424 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2424 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2425 | } | 2425 | } |
2426 | 2426 | ||
2427 | 2427 | ||
2428 | void CalendarView::goToday() | 2428 | void CalendarView::goToday() |
2429 | { | 2429 | { |
2430 | if ( mViewManager->currentView()->isMonthView() ) | 2430 | if ( mViewManager->currentView()->isMonthView() ) |
2431 | mNavigator->selectTodayMonth(); | 2431 | mNavigator->selectTodayMonth(); |
2432 | else | 2432 | else |
2433 | mNavigator->selectToday(); | 2433 | mNavigator->selectToday(); |
2434 | } | 2434 | } |
2435 | 2435 | ||
2436 | void CalendarView::goNext() | 2436 | void CalendarView::goNext() |
2437 | { | 2437 | { |
2438 | mNavigator->selectNext(); | 2438 | mNavigator->selectNext(); |
2439 | } | 2439 | } |
2440 | 2440 | ||
2441 | void CalendarView::goPrevious() | 2441 | void CalendarView::goPrevious() |
2442 | { | 2442 | { |
2443 | mNavigator->selectPrevious(); | 2443 | mNavigator->selectPrevious(); |
2444 | } | 2444 | } |
2445 | void CalendarView::goNextMonth() | 2445 | void CalendarView::goNextMonth() |
2446 | { | 2446 | { |
2447 | mNavigator->selectNextMonth(); | 2447 | mNavigator->selectNextMonth(); |
2448 | } | 2448 | } |
2449 | 2449 | ||
2450 | void CalendarView::goPreviousMonth() | 2450 | void CalendarView::goPreviousMonth() |
2451 | { | 2451 | { |
2452 | mNavigator->selectPreviousMonth(); | 2452 | mNavigator->selectPreviousMonth(); |
2453 | } | 2453 | } |
2454 | void CalendarView::writeLocale() | 2454 | void CalendarView::writeLocale() |
2455 | { | 2455 | { |
2456 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2456 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2457 | #if 0 | 2457 | #if 0 |
2458 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2458 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2459 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2459 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2460 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2460 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2461 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2461 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2462 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2462 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2463 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2463 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2464 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2464 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2465 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2465 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2466 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2466 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2467 | KOPrefs::instance()->mDaylightsavingStart, | 2467 | KOPrefs::instance()->mDaylightsavingStart, |
2468 | KOPrefs::instance()->mDaylightsavingEnd ); | 2468 | KOPrefs::instance()->mDaylightsavingEnd ); |
2469 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2469 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2470 | #endif | 2470 | #endif |
2471 | } | 2471 | } |
2472 | void CalendarView::updateConfig() | 2472 | void CalendarView::updateConfig() |
2473 | { | 2473 | { |
2474 | writeLocale(); | 2474 | writeLocale(); |
2475 | if ( KOPrefs::instance()->mUseAppColors ) | 2475 | if ( KOPrefs::instance()->mUseAppColors ) |
2476 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2476 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2477 | emit configChanged(); | 2477 | emit configChanged(); |
2478 | mTodoList->updateConfig(); | 2478 | mTodoList->updateConfig(); |
2479 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2479 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2480 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2480 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2481 | // To make the "fill window" configurations work | 2481 | // To make the "fill window" configurations work |
2482 | //mViewManager->raiseCurrentView(); | 2482 | //mViewManager->raiseCurrentView(); |
2483 | } | 2483 | } |
2484 | 2484 | ||
2485 | 2485 | ||
2486 | void CalendarView::eventChanged(Event *event) | 2486 | void CalendarView::eventChanged(Event *event) |
2487 | { | 2487 | { |
2488 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2488 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2489 | //updateUnmanagedViews(); | 2489 | //updateUnmanagedViews(); |
2490 | } | 2490 | } |
2491 | 2491 | ||
2492 | void CalendarView::eventAdded(Event *event) | 2492 | void CalendarView::eventAdded(Event *event) |
2493 | { | 2493 | { |
2494 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2494 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2495 | } | 2495 | } |
2496 | 2496 | ||
2497 | void CalendarView::eventToBeDeleted(Event *) | 2497 | void CalendarView::eventToBeDeleted(Event *) |
2498 | { | 2498 | { |
2499 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2499 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2500 | } | 2500 | } |
2501 | 2501 | ||
2502 | void CalendarView::eventDeleted() | 2502 | void CalendarView::eventDeleted() |
2503 | { | 2503 | { |
2504 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2504 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2505 | } | 2505 | } |
2506 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2506 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2507 | { | 2507 | { |
2508 | changeIncidenceDisplay((Incidence *)which, action); | 2508 | changeIncidenceDisplay((Incidence *)which, action); |
2509 | mDateNavigator->updateView(); //LR | 2509 | mDateNavigator->updateView(); //LR |
2510 | //mDialogManager->updateSearchDialog(); | 2510 | //mDialogManager->updateSearchDialog(); |
2511 | 2511 | ||
2512 | if (which) { | 2512 | if (which) { |
2513 | mViewManager->updateWNview(); | 2513 | mViewManager->updateWNview(); |
2514 | //mTodoList->updateView(); | 2514 | //mTodoList->updateView(); |
2515 | } | 2515 | } |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | 2518 | ||
2519 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2519 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2520 | { | 2520 | { |
2521 | updateUnmanagedViews(); | 2521 | updateUnmanagedViews(); |
2522 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2522 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2523 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2523 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2524 | mCalendar->checkAlarmForIncidence( 0, true ); | 2524 | mCalendar->checkAlarmForIncidence( 0, true ); |
2525 | if ( mEventViewerDialog ) | 2525 | if ( mEventViewerDialog ) |
2526 | mEventViewerDialog->hide(); | 2526 | mEventViewerDialog->hide(); |
2527 | } | 2527 | } |
2528 | else | 2528 | else |
2529 | mCalendar->checkAlarmForIncidence( which , false ); | 2529 | mCalendar->checkAlarmForIncidence( which , false ); |
2530 | } | 2530 | } |
2531 | 2531 | ||
2532 | // most of the changeEventDisplays() right now just call the view's | 2532 | // most of the changeEventDisplays() right now just call the view's |
2533 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2533 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2534 | void CalendarView::changeEventDisplay(Event *which, int action) | 2534 | void CalendarView::changeEventDisplay(Event *which, int action) |
2535 | { | 2535 | { |
2536 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2536 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2537 | changeIncidenceDisplay((Incidence *)which, action); | 2537 | changeIncidenceDisplay((Incidence *)which, action); |
2538 | mDateNavigator->updateView(); | 2538 | mDateNavigator->updateView(); |
2539 | //mDialogManager->updateSearchDialog(); | 2539 | //mDialogManager->updateSearchDialog(); |
2540 | 2540 | ||
2541 | if (which) { | 2541 | if (which) { |
2542 | // If there is an event view visible update the display | 2542 | // If there is an event view visible update the display |
2543 | mViewManager->currentView()->changeEventDisplay(which,action); | 2543 | mViewManager->currentView()->changeEventDisplay(which,action); |
2544 | // TODO: check, if update needed | 2544 | // TODO: check, if update needed |
2545 | // if (which->getTodoStatus()) { | 2545 | // if (which->getTodoStatus()) { |
2546 | mTodoList->updateView(); | 2546 | mTodoList->updateView(); |
2547 | // } | 2547 | // } |
2548 | } else { | 2548 | } else { |
2549 | mViewManager->currentView()->updateView(); | 2549 | mViewManager->currentView()->updateView(); |
2550 | } | 2550 | } |
2551 | } | 2551 | } |
2552 | 2552 | ||
2553 | 2553 | ||
2554 | void CalendarView::updateTodoViews() | 2554 | void CalendarView::updateTodoViews() |
2555 | { | 2555 | { |
2556 | mTodoList->updateView(); | 2556 | mTodoList->updateView(); |
2557 | mViewManager->currentView()->updateView(); | 2557 | mViewManager->currentView()->updateView(); |
2558 | 2558 | ||
2559 | } | 2559 | } |
2560 | 2560 | ||
2561 | 2561 | ||
2562 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2562 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2563 | { | 2563 | { |
2564 | mTodoList->updateView(); | 2564 | mTodoList->updateView(); |
2565 | mViewManager->updateView(start, end); | 2565 | mViewManager->updateView(start, end); |
2566 | //mDateNavigator->updateView(); | 2566 | //mDateNavigator->updateView(); |
2567 | } | 2567 | } |
2568 | 2568 | ||
2569 | void CalendarView::clearAllViews() | 2569 | void CalendarView::clearAllViews() |
2570 | { | 2570 | { |
2571 | mTodoList->clearList(); | 2571 | mTodoList->clearList(); |
2572 | mViewManager->clearAllViews(); | 2572 | mViewManager->clearAllViews(); |
2573 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2573 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2574 | if ( sd ) { | 2574 | if ( sd ) { |
2575 | KOListView* kol = sd->listview(); | 2575 | KOListView* kol = sd->listview(); |
2576 | if ( kol ) | 2576 | if ( kol ) |
2577 | kol->clearList(); | 2577 | kol->clearList(); |
2578 | } | 2578 | } |
2579 | } | 2579 | } |
2580 | void CalendarView::updateView() | 2580 | void CalendarView::updateView() |
2581 | { | 2581 | { |
2582 | DateList tmpList = mNavigator->selectedDates(); | 2582 | DateList tmpList = mNavigator->selectedDates(); |
2583 | 2583 | ||
2584 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2584 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2585 | mTodoList->updateView(); | 2585 | mTodoList->updateView(); |
2586 | // We assume that the navigator only selects consecutive days. | 2586 | // We assume that the navigator only selects consecutive days. |
2587 | updateView( tmpList.first(), tmpList.last() ); | 2587 | updateView( tmpList.first(), tmpList.last() ); |
2588 | } | 2588 | } |
2589 | 2589 | ||
2590 | void CalendarView::updateUnmanagedViews() | 2590 | void CalendarView::updateUnmanagedViews() |
2591 | { | 2591 | { |
2592 | mDateNavigator->updateDayMatrix(); | 2592 | mDateNavigator->updateDayMatrix(); |
2593 | } | 2593 | } |
2594 | 2594 | ||
2595 | int CalendarView::msgItemDelete(const QString name) | 2595 | int CalendarView::msgItemDelete(const QString name) |
2596 | { | 2596 | { |
2597 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2597 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2598 | i18n("This item will be\npermanently deleted."), | 2598 | i18n("This item will be\npermanently deleted."), |
2599 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2599 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2600 | } | 2600 | } |
2601 | 2601 | ||
2602 | 2602 | ||
2603 | void CalendarView::edit_cut() | 2603 | void CalendarView::edit_cut() |
2604 | { | 2604 | { |
2605 | Event *anEvent=0; | 2605 | Event *anEvent=0; |
2606 | 2606 | ||
2607 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2607 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2608 | 2608 | ||
2609 | if (mViewManager->currentView()->isEventView()) { | 2609 | if (mViewManager->currentView()->isEventView()) { |
2610 | if ( incidence && incidence->typeID() == eventID ) { | 2610 | if ( incidence && incidence->typeID() == eventID ) { |
2611 | anEvent = static_cast<Event *>(incidence); | 2611 | anEvent = static_cast<Event *>(incidence); |
2612 | } | 2612 | } |
2613 | } | 2613 | } |
2614 | 2614 | ||
2615 | if (!anEvent) { | 2615 | if (!anEvent) { |
2616 | KNotifyClient::beep(); | 2616 | KNotifyClient::beep(); |
2617 | return; | 2617 | return; |
2618 | } | 2618 | } |
2619 | DndFactory factory( mCalendar ); | 2619 | DndFactory factory( mCalendar ); |
2620 | factory.cutIncidence(anEvent); | 2620 | factory.cutIncidence(anEvent); |
2621 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2621 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2622 | } | 2622 | } |
2623 | 2623 | ||
2624 | void CalendarView::edit_copy() | 2624 | void CalendarView::edit_copy() |
2625 | { | 2625 | { |
2626 | Event *anEvent=0; | 2626 | Event *anEvent=0; |
2627 | 2627 | ||
2628 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2628 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2629 | 2629 | ||
2630 | if (mViewManager->currentView()->isEventView()) { | 2630 | if (mViewManager->currentView()->isEventView()) { |
2631 | if ( incidence && incidence->typeID() == eventID ) { | 2631 | if ( incidence && incidence->typeID() == eventID ) { |
2632 | anEvent = static_cast<Event *>(incidence); | 2632 | anEvent = static_cast<Event *>(incidence); |
2633 | } | 2633 | } |
2634 | } | 2634 | } |
2635 | 2635 | ||
2636 | if (!anEvent) { | 2636 | if (!anEvent) { |
2637 | KNotifyClient::beep(); | 2637 | KNotifyClient::beep(); |
2638 | return; | 2638 | return; |
2639 | } | 2639 | } |
2640 | DndFactory factory( mCalendar ); | 2640 | DndFactory factory( mCalendar ); |
2641 | factory.copyIncidence(anEvent); | 2641 | factory.copyIncidence(anEvent); |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | void CalendarView::edit_paste() | 2644 | void CalendarView::edit_paste() |
2645 | { | 2645 | { |
2646 | QDate date = mNavigator->selectedDates().first(); | 2646 | QDate date = mNavigator->selectedDates().first(); |
2647 | 2647 | ||
2648 | DndFactory factory( mCalendar ); | 2648 | DndFactory factory( mCalendar ); |
2649 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2649 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2650 | 2650 | ||
2651 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2651 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2652 | } | 2652 | } |
2653 | void CalendarView::edit_global_options() | 2653 | void CalendarView::edit_global_options() |
2654 | { | 2654 | { |
2655 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2655 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2656 | emit save(); | 2656 | emit save(); |
2657 | emit saveStopTimer(); | 2657 | emit saveStopTimer(); |
2658 | mDialogManager->showGlobalOptionsDialog(); | 2658 | mDialogManager->showGlobalOptionsDialog(); |
2659 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2659 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2660 | emit saveStopTimer(); | 2660 | emit saveStopTimer(); |
2661 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2661 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2662 | i18n("Timezone settings"),i18n("Reload"))) { | 2662 | i18n("Timezone settings"),i18n("Reload"))) { |
2663 | qDebug("KO: TZ reload cancelled "); | 2663 | qDebug("KO: TZ reload cancelled "); |
2664 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2664 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2665 | return; | 2665 | return; |
2666 | } | 2666 | } |
2667 | qDebug("KO: Timezone change "); | 2667 | qDebug("KO: Timezone change "); |
2668 | openCalendar( MainWindow::defaultFileName() ); | 2668 | openCalendar( MainWindow::defaultFileName() ); |
2669 | setModified(true); | 2669 | setModified(true); |
2670 | } | 2670 | } |
2671 | else | 2671 | else |
2672 | qDebug("KO: No tz change "); | 2672 | qDebug("KO: No tz change "); |
2673 | } | 2673 | } |
2674 | void CalendarView::edit_options() | 2674 | void CalendarView::edit_options() |
2675 | { | 2675 | { |
2676 | mDialogManager->showOptionsDialog(); | 2676 | mDialogManager->showOptionsDialog(); |
2677 | } | 2677 | } |
2678 | 2678 | ||
2679 | 2679 | ||
2680 | void CalendarView::slotSelectPickerDate( QDate d) | 2680 | void CalendarView::slotSelectPickerDate( QDate d) |
2681 | { | 2681 | { |
2682 | mDateFrame->hide(); | 2682 | mDateFrame->hide(); |
2683 | if ( mDatePickerMode == 1 ) { | 2683 | if ( mDatePickerMode == 1 ) { |
2684 | mNavigator->slotDaySelect( d ); | 2684 | mNavigator->slotDaySelect( d ); |
2685 | } else if ( mDatePickerMode == 2 ) { | 2685 | } else if ( mDatePickerMode == 2 ) { |
2686 | if ( mMoveIncidence->typeID() == todoID ) { | 2686 | if ( mMoveIncidence->typeID() == todoID ) { |
2687 | Todo * to = (Todo *) mMoveIncidence; | 2687 | Todo * to = (Todo *) mMoveIncidence; |
2688 | QTime tim; | 2688 | QTime tim; |
2689 | int len = 0; | 2689 | int len = 0; |
2690 | if ( to->hasStartDate() && to->hasDueDate() ) | 2690 | if ( to->hasStartDate() && to->hasDueDate() ) |
2691 | len = to->dtStart().secsTo( to->dtDue()); | 2691 | len = to->dtStart().secsTo( to->dtDue()); |
2692 | if ( to->hasDueDate() ) | 2692 | if ( to->hasDueDate() ) |
2693 | tim = to->dtDue().time(); | 2693 | tim = to->dtDue().time(); |
2694 | else { | 2694 | else { |
2695 | tim = QTime ( 0,0,0 ); | 2695 | tim = QTime ( 0,0,0 ); |
2696 | to->setFloats( true ); | 2696 | to->setFloats( true ); |
2697 | to->setHasDueDate( true ); | 2697 | to->setHasDueDate( true ); |
2698 | } | 2698 | } |
2699 | QDateTime dt ( d,tim ); | 2699 | QDateTime dt ( d,tim ); |
2700 | to->setDtDue( dt ); | 2700 | to->setDtDue( dt ); |
2701 | 2701 | ||
2702 | if ( to->hasStartDate() ) { | 2702 | if ( to->hasStartDate() ) { |
2703 | if ( len>0 ) | 2703 | if ( len>0 ) |
2704 | to->setDtStart(to->dtDue().addSecs( -len )); | 2704 | to->setDtStart(to->dtDue().addSecs( -len )); |
2705 | else | 2705 | else |
2706 | if (to->dtStart() > to->dtDue() ) | 2706 | if (to->dtStart() > to->dtDue() ) |
2707 | to->setDtStart(to->dtDue().addDays( -3 )); | 2707 | to->setDtStart(to->dtDue().addDays( -3 )); |
2708 | } | 2708 | } |
2709 | 2709 | ||
2710 | todoChanged( to ); | 2710 | todoChanged( to ); |
2711 | } else { | 2711 | } else { |
2712 | if ( mMoveIncidence->doesRecur() ) { | 2712 | if ( mMoveIncidence->doesRecur() ) { |
2713 | #if 0 | 2713 | #if 0 |
2714 | // PENDING implement this | 2714 | // PENDING implement this |
2715 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2715 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2716 | mCalendar()->addIncidence( newInc ); | 2716 | mCalendar()->addIncidence( newInc ); |
2717 | if ( mMoveIncidence->typeID() == todoID ) | 2717 | if ( mMoveIncidence->typeID() == todoID ) |
2718 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2718 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2719 | else | 2719 | else |
2720 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2720 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2721 | mMoveIncidence = newInc; | 2721 | mMoveIncidence = newInc; |
2722 | 2722 | ||
2723 | #endif | 2723 | #endif |
2724 | } | 2724 | } |
2725 | QTime tim = mMoveIncidence->dtStart().time(); | 2725 | QTime tim = mMoveIncidence->dtStart().time(); |
2726 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2726 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2727 | QDateTime dt ( d,tim ); | 2727 | QDateTime dt ( d,tim ); |
2728 | mMoveIncidence->setDtStart( dt ); | 2728 | mMoveIncidence->setDtStart( dt ); |
2729 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2729 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2730 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2730 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2731 | } | 2731 | } |
2732 | 2732 | ||
2733 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2733 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2734 | } | 2734 | } |
2735 | } | 2735 | } |
2736 | 2736 | ||
2737 | void CalendarView::removeCategories() | 2737 | void CalendarView::removeCategories() |
2738 | { | 2738 | { |
2739 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2739 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2740 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2740 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2741 | QStringList catIncList; | 2741 | QStringList catIncList; |
2742 | QStringList newCatList; | 2742 | QStringList newCatList; |
2743 | Incidence* inc = incList.first(); | 2743 | Incidence* inc = incList.first(); |
2744 | int i; | 2744 | int i; |
2745 | int count = 0; | 2745 | int count = 0; |
2746 | while ( inc ) { | 2746 | while ( inc ) { |
2747 | newCatList.clear(); | 2747 | newCatList.clear(); |
2748 | catIncList = inc->categories() ; | 2748 | catIncList = inc->categories() ; |
2749 | for( i = 0; i< catIncList.count(); ++i ) { | 2749 | for( i = 0; i< catIncList.count(); ++i ) { |
2750 | if ( catList.contains (catIncList[i])) | 2750 | if ( catList.contains (catIncList[i])) |
2751 | newCatList.append( catIncList[i] ); | 2751 | newCatList.append( catIncList[i] ); |
2752 | } | 2752 | } |
2753 | newCatList.sort(); | 2753 | newCatList.sort(); |
2754 | inc->setCategories( newCatList.join(",") ); | 2754 | inc->setCategories( newCatList.join(",") ); |
2755 | inc = incList.next(); | 2755 | inc = incList.next(); |
2756 | } | 2756 | } |
2757 | } | 2757 | } |
2758 | 2758 | ||
2759 | int CalendarView::addCategories() | 2759 | int CalendarView::addCategories() |
2760 | { | 2760 | { |
2761 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2761 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2762 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2762 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2763 | QStringList catIncList; | 2763 | QStringList catIncList; |
2764 | Incidence* inc = incList.first(); | 2764 | Incidence* inc = incList.first(); |
2765 | int i; | 2765 | int i; |
2766 | int count = 0; | 2766 | int count = 0; |
2767 | while ( inc ) { | 2767 | while ( inc ) { |
2768 | catIncList = inc->categories() ; | 2768 | catIncList = inc->categories() ; |
2769 | for( i = 0; i< catIncList.count(); ++i ) { | 2769 | for( i = 0; i< catIncList.count(); ++i ) { |
2770 | if ( !catList.contains (catIncList[i])) { | 2770 | if ( !catList.contains (catIncList[i])) { |
2771 | catList.append( catIncList[i] ); | 2771 | catList.append( catIncList[i] ); |
2772 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2772 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2773 | ++count; | 2773 | ++count; |
2774 | } | 2774 | } |
2775 | } | 2775 | } |
2776 | inc = incList.next(); | 2776 | inc = incList.next(); |
2777 | } | 2777 | } |
2778 | catList.sort(); | 2778 | catList.sort(); |
2779 | KOPrefs::instance()->mCustomCategories = catList; | 2779 | KOPrefs::instance()->mCustomCategories = catList; |
2780 | return count; | 2780 | return count; |
2781 | } | 2781 | } |
2782 | 2782 | ||
2783 | void CalendarView::manageCategories() | 2783 | void CalendarView::manageCategories() |
2784 | { | 2784 | { |
2785 | KOCatPrefs* cp = new KOCatPrefs(); | 2785 | KOCatPrefs* cp = new KOCatPrefs(); |
2786 | cp->show(); | 2786 | cp->show(); |
2787 | int w =cp->sizeHint().width() ; | 2787 | int w =cp->sizeHint().width() ; |
2788 | int h = cp->sizeHint().height() ; | 2788 | int h = cp->sizeHint().height() ; |
2789 | int dw = QApplication::desktop()->width(); | 2789 | int dw = QApplication::desktop()->width(); |
2790 | int dh = QApplication::desktop()->height(); | 2790 | int dh = QApplication::desktop()->height(); |
2791 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2791 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2792 | if ( !cp->exec() ) { | 2792 | if ( !cp->exec() ) { |
2793 | delete cp; | 2793 | delete cp; |
2794 | return; | 2794 | return; |
2795 | } | 2795 | } |
2796 | int count = 0; | 2796 | int count = 0; |
2797 | if ( cp->addCat() ) { | 2797 | if ( cp->addCat() ) { |
2798 | count = addCategories(); | 2798 | count = addCategories(); |
2799 | if ( count ) { | 2799 | if ( count ) { |
2800 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2800 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2801 | writeSettings(); | 2801 | writeSettings(); |
2802 | } else | 2802 | } else |
2803 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2803 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2804 | } else { | 2804 | } else { |
2805 | removeCategories(); | 2805 | removeCategories(); |
2806 | updateView(); | 2806 | updateView(); |
2807 | } | 2807 | } |
2808 | delete cp; | 2808 | delete cp; |
2809 | } | 2809 | } |
2810 | 2810 | ||
2811 | void CalendarView::beamIncidence(Incidence * Inc) | 2811 | void CalendarView::beamIncidence(Incidence * Inc) |
2812 | { | 2812 | { |
2813 | QPtrList<Incidence> delSel ; | 2813 | QPtrList<Incidence> delSel ; |
2814 | delSel.append(Inc); | 2814 | delSel.append(Inc); |
2815 | beamIncidenceList( delSel ); | 2815 | beamIncidenceList( delSel ); |
2816 | } | 2816 | } |
2817 | void CalendarView::beamCalendar() | 2817 | void CalendarView::beamCalendar() |
2818 | { | 2818 | { |
2819 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2819 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2820 | //qDebug("beamCalendar() "); | 2820 | //qDebug("beamCalendar() "); |
2821 | beamIncidenceList( delSel ); | 2821 | beamIncidenceList( delSel ); |
2822 | } | 2822 | } |
2823 | void CalendarView::beamFilteredCalendar() | 2823 | void CalendarView::beamFilteredCalendar() |
2824 | { | 2824 | { |
2825 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2825 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2826 | //qDebug("beamFilteredCalendar() "); | 2826 | //qDebug("beamFilteredCalendar() "); |
2827 | beamIncidenceList( delSel ); | 2827 | beamIncidenceList( delSel ); |
2828 | } | 2828 | } |
2829 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2829 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2830 | { | 2830 | { |
2831 | if ( beamDialog->exec () == QDialog::Rejected ) | 2831 | if ( beamDialog->exec () == QDialog::Rejected ) |
2832 | return; | 2832 | return; |
2833 | #ifdef DESKTOP_VERSION | 2833 | #ifdef DESKTOP_VERSION |
2834 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2834 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2835 | #else | 2835 | #else |
2836 | QString fn = "/tmp/kopibeamfile"; | 2836 | QString fn = "/tmp/kopibeamfile"; |
2837 | #endif | 2837 | #endif |
2838 | QString mes; | 2838 | QString mes; |
2839 | bool createbup = true; | 2839 | bool createbup = true; |
2840 | if ( createbup ) { | 2840 | if ( createbup ) { |
2841 | QString description = "\n"; | 2841 | QString description = "\n"; |
2842 | CalendarLocal* cal = new CalendarLocal(); | 2842 | CalendarLocal* cal = new CalendarLocal(); |
2843 | if ( beamDialog->beamLocal() ) | 2843 | if ( beamDialog->beamLocal() ) |
2844 | cal->setLocalTime(); | 2844 | cal->setLocalTime(); |
2845 | else | 2845 | else |
2846 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2846 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2847 | Incidence *incidence = delSel.first(); | 2847 | Incidence *incidence = delSel.first(); |
2848 | bool addText = false; | 2848 | bool addText = false; |
2849 | if ( delSel.count() < 10 ) | 2849 | if ( delSel.count() < 10 ) |
2850 | addText = true; | 2850 | addText = true; |
2851 | else { | 2851 | else { |
2852 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2852 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2853 | } | 2853 | } |
2854 | while ( incidence ) { | 2854 | while ( incidence ) { |
2855 | Incidence *in = incidence->clone(); | 2855 | Incidence *in = incidence->clone(); |
2856 | if ( ! in->summary().isEmpty() ) { | 2856 | if ( ! in->summary().isEmpty() ) { |
2857 | in->setDescription(""); | 2857 | in->setDescription(""); |
2858 | } else { | 2858 | } else { |
2859 | in->setSummary( in->description().left(20)); | 2859 | in->setSummary( in->description().left(20)); |
2860 | in->setDescription(""); | 2860 | in->setDescription(""); |
2861 | } | 2861 | } |
2862 | if ( addText ) | 2862 | if ( addText ) |
2863 | description += in->summary() + "\n"; | 2863 | description += in->summary() + "\n"; |
2864 | cal->addIncidence( in ); | 2864 | cal->addIncidence( in ); |
2865 | incidence = delSel.next(); | 2865 | incidence = delSel.next(); |
2866 | } | 2866 | } |
2867 | if ( beamDialog->beamVcal() ) { | 2867 | if ( beamDialog->beamVcal() ) { |
2868 | fn += ".vcs"; | 2868 | fn += ".vcs"; |
2869 | FileStorage storage( cal, fn, new VCalFormat ); | 2869 | FileStorage storage( cal, fn, new VCalFormat ); |
2870 | storage.save(); | 2870 | storage.save(); |
2871 | } else { | 2871 | } else { |
2872 | fn += ".ics"; | 2872 | fn += ".ics"; |
2873 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2873 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2874 | storage.save(); | 2874 | storage.save(); |
2875 | } | 2875 | } |
2876 | delete cal; | 2876 | delete cal; |
2877 | mes = i18n("KO/Pi: Ready for beaming"); | 2877 | mes = i18n("KO/Pi: Ready for beaming"); |
2878 | topLevelWidget()->setCaption(mes); | 2878 | topLevelWidget()->setCaption(mes); |
2879 | KApplication::convert2latin1( fn ); | 2879 | KApplication::convert2latin1( fn ); |
2880 | #ifndef DESKTOP_VERSION | 2880 | #ifndef DESKTOP_VERSION |
2881 | Ir *ir = new Ir( this ); | 2881 | Ir *ir = new Ir( this ); |
2882 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2882 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2883 | ir->send( fn, description, "text/x-vCalendar" ); | 2883 | ir->send( fn, description, "text/x-vCalendar" ); |
2884 | #endif | 2884 | #endif |
2885 | } | 2885 | } |
2886 | } | 2886 | } |
2887 | void CalendarView::beamDone( Ir *ir ) | 2887 | void CalendarView::beamDone( Ir *ir ) |
2888 | { | 2888 | { |
2889 | #ifndef DESKTOP_VERSION | 2889 | #ifndef DESKTOP_VERSION |
2890 | delete ir; | 2890 | delete ir; |
2891 | #endif | 2891 | #endif |
2892 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2892 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2893 | topLevelWidget()->raise(); | 2893 | topLevelWidget()->raise(); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | void CalendarView::moveIncidence(Incidence * inc ) | 2896 | void CalendarView::moveIncidence(Incidence * inc ) |
2897 | { | 2897 | { |
2898 | if ( !inc ) return; | 2898 | if ( !inc ) return; |
2899 | showDatePickerPopup(); | 2899 | showDatePickerPopup(); |
2900 | mDatePickerMode = 2; | 2900 | mDatePickerMode = 2; |
2901 | mMoveIncidence = inc ; | 2901 | mMoveIncidence = inc ; |
2902 | QDate da; | 2902 | QDate da; |
2903 | if ( mMoveIncidence->typeID() == todoID ) { | 2903 | if ( mMoveIncidence->typeID() == todoID ) { |
2904 | Todo * to = (Todo *) mMoveIncidence; | 2904 | Todo * to = (Todo *) mMoveIncidence; |
2905 | if ( to->hasDueDate() ) | 2905 | if ( to->hasDueDate() ) |
2906 | da = to->dtDue().date(); | 2906 | da = to->dtDue().date(); |
2907 | else | 2907 | else |
2908 | da = QDate::currentDate(); | 2908 | da = QDate::currentDate(); |
2909 | } else { | 2909 | } else { |
2910 | da = mMoveIncidence->dtStart().date(); | 2910 | da = mMoveIncidence->dtStart().date(); |
2911 | } | 2911 | } |
2912 | //PENDING set date for recurring incidence to date of recurrence | 2912 | //PENDING set date for recurring incidence to date of recurrence |
2913 | //mMoveIncidenceOldDate; | 2913 | //mMoveIncidenceOldDate; |
2914 | mDatePicker->setDate( da ); | 2914 | mDatePicker->setDate( da ); |
2915 | } | 2915 | } |
2916 | void CalendarView::showDatePickerPopup() | 2916 | void CalendarView::showDatePickerPopup() |
2917 | { | 2917 | { |
2918 | if ( mDateFrame->isVisible() ) | 2918 | if ( mDateFrame->isVisible() ) |
2919 | mDateFrame->hide(); | 2919 | mDateFrame->hide(); |
2920 | else { | 2920 | else { |
2921 | int offX = 0, offY = 0; | 2921 | int offX = 0, offY = 0; |
2922 | #ifdef DESKTOP_VERSION | 2922 | #ifdef DESKTOP_VERSION |
2923 | int w =mDatePicker->sizeHint().width() ; | 2923 | int w =mDatePicker->sizeHint().width() ; |
2924 | int h = mDatePicker->sizeHint().height() ; | 2924 | int h = mDatePicker->sizeHint().height() ; |
2925 | int dw = topLevelWidget()->width(); | 2925 | int dw = topLevelWidget()->width(); |
2926 | int dh = topLevelWidget()->height(); | 2926 | int dh = topLevelWidget()->height(); |
2927 | offX = topLevelWidget()->x(); | 2927 | offX = topLevelWidget()->x(); |
2928 | offY = topLevelWidget()->y(); | 2928 | offY = topLevelWidget()->y(); |
2929 | #else | 2929 | #else |
2930 | int w =mDatePicker->sizeHint().width() ; | 2930 | int w =mDatePicker->sizeHint().width() ; |
2931 | int h = mDatePicker->sizeHint().height() ; | 2931 | int h = mDatePicker->sizeHint().height() ; |
2932 | int dw = QApplication::desktop()->width(); | 2932 | int dw = QApplication::desktop()->width(); |
2933 | int dh = QApplication::desktop()->height(); | 2933 | int dh = QApplication::desktop()->height(); |
2934 | #endif | 2934 | #endif |
2935 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2935 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2936 | mDateFrame->show(); | 2936 | mDateFrame->show(); |
2937 | } | 2937 | } |
2938 | } | 2938 | } |
2939 | void CalendarView::showDatePicker( ) | 2939 | void CalendarView::showDatePicker( ) |
2940 | { | 2940 | { |
2941 | showDatePickerPopup(); | 2941 | showDatePickerPopup(); |
2942 | mDatePickerMode = 1; | 2942 | mDatePickerMode = 1; |
2943 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2943 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2944 | } | 2944 | } |
2945 | 2945 | ||
2946 | void CalendarView::showEventEditor() | 2946 | void CalendarView::showEventEditor() |
2947 | { | 2947 | { |
2948 | #ifdef DESKTOP_VERSION | 2948 | #ifdef DESKTOP_VERSION |
2949 | int x,y,w,h; | 2949 | int x,y,w,h; |
2950 | x = mEventEditor->geometry().x(); | 2950 | x = mEventEditor->geometry().x(); |
2951 | y = mEventEditor->geometry().y(); | 2951 | y = mEventEditor->geometry().y(); |
2952 | w = mEventEditor->width(); | 2952 | w = mEventEditor->width(); |
2953 | h = mEventEditor->height(); | 2953 | h = mEventEditor->height(); |
2954 | mEventEditor->show(); | 2954 | mEventEditor->show(); |
2955 | mEventEditor->setGeometry(x,y,w,h); | 2955 | mEventEditor->setGeometry(x,y,w,h); |
2956 | #else | 2956 | #else |
2957 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2957 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2958 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2958 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2959 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2959 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2960 | qApp->processEvents(); | 2960 | qApp->processEvents(); |
2961 | delete mEventEditor; | 2961 | delete mEventEditor; |
2962 | mEventEditor = mDialogManager->getEventEditor(); | 2962 | mEventEditor = mDialogManager->getEventEditor(); |
2963 | topLevelWidget()->setCaption( i18n("") ); | 2963 | topLevelWidget()->setCaption( i18n("") ); |
2964 | } | 2964 | } |
2965 | mEventEditor->showMaximized(); | 2965 | mEventEditor->showMaximized(); |
2966 | #endif | 2966 | #endif |
2967 | } | 2967 | } |
2968 | void CalendarView::showTodoEditor() | 2968 | void CalendarView::showTodoEditor() |
2969 | { | 2969 | { |
2970 | #ifdef DESKTOP_VERSION | 2970 | #ifdef DESKTOP_VERSION |
2971 | int x,y,w,h; | 2971 | int x,y,w,h; |
2972 | x = mTodoEditor->geometry().x(); | 2972 | x = mTodoEditor->geometry().x(); |
2973 | y = mTodoEditor->geometry().y(); | 2973 | y = mTodoEditor->geometry().y(); |
2974 | w = mTodoEditor->width(); | 2974 | w = mTodoEditor->width(); |
2975 | h = mTodoEditor->height(); | 2975 | h = mTodoEditor->height(); |
2976 | mTodoEditor->show(); | 2976 | mTodoEditor->show(); |
2977 | mTodoEditor->setGeometry(x,y,w,h); | 2977 | mTodoEditor->setGeometry(x,y,w,h); |
2978 | #else | 2978 | #else |
2979 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2979 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2980 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2980 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2981 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2981 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2982 | qApp->processEvents(); | 2982 | qApp->processEvents(); |
2983 | delete mTodoEditor; | 2983 | delete mTodoEditor; |
2984 | mTodoEditor = mDialogManager->getTodoEditor(); | 2984 | mTodoEditor = mDialogManager->getTodoEditor(); |
2985 | topLevelWidget()->setCaption( i18n("") ); | 2985 | topLevelWidget()->setCaption( i18n("") ); |
2986 | } | 2986 | } |
2987 | mTodoEditor->showMaximized(); | 2987 | mTodoEditor->showMaximized(); |
2988 | #endif | 2988 | #endif |
2989 | } | 2989 | } |
2990 | 2990 | ||
2991 | void CalendarView::cloneIncidence() | 2991 | void CalendarView::cloneIncidence() |
2992 | { | 2992 | { |
2993 | Incidence *incidence = currentSelection(); | 2993 | Incidence *incidence = currentSelection(); |
2994 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2994 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2995 | if ( incidence ) { | 2995 | if ( incidence ) { |
2996 | cloneIncidence(incidence); | 2996 | cloneIncidence(incidence); |
2997 | } | 2997 | } |
2998 | } | 2998 | } |
2999 | void CalendarView::moveIncidence() | 2999 | void CalendarView::moveIncidence() |
3000 | { | 3000 | { |
3001 | Incidence *incidence = currentSelection(); | 3001 | Incidence *incidence = currentSelection(); |
3002 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3002 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3003 | if ( incidence ) { | 3003 | if ( incidence ) { |
3004 | moveIncidence(incidence); | 3004 | moveIncidence(incidence); |
3005 | } | 3005 | } |
3006 | } | 3006 | } |
3007 | void CalendarView::beamIncidence() | 3007 | void CalendarView::beamIncidence() |
3008 | { | 3008 | { |
3009 | Incidence *incidence = currentSelection(); | 3009 | Incidence *incidence = currentSelection(); |
3010 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3010 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3011 | if ( incidence ) { | 3011 | if ( incidence ) { |
3012 | beamIncidence(incidence); | 3012 | beamIncidence(incidence); |
3013 | } | 3013 | } |
3014 | } | 3014 | } |
3015 | void CalendarView::toggleCancelIncidence() | 3015 | void CalendarView::toggleCancelIncidence() |
3016 | { | 3016 | { |
3017 | Incidence *incidence = currentSelection(); | 3017 | Incidence *incidence = currentSelection(); |
3018 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3018 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3019 | if ( incidence ) { | 3019 | if ( incidence ) { |
3020 | cancelIncidence(incidence); | 3020 | cancelIncidence(incidence); |
3021 | } | 3021 | } |
3022 | } | 3022 | } |
3023 | 3023 | ||
3024 | 3024 | ||
3025 | void CalendarView::cancelIncidence(Incidence * inc ) | 3025 | void CalendarView::cancelIncidence(Incidence * inc ) |
3026 | { | 3026 | { |
3027 | inc->setCancelled( ! inc->cancelled() ); | 3027 | inc->setCancelled( ! inc->cancelled() ); |
3028 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3028 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3029 | updateView(); | 3029 | updateView(); |
3030 | } | 3030 | } |
3031 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3031 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3032 | { | 3032 | { |
3033 | Incidence * newInc = orgInc->clone(); | 3033 | Incidence * newInc = orgInc->clone(); |
3034 | newInc->recreate(); | 3034 | newInc->recreate(); |
3035 | 3035 | ||
3036 | if ( newInc->typeID() == todoID ) { | 3036 | if ( newInc->typeID() == todoID ) { |
3037 | Todo* t = (Todo*) newInc; | 3037 | Todo* t = (Todo*) newInc; |
3038 | bool cloneSub = false; | 3038 | bool cloneSub = false; |
3039 | if ( orgInc->relations().count() ) { | 3039 | if ( orgInc->relations().count() ) { |
3040 | int result = KMessageBox::warningYesNoCancel(this, | 3040 | int result = KMessageBox::warningYesNoCancel(this, |
3041 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3041 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
3042 | i18n("Todo has subtodos"), | 3042 | i18n("Todo has subtodos"), |
3043 | i18n("Yes"), | 3043 | i18n("Yes"), |
3044 | i18n("No")); | 3044 | i18n("No")); |
3045 | 3045 | ||
3046 | if ( result == KMessageBox::Cancel ) { | 3046 | if ( result == KMessageBox::Cancel ) { |
3047 | delete t; | 3047 | delete t; |
3048 | return; | 3048 | return; |
3049 | } | 3049 | } |
3050 | if (result == KMessageBox::Yes) cloneSub = true; | 3050 | if (result == KMessageBox::Yes) cloneSub = true; |
3051 | } | 3051 | } |
3052 | showTodoEditor(); | 3052 | showTodoEditor(); |
3053 | mTodoEditor->editTodo( t ); | 3053 | mTodoEditor->editTodo( t ); |
3054 | if ( mTodoEditor->exec() ) { | 3054 | if ( mTodoEditor->exec() ) { |
3055 | if ( cloneSub ) { | 3055 | if ( cloneSub ) { |
3056 | orgInc->cloneRelations( t ); | 3056 | orgInc->cloneRelations( t ); |
3057 | mCalendar->addIncidenceBranch( t ); | 3057 | mCalendar->addIncidenceBranch( t ); |
3058 | updateView(); | 3058 | updateView(); |
3059 | 3059 | ||
3060 | } else { | 3060 | } else { |
3061 | mCalendar->addTodo( t ); | 3061 | mCalendar->addTodo( t ); |
3062 | updateView(); | 3062 | updateView(); |
3063 | } | 3063 | } |
3064 | } else { | 3064 | } else { |
3065 | delete t; | 3065 | delete t; |
3066 | } | 3066 | } |
3067 | } | 3067 | } |
3068 | else { | 3068 | else { |
3069 | Event* e = (Event*) newInc; | 3069 | Event* e = (Event*) newInc; |
3070 | showEventEditor(); | 3070 | showEventEditor(); |
3071 | mEventEditor->editEvent( e ); | 3071 | mEventEditor->editEvent( e ); |
3072 | if ( mEventEditor->exec() ) { | 3072 | if ( mEventEditor->exec() ) { |
3073 | mCalendar->addEvent( e ); | 3073 | mCalendar->addEvent( e ); |
3074 | updateView(); | 3074 | updateView(); |
3075 | } else { | 3075 | } else { |
3076 | delete e; | 3076 | delete e; |
3077 | } | 3077 | } |
3078 | } | 3078 | } |
3079 | setActiveWindow(); | 3079 | setActiveWindow(); |
3080 | } | 3080 | } |
3081 | 3081 | ||
3082 | void CalendarView::newEvent() | 3082 | void CalendarView::newEvent() |
3083 | { | 3083 | { |
3084 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3084 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3085 | KOAgendaView *aView = mViewManager->agendaView(); | 3085 | KOAgendaView *aView = mViewManager->agendaView(); |
3086 | if (aView) { | 3086 | if (aView) { |
3087 | if (aView->selectionStart().isValid()) { | 3087 | if (aView->selectionStart().isValid()) { |
3088 | if (aView->selectedIsAllDay()) { | 3088 | if (aView->selectedIsAllDay()) { |
3089 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3089 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3090 | } else { | 3090 | } else { |
3091 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3091 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3092 | } | 3092 | } |
3093 | return; | 3093 | return; |
3094 | } | 3094 | } |
3095 | } | 3095 | } |
3096 | 3096 | ||
3097 | QDate date = mNavigator->selectedDates().first(); | 3097 | QDate date = mNavigator->selectedDates().first(); |
3098 | QDateTime current = QDateTime::currentDateTime(); | 3098 | QDateTime current = QDateTime::currentDateTime(); |
3099 | if ( date <= current.date() ) { | 3099 | if ( date <= current.date() ) { |
3100 | int hour = current.time().hour() +1; | 3100 | int hour = current.time().hour() +1; |
3101 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3101 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3102 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3102 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3103 | } else | 3103 | } else |
3104 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3104 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3105 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3105 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3106 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3106 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3107 | } | 3107 | } |
3108 | 3108 | ||
3109 | void CalendarView::newEvent(QDateTime fh) | 3109 | void CalendarView::newEvent(QDateTime fh) |
3110 | { | 3110 | { |
3111 | newEvent(fh, | 3111 | newEvent(fh, |
3112 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3112 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3113 | } | 3113 | } |
3114 | 3114 | ||
3115 | void CalendarView::newEvent(QDate dt) | 3115 | void CalendarView::newEvent(QDate dt) |
3116 | { | 3116 | { |
3117 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3117 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3118 | QDateTime(dt, QTime(0,0,0)), true); | 3118 | QDateTime(dt, QTime(0,0,0)), true); |
3119 | } | 3119 | } |
3120 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3120 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3121 | { | 3121 | { |
3122 | newEvent(fromHint, toHint, false); | 3122 | newEvent(fromHint, toHint, false); |
3123 | } | 3123 | } |
3124 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3124 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3125 | { | 3125 | { |
3126 | 3126 | ||
3127 | showEventEditor(); | 3127 | showEventEditor(); |
3128 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3128 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3129 | if ( mFilterView->filtersEnabled() ) { | 3129 | if ( mFilterView->filtersEnabled() ) { |
3130 | CalFilter *filter = mFilterView->selectedFilter(); | 3130 | CalFilter *filter = mFilterView->selectedFilter(); |
3131 | if (filter && filter->showCategories()) { | 3131 | if (filter && filter->showCategories()) { |
3132 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3132 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3133 | } | 3133 | } |
3134 | if ( filter ) | 3134 | if ( filter ) |
3135 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3135 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3136 | } | 3136 | } |
3137 | mEventEditor->exec(); | 3137 | mEventEditor->exec(); |
3138 | setActiveWindow(); | 3138 | setActiveWindow(); |
3139 | } | 3139 | } |
3140 | void CalendarView::todoAdded(Todo * t) | 3140 | void CalendarView::todoAdded(Todo * t) |
3141 | { | 3141 | { |
3142 | 3142 | ||
3143 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3143 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3144 | updateTodoViews(); | 3144 | updateTodoViews(); |
3145 | } | 3145 | } |
3146 | void CalendarView::todoChanged(Todo * t) | 3146 | void CalendarView::todoChanged(Todo * t) |
3147 | { | 3147 | { |
3148 | emit todoModified( t, 4 ); | 3148 | emit todoModified( t, 4 ); |
3149 | // updateTodoViews(); | 3149 | // updateTodoViews(); |
3150 | } | 3150 | } |
3151 | void CalendarView::todoToBeDeleted(Todo *) | 3151 | void CalendarView::todoToBeDeleted(Todo *) |
3152 | { | 3152 | { |
3153 | //qDebug("todoToBeDeleted(Todo *) "); | 3153 | //qDebug("todoToBeDeleted(Todo *) "); |
3154 | updateTodoViews(); | 3154 | updateTodoViews(); |
3155 | } | 3155 | } |
3156 | void CalendarView::todoDeleted() | 3156 | void CalendarView::todoDeleted() |
3157 | { | 3157 | { |
3158 | //qDebug(" todoDeleted()"); | 3158 | //qDebug(" todoDeleted()"); |
3159 | updateTodoViews(); | 3159 | updateTodoViews(); |
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | 3162 | ||
3163 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3163 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3164 | { | 3164 | { |
3165 | showTodoEditor(); | 3165 | showTodoEditor(); |
3166 | mTodoEditor->newTodo(dt,0,allday); | 3166 | mTodoEditor->newTodo(dt,0,allday); |
3167 | if ( mFilterView->filtersEnabled() ) { | 3167 | if ( mFilterView->filtersEnabled() ) { |
3168 | CalFilter *filter = mFilterView->selectedFilter(); | 3168 | CalFilter *filter = mFilterView->selectedFilter(); |
3169 | if (filter && filter->showCategories()) { | 3169 | if (filter && filter->showCategories()) { |
3170 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3170 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3171 | } | 3171 | } |
3172 | if ( filter ) | 3172 | if ( filter ) |
3173 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3173 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3174 | } | 3174 | } |
3175 | mTodoEditor->exec(); | 3175 | mTodoEditor->exec(); |
3176 | setActiveWindow(); | 3176 | setActiveWindow(); |
3177 | } | 3177 | } |
3178 | 3178 | ||
3179 | void CalendarView::newTodo() | 3179 | void CalendarView::newTodo() |
3180 | { | 3180 | { |
3181 | newTodoDateTime( QDateTime(),true ); | 3181 | newTodoDateTime( QDateTime(),true ); |
3182 | } | 3182 | } |
3183 | 3183 | ||
3184 | void CalendarView::newSubTodo() | 3184 | void CalendarView::newSubTodo() |
3185 | { | 3185 | { |
3186 | Todo *todo = selectedTodo(); | 3186 | Todo *todo = selectedTodo(); |
3187 | if ( todo ) newSubTodo( todo ); | 3187 | if ( todo ) newSubTodo( todo ); |
3188 | } | 3188 | } |
3189 | 3189 | ||
3190 | void CalendarView::newSubTodo(Todo *parentEvent) | 3190 | void CalendarView::newSubTodo(Todo *parentEvent) |
3191 | { | 3191 | { |
3192 | 3192 | ||
3193 | showTodoEditor(); | 3193 | showTodoEditor(); |
3194 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3194 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3195 | mTodoEditor->exec(); | 3195 | mTodoEditor->exec(); |
3196 | setActiveWindow(); | 3196 | setActiveWindow(); |
3197 | } | 3197 | } |
3198 | 3198 | ||
3199 | void CalendarView::newFloatingEvent() | 3199 | void CalendarView::newFloatingEvent() |
3200 | { | 3200 | { |
3201 | DateList tmpList = mNavigator->selectedDates(); | 3201 | DateList tmpList = mNavigator->selectedDates(); |
3202 | QDate date = tmpList.first(); | 3202 | QDate date = tmpList.first(); |
3203 | 3203 | ||
3204 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3204 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3205 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3205 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3206 | } | 3206 | } |
3207 | 3207 | ||
3208 | 3208 | ||
3209 | void CalendarView::editEvent( Event *event ) | 3209 | void CalendarView::editEvent( Event *event ) |
3210 | { | 3210 | { |
3211 | 3211 | ||
3212 | if ( !event ) return; | 3212 | if ( !event ) return; |
3213 | if ( event->isReadOnly() ) { | 3213 | if ( event->isReadOnly() ) { |
3214 | showEvent( event ); | 3214 | showEvent( event ); |
3215 | return; | 3215 | return; |
3216 | } | 3216 | } |
3217 | showEventEditor(); | 3217 | showEventEditor(); |
3218 | mEventEditor->editEvent( event , mFlagEditDescription); | 3218 | mEventEditor->editEvent( event , mFlagEditDescription); |
3219 | mEventEditor->exec(); | 3219 | mEventEditor->exec(); |
3220 | setActiveWindow(); | 3220 | setActiveWindow(); |
3221 | 3221 | ||
3222 | } | 3222 | } |
3223 | void CalendarView::editJournal( Journal *jour ) | 3223 | void CalendarView::editJournal( Journal *jour ) |
3224 | { | 3224 | { |
3225 | if ( !jour ) return; | 3225 | if ( !jour ) return; |
3226 | mDialogManager->hideSearchDialog(); | 3226 | mDialogManager->hideSearchDialog(); |
3227 | mViewManager->showJournalView(); | 3227 | mViewManager->showJournalView(); |
3228 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3228 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3229 | } | 3229 | } |
3230 | void CalendarView::editTodo( Todo *todo ) | 3230 | void CalendarView::editTodo( Todo *todo ) |
3231 | { | 3231 | { |
3232 | if ( !todo ) return; | 3232 | if ( !todo ) return; |
3233 | 3233 | ||
3234 | if ( todo->isReadOnly() ) { | 3234 | if ( todo->isReadOnly() ) { |
3235 | showTodo( todo ); | 3235 | showTodo( todo ); |
3236 | return; | 3236 | return; |
3237 | } | 3237 | } |
3238 | showTodoEditor(); | 3238 | showTodoEditor(); |
3239 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3239 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3240 | mTodoEditor->exec(); | 3240 | mTodoEditor->exec(); |
3241 | setActiveWindow(); | 3241 | setActiveWindow(); |
3242 | 3242 | ||
3243 | } | 3243 | } |
3244 | 3244 | ||
3245 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3245 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3246 | { | 3246 | { |
3247 | if ( !mEventViewerDialog ) { | 3247 | if ( !mEventViewerDialog ) { |
3248 | mEventViewerDialog = new KOEventViewerDialog(0); | 3248 | mEventViewerDialog = new KOEventViewerDialog(0); |
3249 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3249 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3250 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3250 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3251 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3251 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3252 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3252 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3253 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3253 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3254 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3254 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3255 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3255 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3256 | this, SLOT( slotViewerClosed() ) ); | 3256 | this, SLOT( slotViewerClosed() ) ); |
3257 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3257 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3258 | this, SLOT( todoChanged(Todo *) ) ); | 3258 | this, SLOT( todoChanged(Todo *) ) ); |
3259 | mEventViewerDialog->resize( 640, 480 ); | 3259 | mEventViewerDialog->resize( 640, 480 ); |
3260 | 3260 | ||
3261 | } | 3261 | } |
3262 | return mEventViewerDialog; | 3262 | return mEventViewerDialog; |
3263 | } | 3263 | } |
3264 | void CalendarView::showEvent(Event *event) | 3264 | void CalendarView::showEvent(Event *event) |
3265 | { | 3265 | { |
3266 | getEventViewerDialog()->setEvent(event); | 3266 | getEventViewerDialog()->setEvent(event); |
3267 | getEventViewerDialog()->showMe(); | 3267 | getEventViewerDialog()->showMe(); |
3268 | } | 3268 | } |
3269 | 3269 | ||
3270 | void CalendarView::showTodo(Todo *event) | 3270 | void CalendarView::showTodo(Todo *event) |
3271 | { | 3271 | { |
3272 | getEventViewerDialog()->setTodo(event); | 3272 | getEventViewerDialog()->setTodo(event); |
3273 | getEventViewerDialog()->showMe(); | 3273 | getEventViewerDialog()->showMe(); |
3274 | } | 3274 | } |
3275 | void CalendarView::showJournal( Journal *jour ) | 3275 | void CalendarView::showJournal( Journal *jour ) |
3276 | { | 3276 | { |
3277 | getEventViewerDialog()->setJournal(jour); | 3277 | getEventViewerDialog()->setJournal(jour); |
3278 | getEventViewerDialog()->showMe(); | 3278 | getEventViewerDialog()->showMe(); |
3279 | 3279 | ||
3280 | } | 3280 | } |
3281 | // void CalendarView::todoModified (Todo *event, int changed) | 3281 | // void CalendarView::todoModified (Todo *event, int changed) |
3282 | // { | 3282 | // { |
3283 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3283 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3284 | // // kdDebug() << "Todo modified and open" << endl; | 3284 | // // kdDebug() << "Todo modified and open" << endl; |
3285 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3285 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3286 | // // temp->modified (changed); | 3286 | // // temp->modified (changed); |
3287 | 3287 | ||
3288 | // // } | 3288 | // // } |
3289 | 3289 | ||
3290 | // mViewManager->updateView(); | 3290 | // mViewManager->updateView(); |
3291 | // } | 3291 | // } |
3292 | 3292 | ||
3293 | void CalendarView::appointment_show() | 3293 | void CalendarView::appointment_show() |
3294 | { | 3294 | { |
3295 | Event *anEvent = 0; | 3295 | Event *anEvent = 0; |
3296 | 3296 | ||
3297 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3297 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3298 | 3298 | ||
3299 | if (mViewManager->currentView()->isEventView()) { | 3299 | if (mViewManager->currentView()->isEventView()) { |
3300 | if ( incidence && incidence->typeID() == eventID ) { | 3300 | if ( incidence && incidence->typeID() == eventID ) { |
3301 | anEvent = static_cast<Event *>(incidence); | 3301 | anEvent = static_cast<Event *>(incidence); |
3302 | } | 3302 | } |
3303 | } | 3303 | } |
3304 | 3304 | ||
3305 | if (!anEvent) { | 3305 | if (!anEvent) { |
3306 | KNotifyClient::beep(); | 3306 | KNotifyClient::beep(); |
3307 | return; | 3307 | return; |
3308 | } | 3308 | } |
3309 | 3309 | ||
3310 | showEvent(anEvent); | 3310 | showEvent(anEvent); |
3311 | } | 3311 | } |
3312 | 3312 | ||
3313 | void CalendarView::appointment_edit() | 3313 | void CalendarView::appointment_edit() |
3314 | { | 3314 | { |
3315 | Event *anEvent = 0; | 3315 | Event *anEvent = 0; |
3316 | 3316 | ||
3317 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3317 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3318 | 3318 | ||
3319 | if (mViewManager->currentView()->isEventView()) { | 3319 | if (mViewManager->currentView()->isEventView()) { |
3320 | if ( incidence && incidence->typeID() == eventID ) { | 3320 | if ( incidence && incidence->typeID() == eventID ) { |
3321 | anEvent = static_cast<Event *>(incidence); | 3321 | anEvent = static_cast<Event *>(incidence); |
3322 | } | 3322 | } |
3323 | } | 3323 | } |
3324 | 3324 | ||
3325 | if (!anEvent) { | 3325 | if (!anEvent) { |
3326 | KNotifyClient::beep(); | 3326 | KNotifyClient::beep(); |
3327 | return; | 3327 | return; |
3328 | } | 3328 | } |
3329 | 3329 | ||
3330 | editEvent(anEvent); | 3330 | editEvent(anEvent); |
3331 | } | 3331 | } |
3332 | 3332 | ||
3333 | void CalendarView::appointment_delete() | 3333 | void CalendarView::appointment_delete() |
3334 | { | 3334 | { |
3335 | Event *anEvent = 0; | 3335 | Event *anEvent = 0; |
3336 | 3336 | ||
3337 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3337 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3338 | 3338 | ||
3339 | if (mViewManager->currentView()->isEventView()) { | 3339 | if (mViewManager->currentView()->isEventView()) { |
3340 | if ( incidence && incidence->typeID() == eventID ) { | 3340 | if ( incidence && incidence->typeID() == eventID ) { |
3341 | anEvent = static_cast<Event *>(incidence); | 3341 | anEvent = static_cast<Event *>(incidence); |
3342 | } | 3342 | } |
3343 | } | 3343 | } |
3344 | 3344 | ||
3345 | if (!anEvent) { | 3345 | if (!anEvent) { |
3346 | KNotifyClient::beep(); | 3346 | KNotifyClient::beep(); |
3347 | return; | 3347 | return; |
3348 | } | 3348 | } |
3349 | 3349 | ||
3350 | deleteEvent(anEvent); | 3350 | deleteEvent(anEvent); |
3351 | } | 3351 | } |
3352 | 3352 | ||
3353 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3353 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3354 | { | 3354 | { |
3355 | if (!sub) return; | 3355 | if (!sub) return; |
3356 | if ( sub->relatedTo() == parent ) | 3356 | if ( sub->relatedTo() == parent ) |
3357 | return; | 3357 | return; |
3358 | sub->setRelatedTo(parent); | 3358 | sub->setRelatedTo(parent); |
3359 | sub->updated(); | 3359 | sub->updated(); |
3360 | setModified(true); | 3360 | setModified(true); |
3361 | updateView(); | 3361 | updateView(); |
3362 | } | 3362 | } |
3363 | void CalendarView::todo_unsub(Todo *anTodo ) | 3363 | void CalendarView::todo_unsub(Todo *anTodo ) |
3364 | { | 3364 | { |
3365 | todo_resub( 0, anTodo ); | 3365 | todo_resub( 0, anTodo ); |
3366 | } | 3366 | } |
3367 | 3367 | ||
3368 | void CalendarView::deleteTodo(Todo *todo) | 3368 | void CalendarView::deleteTodo(Todo *todo) |
3369 | { | 3369 | { |
3370 | if (!todo) { | 3370 | if (!todo) { |
3371 | KNotifyClient::beep(); | 3371 | KNotifyClient::beep(); |
3372 | return; | 3372 | return; |
3373 | } | 3373 | } |
3374 | if (KOPrefs::instance()->mConfirm) { | 3374 | if (KOPrefs::instance()->mConfirm) { |
3375 | QString text = todo->summary().left(20); | 3375 | QString text = todo->summary().left(20); |
3376 | if (!todo->relations().isEmpty()) { | 3376 | if (!todo->relations().isEmpty()) { |
3377 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3377 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3378 | 3378 | ||
3379 | } | 3379 | } |
3380 | switch (msgItemDelete(text)) { | 3380 | switch (msgItemDelete(text)) { |
3381 | case KMessageBox::Continue: // OK | 3381 | case KMessageBox::Continue: // OK |
3382 | bool deleteT = false; | 3382 | bool deleteT = false; |
3383 | if (!todo->relations().isEmpty()) { | 3383 | if (!todo->relations().isEmpty()) { |
3384 | deleteT = removeCompletedSubTodos( todo ); | 3384 | deleteT = removeCompletedSubTodos( todo ); |
3385 | } | 3385 | } |
3386 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3386 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3387 | if ( !deleteT ) { | 3387 | if ( !deleteT ) { |
3388 | checkExternalId( todo ); | 3388 | checkExternalId( todo ); |
3389 | calendar()->deleteTodo(todo); | 3389 | calendar()->deleteTodo(todo); |
3390 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3390 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3391 | updateView(); | 3391 | updateView(); |
3392 | } | 3392 | } |
3393 | break; | 3393 | break; |
3394 | } // switch | 3394 | } // switch |
3395 | } else { | 3395 | } else { |
3396 | checkExternalId( todo ); | 3396 | checkExternalId( todo ); |
3397 | mCalendar->deleteTodo(todo); | 3397 | mCalendar->deleteTodo(todo); |
3398 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3398 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3399 | updateView(); | 3399 | updateView(); |
3400 | } | 3400 | } |
3401 | 3401 | ||
3402 | emit updateSearchDialog(); | 3402 | emit updateSearchDialog(); |
3403 | } | 3403 | } |
3404 | void CalendarView::deleteJournal(Journal *jour) | 3404 | void CalendarView::deleteJournal(Journal *jour) |
3405 | { | 3405 | { |
3406 | if (!jour) { | 3406 | if (!jour) { |
3407 | KNotifyClient::beep(); | 3407 | KNotifyClient::beep(); |
3408 | return; | 3408 | return; |
3409 | } | 3409 | } |
3410 | if (KOPrefs::instance()->mConfirm) { | 3410 | if (KOPrefs::instance()->mConfirm) { |
3411 | switch (msgItemDelete( jour->description().left(20))) { | 3411 | switch (msgItemDelete( jour->description().left(20))) { |
3412 | case KMessageBox::Continue: // OK | 3412 | case KMessageBox::Continue: // OK |
3413 | calendar()->deleteJournal(jour); | 3413 | calendar()->deleteJournal(jour); |
3414 | updateView(); | 3414 | updateView(); |
3415 | break; | 3415 | break; |
3416 | } // switch | 3416 | } // switch |
3417 | } else { | 3417 | } else { |
3418 | calendar()->deleteJournal(jour);; | 3418 | calendar()->deleteJournal(jour);; |
3419 | updateView(); | 3419 | updateView(); |
3420 | } | 3420 | } |
3421 | emit updateSearchDialog(); | 3421 | emit updateSearchDialog(); |
3422 | } | 3422 | } |
3423 | 3423 | ||
3424 | void CalendarView::deleteEvent(Event *anEvent) | 3424 | void CalendarView::deleteEvent(Event *anEvent) |
3425 | { | 3425 | { |
3426 | if (!anEvent) { | 3426 | if (!anEvent) { |
3427 | KNotifyClient::beep(); | 3427 | KNotifyClient::beep(); |
3428 | return; | 3428 | return; |
3429 | } | 3429 | } |
3430 | 3430 | ||
3431 | if (anEvent->recurrence()->doesRecur()) { | 3431 | if (anEvent->recurrence()->doesRecur()) { |
3432 | QDate itemDate = mViewManager->currentSelectionDate(); | 3432 | QDate itemDate = mViewManager->currentSelectionDate(); |
3433 | int km; | 3433 | int km; |
3434 | if (!itemDate.isValid()) { | 3434 | if (!itemDate.isValid()) { |
3435 | //kdDebug() << "Date Not Valid" << endl; | 3435 | //kdDebug() << "Date Not Valid" << endl; |
3436 | if (KOPrefs::instance()->mConfirm) { | 3436 | if (KOPrefs::instance()->mConfirm) { |
3437 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3437 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3438 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3438 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3439 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3439 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3440 | if ( km == KMessageBox::Continue ) | 3440 | if ( km == KMessageBox::Continue ) |
3441 | km = KMessageBox::No; // No = all below | 3441 | km = KMessageBox::No; // No = all below |
3442 | } else | 3442 | } else |
3443 | km = KMessageBox::No; | 3443 | km = KMessageBox::No; |
3444 | } else { | 3444 | } else { |
3445 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3445 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3446 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3446 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3447 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3447 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3448 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3448 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3449 | i18n("All")); | 3449 | i18n("All")); |
3450 | } | 3450 | } |
3451 | switch(km) { | 3451 | switch(km) { |
3452 | 3452 | ||
3453 | case KMessageBox::No: // Continue // all | 3453 | case KMessageBox::No: // Continue // all |
3454 | //qDebug("KMessageBox::No "); | 3454 | //qDebug("KMessageBox::No "); |
3455 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3455 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3456 | schedule(Scheduler::Cancel,anEvent); | 3456 | schedule(Scheduler::Cancel,anEvent); |
3457 | 3457 | ||
3458 | checkExternalId( anEvent); | 3458 | checkExternalId( anEvent); |
3459 | mCalendar->deleteEvent(anEvent); | 3459 | mCalendar->deleteEvent(anEvent); |
3460 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3460 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3461 | break; | 3461 | break; |
3462 | 3462 | ||
3463 | // Disabled because it does not work | 3463 | // Disabled because it does not work |
3464 | //#if 0 | 3464 | //#if 0 |
3465 | case KMessageBox::Yes: // just this one | 3465 | case KMessageBox::Yes: // just this one |
3466 | //QDate qd = mNavigator->selectedDates().first(); | 3466 | //QDate qd = mNavigator->selectedDates().first(); |
3467 | //if (!qd.isValid()) { | 3467 | //if (!qd.isValid()) { |
3468 | // kdDebug() << "no date selected, or invalid date" << endl; | 3468 | // kdDebug() << "no date selected, or invalid date" << endl; |
3469 | // KNotifyClient::beep(); | 3469 | // KNotifyClient::beep(); |
3470 | // return; | 3470 | // return; |
3471 | //} | 3471 | //} |
3472 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3472 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3473 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3473 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3474 | anEvent->addExDate(itemDate); | 3474 | anEvent->addExDate(itemDate); |
3475 | int duration = anEvent->recurrence()->duration(); | 3475 | int duration = anEvent->recurrence()->duration(); |
3476 | if ( duration > 0 ) { | 3476 | if ( duration > 0 ) { |
3477 | anEvent->recurrence()->setDuration( duration - 1 ); | 3477 | anEvent->recurrence()->setDuration( duration - 1 ); |
3478 | } | 3478 | } |
3479 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3479 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3480 | } | 3480 | } |
3481 | break; | 3481 | break; |
3482 | //#endif | 3482 | //#endif |
3483 | } // switch | 3483 | } // switch |
3484 | } else { | 3484 | } else { |
3485 | if (KOPrefs::instance()->mConfirm) { | 3485 | if (KOPrefs::instance()->mConfirm) { |
3486 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3486 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3487 | i18n("\nAre you sure you want\nto delete this event?"), | 3487 | i18n("\nAre you sure you want\nto delete this event?"), |
3488 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3488 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3489 | case KMessageBox::Continue: // OK | 3489 | case KMessageBox::Continue: // OK |
3490 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3490 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3491 | schedule(Scheduler::Cancel,anEvent); | 3491 | schedule(Scheduler::Cancel,anEvent); |
3492 | checkExternalId( anEvent); | 3492 | checkExternalId( anEvent); |
3493 | mCalendar->deleteEvent(anEvent); | 3493 | mCalendar->deleteEvent(anEvent); |
3494 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3494 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3495 | break; | 3495 | break; |
3496 | } // switch | 3496 | } // switch |
3497 | } else { | 3497 | } else { |
3498 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3498 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3499 | schedule(Scheduler::Cancel,anEvent); | 3499 | schedule(Scheduler::Cancel,anEvent); |
3500 | checkExternalId( anEvent); | 3500 | checkExternalId( anEvent); |
3501 | mCalendar->deleteEvent(anEvent); | 3501 | mCalendar->deleteEvent(anEvent); |
3502 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3502 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3503 | } | 3503 | } |
3504 | } // if-else | 3504 | } // if-else |
3505 | emit updateSearchDialog(); | 3505 | emit updateSearchDialog(); |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | bool CalendarView::deleteEvent(const QString &uid) | 3508 | bool CalendarView::deleteEvent(const QString &uid) |
3509 | { | 3509 | { |
3510 | Event *ev = mCalendar->event(uid); | 3510 | Event *ev = mCalendar->event(uid); |
3511 | if (ev) { | 3511 | if (ev) { |
3512 | deleteEvent(ev); | 3512 | deleteEvent(ev); |
3513 | return true; | 3513 | return true; |
3514 | } else { | 3514 | } else { |
3515 | return false; | 3515 | return false; |
3516 | } | 3516 | } |
3517 | } | 3517 | } |
3518 | 3518 | ||
3519 | /*****************************************************************************/ | 3519 | /*****************************************************************************/ |
3520 | 3520 | ||
3521 | void CalendarView::action_mail() | 3521 | void CalendarView::action_mail() |
3522 | { | 3522 | { |
3523 | #ifndef KORG_NOMAIL | 3523 | #ifndef KORG_NOMAIL |
3524 | KOMailClient mailClient; | 3524 | KOMailClient mailClient; |
3525 | 3525 | ||
3526 | Incidence *incidence = currentSelection(); | 3526 | Incidence *incidence = currentSelection(); |
3527 | 3527 | ||
3528 | if (!incidence) { | 3528 | if (!incidence) { |
3529 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3529 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3530 | return; | 3530 | return; |
3531 | } | 3531 | } |
3532 | if(incidence->attendeeCount() == 0 ) { | 3532 | if(incidence->attendeeCount() == 0 ) { |
3533 | KMessageBox::sorry(this, | 3533 | KMessageBox::sorry(this, |
3534 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3534 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3535 | return; | 3535 | return; |
3536 | } | 3536 | } |
3537 | 3537 | ||
3538 | CalendarLocal cal_tmp; | 3538 | CalendarLocal cal_tmp; |
3539 | Event *event = 0; | 3539 | Event *event = 0; |
3540 | Event *ev = 0; | 3540 | Event *ev = 0; |
3541 | if ( incidence && incidence->typeID() == eventID ) { | 3541 | if ( incidence && incidence->typeID() == eventID ) { |
3542 | event = static_cast<Event *>(incidence); | 3542 | event = static_cast<Event *>(incidence); |
3543 | ev = new Event(*event); | 3543 | ev = new Event(*event); |
3544 | cal_tmp.addEvent(ev); | 3544 | cal_tmp.addEvent(ev); |
3545 | } | 3545 | } |
3546 | ICalFormat mForm(); | 3546 | ICalFormat mForm(); |
3547 | QString attachment = mForm.toString( &cal_tmp ); | 3547 | QString attachment = mForm.toString( &cal_tmp ); |
3548 | if (ev) delete(ev); | 3548 | if (ev) delete(ev); |
3549 | 3549 | ||
3550 | mailClient.mailAttendees(currentSelection(), attachment); | 3550 | mailClient.mailAttendees(currentSelection(), attachment); |
3551 | 3551 | ||
3552 | #endif | 3552 | #endif |
3553 | 3553 | ||
3554 | #if 0 | 3554 | #if 0 |
3555 | Event *anEvent = 0; | 3555 | Event *anEvent = 0; |
3556 | if (mViewManager->currentView()->isEventView()) { | 3556 | if (mViewManager->currentView()->isEventView()) { |
3557 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3557 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3558 | } | 3558 | } |
3559 | 3559 | ||
3560 | if (!anEvent) { | 3560 | if (!anEvent) { |
3561 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3561 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3562 | return; | 3562 | return; |
3563 | } | 3563 | } |
3564 | if(anEvent->attendeeCount() == 0 ) { | 3564 | if(anEvent->attendeeCount() == 0 ) { |
3565 | KMessageBox::sorry(this, | 3565 | KMessageBox::sorry(this, |
3566 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3566 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3567 | return; | 3567 | return; |
3568 | } | 3568 | } |
3569 | 3569 | ||
3570 | mailobject.emailEvent(anEvent); | 3570 | mailobject.emailEvent(anEvent); |
3571 | #endif | 3571 | #endif |
3572 | } | 3572 | } |
3573 | 3573 | ||
3574 | 3574 | ||
3575 | void CalendarView::schedule_publish(Incidence *incidence) | 3575 | void CalendarView::schedule_publish(Incidence *incidence) |
3576 | { | 3576 | { |
3577 | Event *event = 0; | 3577 | Event *event = 0; |
3578 | Todo *todo = 0; | 3578 | Todo *todo = 0; |
3579 | 3579 | ||
3580 | if (incidence == 0) { | 3580 | if (incidence == 0) { |
3581 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3581 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3582 | if (incidence == 0) { | 3582 | if (incidence == 0) { |
3583 | incidence = mTodoList->selectedIncidences().first(); | 3583 | incidence = mTodoList->selectedIncidences().first(); |
3584 | } | 3584 | } |
3585 | } | 3585 | } |
3586 | if ( incidence && incidence->typeID() == eventID ) { | 3586 | if ( incidence && incidence->typeID() == eventID ) { |
3587 | event = static_cast<Event *>(incidence); | 3587 | event = static_cast<Event *>(incidence); |
3588 | } else { | 3588 | } else { |
3589 | if ( incidence && incidence->typeID() == todoID ) { | 3589 | if ( incidence && incidence->typeID() == todoID ) { |
3590 | todo = static_cast<Todo *>(incidence); | 3590 | todo = static_cast<Todo *>(incidence); |
3591 | } | 3591 | } |
3592 | } | 3592 | } |
3593 | 3593 | ||
3594 | if (!event && !todo) { | 3594 | if (!event && !todo) { |
3595 | KMessageBox::sorry(this,i18n("No event selected.")); | 3595 | KMessageBox::sorry(this,i18n("No event selected.")); |
3596 | return; | 3596 | return; |
3597 | } | 3597 | } |
3598 | 3598 | ||
3599 | PublishDialog *publishdlg = new PublishDialog(); | 3599 | PublishDialog *publishdlg = new PublishDialog(); |
3600 | if (incidence->attendeeCount()>0) { | 3600 | if (incidence->attendeeCount()>0) { |
3601 | QPtrList<Attendee> attendees = incidence->attendees(); | 3601 | QPtrList<Attendee> attendees = incidence->attendees(); |
3602 | attendees.first(); | 3602 | attendees.first(); |
3603 | while ( attendees.current()!=0 ) { | 3603 | while ( attendees.current()!=0 ) { |
3604 | publishdlg->addAttendee(attendees.current()); | 3604 | publishdlg->addAttendee(attendees.current()); |
3605 | attendees.next(); | 3605 | attendees.next(); |
3606 | } | 3606 | } |
3607 | } | 3607 | } |
3608 | bool send = true; | 3608 | bool send = true; |
3609 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3609 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3610 | if ( publishdlg->exec() != QDialog::Accepted ) | 3610 | if ( publishdlg->exec() != QDialog::Accepted ) |
3611 | send = false; | 3611 | send = false; |
3612 | } | 3612 | } |
3613 | if ( send ) { | 3613 | if ( send ) { |
3614 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3614 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3615 | if ( event ) { | 3615 | if ( event ) { |
3616 | Event *ev = new Event(*event); | 3616 | Event *ev = new Event(*event); |
3617 | ev->registerObserver(0); | 3617 | ev->registerObserver(0); |
3618 | ev->clearAttendees(); | 3618 | ev->clearAttendees(); |
3619 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3619 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3620 | delete(ev); | 3620 | delete(ev); |
3621 | } | 3621 | } |
3622 | } else { | 3622 | } else { |
3623 | if ( todo ) { | 3623 | if ( todo ) { |
3624 | Todo *ev = new Todo(*todo); | 3624 | Todo *ev = new Todo(*todo); |
3625 | ev->registerObserver(0); | 3625 | ev->registerObserver(0); |
3626 | ev->clearAttendees(); | 3626 | ev->clearAttendees(); |
3627 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3627 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3628 | delete(ev); | 3628 | delete(ev); |
3629 | } | 3629 | } |
3630 | } | 3630 | } |
3631 | } | 3631 | } |
3632 | } | 3632 | } |
3633 | delete publishdlg; | 3633 | delete publishdlg; |
3634 | } | 3634 | } |
3635 | 3635 | ||
3636 | void CalendarView::schedule_request(Incidence *incidence) | 3636 | void CalendarView::schedule_request(Incidence *incidence) |
3637 | { | 3637 | { |
3638 | schedule(Scheduler::Request,incidence); | 3638 | schedule(Scheduler::Request,incidence); |
3639 | } | 3639 | } |
3640 | 3640 | ||
3641 | void CalendarView::schedule_refresh(Incidence *incidence) | 3641 | void CalendarView::schedule_refresh(Incidence *incidence) |
3642 | { | 3642 | { |
3643 | schedule(Scheduler::Refresh,incidence); | 3643 | schedule(Scheduler::Refresh,incidence); |
3644 | } | 3644 | } |
3645 | 3645 | ||
3646 | void CalendarView::schedule_cancel(Incidence *incidence) | 3646 | void CalendarView::schedule_cancel(Incidence *incidence) |
3647 | { | 3647 | { |
3648 | schedule(Scheduler::Cancel,incidence); | 3648 | schedule(Scheduler::Cancel,incidence); |
3649 | } | 3649 | } |
3650 | 3650 | ||
3651 | void CalendarView::schedule_add(Incidence *incidence) | 3651 | void CalendarView::schedule_add(Incidence *incidence) |
3652 | { | 3652 | { |
3653 | schedule(Scheduler::Add,incidence); | 3653 | schedule(Scheduler::Add,incidence); |
3654 | } | 3654 | } |
3655 | 3655 | ||
3656 | void CalendarView::schedule_reply(Incidence *incidence) | 3656 | void CalendarView::schedule_reply(Incidence *incidence) |
3657 | { | 3657 | { |
3658 | schedule(Scheduler::Reply,incidence); | 3658 | schedule(Scheduler::Reply,incidence); |
3659 | } | 3659 | } |
3660 | 3660 | ||
3661 | void CalendarView::schedule_counter(Incidence *incidence) | 3661 | void CalendarView::schedule_counter(Incidence *incidence) |
3662 | { | 3662 | { |
3663 | schedule(Scheduler::Counter,incidence); | 3663 | schedule(Scheduler::Counter,incidence); |
3664 | } | 3664 | } |
3665 | 3665 | ||
3666 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3666 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3667 | { | 3667 | { |
3668 | schedule(Scheduler::Declinecounter,incidence); | 3668 | schedule(Scheduler::Declinecounter,incidence); |
3669 | } | 3669 | } |
3670 | 3670 | ||
3671 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3671 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3672 | { | 3672 | { |
3673 | QDateTime start = QDateTime::currentDateTime(); | 3673 | QDateTime start = QDateTime::currentDateTime(); |
3674 | QDateTime end = start.addDays(daysToPublish); | 3674 | QDateTime end = start.addDays(daysToPublish); |
3675 | 3675 | ||
3676 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3676 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3677 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3677 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3678 | 3678 | ||
3679 | 3679 | ||
3680 | PublishDialog *publishdlg = new PublishDialog(); | 3680 | PublishDialog *publishdlg = new PublishDialog(); |
3681 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3681 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3682 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3682 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3683 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3683 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3684 | delete(freebusy); | 3684 | delete(freebusy); |
3685 | } | 3685 | } |
3686 | } | 3686 | } |
3687 | delete publishdlg; | 3687 | delete publishdlg; |
3688 | } | 3688 | } |
3689 | 3689 | ||
3690 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3690 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3691 | { | 3691 | { |
3692 | Event *event = 0; | 3692 | Event *event = 0; |
3693 | Todo *todo = 0; | 3693 | Todo *todo = 0; |
3694 | 3694 | ||
3695 | if (incidence == 0) { | 3695 | if (incidence == 0) { |
3696 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3696 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3697 | if (incidence == 0) { | 3697 | if (incidence == 0) { |
3698 | incidence = mTodoList->selectedIncidences().first(); | 3698 | incidence = mTodoList->selectedIncidences().first(); |
3699 | } | 3699 | } |
3700 | } | 3700 | } |
3701 | if ( incidence && incidence->typeID() == eventID ) { | 3701 | if ( incidence && incidence->typeID() == eventID ) { |
3702 | event = static_cast<Event *>(incidence); | 3702 | event = static_cast<Event *>(incidence); |
3703 | } | 3703 | } |
3704 | if ( incidence && incidence->typeID() == todoID ) { | 3704 | if ( incidence && incidence->typeID() == todoID ) { |
3705 | todo = static_cast<Todo *>(incidence); | 3705 | todo = static_cast<Todo *>(incidence); |
3706 | } | 3706 | } |
3707 | 3707 | ||
3708 | if (!event && !todo) { | 3708 | if (!event && !todo) { |
3709 | KMessageBox::sorry(this,i18n("No event selected.")); | 3709 | KMessageBox::sorry(this,i18n("No event selected.")); |
3710 | return; | 3710 | return; |
3711 | } | 3711 | } |
3712 | 3712 | ||
3713 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3713 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3714 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3714 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3715 | return; | 3715 | return; |
3716 | } | 3716 | } |
3717 | 3717 | ||
3718 | Event *ev = 0; | 3718 | Event *ev = 0; |
3719 | if (event) ev = new Event(*event); | 3719 | if (event) ev = new Event(*event); |
3720 | Todo *to = 0; | 3720 | Todo *to = 0; |
3721 | if (todo) to = new Todo(*todo); | 3721 | if (todo) to = new Todo(*todo); |
3722 | 3722 | ||
3723 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3723 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3724 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3724 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3725 | if (!me) { | 3725 | if (!me) { |
3726 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3726 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3727 | return; | 3727 | return; |
3728 | } | 3728 | } |
3729 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3729 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3730 | StatusDialog *statdlg = new StatusDialog(this); | 3730 | StatusDialog *statdlg = new StatusDialog(this); |
3731 | if (!statdlg->exec()==QDialog::Accepted) return; | 3731 | if (!statdlg->exec()==QDialog::Accepted) return; |
3732 | me->setStatus( statdlg->status() ); | 3732 | me->setStatus( statdlg->status() ); |
3733 | delete(statdlg); | 3733 | delete(statdlg); |
3734 | } | 3734 | } |
3735 | Attendee *menew = new Attendee(*me); | 3735 | Attendee *menew = new Attendee(*me); |
3736 | if (ev) { | 3736 | if (ev) { |
3737 | ev->clearAttendees(); | 3737 | ev->clearAttendees(); |
3738 | ev->addAttendee(menew,false); | 3738 | ev->addAttendee(menew,false); |
3739 | } else { | 3739 | } else { |
3740 | if (to) { | 3740 | if (to) { |
3741 | todo->clearAttendees(); | 3741 | todo->clearAttendees(); |
3742 | todo->addAttendee(menew,false); | 3742 | todo->addAttendee(menew,false); |
3743 | } | 3743 | } |
3744 | } | 3744 | } |
3745 | } | 3745 | } |
3746 | 3746 | ||
3747 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3747 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3748 | if (ev) { | 3748 | if (ev) { |
3749 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3749 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3750 | } else { | 3750 | } else { |
3751 | if (to) { | 3751 | if (to) { |
3752 | if ( !dlg->addMessage(to,method) ) delete(to); | 3752 | if ( !dlg->addMessage(to,method) ) delete(to); |
3753 | } | 3753 | } |
3754 | } | 3754 | } |
3755 | } | 3755 | } |
3756 | 3756 | ||
3757 | void CalendarView::openAddressbook() | 3757 | void CalendarView::openAddressbook() |
3758 | { | 3758 | { |
3759 | KRun::runCommand("kaddressbook"); | 3759 | KRun::runCommand("kaddressbook"); |
3760 | } | 3760 | } |
3761 | 3761 | ||
3762 | void CalendarView::setModified(bool modified) | 3762 | void CalendarView::setModified(bool modified) |
3763 | { | 3763 | { |
3764 | if ( modified ) | 3764 | if ( modified ) |
3765 | emit signalmodified(); | 3765 | emit signalmodified(); |
3766 | if (mModified != modified) { | 3766 | if (mModified != modified) { |
3767 | mModified = modified; | 3767 | mModified = modified; |
3768 | emit modifiedChanged(mModified); | 3768 | emit modifiedChanged(mModified); |
3769 | } | 3769 | } |
3770 | } | 3770 | } |
3771 | 3771 | ||
3772 | bool CalendarView::isReadOnly() | 3772 | bool CalendarView::isReadOnly() |
3773 | { | 3773 | { |
3774 | return mReadOnly; | 3774 | return mReadOnly; |
3775 | } | 3775 | } |
3776 | 3776 | ||
3777 | void CalendarView::setReadOnly(bool readOnly) | 3777 | void CalendarView::setReadOnly(bool readOnly) |
3778 | { | 3778 | { |
3779 | if (mReadOnly != readOnly) { | 3779 | if (mReadOnly != readOnly) { |
3780 | mReadOnly = readOnly; | 3780 | mReadOnly = readOnly; |
3781 | emit readOnlyChanged(mReadOnly); | 3781 | emit readOnlyChanged(mReadOnly); |
3782 | } | 3782 | } |
3783 | } | 3783 | } |
3784 | 3784 | ||
3785 | bool CalendarView::isModified() | 3785 | bool CalendarView::isModified() |
3786 | { | 3786 | { |
3787 | return mModified; | 3787 | return mModified; |
3788 | } | 3788 | } |
3789 | void CalendarView::slotprintSelInc() | 3789 | void CalendarView::slotprintSelInc() |
3790 | { | 3790 | { |
3791 | if ( currentSelection() == 0 ) { | 3791 | if ( currentSelection() == 0 ) { |
3792 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3792 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3793 | return; | 3793 | return; |
3794 | } | 3794 | } |
3795 | showIncidence(); | 3795 | showIncidence(); |
3796 | getEventViewerDialog()->print(); | 3796 | getEventViewerDialog()->print(); |
3797 | 3797 | ||
3798 | } | 3798 | } |
3799 | void CalendarView::printSetup() | 3799 | void CalendarView::printSetup() |
3800 | { | 3800 | { |
3801 | #ifndef KORG_NOPRINTER | 3801 | #ifndef KORG_NOPRINTER |
3802 | createPrinter(); | 3802 | createPrinter(); |
3803 | 3803 | ||
3804 | mCalPrinter->setupPrinter(); | 3804 | mCalPrinter->setupPrinter(); |
3805 | #endif | 3805 | #endif |
3806 | } | 3806 | } |
3807 | 3807 | ||
3808 | void CalendarView::print() | 3808 | void CalendarView::print() |
3809 | { | 3809 | { |
3810 | #ifndef KORG_NOPRINTER | 3810 | #ifndef KORG_NOPRINTER |
3811 | createPrinter(); | 3811 | createPrinter(); |
3812 | 3812 | ||
3813 | DateList tmpDateList = mNavigator->selectedDates(); | 3813 | DateList tmpDateList = mNavigator->selectedDates(); |
3814 | mCalPrinter->print(CalPrinter::Month, | 3814 | mCalPrinter->print(CalPrinter::Month, |
3815 | tmpDateList.first(), tmpDateList.last()); | 3815 | tmpDateList.first(), tmpDateList.last()); |
3816 | #endif | 3816 | #endif |
3817 | } | 3817 | } |
3818 | 3818 | ||
3819 | void CalendarView::printPreview() | 3819 | void CalendarView::printPreview() |
3820 | { | 3820 | { |
3821 | #ifndef KORG_NOPRINTER | 3821 | #ifndef KORG_NOPRINTER |
3822 | kdDebug() << "CalendarView::printPreview()" << endl; | 3822 | kdDebug() << "CalendarView::printPreview()" << endl; |
3823 | 3823 | ||
3824 | createPrinter(); | 3824 | createPrinter(); |
3825 | 3825 | ||
3826 | DateList tmpDateList = mNavigator->selectedDates(); | 3826 | DateList tmpDateList = mNavigator->selectedDates(); |
3827 | 3827 | ||
3828 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3828 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3829 | tmpDateList.last()); | 3829 | tmpDateList.last()); |
3830 | #endif | 3830 | #endif |
3831 | } | 3831 | } |
3832 | 3832 | ||
3833 | void CalendarView::exportICalendar() | 3833 | void CalendarView::exportICalendar() |
3834 | { | 3834 | { |
3835 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3835 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3836 | 3836 | ||
3837 | // Force correct extension | 3837 | // Force correct extension |
3838 | if (filename.right(4) != ".ics") filename += ".ics"; | 3838 | if (filename.right(4) != ".ics") filename += ".ics"; |
3839 | 3839 | ||
3840 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3840 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3841 | storage.save(); | 3841 | storage.save(); |
3842 | } | 3842 | } |
3843 | 3843 | ||
3844 | bool CalendarView::exportVCalendar( QString filename ) | 3844 | bool CalendarView::exportVCalendar( QString filename ) |
3845 | { | 3845 | { |
3846 | if (mCalendar->journals().count() > 0) { | 3846 | if (mCalendar->journals().count() > 0) { |
3847 | int result = KMessageBox::warningContinueCancel(this, | 3847 | int result = KMessageBox::warningContinueCancel(this, |
3848 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3848 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3849 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3849 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3850 | true); | 3850 | true); |
3851 | if (result != KMessageBox::Continue) return false; | 3851 | if (result != KMessageBox::Continue) return false; |
3852 | } | 3852 | } |
3853 | 3853 | ||
3854 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3854 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3855 | 3855 | ||
3856 | // Force correct extension | 3856 | // Force correct extension |
3857 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3857 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3858 | 3858 | ||
3859 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3859 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3860 | return storage.save(); | 3860 | return storage.save(); |
3861 | 3861 | ||
3862 | } | 3862 | } |
3863 | 3863 | ||
3864 | void CalendarView::eventUpdated(Incidence *) | 3864 | void CalendarView::eventUpdated(Incidence *) |
3865 | { | 3865 | { |
3866 | setModified(); | 3866 | setModified(); |
3867 | // Don't call updateView here. The code, which has caused the update of the | 3867 | // Don't call updateView here. The code, which has caused the update of the |
3868 | // event is responsible for updating the view. | 3868 | // event is responsible for updating the view. |
3869 | // updateView(); | 3869 | // updateView(); |
3870 | } | 3870 | } |
3871 | 3871 | ||
3872 | void CalendarView::adaptNavigationUnits() | 3872 | void CalendarView::adaptNavigationUnits() |
3873 | { | 3873 | { |
3874 | if (mViewManager->currentView()->isEventView()) { | 3874 | if (mViewManager->currentView()->isEventView()) { |
3875 | int days = mViewManager->currentView()->currentDateCount(); | 3875 | int days = mViewManager->currentView()->currentDateCount(); |
3876 | if (days == 1) { | 3876 | if (days == 1) { |
3877 | emit changeNavStringPrev(i18n("&Previous Day")); | 3877 | emit changeNavStringPrev(i18n("&Previous Day")); |
3878 | emit changeNavStringNext(i18n("&Next Day")); | 3878 | emit changeNavStringNext(i18n("&Next Day")); |
3879 | } else { | 3879 | } else { |
3880 | emit changeNavStringPrev(i18n("&Previous Week")); | 3880 | emit changeNavStringPrev(i18n("&Previous Week")); |
3881 | emit changeNavStringNext(i18n("&Next Week")); | 3881 | emit changeNavStringNext(i18n("&Next Week")); |
3882 | } | 3882 | } |
3883 | } | 3883 | } |
3884 | } | 3884 | } |
3885 | 3885 | ||
3886 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3886 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3887 | { | 3887 | { |
3888 | if ( incidence ) mTodoList->clearSelection(); | 3888 | if ( incidence ) mTodoList->clearSelection(); |
3889 | processIncidenceSelection( incidence ); | 3889 | processIncidenceSelection( incidence ); |
3890 | } | 3890 | } |
3891 | 3891 | ||
3892 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3892 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3893 | { | 3893 | { |
3894 | if ( incidence && mViewManager->currentView() ) { | 3894 | if ( incidence && mViewManager->currentView() ) { |
3895 | mViewManager->currentView()->clearSelection(); | 3895 | mViewManager->currentView()->clearSelection(); |
3896 | } | 3896 | } |
3897 | processIncidenceSelection( incidence ); | 3897 | processIncidenceSelection( incidence ); |
3898 | } | 3898 | } |
3899 | 3899 | ||
3900 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3900 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3901 | { | 3901 | { |
3902 | if ( incidence == mSelectedIncidence ) return; | 3902 | if ( incidence == mSelectedIncidence ) return; |
3903 | 3903 | ||
3904 | mSelectedIncidence = incidence; | 3904 | mSelectedIncidence = incidence; |
3905 | 3905 | ||
3906 | emit incidenceSelected( mSelectedIncidence ); | 3906 | emit incidenceSelected( mSelectedIncidence ); |
3907 | 3907 | ||
3908 | if ( incidence && incidence->typeID() == eventID ) { | 3908 | if ( incidence && incidence->typeID() == eventID ) { |
3909 | Event *event = static_cast<Event *>( incidence ); | 3909 | Event *event = static_cast<Event *>( incidence ); |
3910 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3910 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3911 | emit organizerEventsSelected( true ); | 3911 | emit organizerEventsSelected( true ); |
3912 | } else { | 3912 | } else { |
3913 | emit organizerEventsSelected(false); | 3913 | emit organizerEventsSelected(false); |
3914 | } | 3914 | } |
3915 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3915 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3916 | KOPrefs::instance()->email() ) ) { | 3916 | KOPrefs::instance()->email() ) ) { |
3917 | emit groupEventsSelected( true ); | 3917 | emit groupEventsSelected( true ); |
3918 | } else { | 3918 | } else { |
3919 | emit groupEventsSelected(false); | 3919 | emit groupEventsSelected(false); |
3920 | } | 3920 | } |
3921 | return; | 3921 | return; |
3922 | } else { | 3922 | } else { |
3923 | if ( incidence && incidence->typeID() == todoID ) { | 3923 | if ( incidence && incidence->typeID() == todoID ) { |
3924 | emit todoSelected( true ); | 3924 | emit todoSelected( true ); |
3925 | Todo *event = static_cast<Todo *>( incidence ); | 3925 | Todo *event = static_cast<Todo *>( incidence ); |
3926 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3926 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3927 | emit organizerEventsSelected( true ); | 3927 | emit organizerEventsSelected( true ); |
3928 | } else { | 3928 | } else { |
3929 | emit organizerEventsSelected(false); | 3929 | emit organizerEventsSelected(false); |
3930 | } | 3930 | } |
3931 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3931 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3932 | KOPrefs::instance()->email() ) ) { | 3932 | KOPrefs::instance()->email() ) ) { |
3933 | emit groupEventsSelected( true ); | 3933 | emit groupEventsSelected( true ); |
3934 | } else { | 3934 | } else { |
3935 | emit groupEventsSelected(false); | 3935 | emit groupEventsSelected(false); |
3936 | } | 3936 | } |
3937 | return; | 3937 | return; |
3938 | } else { | 3938 | } else { |
3939 | emit todoSelected( false ); | 3939 | emit todoSelected( false ); |
3940 | emit organizerEventsSelected(false); | 3940 | emit organizerEventsSelected(false); |
3941 | emit groupEventsSelected(false); | 3941 | emit groupEventsSelected(false); |
3942 | } | 3942 | } |
3943 | return; | 3943 | return; |
3944 | } | 3944 | } |
3945 | 3945 | ||
3946 | /* if ( incidence && incidence->typeID() == todoID ) { | 3946 | /* if ( incidence && incidence->typeID() == todoID ) { |
3947 | emit todoSelected( true ); | 3947 | emit todoSelected( true ); |
3948 | } else { | 3948 | } else { |
3949 | emit todoSelected( false ); | 3949 | emit todoSelected( false ); |
3950 | }*/ | 3950 | }*/ |
3951 | } | 3951 | } |
3952 | 3952 | ||
3953 | 3953 | ||
3954 | void CalendarView::checkClipboard() | 3954 | void CalendarView::checkClipboard() |
3955 | { | 3955 | { |
3956 | #ifndef KORG_NODND | 3956 | #ifndef KORG_NODND |
3957 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3957 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3958 | emit pasteEnabled(true); | 3958 | emit pasteEnabled(true); |
3959 | } else { | 3959 | } else { |
3960 | emit pasteEnabled(false); | 3960 | emit pasteEnabled(false); |
3961 | } | 3961 | } |
3962 | #endif | 3962 | #endif |
3963 | } | 3963 | } |
3964 | 3964 | ||
3965 | void CalendarView::showDates(const DateList &selectedDates) | 3965 | void CalendarView::showDates(const DateList &selectedDates) |
3966 | { | 3966 | { |
3967 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3967 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3968 | 3968 | ||
3969 | 3969 | ||
3970 | if ( !mBlockShowDates ) { | 3970 | if ( !mBlockShowDates ) { |
3971 | if ( mViewManager->currentView() ) { | 3971 | if ( mViewManager->currentView() ) { |
3972 | updateView( selectedDates.first(), selectedDates.last() ); | 3972 | updateView( selectedDates.first(), selectedDates.last() ); |
3973 | } else { | 3973 | } else { |
3974 | mViewManager->showAgendaView(); | 3974 | mViewManager->showAgendaView(); |
3975 | } | 3975 | } |
3976 | } | 3976 | } |
3977 | 3977 | ||
3978 | QDate date = selectedDates.first(); | 3978 | QDate date = selectedDates.first(); |
3979 | if ( ! date.isValid() ) { | 3979 | if ( ! date.isValid() ) { |
3980 | topLevelWidget()->setCaption(""); | 3980 | topLevelWidget()->setCaption(""); |
3981 | return; | 3981 | return; |
3982 | } | 3982 | } |
3983 | 3983 | ||
3984 | QString selDates; | 3984 | QString selDates; |
3985 | selDates = KGlobal::locale()->formatDate( date, true); | 3985 | selDates = KGlobal::locale()->formatDate( date, true); |
3986 | if (selectedDates.first() < selectedDates.last() ) | 3986 | if (selectedDates.first() < selectedDates.last() ) |
3987 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3987 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3988 | else { | 3988 | else { |
3989 | QString addString; | 3989 | QString addString; |
3990 | if ( date == QDateTime::currentDateTime().date() ) | 3990 | if ( date == QDateTime::currentDateTime().date() ) |
3991 | addString = i18n("Today"); | 3991 | addString = i18n("Today"); |
3992 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 3992 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
3993 | addString = i18n("Tomorrow"); | 3993 | addString = i18n("Tomorrow"); |
3994 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 3994 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
3995 | addString = i18n("Yesterday"); | 3995 | addString = i18n("Yesterday"); |
3996 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 3996 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
3997 | addString = i18n("Day before yesterday"); | 3997 | addString = i18n("Day before yesterday"); |
3998 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 3998 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
3999 | addString = i18n("Day after tomorrow"); | 3999 | addString = i18n("Day after tomorrow"); |
4000 | if ( !addString.isEmpty() ) { | 4000 | if ( !addString.isEmpty() ) { |
4001 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4001 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4002 | return; | 4002 | return; |
4003 | } | 4003 | } |
4004 | } | 4004 | } |
4005 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4005 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4006 | 4006 | ||
4007 | } | 4007 | } |
4008 | 4008 | ||
4009 | QPtrList<CalFilter> CalendarView::filters() | 4009 | QPtrList<CalFilter> CalendarView::filters() |
4010 | { | 4010 | { |
4011 | return mFilters; | 4011 | return mFilters; |
4012 | 4012 | ||
4013 | } | 4013 | } |
4014 | void CalendarView::editFilters() | 4014 | void CalendarView::editFilters() |
4015 | { | 4015 | { |
4016 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4016 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4017 | 4017 | ||
4018 | CalFilter *filter = mFilters.first(); | 4018 | CalFilter *filter = mFilters.first(); |
4019 | while(filter) { | 4019 | while(filter) { |
4020 | kdDebug() << " Filter: " << filter->name() << endl; | 4020 | kdDebug() << " Filter: " << filter->name() << endl; |
4021 | filter = mFilters.next(); | 4021 | filter = mFilters.next(); |
4022 | } | 4022 | } |
4023 | 4023 | ||
4024 | mDialogManager->showFilterEditDialog(&mFilters); | 4024 | mDialogManager->showFilterEditDialog(&mFilters); |
4025 | updateFilter(); | 4025 | updateFilter(); |
4026 | } | 4026 | } |
4027 | void CalendarView::toggleFilter() | 4027 | void CalendarView::toggleFilter() |
4028 | { | 4028 | { |
4029 | showFilter(! mCalEditView->isVisible()); | 4029 | if ( mLeftFrame->isHidden() ) { |
4030 | toggleExpand(); | ||
4031 | showFilter( true ); | ||
4032 | } else | ||
4033 | showFilter(! mCalEditView->isVisible()); | ||
4030 | } | 4034 | } |
4031 | 4035 | ||
4032 | KOFilterView *CalendarView::filterView() | 4036 | KOFilterView *CalendarView::filterView() |
4033 | { | 4037 | { |
4034 | return mFilterView; | 4038 | return mFilterView; |
4035 | } | 4039 | } |
4036 | void CalendarView::selectFilter( int fil ) | 4040 | void CalendarView::selectFilter( int fil ) |
4037 | { | 4041 | { |
4038 | mFilterView->setSelectedFilter( fil ); | 4042 | mFilterView->setSelectedFilter( fil ); |
4039 | } | 4043 | } |
4040 | void CalendarView::showFilter(bool visible) | 4044 | void CalendarView::showFilter(bool visible) |
4041 | { | 4045 | { |
4042 | #if 1 | 4046 | #if 1 |
4043 | if (visible) { | 4047 | if (visible) { |
4044 | mCalEditView->readConfig(); | 4048 | mCalEditView->readConfig(); |
4045 | mCalEditView->show(); | 4049 | mCalEditView->show(); |
4046 | QValueList<int> sizes; | 4050 | QValueList<int> sizes; |
4047 | sizes = mLeftFrame->sizes(); | 4051 | sizes = mLeftFrame->sizes(); |
4048 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4052 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4049 | sizes.clear(); | 4053 | sizes.clear(); |
4050 | sizes << 100; | 4054 | sizes << 100; |
4051 | sizes << 0; | 4055 | sizes << 0; |
4052 | sizes << 0; | 4056 | sizes << 0; |
4053 | sizes << 100; | 4057 | sizes << 100; |
4054 | mLeftFrame->setSizes(sizes); | 4058 | mLeftFrame->setSizes(sizes); |
4055 | } | 4059 | } |
4056 | #if 0 | 4060 | #if 0 |
4057 | sizes = mLeftFrame->sizes(); | 4061 | sizes = mLeftFrame->sizes(); |
4058 | int ccc = 0; | 4062 | int ccc = 0; |
4059 | while ( ccc < sizes.count()) { | 4063 | while ( ccc < sizes.count()) { |
4060 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4064 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4061 | ++ccc; | 4065 | ++ccc; |
4062 | } | 4066 | } |
4063 | #endif | 4067 | #endif |
4064 | 4068 | ||
4065 | } | 4069 | } |
4066 | else { | 4070 | else { |
4067 | mCalEditView->hide(); | 4071 | mCalEditView->hide(); |
4068 | } | 4072 | } |
4069 | #else | 4073 | #else |
4070 | if (visible) mFilterView->show(); | 4074 | if (visible) mFilterView->show(); |
4071 | else mFilterView->hide(); | 4075 | else mFilterView->hide(); |
4072 | #endif | 4076 | #endif |
4073 | } | 4077 | } |
4074 | void CalendarView::toggleFilerEnabled( ) | 4078 | void CalendarView::toggleFilerEnabled( ) |
4075 | { | 4079 | { |
4076 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4080 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4077 | if ( !mFilterView->filtersEnabled() ) | 4081 | if ( !mFilterView->filtersEnabled() ) |
4078 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4082 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4079 | 4083 | ||
4080 | } | 4084 | } |
4081 | void CalendarView::updateFilter() | 4085 | void CalendarView::updateFilter() |
4082 | { | 4086 | { |
4083 | CalFilter *filter = mFilterView->selectedFilter(); | 4087 | CalFilter *filter = mFilterView->selectedFilter(); |
4084 | if (filter) { | 4088 | if (filter) { |
4085 | QString mess; | 4089 | QString mess; |
4086 | if (mFilterView->filtersEnabled()) { | 4090 | if (mFilterView->filtersEnabled()) { |
4087 | mess = i18n("Filter selected: ")+filter->name(); | 4091 | mess = i18n("Filter selected: ")+filter->name(); |
4088 | filter->setEnabled(true); | 4092 | filter->setEnabled(true); |
4089 | } | 4093 | } |
4090 | else filter->setEnabled(false); | 4094 | else filter->setEnabled(false); |
4091 | mCalendar->setFilter(filter); | 4095 | mCalendar->setFilter(filter); |
4092 | updateView(); | 4096 | updateView(); |
4093 | if ( !mess.isEmpty() ) | 4097 | if ( !mess.isEmpty() ) |
4094 | topLevelWidget()->setCaption( mess ); | 4098 | topLevelWidget()->setCaption( mess ); |
4095 | 4099 | ||
4096 | } | 4100 | } |
4097 | emit filtersUpdated(); | 4101 | emit filtersUpdated(); |
4098 | } | 4102 | } |
4099 | 4103 | ||
4100 | void CalendarView::filterEdited() | 4104 | void CalendarView::filterEdited() |
4101 | { | 4105 | { |
4102 | mFilterView->updateFilters(); | 4106 | mFilterView->updateFilters(); |
4103 | updateFilter(); | 4107 | updateFilter(); |
4104 | writeSettings(); | 4108 | writeSettings(); |
4105 | } | 4109 | } |
4106 | 4110 | ||
4107 | 4111 | ||
4108 | void CalendarView::takeOverEvent() | 4112 | void CalendarView::takeOverEvent() |
4109 | { | 4113 | { |
4110 | Incidence *incidence = currentSelection(); | 4114 | Incidence *incidence = currentSelection(); |
4111 | 4115 | ||
4112 | if (!incidence) return; | 4116 | if (!incidence) return; |
4113 | 4117 | ||
4114 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4118 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4115 | incidence->recreate(); | 4119 | incidence->recreate(); |
4116 | incidence->setReadOnly(false); | 4120 | incidence->setReadOnly(false); |
4117 | 4121 | ||
4118 | updateView(); | 4122 | updateView(); |
4119 | } | 4123 | } |
4120 | 4124 | ||
4121 | void CalendarView::takeOverCalendar() | 4125 | void CalendarView::takeOverCalendar() |
4122 | { | 4126 | { |
4123 | // TODO: Create Calendar::allIncidences() function and use it here | 4127 | // TODO: Create Calendar::allIncidences() function and use it here |
4124 | 4128 | ||
4125 | clearAllViews(); | 4129 | clearAllViews(); |
4126 | QPtrList<Event> events = mCalendar->events(); | 4130 | QPtrList<Event> events = mCalendar->events(); |
4127 | for(uint i=0; i<events.count(); ++i) { | 4131 | for(uint i=0; i<events.count(); ++i) { |
4128 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4132 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4129 | events.at(i)->recreate(); | 4133 | events.at(i)->recreate(); |
4130 | events.at(i)->setReadOnly(false); | 4134 | events.at(i)->setReadOnly(false); |
4131 | } | 4135 | } |
4132 | 4136 | ||
4133 | QPtrList<Todo> todos = mCalendar->todos(); | 4137 | QPtrList<Todo> todos = mCalendar->todos(); |
4134 | for(uint i=0; i<todos.count(); ++i) { | 4138 | for(uint i=0; i<todos.count(); ++i) { |
4135 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4139 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4136 | todos.at(i)->recreate(); | 4140 | todos.at(i)->recreate(); |
4137 | todos.at(i)->setReadOnly(false); | 4141 | todos.at(i)->setReadOnly(false); |
4138 | } | 4142 | } |
4139 | 4143 | ||
4140 | QPtrList<Journal> journals = mCalendar->journals(); | 4144 | QPtrList<Journal> journals = mCalendar->journals(); |
4141 | for(uint i=0; i<journals.count(); ++i) { | 4145 | for(uint i=0; i<journals.count(); ++i) { |
4142 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4146 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4143 | journals.at(i)->recreate(); | 4147 | journals.at(i)->recreate(); |
4144 | journals.at(i)->setReadOnly(false); | 4148 | journals.at(i)->setReadOnly(false); |
4145 | } | 4149 | } |
4146 | 4150 | ||
4147 | updateView(); | 4151 | updateView(); |
4148 | } | 4152 | } |
4149 | 4153 | ||
4150 | void CalendarView::showIntro() | 4154 | void CalendarView::showIntro() |
4151 | { | 4155 | { |
4152 | kdDebug() << "To be implemented." << endl; | 4156 | kdDebug() << "To be implemented." << endl; |
4153 | } | 4157 | } |
4154 | 4158 | ||
4155 | QWidgetStack *CalendarView::viewStack() | 4159 | QWidgetStack *CalendarView::viewStack() |
4156 | { | 4160 | { |
4157 | return mRightFrame; | 4161 | return mRightFrame; |
4158 | } | 4162 | } |
4159 | 4163 | ||
4160 | QWidget *CalendarView::leftFrame() | 4164 | QWidget *CalendarView::leftFrame() |
4161 | { | 4165 | { |
4162 | return ( QWidget *)mLeftFrame; | 4166 | return ( QWidget *)mLeftFrame; |
4163 | } | 4167 | } |
4164 | 4168 | ||
4165 | DateNavigator *CalendarView::dateNavigator() | 4169 | DateNavigator *CalendarView::dateNavigator() |
4166 | { | 4170 | { |
4167 | return mNavigator; | 4171 | return mNavigator; |
4168 | } | 4172 | } |
4169 | 4173 | ||
4170 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4174 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4171 | { | 4175 | { |
4172 | return mDateNavigator->navigatorView(); | 4176 | return mDateNavigator->navigatorView(); |
4173 | } | 4177 | } |
4174 | void CalendarView::toggleDateNavigatorWidget() | 4178 | void CalendarView::toggleDateNavigatorWidget() |
4175 | { | 4179 | { |
4176 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4180 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4177 | 4181 | ||
4178 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4182 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4179 | mDateNavigator->hide(); | 4183 | mDateNavigator->hide(); |
4180 | else | 4184 | else |
4181 | mDateNavigator->show(); | 4185 | mDateNavigator->show(); |
4182 | } | 4186 | } |
4183 | void CalendarView::addView(KOrg::BaseView *view) | 4187 | void CalendarView::addView(KOrg::BaseView *view) |
4184 | { | 4188 | { |
4185 | mViewManager->addView(view); | 4189 | mViewManager->addView(view); |
4186 | } | 4190 | } |
4187 | 4191 | ||
4188 | void CalendarView::showView(KOrg::BaseView *view) | 4192 | void CalendarView::showView(KOrg::BaseView *view) |
4189 | { | 4193 | { |
4190 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4194 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4191 | } | 4195 | } |
4192 | 4196 | ||
4193 | Incidence *CalendarView::currentSelection() | 4197 | Incidence *CalendarView::currentSelection() |
4194 | { | 4198 | { |
4195 | return mViewManager->currentSelection(); | 4199 | return mViewManager->currentSelection(); |
4196 | } | 4200 | } |
4197 | void CalendarView::toggleAllDaySize() | 4201 | void CalendarView::toggleAllDaySize() |
4198 | { | 4202 | { |
4199 | /* | 4203 | /* |
4200 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4204 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4201 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4205 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4202 | else | 4206 | else |
4203 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4207 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4204 | */ | 4208 | */ |
4205 | viewManager()->agendaView()->toggleAllDay(); | 4209 | viewManager()->agendaView()->toggleAllDay(); |
4206 | } | 4210 | } |
4207 | void CalendarView::toggleExpand() | 4211 | void CalendarView::toggleExpand() |
4208 | { | 4212 | { |
4209 | // if ( mLeftFrame->isHidden() ) { | 4213 | // if ( mLeftFrame->isHidden() ) { |
4210 | // mLeftFrame->show(); | 4214 | // mLeftFrame->show(); |
4211 | // emit calendarViewExpanded( false ); | 4215 | // emit calendarViewExpanded( false ); |
4212 | // } else { | 4216 | // } else { |
4213 | // mLeftFrame->hide(); | 4217 | // mLeftFrame->hide(); |
4214 | // emit calendarViewExpanded( true ); | 4218 | // emit calendarViewExpanded( true ); |
4215 | // } | 4219 | // } |
4216 | //qDebug(" CalendarView::toggleExpand()"); | 4220 | //qDebug(" CalendarView::toggleExpand()"); |
4217 | globalFlagBlockAgenda = 1; | 4221 | globalFlagBlockAgenda = 1; |
4218 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4222 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4219 | globalFlagBlockAgenda = 5; | 4223 | globalFlagBlockAgenda = 5; |
4220 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4224 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4221 | //mViewManager->showView( 0, true ); | 4225 | //mViewManager->showView( 0, true ); |
4222 | } | 4226 | } |
4223 | 4227 | ||
4224 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4228 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4225 | { | 4229 | { |
4226 | setModified( modified ); | 4230 | setModified( modified ); |
4227 | } | 4231 | } |
4228 | 4232 | ||
4229 | Todo *CalendarView::selectedTodo() | 4233 | Todo *CalendarView::selectedTodo() |
4230 | { | 4234 | { |
4231 | Incidence *incidence = currentSelection(); | 4235 | Incidence *incidence = currentSelection(); |
4232 | if ( incidence && incidence->typeID() == todoID ) { | 4236 | if ( incidence && incidence->typeID() == todoID ) { |
4233 | return static_cast<Todo *>( incidence ); | 4237 | return static_cast<Todo *>( incidence ); |
4234 | } | 4238 | } |
4235 | 4239 | ||
4236 | incidence = mTodoList->selectedIncidences().first(); | 4240 | incidence = mTodoList->selectedIncidences().first(); |
4237 | if ( incidence && incidence->typeID() == todoID ) { | 4241 | if ( incidence && incidence->typeID() == todoID ) { |
4238 | return static_cast<Todo *>( incidence ); | 4242 | return static_cast<Todo *>( incidence ); |
4239 | } | 4243 | } |
4240 | 4244 | ||
4241 | return 0; | 4245 | return 0; |
4242 | } | 4246 | } |
4243 | 4247 | ||
4244 | void CalendarView::dialogClosing(Incidence *in) | 4248 | void CalendarView::dialogClosing(Incidence *in) |
4245 | { | 4249 | { |
4246 | // mDialogList.remove(in); | 4250 | // mDialogList.remove(in); |
4247 | } | 4251 | } |
4248 | 4252 | ||
4249 | void CalendarView::showIncidence() | 4253 | void CalendarView::showIncidence() |
4250 | { | 4254 | { |
4251 | mViewerCallerIsSearchDialog = false; | 4255 | mViewerCallerIsSearchDialog = false; |
4252 | Incidence *incidence = currentSelection(); | 4256 | Incidence *incidence = currentSelection(); |
4253 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4257 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4254 | if ( incidence ) { | 4258 | if ( incidence ) { |
4255 | ShowIncidenceVisitor v; | 4259 | ShowIncidenceVisitor v; |
4256 | v.act( incidence, this ); | 4260 | v.act( incidence, this ); |
4257 | } | 4261 | } |
4258 | } | 4262 | } |
4259 | void CalendarView::editIncidenceDescription() | 4263 | void CalendarView::editIncidenceDescription() |
4260 | { | 4264 | { |
4261 | mFlagEditDescription = true; | 4265 | mFlagEditDescription = true; |
4262 | editIncidence(); | 4266 | editIncidence(); |
4263 | mFlagEditDescription = false; | 4267 | mFlagEditDescription = false; |
4264 | } | 4268 | } |
4265 | void CalendarView::editIncidence() | 4269 | void CalendarView::editIncidence() |
4266 | { | 4270 | { |
4267 | // qDebug("editIncidence() "); | 4271 | // qDebug("editIncidence() "); |
4268 | Incidence *incidence = currentSelection(); | 4272 | Incidence *incidence = currentSelection(); |
4269 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4273 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4270 | if ( incidence ) { | 4274 | if ( incidence ) { |
4271 | EditIncidenceVisitor v; | 4275 | EditIncidenceVisitor v; |
4272 | v.act( incidence, this ); | 4276 | v.act( incidence, this ); |
4273 | } | 4277 | } |
4274 | } | 4278 | } |
4275 | 4279 | ||
4276 | void CalendarView::deleteIncidence() | 4280 | void CalendarView::deleteIncidence() |
4277 | { | 4281 | { |
4278 | Incidence *incidence = currentSelection(); | 4282 | Incidence *incidence = currentSelection(); |
4279 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4283 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4280 | if ( incidence ) { | 4284 | if ( incidence ) { |
4281 | deleteIncidence(incidence); | 4285 | deleteIncidence(incidence); |
4282 | } | 4286 | } |
4283 | } | 4287 | } |
4284 | void CalendarView::showIncidence(QString uid) | 4288 | void CalendarView::showIncidence(QString uid) |
4285 | { | 4289 | { |
4286 | Incidence *inc = mCalendar->incidence( uid ); | 4290 | Incidence *inc = mCalendar->incidence( uid ); |
4287 | if ( inc ) | 4291 | if ( inc ) |
4288 | showIncidence( inc ); | 4292 | showIncidence( inc ); |
4289 | } | 4293 | } |
4290 | void CalendarView::showIncidence(Incidence *incidence) | 4294 | void CalendarView::showIncidence(Incidence *incidence) |
4291 | { | 4295 | { |
4292 | mViewerCallerIsSearchDialog = false; | 4296 | mViewerCallerIsSearchDialog = false; |
4293 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4297 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4294 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4298 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4295 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4299 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4296 | mViewerCallerIsSearchDialog = true; | 4300 | mViewerCallerIsSearchDialog = true; |
4297 | } | 4301 | } |
4298 | } | 4302 | } |
4299 | if ( incidence ) { | 4303 | if ( incidence ) { |
4300 | ShowIncidenceVisitor v; | 4304 | ShowIncidenceVisitor v; |
4301 | v.act( incidence, this ); | 4305 | v.act( incidence, this ); |
4302 | } | 4306 | } |
4303 | } | 4307 | } |
4304 | 4308 | ||
4305 | void CalendarView::editIncidence(Incidence *incidence) | 4309 | void CalendarView::editIncidence(Incidence *incidence) |
4306 | { | 4310 | { |
4307 | if ( incidence ) { | 4311 | if ( incidence ) { |
4308 | 4312 | ||
4309 | EditIncidenceVisitor v; | 4313 | EditIncidenceVisitor v; |
4310 | v.act( incidence, this ); | 4314 | v.act( incidence, this ); |
4311 | 4315 | ||
4312 | } | 4316 | } |
4313 | } | 4317 | } |
4314 | 4318 | ||
4315 | void CalendarView::deleteIncidence(Incidence *incidence) | 4319 | void CalendarView::deleteIncidence(Incidence *incidence) |
4316 | { | 4320 | { |
4317 | //qDebug(" CalendarView::deleteIncidence "); | 4321 | //qDebug(" CalendarView::deleteIncidence "); |
4318 | if ( incidence ) { | 4322 | if ( incidence ) { |
4319 | DeleteIncidenceVisitor v; | 4323 | DeleteIncidenceVisitor v; |
4320 | v.act( incidence, this ); | 4324 | v.act( incidence, this ); |
4321 | } | 4325 | } |
4322 | } | 4326 | } |
4323 | 4327 | ||
4324 | 4328 | ||
4325 | void CalendarView::lookForOutgoingMessages() | 4329 | void CalendarView::lookForOutgoingMessages() |
4326 | { | 4330 | { |
4327 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4331 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4328 | ogd->loadMessages(); | 4332 | ogd->loadMessages(); |
4329 | } | 4333 | } |
4330 | 4334 | ||
4331 | void CalendarView::lookForIncomingMessages() | 4335 | void CalendarView::lookForIncomingMessages() |
4332 | { | 4336 | { |
4333 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4337 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4334 | icd->retrieve(); | 4338 | icd->retrieve(); |
4335 | } | 4339 | } |
4336 | 4340 | ||
4337 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4341 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4338 | { | 4342 | { |
4339 | bool deleteTodo = true; | 4343 | bool deleteTodo = true; |
4340 | QPtrList<Incidence> subTodos; | 4344 | QPtrList<Incidence> subTodos; |
4341 | Incidence *aTodo; | 4345 | Incidence *aTodo; |
4342 | subTodos = t->relations(); | 4346 | subTodos = t->relations(); |
4343 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4347 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4344 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4348 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4345 | deleteTodo = false; | 4349 | deleteTodo = false; |
4346 | } | 4350 | } |
4347 | if ( deleteTodo ) { | 4351 | if ( deleteTodo ) { |
4348 | if ( t->isCompleted() && !t->doesRecur()) { | 4352 | if ( t->isCompleted() && !t->doesRecur()) { |
4349 | checkExternalId( t ); | 4353 | checkExternalId( t ); |
4350 | mCalendar->deleteTodo( t ); | 4354 | mCalendar->deleteTodo( t ); |
4351 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4355 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4352 | } | 4356 | } |
4353 | else | 4357 | else |
4354 | deleteTodo = false; | 4358 | deleteTodo = false; |
4355 | } | 4359 | } |
4356 | return deleteTodo; | 4360 | return deleteTodo; |
4357 | 4361 | ||
4358 | } | 4362 | } |
4359 | void CalendarView::purgeCompleted() | 4363 | void CalendarView::purgeCompleted() |
4360 | { | 4364 | { |
4361 | int result = KMessageBox::warningContinueCancel(this, | 4365 | int result = KMessageBox::warningContinueCancel(this, |
4362 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4366 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4363 | 4367 | ||
4364 | if (result == KMessageBox::Continue) { | 4368 | if (result == KMessageBox::Continue) { |
4365 | 4369 | ||
4366 | QPtrList<Todo> todoCal; | 4370 | QPtrList<Todo> todoCal; |
4367 | QPtrList<Todo> rootTodos; | 4371 | QPtrList<Todo> rootTodos; |
4368 | //QPtrList<Incidence> rel; | 4372 | //QPtrList<Incidence> rel; |
4369 | Todo *aTodo;//, *rTodo; | 4373 | Todo *aTodo;//, *rTodo; |
4370 | Incidence *rIncidence; | 4374 | Incidence *rIncidence; |
4371 | bool childDelete = false; | 4375 | bool childDelete = false; |
4372 | bool deletedOne = true; | 4376 | bool deletedOne = true; |
4373 | todoCal = calendar()->todos(); | 4377 | todoCal = calendar()->todos(); |
4374 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4378 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4375 | if ( !aTodo->relatedTo() ) | 4379 | if ( !aTodo->relatedTo() ) |
4376 | rootTodos.append( aTodo ); | 4380 | rootTodos.append( aTodo ); |
4377 | } | 4381 | } |
4378 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4382 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4379 | removeCompletedSubTodos( aTodo ); | 4383 | removeCompletedSubTodos( aTodo ); |
4380 | } | 4384 | } |
4381 | 4385 | ||
4382 | updateView(); | 4386 | updateView(); |
4383 | } | 4387 | } |
4384 | } | 4388 | } |
4385 | 4389 | ||
4386 | void CalendarView::slotCalendarChanged() | 4390 | void CalendarView::slotCalendarChanged() |
4387 | { | 4391 | { |
4388 | ; | 4392 | ; |
4389 | } | 4393 | } |
4390 | 4394 | ||
4391 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4395 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4392 | { | 4396 | { |
4393 | //qDebug(" alendarView::keyPressEvent "); | 4397 | //qDebug(" alendarView::keyPressEvent "); |
4394 | e->ignore(); | 4398 | e->ignore(); |
4395 | } | 4399 | } |
4396 | 4400 | ||
4397 | 4401 | ||
4398 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4402 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4399 | { | 4403 | { |
4400 | // mSyncManager = manager; | 4404 | // mSyncManager = manager; |
4401 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4405 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4402 | qDebug("KO: SyncKDE request detected!"); | 4406 | qDebug("KO: SyncKDE request detected!"); |
4403 | } | 4407 | } |
4404 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4408 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4405 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4409 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4406 | return syncCalendar( filename, mode ); | 4410 | return syncCalendar( filename, mode ); |
4407 | } | 4411 | } |
4408 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4412 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4409 | { | 4413 | { |
4410 | //mSyncManager = manager; | 4414 | //mSyncManager = manager; |
4411 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4415 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4412 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4416 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4413 | if ( resource == "sharp" ) | 4417 | if ( resource == "sharp" ) |
4414 | syncExternal( 0 ); | 4418 | syncExternal( 0 ); |
4415 | if ( resource == "phone" ) | 4419 | if ( resource == "phone" ) |
4416 | syncExternal( 1 ); | 4420 | syncExternal( 1 ); |
4417 | // pending setmodified | 4421 | // pending setmodified |
4418 | return true; | 4422 | return true; |
4419 | } | 4423 | } |
4420 | void CalendarView::setSyncManager(KSyncManager* manager) | 4424 | void CalendarView::setSyncManager(KSyncManager* manager) |
4421 | { | 4425 | { |
4422 | mSyncManager = manager; | 4426 | mSyncManager = manager; |
4423 | } | 4427 | } |
4424 | 4428 | ||
4425 | void CalendarView::removeSyncInfo( QString syncProfile) | 4429 | void CalendarView::removeSyncInfo( QString syncProfile) |
4426 | { | 4430 | { |
4427 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4431 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4428 | mCalendar->removeSyncInfo( syncProfile ); | 4432 | mCalendar->removeSyncInfo( syncProfile ); |
4429 | 4433 | ||
4430 | } | 4434 | } |
4431 | 4435 | ||
4432 | void CalendarView::undo_delete() | 4436 | void CalendarView::undo_delete() |
4433 | { | 4437 | { |
4434 | //qDebug("undo_delete() "); | 4438 | //qDebug("undo_delete() "); |
4435 | Incidence* undo = mCalendar->undoIncidence(); | 4439 | Incidence* undo = mCalendar->undoIncidence(); |
4436 | if ( !undo ) { | 4440 | if ( !undo ) { |
4437 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4441 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4438 | i18n("KO/Pi")); | 4442 | i18n("KO/Pi")); |
4439 | return; | 4443 | return; |
4440 | } | 4444 | } |
4441 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4445 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4442 | i18n("\nAre you sure you want\nto restore this?"), | 4446 | i18n("\nAre you sure you want\nto restore this?"), |
4443 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4447 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4444 | mCalendar->undoDeleteIncidence(); | 4448 | mCalendar->undoDeleteIncidence(); |
4445 | updateView(); | 4449 | updateView(); |
4446 | } | 4450 | } |
4447 | } | 4451 | } |
4448 | 4452 | ||
4449 | void CalendarView::slotViewerClosed() | 4453 | void CalendarView::slotViewerClosed() |
4450 | { | 4454 | { |
4451 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4455 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4452 | } | 4456 | } |
4453 | 4457 | ||
4454 | void CalendarView::resetFocus() | 4458 | void CalendarView::resetFocus() |
4455 | { | 4459 | { |
4456 | if ( mViewerCallerIsSearchDialog ) { | 4460 | if ( mViewerCallerIsSearchDialog ) { |
4457 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4461 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4458 | mDialogManager->getSearchDialog()->raise(); | 4462 | mDialogManager->getSearchDialog()->raise(); |
4459 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4463 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4460 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4464 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4461 | } else | 4465 | } else |
4462 | mViewerCallerIsSearchDialog = false; | 4466 | mViewerCallerIsSearchDialog = false; |
4463 | } | 4467 | } |
4464 | if ( !mViewerCallerIsSearchDialog ) { | 4468 | if ( !mViewerCallerIsSearchDialog ) { |
4465 | //mViewManager->currentView()->setFocus(); | 4469 | //mViewManager->currentView()->setFocus(); |
4466 | //qDebug("sssssssssssssssset focus "); | 4470 | //qDebug("sssssssssssssssset focus "); |
4467 | topLevelWidget()->raise(); | 4471 | topLevelWidget()->raise(); |
4468 | setActiveWindow(); | 4472 | setActiveWindow(); |
4469 | //setFocus(); | 4473 | //setFocus(); |
4470 | } | 4474 | } |
4471 | mViewerCallerIsSearchDialog = false; | 4475 | mViewerCallerIsSearchDialog = false; |
4472 | } | 4476 | } |
4473 | 4477 | ||
4474 | void CalendarView::showNextAlarms() | 4478 | void CalendarView::showNextAlarms() |
4475 | { | 4479 | { |
4476 | QString message; | 4480 | QString message; |
4477 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4481 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4478 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4482 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4479 | QString sum = mCalendar->nextSummary(); | 4483 | QString sum = mCalendar->nextSummary(); |
4480 | QDateTime nextA = mNextAlarmDateTime; | 4484 | QDateTime nextA = mNextAlarmDateTime; |
4481 | QDateTime cur = QDateTime::currentDateTime(); | 4485 | QDateTime cur = QDateTime::currentDateTime(); |
4482 | int secs = cur.secsTo( nextA ); | 4486 | int secs = cur.secsTo( nextA ); |
4483 | int min = secs /60; | 4487 | int min = secs /60; |
4484 | int hours = min /60; | 4488 | int hours = min /60; |
4485 | min = min % 60; | 4489 | min = min % 60; |
4486 | int days = hours /24; | 4490 | int days = hours /24; |
4487 | hours = hours % 24; | 4491 | hours = hours % 24; |
4488 | 4492 | ||
4489 | //message = i18n("The next alarm is in:\n"); | 4493 | //message = i18n("The next alarm is in:\n"); |
4490 | if ( days > 1 ) | 4494 | if ( days > 1 ) |
4491 | message += i18n("%1 days\n").arg( days ); | 4495 | message += i18n("%1 days\n").arg( days ); |
4492 | else if ( days == 1 ) | 4496 | else if ( days == 1 ) |
4493 | message += i18n("1 day\n"); | 4497 | message += i18n("1 day\n"); |
4494 | if ( hours > 1 ) | 4498 | if ( hours > 1 ) |
4495 | message += i18n("%1 hours\n").arg( hours ); | 4499 | message += i18n("%1 hours\n").arg( hours ); |
4496 | else if ( hours == 1 ) | 4500 | else if ( hours == 1 ) |
4497 | message += i18n("1 hour\n"); | 4501 | message += i18n("1 hour\n"); |
4498 | if ( min > 1 ) | 4502 | if ( min > 1 ) |
4499 | message += i18n("%1 minutes\n").arg( min ); | 4503 | message += i18n("%1 minutes\n").arg( min ); |
4500 | else if ( min == 1 ) | 4504 | else if ( min == 1 ) |
4501 | message += i18n("1 minute\n"); | 4505 | message += i18n("1 minute\n"); |
4502 | if ( message.isEmpty() ) | 4506 | if ( message.isEmpty() ) |
4503 | message = i18n("The next alarm is in\nless than one minute!"); | 4507 | message = i18n("The next alarm is in\nless than one minute!"); |
4504 | else | 4508 | else |
4505 | message = i18n("The next alarm is in:\n") + message; | 4509 | message = i18n("The next alarm is in:\n") + message; |
4506 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4510 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4507 | } else { | 4511 | } else { |
4508 | message = i18n("There is no next alarm."); | 4512 | message = i18n("There is no next alarm."); |
4509 | 4513 | ||
4510 | } | 4514 | } |
4511 | #ifdef DESKTOP_VERSION | 4515 | #ifdef DESKTOP_VERSION |
4512 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4516 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4513 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4517 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4514 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4518 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4515 | } | 4519 | } |
4516 | 4520 | ||
4517 | #endif | 4521 | #endif |
4518 | KMessageBox::information( this, message); | 4522 | KMessageBox::information( this, message); |
4519 | } | 4523 | } |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index e4dc751..bb88386 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,424 +1,424 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <libkcal/calfilter.h> | 34 | #include <libkcal/calfilter.h> |
35 | 35 | ||
36 | #include "kofilterview.h" | 36 | #include "kofilterview.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <kcolorbutton.h> | 40 | #include <kcolorbutton.h> |
41 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> |
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 47 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
48 | const char* name,WFlags fl ) | 48 | const char* name,WFlags fl ) |
49 | : KOFilterView_base(parent,name,fl) | 49 | : KOFilterView_base(parent,name,fl) |
50 | { | 50 | { |
51 | mFilters = filterList; | 51 | mFilters = filterList; |
52 | 52 | ||
53 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 53 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
54 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 54 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
55 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 55 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
56 | } | 56 | } |
57 | 57 | ||
58 | KOFilterView::~KOFilterView() | 58 | KOFilterView::~KOFilterView() |
59 | { | 59 | { |
60 | // no need to delete child widgets, Qt does it all for us | 60 | // no need to delete child widgets, Qt does it all for us |
61 | } | 61 | } |
62 | 62 | ||
63 | bool KOFilterView::filtersEnabled() | 63 | bool KOFilterView::filtersEnabled() |
64 | { | 64 | { |
65 | return mEnabledCheck->isChecked(); | 65 | return mEnabledCheck->isChecked(); |
66 | } | 66 | } |
67 | 67 | ||
68 | void KOFilterView::setFiltersEnabled(bool set) | 68 | void KOFilterView::setFiltersEnabled(bool set) |
69 | { | 69 | { |
70 | mEnabledCheck->setChecked(set); | 70 | mEnabledCheck->setChecked(set); |
71 | emit filterChanged(); | 71 | emit filterChanged(); |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void KOFilterView::updateFilters() | 75 | void KOFilterView::updateFilters() |
76 | { | 76 | { |
77 | mSelectionCombo->clear(); | 77 | mSelectionCombo->clear(); |
78 | 78 | ||
79 | CalFilter *filter = mFilters->first(); | 79 | CalFilter *filter = mFilters->first(); |
80 | while(filter) { | 80 | while(filter) { |
81 | mSelectionCombo->insertItem(filter->name()); | 81 | mSelectionCombo->insertItem(filter->name()); |
82 | filter = mFilters->next(); | 82 | filter = mFilters->next(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | CalFilter *KOFilterView::selectedFilter() | 86 | CalFilter *KOFilterView::selectedFilter() |
87 | { | 87 | { |
88 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 88 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
89 | return f; | 89 | return f; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KOFilterView::setSelectedFilter(QString filterName) | 92 | void KOFilterView::setSelectedFilter(QString filterName) |
93 | { | 93 | { |
94 | int filter_num = mSelectionCombo->count(); | 94 | int filter_num = mSelectionCombo->count(); |
95 | int i; | 95 | int i; |
96 | for (i=0;i<filter_num;i++) { | 96 | for (i=0;i<filter_num;i++) { |
97 | if (mSelectionCombo->text(i)==filterName) | 97 | if (mSelectionCombo->text(i)==filterName) |
98 | mSelectionCombo->setCurrentItem(i); | 98 | mSelectionCombo->setCurrentItem(i); |
99 | } | 99 | } |
100 | emit filterChanged(); | 100 | emit filterChanged(); |
101 | } | 101 | } |
102 | void KOFilterView::setSelectedFilter( int fil ) | 102 | void KOFilterView::setSelectedFilter( int fil ) |
103 | { | 103 | { |
104 | if ( fil >= mSelectionCombo->count() ) | 104 | if ( fil >= mSelectionCombo->count() ) |
105 | return; | 105 | return; |
106 | mSelectionCombo->setCurrentItem( fil ); | 106 | mSelectionCombo->setCurrentItem( fil ); |
107 | emit filterChanged(); | 107 | emit filterChanged(); |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | KOCalEditView::KOCalEditView(QWidget* parent, | 112 | KOCalEditView::KOCalEditView(QWidget* parent, |
113 | const char* name ) | 113 | const char* name ) |
114 | : QScrollView(parent,name) | 114 | : QScrollView(parent,name) |
115 | { | 115 | { |
116 | mw = 0; | 116 | mw = 0; |
117 | setResizePolicy( AutoOneFit ); | 117 | setResizePolicy( AutoOneFit ); |
118 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); | 118 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); |
119 | setLineWidth ( 1 ); | 119 | setLineWidth ( 1 ); |
120 | setMidLineWidth ( 1 ); | 120 | setMidLineWidth ( 1 ); |
121 | setFocusPolicy(NoFocus); | 121 | setFocusPolicy(NoFocus); |
122 | } | 122 | } |
123 | 123 | ||
124 | KOCalEditView::~KOCalEditView() | 124 | KOCalEditView::~KOCalEditView() |
125 | { | 125 | { |
126 | // no need to delete child widgets, Qt does it all for us | 126 | // no need to delete child widgets, Qt does it all for us |
127 | } | 127 | } |
128 | void KOCalEditView::selectCal(int id ,bool b) | 128 | void KOCalEditView::selectCal(int id ,bool b) |
129 | { | 129 | { |
130 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; | 130 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; |
131 | emit calendarEnabled ( id, b ); | 131 | emit calendarEnabled ( id, b ); |
132 | emit needsUpdate(); | 132 | emit needsUpdate(); |
133 | 133 | ||
134 | } | 134 | } |
135 | void KOCalEditView::selectStdCal( int id, bool b ) | 135 | void KOCalEditView::selectStdCal( int id, bool b ) |
136 | { | 136 | { |
137 | 137 | ||
138 | if ( !b ) { | 138 | if ( !b ) { |
139 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); | 139 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); |
140 | if ( it ) { | 140 | if ( it ) { |
141 | it->blockSignals( true ); | 141 | it->blockSignals( true ); |
142 | it->setChecked( true ); | 142 | it->setChecked( true ); |
143 | it->blockSignals( false ); | 143 | it->blockSignals( false ); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | return; | 146 | return; |
147 | } | 147 | } |
148 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); | 148 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); |
149 | KOCalCheckButton* it = mStdandardB.first(); | 149 | KOCalCheckButton* it = mStdandardB.first(); |
150 | while ( it ) { | 150 | while ( it ) { |
151 | if ( it->isChecked() ) { | 151 | if ( it->isChecked() ) { |
152 | if ( it != sen ) { | 152 | if ( it != sen ) { |
153 | it->blockSignals( true ); | 153 | it->blockSignals( true ); |
154 | it->setChecked( false ); | 154 | it->setChecked( false ); |
155 | it->blockSignals( false ); | 155 | it->blockSignals( false ); |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | it = mStdandardB.next(); | 159 | it = mStdandardB.next(); |
160 | } | 160 | } |
161 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 161 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
162 | while ( kkf ) { | 162 | while ( kkf ) { |
163 | kkf->isStandard = false; | 163 | kkf->isStandard = false; |
164 | kkf = KOPrefs::instance()->mCalendars.next(); | 164 | kkf = KOPrefs::instance()->mCalendars.next(); |
165 | } | 165 | } |
166 | KOPrefs::instance()->getCalendar( id )->isStandard = true; | 166 | KOPrefs::instance()->getCalendar( id )->isStandard = true; |
167 | emit setCalendarDefault ( id ); | 167 | emit setCalendarDefault ( id ); |
168 | } | 168 | } |
169 | 169 | ||
170 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 170 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
171 | { | 171 | { |
172 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 172 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
173 | emit alarmEnabled ( id , b ); | 173 | emit alarmEnabled ( id , b ); |
174 | emit needsUpdate(); | 174 | emit needsUpdate(); |
175 | } | 175 | } |
176 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 176 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
177 | { | 177 | { |
178 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 178 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
179 | emit calendarReadonly ( id , b ); | 179 | emit calendarReadonly ( id , b ); |
180 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { | 180 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { |
181 | KOPrefs::instance()->getCalendar( id )->isStandard = false; | 181 | KOPrefs::instance()->getCalendar( id )->isStandard = false; |
182 | KOPrefs::instance()->getCalendar( 1 )->isStandard = true; | 182 | KOPrefs::instance()->getCalendar( 1 )->isStandard = true; |
183 | emit setCalendarDefault ( 1 ); | 183 | emit setCalendarDefault ( 1 ); |
184 | } | 184 | } |
185 | emit needsUpdate(); | 185 | emit needsUpdate(); |
186 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 186 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
187 | 187 | ||
188 | } | 188 | } |
189 | void KOCalEditView::setColor( const QColor& c, int id ) | 189 | void KOCalEditView::setColor( const QColor& c, int id ) |
190 | { | 190 | { |
191 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 191 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
192 | emit needsUpdate(); | 192 | emit needsUpdate(); |
193 | } | 193 | } |
194 | void KOCalEditView::deleteCal( int id ) | 194 | void KOCalEditView::deleteCal( int id ) |
195 | { | 195 | { |
196 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 196 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
197 | QString name = kkf->mName; | 197 | QString name = kkf->mName; |
198 | QString file = kkf->mFileName; | 198 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
199 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 199 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
200 | if ( kkf->isStandard ) | 200 | if ( kkf->isStandard ) |
201 | selectStdCal( 1, true ); | 201 | selectStdCal( 1, true ); |
202 | emit removeCalendar ( id ); | 202 | emit removeCalendar ( id ); |
203 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 203 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
204 | emit needsUpdate(); | 204 | emit needsUpdate(); |
205 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 205 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
206 | } | 206 | } |
207 | void KOCalEditView::infoCal( int id ) | 207 | void KOCalEditView::infoCal( int id ) |
208 | { | 208 | { |
209 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 209 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
210 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; | 210 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); |
211 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { | 211 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
212 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { | 212 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { |
213 | emit calendarAdded( id ); | 213 | emit calendarAdded( id ); |
214 | emit needsUpdate(); | 214 | emit needsUpdate(); |
215 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 215 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | else | 218 | else |
219 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 219 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); |
220 | } | 220 | } |
221 | void KOCalEditView::readConfig() | 221 | void KOCalEditView::readConfig() |
222 | { | 222 | { |
223 | 223 | ||
224 | mStdandardB.clear(); | 224 | mStdandardB.clear(); |
225 | mEnabledB.clear(); | 225 | mEnabledB.clear(); |
226 | mAlarmB.clear(); | 226 | mAlarmB.clear(); |
227 | mROB.clear(); | 227 | mROB.clear(); |
228 | 228 | ||
229 | if ( mw ) delete mw; | 229 | if ( mw ) delete mw; |
230 | mw = new QWidget ( viewport() ); | 230 | mw = new QWidget ( viewport() ); |
231 | addChild(mw); | 231 | addChild(mw); |
232 | 232 | ||
233 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 233 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
234 | mainLayout->setMargin( 3); | 234 | mainLayout->setMargin( 3); |
235 | mainLayout->setSpacing( 2); | 235 | mainLayout->setSpacing( 2); |
236 | QPushButton * addBut = new QPushButton ( mw ); | 236 | QPushButton * addBut = new QPushButton ( mw ); |
237 | addBut->setFocusPolicy(NoFocus); | 237 | addBut->setFocusPolicy(NoFocus); |
238 | mainLayout->addWidget( addBut,0,0 ); | 238 | mainLayout->addWidget( addBut,0,0 ); |
239 | addBut->setPixmap ( SmallIcon("plus")); | 239 | addBut->setPixmap ( SmallIcon("plus")); |
240 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 240 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
241 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 241 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
242 | 242 | ||
243 | addBut = new QPushButton ( mw ); | 243 | addBut = new QPushButton ( mw ); |
244 | addBut->setFocusPolicy(NoFocus); | 244 | addBut->setFocusPolicy(NoFocus); |
245 | mainLayout->addWidget( addBut,0,1 ); | 245 | mainLayout->addWidget( addBut,0,1 ); |
246 | addBut->setPixmap ( SmallIcon("eye")); | 246 | addBut->setPixmap ( SmallIcon("eye")); |
247 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 247 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
248 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 248 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
249 | 249 | ||
250 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); | 250 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); |
251 | mainLayout->addWidget( lab,0,2 ); | 251 | mainLayout->addWidget( lab,0,2 ); |
252 | lab = new QLabel ( i18n(" "), mw ); | 252 | lab = new QLabel ( i18n(" "), mw ); |
253 | mainLayout->addWidget( lab,0,3 ); | 253 | mainLayout->addWidget( lab,0,3 ); |
254 | lab->setFixedWidth( 6 ); | 254 | lab->setFixedWidth( 6 ); |
255 | addBut = new QPushButton ( mw ); | 255 | addBut = new QPushButton ( mw ); |
256 | addBut->setFocusPolicy(NoFocus); | 256 | addBut->setFocusPolicy(NoFocus); |
257 | mainLayout->addWidget( addBut,0,4 ); | 257 | mainLayout->addWidget( addBut,0,4 ); |
258 | addBut->setPixmap ( SmallIcon("bell")); | 258 | addBut->setPixmap ( SmallIcon("bell")); |
259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
260 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 260 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
261 | 261 | ||
262 | addBut = new QPushButton ( mw ); | 262 | addBut = new QPushButton ( mw ); |
263 | addBut->setFocusPolicy(NoFocus); | 263 | addBut->setFocusPolicy(NoFocus); |
264 | mainLayout->addWidget( addBut,0,5 ); | 264 | mainLayout->addWidget( addBut,0,5 ); |
265 | addBut->setPixmap ( SmallIcon("pencil")); | 265 | addBut->setPixmap ( SmallIcon("pencil")); |
266 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 266 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
267 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 267 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
268 | 268 | ||
269 | lab = new QLabel ( i18n(" Color "), mw ); | 269 | lab = new QLabel ( i18n(" Color "), mw ); |
270 | mainLayout->addWidget( lab,0,6 ); | 270 | mainLayout->addWidget( lab,0,6 ); |
271 | #if 0 | 271 | #if 0 |
272 | addBut = new QPushButton ( mw ); | 272 | addBut = new QPushButton ( mw ); |
273 | mainLayout->addWidget( addBut,0,6 ); | 273 | mainLayout->addWidget( addBut,0,6 ); |
274 | addBut->setPixmap ( SmallIcon("minus")); | 274 | addBut->setPixmap ( SmallIcon("minus")); |
275 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); | 275 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); |
276 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 276 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | 279 | ||
280 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 280 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
281 | int row = 1; | 281 | int row = 1; |
282 | while ( kkf ) { | 282 | while ( kkf ) { |
283 | int iii = 0; | 283 | int iii = 0; |
284 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 284 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
285 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); | 285 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); |
286 | cb->setChecked( kkf->isStandard ); | 286 | cb->setChecked( kkf->isStandard ); |
287 | cb->setNum( kkf->mCalNumber ); | 287 | cb->setNum( kkf->mCalNumber ); |
288 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); | 288 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); |
289 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 289 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
290 | cb->setEnabled( false ); | 290 | cb->setEnabled( false ); |
291 | cb = new KOCalCheckButton( mw ); | 291 | cb = new KOCalCheckButton( mw ); |
292 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); | 292 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); |
293 | cb->setChecked( kkf->isEnabled ); | 293 | cb->setChecked( kkf->isEnabled ); |
294 | cb->setNum( kkf->mCalNumber ); | 294 | cb->setNum( kkf->mCalNumber ); |
295 | if ( kkf->mErrorOnLoad ) | 295 | if ( kkf->mErrorOnLoad ) |
296 | cb->setEnabled( false ); | 296 | cb->setEnabled( false ); |
297 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 297 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
298 | KOCalButton* name = new KOCalButton( mw ); | 298 | KOCalButton* name = new KOCalButton( mw ); |
299 | name->setNum( kkf->mCalNumber ); | 299 | name->setNum( kkf->mCalNumber ); |
300 | name->setText( kkf->mName ); | 300 | name->setText( kkf->mName ); |
301 | mainLayout->addWidget( name,row,++iii ); | 301 | mainLayout->addWidget( name,row,++iii ); |
302 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 302 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
303 | lab = new QLabel ( i18n(" "), mw ); | 303 | lab = new QLabel ( i18n(" "), mw ); |
304 | mainLayout->addWidget( lab,row,++iii ); | 304 | mainLayout->addWidget( lab,row,++iii ); |
305 | cb = new KOCalCheckButton( mw ); | 305 | cb = new KOCalCheckButton( mw ); |
306 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); | 306 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); |
307 | cb->setChecked( kkf->isAlarmEnabled ); | 307 | cb->setChecked( kkf->isAlarmEnabled ); |
308 | cb->setNum( kkf->mCalNumber ); | 308 | cb->setNum( kkf->mCalNumber ); |
309 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 309 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
310 | if ( kkf->mErrorOnLoad ) | 310 | if ( kkf->mErrorOnLoad ) |
311 | cb->setEnabled( false ); | 311 | cb->setEnabled( false ); |
312 | cb = new KOCalCheckButton( mw ); | 312 | cb = new KOCalCheckButton( mw ); |
313 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); | 313 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); |
314 | cb->setChecked( kkf->isReadOnly ); | 314 | cb->setChecked( kkf->isReadOnly ); |
315 | cb->setNum( kkf->mCalNumber ); | 315 | cb->setNum( kkf->mCalNumber ); |
316 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 316 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
317 | if ( kkf->mErrorOnLoad ) | 317 | if ( kkf->mErrorOnLoad ) |
318 | cb->setEnabled( false ); | 318 | cb->setEnabled( false ); |
319 | if ( row > 1) { | 319 | if ( row > 1) { |
320 | KColorButton *colb = new KColorButton( mw ); | 320 | KColorButton *colb = new KColorButton( mw ); |
321 | mainLayout->addWidget( colb,row,++iii ); | 321 | mainLayout->addWidget( colb,row,++iii ); |
322 | colb->setID( kkf->mCalNumber ); | 322 | colb->setID( kkf->mCalNumber ); |
323 | colb->setColor( kkf->mDefaultColor ); | 323 | colb->setColor( kkf->mDefaultColor ); |
324 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 324 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
325 | KOCalButton* calb = new KOCalButton( mw ); | 325 | KOCalButton* calb = new KOCalButton( mw ); |
326 | mainLayout->addWidget( calb,row,++iii ); | 326 | mainLayout->addWidget( calb,row,++iii ); |
327 | calb->setNum( kkf->mCalNumber ); | 327 | calb->setNum( kkf->mCalNumber ); |
328 | calb->setPixmap ( SmallIcon("minus")); | 328 | calb->setPixmap ( SmallIcon("minus")); |
329 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 329 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
330 | int hei = calb->sizeHint().height(); | 330 | int hei = calb->sizeHint().height(); |
331 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 331 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
332 | } | 332 | } |
333 | ++row; | 333 | ++row; |
334 | kkf = KOPrefs::instance()->mCalendars.next(); | 334 | kkf = KOPrefs::instance()->mCalendars.next(); |
335 | } | 335 | } |
336 | lab = new QLabel ( "", mw ); | 336 | lab = new QLabel ( "", mw ); |
337 | mainLayout->addWidget( lab,row,0 ); | 337 | mainLayout->addWidget( lab,row,0 ); |
338 | mw->show(); | 338 | mw->show(); |
339 | 339 | ||
340 | } | 340 | } |
341 | void KOCalEditView::addCal() | 341 | void KOCalEditView::addCal() |
342 | { | 342 | { |
343 | bool tryagain = true; | 343 | bool tryagain = true; |
344 | QString name, file; | 344 | QString name, file; |
345 | while ( tryagain ) { | 345 | while ( tryagain ) { |
346 | KONewCalPrefs prefs ( this ); | 346 | KONewCalPrefs prefs ( this ); |
347 | prefs.nameE->setText( name ); | 347 | prefs.nameE->setText( name ); |
348 | prefs.url->setURL( file ); | 348 | prefs.url->setURL( file ); |
349 | if ( ! prefs.exec() ) | 349 | if ( ! prefs.exec() ) |
350 | return; | 350 | return; |
351 | name = prefs.calName(); | 351 | name = prefs.calName(); |
352 | file = prefs.calFileName(); | 352 | file = prefs.calFileName(); |
353 | tryagain = false; | 353 | tryagain = false; |
354 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 354 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
355 | while ( kkf ) { | 355 | while ( kkf ) { |
356 | if ( kkf->mName == name ) { | 356 | if ( kkf->mName == name ) { |
357 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); | 357 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
358 | name = ""; | 358 | name = ""; |
359 | tryagain = true; | 359 | tryagain = true; |
360 | break; | 360 | break; |
361 | } | 361 | } |
362 | if ( kkf->mFileName == file ) { | 362 | if ( kkf->mFileName == file ) { |
363 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( file) ); | 363 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); |
364 | tryagain = true; | 364 | tryagain = true; |
365 | file = ""; | 365 | file = ""; |
366 | break; | 366 | break; |
367 | } | 367 | } |
368 | kkf = KOPrefs::instance()->mCalendars.next(); | 368 | kkf = KOPrefs::instance()->mCalendars.next(); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | QFileInfo fi ( file ); | 371 | QFileInfo fi ( file ); |
372 | if (!fi.exists() ) { | 372 | if (!fi.exists() ) { |
373 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) | 373 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) |
374 | return; | 374 | return; |
375 | QFile fileIn( file ); | 375 | QFile fileIn( file ); |
376 | if (!fileIn.open( IO_WriteOnly ) ) { | 376 | if (!fileIn.open( IO_WriteOnly ) ) { |
377 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); | 377 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | QTextStream tsIn( &fileIn ); | 380 | QTextStream tsIn( &fileIn ); |
381 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 381 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
382 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 382 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
383 | fileIn.close(); | 383 | fileIn.close(); |
384 | } | 384 | } |
385 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 385 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
386 | kkf->mName = name; | 386 | kkf->mName = name; |
387 | kkf->mFileName = file; | 387 | kkf->mFileName = file; |
388 | emit calendarAdded( kkf->mCalNumber ); | 388 | emit calendarAdded( kkf->mCalNumber ); |
389 | emit needsUpdate(); | 389 | emit needsUpdate(); |
390 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 390 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
391 | } | 391 | } |
392 | void KOCalEditView::enableAll() | 392 | void KOCalEditView::enableAll() |
393 | { | 393 | { |
394 | toggleList( mEnabledB ); | 394 | toggleList( mEnabledB ); |
395 | } | 395 | } |
396 | void KOCalEditView::enableAlarm() | 396 | void KOCalEditView::enableAlarm() |
397 | { | 397 | { |
398 | toggleList( mAlarmB ); | 398 | toggleList( mAlarmB ); |
399 | } | 399 | } |
400 | void KOCalEditView::disableRO() | 400 | void KOCalEditView::disableRO() |
401 | { | 401 | { |
402 | toggleList( mROB ); | 402 | toggleList( mROB ); |
403 | } | 403 | } |
404 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) | 404 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) |
405 | { | 405 | { |
406 | bool dis = false; | 406 | bool dis = false; |
407 | KOCalCheckButton* it = list.first(); | 407 | KOCalCheckButton* it = list.first(); |
408 | while ( it ) { | 408 | while ( it ) { |
409 | if ( !it->isChecked() ) { | 409 | if ( !it->isChecked() ) { |
410 | dis = true; | 410 | dis = true; |
411 | break; | 411 | break; |
412 | } | 412 | } |
413 | it = list.next(); | 413 | it = list.next(); |
414 | } | 414 | } |
415 | it = list.first(); | 415 | it = list.first(); |
416 | while ( it ) { | 416 | while ( it ) { |
417 | it->setChecked(dis); | 417 | it->setChecked(dis); |
418 | it = list.next(); | 418 | it = list.next(); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | void KOCalEditView::deleteAll() | 421 | void KOCalEditView::deleteAll() |
422 | { | 422 | { |
423 | qDebug("delteAll"); | 423 | qDebug("delteAll"); |
424 | } | 424 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 13e88ef..926a136 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1542 +1,1526 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
33 | 33 | ||
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kdateedit.h> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 66 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 67 | QDialog( parent, name, true ) |
68 | { | 68 | { |
69 | mTodo = todo; | 69 | mTodo = todo; |
70 | setCaption( i18n("Stop todo") ); | 70 | setCaption( i18n("Stop todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 71 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); | 74 | QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); |
75 | lay->addWidget( lab ); | 75 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignHCenter ); | 76 | lab->setAlignment( AlignHCenter ); |
77 | lab = new QLabel( i18n("Additional Comment:"), this ); | 77 | lab = new QLabel( i18n("Additional Comment:"), this ); |
78 | lay->addWidget( lab ); | 78 | lay->addWidget( lab ); |
79 | mComment = new QLineEdit( this ); | 79 | mComment = new QLineEdit( this ); |
80 | lay->addWidget( mComment ); | 80 | lay->addWidget( mComment ); |
81 | QHBox * start = new QHBox ( this ); | 81 | QHBox * start = new QHBox ( this ); |
82 | lay->addWidget( start ); | 82 | lay->addWidget( start ); |
83 | lab = new QLabel( i18n("Start:"), start ); | 83 | lab = new QLabel( i18n("Start:"), start ); |
84 | QHBox * end = new QHBox ( this ); | 84 | QHBox * end = new QHBox ( this ); |
85 | lay->addWidget( end ); | 85 | lay->addWidget( end ); |
86 | lab = new QLabel( i18n("End:"), end ); | 86 | lab = new QLabel( i18n("End:"), end ); |
87 | sde = new KDateEdit( start ); | 87 | sde = new KDateEdit( start ); |
88 | ste = new KOTimeEdit( start ); | 88 | ste = new KOTimeEdit( start ); |
89 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 89 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
90 | ede = new KDateEdit( end ); | 90 | ede = new KDateEdit( end ); |
91 | ete = new KOTimeEdit(end ); | 91 | ete = new KOTimeEdit(end ); |
92 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 92 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
93 | sde->setDate( mTodo->runStart().date() ); | 93 | sde->setDate( mTodo->runStart().date() ); |
94 | ste->setTime( mTodo->runStart().time() ); | 94 | ste->setTime( mTodo->runStart().time() ); |
95 | ede->setDate( QDate::currentDate()); | 95 | ede->setDate( QDate::currentDate()); |
96 | ete->setTime( QTime::currentTime() ); | 96 | ete->setTime( QTime::currentTime() ); |
97 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 97 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
98 | lay->addWidget( ok ); | 98 | lay->addWidget( ok ); |
99 | ok->setDefault( true ); | ||
99 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 100 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
100 | lay->addWidget( cancel ); | 101 | lay->addWidget( cancel ); |
101 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 102 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
102 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 103 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
103 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 104 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
104 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 105 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
105 | lay->addWidget( ok ); | 106 | lay->addWidget( ok ); |
106 | if (QApplication::desktop()->width() < 320 ) | 107 | if (QApplication::desktop()->width() < 320 ) |
107 | resize( 240, 200 ); | 108 | resize( 240, 200 ); |
108 | else | 109 | else |
109 | resize( 320, 200 ); | 110 | resize( 320, 200 ); |
110 | 111 | ||
111 | } | 112 | } |
112 | 113 | ||
113 | void KOStopTodoPrefs::accept() | 114 | void KOStopTodoPrefs::accept() |
114 | { | 115 | { |
115 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 116 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
116 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 117 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
117 | if ( start > stop ) { | 118 | if ( start > stop ) { |
118 | KMessageBox::sorry(this, | 119 | KMessageBox::sorry(this, |
119 | i18n("The start time is\nafter the end time!"), | 120 | i18n("The start time is\nafter the end time!"), |
120 | i18n("Time mismatch!")); | 121 | i18n("Time mismatch!")); |
121 | return; | 122 | return; |
122 | } | 123 | } |
123 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 124 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
124 | QDialog::accept(); | 125 | QDialog::accept(); |
125 | } | 126 | } |
126 | void KOStopTodoPrefs::doNotSave() | 127 | void KOStopTodoPrefs::doNotSave() |
127 | { | 128 | { |
128 | int result = KMessageBox::warningContinueCancel(this, | 129 | int result = KMessageBox::warningContinueCancel(this, |
129 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); | 130 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); |
130 | if (result != KMessageBox::Continue) return; | 131 | if (result != KMessageBox::Continue) return; |
131 | mTodo->stopRunning(); | 132 | mTodo->stopRunning(); |
132 | QDialog::accept(); | 133 | QDialog::accept(); |
133 | } | 134 | } |
134 | 135 | ||
135 | 136 | ||
136 | class KOTodoViewWhatsThis :public QWhatsThis | 137 | class KOTodoViewWhatsThis :public QWhatsThis |
137 | { | 138 | { |
138 | public: | 139 | public: |
139 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 140 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
140 | 141 | ||
141 | protected: | 142 | protected: |
142 | virtual QString text( const QPoint& p) | 143 | virtual QString text( const QPoint& p) |
143 | { | 144 | { |
144 | return _view->getWhatsThisText(p) ; | 145 | return _view->getWhatsThisText(p) ; |
145 | } | 146 | } |
146 | private: | 147 | private: |
147 | QWidget* _wid; | 148 | QWidget* _wid; |
148 | KOTodoView * _view; | 149 | KOTodoView * _view; |
149 | }; | 150 | }; |
150 | 151 | ||
151 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 152 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
152 | const char *name) : | 153 | const char *name) : |
153 | KListView(parent,name) | 154 | KListView(parent,name) |
154 | { | 155 | { |
155 | mName = QString ( name ); | 156 | mName = QString ( name ); |
156 | mCalendar = calendar; | 157 | mCalendar = calendar; |
157 | #ifndef DESKTOP_VERSION | 158 | #ifndef DESKTOP_VERSION |
158 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 159 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
159 | #endif | 160 | #endif |
160 | mOldCurrent = 0; | 161 | mOldCurrent = 0; |
161 | mMousePressed = false; | 162 | mMousePressed = false; |
162 | 163 | ||
163 | setAcceptDrops(true); | 164 | setAcceptDrops(true); |
164 | viewport()->setAcceptDrops(true); | 165 | viewport()->setAcceptDrops(true); |
165 | int size = 16; | 166 | int size = 16; |
166 | if (qApp->desktop()->width() < 300 ) | 167 | if (qApp->desktop()->width() < 300 ) |
167 | size = 12; | 168 | size = 12; |
168 | setTreeStepSize( size + 6 ); | 169 | setTreeStepSize( size + 6 ); |
169 | 170 | ||
170 | } | 171 | } |
171 | 172 | ||
172 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 173 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
173 | { | 174 | { |
174 | #ifndef KORG_NODND | 175 | #ifndef KORG_NODND |
175 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 176 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
176 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 177 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
177 | !QTextDrag::canDecode( e ) ) { | 178 | !QTextDrag::canDecode( e ) ) { |
178 | e->ignore(); | 179 | e->ignore(); |
179 | return; | 180 | return; |
180 | } | 181 | } |
181 | 182 | ||
182 | mOldCurrent = currentItem(); | 183 | mOldCurrent = currentItem(); |
183 | #endif | 184 | #endif |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 188 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
188 | { | 189 | { |
189 | #ifndef KORG_NODND | 190 | #ifndef KORG_NODND |
190 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 191 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
191 | 192 | ||
192 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 193 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
193 | !QTextDrag::canDecode( e ) ) { | 194 | !QTextDrag::canDecode( e ) ) { |
194 | e->ignore(); | 195 | e->ignore(); |
195 | return; | 196 | return; |
196 | } | 197 | } |
197 | 198 | ||
198 | e->accept(); | 199 | e->accept(); |
199 | #endif | 200 | #endif |
200 | } | 201 | } |
201 | 202 | ||
202 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 203 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
203 | { | 204 | { |
204 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
205 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
206 | 207 | ||
207 | setCurrentItem(mOldCurrent); | 208 | setCurrentItem(mOldCurrent); |
208 | setSelected(mOldCurrent,true); | 209 | setSelected(mOldCurrent,true); |
209 | #endif | 210 | #endif |
210 | } | 211 | } |
211 | 212 | ||
212 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 213 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
213 | { | 214 | { |
214 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
215 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
216 | 217 | ||
217 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 218 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
218 | !QTextDrag::canDecode( e ) ) { | 219 | !QTextDrag::canDecode( e ) ) { |
219 | e->ignore(); | 220 | e->ignore(); |
220 | return; | 221 | return; |
221 | } | 222 | } |
222 | 223 | ||
223 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
224 | Todo *todo = factory.createDropTodo(e); | 225 | Todo *todo = factory.createDropTodo(e); |
225 | 226 | ||
226 | if (todo) { | 227 | if (todo) { |
227 | e->acceptAction(); | 228 | e->acceptAction(); |
228 | 229 | ||
229 | KOTodoViewItem *destination = | 230 | KOTodoViewItem *destination = |
230 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 231 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
231 | Todo *destinationEvent = 0; | 232 | Todo *destinationEvent = 0; |
232 | if (destination) destinationEvent = destination->todo(); | 233 | if (destination) destinationEvent = destination->todo(); |
233 | 234 | ||
234 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 235 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
235 | 236 | ||
236 | if(existingTodo) { | 237 | if(existingTodo) { |
237 | Incidence *to = destinationEvent; | 238 | Incidence *to = destinationEvent; |
238 | while(to) { | 239 | while(to) { |
239 | if (to->uid() == todo->uid()) { | 240 | if (to->uid() == todo->uid()) { |
240 | KMessageBox::sorry(this, | 241 | KMessageBox::sorry(this, |
241 | i18n("Cannot move Todo to itself\nor a child of itself"), | 242 | i18n("Cannot move Todo to itself\nor a child of itself"), |
242 | i18n("Drop Todo")); | 243 | i18n("Drop Todo")); |
243 | delete todo; | 244 | delete todo; |
244 | return; | 245 | return; |
245 | } | 246 | } |
246 | to = to->relatedTo(); | 247 | to = to->relatedTo(); |
247 | } | 248 | } |
248 | internalDrop = true; | 249 | internalDrop = true; |
249 | if ( destinationEvent ) | 250 | if ( destinationEvent ) |
250 | reparentTodoSignal( destinationEvent, existingTodo ); | 251 | reparentTodoSignal( destinationEvent, existingTodo ); |
251 | else | 252 | else |
252 | unparentTodoSignal(existingTodo); | 253 | unparentTodoSignal(existingTodo); |
253 | delete todo; | 254 | delete todo; |
254 | } else { | 255 | } else { |
255 | mCalendar->addTodo(todo); | 256 | mCalendar->addTodo(todo); |
256 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 257 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
257 | if ( destinationEvent ) | 258 | if ( destinationEvent ) |
258 | reparentTodoSignal( destinationEvent, todo ); | 259 | reparentTodoSignal( destinationEvent, todo ); |
259 | } | 260 | } |
260 | } | 261 | } |
261 | else { | 262 | else { |
262 | QString text; | 263 | QString text; |
263 | if (QTextDrag::decode(e,text)) { | 264 | if (QTextDrag::decode(e,text)) { |
264 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 265 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
265 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 266 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
266 | qDebug("Dropped : " + text); | 267 | qDebug("Dropped : " + text); |
267 | QStringList emails = QStringList::split(",",text); | 268 | QStringList emails = QStringList::split(",",text); |
268 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 269 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
269 | int pos = (*it).find("<"); | 270 | int pos = (*it).find("<"); |
270 | QString name = (*it).left(pos); | 271 | QString name = (*it).left(pos); |
271 | QString email = (*it).mid(pos); | 272 | QString email = (*it).mid(pos); |
272 | if (!email.isEmpty() && todoi) { | 273 | if (!email.isEmpty() && todoi) { |
273 | todoi->todo()->addAttendee(new Attendee(name,email)); | 274 | todoi->todo()->addAttendee(new Attendee(name,email)); |
274 | } | 275 | } |
275 | } | 276 | } |
276 | } | 277 | } |
277 | else { | 278 | else { |
278 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 279 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
279 | e->ignore(); | 280 | e->ignore(); |
280 | } | 281 | } |
281 | } | 282 | } |
282 | #endif | 283 | #endif |
283 | } | 284 | } |
284 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 285 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
285 | { | 286 | { |
286 | QListView::wheelEvent (e); | 287 | QListView::wheelEvent (e); |
287 | } | 288 | } |
288 | 289 | ||
289 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 290 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
290 | { | 291 | { |
291 | 292 | ||
292 | QPoint p(contentsToViewport(e->pos())); | 293 | QPoint p(contentsToViewport(e->pos())); |
293 | QListViewItem *i = itemAt(p); | 294 | QListViewItem *i = itemAt(p); |
294 | bool rootClicked = true; | 295 | bool rootClicked = true; |
295 | if (i) { | 296 | if (i) { |
296 | // if the user clicked into the root decoration of the item, don't | 297 | // if the user clicked into the root decoration of the item, don't |
297 | // try to start a drag! | 298 | // try to start a drag! |
298 | int X = p.x(); | 299 | int X = p.x(); |
299 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 300 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
300 | if (X > header()->sectionPos(0) + | 301 | if (X > header()->sectionPos(0) + |
301 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 302 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
302 | itemMargin() +i->height()|| | 303 | itemMargin() +i->height()|| |
303 | X < header()->sectionPos(0)) { | 304 | X < header()->sectionPos(0)) { |
304 | rootClicked = false; | 305 | rootClicked = false; |
305 | } | 306 | } |
306 | } else { | 307 | } else { |
307 | rootClicked = false; | 308 | rootClicked = false; |
308 | } | 309 | } |
309 | #ifndef KORG_NODND | 310 | #ifndef KORG_NODND |
310 | mMousePressed = false; | 311 | mMousePressed = false; |
311 | if (! rootClicked && !( e->button() == RightButton) ) { | 312 | if (! rootClicked && !( e->button() == RightButton) ) { |
312 | mPressPos = e->pos(); | 313 | mPressPos = e->pos(); |
313 | mMousePressed = true; | 314 | mMousePressed = true; |
314 | } else { | 315 | } else { |
315 | mMousePressed = false; | 316 | mMousePressed = false; |
316 | } | 317 | } |
317 | #endif | 318 | #endif |
318 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 319 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
319 | #ifndef DESKTOP_VERSION | 320 | #ifndef DESKTOP_VERSION |
320 | if (!( e->button() == RightButton && rootClicked) ) | 321 | if (!( e->button() == RightButton && rootClicked) ) |
321 | QListView::contentsMousePressEvent(e); | 322 | QListView::contentsMousePressEvent(e); |
322 | #else | 323 | #else |
323 | QListView::contentsMousePressEvent(e); | 324 | QListView::contentsMousePressEvent(e); |
324 | #endif | 325 | #endif |
325 | } | 326 | } |
326 | void KOTodoListView::paintEvent(QPaintEvent* e) | 327 | void KOTodoListView::paintEvent(QPaintEvent* e) |
327 | { | 328 | { |
328 | emit paintNeeded(); | 329 | emit paintNeeded(); |
329 | QListView::paintEvent( e); | 330 | QListView::paintEvent( e); |
330 | } | 331 | } |
331 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 332 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
332 | { | 333 | { |
333 | 334 | ||
334 | #ifndef KORG_NODND | 335 | #ifndef KORG_NODND |
335 | //QListView::contentsMouseMoveEvent(e); | 336 | //QListView::contentsMouseMoveEvent(e); |
336 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 337 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
337 | QApplication::startDragDistance()*3) { | 338 | QApplication::startDragDistance()*3) { |
338 | mMousePressed = false; | 339 | mMousePressed = false; |
339 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 340 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
340 | if (item) { | 341 | if (item) { |
341 | DndFactory factory( mCalendar ); | 342 | DndFactory factory( mCalendar ); |
342 | ICalDrag *vd = factory.createDrag( | 343 | ICalDrag *vd = factory.createDrag( |
343 | ((KOTodoViewItem *)item)->todo(),viewport()); | 344 | ((KOTodoViewItem *)item)->todo(),viewport()); |
344 | internalDrop = false; | 345 | internalDrop = false; |
345 | // we cannot do any senseful here, because the DnD is still broken in Qt | 346 | // we cannot do any senseful here, because the DnD is still broken in Qt |
346 | if (vd->drag()) { | 347 | if (vd->drag()) { |
347 | if ( !internalDrop ) { | 348 | if ( !internalDrop ) { |
348 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 349 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
349 | qDebug("Dnd: External move: Delete drag source "); | 350 | qDebug("Dnd: External move: Delete drag source "); |
350 | } else | 351 | } else |
351 | qDebug("Dnd: Internal move "); | 352 | qDebug("Dnd: Internal move "); |
352 | 353 | ||
353 | } else { | 354 | } else { |
354 | if ( !internalDrop ) { | 355 | if ( !internalDrop ) { |
355 | qDebug("Dnd: External Copy"); | 356 | qDebug("Dnd: External Copy"); |
356 | } else | 357 | } else |
357 | qDebug("DnD: Internal copy: Copy pending"); | 358 | qDebug("DnD: Internal copy: Copy pending"); |
358 | } | 359 | } |
359 | } | 360 | } |
360 | } | 361 | } |
361 | #endif | 362 | #endif |
362 | } | 363 | } |
363 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 364 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
364 | { | 365 | { |
365 | if ( !e->isAutoRepeat() ) { | 366 | if ( !e->isAutoRepeat() ) { |
366 | mFlagKeyPressed = false; | 367 | mFlagKeyPressed = false; |
367 | } | 368 | } |
368 | } | 369 | } |
369 | 370 | ||
370 | 371 | ||
371 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 372 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
372 | { | 373 | { |
373 | qApp->processEvents(); | 374 | qApp->processEvents(); |
374 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 375 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
375 | e->ignore(); | 376 | e->ignore(); |
376 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 377 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
377 | return; | 378 | return; |
378 | } | 379 | } |
379 | if (! e->isAutoRepeat() ) | 380 | if (! e->isAutoRepeat() ) |
380 | mFlagKeyPressed = true; | 381 | mFlagKeyPressed = true; |
381 | QListViewItem* cn; | 382 | QListViewItem* cn; |
382 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 383 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
383 | cn = currentItem(); | 384 | cn = currentItem(); |
384 | if ( cn ) { | 385 | if ( cn ) { |
385 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 386 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
386 | if ( ci ){ | 387 | if ( ci ){ |
387 | if ( e->state() == ShiftButton ) | 388 | if ( e->state() == ShiftButton ) |
388 | ci->setOn( false ); | 389 | ci->setOn( false ); |
389 | else | 390 | else |
390 | ci->setOn( true ); | 391 | ci->setOn( true ); |
391 | cn = cn->itemBelow(); | 392 | cn = cn->itemBelow(); |
392 | if ( cn ) { | 393 | if ( cn ) { |
393 | setCurrentItem ( cn ); | 394 | setCurrentItem ( cn ); |
394 | ensureItemVisible ( cn ); | 395 | ensureItemVisible ( cn ); |
395 | } | 396 | } |
396 | 397 | ||
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | return; | 401 | return; |
401 | } | 402 | } |
402 | 403 | ||
403 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 404 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
404 | switch ( e->key() ) { | 405 | switch ( e->key() ) { |
405 | case Qt::Key_Down: | 406 | case Qt::Key_Down: |
406 | case Qt::Key_Up: | 407 | case Qt::Key_Up: |
407 | QListView::keyPressEvent ( e ); | 408 | QListView::keyPressEvent ( e ); |
408 | break; | 409 | break; |
409 | case Qt::Key_Left: | 410 | case Qt::Key_Left: |
410 | case Qt::Key_Right: | 411 | case Qt::Key_Right: |
411 | QListView::keyPressEvent ( e ); | 412 | QListView::keyPressEvent ( e ); |
412 | e->accept(); | 413 | e->accept(); |
413 | return; | 414 | return; |
414 | break; | 415 | break; |
415 | default: | 416 | default: |
416 | e->ignore(); | 417 | e->ignore(); |
417 | break; | 418 | break; |
418 | } | 419 | } |
419 | return; | 420 | return; |
420 | } | 421 | } |
421 | e->ignore(); | 422 | e->ignore(); |
422 | } | 423 | } |
423 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 424 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
424 | { | 425 | { |
425 | QListView::contentsMouseReleaseEvent(e); | 426 | QListView::contentsMouseReleaseEvent(e); |
426 | mMousePressed = false; | 427 | mMousePressed = false; |
427 | } | 428 | } |
428 | 429 | ||
429 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 430 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
430 | { | 431 | { |
431 | if (!e) return; | 432 | if (!e) return; |
432 | 433 | ||
433 | QPoint vp = contentsToViewport(e->pos()); | 434 | QPoint vp = contentsToViewport(e->pos()); |
434 | 435 | ||
435 | QListViewItem *item = itemAt(vp); | 436 | QListViewItem *item = itemAt(vp); |
436 | 437 | ||
437 | emit double_Clicked(item); | 438 | emit double_Clicked(item); |
438 | if (!item) return; | 439 | if (!item) return; |
439 | 440 | ||
440 | emit doubleClicked(item,vp,0); | 441 | emit doubleClicked(item,vp,0); |
441 | } | 442 | } |
442 | 443 | ||
443 | ///////////////////////////////////////////////////////////////////////////// | 444 | ///////////////////////////////////////////////////////////////////////////// |
444 | 445 | ||
445 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 446 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
446 | QLineEdit(parent) | 447 | QLineEdit(parent) |
447 | { | 448 | { |
448 | setText(i18n("Click to add a new Todo")); | 449 | setText(i18n("Click to add a new Todo")); |
449 | } | 450 | } |
450 | 451 | ||
451 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 452 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
452 | { | 453 | { |
453 | if ( text()==i18n("Click to add a new Todo") ) | 454 | if ( text()==i18n("Click to add a new Todo") ) |
454 | setText(""); | 455 | setText(""); |
455 | QLineEdit::focusInEvent(ev); | 456 | QLineEdit::focusInEvent(ev); |
456 | } | 457 | } |
457 | 458 | ||
458 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 459 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
459 | { | 460 | { |
460 | setText(i18n("Click to add a new Todo")); | 461 | setText(i18n("Click to add a new Todo")); |
461 | QLineEdit::focusOutEvent(ev); | 462 | QLineEdit::focusOutEvent(ev); |
462 | } | 463 | } |
463 | 464 | ||
464 | ///////////////////////////////////////////////////////////////////////////// | 465 | ///////////////////////////////////////////////////////////////////////////// |
465 | 466 | ||
466 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 467 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
467 | KOrg::BaseView(calendar,parent,name) | 468 | KOrg::BaseView(calendar,parent,name) |
468 | { | 469 | { |
469 | mPendingUpdateBeforeRepaint = false; | 470 | mPendingUpdateBeforeRepaint = false; |
470 | isFlatDisplay = false; | 471 | isFlatDisplay = false; |
471 | mNavigator = 0; | 472 | mNavigator = 0; |
472 | QBoxLayout *topLayout = new QVBoxLayout(this); | 473 | QBoxLayout *topLayout = new QVBoxLayout(this); |
473 | mName = QString ( name ); | 474 | mName = QString ( name ); |
474 | mBlockUpdate = false; | 475 | mBlockUpdate = false; |
475 | mQuickAdd = new KOQuickTodo(this); | 476 | mQuickAdd = new KOQuickTodo(this); |
476 | topLayout->addWidget(mQuickAdd); | 477 | topLayout->addWidget(mQuickAdd); |
477 | 478 | ||
478 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 479 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
479 | 480 | ||
480 | mTodoListView = new KOTodoListView(calendar,this, name ); | 481 | mTodoListView = new KOTodoListView(calendar,this, name ); |
481 | topLayout->addWidget(mTodoListView); | 482 | topLayout->addWidget(mTodoListView); |
482 | //mTodoListView->header()->setMaximumHeight(30); | 483 | //mTodoListView->header()->setMaximumHeight(30); |
483 | mTodoListView->setRootIsDecorated(true); | 484 | mTodoListView->setRootIsDecorated(true); |
484 | mTodoListView->setAllColumnsShowFocus(true); | 485 | mTodoListView->setAllColumnsShowFocus(true); |
485 | 486 | ||
486 | mTodoListView->setShowSortIndicator(true); | 487 | mTodoListView->setShowSortIndicator(true); |
487 | 488 | ||
488 | mTodoListView->addColumn(i18n("Todo")); | 489 | mTodoListView->addColumn(i18n("Todo")); |
489 | mTodoListView->addColumn(i18n("Prio")); | 490 | mTodoListView->addColumn(i18n("Prio")); |
490 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 491 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
491 | mTodoListView->addColumn(i18n("Complete")); | 492 | mTodoListView->addColumn(i18n("Complete")); |
492 | mTodoListView->setColumnAlignment(2,AlignCenter); | 493 | mTodoListView->setColumnAlignment(2,AlignCenter); |
493 | 494 | ||
494 | mTodoListView->addColumn(i18n("Due Date")); | 495 | mTodoListView->addColumn(i18n("Due Date")); |
495 | mTodoListView->setColumnAlignment(3,AlignLeft); | 496 | mTodoListView->setColumnAlignment(3,AlignLeft); |
496 | mTodoListView->addColumn(i18n("Due Time")); | 497 | mTodoListView->addColumn(i18n("Due Time")); |
497 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 498 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
498 | 499 | ||
499 | mTodoListView->addColumn(i18n("Start Date")); | 500 | mTodoListView->addColumn(i18n("Start Date")); |
500 | mTodoListView->setColumnAlignment(5,AlignLeft); | 501 | mTodoListView->setColumnAlignment(5,AlignLeft); |
501 | mTodoListView->addColumn(i18n("Start Time")); | 502 | mTodoListView->addColumn(i18n("Start Time")); |
502 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 503 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
503 | 504 | ||
504 | mTodoListView->addColumn(i18n("Cancelled")); | 505 | mTodoListView->addColumn(i18n("Cancelled")); |
505 | mTodoListView->addColumn(i18n("Categories")); | 506 | mTodoListView->addColumn(i18n("Categories")); |
506 | mTodoListView->addColumn(i18n("Calendar")); | 507 | mTodoListView->addColumn(i18n("Calendar")); |
507 | #if 0 | 508 | #if 0 |
508 | mTodoListView->addColumn(i18n("Sort Id")); | 509 | mTodoListView->addColumn(i18n("Sort Id")); |
509 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 510 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
510 | #endif | 511 | #endif |
511 | 512 | ||
512 | mTodoListView->setMinimumHeight( 60 ); | 513 | mTodoListView->setMinimumHeight( 60 ); |
513 | mTodoListView->setItemsRenameable( true ); | 514 | mTodoListView->setItemsRenameable( true ); |
514 | mTodoListView->setRenameable( 0 ); | 515 | mTodoListView->setRenameable( 0 ); |
515 | mTodoListView->setColumnWidth( 0, 120 ); | 516 | mTodoListView->setColumnWidth( 0, 120 ); |
516 | int iii = 0; | 517 | int iii = 0; |
517 | for ( iii = 0; iii< 10 ; ++iii ) | 518 | for ( iii = 0; iii< 10 ; ++iii ) |
518 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 519 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
519 | 520 | ||
520 | 521 | ||
521 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 522 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
522 | 523 | ||
523 | mPriorityPopupMenu = new QPopupMenu(this); | 524 | mPriorityPopupMenu = new QPopupMenu(this); |
524 | for (int i = 1; i <= 5; i++) { | 525 | for (int i = 1; i <= 5; i++) { |
525 | QString label = QString ("%1").arg (i); | 526 | QString label = QString ("%1").arg (i); |
526 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 527 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
527 | } | 528 | } |
528 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 529 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
529 | 530 | ||
530 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 531 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
531 | for (int i = 0; i <= 100; i+=20) { | 532 | for (int i = 0; i <= 100; i+=20) { |
532 | QString label = QString ("%1 %").arg (i); | 533 | QString label = QString ("%1 %").arg (i); |
533 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 534 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
534 | } | 535 | } |
535 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 536 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
536 | 537 | ||
537 | 538 | ||
538 | 539 | ||
539 | mItemPopupMenu = new QPopupMenu(this); | 540 | mItemPopupMenu = new QPopupMenu(this); |
540 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 541 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
541 | SLOT (showTodo())); | 542 | SLOT (showTodo())); |
542 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 543 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
543 | SLOT (editTodo())); | 544 | SLOT (editTodo())); |
544 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 545 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
545 | SLOT (deleteTodo())); | 546 | SLOT (deleteTodo())); |
546 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 547 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
547 | SLOT (cloneTodo())); | 548 | SLOT (cloneTodo())); |
548 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 549 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
549 | SLOT (moveTodo())); | 550 | SLOT (moveTodo())); |
550 | #ifndef DESKTOP_VERSION | 551 | #ifndef DESKTOP_VERSION |
551 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 552 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
552 | SLOT (beamTodo())); | 553 | SLOT (beamTodo())); |
553 | #endif | 554 | #endif |
554 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 555 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
555 | SLOT (cancelTodo())); | 556 | SLOT (cancelTodo())); |
556 | mItemPopupMenu->insertSeparator(); | 557 | mItemPopupMenu->insertSeparator(); |
557 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 558 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
558 | SLOT (toggleRunningItem())); | 559 | SLOT (toggleRunningItem())); |
559 | mItemPopupMenu->insertSeparator(); | 560 | mItemPopupMenu->insertSeparator(); |
560 | /* | 561 | /* |
561 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 562 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
562 | SLOT (newTodo())); | 563 | SLOT (newTodo())); |
563 | */ | 564 | */ |
564 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 565 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
565 | SLOT (newSubTodo())); | 566 | SLOT (newSubTodo())); |
566 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 567 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
567 | SLOT (unparentTodo()),0,21); | 568 | SLOT (unparentTodo()),0,21); |
568 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 569 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
569 | SLOT (reparentTodo()),0,22); | 570 | SLOT (reparentTodo()),0,22); |
570 | mItemPopupMenu->insertSeparator(); | 571 | mItemPopupMenu->insertSeparator(); |
571 | #if 0 | 572 | #if 0 |
572 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 573 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
573 | this, SLOT( purgeCompleted() ) ); | 574 | this, SLOT( purgeCompleted() ) ); |
574 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 575 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
575 | this, SLOT( toggleCompleted() ),0, 33 ); | 576 | this, SLOT( toggleCompleted() ),0, 33 ); |
576 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 577 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
577 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 578 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
578 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 579 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
579 | this, SLOT( toggleRunning() ),0, 35 ); | 580 | this, SLOT( toggleRunning() ),0, 35 ); |
580 | 581 | ||
581 | #endif | 582 | #endif |
582 | mPopupMenu = new QPopupMenu(this); | 583 | mPopupMenu = new QPopupMenu(this); |
583 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 584 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
584 | SLOT (newTodo()),0,1); | 585 | SLOT (newTodo()),0,1); |
585 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 586 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
586 | this, SLOT(purgeCompleted()),0,2); | 587 | this, SLOT(purgeCompleted()),0,2); |
587 | mPopupMenu->insertItem(i18n("Show Completed"), | 588 | mPopupMenu->insertItem(i18n("Show Completed"), |
588 | this, SLOT( toggleCompleted() ),0,3 ); | 589 | this, SLOT( toggleCompleted() ),0,3 ); |
589 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 590 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
590 | this, SLOT( toggleRunning() ),0,5 ); | 591 | this, SLOT( toggleRunning() ),0,5 ); |
591 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 592 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
592 | this, SLOT( setAllOpen() ),0,6 ); | 593 | this, SLOT( setAllOpen() ),0,6 ); |
593 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 594 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
594 | this, SLOT( setAllClose() ),0,7 ); | 595 | this, SLOT( setAllClose() ),0,7 ); |
595 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 596 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
596 | this, SLOT( setAllFlat() ),0,8 ); | 597 | this, SLOT( setAllFlat() ),0,8 ); |
597 | mPopupMenu->insertSeparator(); | 598 | mPopupMenu->insertSeparator(); |
598 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 599 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
599 | this, SLOT( toggleQuickTodo() ),0,4 ); | 600 | this, SLOT( toggleQuickTodo() ),0,4 ); |
600 | mDocPrefs = new DocPrefs( name ); | 601 | mDocPrefs = new DocPrefs( name ); |
601 | 602 | ||
602 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 603 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
603 | mPopupMenu->setCheckable( true ); | 604 | mPopupMenu->setCheckable( true ); |
604 | mItemPopupMenu->setCheckable( true ); | 605 | mItemPopupMenu->setCheckable( true ); |
605 | 606 | ||
606 | 607 | ||
607 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 608 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
608 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 609 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
609 | 610 | ||
610 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 611 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
611 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 612 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
612 | 613 | ||
613 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 614 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
614 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 615 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
615 | 616 | ||
616 | 617 | ||
617 | // Double clicking conflicts with opening/closing the subtree | 618 | // Double clicking conflicts with opening/closing the subtree |
618 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 619 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
619 | SLOT( editItem( QListViewItem *) ) ); | 620 | SLOT( editItem( QListViewItem *) ) ); |
620 | /* | 621 | /* |
621 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 622 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
622 | const QPoint &,int ) ), | 623 | const QPoint &,int ) ), |
623 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 624 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
624 | */ | 625 | */ |
625 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 626 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
626 | const QPoint &,int ) ), | 627 | const QPoint &,int ) ), |
627 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 628 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
628 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 629 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
629 | SLOT( itemClicked( QListViewItem * ) ) ); | 630 | SLOT( itemClicked( QListViewItem * ) ) ); |
630 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 631 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
631 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 632 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
632 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 633 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
633 | SLOT( updateView() ) ); | 634 | SLOT( updateView() ) ); |
634 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 635 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
635 | SLOT( todoModified(Todo *, int) ) ); | 636 | SLOT( todoModified(Todo *, int) ) ); |
636 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 637 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
637 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 638 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
638 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 639 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
639 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 640 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
640 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 641 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
641 | SLOT( paintNeeded()) ); | 642 | SLOT( paintNeeded()) ); |
642 | 643 | ||
643 | #if 0 | 644 | #if 0 |
644 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 645 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
645 | SLOT(selectionChanged(QListViewItem *))); | 646 | SLOT(selectionChanged(QListViewItem *))); |
646 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 647 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
647 | SLOT(selectionChanged(QListViewItem *))); | 648 | SLOT(selectionChanged(QListViewItem *))); |
648 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 649 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
649 | SLOT(selectionChanged(QListViewItem *))); | 650 | SLOT(selectionChanged(QListViewItem *))); |
650 | #endif | 651 | #endif |
651 | 652 | ||
652 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 653 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
653 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 654 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
654 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 655 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
655 | 656 | ||
656 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 657 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
657 | SLOT( processSelectionChange() ) ); | 658 | SLOT( processSelectionChange() ) ); |
658 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 659 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
659 | SLOT( addQuickTodo() ) ); | 660 | SLOT( addQuickTodo() ) ); |
660 | 661 | ||
661 | } | 662 | } |
662 | 663 | ||
663 | KOTodoView::~KOTodoView() | 664 | KOTodoView::~KOTodoView() |
664 | { | 665 | { |
665 | 666 | ||
666 | #if QT_VERSION >= 0x030000 | 667 | #if QT_VERSION >= 0x030000 |
667 | 668 | ||
668 | #else | 669 | #else |
669 | delete mKOTodoViewWhatsThis; | 670 | delete mKOTodoViewWhatsThis; |
670 | #endif | 671 | #endif |
671 | 672 | ||
672 | delete mDocPrefs; | 673 | delete mDocPrefs; |
673 | } | 674 | } |
674 | QString KOTodoView::getWhatsThisText(QPoint p) | 675 | QString KOTodoView::getWhatsThisText(QPoint p) |
675 | { | 676 | { |
676 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 677 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
677 | if ( item ) | 678 | if ( item ) |
678 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 679 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
679 | KOPrefs::instance()->mWTshowDetails, | 680 | KOPrefs::instance()->mWTshowDetails, |
680 | KOPrefs::instance()->mWTshowCreated, | 681 | KOPrefs::instance()->mWTshowCreated, |
681 | KOPrefs::instance()->mWTshowChanged); | 682 | KOPrefs::instance()->mWTshowChanged); |
682 | return i18n("That is the todo view" ); | 683 | return i18n("That is the todo view" ); |
683 | 684 | ||
684 | } | 685 | } |
685 | 686 | ||
686 | void KOTodoView::jumpToDate () | 687 | void KOTodoView::jumpToDate () |
687 | { | 688 | { |
688 | // if (mActiveItem) { | 689 | // if (mActiveItem) { |
689 | // mActiveItem->todo()); | 690 | // mActiveItem->todo()); |
690 | // if ( mActiveItem->todo()->hasDueDate() ) | 691 | // if ( mActiveItem->todo()->hasDueDate() ) |
691 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 692 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
692 | } | 693 | } |
693 | void KOTodoView::paintNeeded() | 694 | void KOTodoView::paintNeeded() |
694 | { | 695 | { |
695 | if ( mPendingUpdateBeforeRepaint ) { | 696 | if ( mPendingUpdateBeforeRepaint ) { |
696 | updateView(); | 697 | updateView(); |
697 | mPendingUpdateBeforeRepaint = false; | 698 | mPendingUpdateBeforeRepaint = false; |
698 | } | 699 | } |
699 | } | 700 | } |
700 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 701 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
701 | { | 702 | { |
702 | if ( mPendingUpdateBeforeRepaint ) { | 703 | if ( mPendingUpdateBeforeRepaint ) { |
703 | updateView(); | 704 | updateView(); |
704 | mPendingUpdateBeforeRepaint = false; | 705 | mPendingUpdateBeforeRepaint = false; |
705 | } | 706 | } |
706 | KOrg::BaseView::paintEvent( pevent); | 707 | KOrg::BaseView::paintEvent( pevent); |
707 | } | 708 | } |
708 | 709 | ||
709 | void KOTodoView::updateView() | 710 | void KOTodoView::updateView() |
710 | { | 711 | { |
711 | pendingSubtodo = 0; | 712 | pendingSubtodo = 0; |
712 | if ( mBlockUpdate ) { | 713 | if ( mBlockUpdate ) { |
713 | return; | 714 | return; |
714 | } | 715 | } |
715 | if ( !isVisible() ) { | 716 | if ( !isVisible() ) { |
716 | mPendingUpdateBeforeRepaint = true; | 717 | mPendingUpdateBeforeRepaint = true; |
717 | return; | 718 | return; |
718 | } | 719 | } |
719 | storeCurrentItem(); | 720 | storeCurrentItem(); |
720 | //qDebug("KOTodoView::updateView() %x", this); | 721 | //qDebug("KOTodoView::updateView() %x", this); |
721 | if ( isFlatDisplay ) { | 722 | if ( isFlatDisplay ) { |
722 | displayAllFlat(); | 723 | displayAllFlat(); |
723 | resetCurrentItem(); | 724 | resetCurrentItem(); |
724 | return; | 725 | return; |
725 | } | 726 | } |
726 | //qDebug("update "); | 727 | //qDebug("update "); |
727 | // kdDebug() << "KOTodoView::updateView()" << endl; | 728 | // kdDebug() << "KOTodoView::updateView()" << endl; |
728 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 729 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
729 | 730 | ||
730 | 731 | ||
731 | mTodoListView->clear(); | 732 | mTodoListView->clear(); |
732 | if ( mName == "todolistsmall" ) { | 733 | if ( mName == "todolistsmall" ) { |
733 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 734 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
734 | int ps = fo.pointSize() -2; | 735 | int ps = fo.pointSize() -2; |
735 | if ( ps > 12 ) | 736 | if ( ps > 12 ) |
736 | ps -= 2; | 737 | ps -= 2; |
737 | fo.setPointSize( ps ); | 738 | fo.setPointSize( ps ); |
738 | } | 739 | } |
739 | } | 740 | } |
740 | 741 | ||
741 | mTodoListView->setFont( fo ); | 742 | mTodoListView->setFont( fo ); |
742 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 743 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
743 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 744 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
744 | QPtrList<Todo> todoList = calendar()->todos(); | 745 | QPtrList<Todo> todoList = calendar()->todos(); |
745 | 746 | ||
746 | /* | 747 | /* |
747 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 748 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
748 | Event *t; | 749 | Event *t; |
749 | for(t = todoList.first(); t; t = todoList.next()) { | 750 | for(t = todoList.first(); t; t = todoList.next()) { |
750 | kdDebug() << " " << t->getSummary() << endl; | 751 | kdDebug() << " " << t->getSummary() << endl; |
751 | 752 | ||
752 | if (t->getRelatedTo()) { | 753 | if (t->getRelatedTo()) { |
753 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 754 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
754 | } | 755 | } |
755 | 756 | ||
756 | QPtrList<Event> l = t->getRelations(); | 757 | QPtrList<Event> l = t->getRelations(); |
757 | Event *c; | 758 | Event *c; |
758 | for(c=l.first();c;c=l.next()) { | 759 | for(c=l.first();c;c=l.next()) { |
759 | kdDebug() << " - relation: " << c->getSummary() << endl; | 760 | kdDebug() << " - relation: " << c->getSummary() << endl; |
760 | } | 761 | } |
761 | } | 762 | } |
762 | */ | 763 | */ |
763 | 764 | ||
764 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 765 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
765 | // specific order of events. That means that we have to generate parent items | 766 | // specific order of events. That means that we have to generate parent items |
766 | // recursively for proper hierarchical display of Todos. | 767 | // recursively for proper hierarchical display of Todos. |
767 | mTodoMap.clear(); | 768 | mTodoMap.clear(); |
768 | Todo *todo; | 769 | Todo *todo; |
769 | todo = todoList.first();// todo; todo = todoList.next()) { | 770 | todo = todoList.first();// todo; todo = todoList.next()) { |
770 | while ( todo ) { | 771 | while ( todo ) { |
771 | bool next = true; | 772 | bool next = true; |
772 | // qDebug("todo %s ", todo->summary().latin1()); | 773 | // qDebug("todo %s ", todo->summary().latin1()); |
773 | Incidence *incidence = todo->relatedTo(); | 774 | Incidence *incidence = todo->relatedTo(); |
774 | while ( incidence ) { | 775 | while ( incidence ) { |
775 | if ( incidence->typeID() == todoID ) { | 776 | if ( incidence->typeID() == todoID ) { |
776 | //qDebug("related %s ",incidence->summary().latin1() ); | 777 | //qDebug("related %s ",incidence->summary().latin1() ); |
777 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 778 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
778 | //qDebug("related not found "); | 779 | //qDebug("related not found "); |
779 | todoList.remove( ); | 780 | todoList.remove( ); |
780 | todo = todoList.current(); | 781 | todo = todoList.current(); |
781 | next = false; | 782 | next = false; |
782 | incidence = 0; | 783 | incidence = 0; |
783 | 784 | ||
784 | } else { | 785 | } else { |
785 | //qDebug("related found "); | 786 | //qDebug("related found "); |
786 | incidence = incidence->relatedTo(); | 787 | incidence = incidence->relatedTo(); |
787 | } | 788 | } |
788 | } else | 789 | } else |
789 | incidence = 0; | 790 | incidence = 0; |
790 | } | 791 | } |
791 | if ( next ) | 792 | if ( next ) |
792 | todo = todoList.next(); | 793 | todo = todoList.next(); |
793 | } | 794 | } |
794 | 795 | ||
795 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 796 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
796 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 797 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
797 | { | 798 | { |
798 | insertTodoItem(todo); | 799 | insertTodoItem(todo); |
799 | } | 800 | } |
800 | } | 801 | } |
801 | // Restore opened/closed state | 802 | // Restore opened/closed state |
802 | mTodoListView->blockSignals( true ); | 803 | mTodoListView->blockSignals( true ); |
803 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 804 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
804 | mTodoListView->blockSignals( false ); | 805 | mTodoListView->blockSignals( false ); |
805 | resetCurrentItem(); | 806 | resetCurrentItem(); |
806 | processSelectionChange(); | 807 | processSelectionChange(); |
807 | } | 808 | } |
808 | 809 | ||
809 | void KOTodoView::storeCurrentItem() | 810 | void KOTodoView::storeCurrentItem() |
810 | { | 811 | { |
811 | mCurItem = 0; | 812 | mCurItem = 0; |
812 | mCurItemRootParent = 0; | 813 | mCurItemRootParent = 0; |
813 | mCurItemParent = 0; | 814 | mCurItemParent = 0; |
814 | mCurItemAbove = 0; | 815 | mCurItemAbove = 0; |
815 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 816 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
816 | if (mActiveItem) { | 817 | if (mActiveItem) { |
817 | mCurItem = mActiveItem->todo(); | 818 | mCurItem = mActiveItem->todo(); |
818 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 819 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
819 | if ( activeItemAbove ) | 820 | if ( activeItemAbove ) |
820 | mCurItemAbove = activeItemAbove->todo(); | 821 | mCurItemAbove = activeItemAbove->todo(); |
821 | mCurItemRootParent = mCurItem; | 822 | mCurItemRootParent = mCurItem; |
822 | mCurItemParent = mCurItemRootParent->relatedTo(); | 823 | mCurItemParent = mCurItemRootParent->relatedTo(); |
823 | while ( mCurItemRootParent->relatedTo() != 0 ) | 824 | while ( mCurItemRootParent->relatedTo() != 0 ) |
824 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 825 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
825 | } | 826 | } |
826 | mActiveItem = 0; | 827 | mActiveItem = 0; |
827 | } | 828 | } |
828 | 829 | ||
829 | void KOTodoView::resetCurrentItem() | 830 | void KOTodoView::resetCurrentItem() |
830 | { | 831 | { |
831 | mTodoListView->setFocus(); | 832 | mTodoListView->setFocus(); |
832 | KOTodoViewItem* foundItem = 0; | 833 | KOTodoViewItem* foundItem = 0; |
833 | KOTodoViewItem* foundItemRoot = 0; | 834 | KOTodoViewItem* foundItemRoot = 0; |
834 | KOTodoViewItem* foundItemParent = 0; | 835 | KOTodoViewItem* foundItemParent = 0; |
835 | KOTodoViewItem* foundItemAbove = 0; | 836 | KOTodoViewItem* foundItemAbove = 0; |
836 | if ( mTodoListView->firstChild () ) { | 837 | if ( mTodoListView->firstChild () ) { |
837 | if ( mCurItem ) { | 838 | if ( mCurItem ) { |
838 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 839 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
839 | while ( item ) { | 840 | while ( item ) { |
840 | if ( item->todo() == mCurItem ) { | 841 | if ( item->todo() == mCurItem ) { |
841 | foundItem = item; | 842 | foundItem = item; |
842 | break; | 843 | break; |
843 | } else if ( item->todo() == mCurItemAbove ) { | 844 | } else if ( item->todo() == mCurItemAbove ) { |
844 | foundItemAbove = item; | 845 | foundItemAbove = item; |
845 | 846 | ||
846 | } | 847 | } |
847 | if ( item->todo() == mCurItemRootParent ) { | 848 | if ( item->todo() == mCurItemRootParent ) { |
848 | foundItemRoot = item; | 849 | foundItemRoot = item; |
849 | } | 850 | } |
850 | if ( item->todo() == mCurItemParent ) { | 851 | if ( item->todo() == mCurItemParent ) { |
851 | foundItemParent = item; | 852 | foundItemParent = item; |
852 | } | 853 | } |
853 | item = (KOTodoViewItem*)item->itemBelow(); | 854 | item = (KOTodoViewItem*)item->itemBelow(); |
854 | } | 855 | } |
855 | if ( ! foundItem ) { | 856 | if ( ! foundItem ) { |
856 | if ( foundItemParent ) { | 857 | if ( foundItemParent ) { |
857 | foundItem = foundItemParent; | 858 | foundItem = foundItemParent; |
858 | } else { | 859 | } else { |
859 | if ( foundItemRoot ) | 860 | if ( foundItemRoot ) |
860 | foundItem = foundItemRoot; | 861 | foundItem = foundItemRoot; |
861 | else | 862 | else |
862 | foundItem = foundItemAbove; | 863 | foundItem = foundItemAbove; |
863 | } | 864 | } |
864 | } | 865 | } |
865 | } | 866 | } |
866 | if ( foundItem ) { | 867 | if ( foundItem ) { |
867 | mTodoListView->setCurrentItem( foundItem ); | 868 | mTodoListView->setCurrentItem( foundItem ); |
868 | mTodoListView->ensureItemVisible( foundItem ); | 869 | mTodoListView->ensureItemVisible( foundItem ); |
869 | } else { | 870 | } else { |
870 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 871 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
871 | } | 872 | } |
872 | } | 873 | } |
873 | mTodoListView->setFocus(); | 874 | mTodoListView->setFocus(); |
874 | } | 875 | } |
875 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 876 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
876 | bool KOTodoView::checkTodo( Todo * todo ) | 877 | bool KOTodoView::checkTodo( Todo * todo ) |
877 | { | 878 | { |
878 | 879 | ||
879 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 880 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
880 | return false; | 881 | return false; |
881 | if ( !todo->isCompleted() ) { | 882 | if ( !todo->isCompleted() ) { |
882 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 883 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
883 | return true; | 884 | return true; |
884 | } | 885 | } |
885 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 886 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
886 | if ( todo->hasStartDate() ) | 887 | if ( todo->hasStartDate() ) |
887 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 888 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
888 | return false; | 889 | return false; |
889 | if ( todo->hasDueDate() ) | 890 | if ( todo->hasDueDate() ) |
890 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 891 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
891 | return false; | 892 | return false; |
892 | } | 893 | } |
893 | return true; | 894 | return true; |
894 | } | 895 | } |
895 | 896 | ||
896 | void KOTodoView::restoreItemState( QListViewItem *item ) | 897 | void KOTodoView::restoreItemState( QListViewItem *item ) |
897 | { | 898 | { |
898 | pendingSubtodo = 0; | 899 | pendingSubtodo = 0; |
899 | while( item ) { | 900 | while( item ) { |
900 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 901 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
901 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 902 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
902 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 903 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
903 | item = item->nextSibling(); | 904 | item = item->nextSibling(); |
904 | } | 905 | } |
905 | } | 906 | } |
906 | 907 | ||
907 | 908 | ||
908 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 909 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
909 | KOTodoView::insertTodoItem(Todo *todo) | 910 | KOTodoView::insertTodoItem(Todo *todo) |
910 | { | 911 | { |
911 | 912 | ||
912 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 913 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
913 | // TODO: Check, if dynmaic cast is necessary | 914 | // TODO: Check, if dynmaic cast is necessary |
914 | 915 | ||
915 | pendingSubtodo = 0; | 916 | pendingSubtodo = 0; |
916 | Incidence *incidence = todo->relatedTo(); | 917 | Incidence *incidence = todo->relatedTo(); |
917 | while ( incidence && !incidence->calEnabled() ) | 918 | while ( incidence && !incidence->calEnabled() ) |
918 | incidence = incidence->relatedTo(); | 919 | incidence = incidence->relatedTo(); |
919 | if (incidence && incidence->typeID() == todoID ) { | 920 | if (incidence && incidence->typeID() == todoID ) { |
920 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 921 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
921 | 922 | ||
922 | // kdDebug() << " has Related" << endl; | 923 | // kdDebug() << " has Related" << endl; |
923 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 924 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
924 | itemIterator = mTodoMap.find(relatedTodo); | 925 | itemIterator = mTodoMap.find(relatedTodo); |
925 | if (itemIterator == mTodoMap.end()) { | 926 | if (itemIterator == mTodoMap.end()) { |
926 | // kdDebug() << " related not yet in list" << endl; | 927 | // kdDebug() << " related not yet in list" << endl; |
927 | itemIterator = insertTodoItem (relatedTodo); | 928 | itemIterator = insertTodoItem (relatedTodo); |
928 | } | 929 | } |
929 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 930 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
930 | // and one into the map. Sure finding is more easy but why? -zecke | 931 | // and one into the map. Sure finding is more easy but why? -zecke |
931 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 932 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
932 | return mTodoMap.insert(todo,todoItem); | 933 | return mTodoMap.insert(todo,todoItem); |
933 | } else { | 934 | } else { |
934 | // kdDebug() << " no Related" << endl; | 935 | // kdDebug() << " no Related" << endl; |
935 | // see above -zecke | 936 | // see above -zecke |
936 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 937 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
937 | return mTodoMap.insert(todo,todoItem); | 938 | return mTodoMap.insert(todo,todoItem); |
938 | } | 939 | } |
939 | } | 940 | } |
940 | 941 | ||
941 | 942 | ||
942 | void KOTodoView::updateConfig() | 943 | void KOTodoView::updateConfig() |
943 | { | 944 | { |
944 | updateView(); | 945 | updateView(); |
945 | mTodoListView->repaintContents(); | 946 | mTodoListView->repaintContents(); |
946 | } | 947 | } |
947 | 948 | ||
948 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 949 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
949 | { | 950 | { |
950 | QPtrList<Incidence> selected; | 951 | QPtrList<Incidence> selected; |
951 | 952 | ||
952 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 953 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
953 | // if (!item) item = mActiveItem; | 954 | // if (!item) item = mActiveItem; |
954 | if (item) selected.append(item->todo()); | 955 | if (item) selected.append(item->todo()); |
955 | 956 | ||
956 | return selected; | 957 | return selected; |
957 | } | 958 | } |
958 | 959 | ||
959 | QPtrList<Todo> KOTodoView::selectedTodos() | 960 | QPtrList<Todo> KOTodoView::selectedTodos() |
960 | { | 961 | { |
961 | QPtrList<Todo> selected; | 962 | QPtrList<Todo> selected; |
962 | 963 | ||
963 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 964 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
964 | // if (!item) item = mActiveItem; | 965 | // if (!item) item = mActiveItem; |
965 | if (item) selected.append(item->todo()); | 966 | if (item) selected.append(item->todo()); |
966 | 967 | ||
967 | return selected; | 968 | return selected; |
968 | } | 969 | } |
969 | 970 | ||
970 | void KOTodoView::changeEventDisplay(Event *, int) | 971 | void KOTodoView::changeEventDisplay(Event *, int) |
971 | { | 972 | { |
972 | updateView(); | 973 | updateView(); |
973 | } | 974 | } |
974 | 975 | ||
975 | void KOTodoView::showDates(const QDate &, const QDate &) | 976 | void KOTodoView::showDates(const QDate &, const QDate &) |
976 | { | 977 | { |
977 | } | 978 | } |
978 | 979 | ||
979 | void KOTodoView::showEvents(QPtrList<Event>) | 980 | void KOTodoView::showEvents(QPtrList<Event>) |
980 | { | 981 | { |
981 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 982 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
982 | } | 983 | } |
983 | 984 | ||
984 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 985 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
985 | const QDate &td) | 986 | const QDate &td) |
986 | { | 987 | { |
987 | #ifndef KORG_NOPRINTER | 988 | #ifndef KORG_NOPRINTER |
988 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 989 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
989 | #endif | 990 | #endif |
990 | } | 991 | } |
991 | 992 | ||
992 | void KOTodoView::editItem(QListViewItem *item ) | 993 | void KOTodoView::editItem(QListViewItem *item ) |
993 | { | 994 | { |
994 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 995 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
995 | } | 996 | } |
996 | 997 | ||
997 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 998 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
998 | { | 999 | { |
999 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1000 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1003 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1003 | { | 1004 | { |
1004 | pendingSubtodo = 0; | 1005 | pendingSubtodo = 0; |
1005 | mActiveItem = (KOTodoViewItem *)item; | 1006 | mActiveItem = (KOTodoViewItem *)item; |
1006 | if (item) { | 1007 | if (item) { |
1007 | switch (column){ | 1008 | switch (column){ |
1008 | case 1: | 1009 | case 1: |
1009 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1010 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1010 | case 2: | 1011 | case 2: |
1011 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1012 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1012 | case 3: | 1013 | case 3: |
1013 | moveTodo(); | 1014 | moveTodo(); |
1014 | break; | 1015 | break; |
1015 | case 8: | 1016 | case 8: |
1016 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 1017 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
1017 | default: | 1018 | default: |
1018 | mItemPopupMenu->popup(QCursor::pos()); | 1019 | mItemPopupMenu->popup(QCursor::pos()); |
1019 | } | 1020 | } |
1020 | } else mPopupMenu->popup(QCursor::pos()); | 1021 | } else mPopupMenu->popup(QCursor::pos()); |
1021 | } | 1022 | } |
1022 | void KOTodoView::newTodo() | 1023 | void KOTodoView::newTodo() |
1023 | { | 1024 | { |
1024 | emit newTodoSignal(); | 1025 | emit newTodoSignal(); |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | void KOTodoView::newSubTodo() | 1028 | void KOTodoView::newSubTodo() |
1028 | { | 1029 | { |
1029 | if (mActiveItem) { | 1030 | if (mActiveItem) { |
1030 | emit newSubTodoSignal(mActiveItem->todo()); | 1031 | emit newSubTodoSignal(mActiveItem->todo()); |
1031 | } | 1032 | } |
1032 | } | 1033 | } |
1033 | void KOTodoView::unparentTodo() | 1034 | void KOTodoView::unparentTodo() |
1034 | { | 1035 | { |
1035 | if (mActiveItem) { | 1036 | if (mActiveItem) { |
1036 | emit unparentTodoSignal(mActiveItem->todo()); | 1037 | emit unparentTodoSignal(mActiveItem->todo()); |
1037 | } | 1038 | } |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | void KOTodoView::reparentTodo() | 1041 | void KOTodoView::reparentTodo() |
1041 | { | 1042 | { |
1042 | if (mActiveItem) { | 1043 | if (mActiveItem) { |
1043 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1044 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1044 | pendingSubtodo = mActiveItem; | 1045 | pendingSubtodo = mActiveItem; |
1045 | } | 1046 | } |
1046 | } | 1047 | } |
1047 | void KOTodoView::editTodo() | 1048 | void KOTodoView::editTodo() |
1048 | { | 1049 | { |
1049 | if (mActiveItem) { | 1050 | if (mActiveItem) { |
1050 | emit editTodoSignal(mActiveItem->todo()); | 1051 | emit editTodoSignal(mActiveItem->todo()); |
1051 | } | 1052 | } |
1052 | } | 1053 | } |
1053 | void KOTodoView::cloneTodo() | 1054 | void KOTodoView::cloneTodo() |
1054 | { | 1055 | { |
1055 | if (mActiveItem) { | 1056 | if (mActiveItem) { |
1056 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1057 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1057 | } | 1058 | } |
1058 | } | 1059 | } |
1059 | void KOTodoView::cancelTodo() | 1060 | void KOTodoView::cancelTodo() |
1060 | { | 1061 | { |
1061 | if (mActiveItem) { | 1062 | if (mActiveItem) { |
1062 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1063 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1063 | } | 1064 | } |
1064 | } | 1065 | } |
1065 | void KOTodoView::moveTodo() | 1066 | void KOTodoView::moveTodo() |
1066 | { | 1067 | { |
1067 | if (mActiveItem) { | 1068 | if (mActiveItem) { |
1068 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1069 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1069 | } | 1070 | } |
1070 | } | 1071 | } |
1071 | void KOTodoView::beamTodo() | 1072 | void KOTodoView::beamTodo() |
1072 | { | 1073 | { |
1073 | if (mActiveItem) { | 1074 | if (mActiveItem) { |
1074 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1075 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1075 | } | 1076 | } |
1076 | } | 1077 | } |
1077 | 1078 | ||
1078 | 1079 | ||
1079 | void KOTodoView::showTodo() | 1080 | void KOTodoView::showTodo() |
1080 | { | 1081 | { |
1081 | if (mActiveItem) { | 1082 | if (mActiveItem) { |
1082 | emit showTodoSignal(mActiveItem->todo()); | 1083 | emit showTodoSignal(mActiveItem->todo()); |
1083 | } | 1084 | } |
1084 | } | 1085 | } |
1085 | 1086 | ||
1086 | void KOTodoView::deleteTodo() | 1087 | void KOTodoView::deleteTodo() |
1087 | { | 1088 | { |
1088 | if (mActiveItem) { | 1089 | if (mActiveItem) { |
1089 | emit deleteTodoSignal(mActiveItem->todo()); | 1090 | emit deleteTodoSignal(mActiveItem->todo()); |
1090 | } | 1091 | } |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | void KOTodoView::setNewPriority(int index) | 1094 | void KOTodoView::setNewPriority(int index) |
1094 | { | 1095 | { |
1095 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1096 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1096 | mActiveItem->todo()->setPriority(mPriority[index]); | 1097 | mActiveItem->todo()->setPriority(mPriority[index]); |
1097 | mActiveItem->construct(); | 1098 | mActiveItem->construct(); |
1098 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1099 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1099 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1100 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1100 | } | 1101 | } |
1101 | } | 1102 | } |
1102 | 1103 | ||
1103 | void KOTodoView::setNewPercentage(int index) | 1104 | void KOTodoView::setNewPercentage(int index) |
1104 | { | 1105 | { |
1105 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1106 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1106 | 1107 | ||
1107 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1108 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1108 | mActiveItem->setOn( true ); | 1109 | mActiveItem->setOn( true ); |
1109 | return; | 1110 | return; |
1110 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1111 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1111 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1112 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1112 | if ( par && par->isOn() ) | 1113 | if ( par && par->isOn() ) |
1113 | par->setOn( false ); | 1114 | par->setOn( false ); |
1114 | } | 1115 | } |
1115 | if (mPercentage[index] == 100) { | 1116 | if (mPercentage[index] == 100) { |
1116 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1117 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1117 | } else { | 1118 | } else { |
1118 | mActiveItem->todo()->setCompleted(false); | 1119 | mActiveItem->todo()->setCompleted(false); |
1119 | } | 1120 | } |
1120 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1121 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1121 | mActiveItem->construct(); | 1122 | mActiveItem->construct(); |
1122 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1123 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1123 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1124 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1124 | } | 1125 | } |
1125 | } | 1126 | } |
1126 | 1127 | ||
1127 | 1128 | ||
1128 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1129 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1129 | { | 1130 | { |
1130 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1131 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1131 | QStringList checkedCategories = todoItem->todo()->categories (); | 1132 | QStringList checkedCategories = todoItem->todo()->categories (); |
1132 | 1133 | ||
1133 | tempMenu->setCheckable (true); | 1134 | tempMenu->setCheckable (true); |
1134 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1135 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1135 | it != KOPrefs::instance()->mCustomCategories.end (); | 1136 | it != KOPrefs::instance()->mCustomCategories.end (); |
1136 | ++it) { | 1137 | ++it) { |
1137 | int index = tempMenu->insertItem (*it); | 1138 | int index = tempMenu->insertItem (*it); |
1138 | mCategory[index] = *it; | 1139 | mCategory[index] = *it; |
1139 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1140 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1140 | } | 1141 | } |
1141 | 1142 | ||
1142 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1143 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1143 | return tempMenu; | 1144 | return tempMenu; |
1144 | 1145 | ||
1145 | 1146 | ||
1146 | } | 1147 | } |
1147 | void KOTodoView::changedCategories(int index) | 1148 | void KOTodoView::changedCategories(int index) |
1148 | { | 1149 | { |
1149 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1150 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1150 | QStringList categories = mActiveItem->todo()->categories (); | 1151 | QStringList categories = mActiveItem->todo()->categories (); |
1151 | QString colcat = categories.first(); | 1152 | QString colcat = categories.first(); |
1152 | if (categories.find (mCategory[index]) != categories.end ()) | 1153 | if (categories.find (mCategory[index]) != categories.end ()) |
1153 | categories.remove (mCategory[index]); | 1154 | categories.remove (mCategory[index]); |
1154 | else | 1155 | else |
1155 | categories.insert (categories.end(), mCategory[index]); | 1156 | categories.insert (categories.end(), mCategory[index]); |
1156 | categories.sort (); | 1157 | categories.sort (); |
1157 | if ( !colcat.isEmpty() ) { | 1158 | if ( !colcat.isEmpty() ) { |
1158 | if ( categories.find ( colcat ) != categories.end () ) { | 1159 | if ( categories.find ( colcat ) != categories.end () ) { |
1159 | categories.remove( colcat ); | 1160 | categories.remove( colcat ); |
1160 | categories.prepend( colcat ); | 1161 | categories.prepend( colcat ); |
1161 | } | 1162 | } |
1162 | } | 1163 | } |
1163 | mActiveItem->todo()->setCategories (categories); | 1164 | mActiveItem->todo()->setCategories (categories); |
1164 | mActiveItem->construct(); | 1165 | mActiveItem->construct(); |
1165 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1166 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1166 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1167 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1167 | } | 1168 | } |
1168 | } | 1169 | } |
1169 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1170 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1170 | { | 1171 | { |
1171 | if ( pendingSubtodo != 0 ) { | 1172 | if ( pendingSubtodo != 0 ) { |
1172 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1173 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1173 | } | 1174 | } |
1174 | pendingSubtodo = 0; | 1175 | pendingSubtodo = 0; |
1175 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1176 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1176 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1177 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1177 | //qDebug("ROW %d ", row); | 1178 | //qDebug("ROW %d ", row); |
1178 | if (!item) { | 1179 | if (!item) { |
1179 | newTodo(); | 1180 | newTodo(); |
1180 | return; | 1181 | return; |
1181 | } else { | 1182 | } else { |
1182 | if ( row == 2 || row == 1 ) { | 1183 | if ( row == 2 || row == 1 ) { |
1183 | mActiveItem = (KOTodoViewItem *) item; | 1184 | mActiveItem = (KOTodoViewItem *) item; |
1184 | newSubTodo(); | 1185 | newSubTodo(); |
1185 | return; | 1186 | return; |
1186 | } | 1187 | } |
1187 | if ( row == 5 || row == 6 ) { | 1188 | if ( row == 5 || row == 6 ) { |
1188 | mActiveItem = (KOTodoViewItem *) item; | 1189 | mActiveItem = (KOTodoViewItem *) item; |
1189 | toggleRunningItem(); | 1190 | toggleRunningItem(); |
1190 | return; | 1191 | return; |
1191 | } | 1192 | } |
1192 | } | 1193 | } |
1193 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1194 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1194 | editItem( item ); | 1195 | editItem( item ); |
1195 | else | 1196 | else |
1196 | showItem( item , QPoint(), 0 ); | 1197 | showItem( item , QPoint(), 0 ); |
1197 | } | 1198 | } |
1198 | void KOTodoView::toggleRunningItem() | 1199 | void KOTodoView::toggleRunningItem() |
1199 | { | 1200 | { |
1200 | // qDebug("KOTodoView::toggleRunning() "); | 1201 | // qDebug("KOTodoView::toggleRunning() "); |
1201 | if ( ! mActiveItem ) | 1202 | if ( ! mActiveItem ) |
1202 | return; | 1203 | return; |
1203 | Todo * t = mActiveItem->todo(); | 1204 | Todo * t = mActiveItem->todo(); |
1204 | if ( t->isRunning() ) { | 1205 | if ( t->isRunning() ) { |
1205 | |||
1206 | |||
1207 | KOStopTodoPrefs tp ( t, this ); | 1206 | KOStopTodoPrefs tp ( t, this ); |
1208 | tp.exec(); | 1207 | tp.exec(); |
1209 | |||
1210 | |||
1211 | #if 0 | ||
1212 | int result = KMessageBox::warningYesNoCancel(this, | ||
1213 | i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note")); | ||
1214 | if (result == KMessageBox::Cancel) return; | ||
1215 | if ( result == KMessageBox::No ) { | ||
1216 | QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); | ||
1217 | t->setRunningFalse( comment ); | ||
1218 | } else { | ||
1219 | t->setRunning( false ); | ||
1220 | } | ||
1221 | mActiveItem->construct(); | 1208 | mActiveItem->construct(); |
1222 | |||
1223 | |||
1224 | #endif | ||
1225 | } else { | 1209 | } else { |
1226 | int result = KMessageBox::warningContinueCancel(this, | 1210 | int result = KMessageBox::warningContinueCancel(this, |
1227 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); | 1211 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); |
1228 | if (result != KMessageBox::Continue) return; | 1212 | if (result != KMessageBox::Continue) return; |
1229 | t->setRunning( true ); | 1213 | t->setRunning( true ); |
1230 | mActiveItem->construct(); | 1214 | mActiveItem->construct(); |
1231 | } | 1215 | } |
1232 | } | 1216 | } |
1233 | 1217 | ||
1234 | void KOTodoView::itemClicked(QListViewItem *item) | 1218 | void KOTodoView::itemClicked(QListViewItem *item) |
1235 | { | 1219 | { |
1236 | //qDebug("KOTodoView::itemClicked %d", item); | 1220 | //qDebug("KOTodoView::itemClicked %d", item); |
1237 | if (!item) { | 1221 | if (!item) { |
1238 | if ( pendingSubtodo != 0 ) { | 1222 | if ( pendingSubtodo != 0 ) { |
1239 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1223 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1240 | } | 1224 | } |
1241 | pendingSubtodo = 0; | 1225 | pendingSubtodo = 0; |
1242 | return; | 1226 | return; |
1243 | } | 1227 | } |
1244 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1228 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1245 | if ( pendingSubtodo != 0 ) { | 1229 | if ( pendingSubtodo != 0 ) { |
1246 | bool allowReparent = true; | 1230 | bool allowReparent = true; |
1247 | QListViewItem *par = item; | 1231 | QListViewItem *par = item; |
1248 | while ( par ) { | 1232 | while ( par ) { |
1249 | if ( par == pendingSubtodo ) { | 1233 | if ( par == pendingSubtodo ) { |
1250 | allowReparent = false; | 1234 | allowReparent = false; |
1251 | break; | 1235 | break; |
1252 | } | 1236 | } |
1253 | par = par->parent(); | 1237 | par = par->parent(); |
1254 | } | 1238 | } |
1255 | if ( !allowReparent ) { | 1239 | if ( !allowReparent ) { |
1256 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1240 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1257 | pendingSubtodo = 0; | 1241 | pendingSubtodo = 0; |
1258 | } else { | 1242 | } else { |
1259 | Todo* newParent = todoItem->todo(); | 1243 | Todo* newParent = todoItem->todo(); |
1260 | Todo* newSub = pendingSubtodo->todo(); | 1244 | Todo* newSub = pendingSubtodo->todo(); |
1261 | pendingSubtodo = 0; | 1245 | pendingSubtodo = 0; |
1262 | emit reparentTodoSignal( newParent,newSub ); | 1246 | emit reparentTodoSignal( newParent,newSub ); |
1263 | return; | 1247 | return; |
1264 | } | 1248 | } |
1265 | } | 1249 | } |
1266 | 1250 | ||
1267 | } | 1251 | } |
1268 | 1252 | ||
1269 | void KOTodoView::setDocumentId( const QString &id ) | 1253 | void KOTodoView::setDocumentId( const QString &id ) |
1270 | { | 1254 | { |
1271 | 1255 | ||
1272 | mDocPrefs->setDoc( id ); | 1256 | mDocPrefs->setDoc( id ); |
1273 | } | 1257 | } |
1274 | 1258 | ||
1275 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1259 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1276 | { | 1260 | { |
1277 | if (!item) return; | 1261 | if (!item) return; |
1278 | 1262 | ||
1279 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1263 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1280 | 1264 | ||
1281 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1265 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1282 | 1266 | ||
1283 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1267 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1284 | } | 1268 | } |
1285 | 1269 | ||
1286 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1270 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1287 | { | 1271 | { |
1288 | mTodoListView->saveLayout(config,group); | 1272 | mTodoListView->saveLayout(config,group); |
1289 | } | 1273 | } |
1290 | 1274 | ||
1291 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1275 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1292 | { | 1276 | { |
1293 | mTodoListView->restoreLayout(config,group); | 1277 | mTodoListView->restoreLayout(config,group); |
1294 | } | 1278 | } |
1295 | 1279 | ||
1296 | void KOTodoView::processSelectionChange() | 1280 | void KOTodoView::processSelectionChange() |
1297 | { | 1281 | { |
1298 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1282 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1299 | 1283 | ||
1300 | KOTodoViewItem *item = | 1284 | KOTodoViewItem *item = |
1301 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1285 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1302 | 1286 | ||
1303 | if ( !item ) { | 1287 | if ( !item ) { |
1304 | emit incidenceSelected( 0 ); | 1288 | emit incidenceSelected( 0 ); |
1305 | } else { | 1289 | } else { |
1306 | emit incidenceSelected( item->todo() ); | 1290 | emit incidenceSelected( item->todo() ); |
1307 | } | 1291 | } |
1308 | } | 1292 | } |
1309 | 1293 | ||
1310 | void KOTodoView::modified(bool b) | 1294 | void KOTodoView::modified(bool b) |
1311 | { | 1295 | { |
1312 | emit isModified(b); | 1296 | emit isModified(b); |
1313 | } | 1297 | } |
1314 | void KOTodoView::setTodoModified( Todo* todo ) | 1298 | void KOTodoView::setTodoModified( Todo* todo ) |
1315 | { | 1299 | { |
1316 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1300 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1317 | } | 1301 | } |
1318 | void KOTodoView::clearSelection() | 1302 | void KOTodoView::clearSelection() |
1319 | { | 1303 | { |
1320 | mTodoListView->selectAll( false ); | 1304 | mTodoListView->selectAll( false ); |
1321 | } | 1305 | } |
1322 | void KOTodoView::setAllOpen() | 1306 | void KOTodoView::setAllOpen() |
1323 | { | 1307 | { |
1324 | if ( isFlatDisplay ) { | 1308 | if ( isFlatDisplay ) { |
1325 | isFlatDisplay = false; | 1309 | isFlatDisplay = false; |
1326 | mPopupMenu->setItemChecked( 8,false ); | 1310 | mPopupMenu->setItemChecked( 8,false ); |
1327 | updateView(); | 1311 | updateView(); |
1328 | } else { | 1312 | } else { |
1329 | storeCurrentItem(); | 1313 | storeCurrentItem(); |
1330 | } | 1314 | } |
1331 | setOpen(mTodoListView->firstChild(), true); | 1315 | setOpen(mTodoListView->firstChild(), true); |
1332 | resetCurrentItem(); | 1316 | resetCurrentItem(); |
1333 | } | 1317 | } |
1334 | void KOTodoView::setAllClose() | 1318 | void KOTodoView::setAllClose() |
1335 | { | 1319 | { |
1336 | if ( isFlatDisplay ) { | 1320 | if ( isFlatDisplay ) { |
1337 | isFlatDisplay = false; | 1321 | isFlatDisplay = false; |
1338 | mPopupMenu->setItemChecked( 8,false ); | 1322 | mPopupMenu->setItemChecked( 8,false ); |
1339 | updateView(); | 1323 | updateView(); |
1340 | } else { | 1324 | } else { |
1341 | storeCurrentItem(); | 1325 | storeCurrentItem(); |
1342 | } | 1326 | } |
1343 | setOpen(mTodoListView->firstChild(), false); | 1327 | setOpen(mTodoListView->firstChild(), false); |
1344 | resetCurrentItem(); | 1328 | resetCurrentItem(); |
1345 | } | 1329 | } |
1346 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1330 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1347 | { | 1331 | { |
1348 | 1332 | ||
1349 | while ( item ) { | 1333 | while ( item ) { |
1350 | setOpen( item->firstChild(), setOpenI ); | 1334 | setOpen( item->firstChild(), setOpenI ); |
1351 | item->setOpen( setOpenI ); | 1335 | item->setOpen( setOpenI ); |
1352 | item = item->nextSibling(); | 1336 | item = item->nextSibling(); |
1353 | } | 1337 | } |
1354 | } | 1338 | } |
1355 | 1339 | ||
1356 | void KOTodoView::displayAllFlat() | 1340 | void KOTodoView::displayAllFlat() |
1357 | { | 1341 | { |
1358 | pendingSubtodo = 0; | 1342 | pendingSubtodo = 0; |
1359 | if ( mBlockUpdate ) { | 1343 | if ( mBlockUpdate ) { |
1360 | return; | 1344 | return; |
1361 | } | 1345 | } |
1362 | mPopupMenu->setItemChecked( 8,true ); | 1346 | mPopupMenu->setItemChecked( 8,true ); |
1363 | isFlatDisplay = true; | 1347 | isFlatDisplay = true; |
1364 | QPtrList<Todo> todoList = calendar()->todos(); | 1348 | QPtrList<Todo> todoList = calendar()->todos(); |
1365 | mTodoMap.clear(); | 1349 | mTodoMap.clear(); |
1366 | mTodoListView->clear(); | 1350 | mTodoListView->clear(); |
1367 | Todo *todo; | 1351 | Todo *todo; |
1368 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1352 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1369 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1353 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1370 | mTodoMap.insert(todo,todoItem); | 1354 | mTodoMap.insert(todo,todoItem); |
1371 | } | 1355 | } |
1372 | mTodoListView->setFocus(); | 1356 | mTodoListView->setFocus(); |
1373 | processSelectionChange(); | 1357 | processSelectionChange(); |
1374 | } | 1358 | } |
1375 | 1359 | ||
1376 | void KOTodoView::setAllFlat() | 1360 | void KOTodoView::setAllFlat() |
1377 | { | 1361 | { |
1378 | if ( isFlatDisplay ) { | 1362 | if ( isFlatDisplay ) { |
1379 | isFlatDisplay = false; | 1363 | isFlatDisplay = false; |
1380 | mPopupMenu->setItemChecked( 8,false ); | 1364 | mPopupMenu->setItemChecked( 8,false ); |
1381 | updateView(); | 1365 | updateView(); |
1382 | return; | 1366 | return; |
1383 | } | 1367 | } |
1384 | storeCurrentItem(); | 1368 | storeCurrentItem(); |
1385 | displayAllFlat(); | 1369 | displayAllFlat(); |
1386 | resetCurrentItem(); | 1370 | resetCurrentItem(); |
1387 | } | 1371 | } |
1388 | 1372 | ||
1389 | void KOTodoView::purgeCompleted() | 1373 | void KOTodoView::purgeCompleted() |
1390 | { | 1374 | { |
1391 | emit purgeCompletedSignal(); | 1375 | emit purgeCompletedSignal(); |
1392 | 1376 | ||
1393 | } | 1377 | } |
1394 | void KOTodoView::toggleQuickTodo() | 1378 | void KOTodoView::toggleQuickTodo() |
1395 | { | 1379 | { |
1396 | if ( mQuickAdd->isVisible() ) { | 1380 | if ( mQuickAdd->isVisible() ) { |
1397 | mQuickAdd->hide(); | 1381 | mQuickAdd->hide(); |
1398 | KOPrefs::instance()->mEnableQuickTodo = false; | 1382 | KOPrefs::instance()->mEnableQuickTodo = false; |
1399 | } | 1383 | } |
1400 | else { | 1384 | else { |
1401 | mQuickAdd->show(); | 1385 | mQuickAdd->show(); |
1402 | KOPrefs::instance()->mEnableQuickTodo = true; | 1386 | KOPrefs::instance()->mEnableQuickTodo = true; |
1403 | } | 1387 | } |
1404 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1388 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1405 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1389 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1406 | } | 1390 | } |
1407 | 1391 | ||
1408 | void KOTodoView::toggleRunning() | 1392 | void KOTodoView::toggleRunning() |
1409 | { | 1393 | { |
1410 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1394 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1411 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1395 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1412 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1396 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1413 | updateView(); | 1397 | updateView(); |
1414 | } | 1398 | } |
1415 | 1399 | ||
1416 | void KOTodoView::toggleCompleted() | 1400 | void KOTodoView::toggleCompleted() |
1417 | { | 1401 | { |
1418 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1402 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1419 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1403 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1420 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1404 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1421 | updateView(); | 1405 | updateView(); |
1422 | } | 1406 | } |
1423 | 1407 | ||
1424 | void KOTodoView::addQuickTodo() | 1408 | void KOTodoView::addQuickTodo() |
1425 | { | 1409 | { |
1426 | Todo *todo = new Todo(); | 1410 | Todo *todo = new Todo(); |
1427 | todo->setSummary(mQuickAdd->text()); | 1411 | todo->setSummary(mQuickAdd->text()); |
1428 | todo->setOrganizer(KOPrefs::instance()->email()); | 1412 | todo->setOrganizer(KOPrefs::instance()->email()); |
1429 | CalFilter * cf = mCalendar->filter(); | 1413 | CalFilter * cf = mCalendar->filter(); |
1430 | if ( cf ) { | 1414 | if ( cf ) { |
1431 | if ( cf->isEnabled()&& cf->showCategories()) { | 1415 | if ( cf->isEnabled()&& cf->showCategories()) { |
1432 | todo->setCategories(cf->categoryList()); | 1416 | todo->setCategories(cf->categoryList()); |
1433 | } | 1417 | } |
1434 | if ( cf->isEnabled() ) | 1418 | if ( cf->isEnabled() ) |
1435 | todo->setSecrecy( cf->getSecrecy()); | 1419 | todo->setSecrecy( cf->getSecrecy()); |
1436 | } | 1420 | } |
1437 | mCalendar->addTodo(todo); | 1421 | mCalendar->addTodo(todo); |
1438 | mQuickAdd->setText(""); | 1422 | mQuickAdd->setText(""); |
1439 | todoModified (todo, KOGlobals::EVENTADDED ); | 1423 | todoModified (todo, KOGlobals::EVENTADDED ); |
1440 | updateView(); | 1424 | updateView(); |
1441 | } | 1425 | } |
1442 | 1426 | ||
1443 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1427 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1444 | { | 1428 | { |
1445 | // e->ignore(); | 1429 | // e->ignore(); |
1446 | //return; | 1430 | //return; |
1447 | //qDebug("KOTodoView::keyPressEvent "); | 1431 | //qDebug("KOTodoView::keyPressEvent "); |
1448 | switch ( e->key() ) { | 1432 | switch ( e->key() ) { |
1449 | case Qt::Key_Down: | 1433 | case Qt::Key_Down: |
1450 | case Qt::Key_Up: | 1434 | case Qt::Key_Up: |
1451 | QWidget::keyPressEvent ( e ); | 1435 | QWidget::keyPressEvent ( e ); |
1452 | break; | 1436 | break; |
1453 | 1437 | ||
1454 | case Qt::Key_Q: | 1438 | case Qt::Key_Q: |
1455 | toggleQuickTodo(); | 1439 | toggleQuickTodo(); |
1456 | break; | 1440 | break; |
1457 | case Qt::Key_U: | 1441 | case Qt::Key_U: |
1458 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1442 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1459 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1443 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1460 | unparentTodo(); | 1444 | unparentTodo(); |
1461 | e->accept(); | 1445 | e->accept(); |
1462 | } else | 1446 | } else |
1463 | e->ignore(); | 1447 | e->ignore(); |
1464 | break; | 1448 | break; |
1465 | case Qt::Key_S: | 1449 | case Qt::Key_S: |
1466 | if ( e->state() == Qt::ControlButton ) { | 1450 | if ( e->state() == Qt::ControlButton ) { |
1467 | e->ignore(); | 1451 | e->ignore(); |
1468 | break; | 1452 | break; |
1469 | } | 1453 | } |
1470 | if ( e->state() == Qt::ShiftButton ) { | 1454 | if ( e->state() == Qt::ShiftButton ) { |
1471 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1455 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1472 | reparentTodo(); | 1456 | reparentTodo(); |
1473 | e->accept(); | 1457 | e->accept(); |
1474 | } else | 1458 | } else |
1475 | e->ignore(); | 1459 | e->ignore(); |
1476 | break; | 1460 | break; |
1477 | case Qt::Key_P: | 1461 | case Qt::Key_P: |
1478 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1462 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1479 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1463 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1480 | if ( pendingSubtodo ) | 1464 | if ( pendingSubtodo ) |
1481 | itemClicked(mActiveItem); | 1465 | itemClicked(mActiveItem); |
1482 | e->accept(); | 1466 | e->accept(); |
1483 | } else | 1467 | } else |
1484 | e->ignore(); | 1468 | e->ignore(); |
1485 | break; | 1469 | break; |
1486 | case Qt::Key_Escape: | 1470 | case Qt::Key_Escape: |
1487 | if ( pendingSubtodo ) { | 1471 | if ( pendingSubtodo ) { |
1488 | itemClicked(0); | 1472 | itemClicked(0); |
1489 | e->accept(); | 1473 | e->accept(); |
1490 | } else | 1474 | } else |
1491 | e->ignore(); | 1475 | e->ignore(); |
1492 | break; | 1476 | break; |
1493 | default: | 1477 | default: |
1494 | e->ignore(); | 1478 | e->ignore(); |
1495 | } | 1479 | } |
1496 | 1480 | ||
1497 | if ( true ) { | 1481 | if ( true ) { |
1498 | if ( e->key() == Qt::Key_I ) { | 1482 | if ( e->key() == Qt::Key_I ) { |
1499 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1483 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1500 | if ( cn ) { | 1484 | if ( cn ) { |
1501 | mActiveItem = cn; | 1485 | mActiveItem = cn; |
1502 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1486 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1503 | if ( ci ){ | 1487 | if ( ci ){ |
1504 | showTodo(); | 1488 | showTodo(); |
1505 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1489 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1506 | if ( cn ) { | 1490 | if ( cn ) { |
1507 | mTodoListView->setCurrentItem ( cn ); | 1491 | mTodoListView->setCurrentItem ( cn ); |
1508 | mTodoListView->ensureItemVisible ( cn ); | 1492 | mTodoListView->ensureItemVisible ( cn ); |
1509 | } | 1493 | } |
1510 | 1494 | ||
1511 | } | 1495 | } |
1512 | } | 1496 | } |
1513 | e->accept(); | 1497 | e->accept(); |
1514 | 1498 | ||
1515 | } | 1499 | } |
1516 | 1500 | ||
1517 | } | 1501 | } |
1518 | 1502 | ||
1519 | } | 1503 | } |
1520 | void KOTodoView::updateTodo( Todo * t, int type ) | 1504 | void KOTodoView::updateTodo( Todo * t, int type ) |
1521 | { | 1505 | { |
1522 | if ( mBlockUpdate) | 1506 | if ( mBlockUpdate) |
1523 | return; | 1507 | return; |
1524 | 1508 | ||
1525 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1509 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1526 | itemIterator = mTodoMap.find(t); | 1510 | itemIterator = mTodoMap.find(t); |
1527 | if (itemIterator != mTodoMap.end()) { | 1511 | if (itemIterator != mTodoMap.end()) { |
1528 | (*itemIterator)->construct(); | 1512 | (*itemIterator)->construct(); |
1529 | } else { | 1513 | } else { |
1530 | if ( type == KOGlobals::EVENTADDED ) { | 1514 | if ( type == KOGlobals::EVENTADDED ) { |
1531 | insertTodoItem( t ); | 1515 | insertTodoItem( t ); |
1532 | } | 1516 | } |
1533 | } | 1517 | } |
1534 | 1518 | ||
1535 | } | 1519 | } |
1536 | 1520 | ||
1537 | void KOTodoView::todoModified(Todo * t , int p ) | 1521 | void KOTodoView::todoModified(Todo * t , int p ) |
1538 | { | 1522 | { |
1539 | mBlockUpdate = true; | 1523 | mBlockUpdate = true; |
1540 | emit todoModifiedSignal ( t, p ); | 1524 | emit todoModifiedSignal ( t, p ); |
1541 | mBlockUpdate = false; | 1525 | mBlockUpdate = false; |
1542 | } | 1526 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 13e186d..f945383 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2526 +1,2527 @@ | |||
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/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "ktoolbar.h" | 60 | #include "ktoolbar.h" |
61 | #include "klocale.h" | 61 | #include "klocale.h" |
62 | #include "kconfig.h" | 62 | #include "kconfig.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | #include <kglobalsettings.h> | 64 | #include <kglobalsettings.h> |
65 | 65 | ||
66 | using namespace KCal; | 66 | using namespace KCal; |
67 | #ifndef _WIN32_ | 67 | #ifndef _WIN32_ |
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | #else | 69 | #else |
70 | #ifdef _OL_IMPORT_ | 70 | #ifdef _OL_IMPORT_ |
71 | #include "koimportoldialog.h" | 71 | #include "koimportoldialog.h" |
72 | #endif | 72 | #endif |
73 | #endif | 73 | #endif |
74 | #include "mainwindow.h" | 74 | #include "mainwindow.h" |
75 | 75 | ||
76 | 76 | ||
77 | class KOex2phonePrefs : public QDialog | 77 | class KOex2phonePrefs : public QDialog |
78 | { | 78 | { |
79 | public: | 79 | public: |
80 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 80 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
81 | QDialog( parent, name, true ) | 81 | QDialog( parent, name, true ) |
82 | { | 82 | { |
83 | setCaption( i18n("Export to phone options") ); | 83 | setCaption( i18n("Export to phone options") ); |
84 | QVBoxLayout* lay = new QVBoxLayout( this ); | 84 | QVBoxLayout* lay = new QVBoxLayout( this ); |
85 | lay->setSpacing( 3 ); | 85 | lay->setSpacing( 3 ); |
86 | lay->setMargin( 3 ); | 86 | lay->setMargin( 3 ); |
87 | QLabel *lab; | 87 | QLabel *lab; |
88 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 88 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
89 | lab->setAlignment (AlignHCenter ); | 89 | lab->setAlignment (AlignHCenter ); |
90 | QHBox* temphb; | 90 | QHBox* temphb; |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("I/O device: "), temphb ); | 92 | new QLabel( i18n("I/O device: "), temphb ); |
93 | mPhoneDevice = new QLineEdit( temphb); | 93 | mPhoneDevice = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Connection: "), temphb ); | 96 | new QLabel( i18n("Connection: "), temphb ); |
97 | mPhoneConnection = new QLineEdit( temphb); | 97 | mPhoneConnection = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | temphb = new QHBox( this ); | 99 | temphb = new QHBox( this ); |
100 | new QLabel( i18n("Model(opt.): "), temphb ); | 100 | new QLabel( i18n("Model(opt.): "), temphb ); |
101 | mPhoneModel = new QLineEdit( temphb); | 101 | mPhoneModel = new QLineEdit( temphb); |
102 | lay->addWidget( temphb ); | 102 | lay->addWidget( temphb ); |
103 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 103 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
104 | mWriteBackFuture->setChecked( true ); | 104 | mWriteBackFuture->setChecked( true ); |
105 | lay->addWidget( mWriteBackFuture ); | 105 | lay->addWidget( mWriteBackFuture ); |
106 | temphb = new QHBox( this ); | 106 | temphb = new QHBox( this ); |
107 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 107 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
108 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 108 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
109 | mWriteBackFutureWeeks->setValue( 8 ); | 109 | mWriteBackFutureWeeks->setValue( 8 ); |
110 | lay->addWidget( temphb ); | 110 | lay->addWidget( temphb ); |
111 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 111 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
112 | lab->setAlignment (AlignHCenter ); | 112 | lab->setAlignment (AlignHCenter ); |
113 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 113 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
114 | lay->addWidget( ok ); | 114 | lay->addWidget( ok ); |
115 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 115 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
116 | lay->addWidget( cancel ); | 116 | lay->addWidget( cancel ); |
117 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 117 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
118 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 118 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
119 | resize( 220, 240 ); | 119 | resize( 220, 240 ); |
120 | qApp->processEvents(); | 120 | qApp->processEvents(); |
121 | int dw = QApplication::desktop()->width(); | 121 | int dw = QApplication::desktop()->width(); |
122 | int dh = QApplication::desktop()->height(); | 122 | int dh = QApplication::desktop()->height(); |
123 | move( (dw-width())/2, (dh - height() )/2 ); | 123 | move( (dw-width())/2, (dh - height() )/2 ); |
124 | } | 124 | } |
125 | 125 | ||
126 | public: | 126 | public: |
127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
128 | QCheckBox* mWriteBackFuture; | 128 | QCheckBox* mWriteBackFuture; |
129 | QSpinBox* mWriteBackFutureWeeks; | 129 | QSpinBox* mWriteBackFutureWeeks; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | int globalFlagBlockStartup; | 132 | int globalFlagBlockStartup; |
133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
134 | QMainWindow( parent, name ) | 134 | QMainWindow( parent, name ) |
135 | { | 135 | { |
136 | 136 | ||
137 | mClosed = false; | 137 | mClosed = false; |
138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
139 | QString confFile = locateLocal("config","korganizerrc"); | 139 | QString confFile = locateLocal("config","korganizerrc"); |
140 | QFileInfo finf ( confFile ); | 140 | QFileInfo finf ( confFile ); |
141 | bool showWarning = !finf.exists(); | 141 | bool showWarning = !finf.exists(); |
142 | setIcon(SmallIcon( "ko24" ) ); | 142 | setIcon(SmallIcon( "ko24" ) ); |
143 | mBlockAtStartup = true; | 143 | mBlockAtStartup = true; |
144 | mFlagKeyPressed = false; | 144 | mFlagKeyPressed = false; |
145 | setCaption("KO/Pi"); | 145 | setCaption("KO/Pi"); |
146 | KOPrefs *p = KOPrefs::instance(); | 146 | KOPrefs *p = KOPrefs::instance(); |
147 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 147 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
148 | p->mCurrentDisplayedView = 0; | 148 | p->mCurrentDisplayedView = 0; |
149 | if ( p->mHourSize > 22 ) | 149 | if ( p->mHourSize > 22 ) |
150 | p->mHourSize = 22; | 150 | p->mHourSize = 22; |
151 | QMainWindow::ToolBarDock tbd; | 151 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 152 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 153 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 154 | tbd = Bottom; |
155 | else | 155 | else |
156 | tbd = Top; | 156 | tbd = Top; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | if ( p->mToolBarUp ) | 159 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 160 | tbd = Right; |
161 | else | 161 | else |
162 | tbd = Left; | 162 | tbd = Left; |
163 | } | 163 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 164 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 166 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 167 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 168 | addToolBar (iconToolBar , tbd ); |
169 | 169 | ||
170 | #ifdef DESKTOP_VERSION | 170 | #ifdef DESKTOP_VERSION |
171 | if ( KOPrefs::instance()->mShowIconFilter ) | 171 | if ( KOPrefs::instance()->mShowIconFilter ) |
172 | #else | 172 | #else |
173 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) | 173 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | { | 176 | { |
177 | if ( p->mToolBarHorF ) { | 177 | if ( p->mToolBarHorF ) { |
178 | if ( p->mToolBarUpF ) | 178 | if ( p->mToolBarUpF ) |
179 | tbd = Bottom; | 179 | tbd = Bottom; |
180 | else | 180 | else |
181 | tbd = Top; | 181 | tbd = Top; |
182 | } | 182 | } |
183 | else { | 183 | else { |
184 | if ( p->mToolBarUpF ) | 184 | if ( p->mToolBarUpF ) |
185 | tbd = Right; | 185 | tbd = Right; |
186 | else | 186 | else |
187 | tbd = Left; | 187 | tbd = Left; |
188 | } | 188 | } |
189 | filterToolBar = new QPEToolBar ( this ); | 189 | filterToolBar = new QPEToolBar ( this ); |
190 | filterMenubar = new QMenuBar( 0 ); | 190 | filterMenubar = new QMenuBar( 0 ); |
191 | QFontMetrics fm ( filterMenubar->font() ); | 191 | QFontMetrics fm ( filterMenubar->font() ); |
192 | 192 | ||
193 | filterPopupMenu = new QPopupMenu( this ); | 193 | filterPopupMenu = new QPopupMenu( this ); |
194 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 194 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
195 | QString addTest = "A"; | 195 | QString addTest = "A"; |
196 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 196 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
197 | #ifdef DESKTOP_VERSION | 197 | #ifdef DESKTOP_VERSION |
198 | addTest = "AAABBBCCCx"; | 198 | addTest = "AAABBBCCCx"; |
199 | #else | 199 | #else |
200 | addTest = "AAx"; | 200 | addTest = "AAx"; |
201 | #endif | 201 | #endif |
202 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 202 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
203 | addToolBar (filterToolBar , tbd ); | 203 | addToolBar (filterToolBar , tbd ); |
204 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 204 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
205 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 205 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
206 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 206 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
207 | filterToolBar->hide(); | 207 | filterToolBar->hide(); |
208 | } else { | 208 | } else { |
209 | filterToolBar = 0; | 209 | filterToolBar = 0; |
210 | filterMenubar = 0; | 210 | filterMenubar = 0; |
211 | filterPopupMenu = 0; | 211 | filterPopupMenu = 0; |
212 | } | 212 | } |
213 | if ( p->mShowIconOnetoolbar ) { | 213 | if ( p->mShowIconOnetoolbar ) { |
214 | viewToolBar = iconToolBar ; | 214 | viewToolBar = iconToolBar ; |
215 | navigatorToolBar = iconToolBar ; | 215 | navigatorToolBar = iconToolBar ; |
216 | } else { | 216 | } else { |
217 | #ifndef DESKTOP_VERSION | 217 | #ifndef DESKTOP_VERSION |
218 | setToolBarsMovable( false ); | 218 | setToolBarsMovable( false ); |
219 | #endif | 219 | #endif |
220 | if ( p->mToolBarHorV ) { | 220 | if ( p->mToolBarHorV ) { |
221 | if ( p->mToolBarUpV ) | 221 | if ( p->mToolBarUpV ) |
222 | tbd = Bottom; | 222 | tbd = Bottom; |
223 | else | 223 | else |
224 | tbd = Top; | 224 | tbd = Top; |
225 | } | 225 | } |
226 | else { | 226 | else { |
227 | if ( p->mToolBarUpV ) | 227 | if ( p->mToolBarUpV ) |
228 | tbd = Right; | 228 | tbd = Right; |
229 | else | 229 | else |
230 | tbd = Left; | 230 | tbd = Left; |
231 | } | 231 | } |
232 | viewToolBar = new QPEToolBar( this ); | 232 | viewToolBar = new QPEToolBar( this ); |
233 | addToolBar (viewToolBar , tbd ); | 233 | addToolBar (viewToolBar , tbd ); |
234 | if ( p->mToolBarHorN ) { | 234 | if ( p->mToolBarHorN ) { |
235 | if ( p->mToolBarUpN ) | 235 | if ( p->mToolBarUpN ) |
236 | tbd = Bottom; | 236 | tbd = Bottom; |
237 | else | 237 | else |
238 | tbd = Top; | 238 | tbd = Top; |
239 | } | 239 | } |
240 | else { | 240 | else { |
241 | if ( p->mToolBarUpN ) | 241 | if ( p->mToolBarUpN ) |
242 | tbd = Right; | 242 | tbd = Right; |
243 | else | 243 | else |
244 | tbd = Left; | 244 | tbd = Left; |
245 | } | 245 | } |
246 | navigatorToolBar = new QPEToolBar( this ); | 246 | navigatorToolBar = new QPEToolBar( this ); |
247 | addToolBar (navigatorToolBar , tbd ); | 247 | addToolBar (navigatorToolBar , tbd ); |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | 251 | ||
252 | mCalendarModifiedFlag = false; | 252 | mCalendarModifiedFlag = false; |
253 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 253 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
254 | splash->setAlignment ( AlignCenter ); | 254 | splash->setAlignment ( AlignCenter ); |
255 | setCentralWidget( splash ); | 255 | setCentralWidget( splash ); |
256 | #ifndef DESKTOP_VERSION | 256 | #ifndef DESKTOP_VERSION |
257 | showMaximized(); | 257 | showMaximized(); |
258 | #endif | 258 | #endif |
259 | 259 | ||
260 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 260 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
261 | setDefaultPreferences(); | 261 | setDefaultPreferences(); |
262 | mCalendar = new CalendarLocal(); | 262 | mCalendar = new CalendarLocal(); |
263 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 263 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
264 | mView->hide(); | 264 | mView->hide(); |
265 | //mView->resize(splash->size() ); | 265 | //mView->resize(splash->size() ); |
266 | initActions(); | 266 | initActions(); |
267 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 267 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
268 | mSyncManager->setBlockSave(false); | 268 | mSyncManager->setBlockSave(false); |
269 | mView->setSyncManager(mSyncManager); | 269 | mView->setSyncManager(mSyncManager); |
270 | #ifndef DESKTOP_VERSION | 270 | #ifndef DESKTOP_VERSION |
271 | iconToolBar->show(); | 271 | iconToolBar->show(); |
272 | qApp->processEvents(); | 272 | qApp->processEvents(); |
273 | #endif | 273 | #endif |
274 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 274 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
275 | int vh = height() ; | 275 | int vh = height() ; |
276 | int vw = width(); | 276 | int vw = width(); |
277 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 277 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
278 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 278 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
279 | vh -= iconToolBar->height(); | 279 | vh -= iconToolBar->height(); |
280 | } else { | 280 | } else { |
281 | vw -= iconToolBar->height(); | 281 | vw -= iconToolBar->height(); |
282 | } | 282 | } |
283 | //mView->setMaximumSize( splash->size() ); | 283 | //mView->setMaximumSize( splash->size() ); |
284 | //mView->resize( splash->size() ); | 284 | //mView->resize( splash->size() ); |
285 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 285 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
286 | mView->readSettings(); | 286 | mView->readSettings(); |
287 | bool newFile = false; | 287 | bool newFile = false; |
288 | if( !QFile::exists( defaultFileName() ) ) { | 288 | if( !QFile::exists( defaultFileName() ) ) { |
289 | QFileInfo finfo ( defaultFileName() ); | 289 | QFileInfo finfo ( defaultFileName() ); |
290 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 290 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
291 | 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"; | 291 | 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"; |
292 | finfo.setFile( oldFile ); | 292 | finfo.setFile( oldFile ); |
293 | if (finfo.exists() ) { | 293 | if (finfo.exists() ) { |
294 | KMessageBox::information( this, message); | 294 | KMessageBox::information( this, message); |
295 | mView->openCalendar( oldFile ); | 295 | mView->openCalendar( oldFile ); |
296 | qApp->processEvents(); | 296 | qApp->processEvents(); |
297 | } else { | 297 | } else { |
298 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 298 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
299 | finfo.setFile( oldFile ); | 299 | finfo.setFile( oldFile ); |
300 | if (finfo.exists() ) { | 300 | if (finfo.exists() ) { |
301 | KMessageBox::information( this, message); | 301 | KMessageBox::information( this, message); |
302 | mView->openCalendar( oldFile ); | 302 | mView->openCalendar( oldFile ); |
303 | qApp->processEvents(); | 303 | qApp->processEvents(); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | mView->saveCalendar( defaultFileName() ); | 306 | mView->saveCalendar( defaultFileName() ); |
307 | newFile = true; | 307 | newFile = true; |
308 | } | 308 | } |
309 | 309 | ||
310 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 310 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
311 | mView->loadCalendars(); | 311 | mView->loadCalendars(); |
312 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 312 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
313 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 313 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
314 | 314 | ||
315 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 315 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
316 | KOPrefs::instance()->setAllDefaults(); | 316 | KOPrefs::instance()->setAllDefaults(); |
317 | int count = mView->addCategories(); | 317 | int count = mView->addCategories(); |
318 | } | 318 | } |
319 | processIncidenceSelection( 0 ); | 319 | processIncidenceSelection( 0 ); |
320 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 320 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
321 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 321 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
322 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 322 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
323 | SLOT( slotModifiedChanged( bool ) ) ); | 323 | SLOT( slotModifiedChanged( bool ) ) ); |
324 | 324 | ||
325 | 325 | ||
326 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 326 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
327 | SLOT( disableBR(bool) ) ); | 327 | SLOT( disableBR(bool) ) ); |
328 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 328 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
329 | mView->setModified( false ); | 329 | mView->setModified( false ); |
330 | mBlockAtStartup = false; | 330 | mBlockAtStartup = false; |
331 | mView->setModified( false ); | 331 | mView->setModified( false ); |
332 | setCentralWidget( mView ); | 332 | setCentralWidget( mView ); |
333 | globalFlagBlockStartup = 0; | 333 | globalFlagBlockStartup = 0; |
334 | mView->show(); | 334 | mView->show(); |
335 | delete splash; | 335 | delete splash; |
336 | if ( newFile ) | 336 | if ( newFile ) |
337 | mView->updateConfig(); | 337 | mView->updateConfig(); |
338 | // qApp->processEvents(); | 338 | // qApp->processEvents(); |
339 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 339 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
340 | //fillSyncMenu(); | 340 | //fillSyncMenu(); |
341 | 341 | ||
342 | 342 | ||
343 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 343 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
344 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 344 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
345 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 345 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
346 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 346 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
347 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 347 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
348 | mSyncManager->setDefaultFileName( sentSyncFile()); | 348 | mSyncManager->setDefaultFileName( sentSyncFile()); |
349 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 349 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
350 | mSyncManager->fillSyncMenu(); | 350 | mSyncManager->fillSyncMenu(); |
351 | 351 | ||
352 | 352 | ||
353 | 353 | ||
354 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 354 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
355 | if ( showWarning ) { | 355 | if ( showWarning ) { |
356 | KMessageBox::information( this, | 356 | KMessageBox::information( this, |
357 | "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"); | 357 | "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"); |
358 | qApp->processEvents(); | 358 | qApp->processEvents(); |
359 | mView->dialogManager()->showSyncOptions(); | 359 | mView->dialogManager()->showSyncOptions(); |
360 | } | 360 | } |
361 | 361 | ||
362 | //US listen for result adressed from Ka/Pi | 362 | //US listen for result adressed from Ka/Pi |
363 | #ifndef DESKTOP_VERSION | 363 | #ifndef DESKTOP_VERSION |
364 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 364 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
365 | #endif | 365 | #endif |
366 | #ifndef DESKTOP_VERSION | 366 | #ifndef DESKTOP_VERSION |
367 | infrared = 0; | 367 | infrared = 0; |
368 | #endif | 368 | #endif |
369 | updateFilterToolbar(); | 369 | updateFilterToolbar(); |
370 | updateWeek( mView->startDate() ); | 370 | updateWeek( mView->startDate() ); |
371 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 371 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
372 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 372 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
373 | mBRdisabled = false; | 373 | mBRdisabled = false; |
374 | //toggleBeamReceive(); | 374 | //toggleBeamReceive(); |
375 | int tiint= 3000; | 375 | int tiint= 3000; |
376 | #ifndef DESKTOP_VERSION | 376 | #ifndef DESKTOP_VERSION |
377 | tiint = 5000; | 377 | tiint = 5000; |
378 | #endif | 378 | #endif |
379 | QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); | 379 | QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); |
380 | } | 380 | } |
381 | MainWindow::~MainWindow() | 381 | MainWindow::~MainWindow() |
382 | { | 382 | { |
383 | //qDebug("MainWindow::~MainWindow() "); | 383 | //qDebug("MainWindow::~MainWindow() "); |
384 | //save toolbar location | 384 | //save toolbar location |
385 | delete mCalendar; | 385 | delete mCalendar; |
386 | delete mSyncManager; | 386 | delete mSyncManager; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | if ( infrared ) | 388 | if ( infrared ) |
389 | delete infrared; | 389 | delete infrared; |
390 | #endif | 390 | #endif |
391 | 391 | ||
392 | 392 | ||
393 | } | 393 | } |
394 | 394 | ||
395 | void MainWindow::disableBR(bool b) | 395 | void MainWindow::disableBR(bool b) |
396 | { | 396 | { |
397 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
398 | if ( b ) { | 398 | if ( b ) { |
399 | if ( infrared ) { | 399 | if ( infrared ) { |
400 | toggleBeamReceive(); | 400 | toggleBeamReceive(); |
401 | mBRdisabled = true; | 401 | mBRdisabled = true; |
402 | } | 402 | } |
403 | mBRdisabled = true; | 403 | mBRdisabled = true; |
404 | } else { | 404 | } else { |
405 | if ( mBRdisabled ) { | 405 | if ( mBRdisabled ) { |
406 | mBRdisabled = false; | 406 | mBRdisabled = false; |
407 | //makes no sense,because other cal ap is probably running | 407 | //makes no sense,because other cal ap is probably running |
408 | // toggleBeamReceive(); | 408 | // toggleBeamReceive(); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | #endif | 411 | #endif |
412 | 412 | ||
413 | } | 413 | } |
414 | bool MainWindow::beamReceiveEnabled() | 414 | bool MainWindow::beamReceiveEnabled() |
415 | { | 415 | { |
416 | #ifndef DESKTOP_VERSION | 416 | #ifndef DESKTOP_VERSION |
417 | return ( infrared != 0 ); | 417 | return ( infrared != 0 ); |
418 | #endif | 418 | #endif |
419 | return false; | 419 | return false; |
420 | } | 420 | } |
421 | 421 | ||
422 | void MainWindow::toggleBeamReceive() | 422 | void MainWindow::toggleBeamReceive() |
423 | { | 423 | { |
424 | if ( mBRdisabled ) | 424 | if ( mBRdisabled ) |
425 | return; | 425 | return; |
426 | #ifndef DESKTOP_VERSION | 426 | #ifndef DESKTOP_VERSION |
427 | if ( infrared ) { | 427 | if ( infrared ) { |
428 | qDebug("KO: Disable BeamReceive "); | 428 | qDebug("KO: Disable BeamReceive "); |
429 | delete infrared; | 429 | delete infrared; |
430 | infrared = 0; | 430 | infrared = 0; |
431 | brAction->setOn(false); | 431 | brAction->setOn(false); |
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | qDebug("KO: Enable BeamReceive "); | 434 | qDebug("KO: Enable BeamReceive "); |
435 | brAction->setOn(true); | 435 | brAction->setOn(true); |
436 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 436 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
437 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 437 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
438 | #endif | 438 | #endif |
439 | } | 439 | } |
440 | void MainWindow::showMaximized () | 440 | void MainWindow::showMaximized () |
441 | { | 441 | { |
442 | #ifndef DESKTOP_VERSION | 442 | #ifndef DESKTOP_VERSION |
443 | if ( ! globalFlagBlockStartup ) | 443 | if ( ! globalFlagBlockStartup ) |
444 | if ( mClosed ) | 444 | if ( mClosed ) |
445 | mView->goToday(); | 445 | mView->goToday(); |
446 | #endif | 446 | #endif |
447 | QWidget::showMaximized () ; | 447 | QWidget::showMaximized () ; |
448 | mClosed = false; | 448 | mClosed = false; |
449 | } | 449 | } |
450 | void MainWindow::closeEvent( QCloseEvent* ce ) | 450 | void MainWindow::closeEvent( QCloseEvent* ce ) |
451 | { | 451 | { |
452 | 452 | ||
453 | 453 | ||
454 | 454 | ||
455 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 455 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
456 | saveOnClose(); | 456 | saveOnClose(); |
457 | mClosed = true; | 457 | mClosed = true; |
458 | ce->accept(); | 458 | ce->accept(); |
459 | return; | 459 | return; |
460 | 460 | ||
461 | } | 461 | } |
462 | 462 | ||
463 | switch( QMessageBox::information( this, "KO/Pi", | 463 | switch( QMessageBox::information( this, "KO/Pi", |
464 | i18n("Do you really want\nto close KO/Pi?"), | 464 | i18n("Do you really want\nto close KO/Pi?"), |
465 | i18n("Close"), i18n("No"), | 465 | i18n("Close"), i18n("No"), |
466 | 0, 0 ) ) { | 466 | 0, 0 ) ) { |
467 | case 0: | 467 | case 0: |
468 | saveOnClose(); | 468 | saveOnClose(); |
469 | mClosed = true; | 469 | mClosed = true; |
470 | ce->accept(); | 470 | ce->accept(); |
471 | break; | 471 | break; |
472 | case 1: | 472 | case 1: |
473 | ce->ignore(); | 473 | ce->ignore(); |
474 | break; | 474 | break; |
475 | case 2: | 475 | case 2: |
476 | 476 | ||
477 | default: | 477 | default: |
478 | break; | 478 | break; |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 484 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
485 | { | 485 | { |
486 | QDataStream stream( data, IO_ReadOnly ); | 486 | QDataStream stream( data, IO_ReadOnly ); |
487 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 487 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
488 | //QString datamess; | 488 | //QString datamess; |
489 | //qDebug("message "); | 489 | //qDebug("message "); |
490 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 490 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
491 | 491 | ||
492 | if ( cmsg == "setDocument(QString)" ) { | 492 | if ( cmsg == "setDocument(QString)" ) { |
493 | QDataStream stream( data, IO_ReadOnly ); | 493 | QDataStream stream( data, IO_ReadOnly ); |
494 | QString fileName; | 494 | QString fileName; |
495 | stream >> fileName; | 495 | stream >> fileName; |
496 | //qDebug("filename %s ", fileName.latin1()); | 496 | //qDebug("filename %s ", fileName.latin1()); |
497 | showMaximized(); | 497 | showMaximized(); |
498 | raise(); | 498 | raise(); |
499 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 499 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
500 | mSyncManager->slotSyncMenu( 1002 ); | 500 | mSyncManager->slotSyncMenu( 1002 ); |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | 503 | ||
504 | if ( cmsg == "-writeFile" ) { | 504 | if ( cmsg == "-writeFile" ) { |
505 | // I made from the "-writeFile" an "-writeAlarm" | 505 | // I made from the "-writeFile" an "-writeAlarm" |
506 | mView->viewManager()->showWhatsNextView(); | 506 | mView->viewManager()->showWhatsNextView(); |
507 | mCalendar->checkAlarmForIncidence( 0, true); | 507 | mCalendar->checkAlarmForIncidence( 0, true); |
508 | showMaximized(); | 508 | showMaximized(); |
509 | raise(); | 509 | raise(); |
510 | return; | 510 | return; |
511 | 511 | ||
512 | } | 512 | } |
513 | if ( cmsg == "-writeFileSilent" ) { | 513 | if ( cmsg == "-writeFileSilent" ) { |
514 | // I made from the "-writeFile" an "-writeAlarm" | 514 | // I made from the "-writeFile" an "-writeAlarm" |
515 | // mView->viewManager()->showWhatsNextView(); | 515 | // mView->viewManager()->showWhatsNextView(); |
516 | mCalendar->checkAlarmForIncidence( 0, true); | 516 | mCalendar->checkAlarmForIncidence( 0, true); |
517 | //showMaximized(); | 517 | //showMaximized(); |
518 | //raise(); | 518 | //raise(); |
519 | hide(); | 519 | hide(); |
520 | return; | 520 | return; |
521 | } | 521 | } |
522 | if ( cmsg == "-newCountdown" ) { | 522 | if ( cmsg == "-newCountdown" ) { |
523 | qDebug("newCountdown "); | 523 | qDebug("newCountdown "); |
524 | 524 | ||
525 | } | 525 | } |
526 | QString msg ; | 526 | QString msg ; |
527 | QString allmsg = cmsg; | 527 | QString allmsg = cmsg; |
528 | while ( allmsg.length() > 0 ) { | 528 | while ( allmsg.length() > 0 ) { |
529 | int nextC = allmsg.find( "-", 1 ); | 529 | int nextC = allmsg.find( "-", 1 ); |
530 | if ( nextC == -1 ) { | 530 | if ( nextC == -1 ) { |
531 | msg = allmsg; | 531 | msg = allmsg; |
532 | allmsg = ""; | 532 | allmsg = ""; |
533 | } else{ | 533 | } else{ |
534 | msg = allmsg.left( nextC ); | 534 | msg = allmsg.left( nextC ); |
535 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 535 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
536 | } | 536 | } |
537 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 537 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
538 | if ( msg == "-newEvent" ) { | 538 | if ( msg == "-newEvent" ) { |
539 | mView->newEvent(); | 539 | mView->newEvent(); |
540 | } | 540 | } |
541 | if ( msg == "-newTodo" ) { | 541 | if ( msg == "-newTodo" ) { |
542 | mView->newTodo(); | 542 | mView->newTodo(); |
543 | 543 | ||
544 | } | 544 | } |
545 | if ( msg == "-showWN" ) { | 545 | if ( msg == "-showWN" ) { |
546 | mView->viewManager()->showWhatsNextView(); | 546 | mView->viewManager()->showWhatsNextView(); |
547 | } | 547 | } |
548 | if ( msg == "-showTodo" ) { | 548 | if ( msg == "-showTodo" ) { |
549 | mView->viewManager()->showTodoView(); | 549 | mView->viewManager()->showTodoView(); |
550 | } | 550 | } |
551 | if ( msg == "-showList" ) { | 551 | if ( msg == "-showList" ) { |
552 | mView->viewManager()->showListView(); | 552 | mView->viewManager()->showListView(); |
553 | } | 553 | } |
554 | else if ( msg == "-showDay" ) { | 554 | else if ( msg == "-showDay" ) { |
555 | mView->viewManager()->showDayView(); | 555 | mView->viewManager()->showDayView(); |
556 | } | 556 | } |
557 | else if ( msg == "-showWWeek" ) { | 557 | else if ( msg == "-showWWeek" ) { |
558 | mView->viewManager()->showWorkWeekView(); | 558 | mView->viewManager()->showWorkWeekView(); |
559 | } | 559 | } |
560 | else if ( msg == "-ringSync" ) { | 560 | else if ( msg == "-ringSync" ) { |
561 | mSyncManager->multiSync( false ); | 561 | mSyncManager->multiSync( false ); |
562 | } | 562 | } |
563 | else if ( msg == "-showWeek" ) { | 563 | else if ( msg == "-showWeek" ) { |
564 | mView->viewManager()->showWeekView(); | 564 | mView->viewManager()->showWeekView(); |
565 | } | 565 | } |
566 | else if ( msg == "-showTodo" ) { | 566 | else if ( msg == "-showTodo" ) { |
567 | mView->viewManager()->showTodoView(); | 567 | mView->viewManager()->showTodoView(); |
568 | } | 568 | } |
569 | else if ( msg == "-showJournal" ) { | 569 | else if ( msg == "-showJournal" ) { |
570 | mView->dateNavigator()->selectDates( 1 ); | 570 | mView->dateNavigator()->selectDates( 1 ); |
571 | mView->dateNavigator()->selectToday(); | 571 | mView->dateNavigator()->selectToday(); |
572 | mView->viewManager()->showJournalView(); | 572 | mView->viewManager()->showJournalView(); |
573 | } | 573 | } |
574 | else if ( msg == "-showKO" ) { | 574 | else if ( msg == "-showKO" ) { |
575 | mView->viewManager()->showNextXView(); | 575 | mView->viewManager()->showNextXView(); |
576 | } | 576 | } |
577 | else if ( msg == "-showWNext" ) { | 577 | else if ( msg == "-showWNext" ) { |
578 | mView->viewManager()->showWhatsNextView(); | 578 | mView->viewManager()->showWhatsNextView(); |
579 | } | 579 | } |
580 | else if ( msg == "nextView()" ) { | 580 | else if ( msg == "nextView()" ) { |
581 | mView->viewManager()->showNextView(); | 581 | mView->viewManager()->showNextView(); |
582 | } | 582 | } |
583 | else if ( msg == "-showNextXView" ) { | 583 | else if ( msg == "-showNextXView" ) { |
584 | mView->viewManager()->showNextXView(); | 584 | mView->viewManager()->showNextXView(); |
585 | } | 585 | } |
586 | 586 | ||
587 | 587 | ||
588 | } | 588 | } |
589 | 589 | ||
590 | showMaximized(); | 590 | showMaximized(); |
591 | raise(); | 591 | raise(); |
592 | } | 592 | } |
593 | 593 | ||
594 | QPixmap MainWindow::loadPixmap( QString name ) | 594 | QPixmap MainWindow::loadPixmap( QString name ) |
595 | { | 595 | { |
596 | return SmallIcon( name ); | 596 | return SmallIcon( name ); |
597 | 597 | ||
598 | } | 598 | } |
599 | void MainWindow::setUsesBigPixmaps ( bool b ) | 599 | void MainWindow::setUsesBigPixmaps ( bool b ) |
600 | { | 600 | { |
601 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); | 601 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); |
602 | if ( b ) | 602 | if ( b ) |
603 | qDebug("KO: BigPixmaps are not supported "); | 603 | qDebug("KO: BigPixmaps are not supported "); |
604 | } | 604 | } |
605 | void MainWindow::initActions() | 605 | void MainWindow::initActions() |
606 | { | 606 | { |
607 | //KOPrefs::instance()->mShowFullMenu | 607 | //KOPrefs::instance()->mShowFullMenu |
608 | iconToolBar->clear(); | 608 | iconToolBar->clear(); |
609 | KOPrefs *p = KOPrefs::instance(); | 609 | KOPrefs *p = KOPrefs::instance(); |
610 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 610 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
611 | 611 | ||
612 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 612 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
613 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 613 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
614 | QPopupMenu *importMenu = new QPopupMenu( this ); | 614 | QPopupMenu *importMenu = new QPopupMenu( this ); |
615 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 615 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
616 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 616 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
617 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 617 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
618 | selectFilterMenu = new QPopupMenu( this ); | 618 | selectFilterMenu = new QPopupMenu( this ); |
619 | selectFilterMenu->setCheckable( true ); | 619 | selectFilterMenu->setCheckable( true ); |
620 | syncMenu = new QPopupMenu( this ); | 620 | syncMenu = new QPopupMenu( this ); |
621 | configureAgendaMenu = new QPopupMenu( this ); | 621 | configureAgendaMenu = new QPopupMenu( this ); |
622 | configureToolBarMenu = new QPopupMenu( this ); | 622 | configureToolBarMenu = new QPopupMenu( this ); |
623 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 623 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
624 | QIconSet icon; | 624 | QIconSet icon; |
625 | int pixWid = 22, pixHei = 22; | 625 | int pixWid = 22, pixHei = 22; |
626 | QString pathString = ""; | 626 | QString pathString = ""; |
627 | if ( !p->mToolBarMiniIcons ) { | 627 | if ( !p->mToolBarMiniIcons ) { |
628 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { | 628 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { |
629 | pathString += "icons16/"; | 629 | pathString += "icons16/"; |
630 | pixWid = 18; pixHei = 16; | 630 | pixWid = 18; pixHei = 16; |
631 | } | 631 | } |
632 | } else { | 632 | } else { |
633 | pathString += "iconsmini/"; | 633 | pathString += "iconsmini/"; |
634 | pixWid = 18; pixHei = 16; | 634 | pixWid = 18; pixHei = 16; |
635 | } | 635 | } |
636 | if ( KOPrefs::instance()->mShowFullMenu ) { | 636 | if ( KOPrefs::instance()->mShowFullMenu ) { |
637 | QMenuBar *menuBar1; | 637 | QMenuBar *menuBar1; |
638 | menuBar1 = menuBar(); | 638 | menuBar1 = menuBar(); |
639 | menuBar1->insertItem( i18n("File"), importMenu ); | 639 | menuBar1->insertItem( i18n("File"), importMenu ); |
640 | menuBar1->insertItem( i18n("View"), viewMenu ); | 640 | menuBar1->insertItem( i18n("View"), viewMenu ); |
641 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 641 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
642 | #ifdef DESKTOP_VERSION | 642 | #ifdef DESKTOP_VERSION |
643 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 643 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
644 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 644 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
645 | #else | 645 | #else |
646 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 646 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
647 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 647 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
648 | #endif | 648 | #endif |
649 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 649 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
650 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 650 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
651 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 651 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
652 | } else { | 652 | } else { |
653 | QPEMenuBar *menuBar1; | 653 | QPEMenuBar *menuBar1; |
654 | menuBar1 = new QPEMenuBar( iconToolBar ); | 654 | menuBar1 = new QPEMenuBar( iconToolBar ); |
655 | QPopupMenu *menuBar = new QPopupMenu( this ); | 655 | QPopupMenu *menuBar = new QPopupMenu( this ); |
656 | icon = loadPixmap( pathString + "z_menu" ); | 656 | icon = loadPixmap( pathString + "z_menu" ); |
657 | menuBar1->insertItem( icon.pixmap(), menuBar); | 657 | menuBar1->insertItem( icon.pixmap(), menuBar); |
658 | //menuBar1->insertItem( i18n("ME"), menuBar); | 658 | //menuBar1->insertItem( i18n("ME"), menuBar); |
659 | menuBar->insertItem( i18n("File"), importMenu ); | 659 | menuBar->insertItem( i18n("File"), importMenu ); |
660 | menuBar->insertItem( i18n("View"), viewMenu ); | 660 | menuBar->insertItem( i18n("View"), viewMenu ); |
661 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 661 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
662 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 662 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
663 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 663 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
664 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 664 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
665 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 665 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
666 | menuBar->insertItem( i18n("Help"), helpMenu ); | 666 | menuBar->insertItem( i18n("Help"), helpMenu ); |
667 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 667 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
668 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 668 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
669 | } | 669 | } |
670 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 670 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
671 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 671 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
672 | 672 | ||
673 | 673 | ||
674 | mWeekBgColor = iconToolBar->backgroundColor(); | 674 | mWeekBgColor = iconToolBar->backgroundColor(); |
675 | mWeekPixmap.resize( pixWid , pixHei ); | 675 | mWeekPixmap.resize( pixWid , pixHei ); |
676 | mWeekPixmap.fill( mWeekBgColor ); | 676 | mWeekPixmap.fill( mWeekBgColor ); |
677 | icon = mWeekPixmap; | 677 | icon = mWeekPixmap; |
678 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 678 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
679 | if ( p-> mShowIconWeekNum ) | 679 | if ( p-> mShowIconWeekNum ) |
680 | mWeekAction->addTo( iconToolBar ); | 680 | mWeekAction->addTo( iconToolBar ); |
681 | mWeekFont = font(); | 681 | mWeekFont = font(); |
682 | 682 | ||
683 | int fontPoint = mWeekFont.pointSize(); | 683 | int fontPoint = mWeekFont.pointSize(); |
684 | QFontMetrics f( mWeekFont ); | 684 | QFontMetrics f( mWeekFont ); |
685 | int fontWid = f.width( "30" ); | 685 | int fontWid = f.width( "30" ); |
686 | while ( fontWid > pixWid ) { | 686 | while ( fontWid > pixWid ) { |
687 | --fontPoint; | 687 | --fontPoint; |
688 | mWeekFont.setPointSize( fontPoint ); | 688 | mWeekFont.setPointSize( fontPoint ); |
689 | QFontMetrics f( mWeekFont ); | 689 | QFontMetrics f( mWeekFont ); |
690 | fontWid = f.width( "30" ); | 690 | fontWid = f.width( "30" ); |
691 | //qDebug("dec-- "); | 691 | //qDebug("dec-- "); |
692 | } | 692 | } |
693 | 693 | ||
694 | connect( mWeekAction, SIGNAL( activated() ), | 694 | connect( mWeekAction, SIGNAL( activated() ), |
695 | this, SLOT( weekAction() ) ); | 695 | this, SLOT( weekAction() ) ); |
696 | 696 | ||
697 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 697 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
698 | if ( p->mShowIconFilterview ) { | 698 | if ( p->mShowIconFilterview ) { |
699 | icon = loadPixmap( pathString + "filter" ); | 699 | icon = loadPixmap( pathString + "filter" ); |
700 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); | 700 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); |
701 | connect( actionFilterMenuTB, SIGNAL( activated() ), | 701 | connect( actionFilterMenuTB, SIGNAL( activated() ), |
702 | this, SLOT( fillFilterMenuTB() ) ); | 702 | this, SLOT( fillFilterMenuTB() ) ); |
703 | actionFilterMenuTB->addTo( iconToolBar ); | 703 | actionFilterMenuTB->addTo( iconToolBar ); |
704 | selectFilterMenuTB = new QPopupMenu( this ); | 704 | selectFilterMenuTB = new QPopupMenu( this ); |
705 | selectFilterMenuTB->setCheckable( true ); | 705 | selectFilterMenuTB->setCheckable( true ); |
706 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 706 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
707 | } | 707 | } |
708 | 708 | ||
709 | //#endif | 709 | //#endif |
710 | // ****************** | 710 | // ****************** |
711 | QAction *action; | 711 | QAction *action; |
712 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 712 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
713 | configureToolBarMenu->setCheckable( true ); | 713 | configureToolBarMenu->setCheckable( true ); |
714 | 714 | ||
715 | 715 | ||
716 | configureAgendaMenu->setCheckable( true ); | 716 | configureAgendaMenu->setCheckable( true ); |
717 | int iii ; | 717 | int iii ; |
718 | for ( iii = 1;iii<= 10 ;++iii ){ | 718 | for ( iii = 1;iii<= 10 ;++iii ){ |
719 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 719 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
720 | } | 720 | } |
721 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 721 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
722 | 722 | ||
723 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 723 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
724 | this, SLOT( showConfigureAgenda( ) ) ); | 724 | this, SLOT( showConfigureAgenda( ) ) ); |
725 | 725 | ||
726 | icon = loadPixmap( pathString + "configure" ); | 726 | icon = loadPixmap( pathString + "configure" ); |
727 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); | 727 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); |
728 | action->addTo( actionMenu ); | 728 | action->addTo( actionMenu ); |
729 | connect( action, SIGNAL( activated() ), | 729 | connect( action, SIGNAL( activated() ), |
730 | mView, SLOT( edit_options() ) ); | 730 | mView, SLOT( edit_options() ) ); |
731 | icon = loadPixmap( pathString + "configure" ); | 731 | icon = loadPixmap( pathString + "configure" ); |
732 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); | 732 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); |
733 | action->addTo( actionMenu ); | 733 | action->addTo( actionMenu ); |
734 | connect( action, SIGNAL( activated() ), | 734 | connect( action, SIGNAL( activated() ), |
735 | mView, SLOT( edit_global_options() ) ); | 735 | mView, SLOT( edit_global_options() ) ); |
736 | actionMenu->insertSeparator(); | 736 | actionMenu->insertSeparator(); |
737 | 737 | ||
738 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 738 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
739 | action->addTo( actionMenu ); | 739 | action->addTo( actionMenu ); |
740 | connect( action, SIGNAL( activated() ), | 740 | connect( action, SIGNAL( activated() ), |
741 | mView, SLOT( undo_delete() ) ); | 741 | mView, SLOT( undo_delete() ) ); |
742 | actionMenu->insertSeparator(); | 742 | actionMenu->insertSeparator(); |
743 | 743 | ||
744 | icon = loadPixmap( pathString + "newevent" ); | 744 | icon = loadPixmap( pathString + "newevent" ); |
745 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 745 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
746 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 746 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
747 | configureToolBarMenu->insertSeparator(); | 747 | configureToolBarMenu->insertSeparator(); |
748 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 748 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
749 | configureToolBarMenu->insertSeparator(); | 749 | configureToolBarMenu->insertSeparator(); |
750 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 750 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
751 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 751 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
752 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 752 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
753 | ne_action->addTo( actionMenu ); | 753 | ne_action->addTo( actionMenu ); |
754 | connect( ne_action, SIGNAL( activated() ), | 754 | connect( ne_action, SIGNAL( activated() ), |
755 | mView, SLOT( newEvent() ) ); | 755 | mView, SLOT( newEvent() ) ); |
756 | icon = loadPixmap( pathString + "newtodo" ); | 756 | icon = loadPixmap( pathString + "newtodo" ); |
757 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 757 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
758 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 758 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
759 | nt_action->addTo( actionMenu ); | 759 | nt_action->addTo( actionMenu ); |
760 | connect( nt_action, SIGNAL( activated() ), | 760 | connect( nt_action, SIGNAL( activated() ), |
761 | mView, SLOT( newTodo() ) ); | 761 | mView, SLOT( newTodo() ) ); |
762 | 762 | ||
763 | icon = loadPixmap( pathString + "today" ); | 763 | icon = loadPixmap( pathString + "today" ); |
764 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 764 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
765 | today_action->addTo( viewMenu ); | 765 | today_action->addTo( viewMenu ); |
766 | connect( today_action, SIGNAL( activated() ), | 766 | connect( today_action, SIGNAL( activated() ), |
767 | mView, SLOT( goToday() ) ); | 767 | mView, SLOT( goToday() ) ); |
768 | viewMenu->insertSeparator(); | 768 | viewMenu->insertSeparator(); |
769 | 769 | ||
770 | // *********************** | 770 | // *********************** |
771 | if ( KOPrefs::instance()->mVerticalScreen ) { | 771 | if ( KOPrefs::instance()->mVerticalScreen ) { |
772 | icon = SmallIcon( "1updownarrow" ); | 772 | icon = SmallIcon( "1updownarrow" ); |
773 | } else { | 773 | } else { |
774 | icon = SmallIcon("1leftrightarrow" ); | 774 | icon = SmallIcon("1leftrightarrow" ); |
775 | } | 775 | } |
776 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); | 776 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); |
777 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); | 777 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); |
778 | FSaction->addTo( viewMenu ); | 778 | FSaction->addTo( viewMenu ); |
779 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); | 779 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); |
780 | 780 | ||
781 | icon = loadPixmap( pathString + "navi" ); | 781 | |
782 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | ||
783 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | ||
784 | action->addTo( viewMenu ); | ||
785 | connect( action, SIGNAL( activated() ), | ||
786 | mView, SLOT( toggleDateNavigatorWidget() ) ); | ||
787 | mToggleNav = action ; | ||
788 | icon = loadPixmap( pathString + "filter" ); | 782 | icon = loadPixmap( pathString + "filter" ); |
789 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); | 783 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); |
790 | icon = loadPixmap( pathString + "configure" ); | 784 | icon = loadPixmap( pathString + "configure" ); |
791 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); | 785 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); |
792 | action->addTo( viewMenu ); | 786 | action->addTo( viewMenu ); |
793 | connect( action, SIGNAL( activated() ), | 787 | connect( action, SIGNAL( activated() ), |
794 | mView, SLOT( toggleFilter() ) ); | 788 | mView, SLOT( toggleFilter() ) ); |
795 | mToggleFilter = action; | 789 | mToggleFilter = action; |
790 | icon = loadPixmap( pathString + "navi" ); | ||
791 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | ||
792 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | ||
793 | action->addTo( viewMenu ); | ||
794 | connect( action, SIGNAL( activated() ), | ||
795 | mView, SLOT( toggleDateNavigatorWidget() ) ); | ||
796 | mToggleNav = action ; | ||
796 | icon = loadPixmap( pathString + "allday" ); | 797 | icon = loadPixmap( pathString + "allday" ); |
797 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); | 798 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); |
798 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 799 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
799 | action->addTo( viewMenu ); | 800 | action->addTo( viewMenu ); |
800 | connect( action, SIGNAL( activated() ), | 801 | connect( action, SIGNAL( activated() ), |
801 | mView, SLOT( toggleAllDaySize() ) ); | 802 | mView, SLOT( toggleAllDaySize() ) ); |
802 | mToggleAllday = action; | 803 | mToggleAllday = action; |
803 | 804 | ||
804 | 805 | ||
805 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 806 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
806 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 807 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
807 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 808 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
808 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 809 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
809 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 810 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
810 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 811 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
811 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 812 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
812 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); | 813 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); |
813 | 814 | ||
814 | viewMenu->insertSeparator(); | 815 | viewMenu->insertSeparator(); |
815 | icon = loadPixmap( pathString + "picker" ); | 816 | icon = loadPixmap( pathString + "picker" ); |
816 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 817 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
817 | action->addTo( viewMenu ); | 818 | action->addTo( viewMenu ); |
818 | connect( action, SIGNAL( activated() ), | 819 | connect( action, SIGNAL( activated() ), |
819 | mView, SLOT( showDatePicker() ) ); | 820 | mView, SLOT( showDatePicker() ) ); |
820 | action->addTo( iconToolBar ); | 821 | action->addTo( iconToolBar ); |
821 | viewMenu->insertSeparator(); | 822 | viewMenu->insertSeparator(); |
822 | 823 | ||
823 | if ( p-> mShowIconToggleFull ) | 824 | if ( p-> mShowIconToggleFull ) |
824 | FSaction->addTo( iconToolBar ); | 825 | FSaction->addTo( iconToolBar ); |
825 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); | 826 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); |
826 | 827 | ||
827 | //******************** | 828 | //******************** |
828 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); | 829 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); |
829 | 830 | ||
830 | 831 | ||
831 | icon = loadPixmap( pathString + "whatsnext" ); | 832 | icon = loadPixmap( pathString + "whatsnext" ); |
832 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 833 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
833 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 834 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
834 | whatsnext_action->addTo( viewMenu ); | 835 | whatsnext_action->addTo( viewMenu ); |
835 | connect( whatsnext_action, SIGNAL( activated() ), | 836 | connect( whatsnext_action, SIGNAL( activated() ), |
836 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 837 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
837 | 838 | ||
838 | icon = loadPixmap( pathString + "xdays" ); | 839 | icon = loadPixmap( pathString + "xdays" ); |
839 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 840 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
840 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 841 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
841 | xdays_action->addTo( viewMenu ); | 842 | xdays_action->addTo( viewMenu ); |
842 | connect( xdays_action, SIGNAL( activated() ), | 843 | connect( xdays_action, SIGNAL( activated() ), |
843 | mView->viewManager(), SLOT( showNextXView() ) ); | 844 | mView->viewManager(), SLOT( showNextXView() ) ); |
844 | 845 | ||
845 | 846 | ||
846 | icon = loadPixmap( pathString + "journal" ); | 847 | icon = loadPixmap( pathString + "journal" ); |
847 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 848 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
848 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 849 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
849 | viewjournal_action->addTo( viewMenu ); | 850 | viewjournal_action->addTo( viewMenu ); |
850 | connect( viewjournal_action, SIGNAL( activated() ), | 851 | connect( viewjournal_action, SIGNAL( activated() ), |
851 | mView->viewManager(), SLOT( showJournalView() ) ); | 852 | mView->viewManager(), SLOT( showJournalView() ) ); |
852 | 853 | ||
853 | 854 | ||
854 | icon = loadPixmap( pathString + "day" ); | 855 | icon = loadPixmap( pathString + "day" ); |
855 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 856 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
856 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 857 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
857 | day1_action->addTo( viewMenu ); | 858 | day1_action->addTo( viewMenu ); |
858 | // action->addTo( toolBar ); | 859 | // action->addTo( toolBar ); |
859 | connect( day1_action, SIGNAL( activated() ), | 860 | connect( day1_action, SIGNAL( activated() ), |
860 | mView->viewManager(), SLOT( showDayView() ) ); | 861 | mView->viewManager(), SLOT( showDayView() ) ); |
861 | 862 | ||
862 | icon = loadPixmap( pathString + "workweek" ); | 863 | icon = loadPixmap( pathString + "workweek" ); |
863 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 864 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
864 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 865 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
865 | day5_action->addTo( viewMenu ); | 866 | day5_action->addTo( viewMenu ); |
866 | connect( day5_action, SIGNAL( activated() ), | 867 | connect( day5_action, SIGNAL( activated() ), |
867 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 868 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
868 | 869 | ||
869 | icon = loadPixmap( pathString + "week" ); | 870 | icon = loadPixmap( pathString + "week" ); |
870 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 871 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
871 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 872 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
872 | day7_action->addTo( viewMenu ); | 873 | day7_action->addTo( viewMenu ); |
873 | connect( day7_action, SIGNAL( activated() ), | 874 | connect( day7_action, SIGNAL( activated() ), |
874 | mView->viewManager(), SLOT( showWeekView() ) ); | 875 | mView->viewManager(), SLOT( showWeekView() ) ); |
875 | 876 | ||
876 | icon = loadPixmap( pathString + "workweek2" ); | 877 | icon = loadPixmap( pathString + "workweek2" ); |
877 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 878 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
878 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 879 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
879 | day6_action->addTo( viewMenu ); | 880 | day6_action->addTo( viewMenu ); |
880 | connect( day6_action, SIGNAL( activated() ), | 881 | connect( day6_action, SIGNAL( activated() ), |
881 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 882 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
882 | 883 | ||
883 | icon = loadPixmap( pathString + "month" ); | 884 | icon = loadPixmap( pathString + "month" ); |
884 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 885 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
885 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 886 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
886 | month_action->addTo( viewMenu ); | 887 | month_action->addTo( viewMenu ); |
887 | connect( month_action, SIGNAL( activated() ), | 888 | connect( month_action, SIGNAL( activated() ), |
888 | mView->viewManager(), SLOT( showMonthView() ) ); | 889 | mView->viewManager(), SLOT( showMonthView() ) ); |
889 | 890 | ||
890 | icon = loadPixmap( pathString + "list" ); | 891 | icon = loadPixmap( pathString + "list" ); |
891 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 892 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
892 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 893 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
893 | showlist_action->addTo( viewMenu ); | 894 | showlist_action->addTo( viewMenu ); |
894 | connect( showlist_action, SIGNAL( activated() ), | 895 | connect( showlist_action, SIGNAL( activated() ), |
895 | mView->viewManager(), SLOT( showListView() ) ); | 896 | mView->viewManager(), SLOT( showListView() ) ); |
896 | 897 | ||
897 | icon = loadPixmap( pathString + "todo" ); | 898 | icon = loadPixmap( pathString + "todo" ); |
898 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 899 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
899 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 900 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
900 | todoview_action->addTo( viewMenu ); | 901 | todoview_action->addTo( viewMenu ); |
901 | connect( todoview_action, SIGNAL( activated() ), | 902 | connect( todoview_action, SIGNAL( activated() ), |
902 | mView->viewManager(), SLOT( showTodoView() ) ); | 903 | mView->viewManager(), SLOT( showTodoView() ) ); |
903 | 904 | ||
904 | 905 | ||
905 | 906 | ||
906 | #if 0 | 907 | #if 0 |
907 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 908 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
908 | action->addTo( viewMenu ); | 909 | action->addTo( viewMenu ); |
909 | connect( action, SIGNAL( activated() ), | 910 | connect( action, SIGNAL( activated() ), |
910 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 911 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
911 | #endif | 912 | #endif |
912 | 913 | ||
913 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 914 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
914 | this ); | 915 | this ); |
915 | mNewSubTodoAction->addTo( actionMenu ); | 916 | mNewSubTodoAction->addTo( actionMenu ); |
916 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 917 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
917 | mView, SLOT( newSubTodo() ) ); | 918 | mView, SLOT( newSubTodo() ) ); |
918 | 919 | ||
919 | actionMenu->insertSeparator(); | 920 | actionMenu->insertSeparator(); |
920 | 921 | ||
921 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 922 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
922 | mShowAction->addTo( actionMenu ); | 923 | mShowAction->addTo( actionMenu ); |
923 | connect( mShowAction, SIGNAL( activated() ), | 924 | connect( mShowAction, SIGNAL( activated() ), |
924 | mView, SLOT( showIncidence() ) ); | 925 | mView, SLOT( showIncidence() ) ); |
925 | 926 | ||
926 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 927 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
927 | mEditAction->addTo( actionMenu ); | 928 | mEditAction->addTo( actionMenu ); |
928 | connect( mEditAction, SIGNAL( activated() ), | 929 | connect( mEditAction, SIGNAL( activated() ), |
929 | mView, SLOT( editIncidence() ) ); | 930 | mView, SLOT( editIncidence() ) ); |
930 | 931 | ||
931 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 932 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
932 | mDeleteAction->addTo( actionMenu ); | 933 | mDeleteAction->addTo( actionMenu ); |
933 | connect( mDeleteAction, SIGNAL( activated() ), | 934 | connect( mDeleteAction, SIGNAL( activated() ), |
934 | mView, SLOT( deleteIncidence() ) ); | 935 | mView, SLOT( deleteIncidence() ) ); |
935 | 936 | ||
936 | 937 | ||
937 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 938 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
938 | mCloneAction->addTo( actionMenu ); | 939 | mCloneAction->addTo( actionMenu ); |
939 | connect( mCloneAction, SIGNAL( activated() ), | 940 | connect( mCloneAction, SIGNAL( activated() ), |
940 | mView, SLOT( cloneIncidence() ) ); | 941 | mView, SLOT( cloneIncidence() ) ); |
941 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 942 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
942 | mMoveAction->addTo( actionMenu ); | 943 | mMoveAction->addTo( actionMenu ); |
943 | connect( mMoveAction, SIGNAL( activated() ), | 944 | connect( mMoveAction, SIGNAL( activated() ), |
944 | mView, SLOT( moveIncidence() ) ); | 945 | mView, SLOT( moveIncidence() ) ); |
945 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 946 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
946 | mBeamAction->addTo( actionMenu ); | 947 | mBeamAction->addTo( actionMenu ); |
947 | connect( mBeamAction, SIGNAL( activated() ), | 948 | connect( mBeamAction, SIGNAL( activated() ), |
948 | mView, SLOT( beamIncidence() ) ); | 949 | mView, SLOT( beamIncidence() ) ); |
949 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 950 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
950 | mCancelAction->addTo( actionMenu ); | 951 | mCancelAction->addTo( actionMenu ); |
951 | connect( mCancelAction, SIGNAL( activated() ), | 952 | connect( mCancelAction, SIGNAL( activated() ), |
952 | mView, SLOT( toggleCancelIncidence() ) ); | 953 | mView, SLOT( toggleCancelIncidence() ) ); |
953 | 954 | ||
954 | actionMenu->insertSeparator(); | 955 | actionMenu->insertSeparator(); |
955 | 956 | ||
956 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 957 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
957 | this ); | 958 | this ); |
958 | action->addTo( actionMenu ); | 959 | action->addTo( actionMenu ); |
959 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 960 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
960 | 961 | ||
961 | icon = loadPixmap( pathString + "search" ); | 962 | icon = loadPixmap( pathString + "search" ); |
962 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 963 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
963 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 964 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
964 | search_action->addTo( actionMenu ); | 965 | search_action->addTo( actionMenu ); |
965 | connect( search_action, SIGNAL( activated() ), | 966 | connect( search_action, SIGNAL( activated() ), |
966 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 967 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
967 | 968 | ||
968 | 969 | ||
969 | 970 | ||
970 | if ( KOPrefs::instance()->mShowFullMenu ) { | 971 | if ( KOPrefs::instance()->mShowFullMenu ) { |
971 | actionMenu->insertSeparator(); | 972 | actionMenu->insertSeparator(); |
972 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 973 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
973 | 974 | ||
974 | } | 975 | } |
975 | // actionMenu->insertSeparator(); | 976 | // actionMenu->insertSeparator(); |
976 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 977 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
977 | this ); | 978 | this ); |
978 | action->addTo( importMenu_X ); | 979 | action->addTo( importMenu_X ); |
979 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 980 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
980 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 981 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
981 | this ); | 982 | this ); |
982 | action->addTo( importMenu_X ); | 983 | action->addTo( importMenu_X ); |
983 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 984 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
984 | importMenu_X->insertSeparator(); | 985 | importMenu_X->insertSeparator(); |
985 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 986 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
986 | this ); | 987 | this ); |
987 | action->addTo( importMenu_X ); | 988 | action->addTo( importMenu_X ); |
988 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 989 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
989 | //#ifndef DESKTOP_VERSION | 990 | //#ifndef DESKTOP_VERSION |
990 | importMenu_X->insertSeparator(); | 991 | importMenu_X->insertSeparator(); |
991 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 992 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
992 | this ); | 993 | this ); |
993 | action->addTo( importMenu_X ); | 994 | action->addTo( importMenu_X ); |
994 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 995 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
995 | //#else | 996 | //#else |
996 | #ifdef _OL_IMPORT_ | 997 | #ifdef _OL_IMPORT_ |
997 | importMenu_X->insertSeparator(); | 998 | importMenu_X->insertSeparator(); |
998 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 999 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
999 | this ); | 1000 | this ); |
1000 | action->addTo( importMenu_X ); | 1001 | action->addTo( importMenu_X ); |
1001 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 1002 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
1002 | #endif | 1003 | #endif |
1003 | //#endif | 1004 | //#endif |
1004 | 1005 | ||
1005 | //importMenu->insertSeparator(); | 1006 | //importMenu->insertSeparator(); |
1006 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 1007 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
1007 | this ); | 1008 | this ); |
1008 | action->addTo( importMenu ); | 1009 | action->addTo( importMenu ); |
1009 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 1010 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
1010 | 1011 | ||
1011 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 1012 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
1012 | this ); | 1013 | this ); |
1013 | action->addTo( importMenu ); | 1014 | action->addTo( importMenu ); |
1014 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 1015 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
1015 | importMenu->insertSeparator(); | 1016 | importMenu->insertSeparator(); |
1016 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 1017 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
1017 | //importMenu->insertSeparator(); | 1018 | //importMenu->insertSeparator(); |
1018 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 1019 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
1019 | this ); | 1020 | this ); |
1020 | action->addTo( exportMenu_X ); | 1021 | action->addTo( exportMenu_X ); |
1021 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 1022 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
1022 | 1023 | ||
1023 | 1024 | ||
1024 | //LR | 1025 | //LR |
1025 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 1026 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
1026 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1027 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1027 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1028 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1028 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 1029 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
1029 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 1030 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
1030 | 1031 | ||
1031 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 1032 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
1032 | #ifndef DESKTOP_VERSION | 1033 | #ifndef DESKTOP_VERSION |
1033 | //importMenu->insertSeparator(); | 1034 | //importMenu->insertSeparator(); |
1034 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 1035 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
1035 | this ); | 1036 | this ); |
1036 | brAction->addTo( beamMenu_X ); | 1037 | brAction->addTo( beamMenu_X ); |
1037 | brAction->setToggleAction (true ) ; | 1038 | brAction->setToggleAction (true ) ; |
1038 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 1039 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
1039 | 1040 | ||
1040 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 1041 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
1041 | this ); | 1042 | this ); |
1042 | action->addTo( beamMenu_X ); | 1043 | action->addTo( beamMenu_X ); |
1043 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 1044 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
1044 | 1045 | ||
1045 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 1046 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
1046 | this ); | 1047 | this ); |
1047 | action->addTo( beamMenu_X ); | 1048 | action->addTo( beamMenu_X ); |
1048 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 1049 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
1049 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 1050 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
1050 | #else | 1051 | #else |
1051 | //importMenu->insertSeparator(); | 1052 | //importMenu->insertSeparator(); |
1052 | icon = loadPixmap( pathString + "print" ); | 1053 | icon = loadPixmap( pathString + "print" ); |
1053 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 1054 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
1054 | action->addTo( beamMenu_X ); | 1055 | action->addTo( beamMenu_X ); |
1055 | connect( action, SIGNAL( activated() ), | 1056 | connect( action, SIGNAL( activated() ), |
1056 | this, SLOT( printCal() ) ); | 1057 | this, SLOT( printCal() ) ); |
1057 | 1058 | ||
1058 | icon = loadPixmap( pathString + "print" ); | 1059 | icon = loadPixmap( pathString + "print" ); |
1059 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 1060 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
1060 | action->addTo( beamMenu_X ); | 1061 | action->addTo( beamMenu_X ); |
1061 | connect( action, SIGNAL( activated() ), | 1062 | connect( action, SIGNAL( activated() ), |
1062 | this, SLOT( printSel() ) ); | 1063 | this, SLOT( printSel() ) ); |
1063 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 1064 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
1064 | action->addTo( beamMenu_X ); | 1065 | action->addTo( beamMenu_X ); |
1065 | connect( action, SIGNAL( activated() ), | 1066 | connect( action, SIGNAL( activated() ), |
1066 | mView->viewManager(), SLOT( slotprintWNV() ) ); | 1067 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1067 | 1068 | ||
1068 | 1069 | ||
1069 | icon = loadPixmap( pathString + "print" ); | 1070 | icon = loadPixmap( pathString + "print" ); |
1070 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); | 1071 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); |
1071 | action->addTo( beamMenu_X ); | 1072 | action->addTo( beamMenu_X ); |
1072 | connect( action, SIGNAL( activated() ), | 1073 | connect( action, SIGNAL( activated() ), |
1073 | this, SLOT( printListView() ) ); | 1074 | this, SLOT( printListView() ) ); |
1074 | 1075 | ||
1075 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | 1076 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); |
1076 | action->addTo( beamMenu_X ); | 1077 | action->addTo( beamMenu_X ); |
1077 | connect( action, SIGNAL( activated() ), | 1078 | connect( action, SIGNAL( activated() ), |
1078 | mView, SLOT( slotprintSelInc() ) ); | 1079 | mView, SLOT( slotprintSelInc() ) ); |
1079 | 1080 | ||
1080 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1081 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
1081 | #endif | 1082 | #endif |
1082 | importMenu->insertSeparator(); | 1083 | importMenu->insertSeparator(); |
1083 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1084 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1084 | this ); | 1085 | this ); |
1085 | action->addTo( importMenu ); | 1086 | action->addTo( importMenu ); |
1086 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1087 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1087 | importMenu->insertSeparator(); | 1088 | importMenu->insertSeparator(); |
1088 | action = new QAction( "beam all", i18n("Save"), 0, | 1089 | action = new QAction( "beam all", i18n("Save"), 0, |
1089 | this ); | 1090 | this ); |
1090 | action->addTo( importMenu ); | 1091 | action->addTo( importMenu ); |
1091 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1092 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1092 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1093 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1093 | this ); | 1094 | this ); |
1094 | action->addTo( importMenu ); | 1095 | action->addTo( importMenu ); |
1095 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1096 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1096 | 1097 | ||
1097 | //menuBar->insertItem( "Configure",configureMenu ); | 1098 | //menuBar->insertItem( "Configure",configureMenu ); |
1098 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1099 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1099 | icon = loadPixmap( "korganizer/korganizer" ); | 1100 | icon = loadPixmap( "korganizer/korganizer" ); |
1100 | 1101 | ||
1101 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1102 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1102 | action->addTo( helpMenu ); | 1103 | action->addTo( helpMenu ); |
1103 | connect( action, SIGNAL( activated() ), | 1104 | connect( action, SIGNAL( activated() ), |
1104 | SLOT( whatsNew() ) ); | 1105 | SLOT( whatsNew() ) ); |
1105 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1106 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1106 | action->addTo( helpMenu ); | 1107 | action->addTo( helpMenu ); |
1107 | connect( action, SIGNAL( activated() ), | 1108 | connect( action, SIGNAL( activated() ), |
1108 | SLOT( features() ) ); | 1109 | SLOT( features() ) ); |
1109 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1110 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1110 | action->addTo( helpMenu ); | 1111 | action->addTo( helpMenu ); |
1111 | connect( action, SIGNAL( activated() ), | 1112 | connect( action, SIGNAL( activated() ), |
1112 | SLOT( keyBindings() ) ); | 1113 | SLOT( keyBindings() ) ); |
1113 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); | 1114 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); |
1114 | action->addTo( helpMenu ); | 1115 | action->addTo( helpMenu ); |
1115 | connect( action, SIGNAL( activated() ), | 1116 | connect( action, SIGNAL( activated() ), |
1116 | SLOT( storagehowto() ) ); | 1117 | SLOT( storagehowto() ) ); |
1117 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); | 1118 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); |
1118 | action->addTo( helpMenu ); | 1119 | action->addTo( helpMenu ); |
1119 | connect( action, SIGNAL( activated() ), | 1120 | connect( action, SIGNAL( activated() ), |
1120 | SLOT( timetrackinghowto() ) ); | 1121 | SLOT( timetrackinghowto() ) ); |
1121 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1122 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1122 | action->addTo( helpMenu ); | 1123 | action->addTo( helpMenu ); |
1123 | connect( action, SIGNAL( activated() ), | 1124 | connect( action, SIGNAL( activated() ), |
1124 | SLOT( synchowto() ) ); | 1125 | SLOT( synchowto() ) ); |
1125 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1126 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1126 | action->addTo( helpMenu ); | 1127 | action->addTo( helpMenu ); |
1127 | connect( action, SIGNAL( activated() ), | 1128 | connect( action, SIGNAL( activated() ), |
1128 | SLOT( kdesynchowto() ) ); | 1129 | SLOT( kdesynchowto() ) ); |
1129 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1130 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1130 | action->addTo( helpMenu ); | 1131 | action->addTo( helpMenu ); |
1131 | connect( action, SIGNAL( activated() ), | 1132 | connect( action, SIGNAL( activated() ), |
1132 | SLOT( multisynchowto() ) ); | 1133 | SLOT( multisynchowto() ) ); |
1133 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1134 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1134 | action->addTo( helpMenu ); | 1135 | action->addTo( helpMenu ); |
1135 | connect( action, SIGNAL( activated() ), | 1136 | connect( action, SIGNAL( activated() ), |
1136 | SLOT( aboutAutoSaving() ) ); | 1137 | SLOT( aboutAutoSaving() ) ); |
1137 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1138 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1138 | action->addTo( helpMenu ); | 1139 | action->addTo( helpMenu ); |
1139 | connect( action, SIGNAL( activated() ), | 1140 | connect( action, SIGNAL( activated() ), |
1140 | SLOT( aboutKnownBugs() ) ); | 1141 | SLOT( aboutKnownBugs() ) ); |
1141 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1142 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1142 | action->addTo( helpMenu ); | 1143 | action->addTo( helpMenu ); |
1143 | connect( action, SIGNAL( activated() ), | 1144 | connect( action, SIGNAL( activated() ), |
1144 | SLOT( usertrans() ) ); | 1145 | SLOT( usertrans() ) ); |
1145 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1146 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1146 | action->addTo( helpMenu ); | 1147 | action->addTo( helpMenu ); |
1147 | connect( action, SIGNAL( activated() ), | 1148 | connect( action, SIGNAL( activated() ), |
1148 | SLOT( faq() ) ); | 1149 | SLOT( faq() ) ); |
1149 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1150 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1150 | action->addTo( helpMenu ); | 1151 | action->addTo( helpMenu ); |
1151 | connect( action, SIGNAL( activated() ), | 1152 | connect( action, SIGNAL( activated() ), |
1152 | SLOT( licence() ) ); | 1153 | SLOT( licence() ) ); |
1153 | action = new QAction( "about", i18n("About..."), 0, this ); | 1154 | action = new QAction( "about", i18n("About..."), 0, this ); |
1154 | action->addTo( helpMenu ); | 1155 | action->addTo( helpMenu ); |
1155 | connect( action, SIGNAL( activated() ), | 1156 | connect( action, SIGNAL( activated() ), |
1156 | SLOT( about() ) ); | 1157 | SLOT( about() ) ); |
1157 | //menuBar->insertSeparator(); | 1158 | //menuBar->insertSeparator(); |
1158 | 1159 | ||
1159 | // ****************************************************** | 1160 | // ****************************************************** |
1160 | // menubar icons | 1161 | // menubar icons |
1161 | 1162 | ||
1162 | 1163 | ||
1163 | 1164 | ||
1164 | //menuBar->insertItem( iconToolBar ); | 1165 | //menuBar->insertItem( iconToolBar ); |
1165 | //xdays_action | 1166 | //xdays_action |
1166 | if (p-> mShowIconNewEvent) | 1167 | if (p-> mShowIconNewEvent) |
1167 | ne_action->addTo( iconToolBar ); | 1168 | ne_action->addTo( iconToolBar ); |
1168 | if (p->mShowIconNewTodo ) | 1169 | if (p->mShowIconNewTodo ) |
1169 | nt_action->addTo( iconToolBar ); | 1170 | nt_action->addTo( iconToolBar ); |
1170 | if (p-> mShowIconSearch) | 1171 | if (p-> mShowIconSearch) |
1171 | search_action->addTo( iconToolBar ); | 1172 | search_action->addTo( iconToolBar ); |
1172 | if (p-> mShowIconWhatsThis) | 1173 | if (p-> mShowIconWhatsThis) |
1173 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1174 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1174 | if (p-> mShowIconNext) | 1175 | if (p-> mShowIconNext) |
1175 | whatsnext_action->addTo( viewToolBar ); | 1176 | whatsnext_action->addTo( viewToolBar ); |
1176 | if (p-> mShowIconNextDays) | 1177 | if (p-> mShowIconNextDays) |
1177 | xdays_action->addTo( viewToolBar ); | 1178 | xdays_action->addTo( viewToolBar ); |
1178 | if (p-> mShowIconJournal) | 1179 | if (p-> mShowIconJournal) |
1179 | viewjournal_action->addTo( viewToolBar ); | 1180 | viewjournal_action->addTo( viewToolBar ); |
1180 | if (p-> mShowIconDay1) | 1181 | if (p-> mShowIconDay1) |
1181 | day1_action->addTo( viewToolBar ); | 1182 | day1_action->addTo( viewToolBar ); |
1182 | if (p-> mShowIconDay5) | 1183 | if (p-> mShowIconDay5) |
1183 | day5_action->addTo( viewToolBar ); | 1184 | day5_action->addTo( viewToolBar ); |
1184 | if (p-> mShowIconDay7) | 1185 | if (p-> mShowIconDay7) |
1185 | day7_action->addTo( viewToolBar ); | 1186 | day7_action->addTo( viewToolBar ); |
1186 | if (p-> mShowIconDay6) | 1187 | if (p-> mShowIconDay6) |
1187 | day6_action->addTo( viewToolBar ); | 1188 | day6_action->addTo( viewToolBar ); |
1188 | if (p-> mShowIconMonth) | 1189 | if (p-> mShowIconMonth) |
1189 | month_action->addTo( viewToolBar ); | 1190 | month_action->addTo( viewToolBar ); |
1190 | if (p-> mShowIconList) | 1191 | if (p-> mShowIconList) |
1191 | showlist_action->addTo( viewToolBar ); | 1192 | showlist_action->addTo( viewToolBar ); |
1192 | if (p-> mShowIconTodoview) | 1193 | if (p-> mShowIconTodoview) |
1193 | todoview_action->addTo( viewToolBar ); | 1194 | todoview_action->addTo( viewToolBar ); |
1194 | 1195 | ||
1195 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1196 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1196 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1197 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1197 | if (p-> mShowIconBackFast) { | 1198 | if (p-> mShowIconBackFast) { |
1198 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1199 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1199 | connect( action, SIGNAL( activated() ), | 1200 | connect( action, SIGNAL( activated() ), |
1200 | mView, SLOT( goPreviousMonth() ) ); | 1201 | mView, SLOT( goPreviousMonth() ) ); |
1201 | action->addTo( navigatorToolBar ); | 1202 | action->addTo( navigatorToolBar ); |
1202 | } | 1203 | } |
1203 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1204 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1204 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1205 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1205 | if (p-> mShowIconBack) { | 1206 | if (p-> mShowIconBack) { |
1206 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1207 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1207 | connect( action, SIGNAL( activated() ), | 1208 | connect( action, SIGNAL( activated() ), |
1208 | mView, SLOT( goPrevious() ) ); | 1209 | mView, SLOT( goPrevious() ) ); |
1209 | action->addTo( navigatorToolBar ); | 1210 | action->addTo( navigatorToolBar ); |
1210 | } | 1211 | } |
1211 | icon = loadPixmap( pathString + "today" ); | 1212 | icon = loadPixmap( pathString + "today" ); |
1212 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1213 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1213 | if (p-> mShowIconToday) | 1214 | if (p-> mShowIconToday) |
1214 | today_action->addTo( navigatorToolBar ); | 1215 | today_action->addTo( navigatorToolBar ); |
1215 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1216 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1216 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1217 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1217 | if (p-> mShowIconForward) { | 1218 | if (p-> mShowIconForward) { |
1218 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1219 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1219 | connect( action, SIGNAL( activated() ), | 1220 | connect( action, SIGNAL( activated() ), |
1220 | mView, SLOT( goNext() ) ); | 1221 | mView, SLOT( goNext() ) ); |
1221 | action->addTo( navigatorToolBar ); | 1222 | action->addTo( navigatorToolBar ); |
1222 | } | 1223 | } |
1223 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1224 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1224 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1225 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1225 | if (p-> mShowIconForwardFast) { | 1226 | if (p-> mShowIconForwardFast) { |
1226 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1227 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1227 | connect( action, SIGNAL( activated() ), | 1228 | connect( action, SIGNAL( activated() ), |
1228 | mView, SLOT( goNextMonth() ) ); | 1229 | mView, SLOT( goNextMonth() ) ); |
1229 | action->addTo( navigatorToolBar ); | 1230 | action->addTo( navigatorToolBar ); |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | 1233 | ||
1233 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1234 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1234 | 1235 | ||
1235 | 1236 | ||
1236 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); | 1237 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); |
1237 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); | 1238 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); |
1238 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); | 1239 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); |
1239 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); | 1240 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); |
1240 | 1241 | ||
1241 | if (p-> mShowIconNewEvent) | 1242 | if (p-> mShowIconNewEvent) |
1242 | configureToolBarMenu->setItemChecked( 10, true ); | 1243 | configureToolBarMenu->setItemChecked( 10, true ); |
1243 | if (p->mShowIconNewTodo ) | 1244 | if (p->mShowIconNewTodo ) |
1244 | configureToolBarMenu->setItemChecked( 20, true ); | 1245 | configureToolBarMenu->setItemChecked( 20, true ); |
1245 | if (p-> mShowIconSearch) | 1246 | if (p-> mShowIconSearch) |
1246 | configureToolBarMenu->setItemChecked( 120, true ); | 1247 | configureToolBarMenu->setItemChecked( 120, true ); |
1247 | if (p-> mShowIconList) | 1248 | if (p-> mShowIconList) |
1248 | configureToolBarMenu->setItemChecked( 30, true ); | 1249 | configureToolBarMenu->setItemChecked( 30, true ); |
1249 | if (p-> mShowIconDay1) | 1250 | if (p-> mShowIconDay1) |
1250 | configureToolBarMenu->setItemChecked( 40, true ); | 1251 | configureToolBarMenu->setItemChecked( 40, true ); |
1251 | if (p-> mShowIconDay5) | 1252 | if (p-> mShowIconDay5) |
1252 | configureToolBarMenu->setItemChecked( 50, true ); | 1253 | configureToolBarMenu->setItemChecked( 50, true ); |
1253 | if (p-> mShowIconDay6) | 1254 | if (p-> mShowIconDay6) |
1254 | configureToolBarMenu->setItemChecked( 75, true ); | 1255 | configureToolBarMenu->setItemChecked( 75, true ); |
1255 | if (p-> mShowIconDay7) | 1256 | if (p-> mShowIconDay7) |
1256 | configureToolBarMenu->setItemChecked( 60, true ); | 1257 | configureToolBarMenu->setItemChecked( 60, true ); |
1257 | if (p-> mShowIconMonth) | 1258 | if (p-> mShowIconMonth) |
1258 | configureToolBarMenu->setItemChecked( 70, true ); | 1259 | configureToolBarMenu->setItemChecked( 70, true ); |
1259 | if (p-> mShowIconTodoview) | 1260 | if (p-> mShowIconTodoview) |
1260 | configureToolBarMenu->setItemChecked( 80, true ); | 1261 | configureToolBarMenu->setItemChecked( 80, true ); |
1261 | if (p-> mShowIconBackFast) | 1262 | if (p-> mShowIconBackFast) |
1262 | configureToolBarMenu->setItemChecked( 200, true ); | 1263 | configureToolBarMenu->setItemChecked( 200, true ); |
1263 | if (p-> mShowIconBack) | 1264 | if (p-> mShowIconBack) |
1264 | configureToolBarMenu->setItemChecked( 210, true ); | 1265 | configureToolBarMenu->setItemChecked( 210, true ); |
1265 | if (p-> mShowIconToday) | 1266 | if (p-> mShowIconToday) |
1266 | configureToolBarMenu->setItemChecked( 130, true ); | 1267 | configureToolBarMenu->setItemChecked( 130, true ); |
1267 | if (p-> mShowIconForward) | 1268 | if (p-> mShowIconForward) |
1268 | configureToolBarMenu->setItemChecked( 220, true ); | 1269 | configureToolBarMenu->setItemChecked( 220, true ); |
1269 | if (p-> mShowIconForwardFast) | 1270 | if (p-> mShowIconForwardFast) |
1270 | configureToolBarMenu->setItemChecked( 230, true ); | 1271 | configureToolBarMenu->setItemChecked( 230, true ); |
1271 | if (p-> mShowIconNextDays) | 1272 | if (p-> mShowIconNextDays) |
1272 | configureToolBarMenu->setItemChecked( 100, true ); | 1273 | configureToolBarMenu->setItemChecked( 100, true ); |
1273 | if (p-> mShowIconNext) | 1274 | if (p-> mShowIconNext) |
1274 | configureToolBarMenu->setItemChecked( 110, true ); | 1275 | configureToolBarMenu->setItemChecked( 110, true ); |
1275 | if (p-> mShowIconJournal) | 1276 | if (p-> mShowIconJournal) |
1276 | configureToolBarMenu->setItemChecked( 90, true ); | 1277 | configureToolBarMenu->setItemChecked( 90, true ); |
1277 | if (p-> mShowIconWhatsThis) | 1278 | if (p-> mShowIconWhatsThis) |
1278 | configureToolBarMenu->setItemChecked( 300, true ); | 1279 | configureToolBarMenu->setItemChecked( 300, true ); |
1279 | if (p-> mShowIconWeekNum) | 1280 | if (p-> mShowIconWeekNum) |
1280 | configureToolBarMenu->setItemChecked( 400, true ); | 1281 | configureToolBarMenu->setItemChecked( 400, true ); |
1281 | if (!p-> mShowIconStretch) { | 1282 | if (!p-> mShowIconStretch) { |
1282 | QLabel* dummy = new QLabel( iconToolBar ); | 1283 | QLabel* dummy = new QLabel( iconToolBar ); |
1283 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1284 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1284 | dummy->setMinimumWidth( 0 ); | 1285 | dummy->setMinimumWidth( 0 ); |
1285 | iconToolBar->setStretchableWidget ( dummy ) ; | 1286 | iconToolBar->setStretchableWidget ( dummy ) ; |
1286 | } | 1287 | } |
1287 | else { | 1288 | else { |
1288 | iconToolBar->setHorizontalStretchable (true ); | 1289 | iconToolBar->setHorizontalStretchable (true ); |
1289 | viewToolBar->setHorizontalStretchable (true ); | 1290 | viewToolBar->setHorizontalStretchable (true ); |
1290 | navigatorToolBar->setHorizontalStretchable (true ); | 1291 | navigatorToolBar->setHorizontalStretchable (true ); |
1291 | iconToolBar->setVerticalStretchable (true ); | 1292 | iconToolBar->setVerticalStretchable (true ); |
1292 | viewToolBar->setVerticalStretchable (true ); | 1293 | viewToolBar->setVerticalStretchable (true ); |
1293 | navigatorToolBar->setVerticalStretchable (true ); | 1294 | navigatorToolBar->setVerticalStretchable (true ); |
1294 | configureToolBarMenu->setItemChecked( 5, true ); | 1295 | configureToolBarMenu->setItemChecked( 5, true ); |
1295 | } | 1296 | } |
1296 | if (p-> mShowIconFilter) | 1297 | if (p-> mShowIconFilter) |
1297 | configureToolBarMenu->setItemChecked( 7, true ); | 1298 | configureToolBarMenu->setItemChecked( 7, true ); |
1298 | if (p-> mShowIconOnetoolbar) | 1299 | if (p-> mShowIconOnetoolbar) |
1299 | configureToolBarMenu->setItemChecked( 6, true ); | 1300 | configureToolBarMenu->setItemChecked( 6, true ); |
1300 | 1301 | ||
1301 | 1302 | ||
1302 | if ( filterMenubar ) { | 1303 | if ( filterMenubar ) { |
1303 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); | 1304 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); |
1304 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); | 1305 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); |
1305 | } | 1306 | } |
1306 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1307 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1307 | configureAgenda( p->mHourSize ); | 1308 | configureAgenda( p->mHourSize ); |
1308 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1309 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1309 | } | 1310 | } |
1310 | 1311 | ||
1311 | void MainWindow::exportToPhone( int mode ) | 1312 | void MainWindow::exportToPhone( int mode ) |
1312 | { | 1313 | { |
1313 | 1314 | ||
1314 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1315 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1315 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1316 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1316 | KOex2phonePrefs ex2phone; | 1317 | KOex2phonePrefs ex2phone; |
1317 | 1318 | ||
1318 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1319 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1319 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1320 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1320 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1321 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1321 | if ( mode == 1 ) | 1322 | if ( mode == 1 ) |
1322 | ex2phone.setCaption(i18n("Export complete calendar")); | 1323 | ex2phone.setCaption(i18n("Export complete calendar")); |
1323 | if ( mode == 2 ) | 1324 | if ( mode == 2 ) |
1324 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1325 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1325 | 1326 | ||
1326 | if ( !ex2phone.exec() ) { | 1327 | if ( !ex2phone.exec() ) { |
1327 | return; | 1328 | return; |
1328 | } | 1329 | } |
1329 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1330 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1330 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1331 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1331 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1332 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1332 | 1333 | ||
1333 | int inFuture = 0; | 1334 | int inFuture = 0; |
1334 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1335 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1335 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1336 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1336 | QPtrList<Incidence> delSel; | 1337 | QPtrList<Incidence> delSel; |
1337 | if ( mode == 1 ) | 1338 | if ( mode == 1 ) |
1338 | delSel = mCalendar->rawIncidences(); | 1339 | delSel = mCalendar->rawIncidences(); |
1339 | if ( mode == 2 ) | 1340 | if ( mode == 2 ) |
1340 | delSel = mCalendar->incidences(); | 1341 | delSel = mCalendar->incidences(); |
1341 | CalendarLocal* cal = new CalendarLocal(); | 1342 | CalendarLocal* cal = new CalendarLocal(); |
1342 | cal->setLocalTime(); | 1343 | cal->setLocalTime(); |
1343 | Incidence *incidence = delSel.first(); | 1344 | Incidence *incidence = delSel.first(); |
1344 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1345 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1345 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1346 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1346 | while ( incidence ) { | 1347 | while ( incidence ) { |
1347 | if ( incidence->typeID() != journalID ) { | 1348 | if ( incidence->typeID() != journalID ) { |
1348 | bool add = true; | 1349 | bool add = true; |
1349 | if ( inFuture ) { | 1350 | if ( inFuture ) { |
1350 | QDateTime dt; | 1351 | QDateTime dt; |
1351 | if ( incidence->typeID() == todoID ) { | 1352 | if ( incidence->typeID() == todoID ) { |
1352 | Todo * t = (Todo*)incidence; | 1353 | Todo * t = (Todo*)incidence; |
1353 | if ( t->hasDueDate() ) | 1354 | if ( t->hasDueDate() ) |
1354 | dt = t->dtDue(); | 1355 | dt = t->dtDue(); |
1355 | else | 1356 | else |
1356 | dt = cur.addSecs( 62 ); | 1357 | dt = cur.addSecs( 62 ); |
1357 | } | 1358 | } |
1358 | else { | 1359 | else { |
1359 | bool ok; | 1360 | bool ok; |
1360 | dt = incidence->getNextOccurence( cur, &ok ); | 1361 | dt = incidence->getNextOccurence( cur, &ok ); |
1361 | if ( !ok ) | 1362 | if ( !ok ) |
1362 | dt = cur.addSecs( -62 ); | 1363 | dt = cur.addSecs( -62 ); |
1363 | } | 1364 | } |
1364 | if ( dt < cur || dt > end ) { | 1365 | if ( dt < cur || dt > end ) { |
1365 | add = false; | 1366 | add = false; |
1366 | } | 1367 | } |
1367 | } | 1368 | } |
1368 | if ( add ) { | 1369 | if ( add ) { |
1369 | Incidence *in = incidence->clone(); | 1370 | Incidence *in = incidence->clone(); |
1370 | cal->addIncidence( in ); | 1371 | cal->addIncidence( in ); |
1371 | } | 1372 | } |
1372 | } | 1373 | } |
1373 | incidence = delSel.next(); | 1374 | incidence = delSel.next(); |
1374 | } | 1375 | } |
1375 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1376 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1376 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1377 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1377 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1378 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1378 | 1379 | ||
1379 | setCaption( i18n("Writing to phone...")); | 1380 | setCaption( i18n("Writing to phone...")); |
1380 | if ( PhoneFormat::writeToPhone( cal ) ) | 1381 | if ( PhoneFormat::writeToPhone( cal ) ) |
1381 | setCaption( i18n("Export to phone successful!")); | 1382 | setCaption( i18n("Export to phone successful!")); |
1382 | else | 1383 | else |
1383 | setCaption( i18n("Error exporting to phone!")); | 1384 | setCaption( i18n("Error exporting to phone!")); |
1384 | delete cal; | 1385 | delete cal; |
1385 | } | 1386 | } |
1386 | 1387 | ||
1387 | 1388 | ||
1388 | void MainWindow::setDefaultPreferences() | 1389 | void MainWindow::setDefaultPreferences() |
1389 | { | 1390 | { |
1390 | KOPrefs *p = KOPrefs::instance(); | 1391 | KOPrefs *p = KOPrefs::instance(); |
1391 | 1392 | ||
1392 | p->mCompactDialogs = true; | 1393 | p->mCompactDialogs = true; |
1393 | p->mConfirm = true; | 1394 | p->mConfirm = true; |
1394 | // p->mEnableQuickTodo = false; | 1395 | // p->mEnableQuickTodo = false; |
1395 | 1396 | ||
1396 | } | 1397 | } |
1397 | 1398 | ||
1398 | QString MainWindow::resourcePath() | 1399 | QString MainWindow::resourcePath() |
1399 | { | 1400 | { |
1400 | return KGlobal::iconLoader()->iconPath(); | 1401 | return KGlobal::iconLoader()->iconPath(); |
1401 | } | 1402 | } |
1402 | 1403 | ||
1403 | void MainWindow::displayText( QString text ,QString cap ) | 1404 | void MainWindow::displayText( QString text ,QString cap ) |
1404 | { | 1405 | { |
1405 | QDialog dia( this, "name", true ); ; | 1406 | QDialog dia( this, "name", true ); ; |
1406 | dia.setCaption( cap ); | 1407 | dia.setCaption( cap ); |
1407 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1408 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1408 | lay->setSpacing( 3 ); | 1409 | lay->setSpacing( 3 ); |
1409 | lay->setMargin( 3 ); | 1410 | lay->setMargin( 3 ); |
1410 | QTextBrowser tb ( &dia ); | 1411 | QTextBrowser tb ( &dia ); |
1411 | lay->addWidget( &tb ); | 1412 | lay->addWidget( &tb ); |
1412 | tb.setText( text ); | 1413 | tb.setText( text ); |
1413 | #ifdef DESKTOP_VERSION | 1414 | #ifdef DESKTOP_VERSION |
1414 | dia.resize( 640, 480); | 1415 | dia.resize( 640, 480); |
1415 | #else | 1416 | #else |
1416 | dia.showMaximized(); | 1417 | dia.showMaximized(); |
1417 | #endif | 1418 | #endif |
1418 | dia.exec(); | 1419 | dia.exec(); |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | void MainWindow::features() | 1422 | void MainWindow::features() |
1422 | { | 1423 | { |
1423 | 1424 | ||
1424 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1425 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1425 | } | 1426 | } |
1426 | 1427 | ||
1427 | void MainWindow::usertrans() | 1428 | void MainWindow::usertrans() |
1428 | { | 1429 | { |
1429 | 1430 | ||
1430 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1431 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1431 | } | 1432 | } |
1432 | 1433 | ||
1433 | void MainWindow::storagehowto() | 1434 | void MainWindow::storagehowto() |
1434 | { | 1435 | { |
1435 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 1436 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
1436 | } | 1437 | } |
1437 | void MainWindow::timetrackinghowto() | 1438 | void MainWindow::timetrackinghowto() |
1438 | { | 1439 | { |
1439 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); | 1440 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); |
1440 | } | 1441 | } |
1441 | void MainWindow::kdesynchowto() | 1442 | void MainWindow::kdesynchowto() |
1442 | { | 1443 | { |
1443 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1444 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1444 | } | 1445 | } |
1445 | void MainWindow::multisynchowto() | 1446 | void MainWindow::multisynchowto() |
1446 | { | 1447 | { |
1447 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1448 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1448 | } | 1449 | } |
1449 | void MainWindow::synchowto() | 1450 | void MainWindow::synchowto() |
1450 | { | 1451 | { |
1451 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1452 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1452 | } | 1453 | } |
1453 | void MainWindow::faq() | 1454 | void MainWindow::faq() |
1454 | { | 1455 | { |
1455 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1456 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1456 | 1457 | ||
1457 | } | 1458 | } |
1458 | void MainWindow::whatsNew() | 1459 | void MainWindow::whatsNew() |
1459 | { | 1460 | { |
1460 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1461 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1461 | 1462 | ||
1462 | } | 1463 | } |
1463 | void MainWindow::licence() | 1464 | void MainWindow::licence() |
1464 | { | 1465 | { |
1465 | KApplication::showLicence(); | 1466 | KApplication::showLicence(); |
1466 | 1467 | ||
1467 | } | 1468 | } |
1468 | void MainWindow::about() | 1469 | void MainWindow::about() |
1469 | { | 1470 | { |
1470 | QString version; | 1471 | QString version; |
1471 | #include <../version> | 1472 | #include <../version> |
1472 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1473 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1473 | i18n("KOrganizer/Platform-independent\n") + | 1474 | i18n("KOrganizer/Platform-independent\n") + |
1474 | "(KO/Pi) " + version + " - " + | 1475 | "(KO/Pi) " + version + " - " + |
1475 | 1476 | ||
1476 | #ifdef DESKTOP_VERSION | 1477 | #ifdef DESKTOP_VERSION |
1477 | i18n("Desktop Edition\n") + | 1478 | i18n("Desktop Edition\n") + |
1478 | #else | 1479 | #else |
1479 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1480 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1480 | #endif | 1481 | #endif |
1481 | 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!") ); | 1482 | 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!") ); |
1482 | } | 1483 | } |
1483 | void MainWindow::keyBindings() | 1484 | void MainWindow::keyBindings() |
1484 | { | 1485 | { |
1485 | QString cap = i18n("KO/Pi Keys + Colors"); | 1486 | QString cap = i18n("KO/Pi Keys + Colors"); |
1486 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1487 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1487 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1488 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1488 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1489 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1489 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1490 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1490 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1491 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1491 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1492 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1492 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ | 1493 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ |
1493 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1494 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1494 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1495 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1495 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1496 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
1496 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1497 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1497 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1498 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1498 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1499 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1499 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1500 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1500 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1501 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1501 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1502 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1502 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ | 1503 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ |
1503 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1504 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1504 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1505 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1505 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1506 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1506 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1507 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1507 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1508 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1508 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1509 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1509 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1510 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1510 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1511 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1511 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1512 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1512 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1513 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1513 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1514 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1514 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1515 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1515 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1516 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1516 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1517 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1517 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1518 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1518 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1519 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1519 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1520 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1520 | i18n("<p><h3>In list view:</h3></p>\n") + | 1521 | i18n("<p><h3>In list view:</h3></p>\n") + |
1521 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1522 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1522 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1523 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1523 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1524 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1524 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1525 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1525 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1526 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1526 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1527 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1527 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1528 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1528 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1529 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1529 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1530 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1530 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1531 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1531 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1532 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1532 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1533 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1533 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1534 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1534 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1535 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1535 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1536 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1536 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1537 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1537 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1538 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1538 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1539 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1539 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1540 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1540 | displayText( text, cap); | 1541 | displayText( text, cap); |
1541 | } | 1542 | } |
1542 | void MainWindow::aboutAutoSaving() | 1543 | void MainWindow::aboutAutoSaving() |
1543 | { | 1544 | { |
1544 | 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"); | 1545 | 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"); |
1545 | 1546 | ||
1546 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1547 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1547 | 1548 | ||
1548 | } | 1549 | } |
1549 | void MainWindow::aboutKnownBugs() | 1550 | void MainWindow::aboutKnownBugs() |
1550 | { | 1551 | { |
1551 | QMessageBox* msg; | 1552 | QMessageBox* msg; |
1552 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1553 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1553 | 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")+ | 1554 | 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")+ |
1554 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1555 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1555 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1556 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1556 | i18n("\nor report them in the bugtracker on\n") + | 1557 | i18n("\nor report them in the bugtracker on\n") + |
1557 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1558 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1558 | QMessageBox::NoIcon, | 1559 | QMessageBox::NoIcon, |
1559 | QMessageBox::Ok, | 1560 | QMessageBox::Ok, |
1560 | QMessageBox::NoButton, | 1561 | QMessageBox::NoButton, |
1561 | QMessageBox::NoButton); | 1562 | QMessageBox::NoButton); |
1562 | msg->exec(); | 1563 | msg->exec(); |
1563 | delete msg; | 1564 | delete msg; |
1564 | 1565 | ||
1565 | } | 1566 | } |
1566 | 1567 | ||
1567 | QString MainWindow::defaultFileName() | 1568 | QString MainWindow::defaultFileName() |
1568 | { | 1569 | { |
1569 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1570 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1570 | } | 1571 | } |
1571 | QString MainWindow::syncFileName() | 1572 | QString MainWindow::syncFileName() |
1572 | { | 1573 | { |
1573 | #ifdef DESKTOP_VERSION | 1574 | #ifdef DESKTOP_VERSION |
1574 | return locateLocal( "tmp", "synccalendar.ics" ); | 1575 | return locateLocal( "tmp", "synccalendar.ics" ); |
1575 | #else | 1576 | #else |
1576 | return QString( "/tmp/synccalendar.ics" ); | 1577 | return QString( "/tmp/synccalendar.ics" ); |
1577 | #endif | 1578 | #endif |
1578 | } | 1579 | } |
1579 | #include "koglobals.h" | 1580 | #include "koglobals.h" |
1580 | #include <kcalendarsystem.h> | 1581 | #include <kcalendarsystem.h> |
1581 | void MainWindow::updateWeek(QDate seda) | 1582 | void MainWindow::updateWeek(QDate seda) |
1582 | { | 1583 | { |
1583 | int weekNum = KGlobal::locale()->weekNum ( seda ); | 1584 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1584 | mWeekPixmap.fill( mWeekBgColor ); | 1585 | mWeekPixmap.fill( mWeekBgColor ); |
1585 | QPainter p ( &mWeekPixmap ); | 1586 | QPainter p ( &mWeekPixmap ); |
1586 | p.setFont( mWeekFont ); | 1587 | p.setFont( mWeekFont ); |
1587 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1588 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1588 | p.end(); | 1589 | p.end(); |
1589 | QIconSet icon3 ( mWeekPixmap ); | 1590 | QIconSet icon3 ( mWeekPixmap ); |
1590 | mWeekAction->setIconSet ( icon3 ); | 1591 | mWeekAction->setIconSet ( icon3 ); |
1591 | 1592 | ||
1592 | } | 1593 | } |
1593 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1594 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1594 | { | 1595 | { |
1595 | updateWeek( selectedDates.first() ); | 1596 | updateWeek( selectedDates.first() ); |
1596 | } | 1597 | } |
1597 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1598 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1598 | { | 1599 | { |
1599 | 1600 | ||
1600 | if ( !incidence ) { | 1601 | if ( !incidence ) { |
1601 | enableIncidenceActions( false ); | 1602 | enableIncidenceActions( false ); |
1602 | 1603 | ||
1603 | mNewSubTodoAction->setEnabled( false ); | 1604 | mNewSubTodoAction->setEnabled( false ); |
1604 | setCaptionToDates(); | 1605 | setCaptionToDates(); |
1605 | return; | 1606 | return; |
1606 | 1607 | ||
1607 | } | 1608 | } |
1608 | 1609 | ||
1609 | //KGlobal::locale()->formatDateTime(nextA, true); | 1610 | //KGlobal::locale()->formatDateTime(nextA, true); |
1610 | QString startString = ""; | 1611 | QString startString = ""; |
1611 | if ( incidence->typeID() != todoID ) { | 1612 | if ( incidence->typeID() != todoID ) { |
1612 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1613 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1613 | if ( incidence->doesFloat() ) { | 1614 | if ( incidence->doesFloat() ) { |
1614 | startString += ": "+incidence->dtStartDateStr( true ); | 1615 | startString += ": "+incidence->dtStartDateStr( true ); |
1615 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1616 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1616 | 1617 | ||
1617 | } else { | 1618 | } else { |
1618 | startString = ": "+incidence->dtStartStr(true); | 1619 | startString = ": "+incidence->dtStartStr(true); |
1619 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1620 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1620 | 1621 | ||
1621 | } | 1622 | } |
1622 | 1623 | ||
1623 | } else { | 1624 | } else { |
1624 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1625 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1625 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1626 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1626 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1627 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1627 | 1628 | ||
1628 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { | 1629 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { |
1629 | bool ok; | 1630 | bool ok; |
1630 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1631 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1631 | if ( ok ) { | 1632 | if ( ok ) { |
1632 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1633 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1633 | startString += i18n(" (%1 y.)"). arg( years ); | 1634 | startString += i18n(" (%1 y.)"). arg( years ); |
1634 | } | 1635 | } |
1635 | } | 1636 | } |
1636 | else | 1637 | else |
1637 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1638 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1638 | } | 1639 | } |
1639 | 1640 | ||
1640 | } | 1641 | } |
1641 | else | 1642 | else |
1642 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1643 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1643 | if ( !incidence->location().isEmpty() ) | 1644 | if ( !incidence->location().isEmpty() ) |
1644 | startString += " (" +incidence->location()+")"; | 1645 | startString += " (" +incidence->location()+")"; |
1645 | setCaption( incidence->summary()+startString); | 1646 | setCaption( incidence->summary()+startString); |
1646 | 1647 | ||
1647 | enableIncidenceActions( true ); | 1648 | enableIncidenceActions( true ); |
1648 | 1649 | ||
1649 | if ( incidence->typeID() == eventID ) { | 1650 | if ( incidence->typeID() == eventID ) { |
1650 | mShowAction->setText( i18n("Show Event...") ); | 1651 | mShowAction->setText( i18n("Show Event...") ); |
1651 | mEditAction->setText( i18n("Edit Event...") ); | 1652 | mEditAction->setText( i18n("Edit Event...") ); |
1652 | mDeleteAction->setText( i18n("Delete Event...") ); | 1653 | mDeleteAction->setText( i18n("Delete Event...") ); |
1653 | 1654 | ||
1654 | mNewSubTodoAction->setEnabled( false ); | 1655 | mNewSubTodoAction->setEnabled( false ); |
1655 | } else if ( incidence->typeID() == todoID ) { | 1656 | } else if ( incidence->typeID() == todoID ) { |
1656 | mShowAction->setText( i18n("Show Todo...") ); | 1657 | mShowAction->setText( i18n("Show Todo...") ); |
1657 | mEditAction->setText( i18n("Edit Todo...") ); | 1658 | mEditAction->setText( i18n("Edit Todo...") ); |
1658 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1659 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1659 | 1660 | ||
1660 | mNewSubTodoAction->setEnabled( true ); | 1661 | mNewSubTodoAction->setEnabled( true ); |
1661 | } else { | 1662 | } else { |
1662 | mShowAction->setText( i18n("Show...") ); | 1663 | mShowAction->setText( i18n("Show...") ); |
1663 | mShowAction->setText( i18n("Edit...") ); | 1664 | mShowAction->setText( i18n("Edit...") ); |
1664 | mShowAction->setText( i18n("Delete...") ); | 1665 | mShowAction->setText( i18n("Delete...") ); |
1665 | 1666 | ||
1666 | mNewSubTodoAction->setEnabled( false ); | 1667 | mNewSubTodoAction->setEnabled( false ); |
1667 | } | 1668 | } |
1668 | } | 1669 | } |
1669 | 1670 | ||
1670 | void MainWindow::enableIncidenceActions( bool enabled ) | 1671 | void MainWindow::enableIncidenceActions( bool enabled ) |
1671 | { | 1672 | { |
1672 | mShowAction->setEnabled( enabled ); | 1673 | mShowAction->setEnabled( enabled ); |
1673 | mEditAction->setEnabled( enabled ); | 1674 | mEditAction->setEnabled( enabled ); |
1674 | mDeleteAction->setEnabled( enabled ); | 1675 | mDeleteAction->setEnabled( enabled ); |
1675 | 1676 | ||
1676 | mCloneAction->setEnabled( enabled ); | 1677 | mCloneAction->setEnabled( enabled ); |
1677 | mMoveAction->setEnabled( enabled ); | 1678 | mMoveAction->setEnabled( enabled ); |
1678 | mBeamAction->setEnabled( enabled ); | 1679 | mBeamAction->setEnabled( enabled ); |
1679 | mCancelAction->setEnabled( enabled ); | 1680 | mCancelAction->setEnabled( enabled ); |
1680 | } | 1681 | } |
1681 | 1682 | ||
1682 | void MainWindow::importOL() | 1683 | void MainWindow::importOL() |
1683 | { | 1684 | { |
1684 | #ifdef _OL_IMPORT_ | 1685 | #ifdef _OL_IMPORT_ |
1685 | mView->clearAllViews(); | 1686 | mView->clearAllViews(); |
1686 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1687 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1687 | id->exec(); | 1688 | id->exec(); |
1688 | delete id; | 1689 | delete id; |
1689 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1690 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1690 | mView->updateView(); | 1691 | mView->updateView(); |
1691 | #endif | 1692 | #endif |
1692 | } | 1693 | } |
1693 | void MainWindow::importBday() | 1694 | void MainWindow::importBday() |
1694 | { | 1695 | { |
1695 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1696 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1696 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1697 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1697 | i18n("Import!"), i18n("Cancel"), 0, | 1698 | i18n("Import!"), i18n("Cancel"), 0, |
1698 | 0, 1 ); | 1699 | 0, 1 ); |
1699 | if ( result == 0 ) { | 1700 | if ( result == 0 ) { |
1700 | mView->importBday(); | 1701 | mView->importBday(); |
1701 | 1702 | ||
1702 | } | 1703 | } |
1703 | 1704 | ||
1704 | 1705 | ||
1705 | } | 1706 | } |
1706 | void MainWindow::importQtopia() | 1707 | void MainWindow::importQtopia() |
1707 | { | 1708 | { |
1708 | //#ifndef DESKTOP_VERSION | 1709 | //#ifndef DESKTOP_VERSION |
1709 | 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"); | 1710 | 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"); |
1710 | #ifdef DESKTOP_VERSION | 1711 | #ifdef DESKTOP_VERSION |
1711 | 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"); | 1712 | 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"); |
1712 | #endif | 1713 | #endif |
1713 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1714 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1714 | i18n("Import!"), i18n("Cancel"), 0, | 1715 | i18n("Import!"), i18n("Cancel"), 0, |
1715 | 0, 1 ); | 1716 | 0, 1 ); |
1716 | if ( result == 0 ) { | 1717 | if ( result == 0 ) { |
1717 | #ifndef DESKTOP_VERSION | 1718 | #ifndef DESKTOP_VERSION |
1718 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1719 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1719 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1720 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1720 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1721 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1721 | #else | 1722 | #else |
1722 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1723 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1723 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1724 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1724 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1725 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1725 | #endif | 1726 | #endif |
1726 | mView->importQtopia( categories, datebook, todolist ); | 1727 | mView->importQtopia( categories, datebook, todolist ); |
1727 | } | 1728 | } |
1728 | mView->calendar()->reInitAlarmSettings(); | 1729 | mView->calendar()->reInitAlarmSettings(); |
1729 | #if 0 | 1730 | #if 0 |
1730 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1731 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1731 | i18n("Not supported \non desktop!\n"), | 1732 | i18n("Not supported \non desktop!\n"), |
1732 | i18n("Ok"), i18n("Cancel"), 0, | 1733 | i18n("Ok"), i18n("Cancel"), 0, |
1733 | 0, 1 ); | 1734 | 0, 1 ); |
1734 | 1735 | ||
1735 | #endif | 1736 | #endif |
1736 | } | 1737 | } |
1737 | 1738 | ||
1738 | void MainWindow::saveOnClose() | 1739 | void MainWindow::saveOnClose() |
1739 | { | 1740 | { |
1740 | KOPrefs *p = KOPrefs::instance(); | 1741 | KOPrefs *p = KOPrefs::instance(); |
1741 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1742 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1742 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1743 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1743 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1744 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1744 | if ( filterToolBar ) { | 1745 | if ( filterToolBar ) { |
1745 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1746 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1746 | } | 1747 | } |
1747 | #ifdef DESKTOP_VERSION | 1748 | #ifdef DESKTOP_VERSION |
1748 | 1749 | ||
1749 | QPoint myP; | 1750 | QPoint myP; |
1750 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1751 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1751 | if ( p->mToolBarHor ) | 1752 | if ( p->mToolBarHor ) |
1752 | p->mToolBarUp = myP.y() > height()/2; | 1753 | p->mToolBarUp = myP.y() > height()/2; |
1753 | else | 1754 | else |
1754 | p->mToolBarUp = myP.x() > width()/2; | 1755 | p->mToolBarUp = myP.x() > width()/2; |
1755 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1756 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1756 | if ( p->mToolBarHorV ) | 1757 | if ( p->mToolBarHorV ) |
1757 | p->mToolBarUpV = myP.y() > height()/2; | 1758 | p->mToolBarUpV = myP.y() > height()/2; |
1758 | else | 1759 | else |
1759 | p->mToolBarUpV = myP.x() > width()/2 ; | 1760 | p->mToolBarUpV = myP.x() > width()/2 ; |
1760 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1761 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1761 | if ( p->mToolBarHorN ) | 1762 | if ( p->mToolBarHorN ) |
1762 | p->mToolBarUpN = myP.y() > height()/2; | 1763 | p->mToolBarUpN = myP.y() > height()/2; |
1763 | else | 1764 | else |
1764 | p->mToolBarUpN = myP.x() > width()/2 ; | 1765 | p->mToolBarUpN = myP.x() > width()/2 ; |
1765 | if ( filterToolBar ) { | 1766 | if ( filterToolBar ) { |
1766 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1767 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1767 | if ( p->mToolBarHorF ) | 1768 | if ( p->mToolBarHorF ) |
1768 | p->mToolBarUpF = myP.y() > height()/2; | 1769 | p->mToolBarUpF = myP.y() > height()/2; |
1769 | else | 1770 | else |
1770 | p->mToolBarUpF = myP.x() > width()/2 ; | 1771 | p->mToolBarUpF = myP.x() > width()/2 ; |
1771 | } | 1772 | } |
1772 | #else | 1773 | #else |
1773 | if ( p->mToolBarHor ) | 1774 | if ( p->mToolBarHor ) |
1774 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1775 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1775 | else | 1776 | else |
1776 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1777 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1777 | if ( p->mToolBarHorV ) | 1778 | if ( p->mToolBarHorV ) |
1778 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1779 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1779 | else | 1780 | else |
1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1781 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1781 | 1782 | ||
1782 | if ( p->mToolBarHorN ) | 1783 | if ( p->mToolBarHorN ) |
1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1784 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1784 | else | 1785 | else |
1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1786 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1786 | if ( filterToolBar ) { | 1787 | if ( filterToolBar ) { |
1787 | if ( p->mToolBarHorF ) | 1788 | if ( p->mToolBarHorF ) |
1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1789 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1789 | else | 1790 | else |
1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1791 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1791 | } | 1792 | } |
1792 | #endif | 1793 | #endif |
1793 | 1794 | ||
1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1795 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1795 | save(); | 1796 | save(); |
1796 | mView->writeSettings(); | 1797 | mView->writeSettings(); |
1797 | } | 1798 | } |
1798 | void MainWindow::slotModifiedChanged( bool changed ) | 1799 | void MainWindow::slotModifiedChanged( bool changed ) |
1799 | { | 1800 | { |
1800 | if ( mBlockAtStartup ) | 1801 | if ( mBlockAtStartup ) |
1801 | return; | 1802 | return; |
1802 | 1803 | ||
1803 | int msec; | 1804 | int msec; |
1804 | // we store the changes after 1 minute, | 1805 | // we store the changes after 1 minute, |
1805 | // and for safety reasons after 10 minutes again | 1806 | // and for safety reasons after 10 minutes again |
1806 | if ( !mSyncManager->blockSave() ) | 1807 | if ( !mSyncManager->blockSave() ) |
1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1808 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1808 | else | 1809 | else |
1809 | msec = 1000 * 600; | 1810 | msec = 1000 * 600; |
1810 | mSaveTimer.start( msec, true ); // 1 minute | 1811 | mSaveTimer.start( msec, true ); // 1 minute |
1811 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1812 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1812 | mCalendarModifiedFlag = true; | 1813 | mCalendarModifiedFlag = true; |
1813 | } | 1814 | } |
1814 | void MainWindow::saveStopTimer() | 1815 | void MainWindow::saveStopTimer() |
1815 | { | 1816 | { |
1816 | mSaveTimer.stop(); | 1817 | mSaveTimer.stop(); |
1817 | } | 1818 | } |
1818 | void MainWindow::save() | 1819 | void MainWindow::save() |
1819 | { | 1820 | { |
1820 | if ( !mCalendarModifiedFlag ) { | 1821 | if ( !mCalendarModifiedFlag ) { |
1821 | qDebug("KO: Calendar not modified. Nothing saved."); | 1822 | qDebug("KO: Calendar not modified. Nothing saved."); |
1822 | return; | 1823 | return; |
1823 | } | 1824 | } |
1824 | if ( mSyncManager->blockSave() ) | 1825 | if ( mSyncManager->blockSave() ) |
1825 | return; | 1826 | return; |
1826 | mSyncManager->setBlockSave(true); | 1827 | mSyncManager->setBlockSave(true); |
1827 | if ( mView->checkAllFileVersions() ) { | 1828 | if ( mView->checkAllFileVersions() ) { |
1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 1829 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1829 | QDate reference ( 2000,1,1); | 1830 | QDate reference ( 2000,1,1); |
1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1831 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 1832 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1832 | setCaption(i18n("Creating backup ... please wait ..." )); | 1833 | setCaption(i18n("Creating backup ... please wait ..." )); |
1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1834 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1834 | // we need the file path, the backup dir and the number of bups as param | 1835 | // we need the file path, the backup dir and the number of bups as param |
1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1836 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1837 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1837 | bupDir = KGlobalSettings::backupDataDir(); | 1838 | bupDir = KGlobalSettings::backupDataDir(); |
1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1839 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1839 | if ( retval == 0 ) { | 1840 | if ( retval == 0 ) { |
1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1841 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1841 | // retval == 0 : backup skipped for today, try again tomorrow | 1842 | // retval == 0 : backup skipped for today, try again tomorrow |
1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1843 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1843 | } else if ( retval == 1 ){ | 1844 | } else if ( retval == 1 ){ |
1844 | qDebug("KO: Backup created."); | 1845 | qDebug("KO: Backup created."); |
1845 | // backup ok | 1846 | // backup ok |
1846 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1847 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1847 | KopiCalendarFile * cal = calendars.first(); | 1848 | KopiCalendarFile * cal = calendars.first(); |
1848 | cal = calendars.next(); | 1849 | cal = calendars.next(); |
1849 | while ( cal ) { | 1850 | while ( cal ) { |
1850 | if ( !cal->mErrorOnLoad ) { | 1851 | if ( !cal->mErrorOnLoad ) { |
1851 | int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1852 | int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1852 | } | 1853 | } |
1853 | cal = calendars.next(); | 1854 | cal = calendars.next(); |
1854 | } | 1855 | } |
1855 | KOPrefs::instance()->mLastBackupDate = daysTo; | 1856 | KOPrefs::instance()->mLastBackupDate = daysTo; |
1856 | } else if ( retval == 2 ){ | 1857 | } else if ( retval == 2 ){ |
1857 | qDebug("KO: Backup globally cancelled."); | 1858 | qDebug("KO: Backup globally cancelled."); |
1858 | // backup globally cancelled | 1859 | // backup globally cancelled |
1859 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 1860 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
1860 | } | 1861 | } |
1861 | // retval == 3: do nothing, try again later | 1862 | // retval == 3: do nothing, try again later |
1862 | } | 1863 | } |
1863 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 1864 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
1864 | } | 1865 | } |
1865 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1866 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1866 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1867 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1867 | qDebug("KO: Start saving data to file!"); | 1868 | qDebug("KO: Start saving data to file!"); |
1868 | mView->saveCalendars(); | 1869 | mView->saveCalendars(); |
1869 | mCalendarModifiedFlag = false; | 1870 | mCalendarModifiedFlag = false; |
1870 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1871 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1871 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1872 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1872 | QString savemes; | 1873 | QString savemes; |
1873 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1874 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1874 | setCaption(savemes); | 1875 | setCaption(savemes); |
1875 | } else | 1876 | } else |
1876 | setCaption(i18n("Saving cancelled!")); | 1877 | setCaption(i18n("Saving cancelled!")); |
1877 | mSyncManager->setBlockSave( false ); | 1878 | mSyncManager->setBlockSave( false ); |
1878 | } | 1879 | } |
1879 | 1880 | ||
1880 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1881 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1881 | { | 1882 | { |
1882 | if ( !e->isAutoRepeat() ) { | 1883 | if ( !e->isAutoRepeat() ) { |
1883 | mFlagKeyPressed = false; | 1884 | mFlagKeyPressed = false; |
1884 | } | 1885 | } |
1885 | } | 1886 | } |
1886 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1887 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1887 | { | 1888 | { |
1888 | qApp->processEvents(); | 1889 | qApp->processEvents(); |
1889 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1890 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1890 | e->ignore(); | 1891 | e->ignore(); |
1891 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1892 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1892 | return; | 1893 | return; |
1893 | } | 1894 | } |
1894 | if (! e->isAutoRepeat() ) | 1895 | if (! e->isAutoRepeat() ) |
1895 | mFlagKeyPressed = true; | 1896 | mFlagKeyPressed = true; |
1896 | KOPrefs *p = KOPrefs::instance(); | 1897 | KOPrefs *p = KOPrefs::instance(); |
1897 | bool showSelectedDates = false; | 1898 | bool showSelectedDates = false; |
1898 | int size; | 1899 | int size; |
1899 | int pro = 0; | 1900 | int pro = 0; |
1900 | //qDebug("MainWindow::keyPressEvent "); | 1901 | //qDebug("MainWindow::keyPressEvent "); |
1901 | switch ( e->key() ) { | 1902 | switch ( e->key() ) { |
1902 | case Qt::Key_Right: | 1903 | case Qt::Key_Right: |
1903 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1904 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1904 | mView->goNextMonth(); | 1905 | mView->goNextMonth(); |
1905 | else | 1906 | else |
1906 | mView->goNext(); | 1907 | mView->goNext(); |
1907 | showSelectedDates = true; | 1908 | showSelectedDates = true; |
1908 | break; | 1909 | break; |
1909 | case Qt::Key_Left: | 1910 | case Qt::Key_Left: |
1910 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1911 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1911 | mView->goPreviousMonth(); | 1912 | mView->goPreviousMonth(); |
1912 | else | 1913 | else |
1913 | mView->goPrevious(); | 1914 | mView->goPrevious(); |
1914 | showSelectedDates = true; | 1915 | showSelectedDates = true; |
1915 | break; | 1916 | break; |
1916 | case Qt::Key_Down: | 1917 | case Qt::Key_Down: |
1917 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1918 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1918 | break; | 1919 | break; |
1919 | case Qt::Key_Up: | 1920 | case Qt::Key_Up: |
1920 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1921 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1921 | break; | 1922 | break; |
1922 | case Qt::Key_K: | 1923 | case Qt::Key_K: |
1923 | mView->viewManager()->showMonthViewWeek(); | 1924 | mView->viewManager()->showMonthViewWeek(); |
1924 | break; | 1925 | break; |
1925 | case Qt::Key_I: | 1926 | case Qt::Key_I: |
1926 | mView->showIncidence(); | 1927 | mView->showIncidence(); |
1927 | break; | 1928 | break; |
1928 | case Qt::Key_Delete: | 1929 | case Qt::Key_Delete: |
1929 | case Qt::Key_Backspace: | 1930 | case Qt::Key_Backspace: |
1930 | mView->deleteIncidence(); | 1931 | mView->deleteIncidence(); |
1931 | break; | 1932 | break; |
1932 | case Qt::Key_D: | 1933 | case Qt::Key_D: |
1933 | mView->viewManager()->showDayView(); | 1934 | mView->viewManager()->showDayView(); |
1934 | showSelectedDates = true; | 1935 | showSelectedDates = true; |
1935 | break; | 1936 | break; |
1936 | case Qt::Key_O: | 1937 | case Qt::Key_O: |
1937 | mView->toggleFilerEnabled( ); | 1938 | mView->toggleFilerEnabled( ); |
1938 | break; | 1939 | break; |
1939 | case Qt::Key_0: | 1940 | case Qt::Key_0: |
1940 | case Qt::Key_1: | 1941 | case Qt::Key_1: |
1941 | case Qt::Key_2: | 1942 | case Qt::Key_2: |
1942 | case Qt::Key_3: | 1943 | case Qt::Key_3: |
1943 | case Qt::Key_4: | 1944 | case Qt::Key_4: |
1944 | case Qt::Key_5: | 1945 | case Qt::Key_5: |
1945 | case Qt::Key_6: | 1946 | case Qt::Key_6: |
1946 | case Qt::Key_7: | 1947 | case Qt::Key_7: |
1947 | case Qt::Key_8: | 1948 | case Qt::Key_8: |
1948 | case Qt::Key_9: | 1949 | case Qt::Key_9: |
1949 | pro = e->key()-48; | 1950 | pro = e->key()-48; |
1950 | if ( pro == 0 ) | 1951 | if ( pro == 0 ) |
1951 | pro = 10; | 1952 | pro = 10; |
1952 | if ( e->state() == Qt::ControlButton) | 1953 | if ( e->state() == Qt::ControlButton) |
1953 | pro += 10; | 1954 | pro += 10; |
1954 | break; | 1955 | break; |
1955 | case Qt::Key_M: | 1956 | case Qt::Key_M: |
1956 | mView->viewManager()->showMonthView(); | 1957 | mView->viewManager()->showMonthView(); |
1957 | showSelectedDates = true; | 1958 | showSelectedDates = true; |
1958 | break; | 1959 | break; |
1959 | case Qt::Key_Insert: | 1960 | case Qt::Key_Insert: |
1960 | mView->newEvent(); | 1961 | mView->newEvent(); |
1961 | break; | 1962 | break; |
1962 | case Qt::Key_S : | 1963 | case Qt::Key_S : |
1963 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1964 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1964 | mView->newSubTodo(); | 1965 | mView->newSubTodo(); |
1965 | else | 1966 | else |
1966 | mView->dialogManager()->showSearchDialog(); | 1967 | mView->dialogManager()->showSearchDialog(); |
1967 | break; | 1968 | break; |
1968 | case Qt::Key_Y : | 1969 | case Qt::Key_Y : |
1969 | case Qt::Key_Z : | 1970 | case Qt::Key_Z : |
1970 | mView->viewManager()->showWorkWeekView(); | 1971 | mView->viewManager()->showWorkWeekView(); |
1971 | showSelectedDates = true; | 1972 | showSelectedDates = true; |
1972 | break; | 1973 | break; |
1973 | case Qt::Key_U : | 1974 | case Qt::Key_U : |
1974 | mView->viewManager()->showWeekView(); | 1975 | mView->viewManager()->showWeekView(); |
1975 | showSelectedDates = true; | 1976 | showSelectedDates = true; |
1976 | break; | 1977 | break; |
1977 | case Qt::Key_H : | 1978 | case Qt::Key_H : |
1978 | keyBindings(); | 1979 | keyBindings(); |
1979 | break; | 1980 | break; |
1980 | case Qt::Key_W: | 1981 | case Qt::Key_W: |
1981 | mView->viewManager()->showWhatsNextView(); | 1982 | mView->viewManager()->showWhatsNextView(); |
1982 | break; | 1983 | break; |
1983 | case Qt::Key_L: | 1984 | case Qt::Key_L: |
1984 | mView->viewManager()->showListView(); | 1985 | mView->viewManager()->showListView(); |
1985 | break; | 1986 | break; |
1986 | case Qt::Key_N: | 1987 | case Qt::Key_N: |
1987 | mView->viewManager()->showNextView(); | 1988 | mView->viewManager()->showNextView(); |
1988 | break; | 1989 | break; |
1989 | case Qt::Key_V: | 1990 | case Qt::Key_V: |
1990 | mView->viewManager()->showTodoView(); | 1991 | mView->viewManager()->showTodoView(); |
1991 | break; | 1992 | break; |
1992 | case Qt::Key_C: | 1993 | case Qt::Key_C: |
1993 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1994 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1994 | break; | 1995 | break; |
1995 | case Qt::Key_P: | 1996 | case Qt::Key_P: |
1996 | mView->showDatePicker( ); | 1997 | mView->showDatePicker( ); |
1997 | break; | 1998 | break; |
1998 | case Qt::Key_F: | 1999 | case Qt::Key_F: |
1999 | mView->editFilters(); | 2000 | mView->editFilters(); |
2000 | break; | 2001 | break; |
2001 | case Qt::Key_R: | 2002 | case Qt::Key_R: |
2002 | mView->toggleFilter(); | 2003 | mView->toggleFilter(); |
2003 | break; | 2004 | break; |
2004 | case Qt::Key_X: | 2005 | case Qt::Key_X: |
2005 | if ( e->state() == Qt::ControlButton ) | 2006 | if ( e->state() == Qt::ControlButton ) |
2006 | mView->toggleDateNavigatorWidget(); | 2007 | mView->toggleDateNavigatorWidget(); |
2007 | else { | 2008 | else { |
2008 | mView->viewManager()->showNextXView(); | 2009 | mView->viewManager()->showNextXView(); |
2009 | showSelectedDates = true; | 2010 | showSelectedDates = true; |
2010 | } | 2011 | } |
2011 | break; | 2012 | break; |
2012 | case Qt::Key_Space: | 2013 | case Qt::Key_Space: |
2013 | mView->toggleExpand(); | 2014 | mView->toggleExpand(); |
2014 | break; | 2015 | break; |
2015 | case Qt::Key_A: | 2016 | case Qt::Key_A: |
2016 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2017 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2017 | mView->showNextAlarms(); | 2018 | mView->showNextAlarms(); |
2018 | else | 2019 | else |
2019 | mView->toggleAllDaySize(); | 2020 | mView->toggleAllDaySize(); |
2020 | break; | 2021 | break; |
2021 | case Qt::Key_T: | 2022 | case Qt::Key_T: |
2022 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2023 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2023 | mView->newTodo(); | 2024 | mView->newTodo(); |
2024 | else { | 2025 | else { |
2025 | mView->goToday(); | 2026 | mView->goToday(); |
2026 | showSelectedDates = true; | 2027 | showSelectedDates = true; |
2027 | } | 2028 | } |
2028 | break; | 2029 | break; |
2029 | case Qt::Key_J: | 2030 | case Qt::Key_J: |
2030 | mView->viewManager()->showJournalView(); | 2031 | mView->viewManager()->showJournalView(); |
2031 | break; | 2032 | break; |
2032 | case Qt::Key_B: | 2033 | case Qt::Key_B: |
2033 | mView->editIncidenceDescription();; | 2034 | mView->editIncidenceDescription();; |
2034 | break; | 2035 | break; |
2035 | // case Qt::Key_Return: | 2036 | // case Qt::Key_Return: |
2036 | case Qt::Key_E: | 2037 | case Qt::Key_E: |
2037 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2038 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2038 | mView->newEvent(); | 2039 | mView->newEvent(); |
2039 | else | 2040 | else |
2040 | mView->editIncidence(); | 2041 | mView->editIncidence(); |
2041 | break; | 2042 | break; |
2042 | case Qt::Key_Plus: | 2043 | case Qt::Key_Plus: |
2043 | size = p->mHourSize +2; | 2044 | size = p->mHourSize +2; |
2044 | if ( size <= 22 ) | 2045 | if ( size <= 22 ) |
2045 | configureAgenda( size ); | 2046 | configureAgenda( size ); |
2046 | break; | 2047 | break; |
2047 | case Qt::Key_Minus: | 2048 | case Qt::Key_Minus: |
2048 | size = p->mHourSize - 2; | 2049 | size = p->mHourSize - 2; |
2049 | if ( size >= 4 ) | 2050 | if ( size >= 4 ) |
2050 | configureAgenda( size ); | 2051 | configureAgenda( size ); |
2051 | break; | 2052 | break; |
2052 | 2053 | ||
2053 | 2054 | ||
2054 | default: | 2055 | default: |
2055 | e->ignore(); | 2056 | e->ignore(); |
2056 | } | 2057 | } |
2057 | if ( pro > 0 ) { | 2058 | if ( pro > 0 ) { |
2058 | mView->selectFilter( pro-1 ); | 2059 | mView->selectFilter( pro-1 ); |
2059 | } | 2060 | } |
2060 | if ( showSelectedDates ) { | 2061 | if ( showSelectedDates ) { |
2061 | ;// setCaptionToDates(); | 2062 | ;// setCaptionToDates(); |
2062 | } | 2063 | } |
2063 | 2064 | ||
2064 | } | 2065 | } |
2065 | void MainWindow::fillFilterMenuTB() | 2066 | void MainWindow::fillFilterMenuTB() |
2066 | { | 2067 | { |
2067 | selectFilterMenuTB->clear(); | 2068 | selectFilterMenuTB->clear(); |
2068 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2069 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2069 | selectFilterMenuTB->insertSeparator(); | 2070 | selectFilterMenuTB->insertSeparator(); |
2070 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2071 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2071 | 2072 | ||
2072 | selectFilterMenuTB->insertSeparator(); | 2073 | selectFilterMenuTB->insertSeparator(); |
2073 | QPtrList<CalFilter> fili = mView->filters(); | 2074 | QPtrList<CalFilter> fili = mView->filters(); |
2074 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2075 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2075 | CalFilter *filter = fili.first(); | 2076 | CalFilter *filter = fili.first(); |
2076 | int iii = 2; | 2077 | int iii = 2; |
2077 | bool checkitem = mView->filterView()->filtersEnabled(); | 2078 | bool checkitem = mView->filterView()->filtersEnabled(); |
2078 | while(filter) { | 2079 | while(filter) { |
2079 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2080 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2080 | if ( filter == curfilter) | 2081 | if ( filter == curfilter) |
2081 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2082 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2082 | filter = fili.next(); | 2083 | filter = fili.next(); |
2083 | ++iii; | 2084 | ++iii; |
2084 | } | 2085 | } |
2085 | if ( !checkitem ) | 2086 | if ( !checkitem ) |
2086 | selectFilterMenuTB->setItemChecked( 1, true ); | 2087 | selectFilterMenuTB->setItemChecked( 1, true ); |
2087 | 2088 | ||
2088 | int x = 0; | 2089 | int x = 0; |
2089 | int y = iconToolBar->height(); | 2090 | int y = iconToolBar->height(); |
2090 | int dX = 0; | 2091 | int dX = 0; |
2091 | int dY = 0; | 2092 | int dY = 0; |
2092 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2093 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2093 | if ( iconToolBar->y() > height()/2 ) { | 2094 | if ( iconToolBar->y() > height()/2 ) { |
2094 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2095 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2095 | y = 0; | 2096 | y = 0; |
2096 | } | 2097 | } |
2097 | } else { | 2098 | } else { |
2098 | if ( iconToolBar->x() > width()/2 ) { // right side | 2099 | if ( iconToolBar->x() > width()/2 ) { // right side |
2099 | x=0; | 2100 | x=0; |
2100 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2101 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2101 | y = 0; | 2102 | y = 0; |
2102 | } else { | 2103 | } else { |
2103 | x= iconToolBar->width(); | 2104 | x= iconToolBar->width(); |
2104 | y = 0; | 2105 | y = 0; |
2105 | } | 2106 | } |
2106 | } | 2107 | } |
2107 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2108 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2108 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2109 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2109 | } | 2110 | } |
2110 | void MainWindow::fillFilterMenu() | 2111 | void MainWindow::fillFilterMenu() |
2111 | { | 2112 | { |
2112 | selectFilterMenu->clear(); | 2113 | selectFilterMenu->clear(); |
2113 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2114 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2114 | selectFilterMenu->insertSeparator(); | 2115 | selectFilterMenu->insertSeparator(); |
2115 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2116 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2116 | 2117 | ||
2117 | selectFilterMenu->insertSeparator(); | 2118 | selectFilterMenu->insertSeparator(); |
2118 | QPtrList<CalFilter> fili = mView->filters(); | 2119 | QPtrList<CalFilter> fili = mView->filters(); |
2119 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2120 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2120 | CalFilter *filter = fili.first(); | 2121 | CalFilter *filter = fili.first(); |
2121 | int iii = 2; | 2122 | int iii = 2; |
2122 | bool checkitem = mView->filterView()->filtersEnabled(); | 2123 | bool checkitem = mView->filterView()->filtersEnabled(); |
2123 | while(filter) { | 2124 | while(filter) { |
2124 | selectFilterMenu->insertItem( filter->name(), iii ); | 2125 | selectFilterMenu->insertItem( filter->name(), iii ); |
2125 | if ( filter == curfilter) | 2126 | if ( filter == curfilter) |
2126 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2127 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2127 | filter = fili.next(); | 2128 | filter = fili.next(); |
2128 | ++iii; | 2129 | ++iii; |
2129 | } | 2130 | } |
2130 | if ( !checkitem ) | 2131 | if ( !checkitem ) |
2131 | selectFilterMenu->setItemChecked( 1, true ); | 2132 | selectFilterMenu->setItemChecked( 1, true ); |
2132 | } | 2133 | } |
2133 | void MainWindow::fillFilterMenuPopup() | 2134 | void MainWindow::fillFilterMenuPopup() |
2134 | { | 2135 | { |
2135 | filterPopupMenu->clear(); | 2136 | filterPopupMenu->clear(); |
2136 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2137 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2137 | 2138 | ||
2138 | filterPopupMenu->insertSeparator(); | 2139 | filterPopupMenu->insertSeparator(); |
2139 | QPtrList<CalFilter> fili = mView->filters(); | 2140 | QPtrList<CalFilter> fili = mView->filters(); |
2140 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2141 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2141 | CalFilter *filter = fili.first(); | 2142 | CalFilter *filter = fili.first(); |
2142 | int iii = 1; | 2143 | int iii = 1; |
2143 | bool checkitem = mView->filterView()->filtersEnabled(); | 2144 | bool checkitem = mView->filterView()->filtersEnabled(); |
2144 | while(filter) { | 2145 | while(filter) { |
2145 | filterPopupMenu->insertItem( filter->name(), iii ); | 2146 | filterPopupMenu->insertItem( filter->name(), iii ); |
2146 | if ( filter == curfilter) | 2147 | if ( filter == curfilter) |
2147 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2148 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2148 | filter = fili.next(); | 2149 | filter = fili.next(); |
2149 | ++iii; | 2150 | ++iii; |
2150 | } | 2151 | } |
2151 | if ( !checkitem ) | 2152 | if ( !checkitem ) |
2152 | filterPopupMenu->setItemChecked( 0, true ); | 2153 | filterPopupMenu->setItemChecked( 0, true ); |
2153 | } | 2154 | } |
2154 | void MainWindow::selectFilter( int fil ) | 2155 | void MainWindow::selectFilter( int fil ) |
2155 | { | 2156 | { |
2156 | 2157 | ||
2157 | if ( fil == 0 ) { | 2158 | if ( fil == 0 ) { |
2158 | mView->editFilters( ); | 2159 | mView->editFilters( ); |
2159 | } else if ( fil == 1 ){ | 2160 | } else if ( fil == 1 ){ |
2160 | if ( mView->filterView()->filtersEnabled() ) | 2161 | if ( mView->filterView()->filtersEnabled() ) |
2161 | mView->toggleFilerEnabled( ); | 2162 | mView->toggleFilerEnabled( ); |
2162 | } else { | 2163 | } else { |
2163 | if ( !mView->filterView()->filtersEnabled() ) { | 2164 | if ( !mView->filterView()->filtersEnabled() ) { |
2164 | mView->filterView()->blockSignals( true ); | 2165 | mView->filterView()->blockSignals( true ); |
2165 | mView->toggleFilerEnabled( ); | 2166 | mView->toggleFilerEnabled( ); |
2166 | mView->filterView()->blockSignals( false ); | 2167 | mView->filterView()->blockSignals( false ); |
2167 | } | 2168 | } |
2168 | mView->selectFilter( fil-2 ); | 2169 | mView->selectFilter( fil-2 ); |
2169 | } | 2170 | } |
2170 | } | 2171 | } |
2171 | void MainWindow::updateFilterToolbar() | 2172 | void MainWindow::updateFilterToolbar() |
2172 | { | 2173 | { |
2173 | if ( filterMenubar ) { | 2174 | if ( filterMenubar ) { |
2174 | if ( !mView->filterView()->filtersEnabled() ) { | 2175 | if ( !mView->filterView()->filtersEnabled() ) { |
2175 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2176 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2176 | } else { | 2177 | } else { |
2177 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2178 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2178 | if ( curfilter ) { | 2179 | if ( curfilter ) { |
2179 | filterMenubar->changeItem( 0, curfilter->name() ); | 2180 | filterMenubar->changeItem( 0, curfilter->name() ); |
2180 | } | 2181 | } |
2181 | } | 2182 | } |
2182 | } | 2183 | } |
2183 | } | 2184 | } |
2184 | void MainWindow::selectFilterPopup( int fil ) | 2185 | void MainWindow::selectFilterPopup( int fil ) |
2185 | { | 2186 | { |
2186 | selectFilter( fil + 1 ); | 2187 | selectFilter( fil + 1 ); |
2187 | 2188 | ||
2188 | } | 2189 | } |
2189 | void MainWindow::configureToolBar( int item ) | 2190 | void MainWindow::configureToolBar( int item ) |
2190 | { | 2191 | { |
2191 | 2192 | ||
2192 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2193 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2193 | KOPrefs *p = KOPrefs::instance(); | 2194 | KOPrefs *p = KOPrefs::instance(); |
2194 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2195 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2195 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2196 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2196 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2197 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2197 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2198 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2198 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2199 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2199 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2200 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2200 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2201 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2201 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2202 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2202 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2203 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2203 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2204 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2204 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2205 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2205 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2206 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2206 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2207 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2207 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2208 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2208 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2209 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2209 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2210 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2210 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2211 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2211 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2212 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2212 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2213 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2213 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2214 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2214 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2215 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2215 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2216 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2216 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2217 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2217 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2218 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2218 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2219 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2219 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2220 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2220 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2221 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2221 | // initActions(); | 2222 | // initActions(); |
2222 | } | 2223 | } |
2223 | void MainWindow::setCaption ( const QString & c ) | 2224 | void MainWindow::setCaption ( const QString & c ) |
2224 | { | 2225 | { |
2225 | QString cap = c; | 2226 | QString cap = c; |
2226 | cap.replace( QRegExp("\n"), " " ); | 2227 | cap.replace( QRegExp("\n"), " " ); |
2227 | cap = cap.stripWhiteSpace(); | 2228 | cap = cap.stripWhiteSpace(); |
2228 | if ( cap.isEmpty() ) | 2229 | if ( cap.isEmpty() ) |
2229 | cap = "KO/Pi"; | 2230 | cap = "KO/Pi"; |
2230 | QWidget::setCaption( cap ); | 2231 | QWidget::setCaption( cap ); |
2231 | } | 2232 | } |
2232 | void MainWindow::setCaptionToDates() | 2233 | void MainWindow::setCaptionToDates() |
2233 | { | 2234 | { |
2234 | QString selDates; | 2235 | QString selDates; |
2235 | QDate date = mView->startDate(); | 2236 | QDate date = mView->startDate(); |
2236 | if ( ! date.isValid() ) { | 2237 | if ( ! date.isValid() ) { |
2237 | setCaption(""); | 2238 | setCaption(""); |
2238 | return; | 2239 | return; |
2239 | } | 2240 | } |
2240 | selDates = KGlobal::locale()->formatDate( date, true); | 2241 | selDates = KGlobal::locale()->formatDate( date, true); |
2241 | if (mView->startDate() < mView->endDate() ) | 2242 | if (mView->startDate() < mView->endDate() ) |
2242 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2243 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2243 | else { | 2244 | else { |
2244 | QString addString; | 2245 | QString addString; |
2245 | if ( date == QDateTime::currentDateTime().date() ) | 2246 | if ( date == QDateTime::currentDateTime().date() ) |
2246 | addString = i18n("Today"); | 2247 | addString = i18n("Today"); |
2247 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2248 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2248 | addString = i18n("Tomorrow"); | 2249 | addString = i18n("Tomorrow"); |
2249 | if ( !addString.isEmpty() ) | 2250 | if ( !addString.isEmpty() ) |
2250 | selDates = addString+", "+selDates ; | 2251 | selDates = addString+", "+selDates ; |
2251 | } | 2252 | } |
2252 | setCaption( i18n("Dates: ") + selDates ); | 2253 | setCaption( i18n("Dates: ") + selDates ); |
2253 | 2254 | ||
2254 | } | 2255 | } |
2255 | void MainWindow::showConfigureAgenda( ) | 2256 | void MainWindow::showConfigureAgenda( ) |
2256 | { | 2257 | { |
2257 | int iii; | 2258 | int iii; |
2258 | for ( iii = 1;iii<= 10 ;++iii ){ | 2259 | for ( iii = 1;iii<= 10 ;++iii ){ |
2259 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2260 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2260 | } | 2261 | } |
2261 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2262 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2262 | } | 2263 | } |
2263 | void MainWindow::configureAgenda( int item ) | 2264 | void MainWindow::configureAgenda( int item ) |
2264 | { | 2265 | { |
2265 | if ( KOPrefs::instance()->mHourSize == item ) | 2266 | if ( KOPrefs::instance()->mHourSize == item ) |
2266 | return; | 2267 | return; |
2267 | KOPrefs::instance()->mHourSize=item; | 2268 | KOPrefs::instance()->mHourSize=item; |
2268 | mView->viewManager()->agendaView()->updateConfig(); | 2269 | mView->viewManager()->agendaView()->updateConfig(); |
2269 | } | 2270 | } |
2270 | 2271 | ||
2271 | void MainWindow::saveCalendar() | 2272 | void MainWindow::saveCalendar() |
2272 | { | 2273 | { |
2273 | QString fn = KOPrefs::instance()->mLastSaveFile; | 2274 | QString fn = KOPrefs::instance()->mLastSaveFile; |
2274 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 2275 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
2275 | 2276 | ||
2276 | if ( fn == "" ) | 2277 | if ( fn == "" ) |
2277 | return; | 2278 | return; |
2278 | QFileInfo info; | 2279 | QFileInfo info; |
2279 | info.setFile( fn ); | 2280 | info.setFile( fn ); |
2280 | QString mes; | 2281 | QString mes; |
2281 | bool createbup = true; | 2282 | bool createbup = true; |
2282 | if ( info. exists() ) { | 2283 | if ( info. exists() ) { |
2283 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 2284 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
2284 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2285 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2285 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2286 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2286 | 0, 1 ); | 2287 | 0, 1 ); |
2287 | if ( result != 0 ) { | 2288 | if ( result != 0 ) { |
2288 | createbup = false; | 2289 | createbup = false; |
2289 | } | 2290 | } |
2290 | } | 2291 | } |
2291 | if ( createbup ) { | 2292 | if ( createbup ) { |
2292 | mView->saveCalendar( fn ); | 2293 | mView->saveCalendar( fn ); |
2293 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 2294 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
2294 | KOPrefs::instance()->mLastSaveFile = fn; | 2295 | KOPrefs::instance()->mLastSaveFile = fn; |
2295 | setCaption(mes); | 2296 | setCaption(mes); |
2296 | } | 2297 | } |
2297 | } | 2298 | } |
2298 | void MainWindow::loadCalendar() | 2299 | void MainWindow::loadCalendar() |
2299 | { | 2300 | { |
2300 | 2301 | ||
2301 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2302 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2302 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2303 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2303 | 2304 | ||
2304 | if ( fn == "" ) | 2305 | if ( fn == "" ) |
2305 | return; | 2306 | return; |
2306 | QFileInfo info; | 2307 | QFileInfo info; |
2307 | info.setFile( fn ); | 2308 | info.setFile( fn ); |
2308 | QString mess; | 2309 | QString mess; |
2309 | bool loadbup = true; | 2310 | bool loadbup = true; |
2310 | if ( info. exists() ) { | 2311 | if ( info. exists() ) { |
2311 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2312 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2312 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2313 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2313 | mess, | 2314 | mess, |
2314 | i18n("Load!"), i18n("Cancel"), 0, | 2315 | i18n("Load!"), i18n("Cancel"), 0, |
2315 | 0, 1 ); | 2316 | 0, 1 ); |
2316 | if ( result != 0 ) { | 2317 | if ( result != 0 ) { |
2317 | loadbup = false; | 2318 | loadbup = false; |
2318 | } | 2319 | } |
2319 | } else { | 2320 | } else { |
2320 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2321 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2321 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2322 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2322 | 0, 1 ); | 2323 | 0, 1 ); |
2323 | 2324 | ||
2324 | return; | 2325 | return; |
2325 | } | 2326 | } |
2326 | if ( loadbup ) { | 2327 | if ( loadbup ) { |
2327 | mView->openCalendar( fn ); | 2328 | mView->openCalendar( fn ); |
2328 | KOPrefs::instance()->mLastLoadFile = fn; | 2329 | KOPrefs::instance()->mLastLoadFile = fn; |
2329 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2330 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2330 | setCaption(mess); | 2331 | setCaption(mess); |
2331 | } | 2332 | } |
2332 | 2333 | ||
2333 | } | 2334 | } |
2334 | void MainWindow::quickImportIcal() | 2335 | void MainWindow::quickImportIcal() |
2335 | { | 2336 | { |
2336 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2337 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2337 | } | 2338 | } |
2338 | void MainWindow::importFile( QString fn, bool quick ) | 2339 | void MainWindow::importFile( QString fn, bool quick ) |
2339 | { | 2340 | { |
2340 | QFileInfo info; | 2341 | QFileInfo info; |
2341 | info.setFile( fn ); | 2342 | info.setFile( fn ); |
2342 | QString mess; | 2343 | QString mess; |
2343 | bool loadbup = true; | 2344 | bool loadbup = true; |
2344 | if ( !info. exists() ) { | 2345 | if ( !info. exists() ) { |
2345 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2346 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2346 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2347 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2347 | mess ); | 2348 | mess ); |
2348 | return; | 2349 | return; |
2349 | } | 2350 | } |
2350 | int result = 0; | 2351 | int result = 0; |
2351 | if ( !quick ) { | 2352 | if ( !quick ) { |
2352 | 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 )); | 2353 | 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 )); |
2353 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2354 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2354 | mess, | 2355 | mess, |
2355 | "Import", "Cancel", 0, | 2356 | "Import", "Cancel", 0, |
2356 | 0, 1 ); | 2357 | 0, 1 ); |
2357 | } | 2358 | } |
2358 | if ( result == 0 ) { | 2359 | if ( result == 0 ) { |
2359 | if ( mView->openCalendar( fn, true )) { | 2360 | if ( mView->openCalendar( fn, true )) { |
2360 | KOPrefs::instance()->mLastImportFile = fn; | 2361 | KOPrefs::instance()->mLastImportFile = fn; |
2361 | setCaption(i18n("Imported file successfully")); | 2362 | setCaption(i18n("Imported file successfully")); |
2362 | } else { | 2363 | } else { |
2363 | setCaption(i18n("Error importing file")); | 2364 | setCaption(i18n("Error importing file")); |
2364 | } | 2365 | } |
2365 | } | 2366 | } |
2366 | } | 2367 | } |
2367 | 2368 | ||
2368 | void MainWindow::importIcal() | 2369 | void MainWindow::importIcal() |
2369 | { | 2370 | { |
2370 | 2371 | ||
2371 | QString fn =KOPrefs::instance()->mLastImportFile; | 2372 | QString fn =KOPrefs::instance()->mLastImportFile; |
2372 | 2373 | ||
2373 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2374 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2374 | if ( fn == "" ) | 2375 | if ( fn == "" ) |
2375 | return; | 2376 | return; |
2376 | importFile( fn, true ); | 2377 | importFile( fn, true ); |
2377 | 2378 | ||
2378 | } | 2379 | } |
2379 | 2380 | ||
2380 | void MainWindow::exportVCalendar() | 2381 | void MainWindow::exportVCalendar() |
2381 | { | 2382 | { |
2382 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2383 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2383 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2384 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2384 | if ( fn == "" ) | 2385 | if ( fn == "" ) |
2385 | return; | 2386 | return; |
2386 | QFileInfo info; | 2387 | QFileInfo info; |
2387 | info.setFile( fn ); | 2388 | info.setFile( fn ); |
2388 | QString mes; | 2389 | QString mes; |
2389 | bool createbup = true; | 2390 | bool createbup = true; |
2390 | if ( info. exists() ) { | 2391 | if ( info. exists() ) { |
2391 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2392 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2392 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2393 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2393 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2394 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2394 | 0, 1 ); | 2395 | 0, 1 ); |
2395 | if ( result != 0 ) { | 2396 | if ( result != 0 ) { |
2396 | createbup = false; | 2397 | createbup = false; |
2397 | } | 2398 | } |
2398 | } | 2399 | } |
2399 | if ( createbup ) { | 2400 | if ( createbup ) { |
2400 | if ( mView->exportVCalendar( fn ) ) { | 2401 | if ( mView->exportVCalendar( fn ) ) { |
2401 | KOPrefs::instance()->mLastVcalFile = fn; | 2402 | KOPrefs::instance()->mLastVcalFile = fn; |
2402 | if ( fn.length() > 20 ) | 2403 | if ( fn.length() > 20 ) |
2403 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2404 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2404 | else | 2405 | else |
2405 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2406 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2406 | setCaption(mes); | 2407 | setCaption(mes); |
2407 | } | 2408 | } |
2408 | } | 2409 | } |
2409 | 2410 | ||
2410 | } | 2411 | } |
2411 | QString MainWindow::sentSyncFile() | 2412 | QString MainWindow::sentSyncFile() |
2412 | { | 2413 | { |
2413 | #ifdef DESKTOP_VERSION | 2414 | #ifdef DESKTOP_VERSION |
2414 | return locateLocal( "tmp", "copysynccal.ics" ); | 2415 | return locateLocal( "tmp", "copysynccal.ics" ); |
2415 | #else | 2416 | #else |
2416 | return QString( "/tmp/copysynccal.ics" ); | 2417 | return QString( "/tmp/copysynccal.ics" ); |
2417 | #endif | 2418 | #endif |
2418 | } | 2419 | } |
2419 | 2420 | ||
2420 | void MainWindow::syncFileRequest() | 2421 | void MainWindow::syncFileRequest() |
2421 | { | 2422 | { |
2422 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2423 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2423 | mSyncManager->slotSyncMenu( 999 ); | 2424 | mSyncManager->slotSyncMenu( 999 ); |
2424 | } | 2425 | } |
2425 | 2426 | ||
2426 | setCaption(i18n("Saving Data to temp file ..." )); | 2427 | setCaption(i18n("Saving Data to temp file ..." )); |
2427 | mView->saveCalendar( sentSyncFile() ); | 2428 | mView->saveCalendar( sentSyncFile() ); |
2428 | setCaption(i18n("Data saved to temp file!" )); | 2429 | setCaption(i18n("Data saved to temp file!" )); |
2429 | 2430 | ||
2430 | } | 2431 | } |
2431 | void MainWindow::getFile( bool success ) | 2432 | void MainWindow::getFile( bool success ) |
2432 | { | 2433 | { |
2433 | if ( ! success ) { | 2434 | if ( ! success ) { |
2434 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2435 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2435 | return; | 2436 | return; |
2436 | } | 2437 | } |
2437 | mView->openCalendar( sentSyncFile() ); | 2438 | mView->openCalendar( sentSyncFile() ); |
2438 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2439 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2439 | mSyncManager->slotSyncMenu( 999 ); | 2440 | mSyncManager->slotSyncMenu( 999 ); |
2440 | } | 2441 | } |
2441 | setCaption( i18n("Pi-Sync successful!") ); | 2442 | setCaption( i18n("Pi-Sync successful!") ); |
2442 | } | 2443 | } |
2443 | void MainWindow::printListView() | 2444 | void MainWindow::printListView() |
2444 | { | 2445 | { |
2445 | 2446 | ||
2446 | 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."); | 2447 | 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."); |
2447 | 2448 | ||
2448 | KMessageBox::information( this, message); | 2449 | KMessageBox::information( this, message); |
2449 | } | 2450 | } |
2450 | void MainWindow::printSel( ) | 2451 | void MainWindow::printSel( ) |
2451 | { | 2452 | { |
2452 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2453 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2453 | } | 2454 | } |
2454 | 2455 | ||
2455 | void MainWindow::printCal() | 2456 | void MainWindow::printCal() |
2456 | { | 2457 | { |
2457 | mView->print();//mCp->showDialog(); | 2458 | mView->print();//mCp->showDialog(); |
2458 | } | 2459 | } |
2459 | 2460 | ||
2460 | 2461 | ||
2461 | #include "libkdepim/kdatepicker.h" | 2462 | #include "libkdepim/kdatepicker.h" |
2462 | #include <kdatetbl.h> | 2463 | #include <kdatetbl.h> |
2463 | 2464 | ||
2464 | void MainWindow::weekAction() | 2465 | void MainWindow::weekAction() |
2465 | { | 2466 | { |
2466 | int month; | 2467 | int month; |
2467 | KPopupFrame* popup = new KPopupFrame(this); | 2468 | KPopupFrame* popup = new KPopupFrame(this); |
2468 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2469 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2469 | // ----- | 2470 | // ----- |
2470 | picker->resize(picker->sizeHint()); | 2471 | picker->resize(picker->sizeHint()); |
2471 | popup->setMainWidget(picker); | 2472 | popup->setMainWidget(picker); |
2472 | picker->setFocus(); | 2473 | picker->setFocus(); |
2473 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2474 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2474 | int x = 0; | 2475 | int x = 0; |
2475 | int y = iconToolBar->height(); | 2476 | int y = iconToolBar->height(); |
2476 | int dX = 0; | 2477 | int dX = 0; |
2477 | int dY = 0; | 2478 | int dY = 0; |
2478 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2479 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2479 | if ( iconToolBar->y() > height()/2 ) { | 2480 | if ( iconToolBar->y() > height()/2 ) { |
2480 | dY = picker->sizeHint().height()+8; | 2481 | dY = picker->sizeHint().height()+8; |
2481 | y = 0; | 2482 | y = 0; |
2482 | } | 2483 | } |
2483 | } else { | 2484 | } else { |
2484 | if ( iconToolBar->x() > width()/2 ) { // right side | 2485 | if ( iconToolBar->x() > width()/2 ) { // right side |
2485 | x=0; | 2486 | x=0; |
2486 | dX= picker->sizeHint().width()+8; | 2487 | dX= picker->sizeHint().width()+8; |
2487 | y = 0; | 2488 | y = 0; |
2488 | } else { | 2489 | } else { |
2489 | x= iconToolBar->width(); | 2490 | x= iconToolBar->width(); |
2490 | y = 0; | 2491 | y = 0; |
2491 | } | 2492 | } |
2492 | } | 2493 | } |
2493 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2494 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2494 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2495 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2495 | { | 2496 | { |
2496 | month = picker->getResult(); | 2497 | month = picker->getResult(); |
2497 | emit selectWeek ( month ); | 2498 | emit selectWeek ( month ); |
2498 | //qDebug("weekSelected %d ", month); | 2499 | //qDebug("weekSelected %d ", month); |
2499 | } | 2500 | } |
2500 | delete popup; | 2501 | delete popup; |
2501 | } | 2502 | } |
2502 | 2503 | ||
2503 | void MainWindow::hideEvent ( QHideEvent * ) | 2504 | void MainWindow::hideEvent ( QHideEvent * ) |
2504 | { | 2505 | { |
2505 | QString message; | 2506 | QString message; |
2506 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2507 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2507 | if ( nextA.isValid() ) { | 2508 | if ( nextA.isValid() ) { |
2508 | QString sum = mCalendar->nextSummary(); | 2509 | QString sum = mCalendar->nextSummary(); |
2509 | 2510 | ||
2510 | 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)); | 2511 | 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)); |
2511 | setCaption( message ); | 2512 | setCaption( message ); |
2512 | } | 2513 | } |
2513 | } | 2514 | } |
2514 | 2515 | ||
2515 | void MainWindow::resizeEvent( QResizeEvent* e) | 2516 | void MainWindow::resizeEvent( QResizeEvent* e) |
2516 | { | 2517 | { |
2517 | #ifndef DESKTOP_VERSION | 2518 | #ifndef DESKTOP_VERSION |
2518 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2519 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2519 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2520 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2520 | filterToolBar->hide(); | 2521 | filterToolBar->hide(); |
2521 | else | 2522 | else |
2522 | filterToolBar->show(); | 2523 | filterToolBar->show(); |
2523 | } | 2524 | } |
2524 | #endif | 2525 | #endif |
2525 | QMainWindow::resizeEvent( e); | 2526 | QMainWindow::resizeEvent( e); |
2526 | } | 2527 | } |
diff --git a/microkde/kglobal.cpp b/microkde/kglobal.cpp index bf7e238..53edd08 100644 --- a/microkde/kglobal.cpp +++ b/microkde/kglobal.cpp | |||
@@ -1,168 +1,175 @@ | |||
1 | #include "kglobal.h" | 1 | #include "kglobal.h" |
2 | #include "kstandarddirs.h" | 2 | #include "kstandarddirs.h" |
3 | #include <qkeycode.h> | 3 | #include <qkeycode.h> |
4 | #include <qapplication.h> | 4 | #include <qapplication.h> |
5 | 5 | ||
6 | KLocale *KGlobal::mLocale = 0; | 6 | KLocale *KGlobal::mLocale = 0; |
7 | KConfig *KGlobal::mConfig = 0; | 7 | KConfig *KGlobal::mConfig = 0; |
8 | KIconLoader *KGlobal::mIconLoader = 0; | 8 | KIconLoader *KGlobal::mIconLoader = 0; |
9 | KStandardDirs *KGlobal::mDirs = 0; | 9 | KStandardDirs *KGlobal::mDirs = 0; |
10 | 10 | ||
11 | QString KGlobal::mAppName = "godot"; | 11 | QString KGlobal::mAppName = "godot"; |
12 | 12 | ||
13 | KLocale *KGlobal::locale() | 13 | KLocale *KGlobal::locale() |
14 | { | 14 | { |
15 | if ( !mLocale ) { | 15 | if ( !mLocale ) { |
16 | ASSERT(mAppName); | 16 | ASSERT(mAppName); |
17 | 17 | ||
18 | mLocale = new KLocale();//mAppName); | 18 | mLocale = new KLocale();//mAppName); |
19 | } | 19 | } |
20 | 20 | ||
21 | return mLocale; | 21 | return mLocale; |
22 | } | 22 | } |
23 | 23 | ||
24 | //US | 24 | //US |
25 | void KGlobal::setLocale(KLocale *kg) | 25 | void KGlobal::setLocale(KLocale *kg) |
26 | { | 26 | { |
27 | mLocale = kg; | 27 | mLocale = kg; |
28 | } | 28 | } |
29 | 29 | ||
30 | KConfig *KGlobal::config() | 30 | KConfig *KGlobal::config() |
31 | { | 31 | { |
32 | //mConfig is set inside setAppName. Though it has to be the first function you call. | 32 | //mConfig is set inside setAppName. Though it has to be the first function you call. |
33 | return mConfig; | 33 | return mConfig; |
34 | } | 34 | } |
35 | 35 | ||
36 | KGlobal::Size KGlobal::getDesktopSize() | 36 | KGlobal::Size KGlobal::getDesktopSize() |
37 | { | 37 | { |
38 | #ifdef DESKTOP_VERSION | 38 | #ifdef DESKTOP_VERSION |
39 | return KGlobal::Desktop; | 39 | return KGlobal::Desktop; |
40 | #else | 40 | #else |
41 | if ( QApplication::desktop()->width() <= 320 ) | 41 | if ( QApplication::desktop()->width() <= 320 ) |
42 | return KGlobal::Small; | 42 | return KGlobal::Small; |
43 | else if ( QApplication::desktop()->width() > 480) | 43 | else if ( QApplication::desktop()->width() > 480) |
44 | return KGlobal::Desktop; | 44 | return KGlobal::Desktop; |
45 | else | 45 | else |
46 | return KGlobal::Medium; | 46 | return KGlobal::Medium; |
47 | #endif | 47 | #endif |
48 | } | 48 | } |
49 | 49 | ||
50 | KGlobal::Orientation KGlobal::getOrientation() | 50 | KGlobal::Orientation KGlobal::getOrientation() |
51 | { | 51 | { |
52 | if (QApplication::desktop()->width() > QApplication::desktop()->height()) | 52 | if (QApplication::desktop()->width() > QApplication::desktop()->height()) |
53 | return KGlobal::Landscape; | 53 | return KGlobal::Landscape; |
54 | else | 54 | else |
55 | return KGlobal::Portrait; | 55 | return KGlobal::Portrait; |
56 | } | 56 | } |
57 | 57 | ||
58 | int KGlobal::getDesktopWidth() | 58 | int KGlobal::getDesktopWidth() |
59 | { | 59 | { |
60 | return QApplication::desktop()->width(); | 60 | return QApplication::desktop()->width(); |
61 | } | 61 | } |
62 | 62 | ||
63 | int KGlobal::getDesktopHeight() | 63 | int KGlobal::getDesktopHeight() |
64 | { | 64 | { |
65 | return QApplication::desktop()->height(); | 65 | return QApplication::desktop()->height(); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | KIconLoader *KGlobal::iconLoader() | 69 | KIconLoader *KGlobal::iconLoader() |
70 | { | 70 | { |
71 | if ( !mIconLoader ) { | 71 | if ( !mIconLoader ) { |
72 | mIconLoader = new KIconLoader(); | 72 | mIconLoader = new KIconLoader(); |
73 | } | 73 | } |
74 | 74 | ||
75 | return mIconLoader; | 75 | return mIconLoader; |
76 | } | 76 | } |
77 | 77 | ||
78 | KStandardDirs *KGlobal::dirs() | 78 | KStandardDirs *KGlobal::dirs() |
79 | { | 79 | { |
80 | if ( !mDirs ) { | 80 | if ( !mDirs ) { |
81 | mDirs = new KStandardDirs(); | 81 | mDirs = new KStandardDirs(); |
82 | } | 82 | } |
83 | 83 | ||
84 | return mDirs; | 84 | return mDirs; |
85 | } | 85 | } |
86 | 86 | ||
87 | void KGlobal::setAppName( const QString &appName ) | 87 | void KGlobal::setAppName( const QString &appName ) |
88 | { | 88 | { |
89 | mAppName = appName; | 89 | mAppName = appName; |
90 | 90 | ||
91 | mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) ); | 91 | mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) ); |
92 | } | 92 | } |
93 | 93 | ||
94 | //US | 94 | //US |
95 | QString KGlobal::getAppName() | 95 | QString KGlobal::getAppName() |
96 | { | 96 | { |
97 | return mAppName; | 97 | return mAppName; |
98 | } | 98 | } |
99 | QString KGlobal::formatMessage ( QString mess, int maxlen ) | 99 | QString KGlobal::formatMessage ( QString mess, int maxlen ) |
100 | { | 100 | { |
101 | //int maxlen = 80; | 101 | //int maxlen = 80; |
102 | if ( maxlen == 0 ) { | ||
103 | maxlen = QApplication::desktop()->width()/10; | ||
104 | if ( maxlen > 32 ) | ||
105 | maxlen = (maxlen * 3) / 4; | ||
106 | if ( maxlen > 100 ) | ||
107 | maxlen = 100; | ||
108 | } | ||
102 | int start = 0; | 109 | int start = 0; |
103 | int end = mess.length(); | 110 | int end = mess.length(); |
104 | QString retVal = ""; | 111 | QString retVal = ""; |
105 | int nl, space; | 112 | int nl, space; |
106 | while ( (end - start) > maxlen ) { | 113 | while ( (end - start) > maxlen ) { |
107 | nl = mess.find( "\n", start ); | 114 | nl = mess.find( "\n", start ); |
108 | if ( nl > 0 && nl < start + maxlen ) { | 115 | if ( nl > 0 && nl < start + maxlen ) { |
109 | nl += 1; | 116 | nl += 1; |
110 | retVal += mess.mid( start, nl - start); | 117 | retVal += mess.mid( start, nl - start); |
111 | start = nl; | 118 | start = nl; |
112 | } else { | 119 | } else { |
113 | space = mess.findRev( " ", start + maxlen ); | 120 | space = mess.findRev( " ", start + maxlen ); |
114 | if ( space < start ) { | 121 | if ( space < start ) { |
115 | retVal += mess.mid( start, maxlen) +"\n"; | 122 | retVal += mess.mid( start, maxlen) +"\n"; |
116 | start += maxlen ; | 123 | start += maxlen ; |
117 | } else { | 124 | } else { |
118 | retVal += mess.mid( start, space - start ) +"\n"; | 125 | retVal += mess.mid( start, space - start ) +"\n"; |
119 | start = space+ 1; | 126 | start = space+ 1; |
120 | } | 127 | } |
121 | } | 128 | } |
122 | } | 129 | } |
123 | retVal += mess.mid( start, end - start ); | 130 | retVal += mess.mid( start, end - start ); |
124 | return retVal; | 131 | return retVal; |
125 | } | 132 | } |
126 | int KGlobal::knumkeykonv( int k ) | 133 | int KGlobal::knumkeykonv( int k ) |
127 | { | 134 | { |
128 | int key; | 135 | int key; |
129 | switch( k ) { | 136 | switch( k ) { |
130 | case Qt::Key_Q : | 137 | case Qt::Key_Q : |
131 | key = Qt::Key_1; | 138 | key = Qt::Key_1; |
132 | break; | 139 | break; |
133 | case Qt::Key_W : | 140 | case Qt::Key_W : |
134 | key = Qt::Key_2; | 141 | key = Qt::Key_2; |
135 | break; | 142 | break; |
136 | case Qt::Key_E : | 143 | case Qt::Key_E : |
137 | key = Qt::Key_3; | 144 | key = Qt::Key_3; |
138 | break; | 145 | break; |
139 | case Qt::Key_R : | 146 | case Qt::Key_R : |
140 | key = Qt::Key_4; | 147 | key = Qt::Key_4; |
141 | break; | 148 | break; |
142 | case Qt::Key_T : | 149 | case Qt::Key_T : |
143 | key = Qt::Key_5; | 150 | key = Qt::Key_5; |
144 | break; | 151 | break; |
145 | case Qt::Key_Z : | 152 | case Qt::Key_Z : |
146 | key = Qt::Key_6; | 153 | key = Qt::Key_6; |
147 | break; | 154 | break; |
148 | case Qt::Key_Y : | 155 | case Qt::Key_Y : |
149 | key = Qt::Key_6; | 156 | key = Qt::Key_6; |
150 | break; | 157 | break; |
151 | case Qt::Key_U : | 158 | case Qt::Key_U : |
152 | key = Qt::Key_7; | 159 | key = Qt::Key_7; |
153 | break; | 160 | break; |
154 | case Qt::Key_I : | 161 | case Qt::Key_I : |
155 | key = Qt::Key_8; | 162 | key = Qt::Key_8; |
156 | break; | 163 | break; |
157 | case Qt::Key_O : | 164 | case Qt::Key_O : |
158 | key = Qt::Key_9; | 165 | key = Qt::Key_9; |
159 | break; | 166 | break; |
160 | case Qt::Key_P : | 167 | case Qt::Key_P : |
161 | key = Qt::Key_0; | 168 | key = Qt::Key_0; |
162 | break; | 169 | break; |
163 | default: | 170 | default: |
164 | key = k; | 171 | key = k; |
165 | break; | 172 | break; |
166 | } // switch | 173 | } // switch |
167 | return key; | 174 | return key; |
168 | } | 175 | } |