author | zautrix <zautrix> | 2005-06-08 10:34:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-08 10:34:22 (UTC) |
commit | 793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (unidiff) | |
tree | 5bc77e2b7a32a541c2a3b3c3d6d50f873216deef /korganizer | |
parent | 39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff) | |
download | kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2 |
changed incidence type to a faster access method
-rw-r--r-- | korganizer/calendarview.cpp | 62 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 16 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 12 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 10 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 10 |
7 files changed, 59 insertions, 59 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 720ad78..7c7466b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4355 +1,4355 @@ | |||
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->type() == "Event" ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->type() == "Todo" ) { | 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->type() == "Todo" ) | 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 | mTodoList->setNavigator( mNavigator ); | 461 | mTodoList->setNavigator( mNavigator ); |
462 | #if 0 | 462 | #if 0 |
463 | if ( QApplication::desktop()->width() < 480 ) { | 463 | if ( QApplication::desktop()->width() < 480 ) { |
464 | leftFrameLayout->addWidget(mFilterView); | 464 | leftFrameLayout->addWidget(mFilterView); |
465 | leftFrameLayout->addWidget(mTodoList, 2 ); | 465 | leftFrameLayout->addWidget(mTodoList, 2 ); |
466 | 466 | ||
467 | } else { | 467 | } else { |
468 | leftFrameLayout->addWidget(mTodoList,2 ); | 468 | leftFrameLayout->addWidget(mTodoList,2 ); |
469 | leftFrameLayout->addWidget(mFilterView ); | 469 | leftFrameLayout->addWidget(mFilterView ); |
470 | } | 470 | } |
471 | #endif | 471 | #endif |
472 | mFilterView->hide(); | 472 | mFilterView->hide(); |
473 | QWidget *rightBox = new QWidget( mMainFrame ); | 473 | QWidget *rightBox = new QWidget( mMainFrame ); |
474 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 474 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
475 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 475 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
476 | mRightFrame = new QWidgetStack( rightBox ); | 476 | mRightFrame = new QWidgetStack( rightBox ); |
477 | rightLayout->addWidget( mRightFrame, 10 ); | 477 | rightLayout->addWidget( mRightFrame, 10 ); |
478 | 478 | ||
479 | //mLeftFrame = (QWidget *)leftFrame; | 479 | //mLeftFrame = (QWidget *)leftFrame; |
480 | if ( KOPrefs::instance()->mVerticalScreen ) { | 480 | if ( KOPrefs::instance()->mVerticalScreen ) { |
481 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 481 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
482 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 482 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
483 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
484 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 484 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
485 | } else { | 485 | } else { |
486 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 486 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
487 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 487 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
488 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | } | 489 | } |
490 | if ( !KOPrefs::instance()->mShowDateNavigator) | 490 | if ( !KOPrefs::instance()->mShowDateNavigator) |
491 | mDateNavigator->hide(); | 491 | mDateNavigator->hide(); |
492 | //qDebug("Calendarview Size %d %d ", width(), height()); | 492 | //qDebug("Calendarview Size %d %d ", width(), height()); |
493 | #endif | 493 | #endif |
494 | 494 | ||
495 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 495 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
496 | SLOT( showDates( const KCal::DateList & ) ) ); | 496 | SLOT( showDates( const KCal::DateList & ) ) ); |
497 | 497 | ||
498 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 498 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
499 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 499 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
500 | 500 | ||
501 | 501 | ||
502 | 502 | ||
503 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 503 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
504 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 504 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
505 | 505 | ||
506 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 506 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
507 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 507 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
508 | 508 | ||
509 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 509 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
510 | mNavigator, SLOT( selectPreviousYear() ) ); | 510 | mNavigator, SLOT( selectPreviousYear() ) ); |
511 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 511 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
512 | mNavigator, SLOT( selectNextYear() ) ); | 512 | mNavigator, SLOT( selectNextYear() ) ); |
513 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 513 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
514 | mNavigator, SLOT( selectPreviousMonth() ) ); | 514 | mNavigator, SLOT( selectPreviousMonth() ) ); |
515 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
516 | mNavigator, SLOT( selectNextMonth() ) ); | 516 | mNavigator, SLOT( selectNextMonth() ) ); |
517 | 517 | ||
518 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 518 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
519 | mNavigator, SLOT( selectPrevious() ) ); | 519 | mNavigator, SLOT( selectPrevious() ) ); |
520 | connect( mDateNavigator, SIGNAL( goNext() ), | 520 | connect( mDateNavigator, SIGNAL( goNext() ), |
521 | mNavigator, SLOT( selectNext() ) ); | 521 | mNavigator, SLOT( selectNext() ) ); |
522 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 522 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
523 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 523 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
524 | 524 | ||
525 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 525 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
526 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 526 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
527 | #if 0 | 527 | #if 0 |
528 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 528 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
529 | SLOT( incidenceAdded( Incidence *) ) ); | 529 | SLOT( incidenceAdded( Incidence *) ) ); |
530 | #endif | 530 | #endif |
531 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 531 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
532 | 532 | ||
533 | connect( this, SIGNAL( configChanged() ), | 533 | connect( this, SIGNAL( configChanged() ), |
534 | mDateNavigator, SLOT( updateConfig() ) ); | 534 | mDateNavigator, SLOT( updateConfig() ) ); |
535 | 535 | ||
536 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 536 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
537 | SLOT( newTodo() ) ); | 537 | SLOT( newTodo() ) ); |
538 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 538 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
539 | SLOT( newSubTodo( Todo * ) ) ); | 539 | SLOT( newSubTodo( Todo * ) ) ); |
540 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 540 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
541 | SLOT( editTodo( Todo * ) ) ); | 541 | SLOT( editTodo( Todo * ) ) ); |
542 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
543 | SLOT( showTodo( Todo *) ) ); | 543 | SLOT( showTodo( Todo *) ) ); |
544 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 544 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
545 | SLOT( deleteTodo( Todo *) ) ); | 545 | SLOT( deleteTodo( Todo *) ) ); |
546 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 546 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
547 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 547 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
548 | SLOT( purgeCompleted() ) ); | 548 | SLOT( purgeCompleted() ) ); |
549 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 549 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
550 | SIGNAL( todoModified( Todo *, int ) ) ); | 550 | SIGNAL( todoModified( Todo *, int ) ) ); |
551 | 551 | ||
552 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 552 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
553 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 553 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
554 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
555 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 555 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 557 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
558 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 558 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
559 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
560 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 560 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
561 | 561 | ||
562 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
563 | this, SLOT ( todo_unsub( Todo * ) ) ); | 563 | this, SLOT ( todo_unsub( Todo * ) ) ); |
564 | 564 | ||
565 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 565 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
566 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 566 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
567 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 567 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
568 | SLOT( updateTodo( Todo *, int ) ) ); | 568 | SLOT( updateTodo( Todo *, int ) ) ); |
569 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
570 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 570 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
571 | 571 | ||
572 | 572 | ||
573 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 573 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
574 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 574 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
575 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 575 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
576 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 576 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
577 | 577 | ||
578 | 578 | ||
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 582 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
583 | SLOT(checkClipboard())); | 583 | SLOT(checkClipboard())); |
584 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 584 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
585 | SLOT( processTodoListSelection( Incidence * ) ) ); | 585 | SLOT( processTodoListSelection( Incidence * ) ) ); |
586 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 586 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
587 | 587 | ||
588 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 588 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
589 | 589 | ||
590 | mDateFrame = new QVBox(0,0,WType_Popup); | 590 | mDateFrame = new QVBox(0,0,WType_Popup); |
591 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 591 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
592 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 592 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
593 | mDateFrame->setLineWidth(3); | 593 | mDateFrame->setLineWidth(3); |
594 | mDateFrame->hide(); | 594 | mDateFrame->hide(); |
595 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 595 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
596 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 596 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
597 | 597 | ||
598 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 598 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
599 | 599 | ||
600 | mEventEditor = mDialogManager->getEventEditor(); | 600 | mEventEditor = mDialogManager->getEventEditor(); |
601 | mTodoEditor = mDialogManager->getTodoEditor(); | 601 | mTodoEditor = mDialogManager->getTodoEditor(); |
602 | 602 | ||
603 | mFlagEditDescription = false; | 603 | mFlagEditDescription = false; |
604 | 604 | ||
605 | mSuspendTimer = new QTimer( this ); | 605 | mSuspendTimer = new QTimer( this ); |
606 | mAlarmTimer = new QTimer( this ); | 606 | mAlarmTimer = new QTimer( this ); |
607 | mRecheckAlarmTimer = new QTimer( this ); | 607 | mRecheckAlarmTimer = new QTimer( this ); |
608 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 608 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
609 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 609 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
610 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 610 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
611 | mAlarmDialog = new AlarmDialog( this ); | 611 | mAlarmDialog = new AlarmDialog( this ); |
612 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 612 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
613 | mAlarmDialog->setServerNotification( false ); | 613 | mAlarmDialog->setServerNotification( false ); |
614 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 614 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
615 | 615 | ||
616 | 616 | ||
617 | #ifndef DESKTOP_VERSION | 617 | #ifndef DESKTOP_VERSION |
618 | //US listen for arriving address resultsets | 618 | //US listen for arriving address resultsets |
619 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 619 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
620 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 620 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
621 | #endif | 621 | #endif |
622 | mDateNavigator->setCalendar( mCalendar ); | 622 | mDateNavigator->setCalendar( mCalendar ); |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | CalendarView::~CalendarView() | 626 | CalendarView::~CalendarView() |
627 | { | 627 | { |
628 | // kdDebug() << "~CalendarView()" << endl; | 628 | // kdDebug() << "~CalendarView()" << endl; |
629 | //qDebug("CalendarView::~CalendarView() "); | 629 | //qDebug("CalendarView::~CalendarView() "); |
630 | delete mDialogManager; | 630 | delete mDialogManager; |
631 | delete mViewManager; | 631 | delete mViewManager; |
632 | delete mStorage; | 632 | delete mStorage; |
633 | delete mDateFrame ; | 633 | delete mDateFrame ; |
634 | delete beamDialog; | 634 | delete beamDialog; |
635 | delete mEventViewerDialog; | 635 | delete mEventViewerDialog; |
636 | //kdDebug() << "~CalendarView() done" << endl; | 636 | //kdDebug() << "~CalendarView() done" << endl; |
637 | } | 637 | } |
638 | void CalendarView::checkAlarms() | 638 | void CalendarView::checkAlarms() |
639 | { | 639 | { |
640 | KConfig *config = KOGlobals::config(); | 640 | KConfig *config = KOGlobals::config(); |
641 | config->setGroup( "AppRun" ); | 641 | config->setGroup( "AppRun" ); |
642 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 642 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
643 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 643 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
644 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; | 644 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; |
645 | //secs -= ( 3600 * 24*3 ); // debug only | 645 | //secs -= ( 3600 * 24*3 ); // debug only |
646 | QDateTime latest = dt.addSecs ( secs ); | 646 | QDateTime latest = dt.addSecs ( secs ); |
647 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 647 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
648 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 648 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
649 | QPtrList<Incidence> al; | 649 | QPtrList<Incidence> al; |
650 | Incidence* inL = el.first(); | 650 | Incidence* inL = el.first(); |
651 | while ( inL ) { | 651 | while ( inL ) { |
652 | bool ok = false; | 652 | bool ok = false; |
653 | int offset = 0; | 653 | int offset = 0; |
654 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 654 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
655 | if ( ok ) { | 655 | if ( ok ) { |
656 | //qDebug("OK %s",next.toString().latin1()); | 656 | //qDebug("OK %s",next.toString().latin1()); |
657 | if ( next < QDateTime::currentDateTime() ) { | 657 | if ( next < QDateTime::currentDateTime() ) { |
658 | al.append( inL ); | 658 | al.append( inL ); |
659 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 659 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | inL = el.next(); | 662 | inL = el.next(); |
663 | } | 663 | } |
664 | if ( al.count() ) { | 664 | if ( al.count() ) { |
665 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 665 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
666 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 666 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
667 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 667 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
668 | lay->setSpacing( 0 ); | 668 | lay->setSpacing( 0 ); |
669 | lay->setMargin( 0 ); | 669 | lay->setMargin( 0 ); |
670 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 670 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
671 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 671 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
672 | lay->addWidget( matb ); | 672 | lay->addWidget( matb ); |
673 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 673 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
674 | int wid = 210; | 674 | int wid = 210; |
675 | int x = QApplication::desktop()->width() - wid - 7; | 675 | int x = QApplication::desktop()->width() - wid - 7; |
676 | int y = QApplication::desktop()->height() - wid - 70; | 676 | int y = QApplication::desktop()->height() - wid - 70; |
677 | dia->setGeometry ( x,y,wid,wid); | 677 | dia->setGeometry ( x,y,wid,wid); |
678 | } else { | 678 | } else { |
679 | int si = 220; | 679 | int si = 220; |
680 | if ( QApplication::desktop()->width() > 470 ) | 680 | if ( QApplication::desktop()->width() > 470 ) |
681 | si = 400; | 681 | si = 400; |
682 | dia->resize(si,si/2); | 682 | dia->resize(si,si/2); |
683 | } | 683 | } |
684 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 684 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
685 | dia->show(); | 685 | dia->show(); |
686 | 686 | ||
687 | } | 687 | } |
688 | } | 688 | } |
689 | void CalendarView::showDay( QDate d ) | 689 | void CalendarView::showDay( QDate d ) |
690 | { | 690 | { |
691 | dateNavigator()->blockSignals( true ); | 691 | dateNavigator()->blockSignals( true ); |
692 | dateNavigator()->selectDate( d ); | 692 | dateNavigator()->selectDate( d ); |
693 | dateNavigator()->blockSignals( false ); | 693 | dateNavigator()->blockSignals( false ); |
694 | mViewManager->showDayView(); | 694 | mViewManager->showDayView(); |
695 | //dateNavigator()->selectDate( d ); | 695 | //dateNavigator()->selectDate( d ); |
696 | } | 696 | } |
697 | void CalendarView::timerAlarm() | 697 | void CalendarView::timerAlarm() |
698 | { | 698 | { |
699 | //qDebug("CalendarView::timerAlarm() "); | 699 | //qDebug("CalendarView::timerAlarm() "); |
700 | computeAlarm(mAlarmNotification ); | 700 | computeAlarm(mAlarmNotification ); |
701 | } | 701 | } |
702 | 702 | ||
703 | void CalendarView::suspendAlarm() | 703 | void CalendarView::suspendAlarm() |
704 | { | 704 | { |
705 | //qDebug(" CalendarView::suspendAlarm() "); | 705 | //qDebug(" CalendarView::suspendAlarm() "); |
706 | computeAlarm(mSuspendAlarmNotification ); | 706 | computeAlarm(mSuspendAlarmNotification ); |
707 | 707 | ||
708 | } | 708 | } |
709 | 709 | ||
710 | void CalendarView::startAlarm( QString mess , QString filename) | 710 | void CalendarView::startAlarm( QString mess , QString filename) |
711 | { | 711 | { |
712 | 712 | ||
713 | topLevelWidget()->showNormal(); | 713 | topLevelWidget()->showNormal(); |
714 | topLevelWidget()->setActiveWindow(); | 714 | topLevelWidget()->setActiveWindow(); |
715 | topLevelWidget()->raise(); | 715 | topLevelWidget()->raise(); |
716 | 716 | ||
717 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 717 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
718 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 718 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
719 | 719 | ||
720 | } | 720 | } |
721 | 721 | ||
722 | void CalendarView::checkNextTimerAlarm() | 722 | void CalendarView::checkNextTimerAlarm() |
723 | { | 723 | { |
724 | mCalendar->checkAlarmForIncidence( 0, true ); | 724 | mCalendar->checkAlarmForIncidence( 0, true ); |
725 | } | 725 | } |
726 | 726 | ||
727 | void CalendarView::computeAlarm( QString msg ) | 727 | void CalendarView::computeAlarm( QString msg ) |
728 | { | 728 | { |
729 | 729 | ||
730 | QString mess = msg; | 730 | QString mess = msg; |
731 | QString mAlarmMessage = mess.mid( 9 ); | 731 | QString mAlarmMessage = mess.mid( 9 ); |
732 | QString filename = MainWindow::resourcePath(); | 732 | QString filename = MainWindow::resourcePath(); |
733 | filename += "koalarm.wav"; | 733 | filename += "koalarm.wav"; |
734 | QString tempfilename; | 734 | QString tempfilename; |
735 | if ( mess.left( 13 ) == "suspend_alarm") { | 735 | if ( mess.left( 13 ) == "suspend_alarm") { |
736 | bool error = false; | 736 | bool error = false; |
737 | int len = mess.mid( 13 ).find("+++"); | 737 | int len = mess.mid( 13 ).find("+++"); |
738 | if ( len < 2 ) | 738 | if ( len < 2 ) |
739 | error = true; | 739 | error = true; |
740 | else { | 740 | else { |
741 | tempfilename = mess.mid( 13, len ); | 741 | tempfilename = mess.mid( 13, len ); |
742 | if ( !QFile::exists( tempfilename ) ) | 742 | if ( !QFile::exists( tempfilename ) ) |
743 | error = true; | 743 | error = true; |
744 | } | 744 | } |
745 | if ( ! error ) { | 745 | if ( ! error ) { |
746 | filename = tempfilename; | 746 | filename = tempfilename; |
747 | } | 747 | } |
748 | mAlarmMessage = mess.mid( 13+len+3 ); | 748 | mAlarmMessage = mess.mid( 13+len+3 ); |
749 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 749 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
750 | startAlarm( mAlarmMessage, filename); | 750 | startAlarm( mAlarmMessage, filename); |
751 | return; | 751 | return; |
752 | } | 752 | } |
753 | if ( mess.left( 11 ) == "timer_alarm") { | 753 | if ( mess.left( 11 ) == "timer_alarm") { |
754 | //mTimerTime = 0; | 754 | //mTimerTime = 0; |
755 | startAlarm( mess.mid( 11 ), filename ); | 755 | startAlarm( mess.mid( 11 ), filename ); |
756 | return; | 756 | return; |
757 | } | 757 | } |
758 | if ( mess.left( 10 ) == "proc_alarm") { | 758 | if ( mess.left( 10 ) == "proc_alarm") { |
759 | bool error = false; | 759 | bool error = false; |
760 | int len = mess.mid( 10 ).find("+++"); | 760 | int len = mess.mid( 10 ).find("+++"); |
761 | if ( len < 2 ) | 761 | if ( len < 2 ) |
762 | error = true; | 762 | error = true; |
763 | else { | 763 | else { |
764 | tempfilename = mess.mid( 10, len ); | 764 | tempfilename = mess.mid( 10, len ); |
765 | if ( !QFile::exists( tempfilename ) ) | 765 | if ( !QFile::exists( tempfilename ) ) |
766 | error = true; | 766 | error = true; |
767 | } | 767 | } |
768 | if ( error ) { | 768 | if ( error ) { |
769 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 769 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
770 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 770 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
771 | } else { | 771 | } else { |
772 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 772 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
773 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 773 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
774 | #ifndef _WIN32_ | 774 | #ifndef _WIN32_ |
775 | if ( vfork () == 0 ) { | 775 | if ( vfork () == 0 ) { |
776 | execl ( tempfilename.latin1(), 0 ); | 776 | execl ( tempfilename.latin1(), 0 ); |
777 | return; | 777 | return; |
778 | } | 778 | } |
779 | #else | 779 | #else |
780 | QProcess* p = new QProcess(); | 780 | QProcess* p = new QProcess(); |
781 | p->addArgument( tempfilename.latin1() ); | 781 | p->addArgument( tempfilename.latin1() ); |
782 | p->start(); | 782 | p->start(); |
783 | return; | 783 | return; |
784 | #endif | 784 | #endif |
785 | 785 | ||
786 | return; | 786 | return; |
787 | } | 787 | } |
788 | 788 | ||
789 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 789 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
790 | } | 790 | } |
791 | if ( mess.left( 11 ) == "audio_alarm") { | 791 | if ( mess.left( 11 ) == "audio_alarm") { |
792 | bool error = false; | 792 | bool error = false; |
793 | int len = mess.mid( 11 ).find("+++"); | 793 | int len = mess.mid( 11 ).find("+++"); |
794 | if ( len < 2 ) | 794 | if ( len < 2 ) |
795 | error = true; | 795 | error = true; |
796 | else { | 796 | else { |
797 | tempfilename = mess.mid( 11, len ); | 797 | tempfilename = mess.mid( 11, len ); |
798 | if ( !QFile::exists( tempfilename ) ) | 798 | if ( !QFile::exists( tempfilename ) ) |
799 | error = true; | 799 | error = true; |
800 | } | 800 | } |
801 | if ( ! error ) { | 801 | if ( ! error ) { |
802 | filename = tempfilename; | 802 | filename = tempfilename; |
803 | } | 803 | } |
804 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 804 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
805 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 805 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
806 | } | 806 | } |
807 | if ( mess.left( 9 ) == "cal_alarm") { | 807 | if ( mess.left( 9 ) == "cal_alarm") { |
808 | mAlarmMessage = mess.mid( 9 ) ; | 808 | mAlarmMessage = mess.mid( 9 ) ; |
809 | } | 809 | } |
810 | 810 | ||
811 | startAlarm( mAlarmMessage, filename ); | 811 | startAlarm( mAlarmMessage, filename ); |
812 | 812 | ||
813 | 813 | ||
814 | } | 814 | } |
815 | 815 | ||
816 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 816 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
817 | { | 817 | { |
818 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 818 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
819 | 819 | ||
820 | mSuspendAlarmNotification = noti; | 820 | mSuspendAlarmNotification = noti; |
821 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 821 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
822 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 822 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
823 | mSuspendTimer->start( ms , true ); | 823 | mSuspendTimer->start( ms , true ); |
824 | 824 | ||
825 | } | 825 | } |
826 | 826 | ||
827 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 827 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
828 | { | 828 | { |
829 | mNextAlarmDateTime = qdt; | 829 | mNextAlarmDateTime = qdt; |
830 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 830 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
831 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 831 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
832 | #ifndef DESKTOP_VERSION | 832 | #ifndef DESKTOP_VERSION |
833 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 833 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
834 | #endif | 834 | #endif |
835 | return; | 835 | return; |
836 | } | 836 | } |
837 | int maxSec; | 837 | int maxSec; |
838 | //maxSec = 5; //testing only | 838 | //maxSec = 5; //testing only |
839 | maxSec = 86400+3600; // one day+1hour | 839 | maxSec = 86400+3600; // one day+1hour |
840 | mAlarmNotification = noti; | 840 | mAlarmNotification = noti; |
841 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 841 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
842 | if ( sec > maxSec ) { | 842 | if ( sec > maxSec ) { |
843 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 843 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
844 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 844 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
845 | return; | 845 | return; |
846 | } else { | 846 | } else { |
847 | mRecheckAlarmTimer->stop(); | 847 | mRecheckAlarmTimer->stop(); |
848 | } | 848 | } |
849 | //qDebug("Alarm timer started with secs: %d ", sec); | 849 | //qDebug("Alarm timer started with secs: %d ", sec); |
850 | mAlarmTimer->start( sec *1000 , true ); | 850 | mAlarmTimer->start( sec *1000 , true ); |
851 | 851 | ||
852 | } | 852 | } |
853 | // called by mRecheckAlarmTimer to get next alarm | 853 | // called by mRecheckAlarmTimer to get next alarm |
854 | // we need this, because a QTimer has only a max range of 25 days | 854 | // we need this, because a QTimer has only a max range of 25 days |
855 | void CalendarView::recheckTimerAlarm() | 855 | void CalendarView::recheckTimerAlarm() |
856 | { | 856 | { |
857 | mAlarmTimer->stop(); | 857 | mAlarmTimer->stop(); |
858 | mRecheckAlarmTimer->stop(); | 858 | mRecheckAlarmTimer->stop(); |
859 | mCalendar->checkAlarmForIncidence( 0, true ); | 859 | mCalendar->checkAlarmForIncidence( 0, true ); |
860 | } | 860 | } |
861 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 861 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
862 | { | 862 | { |
863 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 863 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
864 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 864 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
865 | #ifndef DESKTOP_VERSION | 865 | #ifndef DESKTOP_VERSION |
866 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 866 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
867 | #endif | 867 | #endif |
868 | return; | 868 | return; |
869 | } | 869 | } |
870 | mAlarmTimer->stop(); | 870 | mAlarmTimer->stop(); |
871 | } | 871 | } |
872 | void CalendarView::selectWeekNum ( int num ) | 872 | void CalendarView::selectWeekNum ( int num ) |
873 | { | 873 | { |
874 | dateNavigator()->blockSignals( true ); | 874 | dateNavigator()->blockSignals( true ); |
875 | dateNavigator()->selectWeek( num ); | 875 | dateNavigator()->selectWeek( num ); |
876 | dateNavigator()->blockSignals( false ); | 876 | dateNavigator()->blockSignals( false ); |
877 | mViewManager->showWeekView(); | 877 | mViewManager->showWeekView(); |
878 | } | 878 | } |
879 | KOViewManager *CalendarView::viewManager() | 879 | KOViewManager *CalendarView::viewManager() |
880 | { | 880 | { |
881 | return mViewManager; | 881 | return mViewManager; |
882 | } | 882 | } |
883 | 883 | ||
884 | KODialogManager *CalendarView::dialogManager() | 884 | KODialogManager *CalendarView::dialogManager() |
885 | { | 885 | { |
886 | return mDialogManager; | 886 | return mDialogManager; |
887 | } | 887 | } |
888 | 888 | ||
889 | QDate CalendarView::startDate() | 889 | QDate CalendarView::startDate() |
890 | { | 890 | { |
891 | DateList dates = mNavigator->selectedDates(); | 891 | DateList dates = mNavigator->selectedDates(); |
892 | 892 | ||
893 | return dates.first(); | 893 | return dates.first(); |
894 | } | 894 | } |
895 | 895 | ||
896 | QDate CalendarView::endDate() | 896 | QDate CalendarView::endDate() |
897 | { | 897 | { |
898 | DateList dates = mNavigator->selectedDates(); | 898 | DateList dates = mNavigator->selectedDates(); |
899 | 899 | ||
900 | return dates.last(); | 900 | return dates.last(); |
901 | } | 901 | } |
902 | 902 | ||
903 | 903 | ||
904 | void CalendarView::createPrinter() | 904 | void CalendarView::createPrinter() |
905 | { | 905 | { |
906 | #ifndef KORG_NOPRINTER | 906 | #ifndef KORG_NOPRINTER |
907 | if (!mCalPrinter) { | 907 | if (!mCalPrinter) { |
908 | mCalPrinter = new CalPrinter(this, mCalendar); | 908 | mCalPrinter = new CalPrinter(this, mCalendar); |
909 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 909 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
910 | } | 910 | } |
911 | #endif | 911 | #endif |
912 | } | 912 | } |
913 | 913 | ||
914 | 914 | ||
915 | //KOPrefs::instance()->mWriteBackFile | 915 | //KOPrefs::instance()->mWriteBackFile |
916 | //KOPrefs::instance()->mWriteBackExistingOnly | 916 | //KOPrefs::instance()->mWriteBackExistingOnly |
917 | 917 | ||
918 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 918 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
919 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 919 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
920 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 920 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
921 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 921 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
922 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 922 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
923 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 923 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
924 | 924 | ||
925 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 925 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
926 | { | 926 | { |
927 | 927 | ||
928 | // 0 equal | 928 | // 0 equal |
929 | // 1 take local | 929 | // 1 take local |
930 | // 2 take remote | 930 | // 2 take remote |
931 | // 3 cancel | 931 | // 3 cancel |
932 | QDateTime lastSync = mLastCalendarSync; | 932 | QDateTime lastSync = mLastCalendarSync; |
933 | QDateTime localMod = local->lastModified(); | 933 | QDateTime localMod = local->lastModified(); |
934 | QDateTime remoteMod = remote->lastModified(); | 934 | QDateTime remoteMod = remote->lastModified(); |
935 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 935 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
936 | bool remCh, locCh; | 936 | bool remCh, locCh; |
937 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 937 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
938 | //if ( remCh ) | 938 | //if ( remCh ) |
939 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 939 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
940 | locCh = ( localMod > mLastCalendarSync ); | 940 | locCh = ( localMod > mLastCalendarSync ); |
941 | if ( !remCh && ! locCh ) { | 941 | if ( !remCh && ! locCh ) { |
942 | //qDebug("both not changed "); | 942 | //qDebug("both not changed "); |
943 | lastSync = localMod.addDays(1); | 943 | lastSync = localMod.addDays(1); |
944 | if ( mode <= SYNC_PREF_ASK ) | 944 | if ( mode <= SYNC_PREF_ASK ) |
945 | return 0; | 945 | return 0; |
946 | } else { | 946 | } else { |
947 | if ( locCh ) { | 947 | if ( locCh ) { |
948 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 948 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
949 | lastSync = localMod.addDays( -1 ); | 949 | lastSync = localMod.addDays( -1 ); |
950 | if ( !remCh ) | 950 | if ( !remCh ) |
951 | remoteMod = ( lastSync.addDays( -1 ) ); | 951 | remoteMod = ( lastSync.addDays( -1 ) ); |
952 | } else { | 952 | } else { |
953 | //qDebug(" not loc changed "); | 953 | //qDebug(" not loc changed "); |
954 | lastSync = localMod.addDays( 1 ); | 954 | lastSync = localMod.addDays( 1 ); |
955 | if ( remCh ) | 955 | if ( remCh ) |
956 | remoteMod =( lastSync.addDays( 1 ) ); | 956 | remoteMod =( lastSync.addDays( 1 ) ); |
957 | 957 | ||
958 | } | 958 | } |
959 | } | 959 | } |
960 | full = true; | 960 | full = true; |
961 | if ( mode < SYNC_PREF_ASK ) | 961 | if ( mode < SYNC_PREF_ASK ) |
962 | mode = SYNC_PREF_ASK; | 962 | mode = SYNC_PREF_ASK; |
963 | } else { | 963 | } else { |
964 | if ( localMod == remoteMod ) | 964 | if ( localMod == remoteMod ) |
965 | // if ( local->revision() == remote->revision() ) | 965 | // if ( local->revision() == remote->revision() ) |
966 | return 0; | 966 | return 0; |
967 | 967 | ||
968 | } | 968 | } |
969 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 969 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
970 | 970 | ||
971 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 971 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
972 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 972 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
973 | //full = true; //debug only | 973 | //full = true; //debug only |
974 | if ( full ) { | 974 | if ( full ) { |
975 | bool equ = false; | 975 | bool equ = false; |
976 | if ( local->type() == "Event" ) { | 976 | if ( local->typeID() == eventID ) { |
977 | equ = (*((Event*) local) == *((Event*) remote)); | 977 | equ = (*((Event*) local) == *((Event*) remote)); |
978 | } | 978 | } |
979 | else if ( local->type() =="Todo" ) | 979 | else if ( local->typeID() == todoID ) |
980 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 980 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
981 | else if ( local->type() =="Journal" ) | 981 | else if ( local->typeID() == journalID ) |
982 | equ = (*((Journal*) local) == *((Journal*) remote)); | 982 | equ = (*((Journal*) local) == *((Journal*) remote)); |
983 | if ( equ ) { | 983 | if ( equ ) { |
984 | //qDebug("equal "); | 984 | //qDebug("equal "); |
985 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 985 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
986 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 986 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
987 | } | 987 | } |
988 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 988 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
989 | return 0; | 989 | return 0; |
990 | 990 | ||
991 | }//else //debug only | 991 | }//else //debug only |
992 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 992 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
993 | } | 993 | } |
994 | int result; | 994 | int result; |
995 | bool localIsNew; | 995 | bool localIsNew; |
996 | //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() ); | 996 | //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() ); |
997 | 997 | ||
998 | 998 | ||
999 | // ************************************************ | 999 | // ************************************************ |
1000 | // ************************************************ | 1000 | // ************************************************ |
1001 | // ************************************************ | 1001 | // ************************************************ |
1002 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1002 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1003 | // BUT remoteMod != localMod | 1003 | // BUT remoteMod != localMod |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | if ( full && mode < SYNC_PREF_NEWEST ) | 1006 | if ( full && mode < SYNC_PREF_NEWEST ) |
1007 | mode = SYNC_PREF_ASK; | 1007 | mode = SYNC_PREF_ASK; |
1008 | 1008 | ||
1009 | switch( mode ) { | 1009 | switch( mode ) { |
1010 | case SYNC_PREF_LOCAL: | 1010 | case SYNC_PREF_LOCAL: |
1011 | if ( lastSync > remoteMod ) | 1011 | if ( lastSync > remoteMod ) |
1012 | return 1; | 1012 | return 1; |
1013 | if ( lastSync > localMod ) | 1013 | if ( lastSync > localMod ) |
1014 | return 2; | 1014 | return 2; |
1015 | return 1; | 1015 | return 1; |
1016 | break; | 1016 | break; |
1017 | case SYNC_PREF_REMOTE: | 1017 | case SYNC_PREF_REMOTE: |
1018 | if ( lastSync > localMod ) | 1018 | if ( lastSync > localMod ) |
1019 | return 2; | 1019 | return 2; |
1020 | if ( lastSync > remoteMod ) | 1020 | if ( lastSync > remoteMod ) |
1021 | return 1; | 1021 | return 1; |
1022 | return 2; | 1022 | return 2; |
1023 | break; | 1023 | break; |
1024 | case SYNC_PREF_NEWEST: | 1024 | case SYNC_PREF_NEWEST: |
1025 | if ( localMod >= remoteMod ) | 1025 | if ( localMod >= remoteMod ) |
1026 | return 1; | 1026 | return 1; |
1027 | else | 1027 | else |
1028 | return 2; | 1028 | return 2; |
1029 | break; | 1029 | break; |
1030 | case SYNC_PREF_ASK: | 1030 | case SYNC_PREF_ASK: |
1031 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1031 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1032 | if ( lastSync > remoteMod && lastSync > localMod) | 1032 | if ( lastSync > remoteMod && lastSync > localMod) |
1033 | return 0; | 1033 | return 0; |
1034 | if ( lastSync > remoteMod ) | 1034 | if ( lastSync > remoteMod ) |
1035 | return 1; | 1035 | return 1; |
1036 | if ( lastSync > localMod ) | 1036 | if ( lastSync > localMod ) |
1037 | return 2; | 1037 | return 2; |
1038 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1038 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1039 | localIsNew = localMod >= remoteMod; | 1039 | localIsNew = localMod >= remoteMod; |
1040 | if ( localIsNew ) | 1040 | if ( localIsNew ) |
1041 | getEventViewerDialog()->setColorMode( 1 ); | 1041 | getEventViewerDialog()->setColorMode( 1 ); |
1042 | else | 1042 | else |
1043 | getEventViewerDialog()->setColorMode( 2 ); | 1043 | getEventViewerDialog()->setColorMode( 2 ); |
1044 | getEventViewerDialog()->setIncidence(local); | 1044 | getEventViewerDialog()->setIncidence(local); |
1045 | if ( localIsNew ) | 1045 | if ( localIsNew ) |
1046 | getEventViewerDialog()->setColorMode( 2 ); | 1046 | getEventViewerDialog()->setColorMode( 2 ); |
1047 | else | 1047 | else |
1048 | getEventViewerDialog()->setColorMode( 1 ); | 1048 | getEventViewerDialog()->setColorMode( 1 ); |
1049 | getEventViewerDialog()->addIncidence(remote); | 1049 | getEventViewerDialog()->addIncidence(remote); |
1050 | getEventViewerDialog()->setColorMode( 0 ); | 1050 | getEventViewerDialog()->setColorMode( 0 ); |
1051 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1051 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1052 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1052 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1053 | getEventViewerDialog()->showMe(); | 1053 | getEventViewerDialog()->showMe(); |
1054 | result = getEventViewerDialog()->executeS( localIsNew ); | 1054 | result = getEventViewerDialog()->executeS( localIsNew ); |
1055 | return result; | 1055 | return result; |
1056 | 1056 | ||
1057 | break; | 1057 | break; |
1058 | case SYNC_PREF_FORCE_LOCAL: | 1058 | case SYNC_PREF_FORCE_LOCAL: |
1059 | return 1; | 1059 | return 1; |
1060 | break; | 1060 | break; |
1061 | case SYNC_PREF_FORCE_REMOTE: | 1061 | case SYNC_PREF_FORCE_REMOTE: |
1062 | return 2; | 1062 | return 2; |
1063 | break; | 1063 | break; |
1064 | 1064 | ||
1065 | default: | 1065 | default: |
1066 | // SYNC_PREF_TAKE_BOTH not implemented | 1066 | // SYNC_PREF_TAKE_BOTH not implemented |
1067 | break; | 1067 | break; |
1068 | } | 1068 | } |
1069 | return 0; | 1069 | return 0; |
1070 | } | 1070 | } |
1071 | Event* CalendarView::getLastSyncEvent() | 1071 | Event* CalendarView::getLastSyncEvent() |
1072 | { | 1072 | { |
1073 | Event* lse; | 1073 | Event* lse; |
1074 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1074 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1075 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1075 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1076 | if (!lse) { | 1076 | if (!lse) { |
1077 | lse = new Event(); | 1077 | lse = new Event(); |
1078 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1078 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1079 | QString sum = ""; | 1079 | QString sum = ""; |
1080 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1080 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1081 | sum = "E: "; | 1081 | sum = "E: "; |
1082 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1082 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1083 | lse->setDtStart( mLastCalendarSync ); | 1083 | lse->setDtStart( mLastCalendarSync ); |
1084 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1084 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1085 | lse->setCategories( i18n("SyncEvent") ); | 1085 | lse->setCategories( i18n("SyncEvent") ); |
1086 | lse->setReadOnly( true ); | 1086 | lse->setReadOnly( true ); |
1087 | mCalendar->addEvent( lse ); | 1087 | mCalendar->addEvent( lse ); |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | return lse; | 1090 | return lse; |
1091 | 1091 | ||
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | // we check, if the to delete event has a id for a profile | 1094 | // we check, if the to delete event has a id for a profile |
1095 | // if yes, we set this id in the profile to delete | 1095 | // if yes, we set this id in the profile to delete |
1096 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1096 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1097 | { | 1097 | { |
1098 | if ( lastSync.count() == 0 ) { | 1098 | if ( lastSync.count() == 0 ) { |
1099 | //qDebug(" lastSync.count() == 0"); | 1099 | //qDebug(" lastSync.count() == 0"); |
1100 | return; | 1100 | return; |
1101 | } | 1101 | } |
1102 | if ( toDelete->type() == "Journal" ) | 1102 | if ( toDelete->typeID() == journalID ) |
1103 | return; | 1103 | return; |
1104 | 1104 | ||
1105 | Event* eve = lastSync.first(); | 1105 | Event* eve = lastSync.first(); |
1106 | 1106 | ||
1107 | while ( eve ) { | 1107 | while ( eve ) { |
1108 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1108 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1109 | if ( !id.isEmpty() ) { | 1109 | if ( !id.isEmpty() ) { |
1110 | QString des = eve->description(); | 1110 | QString des = eve->description(); |
1111 | QString pref = "e"; | 1111 | QString pref = "e"; |
1112 | if ( toDelete->type() == "Todo" ) | 1112 | if ( toDelete->typeID() == todoID ) |
1113 | pref = "t"; | 1113 | pref = "t"; |
1114 | des += pref+ id + ","; | 1114 | des += pref+ id + ","; |
1115 | eve->setReadOnly( false ); | 1115 | eve->setReadOnly( false ); |
1116 | eve->setDescription( des ); | 1116 | eve->setDescription( des ); |
1117 | //qDebug("setdes %s ", des.latin1()); | 1117 | //qDebug("setdes %s ", des.latin1()); |
1118 | eve->setReadOnly( true ); | 1118 | eve->setReadOnly( true ); |
1119 | } | 1119 | } |
1120 | eve = lastSync.next(); | 1120 | eve = lastSync.next(); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | } | 1123 | } |
1124 | void CalendarView::checkExternalId( Incidence * inc ) | 1124 | void CalendarView::checkExternalId( Incidence * inc ) |
1125 | { | 1125 | { |
1126 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1126 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1127 | checkExternSyncEvent( lastSync, inc ); | 1127 | checkExternSyncEvent( lastSync, inc ); |
1128 | 1128 | ||
1129 | } | 1129 | } |
1130 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1130 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1131 | { | 1131 | { |
1132 | bool syncOK = true; | 1132 | bool syncOK = true; |
1133 | int addedEvent = 0; | 1133 | int addedEvent = 0; |
1134 | int addedEventR = 0; | 1134 | int addedEventR = 0; |
1135 | int deletedEventR = 0; | 1135 | int deletedEventR = 0; |
1136 | int deletedEventL = 0; | 1136 | int deletedEventL = 0; |
1137 | int changedLocal = 0; | 1137 | int changedLocal = 0; |
1138 | int changedRemote = 0; | 1138 | int changedRemote = 0; |
1139 | int filteredIN = 0; | 1139 | int filteredIN = 0; |
1140 | int filteredOUT = 0; | 1140 | int filteredOUT = 0; |
1141 | //QPtrList<Event> el = local->rawEvents(); | 1141 | //QPtrList<Event> el = local->rawEvents(); |
1142 | Event* eventR; | 1142 | Event* eventR; |
1143 | QString uid; | 1143 | QString uid; |
1144 | int take; | 1144 | int take; |
1145 | Event* eventL; | 1145 | Event* eventL; |
1146 | Event* eventRSync; | 1146 | Event* eventRSync; |
1147 | Event* eventLSync; | 1147 | Event* eventLSync; |
1148 | clearAllViews(); | 1148 | clearAllViews(); |
1149 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1149 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1150 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1150 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1151 | bool fullDateRange = false; | 1151 | bool fullDateRange = false; |
1152 | local->resetTempSyncStat(); | 1152 | local->resetTempSyncStat(); |
1153 | mLastCalendarSync = QDateTime::currentDateTime(); | 1153 | mLastCalendarSync = QDateTime::currentDateTime(); |
1154 | if ( mSyncManager->syncWithDesktop() ) { | 1154 | if ( mSyncManager->syncWithDesktop() ) { |
1155 | remote->resetPilotStat(1); | 1155 | remote->resetPilotStat(1); |
1156 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1156 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1157 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1157 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1158 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1158 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1159 | } else { | 1159 | } else { |
1160 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1160 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1161 | } | 1161 | } |
1162 | } | 1162 | } |
1163 | QDateTime modifiedCalendar = mLastCalendarSync; | 1163 | QDateTime modifiedCalendar = mLastCalendarSync; |
1164 | eventLSync = getLastSyncEvent(); | 1164 | eventLSync = getLastSyncEvent(); |
1165 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1165 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1166 | if ( eventR ) { | 1166 | if ( eventR ) { |
1167 | eventRSync = (Event*) eventR->clone(); | 1167 | eventRSync = (Event*) eventR->clone(); |
1168 | remote->deleteEvent(eventR ); | 1168 | remote->deleteEvent(eventR ); |
1169 | 1169 | ||
1170 | } else { | 1170 | } else { |
1171 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1171 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1172 | eventRSync = (Event*)eventLSync->clone(); | 1172 | eventRSync = (Event*)eventLSync->clone(); |
1173 | } else { | 1173 | } else { |
1174 | fullDateRange = true; | 1174 | fullDateRange = true; |
1175 | eventRSync = new Event(); | 1175 | eventRSync = new Event(); |
1176 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1176 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1177 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1177 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1178 | eventRSync->setDtStart( mLastCalendarSync ); | 1178 | eventRSync->setDtStart( mLastCalendarSync ); |
1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1180 | eventRSync->setCategories( i18n("SyncEvent") ); | 1180 | eventRSync->setCategories( i18n("SyncEvent") ); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1183 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1184 | fullDateRange = true; | 1184 | fullDateRange = true; |
1185 | 1185 | ||
1186 | if ( ! fullDateRange ) { | 1186 | if ( ! fullDateRange ) { |
1187 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1187 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1188 | 1188 | ||
1189 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1189 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1190 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1190 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1191 | fullDateRange = true; | 1191 | fullDateRange = true; |
1192 | } | 1192 | } |
1193 | } | 1193 | } |
1194 | if ( mSyncManager->syncWithDesktop() ) { | 1194 | if ( mSyncManager->syncWithDesktop() ) { |
1195 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1195 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1196 | } | 1196 | } |
1197 | if ( fullDateRange ) | 1197 | if ( fullDateRange ) |
1198 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1198 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1199 | else | 1199 | else |
1200 | mLastCalendarSync = eventLSync->dtStart(); | 1200 | mLastCalendarSync = eventLSync->dtStart(); |
1201 | // for resyncing if own file has changed | 1201 | // for resyncing if own file has changed |
1202 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1202 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1203 | mLastCalendarSync = loadedFileVersion; | 1203 | mLastCalendarSync = loadedFileVersion; |
1204 | //qDebug("setting mLastCalendarSync "); | 1204 | //qDebug("setting mLastCalendarSync "); |
1205 | } | 1205 | } |
1206 | //qDebug("*************************** "); | 1206 | //qDebug("*************************** "); |
1207 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1207 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1208 | QPtrList<Incidence> er = remote->rawIncidences(); | 1208 | QPtrList<Incidence> er = remote->rawIncidences(); |
1209 | Incidence* inR = er.first(); | 1209 | Incidence* inR = er.first(); |
1210 | Incidence* inL; | 1210 | Incidence* inL; |
1211 | QProgressBar bar( er.count(),0 ); | 1211 | QProgressBar bar( er.count(),0 ); |
1212 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1212 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1213 | 1213 | ||
1214 | // ************** setting up filter ************* | 1214 | // ************** setting up filter ************* |
1215 | CalFilter *filterIN = 0; | 1215 | CalFilter *filterIN = 0; |
1216 | CalFilter *filterOUT = 0; | 1216 | CalFilter *filterOUT = 0; |
1217 | CalFilter *filter = mFilters.first(); | 1217 | CalFilter *filter = mFilters.first(); |
1218 | while(filter) { | 1218 | while(filter) { |
1219 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1219 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1220 | filterIN = filter; | 1220 | filterIN = filter; |
1221 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1221 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1222 | filterOUT = filter; | 1222 | filterOUT = filter; |
1223 | filter = mFilters.next(); | 1223 | filter = mFilters.next(); |
1224 | } | 1224 | } |
1225 | int w = 300; | 1225 | int w = 300; |
1226 | if ( QApplication::desktop()->width() < 320 ) | 1226 | if ( QApplication::desktop()->width() < 320 ) |
1227 | w = 220; | 1227 | w = 220; |
1228 | int h = bar.sizeHint().height() ; | 1228 | int h = bar.sizeHint().height() ; |
1229 | int dw = QApplication::desktop()->width(); | 1229 | int dw = QApplication::desktop()->width(); |
1230 | int dh = QApplication::desktop()->height(); | 1230 | int dh = QApplication::desktop()->height(); |
1231 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1231 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1232 | bar.show(); | 1232 | bar.show(); |
1233 | int modulo = (er.count()/10)+1; | 1233 | int modulo = (er.count()/10)+1; |
1234 | int incCounter = 0; | 1234 | int incCounter = 0; |
1235 | while ( inR ) { | 1235 | while ( inR ) { |
1236 | if ( ! bar.isVisible() ) | 1236 | if ( ! bar.isVisible() ) |
1237 | return false; | 1237 | return false; |
1238 | if ( incCounter % modulo == 0 ) | 1238 | if ( incCounter % modulo == 0 ) |
1239 | bar.setProgress( incCounter ); | 1239 | bar.setProgress( incCounter ); |
1240 | ++incCounter; | 1240 | ++incCounter; |
1241 | uid = inR->uid(); | 1241 | uid = inR->uid(); |
1242 | bool skipIncidence = false; | 1242 | bool skipIncidence = false; |
1243 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1243 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1244 | skipIncidence = true; | 1244 | skipIncidence = true; |
1245 | QString idS; | 1245 | QString idS; |
1246 | qApp->processEvents(); | 1246 | qApp->processEvents(); |
1247 | if ( !skipIncidence ) { | 1247 | if ( !skipIncidence ) { |
1248 | inL = local->incidence( uid ); | 1248 | inL = local->incidence( uid ); |
1249 | if ( inL ) { // maybe conflict - same uid in both calendars | 1249 | if ( inL ) { // maybe conflict - same uid in both calendars |
1250 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1250 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1251 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1251 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1252 | if ( take == 3 ) | 1252 | if ( take == 3 ) |
1253 | return false; | 1253 | return false; |
1254 | if ( take == 1 ) {// take local ********************** | 1254 | if ( take == 1 ) {// take local ********************** |
1255 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1255 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1256 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1256 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1257 | else | 1257 | else |
1258 | idS = inR->IDStr(); | 1258 | idS = inR->IDStr(); |
1259 | remote->deleteIncidence( inR ); | 1259 | remote->deleteIncidence( inR ); |
1260 | inR = inL->clone(); | 1260 | inR = inL->clone(); |
1261 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1261 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1262 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1262 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1263 | inR->setIDStr( idS ); | 1263 | inR->setIDStr( idS ); |
1264 | remote->addIncidence( inR ); | 1264 | remote->addIncidence( inR ); |
1265 | if ( mSyncManager->syncWithDesktop() ) | 1265 | if ( mSyncManager->syncWithDesktop() ) |
1266 | inR->setPilotId( 2 ); | 1266 | inR->setPilotId( 2 ); |
1267 | ++changedRemote; | 1267 | ++changedRemote; |
1268 | } else {// take remote ********************** | 1268 | } else {// take remote ********************** |
1269 | idS = inL->IDStr(); | 1269 | idS = inL->IDStr(); |
1270 | int pid = inL->pilotId(); | 1270 | int pid = inL->pilotId(); |
1271 | local->deleteIncidence( inL ); | 1271 | local->deleteIncidence( inL ); |
1272 | inL = inR->clone(); | 1272 | inL = inR->clone(); |
1273 | if ( mSyncManager->syncWithDesktop() ) | 1273 | if ( mSyncManager->syncWithDesktop() ) |
1274 | inL->setPilotId( pid ); | 1274 | inL->setPilotId( pid ); |
1275 | inL->setIDStr( idS ); | 1275 | inL->setIDStr( idS ); |
1276 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1276 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1277 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1277 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1278 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1278 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1279 | } | 1279 | } |
1280 | local->addIncidence( inL ); | 1280 | local->addIncidence( inL ); |
1281 | ++changedLocal; | 1281 | ++changedLocal; |
1282 | } | 1282 | } |
1283 | } | 1283 | } |
1284 | } else { // no conflict ********** add or delete remote | 1284 | } else { // no conflict ********** add or delete remote |
1285 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1285 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1286 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1286 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1287 | QString des = eventLSync->description(); | 1287 | QString des = eventLSync->description(); |
1288 | QString pref = "e"; | 1288 | QString pref = "e"; |
1289 | if ( inR->type() == "Todo" ) | 1289 | if ( inR->typeID() == todoID ) |
1290 | pref = "t"; | 1290 | pref = "t"; |
1291 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1291 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1292 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1292 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1293 | //remote->deleteIncidence( inR ); | 1293 | //remote->deleteIncidence( inR ); |
1294 | ++deletedEventR; | 1294 | ++deletedEventR; |
1295 | } else { | 1295 | } else { |
1296 | inR->setLastModified( modifiedCalendar ); | 1296 | inR->setLastModified( modifiedCalendar ); |
1297 | inL = inR->clone(); | 1297 | inL = inR->clone(); |
1298 | inL->setIDStr( ":" ); | 1298 | inL->setIDStr( ":" ); |
1299 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1299 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1300 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1300 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1301 | local->addIncidence( inL ); | 1301 | local->addIncidence( inL ); |
1302 | ++addedEvent; | 1302 | ++addedEvent; |
1303 | 1303 | ||
1304 | } | 1304 | } |
1305 | } else { | 1305 | } else { |
1306 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1306 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1307 | inR->setLastModified( modifiedCalendar ); | 1307 | inR->setLastModified( modifiedCalendar ); |
1308 | inL = inR->clone(); | 1308 | inL = inR->clone(); |
1309 | inL->setIDStr( ":" ); | 1309 | inL->setIDStr( ":" ); |
1310 | local->addIncidence( inL ); | 1310 | local->addIncidence( inL ); |
1311 | ++addedEvent; | 1311 | ++addedEvent; |
1312 | 1312 | ||
1313 | } else { | 1313 | } else { |
1314 | checkExternSyncEvent(eventRSyncSharp, inR); | 1314 | checkExternSyncEvent(eventRSyncSharp, inR); |
1315 | remote->deleteIncidence( inR ); | 1315 | remote->deleteIncidence( inR ); |
1316 | ++deletedEventR; | 1316 | ++deletedEventR; |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | } else { | 1319 | } else { |
1320 | ++filteredIN; | 1320 | ++filteredIN; |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | } | 1323 | } |
1324 | inR = er.next(); | 1324 | inR = er.next(); |
1325 | } | 1325 | } |
1326 | QPtrList<Incidence> el = local->rawIncidences(); | 1326 | QPtrList<Incidence> el = local->rawIncidences(); |
1327 | inL = el.first(); | 1327 | inL = el.first(); |
1328 | modulo = (el.count()/10)+1; | 1328 | modulo = (el.count()/10)+1; |
1329 | bar.setCaption (i18n("Add / remove events") ); | 1329 | bar.setCaption (i18n("Add / remove events") ); |
1330 | bar.setTotalSteps ( el.count() ) ; | 1330 | bar.setTotalSteps ( el.count() ) ; |
1331 | bar.show(); | 1331 | bar.show(); |
1332 | incCounter = 0; | 1332 | incCounter = 0; |
1333 | 1333 | ||
1334 | while ( inL ) { | 1334 | while ( inL ) { |
1335 | 1335 | ||
1336 | qApp->processEvents(); | 1336 | qApp->processEvents(); |
1337 | if ( ! bar.isVisible() ) | 1337 | if ( ! bar.isVisible() ) |
1338 | return false; | 1338 | return false; |
1339 | if ( incCounter % modulo == 0 ) | 1339 | if ( incCounter % modulo == 0 ) |
1340 | bar.setProgress( incCounter ); | 1340 | bar.setProgress( incCounter ); |
1341 | ++incCounter; | 1341 | ++incCounter; |
1342 | uid = inL->uid(); | 1342 | uid = inL->uid(); |
1343 | bool skipIncidence = false; | 1343 | bool skipIncidence = false; |
1344 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1344 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1345 | skipIncidence = true; | 1345 | skipIncidence = true; |
1346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1347 | skipIncidence = true; | 1347 | skipIncidence = true; |
1348 | if ( !skipIncidence ) { | 1348 | if ( !skipIncidence ) { |
1349 | inR = remote->incidence( uid ); | 1349 | inR = remote->incidence( uid ); |
1350 | if ( ! inR ) { | 1350 | if ( ! inR ) { |
1351 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1351 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1352 | // no conflict ********** add or delete local | 1352 | // no conflict ********** add or delete local |
1353 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1353 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1354 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1354 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1355 | checkExternSyncEvent(eventLSyncSharp, inL); | 1355 | checkExternSyncEvent(eventLSyncSharp, inL); |
1356 | local->deleteIncidence( inL ); | 1356 | local->deleteIncidence( inL ); |
1357 | ++deletedEventL; | 1357 | ++deletedEventL; |
1358 | } else { | 1358 | } else { |
1359 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1359 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1360 | inL->removeID(mCurrentSyncDevice ); | 1360 | inL->removeID(mCurrentSyncDevice ); |
1361 | ++addedEventR; | 1361 | ++addedEventR; |
1362 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1362 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1363 | inL->setLastModified( modifiedCalendar ); | 1363 | inL->setLastModified( modifiedCalendar ); |
1364 | inR = inL->clone(); | 1364 | inR = inL->clone(); |
1365 | inR->setIDStr( ":" ); | 1365 | inR->setIDStr( ":" ); |
1366 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1366 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1367 | remote->addIncidence( inR ); | 1367 | remote->addIncidence( inR ); |
1368 | } | 1368 | } |
1369 | } | 1369 | } |
1370 | } else { | 1370 | } else { |
1371 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1371 | if ( inL->lastModified() < mLastCalendarSync && 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 | ++addedEventR; | 1377 | ++addedEventR; |
1378 | inL->setLastModified( modifiedCalendar ); | 1378 | inL->setLastModified( modifiedCalendar ); |
1379 | inR = inL->clone(); | 1379 | inR = inL->clone(); |
1380 | inR->setIDStr( ":" ); | 1380 | inR->setIDStr( ":" ); |
1381 | remote->addIncidence( inR ); | 1381 | remote->addIncidence( inR ); |
1382 | } | 1382 | } |
1383 | } | 1383 | } |
1384 | } | 1384 | } |
1385 | } else { | 1385 | } else { |
1386 | ++filteredOUT; | 1386 | ++filteredOUT; |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | } | 1389 | } |
1390 | inL = el.next(); | 1390 | inL = el.next(); |
1391 | } | 1391 | } |
1392 | int delFut = 0; | 1392 | int delFut = 0; |
1393 | int remRem = 0; | 1393 | int remRem = 0; |
1394 | if ( mSyncManager->mWriteBackInFuture ) { | 1394 | if ( mSyncManager->mWriteBackInFuture ) { |
1395 | er = remote->rawIncidences(); | 1395 | er = remote->rawIncidences(); |
1396 | remRem = er.count(); | 1396 | remRem = er.count(); |
1397 | inR = er.first(); | 1397 | inR = er.first(); |
1398 | QDateTime dt; | 1398 | QDateTime dt; |
1399 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1399 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1400 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1400 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1401 | while ( inR ) { | 1401 | while ( inR ) { |
1402 | if ( inR->type() == "Todo" ) { | 1402 | if ( inR->typeID() == todoID ) { |
1403 | Todo * t = (Todo*)inR; | 1403 | Todo * t = (Todo*)inR; |
1404 | if ( t->hasDueDate() ) | 1404 | if ( t->hasDueDate() ) |
1405 | dt = t->dtDue(); | 1405 | dt = t->dtDue(); |
1406 | else | 1406 | else |
1407 | dt = cur.addSecs( 62 ); | 1407 | dt = cur.addSecs( 62 ); |
1408 | } | 1408 | } |
1409 | else if (inR->type() == "Event" ) { | 1409 | else if (inR->typeID() == eventID ) { |
1410 | bool ok; | 1410 | bool ok; |
1411 | dt = inR->getNextOccurence( cur, &ok ); | 1411 | dt = inR->getNextOccurence( cur, &ok ); |
1412 | if ( !ok ) | 1412 | if ( !ok ) |
1413 | dt = cur.addSecs( -62 ); | 1413 | dt = cur.addSecs( -62 ); |
1414 | } | 1414 | } |
1415 | else | 1415 | else |
1416 | dt = inR->dtStart(); | 1416 | dt = inR->dtStart(); |
1417 | if ( dt < cur || dt > end ) { | 1417 | if ( dt < cur || dt > end ) { |
1418 | remote->deleteIncidence( inR ); | 1418 | remote->deleteIncidence( inR ); |
1419 | ++delFut; | 1419 | ++delFut; |
1420 | } | 1420 | } |
1421 | inR = er.next(); | 1421 | inR = er.next(); |
1422 | } | 1422 | } |
1423 | } | 1423 | } |
1424 | bar.hide(); | 1424 | bar.hide(); |
1425 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1425 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1426 | eventLSync->setReadOnly( false ); | 1426 | eventLSync->setReadOnly( false ); |
1427 | eventLSync->setDtStart( mLastCalendarSync ); | 1427 | eventLSync->setDtStart( mLastCalendarSync ); |
1428 | eventRSync->setDtStart( mLastCalendarSync ); | 1428 | eventRSync->setDtStart( mLastCalendarSync ); |
1429 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1429 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1430 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1430 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1431 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1431 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1432 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1432 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1433 | eventLSync->setReadOnly( true ); | 1433 | eventLSync->setReadOnly( true ); |
1434 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1434 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1435 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1435 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1436 | remote->addEvent( eventRSync ); | 1436 | remote->addEvent( eventRSync ); |
1437 | else | 1437 | else |
1438 | delete eventRSync; | 1438 | delete eventRSync; |
1439 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1439 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1440 | QString mes; | 1440 | QString mes; |
1441 | 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 ); | 1441 | 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 ); |
1442 | QString delmess; | 1442 | QString delmess; |
1443 | if ( delFut ) { | 1443 | if ( delFut ) { |
1444 | 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); | 1444 | 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); |
1445 | mes += delmess; | 1445 | mes += delmess; |
1446 | } | 1446 | } |
1447 | mes = i18n("Local calendar changed!\n") +mes; | 1447 | mes = i18n("Local calendar changed!\n") +mes; |
1448 | mCalendar->checkAlarmForIncidence( 0, true ); | 1448 | mCalendar->checkAlarmForIncidence( 0, true ); |
1449 | qDebug( mes ); | 1449 | qDebug( mes ); |
1450 | if ( mSyncManager->mShowSyncSummary ) { | 1450 | if ( mSyncManager->mShowSyncSummary ) { |
1451 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1451 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1452 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1452 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1453 | qDebug("KO: WB cancelled "); | 1453 | qDebug("KO: WB cancelled "); |
1454 | mSyncManager->mWriteBackFile = false; | 1454 | mSyncManager->mWriteBackFile = false; |
1455 | return syncOK; | 1455 | return syncOK; |
1456 | } | 1456 | } |
1457 | } | 1457 | } |
1458 | return syncOK; | 1458 | return syncOK; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | void CalendarView::setSyncDevice( QString s ) | 1461 | void CalendarView::setSyncDevice( QString s ) |
1462 | { | 1462 | { |
1463 | mCurrentSyncDevice= s; | 1463 | mCurrentSyncDevice= s; |
1464 | } | 1464 | } |
1465 | void CalendarView::setSyncName( QString s ) | 1465 | void CalendarView::setSyncName( QString s ) |
1466 | { | 1466 | { |
1467 | mCurrentSyncName= s; | 1467 | mCurrentSyncName= s; |
1468 | } | 1468 | } |
1469 | bool CalendarView::syncCalendar(QString filename, int mode) | 1469 | bool CalendarView::syncCalendar(QString filename, int mode) |
1470 | { | 1470 | { |
1471 | //qDebug("syncCalendar %s ", filename.latin1()); | 1471 | //qDebug("syncCalendar %s ", filename.latin1()); |
1472 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1472 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1473 | CalendarLocal* calendar = new CalendarLocal(); | 1473 | CalendarLocal* calendar = new CalendarLocal(); |
1474 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1474 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1475 | FileStorage* storage = new FileStorage( calendar ); | 1475 | FileStorage* storage = new FileStorage( calendar ); |
1476 | bool syncOK = false; | 1476 | bool syncOK = false; |
1477 | storage->setFileName( filename ); | 1477 | storage->setFileName( filename ); |
1478 | // qDebug("loading ... "); | 1478 | // qDebug("loading ... "); |
1479 | if ( storage->load() ) { | 1479 | if ( storage->load() ) { |
1480 | getEventViewerDialog()->setSyncMode( true ); | 1480 | getEventViewerDialog()->setSyncMode( true ); |
1481 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1481 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1482 | getEventViewerDialog()->setSyncMode( false ); | 1482 | getEventViewerDialog()->setSyncMode( false ); |
1483 | if ( syncOK ) { | 1483 | if ( syncOK ) { |
1484 | if ( mSyncManager->mWriteBackFile ) | 1484 | if ( mSyncManager->mWriteBackFile ) |
1485 | { | 1485 | { |
1486 | storage->setSaveFormat( new ICalFormat() ); | 1486 | storage->setSaveFormat( new ICalFormat() ); |
1487 | storage->save(); | 1487 | storage->save(); |
1488 | } | 1488 | } |
1489 | } | 1489 | } |
1490 | setModified( true ); | 1490 | setModified( true ); |
1491 | } | 1491 | } |
1492 | delete storage; | 1492 | delete storage; |
1493 | delete calendar; | 1493 | delete calendar; |
1494 | if ( syncOK ) | 1494 | if ( syncOK ) |
1495 | updateView(); | 1495 | updateView(); |
1496 | return syncOK; | 1496 | return syncOK; |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | void CalendarView::syncExternal( int mode ) | 1499 | void CalendarView::syncExternal( int mode ) |
1500 | { | 1500 | { |
1501 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1501 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1502 | 1502 | ||
1503 | qApp->processEvents(); | 1503 | qApp->processEvents(); |
1504 | CalendarLocal* calendar = new CalendarLocal(); | 1504 | CalendarLocal* calendar = new CalendarLocal(); |
1505 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1505 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1506 | bool syncOK = false; | 1506 | bool syncOK = false; |
1507 | bool loadSuccess = false; | 1507 | bool loadSuccess = false; |
1508 | PhoneFormat* phoneFormat = 0; | 1508 | PhoneFormat* phoneFormat = 0; |
1509 | emit tempDisableBR(true); | 1509 | emit tempDisableBR(true); |
1510 | #ifndef DESKTOP_VERSION | 1510 | #ifndef DESKTOP_VERSION |
1511 | SharpFormat* sharpFormat = 0; | 1511 | SharpFormat* sharpFormat = 0; |
1512 | if ( mode == 0 ) { // sharp | 1512 | if ( mode == 0 ) { // sharp |
1513 | sharpFormat = new SharpFormat () ; | 1513 | sharpFormat = new SharpFormat () ; |
1514 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1514 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1515 | 1515 | ||
1516 | } else | 1516 | } else |
1517 | #endif | 1517 | #endif |
1518 | if ( mode == 1 ) { // phone | 1518 | if ( mode == 1 ) { // phone |
1519 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1519 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1520 | mSyncManager->mPhoneDevice, | 1520 | mSyncManager->mPhoneDevice, |
1521 | mSyncManager->mPhoneConnection, | 1521 | mSyncManager->mPhoneConnection, |
1522 | mSyncManager->mPhoneModel); | 1522 | mSyncManager->mPhoneModel); |
1523 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1523 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1524 | 1524 | ||
1525 | } else { | 1525 | } else { |
1526 | emit tempDisableBR(false); | 1526 | emit tempDisableBR(false); |
1527 | return; | 1527 | return; |
1528 | } | 1528 | } |
1529 | if ( loadSuccess ) { | 1529 | if ( loadSuccess ) { |
1530 | getEventViewerDialog()->setSyncMode( true ); | 1530 | getEventViewerDialog()->setSyncMode( true ); |
1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1532 | getEventViewerDialog()->setSyncMode( false ); | 1532 | getEventViewerDialog()->setSyncMode( false ); |
1533 | qApp->processEvents(); | 1533 | qApp->processEvents(); |
1534 | if ( syncOK ) { | 1534 | if ( syncOK ) { |
1535 | if ( mSyncManager->mWriteBackFile ) | 1535 | if ( mSyncManager->mWriteBackFile ) |
1536 | { | 1536 | { |
1537 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1537 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1538 | Incidence* inc = iL.first(); | 1538 | Incidence* inc = iL.first(); |
1539 | if ( phoneFormat ) { | 1539 | if ( phoneFormat ) { |
1540 | while ( inc ) { | 1540 | while ( inc ) { |
1541 | inc->removeID(mCurrentSyncDevice); | 1541 | inc->removeID(mCurrentSyncDevice); |
1542 | inc = iL.next(); | 1542 | inc = iL.next(); |
1543 | } | 1543 | } |
1544 | } | 1544 | } |
1545 | #ifndef DESKTOP_VERSION | 1545 | #ifndef DESKTOP_VERSION |
1546 | if ( sharpFormat ) | 1546 | if ( sharpFormat ) |
1547 | sharpFormat->save(calendar); | 1547 | sharpFormat->save(calendar); |
1548 | #endif | 1548 | #endif |
1549 | if ( phoneFormat ) | 1549 | if ( phoneFormat ) |
1550 | phoneFormat->save(calendar); | 1550 | phoneFormat->save(calendar); |
1551 | iL = calendar->rawIncidences(); | 1551 | iL = calendar->rawIncidences(); |
1552 | inc = iL.first(); | 1552 | inc = iL.first(); |
1553 | Incidence* loc; | 1553 | Incidence* loc; |
1554 | while ( inc ) { | 1554 | while ( inc ) { |
1555 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1555 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1556 | loc = mCalendar->incidence(inc->uid() ); | 1556 | loc = mCalendar->incidence(inc->uid() ); |
1557 | if ( loc ) { | 1557 | if ( loc ) { |
1558 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1558 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1559 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1559 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1560 | } | 1560 | } |
1561 | } | 1561 | } |
1562 | inc = iL.next(); | 1562 | inc = iL.next(); |
1563 | } | 1563 | } |
1564 | Incidence* lse = getLastSyncEvent(); | 1564 | Incidence* lse = getLastSyncEvent(); |
1565 | if ( lse ) { | 1565 | if ( lse ) { |
1566 | lse->setReadOnly( false ); | 1566 | lse->setReadOnly( false ); |
1567 | lse->setDescription( "" ); | 1567 | lse->setDescription( "" ); |
1568 | lse->setReadOnly( true ); | 1568 | lse->setReadOnly( true ); |
1569 | } | 1569 | } |
1570 | } | 1570 | } |
1571 | } else { | 1571 | } else { |
1572 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1572 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1573 | } | 1573 | } |
1574 | setModified( true ); | 1574 | setModified( true ); |
1575 | } else { | 1575 | } else { |
1576 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1576 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1577 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1577 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1578 | question, i18n("Ok")) ; | 1578 | question, i18n("Ok")) ; |
1579 | 1579 | ||
1580 | } | 1580 | } |
1581 | delete calendar; | 1581 | delete calendar; |
1582 | updateView(); | 1582 | updateView(); |
1583 | emit tempDisableBR(false); | 1583 | emit tempDisableBR(false); |
1584 | return ;//syncOK; | 1584 | return ;//syncOK; |
1585 | 1585 | ||
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | bool CalendarView::importBday() | 1588 | bool CalendarView::importBday() |
1589 | { | 1589 | { |
1590 | #ifndef KORG_NOKABC | 1590 | #ifndef KORG_NOKABC |
1591 | 1591 | ||
1592 | #ifdef DESKTOP_VERSION | 1592 | #ifdef DESKTOP_VERSION |
1593 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1593 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1594 | KABC::AddressBook::Iterator it; | 1594 | KABC::AddressBook::Iterator it; |
1595 | int count = 0; | 1595 | int count = 0; |
1596 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1596 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1597 | ++count; | 1597 | ++count; |
1598 | } | 1598 | } |
1599 | QProgressBar bar(count,0 ); | 1599 | QProgressBar bar(count,0 ); |
1600 | int w = 300; | 1600 | int w = 300; |
1601 | if ( QApplication::desktop()->width() < 320 ) | 1601 | if ( QApplication::desktop()->width() < 320 ) |
1602 | w = 220; | 1602 | w = 220; |
1603 | int h = bar.sizeHint().height() ; | 1603 | int h = bar.sizeHint().height() ; |
1604 | int dw = QApplication::desktop()->width(); | 1604 | int dw = QApplication::desktop()->width(); |
1605 | int dh = QApplication::desktop()->height(); | 1605 | int dh = QApplication::desktop()->height(); |
1606 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1606 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1607 | bar.show(); | 1607 | bar.show(); |
1608 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1608 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1609 | qApp->processEvents(); | 1609 | qApp->processEvents(); |
1610 | count = 0; | 1610 | count = 0; |
1611 | int addCount = 0; | 1611 | int addCount = 0; |
1612 | KCal::Attendee* a = 0; | 1612 | KCal::Attendee* a = 0; |
1613 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1613 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1614 | if ( ! bar.isVisible() ) | 1614 | if ( ! bar.isVisible() ) |
1615 | return false; | 1615 | return false; |
1616 | bar.setProgress( count++ ); | 1616 | bar.setProgress( count++ ); |
1617 | qApp->processEvents(); | 1617 | qApp->processEvents(); |
1618 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1618 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1619 | if ( (*it).birthday().date().isValid() ){ | 1619 | if ( (*it).birthday().date().isValid() ){ |
1620 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1620 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1621 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1621 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1622 | ++addCount; | 1622 | ++addCount; |
1623 | } | 1623 | } |
1624 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1624 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1625 | if ( anni.isValid() ){ | 1625 | if ( anni.isValid() ){ |
1626 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1626 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1627 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1627 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1628 | ++addCount; | 1628 | ++addCount; |
1629 | } | 1629 | } |
1630 | } | 1630 | } |
1631 | updateView(); | 1631 | updateView(); |
1632 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1632 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1633 | #else //DESKTOP_VERSION | 1633 | #else //DESKTOP_VERSION |
1634 | 1634 | ||
1635 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1635 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1636 | // the result should now arrive through method insertBirthdays | 1636 | // the result should now arrive through method insertBirthdays |
1637 | 1637 | ||
1638 | #endif //DESKTOP_VERSION | 1638 | #endif //DESKTOP_VERSION |
1639 | 1639 | ||
1640 | #endif //KORG_NOKABC | 1640 | #endif //KORG_NOKABC |
1641 | 1641 | ||
1642 | 1642 | ||
1643 | return true; | 1643 | return true; |
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1646 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1647 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1647 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1648 | const QStringList& anniversaryList, const QStringList& realNameList, | 1648 | const QStringList& anniversaryList, const QStringList& realNameList, |
1649 | const QStringList& emailList, const QStringList& assembledNameList, | 1649 | const QStringList& emailList, const QStringList& assembledNameList, |
1650 | const QStringList& uidList) | 1650 | const QStringList& uidList) |
1651 | { | 1651 | { |
1652 | //qDebug("KO::CalendarView::insertBirthdays"); | 1652 | //qDebug("KO::CalendarView::insertBirthdays"); |
1653 | if (uid == this->name()) | 1653 | if (uid == this->name()) |
1654 | { | 1654 | { |
1655 | int count = birthdayList.count(); | 1655 | int count = birthdayList.count(); |
1656 | int addCount = 0; | 1656 | int addCount = 0; |
1657 | KCal::Attendee* a = 0; | 1657 | KCal::Attendee* a = 0; |
1658 | 1658 | ||
1659 | //qDebug("CalView 1 %i", count); | 1659 | //qDebug("CalView 1 %i", count); |
1660 | 1660 | ||
1661 | QProgressBar bar(count,0 ); | 1661 | QProgressBar bar(count,0 ); |
1662 | int w = 300; | 1662 | int w = 300; |
1663 | if ( QApplication::desktop()->width() < 320 ) | 1663 | if ( QApplication::desktop()->width() < 320 ) |
1664 | w = 220; | 1664 | w = 220; |
1665 | int h = bar.sizeHint().height() ; | 1665 | int h = bar.sizeHint().height() ; |
1666 | int dw = QApplication::desktop()->width(); | 1666 | int dw = QApplication::desktop()->width(); |
1667 | int dh = QApplication::desktop()->height(); | 1667 | int dh = QApplication::desktop()->height(); |
1668 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1668 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1669 | bar.show(); | 1669 | bar.show(); |
1670 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1670 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1671 | qApp->processEvents(); | 1671 | qApp->processEvents(); |
1672 | 1672 | ||
1673 | QDate birthday; | 1673 | QDate birthday; |
1674 | QDate anniversary; | 1674 | QDate anniversary; |
1675 | QString realName; | 1675 | QString realName; |
1676 | QString email; | 1676 | QString email; |
1677 | QString assembledName; | 1677 | QString assembledName; |
1678 | QString uid; | 1678 | QString uid; |
1679 | bool ok = true; | 1679 | bool ok = true; |
1680 | for ( int i = 0; i < count; i++) | 1680 | for ( int i = 0; i < count; i++) |
1681 | { | 1681 | { |
1682 | if ( ! bar.isVisible() ) | 1682 | if ( ! bar.isVisible() ) |
1683 | return; | 1683 | return; |
1684 | bar.setProgress( i ); | 1684 | bar.setProgress( i ); |
1685 | qApp->processEvents(); | 1685 | qApp->processEvents(); |
1686 | 1686 | ||
1687 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1687 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1688 | if (!ok) { | 1688 | if (!ok) { |
1689 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1689 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1692 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1693 | if (!ok) { | 1693 | if (!ok) { |
1694 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1694 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1695 | } | 1695 | } |
1696 | realName = realNameList[i]; | 1696 | realName = realNameList[i]; |
1697 | email = emailList[i]; | 1697 | email = emailList[i]; |
1698 | assembledName = assembledNameList[i]; | 1698 | assembledName = assembledNameList[i]; |
1699 | uid = uidList[i]; | 1699 | uid = uidList[i]; |
1700 | //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() ); | 1700 | //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() ); |
1701 | 1701 | ||
1702 | if ( birthday.isValid() ){ | 1702 | if ( birthday.isValid() ){ |
1703 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1703 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1704 | KCal::Attendee::ReqParticipant,uid) ; | 1704 | KCal::Attendee::ReqParticipant,uid) ; |
1705 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1705 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1706 | ++addCount; | 1706 | ++addCount; |
1707 | } | 1707 | } |
1708 | 1708 | ||
1709 | if ( anniversary.isValid() ){ | 1709 | if ( anniversary.isValid() ){ |
1710 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1710 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1711 | KCal::Attendee::ReqParticipant,uid) ; | 1711 | KCal::Attendee::ReqParticipant,uid) ; |
1712 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1712 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1713 | ++addCount; | 1713 | ++addCount; |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | updateView(); | 1717 | updateView(); |
1718 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1718 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1719 | 1719 | ||
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | } | 1722 | } |
1723 | 1723 | ||
1724 | 1724 | ||
1725 | 1725 | ||
1726 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1726 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1727 | { | 1727 | { |
1728 | //qDebug("addAnni "); | 1728 | //qDebug("addAnni "); |
1729 | Event * ev = new Event(); | 1729 | Event * ev = new Event(); |
1730 | ev->setOrganizer(KOPrefs::instance()->email()); | 1730 | ev->setOrganizer(KOPrefs::instance()->email()); |
1731 | if ( a ) { | 1731 | if ( a ) { |
1732 | ev->addAttendee( a ); | 1732 | ev->addAttendee( a ); |
1733 | } | 1733 | } |
1734 | QString kind; | 1734 | QString kind; |
1735 | if ( birthday ) { | 1735 | if ( birthday ) { |
1736 | kind = i18n( "Birthday" ); | 1736 | kind = i18n( "Birthday" ); |
1737 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1737 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1738 | } | 1738 | } |
1739 | else { | 1739 | else { |
1740 | kind = i18n( "Anniversary" ); | 1740 | kind = i18n( "Anniversary" ); |
1741 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1741 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1742 | } | 1742 | } |
1743 | ev->setCategories( kind ); | 1743 | ev->setCategories( kind ); |
1744 | ev->setDtStart( QDateTime(date) ); | 1744 | ev->setDtStart( QDateTime(date) ); |
1745 | ev->setDtEnd( QDateTime(date) ); | 1745 | ev->setDtEnd( QDateTime(date) ); |
1746 | ev->setFloats( true ); | 1746 | ev->setFloats( true ); |
1747 | Recurrence * rec = ev->recurrence(); | 1747 | Recurrence * rec = ev->recurrence(); |
1748 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1748 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1749 | rec->addYearlyNum( date.month() ); | 1749 | rec->addYearlyNum( date.month() ); |
1750 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1750 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1751 | delete ev; | 1751 | delete ev; |
1752 | return false; | 1752 | return false; |
1753 | } | 1753 | } |
1754 | return true; | 1754 | return true; |
1755 | 1755 | ||
1756 | } | 1756 | } |
1757 | bool CalendarView::importQtopia( const QString &categories, | 1757 | bool CalendarView::importQtopia( const QString &categories, |
1758 | const QString &datebook, | 1758 | const QString &datebook, |
1759 | const QString &todolist ) | 1759 | const QString &todolist ) |
1760 | { | 1760 | { |
1761 | 1761 | ||
1762 | QtopiaFormat qtopiaFormat; | 1762 | QtopiaFormat qtopiaFormat; |
1763 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1763 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1764 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1764 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1765 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1765 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1766 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1766 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1767 | 1767 | ||
1768 | updateView(); | 1768 | updateView(); |
1769 | return true; | 1769 | return true; |
1770 | 1770 | ||
1771 | #if 0 | 1771 | #if 0 |
1772 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1772 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1773 | mCurrentSyncDevice = "qtopia-XML"; | 1773 | mCurrentSyncDevice = "qtopia-XML"; |
1774 | if ( mSyncManager->mAskForPreferences ) | 1774 | if ( mSyncManager->mAskForPreferences ) |
1775 | edit_sync_options(); | 1775 | edit_sync_options(); |
1776 | qApp->processEvents(); | 1776 | qApp->processEvents(); |
1777 | CalendarLocal* calendar = new CalendarLocal(); | 1777 | CalendarLocal* calendar = new CalendarLocal(); |
1778 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1778 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1779 | bool syncOK = false; | 1779 | bool syncOK = false; |
1780 | QtopiaFormat qtopiaFormat; | 1780 | QtopiaFormat qtopiaFormat; |
1781 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1781 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1782 | bool loadOk = true; | 1782 | bool loadOk = true; |
1783 | if ( !categories.isEmpty() ) | 1783 | if ( !categories.isEmpty() ) |
1784 | loadOk = qtopiaFormat.load( calendar, categories ); | 1784 | loadOk = qtopiaFormat.load( calendar, categories ); |
1785 | if ( loadOk && !datebook.isEmpty() ) | 1785 | if ( loadOk && !datebook.isEmpty() ) |
1786 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1786 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1787 | if ( loadOk && !todolist.isEmpty() ) | 1787 | if ( loadOk && !todolist.isEmpty() ) |
1788 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1788 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1789 | 1789 | ||
1790 | if ( loadOk ) { | 1790 | if ( loadOk ) { |
1791 | getEventViewerDialog()->setSyncMode( true ); | 1791 | getEventViewerDialog()->setSyncMode( true ); |
1792 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1792 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1793 | getEventViewerDialog()->setSyncMode( false ); | 1793 | getEventViewerDialog()->setSyncMode( false ); |
1794 | qApp->processEvents(); | 1794 | qApp->processEvents(); |
1795 | if ( syncOK ) { | 1795 | if ( syncOK ) { |
1796 | if ( mSyncManager->mWriteBackFile ) | 1796 | if ( mSyncManager->mWriteBackFile ) |
1797 | { | 1797 | { |
1798 | // write back XML file | 1798 | // write back XML file |
1799 | 1799 | ||
1800 | } | 1800 | } |
1801 | setModified( true ); | 1801 | setModified( true ); |
1802 | } | 1802 | } |
1803 | } else { | 1803 | } else { |
1804 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1804 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1805 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1805 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1806 | question, i18n("Ok")) ; | 1806 | question, i18n("Ok")) ; |
1807 | } | 1807 | } |
1808 | delete calendar; | 1808 | delete calendar; |
1809 | updateView(); | 1809 | updateView(); |
1810 | return syncOK; | 1810 | return syncOK; |
1811 | 1811 | ||
1812 | 1812 | ||
1813 | #endif | 1813 | #endif |
1814 | 1814 | ||
1815 | } | 1815 | } |
1816 | 1816 | ||
1817 | void CalendarView::setSyncEventsReadOnly() | 1817 | void CalendarView::setSyncEventsReadOnly() |
1818 | { | 1818 | { |
1819 | Event * ev; | 1819 | Event * ev; |
1820 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1820 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1821 | ev = eL.first(); | 1821 | ev = eL.first(); |
1822 | while ( ev ) { | 1822 | while ( ev ) { |
1823 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1823 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1824 | ev->setReadOnly( true ); | 1824 | ev->setReadOnly( true ); |
1825 | ev = eL.next(); | 1825 | ev = eL.next(); |
1826 | } | 1826 | } |
1827 | } | 1827 | } |
1828 | bool CalendarView::openCalendar(QString filename, bool merge) | 1828 | bool CalendarView::openCalendar(QString filename, bool merge) |
1829 | { | 1829 | { |
1830 | 1830 | ||
1831 | if (filename.isEmpty()) { | 1831 | if (filename.isEmpty()) { |
1832 | return false; | 1832 | return false; |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | if (!QFile::exists(filename)) { | 1835 | if (!QFile::exists(filename)) { |
1836 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1836 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1837 | return false; | 1837 | return false; |
1838 | } | 1838 | } |
1839 | 1839 | ||
1840 | globalFlagBlockAgenda = 1; | 1840 | globalFlagBlockAgenda = 1; |
1841 | clearAllViews(); | 1841 | clearAllViews(); |
1842 | if (!merge) { | 1842 | if (!merge) { |
1843 | mViewManager->setDocumentId( filename ); | 1843 | mViewManager->setDocumentId( filename ); |
1844 | mCalendar->close(); | 1844 | mCalendar->close(); |
1845 | } | 1845 | } |
1846 | mStorage->setFileName( filename ); | 1846 | mStorage->setFileName( filename ); |
1847 | 1847 | ||
1848 | if ( mStorage->load() ) { | 1848 | if ( mStorage->load() ) { |
1849 | if ( merge ) ;//setModified( true ); | 1849 | if ( merge ) ;//setModified( true ); |
1850 | else { | 1850 | else { |
1851 | //setModified( true ); | 1851 | //setModified( true ); |
1852 | mViewManager->setDocumentId( filename ); | 1852 | mViewManager->setDocumentId( filename ); |
1853 | mDialogManager->setDocumentId( filename ); | 1853 | mDialogManager->setDocumentId( filename ); |
1854 | mTodoList->setDocumentId( filename ); | 1854 | mTodoList->setDocumentId( filename ); |
1855 | } | 1855 | } |
1856 | globalFlagBlockAgenda = 2; | 1856 | globalFlagBlockAgenda = 2; |
1857 | // if ( getLastSyncEvent() ) | 1857 | // if ( getLastSyncEvent() ) |
1858 | // getLastSyncEvent()->setReadOnly( true ); | 1858 | // getLastSyncEvent()->setReadOnly( true ); |
1859 | mCalendar->reInitAlarmSettings(); | 1859 | mCalendar->reInitAlarmSettings(); |
1860 | setSyncEventsReadOnly(); | 1860 | setSyncEventsReadOnly(); |
1861 | updateUnmanagedViews(); | 1861 | updateUnmanagedViews(); |
1862 | updateView(); | 1862 | updateView(); |
1863 | if ( filename != MainWindow::defaultFileName() ) { | 1863 | if ( filename != MainWindow::defaultFileName() ) { |
1864 | saveCalendar( MainWindow::defaultFileName() ); | 1864 | saveCalendar( MainWindow::defaultFileName() ); |
1865 | } else { | 1865 | } else { |
1866 | QFileInfo finf ( MainWindow::defaultFileName()); | 1866 | QFileInfo finf ( MainWindow::defaultFileName()); |
1867 | if ( finf.exists() ) { | 1867 | if ( finf.exists() ) { |
1868 | setLoadedFileVersion( finf.lastModified () ); | 1868 | setLoadedFileVersion( finf.lastModified () ); |
1869 | } | 1869 | } |
1870 | } | 1870 | } |
1871 | return true; | 1871 | return true; |
1872 | } else { | 1872 | } else { |
1873 | // while failing to load, the calendar object could | 1873 | // while failing to load, the calendar object could |
1874 | // have become partially populated. Clear it out. | 1874 | // have become partially populated. Clear it out. |
1875 | if ( !merge ) { | 1875 | if ( !merge ) { |
1876 | mCalendar->close(); | 1876 | mCalendar->close(); |
1877 | mViewManager->setDocumentId( filename ); | 1877 | mViewManager->setDocumentId( filename ); |
1878 | mDialogManager->setDocumentId( filename ); | 1878 | mDialogManager->setDocumentId( filename ); |
1879 | mTodoList->setDocumentId( filename ); | 1879 | mTodoList->setDocumentId( filename ); |
1880 | } | 1880 | } |
1881 | 1881 | ||
1882 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1882 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1883 | 1883 | ||
1884 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1884 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1885 | globalFlagBlockAgenda = 2; | 1885 | globalFlagBlockAgenda = 2; |
1886 | mCalendar->reInitAlarmSettings(); | 1886 | mCalendar->reInitAlarmSettings(); |
1887 | setSyncEventsReadOnly(); | 1887 | setSyncEventsReadOnly(); |
1888 | updateUnmanagedViews(); | 1888 | updateUnmanagedViews(); |
1889 | updateView(); | 1889 | updateView(); |
1890 | } | 1890 | } |
1891 | return false; | 1891 | return false; |
1892 | } | 1892 | } |
1893 | void CalendarView::showOpenError() | 1893 | void CalendarView::showOpenError() |
1894 | { | 1894 | { |
1895 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1895 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1896 | } | 1896 | } |
1897 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1897 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1898 | { | 1898 | { |
1899 | loadedFileVersion = dt; | 1899 | loadedFileVersion = dt; |
1900 | } | 1900 | } |
1901 | bool CalendarView::checkFileChanged(QString fn) | 1901 | bool CalendarView::checkFileChanged(QString fn) |
1902 | { | 1902 | { |
1903 | QFileInfo finf ( fn ); | 1903 | QFileInfo finf ( fn ); |
1904 | if ( !finf.exists() ) | 1904 | if ( !finf.exists() ) |
1905 | return true; | 1905 | return true; |
1906 | QDateTime dt = finf.lastModified (); | 1906 | QDateTime dt = finf.lastModified (); |
1907 | if ( dt <= loadedFileVersion ) | 1907 | if ( dt <= loadedFileVersion ) |
1908 | return false; | 1908 | return false; |
1909 | return true; | 1909 | return true; |
1910 | 1910 | ||
1911 | } | 1911 | } |
1912 | void CalendarView::watchSavedFile() | 1912 | void CalendarView::watchSavedFile() |
1913 | { | 1913 | { |
1914 | QFileInfo finf ( MainWindow::defaultFileName()); | 1914 | QFileInfo finf ( MainWindow::defaultFileName()); |
1915 | if ( !finf.exists() ) | 1915 | if ( !finf.exists() ) |
1916 | return; | 1916 | return; |
1917 | QDateTime dt = finf.lastModified (); | 1917 | QDateTime dt = finf.lastModified (); |
1918 | if ( dt < loadedFileVersion ) { | 1918 | if ( dt < loadedFileVersion ) { |
1919 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1919 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1920 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1920 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1921 | return; | 1921 | return; |
1922 | } | 1922 | } |
1923 | loadedFileVersion = dt; | 1923 | loadedFileVersion = dt; |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | bool CalendarView::checkFileVersion(QString fn) | 1926 | bool CalendarView::checkFileVersion(QString fn) |
1927 | { | 1927 | { |
1928 | QFileInfo finf ( fn ); | 1928 | QFileInfo finf ( fn ); |
1929 | if ( !finf.exists() ) | 1929 | if ( !finf.exists() ) |
1930 | return true; | 1930 | return true; |
1931 | QDateTime dt = finf.lastModified (); | 1931 | QDateTime dt = finf.lastModified (); |
1932 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1932 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1933 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1933 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1934 | if ( dt <= loadedFileVersion ) | 1934 | if ( dt <= loadedFileVersion ) |
1935 | return true; | 1935 | return true; |
1936 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1936 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1937 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1937 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1938 | i18n("Sync+save")); | 1938 | i18n("Sync+save")); |
1939 | 1939 | ||
1940 | if ( km == KMessageBox::Cancel ) | 1940 | if ( km == KMessageBox::Cancel ) |
1941 | return false; | 1941 | return false; |
1942 | if ( km == KMessageBox::Yes ) | 1942 | if ( km == KMessageBox::Yes ) |
1943 | return true; | 1943 | return true; |
1944 | 1944 | ||
1945 | setSyncDevice("deleteaftersync" ); | 1945 | setSyncDevice("deleteaftersync" ); |
1946 | mSyncManager->mAskForPreferences = true; | 1946 | mSyncManager->mAskForPreferences = true; |
1947 | mSyncManager->mSyncAlgoPrefs = 3; | 1947 | mSyncManager->mSyncAlgoPrefs = 3; |
1948 | mSyncManager->mWriteBackFile = false; | 1948 | mSyncManager->mWriteBackFile = false; |
1949 | mSyncManager->mWriteBackExistingOnly = false; | 1949 | mSyncManager->mWriteBackExistingOnly = false; |
1950 | mSyncManager->mShowSyncSummary = false; | 1950 | mSyncManager->mShowSyncSummary = false; |
1951 | syncCalendar( fn, 3 ); | 1951 | syncCalendar( fn, 3 ); |
1952 | Event * e = getLastSyncEvent(); | 1952 | Event * e = getLastSyncEvent(); |
1953 | if ( e ) | 1953 | if ( e ) |
1954 | deleteEvent ( e ); | 1954 | deleteEvent ( e ); |
1955 | updateView(); | 1955 | updateView(); |
1956 | return true; | 1956 | return true; |
1957 | } | 1957 | } |
1958 | 1958 | ||
1959 | bool CalendarView::saveCalendar( QString filename ) | 1959 | bool CalendarView::saveCalendar( QString filename ) |
1960 | { | 1960 | { |
1961 | 1961 | ||
1962 | // Store back all unsaved data into calendar object | 1962 | // Store back all unsaved data into calendar object |
1963 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1963 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1964 | if ( mViewManager->currentView() ) | 1964 | if ( mViewManager->currentView() ) |
1965 | mViewManager->currentView()->flushView(); | 1965 | mViewManager->currentView()->flushView(); |
1966 | 1966 | ||
1967 | 1967 | ||
1968 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1968 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1969 | mStorage->setSaveFormat( new ICalFormat() ); | 1969 | mStorage->setSaveFormat( new ICalFormat() ); |
1970 | mStorage->setFileName( filename ); | 1970 | mStorage->setFileName( filename ); |
1971 | bool success; | 1971 | bool success; |
1972 | success = mStorage->save(); | 1972 | success = mStorage->save(); |
1973 | if ( !success ) { | 1973 | if ( !success ) { |
1974 | return false; | 1974 | return false; |
1975 | } | 1975 | } |
1976 | if ( filename == MainWindow::defaultFileName() ) { | 1976 | if ( filename == MainWindow::defaultFileName() ) { |
1977 | setLoadedFileVersion( lfv ); | 1977 | setLoadedFileVersion( lfv ); |
1978 | watchSavedFile(); | 1978 | watchSavedFile(); |
1979 | } | 1979 | } |
1980 | return true; | 1980 | return true; |
1981 | } | 1981 | } |
1982 | 1982 | ||
1983 | void CalendarView::closeCalendar() | 1983 | void CalendarView::closeCalendar() |
1984 | { | 1984 | { |
1985 | 1985 | ||
1986 | // child windows no longer valid | 1986 | // child windows no longer valid |
1987 | clearAllViews(); | 1987 | clearAllViews(); |
1988 | emit closingDown(); | 1988 | emit closingDown(); |
1989 | 1989 | ||
1990 | mCalendar->close(); | 1990 | mCalendar->close(); |
1991 | setModified(false); | 1991 | setModified(false); |
1992 | updateView(); | 1992 | updateView(); |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | void CalendarView::archiveCalendar() | 1995 | void CalendarView::archiveCalendar() |
1996 | { | 1996 | { |
1997 | mDialogManager->showArchiveDialog(); | 1997 | mDialogManager->showArchiveDialog(); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | 2000 | ||
2001 | void CalendarView::readSettings() | 2001 | void CalendarView::readSettings() |
2002 | { | 2002 | { |
2003 | 2003 | ||
2004 | 2004 | ||
2005 | // mViewManager->showAgendaView(); | 2005 | // mViewManager->showAgendaView(); |
2006 | QString str; | 2006 | QString str; |
2007 | //qDebug("CalendarView::readSettings() "); | 2007 | //qDebug("CalendarView::readSettings() "); |
2008 | // read settings from the KConfig, supplying reasonable | 2008 | // read settings from the KConfig, supplying reasonable |
2009 | // defaults where none are to be found | 2009 | // defaults where none are to be found |
2010 | KConfig *config = KOGlobals::config(); | 2010 | KConfig *config = KOGlobals::config(); |
2011 | #ifndef KORG_NOSPLITTER | 2011 | #ifndef KORG_NOSPLITTER |
2012 | config->setGroup("KOrganizer Geometry"); | 2012 | config->setGroup("KOrganizer Geometry"); |
2013 | 2013 | ||
2014 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2014 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2015 | if (sizes.count() != 2) { | 2015 | if (sizes.count() != 2) { |
2016 | sizes << mDateNavigator->minimumSizeHint().width(); | 2016 | sizes << mDateNavigator->minimumSizeHint().width(); |
2017 | sizes << 300; | 2017 | sizes << 300; |
2018 | } | 2018 | } |
2019 | mPanner->setSizes(sizes); | 2019 | mPanner->setSizes(sizes); |
2020 | 2020 | ||
2021 | sizes = config->readIntListEntry("Separator2"); | 2021 | sizes = config->readIntListEntry("Separator2"); |
2022 | if ( ( mResourceView && sizes.count() == 4 ) || | 2022 | if ( ( mResourceView && sizes.count() == 4 ) || |
2023 | ( !mResourceView && sizes.count() == 3 ) ) { | 2023 | ( !mResourceView && sizes.count() == 3 ) ) { |
2024 | mLeftSplitter->setSizes(sizes); | 2024 | mLeftSplitter->setSizes(sizes); |
2025 | } | 2025 | } |
2026 | #endif | 2026 | #endif |
2027 | globalFlagBlockAgenda = 1; | 2027 | globalFlagBlockAgenda = 1; |
2028 | mViewManager->showAgendaView(); | 2028 | mViewManager->showAgendaView(); |
2029 | //mViewManager->readSettings( config ); | 2029 | //mViewManager->readSettings( config ); |
2030 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2030 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2031 | readFilterSettings(config); | 2031 | readFilterSettings(config); |
2032 | 2032 | ||
2033 | #ifdef DESKTOP_VERSION | 2033 | #ifdef DESKTOP_VERSION |
2034 | config->setGroup("WidgetLayout"); | 2034 | config->setGroup("WidgetLayout"); |
2035 | QStringList list; | 2035 | QStringList list; |
2036 | list = config->readListEntry("MainLayout"); | 2036 | list = config->readListEntry("MainLayout"); |
2037 | int x,y,w,h; | 2037 | int x,y,w,h; |
2038 | if ( ! list.isEmpty() ) { | 2038 | if ( ! list.isEmpty() ) { |
2039 | x = list[0].toInt(); | 2039 | x = list[0].toInt(); |
2040 | y = list[1].toInt(); | 2040 | y = list[1].toInt(); |
2041 | w = list[2].toInt(); | 2041 | w = list[2].toInt(); |
2042 | h = list[3].toInt(); | 2042 | h = list[3].toInt(); |
2043 | KApplication::testCoords( &x,&y,&w,&h ); | 2043 | KApplication::testCoords( &x,&y,&w,&h ); |
2044 | topLevelWidget()->setGeometry(x,y,w,h); | 2044 | topLevelWidget()->setGeometry(x,y,w,h); |
2045 | 2045 | ||
2046 | } else { | 2046 | } else { |
2047 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2047 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2048 | } | 2048 | } |
2049 | list = config->readListEntry("EditEventLayout"); | 2049 | list = config->readListEntry("EditEventLayout"); |
2050 | if ( ! list.isEmpty() ) { | 2050 | if ( ! list.isEmpty() ) { |
2051 | x = list[0].toInt(); | 2051 | x = list[0].toInt(); |
2052 | y = list[1].toInt(); | 2052 | y = list[1].toInt(); |
2053 | w = list[2].toInt(); | 2053 | w = list[2].toInt(); |
2054 | h = list[3].toInt(); | 2054 | h = list[3].toInt(); |
2055 | KApplication::testCoords( &x,&y,&w,&h ); | 2055 | KApplication::testCoords( &x,&y,&w,&h ); |
2056 | mEventEditor->setGeometry(x,y,w,h); | 2056 | mEventEditor->setGeometry(x,y,w,h); |
2057 | 2057 | ||
2058 | } | 2058 | } |
2059 | list = config->readListEntry("EditTodoLayout"); | 2059 | list = config->readListEntry("EditTodoLayout"); |
2060 | if ( ! list.isEmpty() ) { | 2060 | if ( ! list.isEmpty() ) { |
2061 | x = list[0].toInt(); | 2061 | x = list[0].toInt(); |
2062 | y = list[1].toInt(); | 2062 | y = list[1].toInt(); |
2063 | w = list[2].toInt(); | 2063 | w = list[2].toInt(); |
2064 | h = list[3].toInt(); | 2064 | h = list[3].toInt(); |
2065 | KApplication::testCoords( &x,&y,&w,&h ); | 2065 | KApplication::testCoords( &x,&y,&w,&h ); |
2066 | mTodoEditor->setGeometry(x,y,w,h); | 2066 | mTodoEditor->setGeometry(x,y,w,h); |
2067 | 2067 | ||
2068 | } | 2068 | } |
2069 | list = config->readListEntry("ViewerLayout"); | 2069 | list = config->readListEntry("ViewerLayout"); |
2070 | if ( ! list.isEmpty() ) { | 2070 | if ( ! list.isEmpty() ) { |
2071 | x = list[0].toInt(); | 2071 | x = list[0].toInt(); |
2072 | y = list[1].toInt(); | 2072 | y = list[1].toInt(); |
2073 | w = list[2].toInt(); | 2073 | w = list[2].toInt(); |
2074 | h = list[3].toInt(); | 2074 | h = list[3].toInt(); |
2075 | KApplication::testCoords( &x,&y,&w,&h ); | 2075 | KApplication::testCoords( &x,&y,&w,&h ); |
2076 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2076 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2077 | } | 2077 | } |
2078 | #endif | 2078 | #endif |
2079 | config->setGroup( "Views" ); | 2079 | config->setGroup( "Views" ); |
2080 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2080 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2081 | 2081 | ||
2082 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2082 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2083 | 2083 | ||
2084 | int resetval = 0; | 2084 | int resetval = 0; |
2085 | int maxVal = 0; | 2085 | int maxVal = 0; |
2086 | if (sizes.count() != 3) { | 2086 | if (sizes.count() != 3) { |
2087 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2087 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2088 | resetval = mDateNavigator->sizeHint().width()+2; | 2088 | resetval = mDateNavigator->sizeHint().width()+2; |
2089 | } else { | 2089 | } else { |
2090 | resetval = mDateNavigator->sizeHint().height()+2; | 2090 | resetval = mDateNavigator->sizeHint().height()+2; |
2091 | } | 2091 | } |
2092 | } | 2092 | } |
2093 | if ( resetval ) { | 2093 | if ( resetval ) { |
2094 | sizes.clear(); | 2094 | sizes.clear(); |
2095 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2095 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2096 | maxVal = QApplication::desktop()->width() -10; | 2096 | maxVal = QApplication::desktop()->width() -10; |
2097 | } else { | 2097 | } else { |
2098 | maxVal = QApplication::desktop()->height()-10; | 2098 | maxVal = QApplication::desktop()->height()-10; |
2099 | } | 2099 | } |
2100 | sizes << resetval; | 2100 | sizes << resetval; |
2101 | if ( maxVal < resetval + resetval) | 2101 | if ( maxVal < resetval + resetval) |
2102 | resetval = maxVal - resetval; | 2102 | resetval = maxVal - resetval; |
2103 | sizes << resetval; | 2103 | sizes << resetval; |
2104 | sizes << 100; | 2104 | sizes << 100; |
2105 | } | 2105 | } |
2106 | mLeftFrame->setSizes(sizes); | 2106 | mLeftFrame->setSizes(sizes); |
2107 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2107 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2108 | resetval = 0; | 2108 | resetval = 0; |
2109 | maxVal = 0; | 2109 | maxVal = 0; |
2110 | if (sizes.count() != 2) { | 2110 | if (sizes.count() != 2) { |
2111 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2111 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2112 | resetval = mDateNavigator->sizeHint().width()+2; | 2112 | resetval = mDateNavigator->sizeHint().width()+2; |
2113 | } else { | 2113 | } else { |
2114 | resetval = mDateNavigator->sizeHint().height()+2; | 2114 | resetval = mDateNavigator->sizeHint().height()+2; |
2115 | } | 2115 | } |
2116 | } | 2116 | } |
2117 | if ( resetval ) { | 2117 | if ( resetval ) { |
2118 | sizes.clear(); | 2118 | sizes.clear(); |
2119 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2119 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2120 | maxVal = QApplication::desktop()->width() -10; | 2120 | maxVal = QApplication::desktop()->width() -10; |
2121 | } else { | 2121 | } else { |
2122 | maxVal = QApplication::desktop()->height()-10; | 2122 | maxVal = QApplication::desktop()->height()-10; |
2123 | } | 2123 | } |
2124 | sizes << resetval; | 2124 | sizes << resetval; |
2125 | if ( maxVal < resetval + resetval) | 2125 | if ( maxVal < resetval + resetval) |
2126 | resetval = maxVal - resetval; | 2126 | resetval = maxVal - resetval; |
2127 | sizes << resetval; | 2127 | sizes << resetval; |
2128 | } | 2128 | } |
2129 | mMainFrame->setSizes(sizes); | 2129 | mMainFrame->setSizes(sizes); |
2130 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2130 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2131 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2131 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2132 | else mNavigator->selectDates( dateCount ); | 2132 | else mNavigator->selectDates( dateCount ); |
2133 | // mViewManager->readSettings( config ); | 2133 | // mViewManager->readSettings( config ); |
2134 | updateConfig(); | 2134 | updateConfig(); |
2135 | globalFlagBlockAgenda = 2; | 2135 | globalFlagBlockAgenda = 2; |
2136 | mViewManager->readSettings( config ); | 2136 | mViewManager->readSettings( config ); |
2137 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2137 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2138 | } | 2138 | } |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | void CalendarView::writeSettings() | 2141 | void CalendarView::writeSettings() |
2142 | { | 2142 | { |
2143 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2143 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2144 | 2144 | ||
2145 | KConfig *config = KOGlobals::config(); | 2145 | KConfig *config = KOGlobals::config(); |
2146 | 2146 | ||
2147 | mViewManager->writeSettings( config ); | 2147 | mViewManager->writeSettings( config ); |
2148 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2148 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2149 | mDialogManager->writeSettings( config ); | 2149 | mDialogManager->writeSettings( config ); |
2150 | //KOPrefs::instance()->usrWriteConfig(); | 2150 | //KOPrefs::instance()->usrWriteConfig(); |
2151 | KOPrefs::instance()->writeConfig(); | 2151 | KOPrefs::instance()->writeConfig(); |
2152 | 2152 | ||
2153 | writeFilterSettings(config); | 2153 | writeFilterSettings(config); |
2154 | config->setGroup( "AppRun" ); | 2154 | config->setGroup( "AppRun" ); |
2155 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2155 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2156 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); | 2156 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); |
2157 | config->setGroup( "Views" ); | 2157 | config->setGroup( "Views" ); |
2158 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2158 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2159 | 2159 | ||
2160 | QValueList<int> listINT = mLeftFrame->sizes(); | 2160 | QValueList<int> listINT = mLeftFrame->sizes(); |
2161 | config->writeEntry("Left Splitter Frame",listINT); | 2161 | config->writeEntry("Left Splitter Frame",listINT); |
2162 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2162 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2163 | config->writeEntry("Main Splitter Frame",listINT2); | 2163 | config->writeEntry("Main Splitter Frame",listINT2); |
2164 | #ifdef DESKTOP_VERSION | 2164 | #ifdef DESKTOP_VERSION |
2165 | config->setGroup("WidgetLayout"); | 2165 | config->setGroup("WidgetLayout"); |
2166 | QStringList list ;//= config->readListEntry("MainLayout"); | 2166 | QStringList list ;//= config->readListEntry("MainLayout"); |
2167 | int x,y,w,h; | 2167 | int x,y,w,h; |
2168 | QWidget* wid; | 2168 | QWidget* wid; |
2169 | wid = topLevelWidget(); | 2169 | wid = topLevelWidget(); |
2170 | x = wid->geometry().x(); | 2170 | x = wid->geometry().x(); |
2171 | y = wid->geometry().y(); | 2171 | y = wid->geometry().y(); |
2172 | w = wid->width(); | 2172 | w = wid->width(); |
2173 | h = wid->height(); | 2173 | h = wid->height(); |
2174 | list.clear(); | 2174 | list.clear(); |
2175 | list << QString::number( x ); | 2175 | list << QString::number( x ); |
2176 | list << QString::number( y ); | 2176 | list << QString::number( y ); |
2177 | list << QString::number( w ); | 2177 | list << QString::number( w ); |
2178 | list << QString::number( h ); | 2178 | list << QString::number( h ); |
2179 | config->writeEntry("MainLayout",list ); | 2179 | config->writeEntry("MainLayout",list ); |
2180 | 2180 | ||
2181 | wid = mEventEditor; | 2181 | wid = mEventEditor; |
2182 | x = wid->geometry().x(); | 2182 | x = wid->geometry().x(); |
2183 | y = wid->geometry().y(); | 2183 | y = wid->geometry().y(); |
2184 | w = wid->width(); | 2184 | w = wid->width(); |
2185 | h = wid->height(); | 2185 | h = wid->height(); |
2186 | list.clear(); | 2186 | list.clear(); |
2187 | list << QString::number( x ); | 2187 | list << QString::number( x ); |
2188 | list << QString::number( y ); | 2188 | list << QString::number( y ); |
2189 | list << QString::number( w ); | 2189 | list << QString::number( w ); |
2190 | list << QString::number( h ); | 2190 | list << QString::number( h ); |
2191 | config->writeEntry("EditEventLayout",list ); | 2191 | config->writeEntry("EditEventLayout",list ); |
2192 | 2192 | ||
2193 | wid = mTodoEditor; | 2193 | wid = mTodoEditor; |
2194 | x = wid->geometry().x(); | 2194 | x = wid->geometry().x(); |
2195 | y = wid->geometry().y(); | 2195 | y = wid->geometry().y(); |
2196 | w = wid->width(); | 2196 | w = wid->width(); |
2197 | h = wid->height(); | 2197 | h = wid->height(); |
2198 | list.clear(); | 2198 | list.clear(); |
2199 | list << QString::number( x ); | 2199 | list << QString::number( x ); |
2200 | list << QString::number( y ); | 2200 | list << QString::number( y ); |
2201 | list << QString::number( w ); | 2201 | list << QString::number( w ); |
2202 | list << QString::number( h ); | 2202 | list << QString::number( h ); |
2203 | config->writeEntry("EditTodoLayout",list ); | 2203 | config->writeEntry("EditTodoLayout",list ); |
2204 | wid = getEventViewerDialog(); | 2204 | wid = getEventViewerDialog(); |
2205 | x = wid->geometry().x(); | 2205 | x = wid->geometry().x(); |
2206 | y = wid->geometry().y(); | 2206 | y = wid->geometry().y(); |
2207 | w = wid->width(); | 2207 | w = wid->width(); |
2208 | h = wid->height(); | 2208 | h = wid->height(); |
2209 | list.clear(); | 2209 | list.clear(); |
2210 | list << QString::number( x ); | 2210 | list << QString::number( x ); |
2211 | list << QString::number( y ); | 2211 | list << QString::number( y ); |
2212 | list << QString::number( w ); | 2212 | list << QString::number( w ); |
2213 | list << QString::number( h ); | 2213 | list << QString::number( h ); |
2214 | config->writeEntry("ViewerLayout",list ); | 2214 | config->writeEntry("ViewerLayout",list ); |
2215 | wid = mDialogManager->getSearchDialog(); | 2215 | wid = mDialogManager->getSearchDialog(); |
2216 | if ( wid ) { | 2216 | if ( wid ) { |
2217 | x = wid->geometry().x(); | 2217 | x = wid->geometry().x(); |
2218 | y = wid->geometry().y(); | 2218 | y = wid->geometry().y(); |
2219 | w = wid->width(); | 2219 | w = wid->width(); |
2220 | h = wid->height(); | 2220 | h = wid->height(); |
2221 | list.clear(); | 2221 | list.clear(); |
2222 | list << QString::number( x ); | 2222 | list << QString::number( x ); |
2223 | list << QString::number( y ); | 2223 | list << QString::number( y ); |
2224 | list << QString::number( w ); | 2224 | list << QString::number( w ); |
2225 | list << QString::number( h ); | 2225 | list << QString::number( h ); |
2226 | config->writeEntry("SearchLayout",list ); | 2226 | config->writeEntry("SearchLayout",list ); |
2227 | } | 2227 | } |
2228 | #endif | 2228 | #endif |
2229 | 2229 | ||
2230 | 2230 | ||
2231 | config->sync(); | 2231 | config->sync(); |
2232 | } | 2232 | } |
2233 | 2233 | ||
2234 | void CalendarView::readFilterSettings(KConfig *config) | 2234 | void CalendarView::readFilterSettings(KConfig *config) |
2235 | { | 2235 | { |
2236 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2236 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2237 | 2237 | ||
2238 | mFilters.clear(); | 2238 | mFilters.clear(); |
2239 | 2239 | ||
2240 | config->setGroup("General"); | 2240 | config->setGroup("General"); |
2241 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2241 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2242 | 2242 | ||
2243 | QStringList::ConstIterator it = filterList.begin(); | 2243 | QStringList::ConstIterator it = filterList.begin(); |
2244 | QStringList::ConstIterator end = filterList.end(); | 2244 | QStringList::ConstIterator end = filterList.end(); |
2245 | while(it != end) { | 2245 | while(it != end) { |
2246 | // kdDebug() << " filter: " << (*it) << endl; | 2246 | // kdDebug() << " filter: " << (*it) << endl; |
2247 | 2247 | ||
2248 | CalFilter *filter; | 2248 | CalFilter *filter; |
2249 | filter = new CalFilter(*it); | 2249 | filter = new CalFilter(*it); |
2250 | config->setGroup("Filter_" + (*it).utf8()); | 2250 | config->setGroup("Filter_" + (*it).utf8()); |
2251 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2251 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2252 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2252 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2253 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2253 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2254 | mFilters.append(filter); | 2254 | mFilters.append(filter); |
2255 | 2255 | ||
2256 | ++it; | 2256 | ++it; |
2257 | } | 2257 | } |
2258 | 2258 | ||
2259 | if (mFilters.count() == 0) { | 2259 | if (mFilters.count() == 0) { |
2260 | CalFilter *filter = new CalFilter(i18n("Default")); | 2260 | CalFilter *filter = new CalFilter(i18n("Default")); |
2261 | mFilters.append(filter); | 2261 | mFilters.append(filter); |
2262 | } | 2262 | } |
2263 | mFilterView->updateFilters(); | 2263 | mFilterView->updateFilters(); |
2264 | config->setGroup("FilterView"); | 2264 | config->setGroup("FilterView"); |
2265 | 2265 | ||
2266 | mFilterView->blockSignals(true); | 2266 | mFilterView->blockSignals(true); |
2267 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2267 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2268 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2268 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2269 | mFilterView->blockSignals(false); | 2269 | mFilterView->blockSignals(false); |
2270 | // We do it manually to avoid it being done twice by the above calls | 2270 | // We do it manually to avoid it being done twice by the above calls |
2271 | updateFilter(); | 2271 | updateFilter(); |
2272 | } | 2272 | } |
2273 | 2273 | ||
2274 | void CalendarView::writeFilterSettings(KConfig *config) | 2274 | void CalendarView::writeFilterSettings(KConfig *config) |
2275 | { | 2275 | { |
2276 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2276 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2277 | 2277 | ||
2278 | QStringList filterList; | 2278 | QStringList filterList; |
2279 | 2279 | ||
2280 | CalFilter *filter = mFilters.first(); | 2280 | CalFilter *filter = mFilters.first(); |
2281 | while(filter) { | 2281 | while(filter) { |
2282 | // kdDebug() << " fn: " << filter->name() << endl; | 2282 | // kdDebug() << " fn: " << filter->name() << endl; |
2283 | filterList << filter->name(); | 2283 | filterList << filter->name(); |
2284 | config->setGroup("Filter_" + filter->name().utf8()); | 2284 | config->setGroup("Filter_" + filter->name().utf8()); |
2285 | config->writeEntry("Criteria",filter->criteria()); | 2285 | config->writeEntry("Criteria",filter->criteria()); |
2286 | config->writeEntry("CategoryList",filter->categoryList()); | 2286 | config->writeEntry("CategoryList",filter->categoryList()); |
2287 | filter = mFilters.next(); | 2287 | filter = mFilters.next(); |
2288 | } | 2288 | } |
2289 | config->setGroup("General"); | 2289 | config->setGroup("General"); |
2290 | config->writeEntry("CalendarFilters",filterList); | 2290 | config->writeEntry("CalendarFilters",filterList); |
2291 | 2291 | ||
2292 | config->setGroup("FilterView"); | 2292 | config->setGroup("FilterView"); |
2293 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2293 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2294 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2294 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2295 | } | 2295 | } |
2296 | 2296 | ||
2297 | 2297 | ||
2298 | void CalendarView::goToday() | 2298 | void CalendarView::goToday() |
2299 | { | 2299 | { |
2300 | if ( mViewManager->currentView()->isMonthView() ) | 2300 | if ( mViewManager->currentView()->isMonthView() ) |
2301 | mNavigator->selectTodayMonth(); | 2301 | mNavigator->selectTodayMonth(); |
2302 | else | 2302 | else |
2303 | mNavigator->selectToday(); | 2303 | mNavigator->selectToday(); |
2304 | } | 2304 | } |
2305 | 2305 | ||
2306 | void CalendarView::goNext() | 2306 | void CalendarView::goNext() |
2307 | { | 2307 | { |
2308 | mNavigator->selectNext(); | 2308 | mNavigator->selectNext(); |
2309 | } | 2309 | } |
2310 | 2310 | ||
2311 | void CalendarView::goPrevious() | 2311 | void CalendarView::goPrevious() |
2312 | { | 2312 | { |
2313 | mNavigator->selectPrevious(); | 2313 | mNavigator->selectPrevious(); |
2314 | } | 2314 | } |
2315 | void CalendarView::goNextMonth() | 2315 | void CalendarView::goNextMonth() |
2316 | { | 2316 | { |
2317 | mNavigator->selectNextMonth(); | 2317 | mNavigator->selectNextMonth(); |
2318 | } | 2318 | } |
2319 | 2319 | ||
2320 | void CalendarView::goPreviousMonth() | 2320 | void CalendarView::goPreviousMonth() |
2321 | { | 2321 | { |
2322 | mNavigator->selectPreviousMonth(); | 2322 | mNavigator->selectPreviousMonth(); |
2323 | } | 2323 | } |
2324 | void CalendarView::writeLocale() | 2324 | void CalendarView::writeLocale() |
2325 | { | 2325 | { |
2326 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2326 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2327 | #if 0 | 2327 | #if 0 |
2328 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2328 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2329 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2329 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2330 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2330 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2331 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2331 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2332 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2332 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2333 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2333 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2334 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2334 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2335 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2335 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2336 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2336 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2337 | KOPrefs::instance()->mDaylightsavingStart, | 2337 | KOPrefs::instance()->mDaylightsavingStart, |
2338 | KOPrefs::instance()->mDaylightsavingEnd ); | 2338 | KOPrefs::instance()->mDaylightsavingEnd ); |
2339 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2339 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2340 | #endif | 2340 | #endif |
2341 | } | 2341 | } |
2342 | void CalendarView::updateConfig() | 2342 | void CalendarView::updateConfig() |
2343 | { | 2343 | { |
2344 | writeLocale(); | 2344 | writeLocale(); |
2345 | if ( KOPrefs::instance()->mUseAppColors ) | 2345 | if ( KOPrefs::instance()->mUseAppColors ) |
2346 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2346 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2347 | emit configChanged(); | 2347 | emit configChanged(); |
2348 | mTodoList->updateConfig(); | 2348 | mTodoList->updateConfig(); |
2349 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2349 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2350 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2351 | // To make the "fill window" configurations work | 2351 | // To make the "fill window" configurations work |
2352 | //mViewManager->raiseCurrentView(); | 2352 | //mViewManager->raiseCurrentView(); |
2353 | } | 2353 | } |
2354 | 2354 | ||
2355 | 2355 | ||
2356 | void CalendarView::eventChanged(Event *event) | 2356 | void CalendarView::eventChanged(Event *event) |
2357 | { | 2357 | { |
2358 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2358 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2359 | //updateUnmanagedViews(); | 2359 | //updateUnmanagedViews(); |
2360 | } | 2360 | } |
2361 | 2361 | ||
2362 | void CalendarView::eventAdded(Event *event) | 2362 | void CalendarView::eventAdded(Event *event) |
2363 | { | 2363 | { |
2364 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2364 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2365 | } | 2365 | } |
2366 | 2366 | ||
2367 | void CalendarView::eventToBeDeleted(Event *) | 2367 | void CalendarView::eventToBeDeleted(Event *) |
2368 | { | 2368 | { |
2369 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2369 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2370 | } | 2370 | } |
2371 | 2371 | ||
2372 | void CalendarView::eventDeleted() | 2372 | void CalendarView::eventDeleted() |
2373 | { | 2373 | { |
2374 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2374 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2375 | } | 2375 | } |
2376 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2376 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2377 | { | 2377 | { |
2378 | changeIncidenceDisplay((Incidence *)which, action); | 2378 | changeIncidenceDisplay((Incidence *)which, action); |
2379 | mDateNavigator->updateView(); //LR | 2379 | mDateNavigator->updateView(); //LR |
2380 | //mDialogManager->updateSearchDialog(); | 2380 | //mDialogManager->updateSearchDialog(); |
2381 | 2381 | ||
2382 | if (which) { | 2382 | if (which) { |
2383 | mViewManager->updateWNview(); | 2383 | mViewManager->updateWNview(); |
2384 | //mTodoList->updateView(); | 2384 | //mTodoList->updateView(); |
2385 | } | 2385 | } |
2386 | 2386 | ||
2387 | } | 2387 | } |
2388 | 2388 | ||
2389 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2389 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2390 | { | 2390 | { |
2391 | updateUnmanagedViews(); | 2391 | updateUnmanagedViews(); |
2392 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2392 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2393 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2393 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2394 | mCalendar->checkAlarmForIncidence( 0, true ); | 2394 | mCalendar->checkAlarmForIncidence( 0, true ); |
2395 | if ( mEventViewerDialog ) | 2395 | if ( mEventViewerDialog ) |
2396 | mEventViewerDialog->hide(); | 2396 | mEventViewerDialog->hide(); |
2397 | } | 2397 | } |
2398 | else | 2398 | else |
2399 | mCalendar->checkAlarmForIncidence( which , false ); | 2399 | mCalendar->checkAlarmForIncidence( which , false ); |
2400 | } | 2400 | } |
2401 | 2401 | ||
2402 | // most of the changeEventDisplays() right now just call the view's | 2402 | // most of the changeEventDisplays() right now just call the view's |
2403 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2403 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2404 | void CalendarView::changeEventDisplay(Event *which, int action) | 2404 | void CalendarView::changeEventDisplay(Event *which, int action) |
2405 | { | 2405 | { |
2406 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2406 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2407 | changeIncidenceDisplay((Incidence *)which, action); | 2407 | changeIncidenceDisplay((Incidence *)which, action); |
2408 | mDateNavigator->updateView(); | 2408 | mDateNavigator->updateView(); |
2409 | //mDialogManager->updateSearchDialog(); | 2409 | //mDialogManager->updateSearchDialog(); |
2410 | 2410 | ||
2411 | if (which) { | 2411 | if (which) { |
2412 | // If there is an event view visible update the display | 2412 | // If there is an event view visible update the display |
2413 | mViewManager->currentView()->changeEventDisplay(which,action); | 2413 | mViewManager->currentView()->changeEventDisplay(which,action); |
2414 | // TODO: check, if update needed | 2414 | // TODO: check, if update needed |
2415 | // if (which->getTodoStatus()) { | 2415 | // if (which->getTodoStatus()) { |
2416 | mTodoList->updateView(); | 2416 | mTodoList->updateView(); |
2417 | // } | 2417 | // } |
2418 | } else { | 2418 | } else { |
2419 | mViewManager->currentView()->updateView(); | 2419 | mViewManager->currentView()->updateView(); |
2420 | } | 2420 | } |
2421 | } | 2421 | } |
2422 | 2422 | ||
2423 | 2423 | ||
2424 | void CalendarView::updateTodoViews() | 2424 | void CalendarView::updateTodoViews() |
2425 | { | 2425 | { |
2426 | mTodoList->updateView(); | 2426 | mTodoList->updateView(); |
2427 | mViewManager->currentView()->updateView(); | 2427 | mViewManager->currentView()->updateView(); |
2428 | 2428 | ||
2429 | } | 2429 | } |
2430 | 2430 | ||
2431 | 2431 | ||
2432 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2432 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2433 | { | 2433 | { |
2434 | mTodoList->updateView(); | 2434 | mTodoList->updateView(); |
2435 | mViewManager->updateView(start, end); | 2435 | mViewManager->updateView(start, end); |
2436 | //mDateNavigator->updateView(); | 2436 | //mDateNavigator->updateView(); |
2437 | } | 2437 | } |
2438 | 2438 | ||
2439 | void CalendarView::clearAllViews() | 2439 | void CalendarView::clearAllViews() |
2440 | { | 2440 | { |
2441 | mTodoList->clearList(); | 2441 | mTodoList->clearList(); |
2442 | mViewManager->clearAllViews(); | 2442 | mViewManager->clearAllViews(); |
2443 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2443 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2444 | if ( sd ) { | 2444 | if ( sd ) { |
2445 | KOListView* kol = sd->listview(); | 2445 | KOListView* kol = sd->listview(); |
2446 | if ( kol ) | 2446 | if ( kol ) |
2447 | kol->clearList(); | 2447 | kol->clearList(); |
2448 | } | 2448 | } |
2449 | } | 2449 | } |
2450 | void CalendarView::updateView() | 2450 | void CalendarView::updateView() |
2451 | { | 2451 | { |
2452 | DateList tmpList = mNavigator->selectedDates(); | 2452 | DateList tmpList = mNavigator->selectedDates(); |
2453 | 2453 | ||
2454 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2454 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2455 | mTodoList->updateView(); | 2455 | mTodoList->updateView(); |
2456 | // We assume that the navigator only selects consecutive days. | 2456 | // We assume that the navigator only selects consecutive days. |
2457 | updateView( tmpList.first(), tmpList.last() ); | 2457 | updateView( tmpList.first(), tmpList.last() ); |
2458 | } | 2458 | } |
2459 | 2459 | ||
2460 | void CalendarView::updateUnmanagedViews() | 2460 | void CalendarView::updateUnmanagedViews() |
2461 | { | 2461 | { |
2462 | mDateNavigator->updateDayMatrix(); | 2462 | mDateNavigator->updateDayMatrix(); |
2463 | } | 2463 | } |
2464 | 2464 | ||
2465 | int CalendarView::msgItemDelete(const QString name) | 2465 | int CalendarView::msgItemDelete(const QString name) |
2466 | { | 2466 | { |
2467 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2467 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2468 | i18n("This item will be\npermanently deleted."), | 2468 | i18n("This item will be\npermanently deleted."), |
2469 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2469 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2470 | } | 2470 | } |
2471 | 2471 | ||
2472 | 2472 | ||
2473 | void CalendarView::edit_cut() | 2473 | void CalendarView::edit_cut() |
2474 | { | 2474 | { |
2475 | Event *anEvent=0; | 2475 | Event *anEvent=0; |
2476 | 2476 | ||
2477 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2477 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2478 | 2478 | ||
2479 | if (mViewManager->currentView()->isEventView()) { | 2479 | if (mViewManager->currentView()->isEventView()) { |
2480 | if ( incidence && incidence->type() == "Event" ) { | 2480 | if ( incidence && incidence->typeID() == eventID ) { |
2481 | anEvent = static_cast<Event *>(incidence); | 2481 | anEvent = static_cast<Event *>(incidence); |
2482 | } | 2482 | } |
2483 | } | 2483 | } |
2484 | 2484 | ||
2485 | if (!anEvent) { | 2485 | if (!anEvent) { |
2486 | KNotifyClient::beep(); | 2486 | KNotifyClient::beep(); |
2487 | return; | 2487 | return; |
2488 | } | 2488 | } |
2489 | DndFactory factory( mCalendar ); | 2489 | DndFactory factory( mCalendar ); |
2490 | factory.cutIncidence(anEvent); | 2490 | factory.cutIncidence(anEvent); |
2491 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2491 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2492 | } | 2492 | } |
2493 | 2493 | ||
2494 | void CalendarView::edit_copy() | 2494 | void CalendarView::edit_copy() |
2495 | { | 2495 | { |
2496 | Event *anEvent=0; | 2496 | Event *anEvent=0; |
2497 | 2497 | ||
2498 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2498 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2499 | 2499 | ||
2500 | if (mViewManager->currentView()->isEventView()) { | 2500 | if (mViewManager->currentView()->isEventView()) { |
2501 | if ( incidence && incidence->type() == "Event" ) { | 2501 | if ( incidence && incidence->typeID() == eventID ) { |
2502 | anEvent = static_cast<Event *>(incidence); | 2502 | anEvent = static_cast<Event *>(incidence); |
2503 | } | 2503 | } |
2504 | } | 2504 | } |
2505 | 2505 | ||
2506 | if (!anEvent) { | 2506 | if (!anEvent) { |
2507 | KNotifyClient::beep(); | 2507 | KNotifyClient::beep(); |
2508 | return; | 2508 | return; |
2509 | } | 2509 | } |
2510 | DndFactory factory( mCalendar ); | 2510 | DndFactory factory( mCalendar ); |
2511 | factory.copyIncidence(anEvent); | 2511 | factory.copyIncidence(anEvent); |
2512 | } | 2512 | } |
2513 | 2513 | ||
2514 | void CalendarView::edit_paste() | 2514 | void CalendarView::edit_paste() |
2515 | { | 2515 | { |
2516 | QDate date = mNavigator->selectedDates().first(); | 2516 | QDate date = mNavigator->selectedDates().first(); |
2517 | 2517 | ||
2518 | DndFactory factory( mCalendar ); | 2518 | DndFactory factory( mCalendar ); |
2519 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2519 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2520 | 2520 | ||
2521 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2521 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2522 | } | 2522 | } |
2523 | 2523 | ||
2524 | void CalendarView::edit_options() | 2524 | void CalendarView::edit_options() |
2525 | { | 2525 | { |
2526 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2526 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2527 | emit save(); | 2527 | emit save(); |
2528 | emit saveStopTimer(); | 2528 | emit saveStopTimer(); |
2529 | mDialogManager->showOptionsDialog(); | 2529 | mDialogManager->showOptionsDialog(); |
2530 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2530 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2531 | emit saveStopTimer(); | 2531 | emit saveStopTimer(); |
2532 | 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!"), | 2532 | 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!"), |
2533 | i18n("Timezone settings"),i18n("Reload"))) { | 2533 | i18n("Timezone settings"),i18n("Reload"))) { |
2534 | qDebug("KO: TZ reload cancelled "); | 2534 | qDebug("KO: TZ reload cancelled "); |
2535 | return; | 2535 | return; |
2536 | } | 2536 | } |
2537 | qDebug("KO: Timezone change "); | 2537 | qDebug("KO: Timezone change "); |
2538 | openCalendar( MainWindow::defaultFileName() ); | 2538 | openCalendar( MainWindow::defaultFileName() ); |
2539 | setModified(true); | 2539 | setModified(true); |
2540 | } | 2540 | } |
2541 | else | 2541 | else |
2542 | qDebug("KO: No tz change "); | 2542 | qDebug("KO: No tz change "); |
2543 | 2543 | ||
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | 2546 | ||
2547 | void CalendarView::slotSelectPickerDate( QDate d) | 2547 | void CalendarView::slotSelectPickerDate( QDate d) |
2548 | { | 2548 | { |
2549 | mDateFrame->hide(); | 2549 | mDateFrame->hide(); |
2550 | if ( mDatePickerMode == 1 ) { | 2550 | if ( mDatePickerMode == 1 ) { |
2551 | mNavigator->slotDaySelect( d ); | 2551 | mNavigator->slotDaySelect( d ); |
2552 | } else if ( mDatePickerMode == 2 ) { | 2552 | } else if ( mDatePickerMode == 2 ) { |
2553 | if ( mMoveIncidence->type() == "Todo" ) { | 2553 | if ( mMoveIncidence->typeID() == todoID ) { |
2554 | Todo * to = (Todo *) mMoveIncidence; | 2554 | Todo * to = (Todo *) mMoveIncidence; |
2555 | QTime tim; | 2555 | QTime tim; |
2556 | int len = 0; | 2556 | int len = 0; |
2557 | if ( to->hasStartDate() && to->hasDueDate() ) | 2557 | if ( to->hasStartDate() && to->hasDueDate() ) |
2558 | len = to->dtStart().secsTo( to->dtDue()); | 2558 | len = to->dtStart().secsTo( to->dtDue()); |
2559 | if ( to->hasDueDate() ) | 2559 | if ( to->hasDueDate() ) |
2560 | tim = to->dtDue().time(); | 2560 | tim = to->dtDue().time(); |
2561 | else { | 2561 | else { |
2562 | tim = QTime ( 0,0,0 ); | 2562 | tim = QTime ( 0,0,0 ); |
2563 | to->setFloats( true ); | 2563 | to->setFloats( true ); |
2564 | to->setHasDueDate( true ); | 2564 | to->setHasDueDate( true ); |
2565 | } | 2565 | } |
2566 | QDateTime dt ( d,tim ); | 2566 | QDateTime dt ( d,tim ); |
2567 | to->setDtDue( dt ); | 2567 | to->setDtDue( dt ); |
2568 | 2568 | ||
2569 | if ( to->hasStartDate() ) { | 2569 | if ( to->hasStartDate() ) { |
2570 | if ( len>0 ) | 2570 | if ( len>0 ) |
2571 | to->setDtStart(to->dtDue().addSecs( -len )); | 2571 | to->setDtStart(to->dtDue().addSecs( -len )); |
2572 | else | 2572 | else |
2573 | if (to->dtStart() > to->dtDue() ) | 2573 | if (to->dtStart() > to->dtDue() ) |
2574 | to->setDtStart(to->dtDue().addDays( -3 )); | 2574 | to->setDtStart(to->dtDue().addDays( -3 )); |
2575 | } | 2575 | } |
2576 | 2576 | ||
2577 | todoChanged( to ); | 2577 | todoChanged( to ); |
2578 | } else { | 2578 | } else { |
2579 | if ( mMoveIncidence->doesRecur() ) { | 2579 | if ( mMoveIncidence->doesRecur() ) { |
2580 | #if 0 | 2580 | #if 0 |
2581 | // PENDING implement this | 2581 | // PENDING implement this |
2582 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2582 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2583 | mCalendar()->addIncidence( newInc ); | 2583 | mCalendar()->addIncidence( newInc ); |
2584 | if ( mMoveIncidence->type() == "Todo" ) | 2584 | if ( mMoveIncidence->typeID() == todoID ) |
2585 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2585 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2586 | else | 2586 | else |
2587 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2587 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2588 | mMoveIncidence = newInc; | 2588 | mMoveIncidence = newInc; |
2589 | 2589 | ||
2590 | #endif | 2590 | #endif |
2591 | } | 2591 | } |
2592 | QTime tim = mMoveIncidence->dtStart().time(); | 2592 | QTime tim = mMoveIncidence->dtStart().time(); |
2593 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2593 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2594 | QDateTime dt ( d,tim ); | 2594 | QDateTime dt ( d,tim ); |
2595 | mMoveIncidence->setDtStart( dt ); | 2595 | mMoveIncidence->setDtStart( dt ); |
2596 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2596 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2597 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2597 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2598 | } | 2598 | } |
2599 | 2599 | ||
2600 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2600 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2601 | } | 2601 | } |
2602 | } | 2602 | } |
2603 | 2603 | ||
2604 | void CalendarView::removeCategories() | 2604 | void CalendarView::removeCategories() |
2605 | { | 2605 | { |
2606 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2606 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2607 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2607 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2608 | QStringList catIncList; | 2608 | QStringList catIncList; |
2609 | QStringList newCatList; | 2609 | QStringList newCatList; |
2610 | Incidence* inc = incList.first(); | 2610 | Incidence* inc = incList.first(); |
2611 | int i; | 2611 | int i; |
2612 | int count = 0; | 2612 | int count = 0; |
2613 | while ( inc ) { | 2613 | while ( inc ) { |
2614 | newCatList.clear(); | 2614 | newCatList.clear(); |
2615 | catIncList = inc->categories() ; | 2615 | catIncList = inc->categories() ; |
2616 | for( i = 0; i< catIncList.count(); ++i ) { | 2616 | for( i = 0; i< catIncList.count(); ++i ) { |
2617 | if ( catList.contains (catIncList[i])) | 2617 | if ( catList.contains (catIncList[i])) |
2618 | newCatList.append( catIncList[i] ); | 2618 | newCatList.append( catIncList[i] ); |
2619 | } | 2619 | } |
2620 | newCatList.sort(); | 2620 | newCatList.sort(); |
2621 | inc->setCategories( newCatList.join(",") ); | 2621 | inc->setCategories( newCatList.join(",") ); |
2622 | inc = incList.next(); | 2622 | inc = incList.next(); |
2623 | } | 2623 | } |
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | int CalendarView::addCategories() | 2626 | int CalendarView::addCategories() |
2627 | { | 2627 | { |
2628 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2628 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2629 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2629 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2630 | QStringList catIncList; | 2630 | QStringList catIncList; |
2631 | Incidence* inc = incList.first(); | 2631 | Incidence* inc = incList.first(); |
2632 | int i; | 2632 | int i; |
2633 | int count = 0; | 2633 | int count = 0; |
2634 | while ( inc ) { | 2634 | while ( inc ) { |
2635 | catIncList = inc->categories() ; | 2635 | catIncList = inc->categories() ; |
2636 | for( i = 0; i< catIncList.count(); ++i ) { | 2636 | for( i = 0; i< catIncList.count(); ++i ) { |
2637 | if ( !catList.contains (catIncList[i])) { | 2637 | if ( !catList.contains (catIncList[i])) { |
2638 | catList.append( catIncList[i] ); | 2638 | catList.append( catIncList[i] ); |
2639 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2639 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2640 | ++count; | 2640 | ++count; |
2641 | } | 2641 | } |
2642 | } | 2642 | } |
2643 | inc = incList.next(); | 2643 | inc = incList.next(); |
2644 | } | 2644 | } |
2645 | catList.sort(); | 2645 | catList.sort(); |
2646 | KOPrefs::instance()->mCustomCategories = catList; | 2646 | KOPrefs::instance()->mCustomCategories = catList; |
2647 | return count; | 2647 | return count; |
2648 | } | 2648 | } |
2649 | 2649 | ||
2650 | void CalendarView::manageCategories() | 2650 | void CalendarView::manageCategories() |
2651 | { | 2651 | { |
2652 | KOCatPrefs* cp = new KOCatPrefs(); | 2652 | KOCatPrefs* cp = new KOCatPrefs(); |
2653 | cp->show(); | 2653 | cp->show(); |
2654 | int w =cp->sizeHint().width() ; | 2654 | int w =cp->sizeHint().width() ; |
2655 | int h = cp->sizeHint().height() ; | 2655 | int h = cp->sizeHint().height() ; |
2656 | int dw = QApplication::desktop()->width(); | 2656 | int dw = QApplication::desktop()->width(); |
2657 | int dh = QApplication::desktop()->height(); | 2657 | int dh = QApplication::desktop()->height(); |
2658 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2658 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2659 | if ( !cp->exec() ) { | 2659 | if ( !cp->exec() ) { |
2660 | delete cp; | 2660 | delete cp; |
2661 | return; | 2661 | return; |
2662 | } | 2662 | } |
2663 | int count = 0; | 2663 | int count = 0; |
2664 | if ( cp->addCat() ) { | 2664 | if ( cp->addCat() ) { |
2665 | count = addCategories(); | 2665 | count = addCategories(); |
2666 | if ( count ) { | 2666 | if ( count ) { |
2667 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2667 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2668 | writeSettings(); | 2668 | writeSettings(); |
2669 | } else | 2669 | } else |
2670 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2670 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2671 | } else { | 2671 | } else { |
2672 | removeCategories(); | 2672 | removeCategories(); |
2673 | updateView(); | 2673 | updateView(); |
2674 | } | 2674 | } |
2675 | delete cp; | 2675 | delete cp; |
2676 | } | 2676 | } |
2677 | 2677 | ||
2678 | void CalendarView::beamIncidence(Incidence * Inc) | 2678 | void CalendarView::beamIncidence(Incidence * Inc) |
2679 | { | 2679 | { |
2680 | QPtrList<Incidence> delSel ; | 2680 | QPtrList<Incidence> delSel ; |
2681 | delSel.append(Inc); | 2681 | delSel.append(Inc); |
2682 | beamIncidenceList( delSel ); | 2682 | beamIncidenceList( delSel ); |
2683 | } | 2683 | } |
2684 | void CalendarView::beamCalendar() | 2684 | void CalendarView::beamCalendar() |
2685 | { | 2685 | { |
2686 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2686 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2687 | //qDebug("beamCalendar() "); | 2687 | //qDebug("beamCalendar() "); |
2688 | beamIncidenceList( delSel ); | 2688 | beamIncidenceList( delSel ); |
2689 | } | 2689 | } |
2690 | void CalendarView::beamFilteredCalendar() | 2690 | void CalendarView::beamFilteredCalendar() |
2691 | { | 2691 | { |
2692 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2692 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2693 | //qDebug("beamFilteredCalendar() "); | 2693 | //qDebug("beamFilteredCalendar() "); |
2694 | beamIncidenceList( delSel ); | 2694 | beamIncidenceList( delSel ); |
2695 | } | 2695 | } |
2696 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2696 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2697 | { | 2697 | { |
2698 | if ( beamDialog->exec () == QDialog::Rejected ) | 2698 | if ( beamDialog->exec () == QDialog::Rejected ) |
2699 | return; | 2699 | return; |
2700 | #ifdef DESKTOP_VERSION | 2700 | #ifdef DESKTOP_VERSION |
2701 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2701 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2702 | #else | 2702 | #else |
2703 | QString fn = "/tmp/kopibeamfile"; | 2703 | QString fn = "/tmp/kopibeamfile"; |
2704 | #endif | 2704 | #endif |
2705 | QString mes; | 2705 | QString mes; |
2706 | bool createbup = true; | 2706 | bool createbup = true; |
2707 | if ( createbup ) { | 2707 | if ( createbup ) { |
2708 | QString description = "\n"; | 2708 | QString description = "\n"; |
2709 | CalendarLocal* cal = new CalendarLocal(); | 2709 | CalendarLocal* cal = new CalendarLocal(); |
2710 | if ( beamDialog->beamLocal() ) | 2710 | if ( beamDialog->beamLocal() ) |
2711 | cal->setLocalTime(); | 2711 | cal->setLocalTime(); |
2712 | else | 2712 | else |
2713 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2713 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2714 | Incidence *incidence = delSel.first(); | 2714 | Incidence *incidence = delSel.first(); |
2715 | bool addText = false; | 2715 | bool addText = false; |
2716 | if ( delSel.count() < 10 ) | 2716 | if ( delSel.count() < 10 ) |
2717 | addText = true; | 2717 | addText = true; |
2718 | else { | 2718 | else { |
2719 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2719 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2720 | } | 2720 | } |
2721 | while ( incidence ) { | 2721 | while ( incidence ) { |
2722 | Incidence *in = incidence->clone(); | 2722 | Incidence *in = incidence->clone(); |
2723 | if ( ! in->summary().isEmpty() ) { | 2723 | if ( ! in->summary().isEmpty() ) { |
2724 | in->setDescription(""); | 2724 | in->setDescription(""); |
2725 | } else { | 2725 | } else { |
2726 | in->setSummary( in->description().left(20)); | 2726 | in->setSummary( in->description().left(20)); |
2727 | in->setDescription(""); | 2727 | in->setDescription(""); |
2728 | } | 2728 | } |
2729 | if ( addText ) | 2729 | if ( addText ) |
2730 | description += in->summary() + "\n"; | 2730 | description += in->summary() + "\n"; |
2731 | cal->addIncidence( in ); | 2731 | cal->addIncidence( in ); |
2732 | incidence = delSel.next(); | 2732 | incidence = delSel.next(); |
2733 | } | 2733 | } |
2734 | if ( beamDialog->beamVcal() ) { | 2734 | if ( beamDialog->beamVcal() ) { |
2735 | fn += ".vcs"; | 2735 | fn += ".vcs"; |
2736 | FileStorage storage( cal, fn, new VCalFormat ); | 2736 | FileStorage storage( cal, fn, new VCalFormat ); |
2737 | storage.save(); | 2737 | storage.save(); |
2738 | } else { | 2738 | } else { |
2739 | fn += ".ics"; | 2739 | fn += ".ics"; |
2740 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2740 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2741 | storage.save(); | 2741 | storage.save(); |
2742 | } | 2742 | } |
2743 | delete cal; | 2743 | delete cal; |
2744 | mes = i18n("KO/Pi: Ready for beaming"); | 2744 | mes = i18n("KO/Pi: Ready for beaming"); |
2745 | topLevelWidget()->setCaption(mes); | 2745 | topLevelWidget()->setCaption(mes); |
2746 | KApplication::convert2latin1( fn ); | 2746 | KApplication::convert2latin1( fn ); |
2747 | #ifndef DESKTOP_VERSION | 2747 | #ifndef DESKTOP_VERSION |
2748 | Ir *ir = new Ir( this ); | 2748 | Ir *ir = new Ir( this ); |
2749 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2749 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2750 | ir->send( fn, description, "text/x-vCalendar" ); | 2750 | ir->send( fn, description, "text/x-vCalendar" ); |
2751 | #endif | 2751 | #endif |
2752 | } | 2752 | } |
2753 | } | 2753 | } |
2754 | void CalendarView::beamDone( Ir *ir ) | 2754 | void CalendarView::beamDone( Ir *ir ) |
2755 | { | 2755 | { |
2756 | #ifndef DESKTOP_VERSION | 2756 | #ifndef DESKTOP_VERSION |
2757 | delete ir; | 2757 | delete ir; |
2758 | #endif | 2758 | #endif |
2759 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2759 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2760 | topLevelWidget()->raise(); | 2760 | topLevelWidget()->raise(); |
2761 | } | 2761 | } |
2762 | 2762 | ||
2763 | void CalendarView::moveIncidence(Incidence * inc ) | 2763 | void CalendarView::moveIncidence(Incidence * inc ) |
2764 | { | 2764 | { |
2765 | if ( !inc ) return; | 2765 | if ( !inc ) return; |
2766 | showDatePickerPopup(); | 2766 | showDatePickerPopup(); |
2767 | mDatePickerMode = 2; | 2767 | mDatePickerMode = 2; |
2768 | mMoveIncidence = inc ; | 2768 | mMoveIncidence = inc ; |
2769 | QDate da; | 2769 | QDate da; |
2770 | if ( mMoveIncidence->type() == "Todo" ) { | 2770 | if ( mMoveIncidence->typeID() == todoID ) { |
2771 | Todo * to = (Todo *) mMoveIncidence; | 2771 | Todo * to = (Todo *) mMoveIncidence; |
2772 | if ( to->hasDueDate() ) | 2772 | if ( to->hasDueDate() ) |
2773 | da = to->dtDue().date(); | 2773 | da = to->dtDue().date(); |
2774 | else | 2774 | else |
2775 | da = QDate::currentDate(); | 2775 | da = QDate::currentDate(); |
2776 | } else { | 2776 | } else { |
2777 | da = mMoveIncidence->dtStart().date(); | 2777 | da = mMoveIncidence->dtStart().date(); |
2778 | } | 2778 | } |
2779 | //PENDING set date for recurring incidence to date of recurrence | 2779 | //PENDING set date for recurring incidence to date of recurrence |
2780 | //mMoveIncidenceOldDate; | 2780 | //mMoveIncidenceOldDate; |
2781 | mDatePicker->setDate( da ); | 2781 | mDatePicker->setDate( da ); |
2782 | } | 2782 | } |
2783 | void CalendarView::showDatePickerPopup() | 2783 | void CalendarView::showDatePickerPopup() |
2784 | { | 2784 | { |
2785 | if ( mDateFrame->isVisible() ) | 2785 | if ( mDateFrame->isVisible() ) |
2786 | mDateFrame->hide(); | 2786 | mDateFrame->hide(); |
2787 | else { | 2787 | else { |
2788 | int offX = 0, offY = 0; | 2788 | int offX = 0, offY = 0; |
2789 | #ifdef DESKTOP_VERSION | 2789 | #ifdef DESKTOP_VERSION |
2790 | int w =mDatePicker->sizeHint().width() ; | 2790 | int w =mDatePicker->sizeHint().width() ; |
2791 | int h = mDatePicker->sizeHint().height() ; | 2791 | int h = mDatePicker->sizeHint().height() ; |
2792 | int dw = topLevelWidget()->width(); | 2792 | int dw = topLevelWidget()->width(); |
2793 | int dh = topLevelWidget()->height(); | 2793 | int dh = topLevelWidget()->height(); |
2794 | offX = topLevelWidget()->x(); | 2794 | offX = topLevelWidget()->x(); |
2795 | offY = topLevelWidget()->y(); | 2795 | offY = topLevelWidget()->y(); |
2796 | #else | 2796 | #else |
2797 | int w =mDatePicker->sizeHint().width() ; | 2797 | int w =mDatePicker->sizeHint().width() ; |
2798 | int h = mDatePicker->sizeHint().height() ; | 2798 | int h = mDatePicker->sizeHint().height() ; |
2799 | int dw = QApplication::desktop()->width(); | 2799 | int dw = QApplication::desktop()->width(); |
2800 | int dh = QApplication::desktop()->height(); | 2800 | int dh = QApplication::desktop()->height(); |
2801 | #endif | 2801 | #endif |
2802 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2802 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2803 | mDateFrame->show(); | 2803 | mDateFrame->show(); |
2804 | } | 2804 | } |
2805 | } | 2805 | } |
2806 | void CalendarView::showDatePicker( ) | 2806 | void CalendarView::showDatePicker( ) |
2807 | { | 2807 | { |
2808 | showDatePickerPopup(); | 2808 | showDatePickerPopup(); |
2809 | mDatePickerMode = 1; | 2809 | mDatePickerMode = 1; |
2810 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2810 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2811 | } | 2811 | } |
2812 | 2812 | ||
2813 | void CalendarView::showEventEditor() | 2813 | void CalendarView::showEventEditor() |
2814 | { | 2814 | { |
2815 | #ifdef DESKTOP_VERSION | 2815 | #ifdef DESKTOP_VERSION |
2816 | int x,y,w,h; | 2816 | int x,y,w,h; |
2817 | x = mEventEditor->geometry().x(); | 2817 | x = mEventEditor->geometry().x(); |
2818 | y = mEventEditor->geometry().y(); | 2818 | y = mEventEditor->geometry().y(); |
2819 | w = mEventEditor->width(); | 2819 | w = mEventEditor->width(); |
2820 | h = mEventEditor->height(); | 2820 | h = mEventEditor->height(); |
2821 | mEventEditor->show(); | 2821 | mEventEditor->show(); |
2822 | mEventEditor->setGeometry(x,y,w,h); | 2822 | mEventEditor->setGeometry(x,y,w,h); |
2823 | #else | 2823 | #else |
2824 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2824 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2825 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2825 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2826 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2826 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2827 | qApp->processEvents(); | 2827 | qApp->processEvents(); |
2828 | delete mEventEditor; | 2828 | delete mEventEditor; |
2829 | mEventEditor = mDialogManager->getEventEditor(); | 2829 | mEventEditor = mDialogManager->getEventEditor(); |
2830 | topLevelWidget()->setCaption( i18n("") ); | 2830 | topLevelWidget()->setCaption( i18n("") ); |
2831 | } | 2831 | } |
2832 | mEventEditor->showMaximized(); | 2832 | mEventEditor->showMaximized(); |
2833 | #endif | 2833 | #endif |
2834 | } | 2834 | } |
2835 | void CalendarView::showTodoEditor() | 2835 | void CalendarView::showTodoEditor() |
2836 | { | 2836 | { |
2837 | #ifdef DESKTOP_VERSION | 2837 | #ifdef DESKTOP_VERSION |
2838 | int x,y,w,h; | 2838 | int x,y,w,h; |
2839 | x = mTodoEditor->geometry().x(); | 2839 | x = mTodoEditor->geometry().x(); |
2840 | y = mTodoEditor->geometry().y(); | 2840 | y = mTodoEditor->geometry().y(); |
2841 | w = mTodoEditor->width(); | 2841 | w = mTodoEditor->width(); |
2842 | h = mTodoEditor->height(); | 2842 | h = mTodoEditor->height(); |
2843 | mTodoEditor->show(); | 2843 | mTodoEditor->show(); |
2844 | mTodoEditor->setGeometry(x,y,w,h); | 2844 | mTodoEditor->setGeometry(x,y,w,h); |
2845 | #else | 2845 | #else |
2846 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2846 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2847 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2847 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2848 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2848 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2849 | qApp->processEvents(); | 2849 | qApp->processEvents(); |
2850 | delete mTodoEditor; | 2850 | delete mTodoEditor; |
2851 | mTodoEditor = mDialogManager->getTodoEditor(); | 2851 | mTodoEditor = mDialogManager->getTodoEditor(); |
2852 | topLevelWidget()->setCaption( i18n("") ); | 2852 | topLevelWidget()->setCaption( i18n("") ); |
2853 | } | 2853 | } |
2854 | mTodoEditor->showMaximized(); | 2854 | mTodoEditor->showMaximized(); |
2855 | #endif | 2855 | #endif |
2856 | } | 2856 | } |
2857 | 2857 | ||
2858 | void CalendarView::cloneIncidence() | 2858 | void CalendarView::cloneIncidence() |
2859 | { | 2859 | { |
2860 | Incidence *incidence = currentSelection(); | 2860 | Incidence *incidence = currentSelection(); |
2861 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2861 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2862 | if ( incidence ) { | 2862 | if ( incidence ) { |
2863 | cloneIncidence(incidence); | 2863 | cloneIncidence(incidence); |
2864 | } | 2864 | } |
2865 | } | 2865 | } |
2866 | void CalendarView::moveIncidence() | 2866 | void CalendarView::moveIncidence() |
2867 | { | 2867 | { |
2868 | Incidence *incidence = currentSelection(); | 2868 | Incidence *incidence = currentSelection(); |
2869 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2869 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2870 | if ( incidence ) { | 2870 | if ( incidence ) { |
2871 | moveIncidence(incidence); | 2871 | moveIncidence(incidence); |
2872 | } | 2872 | } |
2873 | } | 2873 | } |
2874 | void CalendarView::beamIncidence() | 2874 | void CalendarView::beamIncidence() |
2875 | { | 2875 | { |
2876 | Incidence *incidence = currentSelection(); | 2876 | Incidence *incidence = currentSelection(); |
2877 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2877 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2878 | if ( incidence ) { | 2878 | if ( incidence ) { |
2879 | beamIncidence(incidence); | 2879 | beamIncidence(incidence); |
2880 | } | 2880 | } |
2881 | } | 2881 | } |
2882 | void CalendarView::toggleCancelIncidence() | 2882 | void CalendarView::toggleCancelIncidence() |
2883 | { | 2883 | { |
2884 | Incidence *incidence = currentSelection(); | 2884 | Incidence *incidence = currentSelection(); |
2885 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2885 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2886 | if ( incidence ) { | 2886 | if ( incidence ) { |
2887 | cancelIncidence(incidence); | 2887 | cancelIncidence(incidence); |
2888 | } | 2888 | } |
2889 | } | 2889 | } |
2890 | 2890 | ||
2891 | 2891 | ||
2892 | void CalendarView::cancelIncidence(Incidence * inc ) | 2892 | void CalendarView::cancelIncidence(Incidence * inc ) |
2893 | { | 2893 | { |
2894 | inc->setCancelled( ! inc->cancelled() ); | 2894 | inc->setCancelled( ! inc->cancelled() ); |
2895 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2895 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2896 | updateView(); | 2896 | updateView(); |
2897 | } | 2897 | } |
2898 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2898 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2899 | { | 2899 | { |
2900 | Incidence * newInc = orgInc->clone(); | 2900 | Incidence * newInc = orgInc->clone(); |
2901 | newInc->recreate(); | 2901 | newInc->recreate(); |
2902 | 2902 | ||
2903 | if ( newInc->type() == "Todo" ) { | 2903 | if ( newInc->typeID() == todoID ) { |
2904 | Todo* t = (Todo*) newInc; | 2904 | Todo* t = (Todo*) newInc; |
2905 | bool cloneSub = false; | 2905 | bool cloneSub = false; |
2906 | if ( orgInc->relations().count() ) { | 2906 | if ( orgInc->relations().count() ) { |
2907 | int result = KMessageBox::warningYesNoCancel(this, | 2907 | int result = KMessageBox::warningYesNoCancel(this, |
2908 | 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 ) ), | 2908 | 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 ) ), |
2909 | i18n("Todo has subtodos"), | 2909 | i18n("Todo has subtodos"), |
2910 | i18n("Yes"), | 2910 | i18n("Yes"), |
2911 | i18n("No")); | 2911 | i18n("No")); |
2912 | 2912 | ||
2913 | if ( result == KMessageBox::Cancel ) { | 2913 | if ( result == KMessageBox::Cancel ) { |
2914 | delete t; | 2914 | delete t; |
2915 | return; | 2915 | return; |
2916 | } | 2916 | } |
2917 | if (result == KMessageBox::Yes) cloneSub = true; | 2917 | if (result == KMessageBox::Yes) cloneSub = true; |
2918 | } | 2918 | } |
2919 | showTodoEditor(); | 2919 | showTodoEditor(); |
2920 | mTodoEditor->editTodo( t ); | 2920 | mTodoEditor->editTodo( t ); |
2921 | if ( mTodoEditor->exec() ) { | 2921 | if ( mTodoEditor->exec() ) { |
2922 | if ( cloneSub ) { | 2922 | if ( cloneSub ) { |
2923 | orgInc->cloneRelations( t ); | 2923 | orgInc->cloneRelations( t ); |
2924 | mCalendar->addIncidenceBranch( t ); | 2924 | mCalendar->addIncidenceBranch( t ); |
2925 | updateView(); | 2925 | updateView(); |
2926 | 2926 | ||
2927 | } else { | 2927 | } else { |
2928 | mCalendar->addTodo( t ); | 2928 | mCalendar->addTodo( t ); |
2929 | updateView(); | 2929 | updateView(); |
2930 | } | 2930 | } |
2931 | } else { | 2931 | } else { |
2932 | delete t; | 2932 | delete t; |
2933 | } | 2933 | } |
2934 | } | 2934 | } |
2935 | else { | 2935 | else { |
2936 | Event* e = (Event*) newInc; | 2936 | Event* e = (Event*) newInc; |
2937 | showEventEditor(); | 2937 | showEventEditor(); |
2938 | mEventEditor->editEvent( e ); | 2938 | mEventEditor->editEvent( e ); |
2939 | if ( mEventEditor->exec() ) { | 2939 | if ( mEventEditor->exec() ) { |
2940 | mCalendar->addEvent( e ); | 2940 | mCalendar->addEvent( e ); |
2941 | updateView(); | 2941 | updateView(); |
2942 | } else { | 2942 | } else { |
2943 | delete e; | 2943 | delete e; |
2944 | } | 2944 | } |
2945 | } | 2945 | } |
2946 | setActiveWindow(); | 2946 | setActiveWindow(); |
2947 | } | 2947 | } |
2948 | 2948 | ||
2949 | void CalendarView::newEvent() | 2949 | void CalendarView::newEvent() |
2950 | { | 2950 | { |
2951 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2951 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2952 | KOAgendaView *aView = mViewManager->agendaView(); | 2952 | KOAgendaView *aView = mViewManager->agendaView(); |
2953 | if (aView) { | 2953 | if (aView) { |
2954 | if (aView->selectionStart().isValid()) { | 2954 | if (aView->selectionStart().isValid()) { |
2955 | if (aView->selectedIsAllDay()) { | 2955 | if (aView->selectedIsAllDay()) { |
2956 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2956 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2957 | } else { | 2957 | } else { |
2958 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2958 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2959 | } | 2959 | } |
2960 | return; | 2960 | return; |
2961 | } | 2961 | } |
2962 | } | 2962 | } |
2963 | 2963 | ||
2964 | QDate date = mNavigator->selectedDates().first(); | 2964 | QDate date = mNavigator->selectedDates().first(); |
2965 | QDateTime current = QDateTime::currentDateTime(); | 2965 | QDateTime current = QDateTime::currentDateTime(); |
2966 | if ( date <= current.date() ) { | 2966 | if ( date <= current.date() ) { |
2967 | int hour = current.time().hour() +1; | 2967 | int hour = current.time().hour() +1; |
2968 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2968 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2969 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2969 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2970 | } else | 2970 | } else |
2971 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2971 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2972 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2972 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2973 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2973 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2974 | } | 2974 | } |
2975 | 2975 | ||
2976 | void CalendarView::newEvent(QDateTime fh) | 2976 | void CalendarView::newEvent(QDateTime fh) |
2977 | { | 2977 | { |
2978 | newEvent(fh, | 2978 | newEvent(fh, |
2979 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2979 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2980 | } | 2980 | } |
2981 | 2981 | ||
2982 | void CalendarView::newEvent(QDate dt) | 2982 | void CalendarView::newEvent(QDate dt) |
2983 | { | 2983 | { |
2984 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2984 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2985 | QDateTime(dt, QTime(0,0,0)), true); | 2985 | QDateTime(dt, QTime(0,0,0)), true); |
2986 | } | 2986 | } |
2987 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2987 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2988 | { | 2988 | { |
2989 | newEvent(fromHint, toHint, false); | 2989 | newEvent(fromHint, toHint, false); |
2990 | } | 2990 | } |
2991 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2991 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2992 | { | 2992 | { |
2993 | 2993 | ||
2994 | showEventEditor(); | 2994 | showEventEditor(); |
2995 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2995 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2996 | if ( mFilterView->filtersEnabled() ) { | 2996 | if ( mFilterView->filtersEnabled() ) { |
2997 | CalFilter *filter = mFilterView->selectedFilter(); | 2997 | CalFilter *filter = mFilterView->selectedFilter(); |
2998 | if (filter && filter->showCategories()) { | 2998 | if (filter && filter->showCategories()) { |
2999 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2999 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3000 | } | 3000 | } |
3001 | if ( filter ) | 3001 | if ( filter ) |
3002 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3002 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3003 | } | 3003 | } |
3004 | mEventEditor->exec(); | 3004 | mEventEditor->exec(); |
3005 | setActiveWindow(); | 3005 | setActiveWindow(); |
3006 | } | 3006 | } |
3007 | void CalendarView::todoAdded(Todo * t) | 3007 | void CalendarView::todoAdded(Todo * t) |
3008 | { | 3008 | { |
3009 | 3009 | ||
3010 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3010 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3011 | updateTodoViews(); | 3011 | updateTodoViews(); |
3012 | } | 3012 | } |
3013 | void CalendarView::todoChanged(Todo * t) | 3013 | void CalendarView::todoChanged(Todo * t) |
3014 | { | 3014 | { |
3015 | emit todoModified( t, 4 ); | 3015 | emit todoModified( t, 4 ); |
3016 | // updateTodoViews(); | 3016 | // updateTodoViews(); |
3017 | } | 3017 | } |
3018 | void CalendarView::todoToBeDeleted(Todo *) | 3018 | void CalendarView::todoToBeDeleted(Todo *) |
3019 | { | 3019 | { |
3020 | //qDebug("todoToBeDeleted(Todo *) "); | 3020 | //qDebug("todoToBeDeleted(Todo *) "); |
3021 | updateTodoViews(); | 3021 | updateTodoViews(); |
3022 | } | 3022 | } |
3023 | void CalendarView::todoDeleted() | 3023 | void CalendarView::todoDeleted() |
3024 | { | 3024 | { |
3025 | //qDebug(" todoDeleted()"); | 3025 | //qDebug(" todoDeleted()"); |
3026 | updateTodoViews(); | 3026 | updateTodoViews(); |
3027 | } | 3027 | } |
3028 | 3028 | ||
3029 | 3029 | ||
3030 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3030 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3031 | { | 3031 | { |
3032 | showTodoEditor(); | 3032 | showTodoEditor(); |
3033 | mTodoEditor->newTodo(dt,0,allday); | 3033 | mTodoEditor->newTodo(dt,0,allday); |
3034 | if ( mFilterView->filtersEnabled() ) { | 3034 | if ( mFilterView->filtersEnabled() ) { |
3035 | CalFilter *filter = mFilterView->selectedFilter(); | 3035 | CalFilter *filter = mFilterView->selectedFilter(); |
3036 | if (filter && filter->showCategories()) { | 3036 | if (filter && filter->showCategories()) { |
3037 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3037 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3038 | } | 3038 | } |
3039 | if ( filter ) | 3039 | if ( filter ) |
3040 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3040 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3041 | } | 3041 | } |
3042 | mTodoEditor->exec(); | 3042 | mTodoEditor->exec(); |
3043 | setActiveWindow(); | 3043 | setActiveWindow(); |
3044 | } | 3044 | } |
3045 | 3045 | ||
3046 | void CalendarView::newTodo() | 3046 | void CalendarView::newTodo() |
3047 | { | 3047 | { |
3048 | newTodoDateTime( QDateTime(),true ); | 3048 | newTodoDateTime( QDateTime(),true ); |
3049 | } | 3049 | } |
3050 | 3050 | ||
3051 | void CalendarView::newSubTodo() | 3051 | void CalendarView::newSubTodo() |
3052 | { | 3052 | { |
3053 | Todo *todo = selectedTodo(); | 3053 | Todo *todo = selectedTodo(); |
3054 | if ( todo ) newSubTodo( todo ); | 3054 | if ( todo ) newSubTodo( todo ); |
3055 | } | 3055 | } |
3056 | 3056 | ||
3057 | void CalendarView::newSubTodo(Todo *parentEvent) | 3057 | void CalendarView::newSubTodo(Todo *parentEvent) |
3058 | { | 3058 | { |
3059 | 3059 | ||
3060 | showTodoEditor(); | 3060 | showTodoEditor(); |
3061 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3061 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3062 | mTodoEditor->exec(); | 3062 | mTodoEditor->exec(); |
3063 | setActiveWindow(); | 3063 | setActiveWindow(); |
3064 | } | 3064 | } |
3065 | 3065 | ||
3066 | void CalendarView::newFloatingEvent() | 3066 | void CalendarView::newFloatingEvent() |
3067 | { | 3067 | { |
3068 | DateList tmpList = mNavigator->selectedDates(); | 3068 | DateList tmpList = mNavigator->selectedDates(); |
3069 | QDate date = tmpList.first(); | 3069 | QDate date = tmpList.first(); |
3070 | 3070 | ||
3071 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3071 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3072 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3072 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3073 | } | 3073 | } |
3074 | 3074 | ||
3075 | 3075 | ||
3076 | void CalendarView::editEvent( Event *event ) | 3076 | void CalendarView::editEvent( Event *event ) |
3077 | { | 3077 | { |
3078 | 3078 | ||
3079 | if ( !event ) return; | 3079 | if ( !event ) return; |
3080 | if ( event->isReadOnly() ) { | 3080 | if ( event->isReadOnly() ) { |
3081 | showEvent( event ); | 3081 | showEvent( event ); |
3082 | return; | 3082 | return; |
3083 | } | 3083 | } |
3084 | showEventEditor(); | 3084 | showEventEditor(); |
3085 | mEventEditor->editEvent( event , mFlagEditDescription); | 3085 | mEventEditor->editEvent( event , mFlagEditDescription); |
3086 | mEventEditor->exec(); | 3086 | mEventEditor->exec(); |
3087 | setActiveWindow(); | 3087 | setActiveWindow(); |
3088 | 3088 | ||
3089 | } | 3089 | } |
3090 | void CalendarView::editJournal( Journal *jour ) | 3090 | void CalendarView::editJournal( Journal *jour ) |
3091 | { | 3091 | { |
3092 | if ( !jour ) return; | 3092 | if ( !jour ) return; |
3093 | mDialogManager->hideSearchDialog(); | 3093 | mDialogManager->hideSearchDialog(); |
3094 | mViewManager->showJournalView(); | 3094 | mViewManager->showJournalView(); |
3095 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3095 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3096 | } | 3096 | } |
3097 | void CalendarView::editTodo( Todo *todo ) | 3097 | void CalendarView::editTodo( Todo *todo ) |
3098 | { | 3098 | { |
3099 | if ( !todo ) return; | 3099 | if ( !todo ) return; |
3100 | 3100 | ||
3101 | if ( todo->isReadOnly() ) { | 3101 | if ( todo->isReadOnly() ) { |
3102 | showTodo( todo ); | 3102 | showTodo( todo ); |
3103 | return; | 3103 | return; |
3104 | } | 3104 | } |
3105 | showTodoEditor(); | 3105 | showTodoEditor(); |
3106 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3106 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3107 | mTodoEditor->exec(); | 3107 | mTodoEditor->exec(); |
3108 | setActiveWindow(); | 3108 | setActiveWindow(); |
3109 | 3109 | ||
3110 | } | 3110 | } |
3111 | 3111 | ||
3112 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3112 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3113 | { | 3113 | { |
3114 | if ( !mEventViewerDialog ) { | 3114 | if ( !mEventViewerDialog ) { |
3115 | mEventViewerDialog = new KOEventViewerDialog(0); | 3115 | mEventViewerDialog = new KOEventViewerDialog(0); |
3116 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3116 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3117 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3117 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3118 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3118 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3119 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3119 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3120 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3120 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3121 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3121 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3122 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3122 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3123 | this, SLOT( slotViewerClosed() ) ); | 3123 | this, SLOT( slotViewerClosed() ) ); |
3124 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3124 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3125 | this, SLOT( todoChanged(Todo *) ) ); | 3125 | this, SLOT( todoChanged(Todo *) ) ); |
3126 | mEventViewerDialog->resize( 640, 480 ); | 3126 | mEventViewerDialog->resize( 640, 480 ); |
3127 | 3127 | ||
3128 | } | 3128 | } |
3129 | return mEventViewerDialog; | 3129 | return mEventViewerDialog; |
3130 | } | 3130 | } |
3131 | void CalendarView::showEvent(Event *event) | 3131 | void CalendarView::showEvent(Event *event) |
3132 | { | 3132 | { |
3133 | getEventViewerDialog()->setEvent(event); | 3133 | getEventViewerDialog()->setEvent(event); |
3134 | getEventViewerDialog()->showMe(); | 3134 | getEventViewerDialog()->showMe(); |
3135 | } | 3135 | } |
3136 | 3136 | ||
3137 | void CalendarView::showTodo(Todo *event) | 3137 | void CalendarView::showTodo(Todo *event) |
3138 | { | 3138 | { |
3139 | getEventViewerDialog()->setTodo(event); | 3139 | getEventViewerDialog()->setTodo(event); |
3140 | getEventViewerDialog()->showMe(); | 3140 | getEventViewerDialog()->showMe(); |
3141 | } | 3141 | } |
3142 | void CalendarView::showJournal( Journal *jour ) | 3142 | void CalendarView::showJournal( Journal *jour ) |
3143 | { | 3143 | { |
3144 | getEventViewerDialog()->setJournal(jour); | 3144 | getEventViewerDialog()->setJournal(jour); |
3145 | getEventViewerDialog()->showMe(); | 3145 | getEventViewerDialog()->showMe(); |
3146 | 3146 | ||
3147 | } | 3147 | } |
3148 | // void CalendarView::todoModified (Todo *event, int changed) | 3148 | // void CalendarView::todoModified (Todo *event, int changed) |
3149 | // { | 3149 | // { |
3150 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3150 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3151 | // // kdDebug() << "Todo modified and open" << endl; | 3151 | // // kdDebug() << "Todo modified and open" << endl; |
3152 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3152 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3153 | // // temp->modified (changed); | 3153 | // // temp->modified (changed); |
3154 | 3154 | ||
3155 | // // } | 3155 | // // } |
3156 | 3156 | ||
3157 | // mViewManager->updateView(); | 3157 | // mViewManager->updateView(); |
3158 | // } | 3158 | // } |
3159 | 3159 | ||
3160 | void CalendarView::appointment_show() | 3160 | void CalendarView::appointment_show() |
3161 | { | 3161 | { |
3162 | Event *anEvent = 0; | 3162 | Event *anEvent = 0; |
3163 | 3163 | ||
3164 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3164 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3165 | 3165 | ||
3166 | if (mViewManager->currentView()->isEventView()) { | 3166 | if (mViewManager->currentView()->isEventView()) { |
3167 | if ( incidence && incidence->type() == "Event" ) { | 3167 | if ( incidence && incidence->typeID() == eventID ) { |
3168 | anEvent = static_cast<Event *>(incidence); | 3168 | anEvent = static_cast<Event *>(incidence); |
3169 | } | 3169 | } |
3170 | } | 3170 | } |
3171 | 3171 | ||
3172 | if (!anEvent) { | 3172 | if (!anEvent) { |
3173 | KNotifyClient::beep(); | 3173 | KNotifyClient::beep(); |
3174 | return; | 3174 | return; |
3175 | } | 3175 | } |
3176 | 3176 | ||
3177 | showEvent(anEvent); | 3177 | showEvent(anEvent); |
3178 | } | 3178 | } |
3179 | 3179 | ||
3180 | void CalendarView::appointment_edit() | 3180 | void CalendarView::appointment_edit() |
3181 | { | 3181 | { |
3182 | Event *anEvent = 0; | 3182 | Event *anEvent = 0; |
3183 | 3183 | ||
3184 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3184 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3185 | 3185 | ||
3186 | if (mViewManager->currentView()->isEventView()) { | 3186 | if (mViewManager->currentView()->isEventView()) { |
3187 | if ( incidence && incidence->type() == "Event" ) { | 3187 | if ( incidence && incidence->typeID() == eventID ) { |
3188 | anEvent = static_cast<Event *>(incidence); | 3188 | anEvent = static_cast<Event *>(incidence); |
3189 | } | 3189 | } |
3190 | } | 3190 | } |
3191 | 3191 | ||
3192 | if (!anEvent) { | 3192 | if (!anEvent) { |
3193 | KNotifyClient::beep(); | 3193 | KNotifyClient::beep(); |
3194 | return; | 3194 | return; |
3195 | } | 3195 | } |
3196 | 3196 | ||
3197 | editEvent(anEvent); | 3197 | editEvent(anEvent); |
3198 | } | 3198 | } |
3199 | 3199 | ||
3200 | void CalendarView::appointment_delete() | 3200 | void CalendarView::appointment_delete() |
3201 | { | 3201 | { |
3202 | Event *anEvent = 0; | 3202 | Event *anEvent = 0; |
3203 | 3203 | ||
3204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3205 | 3205 | ||
3206 | if (mViewManager->currentView()->isEventView()) { | 3206 | if (mViewManager->currentView()->isEventView()) { |
3207 | if ( incidence && incidence->type() == "Event" ) { | 3207 | if ( incidence && incidence->typeID() == eventID ) { |
3208 | anEvent = static_cast<Event *>(incidence); | 3208 | anEvent = static_cast<Event *>(incidence); |
3209 | } | 3209 | } |
3210 | } | 3210 | } |
3211 | 3211 | ||
3212 | if (!anEvent) { | 3212 | if (!anEvent) { |
3213 | KNotifyClient::beep(); | 3213 | KNotifyClient::beep(); |
3214 | return; | 3214 | return; |
3215 | } | 3215 | } |
3216 | 3216 | ||
3217 | deleteEvent(anEvent); | 3217 | deleteEvent(anEvent); |
3218 | } | 3218 | } |
3219 | 3219 | ||
3220 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3220 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3221 | { | 3221 | { |
3222 | if (!sub) return; | 3222 | if (!sub) return; |
3223 | if ( sub->relatedTo() == parent ) | 3223 | if ( sub->relatedTo() == parent ) |
3224 | return; | 3224 | return; |
3225 | sub->setRelatedTo(parent); | 3225 | sub->setRelatedTo(parent); |
3226 | sub->updated(); | 3226 | sub->updated(); |
3227 | setModified(true); | 3227 | setModified(true); |
3228 | updateView(); | 3228 | updateView(); |
3229 | } | 3229 | } |
3230 | void CalendarView::todo_unsub(Todo *anTodo ) | 3230 | void CalendarView::todo_unsub(Todo *anTodo ) |
3231 | { | 3231 | { |
3232 | todo_resub( 0, anTodo ); | 3232 | todo_resub( 0, anTodo ); |
3233 | } | 3233 | } |
3234 | 3234 | ||
3235 | void CalendarView::deleteTodo(Todo *todo) | 3235 | void CalendarView::deleteTodo(Todo *todo) |
3236 | { | 3236 | { |
3237 | if (!todo) { | 3237 | if (!todo) { |
3238 | KNotifyClient::beep(); | 3238 | KNotifyClient::beep(); |
3239 | return; | 3239 | return; |
3240 | } | 3240 | } |
3241 | if (KOPrefs::instance()->mConfirm) { | 3241 | if (KOPrefs::instance()->mConfirm) { |
3242 | QString text = todo->summary().left(20); | 3242 | QString text = todo->summary().left(20); |
3243 | if (!todo->relations().isEmpty()) { | 3243 | if (!todo->relations().isEmpty()) { |
3244 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3244 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3245 | 3245 | ||
3246 | } | 3246 | } |
3247 | switch (msgItemDelete(text)) { | 3247 | switch (msgItemDelete(text)) { |
3248 | case KMessageBox::Continue: // OK | 3248 | case KMessageBox::Continue: // OK |
3249 | bool deleteT = false; | 3249 | bool deleteT = false; |
3250 | if (!todo->relations().isEmpty()) { | 3250 | if (!todo->relations().isEmpty()) { |
3251 | deleteT = removeCompletedSubTodos( todo ); | 3251 | deleteT = removeCompletedSubTodos( todo ); |
3252 | } | 3252 | } |
3253 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3253 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3254 | if ( !deleteT ) { | 3254 | if ( !deleteT ) { |
3255 | checkExternalId( todo ); | 3255 | checkExternalId( todo ); |
3256 | calendar()->deleteTodo(todo); | 3256 | calendar()->deleteTodo(todo); |
3257 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3257 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3258 | updateView(); | 3258 | updateView(); |
3259 | } | 3259 | } |
3260 | break; | 3260 | break; |
3261 | } // switch | 3261 | } // switch |
3262 | } else { | 3262 | } else { |
3263 | checkExternalId( todo ); | 3263 | checkExternalId( todo ); |
3264 | mCalendar->deleteTodo(todo); | 3264 | mCalendar->deleteTodo(todo); |
3265 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3265 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3266 | updateView(); | 3266 | updateView(); |
3267 | } | 3267 | } |
3268 | 3268 | ||
3269 | emit updateSearchDialog(); | 3269 | emit updateSearchDialog(); |
3270 | } | 3270 | } |
3271 | void CalendarView::deleteJournal(Journal *jour) | 3271 | void CalendarView::deleteJournal(Journal *jour) |
3272 | { | 3272 | { |
3273 | if (!jour) { | 3273 | if (!jour) { |
3274 | KNotifyClient::beep(); | 3274 | KNotifyClient::beep(); |
3275 | return; | 3275 | return; |
3276 | } | 3276 | } |
3277 | if (KOPrefs::instance()->mConfirm) { | 3277 | if (KOPrefs::instance()->mConfirm) { |
3278 | switch (msgItemDelete( jour->description().left(20))) { | 3278 | switch (msgItemDelete( jour->description().left(20))) { |
3279 | case KMessageBox::Continue: // OK | 3279 | case KMessageBox::Continue: // OK |
3280 | calendar()->deleteJournal(jour); | 3280 | calendar()->deleteJournal(jour); |
3281 | updateView(); | 3281 | updateView(); |
3282 | break; | 3282 | break; |
3283 | } // switch | 3283 | } // switch |
3284 | } else { | 3284 | } else { |
3285 | calendar()->deleteJournal(jour);; | 3285 | calendar()->deleteJournal(jour);; |
3286 | updateView(); | 3286 | updateView(); |
3287 | } | 3287 | } |
3288 | emit updateSearchDialog(); | 3288 | emit updateSearchDialog(); |
3289 | } | 3289 | } |
3290 | 3290 | ||
3291 | void CalendarView::deleteEvent(Event *anEvent) | 3291 | void CalendarView::deleteEvent(Event *anEvent) |
3292 | { | 3292 | { |
3293 | if (!anEvent) { | 3293 | if (!anEvent) { |
3294 | KNotifyClient::beep(); | 3294 | KNotifyClient::beep(); |
3295 | return; | 3295 | return; |
3296 | } | 3296 | } |
3297 | 3297 | ||
3298 | if (anEvent->recurrence()->doesRecur()) { | 3298 | if (anEvent->recurrence()->doesRecur()) { |
3299 | QDate itemDate = mViewManager->currentSelectionDate(); | 3299 | QDate itemDate = mViewManager->currentSelectionDate(); |
3300 | int km; | 3300 | int km; |
3301 | if (!itemDate.isValid()) { | 3301 | if (!itemDate.isValid()) { |
3302 | //kdDebug() << "Date Not Valid" << endl; | 3302 | //kdDebug() << "Date Not Valid" << endl; |
3303 | if (KOPrefs::instance()->mConfirm) { | 3303 | if (KOPrefs::instance()->mConfirm) { |
3304 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3304 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3305 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3305 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3306 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3306 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3307 | if ( km == KMessageBox::Continue ) | 3307 | if ( km == KMessageBox::Continue ) |
3308 | km = KMessageBox::No; // No = all below | 3308 | km = KMessageBox::No; // No = all below |
3309 | } else | 3309 | } else |
3310 | km = KMessageBox::No; | 3310 | km = KMessageBox::No; |
3311 | } else { | 3311 | } else { |
3312 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3312 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3313 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3313 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3314 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3314 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3315 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3315 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3316 | i18n("All")); | 3316 | i18n("All")); |
3317 | } | 3317 | } |
3318 | switch(km) { | 3318 | switch(km) { |
3319 | 3319 | ||
3320 | case KMessageBox::No: // Continue // all | 3320 | case KMessageBox::No: // Continue // all |
3321 | //qDebug("KMessageBox::No "); | 3321 | //qDebug("KMessageBox::No "); |
3322 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3322 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3323 | schedule(Scheduler::Cancel,anEvent); | 3323 | schedule(Scheduler::Cancel,anEvent); |
3324 | 3324 | ||
3325 | checkExternalId( anEvent); | 3325 | checkExternalId( anEvent); |
3326 | mCalendar->deleteEvent(anEvent); | 3326 | mCalendar->deleteEvent(anEvent); |
3327 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3327 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3328 | break; | 3328 | break; |
3329 | 3329 | ||
3330 | // Disabled because it does not work | 3330 | // Disabled because it does not work |
3331 | //#if 0 | 3331 | //#if 0 |
3332 | case KMessageBox::Yes: // just this one | 3332 | case KMessageBox::Yes: // just this one |
3333 | //QDate qd = mNavigator->selectedDates().first(); | 3333 | //QDate qd = mNavigator->selectedDates().first(); |
3334 | //if (!qd.isValid()) { | 3334 | //if (!qd.isValid()) { |
3335 | // kdDebug() << "no date selected, or invalid date" << endl; | 3335 | // kdDebug() << "no date selected, or invalid date" << endl; |
3336 | // KNotifyClient::beep(); | 3336 | // KNotifyClient::beep(); |
3337 | // return; | 3337 | // return; |
3338 | //} | 3338 | //} |
3339 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3339 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3340 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3340 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3341 | anEvent->addExDate(itemDate); | 3341 | anEvent->addExDate(itemDate); |
3342 | int duration = anEvent->recurrence()->duration(); | 3342 | int duration = anEvent->recurrence()->duration(); |
3343 | if ( duration > 0 ) { | 3343 | if ( duration > 0 ) { |
3344 | anEvent->recurrence()->setDuration( duration - 1 ); | 3344 | anEvent->recurrence()->setDuration( duration - 1 ); |
3345 | } | 3345 | } |
3346 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3346 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3347 | } | 3347 | } |
3348 | break; | 3348 | break; |
3349 | //#endif | 3349 | //#endif |
3350 | } // switch | 3350 | } // switch |
3351 | } else { | 3351 | } else { |
3352 | if (KOPrefs::instance()->mConfirm) { | 3352 | if (KOPrefs::instance()->mConfirm) { |
3353 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3353 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3354 | i18n("\nAre you sure you want\nto delete this event?"), | 3354 | i18n("\nAre you sure you want\nto delete this event?"), |
3355 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3355 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3356 | case KMessageBox::Continue: // OK | 3356 | case KMessageBox::Continue: // OK |
3357 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3357 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3358 | schedule(Scheduler::Cancel,anEvent); | 3358 | schedule(Scheduler::Cancel,anEvent); |
3359 | checkExternalId( anEvent); | 3359 | checkExternalId( anEvent); |
3360 | mCalendar->deleteEvent(anEvent); | 3360 | mCalendar->deleteEvent(anEvent); |
3361 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3361 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3362 | break; | 3362 | break; |
3363 | } // switch | 3363 | } // switch |
3364 | } else { | 3364 | } else { |
3365 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3365 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3366 | schedule(Scheduler::Cancel,anEvent); | 3366 | schedule(Scheduler::Cancel,anEvent); |
3367 | checkExternalId( anEvent); | 3367 | checkExternalId( anEvent); |
3368 | mCalendar->deleteEvent(anEvent); | 3368 | mCalendar->deleteEvent(anEvent); |
3369 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3369 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3370 | } | 3370 | } |
3371 | } // if-else | 3371 | } // if-else |
3372 | emit updateSearchDialog(); | 3372 | emit updateSearchDialog(); |
3373 | } | 3373 | } |
3374 | 3374 | ||
3375 | bool CalendarView::deleteEvent(const QString &uid) | 3375 | bool CalendarView::deleteEvent(const QString &uid) |
3376 | { | 3376 | { |
3377 | Event *ev = mCalendar->event(uid); | 3377 | Event *ev = mCalendar->event(uid); |
3378 | if (ev) { | 3378 | if (ev) { |
3379 | deleteEvent(ev); | 3379 | deleteEvent(ev); |
3380 | return true; | 3380 | return true; |
3381 | } else { | 3381 | } else { |
3382 | return false; | 3382 | return false; |
3383 | } | 3383 | } |
3384 | } | 3384 | } |
3385 | 3385 | ||
3386 | /*****************************************************************************/ | 3386 | /*****************************************************************************/ |
3387 | 3387 | ||
3388 | void CalendarView::action_mail() | 3388 | void CalendarView::action_mail() |
3389 | { | 3389 | { |
3390 | #ifndef KORG_NOMAIL | 3390 | #ifndef KORG_NOMAIL |
3391 | KOMailClient mailClient; | 3391 | KOMailClient mailClient; |
3392 | 3392 | ||
3393 | Incidence *incidence = currentSelection(); | 3393 | Incidence *incidence = currentSelection(); |
3394 | 3394 | ||
3395 | if (!incidence) { | 3395 | if (!incidence) { |
3396 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3396 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3397 | return; | 3397 | return; |
3398 | } | 3398 | } |
3399 | if(incidence->attendeeCount() == 0 ) { | 3399 | if(incidence->attendeeCount() == 0 ) { |
3400 | KMessageBox::sorry(this, | 3400 | KMessageBox::sorry(this, |
3401 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3401 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3402 | return; | 3402 | return; |
3403 | } | 3403 | } |
3404 | 3404 | ||
3405 | CalendarLocal cal_tmp; | 3405 | CalendarLocal cal_tmp; |
3406 | Event *event = 0; | 3406 | Event *event = 0; |
3407 | Event *ev = 0; | 3407 | Event *ev = 0; |
3408 | if ( incidence && incidence->type() == "Event" ) { | 3408 | if ( incidence && incidence->typeID() == eventID ) { |
3409 | event = static_cast<Event *>(incidence); | 3409 | event = static_cast<Event *>(incidence); |
3410 | ev = new Event(*event); | 3410 | ev = new Event(*event); |
3411 | cal_tmp.addEvent(ev); | 3411 | cal_tmp.addEvent(ev); |
3412 | } | 3412 | } |
3413 | ICalFormat mForm(); | 3413 | ICalFormat mForm(); |
3414 | QString attachment = mForm.toString( &cal_tmp ); | 3414 | QString attachment = mForm.toString( &cal_tmp ); |
3415 | if (ev) delete(ev); | 3415 | if (ev) delete(ev); |
3416 | 3416 | ||
3417 | mailClient.mailAttendees(currentSelection(), attachment); | 3417 | mailClient.mailAttendees(currentSelection(), attachment); |
3418 | 3418 | ||
3419 | #endif | 3419 | #endif |
3420 | 3420 | ||
3421 | #if 0 | 3421 | #if 0 |
3422 | Event *anEvent = 0; | 3422 | Event *anEvent = 0; |
3423 | if (mViewManager->currentView()->isEventView()) { | 3423 | if (mViewManager->currentView()->isEventView()) { |
3424 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3424 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3425 | } | 3425 | } |
3426 | 3426 | ||
3427 | if (!anEvent) { | 3427 | if (!anEvent) { |
3428 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3428 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3429 | return; | 3429 | return; |
3430 | } | 3430 | } |
3431 | if(anEvent->attendeeCount() == 0 ) { | 3431 | if(anEvent->attendeeCount() == 0 ) { |
3432 | KMessageBox::sorry(this, | 3432 | KMessageBox::sorry(this, |
3433 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3433 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3434 | return; | 3434 | return; |
3435 | } | 3435 | } |
3436 | 3436 | ||
3437 | mailobject.emailEvent(anEvent); | 3437 | mailobject.emailEvent(anEvent); |
3438 | #endif | 3438 | #endif |
3439 | } | 3439 | } |
3440 | 3440 | ||
3441 | 3441 | ||
3442 | void CalendarView::schedule_publish(Incidence *incidence) | 3442 | void CalendarView::schedule_publish(Incidence *incidence) |
3443 | { | 3443 | { |
3444 | Event *event = 0; | 3444 | Event *event = 0; |
3445 | Todo *todo = 0; | 3445 | Todo *todo = 0; |
3446 | 3446 | ||
3447 | if (incidence == 0) { | 3447 | if (incidence == 0) { |
3448 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3448 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3449 | if (incidence == 0) { | 3449 | if (incidence == 0) { |
3450 | incidence = mTodoList->selectedIncidences().first(); | 3450 | incidence = mTodoList->selectedIncidences().first(); |
3451 | } | 3451 | } |
3452 | } | 3452 | } |
3453 | if ( incidence && incidence->type() == "Event" ) { | 3453 | if ( incidence && incidence->typeID() == eventID ) { |
3454 | event = static_cast<Event *>(incidence); | 3454 | event = static_cast<Event *>(incidence); |
3455 | } else { | 3455 | } else { |
3456 | if ( incidence && incidence->type() == "Todo" ) { | 3456 | if ( incidence && incidence->typeID() == todoID ) { |
3457 | todo = static_cast<Todo *>(incidence); | 3457 | todo = static_cast<Todo *>(incidence); |
3458 | } | 3458 | } |
3459 | } | 3459 | } |
3460 | 3460 | ||
3461 | if (!event && !todo) { | 3461 | if (!event && !todo) { |
3462 | KMessageBox::sorry(this,i18n("No event selected.")); | 3462 | KMessageBox::sorry(this,i18n("No event selected.")); |
3463 | return; | 3463 | return; |
3464 | } | 3464 | } |
3465 | 3465 | ||
3466 | PublishDialog *publishdlg = new PublishDialog(); | 3466 | PublishDialog *publishdlg = new PublishDialog(); |
3467 | if (incidence->attendeeCount()>0) { | 3467 | if (incidence->attendeeCount()>0) { |
3468 | QPtrList<Attendee> attendees = incidence->attendees(); | 3468 | QPtrList<Attendee> attendees = incidence->attendees(); |
3469 | attendees.first(); | 3469 | attendees.first(); |
3470 | while ( attendees.current()!=0 ) { | 3470 | while ( attendees.current()!=0 ) { |
3471 | publishdlg->addAttendee(attendees.current()); | 3471 | publishdlg->addAttendee(attendees.current()); |
3472 | attendees.next(); | 3472 | attendees.next(); |
3473 | } | 3473 | } |
3474 | } | 3474 | } |
3475 | bool send = true; | 3475 | bool send = true; |
3476 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3476 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3477 | if ( publishdlg->exec() != QDialog::Accepted ) | 3477 | if ( publishdlg->exec() != QDialog::Accepted ) |
3478 | send = false; | 3478 | send = false; |
3479 | } | 3479 | } |
3480 | if ( send ) { | 3480 | if ( send ) { |
3481 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3481 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3482 | if ( event ) { | 3482 | if ( event ) { |
3483 | Event *ev = new Event(*event); | 3483 | Event *ev = new Event(*event); |
3484 | ev->registerObserver(0); | 3484 | ev->registerObserver(0); |
3485 | ev->clearAttendees(); | 3485 | ev->clearAttendees(); |
3486 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3486 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3487 | delete(ev); | 3487 | delete(ev); |
3488 | } | 3488 | } |
3489 | } else { | 3489 | } else { |
3490 | if ( todo ) { | 3490 | if ( todo ) { |
3491 | Todo *ev = new Todo(*todo); | 3491 | Todo *ev = new Todo(*todo); |
3492 | ev->registerObserver(0); | 3492 | ev->registerObserver(0); |
3493 | ev->clearAttendees(); | 3493 | ev->clearAttendees(); |
3494 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3494 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3495 | delete(ev); | 3495 | delete(ev); |
3496 | } | 3496 | } |
3497 | } | 3497 | } |
3498 | } | 3498 | } |
3499 | } | 3499 | } |
3500 | delete publishdlg; | 3500 | delete publishdlg; |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | void CalendarView::schedule_request(Incidence *incidence) | 3503 | void CalendarView::schedule_request(Incidence *incidence) |
3504 | { | 3504 | { |
3505 | schedule(Scheduler::Request,incidence); | 3505 | schedule(Scheduler::Request,incidence); |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | void CalendarView::schedule_refresh(Incidence *incidence) | 3508 | void CalendarView::schedule_refresh(Incidence *incidence) |
3509 | { | 3509 | { |
3510 | schedule(Scheduler::Refresh,incidence); | 3510 | schedule(Scheduler::Refresh,incidence); |
3511 | } | 3511 | } |
3512 | 3512 | ||
3513 | void CalendarView::schedule_cancel(Incidence *incidence) | 3513 | void CalendarView::schedule_cancel(Incidence *incidence) |
3514 | { | 3514 | { |
3515 | schedule(Scheduler::Cancel,incidence); | 3515 | schedule(Scheduler::Cancel,incidence); |
3516 | } | 3516 | } |
3517 | 3517 | ||
3518 | void CalendarView::schedule_add(Incidence *incidence) | 3518 | void CalendarView::schedule_add(Incidence *incidence) |
3519 | { | 3519 | { |
3520 | schedule(Scheduler::Add,incidence); | 3520 | schedule(Scheduler::Add,incidence); |
3521 | } | 3521 | } |
3522 | 3522 | ||
3523 | void CalendarView::schedule_reply(Incidence *incidence) | 3523 | void CalendarView::schedule_reply(Incidence *incidence) |
3524 | { | 3524 | { |
3525 | schedule(Scheduler::Reply,incidence); | 3525 | schedule(Scheduler::Reply,incidence); |
3526 | } | 3526 | } |
3527 | 3527 | ||
3528 | void CalendarView::schedule_counter(Incidence *incidence) | 3528 | void CalendarView::schedule_counter(Incidence *incidence) |
3529 | { | 3529 | { |
3530 | schedule(Scheduler::Counter,incidence); | 3530 | schedule(Scheduler::Counter,incidence); |
3531 | } | 3531 | } |
3532 | 3532 | ||
3533 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3533 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3534 | { | 3534 | { |
3535 | schedule(Scheduler::Declinecounter,incidence); | 3535 | schedule(Scheduler::Declinecounter,incidence); |
3536 | } | 3536 | } |
3537 | 3537 | ||
3538 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3538 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3539 | { | 3539 | { |
3540 | QDateTime start = QDateTime::currentDateTime(); | 3540 | QDateTime start = QDateTime::currentDateTime(); |
3541 | QDateTime end = start.addDays(daysToPublish); | 3541 | QDateTime end = start.addDays(daysToPublish); |
3542 | 3542 | ||
3543 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3543 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3544 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3544 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3545 | 3545 | ||
3546 | 3546 | ||
3547 | PublishDialog *publishdlg = new PublishDialog(); | 3547 | PublishDialog *publishdlg = new PublishDialog(); |
3548 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3548 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3549 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3549 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3550 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3550 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3551 | delete(freebusy); | 3551 | delete(freebusy); |
3552 | } | 3552 | } |
3553 | } | 3553 | } |
3554 | delete publishdlg; | 3554 | delete publishdlg; |
3555 | } | 3555 | } |
3556 | 3556 | ||
3557 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3557 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3558 | { | 3558 | { |
3559 | Event *event = 0; | 3559 | Event *event = 0; |
3560 | Todo *todo = 0; | 3560 | Todo *todo = 0; |
3561 | 3561 | ||
3562 | if (incidence == 0) { | 3562 | if (incidence == 0) { |
3563 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3563 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3564 | if (incidence == 0) { | 3564 | if (incidence == 0) { |
3565 | incidence = mTodoList->selectedIncidences().first(); | 3565 | incidence = mTodoList->selectedIncidences().first(); |
3566 | } | 3566 | } |
3567 | } | 3567 | } |
3568 | if ( incidence && incidence->type() == "Event" ) { | 3568 | if ( incidence && incidence->typeID() == eventID ) { |
3569 | event = static_cast<Event *>(incidence); | 3569 | event = static_cast<Event *>(incidence); |
3570 | } | 3570 | } |
3571 | if ( incidence && incidence->type() == "Todo" ) { | 3571 | if ( incidence && incidence->typeID() == todoID ) { |
3572 | todo = static_cast<Todo *>(incidence); | 3572 | todo = static_cast<Todo *>(incidence); |
3573 | } | 3573 | } |
3574 | 3574 | ||
3575 | if (!event && !todo) { | 3575 | if (!event && !todo) { |
3576 | KMessageBox::sorry(this,i18n("No event selected.")); | 3576 | KMessageBox::sorry(this,i18n("No event selected.")); |
3577 | return; | 3577 | return; |
3578 | } | 3578 | } |
3579 | 3579 | ||
3580 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3580 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3581 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3581 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3582 | return; | 3582 | return; |
3583 | } | 3583 | } |
3584 | 3584 | ||
3585 | Event *ev = 0; | 3585 | Event *ev = 0; |
3586 | if (event) ev = new Event(*event); | 3586 | if (event) ev = new Event(*event); |
3587 | Todo *to = 0; | 3587 | Todo *to = 0; |
3588 | if (todo) to = new Todo(*todo); | 3588 | if (todo) to = new Todo(*todo); |
3589 | 3589 | ||
3590 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3590 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3591 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3591 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3592 | if (!me) { | 3592 | if (!me) { |
3593 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3593 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3594 | return; | 3594 | return; |
3595 | } | 3595 | } |
3596 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3596 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3597 | StatusDialog *statdlg = new StatusDialog(this); | 3597 | StatusDialog *statdlg = new StatusDialog(this); |
3598 | if (!statdlg->exec()==QDialog::Accepted) return; | 3598 | if (!statdlg->exec()==QDialog::Accepted) return; |
3599 | me->setStatus( statdlg->status() ); | 3599 | me->setStatus( statdlg->status() ); |
3600 | delete(statdlg); | 3600 | delete(statdlg); |
3601 | } | 3601 | } |
3602 | Attendee *menew = new Attendee(*me); | 3602 | Attendee *menew = new Attendee(*me); |
3603 | if (ev) { | 3603 | if (ev) { |
3604 | ev->clearAttendees(); | 3604 | ev->clearAttendees(); |
3605 | ev->addAttendee(menew,false); | 3605 | ev->addAttendee(menew,false); |
3606 | } else { | 3606 | } else { |
3607 | if (to) { | 3607 | if (to) { |
3608 | todo->clearAttendees(); | 3608 | todo->clearAttendees(); |
3609 | todo->addAttendee(menew,false); | 3609 | todo->addAttendee(menew,false); |
3610 | } | 3610 | } |
3611 | } | 3611 | } |
3612 | } | 3612 | } |
3613 | 3613 | ||
3614 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3614 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3615 | if (ev) { | 3615 | if (ev) { |
3616 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3616 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3617 | } else { | 3617 | } else { |
3618 | if (to) { | 3618 | if (to) { |
3619 | if ( !dlg->addMessage(to,method) ) delete(to); | 3619 | if ( !dlg->addMessage(to,method) ) delete(to); |
3620 | } | 3620 | } |
3621 | } | 3621 | } |
3622 | } | 3622 | } |
3623 | 3623 | ||
3624 | void CalendarView::openAddressbook() | 3624 | void CalendarView::openAddressbook() |
3625 | { | 3625 | { |
3626 | KRun::runCommand("kaddressbook"); | 3626 | KRun::runCommand("kaddressbook"); |
3627 | } | 3627 | } |
3628 | 3628 | ||
3629 | void CalendarView::setModified(bool modified) | 3629 | void CalendarView::setModified(bool modified) |
3630 | { | 3630 | { |
3631 | if ( modified ) | 3631 | if ( modified ) |
3632 | emit signalmodified(); | 3632 | emit signalmodified(); |
3633 | if (mModified != modified) { | 3633 | if (mModified != modified) { |
3634 | mModified = modified; | 3634 | mModified = modified; |
3635 | emit modifiedChanged(mModified); | 3635 | emit modifiedChanged(mModified); |
3636 | } | 3636 | } |
3637 | } | 3637 | } |
3638 | 3638 | ||
3639 | bool CalendarView::isReadOnly() | 3639 | bool CalendarView::isReadOnly() |
3640 | { | 3640 | { |
3641 | return mReadOnly; | 3641 | return mReadOnly; |
3642 | } | 3642 | } |
3643 | 3643 | ||
3644 | void CalendarView::setReadOnly(bool readOnly) | 3644 | void CalendarView::setReadOnly(bool readOnly) |
3645 | { | 3645 | { |
3646 | if (mReadOnly != readOnly) { | 3646 | if (mReadOnly != readOnly) { |
3647 | mReadOnly = readOnly; | 3647 | mReadOnly = readOnly; |
3648 | emit readOnlyChanged(mReadOnly); | 3648 | emit readOnlyChanged(mReadOnly); |
3649 | } | 3649 | } |
3650 | } | 3650 | } |
3651 | 3651 | ||
3652 | bool CalendarView::isModified() | 3652 | bool CalendarView::isModified() |
3653 | { | 3653 | { |
3654 | return mModified; | 3654 | return mModified; |
3655 | } | 3655 | } |
3656 | void CalendarView::slotprintSelInc() | 3656 | void CalendarView::slotprintSelInc() |
3657 | { | 3657 | { |
3658 | if ( currentSelection() == 0 ) { | 3658 | if ( currentSelection() == 0 ) { |
3659 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3659 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3660 | return; | 3660 | return; |
3661 | } | 3661 | } |
3662 | showIncidence(); | 3662 | showIncidence(); |
3663 | getEventViewerDialog()->print(); | 3663 | getEventViewerDialog()->print(); |
3664 | 3664 | ||
3665 | } | 3665 | } |
3666 | void CalendarView::printSetup() | 3666 | void CalendarView::printSetup() |
3667 | { | 3667 | { |
3668 | #ifndef KORG_NOPRINTER | 3668 | #ifndef KORG_NOPRINTER |
3669 | createPrinter(); | 3669 | createPrinter(); |
3670 | 3670 | ||
3671 | mCalPrinter->setupPrinter(); | 3671 | mCalPrinter->setupPrinter(); |
3672 | #endif | 3672 | #endif |
3673 | } | 3673 | } |
3674 | 3674 | ||
3675 | void CalendarView::print() | 3675 | void CalendarView::print() |
3676 | { | 3676 | { |
3677 | #ifndef KORG_NOPRINTER | 3677 | #ifndef KORG_NOPRINTER |
3678 | createPrinter(); | 3678 | createPrinter(); |
3679 | 3679 | ||
3680 | DateList tmpDateList = mNavigator->selectedDates(); | 3680 | DateList tmpDateList = mNavigator->selectedDates(); |
3681 | mCalPrinter->print(CalPrinter::Month, | 3681 | mCalPrinter->print(CalPrinter::Month, |
3682 | tmpDateList.first(), tmpDateList.last()); | 3682 | tmpDateList.first(), tmpDateList.last()); |
3683 | #endif | 3683 | #endif |
3684 | } | 3684 | } |
3685 | 3685 | ||
3686 | void CalendarView::printPreview() | 3686 | void CalendarView::printPreview() |
3687 | { | 3687 | { |
3688 | #ifndef KORG_NOPRINTER | 3688 | #ifndef KORG_NOPRINTER |
3689 | kdDebug() << "CalendarView::printPreview()" << endl; | 3689 | kdDebug() << "CalendarView::printPreview()" << endl; |
3690 | 3690 | ||
3691 | createPrinter(); | 3691 | createPrinter(); |
3692 | 3692 | ||
3693 | DateList tmpDateList = mNavigator->selectedDates(); | 3693 | DateList tmpDateList = mNavigator->selectedDates(); |
3694 | 3694 | ||
3695 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3695 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3696 | tmpDateList.last()); | 3696 | tmpDateList.last()); |
3697 | #endif | 3697 | #endif |
3698 | } | 3698 | } |
3699 | 3699 | ||
3700 | void CalendarView::exportICalendar() | 3700 | void CalendarView::exportICalendar() |
3701 | { | 3701 | { |
3702 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3702 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3703 | 3703 | ||
3704 | // Force correct extension | 3704 | // Force correct extension |
3705 | if (filename.right(4) != ".ics") filename += ".ics"; | 3705 | if (filename.right(4) != ".ics") filename += ".ics"; |
3706 | 3706 | ||
3707 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3707 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3708 | storage.save(); | 3708 | storage.save(); |
3709 | } | 3709 | } |
3710 | 3710 | ||
3711 | bool CalendarView::exportVCalendar( QString filename ) | 3711 | bool CalendarView::exportVCalendar( QString filename ) |
3712 | { | 3712 | { |
3713 | if (mCalendar->journals().count() > 0) { | 3713 | if (mCalendar->journals().count() > 0) { |
3714 | int result = KMessageBox::warningContinueCancel(this, | 3714 | int result = KMessageBox::warningContinueCancel(this, |
3715 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3715 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3716 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3716 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3717 | true); | 3717 | true); |
3718 | if (result != KMessageBox::Continue) return false; | 3718 | if (result != KMessageBox::Continue) return false; |
3719 | } | 3719 | } |
3720 | 3720 | ||
3721 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3721 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3722 | 3722 | ||
3723 | // Force correct extension | 3723 | // Force correct extension |
3724 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3724 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3725 | 3725 | ||
3726 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3726 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3727 | return storage.save(); | 3727 | return storage.save(); |
3728 | 3728 | ||
3729 | } | 3729 | } |
3730 | 3730 | ||
3731 | void CalendarView::eventUpdated(Incidence *) | 3731 | void CalendarView::eventUpdated(Incidence *) |
3732 | { | 3732 | { |
3733 | setModified(); | 3733 | setModified(); |
3734 | // Don't call updateView here. The code, which has caused the update of the | 3734 | // Don't call updateView here. The code, which has caused the update of the |
3735 | // event is responsible for updating the view. | 3735 | // event is responsible for updating the view. |
3736 | // updateView(); | 3736 | // updateView(); |
3737 | } | 3737 | } |
3738 | 3738 | ||
3739 | void CalendarView::adaptNavigationUnits() | 3739 | void CalendarView::adaptNavigationUnits() |
3740 | { | 3740 | { |
3741 | if (mViewManager->currentView()->isEventView()) { | 3741 | if (mViewManager->currentView()->isEventView()) { |
3742 | int days = mViewManager->currentView()->currentDateCount(); | 3742 | int days = mViewManager->currentView()->currentDateCount(); |
3743 | if (days == 1) { | 3743 | if (days == 1) { |
3744 | emit changeNavStringPrev(i18n("&Previous Day")); | 3744 | emit changeNavStringPrev(i18n("&Previous Day")); |
3745 | emit changeNavStringNext(i18n("&Next Day")); | 3745 | emit changeNavStringNext(i18n("&Next Day")); |
3746 | } else { | 3746 | } else { |
3747 | emit changeNavStringPrev(i18n("&Previous Week")); | 3747 | emit changeNavStringPrev(i18n("&Previous Week")); |
3748 | emit changeNavStringNext(i18n("&Next Week")); | 3748 | emit changeNavStringNext(i18n("&Next Week")); |
3749 | } | 3749 | } |
3750 | } | 3750 | } |
3751 | } | 3751 | } |
3752 | 3752 | ||
3753 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3753 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3754 | { | 3754 | { |
3755 | if ( incidence ) mTodoList->clearSelection(); | 3755 | if ( incidence ) mTodoList->clearSelection(); |
3756 | processIncidenceSelection( incidence ); | 3756 | processIncidenceSelection( incidence ); |
3757 | } | 3757 | } |
3758 | 3758 | ||
3759 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3759 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3760 | { | 3760 | { |
3761 | if ( incidence && mViewManager->currentView() ) { | 3761 | if ( incidence && mViewManager->currentView() ) { |
3762 | mViewManager->currentView()->clearSelection(); | 3762 | mViewManager->currentView()->clearSelection(); |
3763 | } | 3763 | } |
3764 | processIncidenceSelection( incidence ); | 3764 | processIncidenceSelection( incidence ); |
3765 | } | 3765 | } |
3766 | 3766 | ||
3767 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3767 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3768 | { | 3768 | { |
3769 | if ( incidence == mSelectedIncidence ) return; | 3769 | if ( incidence == mSelectedIncidence ) return; |
3770 | 3770 | ||
3771 | mSelectedIncidence = incidence; | 3771 | mSelectedIncidence = incidence; |
3772 | 3772 | ||
3773 | emit incidenceSelected( mSelectedIncidence ); | 3773 | emit incidenceSelected( mSelectedIncidence ); |
3774 | 3774 | ||
3775 | if ( incidence && incidence->type() == "Event" ) { | 3775 | if ( incidence && incidence->typeID() == eventID ) { |
3776 | Event *event = static_cast<Event *>( incidence ); | 3776 | Event *event = static_cast<Event *>( incidence ); |
3777 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3777 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3778 | emit organizerEventsSelected( true ); | 3778 | emit organizerEventsSelected( true ); |
3779 | } else { | 3779 | } else { |
3780 | emit organizerEventsSelected(false); | 3780 | emit organizerEventsSelected(false); |
3781 | } | 3781 | } |
3782 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3782 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3783 | KOPrefs::instance()->email() ) ) { | 3783 | KOPrefs::instance()->email() ) ) { |
3784 | emit groupEventsSelected( true ); | 3784 | emit groupEventsSelected( true ); |
3785 | } else { | 3785 | } else { |
3786 | emit groupEventsSelected(false); | 3786 | emit groupEventsSelected(false); |
3787 | } | 3787 | } |
3788 | return; | 3788 | return; |
3789 | } else { | 3789 | } else { |
3790 | if ( incidence && incidence->type() == "Todo" ) { | 3790 | if ( incidence && incidence->typeID() == todoID ) { |
3791 | emit todoSelected( true ); | 3791 | emit todoSelected( true ); |
3792 | Todo *event = static_cast<Todo *>( incidence ); | 3792 | Todo *event = static_cast<Todo *>( incidence ); |
3793 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3793 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3794 | emit organizerEventsSelected( true ); | 3794 | emit organizerEventsSelected( true ); |
3795 | } else { | 3795 | } else { |
3796 | emit organizerEventsSelected(false); | 3796 | emit organizerEventsSelected(false); |
3797 | } | 3797 | } |
3798 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3798 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3799 | KOPrefs::instance()->email() ) ) { | 3799 | KOPrefs::instance()->email() ) ) { |
3800 | emit groupEventsSelected( true ); | 3800 | emit groupEventsSelected( true ); |
3801 | } else { | 3801 | } else { |
3802 | emit groupEventsSelected(false); | 3802 | emit groupEventsSelected(false); |
3803 | } | 3803 | } |
3804 | return; | 3804 | return; |
3805 | } else { | 3805 | } else { |
3806 | emit todoSelected( false ); | 3806 | emit todoSelected( false ); |
3807 | emit organizerEventsSelected(false); | 3807 | emit organizerEventsSelected(false); |
3808 | emit groupEventsSelected(false); | 3808 | emit groupEventsSelected(false); |
3809 | } | 3809 | } |
3810 | return; | 3810 | return; |
3811 | } | 3811 | } |
3812 | 3812 | ||
3813 | /* if ( incidence && incidence->type() == "Todo" ) { | 3813 | /* if ( incidence && incidence->typeID() == todoID ) { |
3814 | emit todoSelected( true ); | 3814 | emit todoSelected( true ); |
3815 | } else { | 3815 | } else { |
3816 | emit todoSelected( false ); | 3816 | emit todoSelected( false ); |
3817 | }*/ | 3817 | }*/ |
3818 | } | 3818 | } |
3819 | 3819 | ||
3820 | 3820 | ||
3821 | void CalendarView::checkClipboard() | 3821 | void CalendarView::checkClipboard() |
3822 | { | 3822 | { |
3823 | #ifndef KORG_NODND | 3823 | #ifndef KORG_NODND |
3824 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3824 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3825 | emit pasteEnabled(true); | 3825 | emit pasteEnabled(true); |
3826 | } else { | 3826 | } else { |
3827 | emit pasteEnabled(false); | 3827 | emit pasteEnabled(false); |
3828 | } | 3828 | } |
3829 | #endif | 3829 | #endif |
3830 | } | 3830 | } |
3831 | 3831 | ||
3832 | void CalendarView::showDates(const DateList &selectedDates) | 3832 | void CalendarView::showDates(const DateList &selectedDates) |
3833 | { | 3833 | { |
3834 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3834 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3835 | 3835 | ||
3836 | 3836 | ||
3837 | if ( !mBlockShowDates ) { | 3837 | if ( !mBlockShowDates ) { |
3838 | if ( mViewManager->currentView() ) { | 3838 | if ( mViewManager->currentView() ) { |
3839 | updateView( selectedDates.first(), selectedDates.last() ); | 3839 | updateView( selectedDates.first(), selectedDates.last() ); |
3840 | } else { | 3840 | } else { |
3841 | mViewManager->showAgendaView(); | 3841 | mViewManager->showAgendaView(); |
3842 | } | 3842 | } |
3843 | } | 3843 | } |
3844 | 3844 | ||
3845 | QDate date = selectedDates.first(); | 3845 | QDate date = selectedDates.first(); |
3846 | if ( ! date.isValid() ) { | 3846 | if ( ! date.isValid() ) { |
3847 | topLevelWidget()->setCaption(""); | 3847 | topLevelWidget()->setCaption(""); |
3848 | return; | 3848 | return; |
3849 | } | 3849 | } |
3850 | 3850 | ||
3851 | QString selDates; | 3851 | QString selDates; |
3852 | selDates = KGlobal::locale()->formatDate( date, true); | 3852 | selDates = KGlobal::locale()->formatDate( date, true); |
3853 | if (selectedDates.first() < selectedDates.last() ) | 3853 | if (selectedDates.first() < selectedDates.last() ) |
3854 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3854 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3855 | else { | 3855 | else { |
3856 | QString addString; | 3856 | QString addString; |
3857 | if ( date == QDateTime::currentDateTime().date() ) | 3857 | if ( date == QDateTime::currentDateTime().date() ) |
3858 | addString = i18n("Today"); | 3858 | addString = i18n("Today"); |
3859 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 3859 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
3860 | addString = i18n("Tomorrow"); | 3860 | addString = i18n("Tomorrow"); |
3861 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 3861 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
3862 | addString = i18n("Yesterday"); | 3862 | addString = i18n("Yesterday"); |
3863 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 3863 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
3864 | addString = i18n("Day before yesterday"); | 3864 | addString = i18n("Day before yesterday"); |
3865 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 3865 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
3866 | addString = i18n("Day after tomorrow"); | 3866 | addString = i18n("Day after tomorrow"); |
3867 | if ( !addString.isEmpty() ) { | 3867 | if ( !addString.isEmpty() ) { |
3868 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3868 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3869 | return; | 3869 | return; |
3870 | } | 3870 | } |
3871 | } | 3871 | } |
3872 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3872 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3873 | 3873 | ||
3874 | } | 3874 | } |
3875 | 3875 | ||
3876 | QPtrList<CalFilter> CalendarView::filters() | 3876 | QPtrList<CalFilter> CalendarView::filters() |
3877 | { | 3877 | { |
3878 | return mFilters; | 3878 | return mFilters; |
3879 | 3879 | ||
3880 | } | 3880 | } |
3881 | void CalendarView::editFilters() | 3881 | void CalendarView::editFilters() |
3882 | { | 3882 | { |
3883 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3883 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3884 | 3884 | ||
3885 | CalFilter *filter = mFilters.first(); | 3885 | CalFilter *filter = mFilters.first(); |
3886 | while(filter) { | 3886 | while(filter) { |
3887 | kdDebug() << " Filter: " << filter->name() << endl; | 3887 | kdDebug() << " Filter: " << filter->name() << endl; |
3888 | filter = mFilters.next(); | 3888 | filter = mFilters.next(); |
3889 | } | 3889 | } |
3890 | 3890 | ||
3891 | mDialogManager->showFilterEditDialog(&mFilters); | 3891 | mDialogManager->showFilterEditDialog(&mFilters); |
3892 | } | 3892 | } |
3893 | void CalendarView::toggleFilter() | 3893 | void CalendarView::toggleFilter() |
3894 | { | 3894 | { |
3895 | showFilter(! mFilterView->isVisible()); | 3895 | showFilter(! mFilterView->isVisible()); |
3896 | } | 3896 | } |
3897 | 3897 | ||
3898 | KOFilterView *CalendarView::filterView() | 3898 | KOFilterView *CalendarView::filterView() |
3899 | { | 3899 | { |
3900 | return mFilterView; | 3900 | return mFilterView; |
3901 | } | 3901 | } |
3902 | void CalendarView::selectFilter( int fil ) | 3902 | void CalendarView::selectFilter( int fil ) |
3903 | { | 3903 | { |
3904 | mFilterView->setSelectedFilter( fil ); | 3904 | mFilterView->setSelectedFilter( fil ); |
3905 | } | 3905 | } |
3906 | void CalendarView::showFilter(bool visible) | 3906 | void CalendarView::showFilter(bool visible) |
3907 | { | 3907 | { |
3908 | if (visible) mFilterView->show(); | 3908 | if (visible) mFilterView->show(); |
3909 | else mFilterView->hide(); | 3909 | else mFilterView->hide(); |
3910 | } | 3910 | } |
3911 | void CalendarView::toggleFilerEnabled( ) | 3911 | void CalendarView::toggleFilerEnabled( ) |
3912 | { | 3912 | { |
3913 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3913 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3914 | if ( !mFilterView->filtersEnabled() ) | 3914 | if ( !mFilterView->filtersEnabled() ) |
3915 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3915 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3916 | 3916 | ||
3917 | } | 3917 | } |
3918 | void CalendarView::updateFilter() | 3918 | void CalendarView::updateFilter() |
3919 | { | 3919 | { |
3920 | CalFilter *filter = mFilterView->selectedFilter(); | 3920 | CalFilter *filter = mFilterView->selectedFilter(); |
3921 | if (filter) { | 3921 | if (filter) { |
3922 | QString mess; | 3922 | QString mess; |
3923 | if (mFilterView->filtersEnabled()) { | 3923 | if (mFilterView->filtersEnabled()) { |
3924 | mess = i18n("Filter selected: ")+filter->name(); | 3924 | mess = i18n("Filter selected: ")+filter->name(); |
3925 | filter->setEnabled(true); | 3925 | filter->setEnabled(true); |
3926 | } | 3926 | } |
3927 | else filter->setEnabled(false); | 3927 | else filter->setEnabled(false); |
3928 | mCalendar->setFilter(filter); | 3928 | mCalendar->setFilter(filter); |
3929 | updateView(); | 3929 | updateView(); |
3930 | if ( !mess.isEmpty() ) | 3930 | if ( !mess.isEmpty() ) |
3931 | topLevelWidget()->setCaption( mess ); | 3931 | topLevelWidget()->setCaption( mess ); |
3932 | 3932 | ||
3933 | } | 3933 | } |
3934 | } | 3934 | } |
3935 | 3935 | ||
3936 | void CalendarView::filterEdited() | 3936 | void CalendarView::filterEdited() |
3937 | { | 3937 | { |
3938 | mFilterView->updateFilters(); | 3938 | mFilterView->updateFilters(); |
3939 | updateFilter(); | 3939 | updateFilter(); |
3940 | writeSettings(); | 3940 | writeSettings(); |
3941 | } | 3941 | } |
3942 | 3942 | ||
3943 | 3943 | ||
3944 | void CalendarView::takeOverEvent() | 3944 | void CalendarView::takeOverEvent() |
3945 | { | 3945 | { |
3946 | Incidence *incidence = currentSelection(); | 3946 | Incidence *incidence = currentSelection(); |
3947 | 3947 | ||
3948 | if (!incidence) return; | 3948 | if (!incidence) return; |
3949 | 3949 | ||
3950 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3950 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3951 | incidence->recreate(); | 3951 | incidence->recreate(); |
3952 | incidence->setReadOnly(false); | 3952 | incidence->setReadOnly(false); |
3953 | 3953 | ||
3954 | updateView(); | 3954 | updateView(); |
3955 | } | 3955 | } |
3956 | 3956 | ||
3957 | void CalendarView::takeOverCalendar() | 3957 | void CalendarView::takeOverCalendar() |
3958 | { | 3958 | { |
3959 | // TODO: Create Calendar::allIncidences() function and use it here | 3959 | // TODO: Create Calendar::allIncidences() function and use it here |
3960 | 3960 | ||
3961 | clearAllViews(); | 3961 | clearAllViews(); |
3962 | QPtrList<Event> events = mCalendar->events(); | 3962 | QPtrList<Event> events = mCalendar->events(); |
3963 | for(uint i=0; i<events.count(); ++i) { | 3963 | for(uint i=0; i<events.count(); ++i) { |
3964 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3964 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3965 | events.at(i)->recreate(); | 3965 | events.at(i)->recreate(); |
3966 | events.at(i)->setReadOnly(false); | 3966 | events.at(i)->setReadOnly(false); |
3967 | } | 3967 | } |
3968 | 3968 | ||
3969 | QPtrList<Todo> todos = mCalendar->todos(); | 3969 | QPtrList<Todo> todos = mCalendar->todos(); |
3970 | for(uint i=0; i<todos.count(); ++i) { | 3970 | for(uint i=0; i<todos.count(); ++i) { |
3971 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3971 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3972 | todos.at(i)->recreate(); | 3972 | todos.at(i)->recreate(); |
3973 | todos.at(i)->setReadOnly(false); | 3973 | todos.at(i)->setReadOnly(false); |
3974 | } | 3974 | } |
3975 | 3975 | ||
3976 | QPtrList<Journal> journals = mCalendar->journals(); | 3976 | QPtrList<Journal> journals = mCalendar->journals(); |
3977 | for(uint i=0; i<journals.count(); ++i) { | 3977 | for(uint i=0; i<journals.count(); ++i) { |
3978 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3978 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3979 | journals.at(i)->recreate(); | 3979 | journals.at(i)->recreate(); |
3980 | journals.at(i)->setReadOnly(false); | 3980 | journals.at(i)->setReadOnly(false); |
3981 | } | 3981 | } |
3982 | 3982 | ||
3983 | updateView(); | 3983 | updateView(); |
3984 | } | 3984 | } |
3985 | 3985 | ||
3986 | void CalendarView::showIntro() | 3986 | void CalendarView::showIntro() |
3987 | { | 3987 | { |
3988 | kdDebug() << "To be implemented." << endl; | 3988 | kdDebug() << "To be implemented." << endl; |
3989 | } | 3989 | } |
3990 | 3990 | ||
3991 | QWidgetStack *CalendarView::viewStack() | 3991 | QWidgetStack *CalendarView::viewStack() |
3992 | { | 3992 | { |
3993 | return mRightFrame; | 3993 | return mRightFrame; |
3994 | } | 3994 | } |
3995 | 3995 | ||
3996 | QWidget *CalendarView::leftFrame() | 3996 | QWidget *CalendarView::leftFrame() |
3997 | { | 3997 | { |
3998 | return ( QWidget *)mLeftFrame; | 3998 | return ( QWidget *)mLeftFrame; |
3999 | } | 3999 | } |
4000 | 4000 | ||
4001 | DateNavigator *CalendarView::dateNavigator() | 4001 | DateNavigator *CalendarView::dateNavigator() |
4002 | { | 4002 | { |
4003 | return mNavigator; | 4003 | return mNavigator; |
4004 | } | 4004 | } |
4005 | 4005 | ||
4006 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4006 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4007 | { | 4007 | { |
4008 | return mDateNavigator->navigatorView(); | 4008 | return mDateNavigator->navigatorView(); |
4009 | } | 4009 | } |
4010 | void CalendarView::toggleDateNavigatorWidget() | 4010 | void CalendarView::toggleDateNavigatorWidget() |
4011 | { | 4011 | { |
4012 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4012 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4013 | 4013 | ||
4014 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4014 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4015 | mDateNavigator->hide(); | 4015 | mDateNavigator->hide(); |
4016 | else | 4016 | else |
4017 | mDateNavigator->show(); | 4017 | mDateNavigator->show(); |
4018 | } | 4018 | } |
4019 | void CalendarView::addView(KOrg::BaseView *view) | 4019 | void CalendarView::addView(KOrg::BaseView *view) |
4020 | { | 4020 | { |
4021 | mViewManager->addView(view); | 4021 | mViewManager->addView(view); |
4022 | } | 4022 | } |
4023 | 4023 | ||
4024 | void CalendarView::showView(KOrg::BaseView *view) | 4024 | void CalendarView::showView(KOrg::BaseView *view) |
4025 | { | 4025 | { |
4026 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4026 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4027 | } | 4027 | } |
4028 | 4028 | ||
4029 | Incidence *CalendarView::currentSelection() | 4029 | Incidence *CalendarView::currentSelection() |
4030 | { | 4030 | { |
4031 | return mViewManager->currentSelection(); | 4031 | return mViewManager->currentSelection(); |
4032 | } | 4032 | } |
4033 | void CalendarView::toggleAllDaySize() | 4033 | void CalendarView::toggleAllDaySize() |
4034 | { | 4034 | { |
4035 | /* | 4035 | /* |
4036 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4036 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4037 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4037 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4038 | else | 4038 | else |
4039 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4039 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4040 | */ | 4040 | */ |
4041 | viewManager()->agendaView()->toggleAllDay(); | 4041 | viewManager()->agendaView()->toggleAllDay(); |
4042 | } | 4042 | } |
4043 | void CalendarView::toggleExpand() | 4043 | void CalendarView::toggleExpand() |
4044 | { | 4044 | { |
4045 | // if ( mLeftFrame->isHidden() ) { | 4045 | // if ( mLeftFrame->isHidden() ) { |
4046 | // mLeftFrame->show(); | 4046 | // mLeftFrame->show(); |
4047 | // emit calendarViewExpanded( false ); | 4047 | // emit calendarViewExpanded( false ); |
4048 | // } else { | 4048 | // } else { |
4049 | // mLeftFrame->hide(); | 4049 | // mLeftFrame->hide(); |
4050 | // emit calendarViewExpanded( true ); | 4050 | // emit calendarViewExpanded( true ); |
4051 | // } | 4051 | // } |
4052 | //qDebug(" CalendarView::toggleExpand()"); | 4052 | //qDebug(" CalendarView::toggleExpand()"); |
4053 | globalFlagBlockAgenda = 1; | 4053 | globalFlagBlockAgenda = 1; |
4054 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4054 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4055 | globalFlagBlockAgenda = 5; | 4055 | globalFlagBlockAgenda = 5; |
4056 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4056 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4057 | //mViewManager->showView( 0, true ); | 4057 | //mViewManager->showView( 0, true ); |
4058 | } | 4058 | } |
4059 | 4059 | ||
4060 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4060 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4061 | { | 4061 | { |
4062 | setModified( modified ); | 4062 | setModified( modified ); |
4063 | } | 4063 | } |
4064 | 4064 | ||
4065 | Todo *CalendarView::selectedTodo() | 4065 | Todo *CalendarView::selectedTodo() |
4066 | { | 4066 | { |
4067 | Incidence *incidence = currentSelection(); | 4067 | Incidence *incidence = currentSelection(); |
4068 | if ( incidence && incidence->type() == "Todo" ) { | 4068 | if ( incidence && incidence->typeID() == todoID ) { |
4069 | return static_cast<Todo *>( incidence ); | 4069 | return static_cast<Todo *>( incidence ); |
4070 | } | 4070 | } |
4071 | 4071 | ||
4072 | incidence = mTodoList->selectedIncidences().first(); | 4072 | incidence = mTodoList->selectedIncidences().first(); |
4073 | if ( incidence && incidence->type() == "Todo" ) { | 4073 | if ( incidence && incidence->typeID() == todoID ) { |
4074 | return static_cast<Todo *>( incidence ); | 4074 | return static_cast<Todo *>( incidence ); |
4075 | } | 4075 | } |
4076 | 4076 | ||
4077 | return 0; | 4077 | return 0; |
4078 | } | 4078 | } |
4079 | 4079 | ||
4080 | void CalendarView::dialogClosing(Incidence *in) | 4080 | void CalendarView::dialogClosing(Incidence *in) |
4081 | { | 4081 | { |
4082 | // mDialogList.remove(in); | 4082 | // mDialogList.remove(in); |
4083 | } | 4083 | } |
4084 | 4084 | ||
4085 | void CalendarView::showIncidence() | 4085 | void CalendarView::showIncidence() |
4086 | { | 4086 | { |
4087 | mViewerCallerIsSearchDialog = false; | 4087 | mViewerCallerIsSearchDialog = false; |
4088 | Incidence *incidence = currentSelection(); | 4088 | Incidence *incidence = currentSelection(); |
4089 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4089 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4090 | if ( incidence ) { | 4090 | if ( incidence ) { |
4091 | ShowIncidenceVisitor v; | 4091 | ShowIncidenceVisitor v; |
4092 | v.act( incidence, this ); | 4092 | v.act( incidence, this ); |
4093 | } | 4093 | } |
4094 | } | 4094 | } |
4095 | void CalendarView::editIncidenceDescription() | 4095 | void CalendarView::editIncidenceDescription() |
4096 | { | 4096 | { |
4097 | mFlagEditDescription = true; | 4097 | mFlagEditDescription = true; |
4098 | editIncidence(); | 4098 | editIncidence(); |
4099 | mFlagEditDescription = false; | 4099 | mFlagEditDescription = false; |
4100 | } | 4100 | } |
4101 | void CalendarView::editIncidence() | 4101 | void CalendarView::editIncidence() |
4102 | { | 4102 | { |
4103 | // qDebug("editIncidence() "); | 4103 | // qDebug("editIncidence() "); |
4104 | Incidence *incidence = currentSelection(); | 4104 | Incidence *incidence = currentSelection(); |
4105 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4105 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4106 | if ( incidence ) { | 4106 | if ( incidence ) { |
4107 | EditIncidenceVisitor v; | 4107 | EditIncidenceVisitor v; |
4108 | v.act( incidence, this ); | 4108 | v.act( incidence, this ); |
4109 | } | 4109 | } |
4110 | } | 4110 | } |
4111 | 4111 | ||
4112 | void CalendarView::deleteIncidence() | 4112 | void CalendarView::deleteIncidence() |
4113 | { | 4113 | { |
4114 | Incidence *incidence = currentSelection(); | 4114 | Incidence *incidence = currentSelection(); |
4115 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4115 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4116 | if ( incidence ) { | 4116 | if ( incidence ) { |
4117 | deleteIncidence(incidence); | 4117 | deleteIncidence(incidence); |
4118 | } | 4118 | } |
4119 | } | 4119 | } |
4120 | void CalendarView::showIncidence(QString uid) | 4120 | void CalendarView::showIncidence(QString uid) |
4121 | { | 4121 | { |
4122 | Incidence *inc = mCalendar->incidence( uid ); | 4122 | Incidence *inc = mCalendar->incidence( uid ); |
4123 | if ( inc ) | 4123 | if ( inc ) |
4124 | showIncidence( inc ); | 4124 | showIncidence( inc ); |
4125 | } | 4125 | } |
4126 | void CalendarView::showIncidence(Incidence *incidence) | 4126 | void CalendarView::showIncidence(Incidence *incidence) |
4127 | { | 4127 | { |
4128 | mViewerCallerIsSearchDialog = false; | 4128 | mViewerCallerIsSearchDialog = false; |
4129 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4129 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4130 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4130 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4131 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4131 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4132 | mViewerCallerIsSearchDialog = true; | 4132 | mViewerCallerIsSearchDialog = true; |
4133 | } | 4133 | } |
4134 | } | 4134 | } |
4135 | if ( incidence ) { | 4135 | if ( incidence ) { |
4136 | ShowIncidenceVisitor v; | 4136 | ShowIncidenceVisitor v; |
4137 | v.act( incidence, this ); | 4137 | v.act( incidence, this ); |
4138 | } | 4138 | } |
4139 | } | 4139 | } |
4140 | 4140 | ||
4141 | void CalendarView::editIncidence(Incidence *incidence) | 4141 | void CalendarView::editIncidence(Incidence *incidence) |
4142 | { | 4142 | { |
4143 | if ( incidence ) { | 4143 | if ( incidence ) { |
4144 | 4144 | ||
4145 | EditIncidenceVisitor v; | 4145 | EditIncidenceVisitor v; |
4146 | v.act( incidence, this ); | 4146 | v.act( incidence, this ); |
4147 | 4147 | ||
4148 | } | 4148 | } |
4149 | } | 4149 | } |
4150 | 4150 | ||
4151 | void CalendarView::deleteIncidence(Incidence *incidence) | 4151 | void CalendarView::deleteIncidence(Incidence *incidence) |
4152 | { | 4152 | { |
4153 | //qDebug(" CalendarView::deleteIncidence "); | 4153 | //qDebug(" CalendarView::deleteIncidence "); |
4154 | if ( incidence ) { | 4154 | if ( incidence ) { |
4155 | DeleteIncidenceVisitor v; | 4155 | DeleteIncidenceVisitor v; |
4156 | v.act( incidence, this ); | 4156 | v.act( incidence, this ); |
4157 | } | 4157 | } |
4158 | } | 4158 | } |
4159 | 4159 | ||
4160 | 4160 | ||
4161 | void CalendarView::lookForOutgoingMessages() | 4161 | void CalendarView::lookForOutgoingMessages() |
4162 | { | 4162 | { |
4163 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4163 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4164 | ogd->loadMessages(); | 4164 | ogd->loadMessages(); |
4165 | } | 4165 | } |
4166 | 4166 | ||
4167 | void CalendarView::lookForIncomingMessages() | 4167 | void CalendarView::lookForIncomingMessages() |
4168 | { | 4168 | { |
4169 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4169 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4170 | icd->retrieve(); | 4170 | icd->retrieve(); |
4171 | } | 4171 | } |
4172 | 4172 | ||
4173 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4173 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4174 | { | 4174 | { |
4175 | bool deleteTodo = true; | 4175 | bool deleteTodo = true; |
4176 | QPtrList<Incidence> subTodos; | 4176 | QPtrList<Incidence> subTodos; |
4177 | Incidence *aTodo; | 4177 | Incidence *aTodo; |
4178 | subTodos = t->relations(); | 4178 | subTodos = t->relations(); |
4179 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4179 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4180 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4180 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4181 | deleteTodo = false; | 4181 | deleteTodo = false; |
4182 | } | 4182 | } |
4183 | if ( deleteTodo ) { | 4183 | if ( deleteTodo ) { |
4184 | if ( t->isCompleted() && !t->doesRecur()) { | 4184 | if ( t->isCompleted() && !t->doesRecur()) { |
4185 | checkExternalId( t ); | 4185 | checkExternalId( t ); |
4186 | mCalendar->deleteTodo( t ); | 4186 | mCalendar->deleteTodo( t ); |
4187 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4187 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4188 | } | 4188 | } |
4189 | else | 4189 | else |
4190 | deleteTodo = false; | 4190 | deleteTodo = false; |
4191 | } | 4191 | } |
4192 | return deleteTodo; | 4192 | return deleteTodo; |
4193 | 4193 | ||
4194 | } | 4194 | } |
4195 | void CalendarView::purgeCompleted() | 4195 | void CalendarView::purgeCompleted() |
4196 | { | 4196 | { |
4197 | int result = KMessageBox::warningContinueCancel(this, | 4197 | int result = KMessageBox::warningContinueCancel(this, |
4198 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4198 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4199 | 4199 | ||
4200 | if (result == KMessageBox::Continue) { | 4200 | if (result == KMessageBox::Continue) { |
4201 | 4201 | ||
4202 | QPtrList<Todo> todoCal; | 4202 | QPtrList<Todo> todoCal; |
4203 | QPtrList<Todo> rootTodos; | 4203 | QPtrList<Todo> rootTodos; |
4204 | //QPtrList<Incidence> rel; | 4204 | //QPtrList<Incidence> rel; |
4205 | Todo *aTodo;//, *rTodo; | 4205 | Todo *aTodo;//, *rTodo; |
4206 | Incidence *rIncidence; | 4206 | Incidence *rIncidence; |
4207 | bool childDelete = false; | 4207 | bool childDelete = false; |
4208 | bool deletedOne = true; | 4208 | bool deletedOne = true; |
4209 | todoCal = calendar()->todos(); | 4209 | todoCal = calendar()->todos(); |
4210 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4210 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4211 | if ( !aTodo->relatedTo() ) | 4211 | if ( !aTodo->relatedTo() ) |
4212 | rootTodos.append( aTodo ); | 4212 | rootTodos.append( aTodo ); |
4213 | } | 4213 | } |
4214 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4214 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4215 | removeCompletedSubTodos( aTodo ); | 4215 | removeCompletedSubTodos( aTodo ); |
4216 | } | 4216 | } |
4217 | 4217 | ||
4218 | updateView(); | 4218 | updateView(); |
4219 | } | 4219 | } |
4220 | } | 4220 | } |
4221 | 4221 | ||
4222 | void CalendarView::slotCalendarChanged() | 4222 | void CalendarView::slotCalendarChanged() |
4223 | { | 4223 | { |
4224 | ; | 4224 | ; |
4225 | } | 4225 | } |
4226 | 4226 | ||
4227 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4227 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4228 | { | 4228 | { |
4229 | //qDebug(" alendarView::keyPressEvent "); | 4229 | //qDebug(" alendarView::keyPressEvent "); |
4230 | e->ignore(); | 4230 | e->ignore(); |
4231 | } | 4231 | } |
4232 | 4232 | ||
4233 | 4233 | ||
4234 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4234 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4235 | { | 4235 | { |
4236 | // mSyncManager = manager; | 4236 | // mSyncManager = manager; |
4237 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4237 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4238 | qDebug("KO: SyncKDE request detected!"); | 4238 | qDebug("KO: SyncKDE request detected!"); |
4239 | } | 4239 | } |
4240 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4240 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4241 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4241 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4242 | return syncCalendar( filename, mode ); | 4242 | return syncCalendar( filename, mode ); |
4243 | } | 4243 | } |
4244 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4244 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4245 | { | 4245 | { |
4246 | //mSyncManager = manager; | 4246 | //mSyncManager = manager; |
4247 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4247 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4248 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4248 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4249 | if ( resource == "sharp" ) | 4249 | if ( resource == "sharp" ) |
4250 | syncExternal( 0 ); | 4250 | syncExternal( 0 ); |
4251 | if ( resource == "phone" ) | 4251 | if ( resource == "phone" ) |
4252 | syncExternal( 1 ); | 4252 | syncExternal( 1 ); |
4253 | // pending setmodified | 4253 | // pending setmodified |
4254 | return true; | 4254 | return true; |
4255 | } | 4255 | } |
4256 | void CalendarView::setSyncManager(KSyncManager* manager) | 4256 | void CalendarView::setSyncManager(KSyncManager* manager) |
4257 | { | 4257 | { |
4258 | mSyncManager = manager; | 4258 | mSyncManager = manager; |
4259 | } | 4259 | } |
4260 | 4260 | ||
4261 | void CalendarView::removeSyncInfo( QString syncProfile) | 4261 | void CalendarView::removeSyncInfo( QString syncProfile) |
4262 | { | 4262 | { |
4263 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4263 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4264 | mCalendar->removeSyncInfo( syncProfile ); | 4264 | mCalendar->removeSyncInfo( syncProfile ); |
4265 | 4265 | ||
4266 | } | 4266 | } |
4267 | 4267 | ||
4268 | void CalendarView::undo_delete() | 4268 | void CalendarView::undo_delete() |
4269 | { | 4269 | { |
4270 | //qDebug("undo_delete() "); | 4270 | //qDebug("undo_delete() "); |
4271 | Incidence* undo = mCalendar->undoIncidence(); | 4271 | Incidence* undo = mCalendar->undoIncidence(); |
4272 | if ( !undo ) { | 4272 | if ( !undo ) { |
4273 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4273 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4274 | i18n("KO/Pi")); | 4274 | i18n("KO/Pi")); |
4275 | return; | 4275 | return; |
4276 | } | 4276 | } |
4277 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4277 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4278 | i18n("\nAre you sure you want\nto restore this?"), | 4278 | i18n("\nAre you sure you want\nto restore this?"), |
4279 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4279 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4280 | mCalendar->undoDeleteIncidence(); | 4280 | mCalendar->undoDeleteIncidence(); |
4281 | updateView(); | 4281 | updateView(); |
4282 | } | 4282 | } |
4283 | } | 4283 | } |
4284 | 4284 | ||
4285 | void CalendarView::slotViewerClosed() | 4285 | void CalendarView::slotViewerClosed() |
4286 | { | 4286 | { |
4287 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4287 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4288 | } | 4288 | } |
4289 | 4289 | ||
4290 | void CalendarView::resetFocus() | 4290 | void CalendarView::resetFocus() |
4291 | { | 4291 | { |
4292 | if ( mViewerCallerIsSearchDialog ) { | 4292 | if ( mViewerCallerIsSearchDialog ) { |
4293 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4293 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4294 | mDialogManager->getSearchDialog()->raise(); | 4294 | mDialogManager->getSearchDialog()->raise(); |
4295 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4295 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4296 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4296 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4297 | } else | 4297 | } else |
4298 | mViewerCallerIsSearchDialog = false; | 4298 | mViewerCallerIsSearchDialog = false; |
4299 | } | 4299 | } |
4300 | if ( !mViewerCallerIsSearchDialog ) { | 4300 | if ( !mViewerCallerIsSearchDialog ) { |
4301 | //mViewManager->currentView()->setFocus(); | 4301 | //mViewManager->currentView()->setFocus(); |
4302 | //qDebug("sssssssssssssssset focus "); | 4302 | //qDebug("sssssssssssssssset focus "); |
4303 | topLevelWidget()->raise(); | 4303 | topLevelWidget()->raise(); |
4304 | setActiveWindow(); | 4304 | setActiveWindow(); |
4305 | //setFocus(); | 4305 | //setFocus(); |
4306 | } | 4306 | } |
4307 | mViewerCallerIsSearchDialog = false; | 4307 | mViewerCallerIsSearchDialog = false; |
4308 | } | 4308 | } |
4309 | 4309 | ||
4310 | void CalendarView::showNextAlarms() | 4310 | void CalendarView::showNextAlarms() |
4311 | { | 4311 | { |
4312 | QString message; | 4312 | QString message; |
4313 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4313 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4314 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4314 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4315 | QString sum = mCalendar->nextSummary(); | 4315 | QString sum = mCalendar->nextSummary(); |
4316 | QDateTime nextA = mNextAlarmDateTime; | 4316 | QDateTime nextA = mNextAlarmDateTime; |
4317 | QDateTime cur = QDateTime::currentDateTime(); | 4317 | QDateTime cur = QDateTime::currentDateTime(); |
4318 | int secs = cur.secsTo( nextA ); | 4318 | int secs = cur.secsTo( nextA ); |
4319 | int min = secs /60; | 4319 | int min = secs /60; |
4320 | int hours = min /60; | 4320 | int hours = min /60; |
4321 | min = min % 60; | 4321 | min = min % 60; |
4322 | int days = hours /24; | 4322 | int days = hours /24; |
4323 | hours = hours % 24; | 4323 | hours = hours % 24; |
4324 | 4324 | ||
4325 | //message = i18n("The next alarm is in:\n"); | 4325 | //message = i18n("The next alarm is in:\n"); |
4326 | if ( days > 1 ) | 4326 | if ( days > 1 ) |
4327 | message += i18n("%1 days\n").arg( days ); | 4327 | message += i18n("%1 days\n").arg( days ); |
4328 | else if ( days == 1 ) | 4328 | else if ( days == 1 ) |
4329 | message += i18n("1 day\n"); | 4329 | message += i18n("1 day\n"); |
4330 | if ( hours > 1 ) | 4330 | if ( hours > 1 ) |
4331 | message += i18n("%1 hours\n").arg( hours ); | 4331 | message += i18n("%1 hours\n").arg( hours ); |
4332 | else if ( hours == 1 ) | 4332 | else if ( hours == 1 ) |
4333 | message += i18n("1 hour\n"); | 4333 | message += i18n("1 hour\n"); |
4334 | if ( min > 1 ) | 4334 | if ( min > 1 ) |
4335 | message += i18n("%1 minutes\n").arg( min ); | 4335 | message += i18n("%1 minutes\n").arg( min ); |
4336 | else if ( min == 1 ) | 4336 | else if ( min == 1 ) |
4337 | message += i18n("1 minute\n"); | 4337 | message += i18n("1 minute\n"); |
4338 | if ( message.isEmpty() ) | 4338 | if ( message.isEmpty() ) |
4339 | message = i18n("The next alarm is in\nless than one minute!"); | 4339 | message = i18n("The next alarm is in\nless than one minute!"); |
4340 | else | 4340 | else |
4341 | message = i18n("The next alarm is in:\n") + message; | 4341 | message = i18n("The next alarm is in:\n") + message; |
4342 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4342 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4343 | } else { | 4343 | } else { |
4344 | message = i18n("There is no next alarm."); | 4344 | message = i18n("There is no next alarm."); |
4345 | 4345 | ||
4346 | } | 4346 | } |
4347 | #ifdef DESKTOP_VERSION | 4347 | #ifdef DESKTOP_VERSION |
4348 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4348 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4349 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4349 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4350 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4350 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4351 | } | 4351 | } |
4352 | 4352 | ||
4353 | #endif | 4353 | #endif |
4354 | KMessageBox::information( this, message); | 4354 | KMessageBox::information( this, message); |
4355 | } | 4355 | } |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 2a2acb1..fc213d8 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,2127 +1,2127 @@ | |||
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 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 66 | { |
67 | setLineWidth(0); | 67 | setLineWidth(0); |
68 | setMargin(0); | 68 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | mTimeBox = new QLabel(this); | 73 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
75 | QPalette pal = mTimeBox->palette(); | 75 | QPalette pal = mTimeBox->palette(); |
76 | pal.setColor(QColorGroup::Foreground, Qt::red); | 76 | pal.setColor(QColorGroup::Foreground, Qt::red); |
77 | mTimeBox->setPalette(pal); | 77 | mTimeBox->setPalette(pal); |
78 | //mTimeBox->setAutoMask(true); | 78 | //mTimeBox->setAutoMask(true); |
79 | 79 | ||
80 | agenda->addChild(mTimeBox); | 80 | agenda->addChild(mTimeBox); |
81 | 81 | ||
82 | oldToday = -1; | 82 | oldToday = -1; |
83 | } | 83 | } |
84 | 84 | ||
85 | MarcusBains::~MarcusBains() | 85 | MarcusBains::~MarcusBains() |
86 | { | 86 | { |
87 | delete minutes; | 87 | delete minutes; |
88 | } | 88 | } |
89 | 89 | ||
90 | int MarcusBains::todayColumn() | 90 | int MarcusBains::todayColumn() |
91 | { | 91 | { |
92 | QDate currentDate = QDate::currentDate(); | 92 | QDate currentDate = QDate::currentDate(); |
93 | 93 | ||
94 | DateList dateList = agenda->dateList(); | 94 | DateList dateList = agenda->dateList(); |
95 | DateList::ConstIterator it; | 95 | DateList::ConstIterator it; |
96 | int col = 0; | 96 | int col = 0; |
97 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 97 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
98 | if((*it) == currentDate) | 98 | if((*it) == currentDate) |
99 | return KOGlobals::self()->reverseLayout() ? | 99 | return KOGlobals::self()->reverseLayout() ? |
100 | agenda->columns() - 1 - col : col; | 100 | agenda->columns() - 1 - col : col; |
101 | ++col; | 101 | ++col; |
102 | } | 102 | } |
103 | 103 | ||
104 | return -1; | 104 | return -1; |
105 | } | 105 | } |
106 | void MarcusBains::updateLoc() | 106 | void MarcusBains::updateLoc() |
107 | { | 107 | { |
108 | updateLocation(); | 108 | updateLocation(); |
109 | } | 109 | } |
110 | void MarcusBains::updateLocation(bool recalculate) | 110 | void MarcusBains::updateLocation(bool recalculate) |
111 | { | 111 | { |
112 | 112 | ||
113 | QTime tim = QTime::currentTime(); | 113 | QTime tim = QTime::currentTime(); |
114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
115 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 115 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
116 | recalculate = true; | 116 | recalculate = true; |
117 | 117 | ||
118 | int mins = tim.hour()*60 + tim.minute(); | 118 | int mins = tim.hour()*60 + tim.minute(); |
119 | int minutesPerCell = 24 * 60 / agenda->rows(); | 119 | int minutesPerCell = 24 * 60 / agenda->rows(); |
120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
121 | int today = recalculate ? todayColumn() : oldToday; | 121 | int today = recalculate ? todayColumn() : oldToday; |
122 | int x = agenda->gridSpacingX()*today; | 122 | int x = agenda->gridSpacingX()*today; |
123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
124 | 124 | ||
125 | oldTime = tim; | 125 | oldTime = tim; |
126 | oldToday = today; | 126 | oldToday = today; |
127 | 127 | ||
128 | if(disabled || (today<0)) { | 128 | if(disabled || (today<0)) { |
129 | hide(); mTimeBox->hide(); | 129 | hide(); mTimeBox->hide(); |
130 | return; | 130 | return; |
131 | } else { | 131 | } else { |
132 | show(); mTimeBox->show(); | 132 | show(); mTimeBox->show(); |
133 | } | 133 | } |
134 | 134 | ||
135 | if(recalculate) | 135 | if(recalculate) |
136 | setFixedSize(agenda->gridSpacingX(),1); | 136 | setFixedSize(agenda->gridSpacingX(),1); |
137 | agenda->moveChild(this, x, y); | 137 | agenda->moveChild(this, x, y); |
138 | raise(); | 138 | raise(); |
139 | 139 | ||
140 | if(recalculate) | 140 | if(recalculate) |
141 | //mTimeBox->setFont(QFont("helvetica",10)); | 141 | //mTimeBox->setFont(QFont("helvetica",10)); |
142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
143 | 143 | ||
144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
145 | mTimeBox->adjustSize(); | 145 | mTimeBox->adjustSize(); |
146 | // the -2 below is there because there is a bug in this program | 146 | // the -2 below is there because there is a bug in this program |
147 | // somewhere, where the last column of this widget is a few pixels | 147 | // somewhere, where the last column of this widget is a few pixels |
148 | // narrower than the other columns. | 148 | // narrower than the other columns. |
149 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 149 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
150 | agenda->moveChild(mTimeBox, | 150 | agenda->moveChild(mTimeBox, |
151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
152 | y-mTimeBox->height()); | 152 | y-mTimeBox->height()); |
153 | 153 | ||
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | minutes->start(5000,true); | 156 | minutes->start(5000,true); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | //////////////////////////////////////////////////////////////////////////// | 160 | //////////////////////////////////////////////////////////////////////////// |
161 | 161 | ||
162 | 162 | ||
163 | /* | 163 | /* |
164 | Create an agenda widget with rows rows and columns columns. | 164 | Create an agenda widget with rows rows and columns columns. |
165 | */ | 165 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
167 | const char *name,WFlags f) : | 167 | const char *name,WFlags f) : |
168 | QScrollView(parent,name,f) | 168 | QScrollView(parent,name,f) |
169 | { | 169 | { |
170 | 170 | ||
171 | mAllAgendaPopup = 0; | 171 | mAllAgendaPopup = 0; |
172 | mColumns = columns; | 172 | mColumns = columns; |
173 | mRows = rows; | 173 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 174 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 175 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 178 | #endif |
179 | mHolidayMask = 0; | 179 | mHolidayMask = 0; |
180 | init(); | 180 | init(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 184 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 185 | all-day events. |
186 | */ | 186 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 188 | QScrollView(parent,name,f) |
189 | { | 189 | { |
190 | mAllAgendaPopup = 0; | 190 | mAllAgendaPopup = 0; |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mPopupTimer = new QTimer(this); | 225 | mPopupTimer = new QTimer(this); |
226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
227 | 227 | ||
228 | mNewItemPopup = new QPopupMenu( this ); | 228 | mNewItemPopup = new QPopupMenu( this ); |
229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
230 | QString pathString = ""; | 230 | QString pathString = ""; |
231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
232 | if ( QApplication::desktop()->width() < 480 ) | 232 | if ( QApplication::desktop()->width() < 480 ) |
233 | pathString += "icons16/"; | 233 | pathString += "icons16/"; |
234 | } else | 234 | } else |
235 | pathString += "iconsmini/"; | 235 | pathString += "iconsmini/"; |
236 | 236 | ||
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
239 | mNewItemPopup->insertSeparator ( ); | 239 | mNewItemPopup->insertSeparator ( ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
246 | #ifndef _WIN32_ | 246 | #ifndef _WIN32_ |
247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
248 | viewport()->setWFlags ( wflags); | 248 | viewport()->setWFlags ( wflags); |
249 | #endif | 249 | #endif |
250 | mGridSpacingX = 80; | 250 | mGridSpacingX = 80; |
251 | mResizeBorderWidth = 8; | 251 | mResizeBorderWidth = 8; |
252 | mScrollBorderWidth = 8; | 252 | mScrollBorderWidth = 8; |
253 | mScrollDelay = 30; | 253 | mScrollDelay = 30; |
254 | mScrollOffset = 10; | 254 | mScrollOffset = 10; |
255 | mPaintPixmap.resize( 20,20); | 255 | mPaintPixmap.resize( 20,20); |
256 | //enableClipper(true); | 256 | //enableClipper(true); |
257 | 257 | ||
258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
259 | // effect. Has to be fixed. | 259 | // effect. Has to be fixed. |
260 | setFocusPolicy(WheelFocus); | 260 | setFocusPolicy(WheelFocus); |
261 | 261 | ||
262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
265 | 265 | ||
266 | mStartCellX = 0; | 266 | mStartCellX = 0; |
267 | mStartCellY = 0; | 267 | mStartCellY = 0; |
268 | mCurrentCellX = 0; | 268 | mCurrentCellX = 0; |
269 | mCurrentCellY = 0; | 269 | mCurrentCellY = 0; |
270 | 270 | ||
271 | mSelectionCellX = 0; | 271 | mSelectionCellX = 0; |
272 | mSelectionYTop = 0; | 272 | mSelectionYTop = 0; |
273 | mSelectionHeight = 0; | 273 | mSelectionHeight = 0; |
274 | 274 | ||
275 | mOldLowerScrollValue = -1; | 275 | mOldLowerScrollValue = -1; |
276 | mOldUpperScrollValue = -1; | 276 | mOldUpperScrollValue = -1; |
277 | 277 | ||
278 | mClickedItem = 0; | 278 | mClickedItem = 0; |
279 | 279 | ||
280 | mActionItem = 0; | 280 | mActionItem = 0; |
281 | mActionType = NOP; | 281 | mActionType = NOP; |
282 | mItemMoved = false; | 282 | mItemMoved = false; |
283 | 283 | ||
284 | mSelectedItem = 0; | 284 | mSelectedItem = 0; |
285 | 285 | ||
286 | // mItems.setAutoDelete(true); | 286 | // mItems.setAutoDelete(true); |
287 | 287 | ||
288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
289 | 289 | ||
290 | viewport()->update(); | 290 | viewport()->update(); |
291 | 291 | ||
292 | setMinimumSize(30, 1); | 292 | setMinimumSize(30, 1); |
293 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 293 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
294 | 294 | ||
295 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 295 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
296 | // controlled in a way that the contents horizontally always fits. Then it is | 296 | // controlled in a way that the contents horizontally always fits. Then it is |
297 | // not necessary to turn off the scrollbar. | 297 | // not necessary to turn off the scrollbar. |
298 | setHScrollBarMode(AlwaysOff); | 298 | setHScrollBarMode(AlwaysOff); |
299 | if ( ! mAllDayMode ) | 299 | if ( ! mAllDayMode ) |
300 | setVScrollBarMode(AlwaysOn); | 300 | setVScrollBarMode(AlwaysOn); |
301 | else | 301 | else |
302 | setVScrollBarMode(AlwaysOff); | 302 | setVScrollBarMode(AlwaysOff); |
303 | 303 | ||
304 | setStartHour(KOPrefs::instance()->mDayBegins); | 304 | setStartHour(KOPrefs::instance()->mDayBegins); |
305 | 305 | ||
306 | calculateWorkingHours(); | 306 | calculateWorkingHours(); |
307 | 307 | ||
308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
309 | SLOT(checkScrollBoundaries(int))); | 309 | SLOT(checkScrollBoundaries(int))); |
310 | 310 | ||
311 | // Create the Marcus Bains line. | 311 | // Create the Marcus Bains line. |
312 | if(mAllDayMode) | 312 | if(mAllDayMode) |
313 | mMarcusBains = 0; | 313 | mMarcusBains = 0; |
314 | else { | 314 | else { |
315 | mMarcusBains = new MarcusBains(this); | 315 | mMarcusBains = new MarcusBains(this); |
316 | addChild(mMarcusBains); | 316 | addChild(mMarcusBains); |
317 | } | 317 | } |
318 | mPopupKind = 0; | 318 | mPopupKind = 0; |
319 | mPopupItem = 0; | 319 | mPopupItem = 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | void KOAgenda::clear() | 322 | void KOAgenda::clear() |
323 | { | 323 | { |
324 | KOAgendaItem *item; | 324 | KOAgendaItem *item; |
325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
326 | mUnusedItems.append( item ); | 326 | mUnusedItems.append( item ); |
327 | //item->hide(); | 327 | //item->hide(); |
328 | } | 328 | } |
329 | mItems.clear(); | 329 | mItems.clear(); |
330 | mSelectedItem = 0; | 330 | mSelectedItem = 0; |
331 | clearSelection(); | 331 | clearSelection(); |
332 | } | 332 | } |
333 | 333 | ||
334 | void KOAgenda::clearSelection() | 334 | void KOAgenda::clearSelection() |
335 | { | 335 | { |
336 | mSelectionCellX = 0; | 336 | mSelectionCellX = 0; |
337 | mSelectionYTop = 0; | 337 | mSelectionYTop = 0; |
338 | mSelectionHeight = 0; | 338 | mSelectionHeight = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOAgenda::marcus_bains() | 341 | void KOAgenda::marcus_bains() |
342 | { | 342 | { |
343 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 343 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void KOAgenda::changeColumns(int columns) | 347 | void KOAgenda::changeColumns(int columns) |
348 | { | 348 | { |
349 | if (columns == 0) { | 349 | if (columns == 0) { |
350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | clear(); | 353 | clear(); |
354 | mColumns = columns; | 354 | mColumns = columns; |
355 | computeSizes(); | 355 | computeSizes(); |
356 | } | 356 | } |
357 | 357 | ||
358 | /* | 358 | /* |
359 | This is the eventFilter function, which gets all events from the KOAgendaItems | 359 | This is the eventFilter function, which gets all events from the KOAgendaItems |
360 | contained in the agenda. It has to handle moving and resizing for all items. | 360 | contained in the agenda. It has to handle moving and resizing for all items. |
361 | */ | 361 | */ |
362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
363 | { | 363 | { |
364 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 364 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
365 | switch(event->type()) { | 365 | switch(event->type()) { |
366 | case QEvent::MouseButtonPress: | 366 | case QEvent::MouseButtonPress: |
367 | case QEvent::MouseButtonDblClick: | 367 | case QEvent::MouseButtonDblClick: |
368 | case QEvent::MouseButtonRelease: | 368 | case QEvent::MouseButtonRelease: |
369 | case QEvent::MouseMove: | 369 | case QEvent::MouseMove: |
370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
371 | 371 | ||
372 | case (QEvent::Leave): | 372 | case (QEvent::Leave): |
373 | if (!mActionItem) | 373 | if (!mActionItem) |
374 | setCursor(arrowCursor); | 374 | setCursor(arrowCursor); |
375 | return true; | 375 | return true; |
376 | 376 | ||
377 | default: | 377 | default: |
378 | return QScrollView::eventFilter(object,event); | 378 | return QScrollView::eventFilter(object,event); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | void KOAgenda::popupMenu() | 381 | void KOAgenda::popupMenu() |
382 | { | 382 | { |
383 | mPopupTimer->stop(); | 383 | mPopupTimer->stop(); |
384 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 384 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
385 | if (mActionItem ) { | 385 | if (mActionItem ) { |
386 | endItemAction(); | 386 | endItemAction(); |
387 | } | 387 | } |
388 | mLeftMouseDown = false; // no more leftMouse computation | 388 | mLeftMouseDown = false; // no more leftMouse computation |
389 | if (mPopupItem) { | 389 | if (mPopupItem) { |
390 | //mClickedItem = mPopupItem; | 390 | //mClickedItem = mPopupItem; |
391 | selectItem(mPopupItem); | 391 | selectItem(mPopupItem); |
392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
393 | mAllAgendaPopup->installEventFilter( this ); | 393 | mAllAgendaPopup->installEventFilter( this ); |
394 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 394 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
395 | 395 | ||
396 | } | 396 | } |
397 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 397 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
399 | endSelectAction( false ); // do not emit new event signal | 399 | endSelectAction( false ); // do not emit new event signal |
400 | mLeftMouseDown = false; // no more leftMouse computation | 400 | mLeftMouseDown = false; // no more leftMouse computation |
401 | } | 401 | } |
402 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 402 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
403 | mNewItemPopup->installEventFilter( this ); | 403 | mNewItemPopup->installEventFilter( this ); |
404 | mNewItemPopup->popup( mPopupPos); | 404 | mNewItemPopup->popup( mPopupPos); |
405 | 405 | ||
406 | } | 406 | } |
407 | mLeftMouseDown = false; | 407 | mLeftMouseDown = false; |
408 | mPopupItem = 0; | 408 | mPopupItem = 0; |
409 | mPopupKind = 0; | 409 | mPopupKind = 0; |
410 | } | 410 | } |
411 | 411 | ||
412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
413 | { | 413 | { |
414 | static int startX = 0; | 414 | static int startX = 0; |
415 | static int startY = 0; | 415 | static int startY = 0; |
416 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 416 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
417 | static bool blockMoving = true; | 417 | static bool blockMoving = true; |
418 | 418 | ||
419 | //qDebug("KOAgenda::eventFilter_mous "); | 419 | //qDebug("KOAgenda::eventFilter_mous "); |
420 | if ( object == mNewItemPopup ) { | 420 | if ( object == mNewItemPopup ) { |
421 | //qDebug("mNewItemPopup "); | 421 | //qDebug("mNewItemPopup "); |
422 | if ( me->type() == QEvent::MouseButtonRelease ) { | 422 | if ( me->type() == QEvent::MouseButtonRelease ) { |
423 | mNewItemPopup->removeEventFilter( this ); | 423 | mNewItemPopup->removeEventFilter( this ); |
424 | int dX = me->globalPos().x() - mPopupPos.x();; | 424 | int dX = me->globalPos().x() - mPopupPos.x();; |
425 | if ( dX < 0 ) | 425 | if ( dX < 0 ) |
426 | dX = -dX; | 426 | dX = -dX; |
427 | int dY = me->globalPos().y() - mPopupPos.y(); | 427 | int dY = me->globalPos().y() - mPopupPos.y(); |
428 | if ( dY < 0 ) | 428 | if ( dY < 0 ) |
429 | dY = -dY; | 429 | dY = -dY; |
430 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 430 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
431 | mNewItemPopup->hide(); | 431 | mNewItemPopup->hide(); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | return true; | 434 | return true; |
435 | } | 435 | } |
436 | if ( object == mAllAgendaPopup ) { | 436 | if ( object == mAllAgendaPopup ) { |
437 | //qDebug(" mAllAgendaPopup "); | 437 | //qDebug(" mAllAgendaPopup "); |
438 | if ( me->type() == QEvent::MouseButtonRelease ) { | 438 | if ( me->type() == QEvent::MouseButtonRelease ) { |
439 | mAllAgendaPopup->removeEventFilter( this ); | 439 | mAllAgendaPopup->removeEventFilter( this ); |
440 | int dX = me->globalPos().x() - mPopupPos.x();; | 440 | int dX = me->globalPos().x() - mPopupPos.x();; |
441 | if ( dX < 0 ) | 441 | if ( dX < 0 ) |
442 | dX = -dX; | 442 | dX = -dX; |
443 | int dY = me->globalPos().y() - mPopupPos.y(); | 443 | int dY = me->globalPos().y() - mPopupPos.y(); |
444 | if ( dY < 0 ) | 444 | if ( dY < 0 ) |
445 | dY = -dY; | 445 | dY = -dY; |
446 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 446 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
447 | mAllAgendaPopup->hide(); | 447 | mAllAgendaPopup->hide(); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | return true; | 450 | return true; |
451 | } | 451 | } |
452 | QPoint viewportPos; | 452 | QPoint viewportPos; |
453 | if (object != viewport()) { | 453 | if (object != viewport()) { |
454 | blockmoveDist = blockmoveDist*2; | 454 | blockmoveDist = blockmoveDist*2; |
455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
456 | } else { | 456 | } else { |
457 | viewportPos = me->pos(); | 457 | viewportPos = me->pos(); |
458 | } | 458 | } |
459 | 459 | ||
460 | switch (me->type()) { | 460 | switch (me->type()) { |
461 | case QEvent::MouseButtonPress: | 461 | case QEvent::MouseButtonPress: |
462 | if (me->button() == LeftButton) { | 462 | if (me->button() == LeftButton) { |
463 | mPopupTimer->start( 600 ); | 463 | mPopupTimer->start( 600 ); |
464 | mLeftMouseDown = true; | 464 | mLeftMouseDown = true; |
465 | } | 465 | } |
466 | blockMoving = true; | 466 | blockMoving = true; |
467 | startX = viewportPos.x(); | 467 | startX = viewportPos.x(); |
468 | startY = viewportPos.y(); | 468 | startY = viewportPos.y(); |
469 | mPopupPos = me->globalPos(); | 469 | mPopupPos = me->globalPos(); |
470 | if (object != viewport()) { | 470 | if (object != viewport()) { |
471 | mPopupItem = (KOAgendaItem *)object; | 471 | mPopupItem = (KOAgendaItem *)object; |
472 | mPopupKind = 1; | 472 | mPopupKind = 1; |
473 | if (me->button() == RightButton) { | 473 | if (me->button() == RightButton) { |
474 | mPopupKind = 3; | 474 | mPopupKind = 3; |
475 | popupMenu(); | 475 | popupMenu(); |
476 | } else if (me->button() == LeftButton) { | 476 | } else if (me->button() == LeftButton) { |
477 | mActionItem = (KOAgendaItem *)object; | 477 | mActionItem = (KOAgendaItem *)object; |
478 | if (mActionItem) { | 478 | if (mActionItem) { |
479 | emit signalClearSelection(); | 479 | emit signalClearSelection(); |
480 | slotClearSelection(); | 480 | slotClearSelection(); |
481 | selectItem(mActionItem); | 481 | selectItem(mActionItem); |
482 | Incidence *incidence = mActionItem->incidence(); | 482 | Incidence *incidence = mActionItem->incidence(); |
483 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 483 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
484 | mActionItem = 0; | 484 | mActionItem = 0; |
485 | } else { | 485 | } else { |
486 | startItemAction(viewportPos); | 486 | startItemAction(viewportPos); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } else { // ---------- viewport() | 490 | } else { // ---------- viewport() |
491 | mPopupItem = 0; | 491 | mPopupItem = 0; |
492 | mPopupKind = 2; | 492 | mPopupKind = 2; |
493 | selectItem(0); | 493 | selectItem(0); |
494 | mActionItem = 0; | 494 | mActionItem = 0; |
495 | if (me->button() == RightButton) { | 495 | if (me->button() == RightButton) { |
496 | int x,y; | 496 | int x,y; |
497 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 497 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
498 | int gx,gy; | 498 | int gx,gy; |
499 | contentsToGrid(x,y,gx,gy); | 499 | contentsToGrid(x,y,gx,gy); |
500 | mCurrentCellX = gx; | 500 | mCurrentCellX = gx; |
501 | mCurrentCellY = gy; | 501 | mCurrentCellY = gy; |
502 | mStartCellX = gx; | 502 | mStartCellX = gx; |
503 | mStartCellY = gy; | 503 | mStartCellY = gy; |
504 | mPopupKind = 4; | 504 | mPopupKind = 4; |
505 | popupMenu(); | 505 | popupMenu(); |
506 | } else if (me->button() == LeftButton) { | 506 | } else if (me->button() == LeftButton) { |
507 | setCursor(arrowCursor); | 507 | setCursor(arrowCursor); |
508 | startSelectAction(viewportPos); | 508 | startSelectAction(viewportPos); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | break; | 511 | break; |
512 | 512 | ||
513 | case QEvent::MouseButtonRelease: | 513 | case QEvent::MouseButtonRelease: |
514 | if (me->button() == LeftButton ) { | 514 | if (me->button() == LeftButton ) { |
515 | mPopupTimer->stop(); | 515 | mPopupTimer->stop(); |
516 | } | 516 | } |
517 | if (object != viewport()) { | 517 | if (object != viewport()) { |
518 | if (me->button() == LeftButton && mLeftMouseDown) { | 518 | if (me->button() == LeftButton && mLeftMouseDown) { |
519 | if (mActionItem) { | 519 | if (mActionItem) { |
520 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 520 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
521 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 521 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
522 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 522 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
523 | mScrollUpTimer.stop(); | 523 | mScrollUpTimer.stop(); |
524 | mScrollDownTimer.stop(); | 524 | mScrollDownTimer.stop(); |
525 | mActionItem->resetMove(); | 525 | mActionItem->resetMove(); |
526 | placeSubCells( mActionItem ); | 526 | placeSubCells( mActionItem ); |
527 | // emit startDragSignal( mActionItem->incidence() ); | 527 | // emit startDragSignal( mActionItem->incidence() ); |
528 | setCursor( arrowCursor ); | 528 | setCursor( arrowCursor ); |
529 | mActionItem = 0; | 529 | mActionItem = 0; |
530 | mActionType = NOP; | 530 | mActionType = NOP; |
531 | mItemMoved = 0; | 531 | mItemMoved = 0; |
532 | mLeftMouseDown = false; | 532 | mLeftMouseDown = false; |
533 | return true; | 533 | return true; |
534 | } | 534 | } |
535 | endItemAction(); | 535 | endItemAction(); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | } else { // ---------- viewport() | 539 | } else { // ---------- viewport() |
540 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 540 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
541 | endSelectAction( true ); // emit new event signal | 541 | endSelectAction( true ); // emit new event signal |
542 | } | 542 | } |
543 | } | 543 | } |
544 | if (me->button() == LeftButton) | 544 | if (me->button() == LeftButton) |
545 | mLeftMouseDown = false; | 545 | mLeftMouseDown = false; |
546 | 546 | ||
547 | break; | 547 | break; |
548 | 548 | ||
549 | case QEvent::MouseMove: | 549 | case QEvent::MouseMove: |
550 | //qDebug("mm "); | 550 | //qDebug("mm "); |
551 | if ( !mLeftMouseDown ) | 551 | if ( !mLeftMouseDown ) |
552 | return false; | 552 | return false; |
553 | if ( blockMoving ) { | 553 | if ( blockMoving ) { |
554 | int dX, dY; | 554 | int dX, dY; |
555 | dX = startX - viewportPos.x(); | 555 | dX = startX - viewportPos.x(); |
556 | if ( dX < 0 ) | 556 | if ( dX < 0 ) |
557 | dX = -dX; | 557 | dX = -dX; |
558 | dY = viewportPos.y() - startY; | 558 | dY = viewportPos.y() - startY; |
559 | if ( dY < 0 ) | 559 | if ( dY < 0 ) |
560 | dY = -dY; | 560 | dY = -dY; |
561 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 561 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
562 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 562 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
563 | blockMoving = false; | 563 | blockMoving = false; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | if ( ! blockMoving ) | 566 | if ( ! blockMoving ) |
567 | mPopupTimer->stop(); | 567 | mPopupTimer->stop(); |
568 | if (object != viewport()) { | 568 | if (object != viewport()) { |
569 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 569 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
570 | if (!moveItem->incidence()->isReadOnly() ) { | 570 | if (!moveItem->incidence()->isReadOnly() ) { |
571 | if (!mActionItem) | 571 | if (!mActionItem) |
572 | setNoActionCursor(moveItem,viewportPos); | 572 | setNoActionCursor(moveItem,viewportPos); |
573 | else { | 573 | else { |
574 | if ( !blockMoving ) | 574 | if ( !blockMoving ) |
575 | performItemAction(viewportPos); | 575 | performItemAction(viewportPos); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | } else { // ---------- viewport() | 578 | } else { // ---------- viewport() |
579 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 579 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
580 | if ( mActionType == SELECT ) { | 580 | if ( mActionType == SELECT ) { |
581 | performSelectAction( viewportPos ); | 581 | performSelectAction( viewportPos ); |
582 | } | 582 | } |
583 | } | 583 | } |
584 | break; | 584 | break; |
585 | 585 | ||
586 | case QEvent::MouseButtonDblClick: | 586 | case QEvent::MouseButtonDblClick: |
587 | mPopupTimer->stop(); | 587 | mPopupTimer->stop(); |
588 | if (object == viewport()) { | 588 | if (object == viewport()) { |
589 | selectItem(0); | 589 | selectItem(0); |
590 | int x,y; | 590 | int x,y; |
591 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 591 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
592 | int gx,gy; | 592 | int gx,gy; |
593 | contentsToGrid(x,y,gx,gy); | 593 | contentsToGrid(x,y,gx,gy); |
594 | emit newEventSignal(gx,gy); | 594 | emit newEventSignal(gx,gy); |
595 | } else { | 595 | } else { |
596 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 596 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
597 | selectItem(doubleClickedItem); | 597 | selectItem(doubleClickedItem); |
598 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 598 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
599 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 599 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
600 | else | 600 | else |
601 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 601 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
602 | } | 602 | } |
603 | break; | 603 | break; |
604 | 604 | ||
605 | default: | 605 | default: |
606 | break; | 606 | break; |
607 | } | 607 | } |
608 | return true; | 608 | return true; |
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | void KOAgenda::newItem( int item ) | 612 | void KOAgenda::newItem( int item ) |
613 | { | 613 | { |
614 | if ( item == 1 ) { //new event | 614 | if ( item == 1 ) { //new event |
615 | newEventSignal(mStartCellX ,mStartCellY ); | 615 | newEventSignal(mStartCellX ,mStartCellY ); |
616 | } else | 616 | } else |
617 | if ( item == 2 ) { //new event | 617 | if ( item == 2 ) { //new event |
618 | newTodoSignal(mStartCellX ,mStartCellY ); | 618 | newTodoSignal(mStartCellX ,mStartCellY ); |
619 | } else | 619 | } else |
620 | { | 620 | { |
621 | emit showDateView( item, mStartCellX ); | 621 | emit showDateView( item, mStartCellX ); |
622 | // 3Day view | 622 | // 3Day view |
623 | // 4Week view | 623 | // 4Week view |
624 | // 5Month view | 624 | // 5Month view |
625 | // 6Journal view | 625 | // 6Journal view |
626 | } | 626 | } |
627 | } | 627 | } |
628 | void KOAgenda::slotClearSelection() | 628 | void KOAgenda::slotClearSelection() |
629 | { | 629 | { |
630 | if (mSelectionHeight) { | 630 | if (mSelectionHeight) { |
631 | int selectionX = mSelectionCellX * mGridSpacingX; | 631 | int selectionX = mSelectionCellX * mGridSpacingX; |
632 | int top = mSelectionYTop - 2 *mGridSpacingY; | 632 | int top = mSelectionYTop - 2 *mGridSpacingY; |
633 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 633 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
634 | clearSelection(); | 634 | clearSelection(); |
635 | repaintContents( selectionX, top, | 635 | repaintContents( selectionX, top, |
636 | mGridSpacingX, hei ,false ); | 636 | mGridSpacingX, hei ,false ); |
637 | } | 637 | } |
638 | 638 | ||
639 | } | 639 | } |
640 | void KOAgenda::startSelectAction(QPoint viewportPos) | 640 | void KOAgenda::startSelectAction(QPoint viewportPos) |
641 | { | 641 | { |
642 | 642 | ||
643 | emit signalClearSelection(); | 643 | emit signalClearSelection(); |
644 | slotClearSelection(); | 644 | slotClearSelection(); |
645 | 645 | ||
646 | mActionType = SELECT; | 646 | mActionType = SELECT; |
647 | 647 | ||
648 | int x,y; | 648 | int x,y; |
649 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 649 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
650 | int gx,gy; | 650 | int gx,gy; |
651 | contentsToGrid(x,y,gx,gy); | 651 | contentsToGrid(x,y,gx,gy); |
652 | 652 | ||
653 | mStartCellX = gx; | 653 | mStartCellX = gx; |
654 | mStartCellY = gy; | 654 | mStartCellY = gy; |
655 | mCurrentCellX = gx; | 655 | mCurrentCellX = gx; |
656 | mCurrentCellY = gy; | 656 | mCurrentCellY = gy; |
657 | 657 | ||
658 | // Store new selection | 658 | // Store new selection |
659 | mSelectionCellX = gx; | 659 | mSelectionCellX = gx; |
660 | mSelectionYTop = gy * mGridSpacingY; | 660 | mSelectionYTop = gy * mGridSpacingY; |
661 | mSelectionHeight = mGridSpacingY; | 661 | mSelectionHeight = mGridSpacingY; |
662 | 662 | ||
663 | // Paint new selection | 663 | // Paint new selection |
664 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 664 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
665 | mGridSpacingX-1, mSelectionHeight ); | 665 | mGridSpacingX-1, mSelectionHeight ); |
666 | } | 666 | } |
667 | 667 | ||
668 | void KOAgenda::performSelectAction(QPoint viewportPos) | 668 | void KOAgenda::performSelectAction(QPoint viewportPos) |
669 | { | 669 | { |
670 | int x,y; | 670 | int x,y; |
671 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 671 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
672 | int gx,gy; | 672 | int gx,gy; |
673 | contentsToGrid(x,y,gx,gy); | 673 | contentsToGrid(x,y,gx,gy); |
674 | 674 | ||
675 | QPoint clipperPos = clipper()-> | 675 | QPoint clipperPos = clipper()-> |
676 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 676 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
677 | 677 | ||
678 | // Scroll if cursor was moved to upper or lower end of agenda. | 678 | // Scroll if cursor was moved to upper or lower end of agenda. |
679 | if (clipperPos.y() < mScrollBorderWidth) { | 679 | if (clipperPos.y() < mScrollBorderWidth) { |
680 | mScrollUpTimer.start(mScrollDelay); | 680 | mScrollUpTimer.start(mScrollDelay); |
681 | } else if (visibleHeight() - clipperPos.y() < | 681 | } else if (visibleHeight() - clipperPos.y() < |
682 | mScrollBorderWidth) { | 682 | mScrollBorderWidth) { |
683 | mScrollDownTimer.start(mScrollDelay); | 683 | mScrollDownTimer.start(mScrollDelay); |
684 | } else { | 684 | } else { |
685 | mScrollUpTimer.stop(); | 685 | mScrollUpTimer.stop(); |
686 | mScrollDownTimer.stop(); | 686 | mScrollDownTimer.stop(); |
687 | } | 687 | } |
688 | 688 | ||
689 | if ( gy > mCurrentCellY ) { | 689 | if ( gy > mCurrentCellY ) { |
690 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 690 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
691 | 691 | ||
692 | 692 | ||
693 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 693 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
694 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 694 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
695 | mGridSpacingX, mSelectionYTop, | 695 | mGridSpacingX, mSelectionYTop, |
696 | mGridSpacingX, mSelectionHeight , false); | 696 | mGridSpacingX, mSelectionHeight , false); |
697 | 697 | ||
698 | mCurrentCellY = gy; | 698 | mCurrentCellY = gy; |
699 | } else if ( gy < mCurrentCellY ) { | 699 | } else if ( gy < mCurrentCellY ) { |
700 | if ( gy >= mStartCellY ) { | 700 | if ( gy >= mStartCellY ) { |
701 | int selectionHeight = mSelectionHeight; | 701 | int selectionHeight = mSelectionHeight; |
702 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 702 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
703 | 703 | ||
704 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 704 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
705 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 705 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
706 | mGridSpacingX, mSelectionYTop, | 706 | mGridSpacingX, mSelectionYTop, |
707 | mGridSpacingX, selectionHeight,false ); | 707 | mGridSpacingX, selectionHeight,false ); |
708 | 708 | ||
709 | mCurrentCellY = gy; | 709 | mCurrentCellY = gy; |
710 | } else { | 710 | } else { |
711 | } | 711 | } |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 715 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
716 | { | 716 | { |
717 | mActionType = NOP; | 717 | mActionType = NOP; |
718 | mScrollUpTimer.stop(); | 718 | mScrollUpTimer.stop(); |
719 | mScrollDownTimer.stop(); | 719 | mScrollDownTimer.stop(); |
720 | 720 | ||
721 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 721 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
722 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 722 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
723 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 723 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
724 | } | 724 | } |
725 | } | 725 | } |
726 | 726 | ||
727 | void KOAgenda::startItemAction(QPoint viewportPos) | 727 | void KOAgenda::startItemAction(QPoint viewportPos) |
728 | { | 728 | { |
729 | int x,y; | 729 | int x,y; |
730 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 730 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
731 | int gx,gy; | 731 | int gx,gy; |
732 | contentsToGrid(x,y,gx,gy); | 732 | contentsToGrid(x,y,gx,gy); |
733 | 733 | ||
734 | mStartCellX = gx; | 734 | mStartCellX = gx; |
735 | mStartCellY = gy; | 735 | mStartCellY = gy; |
736 | mCurrentCellX = gx; | 736 | mCurrentCellX = gx; |
737 | mCurrentCellY = gy; | 737 | mCurrentCellY = gy; |
738 | 738 | ||
739 | if (mAllDayMode) { | 739 | if (mAllDayMode) { |
740 | int gridDistanceX = (x - gx * mGridSpacingX); | 740 | int gridDistanceX = (x - gx * mGridSpacingX); |
741 | if (gridDistanceX < mResizeBorderWidth && | 741 | if (gridDistanceX < mResizeBorderWidth && |
742 | mActionItem->cellX() == mCurrentCellX) { | 742 | mActionItem->cellX() == mCurrentCellX) { |
743 | mActionType = RESIZELEFT; | 743 | mActionType = RESIZELEFT; |
744 | setCursor(sizeHorCursor); | 744 | setCursor(sizeHorCursor); |
745 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 745 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
746 | mActionItem->cellXWidth() == mCurrentCellX) { | 746 | mActionItem->cellXWidth() == mCurrentCellX) { |
747 | mActionType = RESIZERIGHT; | 747 | mActionType = RESIZERIGHT; |
748 | setCursor(sizeHorCursor); | 748 | setCursor(sizeHorCursor); |
749 | } else { | 749 | } else { |
750 | mActionType = MOVE; | 750 | mActionType = MOVE; |
751 | mActionItem->startMove(); | 751 | mActionItem->startMove(); |
752 | setCursor(sizeAllCursor); | 752 | setCursor(sizeAllCursor); |
753 | } | 753 | } |
754 | } else { | 754 | } else { |
755 | int gridDistanceY = (y - gy * mGridSpacingY); | 755 | int gridDistanceY = (y - gy * mGridSpacingY); |
756 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 756 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
757 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 757 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
758 | mActionItem->cellYTop() == mCurrentCellY && | 758 | mActionItem->cellYTop() == mCurrentCellY && |
759 | !mActionItem->firstMultiItem()) { | 759 | !mActionItem->firstMultiItem()) { |
760 | mActionType = RESIZETOP; | 760 | mActionType = RESIZETOP; |
761 | setCursor(sizeVerCursor); | 761 | setCursor(sizeVerCursor); |
762 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 762 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
763 | mActionItem->cellYBottom() == mCurrentCellY && | 763 | mActionItem->cellYBottom() == mCurrentCellY && |
764 | !mActionItem->lastMultiItem()) { | 764 | !mActionItem->lastMultiItem()) { |
765 | mActionType = RESIZEBOTTOM; | 765 | mActionType = RESIZEBOTTOM; |
766 | setCursor(sizeVerCursor); | 766 | setCursor(sizeVerCursor); |
767 | } else { | 767 | } else { |
768 | mActionType = MOVE; | 768 | mActionType = MOVE; |
769 | mActionItem->startMove(); | 769 | mActionItem->startMove(); |
770 | setCursor(sizeAllCursor); | 770 | setCursor(sizeAllCursor); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
775 | void KOAgenda::performItemAction(QPoint viewportPos) | 775 | void KOAgenda::performItemAction(QPoint viewportPos) |
776 | { | 776 | { |
777 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 777 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
778 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 778 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
779 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 779 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
780 | // point = clipper()->mapFromGlobal(point); | 780 | // point = clipper()->mapFromGlobal(point); |
781 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 781 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
782 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 782 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
783 | int x,y; | 783 | int x,y; |
784 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 784 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
785 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 785 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
786 | int gx,gy; | 786 | int gx,gy; |
787 | contentsToGrid(x,y,gx,gy); | 787 | contentsToGrid(x,y,gx,gy); |
788 | QPoint clipperPos = clipper()-> | 788 | QPoint clipperPos = clipper()-> |
789 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 789 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
790 | 790 | ||
791 | // Cursor left active agenda area. | 791 | // Cursor left active agenda area. |
792 | // This starts a drag. | 792 | // This starts a drag. |
793 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 793 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
794 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 794 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
795 | if ( mActionType == MOVE ) { | 795 | if ( mActionType == MOVE ) { |
796 | mScrollUpTimer.stop(); | 796 | mScrollUpTimer.stop(); |
797 | mScrollDownTimer.stop(); | 797 | mScrollDownTimer.stop(); |
798 | mActionItem->resetMove(); | 798 | mActionItem->resetMove(); |
799 | placeSubCells( mActionItem ); | 799 | placeSubCells( mActionItem ); |
800 | // emit startDragSignal( mActionItem->incidence() ); | 800 | // emit startDragSignal( mActionItem->incidence() ); |
801 | setCursor( arrowCursor ); | 801 | setCursor( arrowCursor ); |
802 | mActionItem = 0; | 802 | mActionItem = 0; |
803 | mActionType = NOP; | 803 | mActionType = NOP; |
804 | mItemMoved = 0; | 804 | mItemMoved = 0; |
805 | return; | 805 | return; |
806 | } | 806 | } |
807 | } else { | 807 | } else { |
808 | switch ( mActionType ) { | 808 | switch ( mActionType ) { |
809 | case MOVE: | 809 | case MOVE: |
810 | setCursor( sizeAllCursor ); | 810 | setCursor( sizeAllCursor ); |
811 | break; | 811 | break; |
812 | case RESIZETOP: | 812 | case RESIZETOP: |
813 | case RESIZEBOTTOM: | 813 | case RESIZEBOTTOM: |
814 | setCursor( sizeVerCursor ); | 814 | setCursor( sizeVerCursor ); |
815 | break; | 815 | break; |
816 | case RESIZELEFT: | 816 | case RESIZELEFT: |
817 | case RESIZERIGHT: | 817 | case RESIZERIGHT: |
818 | setCursor( sizeHorCursor ); | 818 | setCursor( sizeHorCursor ); |
819 | break; | 819 | break; |
820 | default: | 820 | default: |
821 | setCursor( arrowCursor ); | 821 | setCursor( arrowCursor ); |
822 | } | 822 | } |
823 | } | 823 | } |
824 | 824 | ||
825 | // Scroll if item was moved to upper or lower end of agenda. | 825 | // Scroll if item was moved to upper or lower end of agenda. |
826 | if (clipperPos.y() < mScrollBorderWidth) { | 826 | if (clipperPos.y() < mScrollBorderWidth) { |
827 | mScrollUpTimer.start(mScrollDelay); | 827 | mScrollUpTimer.start(mScrollDelay); |
828 | } else if (visibleHeight() - clipperPos.y() < | 828 | } else if (visibleHeight() - clipperPos.y() < |
829 | mScrollBorderWidth) { | 829 | mScrollBorderWidth) { |
830 | mScrollDownTimer.start(mScrollDelay); | 830 | mScrollDownTimer.start(mScrollDelay); |
831 | } else { | 831 | } else { |
832 | mScrollUpTimer.stop(); | 832 | mScrollUpTimer.stop(); |
833 | mScrollDownTimer.stop(); | 833 | mScrollDownTimer.stop(); |
834 | } | 834 | } |
835 | 835 | ||
836 | // Move or resize item if necessary | 836 | // Move or resize item if necessary |
837 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 837 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
838 | mItemMoved = true; | 838 | mItemMoved = true; |
839 | mActionItem->raise(); | 839 | mActionItem->raise(); |
840 | if (mActionType == MOVE) { | 840 | if (mActionType == MOVE) { |
841 | // Move all items belonging to a multi item | 841 | // Move all items belonging to a multi item |
842 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 842 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
843 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 843 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
844 | if (!moveItem) moveItem = mActionItem; | 844 | if (!moveItem) moveItem = mActionItem; |
845 | while (moveItem) { | 845 | while (moveItem) { |
846 | int dy; | 846 | int dy; |
847 | if (isMultiItem) dy = 0; | 847 | if (isMultiItem) dy = 0; |
848 | else dy = gy - mCurrentCellY; | 848 | else dy = gy - mCurrentCellY; |
849 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 849 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
850 | int x,y; | 850 | int x,y; |
851 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 851 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
852 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 852 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
853 | mGridSpacingY * moveItem->cellHeight()); | 853 | mGridSpacingY * moveItem->cellHeight()); |
854 | moveChild(moveItem,x,y); | 854 | moveChild(moveItem,x,y); |
855 | moveItem = moveItem->nextMultiItem(); | 855 | moveItem = moveItem->nextMultiItem(); |
856 | } | 856 | } |
857 | } else if (mActionType == RESIZETOP) { | 857 | } else if (mActionType == RESIZETOP) { |
858 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 858 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
859 | mActionItem->expandTop(gy - mCurrentCellY); | 859 | mActionItem->expandTop(gy - mCurrentCellY); |
860 | mActionItem->resize(mActionItem->width(), | 860 | mActionItem->resize(mActionItem->width(), |
861 | mGridSpacingY * mActionItem->cellHeight()); | 861 | mGridSpacingY * mActionItem->cellHeight()); |
862 | int x,y; | 862 | int x,y; |
863 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 863 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
864 | //moveChild(mActionItem,childX(mActionItem),y); | 864 | //moveChild(mActionItem,childX(mActionItem),y); |
865 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 865 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
866 | } | 866 | } |
867 | } else if (mActionType == RESIZEBOTTOM) { | 867 | } else if (mActionType == RESIZEBOTTOM) { |
868 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 868 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
869 | mActionItem->expandBottom(gy - mCurrentCellY); | 869 | mActionItem->expandBottom(gy - mCurrentCellY); |
870 | mActionItem->resize(mActionItem->width(), | 870 | mActionItem->resize(mActionItem->width(), |
871 | mGridSpacingY * mActionItem->cellHeight()); | 871 | mGridSpacingY * mActionItem->cellHeight()); |
872 | } | 872 | } |
873 | } else if (mActionType == RESIZELEFT) { | 873 | } else if (mActionType == RESIZELEFT) { |
874 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 874 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
875 | mActionItem->expandLeft(gx - mCurrentCellX); | 875 | mActionItem->expandLeft(gx - mCurrentCellX); |
876 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 876 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
877 | mActionItem->height()); | 877 | mActionItem->height()); |
878 | int x,y; | 878 | int x,y; |
879 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 879 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
880 | moveChild(mActionItem,x,childY(mActionItem)); | 880 | moveChild(mActionItem,x,childY(mActionItem)); |
881 | } | 881 | } |
882 | } else if (mActionType == RESIZERIGHT) { | 882 | } else if (mActionType == RESIZERIGHT) { |
883 | if (mCurrentCellX >= mActionItem->cellX()) { | 883 | if (mCurrentCellX >= mActionItem->cellX()) { |
884 | mActionItem->expandRight(gx - mCurrentCellX); | 884 | mActionItem->expandRight(gx - mCurrentCellX); |
885 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 885 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
886 | mActionItem->height()); | 886 | mActionItem->height()); |
887 | } | 887 | } |
888 | } | 888 | } |
889 | mCurrentCellX = gx; | 889 | mCurrentCellX = gx; |
890 | mCurrentCellY = gy; | 890 | mCurrentCellY = gy; |
891 | } | 891 | } |
892 | } | 892 | } |
893 | 893 | ||
894 | void KOAgenda::endItemAction() | 894 | void KOAgenda::endItemAction() |
895 | { | 895 | { |
896 | 896 | ||
897 | if ( mItemMoved ) { | 897 | if ( mItemMoved ) { |
898 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 898 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
899 | if ( !placeItem ) { | 899 | if ( !placeItem ) { |
900 | placeItem = mActionItem; | 900 | placeItem = mActionItem; |
901 | } | 901 | } |
902 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 902 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
903 | Incidence* oldInc = placeItem->incidence(); | 903 | Incidence* oldInc = placeItem->incidence(); |
904 | placeItem->recreateIncidence(); | 904 | placeItem->recreateIncidence(); |
905 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 905 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
906 | } | 906 | } |
907 | int type = mActionType; | 907 | int type = mActionType; |
908 | if ( mAllDayMode ) | 908 | if ( mAllDayMode ) |
909 | type = -1; | 909 | type = -1; |
910 | KOAgendaItem *modifiedItem = placeItem; | 910 | KOAgendaItem *modifiedItem = placeItem; |
911 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 911 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
912 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 912 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
913 | KOAgendaItem *item; | 913 | KOAgendaItem *item; |
914 | 914 | ||
915 | if ( placeItem->incidence()->type() == "Todo" ) { | 915 | if ( placeItem->incidence()->typeID() == todoID ) { |
916 | mSelectedItem = 0; | 916 | mSelectedItem = 0; |
917 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 917 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
918 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 918 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
919 | emit itemModified( modifiedItem, mActionType ); | 919 | emit itemModified( modifiedItem, mActionType ); |
920 | } | 920 | } |
921 | else { | 921 | else { |
922 | 922 | ||
923 | 923 | ||
924 | globalFlagBlockAgendaItemPaint = 1; | 924 | globalFlagBlockAgendaItemPaint = 1; |
925 | for ( item=oldconflictItems.first(); item != 0; | 925 | for ( item=oldconflictItems.first(); item != 0; |
926 | item=oldconflictItems.next() ) { | 926 | item=oldconflictItems.next() ) { |
927 | placeSubCells(item); | 927 | placeSubCells(item); |
928 | } | 928 | } |
929 | while ( placeItem ) { | 929 | while ( placeItem ) { |
930 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 930 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
931 | oldconflictItems = placeItem->conflictItems(); | 931 | oldconflictItems = placeItem->conflictItems(); |
932 | for ( item=oldconflictItems.first(); item != 0; | 932 | for ( item=oldconflictItems.first(); item != 0; |
933 | item=oldconflictItems.next() ) { | 933 | item=oldconflictItems.next() ) { |
934 | placeSubCells(item); | 934 | placeSubCells(item); |
935 | } | 935 | } |
936 | placeSubCells( placeItem ); | 936 | placeSubCells( placeItem ); |
937 | placeItem = placeItem->nextMultiItem(); | 937 | placeItem = placeItem->nextMultiItem(); |
938 | } | 938 | } |
939 | globalFlagBlockAgendaItemPaint = 0; | 939 | globalFlagBlockAgendaItemPaint = 0; |
940 | for ( item=oldconflictItems.first(); item != 0; | 940 | for ( item=oldconflictItems.first(); item != 0; |
941 | item=oldconflictItems.next() ) { | 941 | item=oldconflictItems.next() ) { |
942 | globalFlagBlockAgendaItemUpdate = 0; | 942 | globalFlagBlockAgendaItemUpdate = 0; |
943 | item->repaintMe(); | 943 | item->repaintMe(); |
944 | globalFlagBlockAgendaItemUpdate = 1; | 944 | globalFlagBlockAgendaItemUpdate = 1; |
945 | item->repaint( false ); | 945 | item->repaint( false ); |
946 | } | 946 | } |
947 | placeItem = modifiedItem; | 947 | placeItem = modifiedItem; |
948 | 948 | ||
949 | while ( placeItem ) { | 949 | while ( placeItem ) { |
950 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 950 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
951 | globalFlagBlockAgendaItemUpdate = 0; | 951 | globalFlagBlockAgendaItemUpdate = 0; |
952 | placeItem->repaintMe(); | 952 | placeItem->repaintMe(); |
953 | globalFlagBlockAgendaItemUpdate = 1; | 953 | globalFlagBlockAgendaItemUpdate = 1; |
954 | placeItem->repaint(false); | 954 | placeItem->repaint(false); |
955 | placeItem = placeItem->nextMultiItem(); | 955 | placeItem = placeItem->nextMultiItem(); |
956 | } | 956 | } |
957 | emit itemModified( modifiedItem, mActionType ); | 957 | emit itemModified( modifiedItem, mActionType ); |
958 | 958 | ||
959 | 959 | ||
960 | placeItem = modifiedItem; | 960 | placeItem = modifiedItem; |
961 | while ( placeItem ) { | 961 | while ( placeItem ) { |
962 | oldconflictItems = placeItem->conflictItems(); | 962 | oldconflictItems = placeItem->conflictItems(); |
963 | for ( item=oldconflictItems.first(); item != 0; | 963 | for ( item=oldconflictItems.first(); item != 0; |
964 | item=oldconflictItems.next() ) { | 964 | item=oldconflictItems.next() ) { |
965 | placeSubCells(item); | 965 | placeSubCells(item); |
966 | } | 966 | } |
967 | placeSubCells( placeItem ); | 967 | placeSubCells( placeItem ); |
968 | placeItem = placeItem->nextMultiItem(); | 968 | placeItem = placeItem->nextMultiItem(); |
969 | 969 | ||
970 | } | 970 | } |
971 | placeItem = modifiedItem; | 971 | placeItem = modifiedItem; |
972 | while ( placeItem ) { | 972 | while ( placeItem ) { |
973 | oldconflictItems = placeItem->conflictItems(); | 973 | oldconflictItems = placeItem->conflictItems(); |
974 | for ( item=oldconflictItems.first(); item != 0; | 974 | for ( item=oldconflictItems.first(); item != 0; |
975 | item=oldconflictItems.next() ) { | 975 | item=oldconflictItems.next() ) { |
976 | globalFlagBlockAgendaItemUpdate = 0; | 976 | globalFlagBlockAgendaItemUpdate = 0; |
977 | item->repaintMe(); | 977 | item->repaintMe(); |
978 | globalFlagBlockAgendaItemUpdate = 1; | 978 | globalFlagBlockAgendaItemUpdate = 1; |
979 | item->repaint(false); | 979 | item->repaint(false); |
980 | } | 980 | } |
981 | placeItem = placeItem->nextMultiItem(); | 981 | placeItem = placeItem->nextMultiItem(); |
982 | } | 982 | } |
983 | /* | 983 | /* |
984 | 984 | ||
985 | oldconflictItems = modifiedItem->conflictItems(); | 985 | oldconflictItems = modifiedItem->conflictItems(); |
986 | for ( item=oldconflictItems.first(); item != 0; | 986 | for ( item=oldconflictItems.first(); item != 0; |
987 | item=oldconflictItems.next() ) { | 987 | item=oldconflictItems.next() ) { |
988 | globalFlagBlockAgendaItemUpdate = 0; | 988 | globalFlagBlockAgendaItemUpdate = 0; |
989 | item->paintMe(false); | 989 | item->paintMe(false); |
990 | globalFlagBlockAgendaItemUpdate = 1; | 990 | globalFlagBlockAgendaItemUpdate = 1; |
991 | item->repaint(false); | 991 | item->repaint(false); |
992 | } | 992 | } |
993 | */ | 993 | */ |
994 | 994 | ||
995 | 995 | ||
996 | } | 996 | } |
997 | 997 | ||
998 | } | 998 | } |
999 | 999 | ||
1000 | mScrollUpTimer.stop(); | 1000 | mScrollUpTimer.stop(); |
1001 | mScrollDownTimer.stop(); | 1001 | mScrollDownTimer.stop(); |
1002 | setCursor( arrowCursor ); | 1002 | setCursor( arrowCursor ); |
1003 | mActionItem = 0; | 1003 | mActionItem = 0; |
1004 | mActionType = NOP; | 1004 | mActionType = NOP; |
1005 | mItemMoved = 0; | 1005 | mItemMoved = 0; |
1006 | 1006 | ||
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1009 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1010 | { | 1010 | { |
1011 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1011 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1012 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1012 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1013 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1013 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1014 | // point = clipper()->mapFromGlobal(point); | 1014 | // point = clipper()->mapFromGlobal(point); |
1015 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1015 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1016 | 1016 | ||
1017 | int x,y; | 1017 | int x,y; |
1018 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1018 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1019 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1019 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1020 | int gx,gy; | 1020 | int gx,gy; |
1021 | contentsToGrid(x,y,gx,gy); | 1021 | contentsToGrid(x,y,gx,gy); |
1022 | 1022 | ||
1023 | // Change cursor to resize cursor if appropriate | 1023 | // Change cursor to resize cursor if appropriate |
1024 | if (mAllDayMode) { | 1024 | if (mAllDayMode) { |
1025 | int gridDistanceX = (x - gx * mGridSpacingX); | 1025 | int gridDistanceX = (x - gx * mGridSpacingX); |
1026 | if (gridDistanceX < mResizeBorderWidth && | 1026 | if (gridDistanceX < mResizeBorderWidth && |
1027 | moveItem->cellX() == gx) { | 1027 | moveItem->cellX() == gx) { |
1028 | setCursor(sizeHorCursor); | 1028 | setCursor(sizeHorCursor); |
1029 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1029 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1030 | moveItem->cellXWidth() == gx) { | 1030 | moveItem->cellXWidth() == gx) { |
1031 | setCursor(sizeHorCursor); | 1031 | setCursor(sizeHorCursor); |
1032 | } else { | 1032 | } else { |
1033 | setCursor(arrowCursor); | 1033 | setCursor(arrowCursor); |
1034 | } | 1034 | } |
1035 | } else { | 1035 | } else { |
1036 | int gridDistanceY = (y - gy * mGridSpacingY); | 1036 | int gridDistanceY = (y - gy * mGridSpacingY); |
1037 | if (gridDistanceY < mResizeBorderWidth && | 1037 | if (gridDistanceY < mResizeBorderWidth && |
1038 | moveItem->cellYTop() == gy && | 1038 | moveItem->cellYTop() == gy && |
1039 | !moveItem->firstMultiItem()) { | 1039 | !moveItem->firstMultiItem()) { |
1040 | setCursor(sizeVerCursor); | 1040 | setCursor(sizeVerCursor); |
1041 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1041 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1042 | moveItem->cellYBottom() == gy && | 1042 | moveItem->cellYBottom() == gy && |
1043 | !moveItem->lastMultiItem()) { | 1043 | !moveItem->lastMultiItem()) { |
1044 | setCursor(sizeVerCursor); | 1044 | setCursor(sizeVerCursor); |
1045 | } else { | 1045 | } else { |
1046 | setCursor(arrowCursor); | 1046 | setCursor(arrowCursor); |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | 1051 | ||
1052 | /* | 1052 | /* |
1053 | Place item in cell and take care that multiple items using the same cell do | 1053 | Place item in cell and take care that multiple items using the same cell do |
1054 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1054 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1055 | it can get in all cases. | 1055 | it can get in all cases. |
1056 | At the moment the method has a bug: When an item is placed only the sub cell | 1056 | At the moment the method has a bug: When an item is placed only the sub cell |
1057 | widths of the items are changed, which are within the Y region the item to | 1057 | widths of the items are changed, which are within the Y region the item to |
1058 | place spans. When the sub cell width change of one of this items affects a | 1058 | place spans. When the sub cell width change of one of this items affects a |
1059 | cell, where other items are, which do not overlap in Y with the item to place, | 1059 | cell, where other items are, which do not overlap in Y with the item to place, |
1060 | the display gets corrupted, although the corruption looks quite nice. | 1060 | the display gets corrupted, although the corruption looks quite nice. |
1061 | */ | 1061 | */ |
1062 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1062 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1063 | { | 1063 | { |
1064 | 1064 | ||
1065 | QPtrList<KOAgendaItem> conflictItems; | 1065 | QPtrList<KOAgendaItem> conflictItems; |
1066 | int maxSubCells = 0; | 1066 | int maxSubCells = 0; |
1067 | QIntDict<KOAgendaItem> subCellDict(5); | 1067 | QIntDict<KOAgendaItem> subCellDict(5); |
1068 | 1068 | ||
1069 | KOAgendaItem *item; | 1069 | KOAgendaItem *item; |
1070 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1070 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1071 | if (item != placeItem) { | 1071 | if (item != placeItem) { |
1072 | if (placeItem->cellX() <= item->cellXWidth() && | 1072 | if (placeItem->cellX() <= item->cellXWidth() && |
1073 | placeItem->cellXWidth() >= item->cellX()) { | 1073 | placeItem->cellXWidth() >= item->cellX()) { |
1074 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1074 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1075 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1075 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1076 | conflictItems.append(item); | 1076 | conflictItems.append(item); |
1077 | if (item->subCells() > maxSubCells) | 1077 | if (item->subCells() > maxSubCells) |
1078 | maxSubCells = item->subCells(); | 1078 | maxSubCells = item->subCells(); |
1079 | subCellDict.insert(item->subCell(),item); | 1079 | subCellDict.insert(item->subCell(),item); |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | if (conflictItems.count() > 0) { | 1085 | if (conflictItems.count() > 0) { |
1086 | // Look for unused sub cell and insert item | 1086 | // Look for unused sub cell and insert item |
1087 | int i; | 1087 | int i; |
1088 | for(i=0;i<maxSubCells;++i) { | 1088 | for(i=0;i<maxSubCells;++i) { |
1089 | if (!subCellDict.find(i)) { | 1089 | if (!subCellDict.find(i)) { |
1090 | placeItem->setSubCell(i); | 1090 | placeItem->setSubCell(i); |
1091 | break; | 1091 | break; |
1092 | } | 1092 | } |
1093 | } | 1093 | } |
1094 | if (i == maxSubCells) { | 1094 | if (i == maxSubCells) { |
1095 | placeItem->setSubCell(maxSubCells); | 1095 | placeItem->setSubCell(maxSubCells); |
1096 | maxSubCells++; // add new item to number of sub cells | 1096 | maxSubCells++; // add new item to number of sub cells |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | // Prepare for sub cell geometry adjustment | 1099 | // Prepare for sub cell geometry adjustment |
1100 | int newSubCellWidth; | 1100 | int newSubCellWidth; |
1101 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1101 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1102 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1102 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1103 | conflictItems.append(placeItem); | 1103 | conflictItems.append(placeItem); |
1104 | 1104 | ||
1105 | 1105 | ||
1106 | // Adjust sub cell geometry of all direct conflict items | 1106 | // Adjust sub cell geometry of all direct conflict items |
1107 | for ( item=conflictItems.first(); item != 0; | 1107 | for ( item=conflictItems.first(); item != 0; |
1108 | item=conflictItems.next() ) { | 1108 | item=conflictItems.next() ) { |
1109 | item->setSubCells(maxSubCells); | 1109 | item->setSubCells(maxSubCells); |
1110 | if (mAllDayMode) { | 1110 | if (mAllDayMode) { |
1111 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1111 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1112 | } else { | 1112 | } else { |
1113 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1113 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1114 | } | 1114 | } |
1115 | int x,y; | 1115 | int x,y; |
1116 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1116 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1117 | if (mAllDayMode) { | 1117 | if (mAllDayMode) { |
1118 | y += item->subCell() * newSubCellWidth; | 1118 | y += item->subCell() * newSubCellWidth; |
1119 | } else { | 1119 | } else { |
1120 | x += item->subCell() * newSubCellWidth; | 1120 | x += item->subCell() * newSubCellWidth; |
1121 | } | 1121 | } |
1122 | moveChild(item,x,y); | 1122 | moveChild(item,x,y); |
1123 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1123 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1124 | //item->updateItem(); | 1124 | //item->updateItem(); |
1125 | } | 1125 | } |
1126 | // Adjust sub cell geometry of all conflict items of all conflict items | 1126 | // Adjust sub cell geometry of all conflict items of all conflict items |
1127 | for ( item=conflictItems.first(); item != 0; | 1127 | for ( item=conflictItems.first(); item != 0; |
1128 | item=conflictItems.next() ) { | 1128 | item=conflictItems.next() ) { |
1129 | if ( placeItem != item ) { | 1129 | if ( placeItem != item ) { |
1130 | KOAgendaItem *item2; | 1130 | KOAgendaItem *item2; |
1131 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1131 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1132 | for ( item2=conflictItems2.first(); item2 != 0; | 1132 | for ( item2=conflictItems2.first(); item2 != 0; |
1133 | item2=conflictItems2.next() ) { | 1133 | item2=conflictItems2.next() ) { |
1134 | if ( item2->subCells() != maxSubCells) { | 1134 | if ( item2->subCells() != maxSubCells) { |
1135 | item2->setSubCells(maxSubCells); | 1135 | item2->setSubCells(maxSubCells); |
1136 | if (mAllDayMode) { | 1136 | if (mAllDayMode) { |
1137 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1137 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1138 | } else { | 1138 | } else { |
1139 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1139 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1140 | } | 1140 | } |
1141 | int x,y; | 1141 | int x,y; |
1142 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1142 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1143 | if (mAllDayMode) { | 1143 | if (mAllDayMode) { |
1144 | y += item2->subCell() * newSubCellWidth; | 1144 | y += item2->subCell() * newSubCellWidth; |
1145 | } else { | 1145 | } else { |
1146 | x += item2->subCell() * newSubCellWidth; | 1146 | x += item2->subCell() * newSubCellWidth; |
1147 | } | 1147 | } |
1148 | moveChild(item2,x,y); | 1148 | moveChild(item2,x,y); |
1149 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1149 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1150 | } | 1150 | } |
1151 | } | 1151 | } |
1152 | } | 1152 | } |
1153 | } | 1153 | } |
1154 | } else { | 1154 | } else { |
1155 | placeItem->setSubCell(0); | 1155 | placeItem->setSubCell(0); |
1156 | placeItem->setSubCells(1); | 1156 | placeItem->setSubCells(1); |
1157 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1157 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1158 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1158 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1159 | int x,y; | 1159 | int x,y; |
1160 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1160 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1161 | moveChild(placeItem,x,y); | 1161 | moveChild(placeItem,x,y); |
1162 | } | 1162 | } |
1163 | placeItem->setConflictItems(conflictItems); | 1163 | placeItem->setConflictItems(conflictItems); |
1164 | // for ( item=conflictItems.first(); item != 0; | 1164 | // for ( item=conflictItems.first(); item != 0; |
1165 | // item=conflictItems.next() ) { | 1165 | // item=conflictItems.next() ) { |
1166 | // //item->updateItem(); | 1166 | // //item->updateItem(); |
1167 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1167 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1168 | // } | 1168 | // } |
1169 | // placeItem->updateItem(); | 1169 | // placeItem->updateItem(); |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1172 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1173 | { | 1173 | { |
1174 | if ( globalFlagBlockAgenda ) | 1174 | if ( globalFlagBlockAgenda ) |
1175 | return; | 1175 | return; |
1176 | if ( ! mAllDayMode ) { | 1176 | if ( ! mAllDayMode ) { |
1177 | // currently not working for | 1177 | // currently not working for |
1178 | 1178 | ||
1179 | //qDebug("KOAgenda::drawContents "); | 1179 | //qDebug("KOAgenda::drawContents "); |
1180 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1180 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1181 | ;//drawContentsToPainter(); | 1181 | ;//drawContentsToPainter(); |
1182 | 1182 | ||
1183 | QPaintDevice* pd = p->device(); | 1183 | QPaintDevice* pd = p->device(); |
1184 | p->end(); | 1184 | p->end(); |
1185 | int vx, vy; | 1185 | int vx, vy; |
1186 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1186 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1187 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1187 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1188 | mSelectionCellX * mGridSpacingX; | 1188 | mSelectionCellX * mGridSpacingX; |
1189 | contentsToViewport ( cx, cy, vx,vy); | 1189 | contentsToViewport ( cx, cy, vx,vy); |
1190 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1190 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1191 | 1191 | ||
1192 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1192 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1193 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1193 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1194 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1194 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1195 | 1195 | ||
1196 | int vxSel, vySel; | 1196 | int vxSel, vySel; |
1197 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1197 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1198 | int off = mSelectionHeight; | 1198 | int off = mSelectionHeight; |
1199 | if ( vySel < 0 ) | 1199 | if ( vySel < 0 ) |
1200 | off += vySel; | 1200 | off += vySel; |
1201 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1201 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1202 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1202 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1203 | } else { | 1203 | } else { |
1204 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1204 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | if ( mSelectionHeight > 0 ) { | 1207 | if ( mSelectionHeight > 0 ) { |
1208 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1208 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1209 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1209 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1210 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1210 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1211 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1211 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1212 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1212 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1213 | } | 1213 | } |
1214 | } | 1214 | } |
1215 | p->begin( pd ); | 1215 | p->begin( pd ); |
1216 | } else { | 1216 | } else { |
1217 | 1217 | ||
1218 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1218 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1219 | ;//drawContentsToPainter(); | 1219 | ;//drawContentsToPainter(); |
1220 | 1220 | ||
1221 | QPaintDevice* pd = p->device(); | 1221 | QPaintDevice* pd = p->device(); |
1222 | p->end(); | 1222 | p->end(); |
1223 | int vx, vy; | 1223 | int vx, vy; |
1224 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1224 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1225 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1225 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1226 | mSelectionCellX * mGridSpacingX; | 1226 | mSelectionCellX * mGridSpacingX; |
1227 | contentsToViewport ( cx, cy, vx,vy); | 1227 | contentsToViewport ( cx, cy, vx,vy); |
1228 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1228 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1229 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1229 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1230 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1230 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1231 | 1231 | ||
1232 | if ( mSelectionHeight > 0 ) { | 1232 | if ( mSelectionHeight > 0 ) { |
1233 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1233 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1234 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1234 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1235 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1235 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1236 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1236 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1237 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1237 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1238 | } | 1238 | } |
1239 | } | 1239 | } |
1240 | p->begin( pd ); | 1240 | p->begin( pd ); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | void KOAgenda::finishUpdate() | 1245 | void KOAgenda::finishUpdate() |
1246 | { | 1246 | { |
1247 | 1247 | ||
1248 | KOAgendaItem *item; | 1248 | KOAgendaItem *item; |
1249 | globalFlagBlockAgendaItemPaint = 1; | 1249 | globalFlagBlockAgendaItemPaint = 1; |
1250 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1250 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1251 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1251 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1252 | if ( !item->checkLayout() ) { | 1252 | if ( !item->checkLayout() ) { |
1253 | //qDebug(" conflictitem found "); | 1253 | //qDebug(" conflictitem found "); |
1254 | int newSubCellWidth; | 1254 | int newSubCellWidth; |
1255 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1255 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1256 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1256 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1257 | 1257 | ||
1258 | if (mAllDayMode) { | 1258 | if (mAllDayMode) { |
1259 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1259 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1260 | } else { | 1260 | } else { |
1261 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1261 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1262 | } | 1262 | } |
1263 | int x,y; | 1263 | int x,y; |
1264 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1264 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1265 | if (mAllDayMode) { | 1265 | if (mAllDayMode) { |
1266 | y += item->subCell() * newSubCellWidth; | 1266 | y += item->subCell() * newSubCellWidth; |
1267 | } else { | 1267 | } else { |
1268 | x += item->subCell() * newSubCellWidth; | 1268 | x += item->subCell() * newSubCellWidth; |
1269 | } | 1269 | } |
1270 | moveChild(item,x,y); | 1270 | moveChild(item,x,y); |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1273 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1274 | if ( !item->isVisible() ) | 1274 | if ( !item->isVisible() ) |
1275 | item->show(); | 1275 | item->show(); |
1276 | 1276 | ||
1277 | } | 1277 | } |
1278 | globalFlagBlockAgendaItemUpdate = 0; | 1278 | globalFlagBlockAgendaItemUpdate = 0; |
1279 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1279 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1280 | item->repaintMe( ); | 1280 | item->repaintMe( ); |
1281 | } | 1281 | } |
1282 | globalFlagBlockAgendaItemUpdate = 1; | 1282 | globalFlagBlockAgendaItemUpdate = 1; |
1283 | qApp->processEvents(); | 1283 | qApp->processEvents(); |
1284 | globalFlagBlockAgendaItemPaint = 0; | 1284 | globalFlagBlockAgendaItemPaint = 0; |
1285 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1285 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1286 | item->repaint( false ); | 1286 | item->repaint( false ); |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | /* | 1291 | /* |
1292 | Draw grid in the background of the agenda. | 1292 | Draw grid in the background of the agenda. |
1293 | */ | 1293 | */ |
1294 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1294 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1295 | { | 1295 | { |
1296 | 1296 | ||
1297 | 1297 | ||
1298 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1298 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1299 | return; | 1299 | return; |
1300 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1300 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1301 | return; | 1301 | return; |
1302 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1302 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1303 | if ( ch < 1 ) | 1303 | if ( ch < 1 ) |
1304 | ch = 1; | 1304 | ch = 1; |
1305 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1305 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1306 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1306 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1307 | } | 1307 | } |
1308 | mCurPixWid = contentsWidth(); | 1308 | mCurPixWid = contentsWidth(); |
1309 | mCurPixHei = ch; | 1309 | mCurPixHei = ch; |
1310 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1310 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1311 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1311 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1312 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1312 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1313 | } | 1313 | } |
1314 | mPixPainter.begin( &mPaintPixmap) ; | 1314 | mPixPainter.begin( &mPaintPixmap) ; |
1315 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1315 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1316 | QPainter * p ; | 1316 | QPainter * p ; |
1317 | if (paint == 0) { | 1317 | if (paint == 0) { |
1318 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1318 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1319 | p = &mPixPainter; | 1319 | p = &mPixPainter; |
1320 | } | 1320 | } |
1321 | else | 1321 | else |
1322 | p = paint ; | 1322 | p = paint ; |
1323 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1323 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1324 | 1324 | ||
1325 | //--cx;++cw; | 1325 | //--cx;++cw; |
1326 | int lGridSpacingY = mGridSpacingY*2; | 1326 | int lGridSpacingY = mGridSpacingY*2; |
1327 | int selDay; | 1327 | int selDay; |
1328 | if ( !backgroundOnly ) | 1328 | if ( !backgroundOnly ) |
1329 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1329 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1330 | { | 1330 | { |
1331 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1331 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1332 | int x1 = cx; | 1332 | int x1 = cx; |
1333 | int y1 = 0; | 1333 | int y1 = 0; |
1334 | if (y1 < cy) y1 = cy; | 1334 | if (y1 < cy) y1 = cy; |
1335 | int x2 = cx+cw-1; | 1335 | int x2 = cx+cw-1; |
1336 | int y2 = contentsHeight(); | 1336 | int y2 = contentsHeight(); |
1337 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1337 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1338 | if (x2 >= x1 && y2 >= y1) { | 1338 | if (x2 >= x1 && y2 >= y1) { |
1339 | int gxStart = selDay; | 1339 | int gxStart = selDay; |
1340 | int gxEnd = gxStart ; | 1340 | int gxEnd = gxStart ; |
1341 | int xStart = KOGlobals::self()->reverseLayout() ? | 1341 | int xStart = KOGlobals::self()->reverseLayout() ? |
1342 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1342 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1343 | gxStart*mGridSpacingX; | 1343 | gxStart*mGridSpacingX; |
1344 | if (xStart < x1) xStart = x1; | 1344 | if (xStart < x1) xStart = x1; |
1345 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1345 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1346 | (mColumns - gxStart)*mGridSpacingX-1 : | 1346 | (mColumns - gxStart)*mGridSpacingX-1 : |
1347 | (gxStart+1)*mGridSpacingX-1; | 1347 | (gxStart+1)*mGridSpacingX-1; |
1348 | if (xEnd > x2) xEnd = x2; | 1348 | if (xEnd > x2) xEnd = x2; |
1349 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1349 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1350 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1350 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1351 | KOPrefs::instance()->mAgendaBgColor.light()); | 1351 | KOPrefs::instance()->mAgendaBgColor.light()); |
1352 | else | 1352 | else |
1353 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1353 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1354 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1354 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1355 | 1355 | ||
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | } | 1358 | } |
1359 | // Highlight working hours | 1359 | // Highlight working hours |
1360 | 1360 | ||
1361 | if ( !backgroundOnly ) | 1361 | if ( !backgroundOnly ) |
1362 | if (mWorkingHoursEnable) { | 1362 | if (mWorkingHoursEnable) { |
1363 | int x1 = cx; | 1363 | int x1 = cx; |
1364 | int y1 = mWorkingHoursYTop; | 1364 | int y1 = mWorkingHoursYTop; |
1365 | if (y1 < cy) y1 = cy; | 1365 | if (y1 < cy) y1 = cy; |
1366 | int x2 = cx+cw-1; | 1366 | int x2 = cx+cw-1; |
1367 | // int x2 = mGridSpacingX * 5 - 1; | 1367 | // int x2 = mGridSpacingX * 5 - 1; |
1368 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1368 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1369 | int y2 = mWorkingHoursYBottom; | 1369 | int y2 = mWorkingHoursYBottom; |
1370 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1370 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1371 | 1371 | ||
1372 | if (x2 >= x1 && y2 >= y1) { | 1372 | if (x2 >= x1 && y2 >= y1) { |
1373 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1373 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1374 | int gxStart = x1/mGridSpacingX; | 1374 | int gxStart = x1/mGridSpacingX; |
1375 | int gxEnd = x2/mGridSpacingX; | 1375 | int gxEnd = x2/mGridSpacingX; |
1376 | while(gxStart <= gxEnd) { | 1376 | while(gxStart <= gxEnd) { |
1377 | if (gxStart < int(mHolidayMask->count()) && | 1377 | if (gxStart < int(mHolidayMask->count()) && |
1378 | !mHolidayMask->at(gxStart)) { | 1378 | !mHolidayMask->at(gxStart)) { |
1379 | int xStart = KOGlobals::self()->reverseLayout() ? | 1379 | int xStart = KOGlobals::self()->reverseLayout() ? |
1380 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1380 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1381 | gxStart*mGridSpacingX; | 1381 | gxStart*mGridSpacingX; |
1382 | if (xStart < x1) xStart = x1; | 1382 | if (xStart < x1) xStart = x1; |
1383 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1383 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1384 | (mColumns - gxStart)*mGridSpacingX-1 : | 1384 | (mColumns - gxStart)*mGridSpacingX-1 : |
1385 | (gxStart+1)*mGridSpacingX-1; | 1385 | (gxStart+1)*mGridSpacingX-1; |
1386 | if (xEnd > x2) xEnd = x2; | 1386 | if (xEnd > x2) xEnd = x2; |
1387 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1387 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1388 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1388 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1389 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1389 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1390 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1390 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1391 | else | 1391 | else |
1392 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1392 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1393 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1393 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1394 | } else { | 1394 | } else { |
1395 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1395 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1396 | KOPrefs::instance()->mWorkingHoursColor); | 1396 | KOPrefs::instance()->mWorkingHoursColor); |
1397 | } | 1397 | } |
1398 | } | 1398 | } |
1399 | ++gxStart; | 1399 | ++gxStart; |
1400 | } | 1400 | } |
1401 | } | 1401 | } |
1402 | } | 1402 | } |
1403 | /* | 1403 | /* |
1404 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1404 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1405 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1405 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1406 | mSelectionCellX * mGridSpacingX; | 1406 | mSelectionCellX * mGridSpacingX; |
1407 | 1407 | ||
1408 | // Draw selection | 1408 | // Draw selection |
1409 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1409 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1410 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1410 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1411 | // TODO: paint only part within cx,cy,cw,ch | 1411 | // TODO: paint only part within cx,cy,cw,ch |
1412 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1412 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1413 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1413 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1414 | } | 1414 | } |
1415 | */ | 1415 | */ |
1416 | // Draw vertical lines of grid | 1416 | // Draw vertical lines of grid |
1417 | 1417 | ||
1418 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1418 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1419 | if ( mGridSpacingX > 0 ) { | 1419 | if ( mGridSpacingX > 0 ) { |
1420 | while (x < cx + cw) { | 1420 | while (x < cx + cw) { |
1421 | p->drawLine(x,cy,x,cy+ch); | 1421 | p->drawLine(x,cy,x,cy+ch); |
1422 | x+=mGridSpacingX; | 1422 | x+=mGridSpacingX; |
1423 | } | 1423 | } |
1424 | } | 1424 | } |
1425 | // Draw horizontal lines of grid | 1425 | // Draw horizontal lines of grid |
1426 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1426 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1427 | if ( lGridSpacingY > 0 ) { | 1427 | if ( lGridSpacingY > 0 ) { |
1428 | while (y < cy + ch) { | 1428 | while (y < cy + ch) { |
1429 | p->setPen( SolidLine ); | 1429 | p->setPen( SolidLine ); |
1430 | p->drawLine(cx,y,cx+cw,y); | 1430 | p->drawLine(cx,y,cx+cw,y); |
1431 | y+=lGridSpacingY; | 1431 | y+=lGridSpacingY; |
1432 | p->setPen( DotLine ); | 1432 | p->setPen( DotLine ); |
1433 | p->drawLine(cx,y,cx+cw,y); | 1433 | p->drawLine(cx,y,cx+cw,y); |
1434 | y+=lGridSpacingY; | 1434 | y+=lGridSpacingY; |
1435 | } | 1435 | } |
1436 | p->setPen( SolidLine ); | 1436 | p->setPen( SolidLine ); |
1437 | } | 1437 | } |
1438 | mPixPainter.end() ; | 1438 | mPixPainter.end() ; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | /* | 1441 | /* |
1442 | Convert srcollview contents coordinates to agenda grid coordinates. | 1442 | Convert srcollview contents coordinates to agenda grid coordinates. |
1443 | */ | 1443 | */ |
1444 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1444 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1445 | { | 1445 | { |
1446 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1446 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1447 | x/mGridSpacingX; | 1447 | x/mGridSpacingX; |
1448 | gy = y/mGridSpacingY; | 1448 | gy = y/mGridSpacingY; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | /* | 1451 | /* |
1452 | Convert agenda grid coordinates to scrollview contents coordinates. | 1452 | Convert agenda grid coordinates to scrollview contents coordinates. |
1453 | */ | 1453 | */ |
1454 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1454 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1455 | { | 1455 | { |
1456 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1456 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1457 | gx*mGridSpacingX; | 1457 | gx*mGridSpacingX; |
1458 | y = gy*mGridSpacingY; | 1458 | y = gy*mGridSpacingY; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | 1461 | ||
1462 | /* | 1462 | /* |
1463 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1463 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1464 | the grid. | 1464 | the grid. |
1465 | */ | 1465 | */ |
1466 | int KOAgenda::timeToY(const QTime &time) | 1466 | int KOAgenda::timeToY(const QTime &time) |
1467 | { | 1467 | { |
1468 | int minutesPerCell = 24 * 60 / mRows; | 1468 | int minutesPerCell = 24 * 60 / mRows; |
1469 | int timeMinutes = time.hour() * 60 + time.minute(); | 1469 | int timeMinutes = time.hour() * 60 + time.minute(); |
1470 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1470 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1471 | return Y; | 1471 | return Y; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | 1474 | ||
1475 | /* | 1475 | /* |
1476 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1476 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1477 | fit into the grid. | 1477 | fit into the grid. |
1478 | */ | 1478 | */ |
1479 | QTime KOAgenda::gyToTime(int gy) | 1479 | QTime KOAgenda::gyToTime(int gy) |
1480 | { | 1480 | { |
1481 | 1481 | ||
1482 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1482 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1483 | 1483 | ||
1484 | int timeSeconds = secondsPerCell * gy; | 1484 | int timeSeconds = secondsPerCell * gy; |
1485 | 1485 | ||
1486 | QTime time( 0, 0, 0 ); | 1486 | QTime time( 0, 0, 0 ); |
1487 | if ( timeSeconds < 24 * 60 * 60 ) { | 1487 | if ( timeSeconds < 24 * 60 * 60 ) { |
1488 | time = time.addSecs(timeSeconds); | 1488 | time = time.addSecs(timeSeconds); |
1489 | } else { | 1489 | } else { |
1490 | time.setHMS( 23, 59, 59 ); | 1490 | time.setHMS( 23, 59, 59 ); |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | return time; | 1493 | return time; |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | void KOAgenda::setStartHour(int startHour) | 1496 | void KOAgenda::setStartHour(int startHour) |
1497 | { | 1497 | { |
1498 | int startCell = startHour * mRows / 24; | 1498 | int startCell = startHour * mRows / 24; |
1499 | setContentsPos(0,startCell * gridSpacingY()); | 1499 | setContentsPos(0,startCell * gridSpacingY()); |
1500 | } | 1500 | } |
1501 | void KOAgenda::hideUnused() | 1501 | void KOAgenda::hideUnused() |
1502 | { | 1502 | { |
1503 | // experimental only | 1503 | // experimental only |
1504 | // return; | 1504 | // return; |
1505 | KOAgendaItem *item; | 1505 | KOAgendaItem *item; |
1506 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1506 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1507 | item->hide(); | 1507 | item->hide(); |
1508 | } | 1508 | } |
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | 1511 | ||
1512 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1512 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1513 | { | 1513 | { |
1514 | 1514 | ||
1515 | KOAgendaItem *fi; | 1515 | KOAgendaItem *fi; |
1516 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1516 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1517 | if ( fi->incidence() == event ) { | 1517 | if ( fi->incidence() == event ) { |
1518 | mUnusedItems.remove(); | 1518 | mUnusedItems.remove(); |
1519 | fi->init( event, qd ); | 1519 | fi->init( event, qd ); |
1520 | return fi; | 1520 | return fi; |
1521 | } | 1521 | } |
1522 | } | 1522 | } |
1523 | fi=mUnusedItems.first(); | 1523 | fi=mUnusedItems.first(); |
1524 | if ( fi ) { | 1524 | if ( fi ) { |
1525 | mUnusedItems.remove(); | 1525 | mUnusedItems.remove(); |
1526 | fi->init( event, qd ); | 1526 | fi->init( event, qd ); |
1527 | return fi; | 1527 | return fi; |
1528 | } | 1528 | } |
1529 | // qDebug("new KOAgendaItem "); | 1529 | // qDebug("new KOAgendaItem "); |
1530 | 1530 | ||
1531 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1531 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1532 | agendaItem->installEventFilter(this); | 1532 | agendaItem->installEventFilter(this); |
1533 | addChild(agendaItem,0,0); | 1533 | addChild(agendaItem,0,0); |
1534 | return agendaItem; | 1534 | return agendaItem; |
1535 | } | 1535 | } |
1536 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1536 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1537 | { | 1537 | { |
1538 | KOAgendaItem *item; | 1538 | KOAgendaItem *item; |
1539 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1539 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1540 | if ( item->incidence() == todo ) { | 1540 | if ( item->incidence() == todo ) { |
1541 | mItems.remove(); | 1541 | mItems.remove(); |
1542 | return item; | 1542 | return item; |
1543 | } | 1543 | } |
1544 | } | 1544 | } |
1545 | return 0; | 1545 | return 0; |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | 1548 | ||
1549 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1549 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1550 | { | 1550 | { |
1551 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1551 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1552 | KOAgendaItem *item; | 1552 | KOAgendaItem *item; |
1553 | item = getItemForTodo ( todo ); | 1553 | item = getItemForTodo ( todo ); |
1554 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1554 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1555 | if ( item ) { | 1555 | if ( item ) { |
1556 | blockSignals( true ); | 1556 | blockSignals( true ); |
1557 | //qDebug("item found "); | 1557 | //qDebug("item found "); |
1558 | item->hide(); | 1558 | item->hide(); |
1559 | item->setCellX(-2, -1 ); | 1559 | item->setCellX(-2, -1 ); |
1560 | item->select(false); | 1560 | item->select(false); |
1561 | mUnusedItems.append( item ); | 1561 | mUnusedItems.append( item ); |
1562 | mItems.remove( item ); | 1562 | mItems.remove( item ); |
1563 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1563 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1564 | KOAgendaItem *itemit; | 1564 | KOAgendaItem *itemit; |
1565 | //globalFlagBlockAgendaItemPaint = 1; | 1565 | //globalFlagBlockAgendaItemPaint = 1; |
1566 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1566 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1567 | itemit=oldconflictItems.next() ) { | 1567 | itemit=oldconflictItems.next() ) { |
1568 | if ( itemit != item ) | 1568 | if ( itemit != item ) |
1569 | placeSubCells(itemit); | 1569 | placeSubCells(itemit); |
1570 | } | 1570 | } |
1571 | qApp->processEvents(); | 1571 | qApp->processEvents(); |
1572 | //globalFlagBlockAgendaItemPaint = 0; | 1572 | //globalFlagBlockAgendaItemPaint = 0; |
1573 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1573 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1574 | itemit=oldconflictItems.next() ) { | 1574 | itemit=oldconflictItems.next() ) { |
1575 | globalFlagBlockAgendaItemUpdate = 0; | 1575 | globalFlagBlockAgendaItemUpdate = 0; |
1576 | if ( itemit != item ) | 1576 | if ( itemit != item ) |
1577 | itemit->repaintMe(); | 1577 | itemit->repaintMe(); |
1578 | globalFlagBlockAgendaItemUpdate = 1; | 1578 | globalFlagBlockAgendaItemUpdate = 1; |
1579 | itemit->repaint(); | 1579 | itemit->repaint(); |
1580 | } | 1580 | } |
1581 | blockSignals( false ); | 1581 | blockSignals( false ); |
1582 | } | 1582 | } |
1583 | if ( remove ) { | 1583 | if ( remove ) { |
1584 | //qDebug("remove****************************************** "); | 1584 | //qDebug("remove****************************************** "); |
1585 | return; | 1585 | return; |
1586 | } | 1586 | } |
1587 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1587 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1588 | return; | 1588 | return; |
1589 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1589 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1590 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1590 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1591 | QDate currentDate; | 1591 | QDate currentDate; |
1592 | QDateTime dt; | 1592 | QDateTime dt; |
1593 | if ( todo->hasCompletedDate() ) | 1593 | if ( todo->hasCompletedDate() ) |
1594 | dt = todo->completed(); | 1594 | dt = todo->completed(); |
1595 | else | 1595 | else |
1596 | dt = todo->dtDue(); | 1596 | dt = todo->dtDue(); |
1597 | if ( overdue ) { | 1597 | if ( overdue ) { |
1598 | currentDate = QDate::currentDate(); | 1598 | currentDate = QDate::currentDate(); |
1599 | days += todo->dtDue().date().daysTo( currentDate ); | 1599 | days += todo->dtDue().date().daysTo( currentDate ); |
1600 | } | 1600 | } |
1601 | else | 1601 | else |
1602 | currentDate = dt.date(); | 1602 | currentDate = dt.date(); |
1603 | 1603 | ||
1604 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1604 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1605 | if ( ! mAllDayMode ) return; | 1605 | if ( ! mAllDayMode ) return; |
1606 | // aldayagenda | 1606 | // aldayagenda |
1607 | globalFlagBlockAgendaItemPaint = 1; | 1607 | globalFlagBlockAgendaItemPaint = 1; |
1608 | item = insertAllDayItem(todo, currentDate,days, days); | 1608 | item = insertAllDayItem(todo, currentDate,days, days); |
1609 | item->show(); | 1609 | item->show(); |
1610 | 1610 | ||
1611 | } | 1611 | } |
1612 | else { | 1612 | else { |
1613 | if ( mAllDayMode ) return; | 1613 | if ( mAllDayMode ) return; |
1614 | // mAgenda | 1614 | // mAgenda |
1615 | globalFlagBlockAgendaItemPaint = 1; | 1615 | globalFlagBlockAgendaItemPaint = 1; |
1616 | int endY = timeToY(dt.time()) - 1; | 1616 | int endY = timeToY(dt.time()) - 1; |
1617 | int hi = 12/KOPrefs::instance()->mHourSize; | 1617 | int hi = 12/KOPrefs::instance()->mHourSize; |
1618 | int startY = endY - 1-hi; | 1618 | int startY = endY - 1-hi; |
1619 | item = insertItem(todo,currentDate,days,startY,endY); | 1619 | item = insertItem(todo,currentDate,days,startY,endY); |
1620 | item->show(); | 1620 | item->show(); |
1621 | } | 1621 | } |
1622 | qApp->processEvents(); | 1622 | qApp->processEvents(); |
1623 | globalFlagBlockAgendaItemPaint = 0; | 1623 | globalFlagBlockAgendaItemPaint = 0; |
1624 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1624 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1625 | KOAgendaItem *itemit; | 1625 | KOAgendaItem *itemit; |
1626 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1626 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1627 | itemit=oldconflictItems.next() ) { | 1627 | itemit=oldconflictItems.next() ) { |
1628 | globalFlagBlockAgendaItemUpdate = 0; | 1628 | globalFlagBlockAgendaItemUpdate = 0; |
1629 | itemit->repaintMe(); | 1629 | itemit->repaintMe(); |
1630 | globalFlagBlockAgendaItemUpdate = 1; | 1630 | globalFlagBlockAgendaItemUpdate = 1; |
1631 | itemit->repaint(); | 1631 | itemit->repaint(); |
1632 | } | 1632 | } |
1633 | globalFlagBlockAgendaItemUpdate = 0; | 1633 | globalFlagBlockAgendaItemUpdate = 0; |
1634 | item->repaintMe(); | 1634 | item->repaintMe(); |
1635 | globalFlagBlockAgendaItemUpdate = 1; | 1635 | globalFlagBlockAgendaItemUpdate = 1; |
1636 | item->repaint(); | 1636 | item->repaint(); |
1637 | } | 1637 | } |
1638 | /* | 1638 | /* |
1639 | Insert KOAgendaItem into agenda. | 1639 | Insert KOAgendaItem into agenda. |
1640 | */ | 1640 | */ |
1641 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1641 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1642 | { | 1642 | { |
1643 | if (mAllDayMode) { | 1643 | if (mAllDayMode) { |
1644 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1644 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1645 | return 0; | 1645 | return 0; |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1648 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1649 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1649 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1650 | 1650 | ||
1651 | int YSize = YBottom - YTop + 1; | 1651 | int YSize = YBottom - YTop + 1; |
1652 | if (YSize < 0) { | 1652 | if (YSize < 0) { |
1653 | YSize = 1; | 1653 | YSize = 1; |
1654 | } | 1654 | } |
1655 | int iheight = mGridSpacingY * YSize; | 1655 | int iheight = mGridSpacingY * YSize; |
1656 | 1656 | ||
1657 | agendaItem->resize(mGridSpacingX,iheight ); | 1657 | agendaItem->resize(mGridSpacingX,iheight ); |
1658 | agendaItem->setCellXY(X,YTop,YBottom); | 1658 | agendaItem->setCellXY(X,YTop,YBottom); |
1659 | agendaItem->setCellXWidth(X); | 1659 | agendaItem->setCellXWidth(X); |
1660 | 1660 | ||
1661 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1661 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1662 | mItems.append(agendaItem); | 1662 | mItems.append(agendaItem); |
1663 | 1663 | ||
1664 | placeSubCells(agendaItem); | 1664 | placeSubCells(agendaItem); |
1665 | 1665 | ||
1666 | //agendaItem->show(); | 1666 | //agendaItem->show(); |
1667 | 1667 | ||
1668 | marcus_bains(); | 1668 | marcus_bains(); |
1669 | 1669 | ||
1670 | return agendaItem; | 1670 | return agendaItem; |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | 1673 | ||
1674 | /* | 1674 | /* |
1675 | Insert all-day KOAgendaItem into agenda. | 1675 | Insert all-day KOAgendaItem into agenda. |
1676 | */ | 1676 | */ |
1677 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1677 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1678 | { | 1678 | { |
1679 | if (!mAllDayMode) { | 1679 | if (!mAllDayMode) { |
1680 | return 0; | 1680 | return 0; |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1683 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1684 | 1684 | ||
1685 | agendaItem->setCellXY(XBegin,0,0); | 1685 | agendaItem->setCellXY(XBegin,0,0); |
1686 | agendaItem->setCellXWidth(XEnd); | 1686 | agendaItem->setCellXWidth(XEnd); |
1687 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1687 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1688 | 1688 | ||
1689 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1689 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1690 | mItems.append(agendaItem); | 1690 | mItems.append(agendaItem); |
1691 | 1691 | ||
1692 | placeSubCells(agendaItem); | 1692 | placeSubCells(agendaItem); |
1693 | 1693 | ||
1694 | //agendaItem->show(); | 1694 | //agendaItem->show(); |
1695 | 1695 | ||
1696 | return agendaItem; | 1696 | return agendaItem; |
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | 1699 | ||
1700 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1700 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1701 | int YTop,int YBottom) | 1701 | int YTop,int YBottom) |
1702 | { | 1702 | { |
1703 | if (mAllDayMode) { | 1703 | if (mAllDayMode) { |
1704 | ; | 1704 | ; |
1705 | return; | 1705 | return; |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | int cellX,cellYTop,cellYBottom; | 1708 | int cellX,cellYTop,cellYBottom; |
1709 | QString newtext; | 1709 | QString newtext; |
1710 | int width = XEnd - XBegin + 1; | 1710 | int width = XEnd - XBegin + 1; |
1711 | int count = 0; | 1711 | int count = 0; |
1712 | KOAgendaItem *current = 0; | 1712 | KOAgendaItem *current = 0; |
1713 | QPtrList<KOAgendaItem> multiItems; | 1713 | QPtrList<KOAgendaItem> multiItems; |
1714 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1714 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1715 | if (cellX == XBegin) cellYTop = YTop; | 1715 | if (cellX == XBegin) cellYTop = YTop; |
1716 | else cellYTop = 0; | 1716 | else cellYTop = 0; |
1717 | if (cellX == XEnd) cellYBottom = YBottom; | 1717 | if (cellX == XEnd) cellYBottom = YBottom; |
1718 | else cellYBottom = rows() - 1; | 1718 | else cellYBottom = rows() - 1; |
1719 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1719 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1720 | newtext.append(event->summary()); | 1720 | newtext.append(event->summary()); |
1721 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1721 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1722 | current->setText(newtext); | 1722 | current->setText(newtext); |
1723 | multiItems.append(current); | 1723 | multiItems.append(current); |
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | KOAgendaItem *next = 0; | 1726 | KOAgendaItem *next = 0; |
1727 | KOAgendaItem *last = multiItems.last(); | 1727 | KOAgendaItem *last = multiItems.last(); |
1728 | KOAgendaItem *first = multiItems.first(); | 1728 | KOAgendaItem *first = multiItems.first(); |
1729 | KOAgendaItem *setFirst,*setLast; | 1729 | KOAgendaItem *setFirst,*setLast; |
1730 | current = first; | 1730 | current = first; |
1731 | while (current) { | 1731 | while (current) { |
1732 | next = multiItems.next(); | 1732 | next = multiItems.next(); |
1733 | if (current == first) setFirst = 0; | 1733 | if (current == first) setFirst = 0; |
1734 | else setFirst = first; | 1734 | else setFirst = first; |
1735 | if (current == last) setLast = 0; | 1735 | if (current == last) setLast = 0; |
1736 | else setLast = last; | 1736 | else setLast = last; |
1737 | 1737 | ||
1738 | current->setMultiItem(setFirst,next,setLast); | 1738 | current->setMultiItem(setFirst,next,setLast); |
1739 | current = next; | 1739 | current = next; |
1740 | } | 1740 | } |
1741 | 1741 | ||
1742 | marcus_bains(); | 1742 | marcus_bains(); |
1743 | } | 1743 | } |
1744 | 1744 | ||
1745 | 1745 | ||
1746 | //QSizePolicy KOAgenda::sizePolicy() const | 1746 | //QSizePolicy KOAgenda::sizePolicy() const |
1747 | //{ | 1747 | //{ |
1748 | // Thought this would make the all-day event agenda minimum size and the | 1748 | // Thought this would make the all-day event agenda minimum size and the |
1749 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1749 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1750 | // don´t seem to think that an Expanding widget needs more space than a | 1750 | // don´t seem to think that an Expanding widget needs more space than a |
1751 | // Preferred one. | 1751 | // Preferred one. |
1752 | // But it doesn´t hurt, so it stays. | 1752 | // But it doesn´t hurt, so it stays. |
1753 | // if (mAllDayMode) { | 1753 | // if (mAllDayMode) { |
1754 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1754 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1755 | // } else { | 1755 | // } else { |
1756 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1756 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1757 | // } | 1757 | // } |
1758 | //} | 1758 | //} |
1759 | void KOAgenda::finishResize ( ) | 1759 | void KOAgenda::finishResize ( ) |
1760 | { | 1760 | { |
1761 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1761 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1762 | if ( globalFlagBlockAgenda == 0 ) { | 1762 | if ( globalFlagBlockAgenda == 0 ) { |
1763 | finishUpdate(); | 1763 | finishUpdate(); |
1764 | //qDebug("finishUpdate() called "); | 1764 | //qDebug("finishUpdate() called "); |
1765 | } | 1765 | } |
1766 | } | 1766 | } |
1767 | /* | 1767 | /* |
1768 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1768 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1769 | */ | 1769 | */ |
1770 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1770 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1771 | { | 1771 | { |
1772 | mSelectionHeight = 0; | 1772 | mSelectionHeight = 0; |
1773 | mResizeTimer.start( 150 , true ); | 1773 | mResizeTimer.start( 150 , true ); |
1774 | computeSizes(); | 1774 | computeSizes(); |
1775 | return; | 1775 | return; |
1776 | 1776 | ||
1777 | } | 1777 | } |
1778 | void KOAgenda::computeSizes() | 1778 | void KOAgenda::computeSizes() |
1779 | { | 1779 | { |
1780 | if ( globalFlagBlockStartup ) | 1780 | if ( globalFlagBlockStartup ) |
1781 | return; | 1781 | return; |
1782 | int frameOffset = frameWidth() * 2 +1; | 1782 | int frameOffset = frameWidth() * 2 +1; |
1783 | if (mAllDayMode) { | 1783 | if (mAllDayMode) { |
1784 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1784 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1785 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1785 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1786 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1786 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1787 | // mGridSpacingY = height(); | 1787 | // mGridSpacingY = height(); |
1788 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1788 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1789 | 1789 | ||
1790 | KOAgendaItem *item; | 1790 | KOAgendaItem *item; |
1791 | int subCellWidth; | 1791 | int subCellWidth; |
1792 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1792 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1793 | subCellWidth = mGridSpacingY / item->subCells(); | 1793 | subCellWidth = mGridSpacingY / item->subCells(); |
1794 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1794 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1795 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1795 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1796 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1796 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1797 | item->cellX() * mGridSpacingX, | 1797 | item->cellX() * mGridSpacingX, |
1798 | item->subCell() * subCellWidth); | 1798 | item->subCell() * subCellWidth); |
1799 | } | 1799 | } |
1800 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1800 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1801 | } else { | 1801 | } else { |
1802 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1802 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1803 | if (height() > mGridSpacingY * mRows + 1 ) { | 1803 | if (height() > mGridSpacingY * mRows + 1 ) { |
1804 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1804 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1805 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1805 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1806 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1806 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1807 | emit resizedSignal(); | 1807 | emit resizedSignal(); |
1808 | } else | 1808 | } else |
1809 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1809 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1810 | KOAgendaItem *item; | 1810 | KOAgendaItem *item; |
1811 | int subCellWidth; | 1811 | int subCellWidth; |
1812 | 1812 | ||
1813 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1813 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1814 | subCellWidth = mGridSpacingX / item->subCells(); | 1814 | subCellWidth = mGridSpacingX / item->subCells(); |
1815 | item->resize(subCellWidth,item->height()); | 1815 | item->resize(subCellWidth,item->height()); |
1816 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1816 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1817 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1817 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1818 | item->cellX() * mGridSpacingX) + | 1818 | item->cellX() * mGridSpacingX) + |
1819 | item->subCell() * subCellWidth,childY(item)); | 1819 | item->subCell() * subCellWidth,childY(item)); |
1820 | } | 1820 | } |
1821 | } | 1821 | } |
1822 | int cw = contentsWidth(); | 1822 | int cw = contentsWidth(); |
1823 | int ch = contentsHeight(); | 1823 | int ch = contentsHeight(); |
1824 | if ( mAllDayMode ) { | 1824 | if ( mAllDayMode ) { |
1825 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1825 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1826 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1826 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1827 | paintPixAll->resize( cw, ch ); | 1827 | paintPixAll->resize( cw, ch ); |
1828 | } else { | 1828 | } else { |
1829 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1829 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1830 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1830 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1831 | KOAgendaItem::resizePixmap( cw , ch ); | 1831 | KOAgendaItem::resizePixmap( cw , ch ); |
1832 | } | 1832 | } |
1833 | 1833 | ||
1834 | checkScrollBoundaries(); | 1834 | checkScrollBoundaries(); |
1835 | marcus_bains(); | 1835 | marcus_bains(); |
1836 | drawContentsToPainter(); | 1836 | drawContentsToPainter(); |
1837 | viewport()->repaint(false); | 1837 | viewport()->repaint(false); |
1838 | } | 1838 | } |
1839 | 1839 | ||
1840 | void KOAgenda::scrollUp() | 1840 | void KOAgenda::scrollUp() |
1841 | { | 1841 | { |
1842 | scrollBy(0,-mScrollOffset); | 1842 | scrollBy(0,-mScrollOffset); |
1843 | } | 1843 | } |
1844 | 1844 | ||
1845 | 1845 | ||
1846 | void KOAgenda::scrollDown() | 1846 | void KOAgenda::scrollDown() |
1847 | { | 1847 | { |
1848 | scrollBy(0,mScrollOffset); | 1848 | scrollBy(0,mScrollOffset); |
1849 | } | 1849 | } |
1850 | 1850 | ||
1851 | void KOAgenda::popupAlarm() | 1851 | void KOAgenda::popupAlarm() |
1852 | { | 1852 | { |
1853 | if (!mClickedItem) { | 1853 | if (!mClickedItem) { |
1854 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1854 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1855 | return; | 1855 | return; |
1856 | } | 1856 | } |
1857 | // TODO: deal correctly with multiple alarms | 1857 | // TODO: deal correctly with multiple alarms |
1858 | Alarm* alarm; | 1858 | Alarm* alarm; |
1859 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1859 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1860 | for(alarm=list.first();alarm;alarm=list.next()) { | 1860 | for(alarm=list.first();alarm;alarm=list.next()) { |
1861 | alarm->toggleAlarm(); | 1861 | alarm->toggleAlarm(); |
1862 | } | 1862 | } |
1863 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1863 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1864 | mClickedItem->paintMe( true ); | 1864 | mClickedItem->paintMe( true ); |
1865 | mClickedItem->repaint( false ); | 1865 | mClickedItem->repaint( false ); |
1866 | } | 1866 | } |
1867 | 1867 | ||
1868 | /* | 1868 | /* |
1869 | Calculates the minimum width | 1869 | Calculates the minimum width |
1870 | */ | 1870 | */ |
1871 | int KOAgenda::minimumWidth() const | 1871 | int KOAgenda::minimumWidth() const |
1872 | { | 1872 | { |
1873 | // TODO:: develop a way to dynamically determine the minimum width | 1873 | // TODO:: develop a way to dynamically determine the minimum width |
1874 | int min = 100; | 1874 | int min = 100; |
1875 | 1875 | ||
1876 | return min; | 1876 | return min; |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | void KOAgenda::updateConfig() | 1879 | void KOAgenda::updateConfig() |
1880 | { | 1880 | { |
1881 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1881 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1882 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1882 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1883 | if ( mAllDayMode ) { | 1883 | if ( mAllDayMode ) { |
1884 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1884 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1885 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1885 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1886 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1886 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1887 | // setMaximumHeight( mGridSpacingY+1 ); | 1887 | // setMaximumHeight( mGridSpacingY+1 ); |
1888 | viewport()->repaint( false ); | 1888 | viewport()->repaint( false ); |
1889 | //setFixedHeight( mGridSpacingY+1 ); | 1889 | //setFixedHeight( mGridSpacingY+1 ); |
1890 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1890 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1891 | } | 1891 | } |
1892 | else { | 1892 | else { |
1893 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1893 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1894 | calculateWorkingHours(); | 1894 | calculateWorkingHours(); |
1895 | marcus_bains(); | 1895 | marcus_bains(); |
1896 | } | 1896 | } |
1897 | } | 1897 | } |
1898 | 1898 | ||
1899 | void KOAgenda::checkScrollBoundaries() | 1899 | void KOAgenda::checkScrollBoundaries() |
1900 | { | 1900 | { |
1901 | // Invalidate old values to force update | 1901 | // Invalidate old values to force update |
1902 | mOldLowerScrollValue = -1; | 1902 | mOldLowerScrollValue = -1; |
1903 | mOldUpperScrollValue = -1; | 1903 | mOldUpperScrollValue = -1; |
1904 | 1904 | ||
1905 | checkScrollBoundaries(verticalScrollBar()->value()); | 1905 | checkScrollBoundaries(verticalScrollBar()->value()); |
1906 | } | 1906 | } |
1907 | 1907 | ||
1908 | void KOAgenda::checkScrollBoundaries(int v) | 1908 | void KOAgenda::checkScrollBoundaries(int v) |
1909 | { | 1909 | { |
1910 | if ( mGridSpacingY == 0 ) | 1910 | if ( mGridSpacingY == 0 ) |
1911 | return; | 1911 | return; |
1912 | int yMin = v/mGridSpacingY; | 1912 | int yMin = v/mGridSpacingY; |
1913 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1913 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1914 | 1914 | ||
1915 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1915 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1916 | 1916 | ||
1917 | if (yMin != mOldLowerScrollValue) { | 1917 | if (yMin != mOldLowerScrollValue) { |
1918 | mOldLowerScrollValue = yMin; | 1918 | mOldLowerScrollValue = yMin; |
1919 | emit lowerYChanged(yMin); | 1919 | emit lowerYChanged(yMin); |
1920 | } | 1920 | } |
1921 | if (yMax != mOldUpperScrollValue) { | 1921 | if (yMax != mOldUpperScrollValue) { |
1922 | mOldUpperScrollValue = yMax; | 1922 | mOldUpperScrollValue = yMax; |
1923 | emit upperYChanged(yMax); | 1923 | emit upperYChanged(yMax); |
1924 | } | 1924 | } |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | void KOAgenda::deselectItem() | 1927 | void KOAgenda::deselectItem() |
1928 | { | 1928 | { |
1929 | if (mSelectedItem.isNull()) return; | 1929 | if (mSelectedItem.isNull()) return; |
1930 | mSelectedItem->select(false); | 1930 | mSelectedItem->select(false); |
1931 | mSelectedItem = 0; | 1931 | mSelectedItem = 0; |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | void KOAgenda::selectItem(KOAgendaItem *item) | 1934 | void KOAgenda::selectItem(KOAgendaItem *item) |
1935 | { | 1935 | { |
1936 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1936 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1937 | deselectItem(); | 1937 | deselectItem(); |
1938 | if (item == 0) { | 1938 | if (item == 0) { |
1939 | emit incidenceSelected( 0 ); | 1939 | emit incidenceSelected( 0 ); |
1940 | return; | 1940 | return; |
1941 | } | 1941 | } |
1942 | mSelectedItem = item; | 1942 | mSelectedItem = item; |
1943 | mSelectedItem->select(); | 1943 | mSelectedItem->select(); |
1944 | emit incidenceSelected( mSelectedItem->incidence() ); | 1944 | emit incidenceSelected( mSelectedItem->incidence() ); |
1945 | } | 1945 | } |
1946 | 1946 | ||
1947 | // This function seems never be called. | 1947 | // This function seems never be called. |
1948 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1948 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1949 | { | 1949 | { |
1950 | switch(kev->key()) { | 1950 | switch(kev->key()) { |
1951 | case Key_PageDown: | 1951 | case Key_PageDown: |
1952 | verticalScrollBar()->addPage(); | 1952 | verticalScrollBar()->addPage(); |
1953 | break; | 1953 | break; |
1954 | case Key_PageUp: | 1954 | case Key_PageUp: |
1955 | verticalScrollBar()->subtractPage(); | 1955 | verticalScrollBar()->subtractPage(); |
1956 | break; | 1956 | break; |
1957 | case Key_Down: | 1957 | case Key_Down: |
1958 | verticalScrollBar()->addLine(); | 1958 | verticalScrollBar()->addLine(); |
1959 | break; | 1959 | break; |
1960 | case Key_Up: | 1960 | case Key_Up: |
1961 | verticalScrollBar()->subtractLine(); | 1961 | verticalScrollBar()->subtractLine(); |
1962 | break; | 1962 | break; |
1963 | default: | 1963 | default: |
1964 | ; | 1964 | ; |
1965 | } | 1965 | } |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void KOAgenda::calculateWorkingHours() | 1968 | void KOAgenda::calculateWorkingHours() |
1969 | { | 1969 | { |
1970 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1970 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1971 | mWorkingHoursEnable = !mAllDayMode; | 1971 | mWorkingHoursEnable = !mAllDayMode; |
1972 | 1972 | ||
1973 | mWorkingHoursYTop = mGridSpacingY * | 1973 | mWorkingHoursYTop = mGridSpacingY * |
1974 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1974 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1975 | mWorkingHoursYBottom = mGridSpacingY * | 1975 | mWorkingHoursYBottom = mGridSpacingY * |
1976 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1976 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1977 | } | 1977 | } |
1978 | 1978 | ||
1979 | 1979 | ||
1980 | DateList KOAgenda::dateList() const | 1980 | DateList KOAgenda::dateList() const |
1981 | { | 1981 | { |
1982 | return mSelectedDates; | 1982 | return mSelectedDates; |
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | void KOAgenda::setDateList(const DateList &selectedDates) | 1985 | void KOAgenda::setDateList(const DateList &selectedDates) |
1986 | { | 1986 | { |
1987 | mSelectedDates = selectedDates; | 1987 | mSelectedDates = selectedDates; |
1988 | marcus_bains(); | 1988 | marcus_bains(); |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1991 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1992 | { | 1992 | { |
1993 | mHolidayMask = mask; | 1993 | mHolidayMask = mask; |
1994 | 1994 | ||
1995 | /* | 1995 | /* |
1996 | kdDebug() << "HolidayMask: "; | 1996 | kdDebug() << "HolidayMask: "; |
1997 | for(uint i=0;i<mask->count();++i) { | 1997 | for(uint i=0;i<mask->count();++i) { |
1998 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1998 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1999 | } | 1999 | } |
2000 | kdDebug() << endl; | 2000 | kdDebug() << endl; |
2001 | */ | 2001 | */ |
2002 | } | 2002 | } |
2003 | 2003 | ||
2004 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2004 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2005 | { | 2005 | { |
2006 | 2006 | ||
2007 | QScrollView::contentsMousePressEvent(event); | 2007 | QScrollView::contentsMousePressEvent(event); |
2008 | } | 2008 | } |
2009 | 2009 | ||
2010 | void KOAgenda::storePosition() | 2010 | void KOAgenda::storePosition() |
2011 | { | 2011 | { |
2012 | //mContentPosition | 2012 | //mContentPosition |
2013 | int max = mGridSpacingY*4*24; | 2013 | int max = mGridSpacingY*4*24; |
2014 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2014 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2015 | mContentPosition = 0; | 2015 | mContentPosition = 0; |
2016 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2016 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2017 | mContentPosition = -1.0; | 2017 | mContentPosition = -1.0; |
2018 | else | 2018 | else |
2019 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2019 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2020 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2020 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2021 | 2021 | ||
2022 | } | 2022 | } |
2023 | void KOAgenda::restorePosition() | 2023 | void KOAgenda::restorePosition() |
2024 | { | 2024 | { |
2025 | int posY; | 2025 | int posY; |
2026 | int max = mGridSpacingY*4*24; | 2026 | int max = mGridSpacingY*4*24; |
2027 | if ( mContentPosition < 0 ) | 2027 | if ( mContentPosition < 0 ) |
2028 | posY = max-viewport()->height(); | 2028 | posY = max-viewport()->height(); |
2029 | else | 2029 | else |
2030 | if ( mContentPosition == 0 ) | 2030 | if ( mContentPosition == 0 ) |
2031 | posY = 0; | 2031 | posY = 0; |
2032 | else | 2032 | else |
2033 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2033 | posY = (max/mContentPosition)-(viewport()->height()/2); |
2034 | setContentsPos (0, posY ); | 2034 | setContentsPos (0, posY ); |
2035 | //qDebug("posY %d hei %d", posY, max); | 2035 | //qDebug("posY %d hei %d", posY, max); |
2036 | 2036 | ||
2037 | } | 2037 | } |
2038 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2038 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2039 | { | 2039 | { |
2040 | ++x; | 2040 | ++x; |
2041 | QScrollView::moveChild( w, x , y ); | 2041 | QScrollView::moveChild( w, x , y ); |
2042 | } | 2042 | } |
2043 | #include <qmessagebox.h> | 2043 | #include <qmessagebox.h> |
2044 | #ifdef DESKTOP_VERSION | 2044 | #ifdef DESKTOP_VERSION |
2045 | #include <qprinter.h> | 2045 | #include <qprinter.h> |
2046 | #include <qpainter.h> | 2046 | #include <qpainter.h> |
2047 | #include <qpaintdevicemetrics.h> | 2047 | #include <qpaintdevicemetrics.h> |
2048 | 2048 | ||
2049 | #endif | 2049 | #endif |
2050 | void KOAgenda::printSelection() | 2050 | void KOAgenda::printSelection() |
2051 | { | 2051 | { |
2052 | #ifdef DESKTOP_VERSION | 2052 | #ifdef DESKTOP_VERSION |
2053 | if ( mStartCellY == mCurrentCellY ) { | 2053 | if ( mStartCellY == mCurrentCellY ) { |
2054 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2054 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2055 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2055 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2056 | i18n("OK"), 0, 0, | 2056 | i18n("OK"), 0, 0, |
2057 | 0, 1 ); | 2057 | 0, 1 ); |
2058 | return; | 2058 | return; |
2059 | } | 2059 | } |
2060 | 2060 | ||
2061 | float dx, dy; | 2061 | float dx, dy; |
2062 | int x,y,w,h; | 2062 | int x,y,w,h; |
2063 | x= 0; | 2063 | x= 0; |
2064 | w= contentsWidth()+2; | 2064 | w= contentsWidth()+2; |
2065 | // h= contentsHeight(); | 2065 | // h= contentsHeight(); |
2066 | y = mGridSpacingY*mStartCellY; | 2066 | y = mGridSpacingY*mStartCellY; |
2067 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2067 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2068 | 2068 | ||
2069 | //return; | 2069 | //return; |
2070 | QPrinter* printer = new QPrinter(); | 2070 | QPrinter* printer = new QPrinter(); |
2071 | if ( !printer->setup()) { | 2071 | if ( !printer->setup()) { |
2072 | delete printer; | 2072 | delete printer; |
2073 | return; | 2073 | return; |
2074 | } | 2074 | } |
2075 | QPainter p( printer ); | 2075 | QPainter p( printer ); |
2076 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2076 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2077 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2077 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2078 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2078 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2079 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2079 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2080 | // p.drawText( 0, 0, date ); | 2080 | // p.drawText( 0, 0, date ); |
2081 | int offset = m.width()/8; | 2081 | int offset = m.width()/8; |
2082 | // compute the scale | 2082 | // compute the scale |
2083 | dx = ((float) m.width()-offset) / (float)w; | 2083 | dx = ((float) m.width()-offset) / (float)w; |
2084 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2084 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2085 | float scale; | 2085 | float scale; |
2086 | // scale to fit the width or height of the paper | 2086 | // scale to fit the width or height of the paper |
2087 | if ( dx < dy ) | 2087 | if ( dx < dy ) |
2088 | scale = dx; | 2088 | scale = dx; |
2089 | else | 2089 | else |
2090 | scale = dy; | 2090 | scale = dy; |
2091 | // set the scale | 2091 | // set the scale |
2092 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2092 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2093 | 2093 | ||
2094 | int selDay; | 2094 | int selDay; |
2095 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2095 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2096 | float startX = 1; | 2096 | float startX = 1; |
2097 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2097 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2098 | { | 2098 | { |
2099 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2099 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2100 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2100 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2101 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2101 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2102 | startX += widOffset; | 2102 | startX += widOffset; |
2103 | 2103 | ||
2104 | } | 2104 | } |
2105 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2105 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2106 | p.scale( scale, scale ); | 2106 | p.scale( scale, scale ); |
2107 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2107 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2108 | // now printing with y offset: 2 hei | 2108 | // now printing with y offset: 2 hei |
2109 | // p.translate( 0, -y*scale); | 2109 | // p.translate( 0, -y*scale); |
2110 | 2110 | ||
2111 | drawContentsToPainter(&p, true ); | 2111 | drawContentsToPainter(&p, true ); |
2112 | globalFlagBlockAgendaItemUpdate = false; | 2112 | globalFlagBlockAgendaItemUpdate = false; |
2113 | KOAgendaItem *item; | 2113 | KOAgendaItem *item; |
2114 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2114 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2115 | item->select(false); | 2115 | item->select(false); |
2116 | item->paintMe( false, &p ); | 2116 | item->paintMe( false, &p ); |
2117 | } | 2117 | } |
2118 | globalFlagBlockAgendaItemUpdate = true; | 2118 | globalFlagBlockAgendaItemUpdate = true; |
2119 | p.end(); | 2119 | p.end(); |
2120 | delete printer; | 2120 | delete printer; |
2121 | #else | 2121 | #else |
2122 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2122 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2123 | i18n("Not supported \non PDA!\n"), | 2123 | i18n("Not supported \non PDA!\n"), |
2124 | i18n("OK"), 0, 0, | 2124 | i18n("OK"), 0, 0, |
2125 | 0, 1 ); | 2125 | 0, 1 ); |
2126 | #endif | 2126 | #endif |
2127 | } | 2127 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index df2e478..5a3c4d2 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,824 +1,824 @@ | |||
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 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #define AGENDA_ICON_SIZE 7 | 39 | #define AGENDA_ICON_SIZE 7 |
40 | #endif | 40 | #endif |
41 | #include <libkcal/icaldrag.h> | 41 | #include <libkcal/icaldrag.h> |
42 | #include <libkcal/vcaldrag.h> | 42 | #include <libkcal/vcaldrag.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | extern int globalFlagBlockAgenda; | 44 | extern int globalFlagBlockAgenda; |
45 | extern int globalFlagBlockAgendaItemPaint; | 45 | extern int globalFlagBlockAgendaItemPaint; |
46 | extern int globalFlagBlockAgendaItemUpdate; | 46 | extern int globalFlagBlockAgendaItemUpdate; |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | 49 | ||
50 | #include "koagendaitem.h" | 50 | #include "koagendaitem.h" |
51 | //#include "koagendaitem.moc" | 51 | //#include "koagendaitem.moc" |
52 | 52 | ||
53 | 53 | ||
54 | //-------------------------------------------------------------------------- | 54 | //-------------------------------------------------------------------------- |
55 | 55 | ||
56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
57 | 57 | ||
58 | //-------------------------------------------------------------------------- | 58 | //-------------------------------------------------------------------------- |
59 | 59 | ||
60 | class KOAgendaItemWhatsThis :public QWhatsThis | 60 | class KOAgendaItemWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | virtual QString text( const QPoint& ) | 66 | virtual QString text( const QPoint& ) |
67 | { | 67 | { |
68 | return _view->getWhatsThisText() ; | 68 | return _view->getWhatsThisText() ; |
69 | } | 69 | } |
70 | private: | 70 | private: |
71 | KOAgendaItem * _view; | 71 | KOAgendaItem * _view; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
75 | const char *name,WFlags) : | 75 | const char *name,WFlags) : |
76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
77 | { | 77 | { |
78 | #ifndef DESKTOP_VERSION | 78 | #ifndef DESKTOP_VERSION |
79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
80 | #endif | 80 | #endif |
81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); |
82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
83 | setWFlags ( wflags); | 83 | setWFlags ( wflags); |
84 | mAllDay = allday; | 84 | mAllDay = allday; |
85 | init ( incidence, qd ); | 85 | init ( incidence, qd ); |
86 | //setMouseTracking(true); | 86 | //setMouseTracking(true); |
87 | //setAcceptDrops(true); | 87 | //setAcceptDrops(true); |
88 | xPaintCoord = -1; | 88 | xPaintCoord = -1; |
89 | yPaintCoord = -1; | 89 | yPaintCoord = -1; |
90 | } | 90 | } |
91 | QString KOAgendaItem::getWhatsThisText() | 91 | QString KOAgendaItem::getWhatsThisText() |
92 | { | 92 | { |
93 | if ( mIncidence ) | 93 | if ( mIncidence ) |
94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
95 | KOPrefs::instance()->mWTshowDetails, | 95 | KOPrefs::instance()->mWTshowDetails, |
96 | KOPrefs::instance()->mWTshowCreated, | 96 | KOPrefs::instance()->mWTshowCreated, |
97 | KOPrefs::instance()->mWTshowChanged); | 97 | KOPrefs::instance()->mWTshowChanged); |
98 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 98 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
99 | } | 99 | } |
100 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 100 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
101 | { | 101 | { |
102 | mIncidence = incidence; | 102 | mIncidence = incidence; |
103 | mDate = qd; | 103 | mDate = qd; |
104 | mFirstMultiItem = 0; | 104 | mFirstMultiItem = 0; |
105 | mNextMultiItem = 0; | 105 | mNextMultiItem = 0; |
106 | mLastMultiItem = 0; | 106 | mLastMultiItem = 0; |
107 | computeText(); | 107 | computeText(); |
108 | 108 | ||
109 | if ( (incidence->type() == "Todo") && | 109 | if ( (incidence->typeID() == todoID ) && |
110 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 110 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
111 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 111 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
112 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 112 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
113 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 113 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
114 | else | 114 | else |
115 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 115 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
116 | } | 116 | } |
117 | else { | 117 | else { |
118 | QStringList categories = mIncidence->categories(); | 118 | QStringList categories = mIncidence->categories(); |
119 | QString cat = categories.first(); | 119 | QString cat = categories.first(); |
120 | if (cat.isEmpty()) { | 120 | if (cat.isEmpty()) { |
121 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 121 | if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
122 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 122 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
123 | else | 123 | else |
124 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 124 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
125 | } else { | 125 | } else { |
126 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 126 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
127 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 127 | if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
128 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 128 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
129 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 129 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | } | 133 | } |
134 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 134 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor.light(), | 135 | mBackgroundColor.dark(),mBackgroundColor.light(), |
136 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 136 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
137 | setBackgroundColor( mBackgroundColor ); | 137 | setBackgroundColor( mBackgroundColor ); |
138 | 138 | ||
139 | mConflictItems.clear(); | 139 | mConflictItems.clear(); |
140 | setCellXY(0,0,1); | 140 | setCellXY(0,0,1); |
141 | setCellXWidth(0); | 141 | setCellXWidth(0); |
142 | setSubCell(0); | 142 | setSubCell(0); |
143 | setSubCells(1); | 143 | setSubCells(1); |
144 | setMultiItem(0,0,0); | 144 | setMultiItem(0,0,0); |
145 | startMove(); | 145 | startMove(); |
146 | mSelected = true; | 146 | mSelected = true; |
147 | select(false); | 147 | select(false); |
148 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 148 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
149 | mFontPixelSize = fontinf.height();; | 149 | mFontPixelSize = fontinf.height();; |
150 | hide(); | 150 | hide(); |
151 | xPaintCoord = -1; | 151 | xPaintCoord = -1; |
152 | yPaintCoord = -1; | 152 | yPaintCoord = -1; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | KOAgendaItem::~KOAgendaItem() | 156 | KOAgendaItem::~KOAgendaItem() |
157 | { | 157 | { |
158 | #if QT_VERSION >= 0x030000 | 158 | #if QT_VERSION >= 0x030000 |
159 | 159 | ||
160 | #else | 160 | #else |
161 | delete mKOAgendaItemWhatsThis; | 161 | delete mKOAgendaItemWhatsThis; |
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | } | 164 | } |
165 | 165 | ||
166 | void KOAgendaItem::recreateIncidence() | 166 | void KOAgendaItem::recreateIncidence() |
167 | { | 167 | { |
168 | #if 0 | 168 | #if 0 |
169 | Incidence* newInc = mIncidence->clone(); | 169 | Incidence* newInc = mIncidence->clone(); |
170 | newInc->recreate(); | 170 | newInc->recreate(); |
171 | if ( mIncidence->doesRecur() ) { | 171 | if ( mIncidence->doesRecur() ) { |
172 | mIncidence->addExDate( mDate ); | 172 | mIncidence->addExDate( mDate ); |
173 | newInc->recurrence()->unsetRecurs(); | 173 | newInc->recurrence()->unsetRecurs(); |
174 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 174 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
175 | QTime tim = mIncidence->dtStart().time(); | 175 | QTime tim = mIncidence->dtStart().time(); |
176 | newInc->setDtStart( QDateTime(mDate, tim) ); | 176 | newInc->setDtStart( QDateTime(mDate, tim) ); |
177 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 177 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
178 | } | 178 | } |
179 | #endif | 179 | #endif |
180 | mIncidence = mIncidence->recreateCloneException( mDate ); | 180 | mIncidence = mIncidence->recreateCloneException( mDate ); |
181 | } | 181 | } |
182 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 182 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
183 | { | 183 | { |
184 | int size = AGENDA_ICON_SIZE; | 184 | int size = AGENDA_ICON_SIZE; |
185 | 185 | ||
186 | int yOff = 0; | 186 | int yOff = 0; |
187 | int xOff = 0; | 187 | int xOff = 0; |
188 | int x = pos().x() +3; | 188 | int x = pos().x() +3; |
189 | int y; | 189 | int y; |
190 | if ( mAllDay ) | 190 | if ( mAllDay ) |
191 | y = pos().y()+3; | 191 | y = pos().y()+3; |
192 | else | 192 | else |
193 | y = mCellYTop * ( height() / cellHeight() ) +3; | 193 | y = mCellYTop * ( height() / cellHeight() ) +3; |
194 | if (mIncidence->cancelled()) { | 194 | if (mIncidence->cancelled()) { |
195 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 195 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
196 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 196 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
197 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 197 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
198 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 198 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
199 | if ( horLayout ) | 199 | if ( horLayout ) |
200 | ++xOff; | 200 | ++xOff; |
201 | else | 201 | else |
202 | ++yOff; | 202 | ++yOff; |
203 | } | 203 | } |
204 | if (mIncidence->isAlarmEnabled()) { | 204 | if (mIncidence->isAlarmEnabled()) { |
205 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 205 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
206 | if ( horLayout ) | 206 | if ( horLayout ) |
207 | ++xOff; | 207 | ++xOff; |
208 | else | 208 | else |
209 | ++yOff; | 209 | ++yOff; |
210 | } | 210 | } |
211 | if (mIncidence->recurrence()->doesRecur()) { | 211 | if (mIncidence->recurrence()->doesRecur()) { |
212 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 212 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
213 | if ( horLayout ) | 213 | if ( horLayout ) |
214 | ++xOff; | 214 | ++xOff; |
215 | else | 215 | else |
216 | ++yOff; | 216 | ++yOff; |
217 | } | 217 | } |
218 | if (mIncidence->description().length() > 0) { | 218 | if (mIncidence->description().length() > 0) { |
219 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 219 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
220 | if ( horLayout ) | 220 | if ( horLayout ) |
221 | ++xOff; | 221 | ++xOff; |
222 | else | 222 | else |
223 | ++yOff; | 223 | ++yOff; |
224 | } | 224 | } |
225 | if (mIncidence->isReadOnly()) { | 225 | if (mIncidence->isReadOnly()) { |
226 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 226 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
227 | if ( horLayout ) | 227 | if ( horLayout ) |
228 | ++xOff; | 228 | ++xOff; |
229 | else | 229 | else |
230 | ++yOff; | 230 | ++yOff; |
231 | } | 231 | } |
232 | 232 | ||
233 | if (mIncidence->attendeeCount()>0) { | 233 | if (mIncidence->attendeeCount()>0) { |
234 | 234 | ||
235 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 235 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
236 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 236 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
237 | if ( horLayout ) | 237 | if ( horLayout ) |
238 | ++xOff; | 238 | ++xOff; |
239 | else | 239 | else |
240 | ++yOff; | 240 | ++yOff; |
241 | } else { | 241 | } else { |
242 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 242 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
243 | if (me!=0) { | 243 | if (me!=0) { |
244 | 244 | ||
245 | 245 | ||
246 | } else { | 246 | } else { |
247 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 247 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
248 | if ( horLayout ) | 248 | if ( horLayout ) |
249 | ++xOff; | 249 | ++xOff; |
250 | else | 250 | else |
251 | ++yOff; | 251 | ++yOff; |
252 | 252 | ||
253 | } | 253 | } |
254 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 254 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
255 | if ( horLayout ) | 255 | if ( horLayout ) |
256 | ++xOff; | 256 | ++xOff; |
257 | else | 257 | else |
258 | ++yOff; | 258 | ++yOff; |
259 | 259 | ||
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | return ( yOff || xOff ); | 263 | return ( yOff || xOff ); |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void KOAgendaItem::select(bool selected) | 267 | void KOAgendaItem::select(bool selected) |
268 | { | 268 | { |
269 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 269 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
270 | if (mSelected == selected) return; | 270 | if (mSelected == selected) return; |
271 | mSelected = selected; | 271 | mSelected = selected; |
272 | if ( ! isVisible() ) | 272 | if ( ! isVisible() ) |
273 | return; | 273 | return; |
274 | if ( firstMultiItem() ) | 274 | if ( firstMultiItem() ) |
275 | firstMultiItem()->select( selected ); | 275 | firstMultiItem()->select( selected ); |
276 | if ( !firstMultiItem() && nextMultiItem() ) { | 276 | if ( !firstMultiItem() && nextMultiItem() ) { |
277 | KOAgendaItem * placeItem = nextMultiItem(); | 277 | KOAgendaItem * placeItem = nextMultiItem(); |
278 | while ( placeItem ) { | 278 | while ( placeItem ) { |
279 | placeItem->select( selected ); | 279 | placeItem->select( selected ); |
280 | placeItem = placeItem->nextMultiItem(); | 280 | placeItem = placeItem->nextMultiItem(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | globalFlagBlockAgendaItemUpdate = 0; | 283 | globalFlagBlockAgendaItemUpdate = 0; |
284 | paintMe( selected ); | 284 | paintMe( selected ); |
285 | globalFlagBlockAgendaItemUpdate = 1; | 285 | globalFlagBlockAgendaItemUpdate = 1; |
286 | repaint( false ); | 286 | repaint( false ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | /* | 290 | /* |
291 | The eventFilter has to filter the mouse events of the agenda item childs. The | 291 | The eventFilter has to filter the mouse events of the agenda item childs. The |
292 | events are fed into the event handling method of KOAgendaItem. This allows the | 292 | events are fed into the event handling method of KOAgendaItem. This allows the |
293 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 293 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
294 | */ | 294 | */ |
295 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 295 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
296 | { | 296 | { |
297 | if (e->type() == QEvent::MouseButtonPress || | 297 | if (e->type() == QEvent::MouseButtonPress || |
298 | e->type() == QEvent::MouseButtonDblClick || | 298 | e->type() == QEvent::MouseButtonDblClick || |
299 | e->type() == QEvent::MouseButtonRelease || | 299 | e->type() == QEvent::MouseButtonRelease || |
300 | e->type() == QEvent::MouseMove) { | 300 | e->type() == QEvent::MouseMove) { |
301 | QMouseEvent *me = (QMouseEvent *)e; | 301 | QMouseEvent *me = (QMouseEvent *)e; |
302 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 302 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
303 | mapToGlobal(me->pos())); | 303 | mapToGlobal(me->pos())); |
304 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 304 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
305 | return event(&returnEvent); | 305 | return event(&returnEvent); |
306 | } else { | 306 | } else { |
307 | return false; | 307 | return false; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | void KOAgendaItem::repaintMe( ) | 310 | void KOAgendaItem::repaintMe( ) |
311 | { | 311 | { |
312 | paintMe ( mSelected ); | 312 | paintMe ( mSelected ); |
313 | } | 313 | } |
314 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 314 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
315 | { | 315 | { |
316 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 316 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
317 | return; | 317 | return; |
318 | QPainter pa; | 318 | QPainter pa; |
319 | 319 | ||
320 | if ( mSelected ) { | 320 | if ( mSelected ) { |
321 | pa.begin( paintPixSel() ); | 321 | pa.begin( paintPixSel() ); |
322 | } else { | 322 | } else { |
323 | if ( mAllDay ) | 323 | if ( mAllDay ) |
324 | pa.begin( paintPixAllday() ); | 324 | pa.begin( paintPixAllday() ); |
325 | else | 325 | else |
326 | pa.begin( paintPix() ); | 326 | pa.begin( paintPix() ); |
327 | } | 327 | } |
328 | int x, yy, w, h; | 328 | int x, yy, w, h; |
329 | float nfh = 7.0; | 329 | float nfh = 7.0; |
330 | x = pos().x(); w = width(); h = height (); | 330 | x = pos().x(); w = width(); h = height (); |
331 | if ( mAllDay ) | 331 | if ( mAllDay ) |
332 | yy = y(); | 332 | yy = y(); |
333 | else | 333 | else |
334 | yy = mCellYTop * ( height() / cellHeight() ); | 334 | yy = mCellYTop * ( height() / cellHeight() ); |
335 | xPaintCoord= x; | 335 | xPaintCoord= x; |
336 | yPaintCoord = yy; | 336 | yPaintCoord = yy; |
337 | wPaintCoord = width(); | 337 | wPaintCoord = width(); |
338 | hPaintCoord = height(); | 338 | hPaintCoord = height(); |
339 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 339 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
340 | if ( paint == 0 ) | 340 | if ( paint == 0 ) |
341 | paint = &pa; | 341 | paint = &pa; |
342 | bool horLayout = ( w < h ); | 342 | bool horLayout = ( w < h ); |
343 | int maxhei = mFontPixelSize+4; | 343 | int maxhei = mFontPixelSize+4; |
344 | if ( horLayout ) | 344 | if ( horLayout ) |
345 | maxhei += AGENDA_ICON_SIZE -4; | 345 | maxhei += AGENDA_ICON_SIZE -4; |
346 | bool small = ( h < maxhei ); | 346 | bool small = ( h < maxhei ); |
347 | if ( ! small ) | 347 | if ( ! small ) |
348 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 348 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
349 | else { | 349 | else { |
350 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 350 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
351 | f.setBold( false ); | 351 | f.setBold( false ); |
352 | int fh = f.pointSize(); | 352 | int fh = f.pointSize(); |
353 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 353 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
354 | if ( nfh < 6 ) | 354 | if ( nfh < 6 ) |
355 | nfh = 6; | 355 | nfh = 6; |
356 | f.setPointSize( nfh ); | 356 | f.setPointSize( nfh ); |
357 | paint->setFont(f); | 357 | paint->setFont(f); |
358 | } | 358 | } |
359 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 359 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
360 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 360 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
361 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 361 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
362 | if ( mIncidence->type() == "Todo" ) { | 362 | if ( mIncidence->typeID() == todoID ) { |
363 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 363 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
364 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 364 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
365 | int yyy = yy+3; | 365 | int yyy = yy+3; |
366 | if ( tempTodo->isCompleted() ) | 366 | if ( tempTodo->isCompleted() ) |
367 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 367 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
368 | else { | 368 | else { |
369 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 369 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
370 | 370 | ||
371 | } | 371 | } |
372 | } | 372 | } |
373 | bool addIcon = false; | 373 | bool addIcon = false; |
374 | if ( ! small || w > 3 * h || h > 3* w ) | 374 | if ( ! small || w > 3 * h || h > 3* w ) |
375 | addIcon = updateIcons( paint, horLayout ); | 375 | addIcon = updateIcons( paint, horLayout ); |
376 | 376 | ||
377 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 377 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
378 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 378 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
379 | if ( ! small ) { | 379 | if ( ! small ) { |
380 | x += 3; yy += 3;w -= 6; h-= 5; | 380 | x += 3; yy += 3;w -= 6; h-= 5; |
381 | } else { | 381 | } else { |
382 | x += 2; yy += 1;w -= 4; h-= 4; | 382 | x += 2; yy += 1;w -= 4; h-= 4; |
383 | if ( nfh < 6.01 ) { | 383 | if ( nfh < 6.01 ) { |
384 | yy -= 2; | 384 | yy -= 2; |
385 | h += 4; | 385 | h += 4; |
386 | } | 386 | } |
387 | else | 387 | else |
388 | if ( nfh < h -2 ) | 388 | if ( nfh < h -2 ) |
389 | ++yy; | 389 | ++yy; |
390 | } | 390 | } |
391 | int align; | 391 | int align; |
392 | #ifndef DESKTOP_VERSION | 392 | #ifndef DESKTOP_VERSION |
393 | align = ( AlignLeft|WordBreak|AlignTop); | 393 | align = ( AlignLeft|WordBreak|AlignTop); |
394 | #else | 394 | #else |
395 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 395 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
396 | #endif | 396 | #endif |
397 | if ( addIcon ) { | 397 | if ( addIcon ) { |
398 | if ( ! horLayout ) { | 398 | if ( ! horLayout ) { |
399 | x += AGENDA_ICON_SIZE+3; | 399 | x += AGENDA_ICON_SIZE+3; |
400 | w -= (AGENDA_ICON_SIZE+3); | 400 | w -= (AGENDA_ICON_SIZE+3); |
401 | } | 401 | } |
402 | else { | 402 | else { |
403 | yy+= AGENDA_ICON_SIZE+2; | 403 | yy+= AGENDA_ICON_SIZE+2; |
404 | h -=(AGENDA_ICON_SIZE+3); | 404 | h -=(AGENDA_ICON_SIZE+3); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 407 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
408 | if ( colsum < 250 ) | 408 | if ( colsum < 250 ) |
409 | paint->setPen ( white); | 409 | paint->setPen ( white); |
410 | if ( x < 0 ) { | 410 | if ( x < 0 ) { |
411 | w = w+x-3; | 411 | w = w+x-3; |
412 | x = 3; | 412 | x = 3; |
413 | if ( w > parentWidget()->width() ){ | 413 | if ( w > parentWidget()->width() ){ |
414 | w = parentWidget()->width() - 6; | 414 | w = parentWidget()->width() - 6; |
415 | #ifndef DESKTOP_VERSION | 415 | #ifndef DESKTOP_VERSION |
416 | align = ( AlignHCenter|WordBreak|AlignTop); | 416 | align = ( AlignHCenter|WordBreak|AlignTop); |
417 | #else | 417 | #else |
418 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 418 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
419 | #endif | 419 | #endif |
420 | 420 | ||
421 | } | 421 | } |
422 | } | 422 | } |
423 | QRect dr; | 423 | QRect dr; |
424 | if ( w + x > parentWidget()->width() ) | 424 | if ( w + x > parentWidget()->width() ) |
425 | w = parentWidget()->width()-x; | 425 | w = parentWidget()->width()-x; |
426 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 426 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
427 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 427 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
428 | if ( mIncidence->cancelled() ){ | 428 | if ( mIncidence->cancelled() ){ |
429 | 429 | ||
430 | 430 | ||
431 | small = ( height() < 20 ); | 431 | small = ( height() < 20 ); |
432 | 432 | ||
433 | if ( ! small ) { | 433 | if ( ! small ) { |
434 | QFontMetrics fm ( paint->font() ); | 434 | QFontMetrics fm ( paint->font() ); |
435 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 435 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
436 | } | 436 | } |
437 | 437 | ||
438 | } | 438 | } |
439 | pa.end(); | 439 | pa.end(); |
440 | 440 | ||
441 | } | 441 | } |
442 | void KOAgendaItem::resizePixmap( int w , int h ) | 442 | void KOAgendaItem::resizePixmap( int w , int h ) |
443 | { | 443 | { |
444 | paintPix()->resize( w, h ); | 444 | paintPix()->resize( w, h ); |
445 | paintPixSel()->resize( w, h ); | 445 | paintPixSel()->resize( w, h ); |
446 | 446 | ||
447 | } | 447 | } |
448 | QPixmap * KOAgendaItem::paintPix() | 448 | QPixmap * KOAgendaItem::paintPix() |
449 | { | 449 | { |
450 | static QPixmap* mPaintPix = 0; | 450 | static QPixmap* mPaintPix = 0; |
451 | if ( ! mPaintPix ) { | 451 | if ( ! mPaintPix ) { |
452 | int w = QApplication::desktop()->width(); | 452 | int w = QApplication::desktop()->width(); |
453 | int h = QApplication::desktop()->height(); | 453 | int h = QApplication::desktop()->height(); |
454 | mPaintPix = new QPixmap(w,h); | 454 | mPaintPix = new QPixmap(w,h); |
455 | } | 455 | } |
456 | return mPaintPix ; | 456 | return mPaintPix ; |
457 | } | 457 | } |
458 | QPixmap * KOAgendaItem::paintPixAllday() | 458 | QPixmap * KOAgendaItem::paintPixAllday() |
459 | { | 459 | { |
460 | static QPixmap* mPaintPixA = 0; | 460 | static QPixmap* mPaintPixA = 0; |
461 | if ( ! mPaintPixA ) { | 461 | if ( ! mPaintPixA ) { |
462 | int w = QApplication::desktop()->width(); | 462 | int w = QApplication::desktop()->width(); |
463 | int h = QApplication::desktop()->height()/3; | 463 | int h = QApplication::desktop()->height()/3; |
464 | mPaintPixA = new QPixmap(w,h); | 464 | mPaintPixA = new QPixmap(w,h); |
465 | } | 465 | } |
466 | return mPaintPixA ; | 466 | return mPaintPixA ; |
467 | } | 467 | } |
468 | QPixmap * KOAgendaItem::paintPixSel() | 468 | QPixmap * KOAgendaItem::paintPixSel() |
469 | { | 469 | { |
470 | static QPixmap* mPaintPixSel = 0; | 470 | static QPixmap* mPaintPixSel = 0; |
471 | if ( ! mPaintPixSel ) { | 471 | if ( ! mPaintPixSel ) { |
472 | int w = QApplication::desktop()->width(); | 472 | int w = QApplication::desktop()->width(); |
473 | int h = QApplication::desktop()->height(); | 473 | int h = QApplication::desktop()->height(); |
474 | mPaintPixSel = new QPixmap(w,h); | 474 | mPaintPixSel = new QPixmap(w,h); |
475 | } | 475 | } |
476 | return mPaintPixSel ; | 476 | return mPaintPixSel ; |
477 | } | 477 | } |
478 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 478 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
479 | { | 479 | { |
480 | 480 | ||
481 | if ( globalFlagBlockAgendaItemPaint ) | 481 | if ( globalFlagBlockAgendaItemPaint ) |
482 | return; | 482 | return; |
483 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 483 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
484 | return; | 484 | return; |
485 | int yy; | 485 | int yy; |
486 | if ( mAllDay ) | 486 | if ( mAllDay ) |
487 | yy = y(); | 487 | yy = y(); |
488 | else | 488 | else |
489 | yy = mCellYTop * ( height() / cellHeight() ); | 489 | yy = mCellYTop * ( height() / cellHeight() ); |
490 | int xx = x(); | 490 | int xx = x(); |
491 | 491 | ||
492 | if ( xPaintCoord != xx || yPaintCoord != yy || | 492 | if ( xPaintCoord != xx || yPaintCoord != yy || |
493 | wPaintCoord != width() || hPaintCoord != height()) { | 493 | wPaintCoord != width() || hPaintCoord != height()) { |
494 | xPaintCoord= xx; | 494 | xPaintCoord= xx; |
495 | yPaintCoord = yy; | 495 | yPaintCoord = yy; |
496 | wPaintCoord = width(); | 496 | wPaintCoord = width(); |
497 | hPaintCoord = height(); | 497 | hPaintCoord = height(); |
498 | globalFlagBlockAgendaItemUpdate = 0; | 498 | globalFlagBlockAgendaItemUpdate = 0; |
499 | paintMe( mSelected ); | 499 | paintMe( mSelected ); |
500 | //qDebug("calling paintMe "); | 500 | //qDebug("calling paintMe "); |
501 | globalFlagBlockAgendaItemUpdate = 1; | 501 | globalFlagBlockAgendaItemUpdate = 1; |
502 | } | 502 | } |
503 | int rx, ry, rw, rh; | 503 | int rx, ry, rw, rh; |
504 | rx = e->rect().x(); | 504 | rx = e->rect().x(); |
505 | ry = e->rect().y(); | 505 | ry = e->rect().y(); |
506 | rw = e->rect().width(); | 506 | rw = e->rect().width(); |
507 | rh = e->rect().height(); | 507 | rh = e->rect().height(); |
508 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 508 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
509 | 509 | ||
510 | QPixmap* paintFrom ; | 510 | QPixmap* paintFrom ; |
511 | if ( mSelected ) { | 511 | if ( mSelected ) { |
512 | paintFrom = paintPixSel(); | 512 | paintFrom = paintPixSel(); |
513 | } else { | 513 | } else { |
514 | if ( mAllDay ) | 514 | if ( mAllDay ) |
515 | paintFrom = paintPixAllday(); | 515 | paintFrom = paintPixAllday(); |
516 | else | 516 | else |
517 | paintFrom = paintPix(); | 517 | paintFrom = paintPix(); |
518 | } | 518 | } |
519 | xx += rx; | 519 | xx += rx; |
520 | 520 | ||
521 | if ( xx < 0 ) { | 521 | if ( xx < 0 ) { |
522 | rw = rw + xx; | 522 | rw = rw + xx; |
523 | rx -= xx; | 523 | rx -= xx; |
524 | xx = 0; | 524 | xx = 0; |
525 | if ( rw <= 1 ) { | 525 | if ( rw <= 1 ) { |
526 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 526 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | } | 529 | } |
530 | if ( paintFrom->width() < xx+rw ) { | 530 | if ( paintFrom->width() < xx+rw ) { |
531 | rw = paintFrom->width() - xx; | 531 | rw = paintFrom->width() - xx; |
532 | if ( rw <= 1 ) { | 532 | if ( rw <= 1 ) { |
533 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 533 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
534 | return; | 534 | return; |
535 | } | 535 | } |
536 | } | 536 | } |
537 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 537 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
538 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 538 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
539 | } | 539 | } |
540 | void KOAgendaItem::computeText() | 540 | void KOAgendaItem::computeText() |
541 | { | 541 | { |
542 | mDisplayedText = mIncidence->summary(); | 542 | mDisplayedText = mIncidence->summary(); |
543 | if ( (mIncidence->type() == "Todo") ) { | 543 | if ( (mIncidence->typeID() == todoID ) ) { |
544 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 544 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
545 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 545 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
546 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 546 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
547 | else if ( !(mIncidence->doesFloat())) | 547 | else if ( !(mIncidence->doesFloat())) |
548 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 548 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
549 | } | 549 | } |
550 | } else { | 550 | } else { |
551 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 551 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
552 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 552 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
553 | 553 | ||
554 | if ( mAllDay ) { | 554 | if ( mAllDay ) { |
555 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 555 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
556 | if ( mIncidence->doesRecur() ) { | 556 | if ( mIncidence->doesRecur() ) { |
557 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 557 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
558 | } else { | 558 | } else { |
559 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 559 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
560 | } | 560 | } |
561 | } | 561 | } |
562 | } | 562 | } |
563 | } | 563 | } |
564 | 564 | ||
565 | if ( !mIncidence->location().isEmpty() ) { | 565 | if ( !mIncidence->location().isEmpty() ) { |
566 | if ( mAllDay ) | 566 | if ( mAllDay ) |
567 | mDisplayedText += " ("; | 567 | mDisplayedText += " ("; |
568 | else | 568 | else |
569 | mDisplayedText += "\n("; | 569 | mDisplayedText += "\n("; |
570 | mDisplayedText += mIncidence->location() +")"; | 570 | mDisplayedText += mIncidence->location() +")"; |
571 | } | 571 | } |
572 | #ifdef DESKTOP_VERSION | 572 | #ifdef DESKTOP_VERSION |
573 | QString tipText = mIncidence->summary(); | 573 | QString tipText = mIncidence->summary(); |
574 | if ( !mIncidence->doesFloat() ) { | 574 | if ( !mIncidence->doesFloat() ) { |
575 | if ( mIncidence->type() == "Event" ) { | 575 | if ( mIncidence->typeID() == eventID ) { |
576 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 576 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
577 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 577 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
578 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 578 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
579 | } | 579 | } |
580 | else { | 580 | else { |
581 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 581 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
582 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 582 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
583 | } | 583 | } |
584 | } | 584 | } |
585 | else if ( mIncidence->type() == "Todo" ) { | 585 | else if ( mIncidence->typeID() == todoID ) { |
586 | if (mIncidence->hasStartDate()) | 586 | if (mIncidence->hasStartDate()) |
587 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 587 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
588 | if (((Todo*)mIncidence)->hasDueDate()) | 588 | if (((Todo*)mIncidence)->hasDueDate()) |
589 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 589 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
590 | } | 590 | } |
591 | } else if ( mIncidence->type() == "Todo" ) { | 591 | } else if ( mIncidence->typeID() == todoID ) { |
592 | if (mIncidence->hasStartDate()) | 592 | if (mIncidence->hasStartDate()) |
593 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 593 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
594 | if (((Todo*)mIncidence)->hasDueDate()) | 594 | if (((Todo*)mIncidence)->hasDueDate()) |
595 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 595 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
596 | } | 596 | } |
597 | 597 | ||
598 | if (!mIncidence->location().isEmpty()) { | 598 | if (!mIncidence->location().isEmpty()) { |
599 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 599 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
600 | } | 600 | } |
601 | QToolTip::add(this,tipText,toolTipGroup(),""); | 601 | QToolTip::add(this,tipText,toolTipGroup(),""); |
602 | #endif | 602 | #endif |
603 | } | 603 | } |
604 | void KOAgendaItem::updateItem() | 604 | void KOAgendaItem::updateItem() |
605 | { | 605 | { |
606 | computeText(); | 606 | computeText(); |
607 | 607 | ||
608 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 608 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
609 | paintMe( mSelected ); | 609 | paintMe( mSelected ); |
610 | repaint( false); | 610 | repaint( false); |
611 | } | 611 | } |
612 | 612 | ||
613 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 613 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
614 | { | 614 | { |
615 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 615 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
616 | paintMe( mSelected ); | 616 | paintMe( mSelected ); |
617 | repaint( false ); | 617 | repaint( false ); |
618 | } | 618 | } |
619 | 619 | ||
620 | /* | 620 | /* |
621 | Return height of item in units of agenda cells | 621 | Return height of item in units of agenda cells |
622 | */ | 622 | */ |
623 | int KOAgendaItem::cellHeight() | 623 | int KOAgendaItem::cellHeight() |
624 | { | 624 | { |
625 | int ret = mCellYBottom - mCellYTop + 1; | 625 | int ret = mCellYBottom - mCellYTop + 1; |
626 | if ( ret <= 0 ) { | 626 | if ( ret <= 0 ) { |
627 | ret = 1; | 627 | ret = 1; |
628 | mCellYBottom = 0; | 628 | mCellYBottom = 0; |
629 | mCellYTop = 0; | 629 | mCellYTop = 0; |
630 | } | 630 | } |
631 | return ret; | 631 | return ret; |
632 | } | 632 | } |
633 | 633 | ||
634 | /* | 634 | /* |
635 | Return height of item in units of agenda cells | 635 | Return height of item in units of agenda cells |
636 | */ | 636 | */ |
637 | int KOAgendaItem::cellWidth() | 637 | int KOAgendaItem::cellWidth() |
638 | { | 638 | { |
639 | return mCellXWidth - mCellX + 1; | 639 | return mCellXWidth - mCellX + 1; |
640 | } | 640 | } |
641 | 641 | ||
642 | void KOAgendaItem::setItemDate(QDate qd) | 642 | void KOAgendaItem::setItemDate(QDate qd) |
643 | { | 643 | { |
644 | mDate = qd; | 644 | mDate = qd; |
645 | } | 645 | } |
646 | 646 | ||
647 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 647 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
648 | { | 648 | { |
649 | mCellX = X; | 649 | mCellX = X; |
650 | mCellYTop = YTop; | 650 | mCellYTop = YTop; |
651 | mCellYBottom = YBottom; | 651 | mCellYBottom = YBottom; |
652 | } | 652 | } |
653 | 653 | ||
654 | void KOAgendaItem::setCellXWidth(int xwidth) | 654 | void KOAgendaItem::setCellXWidth(int xwidth) |
655 | { | 655 | { |
656 | mCellXWidth = xwidth; | 656 | mCellXWidth = xwidth; |
657 | } | 657 | } |
658 | 658 | ||
659 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 659 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
660 | { | 660 | { |
661 | mCellX = XLeft; | 661 | mCellX = XLeft; |
662 | mCellXWidth = XRight; | 662 | mCellXWidth = XRight; |
663 | } | 663 | } |
664 | 664 | ||
665 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 665 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
666 | { | 666 | { |
667 | mCellYTop = YTop; | 667 | mCellYTop = YTop; |
668 | mCellYBottom = YBottom; | 668 | mCellYBottom = YBottom; |
669 | } | 669 | } |
670 | 670 | ||
671 | void KOAgendaItem::setSubCell(int subCell) | 671 | void KOAgendaItem::setSubCell(int subCell) |
672 | { | 672 | { |
673 | mSubCell = subCell; | 673 | mSubCell = subCell; |
674 | } | 674 | } |
675 | 675 | ||
676 | void KOAgendaItem::setSubCells(int subCells) | 676 | void KOAgendaItem::setSubCells(int subCells) |
677 | { | 677 | { |
678 | mSubCells = subCells; | 678 | mSubCells = subCells; |
679 | } | 679 | } |
680 | 680 | ||
681 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 681 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
682 | KOAgendaItem *last) | 682 | KOAgendaItem *last) |
683 | { | 683 | { |
684 | mFirstMultiItem = first; | 684 | mFirstMultiItem = first; |
685 | mNextMultiItem = next; | 685 | mNextMultiItem = next; |
686 | mLastMultiItem = last; | 686 | mLastMultiItem = last; |
687 | } | 687 | } |
688 | 688 | ||
689 | void KOAgendaItem::startMove() | 689 | void KOAgendaItem::startMove() |
690 | { | 690 | { |
691 | mStartCellX = mCellX; | 691 | mStartCellX = mCellX; |
692 | mStartCellXWidth = mCellXWidth; | 692 | mStartCellXWidth = mCellXWidth; |
693 | mStartCellYTop = mCellYTop; | 693 | mStartCellYTop = mCellYTop; |
694 | mStartCellYBottom = mCellYBottom; | 694 | mStartCellYBottom = mCellYBottom; |
695 | } | 695 | } |
696 | 696 | ||
697 | void KOAgendaItem::resetMove() | 697 | void KOAgendaItem::resetMove() |
698 | { | 698 | { |
699 | mCellX = mStartCellX; | 699 | mCellX = mStartCellX; |
700 | mCellXWidth = mStartCellXWidth; | 700 | mCellXWidth = mStartCellXWidth; |
701 | mCellYTop = mStartCellYTop; | 701 | mCellYTop = mStartCellYTop; |
702 | mCellYBottom = mStartCellYBottom; | 702 | mCellYBottom = mStartCellYBottom; |
703 | } | 703 | } |
704 | 704 | ||
705 | void KOAgendaItem::moveRelative(int dx, int dy) | 705 | void KOAgendaItem::moveRelative(int dx, int dy) |
706 | { | 706 | { |
707 | int newX = cellX() + dx; | 707 | int newX = cellX() + dx; |
708 | int newXWidth = cellXWidth() + dx; | 708 | int newXWidth = cellXWidth() + dx; |
709 | int newYTop = cellYTop() + dy; | 709 | int newYTop = cellYTop() + dy; |
710 | int newYBottom = cellYBottom() + dy; | 710 | int newYBottom = cellYBottom() + dy; |
711 | setCellXY(newX,newYTop,newYBottom); | 711 | setCellXY(newX,newYTop,newYBottom); |
712 | setCellXWidth(newXWidth); | 712 | setCellXWidth(newXWidth); |
713 | } | 713 | } |
714 | 714 | ||
715 | void KOAgendaItem::expandTop(int dy) | 715 | void KOAgendaItem::expandTop(int dy) |
716 | { | 716 | { |
717 | int newYTop = cellYTop() + dy; | 717 | int newYTop = cellYTop() + dy; |
718 | int newYBottom = cellYBottom(); | 718 | int newYBottom = cellYBottom(); |
719 | if (newYTop > newYBottom) newYTop = newYBottom; | 719 | if (newYTop > newYBottom) newYTop = newYBottom; |
720 | setCellY(newYTop, newYBottom); | 720 | setCellY(newYTop, newYBottom); |
721 | } | 721 | } |
722 | 722 | ||
723 | void KOAgendaItem::expandBottom(int dy) | 723 | void KOAgendaItem::expandBottom(int dy) |
724 | { | 724 | { |
725 | int newYTop = cellYTop(); | 725 | int newYTop = cellYTop(); |
726 | int newYBottom = cellYBottom() + dy; | 726 | int newYBottom = cellYBottom() + dy; |
727 | if (newYBottom < newYTop) newYBottom = newYTop; | 727 | if (newYBottom < newYTop) newYBottom = newYTop; |
728 | setCellY(newYTop, newYBottom); | 728 | setCellY(newYTop, newYBottom); |
729 | } | 729 | } |
730 | 730 | ||
731 | void KOAgendaItem::expandLeft(int dx) | 731 | void KOAgendaItem::expandLeft(int dx) |
732 | { | 732 | { |
733 | int newX = cellX() + dx; | 733 | int newX = cellX() + dx; |
734 | int newXWidth = cellXWidth(); | 734 | int newXWidth = cellXWidth(); |
735 | if (newX > newXWidth) newX = newXWidth; | 735 | if (newX > newXWidth) newX = newXWidth; |
736 | setCellX(newX,newXWidth); | 736 | setCellX(newX,newXWidth); |
737 | } | 737 | } |
738 | 738 | ||
739 | void KOAgendaItem::expandRight(int dx) | 739 | void KOAgendaItem::expandRight(int dx) |
740 | { | 740 | { |
741 | int newX = cellX(); | 741 | int newX = cellX(); |
742 | int newXWidth = cellXWidth() + dx; | 742 | int newXWidth = cellXWidth() + dx; |
743 | if (newXWidth < newX) newXWidth = newX; | 743 | if (newXWidth < newX) newXWidth = newX; |
744 | setCellX(newX,newXWidth); | 744 | setCellX(newX,newXWidth); |
745 | } | 745 | } |
746 | 746 | ||
747 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 747 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
748 | { | 748 | { |
749 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 749 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
750 | return mToolTipGroup; | 750 | return mToolTipGroup; |
751 | } | 751 | } |
752 | 752 | ||
753 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 753 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
754 | { | 754 | { |
755 | #ifndef KORG_NODND | 755 | #ifndef KORG_NODND |
756 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 756 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
757 | !QTextDrag::canDecode( e ) ) { | 757 | !QTextDrag::canDecode( e ) ) { |
758 | e->ignore(); | 758 | e->ignore(); |
759 | return; | 759 | return; |
760 | } | 760 | } |
761 | e->accept(); | 761 | e->accept(); |
762 | #endif | 762 | #endif |
763 | } | 763 | } |
764 | 764 | ||
765 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 765 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
766 | { | 766 | { |
767 | #ifndef KORG_NODND | 767 | #ifndef KORG_NODND |
768 | QString text; | 768 | QString text; |
769 | if(QTextDrag::decode(e,text)) | 769 | if(QTextDrag::decode(e,text)) |
770 | { | 770 | { |
771 | kdDebug() << "Dropped : " << text << endl; | 771 | kdDebug() << "Dropped : " << text << endl; |
772 | QStringList emails = QStringList::split(",",text); | 772 | QStringList emails = QStringList::split(",",text); |
773 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 773 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
774 | kdDebug() << " Email: " << (*it) << endl; | 774 | kdDebug() << " Email: " << (*it) << endl; |
775 | int pos = (*it).find("<"); | 775 | int pos = (*it).find("<"); |
776 | QString name = (*it).left(pos); | 776 | QString name = (*it).left(pos); |
777 | QString email = (*it).mid(pos); | 777 | QString email = (*it).mid(pos); |
778 | if (!email.isEmpty()) { | 778 | if (!email.isEmpty()) { |
779 | mIncidence->addAttendee(new Attendee(name,email)); | 779 | mIncidence->addAttendee(new Attendee(name,email)); |
780 | } | 780 | } |
781 | } | 781 | } |
782 | } | 782 | } |
783 | #endif | 783 | #endif |
784 | } | 784 | } |
785 | 785 | ||
786 | 786 | ||
787 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 787 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
788 | { | 788 | { |
789 | return mConflictItems; | 789 | return mConflictItems; |
790 | } | 790 | } |
791 | 791 | ||
792 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 792 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
793 | { | 793 | { |
794 | mConflictItems = ci; | 794 | mConflictItems = ci; |
795 | KOAgendaItem *item; | 795 | KOAgendaItem *item; |
796 | for ( item=mConflictItems.first(); item != 0; | 796 | for ( item=mConflictItems.first(); item != 0; |
797 | item=mConflictItems.next() ) { | 797 | item=mConflictItems.next() ) { |
798 | item->addConflictItem(this); | 798 | item->addConflictItem(this); |
799 | } | 799 | } |
800 | } | 800 | } |
801 | 801 | ||
802 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 802 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
803 | { | 803 | { |
804 | if (mConflictItems.find(ci)<0) | 804 | if (mConflictItems.find(ci)<0) |
805 | mConflictItems.append(ci); | 805 | mConflictItems.append(ci); |
806 | } | 806 | } |
807 | 807 | ||
808 | bool KOAgendaItem::checkLayout() | 808 | bool KOAgendaItem::checkLayout() |
809 | { | 809 | { |
810 | if ( !mConflictItems.count() ) | 810 | if ( !mConflictItems.count() ) |
811 | return true; | 811 | return true; |
812 | int max = 0; | 812 | int max = 0; |
813 | KOAgendaItem *item; | 813 | KOAgendaItem *item; |
814 | for ( item=mConflictItems.first(); item != 0; | 814 | for ( item=mConflictItems.first(); item != 0; |
815 | item=mConflictItems.next() ) { | 815 | item=mConflictItems.next() ) { |
816 | if ( item->subCells() > max ) | 816 | if ( item->subCells() > max ) |
817 | max = item->subCells(); | 817 | max = item->subCells(); |
818 | } | 818 | } |
819 | if ( max > subCells() ) { | 819 | if ( max > subCells() ) { |
820 | setSubCells( max ); | 820 | setSubCells( max ); |
821 | return false; | 821 | return false; |
822 | } | 822 | } |
823 | return true; | 823 | return true; |
824 | } | 824 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 7022e02..be51694 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1371 +1,1371 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpaintdevicemetrics.h> | 38 | #include <qpaintdevicemetrics.h> |
39 | 39 | ||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | 44 | ||
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | #include <libkcal/calendar.h> | 46 | #include <libkcal/calendar.h> |
47 | #include <libkcal/calendarlocal.h> | 47 | #include <libkcal/calendarlocal.h> |
48 | #include <libkcal/icalformat.h> | 48 | #include <libkcal/icalformat.h> |
49 | #include <libkcal/vcalformat.h> | 49 | #include <libkcal/vcalformat.h> |
50 | #include <libkcal/recurrence.h> | 50 | #include <libkcal/recurrence.h> |
51 | #include <libkcal/filestorage.h> | 51 | #include <libkcal/filestorage.h> |
52 | #include <libkdepim/categoryselectdialog.h> | 52 | #include <libkdepim/categoryselectdialog.h> |
53 | #include <libkcal/kincidenceformatter.h> | 53 | #include <libkcal/kincidenceformatter.h> |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef KORG_NOPRINTER | 60 | #ifndef KORG_NOPRINTER |
61 | #include "calprinter.h" | 61 | #include "calprinter.h" |
62 | #endif | 62 | #endif |
63 | #include "koglobals.h" | 63 | #include "koglobals.h" |
64 | #include "koprefs.h" | 64 | #include "koprefs.h" |
65 | #include "kfiledialog.h" | 65 | #include "kfiledialog.h" |
66 | 66 | ||
67 | #include "kolistview.h" | 67 | #include "kolistview.h" |
68 | #include "koeventviewer.h" | 68 | #include "koeventviewer.h" |
69 | 69 | ||
70 | 70 | ||
71 | 71 | ||
72 | 72 | ||
73 | class KOListViewWhatsThis :public QWhatsThis | 73 | class KOListViewWhatsThis :public QWhatsThis |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | virtual QString text( const QPoint& p) | 79 | virtual QString text( const QPoint& p) |
80 | { | 80 | { |
81 | return _view->getWhatsThisText(p) ; | 81 | return _view->getWhatsThisText(p) ; |
82 | } | 82 | } |
83 | private: | 83 | private: |
84 | QWidget* _wid; | 84 | QWidget* _wid; |
85 | KOListView * _view; | 85 | KOListView * _view; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
90 | { | 90 | { |
91 | mItem = item; | 91 | mItem = item; |
92 | mDate = date; | 92 | mDate = date; |
93 | } | 93 | } |
94 | 94 | ||
95 | ListItemVisitor::~ListItemVisitor() | 95 | ListItemVisitor::~ListItemVisitor() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | bool ListItemVisitor::visit(Event *e) | 99 | bool ListItemVisitor::visit(Event *e) |
100 | { | 100 | { |
101 | bool ok = false; | 101 | bool ok = false; |
102 | QString start, end; | 102 | QString start, end; |
103 | QDate ds, de; | 103 | QDate ds, de; |
104 | if ( e->doesRecur() ) { | 104 | if ( e->doesRecur() ) { |
105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
106 | if ( ok ) { | 106 | if ( ok ) { |
107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
108 | start = KGlobal::locale()->formatDate(ds,true); | 108 | start = KGlobal::locale()->formatDate(ds,true); |
109 | de = ds.addDays( days); | 109 | de = ds.addDays( days); |
110 | end = KGlobal::locale()->formatDate(de,true); | 110 | end = KGlobal::locale()->formatDate(de,true); |
111 | } | 111 | } |
112 | 112 | ||
113 | } | 113 | } |
114 | if ( ! ok ) { | 114 | if ( ! ok ) { |
115 | start =e->dtStartDateStr(); | 115 | start =e->dtStartDateStr(); |
116 | end = e->dtEndDateStr(); | 116 | end = e->dtEndDateStr(); |
117 | ds = e->dtStart().date(); | 117 | ds = e->dtStart().date(); |
118 | de = e->dtEnd().date(); | 118 | de = e->dtEnd().date(); |
119 | } | 119 | } |
120 | mItem->setText(0,e->summary()); | 120 | mItem->setText(0,e->summary()); |
121 | mItem->setText(1,start); | 121 | mItem->setText(1,start); |
122 | if ( e->doesFloat() ) | 122 | if ( e->doesFloat() ) |
123 | mItem->setText(2,"---"); | 123 | mItem->setText(2,"---"); |
124 | else | 124 | else |
125 | mItem->setText(2,e->dtStartTimeStr()); | 125 | mItem->setText(2,e->dtStartTimeStr()); |
126 | mItem->setText(3,end); | 126 | mItem->setText(3,end); |
127 | if ( e->doesFloat() ) | 127 | if ( e->doesFloat() ) |
128 | mItem->setText(4,"---"); | 128 | mItem->setText(4,"---"); |
129 | else | 129 | else |
130 | mItem->setText(4,e->dtEndTimeStr()); | 130 | mItem->setText(4,e->dtEndTimeStr()); |
131 | if ( e->isAlarmEnabled() ) { | 131 | if ( e->isAlarmEnabled() ) { |
132 | mItem->setText(5,e->alarms().first()->offsetText() ); | 132 | mItem->setText(5,e->alarms().first()->offsetText() ); |
133 | } else { | 133 | } else { |
134 | mItem->setText(5, i18n("No")); | 134 | mItem->setText(5, i18n("No")); |
135 | } | 135 | } |
136 | mItem->setText(6, e->recurrence()->recurrenceText()); | 136 | mItem->setText(6, e->recurrence()->recurrenceText()); |
137 | if( ! e->doesRecur() ) | 137 | if( ! e->doesRecur() ) |
138 | mItem->setSortKey( 6, "-" ); | 138 | mItem->setSortKey( 6, "-" ); |
139 | mItem->setText(7,"---"); | 139 | mItem->setText(7,"---"); |
140 | mItem->setText(8,"---"); | 140 | mItem->setText(8,"---"); |
141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
142 | mItem->setText(10,e->categoriesStr()); | 142 | mItem->setText(10,e->categoriesStr()); |
143 | 143 | ||
144 | QString key; | 144 | QString key; |
145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
146 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 146 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
147 | mItem->setSortKey(1,key); | 147 | mItem->setSortKey(1,key); |
148 | 148 | ||
149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
150 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 150 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
151 | mItem->setSortKey(3,key); | 151 | mItem->setSortKey(3,key); |
152 | return true; | 152 | return true; |
153 | } | 153 | } |
154 | 154 | ||
155 | bool ListItemVisitor::visit(Todo *t) | 155 | bool ListItemVisitor::visit(Todo *t) |
156 | { | 156 | { |
157 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); | 157 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); |
158 | if (t->hasStartDate()) { | 158 | if (t->hasStartDate()) { |
159 | mItem->setText(1,t->dtStartDateStr()); | 159 | mItem->setText(1,t->dtStartDateStr()); |
160 | if (t->doesFloat()) { | 160 | if (t->doesFloat()) { |
161 | mItem->setText(2,"---"); | 161 | mItem->setText(2,"---"); |
162 | } else { | 162 | } else { |
163 | mItem->setText(2,t->dtStartTimeStr()); | 163 | mItem->setText(2,t->dtStartTimeStr()); |
164 | } | 164 | } |
165 | } else { | 165 | } else { |
166 | mItem->setText(1,"---"); | 166 | mItem->setText(1,"---"); |
167 | mItem->setText(2,"---"); | 167 | mItem->setText(2,"---"); |
168 | } | 168 | } |
169 | mItem->setText(3,"---"); | 169 | mItem->setText(3,"---"); |
170 | mItem->setText(4,"---"); | 170 | mItem->setText(4,"---"); |
171 | if ( t->isAlarmEnabled() ) { | 171 | if ( t->isAlarmEnabled() ) { |
172 | mItem->setText(5,t->alarms().first()->offsetText() ); | 172 | mItem->setText(5,t->alarms().first()->offsetText() ); |
173 | } else { | 173 | } else { |
174 | mItem->setText(5, i18n("No")); | 174 | mItem->setText(5, i18n("No")); |
175 | } | 175 | } |
176 | mItem->setText(6, t->recurrence()->recurrenceText()); | 176 | mItem->setText(6, t->recurrence()->recurrenceText()); |
177 | if( ! t->doesRecur() ) | 177 | if( ! t->doesRecur() ) |
178 | mItem->setSortKey( 6, "-" ); | 178 | mItem->setSortKey( 6, "-" ); |
179 | if (t->hasDueDate()) { | 179 | if (t->hasDueDate()) { |
180 | mItem->setText(7,t->dtDueDateStr()); | 180 | mItem->setText(7,t->dtDueDateStr()); |
181 | if (t->doesFloat()) { | 181 | if (t->doesFloat()) { |
182 | mItem->setText(8,"---"); | 182 | mItem->setText(8,"---"); |
183 | } else { | 183 | } else { |
184 | mItem->setText(8,t->dtDueTimeStr()); | 184 | mItem->setText(8,t->dtDueTimeStr()); |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | mItem->setText(7,"---"); | 187 | mItem->setText(7,"---"); |
188 | mItem->setText(8,"---"); | 188 | mItem->setText(8,"---"); |
189 | } | 189 | } |
190 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 190 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
191 | mItem->setText(10,t->categoriesStr()); | 191 | mItem->setText(10,t->categoriesStr()); |
192 | 192 | ||
193 | QString key; | 193 | QString key; |
194 | QDate d; | 194 | QDate d; |
195 | if (t->hasDueDate()) { | 195 | if (t->hasDueDate()) { |
196 | d = t->dtDue().date(); | 196 | d = t->dtDue().date(); |
197 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 197 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
198 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 198 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
199 | mItem->setSortKey(7,key); | 199 | mItem->setSortKey(7,key); |
200 | } | 200 | } |
201 | if ( t->hasStartDate() ) { | 201 | if ( t->hasStartDate() ) { |
202 | d = t->dtStart().date(); | 202 | d = t->dtStart().date(); |
203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
204 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 204 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
205 | mItem->setSortKey(1,key); | 205 | mItem->setSortKey(1,key); |
206 | } | 206 | } |
207 | return true; | 207 | return true; |
208 | } | 208 | } |
209 | 209 | ||
210 | bool ListItemVisitor::visit(Journal * j) | 210 | bool ListItemVisitor::visit(Journal * j) |
211 | { | 211 | { |
212 | QString des = j->description().left(30); | 212 | QString des = j->description().left(30); |
213 | des = des.simplifyWhiteSpace (); | 213 | des = des.simplifyWhiteSpace (); |
214 | des.replace (QRegExp ("\\n"),"" ); | 214 | des.replace (QRegExp ("\\n"),"" ); |
215 | des.replace (QRegExp ("\\r"),"" ); | 215 | des.replace (QRegExp ("\\r"),"" ); |
216 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 216 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
217 | mItem->setText(1,j->dtStartDateStr()); | 217 | mItem->setText(1,j->dtStartDateStr()); |
218 | mItem->setText(2,"---"); | 218 | mItem->setText(2,"---"); |
219 | mItem->setText(3,"---"); | 219 | mItem->setText(3,"---"); |
220 | mItem->setText(4,"---"); | 220 | mItem->setText(4,"---"); |
221 | mItem->setText(5,"---"); | 221 | mItem->setText(5,"---"); |
222 | mItem->setText(6,"---"); | 222 | mItem->setText(6,"---"); |
223 | mItem->setText(7,j->dtStartDateStr()); | 223 | mItem->setText(7,j->dtStartDateStr()); |
224 | mItem->setText(8,"---"); | 224 | mItem->setText(8,"---"); |
225 | mItem->setText(9,"---"); | 225 | mItem->setText(9,"---"); |
226 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 226 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
227 | 227 | ||
228 | QString key; | 228 | QString key; |
229 | QDate d = j->dtStart().date(); | 229 | QDate d = j->dtStart().date(); |
230 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 230 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
231 | mItem->setSortKey(1,key); | 231 | mItem->setSortKey(1,key); |
232 | mItem->setSortKey(7,key); | 232 | mItem->setSortKey(7,key); |
233 | 233 | ||
234 | return true; | 234 | return true; |
235 | } | 235 | } |
236 | 236 | ||
237 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 237 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
238 | const char *name) | 238 | const char *name) |
239 | : KOEventView(calendar, parent, name) | 239 | : KOEventView(calendar, parent, name) |
240 | { | 240 | { |
241 | mActiveItem = 0; | 241 | mActiveItem = 0; |
242 | mListView = new KOListViewListView(this); | 242 | mListView = new KOListViewListView(this); |
243 | mListView->addColumn(i18n("Summary")); | 243 | mListView->addColumn(i18n("Summary")); |
244 | mListView->addColumn(i18n("Start Date")); | 244 | mListView->addColumn(i18n("Start Date")); |
245 | mListView->addColumn(i18n("Start Time")); | 245 | mListView->addColumn(i18n("Start Time")); |
246 | mListView->addColumn(i18n("End Date")); | 246 | mListView->addColumn(i18n("End Date")); |
247 | mListView->addColumn(i18n("End Time")); | 247 | mListView->addColumn(i18n("End Time")); |
248 | mListView->addColumn(i18n("Alarm")); // alarm set? | 248 | mListView->addColumn(i18n("Alarm")); // alarm set? |
249 | mListView->addColumn(i18n("Recurs")); // recurs? | 249 | mListView->addColumn(i18n("Recurs")); // recurs? |
250 | mListView->addColumn(i18n("Due Date")); | 250 | mListView->addColumn(i18n("Due Date")); |
251 | mListView->addColumn(i18n("Due Time")); | 251 | mListView->addColumn(i18n("Due Time")); |
252 | mListView->addColumn(i18n("Cancelled")); | 252 | mListView->addColumn(i18n("Cancelled")); |
253 | mListView->addColumn(i18n("Categories")); | 253 | mListView->addColumn(i18n("Categories")); |
254 | 254 | ||
255 | mListView->setColumnAlignment(0,AlignLeft); | 255 | mListView->setColumnAlignment(0,AlignLeft); |
256 | mListView->setColumnAlignment(1,AlignLeft); | 256 | mListView->setColumnAlignment(1,AlignLeft); |
257 | mListView->setColumnAlignment(2,AlignHCenter); | 257 | mListView->setColumnAlignment(2,AlignHCenter); |
258 | mListView->setColumnAlignment(3,AlignLeft); | 258 | mListView->setColumnAlignment(3,AlignLeft); |
259 | mListView->setColumnAlignment(4,AlignHCenter); | 259 | mListView->setColumnAlignment(4,AlignHCenter); |
260 | mListView->setColumnAlignment(5,AlignLeft); | 260 | mListView->setColumnAlignment(5,AlignLeft); |
261 | mListView->setColumnAlignment(6,AlignLeft); | 261 | mListView->setColumnAlignment(6,AlignLeft); |
262 | mListView->setColumnAlignment(7,AlignLeft); | 262 | mListView->setColumnAlignment(7,AlignLeft); |
263 | mListView->setColumnAlignment(8,AlignLeft); | 263 | mListView->setColumnAlignment(8,AlignLeft); |
264 | mListView->setColumnAlignment(9,AlignLeft); | 264 | mListView->setColumnAlignment(9,AlignLeft); |
265 | mListView->setColumnAlignment(10,AlignLeft); | 265 | mListView->setColumnAlignment(10,AlignLeft); |
266 | mListView->setColumnWidthMode(10, QListView::Manual); | 266 | mListView->setColumnWidthMode(10, QListView::Manual); |
267 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 267 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
268 | 268 | ||
269 | int iii = 0; | 269 | int iii = 0; |
270 | for ( iii = 0; iii< 10 ; ++iii ) | 270 | for ( iii = 0; iii< 10 ; ++iii ) |
271 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 271 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
272 | 272 | ||
273 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 273 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
274 | layoutTop->addWidget(mListView); | 274 | layoutTop->addWidget(mListView); |
275 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 275 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
276 | mPopupMenu = eventPopup(); | 276 | mPopupMenu = eventPopup(); |
277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
278 | i18n("Select all"),this, | 278 | i18n("Select all"),this, |
279 | SLOT(allSelection()),true); | 279 | SLOT(allSelection()),true); |
280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
281 | i18n("Deselect all"),this, | 281 | i18n("Deselect all"),this, |
282 | SLOT(clearSelection()),true); | 282 | SLOT(clearSelection()),true); |
283 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 283 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
284 | i18n("Delete all selected"),this, | 284 | i18n("Delete all selected"),this, |
285 | SLOT(deleteAll()),true); | 285 | SLOT(deleteAll()),true); |
286 | #ifdef DESKTOP_VERSION | 286 | #ifdef DESKTOP_VERSION |
287 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 287 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
288 | i18n("Hide all selected"),this, | 288 | i18n("Hide all selected"),this, |
289 | SLOT(hideAll()),true); | 289 | SLOT(hideAll()),true); |
290 | #endif | 290 | #endif |
291 | mPopupMenu->insertSeparator(); | 291 | mPopupMenu->insertSeparator(); |
292 | #ifdef DESKTOP_VERSION | 292 | #ifdef DESKTOP_VERSION |
293 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 293 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
294 | i18n("Print complete list"),this, | 294 | i18n("Print complete list"),this, |
295 | SLOT(printList()),true); | 295 | SLOT(printList()),true); |
296 | mPopupMenu->insertSeparator(); | 296 | mPopupMenu->insertSeparator(); |
297 | #endif | 297 | #endif |
298 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 298 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
299 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 299 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
300 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 300 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
301 | SLOT(saveToFile())); | 301 | SLOT(saveToFile())); |
302 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 302 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
303 | SLOT(saveToFileVCS())); | 303 | SLOT(saveToFileVCS())); |
304 | exportPO->insertItem( i18n("Journal/Details..."),this, | 304 | exportPO->insertItem( i18n("Journal/Details..."),this, |
305 | SLOT(saveDescriptionToFile())); | 305 | SLOT(saveDescriptionToFile())); |
306 | // mPopupMenu->insertSeparator(); | 306 | // mPopupMenu->insertSeparator(); |
307 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 307 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
308 | i18n("Add Categ. to selected..."),this, | 308 | i18n("Add Categ. to selected..."),this, |
309 | SLOT(addCat()),true); | 309 | SLOT(addCat()),true); |
310 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 310 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
311 | i18n("Set Categ. for selected..."),this, | 311 | i18n("Set Categ. for selected..."),this, |
312 | SLOT(setCat()),true); | 312 | SLOT(setCat()),true); |
313 | //mPopupMenu->insertSeparator(); | 313 | //mPopupMenu->insertSeparator(); |
314 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 314 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
315 | i18n("Set alarm for selected..."),this, | 315 | i18n("Set alarm for selected..."),this, |
316 | SLOT(setAlarm()),true); | 316 | SLOT(setAlarm()),true); |
317 | 317 | ||
318 | 318 | ||
319 | #ifndef DESKTOP_VERSION | 319 | #ifndef DESKTOP_VERSION |
320 | mPopupMenu->insertSeparator(); | 320 | mPopupMenu->insertSeparator(); |
321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
322 | i18n("Beam selected via IR"),this, | 322 | i18n("Beam selected via IR"),this, |
323 | SLOT(beamSelected()),true); | 323 | SLOT(beamSelected()),true); |
324 | #endif | 324 | #endif |
325 | /* | 325 | /* |
326 | mPopupMenu = new QPopupMenu; | 326 | mPopupMenu = new QPopupMenu; |
327 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 327 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
328 | SLOT (editEvent())); | 328 | SLOT (editEvent())); |
329 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 329 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
330 | SLOT (deleteEvent())); | 330 | SLOT (deleteEvent())); |
331 | mPopupMenu->insertSeparator(); | 331 | mPopupMenu->insertSeparator(); |
332 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 332 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
333 | SLOT(showDates())); | 333 | SLOT(showDates())); |
334 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 334 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
335 | SLOT(hideDates())); | 335 | SLOT(hideDates())); |
336 | */ | 336 | */ |
337 | QObject::connect(mListView,SIGNAL( newEvent()), | 337 | QObject::connect(mListView,SIGNAL( newEvent()), |
338 | this,SIGNAL(signalNewEvent())); | 338 | this,SIGNAL(signalNewEvent())); |
339 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 339 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
340 | this,SLOT(defaultItemAction(QListViewItem *))); | 340 | this,SLOT(defaultItemAction(QListViewItem *))); |
341 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 341 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
342 | const QPoint &, int )), | 342 | const QPoint &, int )), |
343 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 343 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
344 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 344 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
345 | SLOT(processSelectionChange(QListViewItem *))); | 345 | SLOT(processSelectionChange(QListViewItem *))); |
346 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 346 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
347 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 347 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
348 | 348 | ||
349 | readSettings(KOGlobals::config(),"KOListView Layout"); | 349 | readSettings(KOGlobals::config(),"KOListView Layout"); |
350 | } | 350 | } |
351 | 351 | ||
352 | KOListView::~KOListView() | 352 | KOListView::~KOListView() |
353 | { | 353 | { |
354 | delete mPopupMenu; | 354 | delete mPopupMenu; |
355 | #if QT_VERSION >= 0x030000 | 355 | #if QT_VERSION >= 0x030000 |
356 | 356 | ||
357 | #else | 357 | #else |
358 | delete mKOListViewWhatsThis; | 358 | delete mKOListViewWhatsThis; |
359 | #endif | 359 | #endif |
360 | } | 360 | } |
361 | 361 | ||
362 | QString KOListView::getWhatsThisText(QPoint p) | 362 | QString KOListView::getWhatsThisText(QPoint p) |
363 | { | 363 | { |
364 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 364 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
365 | if ( item ) | 365 | if ( item ) |
366 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 366 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
367 | KOPrefs::instance()->mWTshowDetails, | 367 | KOPrefs::instance()->mWTshowDetails, |
368 | KOPrefs::instance()->mWTshowCreated, | 368 | KOPrefs::instance()->mWTshowCreated, |
369 | KOPrefs::instance()->mWTshowChanged); | 369 | KOPrefs::instance()->mWTshowChanged); |
370 | return i18n("That is the list view" ); | 370 | return i18n("That is the list view" ); |
371 | 371 | ||
372 | } | 372 | } |
373 | 373 | ||
374 | void KOListView::updateList() | 374 | void KOListView::updateList() |
375 | { | 375 | { |
376 | // qDebug(" KOListView::updateList() "); | 376 | // qDebug(" KOListView::updateList() "); |
377 | 377 | ||
378 | } | 378 | } |
379 | 379 | ||
380 | void KOListView::clearList() | 380 | void KOListView::clearList() |
381 | { | 381 | { |
382 | clear (); | 382 | clear (); |
383 | } | 383 | } |
384 | void KOListView::addCat( ) | 384 | void KOListView::addCat( ) |
385 | { | 385 | { |
386 | setCategories( false ); | 386 | setCategories( false ); |
387 | } | 387 | } |
388 | void KOListView::setCat() | 388 | void KOListView::setCat() |
389 | { | 389 | { |
390 | setCategories( true ); | 390 | setCategories( true ); |
391 | } | 391 | } |
392 | void KOListView::setAlarm() | 392 | void KOListView::setAlarm() |
393 | { | 393 | { |
394 | KOAlarmPrefs kap( this); | 394 | KOAlarmPrefs kap( this); |
395 | if ( !kap.exec() ) | 395 | if ( !kap.exec() ) |
396 | return; | 396 | return; |
397 | QStringList itemList; | 397 | QStringList itemList; |
398 | QPtrList<KOListViewItem> sel ; | 398 | QPtrList<KOListViewItem> sel ; |
399 | QListViewItem *qitem = mListView->firstChild (); | 399 | QListViewItem *qitem = mListView->firstChild (); |
400 | while ( qitem ) { | 400 | while ( qitem ) { |
401 | if ( qitem->isSelected() ) { | 401 | if ( qitem->isSelected() ) { |
402 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 402 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
403 | if ( inc->type() != "Journal" ) { | 403 | if ( inc->typeID() != journalID ) { |
404 | if ( inc->type() == "Todo" ) { | 404 | if ( inc->typeID() == todoID ) { |
405 | if ( ((Todo*)inc)->hasDueDate() ) | 405 | if ( ((Todo*)inc)->hasDueDate() ) |
406 | sel.append(((KOListViewItem *)qitem)); | 406 | sel.append(((KOListViewItem *)qitem)); |
407 | } else | 407 | } else |
408 | sel.append(((KOListViewItem *)qitem)); | 408 | sel.append(((KOListViewItem *)qitem)); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | qitem = qitem->nextSibling(); | 411 | qitem = qitem->nextSibling(); |
412 | } | 412 | } |
413 | int count = 0; | 413 | int count = 0; |
414 | KOListViewItem * item, *temp; | 414 | KOListViewItem * item, *temp; |
415 | item = sel.first(); | 415 | item = sel.first(); |
416 | Incidence* inc; | 416 | Incidence* inc; |
417 | while ( item ) { | 417 | while ( item ) { |
418 | inc = item->data(); | 418 | inc = item->data(); |
419 | ++count; | 419 | ++count; |
420 | if (kap.mAlarmButton->isChecked()) { | 420 | if (kap.mAlarmButton->isChecked()) { |
421 | if (inc->alarms().count() == 0) | 421 | if (inc->alarms().count() == 0) |
422 | inc->newAlarm(); | 422 | inc->newAlarm(); |
423 | QPtrList<Alarm> alarms = inc->alarms(); | 423 | QPtrList<Alarm> alarms = inc->alarms(); |
424 | Alarm *alarm; | 424 | Alarm *alarm; |
425 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 425 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
426 | alarm->setEnabled(true); | 426 | alarm->setEnabled(true); |
427 | int j = kap.mAlarmTimeEdit->value()* -60; | 427 | int j = kap.mAlarmTimeEdit->value()* -60; |
428 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 428 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
429 | j = j * 60; | 429 | j = j * 60; |
430 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 430 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
431 | j = j * (60 * 24); | 431 | j = j * (60 * 24); |
432 | alarm->setStartOffset( j ); | 432 | alarm->setStartOffset( j ); |
433 | 433 | ||
434 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 434 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
435 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 435 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
436 | } | 436 | } |
437 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 437 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
438 | alarm->setAudioAlarm(kap.mAlarmSound); | 438 | alarm->setAudioAlarm(kap.mAlarmSound); |
439 | else | 439 | else |
440 | alarm->setType(Alarm::Invalid); | 440 | alarm->setType(Alarm::Invalid); |
441 | //alarm->setAudioAlarm("default"); | 441 | //alarm->setAudioAlarm("default"); |
442 | // TODO: Deal with multiple alarms | 442 | // TODO: Deal with multiple alarms |
443 | break; // For now, stop after the first alarm | 443 | break; // For now, stop after the first alarm |
444 | } | 444 | } |
445 | } else { | 445 | } else { |
446 | Alarm* alarm = inc->alarms().first(); | 446 | Alarm* alarm = inc->alarms().first(); |
447 | if ( alarm ) { | 447 | if ( alarm ) { |
448 | alarm->setEnabled(false); | 448 | alarm->setEnabled(false); |
449 | alarm->setType(Alarm::Invalid); | 449 | alarm->setType(Alarm::Invalid); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | ListItemVisitor v(item, mStartDate ); | 452 | ListItemVisitor v(item, mStartDate ); |
453 | inc->accept(v); | 453 | inc->accept(v); |
454 | item = sel.next(); | 454 | item = sel.next(); |
455 | } | 455 | } |
456 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 456 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
457 | qDebug("KO: Set alarm for %d items", count); | 457 | qDebug("KO: Set alarm for %d items", count); |
458 | calendar()->reInitAlarmSettings(); | 458 | calendar()->reInitAlarmSettings(); |
459 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 459 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
460 | } | 460 | } |
461 | void KOListView::setCategories( bool removeOld ) | 461 | void KOListView::setCategories( bool removeOld ) |
462 | { | 462 | { |
463 | 463 | ||
464 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 464 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
465 | csd->setColorEnabled(); | 465 | csd->setColorEnabled(); |
466 | if (! csd->exec()) { | 466 | if (! csd->exec()) { |
467 | delete csd; | 467 | delete csd; |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | QStringList catList = csd->selectedCategories(); | 470 | QStringList catList = csd->selectedCategories(); |
471 | delete csd; | 471 | delete csd; |
472 | // if ( catList.count() == 0 ) | 472 | // if ( catList.count() == 0 ) |
473 | // return; | 473 | // return; |
474 | //catList.sort(); | 474 | //catList.sort(); |
475 | QString categoriesStr = catList.join(","); | 475 | QString categoriesStr = catList.join(","); |
476 | int i; | 476 | int i; |
477 | QStringList itemList; | 477 | QStringList itemList; |
478 | QPtrList<KOListViewItem> sel ; | 478 | QPtrList<KOListViewItem> sel ; |
479 | QListViewItem *qitem = mListView->firstChild (); | 479 | QListViewItem *qitem = mListView->firstChild (); |
480 | while ( qitem ) { | 480 | while ( qitem ) { |
481 | if ( qitem->isSelected() ) { | 481 | if ( qitem->isSelected() ) { |
482 | sel.append(((KOListViewItem *)qitem)); | 482 | sel.append(((KOListViewItem *)qitem)); |
483 | } | 483 | } |
484 | qitem = qitem->nextSibling(); | 484 | qitem = qitem->nextSibling(); |
485 | } | 485 | } |
486 | KOListViewItem * item, *temp; | 486 | KOListViewItem * item, *temp; |
487 | item = sel.first(); | 487 | item = sel.first(); |
488 | if( item ) { | 488 | if( item ) { |
489 | Incidence* inc = item->data() ; | 489 | Incidence* inc = item->data() ; |
490 | bool setSub = false; | 490 | bool setSub = false; |
491 | if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { | 491 | if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { |
492 | int result = KMessageBox::warningYesNoCancel(this, | 492 | int result = KMessageBox::warningYesNoCancel(this, |
493 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), | 493 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), |
494 | i18n("Todo has subtodos"), | 494 | i18n("Todo has subtodos"), |
495 | i18n("Yes"), | 495 | i18n("Yes"), |
496 | i18n("No")); | 496 | i18n("No")); |
497 | if (result == KMessageBox::Cancel) item = 0; | 497 | if (result == KMessageBox::Cancel) item = 0; |
498 | if (result == KMessageBox::Yes) setSub = true; | 498 | if (result == KMessageBox::Yes) setSub = true; |
499 | } | 499 | } |
500 | while ( item ) { | 500 | while ( item ) { |
501 | inc = item->data(); | 501 | inc = item->data(); |
502 | if ( removeOld ) { | 502 | if ( removeOld ) { |
503 | inc->setCategories( catList, setSub ); | 503 | inc->setCategories( catList, setSub ); |
504 | } else { | 504 | } else { |
505 | inc->addCategories( catList, setSub ); | 505 | inc->addCategories( catList, setSub ); |
506 | } | 506 | } |
507 | ListItemVisitor v(item, mStartDate ); | 507 | ListItemVisitor v(item, mStartDate ); |
508 | inc->accept(v); | 508 | inc->accept(v); |
509 | item = sel.next(); | 509 | item = sel.next(); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 512 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void KOListView::beamSelected() | 515 | void KOListView::beamSelected() |
516 | { | 516 | { |
517 | int icount = 0; | 517 | int icount = 0; |
518 | QPtrList<Incidence> delSel ; | 518 | QPtrList<Incidence> delSel ; |
519 | QListViewItem *item = mListView->firstChild (); | 519 | QListViewItem *item = mListView->firstChild (); |
520 | while ( item ) { | 520 | while ( item ) { |
521 | if ( item->isSelected() ) { | 521 | if ( item->isSelected() ) { |
522 | delSel.append(((KOListViewItem *)item)->data()); | 522 | delSel.append(((KOListViewItem *)item)->data()); |
523 | ++icount; | 523 | ++icount; |
524 | } | 524 | } |
525 | 525 | ||
526 | item = item->nextSibling(); | 526 | item = item->nextSibling(); |
527 | } | 527 | } |
528 | if ( icount ) { | 528 | if ( icount ) { |
529 | emit beamIncidenceList( delSel ); | 529 | emit beamIncidenceList( delSel ); |
530 | return; | 530 | return; |
531 | QString fn ; | 531 | QString fn ; |
532 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 532 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
533 | QString mes; | 533 | QString mes; |
534 | bool createbup = true; | 534 | bool createbup = true; |
535 | if ( createbup ) { | 535 | if ( createbup ) { |
536 | QString description = "\n"; | 536 | QString description = "\n"; |
537 | CalendarLocal* cal = new CalendarLocal(); | 537 | CalendarLocal* cal = new CalendarLocal(); |
538 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 538 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
539 | Incidence *incidence = delSel.first(); | 539 | Incidence *incidence = delSel.first(); |
540 | while ( incidence ) { | 540 | while ( incidence ) { |
541 | Incidence *in = incidence->clone(); | 541 | Incidence *in = incidence->clone(); |
542 | description += in->summary() + "\n"; | 542 | description += in->summary() + "\n"; |
543 | cal->addIncidence( in ); | 543 | cal->addIncidence( in ); |
544 | incidence = delSel.next(); | 544 | incidence = delSel.next(); |
545 | } | 545 | } |
546 | FileStorage storage( cal, fn, new VCalFormat ); | 546 | FileStorage storage( cal, fn, new VCalFormat ); |
547 | storage.save(); | 547 | storage.save(); |
548 | delete cal; | 548 | delete cal; |
549 | mes = i18n("KO/Pi: Ready for beaming"); | 549 | mes = i18n("KO/Pi: Ready for beaming"); |
550 | topLevelWidget()->setCaption(mes); | 550 | topLevelWidget()->setCaption(mes); |
551 | 551 | ||
552 | #ifndef DESKTOP_VERSION | 552 | #ifndef DESKTOP_VERSION |
553 | Ir *ir = new Ir( this ); | 553 | Ir *ir = new Ir( this ); |
554 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 554 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
555 | ir->send( fn, description, "text/x-vCalendar" ); | 555 | ir->send( fn, description, "text/x-vCalendar" ); |
556 | #endif | 556 | #endif |
557 | } | 557 | } |
558 | } | 558 | } |
559 | } | 559 | } |
560 | void KOListView::beamDone( Ir *ir ) | 560 | void KOListView::beamDone( Ir *ir ) |
561 | { | 561 | { |
562 | #ifndef DESKTOP_VERSION | 562 | #ifndef DESKTOP_VERSION |
563 | delete ir; | 563 | delete ir; |
564 | #endif | 564 | #endif |
565 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 565 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
566 | } | 566 | } |
567 | 567 | ||
568 | void KOListView::saveDescriptionToFile() | 568 | void KOListView::saveDescriptionToFile() |
569 | { | 569 | { |
570 | 570 | ||
571 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 571 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
572 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 572 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
573 | i18n("Continue"), i18n("Cancel"), 0, | 573 | i18n("Continue"), i18n("Cancel"), 0, |
574 | 0, 1 ); | 574 | 0, 1 ); |
575 | if ( result != 0 ) { | 575 | if ( result != 0 ) { |
576 | return; | 576 | return; |
577 | } | 577 | } |
578 | int icount = 0; | 578 | int icount = 0; |
579 | QPtrList<Incidence> delSel ; | 579 | QPtrList<Incidence> delSel ; |
580 | QListViewItem *item = mListView->firstChild (); | 580 | QListViewItem *item = mListView->firstChild (); |
581 | while ( item ) { | 581 | while ( item ) { |
582 | if ( item->isSelected() ) { | 582 | if ( item->isSelected() ) { |
583 | delSel.append(((KOListViewItem *)item)->data()); | 583 | delSel.append(((KOListViewItem *)item)->data()); |
584 | ++icount; | 584 | ++icount; |
585 | } | 585 | } |
586 | 586 | ||
587 | item = item->nextSibling(); | 587 | item = item->nextSibling(); |
588 | } | 588 | } |
589 | if ( icount ) { | 589 | if ( icount ) { |
590 | QString fn = KOPrefs::instance()->mLastSaveFile; | 590 | QString fn = KOPrefs::instance()->mLastSaveFile; |
591 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 591 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
592 | 592 | ||
593 | if ( fn == "" ) | 593 | if ( fn == "" ) |
594 | return; | 594 | return; |
595 | QFileInfo info; | 595 | QFileInfo info; |
596 | info.setFile( fn ); | 596 | info.setFile( fn ); |
597 | QString mes; | 597 | QString mes; |
598 | bool createbup = true; | 598 | bool createbup = true; |
599 | if ( info. exists() ) { | 599 | if ( info. exists() ) { |
600 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 600 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
601 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 601 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
602 | i18n("Overwrite!"), i18n("Cancel"), 0, | 602 | i18n("Overwrite!"), i18n("Cancel"), 0, |
603 | 0, 1 ); | 603 | 0, 1 ); |
604 | if ( result != 0 ) { | 604 | if ( result != 0 ) { |
605 | createbup = false; | 605 | createbup = false; |
606 | } | 606 | } |
607 | } | 607 | } |
608 | if ( createbup ) { | 608 | if ( createbup ) { |
609 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 609 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
610 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 610 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
611 | Incidence *incidence = delSel.first(); | 611 | Incidence *incidence = delSel.first(); |
612 | icount = 0; | 612 | icount = 0; |
613 | while ( incidence ) { | 613 | while ( incidence ) { |
614 | if ( incidence->type() == "Journal" ) { | 614 | if ( incidence->typeID() == journalID ) { |
615 | text += "\n************************************\n"; | 615 | text += "\n************************************\n"; |
616 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 616 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
617 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 617 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
618 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 618 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
619 | ++icount; | 619 | ++icount; |
620 | 620 | ||
621 | } else { | 621 | } else { |
622 | if ( !incidence->description().isEmpty() ) { | 622 | if ( !incidence->description().isEmpty() ) { |
623 | text += "\n************************************\n"; | 623 | text += "\n************************************\n"; |
624 | if ( incidence->type() == "Todo" ) | 624 | if ( incidence->typeID() == todoID ) |
625 | text += i18n("To-Do: "); | 625 | text += i18n("To-Do: "); |
626 | text += incidence->summary(); | 626 | text += incidence->summary(); |
627 | if ( incidence->hasStartDate() ) | 627 | if ( incidence->hasStartDate() ) |
628 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 628 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
629 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 629 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
630 | if ( !incidence->location().isEmpty() ) | 630 | if ( !incidence->location().isEmpty() ) |
631 | text += "\n" +i18n("Location: ") + incidence->location(); | 631 | text += "\n" +i18n("Location: ") + incidence->location(); |
632 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 632 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
633 | ++icount; | 633 | ++icount; |
634 | 634 | ||
635 | } | 635 | } |
636 | } | 636 | } |
637 | incidence = delSel.next(); | 637 | incidence = delSel.next(); |
638 | } | 638 | } |
639 | QFile file( fn ); | 639 | QFile file( fn ); |
640 | if (!file.open( IO_WriteOnly ) ) { | 640 | if (!file.open( IO_WriteOnly ) ) { |
641 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 641 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
642 | return; | 642 | return; |
643 | } | 643 | } |
644 | QTextStream ts( &file ); | 644 | QTextStream ts( &file ); |
645 | ts << text; | 645 | ts << text; |
646 | file.close(); | 646 | file.close(); |
647 | //qDebug("%s ", text.latin1()); | 647 | //qDebug("%s ", text.latin1()); |
648 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 648 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
649 | KOPrefs::instance()->mLastSaveFile = fn; | 649 | KOPrefs::instance()->mLastSaveFile = fn; |
650 | topLevelWidget()->setCaption(mes); | 650 | topLevelWidget()->setCaption(mes); |
651 | } | 651 | } |
652 | } | 652 | } |
653 | } | 653 | } |
654 | void KOListView::saveToFileVCS() | 654 | void KOListView::saveToFileVCS() |
655 | { | 655 | { |
656 | writeToFile( false ); | 656 | writeToFile( false ); |
657 | } | 657 | } |
658 | void KOListView::saveToFile() | 658 | void KOListView::saveToFile() |
659 | { | 659 | { |
660 | writeToFile( true ); | 660 | writeToFile( true ); |
661 | } | 661 | } |
662 | void KOListView::writeToFile( bool iCal ) | 662 | void KOListView::writeToFile( bool iCal ) |
663 | { | 663 | { |
664 | 664 | ||
665 | int icount = 0; | 665 | int icount = 0; |
666 | QPtrList<Incidence> delSel ; | 666 | QPtrList<Incidence> delSel ; |
667 | QListViewItem *item = mListView->firstChild (); | 667 | QListViewItem *item = mListView->firstChild (); |
668 | bool journal = iCal; // warn only for vCal | 668 | bool journal = iCal; // warn only for vCal |
669 | while ( item ) { | 669 | while ( item ) { |
670 | if ( item->isSelected() ) { | 670 | if ( item->isSelected() ) { |
671 | if ( !journal ) | 671 | if ( !journal ) |
672 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") | 672 | if ( ((KOListViewItem *)item)->data()->typeID() == journalID ) |
673 | journal = true; | 673 | journal = true; |
674 | delSel.append(((KOListViewItem *)item)->data()); | 674 | delSel.append(((KOListViewItem *)item)->data()); |
675 | ++icount; | 675 | ++icount; |
676 | } | 676 | } |
677 | 677 | ||
678 | item = item->nextSibling(); | 678 | item = item->nextSibling(); |
679 | } | 679 | } |
680 | if ( !iCal && journal ) { | 680 | if ( !iCal && journal ) { |
681 | int result = KMessageBox::warningContinueCancel(this, | 681 | int result = KMessageBox::warningContinueCancel(this, |
682 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 682 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
683 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 683 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
684 | true); | 684 | true); |
685 | if (result != KMessageBox::Continue) return; | 685 | if (result != KMessageBox::Continue) return; |
686 | } | 686 | } |
687 | if ( icount ) { | 687 | if ( icount ) { |
688 | QString fn = KOPrefs::instance()->mLastSaveFile; | 688 | QString fn = KOPrefs::instance()->mLastSaveFile; |
689 | QString extension; | 689 | QString extension; |
690 | if ( iCal ) { | 690 | if ( iCal ) { |
691 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 691 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
692 | fn = fn.left( fn.length() -3) + "ics"; | 692 | fn = fn.left( fn.length() -3) + "ics"; |
693 | } | 693 | } |
694 | } else { | 694 | } else { |
695 | if ( fn.right( 4 ).lower() == ".ics" ) { | 695 | if ( fn.right( 4 ).lower() == ".ics" ) { |
696 | fn = fn.left( fn.length() -3) + "vcs"; | 696 | fn = fn.left( fn.length() -3) + "vcs"; |
697 | } | 697 | } |
698 | } | 698 | } |
699 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 699 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
700 | 700 | ||
701 | if ( fn == "" ) | 701 | if ( fn == "" ) |
702 | return; | 702 | return; |
703 | QFileInfo info; | 703 | QFileInfo info; |
704 | info.setFile( fn ); | 704 | info.setFile( fn ); |
705 | QString mes; | 705 | QString mes; |
706 | bool createbup = true; | 706 | bool createbup = true; |
707 | if ( info. exists() ) { | 707 | if ( info. exists() ) { |
708 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 708 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
709 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 709 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
710 | i18n("Overwrite!"), i18n("Cancel"), 0, | 710 | i18n("Overwrite!"), i18n("Cancel"), 0, |
711 | 0, 1 ); | 711 | 0, 1 ); |
712 | if ( result != 0 ) { | 712 | if ( result != 0 ) { |
713 | createbup = false; | 713 | createbup = false; |
714 | } | 714 | } |
715 | } | 715 | } |
716 | if ( createbup ) { | 716 | if ( createbup ) { |
717 | CalendarLocal cal; | 717 | CalendarLocal cal; |
718 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 718 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
719 | Incidence *incidence = delSel.first(); | 719 | Incidence *incidence = delSel.first(); |
720 | while ( incidence ) { | 720 | while ( incidence ) { |
721 | cal.addIncidence( incidence->clone() ); | 721 | cal.addIncidence( incidence->clone() ); |
722 | incidence = delSel.next(); | 722 | incidence = delSel.next(); |
723 | } | 723 | } |
724 | if ( iCal ) { | 724 | if ( iCal ) { |
725 | ICalFormat format; | 725 | ICalFormat format; |
726 | format.save( &cal, fn ); | 726 | format.save( &cal, fn ); |
727 | } else { | 727 | } else { |
728 | 728 | ||
729 | VCalFormat format; | 729 | VCalFormat format; |
730 | format.save( &cal, fn ); | 730 | format.save( &cal, fn ); |
731 | } | 731 | } |
732 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 732 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
733 | KOPrefs::instance()->mLastSaveFile = fn; | 733 | KOPrefs::instance()->mLastSaveFile = fn; |
734 | topLevelWidget()->setCaption(mes); | 734 | topLevelWidget()->setCaption(mes); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 737 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
738 | } | 738 | } |
739 | void KOListView::hideAll() | 739 | void KOListView::hideAll() |
740 | { | 740 | { |
741 | QPtrList<QListViewItem> delSel ; | 741 | QPtrList<QListViewItem> delSel ; |
742 | QListViewItem *item = mListView->firstChild (); | 742 | QListViewItem *item = mListView->firstChild (); |
743 | while ( item ) { | 743 | while ( item ) { |
744 | if ( item->isSelected() ) { | 744 | if ( item->isSelected() ) { |
745 | delSel.append(item); | 745 | delSel.append(item); |
746 | } | 746 | } |
747 | item = item->nextSibling(); | 747 | item = item->nextSibling(); |
748 | } | 748 | } |
749 | item = delSel.first() ; | 749 | item = delSel.first() ; |
750 | while ( item ) { | 750 | while ( item ) { |
751 | QListViewItem * del = item; | 751 | QListViewItem * del = item; |
752 | item = delSel.next(); | 752 | item = delSel.next(); |
753 | delete del; | 753 | delete del; |
754 | } | 754 | } |
755 | } | 755 | } |
756 | void KOListView::printList() | 756 | void KOListView::printList() |
757 | { | 757 | { |
758 | mListView->printList(); | 758 | mListView->printList(); |
759 | } | 759 | } |
760 | void KOListView::deleteAll() | 760 | void KOListView::deleteAll() |
761 | { | 761 | { |
762 | int icount = 0; | 762 | int icount = 0; |
763 | QPtrList<Incidence> delSel ; | 763 | QPtrList<Incidence> delSel ; |
764 | QListViewItem *item = mListView->firstChild (); | 764 | QListViewItem *item = mListView->firstChild (); |
765 | while ( item ) { | 765 | while ( item ) { |
766 | if ( item->isSelected() ) { | 766 | if ( item->isSelected() ) { |
767 | delSel.append(((KOListViewItem *)item)->data()); | 767 | delSel.append(((KOListViewItem *)item)->data()); |
768 | ++icount; | 768 | ++icount; |
769 | } | 769 | } |
770 | 770 | ||
771 | item = item->nextSibling(); | 771 | item = item->nextSibling(); |
772 | } | 772 | } |
773 | if ( icount ) { | 773 | if ( icount ) { |
774 | Incidence *incidence = delSel.first(); | 774 | Incidence *incidence = delSel.first(); |
775 | Incidence *toDelete; | 775 | Incidence *toDelete; |
776 | KOPrefs *p = KOPrefs::instance(); | 776 | KOPrefs *p = KOPrefs::instance(); |
777 | bool confirm = p->mConfirm; | 777 | bool confirm = p->mConfirm; |
778 | QString mess; | 778 | QString mess; |
779 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 779 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
780 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 780 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
781 | p->mConfirm = false; | 781 | p->mConfirm = false; |
782 | int delCounter = 0; | 782 | int delCounter = 0; |
783 | QDialog dia ( this, "p-dialog", true ); | 783 | QDialog dia ( this, "p-dialog", true ); |
784 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 784 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
785 | QVBoxLayout lay( &dia ); | 785 | QVBoxLayout lay( &dia ); |
786 | lay.setMargin(7); | 786 | lay.setMargin(7); |
787 | lay.setSpacing(7); | 787 | lay.setSpacing(7); |
788 | lay.addWidget( &lab); | 788 | lay.addWidget( &lab); |
789 | QProgressBar bar( icount, &dia ); | 789 | QProgressBar bar( icount, &dia ); |
790 | lay.addWidget( &bar); | 790 | lay.addWidget( &bar); |
791 | int w = 220; | 791 | int w = 220; |
792 | int h = 50; | 792 | int h = 50; |
793 | int dw = QApplication::desktop()->width(); | 793 | int dw = QApplication::desktop()->width(); |
794 | int dh = QApplication::desktop()->height(); | 794 | int dh = QApplication::desktop()->height(); |
795 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 795 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
796 | //dia.resize( 240,50 ); | 796 | //dia.resize( 240,50 ); |
797 | dia.show(); | 797 | dia.show(); |
798 | 798 | ||
799 | while ( incidence ) { | 799 | while ( incidence ) { |
800 | bar.setProgress( delCounter ); | 800 | bar.setProgress( delCounter ); |
801 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 801 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
802 | dia.setCaption( mess ); | 802 | dia.setCaption( mess ); |
803 | qApp->processEvents(); | 803 | qApp->processEvents(); |
804 | toDelete = (incidence); | 804 | toDelete = (incidence); |
805 | incidence = delSel.next(); | 805 | incidence = delSel.next(); |
806 | emit deleteIncidenceSignal(toDelete ); | 806 | emit deleteIncidenceSignal(toDelete ); |
807 | if ( dia.result() != 0 ) | 807 | if ( dia.result() != 0 ) |
808 | break; | 808 | break; |
809 | 809 | ||
810 | } | 810 | } |
811 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 811 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
812 | topLevelWidget ()->setCaption( mess ); | 812 | topLevelWidget ()->setCaption( mess ); |
813 | p->mConfirm = confirm; | 813 | p->mConfirm = confirm; |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
817 | 817 | ||
818 | } | 818 | } |
819 | int KOListView::maxDatesHint() | 819 | int KOListView::maxDatesHint() |
820 | { | 820 | { |
821 | return 0; | 821 | return 0; |
822 | } | 822 | } |
823 | 823 | ||
824 | int KOListView::currentDateCount() | 824 | int KOListView::currentDateCount() |
825 | { | 825 | { |
826 | return 0; | 826 | return 0; |
827 | } | 827 | } |
828 | 828 | ||
829 | QPtrList<Incidence> KOListView::selectedIncidences() | 829 | QPtrList<Incidence> KOListView::selectedIncidences() |
830 | { | 830 | { |
831 | QPtrList<Incidence> eventList; | 831 | QPtrList<Incidence> eventList; |
832 | QListViewItem *item = mListView->firstChild (); | 832 | QListViewItem *item = mListView->firstChild (); |
833 | while ( item ) { | 833 | while ( item ) { |
834 | if ( item->isSelected() ) { | 834 | if ( item->isSelected() ) { |
835 | eventList.append(((KOListViewItem *)item)->data()); | 835 | eventList.append(((KOListViewItem *)item)->data()); |
836 | } | 836 | } |
837 | 837 | ||
838 | item = item->nextSibling(); | 838 | item = item->nextSibling(); |
839 | } | 839 | } |
840 | 840 | ||
841 | // // QListViewItem *item = mListView->selectedItem(); | 841 | // // QListViewItem *item = mListView->selectedItem(); |
842 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 842 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
843 | 843 | ||
844 | return eventList; | 844 | return eventList; |
845 | } | 845 | } |
846 | 846 | ||
847 | DateList KOListView::selectedDates() | 847 | DateList KOListView::selectedDates() |
848 | { | 848 | { |
849 | DateList eventList; | 849 | DateList eventList; |
850 | return eventList; | 850 | return eventList; |
851 | } | 851 | } |
852 | 852 | ||
853 | void KOListView::showDates(bool show) | 853 | void KOListView::showDates(bool show) |
854 | { | 854 | { |
855 | // Shouldn't we set it to a value greater 0? When showDates is called with | 855 | // Shouldn't we set it to a value greater 0? When showDates is called with |
856 | // show == true at first, then the columnwidths are set to zero. | 856 | // show == true at first, then the columnwidths are set to zero. |
857 | static int oldColWidth1 = 0; | 857 | static int oldColWidth1 = 0; |
858 | static int oldColWidth3 = 0; | 858 | static int oldColWidth3 = 0; |
859 | 859 | ||
860 | if (!show) { | 860 | if (!show) { |
861 | oldColWidth1 = mListView->columnWidth(1); | 861 | oldColWidth1 = mListView->columnWidth(1); |
862 | oldColWidth3 = mListView->columnWidth(3); | 862 | oldColWidth3 = mListView->columnWidth(3); |
863 | mListView->setColumnWidth(1, 0); | 863 | mListView->setColumnWidth(1, 0); |
864 | mListView->setColumnWidth(3, 0); | 864 | mListView->setColumnWidth(3, 0); |
865 | } else { | 865 | } else { |
866 | mListView->setColumnWidth(1, oldColWidth1); | 866 | mListView->setColumnWidth(1, oldColWidth1); |
867 | mListView->setColumnWidth(3, oldColWidth3); | 867 | mListView->setColumnWidth(3, oldColWidth3); |
868 | } | 868 | } |
869 | mListView->repaint(); | 869 | mListView->repaint(); |
870 | } | 870 | } |
871 | 871 | ||
872 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 872 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
873 | const QDate &td) | 873 | const QDate &td) |
874 | { | 874 | { |
875 | #ifndef KORG_NOPRINTER | 875 | #ifndef KORG_NOPRINTER |
876 | calPrinter->preview(CalPrinter::Day, fd, td); | 876 | calPrinter->preview(CalPrinter::Day, fd, td); |
877 | #endif | 877 | #endif |
878 | } | 878 | } |
879 | 879 | ||
880 | void KOListView::showDates() | 880 | void KOListView::showDates() |
881 | { | 881 | { |
882 | showDates(true); | 882 | showDates(true); |
883 | } | 883 | } |
884 | 884 | ||
885 | void KOListView::hideDates() | 885 | void KOListView::hideDates() |
886 | { | 886 | { |
887 | showDates(false); | 887 | showDates(false); |
888 | } | 888 | } |
889 | 889 | ||
890 | void KOListView::resetFocus() | 890 | void KOListView::resetFocus() |
891 | { | 891 | { |
892 | topLevelWidget()->setActiveWindow(); | 892 | topLevelWidget()->setActiveWindow(); |
893 | topLevelWidget()->raise(); | 893 | topLevelWidget()->raise(); |
894 | mListView->setFocus(); | 894 | mListView->setFocus(); |
895 | } | 895 | } |
896 | void KOListView::updateView() | 896 | void KOListView::updateView() |
897 | { | 897 | { |
898 | mListView->setFocus(); | 898 | mListView->setFocus(); |
899 | if ( mListView->firstChild () ) | 899 | if ( mListView->firstChild () ) |
900 | mListView->setCurrentItem( mListView->firstChild () ); | 900 | mListView->setCurrentItem( mListView->firstChild () ); |
901 | } | 901 | } |
902 | void KOListView::updateConfig() | 902 | void KOListView::updateConfig() |
903 | { | 903 | { |
904 | 904 | ||
905 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 905 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
906 | updateView(); | 906 | updateView(); |
907 | 907 | ||
908 | } | 908 | } |
909 | void KOListView::setStartDate(const QDate &start) | 909 | void KOListView::setStartDate(const QDate &start) |
910 | { | 910 | { |
911 | mStartDate = start; | 911 | mStartDate = start; |
912 | } | 912 | } |
913 | 913 | ||
914 | void KOListView::showDates(const QDate &start, const QDate &end) | 914 | void KOListView::showDates(const QDate &start, const QDate &end) |
915 | { | 915 | { |
916 | clear(); | 916 | clear(); |
917 | mStartDate = start; | 917 | mStartDate = start; |
918 | QDate date = start; | 918 | QDate date = start; |
919 | QPtrList<Journal> j_list; | 919 | QPtrList<Journal> j_list; |
920 | while( date <= end ) { | 920 | while( date <= end ) { |
921 | addEvents(calendar()->events(date)); | 921 | addEvents(calendar()->events(date)); |
922 | addTodos(calendar()->todos(date)); | 922 | addTodos(calendar()->todos(date)); |
923 | Journal* jo = calendar()->journal(date); | 923 | Journal* jo = calendar()->journal(date); |
924 | if ( jo ) | 924 | if ( jo ) |
925 | j_list.append( jo ); | 925 | j_list.append( jo ); |
926 | date = date.addDays( 1 ); | 926 | date = date.addDays( 1 ); |
927 | } | 927 | } |
928 | addJournals(j_list); | 928 | addJournals(j_list); |
929 | emit incidenceSelected( 0 ); | 929 | emit incidenceSelected( 0 ); |
930 | updateView(); | 930 | updateView(); |
931 | 931 | ||
932 | } | 932 | } |
933 | 933 | ||
934 | void KOListView::addEvents(QPtrList<Event> eventList) | 934 | void KOListView::addEvents(QPtrList<Event> eventList) |
935 | { | 935 | { |
936 | 936 | ||
937 | Event *ev; | 937 | Event *ev; |
938 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 938 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
939 | addIncidence(ev); | 939 | addIncidence(ev); |
940 | } | 940 | } |
941 | if ( !mListView->currentItem() ){ | 941 | if ( !mListView->currentItem() ){ |
942 | updateView(); | 942 | updateView(); |
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | void KOListView::addTodos(QPtrList<Todo> eventList) | 946 | void KOListView::addTodos(QPtrList<Todo> eventList) |
947 | { | 947 | { |
948 | Todo *ev; | 948 | Todo *ev; |
949 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 949 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
950 | addIncidence(ev); | 950 | addIncidence(ev); |
951 | } | 951 | } |
952 | if ( !mListView->currentItem() ){ | 952 | if ( !mListView->currentItem() ){ |
953 | updateView(); | 953 | updateView(); |
954 | } | 954 | } |
955 | } | 955 | } |
956 | void KOListView::addJournals(QPtrList<Journal> eventList) | 956 | void KOListView::addJournals(QPtrList<Journal> eventList) |
957 | { | 957 | { |
958 | Journal *ev; | 958 | Journal *ev; |
959 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 959 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
960 | addIncidence(ev); | 960 | addIncidence(ev); |
961 | } | 961 | } |
962 | if ( !mListView->currentItem() ){ | 962 | if ( !mListView->currentItem() ){ |
963 | updateView(); | 963 | updateView(); |
964 | } | 964 | } |
965 | } | 965 | } |
966 | 966 | ||
967 | void KOListView::addIncidence(Incidence *incidence) | 967 | void KOListView::addIncidence(Incidence *incidence) |
968 | { | 968 | { |
969 | if ( mUidDict.find( incidence->uid() ) ) return; | 969 | if ( mUidDict.find( incidence->uid() ) ) return; |
970 | 970 | ||
971 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 971 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
972 | mUidDict.insert( incidence->uid(), incidence ); | 972 | mUidDict.insert( incidence->uid(), incidence ); |
973 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 973 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
974 | ListItemVisitor v(item, mStartDate ); | 974 | ListItemVisitor v(item, mStartDate ); |
975 | if (incidence->accept(v)) { | 975 | if (incidence->accept(v)) { |
976 | return; | 976 | return; |
977 | } | 977 | } |
978 | else delete item; | 978 | else delete item; |
979 | } | 979 | } |
980 | 980 | ||
981 | void KOListView::showEvents(QPtrList<Event> eventList) | 981 | void KOListView::showEvents(QPtrList<Event> eventList) |
982 | { | 982 | { |
983 | clear(); | 983 | clear(); |
984 | 984 | ||
985 | addEvents(eventList); | 985 | addEvents(eventList); |
986 | 986 | ||
987 | // After new creation of list view no events are selected. | 987 | // After new creation of list view no events are selected. |
988 | emit incidenceSelected( 0 ); | 988 | emit incidenceSelected( 0 ); |
989 | } | 989 | } |
990 | int KOListView::count() | 990 | int KOListView::count() |
991 | { | 991 | { |
992 | return mListView->childCount(); | 992 | return mListView->childCount(); |
993 | } | 993 | } |
994 | 994 | ||
995 | void KOListView::changeEventDisplay(Event *event, int action) | 995 | void KOListView::changeEventDisplay(Event *event, int action) |
996 | { | 996 | { |
997 | KOListViewItem *item; | 997 | KOListViewItem *item; |
998 | 998 | ||
999 | switch(action) { | 999 | switch(action) { |
1000 | case KOGlobals::EVENTADDED: | 1000 | case KOGlobals::EVENTADDED: |
1001 | addIncidence( event ); | 1001 | addIncidence( event ); |
1002 | break; | 1002 | break; |
1003 | case KOGlobals::EVENTEDITED: | 1003 | case KOGlobals::EVENTEDITED: |
1004 | item = getItemForEvent(event); | 1004 | item = getItemForEvent(event); |
1005 | if (item) { | 1005 | if (item) { |
1006 | mUidDict.remove( event->uid() ); | 1006 | mUidDict.remove( event->uid() ); |
1007 | delete item; | 1007 | delete item; |
1008 | addIncidence( event ); | 1008 | addIncidence( event ); |
1009 | } | 1009 | } |
1010 | break; | 1010 | break; |
1011 | case KOGlobals::EVENTDELETED: | 1011 | case KOGlobals::EVENTDELETED: |
1012 | item = getItemForEvent(event); | 1012 | item = getItemForEvent(event); |
1013 | if (item) { | 1013 | if (item) { |
1014 | mUidDict.remove( event->uid() ); | 1014 | mUidDict.remove( event->uid() ); |
1015 | delete item; | 1015 | delete item; |
1016 | } | 1016 | } |
1017 | break; | 1017 | break; |
1018 | default: | 1018 | default: |
1019 | ; | 1019 | ; |
1020 | } | 1020 | } |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 1023 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
1024 | { | 1024 | { |
1025 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 1025 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
1026 | while (item) { | 1026 | while (item) { |
1027 | if (item->data() == event) return item; | 1027 | if (item->data() == event) return item; |
1028 | item = (KOListViewItem *)item->nextSibling(); | 1028 | item = (KOListViewItem *)item->nextSibling(); |
1029 | } | 1029 | } |
1030 | return 0; | 1030 | return 0; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | void KOListView::defaultItemAction(QListViewItem *i) | 1033 | void KOListView::defaultItemAction(QListViewItem *i) |
1034 | { | 1034 | { |
1035 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 1035 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
1036 | if ( item ) defaultAction( item->data() ); | 1036 | if ( item ) defaultAction( item->data() ); |
1037 | 1037 | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1040 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1041 | { | 1041 | { |
1042 | mActiveItem = (KOListViewItem *)item; | 1042 | mActiveItem = (KOListViewItem *)item; |
1043 | if (mActiveItem) { | 1043 | if (mActiveItem) { |
1044 | Incidence *incidence = mActiveItem->data(); | 1044 | Incidence *incidence = mActiveItem->data(); |
1045 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | 1045 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); |
1046 | mPopupMenu->showIncidencePopup(incidence); | 1046 | mPopupMenu->showIncidencePopup(incidence); |
1047 | 1047 | ||
1048 | /* | 1048 | /* |
1049 | if ( incidence && incidence->type() == "Event" ) { | 1049 | if ( incidence && incidence->type() == "Event" ) { |
1050 | Event *event = static_cast<Event *>( incidence ); | 1050 | Event *event = static_cast<Event *>( incidence ); |
1051 | mPopupMenu->showEventPopup(event); | 1051 | mPopupMenu->showEventPopup(event); |
1052 | } | 1052 | } |
1053 | */ | 1053 | */ |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | void KOListView::readSettings(KConfig *config, QString setting) | 1057 | void KOListView::readSettings(KConfig *config, QString setting) |
1058 | { | 1058 | { |
1059 | // qDebug("KOListView::readSettings "); | 1059 | // qDebug("KOListView::readSettings "); |
1060 | mListView->restoreLayout(config,setting); | 1060 | mListView->restoreLayout(config,setting); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | void KOListView::writeSettings(KConfig *config, QString setting) | 1063 | void KOListView::writeSettings(KConfig *config, QString setting) |
1064 | { | 1064 | { |
1065 | // qDebug("KOListView::writeSettings "); | 1065 | // qDebug("KOListView::writeSettings "); |
1066 | mListView->saveLayout(config, setting); | 1066 | mListView->saveLayout(config, setting); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | void KOListView::processSelectionChange(QListViewItem *) | 1069 | void KOListView::processSelectionChange(QListViewItem *) |
1070 | { | 1070 | { |
1071 | 1071 | ||
1072 | KOListViewItem *item = | 1072 | KOListViewItem *item = |
1073 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1073 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1074 | 1074 | ||
1075 | if ( !item ) { | 1075 | if ( !item ) { |
1076 | emit incidenceSelected( 0 ); | 1076 | emit incidenceSelected( 0 ); |
1077 | } else { | 1077 | } else { |
1078 | emit incidenceSelected( item->data() ); | 1078 | emit incidenceSelected( item->data() ); |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | void KOListView::clearSelection() | 1082 | void KOListView::clearSelection() |
1083 | { | 1083 | { |
1084 | mListView->selectAll( false ); | 1084 | mListView->selectAll( false ); |
1085 | } | 1085 | } |
1086 | void KOListView::allSelection() | 1086 | void KOListView::allSelection() |
1087 | { | 1087 | { |
1088 | mListView->selectAll( true ); | 1088 | mListView->selectAll( true ); |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void KOListView::clear() | 1091 | void KOListView::clear() |
1092 | { | 1092 | { |
1093 | mListView->clear(); | 1093 | mListView->clear(); |
1094 | mUidDict.clear(); | 1094 | mUidDict.clear(); |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | Incidence* KOListView::currentItem() | 1097 | Incidence* KOListView::currentItem() |
1098 | { | 1098 | { |
1099 | if ( mListView->currentItem() ) | 1099 | if ( mListView->currentItem() ) |
1100 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1100 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1101 | return 0; | 1101 | return 0; |
1102 | } | 1102 | } |
1103 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1103 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1104 | { | 1104 | { |
1105 | 1105 | ||
1106 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1106 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1107 | deleteAll(); | 1107 | deleteAll(); |
1108 | return; | 1108 | return; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | e->ignore(); | 1111 | e->ignore(); |
1112 | } | 1112 | } |
1113 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1113 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1114 | { | 1114 | { |
1115 | 1115 | ||
1116 | switch ( e->key() ) { | 1116 | switch ( e->key() ) { |
1117 | case Qt::Key_Down: | 1117 | case Qt::Key_Down: |
1118 | if ( e->state() == ShiftButton ) { | 1118 | if ( e->state() == ShiftButton ) { |
1119 | QListViewItem* cn = currentItem(); | 1119 | QListViewItem* cn = currentItem(); |
1120 | if ( !cn ) | 1120 | if ( !cn ) |
1121 | cn = firstChild(); | 1121 | cn = firstChild(); |
1122 | if ( !cn ) | 1122 | if ( !cn ) |
1123 | return; | 1123 | return; |
1124 | while ( cn->nextSibling() ) | 1124 | while ( cn->nextSibling() ) |
1125 | cn = cn->nextSibling(); | 1125 | cn = cn->nextSibling(); |
1126 | setCurrentItem ( cn ); | 1126 | setCurrentItem ( cn ); |
1127 | ensureItemVisible ( cn ); | 1127 | ensureItemVisible ( cn ); |
1128 | 1128 | ||
1129 | e->accept(); | 1129 | e->accept(); |
1130 | return; | 1130 | return; |
1131 | } | 1131 | } |
1132 | if ( e->state() == ControlButton ) { | 1132 | if ( e->state() == ControlButton ) { |
1133 | int count = childCount (); | 1133 | int count = childCount (); |
1134 | int jump = count / 5; | 1134 | int jump = count / 5; |
1135 | QListViewItem* cn; | 1135 | QListViewItem* cn; |
1136 | cn = currentItem(); | 1136 | cn = currentItem(); |
1137 | if ( ! cn ) | 1137 | if ( ! cn ) |
1138 | return; | 1138 | return; |
1139 | if ( jump == 0 ) | 1139 | if ( jump == 0 ) |
1140 | jump = 1; | 1140 | jump = 1; |
1141 | while ( jump && cn->nextSibling() ) { | 1141 | while ( jump && cn->nextSibling() ) { |
1142 | cn = cn->nextSibling(); | 1142 | cn = cn->nextSibling(); |
1143 | --jump; | 1143 | --jump; |
1144 | } | 1144 | } |
1145 | setCurrentItem ( cn ); | 1145 | setCurrentItem ( cn ); |
1146 | ensureItemVisible ( cn ); | 1146 | ensureItemVisible ( cn ); |
1147 | 1147 | ||
1148 | } else | 1148 | } else |
1149 | QListView::keyPressEvent ( e ) ; | 1149 | QListView::keyPressEvent ( e ) ; |
1150 | e->accept(); | 1150 | e->accept(); |
1151 | break; | 1151 | break; |
1152 | 1152 | ||
1153 | case Qt::Key_Up: | 1153 | case Qt::Key_Up: |
1154 | if ( e->state() == ShiftButton ) { | 1154 | if ( e->state() == ShiftButton ) { |
1155 | QListViewItem* cn = firstChild(); | 1155 | QListViewItem* cn = firstChild(); |
1156 | if ( cn ) { | 1156 | if ( cn ) { |
1157 | setCurrentItem ( cn ); | 1157 | setCurrentItem ( cn ); |
1158 | ensureItemVisible ( cn ); | 1158 | ensureItemVisible ( cn ); |
1159 | } | 1159 | } |
1160 | e->accept(); | 1160 | e->accept(); |
1161 | return; | 1161 | return; |
1162 | } | 1162 | } |
1163 | if ( e->state() == ControlButton ) { | 1163 | if ( e->state() == ControlButton ) { |
1164 | int count = childCount (); | 1164 | int count = childCount (); |
1165 | int jump = count / 5; | 1165 | int jump = count / 5; |
1166 | QListViewItem* cn; | 1166 | QListViewItem* cn; |
1167 | cn = currentItem(); | 1167 | cn = currentItem(); |
1168 | if ( ! cn ) | 1168 | if ( ! cn ) |
1169 | return; | 1169 | return; |
1170 | if ( jump == 0 ) | 1170 | if ( jump == 0 ) |
1171 | jump = 1; | 1171 | jump = 1; |
1172 | while ( jump && cn->itemAbove ()) { | 1172 | while ( jump && cn->itemAbove ()) { |
1173 | cn = cn->itemAbove (); | 1173 | cn = cn->itemAbove (); |
1174 | --jump; | 1174 | --jump; |
1175 | } | 1175 | } |
1176 | setCurrentItem ( cn ); | 1176 | setCurrentItem ( cn ); |
1177 | ensureItemVisible ( cn ); | 1177 | ensureItemVisible ( cn ); |
1178 | } else | 1178 | } else |
1179 | QListView::keyPressEvent ( e ) ; | 1179 | QListView::keyPressEvent ( e ) ; |
1180 | e->accept(); | 1180 | e->accept(); |
1181 | break; | 1181 | break; |
1182 | case Qt::Key_I: { | 1182 | case Qt::Key_I: { |
1183 | QListViewItem* cn; | 1183 | QListViewItem* cn; |
1184 | cn = currentItem(); | 1184 | cn = currentItem(); |
1185 | if ( cn ) { | 1185 | if ( cn ) { |
1186 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1186 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1187 | if ( ci ){ | 1187 | if ( ci ){ |
1188 | //emit showIncidence( ci->data()); | 1188 | //emit showIncidence( ci->data()); |
1189 | cn = cn->nextSibling(); | 1189 | cn = cn->nextSibling(); |
1190 | if ( cn ) { | 1190 | if ( cn ) { |
1191 | setCurrentItem ( cn ); | 1191 | setCurrentItem ( cn ); |
1192 | ensureItemVisible ( cn ); | 1192 | ensureItemVisible ( cn ); |
1193 | } | 1193 | } |
1194 | emit showIncidence( ci->data()); | 1194 | emit showIncidence( ci->data()); |
1195 | } | 1195 | } |
1196 | } | 1196 | } |
1197 | e->accept(); | 1197 | e->accept(); |
1198 | } | 1198 | } |
1199 | break; | 1199 | break; |
1200 | case Qt::Key_Return: | 1200 | case Qt::Key_Return: |
1201 | case Qt::Key_Enter: | 1201 | case Qt::Key_Enter: |
1202 | { | 1202 | { |
1203 | QListViewItem* cn; | 1203 | QListViewItem* cn; |
1204 | cn = currentItem(); | 1204 | cn = currentItem(); |
1205 | if ( cn ) { | 1205 | if ( cn ) { |
1206 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1206 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1207 | if ( ci ){ | 1207 | if ( ci ){ |
1208 | if ( e->state() == ShiftButton ) | 1208 | if ( e->state() == ShiftButton ) |
1209 | ci->setSelected( false ); | 1209 | ci->setSelected( false ); |
1210 | else | 1210 | else |
1211 | ci->setSelected( true ); | 1211 | ci->setSelected( true ); |
1212 | cn = cn->nextSibling(); | 1212 | cn = cn->nextSibling(); |
1213 | if ( cn ) { | 1213 | if ( cn ) { |
1214 | setCurrentItem ( cn ); | 1214 | setCurrentItem ( cn ); |
1215 | ensureItemVisible ( cn ); | 1215 | ensureItemVisible ( cn ); |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | e->accept(); | 1219 | e->accept(); |
1220 | } | 1220 | } |
1221 | break; | 1221 | break; |
1222 | default: | 1222 | default: |
1223 | e->ignore(); | 1223 | e->ignore(); |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1226 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1227 | : KListView( lv, "kolistlistview", false ) | 1227 | : KListView( lv, "kolistlistview", false ) |
1228 | { | 1228 | { |
1229 | mYMousePos = 0; | 1229 | mYMousePos = 0; |
1230 | mPopupTimer = new QTimer(this); | 1230 | mPopupTimer = new QTimer(this); |
1231 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1231 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1232 | #ifndef DESKTOP_VERSION | 1232 | #ifndef DESKTOP_VERSION |
1233 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1233 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1234 | #endif | 1234 | #endif |
1235 | setSelectionMode( QListView::Multi ); | 1235 | setSelectionMode( QListView::Multi ); |
1236 | setMultiSelection( true); | 1236 | setMultiSelection( true); |
1237 | } | 1237 | } |
1238 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1238 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) |
1239 | { | 1239 | { |
1240 | int selCount = 0; | 1240 | int selCount = 0; |
1241 | QListViewItem *qitem = firstChild (); | 1241 | QListViewItem *qitem = firstChild (); |
1242 | while ( qitem ) { | 1242 | while ( qitem ) { |
1243 | if ( qitem->isSelected() && item != qitem ) | 1243 | if ( qitem->isSelected() && item != qitem ) |
1244 | return true; | 1244 | return true; |
1245 | qitem = qitem->nextSibling(); | 1245 | qitem = qitem->nextSibling(); |
1246 | } | 1246 | } |
1247 | return false; | 1247 | return false; |
1248 | } | 1248 | } |
1249 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1249 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1250 | { | 1250 | { |
1251 | if (!e) return; | 1251 | if (!e) return; |
1252 | QPoint vp = contentsToViewport(e->pos()); | 1252 | QPoint vp = contentsToViewport(e->pos()); |
1253 | QListViewItem *item = itemAt(vp); | 1253 | QListViewItem *item = itemAt(vp); |
1254 | if (!item) { | 1254 | if (!item) { |
1255 | emit newEvent(); | 1255 | emit newEvent(); |
1256 | return; | 1256 | return; |
1257 | } | 1257 | } |
1258 | KListView::contentsMouseDoubleClickEvent(e); | 1258 | KListView::contentsMouseDoubleClickEvent(e); |
1259 | } | 1259 | } |
1260 | #if 0 | 1260 | #if 0 |
1261 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1261 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1262 | { | 1262 | { |
1263 | //qDebug("contentsMousePressEvent++++ "); | 1263 | //qDebug("contentsMousePressEvent++++ "); |
1264 | KListView::contentsMousePressEvent( e ); | 1264 | KListView::contentsMousePressEvent( e ); |
1265 | if ( e->button() == RightButton ) { | 1265 | if ( e->button() == RightButton ) { |
1266 | QListViewItem* ci = currentItem(); | 1266 | QListViewItem* ci = currentItem(); |
1267 | clearSelection () ; | 1267 | clearSelection () ; |
1268 | if ( ci ) | 1268 | if ( ci ) |
1269 | ci->setSelected( true ); | 1269 | ci->setSelected( true ); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1272 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1273 | { | 1273 | { |
1274 | KListView::contentsMouseReleaseEvent(e); | 1274 | KListView::contentsMouseReleaseEvent(e); |
1275 | } | 1275 | } |
1276 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1276 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1277 | { | 1277 | { |
1278 | KListView::contentsMouseMoveEvent(e); | 1278 | KListView::contentsMouseMoveEvent(e); |
1279 | } | 1279 | } |
1280 | #endif | 1280 | #endif |
1281 | void KOListViewListView::popupMenu() | 1281 | void KOListViewListView::popupMenu() |
1282 | { | 1282 | { |
1283 | mPopupTimer->stop(); | 1283 | mPopupTimer->stop(); |
1284 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1284 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1285 | QApplication::postEvent( this->viewport(), e ); | 1285 | QApplication::postEvent( this->viewport(), e ); |
1286 | 1286 | ||
1287 | } | 1287 | } |
1288 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1288 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1289 | { | 1289 | { |
1290 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1290 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1291 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1291 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1292 | if ( e->button() == LeftButton ) { | 1292 | if ( e->button() == LeftButton ) { |
1293 | mPopupTimer->start( 600 ); | 1293 | mPopupTimer->start( 600 ); |
1294 | mEventPos = contentsToViewport(e->pos()); | 1294 | mEventPos = contentsToViewport(e->pos()); |
1295 | mEventGlobalPos = e->globalPos(); | 1295 | mEventGlobalPos = e->globalPos(); |
1296 | } | 1296 | } |
1297 | KListView::contentsMousePressEvent( e ); | 1297 | KListView::contentsMousePressEvent( e ); |
1298 | if ( e->button() == RightButton ) { | 1298 | if ( e->button() == RightButton ) { |
1299 | QListViewItem* ci = currentItem(); | 1299 | QListViewItem* ci = currentItem(); |
1300 | //clearSelection(); | 1300 | //clearSelection(); |
1301 | if ( ci ) | 1301 | if ( ci ) |
1302 | ci->setSelected( true ); | 1302 | ci->setSelected( true ); |
1303 | } | 1303 | } |
1304 | } | 1304 | } |
1305 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1305 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1306 | { | 1306 | { |
1307 | mPopupTimer->stop(); | 1307 | mPopupTimer->stop(); |
1308 | KListView::contentsMouseReleaseEvent(e); | 1308 | KListView::contentsMouseReleaseEvent(e); |
1309 | } | 1309 | } |
1310 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1310 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1311 | { | 1311 | { |
1312 | // qDebug("contentsMouseMoveEv....... "); | 1312 | // qDebug("contentsMouseMoveEv....... "); |
1313 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1313 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1314 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1314 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1315 | if ( diff < 0 ) diff = -diff; | 1315 | if ( diff < 0 ) diff = -diff; |
1316 | if ( diff > 15 ) | 1316 | if ( diff > 15 ) |
1317 | mPopupTimer->stop(); | 1317 | mPopupTimer->stop(); |
1318 | else { | 1318 | else { |
1319 | mEventPos = contentsToViewport(e->pos()); | 1319 | mEventPos = contentsToViewport(e->pos()); |
1320 | mEventGlobalPos = e->globalPos(); | 1320 | mEventGlobalPos = e->globalPos(); |
1321 | } | 1321 | } |
1322 | KListView::contentsMouseMoveEvent(e); | 1322 | KListView::contentsMouseMoveEvent(e); |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | #define protected public | 1325 | #define protected public |
1326 | #include <qheader.h> | 1326 | #include <qheader.h> |
1327 | #undef protected | 1327 | #undef protected |
1328 | void KOListViewListView::printList() | 1328 | void KOListViewListView::printList() |
1329 | { | 1329 | { |
1330 | #ifdef DESKTOP_VERSION | 1330 | #ifdef DESKTOP_VERSION |
1331 | KOPrintPrefs pp ( this ); | 1331 | KOPrintPrefs pp ( this ); |
1332 | if (!pp.exec() ) | 1332 | if (!pp.exec() ) |
1333 | return; | 1333 | return; |
1334 | int scaleval = pp.printMode() ; | 1334 | int scaleval = pp.printMode() ; |
1335 | 1335 | ||
1336 | QPrinter printer; | 1336 | QPrinter printer; |
1337 | if (!printer.setup() ) | 1337 | if (!printer.setup() ) |
1338 | return; | 1338 | return; |
1339 | clearSelection (); | 1339 | clearSelection (); |
1340 | QPainter p; | 1340 | QPainter p; |
1341 | p.begin ( &printer ); | 1341 | p.begin ( &printer ); |
1342 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 1342 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
1343 | float dx, dy; | 1343 | float dx, dy; |
1344 | int wid = (m.width() * 9)/10; | 1344 | int wid = (m.width() * 9)/10; |
1345 | dx = (float) wid/(float)contentsWidth (); | 1345 | dx = (float) wid/(float)contentsWidth (); |
1346 | dy = (float)(m.height()) / (float)contentsHeight (); | 1346 | dy = (float)(m.height()) / (float)contentsHeight (); |
1347 | float scale; | 1347 | float scale; |
1348 | // scale to fit the width or height of the paper | 1348 | // scale to fit the width or height of the paper |
1349 | if ( dx < dy ) | 1349 | if ( dx < dy ) |
1350 | scale = dx; | 1350 | scale = dx; |
1351 | else | 1351 | else |
1352 | scale = dy; | 1352 | scale = dy; |
1353 | 1353 | ||
1354 | p.translate( m.width()/10,m.width()/10 ); | 1354 | p.translate( m.width()/10,m.width()/10 ); |
1355 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1355 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1356 | p.scale( scale, scale ); | 1356 | p.scale( scale, scale ); |
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | int cou = header()->count(); | 1359 | int cou = header()->count(); |
1360 | int iii; | 1360 | int iii; |
1361 | QRect rect ( 0,0,0, header()->height()); | 1361 | QRect rect ( 0,0,0, header()->height()); |
1362 | for ( iii = 0; iii < cou; ++iii ) { | 1362 | for ( iii = 0; iii < cou; ++iii ) { |
1363 | rect.setLeft ( header()->sectionPos( iii ) ); | 1363 | rect.setLeft ( header()->sectionPos( iii ) ); |
1364 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1364 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1365 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1365 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
1366 | } | 1366 | } |
1367 | p.translate( 0, header()->height()); | 1367 | p.translate( 0, header()->height()); |
1368 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | 1368 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); |
1369 | p.end(); | 1369 | p.end(); |
1370 | #endif | 1370 | #endif |
1371 | } | 1371 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 5aaf360..2602487 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1465 +1,1465 @@ | |||
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 | 28 | ||
29 | #include <qinputdialog.h> | 29 | #include <qinputdialog.h> |
30 | 30 | ||
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include "koprefs.h" | 33 | #include "koprefs.h" |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | 38 | ||
39 | #include <libkcal/icaldrag.h> | 39 | #include <libkcal/icaldrag.h> |
40 | #include <libkcal/vcaldrag.h> | 40 | #include <libkcal/vcaldrag.h> |
41 | #include <libkcal/calfilter.h> | 41 | #include <libkcal/calfilter.h> |
42 | #include <libkcal/dndfactory.h> | 42 | #include <libkcal/dndfactory.h> |
43 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
45 | #include <kresources/resourceselectdialog.h> | 45 | #include <kresources/resourceselectdialog.h> |
46 | #include <libkcal/kincidenceformatter.h> | 46 | #include <libkcal/kincidenceformatter.h> |
47 | #ifndef DESKTOP_VERSION | 47 | #ifndef DESKTOP_VERSION |
48 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
49 | #else | 49 | #else |
50 | #include <qapplication.h> | 50 | #include <qapplication.h> |
51 | #endif | 51 | #endif |
52 | #ifndef KORG_NOPRINTER | 52 | #ifndef KORG_NOPRINTER |
53 | #include "calprinter.h" | 53 | #include "calprinter.h" |
54 | #endif | 54 | #endif |
55 | #include "docprefs.h" | 55 | #include "docprefs.h" |
56 | 56 | ||
57 | #include "kotodoview.h" | 57 | #include "kotodoview.h" |
58 | using namespace KOrg; | 58 | using namespace KOrg; |
59 | 59 | ||
60 | 60 | ||
61 | class KOTodoViewWhatsThis :public QWhatsThis | 61 | class KOTodoViewWhatsThis :public QWhatsThis |
62 | { | 62 | { |
63 | public: | 63 | public: |
64 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 64 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _view->getWhatsThisText(p) ; | 69 | return _view->getWhatsThisText(p) ; |
70 | } | 70 | } |
71 | private: | 71 | private: |
72 | QWidget* _wid; | 72 | QWidget* _wid; |
73 | KOTodoView * _view; | 73 | KOTodoView * _view; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 76 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
77 | const char *name) : | 77 | const char *name) : |
78 | KListView(parent,name) | 78 | KListView(parent,name) |
79 | { | 79 | { |
80 | mName = QString ( name ); | 80 | mName = QString ( name ); |
81 | mCalendar = calendar; | 81 | mCalendar = calendar; |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mOldCurrent = 0; | 85 | mOldCurrent = 0; |
86 | mMousePressed = false; | 86 | mMousePressed = false; |
87 | 87 | ||
88 | setAcceptDrops(true); | 88 | setAcceptDrops(true); |
89 | viewport()->setAcceptDrops(true); | 89 | viewport()->setAcceptDrops(true); |
90 | int size = 16; | 90 | int size = 16; |
91 | if (qApp->desktop()->width() < 300 ) | 91 | if (qApp->desktop()->width() < 300 ) |
92 | size = 12; | 92 | size = 12; |
93 | setTreeStepSize( size + 6 ); | 93 | setTreeStepSize( size + 6 ); |
94 | 94 | ||
95 | } | 95 | } |
96 | 96 | ||
97 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 97 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
98 | { | 98 | { |
99 | #ifndef KORG_NODND | 99 | #ifndef KORG_NODND |
100 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 100 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
101 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 101 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
102 | !QTextDrag::canDecode( e ) ) { | 102 | !QTextDrag::canDecode( e ) ) { |
103 | e->ignore(); | 103 | e->ignore(); |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | 106 | ||
107 | mOldCurrent = currentItem(); | 107 | mOldCurrent = currentItem(); |
108 | #endif | 108 | #endif |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 112 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
113 | { | 113 | { |
114 | #ifndef KORG_NODND | 114 | #ifndef KORG_NODND |
115 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 115 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
116 | 116 | ||
117 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 117 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
118 | !QTextDrag::canDecode( e ) ) { | 118 | !QTextDrag::canDecode( e ) ) { |
119 | e->ignore(); | 119 | e->ignore(); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | e->accept(); | 123 | e->accept(); |
124 | #endif | 124 | #endif |
125 | } | 125 | } |
126 | 126 | ||
127 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 127 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
128 | { | 128 | { |
129 | #ifndef KORG_NODND | 129 | #ifndef KORG_NODND |
130 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 130 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
131 | 131 | ||
132 | setCurrentItem(mOldCurrent); | 132 | setCurrentItem(mOldCurrent); |
133 | setSelected(mOldCurrent,true); | 133 | setSelected(mOldCurrent,true); |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 137 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
138 | { | 138 | { |
139 | #ifndef KORG_NODND | 139 | #ifndef KORG_NODND |
140 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 140 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
141 | 141 | ||
142 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 142 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
143 | !QTextDrag::canDecode( e ) ) { | 143 | !QTextDrag::canDecode( e ) ) { |
144 | e->ignore(); | 144 | e->ignore(); |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | 147 | ||
148 | DndFactory factory( mCalendar ); | 148 | DndFactory factory( mCalendar ); |
149 | Todo *todo = factory.createDropTodo(e); | 149 | Todo *todo = factory.createDropTodo(e); |
150 | 150 | ||
151 | if (todo) { | 151 | if (todo) { |
152 | e->acceptAction(); | 152 | e->acceptAction(); |
153 | 153 | ||
154 | KOTodoViewItem *destination = | 154 | KOTodoViewItem *destination = |
155 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 155 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
156 | Todo *destinationEvent = 0; | 156 | Todo *destinationEvent = 0; |
157 | if (destination) destinationEvent = destination->todo(); | 157 | if (destination) destinationEvent = destination->todo(); |
158 | 158 | ||
159 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 159 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
160 | 160 | ||
161 | if(existingTodo) { | 161 | if(existingTodo) { |
162 | Incidence *to = destinationEvent; | 162 | Incidence *to = destinationEvent; |
163 | while(to) { | 163 | while(to) { |
164 | if (to->uid() == todo->uid()) { | 164 | if (to->uid() == todo->uid()) { |
165 | KMessageBox::sorry(this, | 165 | KMessageBox::sorry(this, |
166 | i18n("Cannot move Todo to itself\nor a child of itself"), | 166 | i18n("Cannot move Todo to itself\nor a child of itself"), |
167 | i18n("Drop Todo")); | 167 | i18n("Drop Todo")); |
168 | delete todo; | 168 | delete todo; |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | to = to->relatedTo(); | 171 | to = to->relatedTo(); |
172 | } | 172 | } |
173 | internalDrop = true; | 173 | internalDrop = true; |
174 | if ( destinationEvent ) | 174 | if ( destinationEvent ) |
175 | reparentTodoSignal( destinationEvent, existingTodo ); | 175 | reparentTodoSignal( destinationEvent, existingTodo ); |
176 | else | 176 | else |
177 | unparentTodoSignal(existingTodo); | 177 | unparentTodoSignal(existingTodo); |
178 | delete todo; | 178 | delete todo; |
179 | } else { | 179 | } else { |
180 | mCalendar->addTodo(todo); | 180 | mCalendar->addTodo(todo); |
181 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 181 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
182 | if ( destinationEvent ) | 182 | if ( destinationEvent ) |
183 | reparentTodoSignal( destinationEvent, todo ); | 183 | reparentTodoSignal( destinationEvent, todo ); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | else { | 186 | else { |
187 | QString text; | 187 | QString text; |
188 | if (QTextDrag::decode(e,text)) { | 188 | if (QTextDrag::decode(e,text)) { |
189 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 189 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
190 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 190 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
191 | qDebug("Dropped : " + text); | 191 | qDebug("Dropped : " + text); |
192 | QStringList emails = QStringList::split(",",text); | 192 | QStringList emails = QStringList::split(",",text); |
193 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 193 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
194 | int pos = (*it).find("<"); | 194 | int pos = (*it).find("<"); |
195 | QString name = (*it).left(pos); | 195 | QString name = (*it).left(pos); |
196 | QString email = (*it).mid(pos); | 196 | QString email = (*it).mid(pos); |
197 | if (!email.isEmpty() && todoi) { | 197 | if (!email.isEmpty() && todoi) { |
198 | todoi->todo()->addAttendee(new Attendee(name,email)); | 198 | todoi->todo()->addAttendee(new Attendee(name,email)); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | else { | 202 | else { |
203 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 203 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
204 | e->ignore(); | 204 | e->ignore(); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | #endif | 207 | #endif |
208 | } | 208 | } |
209 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 209 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
210 | { | 210 | { |
211 | QListView::wheelEvent (e); | 211 | QListView::wheelEvent (e); |
212 | } | 212 | } |
213 | 213 | ||
214 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 214 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
215 | { | 215 | { |
216 | 216 | ||
217 | QPoint p(contentsToViewport(e->pos())); | 217 | QPoint p(contentsToViewport(e->pos())); |
218 | QListViewItem *i = itemAt(p); | 218 | QListViewItem *i = itemAt(p); |
219 | bool rootClicked = true; | 219 | bool rootClicked = true; |
220 | if (i) { | 220 | if (i) { |
221 | // if the user clicked into the root decoration of the item, don't | 221 | // if the user clicked into the root decoration of the item, don't |
222 | // try to start a drag! | 222 | // try to start a drag! |
223 | int X = p.x(); | 223 | int X = p.x(); |
224 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 224 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
225 | if (X > header()->sectionPos(0) + | 225 | if (X > header()->sectionPos(0) + |
226 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 226 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
227 | itemMargin() +i->height()|| | 227 | itemMargin() +i->height()|| |
228 | X < header()->sectionPos(0)) { | 228 | X < header()->sectionPos(0)) { |
229 | rootClicked = false; | 229 | rootClicked = false; |
230 | } | 230 | } |
231 | } else { | 231 | } else { |
232 | rootClicked = false; | 232 | rootClicked = false; |
233 | } | 233 | } |
234 | #ifndef KORG_NODND | 234 | #ifndef KORG_NODND |
235 | mMousePressed = false; | 235 | mMousePressed = false; |
236 | if (! rootClicked && !( e->button() == RightButton) ) { | 236 | if (! rootClicked && !( e->button() == RightButton) ) { |
237 | mPressPos = e->pos(); | 237 | mPressPos = e->pos(); |
238 | mMousePressed = true; | 238 | mMousePressed = true; |
239 | } else { | 239 | } else { |
240 | mMousePressed = false; | 240 | mMousePressed = false; |
241 | } | 241 | } |
242 | #endif | 242 | #endif |
243 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 243 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
244 | #ifndef DESKTOP_VERSION | 244 | #ifndef DESKTOP_VERSION |
245 | if (!( e->button() == RightButton && rootClicked) ) | 245 | if (!( e->button() == RightButton && rootClicked) ) |
246 | QListView::contentsMousePressEvent(e); | 246 | QListView::contentsMousePressEvent(e); |
247 | #else | 247 | #else |
248 | QListView::contentsMousePressEvent(e); | 248 | QListView::contentsMousePressEvent(e); |
249 | #endif | 249 | #endif |
250 | } | 250 | } |
251 | void KOTodoListView::paintEvent(QPaintEvent* e) | 251 | void KOTodoListView::paintEvent(QPaintEvent* e) |
252 | { | 252 | { |
253 | emit paintNeeded(); | 253 | emit paintNeeded(); |
254 | QListView::paintEvent( e); | 254 | QListView::paintEvent( e); |
255 | } | 255 | } |
256 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 256 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
257 | { | 257 | { |
258 | 258 | ||
259 | #ifndef KORG_NODND | 259 | #ifndef KORG_NODND |
260 | //QListView::contentsMouseMoveEvent(e); | 260 | //QListView::contentsMouseMoveEvent(e); |
261 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 261 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
262 | QApplication::startDragDistance()*3) { | 262 | QApplication::startDragDistance()*3) { |
263 | mMousePressed = false; | 263 | mMousePressed = false; |
264 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 264 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
265 | if (item) { | 265 | if (item) { |
266 | DndFactory factory( mCalendar ); | 266 | DndFactory factory( mCalendar ); |
267 | ICalDrag *vd = factory.createDrag( | 267 | ICalDrag *vd = factory.createDrag( |
268 | ((KOTodoViewItem *)item)->todo(),viewport()); | 268 | ((KOTodoViewItem *)item)->todo(),viewport()); |
269 | internalDrop = false; | 269 | internalDrop = false; |
270 | // we cannot do any senseful here, because the DnD is still broken in Qt | 270 | // we cannot do any senseful here, because the DnD is still broken in Qt |
271 | if (vd->drag()) { | 271 | if (vd->drag()) { |
272 | if ( !internalDrop ) { | 272 | if ( !internalDrop ) { |
273 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 273 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
274 | qDebug("Dnd: External move: Delete drag source "); | 274 | qDebug("Dnd: External move: Delete drag source "); |
275 | } else | 275 | } else |
276 | qDebug("Dnd: Internal move "); | 276 | qDebug("Dnd: Internal move "); |
277 | 277 | ||
278 | } else { | 278 | } else { |
279 | if ( !internalDrop ) { | 279 | if ( !internalDrop ) { |
280 | qDebug("Dnd: External Copy"); | 280 | qDebug("Dnd: External Copy"); |
281 | } else | 281 | } else |
282 | qDebug("DnD: Internal copy: Copy pending"); | 282 | qDebug("DnD: Internal copy: Copy pending"); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | #endif | 286 | #endif |
287 | } | 287 | } |
288 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 288 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
289 | { | 289 | { |
290 | if ( !e->isAutoRepeat() ) { | 290 | if ( !e->isAutoRepeat() ) { |
291 | mFlagKeyPressed = false; | 291 | mFlagKeyPressed = false; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 296 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
297 | { | 297 | { |
298 | qApp->processEvents(); | 298 | qApp->processEvents(); |
299 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 299 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
300 | e->ignore(); | 300 | e->ignore(); |
301 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 301 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
302 | return; | 302 | return; |
303 | } | 303 | } |
304 | if (! e->isAutoRepeat() ) | 304 | if (! e->isAutoRepeat() ) |
305 | mFlagKeyPressed = true; | 305 | mFlagKeyPressed = true; |
306 | QListViewItem* cn; | 306 | QListViewItem* cn; |
307 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 307 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
308 | cn = currentItem(); | 308 | cn = currentItem(); |
309 | if ( cn ) { | 309 | if ( cn ) { |
310 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 310 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
311 | if ( ci ){ | 311 | if ( ci ){ |
312 | if ( e->state() == ShiftButton ) | 312 | if ( e->state() == ShiftButton ) |
313 | ci->setOn( false ); | 313 | ci->setOn( false ); |
314 | else | 314 | else |
315 | ci->setOn( true ); | 315 | ci->setOn( true ); |
316 | cn = cn->itemBelow(); | 316 | cn = cn->itemBelow(); |
317 | if ( cn ) { | 317 | if ( cn ) { |
318 | setCurrentItem ( cn ); | 318 | setCurrentItem ( cn ); |
319 | ensureItemVisible ( cn ); | 319 | ensureItemVisible ( cn ); |
320 | } | 320 | } |
321 | 321 | ||
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | return; | 325 | return; |
326 | } | 326 | } |
327 | 327 | ||
328 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 328 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
329 | switch ( e->key() ) { | 329 | switch ( e->key() ) { |
330 | case Qt::Key_Down: | 330 | case Qt::Key_Down: |
331 | case Qt::Key_Up: | 331 | case Qt::Key_Up: |
332 | QListView::keyPressEvent ( e ); | 332 | QListView::keyPressEvent ( e ); |
333 | break; | 333 | break; |
334 | case Qt::Key_Left: | 334 | case Qt::Key_Left: |
335 | case Qt::Key_Right: | 335 | case Qt::Key_Right: |
336 | QListView::keyPressEvent ( e ); | 336 | QListView::keyPressEvent ( e ); |
337 | e->accept(); | 337 | e->accept(); |
338 | return; | 338 | return; |
339 | break; | 339 | break; |
340 | default: | 340 | default: |
341 | e->ignore(); | 341 | e->ignore(); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | e->ignore(); | 346 | e->ignore(); |
347 | } | 347 | } |
348 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 348 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
349 | { | 349 | { |
350 | QListView::contentsMouseReleaseEvent(e); | 350 | QListView::contentsMouseReleaseEvent(e); |
351 | mMousePressed = false; | 351 | mMousePressed = false; |
352 | } | 352 | } |
353 | 353 | ||
354 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 354 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
355 | { | 355 | { |
356 | if (!e) return; | 356 | if (!e) return; |
357 | 357 | ||
358 | QPoint vp = contentsToViewport(e->pos()); | 358 | QPoint vp = contentsToViewport(e->pos()); |
359 | 359 | ||
360 | QListViewItem *item = itemAt(vp); | 360 | QListViewItem *item = itemAt(vp); |
361 | 361 | ||
362 | emit double_Clicked(item); | 362 | emit double_Clicked(item); |
363 | if (!item) return; | 363 | if (!item) return; |
364 | 364 | ||
365 | emit doubleClicked(item,vp,0); | 365 | emit doubleClicked(item,vp,0); |
366 | } | 366 | } |
367 | 367 | ||
368 | ///////////////////////////////////////////////////////////////////////////// | 368 | ///////////////////////////////////////////////////////////////////////////// |
369 | 369 | ||
370 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 370 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
371 | QLineEdit(parent) | 371 | QLineEdit(parent) |
372 | { | 372 | { |
373 | setText(i18n("Click to add a new Todo")); | 373 | setText(i18n("Click to add a new Todo")); |
374 | } | 374 | } |
375 | 375 | ||
376 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 376 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
377 | { | 377 | { |
378 | if ( text()==i18n("Click to add a new Todo") ) | 378 | if ( text()==i18n("Click to add a new Todo") ) |
379 | setText(""); | 379 | setText(""); |
380 | QLineEdit::focusInEvent(ev); | 380 | QLineEdit::focusInEvent(ev); |
381 | } | 381 | } |
382 | 382 | ||
383 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 383 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
384 | { | 384 | { |
385 | setText(i18n("Click to add a new Todo")); | 385 | setText(i18n("Click to add a new Todo")); |
386 | QLineEdit::focusOutEvent(ev); | 386 | QLineEdit::focusOutEvent(ev); |
387 | } | 387 | } |
388 | 388 | ||
389 | ///////////////////////////////////////////////////////////////////////////// | 389 | ///////////////////////////////////////////////////////////////////////////// |
390 | 390 | ||
391 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 391 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
392 | KOrg::BaseView(calendar,parent,name) | 392 | KOrg::BaseView(calendar,parent,name) |
393 | { | 393 | { |
394 | mPendingUpdateBeforeRepaint = false; | 394 | mPendingUpdateBeforeRepaint = false; |
395 | isFlatDisplay = false; | 395 | isFlatDisplay = false; |
396 | mNavigator = 0; | 396 | mNavigator = 0; |
397 | QBoxLayout *topLayout = new QVBoxLayout(this); | 397 | QBoxLayout *topLayout = new QVBoxLayout(this); |
398 | mName = QString ( name ); | 398 | mName = QString ( name ); |
399 | mBlockUpdate = false; | 399 | mBlockUpdate = false; |
400 | mQuickAdd = new KOQuickTodo(this); | 400 | mQuickAdd = new KOQuickTodo(this); |
401 | topLayout->addWidget(mQuickAdd); | 401 | topLayout->addWidget(mQuickAdd); |
402 | 402 | ||
403 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 403 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
404 | 404 | ||
405 | mTodoListView = new KOTodoListView(calendar,this, name ); | 405 | mTodoListView = new KOTodoListView(calendar,this, name ); |
406 | topLayout->addWidget(mTodoListView); | 406 | topLayout->addWidget(mTodoListView); |
407 | //mTodoListView->header()->setMaximumHeight(30); | 407 | //mTodoListView->header()->setMaximumHeight(30); |
408 | mTodoListView->setRootIsDecorated(true); | 408 | mTodoListView->setRootIsDecorated(true); |
409 | mTodoListView->setAllColumnsShowFocus(true); | 409 | mTodoListView->setAllColumnsShowFocus(true); |
410 | 410 | ||
411 | mTodoListView->setShowSortIndicator(true); | 411 | mTodoListView->setShowSortIndicator(true); |
412 | 412 | ||
413 | mTodoListView->addColumn(i18n("Todo")); | 413 | mTodoListView->addColumn(i18n("Todo")); |
414 | mTodoListView->addColumn(i18n("Prio")); | 414 | mTodoListView->addColumn(i18n("Prio")); |
415 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 415 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
416 | mTodoListView->addColumn(i18n("Complete")); | 416 | mTodoListView->addColumn(i18n("Complete")); |
417 | mTodoListView->setColumnAlignment(2,AlignCenter); | 417 | mTodoListView->setColumnAlignment(2,AlignCenter); |
418 | 418 | ||
419 | mTodoListView->addColumn(i18n("Due Date")); | 419 | mTodoListView->addColumn(i18n("Due Date")); |
420 | mTodoListView->setColumnAlignment(3,AlignLeft); | 420 | mTodoListView->setColumnAlignment(3,AlignLeft); |
421 | mTodoListView->addColumn(i18n("Due Time")); | 421 | mTodoListView->addColumn(i18n("Due Time")); |
422 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 422 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
423 | 423 | ||
424 | mTodoListView->addColumn(i18n("Start Date")); | 424 | mTodoListView->addColumn(i18n("Start Date")); |
425 | mTodoListView->setColumnAlignment(5,AlignLeft); | 425 | mTodoListView->setColumnAlignment(5,AlignLeft); |
426 | mTodoListView->addColumn(i18n("Start Time")); | 426 | mTodoListView->addColumn(i18n("Start Time")); |
427 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 427 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
428 | 428 | ||
429 | mTodoListView->addColumn(i18n("Cancelled")); | 429 | mTodoListView->addColumn(i18n("Cancelled")); |
430 | mTodoListView->addColumn(i18n("Categories")); | 430 | mTodoListView->addColumn(i18n("Categories")); |
431 | #if 0 | 431 | #if 0 |
432 | mTodoListView->addColumn(i18n("Sort Id")); | 432 | mTodoListView->addColumn(i18n("Sort Id")); |
433 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 433 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
434 | #endif | 434 | #endif |
435 | 435 | ||
436 | mTodoListView->setMinimumHeight( 60 ); | 436 | mTodoListView->setMinimumHeight( 60 ); |
437 | mTodoListView->setItemsRenameable( true ); | 437 | mTodoListView->setItemsRenameable( true ); |
438 | mTodoListView->setRenameable( 0 ); | 438 | mTodoListView->setRenameable( 0 ); |
439 | mTodoListView->setColumnWidth( 0, 120 ); | 439 | mTodoListView->setColumnWidth( 0, 120 ); |
440 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 440 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
441 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 441 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
442 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 442 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
443 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 443 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
444 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 444 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
445 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 445 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
446 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 446 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
447 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 447 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
448 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 448 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
449 | 449 | ||
450 | 450 | ||
451 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 451 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
452 | 452 | ||
453 | mPriorityPopupMenu = new QPopupMenu(this); | 453 | mPriorityPopupMenu = new QPopupMenu(this); |
454 | for (int i = 1; i <= 5; i++) { | 454 | for (int i = 1; i <= 5; i++) { |
455 | QString label = QString ("%1").arg (i); | 455 | QString label = QString ("%1").arg (i); |
456 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 456 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
457 | } | 457 | } |
458 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 458 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
459 | 459 | ||
460 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 460 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
461 | for (int i = 0; i <= 100; i+=20) { | 461 | for (int i = 0; i <= 100; i+=20) { |
462 | QString label = QString ("%1 %").arg (i); | 462 | QString label = QString ("%1 %").arg (i); |
463 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 463 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
464 | } | 464 | } |
465 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 465 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
466 | 466 | ||
467 | 467 | ||
468 | 468 | ||
469 | mItemPopupMenu = new QPopupMenu(this); | 469 | mItemPopupMenu = new QPopupMenu(this); |
470 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 470 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
471 | SLOT (showTodo())); | 471 | SLOT (showTodo())); |
472 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 472 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
473 | SLOT (editTodo())); | 473 | SLOT (editTodo())); |
474 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 474 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
475 | SLOT (deleteTodo())); | 475 | SLOT (deleteTodo())); |
476 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 476 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
477 | SLOT (cloneTodo())); | 477 | SLOT (cloneTodo())); |
478 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 478 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
479 | SLOT (moveTodo())); | 479 | SLOT (moveTodo())); |
480 | #ifndef DESKTOP_VERSION | 480 | #ifndef DESKTOP_VERSION |
481 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 481 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
482 | SLOT (beamTodo())); | 482 | SLOT (beamTodo())); |
483 | #endif | 483 | #endif |
484 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 484 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
485 | SLOT (cancelTodo())); | 485 | SLOT (cancelTodo())); |
486 | mItemPopupMenu->insertSeparator(); | 486 | mItemPopupMenu->insertSeparator(); |
487 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 487 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
488 | SLOT (toggleRunningItem())); | 488 | SLOT (toggleRunningItem())); |
489 | mItemPopupMenu->insertSeparator(); | 489 | mItemPopupMenu->insertSeparator(); |
490 | /* | 490 | /* |
491 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 491 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
492 | SLOT (newTodo())); | 492 | SLOT (newTodo())); |
493 | */ | 493 | */ |
494 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 494 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
495 | SLOT (newSubTodo())); | 495 | SLOT (newSubTodo())); |
496 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 496 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
497 | SLOT (unparentTodo()),0,21); | 497 | SLOT (unparentTodo()),0,21); |
498 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 498 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
499 | SLOT (reparentTodo()),0,22); | 499 | SLOT (reparentTodo()),0,22); |
500 | mItemPopupMenu->insertSeparator(); | 500 | mItemPopupMenu->insertSeparator(); |
501 | #if 0 | 501 | #if 0 |
502 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 502 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
503 | this, SLOT( purgeCompleted() ) ); | 503 | this, SLOT( purgeCompleted() ) ); |
504 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 504 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
505 | this, SLOT( toggleCompleted() ),0, 33 ); | 505 | this, SLOT( toggleCompleted() ),0, 33 ); |
506 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 506 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
507 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 507 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
508 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 508 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
509 | this, SLOT( toggleRunning() ),0, 35 ); | 509 | this, SLOT( toggleRunning() ),0, 35 ); |
510 | 510 | ||
511 | #endif | 511 | #endif |
512 | mPopupMenu = new QPopupMenu(this); | 512 | mPopupMenu = new QPopupMenu(this); |
513 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 513 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
514 | SLOT (newTodo()),0,1); | 514 | SLOT (newTodo()),0,1); |
515 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 515 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
516 | this, SLOT(purgeCompleted()),0,2); | 516 | this, SLOT(purgeCompleted()),0,2); |
517 | mPopupMenu->insertItem(i18n("Show Completed"), | 517 | mPopupMenu->insertItem(i18n("Show Completed"), |
518 | this, SLOT( toggleCompleted() ),0,3 ); | 518 | this, SLOT( toggleCompleted() ),0,3 ); |
519 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 519 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
520 | this, SLOT( toggleRunning() ),0,5 ); | 520 | this, SLOT( toggleRunning() ),0,5 ); |
521 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 521 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
522 | this, SLOT( setAllOpen() ),0,6 ); | 522 | this, SLOT( setAllOpen() ),0,6 ); |
523 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 523 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
524 | this, SLOT( setAllClose() ),0,7 ); | 524 | this, SLOT( setAllClose() ),0,7 ); |
525 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 525 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
526 | this, SLOT( setAllFlat() ),0,8 ); | 526 | this, SLOT( setAllFlat() ),0,8 ); |
527 | mPopupMenu->insertSeparator(); | 527 | mPopupMenu->insertSeparator(); |
528 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 528 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
529 | this, SLOT( toggleQuickTodo() ),0,4 ); | 529 | this, SLOT( toggleQuickTodo() ),0,4 ); |
530 | mDocPrefs = new DocPrefs( name ); | 530 | mDocPrefs = new DocPrefs( name ); |
531 | 531 | ||
532 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 532 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
533 | mPopupMenu->setCheckable( true ); | 533 | mPopupMenu->setCheckable( true ); |
534 | mItemPopupMenu->setCheckable( true ); | 534 | mItemPopupMenu->setCheckable( true ); |
535 | 535 | ||
536 | 536 | ||
537 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 537 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
538 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 538 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
539 | 539 | ||
540 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 540 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
541 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 541 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
542 | 542 | ||
543 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 543 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
544 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 544 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
545 | 545 | ||
546 | 546 | ||
547 | // Double clicking conflicts with opening/closing the subtree | 547 | // Double clicking conflicts with opening/closing the subtree |
548 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 548 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
549 | SLOT( editItem( QListViewItem *) ) ); | 549 | SLOT( editItem( QListViewItem *) ) ); |
550 | /* | 550 | /* |
551 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 551 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
552 | const QPoint &,int ) ), | 552 | const QPoint &,int ) ), |
553 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 553 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
554 | */ | 554 | */ |
555 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 555 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
556 | const QPoint &,int ) ), | 556 | const QPoint &,int ) ), |
557 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 557 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
558 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 558 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
559 | SLOT( itemClicked( QListViewItem * ) ) ); | 559 | SLOT( itemClicked( QListViewItem * ) ) ); |
560 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 560 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
561 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 561 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
562 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 562 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
563 | SLOT( updateView() ) ); | 563 | SLOT( updateView() ) ); |
564 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 564 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
565 | SLOT( todoModified(Todo *, int) ) ); | 565 | SLOT( todoModified(Todo *, int) ) ); |
566 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 566 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
567 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 567 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
568 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 568 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
569 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 569 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
570 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 570 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
571 | SLOT( paintNeeded()) ); | 571 | SLOT( paintNeeded()) ); |
572 | 572 | ||
573 | #if 0 | 573 | #if 0 |
574 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 574 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
575 | SLOT(selectionChanged(QListViewItem *))); | 575 | SLOT(selectionChanged(QListViewItem *))); |
576 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 576 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
577 | SLOT(selectionChanged(QListViewItem *))); | 577 | SLOT(selectionChanged(QListViewItem *))); |
578 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 578 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
579 | SLOT(selectionChanged(QListViewItem *))); | 579 | SLOT(selectionChanged(QListViewItem *))); |
580 | #endif | 580 | #endif |
581 | 581 | ||
582 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 582 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
583 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 583 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
584 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 584 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
585 | 585 | ||
586 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 586 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
587 | SLOT( processSelectionChange() ) ); | 587 | SLOT( processSelectionChange() ) ); |
588 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 588 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
589 | SLOT( addQuickTodo() ) ); | 589 | SLOT( addQuickTodo() ) ); |
590 | 590 | ||
591 | } | 591 | } |
592 | 592 | ||
593 | KOTodoView::~KOTodoView() | 593 | KOTodoView::~KOTodoView() |
594 | { | 594 | { |
595 | 595 | ||
596 | #if QT_VERSION >= 0x030000 | 596 | #if QT_VERSION >= 0x030000 |
597 | 597 | ||
598 | #else | 598 | #else |
599 | delete mKOTodoViewWhatsThis; | 599 | delete mKOTodoViewWhatsThis; |
600 | #endif | 600 | #endif |
601 | 601 | ||
602 | delete mDocPrefs; | 602 | delete mDocPrefs; |
603 | } | 603 | } |
604 | QString KOTodoView::getWhatsThisText(QPoint p) | 604 | QString KOTodoView::getWhatsThisText(QPoint p) |
605 | { | 605 | { |
606 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 606 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
607 | if ( item ) | 607 | if ( item ) |
608 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 608 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
609 | KOPrefs::instance()->mWTshowDetails, | 609 | KOPrefs::instance()->mWTshowDetails, |
610 | KOPrefs::instance()->mWTshowCreated, | 610 | KOPrefs::instance()->mWTshowCreated, |
611 | KOPrefs::instance()->mWTshowChanged); | 611 | KOPrefs::instance()->mWTshowChanged); |
612 | return i18n("That is the todo view" ); | 612 | return i18n("That is the todo view" ); |
613 | 613 | ||
614 | } | 614 | } |
615 | 615 | ||
616 | void KOTodoView::jumpToDate () | 616 | void KOTodoView::jumpToDate () |
617 | { | 617 | { |
618 | // if (mActiveItem) { | 618 | // if (mActiveItem) { |
619 | // mActiveItem->todo()); | 619 | // mActiveItem->todo()); |
620 | // if ( mActiveItem->todo()->hasDueDate() ) | 620 | // if ( mActiveItem->todo()->hasDueDate() ) |
621 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 621 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
622 | } | 622 | } |
623 | void KOTodoView::paintNeeded() | 623 | void KOTodoView::paintNeeded() |
624 | { | 624 | { |
625 | if ( mPendingUpdateBeforeRepaint ) { | 625 | if ( mPendingUpdateBeforeRepaint ) { |
626 | updateView(); | 626 | updateView(); |
627 | mPendingUpdateBeforeRepaint = false; | 627 | mPendingUpdateBeforeRepaint = false; |
628 | } | 628 | } |
629 | } | 629 | } |
630 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 630 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
631 | { | 631 | { |
632 | if ( mPendingUpdateBeforeRepaint ) { | 632 | if ( mPendingUpdateBeforeRepaint ) { |
633 | updateView(); | 633 | updateView(); |
634 | mPendingUpdateBeforeRepaint = false; | 634 | mPendingUpdateBeforeRepaint = false; |
635 | } | 635 | } |
636 | KOrg::BaseView::paintEvent( pevent); | 636 | KOrg::BaseView::paintEvent( pevent); |
637 | } | 637 | } |
638 | 638 | ||
639 | void KOTodoView::updateView() | 639 | void KOTodoView::updateView() |
640 | { | 640 | { |
641 | pendingSubtodo = 0; | 641 | pendingSubtodo = 0; |
642 | if ( mBlockUpdate ) { | 642 | if ( mBlockUpdate ) { |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | if ( !isVisible() ) { | 645 | if ( !isVisible() ) { |
646 | mPendingUpdateBeforeRepaint = true; | 646 | mPendingUpdateBeforeRepaint = true; |
647 | return; | 647 | return; |
648 | } | 648 | } |
649 | storeCurrentItem(); | 649 | storeCurrentItem(); |
650 | //qDebug("KOTodoView::updateView() %x", this); | 650 | //qDebug("KOTodoView::updateView() %x", this); |
651 | if ( isFlatDisplay ) { | 651 | if ( isFlatDisplay ) { |
652 | displayAllFlat(); | 652 | displayAllFlat(); |
653 | resetCurrentItem(); | 653 | resetCurrentItem(); |
654 | return; | 654 | return; |
655 | } | 655 | } |
656 | //qDebug("update "); | 656 | //qDebug("update "); |
657 | // kdDebug() << "KOTodoView::updateView()" << endl; | 657 | // kdDebug() << "KOTodoView::updateView()" << endl; |
658 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 658 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
659 | 659 | ||
660 | 660 | ||
661 | mTodoListView->clear(); | 661 | mTodoListView->clear(); |
662 | if ( mName == "todolistsmall" ) { | 662 | if ( mName == "todolistsmall" ) { |
663 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 663 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
664 | int ps = fo.pointSize() -2; | 664 | int ps = fo.pointSize() -2; |
665 | if ( ps > 12 ) | 665 | if ( ps > 12 ) |
666 | ps -= 2; | 666 | ps -= 2; |
667 | fo.setPointSize( ps ); | 667 | fo.setPointSize( ps ); |
668 | } | 668 | } |
669 | } | 669 | } |
670 | 670 | ||
671 | mTodoListView->setFont( fo ); | 671 | mTodoListView->setFont( fo ); |
672 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 672 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
673 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 673 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
674 | QPtrList<Todo> todoList = calendar()->todos(); | 674 | QPtrList<Todo> todoList = calendar()->todos(); |
675 | 675 | ||
676 | /* | 676 | /* |
677 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 677 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
678 | Event *t; | 678 | Event *t; |
679 | for(t = todoList.first(); t; t = todoList.next()) { | 679 | for(t = todoList.first(); t; t = todoList.next()) { |
680 | kdDebug() << " " << t->getSummary() << endl; | 680 | kdDebug() << " " << t->getSummary() << endl; |
681 | 681 | ||
682 | if (t->getRelatedTo()) { | 682 | if (t->getRelatedTo()) { |
683 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 683 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
684 | } | 684 | } |
685 | 685 | ||
686 | QPtrList<Event> l = t->getRelations(); | 686 | QPtrList<Event> l = t->getRelations(); |
687 | Event *c; | 687 | Event *c; |
688 | for(c=l.first();c;c=l.next()) { | 688 | for(c=l.first();c;c=l.next()) { |
689 | kdDebug() << " - relation: " << c->getSummary() << endl; | 689 | kdDebug() << " - relation: " << c->getSummary() << endl; |
690 | } | 690 | } |
691 | } | 691 | } |
692 | */ | 692 | */ |
693 | 693 | ||
694 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 694 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
695 | // specific order of events. That means that we have to generate parent items | 695 | // specific order of events. That means that we have to generate parent items |
696 | // recursively for proper hierarchical display of Todos. | 696 | // recursively for proper hierarchical display of Todos. |
697 | mTodoMap.clear(); | 697 | mTodoMap.clear(); |
698 | Todo *todo; | 698 | Todo *todo; |
699 | todo = todoList.first();// todo; todo = todoList.next()) { | 699 | todo = todoList.first();// todo; todo = todoList.next()) { |
700 | while ( todo ) { | 700 | while ( todo ) { |
701 | bool next = true; | 701 | bool next = true; |
702 | // qDebug("todo %s ", todo->summary().latin1()); | 702 | // qDebug("todo %s ", todo->summary().latin1()); |
703 | Incidence *incidence = todo->relatedTo(); | 703 | Incidence *incidence = todo->relatedTo(); |
704 | while ( incidence ) { | 704 | while ( incidence ) { |
705 | if ( incidence->type() == "Todo") { | 705 | if ( incidence->typeID() == todoID ) { |
706 | //qDebug("related %s ",incidence->summary().latin1() ); | 706 | //qDebug("related %s ",incidence->summary().latin1() ); |
707 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 707 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
708 | //qDebug("related not found "); | 708 | //qDebug("related not found "); |
709 | todoList.remove( ); | 709 | todoList.remove( ); |
710 | todo = todoList.current(); | 710 | todo = todoList.current(); |
711 | next = false; | 711 | next = false; |
712 | incidence = 0; | 712 | incidence = 0; |
713 | 713 | ||
714 | } else { | 714 | } else { |
715 | //qDebug("related found "); | 715 | //qDebug("related found "); |
716 | incidence = incidence->relatedTo(); | 716 | incidence = incidence->relatedTo(); |
717 | } | 717 | } |
718 | } else | 718 | } else |
719 | incidence = 0; | 719 | incidence = 0; |
720 | } | 720 | } |
721 | if ( next ) | 721 | if ( next ) |
722 | todo = todoList.next(); | 722 | todo = todoList.next(); |
723 | } | 723 | } |
724 | 724 | ||
725 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 725 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
726 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 726 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
727 | { | 727 | { |
728 | insertTodoItem(todo); | 728 | insertTodoItem(todo); |
729 | } | 729 | } |
730 | } | 730 | } |
731 | // Restore opened/closed state | 731 | // Restore opened/closed state |
732 | mTodoListView->blockSignals( true ); | 732 | mTodoListView->blockSignals( true ); |
733 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 733 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
734 | mTodoListView->blockSignals( false ); | 734 | mTodoListView->blockSignals( false ); |
735 | resetCurrentItem(); | 735 | resetCurrentItem(); |
736 | processSelectionChange(); | 736 | processSelectionChange(); |
737 | } | 737 | } |
738 | 738 | ||
739 | void KOTodoView::storeCurrentItem() | 739 | void KOTodoView::storeCurrentItem() |
740 | { | 740 | { |
741 | mCurItem = 0; | 741 | mCurItem = 0; |
742 | mCurItemRootParent = 0; | 742 | mCurItemRootParent = 0; |
743 | mCurItemParent = 0; | 743 | mCurItemParent = 0; |
744 | mCurItemAbove = 0; | 744 | mCurItemAbove = 0; |
745 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 745 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
746 | if (mActiveItem) { | 746 | if (mActiveItem) { |
747 | mCurItem = mActiveItem->todo(); | 747 | mCurItem = mActiveItem->todo(); |
748 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 748 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
749 | if ( activeItemAbove ) | 749 | if ( activeItemAbove ) |
750 | mCurItemAbove = activeItemAbove->todo(); | 750 | mCurItemAbove = activeItemAbove->todo(); |
751 | mCurItemRootParent = mCurItem; | 751 | mCurItemRootParent = mCurItem; |
752 | mCurItemParent = mCurItemRootParent->relatedTo(); | 752 | mCurItemParent = mCurItemRootParent->relatedTo(); |
753 | while ( mCurItemRootParent->relatedTo() != 0 ) | 753 | while ( mCurItemRootParent->relatedTo() != 0 ) |
754 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 754 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
755 | } | 755 | } |
756 | mActiveItem = 0; | 756 | mActiveItem = 0; |
757 | } | 757 | } |
758 | 758 | ||
759 | void KOTodoView::resetCurrentItem() | 759 | void KOTodoView::resetCurrentItem() |
760 | { | 760 | { |
761 | mTodoListView->setFocus(); | 761 | mTodoListView->setFocus(); |
762 | KOTodoViewItem* foundItem = 0; | 762 | KOTodoViewItem* foundItem = 0; |
763 | KOTodoViewItem* foundItemRoot = 0; | 763 | KOTodoViewItem* foundItemRoot = 0; |
764 | KOTodoViewItem* foundItemParent = 0; | 764 | KOTodoViewItem* foundItemParent = 0; |
765 | KOTodoViewItem* foundItemAbove = 0; | 765 | KOTodoViewItem* foundItemAbove = 0; |
766 | if ( mTodoListView->firstChild () ) { | 766 | if ( mTodoListView->firstChild () ) { |
767 | if ( mCurItem ) { | 767 | if ( mCurItem ) { |
768 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 768 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
769 | while ( item ) { | 769 | while ( item ) { |
770 | if ( item->todo() == mCurItem ) { | 770 | if ( item->todo() == mCurItem ) { |
771 | foundItem = item; | 771 | foundItem = item; |
772 | break; | 772 | break; |
773 | } else if ( item->todo() == mCurItemAbove ) { | 773 | } else if ( item->todo() == mCurItemAbove ) { |
774 | foundItemAbove = item; | 774 | foundItemAbove = item; |
775 | 775 | ||
776 | } | 776 | } |
777 | if ( item->todo() == mCurItemRootParent ) { | 777 | if ( item->todo() == mCurItemRootParent ) { |
778 | foundItemRoot = item; | 778 | foundItemRoot = item; |
779 | } | 779 | } |
780 | if ( item->todo() == mCurItemParent ) { | 780 | if ( item->todo() == mCurItemParent ) { |
781 | foundItemParent = item; | 781 | foundItemParent = item; |
782 | } | 782 | } |
783 | item = (KOTodoViewItem*)item->itemBelow(); | 783 | item = (KOTodoViewItem*)item->itemBelow(); |
784 | } | 784 | } |
785 | if ( ! foundItem ) { | 785 | if ( ! foundItem ) { |
786 | if ( foundItemParent ) { | 786 | if ( foundItemParent ) { |
787 | foundItem = foundItemParent; | 787 | foundItem = foundItemParent; |
788 | } else { | 788 | } else { |
789 | if ( foundItemRoot ) | 789 | if ( foundItemRoot ) |
790 | foundItem = foundItemRoot; | 790 | foundItem = foundItemRoot; |
791 | else | 791 | else |
792 | foundItem = foundItemAbove; | 792 | foundItem = foundItemAbove; |
793 | } | 793 | } |
794 | } | 794 | } |
795 | } | 795 | } |
796 | if ( foundItem ) { | 796 | if ( foundItem ) { |
797 | mTodoListView->setCurrentItem( foundItem ); | 797 | mTodoListView->setCurrentItem( foundItem ); |
798 | mTodoListView->ensureItemVisible( foundItem ); | 798 | mTodoListView->ensureItemVisible( foundItem ); |
799 | } else { | 799 | } else { |
800 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 800 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
801 | } | 801 | } |
802 | } | 802 | } |
803 | mTodoListView->setFocus(); | 803 | mTodoListView->setFocus(); |
804 | } | 804 | } |
805 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 805 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
806 | bool KOTodoView::checkTodo( Todo * todo ) | 806 | bool KOTodoView::checkTodo( Todo * todo ) |
807 | { | 807 | { |
808 | 808 | ||
809 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 809 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
810 | return false; | 810 | return false; |
811 | if ( !todo->isCompleted() ) { | 811 | if ( !todo->isCompleted() ) { |
812 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 812 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
813 | return true; | 813 | return true; |
814 | } | 814 | } |
815 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 815 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
816 | if ( todo->hasStartDate() ) | 816 | if ( todo->hasStartDate() ) |
817 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 817 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
818 | return false; | 818 | return false; |
819 | if ( todo->hasDueDate() ) | 819 | if ( todo->hasDueDate() ) |
820 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 820 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
821 | return false; | 821 | return false; |
822 | } | 822 | } |
823 | return true; | 823 | return true; |
824 | } | 824 | } |
825 | 825 | ||
826 | void KOTodoView::restoreItemState( QListViewItem *item ) | 826 | void KOTodoView::restoreItemState( QListViewItem *item ) |
827 | { | 827 | { |
828 | pendingSubtodo = 0; | 828 | pendingSubtodo = 0; |
829 | while( item ) { | 829 | while( item ) { |
830 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 830 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
831 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 831 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
832 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 832 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
833 | item = item->nextSibling(); | 833 | item = item->nextSibling(); |
834 | } | 834 | } |
835 | } | 835 | } |
836 | 836 | ||
837 | 837 | ||
838 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 838 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
839 | KOTodoView::insertTodoItem(Todo *todo) | 839 | KOTodoView::insertTodoItem(Todo *todo) |
840 | { | 840 | { |
841 | 841 | ||
842 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 842 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
843 | // TODO: Check, if dynmaic cast is necessary | 843 | // TODO: Check, if dynmaic cast is necessary |
844 | 844 | ||
845 | pendingSubtodo = 0; | 845 | pendingSubtodo = 0; |
846 | Incidence *incidence = todo->relatedTo(); | 846 | Incidence *incidence = todo->relatedTo(); |
847 | if (incidence && incidence->type() == "Todo") { | 847 | if (incidence && incidence->typeID() == todoID ) { |
848 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 848 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
849 | 849 | ||
850 | // kdDebug() << " has Related" << endl; | 850 | // kdDebug() << " has Related" << endl; |
851 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 851 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
852 | itemIterator = mTodoMap.find(relatedTodo); | 852 | itemIterator = mTodoMap.find(relatedTodo); |
853 | if (itemIterator == mTodoMap.end()) { | 853 | if (itemIterator == mTodoMap.end()) { |
854 | // kdDebug() << " related not yet in list" << endl; | 854 | // kdDebug() << " related not yet in list" << endl; |
855 | itemIterator = insertTodoItem (relatedTodo); | 855 | itemIterator = insertTodoItem (relatedTodo); |
856 | } | 856 | } |
857 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 857 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
858 | // and one into the map. Sure finding is more easy but why? -zecke | 858 | // and one into the map. Sure finding is more easy but why? -zecke |
859 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 859 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
860 | return mTodoMap.insert(todo,todoItem); | 860 | return mTodoMap.insert(todo,todoItem); |
861 | } else { | 861 | } else { |
862 | // kdDebug() << " no Related" << endl; | 862 | // kdDebug() << " no Related" << endl; |
863 | // see above -zecke | 863 | // see above -zecke |
864 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 864 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
865 | return mTodoMap.insert(todo,todoItem); | 865 | return mTodoMap.insert(todo,todoItem); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | 868 | ||
869 | 869 | ||
870 | void KOTodoView::updateConfig() | 870 | void KOTodoView::updateConfig() |
871 | { | 871 | { |
872 | updateView(); | 872 | updateView(); |
873 | mTodoListView->repaintContents(); | 873 | mTodoListView->repaintContents(); |
874 | } | 874 | } |
875 | 875 | ||
876 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 876 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
877 | { | 877 | { |
878 | QPtrList<Incidence> selected; | 878 | QPtrList<Incidence> selected; |
879 | 879 | ||
880 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 880 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
881 | // if (!item) item = mActiveItem; | 881 | // if (!item) item = mActiveItem; |
882 | if (item) selected.append(item->todo()); | 882 | if (item) selected.append(item->todo()); |
883 | 883 | ||
884 | return selected; | 884 | return selected; |
885 | } | 885 | } |
886 | 886 | ||
887 | QPtrList<Todo> KOTodoView::selectedTodos() | 887 | QPtrList<Todo> KOTodoView::selectedTodos() |
888 | { | 888 | { |
889 | QPtrList<Todo> selected; | 889 | QPtrList<Todo> selected; |
890 | 890 | ||
891 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 891 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
892 | // if (!item) item = mActiveItem; | 892 | // if (!item) item = mActiveItem; |
893 | if (item) selected.append(item->todo()); | 893 | if (item) selected.append(item->todo()); |
894 | 894 | ||
895 | return selected; | 895 | return selected; |
896 | } | 896 | } |
897 | 897 | ||
898 | void KOTodoView::changeEventDisplay(Event *, int) | 898 | void KOTodoView::changeEventDisplay(Event *, int) |
899 | { | 899 | { |
900 | updateView(); | 900 | updateView(); |
901 | } | 901 | } |
902 | 902 | ||
903 | void KOTodoView::showDates(const QDate &, const QDate &) | 903 | void KOTodoView::showDates(const QDate &, const QDate &) |
904 | { | 904 | { |
905 | } | 905 | } |
906 | 906 | ||
907 | void KOTodoView::showEvents(QPtrList<Event>) | 907 | void KOTodoView::showEvents(QPtrList<Event>) |
908 | { | 908 | { |
909 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 909 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
910 | } | 910 | } |
911 | 911 | ||
912 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 912 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
913 | const QDate &td) | 913 | const QDate &td) |
914 | { | 914 | { |
915 | #ifndef KORG_NOPRINTER | 915 | #ifndef KORG_NOPRINTER |
916 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 916 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
917 | #endif | 917 | #endif |
918 | } | 918 | } |
919 | 919 | ||
920 | void KOTodoView::editItem(QListViewItem *item ) | 920 | void KOTodoView::editItem(QListViewItem *item ) |
921 | { | 921 | { |
922 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 922 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
923 | } | 923 | } |
924 | 924 | ||
925 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 925 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
926 | { | 926 | { |
927 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 927 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
928 | } | 928 | } |
929 | 929 | ||
930 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 930 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
931 | { | 931 | { |
932 | pendingSubtodo = 0; | 932 | pendingSubtodo = 0; |
933 | mActiveItem = (KOTodoViewItem *)item; | 933 | mActiveItem = (KOTodoViewItem *)item; |
934 | if (item) { | 934 | if (item) { |
935 | switch (column){ | 935 | switch (column){ |
936 | case 1: | 936 | case 1: |
937 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 937 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
938 | case 2: | 938 | case 2: |
939 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 939 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
940 | case 3: | 940 | case 3: |
941 | moveTodo(); | 941 | moveTodo(); |
942 | break; | 942 | break; |
943 | case 8: | 943 | case 8: |
944 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 944 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
945 | default: | 945 | default: |
946 | mItemPopupMenu->popup(QCursor::pos()); | 946 | mItemPopupMenu->popup(QCursor::pos()); |
947 | } | 947 | } |
948 | } else mPopupMenu->popup(QCursor::pos()); | 948 | } else mPopupMenu->popup(QCursor::pos()); |
949 | } | 949 | } |
950 | void KOTodoView::newTodo() | 950 | void KOTodoView::newTodo() |
951 | { | 951 | { |
952 | emit newTodoSignal(); | 952 | emit newTodoSignal(); |
953 | } | 953 | } |
954 | 954 | ||
955 | void KOTodoView::newSubTodo() | 955 | void KOTodoView::newSubTodo() |
956 | { | 956 | { |
957 | if (mActiveItem) { | 957 | if (mActiveItem) { |
958 | emit newSubTodoSignal(mActiveItem->todo()); | 958 | emit newSubTodoSignal(mActiveItem->todo()); |
959 | } | 959 | } |
960 | } | 960 | } |
961 | void KOTodoView::unparentTodo() | 961 | void KOTodoView::unparentTodo() |
962 | { | 962 | { |
963 | if (mActiveItem) { | 963 | if (mActiveItem) { |
964 | emit unparentTodoSignal(mActiveItem->todo()); | 964 | emit unparentTodoSignal(mActiveItem->todo()); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | void KOTodoView::reparentTodo() | 968 | void KOTodoView::reparentTodo() |
969 | { | 969 | { |
970 | if (mActiveItem) { | 970 | if (mActiveItem) { |
971 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 971 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
972 | pendingSubtodo = mActiveItem; | 972 | pendingSubtodo = mActiveItem; |
973 | } | 973 | } |
974 | } | 974 | } |
975 | void KOTodoView::editTodo() | 975 | void KOTodoView::editTodo() |
976 | { | 976 | { |
977 | if (mActiveItem) { | 977 | if (mActiveItem) { |
978 | emit editTodoSignal(mActiveItem->todo()); | 978 | emit editTodoSignal(mActiveItem->todo()); |
979 | } | 979 | } |
980 | } | 980 | } |
981 | void KOTodoView::cloneTodo() | 981 | void KOTodoView::cloneTodo() |
982 | { | 982 | { |
983 | if (mActiveItem) { | 983 | if (mActiveItem) { |
984 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 984 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
985 | } | 985 | } |
986 | } | 986 | } |
987 | void KOTodoView::cancelTodo() | 987 | void KOTodoView::cancelTodo() |
988 | { | 988 | { |
989 | if (mActiveItem) { | 989 | if (mActiveItem) { |
990 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 990 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
991 | } | 991 | } |
992 | } | 992 | } |
993 | void KOTodoView::moveTodo() | 993 | void KOTodoView::moveTodo() |
994 | { | 994 | { |
995 | if (mActiveItem) { | 995 | if (mActiveItem) { |
996 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 996 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
997 | } | 997 | } |
998 | } | 998 | } |
999 | void KOTodoView::beamTodo() | 999 | void KOTodoView::beamTodo() |
1000 | { | 1000 | { |
1001 | if (mActiveItem) { | 1001 | if (mActiveItem) { |
1002 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1002 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1003 | } | 1003 | } |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | 1006 | ||
1007 | void KOTodoView::showTodo() | 1007 | void KOTodoView::showTodo() |
1008 | { | 1008 | { |
1009 | if (mActiveItem) { | 1009 | if (mActiveItem) { |
1010 | emit showTodoSignal(mActiveItem->todo()); | 1010 | emit showTodoSignal(mActiveItem->todo()); |
1011 | } | 1011 | } |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | void KOTodoView::deleteTodo() | 1014 | void KOTodoView::deleteTodo() |
1015 | { | 1015 | { |
1016 | if (mActiveItem) { | 1016 | if (mActiveItem) { |
1017 | emit deleteTodoSignal(mActiveItem->todo()); | 1017 | emit deleteTodoSignal(mActiveItem->todo()); |
1018 | } | 1018 | } |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | void KOTodoView::setNewPriority(int index) | 1021 | void KOTodoView::setNewPriority(int index) |
1022 | { | 1022 | { |
1023 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1023 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1024 | mActiveItem->todo()->setPriority(mPriority[index]); | 1024 | mActiveItem->todo()->setPriority(mPriority[index]); |
1025 | mActiveItem->construct(); | 1025 | mActiveItem->construct(); |
1026 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1026 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1027 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1027 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | void KOTodoView::setNewPercentage(int index) | 1031 | void KOTodoView::setNewPercentage(int index) |
1032 | { | 1032 | { |
1033 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1033 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1034 | 1034 | ||
1035 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1035 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1036 | mActiveItem->setOn( true ); | 1036 | mActiveItem->setOn( true ); |
1037 | return; | 1037 | return; |
1038 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1038 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1039 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1039 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1040 | if ( par && par->isOn() ) | 1040 | if ( par && par->isOn() ) |
1041 | par->setOn( false ); | 1041 | par->setOn( false ); |
1042 | } | 1042 | } |
1043 | if (mPercentage[index] == 100) { | 1043 | if (mPercentage[index] == 100) { |
1044 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1044 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1045 | } else { | 1045 | } else { |
1046 | mActiveItem->todo()->setCompleted(false); | 1046 | mActiveItem->todo()->setCompleted(false); |
1047 | } | 1047 | } |
1048 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1048 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1049 | mActiveItem->construct(); | 1049 | mActiveItem->construct(); |
1050 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1050 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1051 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1051 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | 1055 | ||
1056 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1056 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1057 | { | 1057 | { |
1058 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1058 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1059 | QStringList checkedCategories = todoItem->todo()->categories (); | 1059 | QStringList checkedCategories = todoItem->todo()->categories (); |
1060 | 1060 | ||
1061 | tempMenu->setCheckable (true); | 1061 | tempMenu->setCheckable (true); |
1062 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1062 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1063 | it != KOPrefs::instance()->mCustomCategories.end (); | 1063 | it != KOPrefs::instance()->mCustomCategories.end (); |
1064 | ++it) { | 1064 | ++it) { |
1065 | int index = tempMenu->insertItem (*it); | 1065 | int index = tempMenu->insertItem (*it); |
1066 | mCategory[index] = *it; | 1066 | mCategory[index] = *it; |
1067 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1067 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1070 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1071 | return tempMenu; | 1071 | return tempMenu; |
1072 | 1072 | ||
1073 | 1073 | ||
1074 | } | 1074 | } |
1075 | void KOTodoView::changedCategories(int index) | 1075 | void KOTodoView::changedCategories(int index) |
1076 | { | 1076 | { |
1077 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1077 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1078 | QStringList categories = mActiveItem->todo()->categories (); | 1078 | QStringList categories = mActiveItem->todo()->categories (); |
1079 | QString colcat = categories.first(); | 1079 | QString colcat = categories.first(); |
1080 | if (categories.find (mCategory[index]) != categories.end ()) | 1080 | if (categories.find (mCategory[index]) != categories.end ()) |
1081 | categories.remove (mCategory[index]); | 1081 | categories.remove (mCategory[index]); |
1082 | else | 1082 | else |
1083 | categories.insert (categories.end(), mCategory[index]); | 1083 | categories.insert (categories.end(), mCategory[index]); |
1084 | categories.sort (); | 1084 | categories.sort (); |
1085 | if ( !colcat.isEmpty() ) { | 1085 | if ( !colcat.isEmpty() ) { |
1086 | if ( categories.find ( colcat ) != categories.end () ) { | 1086 | if ( categories.find ( colcat ) != categories.end () ) { |
1087 | categories.remove( colcat ); | 1087 | categories.remove( colcat ); |
1088 | categories.prepend( colcat ); | 1088 | categories.prepend( colcat ); |
1089 | } | 1089 | } |
1090 | } | 1090 | } |
1091 | mActiveItem->todo()->setCategories (categories); | 1091 | mActiveItem->todo()->setCategories (categories); |
1092 | mActiveItem->construct(); | 1092 | mActiveItem->construct(); |
1093 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1093 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1094 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1094 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1095 | } | 1095 | } |
1096 | } | 1096 | } |
1097 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1097 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1098 | { | 1098 | { |
1099 | if ( pendingSubtodo != 0 ) { | 1099 | if ( pendingSubtodo != 0 ) { |
1100 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1100 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1101 | } | 1101 | } |
1102 | pendingSubtodo = 0; | 1102 | pendingSubtodo = 0; |
1103 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1103 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1104 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1104 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1105 | //qDebug("ROW %d ", row); | 1105 | //qDebug("ROW %d ", row); |
1106 | if (!item) { | 1106 | if (!item) { |
1107 | newTodo(); | 1107 | newTodo(); |
1108 | return; | 1108 | return; |
1109 | } else { | 1109 | } else { |
1110 | if ( row == 2 || row == 1 ) { | 1110 | if ( row == 2 || row == 1 ) { |
1111 | mActiveItem = (KOTodoViewItem *) item; | 1111 | mActiveItem = (KOTodoViewItem *) item; |
1112 | newSubTodo(); | 1112 | newSubTodo(); |
1113 | return; | 1113 | return; |
1114 | } | 1114 | } |
1115 | if ( row == 5 || row == 6 ) { | 1115 | if ( row == 5 || row == 6 ) { |
1116 | mActiveItem = (KOTodoViewItem *) item; | 1116 | mActiveItem = (KOTodoViewItem *) item; |
1117 | toggleRunningItem(); | 1117 | toggleRunningItem(); |
1118 | return; | 1118 | return; |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1121 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1122 | editItem( item ); | 1122 | editItem( item ); |
1123 | else | 1123 | else |
1124 | showItem( item , QPoint(), 0 ); | 1124 | showItem( item , QPoint(), 0 ); |
1125 | } | 1125 | } |
1126 | void KOTodoView::toggleRunningItem() | 1126 | void KOTodoView::toggleRunningItem() |
1127 | { | 1127 | { |
1128 | // qDebug("KOTodoView::toggleRunning() "); | 1128 | // qDebug("KOTodoView::toggleRunning() "); |
1129 | if ( ! mActiveItem ) | 1129 | if ( ! mActiveItem ) |
1130 | return; | 1130 | return; |
1131 | Todo * t = mActiveItem->todo(); | 1131 | Todo * t = mActiveItem->todo(); |
1132 | if ( t->isRunning() ) { | 1132 | if ( t->isRunning() ) { |
1133 | #if 0 | 1133 | #if 0 |
1134 | int result = KMessageBox::warningContinueCancel(this, | 1134 | int result = KMessageBox::warningContinueCancel(this, |
1135 | 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 todo"),i18n("Cancel"), true); | 1135 | 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 todo"),i18n("Cancel"), true); |
1136 | #endif | 1136 | #endif |
1137 | 1137 | ||
1138 | int result = KMessageBox::warningYesNoCancel(this, | 1138 | int result = KMessageBox::warningYesNoCancel(this, |
1139 | 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")); | 1139 | 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")); |
1140 | if (result == KMessageBox::Cancel) return; | 1140 | if (result == KMessageBox::Cancel) return; |
1141 | if ( result == KMessageBox::No ) { | 1141 | if ( result == KMessageBox::No ) { |
1142 | QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); | 1142 | QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); |
1143 | t->setRunningFalse( comment ); | 1143 | t->setRunningFalse( comment ); |
1144 | } else { | 1144 | } else { |
1145 | t->setRunning( false ); | 1145 | t->setRunning( false ); |
1146 | } | 1146 | } |
1147 | mActiveItem->construct(); | 1147 | mActiveItem->construct(); |
1148 | } else { | 1148 | } else { |
1149 | int result = KMessageBox::warningContinueCancel(this, | 1149 | int result = KMessageBox::warningContinueCancel(this, |
1150 | i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); | 1150 | i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); |
1151 | if (result != KMessageBox::Continue) return; | 1151 | if (result != KMessageBox::Continue) return; |
1152 | t->setRunning( true ); | 1152 | t->setRunning( true ); |
1153 | mActiveItem->construct(); | 1153 | mActiveItem->construct(); |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void KOTodoView::itemClicked(QListViewItem *item) | 1157 | void KOTodoView::itemClicked(QListViewItem *item) |
1158 | { | 1158 | { |
1159 | //qDebug("KOTodoView::itemClicked %d", item); | 1159 | //qDebug("KOTodoView::itemClicked %d", item); |
1160 | if (!item) { | 1160 | if (!item) { |
1161 | if ( pendingSubtodo != 0 ) { | 1161 | if ( pendingSubtodo != 0 ) { |
1162 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1162 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1163 | } | 1163 | } |
1164 | pendingSubtodo = 0; | 1164 | pendingSubtodo = 0; |
1165 | return; | 1165 | return; |
1166 | } | 1166 | } |
1167 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1167 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1168 | if ( pendingSubtodo != 0 ) { | 1168 | if ( pendingSubtodo != 0 ) { |
1169 | bool allowReparent = true; | 1169 | bool allowReparent = true; |
1170 | QListViewItem *par = item; | 1170 | QListViewItem *par = item; |
1171 | while ( par ) { | 1171 | while ( par ) { |
1172 | if ( par == pendingSubtodo ) { | 1172 | if ( par == pendingSubtodo ) { |
1173 | allowReparent = false; | 1173 | allowReparent = false; |
1174 | break; | 1174 | break; |
1175 | } | 1175 | } |
1176 | par = par->parent(); | 1176 | par = par->parent(); |
1177 | } | 1177 | } |
1178 | if ( !allowReparent ) { | 1178 | if ( !allowReparent ) { |
1179 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1179 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1180 | pendingSubtodo = 0; | 1180 | pendingSubtodo = 0; |
1181 | } else { | 1181 | } else { |
1182 | Todo* newParent = todoItem->todo(); | 1182 | Todo* newParent = todoItem->todo(); |
1183 | Todo* newSub = pendingSubtodo->todo(); | 1183 | Todo* newSub = pendingSubtodo->todo(); |
1184 | pendingSubtodo = 0; | 1184 | pendingSubtodo = 0; |
1185 | emit reparentTodoSignal( newParent,newSub ); | 1185 | emit reparentTodoSignal( newParent,newSub ); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | void KOTodoView::setDocumentId( const QString &id ) | 1192 | void KOTodoView::setDocumentId( const QString &id ) |
1193 | { | 1193 | { |
1194 | 1194 | ||
1195 | mDocPrefs->setDoc( id ); | 1195 | mDocPrefs->setDoc( id ); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1198 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1199 | { | 1199 | { |
1200 | if (!item) return; | 1200 | if (!item) return; |
1201 | 1201 | ||
1202 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1202 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1203 | 1203 | ||
1204 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1204 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1205 | 1205 | ||
1206 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1206 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1209 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1210 | { | 1210 | { |
1211 | mTodoListView->saveLayout(config,group); | 1211 | mTodoListView->saveLayout(config,group); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1214 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1215 | { | 1215 | { |
1216 | mTodoListView->restoreLayout(config,group); | 1216 | mTodoListView->restoreLayout(config,group); |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | void KOTodoView::processSelectionChange() | 1219 | void KOTodoView::processSelectionChange() |
1220 | { | 1220 | { |
1221 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1221 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1222 | 1222 | ||
1223 | KOTodoViewItem *item = | 1223 | KOTodoViewItem *item = |
1224 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1224 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1225 | 1225 | ||
1226 | if ( !item ) { | 1226 | if ( !item ) { |
1227 | emit incidenceSelected( 0 ); | 1227 | emit incidenceSelected( 0 ); |
1228 | } else { | 1228 | } else { |
1229 | emit incidenceSelected( item->todo() ); | 1229 | emit incidenceSelected( item->todo() ); |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | void KOTodoView::modified(bool b) | 1233 | void KOTodoView::modified(bool b) |
1234 | { | 1234 | { |
1235 | emit isModified(b); | 1235 | emit isModified(b); |
1236 | } | 1236 | } |
1237 | void KOTodoView::setTodoModified( Todo* todo ) | 1237 | void KOTodoView::setTodoModified( Todo* todo ) |
1238 | { | 1238 | { |
1239 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1239 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1240 | } | 1240 | } |
1241 | void KOTodoView::clearSelection() | 1241 | void KOTodoView::clearSelection() |
1242 | { | 1242 | { |
1243 | mTodoListView->selectAll( false ); | 1243 | mTodoListView->selectAll( false ); |
1244 | } | 1244 | } |
1245 | void KOTodoView::setAllOpen() | 1245 | void KOTodoView::setAllOpen() |
1246 | { | 1246 | { |
1247 | if ( isFlatDisplay ) { | 1247 | if ( isFlatDisplay ) { |
1248 | isFlatDisplay = false; | 1248 | isFlatDisplay = false; |
1249 | mPopupMenu->setItemChecked( 8,false ); | 1249 | mPopupMenu->setItemChecked( 8,false ); |
1250 | updateView(); | 1250 | updateView(); |
1251 | } else { | 1251 | } else { |
1252 | storeCurrentItem(); | 1252 | storeCurrentItem(); |
1253 | } | 1253 | } |
1254 | setOpen(mTodoListView->firstChild(), true); | 1254 | setOpen(mTodoListView->firstChild(), true); |
1255 | resetCurrentItem(); | 1255 | resetCurrentItem(); |
1256 | } | 1256 | } |
1257 | void KOTodoView::setAllClose() | 1257 | void KOTodoView::setAllClose() |
1258 | { | 1258 | { |
1259 | if ( isFlatDisplay ) { | 1259 | if ( isFlatDisplay ) { |
1260 | isFlatDisplay = false; | 1260 | isFlatDisplay = false; |
1261 | mPopupMenu->setItemChecked( 8,false ); | 1261 | mPopupMenu->setItemChecked( 8,false ); |
1262 | updateView(); | 1262 | updateView(); |
1263 | } else { | 1263 | } else { |
1264 | storeCurrentItem(); | 1264 | storeCurrentItem(); |
1265 | } | 1265 | } |
1266 | setOpen(mTodoListView->firstChild(), false); | 1266 | setOpen(mTodoListView->firstChild(), false); |
1267 | resetCurrentItem(); | 1267 | resetCurrentItem(); |
1268 | } | 1268 | } |
1269 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1269 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1270 | { | 1270 | { |
1271 | 1271 | ||
1272 | while ( item ) { | 1272 | while ( item ) { |
1273 | setOpen( item->firstChild(), setOpenI ); | 1273 | setOpen( item->firstChild(), setOpenI ); |
1274 | item->setOpen( setOpenI ); | 1274 | item->setOpen( setOpenI ); |
1275 | item = item->nextSibling(); | 1275 | item = item->nextSibling(); |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | void KOTodoView::displayAllFlat() | 1279 | void KOTodoView::displayAllFlat() |
1280 | { | 1280 | { |
1281 | pendingSubtodo = 0; | 1281 | pendingSubtodo = 0; |
1282 | if ( mBlockUpdate ) { | 1282 | if ( mBlockUpdate ) { |
1283 | return; | 1283 | return; |
1284 | } | 1284 | } |
1285 | mPopupMenu->setItemChecked( 8,true ); | 1285 | mPopupMenu->setItemChecked( 8,true ); |
1286 | isFlatDisplay = true; | 1286 | isFlatDisplay = true; |
1287 | QPtrList<Todo> todoList = calendar()->todos(); | 1287 | QPtrList<Todo> todoList = calendar()->todos(); |
1288 | mTodoMap.clear(); | 1288 | mTodoMap.clear(); |
1289 | mTodoListView->clear(); | 1289 | mTodoListView->clear(); |
1290 | Todo *todo; | 1290 | Todo *todo; |
1291 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1291 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1292 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1292 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1293 | mTodoMap.insert(todo,todoItem); | 1293 | mTodoMap.insert(todo,todoItem); |
1294 | } | 1294 | } |
1295 | mTodoListView->setFocus(); | 1295 | mTodoListView->setFocus(); |
1296 | processSelectionChange(); | 1296 | processSelectionChange(); |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | void KOTodoView::setAllFlat() | 1299 | void KOTodoView::setAllFlat() |
1300 | { | 1300 | { |
1301 | if ( isFlatDisplay ) { | 1301 | if ( isFlatDisplay ) { |
1302 | isFlatDisplay = false; | 1302 | isFlatDisplay = false; |
1303 | mPopupMenu->setItemChecked( 8,false ); | 1303 | mPopupMenu->setItemChecked( 8,false ); |
1304 | updateView(); | 1304 | updateView(); |
1305 | return; | 1305 | return; |
1306 | } | 1306 | } |
1307 | storeCurrentItem(); | 1307 | storeCurrentItem(); |
1308 | displayAllFlat(); | 1308 | displayAllFlat(); |
1309 | resetCurrentItem(); | 1309 | resetCurrentItem(); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | void KOTodoView::purgeCompleted() | 1312 | void KOTodoView::purgeCompleted() |
1313 | { | 1313 | { |
1314 | emit purgeCompletedSignal(); | 1314 | emit purgeCompletedSignal(); |
1315 | 1315 | ||
1316 | } | 1316 | } |
1317 | void KOTodoView::toggleQuickTodo() | 1317 | void KOTodoView::toggleQuickTodo() |
1318 | { | 1318 | { |
1319 | if ( mQuickAdd->isVisible() ) { | 1319 | if ( mQuickAdd->isVisible() ) { |
1320 | mQuickAdd->hide(); | 1320 | mQuickAdd->hide(); |
1321 | KOPrefs::instance()->mEnableQuickTodo = false; | 1321 | KOPrefs::instance()->mEnableQuickTodo = false; |
1322 | } | 1322 | } |
1323 | else { | 1323 | else { |
1324 | mQuickAdd->show(); | 1324 | mQuickAdd->show(); |
1325 | KOPrefs::instance()->mEnableQuickTodo = true; | 1325 | KOPrefs::instance()->mEnableQuickTodo = true; |
1326 | } | 1326 | } |
1327 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1327 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1328 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1328 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | void KOTodoView::toggleRunning() | 1331 | void KOTodoView::toggleRunning() |
1332 | { | 1332 | { |
1333 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1333 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1334 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1334 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1335 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1335 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1336 | updateView(); | 1336 | updateView(); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | void KOTodoView::toggleCompleted() | 1339 | void KOTodoView::toggleCompleted() |
1340 | { | 1340 | { |
1341 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1341 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1342 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1342 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1343 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1343 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1344 | updateView(); | 1344 | updateView(); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | void KOTodoView::addQuickTodo() | 1347 | void KOTodoView::addQuickTodo() |
1348 | { | 1348 | { |
1349 | Todo *todo = new Todo(); | 1349 | Todo *todo = new Todo(); |
1350 | todo->setSummary(mQuickAdd->text()); | 1350 | todo->setSummary(mQuickAdd->text()); |
1351 | todo->setOrganizer(KOPrefs::instance()->email()); | 1351 | todo->setOrganizer(KOPrefs::instance()->email()); |
1352 | CalFilter * cf = mCalendar->filter(); | 1352 | CalFilter * cf = mCalendar->filter(); |
1353 | if ( cf ) { | 1353 | if ( cf ) { |
1354 | if ( cf->isEnabled()&& cf->showCategories()) { | 1354 | if ( cf->isEnabled()&& cf->showCategories()) { |
1355 | todo->setCategories(cf->categoryList()); | 1355 | todo->setCategories(cf->categoryList()); |
1356 | } | 1356 | } |
1357 | if ( cf->isEnabled() ) | 1357 | if ( cf->isEnabled() ) |
1358 | todo->setSecrecy( cf->getSecrecy()); | 1358 | todo->setSecrecy( cf->getSecrecy()); |
1359 | } | 1359 | } |
1360 | mCalendar->addTodo(todo); | 1360 | mCalendar->addTodo(todo); |
1361 | mQuickAdd->setText(""); | 1361 | mQuickAdd->setText(""); |
1362 | todoModified (todo, KOGlobals::EVENTADDED ); | 1362 | todoModified (todo, KOGlobals::EVENTADDED ); |
1363 | updateView(); | 1363 | updateView(); |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1366 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1367 | { | 1367 | { |
1368 | // e->ignore(); | 1368 | // e->ignore(); |
1369 | //return; | 1369 | //return; |
1370 | //qDebug("KOTodoView::keyPressEvent "); | 1370 | //qDebug("KOTodoView::keyPressEvent "); |
1371 | switch ( e->key() ) { | 1371 | switch ( e->key() ) { |
1372 | case Qt::Key_Down: | 1372 | case Qt::Key_Down: |
1373 | case Qt::Key_Up: | 1373 | case Qt::Key_Up: |
1374 | QWidget::keyPressEvent ( e ); | 1374 | QWidget::keyPressEvent ( e ); |
1375 | break; | 1375 | break; |
1376 | 1376 | ||
1377 | case Qt::Key_Q: | 1377 | case Qt::Key_Q: |
1378 | toggleQuickTodo(); | 1378 | toggleQuickTodo(); |
1379 | break; | 1379 | break; |
1380 | case Qt::Key_U: | 1380 | case Qt::Key_U: |
1381 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1381 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1382 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1382 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1383 | unparentTodo(); | 1383 | unparentTodo(); |
1384 | e->accept(); | 1384 | e->accept(); |
1385 | } else | 1385 | } else |
1386 | e->ignore(); | 1386 | e->ignore(); |
1387 | break; | 1387 | break; |
1388 | case Qt::Key_S: | 1388 | case Qt::Key_S: |
1389 | if ( e->state() == Qt::ControlButton ) { | 1389 | if ( e->state() == Qt::ControlButton ) { |
1390 | e->ignore(); | 1390 | e->ignore(); |
1391 | break; | 1391 | break; |
1392 | } | 1392 | } |
1393 | if ( e->state() == Qt::ShiftButton ) { | 1393 | if ( e->state() == Qt::ShiftButton ) { |
1394 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1394 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1395 | reparentTodo(); | 1395 | reparentTodo(); |
1396 | e->accept(); | 1396 | e->accept(); |
1397 | } else | 1397 | } else |
1398 | e->ignore(); | 1398 | e->ignore(); |
1399 | break; | 1399 | break; |
1400 | case Qt::Key_P: | 1400 | case Qt::Key_P: |
1401 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1401 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1402 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1402 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1403 | if ( pendingSubtodo ) | 1403 | if ( pendingSubtodo ) |
1404 | itemClicked(mActiveItem); | 1404 | itemClicked(mActiveItem); |
1405 | e->accept(); | 1405 | e->accept(); |
1406 | } else | 1406 | } else |
1407 | e->ignore(); | 1407 | e->ignore(); |
1408 | break; | 1408 | break; |
1409 | case Qt::Key_Escape: | 1409 | case Qt::Key_Escape: |
1410 | if ( pendingSubtodo ) { | 1410 | if ( pendingSubtodo ) { |
1411 | itemClicked(0); | 1411 | itemClicked(0); |
1412 | e->accept(); | 1412 | e->accept(); |
1413 | } else | 1413 | } else |
1414 | e->ignore(); | 1414 | e->ignore(); |
1415 | break; | 1415 | break; |
1416 | default: | 1416 | default: |
1417 | e->ignore(); | 1417 | e->ignore(); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | if ( true ) { | 1420 | if ( true ) { |
1421 | if ( e->key() == Qt::Key_I ) { | 1421 | if ( e->key() == Qt::Key_I ) { |
1422 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1422 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1423 | if ( cn ) { | 1423 | if ( cn ) { |
1424 | mActiveItem = cn; | 1424 | mActiveItem = cn; |
1425 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1425 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1426 | if ( ci ){ | 1426 | if ( ci ){ |
1427 | showTodo(); | 1427 | showTodo(); |
1428 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1428 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1429 | if ( cn ) { | 1429 | if ( cn ) { |
1430 | mTodoListView->setCurrentItem ( cn ); | 1430 | mTodoListView->setCurrentItem ( cn ); |
1431 | mTodoListView->ensureItemVisible ( cn ); | 1431 | mTodoListView->ensureItemVisible ( cn ); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | } | 1434 | } |
1435 | } | 1435 | } |
1436 | e->accept(); | 1436 | e->accept(); |
1437 | 1437 | ||
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | } | 1442 | } |
1443 | void KOTodoView::updateTodo( Todo * t, int type ) | 1443 | void KOTodoView::updateTodo( Todo * t, int type ) |
1444 | { | 1444 | { |
1445 | if ( mBlockUpdate) | 1445 | if ( mBlockUpdate) |
1446 | return; | 1446 | return; |
1447 | 1447 | ||
1448 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1448 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1449 | itemIterator = mTodoMap.find(t); | 1449 | itemIterator = mTodoMap.find(t); |
1450 | if (itemIterator != mTodoMap.end()) { | 1450 | if (itemIterator != mTodoMap.end()) { |
1451 | (*itemIterator)->construct(); | 1451 | (*itemIterator)->construct(); |
1452 | } else { | 1452 | } else { |
1453 | if ( type == KOGlobals::EVENTADDED ) { | 1453 | if ( type == KOGlobals::EVENTADDED ) { |
1454 | insertTodoItem( t ); | 1454 | insertTodoItem( t ); |
1455 | } | 1455 | } |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | void KOTodoView::todoModified(Todo * t , int p ) | 1460 | void KOTodoView::todoModified(Todo * t , int p ) |
1461 | { | 1461 | { |
1462 | mBlockUpdate = true; | 1462 | mBlockUpdate = true; |
1463 | emit todoModifiedSignal ( t, p ); | 1463 | emit todoModifiedSignal ( t, p ); |
1464 | mBlockUpdate = false; | 1464 | mBlockUpdate = false; |
1465 | } | 1465 | } |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 62d7ede..e8574a0 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -1,789 +1,789 @@ | |||
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 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 28 | #include <qpaintdevicemetrics.h> |
29 | #endif | 29 | #endif |
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 39 | #include "calprinter.h" |
40 | #endif | 40 | #endif |
41 | #include "koglobals.h" | 41 | #include "koglobals.h" |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
44 | #include "koeventviewer.h" | 44 | #include "koeventviewer.h" |
45 | #include <qstylesheet.h> | 45 | #include <qstylesheet.h> |
46 | #include "kowhatsnextview.h" | 46 | #include "kowhatsnextview.h" |
47 | using namespace KOrg; | 47 | using namespace KOrg; |
48 | 48 | ||
49 | void WhatsNextTextBrowser::setSource(const QString& n) | 49 | void WhatsNextTextBrowser::setSource(const QString& n) |
50 | { | 50 | { |
51 | 51 | ||
52 | if (n.startsWith("event:")) { | 52 | if (n.startsWith("event:")) { |
53 | emit showIncidence(n); | 53 | emit showIncidence(n); |
54 | return; | 54 | return; |
55 | } else if (n.startsWith("todo:")) { | 55 | } else if (n.startsWith("todo:")) { |
56 | emit showIncidence(n); | 56 | emit showIncidence(n); |
57 | return; | 57 | return; |
58 | } else { | 58 | } else { |
59 | QTextBrowser::setSource(n); | 59 | QTextBrowser::setSource(n); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | void WhatsNextTextBrowser::printMe() | 62 | void WhatsNextTextBrowser::printMe() |
63 | { | 63 | { |
64 | #ifdef DESKTOP_VERSION | 64 | #ifdef DESKTOP_VERSION |
65 | KOPrintPrefs pp ( this ); | 65 | KOPrintPrefs pp ( this ); |
66 | if (!pp.exec() ) | 66 | if (!pp.exec() ) |
67 | return; | 67 | return; |
68 | int scaleval = pp.printMode() ; | 68 | int scaleval = pp.printMode() ; |
69 | 69 | ||
70 | QPrinter printer; | 70 | QPrinter printer; |
71 | if (!printer.setup() ) | 71 | if (!printer.setup() ) |
72 | return; | 72 | return; |
73 | QPainter p; | 73 | QPainter p; |
74 | p.begin ( &printer ); | 74 | p.begin ( &printer ); |
75 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 75 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
76 | float dx, dy; | 76 | float dx, dy; |
77 | int wid = (m.width() * 9)/10; | 77 | int wid = (m.width() * 9)/10; |
78 | dx = (float) wid/(float)contentsWidth (); | 78 | dx = (float) wid/(float)contentsWidth (); |
79 | dy = (float)(m.height()) / (float)contentsHeight (); | 79 | dy = (float)(m.height()) / (float)contentsHeight (); |
80 | float scale; | 80 | float scale; |
81 | // scale to fit the width or height of the paper | 81 | // scale to fit the width or height of the paper |
82 | if ( dx < dy ) | 82 | if ( dx < dy ) |
83 | scale = dx; | 83 | scale = dx; |
84 | else | 84 | else |
85 | scale = dy; | 85 | scale = dy; |
86 | p.translate( m.width()/10,0 ); | 86 | p.translate( m.width()/10,0 ); |
87 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 87 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
88 | p.scale( scale, scale ); | 88 | p.scale( scale, scale ); |
89 | } | 89 | } |
90 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 90 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
91 | p.end(); | 91 | p.end(); |
92 | #endif | 92 | #endif |
93 | } | 93 | } |
94 | 94 | ||
95 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 95 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
96 | const char *name) | 96 | const char *name) |
97 | : KOrg::BaseView(calendar, parent, name) | 97 | : KOrg::BaseView(calendar, parent, name) |
98 | { | 98 | { |
99 | // mDateLabel = | 99 | // mDateLabel = |
100 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 100 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
101 | // mDateLabel->setMargin(2); | 101 | // mDateLabel->setMargin(2); |
102 | // mDateLabel->setAlignment(AlignCenter); | 102 | // mDateLabel->setAlignment(AlignCenter); |
103 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 103 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
104 | mView = new WhatsNextTextBrowser(this); | 104 | mView = new WhatsNextTextBrowser(this); |
105 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 105 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
106 | QStyleSheet* stsh = mView->styleSheet(); | 106 | QStyleSheet* stsh = mView->styleSheet(); |
107 | QStyleSheetItem * style ; | 107 | QStyleSheetItem * style ; |
108 | style = stsh->item ("h2" ); | 108 | style = stsh->item ("h2" ); |
109 | if ( style ) { | 109 | if ( style ) { |
110 | style->setMargin(QStyleSheetItem::MarginAll,0); | 110 | style->setMargin(QStyleSheetItem::MarginAll,0); |
111 | } | 111 | } |
112 | style = stsh->item ("h3" ); | 112 | style = stsh->item ("h3" ); |
113 | if ( style ) { | 113 | if ( style ) { |
114 | style->setMargin(QStyleSheetItem::MarginAll,0); | 114 | style->setMargin(QStyleSheetItem::MarginAll,0); |
115 | } | 115 | } |
116 | mEventViewer = 0; | 116 | mEventViewer = 0; |
117 | 117 | ||
118 | QBoxLayout *topLayout = new QVBoxLayout(this); | 118 | QBoxLayout *topLayout = new QVBoxLayout(this); |
119 | // topLayout->addWidget(mDateLabel); | 119 | // topLayout->addWidget(mDateLabel); |
120 | topLayout->addWidget(mView); | 120 | topLayout->addWidget(mView); |
121 | mTimer = new QTimer( this ); | 121 | mTimer = new QTimer( this ); |
122 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 122 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
123 | 123 | ||
124 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 124 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
125 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 125 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
126 | } | 126 | } |
127 | 127 | ||
128 | KOWhatsNextView::~KOWhatsNextView() | 128 | KOWhatsNextView::~KOWhatsNextView() |
129 | { | 129 | { |
130 | } | 130 | } |
131 | 131 | ||
132 | int KOWhatsNextView::maxDatesHint() | 132 | int KOWhatsNextView::maxDatesHint() |
133 | { | 133 | { |
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | int KOWhatsNextView::currentDateCount() | 137 | int KOWhatsNextView::currentDateCount() |
138 | { | 138 | { |
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | void KOWhatsNextView::clearList() | 142 | void KOWhatsNextView::clearList() |
143 | { | 143 | { |
144 | mTimer->stop(); | 144 | mTimer->stop(); |
145 | mView->setText(" "); | 145 | mView->setText(" "); |
146 | } | 146 | } |
147 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 147 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
148 | { | 148 | { |
149 | QPtrList<Incidence> eventList; | 149 | QPtrList<Incidence> eventList; |
150 | 150 | ||
151 | return eventList; | 151 | return eventList; |
152 | } | 152 | } |
153 | 153 | ||
154 | void KOWhatsNextView::printMe() | 154 | void KOWhatsNextView::printMe() |
155 | { | 155 | { |
156 | #ifdef DESKTOP_VERSION | 156 | #ifdef DESKTOP_VERSION |
157 | mView->printMe(); | 157 | mView->printMe(); |
158 | #endif | 158 | #endif |
159 | } | 159 | } |
160 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 160 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
161 | const QDate &td) | 161 | const QDate &td) |
162 | { | 162 | { |
163 | #ifndef KORG_NOPRINTER | 163 | #ifndef KORG_NOPRINTER |
164 | calPrinter->preview(CalPrinter::Day, fd, td); | 164 | calPrinter->preview(CalPrinter::Day, fd, td); |
165 | #endif | 165 | #endif |
166 | } | 166 | } |
167 | void KOWhatsNextView::updateConfig() | 167 | void KOWhatsNextView::updateConfig() |
168 | { | 168 | { |
169 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 169 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
170 | updateView(); | 170 | updateView(); |
171 | 171 | ||
172 | } | 172 | } |
173 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 173 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
174 | { | 174 | { |
175 | //qDebug("KOWhatsNextView::showEvent "); | 175 | //qDebug("KOWhatsNextView::showEvent "); |
176 | restartTimer(); | 176 | restartTimer(); |
177 | QWidget::showEvent ( e ); | 177 | QWidget::showEvent ( e ); |
178 | } | 178 | } |
179 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 179 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
180 | { | 180 | { |
181 | //qDebug(" KOWhatsNextView::hideEvent"); | 181 | //qDebug(" KOWhatsNextView::hideEvent"); |
182 | mTimer->stop(); | 182 | mTimer->stop(); |
183 | QWidget::hideEvent ( e ); | 183 | QWidget::hideEvent ( e ); |
184 | } | 184 | } |
185 | void KOWhatsNextView::restartTimer() | 185 | void KOWhatsNextView::restartTimer() |
186 | { | 186 | { |
187 | //qDebug("KOWhatsNextView::restartTimer() "); | 187 | //qDebug("KOWhatsNextView::restartTimer() "); |
188 | mTimer->start( 300000 ); | 188 | mTimer->start( 300000 ); |
189 | //mTimer->start( 5000 ); | 189 | //mTimer->start( 5000 ); |
190 | } | 190 | } |
191 | void KOWhatsNextView::updateView() | 191 | void KOWhatsNextView::updateView() |
192 | { | 192 | { |
193 | //qDebug("KOWhatsNextView::updateView() "); | 193 | //qDebug("KOWhatsNextView::updateView() "); |
194 | if ( mTimer->isActive() ) | 194 | if ( mTimer->isActive() ) |
195 | restartTimer(); | 195 | restartTimer(); |
196 | mCurrentMaxPrio = 5; | 196 | mCurrentMaxPrio = 5; |
197 | //qDebug("KOWhatsNextView::updateView() "); | 197 | //qDebug("KOWhatsNextView::updateView() "); |
198 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 198 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
199 | KIconLoader kil("korganizer"); | 199 | KIconLoader kil("korganizer"); |
200 | QString ipath;// = new QString(); | 200 | QString ipath;// = new QString(); |
201 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 201 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
202 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 202 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
203 | mText = "<table width=\"100%\">\n"; | 203 | mText = "<table width=\"100%\">\n"; |
204 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 204 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
205 | #ifdef DESKTOP_VERSION | 205 | #ifdef DESKTOP_VERSION |
206 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 206 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
207 | #else | 207 | #else |
208 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 208 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
209 | #endif | 209 | #endif |
210 | // mText += "<img src=\""; | 210 | // mText += "<img src=\""; |
211 | // mText += ipath; | 211 | // mText += ipath; |
212 | // mText += "\">"; | 212 | // mText += "\">"; |
213 | mEventDate = QDate::currentDate(); | 213 | mEventDate = QDate::currentDate(); |
214 | #ifdef DESKTOP_VERSION | 214 | #ifdef DESKTOP_VERSION |
215 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 215 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
216 | #else | 216 | #else |
217 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 217 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
218 | #endif | 218 | #endif |
219 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 219 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
220 | int iii; | 220 | int iii; |
221 | mTodos.clear(); | 221 | mTodos.clear(); |
222 | QPtrList<Event> events; | 222 | QPtrList<Event> events; |
223 | QPtrList<Todo> todos = calendar()->todos(); | 223 | QPtrList<Todo> todos = calendar()->todos(); |
224 | Todo * todo; | 224 | Todo * todo; |
225 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 225 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
226 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 226 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
227 | bool itemAdded = false; | 227 | bool itemAdded = false; |
228 | for ( iii = 0; iii < daysToShow; ++iii ) { | 228 | for ( iii = 0; iii < daysToShow; ++iii ) { |
229 | QString date; | 229 | QString date; |
230 | itemAdded = false; | 230 | itemAdded = false; |
231 | events = calendar()->events( mEventDate, true ); | 231 | events = calendar()->events( mEventDate, true ); |
232 | 232 | ||
233 | if ( iii == 0 ) { // today !!! | 233 | if ( iii == 0 ) { // today !!! |
234 | todo = todos.first(); | 234 | todo = todos.first(); |
235 | while(todo) { | 235 | while(todo) { |
236 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 236 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
237 | if ( ! itemAdded ) { | 237 | if ( ! itemAdded ) { |
238 | appendDay ( iii, mEventDate ); | 238 | appendDay ( iii, mEventDate ); |
239 | //itemAdded = true; | 239 | //itemAdded = true; |
240 | 240 | ||
241 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 241 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
242 | appendEvent(todo, false, false, !itemAdded ); | 242 | appendEvent(todo, false, false, !itemAdded ); |
243 | itemAdded = true; | 243 | itemAdded = true; |
244 | } | 244 | } |
245 | todo = todos.next(); | 245 | todo = todos.next(); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | if (events.count() > 0) { | 250 | if (events.count() > 0) { |
251 | // mText += "<p></p>"; | 251 | // mText += "<p></p>"; |
252 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 252 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
253 | // mText += "<h2>"; | 253 | // mText += "<h2>"; |
254 | //mText += " <img src=\""; | 254 | //mText += " <img src=\""; |
255 | //mText += ipath; | 255 | //mText += ipath; |
256 | //mText += "\">"; | 256 | //mText += "\">"; |
257 | if ( ! itemAdded ) { | 257 | if ( ! itemAdded ) { |
258 | appendDay ( iii, mEventDate ); | 258 | appendDay ( iii, mEventDate ); |
259 | 259 | ||
260 | } | 260 | } |
261 | // for first day (iii == 0) | 261 | // for first day (iii == 0) |
262 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 262 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
263 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 263 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
264 | // we must append it in the first successful call of appendEvent() | 264 | // we must append it in the first successful call of appendEvent() |
265 | Event *ev = events.first(); | 265 | Event *ev = events.first(); |
266 | while(ev) { | 266 | while(ev) { |
267 | //qDebug("+++++event append %s", ev->summary().latin1()); | 267 | //qDebug("+++++event append %s", ev->summary().latin1()); |
268 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 268 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
269 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 269 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
270 | itemAdded = true; | 270 | itemAdded = true; |
271 | } | 271 | } |
272 | ev = events.next(); | 272 | ev = events.next(); |
273 | } | 273 | } |
274 | 274 | ||
275 | //mText += "</table>\n"; | 275 | //mText += "</table>\n"; |
276 | } | 276 | } |
277 | 277 | ||
278 | todo = todos.first(); | 278 | todo = todos.first(); |
279 | while(todo) { | 279 | while(todo) { |
280 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 280 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
281 | if ( ! itemAdded ) { | 281 | if ( ! itemAdded ) { |
282 | appendDay ( iii, mEventDate ); | 282 | appendDay ( iii, mEventDate ); |
283 | //itemAdded = true; | 283 | //itemAdded = true; |
284 | } | 284 | } |
285 | appendEvent(todo, false , iii!= 0,!itemAdded); | 285 | appendEvent(todo, false , iii!= 0,!itemAdded); |
286 | itemAdded = true; | 286 | itemAdded = true; |
287 | } | 287 | } |
288 | todo = todos.next(); | 288 | todo = todos.next(); |
289 | } | 289 | } |
290 | if ( !itemAdded && iii == 0 ) { | 290 | if ( !itemAdded && iii == 0 ) { |
291 | // appendDay ( iii, mEventDate ); | 291 | // appendDay ( iii, mEventDate ); |
292 | //mText += "<table>"; | 292 | //mText += "<table>"; |
293 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 293 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
294 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; | 294 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; |
295 | //mText +="</table>"; | 295 | //mText +="</table>"; |
296 | } | 296 | } |
297 | if ( itemAdded ) | 297 | if ( itemAdded ) |
298 | mText += "</table>\n"; | 298 | mText += "</table>\n"; |
299 | mEventDate = mEventDate.addDays( 1 ); | 299 | mEventDate = mEventDate.addDays( 1 ); |
300 | } | 300 | } |
301 | 301 | ||
302 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 302 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
303 | if (todos.count() > 0 && topmostPrios > 0 ) { | 303 | if (todos.count() > 0 && topmostPrios > 0 ) { |
304 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 304 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
305 | // mText += "<h2>"; | 305 | // mText += "<h2>"; |
306 | //<img src=\""; | 306 | //<img src=\""; |
307 | // mText += ipath; | 307 | // mText += ipath; |
308 | // mText += "\">"; | 308 | // mText += "\">"; |
309 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 309 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
310 | 310 | ||
311 | //mText += "<ul>\n"; | 311 | //mText += "<ul>\n"; |
312 | bool gotone = false; | 312 | bool gotone = false; |
313 | int priority = 1; | 313 | int priority = 1; |
314 | int priosFound = 0; | 314 | int priosFound = 0; |
315 | #ifdef DESKTOP_VERSION | 315 | #ifdef DESKTOP_VERSION |
316 | mText +="<p></p>"; | 316 | mText +="<p></p>"; |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; | 319 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; |
320 | mText += "<ul>\n"; | 320 | mText += "<ul>\n"; |
321 | while (!gotone && priority<6) { | 321 | while (!gotone && priority<6) { |
322 | todo = todos.first(); | 322 | todo = todos.first(); |
323 | while(todo) { | 323 | while(todo) { |
324 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 324 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
325 | mCurrentMaxPrio = priority - priosFound + topmostPrios -1; | 325 | mCurrentMaxPrio = priority - priosFound + topmostPrios -1; |
326 | if ( appendTodo(todo) ) | 326 | if ( appendTodo(todo) ) |
327 | gotone = true; | 327 | gotone = true; |
328 | } | 328 | } |
329 | todo = todos.next(); | 329 | todo = todos.next(); |
330 | } | 330 | } |
331 | if ( gotone ) { | 331 | if ( gotone ) { |
332 | gotone = false; | 332 | gotone = false; |
333 | ++priosFound; | 333 | ++priosFound; |
334 | if ( priosFound == topmostPrios ) | 334 | if ( priosFound == topmostPrios ) |
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | priority++; | 337 | priority++; |
338 | // kdDebug() << "adding the todos..." << endl; | 338 | // kdDebug() << "adding the todos..." << endl; |
339 | } | 339 | } |
340 | mText += "</ul>\n"; | 340 | mText += "</ul>\n"; |
341 | } | 341 | } |
342 | 342 | ||
343 | int replys = 0; | 343 | int replys = 0; |
344 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 344 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
345 | if (events.count() > 0) { | 345 | if (events.count() > 0) { |
346 | Event *ev = events.first(); | 346 | Event *ev = events.first(); |
347 | while(ev) { | 347 | while(ev) { |
348 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 348 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
349 | if (me!=0) { | 349 | if (me!=0) { |
350 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 350 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
351 | if (replys == 0) { | 351 | if (replys == 0) { |
352 | mText += "<p></p>"; | 352 | mText += "<p></p>"; |
353 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 353 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
354 | //mText += "<h2>"; | 354 | //mText += "<h2>"; |
355 | //<img src=\""; | 355 | //<img src=\""; |
356 | // mText += ipath; | 356 | // mText += ipath; |
357 | // mText += "\">"; | 357 | // mText += "\">"; |
358 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 358 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
359 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 359 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
360 | mText += "<table>\n"; | 360 | mText += "<table>\n"; |
361 | } | 361 | } |
362 | replys++; | 362 | replys++; |
363 | appendEvent(ev,true); | 363 | appendEvent(ev,true); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | ev = events.next(); | 366 | ev = events.next(); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | todos = calendar()->todos(); | 369 | todos = calendar()->todos(); |
370 | if (todos.count() > 0) { | 370 | if (todos.count() > 0) { |
371 | Todo *to = todos.first(); | 371 | Todo *to = todos.first(); |
372 | while(to) { | 372 | while(to) { |
373 | if ( !to->isCompleted() ){ | 373 | if ( !to->isCompleted() ){ |
374 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 374 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
375 | if (me!=0) { | 375 | if (me!=0) { |
376 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 376 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
377 | if (replys == 0) { | 377 | if (replys == 0) { |
378 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 378 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
379 | mText += "<table>\n"; | 379 | mText += "<table>\n"; |
380 | } | 380 | } |
381 | replys++; | 381 | replys++; |
382 | appendEvent(to, true); | 382 | appendEvent(to, true); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | to = todos.next(); | 386 | to = todos.next(); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | if (replys > 0 ) mText += "</table>\n"; | 389 | if (replys > 0 ) mText += "</table>\n"; |
390 | 390 | ||
391 | 391 | ||
392 | mText += "</td></tr>\n</table>\n"; | 392 | mText += "</td></tr>\n</table>\n"; |
393 | 393 | ||
394 | mView->setText(mText); | 394 | mView->setText(mText); |
395 | mView->setFocus(); | 395 | mView->setFocus(); |
396 | 396 | ||
397 | // QPixmap bPix = SmallIcon( "back" ); | 397 | // QPixmap bPix = SmallIcon( "back" ); |
398 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 398 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
399 | // QWidget* test = new QWidget(); | 399 | // QWidget* test = new QWidget(); |
400 | // test->setBackgroundMode(FixedPixmap ); | 400 | // test->setBackgroundMode(FixedPixmap ); |
401 | // test->setBackgroundPixmap ( bPix ); | 401 | // test->setBackgroundPixmap ( bPix ); |
402 | // test->resize( 300, 400 ); | 402 | // test->resize( 300, 400 ); |
403 | // test->show(); | 403 | // test->show(); |
404 | // mView->setBackgroundMode(FixedPixmap ); | 404 | // mView->setBackgroundMode(FixedPixmap ); |
405 | // mView->setBackgroundPixmap ( bPix ); | 405 | // mView->setBackgroundPixmap ( bPix ); |
406 | // qDebug("%s ",mText.latin1()); | 406 | // qDebug("%s ",mText.latin1()); |
407 | } | 407 | } |
408 | 408 | ||
409 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 409 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
410 | { | 410 | { |
411 | QString date; | 411 | QString date; |
412 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 412 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
413 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 413 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
414 | if ( i == 0 ) { | 414 | if ( i == 0 ) { |
415 | //mText += "<table>\n"; | 415 | //mText += "<table>\n"; |
416 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 416 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
417 | } | 417 | } |
418 | else if ( i == 1 ) | 418 | else if ( i == 1 ) |
419 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 419 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
420 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 420 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
421 | mText += "<h2>" + date + "</h2>\n"; | 421 | mText += "<h2>" + date + "</h2>\n"; |
422 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 422 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
423 | mText += "<table>\n"; | 423 | mText += "<table>\n"; |
424 | 424 | ||
425 | 425 | ||
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | if ( i == 0 ) { | 428 | if ( i == 0 ) { |
429 | //mText += "<table>\n"; | 429 | //mText += "<table>\n"; |
430 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 430 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
431 | } | 431 | } |
432 | 432 | ||
433 | #ifdef DESKTOP_VERSION | 433 | #ifdef DESKTOP_VERSION |
434 | else if ( i == 1 ) { | 434 | else if ( i == 1 ) { |
435 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 435 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
436 | } | 436 | } |
437 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 437 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
438 | #else | 438 | #else |
439 | else if ( i == 1 ) { | 439 | else if ( i == 1 ) { |
440 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 440 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
441 | } | 441 | } |
442 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 442 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
443 | 443 | ||
444 | #endif | 444 | #endif |
445 | mText += "<h2>" + date + "</h2>\n"; | 445 | mText += "<h2>" + date + "</h2>\n"; |
446 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 446 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
447 | mText += "<table>\n"; | 447 | mText += "<table>\n"; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 452 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
453 | { | 453 | { |
454 | updateView(); | 454 | updateView(); |
455 | } | 455 | } |
456 | 456 | ||
457 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 457 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
458 | { | 458 | { |
459 | } | 459 | } |
460 | 460 | ||
461 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 461 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
462 | { | 462 | { |
463 | switch(action) { | 463 | switch(action) { |
464 | case KOGlobals::EVENTADDED: | 464 | case KOGlobals::EVENTADDED: |
465 | updateView(); | 465 | updateView(); |
466 | break; | 466 | break; |
467 | case KOGlobals::EVENTEDITED: | 467 | case KOGlobals::EVENTEDITED: |
468 | updateView(); | 468 | updateView(); |
469 | break; | 469 | break; |
470 | case KOGlobals::EVENTDELETED: | 470 | case KOGlobals::EVENTDELETED: |
471 | updateView(); | 471 | updateView(); |
472 | break; | 472 | break; |
473 | default: | 473 | default: |
474 | updateView(); | 474 | updateView(); |
475 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 475 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) | 479 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) |
480 | { | 480 | { |
481 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) | 481 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) |
482 | return false; | 482 | return false; |
483 | QDateTime cdt = QDateTime::currentDateTime(); | 483 | QDateTime cdt = QDateTime::currentDateTime(); |
484 | QDateTime noc; | 484 | QDateTime noc; |
485 | QString tempText; | 485 | QString tempText; |
486 | if ( appendTable && !notRed ) { | 486 | if ( appendTable && !notRed ) { |
487 | tempText = "<table>"; | 487 | tempText = "<table>"; |
488 | } | 488 | } |
489 | bool ok = true; | 489 | bool ok = true; |
490 | if ( reply ) { | 490 | if ( reply ) { |
491 | noc = ev->getNextOccurence( cdt, &ok ); | 491 | noc = ev->getNextOccurence( cdt, &ok ); |
492 | if (! ok && ev->type() == "Event") | 492 | if (! ok && ev->typeID() == eventID) |
493 | return false; | 493 | return false; |
494 | } | 494 | } |
495 | bool bDay = false; | 495 | bool bDay = false; |
496 | if ( ev->isBirthday() || ev->isAnniversary() ) | 496 | if ( ev->isBirthday() || ev->isAnniversary() ) |
497 | bDay = true; | 497 | bDay = true; |
498 | tempText += "<tr><td><b>"; | 498 | tempText += "<tr><td><b>"; |
499 | if (ev->type()=="Event") { | 499 | if (ev->typeID() == eventID ) { |
500 | if (reply) { | 500 | if (reply) { |
501 | if (!ev->doesFloat()) | 501 | if (!ev->doesFloat()) |
502 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; | 502 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; |
503 | else | 503 | else |
504 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 504 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
505 | 505 | ||
506 | } else { | 506 | } else { |
507 | if (!ev->doesFloat()) { | 507 | if (!ev->doesFloat()) { |
508 | Event *event = static_cast<Event *>(ev); | 508 | Event *event = static_cast<Event *>(ev); |
509 | QDateTime st,end; | 509 | QDateTime st,end; |
510 | if ( event->recurrence()->doesRecur() ) { | 510 | if ( event->recurrence()->doesRecur() ) { |
511 | QDate recDate= mEventDate; | 511 | QDate recDate= mEventDate; |
512 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 512 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
513 | while ( ! event->recursOn( recDate ) ) { | 513 | while ( ! event->recursOn( recDate ) ) { |
514 | recDate = recDate.addDays( -1 ); | 514 | recDate = recDate.addDays( -1 ); |
515 | 515 | ||
516 | } | 516 | } |
517 | st = QDateTime ( recDate, event->dtStart().time() ); | 517 | st = QDateTime ( recDate, event->dtStart().time() ); |
518 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 518 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
519 | } | 519 | } |
520 | else { | 520 | else { |
521 | st = event->dtStart(); | 521 | st = event->dtStart(); |
522 | end = event->dtEnd(); | 522 | end = event->dtEnd(); |
523 | } | 523 | } |
524 | 524 | ||
525 | 525 | ||
526 | QString dateText; | 526 | QString dateText; |
527 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 527 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
528 | if ( st.date() < mEventDate ) | 528 | if ( st.date() < mEventDate ) |
529 | dateText = "++:++-"; | 529 | dateText = "++:++-"; |
530 | else | 530 | else |
531 | dateText = event->dtStartTimeStr() + "-"; | 531 | dateText = event->dtStartTimeStr() + "-"; |
532 | if ( end.date() > mEventDate ) | 532 | if ( end.date() > mEventDate ) |
533 | dateText += "++:++"; | 533 | dateText += "++:++"; |
534 | else | 534 | else |
535 | dateText += event->dtEndTimeStr(); | 535 | dateText += event->dtEndTimeStr(); |
536 | if ( notRed ) | 536 | if ( notRed ) |
537 | tempText += dateText; | 537 | tempText += dateText; |
538 | else { | 538 | else { |
539 | if ( end < cdt ) { | 539 | if ( end < cdt ) { |
540 | if ( !KOPrefs::instance()->mWNViewShowsPast ) | 540 | if ( !KOPrefs::instance()->mWNViewShowsPast ) |
541 | return false; | 541 | return false; |
542 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; | 542 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; |
543 | } | 543 | } |
544 | else if ( st < cdt ) | 544 | else if ( st < cdt ) |
545 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; | 545 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; |
546 | else | 546 | else |
547 | tempText += dateText; | 547 | tempText += dateText; |
548 | 548 | ||
549 | } | 549 | } |
550 | 550 | ||
551 | } else { | 551 | } else { |
552 | if ( bDay ) { | 552 | if ( bDay ) { |
553 | 553 | ||
554 | if ( ev->isBirthday()) | 554 | if ( ev->isBirthday()) |
555 | tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; | 555 | tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; |
556 | else | 556 | else |
557 | tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; | 557 | tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; |
558 | } else { | 558 | } else { |
559 | tempText += i18n("Allday:"); | 559 | tempText += i18n("Allday:"); |
560 | } | 560 | } |
561 | 561 | ||
562 | } | 562 | } |
563 | } | 563 | } |
564 | } else { | 564 | } else { |
565 | mTodos.append( ev ); | 565 | mTodos.append( ev ); |
566 | tempText += i18n("ToDo:"); | 566 | tempText += i18n("ToDo:"); |
567 | if (reply) { | 567 | if (reply) { |
568 | tempText += " "; | 568 | tempText += " "; |
569 | if ( noc != cdt ) { | 569 | if ( noc != cdt ) { |
570 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 570 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
571 | } | 571 | } |
572 | } else { | 572 | } else { |
573 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 573 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
574 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 574 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
575 | QString dfs = KGlobal::locale()->dateFormatShort(); | 575 | QString dfs = KGlobal::locale()->dateFormatShort(); |
576 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 576 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
577 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; | 577 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
578 | KGlobal::locale()->setDateFormatShort(dfs); | 578 | KGlobal::locale()->setDateFormatShort(dfs); |
579 | } else { | 579 | } else { |
580 | if (!ev->doesFloat() ) | 580 | if (!ev->doesFloat() ) |
581 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 581 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
582 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 582 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
583 | 583 | ||
584 | 584 | ||
585 | } else | 585 | } else |
586 | tempText +=((Todo*)ev)->dtDueTimeStr(); | 586 | tempText +=((Todo*)ev)->dtDueTimeStr(); |
587 | mTodos.append( ev ); | 587 | mTodos.append( ev ); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | } | 590 | } |
591 | tempText += "</b></td><td>"; | 591 | tempText += "</b></td><td>"; |
592 | bool needClose = false; | 592 | bool needClose = false; |
593 | if ( ev->cancelled() ) { | 593 | if ( ev->cancelled() ) { |
594 | tempText += "<font color=\"#F00000\">[c"; | 594 | tempText += "<font color=\"#F00000\">[c"; |
595 | needClose =true; | 595 | needClose =true; |
596 | 596 | ||
597 | } | 597 | } |
598 | if ( ev->isAlarmEnabled() ) { | 598 | if ( ev->isAlarmEnabled() ) { |
599 | if ( !needClose) | 599 | if ( !needClose) |
600 | tempText +="["; | 600 | tempText +="["; |
601 | tempText += "a"; | 601 | tempText += "a"; |
602 | needClose =true; | 602 | needClose =true; |
603 | 603 | ||
604 | } | 604 | } |
605 | if ( ev->description().length() > 0 ) { | 605 | if ( ev->description().length() > 0 ) { |
606 | if ( !needClose) | 606 | if ( !needClose) |
607 | tempText +="["; | 607 | tempText +="["; |
608 | tempText += "i"; | 608 | tempText += "i"; |
609 | needClose =true; | 609 | needClose =true; |
610 | } | 610 | } |
611 | if ( ev->recurrence()->doesRecur() ) { | 611 | if ( ev->recurrence()->doesRecur() ) { |
612 | if ( !needClose) | 612 | if ( !needClose) |
613 | tempText +="["; | 613 | tempText +="["; |
614 | tempText += "r"; | 614 | tempText += "r"; |
615 | needClose =true; | 615 | needClose =true; |
616 | } | 616 | } |
617 | if ( needClose ) { | 617 | if ( needClose ) { |
618 | tempText += "] "; | 618 | tempText += "] "; |
619 | } | 619 | } |
620 | if ( ev->cancelled() ) | 620 | if ( ev->cancelled() ) |
621 | tempText += "</font>"; | 621 | tempText += "</font>"; |
622 | tempText += "<a "; | 622 | tempText += "<a "; |
623 | if (ev->type()=="Event") tempText += "href=\"event:"; | 623 | if (ev->typeID() == eventID ) tempText += "href=\"event:"; |
624 | if (ev->type()=="Todo") tempText += "href=\"todo:"; | 624 | if (ev->typeID() == todoID ) tempText += "href=\"todo:"; |
625 | tempText += ev->uid() + "\">"; | 625 | tempText += ev->uid() + "\">"; |
626 | if ( ev->summary().length() > 0 ) | 626 | if ( ev->summary().length() > 0 ) |
627 | tempText += ev->summary(); | 627 | tempText += ev->summary(); |
628 | else | 628 | else |
629 | tempText += i18n("-no summary-"); | 629 | tempText += i18n("-no summary-"); |
630 | if ( bDay ) { | 630 | if ( bDay ) { |
631 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); | 631 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); |
632 | if ( ok ) { | 632 | if ( ok ) { |
633 | int years = 0; | 633 | int years = 0; |
634 | if ( ev->type() =="Todo" ) { | 634 | if ( ev->typeID() == todoID ) { |
635 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); | 635 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); |
636 | } else | 636 | } else |
637 | years = noc.date().year() - ev->dtStart().date().year(); | 637 | years = noc.date().year() - ev->dtStart().date().year(); |
638 | tempText += i18n(" (%1 y.)"). arg( years ); | 638 | tempText += i18n(" (%1 y.)"). arg( years ); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | tempText += "</a>"; | 642 | tempText += "</a>"; |
643 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 643 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
644 | if ( !ev->location().isEmpty() ) | 644 | if ( !ev->location().isEmpty() ) |
645 | tempText += " ("+ev->location() +")"; | 645 | tempText += " ("+ev->location() +")"; |
646 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 646 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
647 | tempText += " ["+ev->relatedTo()->summary() +"]"; | 647 | tempText += " ["+ev->relatedTo()->summary() +"]"; |
648 | tempText += "</td></tr>\n"; | 648 | tempText += "</td></tr>\n"; |
649 | mText += tempText; | 649 | mText += tempText; |
650 | return true; | 650 | return true; |
651 | } | 651 | } |
652 | 652 | ||
653 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 653 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
654 | { | 654 | { |
655 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 655 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
656 | 656 | ||
657 | mTodos.append( ev ); | 657 | mTodos.append( ev ); |
658 | if ( !isSub ) | 658 | if ( !isSub ) |
659 | mText += "<p>"; | 659 | mText += "<p>"; |
660 | else | 660 | else |
661 | mText += "<li>"; | 661 | mText += "<li>"; |
662 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 662 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
663 | 663 | ||
664 | 664 | ||
665 | mText += ind; | 665 | mText += ind; |
666 | bool needClose = false; | 666 | bool needClose = false; |
667 | if ( ev->cancelled() ) { | 667 | if ( ev->cancelled() ) { |
668 | mText += "<font color=\"#F00000\">[c"; | 668 | mText += "<font color=\"#F00000\">[c"; |
669 | needClose =true; | 669 | needClose =true; |
670 | 670 | ||
671 | } | 671 | } |
672 | if ( ev->isAlarmEnabled() ) { | 672 | if ( ev->isAlarmEnabled() ) { |
673 | if ( !needClose) | 673 | if ( !needClose) |
674 | mText +="["; | 674 | mText +="["; |
675 | mText += "a"; | 675 | mText += "a"; |
676 | needClose =true; | 676 | needClose =true; |
677 | 677 | ||
678 | } | 678 | } |
679 | 679 | ||
680 | if ( ev->description().length() > 0 ) { | 680 | if ( ev->description().length() > 0 ) { |
681 | if ( !needClose) | 681 | if ( !needClose) |
682 | mText +="["; | 682 | mText +="["; |
683 | mText += "i"; | 683 | mText += "i"; |
684 | needClose =true; | 684 | needClose =true; |
685 | } | 685 | } |
686 | if ( ev->doesRecur() ) { | 686 | if ( ev->doesRecur() ) { |
687 | if ( !needClose) | 687 | if ( !needClose) |
688 | mText +="["; | 688 | mText +="["; |
689 | mText += "r"; | 689 | mText += "r"; |
690 | needClose =true; | 690 | needClose =true; |
691 | } | 691 | } |
692 | // if ( ev->recurrence()->doesRecur() ) { | 692 | // if ( ev->recurrence()->doesRecur() ) { |
693 | // if ( !needClose) | 693 | // if ( !needClose) |
694 | // mText +="("; | 694 | // mText +="("; |
695 | // mText += "r"; | 695 | // mText += "r"; |
696 | // needClose =true; | 696 | // needClose =true; |
697 | // } | 697 | // } |
698 | if ( needClose ) | 698 | if ( needClose ) |
699 | mText += "] "; | 699 | mText += "] "; |
700 | if ( ev->cancelled() ) | 700 | if ( ev->cancelled() ) |
701 | mText += "</font>"; | 701 | mText += "</font>"; |
702 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 702 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
703 | if ( ev->summary().length() > 0 ) | 703 | if ( ev->summary().length() > 0 ) |
704 | mText += ev->summary(); | 704 | mText += ev->summary(); |
705 | else | 705 | else |
706 | mText += i18n("-no summary-"); | 706 | mText += i18n("-no summary-"); |
707 | mText += "</a>"; | 707 | mText += "</a>"; |
708 | if ( ((Todo*)ev)->hasDueDate () ) { | 708 | if ( ((Todo*)ev)->hasDueDate () ) { |
709 | QString year = ""; | 709 | QString year = ""; |
710 | int ye = ((Todo*)ev)->dtDue().date().year(); | 710 | int ye = ((Todo*)ev)->dtDue().date().year(); |
711 | if ( QDateTime::currentDateTime().date().year() != ye ) | 711 | if ( QDateTime::currentDateTime().date().year() != ye ) |
712 | year = QString::number( ye ); | 712 | year = QString::number( ye ); |
713 | QString dfs = KGlobal::locale()->dateFormatShort(); | 713 | QString dfs = KGlobal::locale()->dateFormatShort(); |
714 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 714 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
715 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 715 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
716 | KGlobal::locale()->setDateFormatShort(dfs); | 716 | KGlobal::locale()->setDateFormatShort(dfs); |
717 | } | 717 | } |
718 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 718 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
719 | if ( !ev->location().isEmpty() ) | 719 | if ( !ev->location().isEmpty() ) |
720 | mText += " ("+ev->location() +")"; | 720 | mText += " ("+ev->location() +")"; |
721 | if ( !isSub ) { | 721 | if ( !isSub ) { |
722 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 722 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
723 | mText += " ["+ev->relatedTo()->summary() +"]"; | 723 | mText += " ["+ev->relatedTo()->summary() +"]"; |
724 | mText += "</p>\n"; | 724 | mText += "</p>\n"; |
725 | } | 725 | } |
726 | else { | 726 | else { |
727 | ind += "-"; | 727 | ind += "-"; |
728 | mText += "</li>\n"; | 728 | mText += "</li>\n"; |
729 | } | 729 | } |
730 | QPtrList<Incidence> Relations = ev->relations(); | 730 | QPtrList<Incidence> Relations = ev->relations(); |
731 | Incidence *to; | 731 | Incidence *to; |
732 | for (to=Relations.first();to;to=Relations.next()) { | 732 | for (to=Relations.first();to;to=Relations.next()) { |
733 | if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) | 733 | if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) |
734 | appendTodo( to, ind , true ); | 734 | appendTodo( to, ind , true ); |
735 | } | 735 | } |
736 | 736 | ||
737 | return true; | 737 | return true; |
738 | } | 738 | } |
739 | 739 | ||
740 | /* | 740 | /* |
741 | void KOWhatsNextView::createEventViewer() | 741 | void KOWhatsNextView::createEventViewer() |
742 | { | 742 | { |
743 | if (!mEventViewer) { | 743 | if (!mEventViewer) { |
744 | 744 | ||
745 | mEventViewer = new KOEventViewerDialog(this); | 745 | mEventViewer = new KOEventViewerDialog(this); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | */ | 748 | */ |
749 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 749 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
750 | { | 750 | { |
751 | mEventViewer = v; | 751 | mEventViewer = v; |
752 | } | 752 | } |
753 | 753 | ||
754 | // TODO: Create this function in CalendarView and remove it from here | 754 | // TODO: Create this function in CalendarView and remove it from here |
755 | void KOWhatsNextView::showIncidence(const QString &uid) | 755 | void KOWhatsNextView::showIncidence(const QString &uid) |
756 | { | 756 | { |
757 | 757 | ||
758 | if ( !mEventViewer ) { | 758 | if ( !mEventViewer ) { |
759 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 759 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
760 | return; | 760 | return; |
761 | } | 761 | } |
762 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 762 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
763 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 763 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
764 | if (uid.startsWith("event:")) { | 764 | if (uid.startsWith("event:")) { |
765 | #ifdef DESKTOP_VERSION | 765 | #ifdef DESKTOP_VERSION |
766 | Event *event = calendar()->event(uid.mid(8)); | 766 | Event *event = calendar()->event(uid.mid(8)); |
767 | #else | 767 | #else |
768 | Event *event = calendar()->event(uid.mid(6)); | 768 | Event *event = calendar()->event(uid.mid(6)); |
769 | #endif | 769 | #endif |
770 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 770 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
771 | if (!event) return; | 771 | if (!event) return; |
772 | //createEventViewer(); | 772 | //createEventViewer(); |
773 | mEventViewer->setEvent(event); | 773 | mEventViewer->setEvent(event); |
774 | } else if (uid.startsWith("todo:")) { | 774 | } else if (uid.startsWith("todo:")) { |
775 | #ifdef DESKTOP_VERSION | 775 | #ifdef DESKTOP_VERSION |
776 | Todo *todo = calendar()->todo(uid.mid(7)); | 776 | Todo *todo = calendar()->todo(uid.mid(7)); |
777 | #else | 777 | #else |
778 | Todo *todo = calendar()->todo(uid.mid(5)); | 778 | Todo *todo = calendar()->todo(uid.mid(5)); |
779 | #endif | 779 | #endif |
780 | if (!todo) return; | 780 | if (!todo) return; |
781 | //createEventViewer(); | 781 | //createEventViewer(); |
782 | mEventViewer->setTodo(todo); | 782 | mEventViewer->setTodo(todo); |
783 | } else { | 783 | } else { |
784 | return; | 784 | return; |
785 | 785 | ||
786 | } | 786 | } |
787 | mEventViewer->showMe(); | 787 | mEventViewer->showMe(); |
788 | mEventViewer->raise(); | 788 | mEventViewer->raise(); |
789 | } | 789 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 53b65b2..481eab4 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2500 +1,2500 @@ | |||
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->openCalendar( defaultFileName() ); | 311 | mView->openCalendar( defaultFileName() ); |
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 ) { | 628 | if ( QApplication::desktop()->width() < 480 ) { |
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..."), 0, this ); | 727 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 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 | actionMenu->insertSeparator(); | 731 | actionMenu->insertSeparator(); |
732 | 732 | ||
733 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 733 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
734 | action->addTo( actionMenu ); | 734 | action->addTo( actionMenu ); |
735 | connect( action, SIGNAL( activated() ), | 735 | connect( action, SIGNAL( activated() ), |
736 | mView, SLOT( undo_delete() ) ); | 736 | mView, SLOT( undo_delete() ) ); |
737 | actionMenu->insertSeparator(); | 737 | actionMenu->insertSeparator(); |
738 | 738 | ||
739 | icon = loadPixmap( pathString + "newevent" ); | 739 | icon = loadPixmap( pathString + "newevent" ); |
740 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 740 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
741 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 741 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
742 | configureToolBarMenu->insertSeparator(); | 742 | configureToolBarMenu->insertSeparator(); |
743 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 743 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
744 | configureToolBarMenu->insertSeparator(); | 744 | configureToolBarMenu->insertSeparator(); |
745 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 745 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
746 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 746 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
747 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 747 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
748 | ne_action->addTo( actionMenu ); | 748 | ne_action->addTo( actionMenu ); |
749 | connect( ne_action, SIGNAL( activated() ), | 749 | connect( ne_action, SIGNAL( activated() ), |
750 | mView, SLOT( newEvent() ) ); | 750 | mView, SLOT( newEvent() ) ); |
751 | icon = loadPixmap( pathString + "newtodo" ); | 751 | icon = loadPixmap( pathString + "newtodo" ); |
752 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 752 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
753 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 753 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
754 | nt_action->addTo( actionMenu ); | 754 | nt_action->addTo( actionMenu ); |
755 | connect( nt_action, SIGNAL( activated() ), | 755 | connect( nt_action, SIGNAL( activated() ), |
756 | mView, SLOT( newTodo() ) ); | 756 | mView, SLOT( newTodo() ) ); |
757 | 757 | ||
758 | icon = loadPixmap( pathString + "today" ); | 758 | icon = loadPixmap( pathString + "today" ); |
759 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 759 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
760 | today_action->addTo( viewMenu ); | 760 | today_action->addTo( viewMenu ); |
761 | connect( today_action, SIGNAL( activated() ), | 761 | connect( today_action, SIGNAL( activated() ), |
762 | mView, SLOT( goToday() ) ); | 762 | mView, SLOT( goToday() ) ); |
763 | viewMenu->insertSeparator(); | 763 | viewMenu->insertSeparator(); |
764 | 764 | ||
765 | // *********************** | 765 | // *********************** |
766 | if ( KOPrefs::instance()->mVerticalScreen ) { | 766 | if ( KOPrefs::instance()->mVerticalScreen ) { |
767 | icon = SmallIcon( "1updownarrow" ); | 767 | icon = SmallIcon( "1updownarrow" ); |
768 | } else { | 768 | } else { |
769 | icon = SmallIcon("1leftrightarrow" ); | 769 | icon = SmallIcon("1leftrightarrow" ); |
770 | } | 770 | } |
771 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); | 771 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); |
772 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); | 772 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); |
773 | FSaction->addTo( viewMenu ); | 773 | FSaction->addTo( viewMenu ); |
774 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); | 774 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); |
775 | 775 | ||
776 | icon = loadPixmap( pathString + "navi" ); | 776 | icon = loadPixmap( pathString + "navi" ); |
777 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | 777 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); |
778 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 778 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
779 | action->addTo( viewMenu ); | 779 | action->addTo( viewMenu ); |
780 | connect( action, SIGNAL( activated() ), | 780 | connect( action, SIGNAL( activated() ), |
781 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 781 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
782 | mToggleNav = action ; | 782 | mToggleNav = action ; |
783 | icon = loadPixmap( pathString + "filter" ); | 783 | icon = loadPixmap( pathString + "filter" ); |
784 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); | 784 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); |
785 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 785 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
786 | action->addTo( viewMenu ); | 786 | action->addTo( viewMenu ); |
787 | connect( action, SIGNAL( activated() ), | 787 | connect( action, SIGNAL( activated() ), |
788 | mView, SLOT( toggleFilter() ) ); | 788 | mView, SLOT( toggleFilter() ) ); |
789 | mToggleFilter = action; | 789 | mToggleFilter = action; |
790 | icon = loadPixmap( pathString + "allday" ); | 790 | icon = loadPixmap( pathString + "allday" ); |
791 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); | 791 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); |
792 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 792 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
793 | action->addTo( viewMenu ); | 793 | action->addTo( viewMenu ); |
794 | connect( action, SIGNAL( activated() ), | 794 | connect( action, SIGNAL( activated() ), |
795 | mView, SLOT( toggleAllDaySize() ) ); | 795 | mView, SLOT( toggleAllDaySize() ) ); |
796 | mToggleAllday = action; | 796 | mToggleAllday = action; |
797 | 797 | ||
798 | 798 | ||
799 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 799 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
800 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 800 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
801 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 801 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
802 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 802 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
803 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 803 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
804 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 804 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
805 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 805 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
806 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); | 806 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); |
807 | 807 | ||
808 | viewMenu->insertSeparator(); | 808 | viewMenu->insertSeparator(); |
809 | icon = loadPixmap( pathString + "picker" ); | 809 | icon = loadPixmap( pathString + "picker" ); |
810 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 810 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
811 | action->addTo( viewMenu ); | 811 | action->addTo( viewMenu ); |
812 | connect( action, SIGNAL( activated() ), | 812 | connect( action, SIGNAL( activated() ), |
813 | mView, SLOT( showDatePicker() ) ); | 813 | mView, SLOT( showDatePicker() ) ); |
814 | action->addTo( iconToolBar ); | 814 | action->addTo( iconToolBar ); |
815 | viewMenu->insertSeparator(); | 815 | viewMenu->insertSeparator(); |
816 | 816 | ||
817 | if ( p-> mShowIconToggleFull ) | 817 | if ( p-> mShowIconToggleFull ) |
818 | FSaction->addTo( iconToolBar ); | 818 | FSaction->addTo( iconToolBar ); |
819 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); | 819 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); |
820 | 820 | ||
821 | //******************** | 821 | //******************** |
822 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); | 822 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); |
823 | 823 | ||
824 | 824 | ||
825 | icon = loadPixmap( pathString + "whatsnext" ); | 825 | icon = loadPixmap( pathString + "whatsnext" ); |
826 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 826 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
827 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 827 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
828 | whatsnext_action->addTo( viewMenu ); | 828 | whatsnext_action->addTo( viewMenu ); |
829 | connect( whatsnext_action, SIGNAL( activated() ), | 829 | connect( whatsnext_action, SIGNAL( activated() ), |
830 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 830 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
831 | 831 | ||
832 | icon = loadPixmap( pathString + "xdays" ); | 832 | icon = loadPixmap( pathString + "xdays" ); |
833 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 833 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
834 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 834 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
835 | xdays_action->addTo( viewMenu ); | 835 | xdays_action->addTo( viewMenu ); |
836 | connect( xdays_action, SIGNAL( activated() ), | 836 | connect( xdays_action, SIGNAL( activated() ), |
837 | mView->viewManager(), SLOT( showNextXView() ) ); | 837 | mView->viewManager(), SLOT( showNextXView() ) ); |
838 | 838 | ||
839 | 839 | ||
840 | icon = loadPixmap( pathString + "journal" ); | 840 | icon = loadPixmap( pathString + "journal" ); |
841 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 841 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
842 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 842 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
843 | viewjournal_action->addTo( viewMenu ); | 843 | viewjournal_action->addTo( viewMenu ); |
844 | connect( viewjournal_action, SIGNAL( activated() ), | 844 | connect( viewjournal_action, SIGNAL( activated() ), |
845 | mView->viewManager(), SLOT( showJournalView() ) ); | 845 | mView->viewManager(), SLOT( showJournalView() ) ); |
846 | 846 | ||
847 | 847 | ||
848 | icon = loadPixmap( pathString + "day" ); | 848 | icon = loadPixmap( pathString + "day" ); |
849 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 849 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
850 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 850 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
851 | day1_action->addTo( viewMenu ); | 851 | day1_action->addTo( viewMenu ); |
852 | // action->addTo( toolBar ); | 852 | // action->addTo( toolBar ); |
853 | connect( day1_action, SIGNAL( activated() ), | 853 | connect( day1_action, SIGNAL( activated() ), |
854 | mView->viewManager(), SLOT( showDayView() ) ); | 854 | mView->viewManager(), SLOT( showDayView() ) ); |
855 | 855 | ||
856 | icon = loadPixmap( pathString + "workweek" ); | 856 | icon = loadPixmap( pathString + "workweek" ); |
857 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 857 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
858 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 858 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
859 | day5_action->addTo( viewMenu ); | 859 | day5_action->addTo( viewMenu ); |
860 | connect( day5_action, SIGNAL( activated() ), | 860 | connect( day5_action, SIGNAL( activated() ), |
861 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 861 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
862 | 862 | ||
863 | icon = loadPixmap( pathString + "week" ); | 863 | icon = loadPixmap( pathString + "week" ); |
864 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 864 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
865 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 865 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
866 | day7_action->addTo( viewMenu ); | 866 | day7_action->addTo( viewMenu ); |
867 | connect( day7_action, SIGNAL( activated() ), | 867 | connect( day7_action, SIGNAL( activated() ), |
868 | mView->viewManager(), SLOT( showWeekView() ) ); | 868 | mView->viewManager(), SLOT( showWeekView() ) ); |
869 | 869 | ||
870 | icon = loadPixmap( pathString + "workweek2" ); | 870 | icon = loadPixmap( pathString + "workweek2" ); |
871 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 871 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
872 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 872 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
873 | day6_action->addTo( viewMenu ); | 873 | day6_action->addTo( viewMenu ); |
874 | connect( day6_action, SIGNAL( activated() ), | 874 | connect( day6_action, SIGNAL( activated() ), |
875 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 875 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
876 | 876 | ||
877 | icon = loadPixmap( pathString + "month" ); | 877 | icon = loadPixmap( pathString + "month" ); |
878 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 878 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
879 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 879 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
880 | month_action->addTo( viewMenu ); | 880 | month_action->addTo( viewMenu ); |
881 | connect( month_action, SIGNAL( activated() ), | 881 | connect( month_action, SIGNAL( activated() ), |
882 | mView->viewManager(), SLOT( showMonthView() ) ); | 882 | mView->viewManager(), SLOT( showMonthView() ) ); |
883 | 883 | ||
884 | icon = loadPixmap( pathString + "list" ); | 884 | icon = loadPixmap( pathString + "list" ); |
885 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 885 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
886 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 886 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
887 | showlist_action->addTo( viewMenu ); | 887 | showlist_action->addTo( viewMenu ); |
888 | connect( showlist_action, SIGNAL( activated() ), | 888 | connect( showlist_action, SIGNAL( activated() ), |
889 | mView->viewManager(), SLOT( showListView() ) ); | 889 | mView->viewManager(), SLOT( showListView() ) ); |
890 | 890 | ||
891 | icon = loadPixmap( pathString + "todo" ); | 891 | icon = loadPixmap( pathString + "todo" ); |
892 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 892 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
893 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 893 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
894 | todoview_action->addTo( viewMenu ); | 894 | todoview_action->addTo( viewMenu ); |
895 | connect( todoview_action, SIGNAL( activated() ), | 895 | connect( todoview_action, SIGNAL( activated() ), |
896 | mView->viewManager(), SLOT( showTodoView() ) ); | 896 | mView->viewManager(), SLOT( showTodoView() ) ); |
897 | 897 | ||
898 | 898 | ||
899 | 899 | ||
900 | #if 0 | 900 | #if 0 |
901 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 901 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
902 | action->addTo( viewMenu ); | 902 | action->addTo( viewMenu ); |
903 | connect( action, SIGNAL( activated() ), | 903 | connect( action, SIGNAL( activated() ), |
904 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 904 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
905 | #endif | 905 | #endif |
906 | 906 | ||
907 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 907 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
908 | this ); | 908 | this ); |
909 | mNewSubTodoAction->addTo( actionMenu ); | 909 | mNewSubTodoAction->addTo( actionMenu ); |
910 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 910 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
911 | mView, SLOT( newSubTodo() ) ); | 911 | mView, SLOT( newSubTodo() ) ); |
912 | 912 | ||
913 | actionMenu->insertSeparator(); | 913 | actionMenu->insertSeparator(); |
914 | 914 | ||
915 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 915 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
916 | mShowAction->addTo( actionMenu ); | 916 | mShowAction->addTo( actionMenu ); |
917 | connect( mShowAction, SIGNAL( activated() ), | 917 | connect( mShowAction, SIGNAL( activated() ), |
918 | mView, SLOT( showIncidence() ) ); | 918 | mView, SLOT( showIncidence() ) ); |
919 | 919 | ||
920 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 920 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
921 | mEditAction->addTo( actionMenu ); | 921 | mEditAction->addTo( actionMenu ); |
922 | connect( mEditAction, SIGNAL( activated() ), | 922 | connect( mEditAction, SIGNAL( activated() ), |
923 | mView, SLOT( editIncidence() ) ); | 923 | mView, SLOT( editIncidence() ) ); |
924 | 924 | ||
925 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 925 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
926 | mDeleteAction->addTo( actionMenu ); | 926 | mDeleteAction->addTo( actionMenu ); |
927 | connect( mDeleteAction, SIGNAL( activated() ), | 927 | connect( mDeleteAction, SIGNAL( activated() ), |
928 | mView, SLOT( deleteIncidence() ) ); | 928 | mView, SLOT( deleteIncidence() ) ); |
929 | 929 | ||
930 | 930 | ||
931 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 931 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
932 | mCloneAction->addTo( actionMenu ); | 932 | mCloneAction->addTo( actionMenu ); |
933 | connect( mCloneAction, SIGNAL( activated() ), | 933 | connect( mCloneAction, SIGNAL( activated() ), |
934 | mView, SLOT( cloneIncidence() ) ); | 934 | mView, SLOT( cloneIncidence() ) ); |
935 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 935 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
936 | mMoveAction->addTo( actionMenu ); | 936 | mMoveAction->addTo( actionMenu ); |
937 | connect( mMoveAction, SIGNAL( activated() ), | 937 | connect( mMoveAction, SIGNAL( activated() ), |
938 | mView, SLOT( moveIncidence() ) ); | 938 | mView, SLOT( moveIncidence() ) ); |
939 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 939 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
940 | mBeamAction->addTo( actionMenu ); | 940 | mBeamAction->addTo( actionMenu ); |
941 | connect( mBeamAction, SIGNAL( activated() ), | 941 | connect( mBeamAction, SIGNAL( activated() ), |
942 | mView, SLOT( beamIncidence() ) ); | 942 | mView, SLOT( beamIncidence() ) ); |
943 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 943 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
944 | mCancelAction->addTo( actionMenu ); | 944 | mCancelAction->addTo( actionMenu ); |
945 | connect( mCancelAction, SIGNAL( activated() ), | 945 | connect( mCancelAction, SIGNAL( activated() ), |
946 | mView, SLOT( toggleCancelIncidence() ) ); | 946 | mView, SLOT( toggleCancelIncidence() ) ); |
947 | 947 | ||
948 | actionMenu->insertSeparator(); | 948 | actionMenu->insertSeparator(); |
949 | 949 | ||
950 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 950 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
951 | this ); | 951 | this ); |
952 | action->addTo( actionMenu ); | 952 | action->addTo( actionMenu ); |
953 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 953 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
954 | 954 | ||
955 | icon = loadPixmap( pathString + "search" ); | 955 | icon = loadPixmap( pathString + "search" ); |
956 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 956 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
957 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 957 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
958 | search_action->addTo( actionMenu ); | 958 | search_action->addTo( actionMenu ); |
959 | connect( search_action, SIGNAL( activated() ), | 959 | connect( search_action, SIGNAL( activated() ), |
960 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 960 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
961 | 961 | ||
962 | 962 | ||
963 | 963 | ||
964 | if ( KOPrefs::instance()->mShowFullMenu ) { | 964 | if ( KOPrefs::instance()->mShowFullMenu ) { |
965 | actionMenu->insertSeparator(); | 965 | actionMenu->insertSeparator(); |
966 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 966 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
967 | 967 | ||
968 | } | 968 | } |
969 | // actionMenu->insertSeparator(); | 969 | // actionMenu->insertSeparator(); |
970 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 970 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
971 | this ); | 971 | this ); |
972 | action->addTo( importMenu_X ); | 972 | action->addTo( importMenu_X ); |
973 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 973 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
974 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 974 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
975 | this ); | 975 | this ); |
976 | action->addTo( importMenu_X ); | 976 | action->addTo( importMenu_X ); |
977 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 977 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
978 | importMenu_X->insertSeparator(); | 978 | importMenu_X->insertSeparator(); |
979 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 979 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
980 | this ); | 980 | this ); |
981 | action->addTo( importMenu_X ); | 981 | action->addTo( importMenu_X ); |
982 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 982 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
983 | //#ifndef DESKTOP_VERSION | 983 | //#ifndef DESKTOP_VERSION |
984 | importMenu_X->insertSeparator(); | 984 | importMenu_X->insertSeparator(); |
985 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 985 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
986 | this ); | 986 | this ); |
987 | action->addTo( importMenu_X ); | 987 | action->addTo( importMenu_X ); |
988 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 988 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
989 | //#else | 989 | //#else |
990 | #ifdef _OL_IMPORT_ | 990 | #ifdef _OL_IMPORT_ |
991 | importMenu_X->insertSeparator(); | 991 | importMenu_X->insertSeparator(); |
992 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 992 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
993 | this ); | 993 | this ); |
994 | action->addTo( importMenu_X ); | 994 | action->addTo( importMenu_X ); |
995 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 995 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
996 | #endif | 996 | #endif |
997 | //#endif | 997 | //#endif |
998 | 998 | ||
999 | //importMenu->insertSeparator(); | 999 | //importMenu->insertSeparator(); |
1000 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 1000 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
1001 | this ); | 1001 | this ); |
1002 | action->addTo( importMenu ); | 1002 | action->addTo( importMenu ); |
1003 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 1003 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
1004 | 1004 | ||
1005 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 1005 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
1006 | this ); | 1006 | this ); |
1007 | action->addTo( importMenu ); | 1007 | action->addTo( importMenu ); |
1008 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 1008 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
1009 | importMenu->insertSeparator(); | 1009 | importMenu->insertSeparator(); |
1010 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 1010 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
1011 | //importMenu->insertSeparator(); | 1011 | //importMenu->insertSeparator(); |
1012 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 1012 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
1013 | this ); | 1013 | this ); |
1014 | action->addTo( exportMenu_X ); | 1014 | action->addTo( exportMenu_X ); |
1015 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 1015 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
1016 | 1016 | ||
1017 | 1017 | ||
1018 | //LR | 1018 | //LR |
1019 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 1019 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
1020 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1020 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1021 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1021 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1022 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 1022 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
1023 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 1023 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
1024 | 1024 | ||
1025 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 1025 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
1026 | #ifndef DESKTOP_VERSION | 1026 | #ifndef DESKTOP_VERSION |
1027 | //importMenu->insertSeparator(); | 1027 | //importMenu->insertSeparator(); |
1028 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 1028 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
1029 | this ); | 1029 | this ); |
1030 | brAction->addTo( beamMenu_X ); | 1030 | brAction->addTo( beamMenu_X ); |
1031 | brAction->setToggleAction (true ) ; | 1031 | brAction->setToggleAction (true ) ; |
1032 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 1032 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
1033 | 1033 | ||
1034 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 1034 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
1035 | this ); | 1035 | this ); |
1036 | action->addTo( beamMenu_X ); | 1036 | action->addTo( beamMenu_X ); |
1037 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 1037 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
1038 | 1038 | ||
1039 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 1039 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
1040 | this ); | 1040 | this ); |
1041 | action->addTo( beamMenu_X ); | 1041 | action->addTo( beamMenu_X ); |
1042 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 1042 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
1043 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 1043 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
1044 | #else | 1044 | #else |
1045 | //importMenu->insertSeparator(); | 1045 | //importMenu->insertSeparator(); |
1046 | icon = loadPixmap( pathString + "print" ); | 1046 | icon = loadPixmap( pathString + "print" ); |
1047 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 1047 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
1048 | action->addTo( beamMenu_X ); | 1048 | action->addTo( beamMenu_X ); |
1049 | connect( action, SIGNAL( activated() ), | 1049 | connect( action, SIGNAL( activated() ), |
1050 | this, SLOT( printCal() ) ); | 1050 | this, SLOT( printCal() ) ); |
1051 | 1051 | ||
1052 | icon = loadPixmap( pathString + "print" ); | 1052 | icon = loadPixmap( pathString + "print" ); |
1053 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 1053 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
1054 | action->addTo( beamMenu_X ); | 1054 | action->addTo( beamMenu_X ); |
1055 | connect( action, SIGNAL( activated() ), | 1055 | connect( action, SIGNAL( activated() ), |
1056 | this, SLOT( printSel() ) ); | 1056 | this, SLOT( printSel() ) ); |
1057 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 1057 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
1058 | action->addTo( beamMenu_X ); | 1058 | action->addTo( beamMenu_X ); |
1059 | connect( action, SIGNAL( activated() ), | 1059 | connect( action, SIGNAL( activated() ), |
1060 | mView->viewManager(), SLOT( slotprintWNV() ) ); | 1060 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1061 | 1061 | ||
1062 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | 1062 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); |
1063 | action->addTo( beamMenu_X ); | 1063 | action->addTo( beamMenu_X ); |
1064 | connect( action, SIGNAL( activated() ), | 1064 | connect( action, SIGNAL( activated() ), |
1065 | mView, SLOT( slotprintSelInc() ) ); | 1065 | mView, SLOT( slotprintSelInc() ) ); |
1066 | 1066 | ||
1067 | 1067 | ||
1068 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1068 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
1069 | #endif | 1069 | #endif |
1070 | importMenu->insertSeparator(); | 1070 | importMenu->insertSeparator(); |
1071 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1071 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1072 | this ); | 1072 | this ); |
1073 | action->addTo( importMenu ); | 1073 | action->addTo( importMenu ); |
1074 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1074 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1075 | importMenu->insertSeparator(); | 1075 | importMenu->insertSeparator(); |
1076 | action = new QAction( "beam all", i18n("Save"), 0, | 1076 | action = new QAction( "beam all", i18n("Save"), 0, |
1077 | this ); | 1077 | this ); |
1078 | action->addTo( importMenu ); | 1078 | action->addTo( importMenu ); |
1079 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1079 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1080 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1080 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1081 | this ); | 1081 | this ); |
1082 | action->addTo( importMenu ); | 1082 | action->addTo( importMenu ); |
1083 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1083 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1084 | 1084 | ||
1085 | //menuBar->insertItem( "Configure",configureMenu ); | 1085 | //menuBar->insertItem( "Configure",configureMenu ); |
1086 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1086 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1087 | icon = loadPixmap( "korganizer/korganizer" ); | 1087 | icon = loadPixmap( "korganizer/korganizer" ); |
1088 | 1088 | ||
1089 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1089 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1090 | action->addTo( helpMenu ); | 1090 | action->addTo( helpMenu ); |
1091 | connect( action, SIGNAL( activated() ), | 1091 | connect( action, SIGNAL( activated() ), |
1092 | SLOT( whatsNew() ) ); | 1092 | SLOT( whatsNew() ) ); |
1093 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1093 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1094 | action->addTo( helpMenu ); | 1094 | action->addTo( helpMenu ); |
1095 | connect( action, SIGNAL( activated() ), | 1095 | connect( action, SIGNAL( activated() ), |
1096 | SLOT( features() ) ); | 1096 | SLOT( features() ) ); |
1097 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1097 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1098 | action->addTo( helpMenu ); | 1098 | action->addTo( helpMenu ); |
1099 | connect( action, SIGNAL( activated() ), | 1099 | connect( action, SIGNAL( activated() ), |
1100 | SLOT( keyBindings() ) ); | 1100 | SLOT( keyBindings() ) ); |
1101 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); | 1101 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); |
1102 | action->addTo( helpMenu ); | 1102 | action->addTo( helpMenu ); |
1103 | connect( action, SIGNAL( activated() ), | 1103 | connect( action, SIGNAL( activated() ), |
1104 | SLOT( storagehowto() ) ); | 1104 | SLOT( storagehowto() ) ); |
1105 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); | 1105 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); |
1106 | action->addTo( helpMenu ); | 1106 | action->addTo( helpMenu ); |
1107 | connect( action, SIGNAL( activated() ), | 1107 | connect( action, SIGNAL( activated() ), |
1108 | SLOT( timetrackinghowto() ) ); | 1108 | SLOT( timetrackinghowto() ) ); |
1109 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1109 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1110 | action->addTo( helpMenu ); | 1110 | action->addTo( helpMenu ); |
1111 | connect( action, SIGNAL( activated() ), | 1111 | connect( action, SIGNAL( activated() ), |
1112 | SLOT( synchowto() ) ); | 1112 | SLOT( synchowto() ) ); |
1113 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1113 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1114 | action->addTo( helpMenu ); | 1114 | action->addTo( helpMenu ); |
1115 | connect( action, SIGNAL( activated() ), | 1115 | connect( action, SIGNAL( activated() ), |
1116 | SLOT( kdesynchowto() ) ); | 1116 | SLOT( kdesynchowto() ) ); |
1117 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1117 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1118 | action->addTo( helpMenu ); | 1118 | action->addTo( helpMenu ); |
1119 | connect( action, SIGNAL( activated() ), | 1119 | connect( action, SIGNAL( activated() ), |
1120 | SLOT( multisynchowto() ) ); | 1120 | SLOT( multisynchowto() ) ); |
1121 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1121 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1122 | action->addTo( helpMenu ); | 1122 | action->addTo( helpMenu ); |
1123 | connect( action, SIGNAL( activated() ), | 1123 | connect( action, SIGNAL( activated() ), |
1124 | SLOT( aboutAutoSaving() ) ); | 1124 | SLOT( aboutAutoSaving() ) ); |
1125 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1125 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1126 | action->addTo( helpMenu ); | 1126 | action->addTo( helpMenu ); |
1127 | connect( action, SIGNAL( activated() ), | 1127 | connect( action, SIGNAL( activated() ), |
1128 | SLOT( aboutKnownBugs() ) ); | 1128 | SLOT( aboutKnownBugs() ) ); |
1129 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1129 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1130 | action->addTo( helpMenu ); | 1130 | action->addTo( helpMenu ); |
1131 | connect( action, SIGNAL( activated() ), | 1131 | connect( action, SIGNAL( activated() ), |
1132 | SLOT( usertrans() ) ); | 1132 | SLOT( usertrans() ) ); |
1133 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1133 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1134 | action->addTo( helpMenu ); | 1134 | action->addTo( helpMenu ); |
1135 | connect( action, SIGNAL( activated() ), | 1135 | connect( action, SIGNAL( activated() ), |
1136 | SLOT( faq() ) ); | 1136 | SLOT( faq() ) ); |
1137 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1137 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1138 | action->addTo( helpMenu ); | 1138 | action->addTo( helpMenu ); |
1139 | connect( action, SIGNAL( activated() ), | 1139 | connect( action, SIGNAL( activated() ), |
1140 | SLOT( licence() ) ); | 1140 | SLOT( licence() ) ); |
1141 | action = new QAction( "about", i18n("About..."), 0, this ); | 1141 | action = new QAction( "about", i18n("About..."), 0, this ); |
1142 | action->addTo( helpMenu ); | 1142 | action->addTo( helpMenu ); |
1143 | connect( action, SIGNAL( activated() ), | 1143 | connect( action, SIGNAL( activated() ), |
1144 | SLOT( about() ) ); | 1144 | SLOT( about() ) ); |
1145 | //menuBar->insertSeparator(); | 1145 | //menuBar->insertSeparator(); |
1146 | 1146 | ||
1147 | // ****************************************************** | 1147 | // ****************************************************** |
1148 | // menubar icons | 1148 | // menubar icons |
1149 | 1149 | ||
1150 | 1150 | ||
1151 | 1151 | ||
1152 | //menuBar->insertItem( iconToolBar ); | 1152 | //menuBar->insertItem( iconToolBar ); |
1153 | //xdays_action | 1153 | //xdays_action |
1154 | if (p-> mShowIconNewEvent) | 1154 | if (p-> mShowIconNewEvent) |
1155 | ne_action->addTo( iconToolBar ); | 1155 | ne_action->addTo( iconToolBar ); |
1156 | if (p->mShowIconNewTodo ) | 1156 | if (p->mShowIconNewTodo ) |
1157 | nt_action->addTo( iconToolBar ); | 1157 | nt_action->addTo( iconToolBar ); |
1158 | if (p-> mShowIconSearch) | 1158 | if (p-> mShowIconSearch) |
1159 | search_action->addTo( iconToolBar ); | 1159 | search_action->addTo( iconToolBar ); |
1160 | if (p-> mShowIconWhatsThis) | 1160 | if (p-> mShowIconWhatsThis) |
1161 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1161 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1162 | if (p-> mShowIconNext) | 1162 | if (p-> mShowIconNext) |
1163 | whatsnext_action->addTo( viewToolBar ); | 1163 | whatsnext_action->addTo( viewToolBar ); |
1164 | if (p-> mShowIconNextDays) | 1164 | if (p-> mShowIconNextDays) |
1165 | xdays_action->addTo( viewToolBar ); | 1165 | xdays_action->addTo( viewToolBar ); |
1166 | if (p-> mShowIconJournal) | 1166 | if (p-> mShowIconJournal) |
1167 | viewjournal_action->addTo( viewToolBar ); | 1167 | viewjournal_action->addTo( viewToolBar ); |
1168 | if (p-> mShowIconDay1) | 1168 | if (p-> mShowIconDay1) |
1169 | day1_action->addTo( viewToolBar ); | 1169 | day1_action->addTo( viewToolBar ); |
1170 | if (p-> mShowIconDay5) | 1170 | if (p-> mShowIconDay5) |
1171 | day5_action->addTo( viewToolBar ); | 1171 | day5_action->addTo( viewToolBar ); |
1172 | if (p-> mShowIconDay7) | 1172 | if (p-> mShowIconDay7) |
1173 | day7_action->addTo( viewToolBar ); | 1173 | day7_action->addTo( viewToolBar ); |
1174 | if (p-> mShowIconDay6) | 1174 | if (p-> mShowIconDay6) |
1175 | day6_action->addTo( viewToolBar ); | 1175 | day6_action->addTo( viewToolBar ); |
1176 | if (p-> mShowIconMonth) | 1176 | if (p-> mShowIconMonth) |
1177 | month_action->addTo( viewToolBar ); | 1177 | month_action->addTo( viewToolBar ); |
1178 | if (p-> mShowIconList) | 1178 | if (p-> mShowIconList) |
1179 | showlist_action->addTo( viewToolBar ); | 1179 | showlist_action->addTo( viewToolBar ); |
1180 | if (p-> mShowIconTodoview) | 1180 | if (p-> mShowIconTodoview) |
1181 | todoview_action->addTo( viewToolBar ); | 1181 | todoview_action->addTo( viewToolBar ); |
1182 | 1182 | ||
1183 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1183 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1184 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1184 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1185 | if (p-> mShowIconBackFast) { | 1185 | if (p-> mShowIconBackFast) { |
1186 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1186 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1187 | connect( action, SIGNAL( activated() ), | 1187 | connect( action, SIGNAL( activated() ), |
1188 | mView, SLOT( goPreviousMonth() ) ); | 1188 | mView, SLOT( goPreviousMonth() ) ); |
1189 | action->addTo( navigatorToolBar ); | 1189 | action->addTo( navigatorToolBar ); |
1190 | } | 1190 | } |
1191 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1191 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1192 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1192 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1193 | if (p-> mShowIconBack) { | 1193 | if (p-> mShowIconBack) { |
1194 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1194 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1195 | connect( action, SIGNAL( activated() ), | 1195 | connect( action, SIGNAL( activated() ), |
1196 | mView, SLOT( goPrevious() ) ); | 1196 | mView, SLOT( goPrevious() ) ); |
1197 | action->addTo( navigatorToolBar ); | 1197 | action->addTo( navigatorToolBar ); |
1198 | } | 1198 | } |
1199 | icon = loadPixmap( pathString + "today" ); | 1199 | icon = loadPixmap( pathString + "today" ); |
1200 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1200 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1201 | if (p-> mShowIconToday) | 1201 | if (p-> mShowIconToday) |
1202 | today_action->addTo( navigatorToolBar ); | 1202 | today_action->addTo( navigatorToolBar ); |
1203 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1203 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1204 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1204 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1205 | if (p-> mShowIconForward) { | 1205 | if (p-> mShowIconForward) { |
1206 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1206 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1207 | connect( action, SIGNAL( activated() ), | 1207 | connect( action, SIGNAL( activated() ), |
1208 | mView, SLOT( goNext() ) ); | 1208 | mView, SLOT( goNext() ) ); |
1209 | action->addTo( navigatorToolBar ); | 1209 | action->addTo( navigatorToolBar ); |
1210 | } | 1210 | } |
1211 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1211 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1212 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1212 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1213 | if (p-> mShowIconForwardFast) { | 1213 | if (p-> mShowIconForwardFast) { |
1214 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1214 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1215 | connect( action, SIGNAL( activated() ), | 1215 | connect( action, SIGNAL( activated() ), |
1216 | mView, SLOT( goNextMonth() ) ); | 1216 | mView, SLOT( goNextMonth() ) ); |
1217 | action->addTo( navigatorToolBar ); | 1217 | action->addTo( navigatorToolBar ); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | 1220 | ||
1221 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1221 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1222 | 1222 | ||
1223 | 1223 | ||
1224 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); | 1224 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); |
1225 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); | 1225 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); |
1226 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); | 1226 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); |
1227 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); | 1227 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); |
1228 | 1228 | ||
1229 | if (p-> mShowIconNewEvent) | 1229 | if (p-> mShowIconNewEvent) |
1230 | configureToolBarMenu->setItemChecked( 10, true ); | 1230 | configureToolBarMenu->setItemChecked( 10, true ); |
1231 | if (p->mShowIconNewTodo ) | 1231 | if (p->mShowIconNewTodo ) |
1232 | configureToolBarMenu->setItemChecked( 20, true ); | 1232 | configureToolBarMenu->setItemChecked( 20, true ); |
1233 | if (p-> mShowIconSearch) | 1233 | if (p-> mShowIconSearch) |
1234 | configureToolBarMenu->setItemChecked( 120, true ); | 1234 | configureToolBarMenu->setItemChecked( 120, true ); |
1235 | if (p-> mShowIconList) | 1235 | if (p-> mShowIconList) |
1236 | configureToolBarMenu->setItemChecked( 30, true ); | 1236 | configureToolBarMenu->setItemChecked( 30, true ); |
1237 | if (p-> mShowIconDay1) | 1237 | if (p-> mShowIconDay1) |
1238 | configureToolBarMenu->setItemChecked( 40, true ); | 1238 | configureToolBarMenu->setItemChecked( 40, true ); |
1239 | if (p-> mShowIconDay5) | 1239 | if (p-> mShowIconDay5) |
1240 | configureToolBarMenu->setItemChecked( 50, true ); | 1240 | configureToolBarMenu->setItemChecked( 50, true ); |
1241 | if (p-> mShowIconDay6) | 1241 | if (p-> mShowIconDay6) |
1242 | configureToolBarMenu->setItemChecked( 75, true ); | 1242 | configureToolBarMenu->setItemChecked( 75, true ); |
1243 | if (p-> mShowIconDay7) | 1243 | if (p-> mShowIconDay7) |
1244 | configureToolBarMenu->setItemChecked( 60, true ); | 1244 | configureToolBarMenu->setItemChecked( 60, true ); |
1245 | if (p-> mShowIconMonth) | 1245 | if (p-> mShowIconMonth) |
1246 | configureToolBarMenu->setItemChecked( 70, true ); | 1246 | configureToolBarMenu->setItemChecked( 70, true ); |
1247 | if (p-> mShowIconTodoview) | 1247 | if (p-> mShowIconTodoview) |
1248 | configureToolBarMenu->setItemChecked( 80, true ); | 1248 | configureToolBarMenu->setItemChecked( 80, true ); |
1249 | if (p-> mShowIconBackFast) | 1249 | if (p-> mShowIconBackFast) |
1250 | configureToolBarMenu->setItemChecked( 200, true ); | 1250 | configureToolBarMenu->setItemChecked( 200, true ); |
1251 | if (p-> mShowIconBack) | 1251 | if (p-> mShowIconBack) |
1252 | configureToolBarMenu->setItemChecked( 210, true ); | 1252 | configureToolBarMenu->setItemChecked( 210, true ); |
1253 | if (p-> mShowIconToday) | 1253 | if (p-> mShowIconToday) |
1254 | configureToolBarMenu->setItemChecked( 130, true ); | 1254 | configureToolBarMenu->setItemChecked( 130, true ); |
1255 | if (p-> mShowIconForward) | 1255 | if (p-> mShowIconForward) |
1256 | configureToolBarMenu->setItemChecked( 220, true ); | 1256 | configureToolBarMenu->setItemChecked( 220, true ); |
1257 | if (p-> mShowIconForwardFast) | 1257 | if (p-> mShowIconForwardFast) |
1258 | configureToolBarMenu->setItemChecked( 230, true ); | 1258 | configureToolBarMenu->setItemChecked( 230, true ); |
1259 | if (p-> mShowIconNextDays) | 1259 | if (p-> mShowIconNextDays) |
1260 | configureToolBarMenu->setItemChecked( 100, true ); | 1260 | configureToolBarMenu->setItemChecked( 100, true ); |
1261 | if (p-> mShowIconNext) | 1261 | if (p-> mShowIconNext) |
1262 | configureToolBarMenu->setItemChecked( 110, true ); | 1262 | configureToolBarMenu->setItemChecked( 110, true ); |
1263 | if (p-> mShowIconJournal) | 1263 | if (p-> mShowIconJournal) |
1264 | configureToolBarMenu->setItemChecked( 90, true ); | 1264 | configureToolBarMenu->setItemChecked( 90, true ); |
1265 | if (p-> mShowIconWhatsThis) | 1265 | if (p-> mShowIconWhatsThis) |
1266 | configureToolBarMenu->setItemChecked( 300, true ); | 1266 | configureToolBarMenu->setItemChecked( 300, true ); |
1267 | if (p-> mShowIconWeekNum) | 1267 | if (p-> mShowIconWeekNum) |
1268 | configureToolBarMenu->setItemChecked( 400, true ); | 1268 | configureToolBarMenu->setItemChecked( 400, true ); |
1269 | if (!p-> mShowIconStretch) { | 1269 | if (!p-> mShowIconStretch) { |
1270 | QLabel* dummy = new QLabel( iconToolBar ); | 1270 | QLabel* dummy = new QLabel( iconToolBar ); |
1271 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1271 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1272 | dummy->setMinimumWidth( 0 ); | 1272 | dummy->setMinimumWidth( 0 ); |
1273 | iconToolBar->setStretchableWidget ( dummy ) ; | 1273 | iconToolBar->setStretchableWidget ( dummy ) ; |
1274 | } | 1274 | } |
1275 | else { | 1275 | else { |
1276 | iconToolBar->setHorizontalStretchable (true ); | 1276 | iconToolBar->setHorizontalStretchable (true ); |
1277 | viewToolBar->setHorizontalStretchable (true ); | 1277 | viewToolBar->setHorizontalStretchable (true ); |
1278 | navigatorToolBar->setHorizontalStretchable (true ); | 1278 | navigatorToolBar->setHorizontalStretchable (true ); |
1279 | iconToolBar->setVerticalStretchable (true ); | 1279 | iconToolBar->setVerticalStretchable (true ); |
1280 | viewToolBar->setVerticalStretchable (true ); | 1280 | viewToolBar->setVerticalStretchable (true ); |
1281 | navigatorToolBar->setVerticalStretchable (true ); | 1281 | navigatorToolBar->setVerticalStretchable (true ); |
1282 | configureToolBarMenu->setItemChecked( 5, true ); | 1282 | configureToolBarMenu->setItemChecked( 5, true ); |
1283 | } | 1283 | } |
1284 | if (p-> mShowIconFilter) | 1284 | if (p-> mShowIconFilter) |
1285 | configureToolBarMenu->setItemChecked( 7, true ); | 1285 | configureToolBarMenu->setItemChecked( 7, true ); |
1286 | if (p-> mShowIconOnetoolbar) | 1286 | if (p-> mShowIconOnetoolbar) |
1287 | configureToolBarMenu->setItemChecked( 6, true ); | 1287 | configureToolBarMenu->setItemChecked( 6, true ); |
1288 | 1288 | ||
1289 | 1289 | ||
1290 | if ( filterMenubar ) { | 1290 | if ( filterMenubar ) { |
1291 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); | 1291 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); |
1292 | connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); | 1292 | connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); |
1293 | } | 1293 | } |
1294 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1294 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1295 | configureAgenda( p->mHourSize ); | 1295 | configureAgenda( p->mHourSize ); |
1296 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1296 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | void MainWindow::exportToPhone( int mode ) | 1299 | void MainWindow::exportToPhone( int mode ) |
1300 | { | 1300 | { |
1301 | 1301 | ||
1302 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1302 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1303 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1303 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1304 | KOex2phonePrefs ex2phone; | 1304 | KOex2phonePrefs ex2phone; |
1305 | 1305 | ||
1306 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1306 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1307 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1307 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1308 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1308 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1309 | if ( mode == 1 ) | 1309 | if ( mode == 1 ) |
1310 | ex2phone.setCaption(i18n("Export complete calendar")); | 1310 | ex2phone.setCaption(i18n("Export complete calendar")); |
1311 | if ( mode == 2 ) | 1311 | if ( mode == 2 ) |
1312 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1312 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1313 | 1313 | ||
1314 | if ( !ex2phone.exec() ) { | 1314 | if ( !ex2phone.exec() ) { |
1315 | return; | 1315 | return; |
1316 | } | 1316 | } |
1317 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1317 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1318 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1318 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1319 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1319 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1320 | 1320 | ||
1321 | int inFuture = 0; | 1321 | int inFuture = 0; |
1322 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1322 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1323 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1323 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1324 | QPtrList<Incidence> delSel; | 1324 | QPtrList<Incidence> delSel; |
1325 | if ( mode == 1 ) | 1325 | if ( mode == 1 ) |
1326 | delSel = mCalendar->rawIncidences(); | 1326 | delSel = mCalendar->rawIncidences(); |
1327 | if ( mode == 2 ) | 1327 | if ( mode == 2 ) |
1328 | delSel = mCalendar->incidences(); | 1328 | delSel = mCalendar->incidences(); |
1329 | CalendarLocal* cal = new CalendarLocal(); | 1329 | CalendarLocal* cal = new CalendarLocal(); |
1330 | cal->setLocalTime(); | 1330 | cal->setLocalTime(); |
1331 | Incidence *incidence = delSel.first(); | 1331 | Incidence *incidence = delSel.first(); |
1332 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1332 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1333 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1333 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1334 | while ( incidence ) { | 1334 | while ( incidence ) { |
1335 | if ( incidence->type() != "Journal" ) { | 1335 | if ( incidence->typeID() != journalID ) { |
1336 | bool add = true; | 1336 | bool add = true; |
1337 | if ( inFuture ) { | 1337 | if ( inFuture ) { |
1338 | QDateTime dt; | 1338 | QDateTime dt; |
1339 | if ( incidence->type() == "Todo" ) { | 1339 | if ( incidence->typeID() == todoID ) { |
1340 | Todo * t = (Todo*)incidence; | 1340 | Todo * t = (Todo*)incidence; |
1341 | if ( t->hasDueDate() ) | 1341 | if ( t->hasDueDate() ) |
1342 | dt = t->dtDue(); | 1342 | dt = t->dtDue(); |
1343 | else | 1343 | else |
1344 | dt = cur.addSecs( 62 ); | 1344 | dt = cur.addSecs( 62 ); |
1345 | } | 1345 | } |
1346 | else { | 1346 | else { |
1347 | bool ok; | 1347 | bool ok; |
1348 | dt = incidence->getNextOccurence( cur, &ok ); | 1348 | dt = incidence->getNextOccurence( cur, &ok ); |
1349 | if ( !ok ) | 1349 | if ( !ok ) |
1350 | dt = cur.addSecs( -62 ); | 1350 | dt = cur.addSecs( -62 ); |
1351 | } | 1351 | } |
1352 | if ( dt < cur || dt > end ) { | 1352 | if ( dt < cur || dt > end ) { |
1353 | add = false; | 1353 | add = false; |
1354 | } | 1354 | } |
1355 | } | 1355 | } |
1356 | if ( add ) { | 1356 | if ( add ) { |
1357 | Incidence *in = incidence->clone(); | 1357 | Incidence *in = incidence->clone(); |
1358 | cal->addIncidence( in ); | 1358 | cal->addIncidence( in ); |
1359 | } | 1359 | } |
1360 | } | 1360 | } |
1361 | incidence = delSel.next(); | 1361 | incidence = delSel.next(); |
1362 | } | 1362 | } |
1363 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1363 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1364 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1364 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1365 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1365 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1366 | 1366 | ||
1367 | setCaption( i18n("Writing to phone...")); | 1367 | setCaption( i18n("Writing to phone...")); |
1368 | if ( PhoneFormat::writeToPhone( cal ) ) | 1368 | if ( PhoneFormat::writeToPhone( cal ) ) |
1369 | setCaption( i18n("Export to phone successful!")); | 1369 | setCaption( i18n("Export to phone successful!")); |
1370 | else | 1370 | else |
1371 | setCaption( i18n("Error exporting to phone!")); | 1371 | setCaption( i18n("Error exporting to phone!")); |
1372 | delete cal; | 1372 | delete cal; |
1373 | } | 1373 | } |
1374 | 1374 | ||
1375 | 1375 | ||
1376 | void MainWindow::setDefaultPreferences() | 1376 | void MainWindow::setDefaultPreferences() |
1377 | { | 1377 | { |
1378 | KOPrefs *p = KOPrefs::instance(); | 1378 | KOPrefs *p = KOPrefs::instance(); |
1379 | 1379 | ||
1380 | p->mCompactDialogs = true; | 1380 | p->mCompactDialogs = true; |
1381 | p->mConfirm = true; | 1381 | p->mConfirm = true; |
1382 | // p->mEnableQuickTodo = false; | 1382 | // p->mEnableQuickTodo = false; |
1383 | 1383 | ||
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | QString MainWindow::resourcePath() | 1386 | QString MainWindow::resourcePath() |
1387 | { | 1387 | { |
1388 | return KGlobal::iconLoader()->iconPath(); | 1388 | return KGlobal::iconLoader()->iconPath(); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | void MainWindow::displayText( QString text ,QString cap ) | 1391 | void MainWindow::displayText( QString text ,QString cap ) |
1392 | { | 1392 | { |
1393 | QDialog dia( this, "name", true ); ; | 1393 | QDialog dia( this, "name", true ); ; |
1394 | dia.setCaption( cap ); | 1394 | dia.setCaption( cap ); |
1395 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1395 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1396 | lay->setSpacing( 3 ); | 1396 | lay->setSpacing( 3 ); |
1397 | lay->setMargin( 3 ); | 1397 | lay->setMargin( 3 ); |
1398 | QTextBrowser tb ( &dia ); | 1398 | QTextBrowser tb ( &dia ); |
1399 | lay->addWidget( &tb ); | 1399 | lay->addWidget( &tb ); |
1400 | tb.setText( text ); | 1400 | tb.setText( text ); |
1401 | #ifdef DESKTOP_VERSION | 1401 | #ifdef DESKTOP_VERSION |
1402 | dia.resize( 640, 480); | 1402 | dia.resize( 640, 480); |
1403 | #else | 1403 | #else |
1404 | dia.showMaximized(); | 1404 | dia.showMaximized(); |
1405 | #endif | 1405 | #endif |
1406 | dia.exec(); | 1406 | dia.exec(); |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | void MainWindow::features() | 1409 | void MainWindow::features() |
1410 | { | 1410 | { |
1411 | 1411 | ||
1412 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1412 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | void MainWindow::usertrans() | 1415 | void MainWindow::usertrans() |
1416 | { | 1416 | { |
1417 | 1417 | ||
1418 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1418 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | void MainWindow::storagehowto() | 1421 | void MainWindow::storagehowto() |
1422 | { | 1422 | { |
1423 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 1423 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
1424 | } | 1424 | } |
1425 | void MainWindow::timetrackinghowto() | 1425 | void MainWindow::timetrackinghowto() |
1426 | { | 1426 | { |
1427 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); | 1427 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); |
1428 | } | 1428 | } |
1429 | void MainWindow::kdesynchowto() | 1429 | void MainWindow::kdesynchowto() |
1430 | { | 1430 | { |
1431 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1431 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1432 | } | 1432 | } |
1433 | void MainWindow::multisynchowto() | 1433 | void MainWindow::multisynchowto() |
1434 | { | 1434 | { |
1435 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1435 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1436 | } | 1436 | } |
1437 | void MainWindow::synchowto() | 1437 | void MainWindow::synchowto() |
1438 | { | 1438 | { |
1439 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1439 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1440 | } | 1440 | } |
1441 | void MainWindow::faq() | 1441 | void MainWindow::faq() |
1442 | { | 1442 | { |
1443 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1443 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1444 | 1444 | ||
1445 | } | 1445 | } |
1446 | void MainWindow::whatsNew() | 1446 | void MainWindow::whatsNew() |
1447 | { | 1447 | { |
1448 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1448 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1449 | 1449 | ||
1450 | } | 1450 | } |
1451 | void MainWindow::licence() | 1451 | void MainWindow::licence() |
1452 | { | 1452 | { |
1453 | KApplication::showLicence(); | 1453 | KApplication::showLicence(); |
1454 | 1454 | ||
1455 | } | 1455 | } |
1456 | void MainWindow::about() | 1456 | void MainWindow::about() |
1457 | { | 1457 | { |
1458 | QString version; | 1458 | QString version; |
1459 | #include <../version> | 1459 | #include <../version> |
1460 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1460 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1461 | i18n("KOrganizer/Platform-independent\n") + | 1461 | i18n("KOrganizer/Platform-independent\n") + |
1462 | "(KO/Pi) " + version + " - " + | 1462 | "(KO/Pi) " + version + " - " + |
1463 | 1463 | ||
1464 | #ifdef DESKTOP_VERSION | 1464 | #ifdef DESKTOP_VERSION |
1465 | i18n("Desktop Edition\n") + | 1465 | i18n("Desktop Edition\n") + |
1466 | #else | 1466 | #else |
1467 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1467 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1468 | #endif | 1468 | #endif |
1469 | 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!") ); | 1469 | 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!") ); |
1470 | } | 1470 | } |
1471 | void MainWindow::keyBindings() | 1471 | void MainWindow::keyBindings() |
1472 | { | 1472 | { |
1473 | QString cap = i18n("KO/Pi Keys + Colors"); | 1473 | QString cap = i18n("KO/Pi Keys + Colors"); |
1474 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1474 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1475 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1475 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1476 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1476 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1477 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1477 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1478 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1478 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1479 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1479 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1480 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1480 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1481 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1481 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1482 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1482 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1483 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1483 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
1484 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1484 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1485 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1485 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1486 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1486 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1487 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1487 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1488 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1488 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1489 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1489 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1490 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ | 1490 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ |
1491 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1491 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1492 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1492 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1493 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1493 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1494 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1494 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1495 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1495 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1496 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1496 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1497 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1497 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1498 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1498 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1499 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1499 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1500 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1500 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1501 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1501 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1502 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1502 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1503 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1503 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1504 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1504 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1505 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1505 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1506 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1506 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1507 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1507 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1508 | i18n("<p><h3>In list view:</h3></p>\n") + | 1508 | i18n("<p><h3>In list view:</h3></p>\n") + |
1509 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1509 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1510 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1510 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1511 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1511 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1512 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1512 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1513 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1513 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1514 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1514 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1515 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1515 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1516 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1516 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1517 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1517 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1518 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1518 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1519 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1519 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1520 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1520 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1521 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1521 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1522 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1522 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1523 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1523 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1524 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1524 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1525 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1525 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1526 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1526 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1527 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1527 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1528 | displayText( text, cap); | 1528 | displayText( text, cap); |
1529 | } | 1529 | } |
1530 | void MainWindow::aboutAutoSaving() | 1530 | void MainWindow::aboutAutoSaving() |
1531 | { | 1531 | { |
1532 | 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"); | 1532 | 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"); |
1533 | 1533 | ||
1534 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1534 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1535 | 1535 | ||
1536 | } | 1536 | } |
1537 | void MainWindow::aboutKnownBugs() | 1537 | void MainWindow::aboutKnownBugs() |
1538 | { | 1538 | { |
1539 | QMessageBox* msg; | 1539 | QMessageBox* msg; |
1540 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1540 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1541 | 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")+ | 1541 | 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")+ |
1542 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1542 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1543 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1543 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1544 | i18n("\nor report them in the bugtracker on\n") + | 1544 | i18n("\nor report them in the bugtracker on\n") + |
1545 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1545 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1546 | QMessageBox::NoIcon, | 1546 | QMessageBox::NoIcon, |
1547 | QMessageBox::Ok, | 1547 | QMessageBox::Ok, |
1548 | QMessageBox::NoButton, | 1548 | QMessageBox::NoButton, |
1549 | QMessageBox::NoButton); | 1549 | QMessageBox::NoButton); |
1550 | msg->exec(); | 1550 | msg->exec(); |
1551 | delete msg; | 1551 | delete msg; |
1552 | 1552 | ||
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | QString MainWindow::defaultFileName() | 1555 | QString MainWindow::defaultFileName() |
1556 | { | 1556 | { |
1557 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1557 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1558 | } | 1558 | } |
1559 | QString MainWindow::syncFileName() | 1559 | QString MainWindow::syncFileName() |
1560 | { | 1560 | { |
1561 | #ifdef DESKTOP_VERSION | 1561 | #ifdef DESKTOP_VERSION |
1562 | return locateLocal( "tmp", "synccalendar.ics" ); | 1562 | return locateLocal( "tmp", "synccalendar.ics" ); |
1563 | #else | 1563 | #else |
1564 | return QString( "/tmp/synccalendar.ics" ); | 1564 | return QString( "/tmp/synccalendar.ics" ); |
1565 | #endif | 1565 | #endif |
1566 | } | 1566 | } |
1567 | #include "koglobals.h" | 1567 | #include "koglobals.h" |
1568 | #include <kcalendarsystem.h> | 1568 | #include <kcalendarsystem.h> |
1569 | void MainWindow::updateWeek(QDate seda) | 1569 | void MainWindow::updateWeek(QDate seda) |
1570 | { | 1570 | { |
1571 | int weekNum = KGlobal::locale()->weekNum ( seda ); | 1571 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1572 | mWeekPixmap.fill( mWeekBgColor ); | 1572 | mWeekPixmap.fill( mWeekBgColor ); |
1573 | QPainter p ( &mWeekPixmap ); | 1573 | QPainter p ( &mWeekPixmap ); |
1574 | p.setFont( mWeekFont ); | 1574 | p.setFont( mWeekFont ); |
1575 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1575 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1576 | p.end(); | 1576 | p.end(); |
1577 | QIconSet icon3 ( mWeekPixmap ); | 1577 | QIconSet icon3 ( mWeekPixmap ); |
1578 | mWeekAction->setIconSet ( icon3 ); | 1578 | mWeekAction->setIconSet ( icon3 ); |
1579 | 1579 | ||
1580 | } | 1580 | } |
1581 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1581 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1582 | { | 1582 | { |
1583 | updateWeek( selectedDates.first() ); | 1583 | updateWeek( selectedDates.first() ); |
1584 | } | 1584 | } |
1585 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1585 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1586 | { | 1586 | { |
1587 | 1587 | ||
1588 | if ( !incidence ) { | 1588 | if ( !incidence ) { |
1589 | enableIncidenceActions( false ); | 1589 | enableIncidenceActions( false ); |
1590 | 1590 | ||
1591 | mNewSubTodoAction->setEnabled( false ); | 1591 | mNewSubTodoAction->setEnabled( false ); |
1592 | setCaptionToDates(); | 1592 | setCaptionToDates(); |
1593 | return; | 1593 | return; |
1594 | 1594 | ||
1595 | } | 1595 | } |
1596 | 1596 | ||
1597 | //KGlobal::locale()->formatDateTime(nextA, true); | 1597 | //KGlobal::locale()->formatDateTime(nextA, true); |
1598 | QString startString = ""; | 1598 | QString startString = ""; |
1599 | if ( incidence->type() != "Todo" ) { | 1599 | if ( incidence->typeID() != todoID ) { |
1600 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1600 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1601 | if ( incidence->doesFloat() ) { | 1601 | if ( incidence->doesFloat() ) { |
1602 | startString += ": "+incidence->dtStartDateStr( true ); | 1602 | startString += ": "+incidence->dtStartDateStr( true ); |
1603 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1603 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1604 | 1604 | ||
1605 | } else { | 1605 | } else { |
1606 | startString = ": "+incidence->dtStartStr(true); | 1606 | startString = ": "+incidence->dtStartStr(true); |
1607 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1607 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1608 | 1608 | ||
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | } else { | 1611 | } else { |
1612 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1612 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1613 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1613 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1614 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1614 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1615 | 1615 | ||
1616 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { | 1616 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { |
1617 | bool ok; | 1617 | bool ok; |
1618 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1618 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1619 | if ( ok ) { | 1619 | if ( ok ) { |
1620 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1620 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1621 | startString += i18n(" (%1 y.)"). arg( years ); | 1621 | startString += i18n(" (%1 y.)"). arg( years ); |
1622 | } | 1622 | } |
1623 | } | 1623 | } |
1624 | else | 1624 | else |
1625 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1625 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | } | 1628 | } |
1629 | else | 1629 | else |
1630 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1630 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1631 | if ( !incidence->location().isEmpty() ) | 1631 | if ( !incidence->location().isEmpty() ) |
1632 | startString += " (" +incidence->location()+")"; | 1632 | startString += " (" +incidence->location()+")"; |
1633 | setCaption( incidence->summary()+startString); | 1633 | setCaption( incidence->summary()+startString); |
1634 | 1634 | ||
1635 | enableIncidenceActions( true ); | 1635 | enableIncidenceActions( true ); |
1636 | 1636 | ||
1637 | if ( incidence->type() == "Event" ) { | 1637 | if ( incidence->typeID() == eventID ) { |
1638 | mShowAction->setText( i18n("Show Event...") ); | 1638 | mShowAction->setText( i18n("Show Event...") ); |
1639 | mEditAction->setText( i18n("Edit Event...") ); | 1639 | mEditAction->setText( i18n("Edit Event...") ); |
1640 | mDeleteAction->setText( i18n("Delete Event...") ); | 1640 | mDeleteAction->setText( i18n("Delete Event...") ); |
1641 | 1641 | ||
1642 | mNewSubTodoAction->setEnabled( false ); | 1642 | mNewSubTodoAction->setEnabled( false ); |
1643 | } else if ( incidence->type() == "Todo" ) { | 1643 | } else if ( incidence->typeID() == todoID ) { |
1644 | mShowAction->setText( i18n("Show Todo...") ); | 1644 | mShowAction->setText( i18n("Show Todo...") ); |
1645 | mEditAction->setText( i18n("Edit Todo...") ); | 1645 | mEditAction->setText( i18n("Edit Todo...") ); |
1646 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1646 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1647 | 1647 | ||
1648 | mNewSubTodoAction->setEnabled( true ); | 1648 | mNewSubTodoAction->setEnabled( true ); |
1649 | } else { | 1649 | } else { |
1650 | mShowAction->setText( i18n("Show...") ); | 1650 | mShowAction->setText( i18n("Show...") ); |
1651 | mShowAction->setText( i18n("Edit...") ); | 1651 | mShowAction->setText( i18n("Edit...") ); |
1652 | mShowAction->setText( i18n("Delete...") ); | 1652 | mShowAction->setText( i18n("Delete...") ); |
1653 | 1653 | ||
1654 | mNewSubTodoAction->setEnabled( false ); | 1654 | mNewSubTodoAction->setEnabled( false ); |
1655 | } | 1655 | } |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | void MainWindow::enableIncidenceActions( bool enabled ) | 1658 | void MainWindow::enableIncidenceActions( bool enabled ) |
1659 | { | 1659 | { |
1660 | mShowAction->setEnabled( enabled ); | 1660 | mShowAction->setEnabled( enabled ); |
1661 | mEditAction->setEnabled( enabled ); | 1661 | mEditAction->setEnabled( enabled ); |
1662 | mDeleteAction->setEnabled( enabled ); | 1662 | mDeleteAction->setEnabled( enabled ); |
1663 | 1663 | ||
1664 | mCloneAction->setEnabled( enabled ); | 1664 | mCloneAction->setEnabled( enabled ); |
1665 | mMoveAction->setEnabled( enabled ); | 1665 | mMoveAction->setEnabled( enabled ); |
1666 | mBeamAction->setEnabled( enabled ); | 1666 | mBeamAction->setEnabled( enabled ); |
1667 | mCancelAction->setEnabled( enabled ); | 1667 | mCancelAction->setEnabled( enabled ); |
1668 | } | 1668 | } |
1669 | 1669 | ||
1670 | void MainWindow::importOL() | 1670 | void MainWindow::importOL() |
1671 | { | 1671 | { |
1672 | #ifdef _OL_IMPORT_ | 1672 | #ifdef _OL_IMPORT_ |
1673 | mView->clearAllViews(); | 1673 | mView->clearAllViews(); |
1674 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1674 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1675 | id->exec(); | 1675 | id->exec(); |
1676 | delete id; | 1676 | delete id; |
1677 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1677 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1678 | mView->updateView(); | 1678 | mView->updateView(); |
1679 | #endif | 1679 | #endif |
1680 | } | 1680 | } |
1681 | void MainWindow::importBday() | 1681 | void MainWindow::importBday() |
1682 | { | 1682 | { |
1683 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1683 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1684 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1684 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1685 | i18n("Import!"), i18n("Cancel"), 0, | 1685 | i18n("Import!"), i18n("Cancel"), 0, |
1686 | 0, 1 ); | 1686 | 0, 1 ); |
1687 | if ( result == 0 ) { | 1687 | if ( result == 0 ) { |
1688 | mView->importBday(); | 1688 | mView->importBday(); |
1689 | 1689 | ||
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | 1692 | ||
1693 | } | 1693 | } |
1694 | void MainWindow::importQtopia() | 1694 | void MainWindow::importQtopia() |
1695 | { | 1695 | { |
1696 | //#ifndef DESKTOP_VERSION | 1696 | //#ifndef DESKTOP_VERSION |
1697 | 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"); | 1697 | 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"); |
1698 | #ifdef DESKTOP_VERSION | 1698 | #ifdef DESKTOP_VERSION |
1699 | 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"); | 1699 | 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"); |
1700 | #endif | 1700 | #endif |
1701 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1701 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1702 | i18n("Import!"), i18n("Cancel"), 0, | 1702 | i18n("Import!"), i18n("Cancel"), 0, |
1703 | 0, 1 ); | 1703 | 0, 1 ); |
1704 | if ( result == 0 ) { | 1704 | if ( result == 0 ) { |
1705 | #ifndef DESKTOP_VERSION | 1705 | #ifndef DESKTOP_VERSION |
1706 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1706 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1707 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1707 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1708 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1708 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1709 | #else | 1709 | #else |
1710 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1710 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1711 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1711 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1712 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1712 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1713 | #endif | 1713 | #endif |
1714 | mView->importQtopia( categories, datebook, todolist ); | 1714 | mView->importQtopia( categories, datebook, todolist ); |
1715 | } | 1715 | } |
1716 | mView->calendar()->reInitAlarmSettings(); | 1716 | mView->calendar()->reInitAlarmSettings(); |
1717 | #if 0 | 1717 | #if 0 |
1718 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1718 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1719 | i18n("Not supported \non desktop!\n"), | 1719 | i18n("Not supported \non desktop!\n"), |
1720 | i18n("Ok"), i18n("Cancel"), 0, | 1720 | i18n("Ok"), i18n("Cancel"), 0, |
1721 | 0, 1 ); | 1721 | 0, 1 ); |
1722 | 1722 | ||
1723 | #endif | 1723 | #endif |
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | void MainWindow::saveOnClose() | 1726 | void MainWindow::saveOnClose() |
1727 | { | 1727 | { |
1728 | KOPrefs *p = KOPrefs::instance(); | 1728 | KOPrefs *p = KOPrefs::instance(); |
1729 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1729 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1730 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1730 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1731 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1731 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1732 | if ( filterToolBar ) { | 1732 | if ( filterToolBar ) { |
1733 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1733 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1734 | } | 1734 | } |
1735 | #ifdef DESKTOP_VERSION | 1735 | #ifdef DESKTOP_VERSION |
1736 | 1736 | ||
1737 | QPoint myP; | 1737 | QPoint myP; |
1738 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1738 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1739 | if ( p->mToolBarHor ) | 1739 | if ( p->mToolBarHor ) |
1740 | p->mToolBarUp = myP.y() > height()/2; | 1740 | p->mToolBarUp = myP.y() > height()/2; |
1741 | else | 1741 | else |
1742 | p->mToolBarUp = myP.x() > width()/2; | 1742 | p->mToolBarUp = myP.x() > width()/2; |
1743 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1743 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1744 | if ( p->mToolBarHorV ) | 1744 | if ( p->mToolBarHorV ) |
1745 | p->mToolBarUpV = myP.y() > height()/2; | 1745 | p->mToolBarUpV = myP.y() > height()/2; |
1746 | else | 1746 | else |
1747 | p->mToolBarUpV = myP.x() > width()/2 ; | 1747 | p->mToolBarUpV = myP.x() > width()/2 ; |
1748 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1748 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1749 | if ( p->mToolBarHorN ) | 1749 | if ( p->mToolBarHorN ) |
1750 | p->mToolBarUpN = myP.y() > height()/2; | 1750 | p->mToolBarUpN = myP.y() > height()/2; |
1751 | else | 1751 | else |
1752 | p->mToolBarUpN = myP.x() > width()/2 ; | 1752 | p->mToolBarUpN = myP.x() > width()/2 ; |
1753 | if ( filterToolBar ) { | 1753 | if ( filterToolBar ) { |
1754 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1754 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1755 | if ( p->mToolBarHorF ) | 1755 | if ( p->mToolBarHorF ) |
1756 | p->mToolBarUpF = myP.y() > height()/2; | 1756 | p->mToolBarUpF = myP.y() > height()/2; |
1757 | else | 1757 | else |
1758 | p->mToolBarUpF = myP.x() > width()/2 ; | 1758 | p->mToolBarUpF = myP.x() > width()/2 ; |
1759 | } | 1759 | } |
1760 | #else | 1760 | #else |
1761 | if ( p->mToolBarHor ) | 1761 | if ( p->mToolBarHor ) |
1762 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1762 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1763 | else | 1763 | else |
1764 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1764 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1765 | if ( p->mToolBarHorV ) | 1765 | if ( p->mToolBarHorV ) |
1766 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1766 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1767 | else | 1767 | else |
1768 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1768 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1769 | 1769 | ||
1770 | if ( p->mToolBarHorN ) | 1770 | if ( p->mToolBarHorN ) |
1771 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1771 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1772 | else | 1772 | else |
1773 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1773 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1774 | if ( filterToolBar ) { | 1774 | if ( filterToolBar ) { |
1775 | if ( p->mToolBarHorF ) | 1775 | if ( p->mToolBarHorF ) |
1776 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1776 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1777 | else | 1777 | else |
1778 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1778 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1779 | } | 1779 | } |
1780 | #endif | 1780 | #endif |
1781 | 1781 | ||
1782 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1782 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1783 | save(); | 1783 | save(); |
1784 | mView->writeSettings(); | 1784 | mView->writeSettings(); |
1785 | } | 1785 | } |
1786 | void MainWindow::slotModifiedChanged( bool changed ) | 1786 | void MainWindow::slotModifiedChanged( bool changed ) |
1787 | { | 1787 | { |
1788 | if ( mBlockAtStartup ) | 1788 | if ( mBlockAtStartup ) |
1789 | return; | 1789 | return; |
1790 | 1790 | ||
1791 | int msec; | 1791 | int msec; |
1792 | // we store the changes after 1 minute, | 1792 | // we store the changes after 1 minute, |
1793 | // and for safety reasons after 10 minutes again | 1793 | // and for safety reasons after 10 minutes again |
1794 | if ( !mSyncManager->blockSave() ) | 1794 | if ( !mSyncManager->blockSave() ) |
1795 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1795 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1796 | else | 1796 | else |
1797 | msec = 1000 * 600; | 1797 | msec = 1000 * 600; |
1798 | mSaveTimer.start( msec, true ); // 1 minute | 1798 | mSaveTimer.start( msec, true ); // 1 minute |
1799 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1799 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1800 | mCalendarModifiedFlag = true; | 1800 | mCalendarModifiedFlag = true; |
1801 | } | 1801 | } |
1802 | void MainWindow::saveStopTimer() | 1802 | void MainWindow::saveStopTimer() |
1803 | { | 1803 | { |
1804 | mSaveTimer.stop(); | 1804 | mSaveTimer.stop(); |
1805 | } | 1805 | } |
1806 | void MainWindow::save() | 1806 | void MainWindow::save() |
1807 | { | 1807 | { |
1808 | if ( !mCalendarModifiedFlag ) { | 1808 | if ( !mCalendarModifiedFlag ) { |
1809 | qDebug("KO: Calendar not modified. Nothing saved."); | 1809 | qDebug("KO: Calendar not modified. Nothing saved."); |
1810 | return; | 1810 | return; |
1811 | } | 1811 | } |
1812 | if ( mSyncManager->blockSave() ) | 1812 | if ( mSyncManager->blockSave() ) |
1813 | return; | 1813 | return; |
1814 | mSyncManager->setBlockSave(true); | 1814 | mSyncManager->setBlockSave(true); |
1815 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1815 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1816 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 1816 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1817 | QDate reference ( 2000,1,1); | 1817 | QDate reference ( 2000,1,1); |
1818 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1818 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1819 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 1819 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1820 | setCaption(i18n("Creating backup ... please wait ..." )); | 1820 | setCaption(i18n("Creating backup ... please wait ..." )); |
1821 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1821 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1822 | // we need the file path, the backup dir and the number of bups as param | 1822 | // we need the file path, the backup dir and the number of bups as param |
1823 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1823 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1824 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1824 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1825 | bupDir = KGlobalSettings::backupDataDir(); | 1825 | bupDir = KGlobalSettings::backupDataDir(); |
1826 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1826 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1827 | if ( retval == 0 ) { | 1827 | if ( retval == 0 ) { |
1828 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1828 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1829 | // retval == 0 : backup skipped for today, try again tomorrow | 1829 | // retval == 0 : backup skipped for today, try again tomorrow |
1830 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1830 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1831 | } else if ( retval == 1 ){ | 1831 | } else if ( retval == 1 ){ |
1832 | qDebug("KO: Backup created."); | 1832 | qDebug("KO: Backup created."); |
1833 | // backup ok | 1833 | // backup ok |
1834 | KOPrefs::instance()->mLastBackupDate = daysTo; | 1834 | KOPrefs::instance()->mLastBackupDate = daysTo; |
1835 | 1835 | ||
1836 | } else if ( retval == 2 ){ | 1836 | } else if ( retval == 2 ){ |
1837 | qDebug("KO: Backup globally cancelled."); | 1837 | qDebug("KO: Backup globally cancelled."); |
1838 | // backup globally cancelled | 1838 | // backup globally cancelled |
1839 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 1839 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
1840 | } | 1840 | } |
1841 | // retval == 3: do nothing, try again later | 1841 | // retval == 3: do nothing, try again later |
1842 | } | 1842 | } |
1843 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 1843 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
1844 | } | 1844 | } |
1845 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1845 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1846 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1846 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1847 | qDebug("KO: Start saving data to file!"); | 1847 | qDebug("KO: Start saving data to file!"); |
1848 | mView->saveCalendar( defaultFileName() ); | 1848 | mView->saveCalendar( defaultFileName() ); |
1849 | mCalendarModifiedFlag = false; | 1849 | mCalendarModifiedFlag = false; |
1850 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1850 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1851 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1851 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1852 | QString savemes; | 1852 | QString savemes; |
1853 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1853 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1854 | setCaption(savemes); | 1854 | setCaption(savemes); |
1855 | } else | 1855 | } else |
1856 | setCaption(i18n("Saving cancelled!")); | 1856 | setCaption(i18n("Saving cancelled!")); |
1857 | mSyncManager->setBlockSave( false ); | 1857 | mSyncManager->setBlockSave( false ); |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1860 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1861 | { | 1861 | { |
1862 | if ( !e->isAutoRepeat() ) { | 1862 | if ( !e->isAutoRepeat() ) { |
1863 | mFlagKeyPressed = false; | 1863 | mFlagKeyPressed = false; |
1864 | } | 1864 | } |
1865 | } | 1865 | } |
1866 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1866 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1867 | { | 1867 | { |
1868 | qApp->processEvents(); | 1868 | qApp->processEvents(); |
1869 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1869 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1870 | e->ignore(); | 1870 | e->ignore(); |
1871 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1871 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1872 | return; | 1872 | return; |
1873 | } | 1873 | } |
1874 | if (! e->isAutoRepeat() ) | 1874 | if (! e->isAutoRepeat() ) |
1875 | mFlagKeyPressed = true; | 1875 | mFlagKeyPressed = true; |
1876 | KOPrefs *p = KOPrefs::instance(); | 1876 | KOPrefs *p = KOPrefs::instance(); |
1877 | bool showSelectedDates = false; | 1877 | bool showSelectedDates = false; |
1878 | int size; | 1878 | int size; |
1879 | int pro = 0; | 1879 | int pro = 0; |
1880 | //qDebug("MainWindow::keyPressEvent "); | 1880 | //qDebug("MainWindow::keyPressEvent "); |
1881 | switch ( e->key() ) { | 1881 | switch ( e->key() ) { |
1882 | case Qt::Key_Right: | 1882 | case Qt::Key_Right: |
1883 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1883 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1884 | mView->goNextMonth(); | 1884 | mView->goNextMonth(); |
1885 | else | 1885 | else |
1886 | mView->goNext(); | 1886 | mView->goNext(); |
1887 | showSelectedDates = true; | 1887 | showSelectedDates = true; |
1888 | break; | 1888 | break; |
1889 | case Qt::Key_Left: | 1889 | case Qt::Key_Left: |
1890 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1890 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1891 | mView->goPreviousMonth(); | 1891 | mView->goPreviousMonth(); |
1892 | else | 1892 | else |
1893 | mView->goPrevious(); | 1893 | mView->goPrevious(); |
1894 | showSelectedDates = true; | 1894 | showSelectedDates = true; |
1895 | break; | 1895 | break; |
1896 | case Qt::Key_Down: | 1896 | case Qt::Key_Down: |
1897 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1897 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1898 | break; | 1898 | break; |
1899 | case Qt::Key_Up: | 1899 | case Qt::Key_Up: |
1900 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1900 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1901 | break; | 1901 | break; |
1902 | case Qt::Key_K: | 1902 | case Qt::Key_K: |
1903 | mView->viewManager()->showMonthViewWeek(); | 1903 | mView->viewManager()->showMonthViewWeek(); |
1904 | break; | 1904 | break; |
1905 | case Qt::Key_I: | 1905 | case Qt::Key_I: |
1906 | mView->showIncidence(); | 1906 | mView->showIncidence(); |
1907 | break; | 1907 | break; |
1908 | case Qt::Key_Delete: | 1908 | case Qt::Key_Delete: |
1909 | case Qt::Key_Backspace: | 1909 | case Qt::Key_Backspace: |
1910 | mView->deleteIncidence(); | 1910 | mView->deleteIncidence(); |
1911 | break; | 1911 | break; |
1912 | case Qt::Key_D: | 1912 | case Qt::Key_D: |
1913 | mView->viewManager()->showDayView(); | 1913 | mView->viewManager()->showDayView(); |
1914 | showSelectedDates = true; | 1914 | showSelectedDates = true; |
1915 | break; | 1915 | break; |
1916 | case Qt::Key_O: | 1916 | case Qt::Key_O: |
1917 | mView->toggleFilerEnabled( ); | 1917 | mView->toggleFilerEnabled( ); |
1918 | break; | 1918 | break; |
1919 | case Qt::Key_0: | 1919 | case Qt::Key_0: |
1920 | case Qt::Key_1: | 1920 | case Qt::Key_1: |
1921 | case Qt::Key_2: | 1921 | case Qt::Key_2: |
1922 | case Qt::Key_3: | 1922 | case Qt::Key_3: |
1923 | case Qt::Key_4: | 1923 | case Qt::Key_4: |
1924 | case Qt::Key_5: | 1924 | case Qt::Key_5: |
1925 | case Qt::Key_6: | 1925 | case Qt::Key_6: |
1926 | case Qt::Key_7: | 1926 | case Qt::Key_7: |
1927 | case Qt::Key_8: | 1927 | case Qt::Key_8: |
1928 | case Qt::Key_9: | 1928 | case Qt::Key_9: |
1929 | pro = e->key()-48; | 1929 | pro = e->key()-48; |
1930 | if ( pro == 0 ) | 1930 | if ( pro == 0 ) |
1931 | pro = 10; | 1931 | pro = 10; |
1932 | if ( e->state() == Qt::ControlButton) | 1932 | if ( e->state() == Qt::ControlButton) |
1933 | pro += 10; | 1933 | pro += 10; |
1934 | break; | 1934 | break; |
1935 | case Qt::Key_M: | 1935 | case Qt::Key_M: |
1936 | mView->viewManager()->showMonthView(); | 1936 | mView->viewManager()->showMonthView(); |
1937 | showSelectedDates = true; | 1937 | showSelectedDates = true; |
1938 | break; | 1938 | break; |
1939 | case Qt::Key_Insert: | 1939 | case Qt::Key_Insert: |
1940 | mView->newEvent(); | 1940 | mView->newEvent(); |
1941 | break; | 1941 | break; |
1942 | case Qt::Key_S : | 1942 | case Qt::Key_S : |
1943 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1943 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1944 | mView->newSubTodo(); | 1944 | mView->newSubTodo(); |
1945 | else | 1945 | else |
1946 | mView->dialogManager()->showSearchDialog(); | 1946 | mView->dialogManager()->showSearchDialog(); |
1947 | break; | 1947 | break; |
1948 | case Qt::Key_Y : | 1948 | case Qt::Key_Y : |
1949 | case Qt::Key_Z : | 1949 | case Qt::Key_Z : |
1950 | mView->viewManager()->showWorkWeekView(); | 1950 | mView->viewManager()->showWorkWeekView(); |
1951 | showSelectedDates = true; | 1951 | showSelectedDates = true; |
1952 | break; | 1952 | break; |
1953 | case Qt::Key_U : | 1953 | case Qt::Key_U : |
1954 | mView->viewManager()->showWeekView(); | 1954 | mView->viewManager()->showWeekView(); |
1955 | showSelectedDates = true; | 1955 | showSelectedDates = true; |
1956 | break; | 1956 | break; |
1957 | case Qt::Key_H : | 1957 | case Qt::Key_H : |
1958 | keyBindings(); | 1958 | keyBindings(); |
1959 | break; | 1959 | break; |
1960 | case Qt::Key_W: | 1960 | case Qt::Key_W: |
1961 | mView->viewManager()->showWhatsNextView(); | 1961 | mView->viewManager()->showWhatsNextView(); |
1962 | break; | 1962 | break; |
1963 | case Qt::Key_L: | 1963 | case Qt::Key_L: |
1964 | mView->viewManager()->showListView(); | 1964 | mView->viewManager()->showListView(); |
1965 | break; | 1965 | break; |
1966 | case Qt::Key_N: | 1966 | case Qt::Key_N: |
1967 | mView->viewManager()->showNextView(); | 1967 | mView->viewManager()->showNextView(); |
1968 | break; | 1968 | break; |
1969 | case Qt::Key_V: | 1969 | case Qt::Key_V: |
1970 | mView->viewManager()->showTodoView(); | 1970 | mView->viewManager()->showTodoView(); |
1971 | break; | 1971 | break; |
1972 | case Qt::Key_C: | 1972 | case Qt::Key_C: |
1973 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1973 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1974 | break; | 1974 | break; |
1975 | case Qt::Key_P: | 1975 | case Qt::Key_P: |
1976 | mView->showDatePicker( ); | 1976 | mView->showDatePicker( ); |
1977 | break; | 1977 | break; |
1978 | case Qt::Key_F: | 1978 | case Qt::Key_F: |
1979 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1979 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1980 | mView->editFilters(); | 1980 | mView->editFilters(); |
1981 | else | 1981 | else |
1982 | mView->toggleFilter(); | 1982 | mView->toggleFilter(); |
1983 | break; | 1983 | break; |
1984 | case Qt::Key_X: | 1984 | case Qt::Key_X: |
1985 | if ( e->state() == Qt::ControlButton ) | 1985 | if ( e->state() == Qt::ControlButton ) |
1986 | mView->toggleDateNavigatorWidget(); | 1986 | mView->toggleDateNavigatorWidget(); |
1987 | else { | 1987 | else { |
1988 | mView->viewManager()->showNextXView(); | 1988 | mView->viewManager()->showNextXView(); |
1989 | showSelectedDates = true; | 1989 | showSelectedDates = true; |
1990 | } | 1990 | } |
1991 | break; | 1991 | break; |
1992 | case Qt::Key_Space: | 1992 | case Qt::Key_Space: |
1993 | mView->toggleExpand(); | 1993 | mView->toggleExpand(); |
1994 | break; | 1994 | break; |
1995 | case Qt::Key_A: | 1995 | case Qt::Key_A: |
1996 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 1996 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
1997 | mView->showNextAlarms(); | 1997 | mView->showNextAlarms(); |
1998 | else | 1998 | else |
1999 | mView->toggleAllDaySize(); | 1999 | mView->toggleAllDaySize(); |
2000 | break; | 2000 | break; |
2001 | case Qt::Key_T: | 2001 | case Qt::Key_T: |
2002 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2002 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2003 | mView->newTodo(); | 2003 | mView->newTodo(); |
2004 | else { | 2004 | else { |
2005 | mView->goToday(); | 2005 | mView->goToday(); |
2006 | showSelectedDates = true; | 2006 | showSelectedDates = true; |
2007 | } | 2007 | } |
2008 | break; | 2008 | break; |
2009 | case Qt::Key_J: | 2009 | case Qt::Key_J: |
2010 | mView->viewManager()->showJournalView(); | 2010 | mView->viewManager()->showJournalView(); |
2011 | break; | 2011 | break; |
2012 | case Qt::Key_B: | 2012 | case Qt::Key_B: |
2013 | mView->editIncidenceDescription();; | 2013 | mView->editIncidenceDescription();; |
2014 | break; | 2014 | break; |
2015 | // case Qt::Key_Return: | 2015 | // case Qt::Key_Return: |
2016 | case Qt::Key_E: | 2016 | case Qt::Key_E: |
2017 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2017 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2018 | mView->newEvent(); | 2018 | mView->newEvent(); |
2019 | else | 2019 | else |
2020 | mView->editIncidence(); | 2020 | mView->editIncidence(); |
2021 | break; | 2021 | break; |
2022 | case Qt::Key_Plus: | 2022 | case Qt::Key_Plus: |
2023 | size = p->mHourSize +2; | 2023 | size = p->mHourSize +2; |
2024 | if ( size <= 22 ) | 2024 | if ( size <= 22 ) |
2025 | configureAgenda( size ); | 2025 | configureAgenda( size ); |
2026 | break; | 2026 | break; |
2027 | case Qt::Key_Minus: | 2027 | case Qt::Key_Minus: |
2028 | size = p->mHourSize - 2; | 2028 | size = p->mHourSize - 2; |
2029 | if ( size >= 4 ) | 2029 | if ( size >= 4 ) |
2030 | configureAgenda( size ); | 2030 | configureAgenda( size ); |
2031 | break; | 2031 | break; |
2032 | 2032 | ||
2033 | 2033 | ||
2034 | default: | 2034 | default: |
2035 | e->ignore(); | 2035 | e->ignore(); |
2036 | } | 2036 | } |
2037 | if ( pro > 0 ) { | 2037 | if ( pro > 0 ) { |
2038 | mView->selectFilter( pro-1 ); | 2038 | mView->selectFilter( pro-1 ); |
2039 | } | 2039 | } |
2040 | if ( showSelectedDates ) { | 2040 | if ( showSelectedDates ) { |
2041 | ;// setCaptionToDates(); | 2041 | ;// setCaptionToDates(); |
2042 | } | 2042 | } |
2043 | 2043 | ||
2044 | } | 2044 | } |
2045 | void MainWindow::fillFilterMenuTB() | 2045 | void MainWindow::fillFilterMenuTB() |
2046 | { | 2046 | { |
2047 | selectFilterMenuTB->clear(); | 2047 | selectFilterMenuTB->clear(); |
2048 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2048 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2049 | selectFilterMenuTB->insertSeparator(); | 2049 | selectFilterMenuTB->insertSeparator(); |
2050 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2050 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2051 | 2051 | ||
2052 | selectFilterMenuTB->insertSeparator(); | 2052 | selectFilterMenuTB->insertSeparator(); |
2053 | QPtrList<CalFilter> fili = mView->filters(); | 2053 | QPtrList<CalFilter> fili = mView->filters(); |
2054 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2054 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2055 | CalFilter *filter = fili.first(); | 2055 | CalFilter *filter = fili.first(); |
2056 | int iii = 2; | 2056 | int iii = 2; |
2057 | bool checkitem = mView->filterView()->filtersEnabled(); | 2057 | bool checkitem = mView->filterView()->filtersEnabled(); |
2058 | while(filter) { | 2058 | while(filter) { |
2059 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2059 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2060 | if ( filter == curfilter) | 2060 | if ( filter == curfilter) |
2061 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2061 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2062 | filter = fili.next(); | 2062 | filter = fili.next(); |
2063 | ++iii; | 2063 | ++iii; |
2064 | } | 2064 | } |
2065 | if ( !checkitem ) | 2065 | if ( !checkitem ) |
2066 | selectFilterMenuTB->setItemChecked( 1, true ); | 2066 | selectFilterMenuTB->setItemChecked( 1, true ); |
2067 | 2067 | ||
2068 | int x = 0; | 2068 | int x = 0; |
2069 | int y = iconToolBar->height(); | 2069 | int y = iconToolBar->height(); |
2070 | int dX = 0; | 2070 | int dX = 0; |
2071 | int dY = 0; | 2071 | int dY = 0; |
2072 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2072 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2073 | if ( iconToolBar->y() > height()/2 ) { | 2073 | if ( iconToolBar->y() > height()/2 ) { |
2074 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2074 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2075 | y = 0; | 2075 | y = 0; |
2076 | } | 2076 | } |
2077 | } else { | 2077 | } else { |
2078 | if ( iconToolBar->x() > width()/2 ) { // right side | 2078 | if ( iconToolBar->x() > width()/2 ) { // right side |
2079 | x=0; | 2079 | x=0; |
2080 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2080 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2081 | y = 0; | 2081 | y = 0; |
2082 | } else { | 2082 | } else { |
2083 | x= iconToolBar->width(); | 2083 | x= iconToolBar->width(); |
2084 | y = 0; | 2084 | y = 0; |
2085 | } | 2085 | } |
2086 | } | 2086 | } |
2087 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2087 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2088 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2088 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2089 | } | 2089 | } |
2090 | void MainWindow::fillFilterMenu() | 2090 | void MainWindow::fillFilterMenu() |
2091 | { | 2091 | { |
2092 | selectFilterMenu->clear(); | 2092 | selectFilterMenu->clear(); |
2093 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2093 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2094 | selectFilterMenu->insertSeparator(); | 2094 | selectFilterMenu->insertSeparator(); |
2095 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2095 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2096 | 2096 | ||
2097 | selectFilterMenu->insertSeparator(); | 2097 | selectFilterMenu->insertSeparator(); |
2098 | QPtrList<CalFilter> fili = mView->filters(); | 2098 | QPtrList<CalFilter> fili = mView->filters(); |
2099 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2099 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2100 | CalFilter *filter = fili.first(); | 2100 | CalFilter *filter = fili.first(); |
2101 | int iii = 2; | 2101 | int iii = 2; |
2102 | bool checkitem = mView->filterView()->filtersEnabled(); | 2102 | bool checkitem = mView->filterView()->filtersEnabled(); |
2103 | while(filter) { | 2103 | while(filter) { |
2104 | selectFilterMenu->insertItem( filter->name(), iii ); | 2104 | selectFilterMenu->insertItem( filter->name(), iii ); |
2105 | if ( filter == curfilter) | 2105 | if ( filter == curfilter) |
2106 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2106 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2107 | filter = fili.next(); | 2107 | filter = fili.next(); |
2108 | ++iii; | 2108 | ++iii; |
2109 | } | 2109 | } |
2110 | if ( !checkitem ) | 2110 | if ( !checkitem ) |
2111 | selectFilterMenu->setItemChecked( 1, true ); | 2111 | selectFilterMenu->setItemChecked( 1, true ); |
2112 | } | 2112 | } |
2113 | void MainWindow::fillFilterMenuPopup() | 2113 | void MainWindow::fillFilterMenuPopup() |
2114 | { | 2114 | { |
2115 | filterPopupMenu->clear(); | 2115 | filterPopupMenu->clear(); |
2116 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2116 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2117 | 2117 | ||
2118 | filterPopupMenu->insertSeparator(); | 2118 | filterPopupMenu->insertSeparator(); |
2119 | QPtrList<CalFilter> fili = mView->filters(); | 2119 | QPtrList<CalFilter> fili = mView->filters(); |
2120 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2120 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2121 | CalFilter *filter = fili.first(); | 2121 | CalFilter *filter = fili.first(); |
2122 | int iii = 1; | 2122 | int iii = 1; |
2123 | bool checkitem = mView->filterView()->filtersEnabled(); | 2123 | bool checkitem = mView->filterView()->filtersEnabled(); |
2124 | while(filter) { | 2124 | while(filter) { |
2125 | filterPopupMenu->insertItem( filter->name(), iii ); | 2125 | filterPopupMenu->insertItem( filter->name(), iii ); |
2126 | if ( filter == curfilter) | 2126 | if ( filter == curfilter) |
2127 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2127 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2128 | filter = fili.next(); | 2128 | filter = fili.next(); |
2129 | ++iii; | 2129 | ++iii; |
2130 | } | 2130 | } |
2131 | if ( !checkitem ) | 2131 | if ( !checkitem ) |
2132 | filterPopupMenu->setItemChecked( 0, true ); | 2132 | filterPopupMenu->setItemChecked( 0, true ); |
2133 | } | 2133 | } |
2134 | void MainWindow::selectFilter( int fil ) | 2134 | void MainWindow::selectFilter( int fil ) |
2135 | { | 2135 | { |
2136 | 2136 | ||
2137 | if ( fil == 0 ) { | 2137 | if ( fil == 0 ) { |
2138 | mView->editFilters( ); | 2138 | mView->editFilters( ); |
2139 | } else if ( fil == 1 ){ | 2139 | } else if ( fil == 1 ){ |
2140 | if ( mView->filterView()->filtersEnabled() ) | 2140 | if ( mView->filterView()->filtersEnabled() ) |
2141 | mView->toggleFilerEnabled( ); | 2141 | mView->toggleFilerEnabled( ); |
2142 | } else { | 2142 | } else { |
2143 | if ( !mView->filterView()->filtersEnabled() ) { | 2143 | if ( !mView->filterView()->filtersEnabled() ) { |
2144 | mView->filterView()->blockSignals( true ); | 2144 | mView->filterView()->blockSignals( true ); |
2145 | mView->toggleFilerEnabled( ); | 2145 | mView->toggleFilerEnabled( ); |
2146 | mView->filterView()->blockSignals( false ); | 2146 | mView->filterView()->blockSignals( false ); |
2147 | } | 2147 | } |
2148 | mView->selectFilter( fil-2 ); | 2148 | mView->selectFilter( fil-2 ); |
2149 | } | 2149 | } |
2150 | } | 2150 | } |
2151 | void MainWindow::updateFilterToolbar() | 2151 | void MainWindow::updateFilterToolbar() |
2152 | { | 2152 | { |
2153 | if ( filterMenubar ) { | 2153 | if ( filterMenubar ) { |
2154 | if ( !mView->filterView()->filtersEnabled() ) { | 2154 | if ( !mView->filterView()->filtersEnabled() ) { |
2155 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2155 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2156 | } else { | 2156 | } else { |
2157 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2157 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2158 | if ( curfilter ) { | 2158 | if ( curfilter ) { |
2159 | filterMenubar->changeItem( 0, curfilter->name() ); | 2159 | filterMenubar->changeItem( 0, curfilter->name() ); |
2160 | } | 2160 | } |
2161 | } | 2161 | } |
2162 | } | 2162 | } |
2163 | } | 2163 | } |
2164 | void MainWindow::selectFilterPopup( int fil ) | 2164 | void MainWindow::selectFilterPopup( int fil ) |
2165 | { | 2165 | { |
2166 | selectFilter( fil + 1 ); | 2166 | selectFilter( fil + 1 ); |
2167 | 2167 | ||
2168 | } | 2168 | } |
2169 | void MainWindow::configureToolBar( int item ) | 2169 | void MainWindow::configureToolBar( int item ) |
2170 | { | 2170 | { |
2171 | 2171 | ||
2172 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2172 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2173 | KOPrefs *p = KOPrefs::instance(); | 2173 | KOPrefs *p = KOPrefs::instance(); |
2174 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2174 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2175 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2175 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2176 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2176 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2177 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2177 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2178 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2178 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2179 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2179 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2180 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2180 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2181 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2181 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2182 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2182 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2183 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2183 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2184 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2184 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2185 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2185 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2186 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2186 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2187 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2187 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2188 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2188 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2189 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2189 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2190 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2190 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2191 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2191 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2192 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2192 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2193 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2193 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2194 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2194 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2195 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2195 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2196 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2196 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2197 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2197 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2198 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2198 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2199 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2199 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2200 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2200 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2201 | // initActions(); | 2201 | // initActions(); |
2202 | } | 2202 | } |
2203 | void MainWindow::setCaption ( const QString & c ) | 2203 | void MainWindow::setCaption ( const QString & c ) |
2204 | { | 2204 | { |
2205 | QString cap = c; | 2205 | QString cap = c; |
2206 | cap.replace( QRegExp("\n"), " " ); | 2206 | cap.replace( QRegExp("\n"), " " ); |
2207 | cap = cap.stripWhiteSpace(); | 2207 | cap = cap.stripWhiteSpace(); |
2208 | if ( cap.isEmpty() ) | 2208 | if ( cap.isEmpty() ) |
2209 | cap = "KO/Pi"; | 2209 | cap = "KO/Pi"; |
2210 | QWidget::setCaption( cap ); | 2210 | QWidget::setCaption( cap ); |
2211 | } | 2211 | } |
2212 | void MainWindow::setCaptionToDates() | 2212 | void MainWindow::setCaptionToDates() |
2213 | { | 2213 | { |
2214 | QString selDates; | 2214 | QString selDates; |
2215 | QDate date = mView->startDate(); | 2215 | QDate date = mView->startDate(); |
2216 | if ( ! date.isValid() ) { | 2216 | if ( ! date.isValid() ) { |
2217 | setCaption(""); | 2217 | setCaption(""); |
2218 | return; | 2218 | return; |
2219 | } | 2219 | } |
2220 | selDates = KGlobal::locale()->formatDate( date, true); | 2220 | selDates = KGlobal::locale()->formatDate( date, true); |
2221 | if (mView->startDate() < mView->endDate() ) | 2221 | if (mView->startDate() < mView->endDate() ) |
2222 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2222 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2223 | else { | 2223 | else { |
2224 | QString addString; | 2224 | QString addString; |
2225 | if ( date == QDateTime::currentDateTime().date() ) | 2225 | if ( date == QDateTime::currentDateTime().date() ) |
2226 | addString = i18n("Today"); | 2226 | addString = i18n("Today"); |
2227 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2227 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2228 | addString = i18n("Tomorrow"); | 2228 | addString = i18n("Tomorrow"); |
2229 | if ( !addString.isEmpty() ) | 2229 | if ( !addString.isEmpty() ) |
2230 | selDates = addString+", "+selDates ; | 2230 | selDates = addString+", "+selDates ; |
2231 | } | 2231 | } |
2232 | setCaption( i18n("Dates: ") + selDates ); | 2232 | setCaption( i18n("Dates: ") + selDates ); |
2233 | 2233 | ||
2234 | } | 2234 | } |
2235 | void MainWindow::showConfigureAgenda( ) | 2235 | void MainWindow::showConfigureAgenda( ) |
2236 | { | 2236 | { |
2237 | int iii; | 2237 | int iii; |
2238 | for ( iii = 1;iii<= 10 ;++iii ){ | 2238 | for ( iii = 1;iii<= 10 ;++iii ){ |
2239 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2239 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2240 | } | 2240 | } |
2241 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2241 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2242 | } | 2242 | } |
2243 | void MainWindow::configureAgenda( int item ) | 2243 | void MainWindow::configureAgenda( int item ) |
2244 | { | 2244 | { |
2245 | if ( KOPrefs::instance()->mHourSize == item ) | 2245 | if ( KOPrefs::instance()->mHourSize == item ) |
2246 | return; | 2246 | return; |
2247 | KOPrefs::instance()->mHourSize=item; | 2247 | KOPrefs::instance()->mHourSize=item; |
2248 | mView->viewManager()->agendaView()->updateConfig(); | 2248 | mView->viewManager()->agendaView()->updateConfig(); |
2249 | } | 2249 | } |
2250 | 2250 | ||
2251 | void MainWindow::saveCalendar() | 2251 | void MainWindow::saveCalendar() |
2252 | { | 2252 | { |
2253 | QString fn = KOPrefs::instance()->mLastSaveFile; | 2253 | QString fn = KOPrefs::instance()->mLastSaveFile; |
2254 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 2254 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
2255 | 2255 | ||
2256 | if ( fn == "" ) | 2256 | if ( fn == "" ) |
2257 | return; | 2257 | return; |
2258 | QFileInfo info; | 2258 | QFileInfo info; |
2259 | info.setFile( fn ); | 2259 | info.setFile( fn ); |
2260 | QString mes; | 2260 | QString mes; |
2261 | bool createbup = true; | 2261 | bool createbup = true; |
2262 | if ( info. exists() ) { | 2262 | if ( info. exists() ) { |
2263 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 2263 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
2264 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2264 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2265 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2265 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2266 | 0, 1 ); | 2266 | 0, 1 ); |
2267 | if ( result != 0 ) { | 2267 | if ( result != 0 ) { |
2268 | createbup = false; | 2268 | createbup = false; |
2269 | } | 2269 | } |
2270 | } | 2270 | } |
2271 | if ( createbup ) { | 2271 | if ( createbup ) { |
2272 | mView->saveCalendar( fn ); | 2272 | mView->saveCalendar( fn ); |
2273 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 2273 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
2274 | KOPrefs::instance()->mLastSaveFile = fn; | 2274 | KOPrefs::instance()->mLastSaveFile = fn; |
2275 | setCaption(mes); | 2275 | setCaption(mes); |
2276 | } | 2276 | } |
2277 | } | 2277 | } |
2278 | void MainWindow::loadCalendar() | 2278 | void MainWindow::loadCalendar() |
2279 | { | 2279 | { |
2280 | 2280 | ||
2281 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2281 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2282 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2282 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2283 | 2283 | ||
2284 | if ( fn == "" ) | 2284 | if ( fn == "" ) |
2285 | return; | 2285 | return; |
2286 | QFileInfo info; | 2286 | QFileInfo info; |
2287 | info.setFile( fn ); | 2287 | info.setFile( fn ); |
2288 | QString mess; | 2288 | QString mess; |
2289 | bool loadbup = true; | 2289 | bool loadbup = true; |
2290 | if ( info. exists() ) { | 2290 | if ( info. exists() ) { |
2291 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2291 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2292 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2292 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2293 | mess, | 2293 | mess, |
2294 | i18n("Load!"), i18n("Cancel"), 0, | 2294 | i18n("Load!"), i18n("Cancel"), 0, |
2295 | 0, 1 ); | 2295 | 0, 1 ); |
2296 | if ( result != 0 ) { | 2296 | if ( result != 0 ) { |
2297 | loadbup = false; | 2297 | loadbup = false; |
2298 | } | 2298 | } |
2299 | } else { | 2299 | } else { |
2300 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2300 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2301 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2301 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2302 | 0, 1 ); | 2302 | 0, 1 ); |
2303 | 2303 | ||
2304 | return; | 2304 | return; |
2305 | } | 2305 | } |
2306 | if ( loadbup ) { | 2306 | if ( loadbup ) { |
2307 | mView->openCalendar( fn ); | 2307 | mView->openCalendar( fn ); |
2308 | KOPrefs::instance()->mLastLoadFile = fn; | 2308 | KOPrefs::instance()->mLastLoadFile = fn; |
2309 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2309 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2310 | setCaption(mess); | 2310 | setCaption(mess); |
2311 | } | 2311 | } |
2312 | 2312 | ||
2313 | } | 2313 | } |
2314 | void MainWindow::quickImportIcal() | 2314 | void MainWindow::quickImportIcal() |
2315 | { | 2315 | { |
2316 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2316 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2317 | } | 2317 | } |
2318 | void MainWindow::importFile( QString fn, bool quick ) | 2318 | void MainWindow::importFile( QString fn, bool quick ) |
2319 | { | 2319 | { |
2320 | QFileInfo info; | 2320 | QFileInfo info; |
2321 | info.setFile( fn ); | 2321 | info.setFile( fn ); |
2322 | QString mess; | 2322 | QString mess; |
2323 | bool loadbup = true; | 2323 | bool loadbup = true; |
2324 | if ( !info. exists() ) { | 2324 | if ( !info. exists() ) { |
2325 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2325 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2326 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2326 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2327 | mess ); | 2327 | mess ); |
2328 | return; | 2328 | return; |
2329 | } | 2329 | } |
2330 | int result = 0; | 2330 | int result = 0; |
2331 | if ( !quick ) { | 2331 | if ( !quick ) { |
2332 | 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 )); | 2332 | 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 )); |
2333 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2333 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2334 | mess, | 2334 | mess, |
2335 | "Import", "Cancel", 0, | 2335 | "Import", "Cancel", 0, |
2336 | 0, 1 ); | 2336 | 0, 1 ); |
2337 | } | 2337 | } |
2338 | if ( result == 0 ) { | 2338 | if ( result == 0 ) { |
2339 | if ( mView->openCalendar( fn, true )) { | 2339 | if ( mView->openCalendar( fn, true )) { |
2340 | KOPrefs::instance()->mLastImportFile = fn; | 2340 | KOPrefs::instance()->mLastImportFile = fn; |
2341 | setCaption(i18n("Imported file successfully")); | 2341 | setCaption(i18n("Imported file successfully")); |
2342 | } else { | 2342 | } else { |
2343 | setCaption(i18n("Error importing file")); | 2343 | setCaption(i18n("Error importing file")); |
2344 | } | 2344 | } |
2345 | } | 2345 | } |
2346 | } | 2346 | } |
2347 | 2347 | ||
2348 | void MainWindow::importIcal() | 2348 | void MainWindow::importIcal() |
2349 | { | 2349 | { |
2350 | 2350 | ||
2351 | QString fn =KOPrefs::instance()->mLastImportFile; | 2351 | QString fn =KOPrefs::instance()->mLastImportFile; |
2352 | 2352 | ||
2353 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2353 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2354 | if ( fn == "" ) | 2354 | if ( fn == "" ) |
2355 | return; | 2355 | return; |
2356 | importFile( fn, true ); | 2356 | importFile( fn, true ); |
2357 | 2357 | ||
2358 | } | 2358 | } |
2359 | 2359 | ||
2360 | void MainWindow::exportVCalendar() | 2360 | void MainWindow::exportVCalendar() |
2361 | { | 2361 | { |
2362 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2362 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2363 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2363 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2364 | if ( fn == "" ) | 2364 | if ( fn == "" ) |
2365 | return; | 2365 | return; |
2366 | QFileInfo info; | 2366 | QFileInfo info; |
2367 | info.setFile( fn ); | 2367 | info.setFile( fn ); |
2368 | QString mes; | 2368 | QString mes; |
2369 | bool createbup = true; | 2369 | bool createbup = true; |
2370 | if ( info. exists() ) { | 2370 | if ( info. exists() ) { |
2371 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2371 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2372 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2372 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2373 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2373 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2374 | 0, 1 ); | 2374 | 0, 1 ); |
2375 | if ( result != 0 ) { | 2375 | if ( result != 0 ) { |
2376 | createbup = false; | 2376 | createbup = false; |
2377 | } | 2377 | } |
2378 | } | 2378 | } |
2379 | if ( createbup ) { | 2379 | if ( createbup ) { |
2380 | if ( mView->exportVCalendar( fn ) ) { | 2380 | if ( mView->exportVCalendar( fn ) ) { |
2381 | KOPrefs::instance()->mLastVcalFile = fn; | 2381 | KOPrefs::instance()->mLastVcalFile = fn; |
2382 | if ( fn.length() > 20 ) | 2382 | if ( fn.length() > 20 ) |
2383 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2383 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2384 | else | 2384 | else |
2385 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2385 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2386 | setCaption(mes); | 2386 | setCaption(mes); |
2387 | } | 2387 | } |
2388 | } | 2388 | } |
2389 | 2389 | ||
2390 | } | 2390 | } |
2391 | QString MainWindow::sentSyncFile() | 2391 | QString MainWindow::sentSyncFile() |
2392 | { | 2392 | { |
2393 | #ifdef DESKTOP_VERSION | 2393 | #ifdef DESKTOP_VERSION |
2394 | return locateLocal( "tmp", "copysynccal.ics" ); | 2394 | return locateLocal( "tmp", "copysynccal.ics" ); |
2395 | #else | 2395 | #else |
2396 | return QString( "/tmp/copysynccal.ics" ); | 2396 | return QString( "/tmp/copysynccal.ics" ); |
2397 | #endif | 2397 | #endif |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | void MainWindow::syncFileRequest() | 2400 | void MainWindow::syncFileRequest() |
2401 | { | 2401 | { |
2402 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2402 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2403 | mSyncManager->slotSyncMenu( 999 ); | 2403 | mSyncManager->slotSyncMenu( 999 ); |
2404 | } | 2404 | } |
2405 | 2405 | ||
2406 | setCaption(i18n("Saving Data to temp file ..." )); | 2406 | setCaption(i18n("Saving Data to temp file ..." )); |
2407 | mView->saveCalendar( sentSyncFile() ); | 2407 | mView->saveCalendar( sentSyncFile() ); |
2408 | setCaption(i18n("Data saved to temp file!" )); | 2408 | setCaption(i18n("Data saved to temp file!" )); |
2409 | 2409 | ||
2410 | } | 2410 | } |
2411 | void MainWindow::getFile( bool success ) | 2411 | void MainWindow::getFile( bool success ) |
2412 | { | 2412 | { |
2413 | if ( ! success ) { | 2413 | if ( ! success ) { |
2414 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2414 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2415 | return; | 2415 | return; |
2416 | } | 2416 | } |
2417 | mView->openCalendar( sentSyncFile() ); | 2417 | mView->openCalendar( sentSyncFile() ); |
2418 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2418 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2419 | mSyncManager->slotSyncMenu( 999 ); | 2419 | mSyncManager->slotSyncMenu( 999 ); |
2420 | } | 2420 | } |
2421 | setCaption( i18n("Pi-Sync successful!") ); | 2421 | setCaption( i18n("Pi-Sync successful!") ); |
2422 | } | 2422 | } |
2423 | 2423 | ||
2424 | void MainWindow::printSel( ) | 2424 | void MainWindow::printSel( ) |
2425 | { | 2425 | { |
2426 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2426 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2427 | } | 2427 | } |
2428 | 2428 | ||
2429 | void MainWindow::printCal() | 2429 | void MainWindow::printCal() |
2430 | { | 2430 | { |
2431 | mView->print();//mCp->showDialog(); | 2431 | mView->print();//mCp->showDialog(); |
2432 | } | 2432 | } |
2433 | 2433 | ||
2434 | 2434 | ||
2435 | #include "libkdepim/kdatepicker.h" | 2435 | #include "libkdepim/kdatepicker.h" |
2436 | #include <kdatetbl.h> | 2436 | #include <kdatetbl.h> |
2437 | 2437 | ||
2438 | void MainWindow::weekAction() | 2438 | void MainWindow::weekAction() |
2439 | { | 2439 | { |
2440 | int month; | 2440 | int month; |
2441 | KPopupFrame* popup = new KPopupFrame(this); | 2441 | KPopupFrame* popup = new KPopupFrame(this); |
2442 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2442 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2443 | // ----- | 2443 | // ----- |
2444 | picker->resize(picker->sizeHint()); | 2444 | picker->resize(picker->sizeHint()); |
2445 | popup->setMainWidget(picker); | 2445 | popup->setMainWidget(picker); |
2446 | picker->setFocus(); | 2446 | picker->setFocus(); |
2447 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2447 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2448 | int x = 0; | 2448 | int x = 0; |
2449 | int y = iconToolBar->height(); | 2449 | int y = iconToolBar->height(); |
2450 | int dX = 0; | 2450 | int dX = 0; |
2451 | int dY = 0; | 2451 | int dY = 0; |
2452 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2452 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2453 | if ( iconToolBar->y() > height()/2 ) { | 2453 | if ( iconToolBar->y() > height()/2 ) { |
2454 | dY = picker->sizeHint().height()+8; | 2454 | dY = picker->sizeHint().height()+8; |
2455 | y = 0; | 2455 | y = 0; |
2456 | } | 2456 | } |
2457 | } else { | 2457 | } else { |
2458 | if ( iconToolBar->x() > width()/2 ) { // right side | 2458 | if ( iconToolBar->x() > width()/2 ) { // right side |
2459 | x=0; | 2459 | x=0; |
2460 | dX= picker->sizeHint().width()+8; | 2460 | dX= picker->sizeHint().width()+8; |
2461 | y = 0; | 2461 | y = 0; |
2462 | } else { | 2462 | } else { |
2463 | x= iconToolBar->width(); | 2463 | x= iconToolBar->width(); |
2464 | y = 0; | 2464 | y = 0; |
2465 | } | 2465 | } |
2466 | } | 2466 | } |
2467 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2467 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2468 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2468 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2469 | { | 2469 | { |
2470 | month = picker->getResult(); | 2470 | month = picker->getResult(); |
2471 | emit selectWeek ( month ); | 2471 | emit selectWeek ( month ); |
2472 | //qDebug("weekSelected %d ", month); | 2472 | //qDebug("weekSelected %d ", month); |
2473 | } | 2473 | } |
2474 | delete popup; | 2474 | delete popup; |
2475 | } | 2475 | } |
2476 | 2476 | ||
2477 | void MainWindow::hideEvent ( QHideEvent * ) | 2477 | void MainWindow::hideEvent ( QHideEvent * ) |
2478 | { | 2478 | { |
2479 | QString message; | 2479 | QString message; |
2480 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2480 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2481 | if ( nextA.isValid() ) { | 2481 | if ( nextA.isValid() ) { |
2482 | QString sum = mCalendar->nextSummary(); | 2482 | QString sum = mCalendar->nextSummary(); |
2483 | 2483 | ||
2484 | 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)); | 2484 | 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)); |
2485 | setCaption( message ); | 2485 | setCaption( message ); |
2486 | } | 2486 | } |
2487 | } | 2487 | } |
2488 | 2488 | ||
2489 | void MainWindow::resizeEvent( QResizeEvent* e) | 2489 | void MainWindow::resizeEvent( QResizeEvent* e) |
2490 | { | 2490 | { |
2491 | #ifndef DESKTOP_VERSION | 2491 | #ifndef DESKTOP_VERSION |
2492 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2492 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2493 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2493 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2494 | filterToolBar->hide(); | 2494 | filterToolBar->hide(); |
2495 | else | 2495 | else |
2496 | filterToolBar->show(); | 2496 | filterToolBar->show(); |
2497 | } | 2497 | } |
2498 | #endif | 2498 | #endif |
2499 | QMainWindow::resizeEvent( e); | 2499 | QMainWindow::resizeEvent( e); |
2500 | } | 2500 | } |