author | zautrix <zautrix> | 2005-06-29 10:36:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 10:36:31 (UTC) |
commit | b7044dfc9516d546683973985555c481d59fc677 (patch) (unidiff) | |
tree | b521090cfc8eb6c8c6a6f6f8167c83058ea1361b | |
parent | f226b4cd2ce06a6948811fe04d80fe3ffa44f695 (diff) | |
download | kdepimpi-b7044dfc9516d546683973985555c481d59fc677.zip kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.gz kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.bz2 |
journal fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 61 | ||||
-rw-r--r-- | korganizer/journalentry.h | 5 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 110 | ||||
-rw-r--r-- | korganizer/kojournalview.h | 10 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 7 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 1 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 14 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 |
10 files changed, 173 insertions, 38 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a62145a..697093e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -82,768 +82,769 @@ | |||
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); | 464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); |
465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
466 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | ||
466 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 467 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
467 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 468 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
468 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 469 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
469 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 470 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
470 | mTodoList->setNavigator( mNavigator ); | 471 | mTodoList->setNavigator( mNavigator ); |
471 | #if 0 | 472 | #if 0 |
472 | if ( QApplication::desktop()->width() < 480 ) { | 473 | if ( QApplication::desktop()->width() < 480 ) { |
473 | leftFrameLayout->addWidget(mFilterView); | 474 | leftFrameLayout->addWidget(mFilterView); |
474 | leftFrameLayout->addWidget(mTodoList, 2 ); | 475 | leftFrameLayout->addWidget(mTodoList, 2 ); |
475 | 476 | ||
476 | } else { | 477 | } else { |
477 | leftFrameLayout->addWidget(mTodoList,2 ); | 478 | leftFrameLayout->addWidget(mTodoList,2 ); |
478 | leftFrameLayout->addWidget(mFilterView ); | 479 | leftFrameLayout->addWidget(mFilterView ); |
479 | } | 480 | } |
480 | #endif | 481 | #endif |
481 | mFilterView->hide(); | 482 | mFilterView->hide(); |
482 | mCalEditView->hide(); | 483 | mCalEditView->hide(); |
483 | QWidget *rightBox = new QWidget( mMainFrame ); | 484 | QWidget *rightBox = new QWidget( mMainFrame ); |
484 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 485 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
485 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 486 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
486 | mRightFrame = new QWidgetStack( rightBox ); | 487 | mRightFrame = new QWidgetStack( rightBox ); |
487 | rightLayout->addWidget( mRightFrame, 10 ); | 488 | rightLayout->addWidget( mRightFrame, 10 ); |
488 | 489 | ||
489 | //mLeftFrame = (QWidget *)leftFrame; | 490 | //mLeftFrame = (QWidget *)leftFrame; |
490 | if ( KOPrefs::instance()->mVerticalScreen ) { | 491 | if ( KOPrefs::instance()->mVerticalScreen ) { |
491 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 492 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
492 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 493 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
493 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 494 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
494 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 495 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
495 | } else { | 496 | } else { |
496 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 497 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
497 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 498 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
498 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 499 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
499 | } | 500 | } |
500 | if ( !KOPrefs::instance()->mShowDateNavigator) | 501 | if ( !KOPrefs::instance()->mShowDateNavigator) |
501 | mDateNavigator->hide(); | 502 | mDateNavigator->hide(); |
502 | //qDebug("Calendarview Size %d %d ", width(), height()); | 503 | //qDebug("Calendarview Size %d %d ", width(), height()); |
503 | #endif | 504 | #endif |
504 | 505 | ||
505 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 506 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
506 | SLOT( showDates( const KCal::DateList & ) ) ); | 507 | SLOT( showDates( const KCal::DateList & ) ) ); |
507 | 508 | ||
508 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 509 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
509 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 510 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
510 | 511 | ||
511 | 512 | ||
512 | 513 | ||
513 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 514 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
514 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 515 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
515 | 516 | ||
516 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 517 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
517 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 518 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
518 | 519 | ||
519 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 520 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
520 | mNavigator, SLOT( selectPreviousYear() ) ); | 521 | mNavigator, SLOT( selectPreviousYear() ) ); |
521 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 522 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
522 | mNavigator, SLOT( selectNextYear() ) ); | 523 | mNavigator, SLOT( selectNextYear() ) ); |
523 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 524 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
524 | mNavigator, SLOT( selectPreviousMonth() ) ); | 525 | mNavigator, SLOT( selectPreviousMonth() ) ); |
525 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 526 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
526 | mNavigator, SLOT( selectNextMonth() ) ); | 527 | mNavigator, SLOT( selectNextMonth() ) ); |
527 | 528 | ||
528 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 529 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
529 | mNavigator, SLOT( selectPrevious() ) ); | 530 | mNavigator, SLOT( selectPrevious() ) ); |
530 | connect( mDateNavigator, SIGNAL( goNext() ), | 531 | connect( mDateNavigator, SIGNAL( goNext() ), |
531 | mNavigator, SLOT( selectNext() ) ); | 532 | mNavigator, SLOT( selectNext() ) ); |
532 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 533 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
533 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 534 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
534 | 535 | ||
535 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 536 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
536 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 537 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
537 | #if 0 | 538 | #if 0 |
538 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 539 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
539 | SLOT( incidenceAdded( Incidence *) ) ); | 540 | SLOT( incidenceAdded( Incidence *) ) ); |
540 | #endif | 541 | #endif |
541 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 542 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
542 | 543 | ||
543 | connect( this, SIGNAL( configChanged() ), | 544 | connect( this, SIGNAL( configChanged() ), |
544 | mDateNavigator, SLOT( updateConfig() ) ); | 545 | mDateNavigator, SLOT( updateConfig() ) ); |
545 | 546 | ||
546 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 547 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
547 | SLOT( newTodo() ) ); | 548 | SLOT( newTodo() ) ); |
548 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 549 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
549 | SLOT( newSubTodo( Todo * ) ) ); | 550 | SLOT( newSubTodo( Todo * ) ) ); |
550 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 551 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
551 | SLOT( editTodo( Todo * ) ) ); | 552 | SLOT( editTodo( Todo * ) ) ); |
552 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 553 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
553 | SLOT( showTodo( Todo *) ) ); | 554 | SLOT( showTodo( Todo *) ) ); |
554 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 555 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
555 | SLOT( deleteTodo( Todo *) ) ); | 556 | SLOT( deleteTodo( Todo *) ) ); |
556 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 557 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
557 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 558 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
558 | SLOT( purgeCompleted() ) ); | 559 | SLOT( purgeCompleted() ) ); |
559 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 560 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
560 | SIGNAL( todoModified( Todo *, int ) ) ); | 561 | SIGNAL( todoModified( Todo *, int ) ) ); |
561 | 562 | ||
562 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 563 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
563 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 564 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
564 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 565 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
565 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 566 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
566 | 567 | ||
567 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 568 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
568 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 569 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
569 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 570 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
570 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 571 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
571 | 572 | ||
572 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 573 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
573 | this, SLOT ( todo_unsub( Todo * ) ) ); | 574 | this, SLOT ( todo_unsub( Todo * ) ) ); |
574 | 575 | ||
575 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 576 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
576 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 577 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
577 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 578 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
578 | SLOT( updateTodo( Todo *, int ) ) ); | 579 | SLOT( updateTodo( Todo *, int ) ) ); |
579 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 580 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
580 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 581 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
581 | 582 | ||
582 | 583 | ||
583 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 584 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
584 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 585 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
585 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 586 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
586 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 587 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
587 | 588 | ||
588 | 589 | ||
589 | 590 | ||
590 | 591 | ||
591 | 592 | ||
592 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 593 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
593 | SLOT(checkClipboard())); | 594 | SLOT(checkClipboard())); |
594 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 595 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
595 | SLOT( processTodoListSelection( Incidence * ) ) ); | 596 | SLOT( processTodoListSelection( Incidence * ) ) ); |
596 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 597 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
597 | 598 | ||
598 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 599 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
599 | 600 | ||
600 | mDateFrame = new QVBox(0,0,WType_Popup); | 601 | mDateFrame = new QVBox(0,0,WType_Popup); |
601 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 602 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
602 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 603 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
603 | mDateFrame->setLineWidth(3); | 604 | mDateFrame->setLineWidth(3); |
604 | mDateFrame->hide(); | 605 | mDateFrame->hide(); |
605 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 606 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
606 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 607 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
607 | 608 | ||
608 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 609 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
609 | 610 | ||
610 | mEventEditor = mDialogManager->getEventEditor(); | 611 | mEventEditor = mDialogManager->getEventEditor(); |
611 | mTodoEditor = mDialogManager->getTodoEditor(); | 612 | mTodoEditor = mDialogManager->getTodoEditor(); |
612 | 613 | ||
613 | mFlagEditDescription = false; | 614 | mFlagEditDescription = false; |
614 | 615 | ||
615 | mSuspendTimer = new QTimer( this ); | 616 | mSuspendTimer = new QTimer( this ); |
616 | mAlarmTimer = new QTimer( this ); | 617 | mAlarmTimer = new QTimer( this ); |
617 | mRecheckAlarmTimer = new QTimer( this ); | 618 | mRecheckAlarmTimer = new QTimer( this ); |
618 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 619 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
619 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 620 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
620 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 621 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
621 | mAlarmDialog = new AlarmDialog( this ); | 622 | mAlarmDialog = new AlarmDialog( this ); |
622 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 623 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
623 | mAlarmDialog->setServerNotification( false ); | 624 | mAlarmDialog->setServerNotification( false ); |
624 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 625 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
625 | 626 | ||
626 | 627 | ||
627 | #ifndef DESKTOP_VERSION | 628 | #ifndef DESKTOP_VERSION |
628 | //US listen for arriving address resultsets | 629 | //US listen for arriving address resultsets |
629 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 630 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
630 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 631 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
631 | #endif | 632 | #endif |
632 | mDateNavigator->setCalendar( mCalendar ); | 633 | mDateNavigator->setCalendar( mCalendar ); |
633 | } | 634 | } |
634 | 635 | ||
635 | 636 | ||
636 | CalendarView::~CalendarView() | 637 | CalendarView::~CalendarView() |
637 | { | 638 | { |
638 | // kdDebug() << "~CalendarView()" << endl; | 639 | // kdDebug() << "~CalendarView()" << endl; |
639 | //qDebug("CalendarView::~CalendarView() "); | 640 | //qDebug("CalendarView::~CalendarView() "); |
640 | delete mDialogManager; | 641 | delete mDialogManager; |
641 | delete mViewManager; | 642 | delete mViewManager; |
642 | delete mStorage; | 643 | delete mStorage; |
643 | delete mDateFrame ; | 644 | delete mDateFrame ; |
644 | delete beamDialog; | 645 | delete beamDialog; |
645 | delete mEventViewerDialog; | 646 | delete mEventViewerDialog; |
646 | //kdDebug() << "~CalendarView() done" << endl; | 647 | //kdDebug() << "~CalendarView() done" << endl; |
647 | } | 648 | } |
648 | void CalendarView::checkAlarms() | 649 | void CalendarView::checkAlarms() |
649 | { | 650 | { |
650 | KConfig *config = KOGlobals::config(); | 651 | KConfig *config = KOGlobals::config(); |
651 | config->setGroup( "AppRun" ); | 652 | config->setGroup( "AppRun" ); |
652 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 653 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
653 | int daysto = dt.daysTo( QDate::currentDate() ); | 654 | int daysto = dt.daysTo( QDate::currentDate() ); |
654 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 655 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
655 | dt = dt.addDays( days ); | 656 | dt = dt.addDays( days ); |
656 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 657 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
657 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 658 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
658 | //qDebug("KO: Reading program stop %d ", secs); | 659 | //qDebug("KO: Reading program stop %d ", secs); |
659 | //secs -= ( 3600 * 24*3 ); // debug only | 660 | //secs -= ( 3600 * 24*3 ); // debug only |
660 | QDateTime latest = dt.addSecs ( secs ); | 661 | QDateTime latest = dt.addSecs ( secs ); |
661 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 662 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
662 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 663 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
663 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 664 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
664 | QPtrList<Incidence> al; | 665 | QPtrList<Incidence> al; |
665 | Incidence* inL = el.first(); | 666 | Incidence* inL = el.first(); |
666 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 667 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
667 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 668 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
668 | while ( inL ) { | 669 | while ( inL ) { |
669 | bool ok = false; | 670 | bool ok = false; |
670 | int offset = 0; | 671 | int offset = 0; |
671 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 672 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
672 | if ( ok ) { | 673 | if ( ok ) { |
673 | //qDebug("OK %s",next.toString().latin1()); | 674 | //qDebug("OK %s",next.toString().latin1()); |
674 | if ( next < cur ) { | 675 | if ( next < cur ) { |
675 | al.append( inL ); | 676 | al.append( inL ); |
676 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 677 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
677 | } | 678 | } |
678 | } | 679 | } |
679 | inL = el.next(); | 680 | inL = el.next(); |
680 | } | 681 | } |
681 | if ( al.count() ) { | 682 | if ( al.count() ) { |
682 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 683 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
683 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 684 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
684 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 685 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
685 | lay->setSpacing( 0 ); | 686 | lay->setSpacing( 0 ); |
686 | lay->setMargin( 0 ); | 687 | lay->setMargin( 0 ); |
687 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 688 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
688 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 689 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
689 | lay->addWidget( matb ); | 690 | lay->addWidget( matb ); |
690 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 691 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
691 | int wid = 210; | 692 | int wid = 210; |
692 | int x = QApplication::desktop()->width() - wid - 7; | 693 | int x = QApplication::desktop()->width() - wid - 7; |
693 | int y = QApplication::desktop()->height() - wid - 70; | 694 | int y = QApplication::desktop()->height() - wid - 70; |
694 | dia->setGeometry ( x,y,wid,wid); | 695 | dia->setGeometry ( x,y,wid,wid); |
695 | } else { | 696 | } else { |
696 | int si = 220; | 697 | int si = 220; |
697 | if ( QApplication::desktop()->width() > 470 ) | 698 | if ( QApplication::desktop()->width() > 470 ) |
698 | si = 400; | 699 | si = 400; |
699 | dia->resize(si,si/2); | 700 | dia->resize(si,si/2); |
700 | } | 701 | } |
701 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 702 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
702 | dia->show(); | 703 | dia->show(); |
703 | 704 | ||
704 | } | 705 | } |
705 | } | 706 | } |
706 | void CalendarView::showDay( QDate d ) | 707 | void CalendarView::showDay( QDate d ) |
707 | { | 708 | { |
708 | dateNavigator()->blockSignals( true ); | 709 | dateNavigator()->blockSignals( true ); |
709 | dateNavigator()->selectDate( d ); | 710 | dateNavigator()->selectDate( d ); |
710 | dateNavigator()->blockSignals( false ); | 711 | dateNavigator()->blockSignals( false ); |
711 | mViewManager->showDayView(); | 712 | mViewManager->showDayView(); |
712 | //dateNavigator()->selectDate( d ); | 713 | //dateNavigator()->selectDate( d ); |
713 | } | 714 | } |
714 | void CalendarView::timerAlarm() | 715 | void CalendarView::timerAlarm() |
715 | { | 716 | { |
716 | //qDebug("CalendarView::timerAlarm() "); | 717 | //qDebug("CalendarView::timerAlarm() "); |
717 | computeAlarm(mAlarmNotification ); | 718 | computeAlarm(mAlarmNotification ); |
718 | } | 719 | } |
719 | 720 | ||
720 | void CalendarView::suspendAlarm() | 721 | void CalendarView::suspendAlarm() |
721 | { | 722 | { |
722 | //qDebug(" CalendarView::suspendAlarm() "); | 723 | //qDebug(" CalendarView::suspendAlarm() "); |
723 | computeAlarm(mSuspendAlarmNotification ); | 724 | computeAlarm(mSuspendAlarmNotification ); |
724 | 725 | ||
725 | } | 726 | } |
726 | 727 | ||
727 | void CalendarView::startAlarm( QString mess , QString filename) | 728 | void CalendarView::startAlarm( QString mess , QString filename) |
728 | { | 729 | { |
729 | 730 | ||
730 | topLevelWidget()->showNormal(); | 731 | topLevelWidget()->showNormal(); |
731 | topLevelWidget()->setActiveWindow(); | 732 | topLevelWidget()->setActiveWindow(); |
732 | topLevelWidget()->raise(); | 733 | topLevelWidget()->raise(); |
733 | 734 | ||
734 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 735 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
735 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 736 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
736 | 737 | ||
737 | } | 738 | } |
738 | 739 | ||
739 | void CalendarView::checkNextTimerAlarm() | 740 | void CalendarView::checkNextTimerAlarm() |
740 | { | 741 | { |
741 | mCalendar->checkAlarmForIncidence( 0, true ); | 742 | mCalendar->checkAlarmForIncidence( 0, true ); |
742 | } | 743 | } |
743 | 744 | ||
744 | void CalendarView::computeAlarm( QString msg ) | 745 | void CalendarView::computeAlarm( QString msg ) |
745 | { | 746 | { |
746 | 747 | ||
747 | QString mess = msg; | 748 | QString mess = msg; |
748 | QString mAlarmMessage = mess.mid( 9 ); | 749 | QString mAlarmMessage = mess.mid( 9 ); |
749 | QString filename = MainWindow::resourcePath(); | 750 | QString filename = MainWindow::resourcePath(); |
750 | filename += "koalarm.wav"; | 751 | filename += "koalarm.wav"; |
751 | QString tempfilename; | 752 | QString tempfilename; |
752 | if ( mess.left( 13 ) == "suspend_alarm") { | 753 | if ( mess.left( 13 ) == "suspend_alarm") { |
753 | bool error = false; | 754 | bool error = false; |
754 | int len = mess.mid( 13 ).find("+++"); | 755 | int len = mess.mid( 13 ).find("+++"); |
755 | if ( len < 2 ) | 756 | if ( len < 2 ) |
756 | error = true; | 757 | error = true; |
757 | else { | 758 | else { |
758 | tempfilename = mess.mid( 13, len ); | 759 | tempfilename = mess.mid( 13, len ); |
759 | if ( !QFile::exists( tempfilename ) ) | 760 | if ( !QFile::exists( tempfilename ) ) |
760 | error = true; | 761 | error = true; |
761 | } | 762 | } |
762 | if ( ! error ) { | 763 | if ( ! error ) { |
763 | filename = tempfilename; | 764 | filename = tempfilename; |
764 | } | 765 | } |
765 | mAlarmMessage = mess.mid( 13+len+3 ); | 766 | mAlarmMessage = mess.mid( 13+len+3 ); |
766 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 767 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
767 | startAlarm( mAlarmMessage, filename); | 768 | startAlarm( mAlarmMessage, filename); |
768 | return; | 769 | return; |
769 | } | 770 | } |
770 | if ( mess.left( 11 ) == "timer_alarm") { | 771 | if ( mess.left( 11 ) == "timer_alarm") { |
771 | //mTimerTime = 0; | 772 | //mTimerTime = 0; |
772 | startAlarm( mess.mid( 11 ), filename ); | 773 | startAlarm( mess.mid( 11 ), filename ); |
773 | return; | 774 | return; |
774 | } | 775 | } |
775 | if ( mess.left( 10 ) == "proc_alarm") { | 776 | if ( mess.left( 10 ) == "proc_alarm") { |
776 | bool error = false; | 777 | bool error = false; |
777 | int len = mess.mid( 10 ).find("+++"); | 778 | int len = mess.mid( 10 ).find("+++"); |
778 | if ( len < 2 ) | 779 | if ( len < 2 ) |
779 | error = true; | 780 | error = true; |
780 | else { | 781 | else { |
781 | tempfilename = mess.mid( 10, len ); | 782 | tempfilename = mess.mid( 10, len ); |
782 | if ( !QFile::exists( tempfilename ) ) | 783 | if ( !QFile::exists( tempfilename ) ) |
783 | error = true; | 784 | error = true; |
784 | } | 785 | } |
785 | if ( error ) { | 786 | if ( error ) { |
786 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 787 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
787 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 788 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
788 | } else { | 789 | } else { |
789 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 790 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
790 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 791 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
791 | #ifndef _WIN32_ | 792 | #ifndef _WIN32_ |
792 | if ( vfork () == 0 ) { | 793 | if ( vfork () == 0 ) { |
793 | execl ( tempfilename.latin1(), 0 ); | 794 | execl ( tempfilename.latin1(), 0 ); |
794 | return; | 795 | return; |
795 | } | 796 | } |
796 | #else | 797 | #else |
797 | QProcess* p = new QProcess(); | 798 | QProcess* p = new QProcess(); |
798 | p->addArgument( tempfilename.latin1() ); | 799 | p->addArgument( tempfilename.latin1() ); |
799 | p->start(); | 800 | p->start(); |
800 | return; | 801 | return; |
801 | #endif | 802 | #endif |
802 | 803 | ||
803 | return; | 804 | return; |
804 | } | 805 | } |
805 | 806 | ||
806 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 807 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
807 | } | 808 | } |
808 | if ( mess.left( 11 ) == "audio_alarm") { | 809 | if ( mess.left( 11 ) == "audio_alarm") { |
809 | bool error = false; | 810 | bool error = false; |
810 | int len = mess.mid( 11 ).find("+++"); | 811 | int len = mess.mid( 11 ).find("+++"); |
811 | if ( len < 2 ) | 812 | if ( len < 2 ) |
812 | error = true; | 813 | error = true; |
813 | else { | 814 | else { |
814 | tempfilename = mess.mid( 11, len ); | 815 | tempfilename = mess.mid( 11, len ); |
815 | if ( !QFile::exists( tempfilename ) ) | 816 | if ( !QFile::exists( tempfilename ) ) |
816 | error = true; | 817 | error = true; |
817 | } | 818 | } |
818 | if ( ! error ) { | 819 | if ( ! error ) { |
819 | filename = tempfilename; | 820 | filename = tempfilename; |
820 | } | 821 | } |
821 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 822 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
822 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 823 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
823 | } | 824 | } |
824 | if ( mess.left( 9 ) == "cal_alarm") { | 825 | if ( mess.left( 9 ) == "cal_alarm") { |
825 | mAlarmMessage = mess.mid( 9 ) ; | 826 | mAlarmMessage = mess.mid( 9 ) ; |
826 | } | 827 | } |
827 | 828 | ||
828 | startAlarm( mAlarmMessage, filename ); | 829 | startAlarm( mAlarmMessage, filename ); |
829 | 830 | ||
830 | 831 | ||
831 | } | 832 | } |
832 | 833 | ||
833 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 834 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
834 | { | 835 | { |
835 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 836 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
836 | 837 | ||
837 | mSuspendAlarmNotification = noti; | 838 | mSuspendAlarmNotification = noti; |
838 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 839 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
839 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 840 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
840 | mSuspendTimer->start( ms , true ); | 841 | mSuspendTimer->start( ms , true ); |
841 | 842 | ||
842 | } | 843 | } |
843 | 844 | ||
844 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 845 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
845 | { | 846 | { |
846 | mNextAlarmDateTime = qdt; | 847 | mNextAlarmDateTime = qdt; |
847 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 848 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
848 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 849 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
849 | #ifndef DESKTOP_VERSION | 850 | #ifndef DESKTOP_VERSION |
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index c19a5ca..7274849 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,250 +1,287 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // | 24 | // |
25 | // Journal Entry | 25 | // Journal Entry |
26 | 26 | ||
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qtextcodec.h> | 33 | #include <qtextcodec.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <ktextedit.h> | 41 | #include <ktextedit.h> |
42 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | 45 | ||
46 | #include <libkcal/journal.h> | 46 | #include <libkcal/journal.h> |
47 | #include <libkcal/calendarresources.h> | 47 | #include <libkcal/calendarresources.h> |
48 | #include <libkcal/resourcecalendar.h> | 48 | #include <libkcal/resourcecalendar.h> |
49 | #include <kresources/resourceselectdialog.h> | 49 | #include <kresources/resourceselectdialog.h> |
50 | 50 | ||
51 | #include "journalentry.h" | 51 | #include "journalentry.h" |
52 | //#include "journalentry.moc" | 52 | //#include "journalentry.moc" |
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
57 | QFrame(parent) | 57 | QFrame(parent) |
58 | { | 58 | { |
59 | showOnlyMode = false; | ||
59 | mCalendar = calendar; | 60 | mCalendar = calendar; |
60 | mJournal = 0; | 61 | mJournal = 0; |
61 | mDirty = false; | 62 | mDirty = false; |
62 | 63 | ||
63 | QHBox * vb = new QHBox ( this ); | 64 | QHBox * vb = new QHBox ( this ); |
65 | QPushButton * newJournal = new QPushButton( vb ); | ||
66 | QIconSet icon; | ||
67 | if ( QApplication::desktop()->width() < 321 ) | ||
68 | icon = SmallIcon("ko16old"); | ||
69 | else | ||
70 | icon = SmallIcon("ko24old"); | ||
71 | newJournal->setIconSet (icon ) ; | ||
72 | int size = newJournal->sizeHint().height(); | ||
73 | newJournal->setFixedSize( size, size ); | ||
74 | |||
75 | |||
76 | QPushButton * toggleJournal = new QPushButton( vb ); | ||
77 | icon = SmallIcon("1updownarrow"); | ||
78 | toggleJournal->setIconSet (icon ) ; | ||
79 | //int size = toggleJournal->sizeHint().height(); | ||
80 | toggleJournal->setFixedSize( size * 2 /3 , size ); | ||
81 | |||
82 | |||
83 | |||
84 | mTitleLabel = new QLabel(i18n("Title"),vb); | ||
85 | mTitleLabel->setMargin(2); | ||
86 | mTitleLabel->setAlignment(AlignCenter); | ||
64 | QPushButton * loadTemplate = new QPushButton( vb ); | 87 | QPushButton * loadTemplate = new QPushButton( vb ); |
65 | QPushButton * saveTemplate = new QPushButton( vb ); | 88 | QPushButton * saveTemplate = new QPushButton( vb ); |
66 | QIconSet icon; | ||
67 | if ( QApplication::desktop()->width() < 321 ) | 89 | if ( QApplication::desktop()->width() < 321 ) |
68 | icon = SmallIcon("fileexport16"); | 90 | icon = SmallIcon("fileexport16"); |
69 | else | 91 | else |
70 | icon = SmallIcon("fileexport"); | 92 | icon = SmallIcon("fileexport"); |
71 | saveTemplate->setIconSet (icon ) ; | 93 | saveTemplate->setIconSet (icon ) ; |
72 | int size = saveTemplate->sizeHint().height(); | 94 | //size = saveTemplate->sizeHint().height(); |
73 | saveTemplate->setFixedSize( size, size ); | 95 | saveTemplate->setFixedSize( size, size ); |
74 | if ( QApplication::desktop()->width() < 321 ) | 96 | if ( QApplication::desktop()->width() < 321 ) |
75 | icon = SmallIcon("fileimport16"); | 97 | icon = SmallIcon("fileimport16"); |
76 | else | 98 | else |
77 | icon = SmallIcon("fileimport"); | 99 | icon = SmallIcon("fileimport"); |
78 | loadTemplate->setIconSet (icon ) ; | 100 | loadTemplate->setIconSet (icon ) ; |
79 | loadTemplate->setFixedSize( size, size ); | 101 | loadTemplate->setFixedSize( size, size ); |
80 | |||
81 | mTitleLabel = new QLabel(i18n("Title"),vb); | ||
82 | mTitleLabel->setMargin(2); | ||
83 | mTitleLabel->setAlignment(AlignCenter); | ||
84 | |||
85 | mEditor = new KTextEdit(this); | 102 | mEditor = new KTextEdit(this); |
86 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); | 103 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); |
87 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
88 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 105 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
89 | #endif | 106 | #endif |
90 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 107 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
91 | QBoxLayout *topLayout = new QVBoxLayout(this); | 108 | QBoxLayout *topLayout = new QVBoxLayout(this); |
92 | topLayout->addWidget(vb); | 109 | topLayout->addWidget(vb); |
93 | topLayout->addWidget(mEditor); | 110 | topLayout->addWidget(mEditor); |
94 | mEditor->installEventFilter(this); | 111 | mEditor->installEventFilter(this); |
95 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 112 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
96 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 113 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
114 | connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); | ||
115 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | ||
97 | } | 116 | } |
98 | 117 | ||
99 | JournalEntry::~JournalEntry() | 118 | JournalEntry::~JournalEntry() |
100 | { | 119 | { |
101 | } | 120 | } |
102 | 121 | ||
103 | void JournalEntry::slotSaveTemplate() | 122 | void JournalEntry::slotSaveTemplate() |
104 | { | 123 | { |
105 | QString fileName =locateLocal( "templates", "journals" ); | 124 | QString fileName =locateLocal( "templates", "journals" ); |
106 | QDir t_dir; | 125 | QDir t_dir; |
107 | if ( !t_dir.exists(fileName) ) | 126 | if ( !t_dir.exists(fileName) ) |
108 | t_dir.mkdir ( fileName ); | 127 | t_dir.mkdir ( fileName ); |
109 | fileName += "/journal"; | 128 | fileName += "/journal"; |
110 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 129 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
111 | if ( fileName.length() == 0 ) | 130 | if ( fileName.length() == 0 ) |
112 | return; | 131 | return; |
113 | 132 | ||
114 | QFile fileIn( fileName ); | 133 | QFile fileIn( fileName ); |
115 | if (!fileIn.open( IO_WriteOnly ) ) { | 134 | if (!fileIn.open( IO_WriteOnly ) ) { |
116 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 135 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
117 | .arg( fileName ) ); | 136 | .arg( fileName ) ); |
118 | return; | 137 | return; |
119 | } | 138 | } |
120 | // QString text; | 139 | // QString text; |
121 | QTextStream tsIn( &fileIn ); | 140 | QTextStream tsIn( &fileIn ); |
122 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 141 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
123 | tsIn << mEditor->text(); | 142 | tsIn << mEditor->text(); |
124 | fileIn.close(); | 143 | fileIn.close(); |
125 | } | 144 | } |
126 | void JournalEntry::slotLoadTemplate() | 145 | void JournalEntry::slotLoadTemplate() |
127 | { | 146 | { |
128 | QString fileName =locateLocal( "templates", "journals" ); | 147 | QString fileName =locateLocal( "templates", "journals" ); |
129 | QDir t_dir; | 148 | QDir t_dir; |
130 | if ( !t_dir.exists(fileName) ) | 149 | if ( !t_dir.exists(fileName) ) |
131 | t_dir.mkdir ( fileName ); | 150 | t_dir.mkdir ( fileName ); |
132 | fileName += "/journal"; | 151 | fileName += "/journal"; |
133 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 152 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
134 | if ( fileName.length() == 0 ) | 153 | if ( fileName.length() == 0 ) |
135 | return; | 154 | return; |
136 | QFile fileIn( fileName ); | 155 | QFile fileIn( fileName ); |
137 | if (!fileIn.open( IO_ReadOnly ) ) { | 156 | if (!fileIn.open( IO_ReadOnly ) ) { |
138 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 157 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
139 | .arg( fileName ) ); | 158 | .arg( fileName ) ); |
140 | return; | 159 | return; |
141 | } | 160 | } |
142 | QTextStream tsIn( &fileIn ); | 161 | QTextStream tsIn( &fileIn ); |
143 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 162 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
144 | QString text = tsIn.read(); | 163 | QString text = tsIn.read(); |
145 | fileIn.close(); | 164 | fileIn.close(); |
146 | int line, col; | 165 | int line, col; |
147 | mEditor->getCursorPosition (& line, & col ); | 166 | mEditor->getCursorPosition (& line, & col ); |
148 | mEditor-> insertAt ( text, line, col, true ); | 167 | mEditor-> insertAt ( text, line, col, true ); |
149 | //mEditor->setIgnoreMark( true ); | 168 | //mEditor->setIgnoreMark( true ); |
150 | setDirty(); | 169 | setDirty(); |
151 | } | 170 | } |
152 | void JournalEntry::setDate(const QDate &date) | 171 | void JournalEntry::setDate(const QDate &date) |
153 | { | 172 | { |
173 | showOnlyMode = false; | ||
174 | mDate = date; | ||
154 | writeJournal(); | 175 | writeJournal(); |
176 | int id = mCalendar->defaultCalendar(); | ||
177 | if ( id == 1 ) { | ||
178 | mTitleLabel->setText(KGlobal::locale()->formatDate(date)); | ||
179 | } else { | ||
180 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | ||
181 | mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); | ||
182 | } | ||
183 | } | ||
155 | 184 | ||
156 | mTitleLabel->setText(KGlobal::locale()->formatDate(date)); | 185 | void JournalEntry::toggleShowJournal() |
157 | 186 | { | |
158 | 187 | if ( showOnlyMode ) | |
159 | mDate = date; | 188 | emit showJournalOnly( 0 ); |
189 | else | ||
190 | emit showJournalOnly( mJournal ); | ||
160 | } | 191 | } |
161 | 192 | ||
162 | void JournalEntry::setJournal(Journal *journal) | 193 | void JournalEntry::setJournal(Journal *journal) |
163 | { | 194 | { |
164 | writeJournal(); | 195 | writeJournal(); |
165 | 196 | ||
166 | mJournal = journal; | 197 | mJournal = journal; |
167 | 198 | ||
168 | mEditor->setText(mJournal->description()); | 199 | mEditor->setText(mJournal->description()); |
169 | 200 | int id = mJournal->calID(); | |
201 | if ( id > 1 ) { | ||
202 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | ||
203 | mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); | ||
204 | } else { | ||
205 | mTitleLabel->setText(KGlobal::locale()->formatDate(mDate)); | ||
206 | } | ||
170 | mDirty = false; | 207 | mDirty = false; |
171 | } | 208 | } |
172 | 209 | ||
173 | Journal *JournalEntry::journal() const | 210 | Journal *JournalEntry::journal() const |
174 | { | 211 | { |
175 | return mJournal; | 212 | return mJournal; |
176 | } | 213 | } |
177 | 214 | ||
178 | void JournalEntry::setDirty() | 215 | void JournalEntry::setDirty() |
179 | { | 216 | { |
180 | mDirty = true; | 217 | mDirty = true; |
181 | 218 | ||
182 | // kdDebug() << "JournalEntry::setDirty()" << endl; | 219 | // kdDebug() << "JournalEntry::setDirty()" << endl; |
183 | } | 220 | } |
184 | 221 | ||
185 | void JournalEntry::clear() | 222 | void JournalEntry::clear() |
186 | { | 223 | { |
187 | mJournal = 0; | 224 | mJournal = 0; |
188 | mEditor->setText(""); | 225 | mEditor->setText(""); |
189 | } | 226 | } |
190 | 227 | ||
191 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 228 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
192 | { | 229 | { |
193 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 230 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
194 | 231 | ||
195 | if ( e->type() == QEvent::FocusOut ) { | 232 | if ( e->type() == QEvent::FocusOut ) { |
196 | writeJournal(); | 233 | writeJournal(); |
197 | } | 234 | } |
198 | if ( e->type() == QEvent::KeyPress ) { | 235 | if ( e->type() == QEvent::KeyPress ) { |
199 | QKeyEvent * k = (QKeyEvent *) e; | 236 | QKeyEvent * k = (QKeyEvent *) e; |
200 | if ( k->state() == Qt::ControlButton ) { | 237 | if ( k->state() == Qt::ControlButton ) { |
201 | k->ignore(); | 238 | k->ignore(); |
202 | //return true; | 239 | //return true; |
203 | } | 240 | } |
204 | } | 241 | } |
205 | 242 | ||
206 | return QFrame::eventFilter( o, e ); // standard event processing | 243 | return QFrame::eventFilter( o, e ); // standard event processing |
207 | } | 244 | } |
208 | 245 | ||
209 | void JournalEntry::writeJournal() | 246 | void JournalEntry::writeJournal() |
210 | { | 247 | { |
211 | // kdDebug() << "JournalEntry::writeJournal()" << endl; | 248 | // kdDebug() << "JournalEntry::writeJournal()" << endl; |
212 | if (!mDirty) return; | 249 | if (!mDirty) return; |
213 | 250 | ||
214 | if (mEditor->text().isEmpty()) { | 251 | if (mEditor->text().isEmpty()) { |
215 | if ( mJournal ) { | 252 | if ( mJournal ) { |
216 | mDirty = false; | 253 | mDirty = false; |
217 | bool conf = KOPrefs::instance()->mConfirm; | 254 | bool conf = KOPrefs::instance()->mConfirm; |
218 | KOPrefs::instance()->mConfirm = false; | 255 | KOPrefs::instance()->mConfirm = false; |
219 | emit deleteJournal(mJournal); | 256 | emit deleteJournal(mJournal); |
220 | KOPrefs::instance()->mConfirm = conf; | 257 | KOPrefs::instance()->mConfirm = conf; |
221 | mJournal = 0; | 258 | mJournal = 0; |
222 | } | 259 | } |
223 | return; | 260 | return; |
224 | } | 261 | } |
225 | 262 | ||
226 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 263 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
227 | 264 | ||
228 | if (!mJournal) { | 265 | if (!mJournal) { |
229 | mJournal = new Journal; | 266 | mJournal = new Journal; |
230 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 267 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
231 | mCalendar->addJournal(mJournal); | 268 | mCalendar->addJournal(mJournal); |
232 | } | 269 | } |
233 | 270 | ||
234 | mJournal->setDescription(mEditor->text()); | 271 | mJournal->setDescription(mEditor->text()); |
235 | //qDebug("tttt%s ", mEditor->text().latin1()); | 272 | //qDebug("tttt%s ", mEditor->text().latin1()); |
236 | 273 | ||
237 | mDirty = false; | 274 | mDirty = false; |
238 | } | 275 | } |
239 | 276 | ||
240 | void JournalEntry::flushEntry() | 277 | void JournalEntry::flushEntry() |
241 | { | 278 | { |
242 | if (!mDirty) return; | 279 | if (!mDirty) return; |
243 | 280 | ||
244 | writeJournal(); | 281 | writeJournal(); |
245 | } | 282 | } |
246 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) | 283 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) |
247 | { | 284 | { |
248 | e->ignore(); | 285 | e->ignore(); |
249 | 286 | ||
250 | } | 287 | } |
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index f1a1fef..85ad5df 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h | |||
@@ -1,75 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef JOURNALENTRY_H | 23 | #ifndef JOURNALENTRY_H |
24 | #define JOURNALENTRY_H | 24 | #define JOURNALENTRY_H |
25 | // | 25 | // |
26 | // Widget showing one Journal entry | 26 | // Widget showing one Journal entry |
27 | 27 | ||
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | class QLabel; | 32 | class QLabel; |
33 | class KTextEdit; | 33 | class KTextEdit; |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | class JournalEntry : public QFrame { | 37 | class JournalEntry : public QFrame { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | public: | 39 | public: |
40 | JournalEntry(Calendar *,QWidget *parent); | 40 | JournalEntry(Calendar *,QWidget *parent); |
41 | virtual ~JournalEntry(); | 41 | virtual ~JournalEntry(); |
42 | 42 | ||
43 | void setJournal(Journal *); | 43 | void setJournal(Journal *); |
44 | Journal *journal() const; | 44 | Journal *journal() const; |
45 | 45 | ||
46 | void setDate(const QDate &); | 46 | void setDate(const QDate &); |
47 | 47 | ||
48 | void clear(); | 48 | void clear(); |
49 | 49 | ||
50 | void flushEntry(); | 50 | void flushEntry(); |
51 | void setShowOnly() {showOnlyMode = true;} | ||
51 | 52 | ||
52 | protected slots: | 53 | protected slots: |
53 | void slotSaveTemplate(); | 54 | void slotSaveTemplate(); |
54 | void slotLoadTemplate(); | 55 | void slotLoadTemplate(); |
55 | void setDirty(); | 56 | void setDirty(); |
57 | void toggleShowJournal(); | ||
56 | signals: | 58 | signals: |
57 | void deleteJournal(Journal *); | 59 | void deleteJournal(Journal *); |
60 | void newJournal(); | ||
61 | void showJournalOnly( Journal * ); | ||
58 | 62 | ||
59 | protected: | 63 | protected: |
60 | bool eventFilter( QObject *o, QEvent *e ); | 64 | bool eventFilter( QObject *o, QEvent *e ); |
61 | 65 | ||
62 | void writeJournal(); | 66 | void writeJournal(); |
63 | 67 | ||
64 | private: | 68 | private: |
69 | bool showOnlyMode; | ||
65 | Calendar *mCalendar; | 70 | Calendar *mCalendar; |
66 | Journal *mJournal; | 71 | Journal *mJournal; |
67 | QDate mDate; | 72 | QDate mDate; |
68 | void keyPressEvent ( QKeyEvent * ) ; | 73 | void keyPressEvent ( QKeyEvent * ) ; |
69 | QLabel *mTitleLabel; | 74 | QLabel *mTitleLabel; |
70 | KTextEdit *mEditor; | 75 | KTextEdit *mEditor; |
71 | 76 | ||
72 | bool mDirty; | 77 | bool mDirty; |
73 | }; | 78 | }; |
74 | 79 | ||
75 | #endif | 80 | #endif |
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp | |||
@@ -1,116 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // | 24 | // |
25 | // View of Journal entries | 25 | // View of Journal entries |
26 | 26 | ||
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | 29 | ||
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include "koprefs.h" | 32 | #include "koprefs.h" |
33 | 33 | ||
34 | #include <libkcal/calendar.h> | 34 | #include <libkcal/calendar.h> |
35 | 35 | ||
36 | #include "journalentry.h" | 36 | #include "journalentry.h" |
37 | 37 | ||
38 | #include "kojournalview.h" | 38 | #include "kojournalview.h" |
39 | using namespace KOrg; | 39 | using namespace KOrg; |
40 | 40 | ||
41 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, | 41 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, |
42 | const char *name) | 42 | const char *name) |
43 | : KOrg::BaseView(calendar, parent, name) | 43 | : KOrg::BaseView(calendar, parent, name) |
44 | { | 44 | { |
45 | mEntry = new JournalEntry(calendar,this); | 45 | mCalendar = calendar; |
46 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 46 | mTopLayout = new QVBoxLayout(this); |
47 | QBoxLayout *topLayout = new QVBoxLayout(this); | 47 | getNewEntry(); |
48 | topLayout->addWidget(mEntry); | ||
49 | connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; | ||
50 | } | 48 | } |
51 | 49 | ||
52 | KOJournalView::~KOJournalView() | 50 | KOJournalView::~KOJournalView() |
53 | { | 51 | { |
54 | } | 52 | } |
55 | 53 | ||
56 | int KOJournalView::currentDateCount() | 54 | int KOJournalView::currentDateCount() |
57 | { | 55 | { |
58 | return 0; | 56 | return 0; |
59 | } | 57 | } |
58 | JournalEntry* KOJournalView::getNewEntry() | ||
59 | { | ||
60 | JournalEntry* Entry = new JournalEntry(mCalendar,this); | ||
61 | jEntries.append( Entry ); | ||
62 | mTopLayout->addWidget(Entry); | ||
63 | Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); | ||
64 | connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; | ||
65 | connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; | ||
66 | connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; | ||
67 | return Entry; | ||
68 | } | ||
60 | 69 | ||
61 | QPtrList<Incidence> KOJournalView::selectedIncidences() | 70 | QPtrList<Incidence> KOJournalView::selectedIncidences() |
62 | { | 71 | { |
63 | QPtrList<Incidence> eventList; | 72 | QPtrList<Incidence> eventList; |
64 | 73 | ||
65 | return eventList; | 74 | return eventList; |
66 | } | 75 | } |
67 | void KOJournalView::updateConfig() | 76 | void KOJournalView::updateConfig() |
68 | { | 77 | { |
69 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 78 | JournalEntry* mEntry = jEntries.first(); |
79 | while ( mEntry ) { | ||
80 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | ||
81 | mEntry = jEntries.next(); | ||
82 | } | ||
70 | } | 83 | } |
71 | void KOJournalView::updateView() | 84 | void KOJournalView::updateView() |
72 | { | 85 | { |
73 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 86 | JournalEntry* mEntry = jEntries.first(); |
87 | while ( mEntry ) { | ||
88 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | ||
89 | mEntry = jEntries.next(); | ||
90 | } | ||
91 | showDates( mDate, QDate() ); | ||
74 | } | 92 | } |
75 | 93 | ||
76 | void KOJournalView::flushView() | 94 | void KOJournalView::flushView() |
77 | { | 95 | { |
78 | mEntry->flushEntry(); | 96 | JournalEntry* mEntry = jEntries.first(); |
97 | while ( mEntry ) { | ||
98 | mEntry->flushEntry(); | ||
99 | mEntry = jEntries.next(); | ||
100 | } | ||
79 | } | 101 | } |
80 | 102 | ||
81 | void KOJournalView::clearList() | 103 | void KOJournalView::clearList() |
82 | { | 104 | { |
83 | mEntry->clear(); | 105 | JournalEntry* mEntry = jEntries.first(); |
106 | while ( mEntry ) { | ||
107 | mEntry->clear(); | ||
108 | mEntry = jEntries.next(); | ||
109 | } | ||
84 | } | 110 | } |
85 | void KOJournalView::showDates(const QDate &start, const QDate &) | 111 | void KOJournalView::newJournal() |
86 | { | 112 | { |
87 | // kdDebug() << "KOJournalView::selectDates()" << endl; | 113 | Journal* mJournal = new Journal; |
114 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | ||
115 | mCalendar->addJournal(mJournal); | ||
116 | showDates( mDate, QDate() ); | ||
117 | } | ||
88 | 118 | ||
89 | mEntry->setDate(start); | 119 | void KOJournalView::showOnly ( Journal* j ) |
120 | { | ||
121 | if ( j == 0 ) { | ||
122 | showDates( mDate, QDate() ); | ||
123 | return; | ||
124 | } | ||
125 | QPtrList<Journal> jl; | ||
126 | jl.append ( j ); | ||
127 | showList( jl ); | ||
128 | JournalEntry* mEntry = jEntries.first(); | ||
129 | mEntry->setShowOnly(); | ||
130 | } | ||
131 | void KOJournalView::showList(QPtrList<Journal> jl) | ||
132 | { | ||
133 | JournalEntry* mEntry = jEntries.first(); | ||
134 | JournalEntry* firstEntry = mEntry; | ||
135 | int count = jl.count(); | ||
136 | int iii = 0; | ||
137 | while ( iii < count ) { | ||
138 | if ( !mEntry ) { | ||
139 | mEntry = getNewEntry(); | ||
140 | mEntry->show(); | ||
141 | mEntry->setDate(mDate); | ||
142 | mEntry->setJournal(jl.at(iii)); | ||
143 | mEntry = 0; | ||
144 | } else { | ||
145 | mEntry->setDate(mDate); | ||
146 | mEntry->setJournal(jl.at(iii)); | ||
147 | mEntry->show(); | ||
148 | mEntry = jEntries.next(); | ||
149 | } | ||
150 | ++iii; | ||
151 | } | ||
152 | while ( mEntry ) { | ||
153 | mEntry->setDate(mDate); | ||
154 | mEntry->clear(); | ||
155 | if ( mEntry != firstEntry ) | ||
156 | mEntry->hide(); | ||
157 | else | ||
158 | mEntry->show(); | ||
159 | mEntry = jEntries.next(); | ||
160 | } | ||
161 | } | ||
90 | 162 | ||
91 | Journal *j = calendar()->journal(start); | 163 | void KOJournalView::showDates(const QDate &start, const QDate &) |
92 | if (j) mEntry->setJournal(j); | 164 | { |
93 | else mEntry->clear(); | 165 | mDate = start; |
94 | 166 | QPtrList<Journal> jl = calendar()->journals4Date( start ); | |
95 | // emit incidenceSelected( 0 ); | 167 | showList( jl ); |
96 | } | 168 | } |
97 | 169 | ||
98 | void KOJournalView::showEvents(QPtrList<Event>) | 170 | void KOJournalView::showEvents(QPtrList<Event>) |
99 | { | 171 | { |
100 | // After new creation of list view no events are selected. | 172 | // After new creation of list view no events are selected. |
101 | // emit incidenceSelected( 0 ); | 173 | // emit incidenceSelected( 0 ); |
102 | } | 174 | } |
103 | 175 | ||
104 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) | 176 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) |
105 | { | 177 | { |
106 | updateView(); | 178 | updateView(); |
107 | } | 179 | } |
108 | 180 | ||
109 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) | 181 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) |
110 | { | 182 | { |
111 | //qDebug("keyPressEven "); | 183 | //qDebug("keyPressEven "); |
112 | if ( e->state() == Qt::ControlButton ) { | 184 | if ( e->state() == Qt::ControlButton ) { |
113 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) | 185 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) |
114 | e->ignore(); | 186 | e->ignore(); |
115 | } | 187 | } |
116 | } | 188 | } |
diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h index 445f940..aabf11c 100644 --- a/korganizer/kojournalview.h +++ b/korganizer/kojournalview.h | |||
@@ -1,68 +1,76 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KOJOURNALVIEW_H | 23 | #ifndef _KOJOURNALVIEW_H |
24 | #define _KOJOURNALVIEW_H | 24 | #define _KOJOURNALVIEW_H |
25 | 25 | ||
26 | #include <korganizer/baseview.h> | 26 | #include <korganizer/baseview.h> |
27 | #include <qlayout.h> | ||
27 | 28 | ||
28 | class JournalEntry; | 29 | class JournalEntry; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * This class provides a journal view. | 32 | * This class provides a journal view. |
32 | 33 | ||
33 | * @short View for Journal components. | 34 | * @short View for Journal components. |
34 | * @author Cornelius Schumacher <schumacher@kde.org> | 35 | * @author Cornelius Schumacher <schumacher@kde.org> |
35 | * @see KOBaseView | 36 | * @see KOBaseView |
36 | */ | 37 | */ |
37 | class KOJournalView : public KOrg::BaseView | 38 | class KOJournalView : public KOrg::BaseView |
38 | { | 39 | { |
39 | Q_OBJECT | 40 | Q_OBJECT |
40 | public: | 41 | public: |
41 | KOJournalView(Calendar *calendar, QWidget *parent = 0, | 42 | KOJournalView(Calendar *calendar, QWidget *parent = 0, |
42 | const char *name = 0); | 43 | const char *name = 0); |
43 | ~KOJournalView(); | 44 | ~KOJournalView(); |
44 | 45 | ||
45 | virtual int currentDateCount(); | 46 | virtual int currentDateCount(); |
46 | void clearList(); | 47 | void clearList(); |
47 | virtual QPtrList<Incidence> selectedIncidences(); | 48 | virtual QPtrList<Incidence> selectedIncidences(); |
48 | DateList selectedDates() | 49 | DateList selectedDates() |
49 | {DateList q; | 50 | {DateList q; |
50 | return q;}; | 51 | return q;}; |
51 | signals: | 52 | signals: |
52 | void deleteJournal(Journal *); | 53 | void deleteJournal(Journal *); |
53 | public slots: | 54 | public slots: |
55 | void showOnly ( Journal* ); | ||
56 | void newJournal(); | ||
54 | void updateView(); | 57 | void updateView(); |
55 | void flushView(); | 58 | void flushView(); |
56 | void updateConfig(); | 59 | void updateConfig(); |
57 | void showDates( const QDate &start, const QDate &end ); | 60 | void showDates( const QDate &start, const QDate &end ); |
58 | void showEvents(QPtrList<Event> eventList); | 61 | void showEvents(QPtrList<Event> eventList); |
59 | 62 | ||
60 | void changeEventDisplay(Event *, int); | 63 | void changeEventDisplay(Event *, int); |
61 | 64 | ||
62 | private: | 65 | private: |
63 | JournalEntry *mEntry; | 66 | void showList(QPtrList<Journal> jl); |
67 | Calendar *mCalendar; | ||
68 | JournalEntry* getNewEntry(); | ||
69 | QPtrList<JournalEntry> jEntries; | ||
64 | void keyPressEvent ( QKeyEvent * ) ; | 70 | void keyPressEvent ( QKeyEvent * ) ; |
71 | QBoxLayout *mTopLayout; | ||
72 | QDate mDate; | ||
65 | 73 | ||
66 | }; | 74 | }; |
67 | 75 | ||
68 | #endif | 76 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 5d9af6d..7b307f7 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,668 +1,675 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | flagResetViewChangeDate = 0; | 64 | flagResetViewChangeDate = 0; |
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") { | 91 | else if (view == "Month") { |
92 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 92 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
93 | showMonthView(); | 93 | showMonthView(); |
94 | else | 94 | else |
95 | showMonthViewWeek(); | 95 | showMonthViewWeek(); |
96 | } | 96 | } |
97 | else if (view == "List") showListView(); | 97 | else if (view == "List") showListView(); |
98 | else if (view == "Journal") showJournalView(); | 98 | else if (view == "Journal") showJournalView(); |
99 | else if (view == "TimeSpan") showTimeSpanView(); | 99 | else if (view == "TimeSpan") showTimeSpanView(); |
100 | else if (view == "Todo") showTodoView(); | 100 | else if (view == "Todo") showTodoView(); |
101 | else { | 101 | else { |
102 | config->setGroup( "Views" ); | 102 | config->setGroup( "Views" ); |
103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
104 | mCurrentAgendaView = dateCount; | 104 | mCurrentAgendaView = dateCount; |
105 | showAgendaView(); | 105 | showAgendaView(); |
106 | mCurrentAgendaView = dateCount; | 106 | mCurrentAgendaView = dateCount; |
107 | #ifdef DESKTOP_VERSION | 107 | #ifdef DESKTOP_VERSION |
108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); | 108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); |
109 | #endif | 109 | #endif |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | |||
113 | void KOViewManager::showDateView( int view, QDate date) | 114 | void KOViewManager::showDateView( int view, QDate date) |
114 | { | 115 | { |
115 | static int lastMode = 0; | 116 | static int lastMode = 0; |
116 | static int lastCount = 0; | 117 | static int lastCount = 0; |
117 | static bool lastNDMode = false; | 118 | static bool lastNDMode = false; |
118 | static QDate lastDate; | 119 | static QDate lastDate; |
119 | //qDebug("date %d %s", view, date.toString().latin1()); | 120 | //qDebug("date %d %s", view, date.toString().latin1()); |
120 | 121 | ||
121 | if (view != 9) | 122 | if (view != 9) |
122 | lastMode = 0; | 123 | lastMode = 0; |
123 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); | 124 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); |
124 | bool savemFlagShowNextxDays = mFlagShowNextxDays; | 125 | bool savemFlagShowNextxDays = mFlagShowNextxDays; |
125 | mFlagShowNextxDays = false; | 126 | mFlagShowNextxDays = false; |
126 | if ( view == 3 ) { | 127 | if ( view == 3 ) { |
127 | //mCurrentAgendaView = 1 ; | 128 | //mCurrentAgendaView = 1 ; |
128 | lastDate = mMainView->dateNavigator()->selectedDates().first(); | 129 | lastDate = mMainView->dateNavigator()->selectedDates().first(); |
129 | lastCount = mMainView->dateNavigator()->selectedDates().count(); | 130 | lastCount = mMainView->dateNavigator()->selectedDates().count(); |
130 | lastNDMode = savemFlagShowNextxDays; | 131 | lastNDMode = savemFlagShowNextxDays; |
131 | mMainView->dateNavigator()->selectDate( date ); | 132 | mMainView->dateNavigator()->selectDate( date ); |
132 | lastMode = 1; | 133 | lastMode = 1; |
133 | mCurrentAgendaView = 1 ; | 134 | mCurrentAgendaView = 1 ; |
134 | } else if (view == 4 ) { | 135 | } else if (view == 4 ) { |
135 | mCurrentAgendaView = 7 ; | 136 | mCurrentAgendaView = 7 ; |
136 | mMainView->dateNavigator()->selectDates( date, 7 ); | 137 | mMainView->dateNavigator()->selectDates( date, 7 ); |
137 | } else if (view == 5 ) { | 138 | } else if (view == 5 ) { |
138 | mCurrentAgendaView = 14 ; | 139 | mCurrentAgendaView = 14 ; |
139 | mMainView->dateNavigator()->selectDates( date, 14); | 140 | mMainView->dateNavigator()->selectDates( date, 14); |
140 | } else if (view == 6 ) { | 141 | } else if (view == 6 ) { |
141 | resetDateSilent( date,1); | 142 | resetDateSilent( date,1); |
142 | showMonthView(); | 143 | showMonthView(); |
143 | } else if (view == 7 ) { | 144 | } else if (view == 7 ) { |
144 | mMainView->dateNavigator()->selectDate( date ); | 145 | mMainView->dateNavigator()->selectDate( date ); |
145 | showJournalView(); | 146 | showJournalView(); |
146 | } else if (view == 8 ) { | 147 | } else if (view == 8 ) { |
147 | globalFlagBlockAgenda = 1; | 148 | globalFlagBlockAgenda = 1; |
148 | if ( mCurrentAgendaView != 3 ) | 149 | if ( mCurrentAgendaView != 3 ) |
149 | mCurrentAgendaView = -1; | 150 | mCurrentAgendaView = -1; |
150 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 151 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
151 | globalFlagBlockAgenda = 2; | 152 | globalFlagBlockAgenda = 2; |
152 | mMainView->dateNavigator()->selectDates( date , | 153 | mMainView->dateNavigator()->selectDates( date , |
153 | KOPrefs::instance()->mNextXDays ); | 154 | KOPrefs::instance()->mNextXDays ); |
154 | mFlagShowNextxDays = true; | 155 | mFlagShowNextxDays = true; |
155 | mCurrentAgendaView = 3 ; | 156 | mCurrentAgendaView = 3 ; |
156 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) | 157 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) |
157 | if ( lastMode ) { | 158 | if ( lastMode ) { |
158 | mCurrentAgendaView = lastCount ; | 159 | mCurrentAgendaView = lastCount ; |
159 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); | 160 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); |
160 | mFlagShowNextxDays = lastNDMode; | 161 | mFlagShowNextxDays = lastNDMode; |
161 | if ( mFlagShowNextxDays ) { | 162 | if ( mFlagShowNextxDays ) { |
162 | mCurrentAgendaView = 3 ; | 163 | mCurrentAgendaView = 3 ; |
163 | } | 164 | } |
164 | } else | 165 | } else |
165 | showWeekView(); | 166 | showWeekView(); |
166 | } else if (view == 10) { | 167 | } else if (view == 10) { |
167 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); | 168 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); |
168 | } | 169 | } |
169 | } | 170 | } |
170 | 171 | ||
171 | 172 | ||
172 | 173 | ||
173 | void KOViewManager::writeSettings(KConfig *config) | 174 | void KOViewManager::writeSettings(KConfig *config) |
174 | { | 175 | { |
175 | config->setGroup("General"); | 176 | config->setGroup("General"); |
176 | 177 | ||
177 | QString view; | 178 | QString view; |
178 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 179 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
179 | else if (mCurrentView == mMonthView) view = "Month"; | 180 | else if (mCurrentView == mMonthView) view = "Month"; |
180 | else if (mCurrentView == mListView) view = "List"; | 181 | else if (mCurrentView == mListView) view = "List"; |
181 | else if (mCurrentView == mJournalView) view = "Journal"; | 182 | else if (mCurrentView == mJournalView) view = "Journal"; |
182 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 183 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
183 | else if (mCurrentView == mTodoView) view = "Todo"; | 184 | else if (mCurrentView == mTodoView) view = "Todo"; |
184 | else view = "Agenda"; | 185 | else view = "Agenda"; |
185 | 186 | ||
186 | config->writeEntry("Current View",view); | 187 | config->writeEntry("Current View",view); |
187 | 188 | ||
188 | if (mAgendaView) { | 189 | if (mAgendaView) { |
189 | mAgendaView->writeSettings(config); | 190 | mAgendaView->writeSettings(config); |
190 | } | 191 | } |
191 | if (mTimeSpanView) { | 192 | if (mTimeSpanView) { |
192 | mTimeSpanView->writeSettings(config); | 193 | mTimeSpanView->writeSettings(config); |
193 | } | 194 | } |
194 | if (mListView) { | 195 | if (mListView) { |
195 | mListView->writeSettings(config); | 196 | mListView->writeSettings(config); |
196 | } | 197 | } |
197 | if (mTodoView) { | 198 | if (mTodoView) { |
198 | mTodoView->saveLayout(config,"Todo View"); | 199 | mTodoView->saveLayout(config,"Todo View"); |
199 | } | 200 | } |
200 | } | 201 | } |
201 | void KOViewManager::showNextView() | 202 | void KOViewManager::showNextView() |
202 | { | 203 | { |
203 | static int selecteddatescount = 0; | 204 | static int selecteddatescount = 0; |
204 | static QDate selecteddate = QDate ( 2000, 1, 1 ); | 205 | static QDate selecteddate = QDate ( 2000, 1, 1 ); |
205 | static QDate baseCycleDate = QDate ( 2000, 1, 1 ); | 206 | static QDate baseCycleDate = QDate ( 2000, 1, 1 ); |
206 | int newCount = mMainView->dateNavigator()->selectedDates().count(); | 207 | int newCount = mMainView->dateNavigator()->selectedDates().count(); |
207 | if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { | 208 | if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { |
208 | flagResetViewChangeDate = 1; | 209 | flagResetViewChangeDate = 1; |
209 | } | 210 | } |
210 | if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) | 211 | if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) |
211 | flagResetViewChangeDate = 1; | 212 | flagResetViewChangeDate = 1; |
212 | if ( flagResetViewChangeDate > 0 ) { | 213 | if ( flagResetViewChangeDate > 0 ) { |
213 | baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); | 214 | baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); |
214 | //qDebug("newCycle "); | 215 | //qDebug("newCycle "); |
215 | } | 216 | } |
216 | if (mCurrentView == mWhatsNextView) goto NEXT_X; | 217 | if (mCurrentView == mWhatsNextView) goto NEXT_X; |
217 | if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; | 218 | if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; |
218 | if (mCurrentView == mJournalView ) goto DAY_1; | 219 | if (mCurrentView == mJournalView ) goto DAY_1; |
219 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; | 220 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; |
220 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; | 221 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; |
221 | if (mCurrentView == mAgendaView ) goto DAY_6; | 222 | if (mCurrentView == mAgendaView ) goto DAY_6; |
222 | if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; | 223 | if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; |
223 | if (mCurrentView == mMonthView ) goto LIST; | 224 | if (mCurrentView == mMonthView ) goto LIST; |
224 | if (mCurrentView == mListView ) goto TODO; | 225 | if (mCurrentView == mListView ) goto TODO; |
225 | // if (mCurrentView == mTodoView ) goto NEXT; | 226 | // if (mCurrentView == mTodoView ) goto NEXT; |
226 | NEXT: | 227 | NEXT: |
227 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} | 228 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} |
228 | NEXT_X: | 229 | NEXT_X: |
229 | if ( KOPrefs::instance()->mShowIconNextDays ) { | 230 | if ( KOPrefs::instance()->mShowIconNextDays ) { |
230 | showNextXView(); | 231 | showNextXView(); |
231 | goto ENTE ; | 232 | goto ENTE ; |
232 | } | 233 | } |
233 | JOURNAL: | 234 | JOURNAL: |
234 | if ( KOPrefs::instance()->mShowIconJournal ) { | 235 | if ( KOPrefs::instance()->mShowIconJournal ) { |
235 | resetDateSilent( baseCycleDate , 1 ); | 236 | resetDateSilent( baseCycleDate , 1 ); |
236 | showJournalView() ;goto ENTE ;} | 237 | showJournalView() ;goto ENTE ;} |
237 | DAY_1: | 238 | DAY_1: |
238 | if ( KOPrefs::instance()->mShowIconDay1 ) { | 239 | if ( KOPrefs::instance()->mShowIconDay1 ) { |
239 | resetDateSilent( baseCycleDate , 2 ); | 240 | resetDateSilent( baseCycleDate , 2 ); |
240 | showDayView() ;goto ENTE ;} | 241 | showDayView() ;goto ENTE ;} |
241 | DAY_5: | 242 | DAY_5: |
242 | if ( KOPrefs::instance()->mShowIconDay5 ) { | 243 | if ( KOPrefs::instance()->mShowIconDay5 ) { |
243 | resetDateSilent( baseCycleDate , 2 ); | 244 | resetDateSilent( baseCycleDate , 2 ); |
244 | showWorkWeekView() ;goto ENTE ;} | 245 | showWorkWeekView() ;goto ENTE ;} |
245 | DAY_7: | 246 | DAY_7: |
246 | if ( KOPrefs::instance()->mShowIconDay7 ) { | 247 | if ( KOPrefs::instance()->mShowIconDay7 ) { |
247 | resetDateSilent( baseCycleDate , 2 ); | 248 | resetDateSilent( baseCycleDate , 2 ); |
248 | showWeekView();goto ENTE ;} | 249 | showWeekView();goto ENTE ;} |
249 | DAY_6: | 250 | DAY_6: |
250 | if ( KOPrefs::instance()->mShowIconDay6 ) { | 251 | if ( KOPrefs::instance()->mShowIconDay6 ) { |
251 | resetDateSilent( baseCycleDate , 2 ); | 252 | resetDateSilent( baseCycleDate , 2 ); |
252 | showMonthViewWeek();goto ENTE ;} | 253 | showMonthViewWeek();goto ENTE ;} |
253 | MONTH: | 254 | MONTH: |
254 | if ( KOPrefs::instance()->mShowIconMonth ) { | 255 | if ( KOPrefs::instance()->mShowIconMonth ) { |
255 | resetDateSilent( baseCycleDate , 2 ); | 256 | resetDateSilent( baseCycleDate , 2 ); |
256 | showMonthView();goto ENTE ;} | 257 | showMonthView();goto ENTE ;} |
257 | LIST: | 258 | LIST: |
258 | if ( KOPrefs::instance()->mShowIconList ) { | 259 | if ( KOPrefs::instance()->mShowIconList ) { |
259 | resetDateSilent( baseCycleDate , 2 ); | 260 | resetDateSilent( baseCycleDate , 2 ); |
260 | showListView() ;goto ENTE ;} | 261 | showListView() ;goto ENTE ;} |
261 | TODO: | 262 | TODO: |
262 | if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} | 263 | if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} |
263 | if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} | 264 | if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} |
264 | if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} | 265 | if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} |
265 | if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} | 266 | if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} |
266 | if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} | 267 | if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} |
267 | if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} | 268 | if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} |
268 | if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} | 269 | if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} |
269 | if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} | 270 | if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} |
270 | if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} | 271 | if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} |
271 | if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} | 272 | if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} |
272 | //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} | 273 | //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} |
273 | ENTE: | 274 | ENTE: |
274 | flagResetViewChangeDate = 0; | 275 | flagResetViewChangeDate = 0; |
275 | selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); | 276 | selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); |
276 | selecteddate = mMainView->dateNavigator()->selectedDates().first(); | 277 | selecteddate = mMainView->dateNavigator()->selectedDates().first(); |
277 | 278 | ||
278 | } | 279 | } |
279 | void KOViewManager::resetDateSilent( QDate date , int days ) | 280 | void KOViewManager::resetDateSilent( QDate date , int days ) |
280 | { | 281 | { |
281 | mMainView->dateNavigator()->blockSignals( true ); | 282 | mMainView->dateNavigator()->blockSignals( true ); |
282 | mMainView->dateNavigator()->selectDates( date , days ); | 283 | mMainView->dateNavigator()->selectDates( date , days ); |
283 | mMainView->dateNavigator()->blockSignals( false ); | 284 | mMainView->dateNavigator()->blockSignals( false ); |
284 | } | 285 | } |
286 | void KOViewManager::setDefaultCalendar(int) | ||
287 | { | ||
288 | if ( mJournalView && mCurrentView == mJournalView ) | ||
289 | mJournalView->updateView(); | ||
290 | } | ||
291 | |||
285 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 292 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
286 | { | 293 | { |
287 | if ( flagResetViewChangeDate < 10 ) | 294 | if ( flagResetViewChangeDate < 10 ) |
288 | ++flagResetViewChangeDate; | 295 | ++flagResetViewChangeDate; |
289 | //mFlagShowNextxDays = false; | 296 | //mFlagShowNextxDays = false; |
290 | //if(view == mCurrentView) return; | 297 | //if(view == mCurrentView) return; |
291 | if ( view == 0 ) { | 298 | if ( view == 0 ) { |
292 | view = mCurrentView; | 299 | view = mCurrentView; |
293 | if ( view == 0 ) | 300 | if ( view == 0 ) |
294 | return; | 301 | return; |
295 | } | 302 | } |
296 | bool callupdate = !(view == mCurrentView); | 303 | bool callupdate = !(view == mCurrentView); |
297 | bool full = fullScreen; | 304 | bool full = fullScreen; |
298 | if(view == mCurrentView && view != mWhatsNextView ) { | 305 | if(view == mCurrentView && view != mWhatsNextView ) { |
299 | if ( mCurrentAgendaView < 0 ) | 306 | if ( mCurrentAgendaView < 0 ) |
300 | return; | 307 | return; |
301 | if ( view != mMonthView ) | 308 | if ( view != mMonthView ) |
302 | full = mMainView->leftFrame()->isVisible(); | 309 | full = mMainView->leftFrame()->isVisible(); |
303 | } else { | 310 | } else { |
304 | if ( view == mMonthView && mMonthView) | 311 | if ( view == mMonthView && mMonthView) |
305 | ;//mMonthView->skipResize = true ; | 312 | ;//mMonthView->skipResize = true ; |
306 | mCurrentView = view; | 313 | mCurrentView = view; |
307 | // bool full = fullScreen; | 314 | // bool full = fullScreen; |
308 | bool isFull = !mMainView->leftFrame()->isVisible(); | 315 | bool isFull = !mMainView->leftFrame()->isVisible(); |
309 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 316 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
310 | full = true; | 317 | full = true; |
311 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 318 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
312 | full = false; | 319 | full = false; |
313 | } | 320 | } |
314 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 321 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
315 | //raiseCurrentView( full ); | 322 | //raiseCurrentView( full ); |
316 | mMainView->processIncidenceSelection( 0 ); | 323 | mMainView->processIncidenceSelection( 0 ); |
317 | //mMainView->updateView(); | 324 | //mMainView->updateView(); |
318 | raiseCurrentView( full, callupdate ); | 325 | raiseCurrentView( full, callupdate ); |
319 | mMainView->adaptNavigationUnits(); | 326 | mMainView->adaptNavigationUnits(); |
320 | mMainView->updateUnmanagedViews(); | 327 | mMainView->updateUnmanagedViews(); |
321 | } | 328 | } |
322 | 329 | ||
323 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 330 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
324 | { | 331 | { |
325 | mCurrentAgendaView = 0; | 332 | mCurrentAgendaView = 0; |
326 | if ( fullScreen ) { | 333 | if ( fullScreen ) { |
327 | mMainView->leftFrame()->hide(); | 334 | mMainView->leftFrame()->hide(); |
328 | } else { | 335 | } else { |
329 | mMainView->leftFrame()->show(); | 336 | mMainView->leftFrame()->show(); |
330 | } | 337 | } |
331 | //if ( mCurrentView == mMonthView ) qApp->processEvents(); | 338 | //if ( mCurrentView == mMonthView ) qApp->processEvents(); |
332 | emit signalFullScreen( !fullScreen ); | 339 | emit signalFullScreen( !fullScreen ); |
333 | if ( callUpdateView ) | 340 | if ( callUpdateView ) |
334 | mMainView->updateView(); | 341 | mMainView->updateView(); |
335 | 342 | ||
336 | if ( globalFlagBlockAgenda == 5 ) { | 343 | if ( globalFlagBlockAgenda == 5 ) { |
337 | globalFlagBlockAgenda = 4; | 344 | globalFlagBlockAgenda = 4; |
338 | globalFlagBlockAgendaItemPaint = 1; | 345 | globalFlagBlockAgendaItemPaint = 1; |
339 | } | 346 | } |
340 | mMainView->viewStack()->raiseWidget(mCurrentView); | 347 | mMainView->viewStack()->raiseWidget(mCurrentView); |
341 | if ( globalFlagBlockAgenda == 4 ) { | 348 | if ( globalFlagBlockAgenda == 4 ) { |
342 | if ( mCurrentView == mAgendaView ) { | 349 | if ( mCurrentView == mAgendaView ) { |
343 | //globalFlagBlockAgenda =1 ; | 350 | //globalFlagBlockAgenda =1 ; |
344 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 351 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
345 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 352 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
346 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 353 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
347 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 354 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
348 | qApp->processEvents(); | 355 | qApp->processEvents(); |
349 | //qDebug("qApp->processEvents() "); | 356 | //qDebug("qApp->processEvents() "); |
350 | globalFlagBlockAgenda = 0; | 357 | globalFlagBlockAgenda = 0; |
351 | mAgendaView->repaintAgenda(); | 358 | mAgendaView->repaintAgenda(); |
352 | 359 | ||
353 | } | 360 | } |
354 | globalFlagBlockAgenda = 0; | 361 | globalFlagBlockAgenda = 0; |
355 | } | 362 | } |
356 | emit signalAgendaView( mCurrentView == mAgendaView ); | 363 | emit signalAgendaView( mCurrentView == mAgendaView ); |
357 | //qDebug("raiseCurrentView ende "); | 364 | //qDebug("raiseCurrentView ende "); |
358 | 365 | ||
359 | } | 366 | } |
360 | 367 | ||
361 | void KOViewManager::clearAllViews() | 368 | void KOViewManager::clearAllViews() |
362 | { | 369 | { |
363 | 370 | ||
364 | if ( mTodoView ) mTodoView->clearList(); | 371 | if ( mTodoView ) mTodoView->clearList(); |
365 | if ( mListView ) mListView->clearList(); | 372 | if ( mListView ) mListView->clearList(); |
366 | 373 | ||
367 | if ( mAgendaView ) mAgendaView->clearList(); | 374 | if ( mAgendaView ) mAgendaView->clearList(); |
368 | if ( mMonthView ) mMonthView->clearList(); | 375 | if ( mMonthView ) mMonthView->clearList(); |
369 | if ( mWhatsNextView ) mWhatsNextView->clearList(); | 376 | if ( mWhatsNextView ) mWhatsNextView->clearList(); |
370 | if ( mJournalView ) mJournalView->clearList(); | 377 | if ( mJournalView ) mJournalView->clearList(); |
371 | 378 | ||
372 | } | 379 | } |
373 | void KOViewManager::updateView() | 380 | void KOViewManager::updateView() |
374 | { | 381 | { |
375 | // qDebug("KOViewManager::updateView() "); | 382 | // qDebug("KOViewManager::updateView() "); |
376 | // if we are updating mTodoView, we get endless recursion | 383 | // if we are updating mTodoView, we get endless recursion |
377 | if ( mTodoView == mCurrentView ) | 384 | if ( mTodoView == mCurrentView ) |
378 | return; | 385 | return; |
379 | if ( mCurrentView ) mCurrentView->updateView(); | 386 | if ( mCurrentView ) mCurrentView->updateView(); |
380 | 387 | ||
381 | } | 388 | } |
382 | 389 | ||
383 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 390 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
384 | { | 391 | { |
385 | // kdDebug() << "KOViewManager::updateView()" << endl; | 392 | // kdDebug() << "KOViewManager::updateView()" << endl; |
386 | 393 | ||
387 | if (mCurrentView) mCurrentView->showDates(start, end); | 394 | if (mCurrentView) mCurrentView->showDates(start, end); |
388 | 395 | ||
389 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 396 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
390 | } | 397 | } |
391 | 398 | ||
392 | 399 | ||
393 | void KOViewManager::updateWNview() | 400 | void KOViewManager::updateWNview() |
394 | { | 401 | { |
395 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 402 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
396 | mWhatsNextView->updateView(); | 403 | mWhatsNextView->updateView(); |
397 | if ( mCurrentView == mMonthView && mMonthView ) | 404 | if ( mCurrentView == mMonthView && mMonthView ) |
398 | mMonthView->updateView(); | 405 | mMonthView->updateView(); |
399 | 406 | ||
400 | } | 407 | } |
401 | void KOViewManager::showWhatsNextView() | 408 | void KOViewManager::showWhatsNextView() |
402 | { | 409 | { |
403 | if (!mWhatsNextView) { | 410 | if (!mWhatsNextView) { |
404 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 411 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
405 | "KOViewManager::WhatsNextView"); | 412 | "KOViewManager::WhatsNextView"); |
406 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 413 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
407 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 414 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
408 | addView(mWhatsNextView); | 415 | addView(mWhatsNextView); |
409 | connect(this, SIGNAL( printWNV() ), | 416 | connect(this, SIGNAL( printWNV() ), |
410 | mWhatsNextView, SLOT( printMe() ) ); | 417 | mWhatsNextView, SLOT( printMe() ) ); |
411 | } | 418 | } |
412 | globalFlagBlockAgenda = 1; | 419 | globalFlagBlockAgenda = 1; |
413 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; | 420 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; |
414 | showView(mWhatsNextView, true ); | 421 | showView(mWhatsNextView, true ); |
415 | //mWhatsNextView->updateView(); | 422 | //mWhatsNextView->updateView(); |
416 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; | 423 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; |
417 | } | 424 | } |
418 | 425 | ||
419 | void KOViewManager::slotprintWNV() | 426 | void KOViewManager::slotprintWNV() |
420 | { | 427 | { |
421 | if (!mWhatsNextView) | 428 | if (!mWhatsNextView) |
422 | showWhatsNextView(); | 429 | showWhatsNextView(); |
423 | emit printWNV(); | 430 | emit printWNV(); |
424 | 431 | ||
425 | } | 432 | } |
426 | void KOViewManager::showListView() | 433 | void KOViewManager::showListView() |
427 | { | 434 | { |
428 | if (!mListView) { | 435 | if (!mListView) { |
429 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 436 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
430 | addView(mListView); | 437 | addView(mListView); |
431 | 438 | ||
432 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 439 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
433 | mMainView, SLOT(showIncidence(Incidence *))); | 440 | mMainView, SLOT(showIncidence(Incidence *))); |
434 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 441 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
435 | mMainView, SLOT(editIncidence(Incidence *))); | 442 | mMainView, SLOT(editIncidence(Incidence *))); |
436 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 443 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
437 | mMainView, SLOT(deleteIncidence(Incidence *))); | 444 | mMainView, SLOT(deleteIncidence(Incidence *))); |
438 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 445 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
439 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 446 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
440 | connect( mListView, SIGNAL( signalNewEvent() ), | 447 | connect( mListView, SIGNAL( signalNewEvent() ), |
441 | mMainView, SLOT( newEvent() ) ); | 448 | mMainView, SLOT( newEvent() ) ); |
442 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 449 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
443 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 450 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
444 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 451 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
445 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 452 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
446 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 453 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
447 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 454 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
448 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 455 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
449 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 456 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
450 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 457 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
451 | } | 458 | } |
452 | // bool temp = mFlagShowNextxDays; | 459 | // bool temp = mFlagShowNextxDays; |
453 | //globalFlagBlockPainting = true; | 460 | //globalFlagBlockPainting = true; |
454 | globalFlagBlockAgenda = 1; | 461 | globalFlagBlockAgenda = 1; |
455 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 462 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
456 | mMainView->setBlockShowDates( true ); | 463 | mMainView->setBlockShowDates( true ); |
457 | mMainView->dateNavigator()->selectMonth(); | 464 | mMainView->dateNavigator()->selectMonth(); |
458 | mMainView->setBlockShowDates( false ); | 465 | mMainView->setBlockShowDates( false ); |
459 | } | 466 | } |
460 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; | 467 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; |
461 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 468 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
462 | //mFlagShowNextxDays = temp; | 469 | //mFlagShowNextxDays = temp; |
463 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; | 470 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; |
464 | } | 471 | } |
465 | 472 | ||
466 | void KOViewManager::showAgendaView( bool fullScreen ) | 473 | void KOViewManager::showAgendaView( bool fullScreen ) |
467 | { | 474 | { |
468 | 475 | ||
469 | mMainView->dialogManager()->hideSearchDialog(); | 476 | mMainView->dialogManager()->hideSearchDialog(); |
470 | // qDebug("KOViewManager::showAgendaView "); | 477 | // qDebug("KOViewManager::showAgendaView "); |
471 | bool full; | 478 | bool full; |
472 | full = fullScreen; | 479 | full = fullScreen; |
473 | if (!mAgendaView) { | 480 | if (!mAgendaView) { |
474 | full = false; | 481 | full = false; |
475 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 482 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
476 | addView(mAgendaView); | 483 | addView(mAgendaView); |
477 | #ifndef DESKTOP_VERSION | 484 | #ifndef DESKTOP_VERSION |
478 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 485 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
479 | #endif | 486 | #endif |
480 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 487 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
481 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 488 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
482 | 489 | ||
483 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 490 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
484 | 491 | ||
485 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 492 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
486 | 493 | ||
487 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 494 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
488 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 495 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
489 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 496 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
490 | mMainView, SLOT(newEvent(QDateTime))); | 497 | mMainView, SLOT(newEvent(QDateTime))); |
491 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 498 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
492 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 499 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
493 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 500 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
494 | mMainView, SLOT(newEvent(QDate))); | 501 | mMainView, SLOT(newEvent(QDate))); |
495 | 502 | ||
496 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 503 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
497 | mMainView, SLOT(editIncidence(Incidence *))); | 504 | mMainView, SLOT(editIncidence(Incidence *))); |
498 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 505 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
499 | mMainView, SLOT(showIncidence(Incidence *))); | 506 | mMainView, SLOT(showIncidence(Incidence *))); |
500 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 507 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
501 | mMainView, SLOT(deleteIncidence(Incidence *))); | 508 | mMainView, SLOT(deleteIncidence(Incidence *))); |
502 | 509 | ||
503 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 510 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
504 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 511 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
505 | 512 | ||
506 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 513 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
507 | mMainView, SLOT( toggleExpand() ) ); | 514 | mMainView, SLOT( toggleExpand() ) ); |
508 | 515 | ||
509 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 516 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
510 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 517 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
511 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 518 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
512 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 519 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
513 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 520 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
514 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 521 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
515 | SLOT( updateTodo( Todo *, int ) ) ); | 522 | SLOT( updateTodo( Todo *, int ) ) ); |
516 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 523 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
517 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 524 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
518 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 525 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
519 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 526 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
520 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 527 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
521 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 528 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
522 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), | 529 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), |
523 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); | 530 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); |
524 | mAgendaView->readSettings(); | 531 | mAgendaView->readSettings(); |
525 | mAgendaView->updateConfig(); | 532 | mAgendaView->updateConfig(); |
526 | } | 533 | } |
527 | 534 | ||
528 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; | 535 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; |
529 | showView( mAgendaView, full); | 536 | showView( mAgendaView, full); |
530 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; | 537 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; |
531 | } | 538 | } |
532 | 539 | ||
533 | void KOViewManager::showDayView() | 540 | void KOViewManager::showDayView() |
534 | { | 541 | { |
535 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 542 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
536 | mFlagShowNextxDays = false; | 543 | mFlagShowNextxDays = false; |
537 | globalFlagBlockLabel = 1; | 544 | globalFlagBlockLabel = 1; |
538 | globalFlagBlockAgenda = 1; | 545 | globalFlagBlockAgenda = 1; |
539 | if ( mCurrentAgendaView != 1 ) | 546 | if ( mCurrentAgendaView != 1 ) |
540 | mCurrentAgendaView = -1; | 547 | mCurrentAgendaView = -1; |
541 | showAgendaView(); | 548 | showAgendaView(); |
542 | qApp->processEvents(); | 549 | qApp->processEvents(); |
543 | globalFlagBlockAgenda = 2; | 550 | globalFlagBlockAgenda = 2; |
544 | globalFlagBlockLabel = 0; | 551 | globalFlagBlockLabel = 0; |
545 | mMainView->dateNavigator()->selectDates( 1 ); | 552 | mMainView->dateNavigator()->selectDates( 1 ); |
546 | mCurrentAgendaView = 1 ; | 553 | mCurrentAgendaView = 1 ; |
547 | 554 | ||
548 | } | 555 | } |
549 | 556 | ||
550 | void KOViewManager::showWorkWeekView() | 557 | void KOViewManager::showWorkWeekView() |
551 | { | 558 | { |
552 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 559 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
553 | mFlagShowNextxDays = false; | 560 | mFlagShowNextxDays = false; |
554 | globalFlagBlockAgenda = 1; | 561 | globalFlagBlockAgenda = 1; |
555 | globalFlagBlockLabel = 1; | 562 | globalFlagBlockLabel = 1; |
556 | if ( mCurrentAgendaView != 5 ) | 563 | if ( mCurrentAgendaView != 5 ) |
557 | mCurrentAgendaView = -1; | 564 | mCurrentAgendaView = -1; |
558 | showAgendaView(); | 565 | showAgendaView(); |
559 | qApp->processEvents(); | 566 | qApp->processEvents(); |
560 | globalFlagBlockAgenda = 2; | 567 | globalFlagBlockAgenda = 2; |
561 | globalFlagBlockLabel = 0; | 568 | globalFlagBlockLabel = 0; |
562 | mMainView->dateNavigator()->selectWorkWeek(); | 569 | mMainView->dateNavigator()->selectWorkWeek(); |
563 | mCurrentAgendaView = 5 ; | 570 | mCurrentAgendaView = 5 ; |
564 | 571 | ||
565 | } | 572 | } |
566 | 573 | ||
567 | void KOViewManager::showWeekView() | 574 | void KOViewManager::showWeekView() |
568 | { | 575 | { |
569 | 576 | ||
570 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 577 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
571 | mFlagShowNextxDays = false; | 578 | mFlagShowNextxDays = false; |
572 | globalFlagBlockAgenda = 1; | 579 | globalFlagBlockAgenda = 1; |
573 | globalFlagBlockLabel = 1; | 580 | globalFlagBlockLabel = 1; |
574 | if ( mCurrentAgendaView != 7 ) | 581 | if ( mCurrentAgendaView != 7 ) |
575 | mCurrentAgendaView = -1; | 582 | mCurrentAgendaView = -1; |
576 | showAgendaView(); | 583 | showAgendaView(); |
577 | qApp->processEvents(); | 584 | qApp->processEvents(); |
578 | globalFlagBlockAgenda = 2; | 585 | globalFlagBlockAgenda = 2; |
579 | globalFlagBlockLabel = 0; | 586 | globalFlagBlockLabel = 0; |
580 | mMainView->dateNavigator()->selectWeek(); | 587 | mMainView->dateNavigator()->selectWeek(); |
581 | mCurrentAgendaView = 7 ; | 588 | mCurrentAgendaView = 7 ; |
582 | } | 589 | } |
583 | 590 | ||
584 | void KOViewManager::showNextXView() | 591 | void KOViewManager::showNextXView() |
585 | { | 592 | { |
586 | 593 | ||
587 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; | 594 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; |
588 | globalFlagBlockAgenda = 1; | 595 | globalFlagBlockAgenda = 1; |
589 | if ( mCurrentAgendaView != 3 ) | 596 | if ( mCurrentAgendaView != 3 ) |
590 | mCurrentAgendaView = -1; | 597 | mCurrentAgendaView = -1; |
591 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 598 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
592 | globalFlagBlockAgenda = 2; | 599 | globalFlagBlockAgenda = 2; |
593 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 600 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
594 | KOPrefs::instance()->mNextXDays ); | 601 | KOPrefs::instance()->mNextXDays ); |
595 | mFlagShowNextxDays = true; | 602 | mFlagShowNextxDays = true; |
596 | mCurrentAgendaView = 3 ; | 603 | mCurrentAgendaView = 3 ; |
597 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; | 604 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; |
598 | } | 605 | } |
599 | bool KOViewManager::showsNextDays() | 606 | bool KOViewManager::showsNextDays() |
600 | { | 607 | { |
601 | return mFlagShowNextxDays; | 608 | return mFlagShowNextxDays; |
602 | } | 609 | } |
603 | void KOViewManager::createMonthView() | 610 | void KOViewManager::createMonthView() |
604 | { | 611 | { |
605 | if (!mMonthView) { | 612 | if (!mMonthView) { |
606 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 613 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
607 | 614 | ||
608 | addView(mMonthView); | 615 | addView(mMonthView); |
609 | // mMonthView->show(); | 616 | // mMonthView->show(); |
610 | // SIGNALS/SLOTS FOR MONTH VIEW | 617 | // SIGNALS/SLOTS FOR MONTH VIEW |
611 | 618 | ||
612 | connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); | 619 | connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); |
613 | 620 | ||
614 | connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), | 621 | connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), |
615 | mMainView, SLOT(newTodoDateTime(QDateTime, bool))); | 622 | mMainView, SLOT(newTodoDateTime(QDateTime, bool))); |
616 | 623 | ||
617 | 624 | ||
618 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 625 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
619 | mMainView, SLOT(newEvent(QDateTime))); | 626 | mMainView, SLOT(newEvent(QDateTime))); |
620 | 627 | ||
621 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 628 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
622 | mMainView, SLOT(showIncidence(Incidence *))); | 629 | mMainView, SLOT(showIncidence(Incidence *))); |
623 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 630 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
624 | mMainView, SLOT(editIncidence(Incidence *))); | 631 | mMainView, SLOT(editIncidence(Incidence *))); |
625 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 632 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
626 | mMainView, SLOT(deleteIncidence(Incidence *))); | 633 | mMainView, SLOT(deleteIncidence(Incidence *))); |
627 | 634 | ||
628 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 635 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
629 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 636 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
630 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 637 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
631 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 638 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
632 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 639 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
633 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 640 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
634 | 641 | ||
635 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 642 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
636 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 643 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
637 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 644 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
638 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 645 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
639 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 646 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
640 | mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); | 647 | mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); |
641 | connect( mMonthView, SIGNAL( selectMonth() ), | 648 | connect( mMonthView, SIGNAL( selectMonth() ), |
642 | mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); | 649 | mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); |
643 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 650 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
644 | mMainView, SLOT ( showDay( QDate ) ) ); | 651 | mMainView, SLOT ( showDay( QDate ) ) ); |
645 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 652 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
646 | connect( mMonthView, SIGNAL(nextMonth() ), | 653 | connect( mMonthView, SIGNAL(nextMonth() ), |
647 | mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 654 | mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
648 | connect( mMonthView, SIGNAL(prevMonth() ), | 655 | connect( mMonthView, SIGNAL(prevMonth() ), |
649 | mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 656 | mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
650 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), | 657 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), |
651 | mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); | 658 | mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); |
652 | connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), | 659 | connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), |
653 | mMainView->dateNavigator(), SLOT( selectNextYear() ) ); | 660 | mMainView->dateNavigator(), SLOT( selectNextYear() ) ); |
654 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), | 661 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), |
655 | mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); | 662 | mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); |
656 | connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), | 663 | connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), |
657 | mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); | 664 | mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); |
658 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), | 665 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), |
659 | mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); | 666 | mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); |
660 | connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), | 667 | connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), |
661 | mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); | 668 | mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); |
662 | 669 | ||
663 | connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 670 | connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
664 | mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); | 671 | mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); |
665 | 672 | ||
666 | 673 | ||
667 | connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), | 674 | connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), |
668 | mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); | 675 | mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); |
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 838583b..d5a8e3b 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h | |||
@@ -1,127 +1,128 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 | 3 | Copyright (c) 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef KOVIEWMANAGER_H | 24 | #ifndef KOVIEWMANAGER_H |
25 | #define KOVIEWMANAGER_H | 25 | #define KOVIEWMANAGER_H |
26 | 26 | ||
27 | #include <qobject.h> | 27 | #include <qobject.h> |
28 | 28 | ||
29 | #include <korganizer/baseview.h> | 29 | #include <korganizer/baseview.h> |
30 | 30 | ||
31 | class CalendarView; | 31 | class CalendarView; |
32 | 32 | ||
33 | class KOListView; | 33 | class KOListView; |
34 | class KOAgendaView; | 34 | class KOAgendaView; |
35 | class KOMonthView; | 35 | class KOMonthView; |
36 | class KOTimeSpanView; | 36 | class KOTimeSpanView; |
37 | class KOTodoView; | 37 | class KOTodoView; |
38 | class KOWhatsNextView; | 38 | class KOWhatsNextView; |
39 | class KOJournalView; | 39 | class KOJournalView; |
40 | 40 | ||
41 | using namespace KCal; | 41 | using namespace KCal; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | This class manages the views of the calendar. It owns the objects and handles | 44 | This class manages the views of the calendar. It owns the objects and handles |
45 | creation and selection. | 45 | creation and selection. |
46 | */ | 46 | */ |
47 | class KOViewManager : public QObject | 47 | class KOViewManager : public QObject |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOViewManager( CalendarView * ); | 51 | KOViewManager( CalendarView * ); |
52 | virtual ~KOViewManager(); | 52 | virtual ~KOViewManager(); |
53 | 53 | ||
54 | /** changes the view to be the currently selected view */ | 54 | /** changes the view to be the currently selected view */ |
55 | void showView(KOrg::BaseView *, bool fullScreen = false ); | 55 | void showView(KOrg::BaseView *, bool fullScreen = false ); |
56 | void updateWNview(); | 56 | void updateWNview(); |
57 | void readSettings(KConfig *config); | 57 | void readSettings(KConfig *config); |
58 | void writeSettings(KConfig *config); | 58 | void writeSettings(KConfig *config); |
59 | bool showsNextDays(); | 59 | bool showsNextDays(); |
60 | /** Read which view was shown last from config file */ | 60 | /** Read which view was shown last from config file */ |
61 | void readCurrentView(KConfig *); | 61 | void readCurrentView(KConfig *); |
62 | /** Write which view is currently shown to config file */ | 62 | /** Write which view is currently shown to config file */ |
63 | void writeCurrentView(KConfig *); | 63 | void writeCurrentView(KConfig *); |
64 | 64 | ||
65 | KOrg::BaseView *currentView(); | 65 | KOrg::BaseView *currentView(); |
66 | 66 | ||
67 | void setDocumentId( const QString & ); | 67 | void setDocumentId( const QString & ); |
68 | 68 | ||
69 | void updateView( const QDate &start, const QDate &end ); | 69 | void updateView( const QDate &start, const QDate &end ); |
70 | void clearAllViews(); | 70 | void clearAllViews(); |
71 | 71 | ||
72 | void raiseCurrentView( bool fullScreen = false , bool updateView = false); | 72 | void raiseCurrentView( bool fullScreen = false , bool updateView = false); |
73 | 73 | ||
74 | void addView(KOrg::BaseView *); | 74 | void addView(KOrg::BaseView *); |
75 | 75 | ||
76 | Incidence *currentSelection(); | 76 | Incidence *currentSelection(); |
77 | QDate currentSelectionDate(); | 77 | QDate currentSelectionDate(); |
78 | 78 | ||
79 | KOAgendaView *agendaView() const { return mAgendaView; } | 79 | KOAgendaView *agendaView() const { return mAgendaView; } |
80 | 80 | ||
81 | signals: | 81 | signals: |
82 | void printWNV(); | 82 | void printWNV(); |
83 | void signalFullScreen( bool ); | 83 | void signalFullScreen( bool ); |
84 | void signalAgendaView( bool ); | 84 | void signalAgendaView( bool ); |
85 | public slots: | 85 | public slots: |
86 | void setDefaultCalendar(int); | ||
86 | void slotprintWNV(); | 87 | void slotprintWNV(); |
87 | void showNextView(); | 88 | void showNextView(); |
88 | void showMonth( const QDate & ); | 89 | void showMonth( const QDate & ); |
89 | void showDateView( int, QDate ); | 90 | void showDateView( int, QDate ); |
90 | void updateView(); | 91 | void updateView(); |
91 | void showWhatsNextView(); | 92 | void showWhatsNextView(); |
92 | void showListView(); | 93 | void showListView(); |
93 | void showAgendaView( bool fullScreen = false ); | 94 | void showAgendaView( bool fullScreen = false ); |
94 | void showDayView(); | 95 | void showDayView(); |
95 | void showWorkWeekView(); | 96 | void showWorkWeekView(); |
96 | void showWeekView(); | 97 | void showWeekView(); |
97 | void showNextXView(); | 98 | void showNextXView(); |
98 | void showMonthView(); | 99 | void showMonthView(); |
99 | void showMonthViewWeek(); | 100 | void showMonthViewWeek(); |
100 | void showTodoView(); | 101 | void showTodoView(); |
101 | void showJournalView(); | 102 | void showJournalView(); |
102 | void showTimeSpanView(); | 103 | void showTimeSpanView(); |
103 | 104 | ||
104 | private: | 105 | private: |
105 | void resetDateSilent( QDate date , int days ); | 106 | void resetDateSilent( QDate date , int days ); |
106 | int flagResetViewChangeDate; | 107 | int flagResetViewChangeDate; |
107 | QDate currentViewChangeDate; | 108 | QDate currentViewChangeDate; |
108 | void createMonthView(); | 109 | void createMonthView(); |
109 | CalendarView *mMainView; | 110 | CalendarView *mMainView; |
110 | 111 | ||
111 | int mCurrentAgendaView; | 112 | int mCurrentAgendaView; |
112 | KOAgendaView *mAgendaView; | 113 | KOAgendaView *mAgendaView; |
113 | KOListView *mListView; | 114 | KOListView *mListView; |
114 | KOMonthView *mMonthView; | 115 | KOMonthView *mMonthView; |
115 | KOTodoView *mTodoView; | 116 | KOTodoView *mTodoView; |
116 | KOWhatsNextView *mWhatsNextView; | 117 | KOWhatsNextView *mWhatsNextView; |
117 | KOJournalView *mJournalView; | 118 | KOJournalView *mJournalView; |
118 | KOTimeSpanView *mTimeSpanView; | 119 | KOTimeSpanView *mTimeSpanView; |
119 | 120 | ||
120 | KOrg::BaseView *mCurrentView; // currently active event view | 121 | KOrg::BaseView *mCurrentView; // currently active event view |
121 | 122 | ||
122 | int mAgendaViewMode; | 123 | int mAgendaViewMode; |
123 | bool mFlagShowNextxDays; | 124 | bool mFlagShowNextxDays; |
124 | 125 | ||
125 | }; | 126 | }; |
126 | 127 | ||
127 | #endif | 128 | #endif |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2efa355..4652fe5 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,376 +1,377 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | virtual void addCalendar( Calendar* ) = 0; | 77 | virtual void addCalendar( Calendar* ) = 0; |
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual void setSyncEventsReadOnly() = 0; | 79 | virtual void setSyncEventsReadOnly() = 0; |
80 | virtual void stopAllTodos() = 0; | 80 | virtual void stopAllTodos() = 0; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | Sync changes in memory to persistant storage. | 83 | Sync changes in memory to persistant storage. |
84 | */ | 84 | */ |
85 | virtual void save() = 0; | 85 | virtual void save() = 0; |
86 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 86 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
87 | virtual void removeSyncInfo( QString syncProfile) = 0; | 87 | virtual void removeSyncInfo( QString syncProfile) = 0; |
88 | virtual bool isSaving() { return false; } | 88 | virtual bool isSaving() { return false; } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | Return the owner of the calendar's full name. | 91 | Return the owner of the calendar's full name. |
92 | */ | 92 | */ |
93 | const QString &getOwner() const; | 93 | const QString &getOwner() const; |
94 | /** | 94 | /** |
95 | Set the owner of the calendar. Should be owner's full name. | 95 | Set the owner of the calendar. Should be owner's full name. |
96 | */ | 96 | */ |
97 | void setOwner( const QString &os ); | 97 | void setOwner( const QString &os ); |
98 | /** | 98 | /** |
99 | Return the email address of the calendar owner. | 99 | Return the email address of the calendar owner. |
100 | */ | 100 | */ |
101 | const QString &getEmail(); | 101 | const QString &getEmail(); |
102 | /** | 102 | /** |
103 | Set the email address of the calendar owner. | 103 | Set the email address of the calendar owner. |
104 | */ | 104 | */ |
105 | void setEmail( const QString & ); | 105 | void setEmail( const QString & ); |
106 | 106 | ||
107 | /** | 107 | /** |
108 | Set time zone from a timezone string (e.g. -2:00) | 108 | Set time zone from a timezone string (e.g. -2:00) |
109 | */ | 109 | */ |
110 | void setTimeZone( const QString &tz ); | 110 | void setTimeZone( const QString &tz ); |
111 | /** | 111 | /** |
112 | Set time zone from a minutes value (e.g. -60) | 112 | Set time zone from a minutes value (e.g. -60) |
113 | */ | 113 | */ |
114 | void setTimeZone( int tz ); | 114 | void setTimeZone( int tz ); |
115 | /** | 115 | /** |
116 | Return time zone as offest in minutes. | 116 | Return time zone as offest in minutes. |
117 | */ | 117 | */ |
118 | int getTimeZone() const; | 118 | int getTimeZone() const; |
119 | /** | 119 | /** |
120 | Compute an ISO 8601 format string from the time zone. | 120 | Compute an ISO 8601 format string from the time zone. |
121 | */ | 121 | */ |
122 | QString getTimeZoneStr() const; | 122 | QString getTimeZoneStr() const; |
123 | /** | 123 | /** |
124 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 124 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
125 | values). | 125 | values). |
126 | */ | 126 | */ |
127 | void setTimeZoneId( const QString & ); | 127 | void setTimeZoneId( const QString & ); |
128 | /** | 128 | /** |
129 | Return time zone id. | 129 | Return time zone id. |
130 | */ | 130 | */ |
131 | QString timeZoneId() const; | 131 | QString timeZoneId() const; |
132 | /** | 132 | /** |
133 | Use local time, not UTC or a time zone. | 133 | Use local time, not UTC or a time zone. |
134 | */ | 134 | */ |
135 | void setLocalTime(); | 135 | void setLocalTime(); |
136 | /** | 136 | /** |
137 | Return whether local time is being used. | 137 | Return whether local time is being used. |
138 | */ | 138 | */ |
139 | bool isLocalTime() const; | 139 | bool isLocalTime() const; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | Add an incidence to calendar. | 142 | Add an incidence to calendar. |
143 | 143 | ||
144 | @return true on success, false on error. | 144 | @return true on success, false on error. |
145 | */ | 145 | */ |
146 | virtual bool addIncidence( Incidence * ); | 146 | virtual bool addIncidence( Incidence * ); |
147 | 147 | ||
148 | // Adds an incidence and all relatedto incidences to the cal | 148 | // Adds an incidence and all relatedto incidences to the cal |
149 | void addIncidenceBranch( Incidence * ); | 149 | void addIncidenceBranch( Incidence * ); |
150 | /** | 150 | /** |
151 | Return filtered list of all incidences of this calendar. | 151 | Return filtered list of all incidences of this calendar. |
152 | */ | 152 | */ |
153 | virtual QPtrList<Incidence> incidences(); | 153 | virtual QPtrList<Incidence> incidences(); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Return unfiltered list of all incidences of this calendar. | 156 | Return unfiltered list of all incidences of this calendar. |
157 | */ | 157 | */ |
158 | virtual QPtrList<Incidence> rawIncidences(); | 158 | virtual QPtrList<Incidence> rawIncidences(); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Adds a Event to this calendar object. | 161 | Adds a Event to this calendar object. |
162 | @param anEvent a pointer to the event to add | 162 | @param anEvent a pointer to the event to add |
163 | 163 | ||
164 | @return true on success, false on error. | 164 | @return true on success, false on error. |
165 | */ | 165 | */ |
166 | virtual bool addEventNoDup( Event *event ) = 0; | 166 | virtual bool addEventNoDup( Event *event ) = 0; |
167 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 167 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
168 | virtual bool addEvent( Event *anEvent ) = 0; | 168 | virtual bool addEvent( Event *anEvent ) = 0; |
169 | /** | 169 | /** |
170 | Delete event from calendar. | 170 | Delete event from calendar. |
171 | */ | 171 | */ |
172 | virtual void deleteEvent( Event * ) = 0; | 172 | virtual void deleteEvent( Event * ) = 0; |
173 | /** | 173 | /** |
174 | Retrieves an event on the basis of the unique string ID. | 174 | Retrieves an event on the basis of the unique string ID. |
175 | */ | 175 | */ |
176 | virtual Event *event( const QString &UniqueStr ) = 0; | 176 | virtual Event *event( const QString &UniqueStr ) = 0; |
177 | virtual Event *event( QString, QString ) = 0; | 177 | virtual Event *event( QString, QString ) = 0; |
178 | /** | 178 | /** |
179 | Builds and then returns a list of all events that match for the | 179 | Builds and then returns a list of all events that match for the |
180 | date specified. useful for dayView, etc. etc. | 180 | date specified. useful for dayView, etc. etc. |
181 | The calendar filter is applied. | 181 | The calendar filter is applied. |
182 | */ | 182 | */ |
183 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 183 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
184 | /** | 184 | /** |
185 | Get events, which occur on the given date. | 185 | Get events, which occur on the given date. |
186 | The calendar filter is applied. | 186 | The calendar filter is applied. |
187 | */ | 187 | */ |
188 | QPtrList<Event> events( const QDateTime &qdt ); | 188 | QPtrList<Event> events( const QDateTime &qdt ); |
189 | /** | 189 | /** |
190 | Get events in a range of dates. If inclusive is set to true, only events | 190 | Get events in a range of dates. If inclusive is set to true, only events |
191 | are returned, which are completely included in the range. | 191 | are returned, which are completely included in the range. |
192 | The calendar filter is applied. | 192 | The calendar filter is applied. |
193 | */ | 193 | */ |
194 | QPtrList<Event> events( const QDate &start, const QDate &end, | 194 | QPtrList<Event> events( const QDate &start, const QDate &end, |
195 | bool inclusive = false); | 195 | bool inclusive = false); |
196 | /** | 196 | /** |
197 | Return filtered list of all events in calendar. | 197 | Return filtered list of all events in calendar. |
198 | */ | 198 | */ |
199 | virtual QPtrList<Event> events(); | 199 | virtual QPtrList<Event> events(); |
200 | /** | 200 | /** |
201 | Return unfiltered list of all events in calendar. | 201 | Return unfiltered list of all events in calendar. |
202 | */ | 202 | */ |
203 | virtual QPtrList<Event> rawEvents() = 0; | 203 | virtual QPtrList<Event> rawEvents() = 0; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | Add a todo to the todolist. | 206 | Add a todo to the todolist. |
207 | 207 | ||
208 | @return true on success, false on error. | 208 | @return true on success, false on error. |
209 | */ | 209 | */ |
210 | virtual bool addTodo( Todo *todo ) = 0; | 210 | virtual bool addTodo( Todo *todo ) = 0; |
211 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 211 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
212 | /** | 212 | /** |
213 | Remove a todo from the todolist. | 213 | Remove a todo from the todolist. |
214 | */ | 214 | */ |
215 | virtual void deleteTodo( Todo * ) = 0; | 215 | virtual void deleteTodo( Todo * ) = 0; |
216 | virtual void deleteJournal( Journal * ) = 0; | 216 | virtual void deleteJournal( Journal * ) = 0; |
217 | /** | 217 | /** |
218 | Return filterd list of todos. | 218 | Return filterd list of todos. |
219 | */ | 219 | */ |
220 | virtual QPtrList<Todo> todos(); | 220 | virtual QPtrList<Todo> todos(); |
221 | /** | 221 | /** |
222 | Searches todolist for an event with this unique string identifier, | 222 | Searches todolist for an event with this unique string identifier, |
223 | returns a pointer or null. | 223 | returns a pointer or null. |
224 | */ | 224 | */ |
225 | virtual Todo *todo( const QString &uid ) = 0; | 225 | virtual Todo *todo( const QString &uid ) = 0; |
226 | virtual Todo *todo( QString, QString ) = 0; | 226 | virtual Todo *todo( QString, QString ) = 0; |
227 | /** | 227 | /** |
228 | Returns list of todos due on the specified date. | 228 | Returns list of todos due on the specified date. |
229 | */ | 229 | */ |
230 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 230 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
231 | /** | 231 | /** |
232 | Return unfiltered list of todos. | 232 | Return unfiltered list of todos. |
233 | */ | 233 | */ |
234 | virtual QPtrList<Todo> rawTodos() = 0; | 234 | virtual QPtrList<Todo> rawTodos() = 0; |
235 | 235 | ||
236 | /** | 236 | /** |
237 | Add a Journal entry to calendar. | 237 | Add a Journal entry to calendar. |
238 | 238 | ||
239 | @return true on success, false on error. | 239 | @return true on success, false on error. |
240 | */ | 240 | */ |
241 | virtual bool addJournal( Journal * ) = 0; | 241 | virtual bool addJournal( Journal * ) = 0; |
242 | /** | 242 | /** |
243 | Return Journal for given date. | 243 | Return Journal for given date. |
244 | */ | 244 | */ |
245 | virtual Journal *journal( const QDate & ) = 0; | 245 | virtual Journal *journal( const QDate & ) = 0; |
246 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; | ||
246 | /** | 247 | /** |
247 | Return Journal with given UID. | 248 | Return Journal with given UID. |
248 | */ | 249 | */ |
249 | virtual Journal *journal( const QString &UID ) = 0; | 250 | virtual Journal *journal( const QString &UID ) = 0; |
250 | /** | 251 | /** |
251 | Return list of all Journal entries. | 252 | Return list of all Journal entries. |
252 | */ | 253 | */ |
253 | virtual QPtrList<Journal> journals() = 0; | 254 | virtual QPtrList<Journal> journals() = 0; |
254 | 255 | ||
255 | /** | 256 | /** |
256 | Searches all incidence types for an incidence with this unique | 257 | Searches all incidence types for an incidence with this unique |
257 | string identifier, returns a pointer or null. | 258 | string identifier, returns a pointer or null. |
258 | */ | 259 | */ |
259 | Incidence* incidence( const QString&UID ); | 260 | Incidence* incidence( const QString&UID ); |
260 | 261 | ||
261 | /** | 262 | /** |
262 | Setup relations for an incidence. | 263 | Setup relations for an incidence. |
263 | */ | 264 | */ |
264 | virtual void setupRelations( Incidence * ); | 265 | virtual void setupRelations( Incidence * ); |
265 | /** | 266 | /** |
266 | Remove all relations to an incidence | 267 | Remove all relations to an incidence |
267 | */ | 268 | */ |
268 | virtual void removeRelations( Incidence * ); | 269 | virtual void removeRelations( Incidence * ); |
269 | 270 | ||
270 | /** | 271 | /** |
271 | Set calendar filter, which filters events for the events() functions. | 272 | Set calendar filter, which filters events for the events() functions. |
272 | The Filter object is owned by the caller. | 273 | The Filter object is owned by the caller. |
273 | */ | 274 | */ |
274 | void setFilter( CalFilter * ); | 275 | void setFilter( CalFilter * ); |
275 | /** | 276 | /** |
276 | Return calendar filter. | 277 | Return calendar filter. |
277 | */ | 278 | */ |
278 | CalFilter *filter(); | 279 | CalFilter *filter(); |
279 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 280 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
280 | virtual QString nextSummary( ) const = 0; | 281 | virtual QString nextSummary( ) const = 0; |
281 | virtual void reInitAlarmSettings() = 0; | 282 | virtual void reInitAlarmSettings() = 0; |
282 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 283 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
283 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 284 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
284 | /** | 285 | /** |
285 | Return all alarms, which ocur in the given time interval. | 286 | Return all alarms, which ocur in the given time interval. |
286 | */ | 287 | */ |
287 | virtual Alarm::List alarms( const QDateTime &from, | 288 | virtual Alarm::List alarms( const QDateTime &from, |
288 | const QDateTime &to ) = 0; | 289 | const QDateTime &to ) = 0; |
289 | 290 | ||
290 | class Observer { | 291 | class Observer { |
291 | public: | 292 | public: |
292 | virtual void calendarModified( bool, Calendar * ) = 0; | 293 | virtual void calendarModified( bool, Calendar * ) = 0; |
293 | }; | 294 | }; |
294 | 295 | ||
295 | void registerObserver( Observer * ); | 296 | void registerObserver( Observer * ); |
296 | 297 | ||
297 | void setModified( bool ); | 298 | void setModified( bool ); |
298 | 299 | ||
299 | /** | 300 | /** |
300 | Set product id returned by loadedProductId(). This function is only | 301 | Set product id returned by loadedProductId(). This function is only |
301 | useful for the calendar loading code. | 302 | useful for the calendar loading code. |
302 | */ | 303 | */ |
303 | void setLoadedProductId( const QString & ); | 304 | void setLoadedProductId( const QString & ); |
304 | /** | 305 | /** |
305 | Return product id taken from file that has been loaded. Returns | 306 | Return product id taken from file that has been loaded. Returns |
306 | QString::null, if no calendar has been loaded. | 307 | QString::null, if no calendar has been loaded. |
307 | */ | 308 | */ |
308 | QString loadedProductId(); | 309 | QString loadedProductId(); |
309 | int defaultCalendar(); | 310 | int defaultCalendar(); |
310 | void setDontDeleteIncidencesOnClose (); | 311 | void setDontDeleteIncidencesOnClose (); |
311 | public slots: | 312 | public slots: |
312 | void setDefaultCalendar( int ); | 313 | void setDefaultCalendar( int ); |
313 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 314 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
314 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 315 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
315 | virtual void setReadOnly( int id, bool enable ) = 0; | 316 | virtual void setReadOnly( int id, bool enable ) = 0; |
316 | virtual void setDefaultCalendarEnabledOnly() = 0; | 317 | virtual void setDefaultCalendarEnabledOnly() = 0; |
317 | virtual void setCalendarRemove( int id ) = 0; | 318 | virtual void setCalendarRemove( int id ) = 0; |
318 | signals: | 319 | signals: |
319 | void calendarChanged(); | 320 | void calendarChanged(); |
320 | void calendarSaved(); | 321 | void calendarSaved(); |
321 | void calendarLoaded(); | 322 | void calendarLoaded(); |
322 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 323 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
323 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 324 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
324 | 325 | ||
325 | protected: | 326 | protected: |
326 | /** | 327 | /** |
327 | Get unfiltered events, which occur on the given date. | 328 | Get unfiltered events, which occur on the given date. |
328 | */ | 329 | */ |
329 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 330 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
330 | /** | 331 | /** |
331 | Get unfiltered events, which occur on the given date. | 332 | Get unfiltered events, which occur on the given date. |
332 | */ | 333 | */ |
333 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 334 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
334 | bool sorted = false ) = 0; | 335 | bool sorted = false ) = 0; |
335 | /** | 336 | /** |
336 | Get events in a range of dates. If inclusive is set to true, only events | 337 | Get events in a range of dates. If inclusive is set to true, only events |
337 | are returned, which are completely included in the range. | 338 | are returned, which are completely included in the range. |
338 | */ | 339 | */ |
339 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 340 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
340 | bool inclusive = false ) = 0; | 341 | bool inclusive = false ) = 0; |
341 | 342 | ||
342 | Incidence *mNextAlarmIncidence; | 343 | Incidence *mNextAlarmIncidence; |
343 | Incidence *mUndoIncidence; | 344 | Incidence *mUndoIncidence; |
344 | int mDefaultCalendar; | 345 | int mDefaultCalendar; |
345 | bool mDeleteIncidencesOnClose; | 346 | bool mDeleteIncidencesOnClose; |
346 | 347 | ||
347 | private: | 348 | private: |
348 | void init(); | 349 | void init(); |
349 | 350 | ||
350 | QString mOwner; // who the calendar belongs to | 351 | QString mOwner; // who the calendar belongs to |
351 | QString mOwnerEmail; // email address of the owner | 352 | QString mOwnerEmail; // email address of the owner |
352 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 353 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
353 | bool mLocalTime; // use local time, not UTC or a time zone | 354 | bool mLocalTime; // use local time, not UTC or a time zone |
354 | 355 | ||
355 | 356 | ||
356 | CalFilter *mFilter; | 357 | CalFilter *mFilter; |
357 | CalFilter *mDefaultFilter; | 358 | CalFilter *mDefaultFilter; |
358 | 359 | ||
359 | 360 | ||
360 | QString mTimeZoneId; | 361 | QString mTimeZoneId; |
361 | 362 | ||
362 | Observer *mObserver; | 363 | Observer *mObserver; |
363 | bool mNewObserver; | 364 | bool mNewObserver; |
364 | 365 | ||
365 | bool mModified; | 366 | bool mModified; |
366 | 367 | ||
367 | QString mLoadedProductId; | 368 | QString mLoadedProductId; |
368 | 369 | ||
369 | // This list is used to put together related todos | 370 | // This list is used to put together related todos |
370 | QDict<Incidence> mOrphans; | 371 | QDict<Incidence> mOrphans; |
371 | QDict<Incidence> mOrphanUids; | 372 | QDict<Incidence> mOrphanUids; |
372 | }; | 373 | }; |
373 | 374 | ||
374 | } | 375 | } |
375 | 376 | ||
376 | #endif | 377 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 418bfca..ca64e66 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -395,531 +395,533 @@ void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted | |||
395 | //QDateTime nextEvent; | 395 | //QDateTime nextEvent; |
396 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 396 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
397 | computeNextAlarm = true; | 397 | computeNextAlarm = true; |
398 | } else { | 398 | } else { |
399 | if ( ! deleted ) { | 399 | if ( ! deleted ) { |
400 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 400 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
401 | if ( ok ) { | 401 | if ( ok ) { |
402 | if ( nextA < mNextAlarmDateTime ) { | 402 | if ( nextA < mNextAlarmDateTime ) { |
403 | deRegisterAlarm(); | 403 | deRegisterAlarm(); |
404 | mNextAlarmDateTime = nextA; | 404 | mNextAlarmDateTime = nextA; |
405 | mNextSummary = incidence->summary(); | 405 | mNextSummary = incidence->summary(); |
406 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 406 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
407 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 407 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
408 | newNextAlarm = true; | 408 | newNextAlarm = true; |
409 | mNextAlarmIncidence = incidence; | 409 | mNextAlarmIncidence = incidence; |
410 | } else { | 410 | } else { |
411 | if ( incidence == mNextAlarmIncidence ) { | 411 | if ( incidence == mNextAlarmIncidence ) { |
412 | computeNextAlarm = true; | 412 | computeNextAlarm = true; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | } else { | 415 | } else { |
416 | if ( mNextAlarmIncidence == incidence ) { | 416 | if ( mNextAlarmIncidence == incidence ) { |
417 | computeNextAlarm = true; | 417 | computeNextAlarm = true; |
418 | } | 418 | } |
419 | } | 419 | } |
420 | } else { // deleted | 420 | } else { // deleted |
421 | if ( incidence == mNextAlarmIncidence ) { | 421 | if ( incidence == mNextAlarmIncidence ) { |
422 | computeNextAlarm = true; | 422 | computeNextAlarm = true; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } | 425 | } |
426 | if ( computeNextAlarm ) { | 426 | if ( computeNextAlarm ) { |
427 | deRegisterAlarm(); | 427 | deRegisterAlarm(); |
428 | nextA = nextAlarm( 1000 ); | 428 | nextA = nextAlarm( 1000 ); |
429 | if (! mNextAlarmIncidence ) { | 429 | if (! mNextAlarmIncidence ) { |
430 | return; | 430 | return; |
431 | } | 431 | } |
432 | newNextAlarm = true; | 432 | newNextAlarm = true; |
433 | } | 433 | } |
434 | if ( newNextAlarm ) | 434 | if ( newNextAlarm ) |
435 | registerAlarm(); | 435 | registerAlarm(); |
436 | } | 436 | } |
437 | QString CalendarLocal:: getAlarmNotification() | 437 | QString CalendarLocal:: getAlarmNotification() |
438 | { | 438 | { |
439 | QString ret; | 439 | QString ret; |
440 | // this should not happen | 440 | // this should not happen |
441 | if (! mNextAlarmIncidence ) | 441 | if (! mNextAlarmIncidence ) |
442 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 442 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
443 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 443 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
444 | if ( alarm->type() == Alarm::Procedure ) { | 444 | if ( alarm->type() == Alarm::Procedure ) { |
445 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 445 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
446 | } else { | 446 | } else { |
447 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 447 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
448 | } | 448 | } |
449 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 449 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
450 | if ( mNextSummary.length() > 25 ) | 450 | if ( mNextSummary.length() > 25 ) |
451 | ret += "\n" + mNextSummary.mid(25, 25 ); | 451 | ret += "\n" + mNextSummary.mid(25, 25 ); |
452 | ret+= "\n"+mNextAlarmEventDateTimeString; | 452 | ret+= "\n"+mNextAlarmEventDateTimeString; |
453 | return ret; | 453 | return ret; |
454 | } | 454 | } |
455 | void CalendarLocal::registerAlarm() | 455 | void CalendarLocal::registerAlarm() |
456 | { | 456 | { |
457 | mLastAlarmNotificationString = getAlarmNotification(); | 457 | mLastAlarmNotificationString = getAlarmNotification(); |
458 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 458 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
459 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 459 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
460 | // #ifndef DESKTOP_VERSION | 460 | // #ifndef DESKTOP_VERSION |
461 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 461 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
462 | // #endif | 462 | // #endif |
463 | } | 463 | } |
464 | void CalendarLocal::deRegisterAlarm() | 464 | void CalendarLocal::deRegisterAlarm() |
465 | { | 465 | { |
466 | if ( mLastAlarmNotificationString.isNull() ) | 466 | if ( mLastAlarmNotificationString.isNull() ) |
467 | return; | 467 | return; |
468 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 468 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
469 | 469 | ||
470 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 470 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
471 | mNextAlarmEventDateTime = QDateTime(); | 471 | mNextAlarmEventDateTime = QDateTime(); |
472 | // #ifndef DESKTOP_VERSION | 472 | // #ifndef DESKTOP_VERSION |
473 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 473 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
474 | // #endif | 474 | // #endif |
475 | } | 475 | } |
476 | 476 | ||
477 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 477 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
478 | { | 478 | { |
479 | QPtrList<Todo> todos; | 479 | QPtrList<Todo> todos; |
480 | 480 | ||
481 | Todo *todo; | 481 | Todo *todo; |
482 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 482 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
483 | if ( !todo->calEnabled() ) continue; | 483 | if ( !todo->calEnabled() ) continue; |
484 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 484 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
485 | todos.append( todo ); | 485 | todos.append( todo ); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | filter()->apply( &todos ); | 489 | filter()->apply( &todos ); |
490 | return todos; | 490 | return todos; |
491 | } | 491 | } |
492 | void CalendarLocal::reInitAlarmSettings() | 492 | void CalendarLocal::reInitAlarmSettings() |
493 | { | 493 | { |
494 | if ( !mNextAlarmIncidence ) { | 494 | if ( !mNextAlarmIncidence ) { |
495 | nextAlarm( 1000 ); | 495 | nextAlarm( 1000 ); |
496 | } | 496 | } |
497 | deRegisterAlarm(); | 497 | deRegisterAlarm(); |
498 | mNextAlarmIncidence = 0; | 498 | mNextAlarmIncidence = 0; |
499 | checkAlarmForIncidence( 0, false ); | 499 | checkAlarmForIncidence( 0, false ); |
500 | 500 | ||
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | 504 | ||
505 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 505 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
506 | { | 506 | { |
507 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 507 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
508 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 508 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
509 | QDateTime next; | 509 | QDateTime next; |
510 | Event *e; | 510 | Event *e; |
511 | bool ok; | 511 | bool ok; |
512 | bool found = false; | 512 | bool found = false; |
513 | int offset; | 513 | int offset; |
514 | mNextAlarmIncidence = 0; | 514 | mNextAlarmIncidence = 0; |
515 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 515 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
516 | if ( !e->calEnabled() ) continue; | 516 | if ( !e->calEnabled() ) continue; |
517 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 517 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
518 | if ( ok ) { | 518 | if ( ok ) { |
519 | if ( next < nextA ) { | 519 | if ( next < nextA ) { |
520 | nextA = next; | 520 | nextA = next; |
521 | found = true; | 521 | found = true; |
522 | mNextSummary = e->summary(); | 522 | mNextSummary = e->summary(); |
523 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 523 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
524 | mNextAlarmIncidence = (Incidence *) e; | 524 | mNextAlarmIncidence = (Incidence *) e; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | } | 527 | } |
528 | Todo *t; | 528 | Todo *t; |
529 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 529 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
530 | if ( !t->calEnabled() ) continue; | 530 | if ( !t->calEnabled() ) continue; |
531 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 531 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
532 | if ( ok ) { | 532 | if ( ok ) { |
533 | if ( next < nextA ) { | 533 | if ( next < nextA ) { |
534 | nextA = next; | 534 | nextA = next; |
535 | found = true; | 535 | found = true; |
536 | mNextSummary = t->summary(); | 536 | mNextSummary = t->summary(); |
537 | mNextAlarmEventDateTime = next.addSecs(offset ); | 537 | mNextAlarmEventDateTime = next.addSecs(offset ); |
538 | mNextAlarmIncidence = (Incidence *) t; | 538 | mNextAlarmIncidence = (Incidence *) t; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | } | 541 | } |
542 | if ( mNextAlarmIncidence ) { | 542 | if ( mNextAlarmIncidence ) { |
543 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 543 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
544 | mNextAlarmDateTime = nextA; | 544 | mNextAlarmDateTime = nextA; |
545 | } | 545 | } |
546 | return nextA; | 546 | return nextA; |
547 | } | 547 | } |
548 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 548 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
549 | { | 549 | { |
550 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 550 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
551 | } | 551 | } |
552 | 552 | ||
553 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 553 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
554 | { | 554 | { |
555 | 555 | ||
556 | Alarm::List alarms; | 556 | Alarm::List alarms; |
557 | 557 | ||
558 | Event *e; | 558 | Event *e; |
559 | 559 | ||
560 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 560 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
561 | if ( !e->calEnabled() ) continue; | 561 | if ( !e->calEnabled() ) continue; |
562 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 562 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
563 | else appendAlarms( alarms, e, from, to ); | 563 | else appendAlarms( alarms, e, from, to ); |
564 | } | 564 | } |
565 | 565 | ||
566 | Todo *t; | 566 | Todo *t; |
567 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 567 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
568 | if ( !t->calEnabled() ) continue; | 568 | if ( !t->calEnabled() ) continue; |
569 | appendAlarms( alarms, t, from, to ); | 569 | appendAlarms( alarms, t, from, to ); |
570 | } | 570 | } |
571 | 571 | ||
572 | return alarms; | 572 | return alarms; |
573 | } | 573 | } |
574 | 574 | ||
575 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 575 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
576 | const QDateTime &from, const QDateTime &to ) | 576 | const QDateTime &from, const QDateTime &to ) |
577 | { | 577 | { |
578 | QPtrList<Alarm> alarmList = incidence->alarms(); | 578 | QPtrList<Alarm> alarmList = incidence->alarms(); |
579 | Alarm *alarm; | 579 | Alarm *alarm; |
580 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 580 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
581 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 581 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
582 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 582 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
583 | if ( alarm->enabled() ) { | 583 | if ( alarm->enabled() ) { |
584 | if ( alarm->time() >= from && alarm->time() <= to ) { | 584 | if ( alarm->time() >= from && alarm->time() <= to ) { |
585 | alarms.append( alarm ); | 585 | alarms.append( alarm ); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 591 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
592 | Incidence *incidence, | 592 | Incidence *incidence, |
593 | const QDateTime &from, | 593 | const QDateTime &from, |
594 | const QDateTime &to ) | 594 | const QDateTime &to ) |
595 | { | 595 | { |
596 | 596 | ||
597 | QPtrList<Alarm> alarmList = incidence->alarms(); | 597 | QPtrList<Alarm> alarmList = incidence->alarms(); |
598 | Alarm *alarm; | 598 | Alarm *alarm; |
599 | QDateTime qdt; | 599 | QDateTime qdt; |
600 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 600 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
601 | if (incidence->recursOn(from.date())) { | 601 | if (incidence->recursOn(from.date())) { |
602 | qdt.setTime(alarm->time().time()); | 602 | qdt.setTime(alarm->time().time()); |
603 | qdt.setDate(from.date()); | 603 | qdt.setDate(from.date()); |
604 | } | 604 | } |
605 | else qdt = alarm->time(); | 605 | else qdt = alarm->time(); |
606 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 606 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
607 | if ( alarm->enabled() ) { | 607 | if ( alarm->enabled() ) { |
608 | if ( qdt >= from && qdt <= to ) { | 608 | if ( qdt >= from && qdt <= to ) { |
609 | alarms.append( alarm ); | 609 | alarms.append( alarm ); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | /****************************** PROTECTED METHODS ****************************/ | 616 | /****************************** PROTECTED METHODS ****************************/ |
617 | 617 | ||
618 | // after changes are made to an event, this should be called. | 618 | // after changes are made to an event, this should be called. |
619 | void CalendarLocal::update( IncidenceBase *incidence ) | 619 | void CalendarLocal::update( IncidenceBase *incidence ) |
620 | { | 620 | { |
621 | incidence->setSyncStatus( Event::SYNCMOD ); | 621 | incidence->setSyncStatus( Event::SYNCMOD ); |
622 | incidence->setLastModified( QDateTime::currentDateTime() ); | 622 | incidence->setLastModified( QDateTime::currentDateTime() ); |
623 | // we should probably update the revision number here, | 623 | // we should probably update the revision number here, |
624 | // or internally in the Event itself when certain things change. | 624 | // or internally in the Event itself when certain things change. |
625 | // need to verify with ical documentation. | 625 | // need to verify with ical documentation. |
626 | 626 | ||
627 | setModified( true ); | 627 | setModified( true ); |
628 | } | 628 | } |
629 | 629 | ||
630 | void CalendarLocal::insertEvent( Event *event ) | 630 | void CalendarLocal::insertEvent( Event *event ) |
631 | { | 631 | { |
632 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 632 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 636 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
637 | { | 637 | { |
638 | QPtrList<Event> eventList; | 638 | QPtrList<Event> eventList; |
639 | 639 | ||
640 | Event *event; | 640 | Event *event; |
641 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 641 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
642 | if ( !event->calEnabled() ) continue; | 642 | if ( !event->calEnabled() ) continue; |
643 | if ( event->doesRecur() ) { | 643 | if ( event->doesRecur() ) { |
644 | if ( event->isMultiDay() ) { | 644 | if ( event->isMultiDay() ) { |
645 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 645 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
646 | int i; | 646 | int i; |
647 | for ( i = 0; i <= extraDays; i++ ) { | 647 | for ( i = 0; i <= extraDays; i++ ) { |
648 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 648 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
649 | eventList.append( event ); | 649 | eventList.append( event ); |
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | } | 652 | } |
653 | } else { | 653 | } else { |
654 | if ( event->recursOn( qd ) ) | 654 | if ( event->recursOn( qd ) ) |
655 | eventList.append( event ); | 655 | eventList.append( event ); |
656 | } | 656 | } |
657 | } else { | 657 | } else { |
658 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 658 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
659 | eventList.append( event ); | 659 | eventList.append( event ); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | if ( !sorted ) { | 664 | if ( !sorted ) { |
665 | return eventList; | 665 | return eventList; |
666 | } | 666 | } |
667 | 667 | ||
668 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 668 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
669 | // now, we have to sort it based on dtStart.time() | 669 | // now, we have to sort it based on dtStart.time() |
670 | QPtrList<Event> eventListSorted; | 670 | QPtrList<Event> eventListSorted; |
671 | Event *sortEvent; | 671 | Event *sortEvent; |
672 | for ( event = eventList.first(); event; event = eventList.next() ) { | 672 | for ( event = eventList.first(); event; event = eventList.next() ) { |
673 | sortEvent = eventListSorted.first(); | 673 | sortEvent = eventListSorted.first(); |
674 | int i = 0; | 674 | int i = 0; |
675 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 675 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
676 | { | 676 | { |
677 | i++; | 677 | i++; |
678 | sortEvent = eventListSorted.next(); | 678 | sortEvent = eventListSorted.next(); |
679 | } | 679 | } |
680 | eventListSorted.insert( i, event ); | 680 | eventListSorted.insert( i, event ); |
681 | } | 681 | } |
682 | return eventListSorted; | 682 | return eventListSorted; |
683 | } | 683 | } |
684 | 684 | ||
685 | 685 | ||
686 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 686 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
687 | bool inclusive ) | 687 | bool inclusive ) |
688 | { | 688 | { |
689 | Event *event = 0; | 689 | Event *event = 0; |
690 | 690 | ||
691 | QPtrList<Event> eventList; | 691 | QPtrList<Event> eventList; |
692 | 692 | ||
693 | // Get non-recurring events | 693 | // Get non-recurring events |
694 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 694 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
695 | if ( !event->calEnabled() ) continue; | 695 | if ( !event->calEnabled() ) continue; |
696 | if ( event->doesRecur() ) { | 696 | if ( event->doesRecur() ) { |
697 | QDate rStart = event->dtStart().date(); | 697 | QDate rStart = event->dtStart().date(); |
698 | bool found = false; | 698 | bool found = false; |
699 | if ( inclusive ) { | 699 | if ( inclusive ) { |
700 | if ( rStart >= start && rStart <= end ) { | 700 | if ( rStart >= start && rStart <= end ) { |
701 | // Start date of event is in range. Now check for end date. | 701 | // Start date of event is in range. Now check for end date. |
702 | // if duration is negative, event recurs forever, so do not include it. | 702 | // if duration is negative, event recurs forever, so do not include it. |
703 | if ( event->recurrence()->duration() == 0 ) { // End date set | 703 | if ( event->recurrence()->duration() == 0 ) { // End date set |
704 | QDate rEnd = event->recurrence()->endDate(); | 704 | QDate rEnd = event->recurrence()->endDate(); |
705 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 705 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
706 | found = true; | 706 | found = true; |
707 | } | 707 | } |
708 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 708 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
709 | // TODO: Calculate end date from duration. Should be done in Event | 709 | // TODO: Calculate end date from duration. Should be done in Event |
710 | // For now exclude all events with a duration. | 710 | // For now exclude all events with a duration. |
711 | } | 711 | } |
712 | } | 712 | } |
713 | } else { | 713 | } else { |
714 | bool founOne; | 714 | bool founOne; |
715 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 715 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
716 | if ( founOne ) { | 716 | if ( founOne ) { |
717 | if ( next <= end ) { | 717 | if ( next <= end ) { |
718 | found = true; | 718 | found = true; |
719 | } | 719 | } |
720 | } | 720 | } |
721 | 721 | ||
722 | /* | 722 | /* |
723 | // crap !!! | 723 | // crap !!! |
724 | if ( rStart <= end ) { // Start date not after range | 724 | if ( rStart <= end ) { // Start date not after range |
725 | if ( rStart >= start ) { // Start date within range | 725 | if ( rStart >= start ) { // Start date within range |
726 | found = true; | 726 | found = true; |
727 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 727 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
728 | found = true; | 728 | found = true; |
729 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 729 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
730 | QDate rEnd = event->recurrence()->endDate(); | 730 | QDate rEnd = event->recurrence()->endDate(); |
731 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 731 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
732 | found = true; | 732 | found = true; |
733 | } | 733 | } |
734 | } else { // Duration set | 734 | } else { // Duration set |
735 | // TODO: Calculate end date from duration. Should be done in Event | 735 | // TODO: Calculate end date from duration. Should be done in Event |
736 | // For now include all events with a duration. | 736 | // For now include all events with a duration. |
737 | found = true; | 737 | found = true; |
738 | } | 738 | } |
739 | } | 739 | } |
740 | */ | 740 | */ |
741 | 741 | ||
742 | } | 742 | } |
743 | 743 | ||
744 | if ( found ) eventList.append( event ); | 744 | if ( found ) eventList.append( event ); |
745 | } else { | 745 | } else { |
746 | QDate s = event->dtStart().date(); | 746 | QDate s = event->dtStart().date(); |
747 | QDate e = event->dtEnd().date(); | 747 | QDate e = event->dtEnd().date(); |
748 | 748 | ||
749 | if ( inclusive ) { | 749 | if ( inclusive ) { |
750 | if ( s >= start && e <= end ) { | 750 | if ( s >= start && e <= end ) { |
751 | eventList.append( event ); | 751 | eventList.append( event ); |
752 | } | 752 | } |
753 | } else { | 753 | } else { |
754 | if ( ( e >= start && s <= end ) ) { | 754 | if ( ( e >= start && s <= end ) ) { |
755 | eventList.append( event ); | 755 | eventList.append( event ); |
756 | } | 756 | } |
757 | } | 757 | } |
758 | } | 758 | } |
759 | } | 759 | } |
760 | 760 | ||
761 | return eventList; | 761 | return eventList; |
762 | } | 762 | } |
763 | 763 | ||
764 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 764 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
765 | { | 765 | { |
766 | return rawEventsForDate( qdt.date() ); | 766 | return rawEventsForDate( qdt.date() ); |
767 | } | 767 | } |
768 | 768 | ||
769 | QPtrList<Event> CalendarLocal::rawEvents() | 769 | QPtrList<Event> CalendarLocal::rawEvents() |
770 | { | 770 | { |
771 | QPtrList<Event> el; | 771 | QPtrList<Event> el; |
772 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 772 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
773 | if ( it->calEnabled() ) el.append( it ); | 773 | if ( it->calEnabled() ) el.append( it ); |
774 | return el; | 774 | return el; |
775 | } | 775 | } |
776 | 776 | ||
777 | bool CalendarLocal::addJournal(Journal *journal) | 777 | bool CalendarLocal::addJournal(Journal *journal) |
778 | { | 778 | { |
779 | if ( journal->dtStart().isValid()) | 779 | mJournalList.append(journal); |
780 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | ||
781 | else | ||
782 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | ||
783 | |||
784 | mJournalList.append(journal); | ||
785 | 780 | ||
786 | journal->registerObserver( this ); | 781 | journal->registerObserver( this ); |
787 | 782 | ||
788 | setModified( true ); | 783 | setModified( true ); |
789 | journal->setCalID( mDefaultCalendar ); | 784 | journal->setCalID( mDefaultCalendar ); |
790 | journal->setCalEnabled( true ); | 785 | journal->setCalEnabled( true ); |
791 | return true; | 786 | return true; |
792 | } | 787 | } |
793 | 788 | ||
794 | void CalendarLocal::deleteJournal( Journal *journal ) | 789 | void CalendarLocal::deleteJournal( Journal *journal ) |
795 | { | 790 | { |
796 | if ( mUndoIncidence ) delete mUndoIncidence; | 791 | if ( mUndoIncidence ) delete mUndoIncidence; |
797 | mUndoIncidence = journal->clone(); | 792 | mUndoIncidence = journal->clone(); |
798 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 793 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
799 | if ( mJournalList.removeRef(journal) ) { | 794 | if ( mJournalList.removeRef(journal) ) { |
800 | setModified( true ); | 795 | setModified( true ); |
801 | } | 796 | } |
802 | } | 797 | } |
803 | 798 | ||
799 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | ||
800 | { | ||
801 | QPtrList<Journal> el; | ||
802 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
803 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); | ||
804 | return el; | ||
805 | } | ||
804 | Journal *CalendarLocal::journal( const QDate &date ) | 806 | Journal *CalendarLocal::journal( const QDate &date ) |
805 | { | 807 | { |
806 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 808 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
807 | 809 | ||
808 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 810 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
809 | if ( it->calEnabled() && it->dtStart().date() == date ) | 811 | if ( it->calEnabled() && it->dtStart().date() == date ) |
810 | return it; | 812 | return it; |
811 | 813 | ||
812 | return 0; | 814 | return 0; |
813 | } | 815 | } |
814 | 816 | ||
815 | Journal *CalendarLocal::journal( const QString &uid ) | 817 | Journal *CalendarLocal::journal( const QString &uid ) |
816 | { | 818 | { |
817 | Journal * retVal = 0; | 819 | Journal * retVal = 0; |
818 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 820 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
819 | if ( it->calEnabled() && it->uid() == uid ) { | 821 | if ( it->calEnabled() && it->uid() == uid ) { |
820 | if ( retVal ) { | 822 | if ( retVal ) { |
821 | if ( retVal->calID() > it->calID() ) { | 823 | if ( retVal->calID() > it->calID() ) { |
822 | retVal = it; | 824 | retVal = it; |
823 | } | 825 | } |
824 | } else { | 826 | } else { |
825 | retVal = it; | 827 | retVal = it; |
826 | } | 828 | } |
827 | } | 829 | } |
828 | return retVal; | 830 | return retVal; |
829 | } | 831 | } |
830 | 832 | ||
831 | QPtrList<Journal> CalendarLocal::journals() | 833 | QPtrList<Journal> CalendarLocal::journals() |
832 | { | 834 | { |
833 | QPtrList<Journal> el; | 835 | QPtrList<Journal> el; |
834 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 836 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
835 | if ( it->calEnabled() ) el.append( it ); | 837 | if ( it->calEnabled() ) el.append( it ); |
836 | return el; | 838 | return el; |
837 | } | 839 | } |
838 | void CalendarLocal::setCalendarRemove( int id ) | 840 | void CalendarLocal::setCalendarRemove( int id ) |
839 | { | 841 | { |
840 | 842 | ||
841 | { | 843 | { |
842 | QPtrList<Event> EventList = mEventList; | 844 | QPtrList<Event> EventList = mEventList; |
843 | Event * ev = EventList.first(); | 845 | Event * ev = EventList.first(); |
844 | while ( ev ) { | 846 | while ( ev ) { |
845 | if ( ev->calID() == id ) | 847 | if ( ev->calID() == id ) |
846 | deleteEvent( ev ); | 848 | deleteEvent( ev ); |
847 | ev = EventList.next(); | 849 | ev = EventList.next(); |
848 | } | 850 | } |
849 | } | 851 | } |
850 | { | 852 | { |
851 | 853 | ||
852 | QPtrList<Todo> TodoList = mTodoList; | 854 | QPtrList<Todo> TodoList = mTodoList; |
853 | Todo * ev = TodoList.first(); | 855 | Todo * ev = TodoList.first(); |
854 | while ( ev ) { | 856 | while ( ev ) { |
855 | if ( ev->calID() == id ) | 857 | if ( ev->calID() == id ) |
856 | deleteTodo( ev ); | 858 | deleteTodo( ev ); |
857 | ev = TodoList.next(); | 859 | ev = TodoList.next(); |
858 | } | 860 | } |
859 | } | 861 | } |
860 | { | 862 | { |
861 | QPtrList<Journal> JournalList = mJournalList; | 863 | QPtrList<Journal> JournalList = mJournalList; |
862 | Journal * ev = JournalList.first(); | 864 | Journal * ev = JournalList.first(); |
863 | while ( ev ) { | 865 | while ( ev ) { |
864 | if ( ev->calID() == id ) | 866 | if ( ev->calID() == id ) |
865 | deleteJournal( ev ); | 867 | deleteJournal( ev ); |
866 | ev = JournalList.next(); | 868 | ev = JournalList.next(); |
867 | } | 869 | } |
868 | } | 870 | } |
869 | 871 | ||
870 | if ( mUndoIncidence ) delete mUndoIncidence; | 872 | if ( mUndoIncidence ) delete mUndoIncidence; |
871 | mUndoIncidence = 0; | 873 | mUndoIncidence = 0; |
872 | 874 | ||
873 | } | 875 | } |
874 | 876 | ||
875 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 877 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
876 | { | 878 | { |
877 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 879 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
878 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 880 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
879 | 881 | ||
880 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 882 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
881 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 883 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
882 | 884 | ||
883 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 885 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
884 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 886 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
885 | 887 | ||
886 | } | 888 | } |
887 | 889 | ||
888 | void CalendarLocal::setReadOnly( int id, bool enable ) | 890 | void CalendarLocal::setReadOnly( int id, bool enable ) |
889 | { | 891 | { |
890 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 892 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
891 | if ( it->calID() == id ) it->setReadOnly( enable ); | 893 | if ( it->calID() == id ) it->setReadOnly( enable ); |
892 | 894 | ||
893 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 895 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
894 | if ( it->calID() == id ) it->setReadOnly( enable ); | 896 | if ( it->calID() == id ) it->setReadOnly( enable ); |
895 | 897 | ||
896 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 898 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
897 | if ( it->calID() == id ) it->setReadOnly( enable ); | 899 | if ( it->calID() == id ) it->setReadOnly( enable ); |
898 | 900 | ||
899 | } | 901 | } |
900 | 902 | ||
901 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 903 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
902 | { | 904 | { |
903 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 905 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
904 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 906 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
905 | 907 | ||
906 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 908 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
907 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 909 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
908 | 910 | ||
909 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 911 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
910 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 912 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
911 | reInitAlarmSettings(); | 913 | reInitAlarmSettings(); |
912 | 914 | ||
913 | } | 915 | } |
914 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 916 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
915 | { | 917 | { |
916 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 918 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
917 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 919 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
918 | 920 | ||
919 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 921 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
920 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 922 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
921 | 923 | ||
922 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 924 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
923 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 925 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
924 | 926 | ||
925 | } | 927 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index d32597f..98d16a3 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,226 +1,227 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | void setSyncEventsReadOnly(); | 48 | void setSyncEventsReadOnly(); |
49 | void stopAllTodos(); | 49 | void stopAllTodos(); |
50 | /** | 50 | /** |
51 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 51 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
52 | calendar. Any information already present is lost. | 52 | calendar. Any information already present is lost. |
53 | @return true, if successfull, false on error. | 53 | @return true, if successfull, false on error. |
54 | @param fileName the name of the calendar on disk. | 54 | @param fileName the name of the calendar on disk. |
55 | */ | 55 | */ |
56 | bool load( const QString &fileName ); | 56 | bool load( const QString &fileName ); |
57 | /** | 57 | /** |
58 | Writes out the calendar to disk in the specified \a format. | 58 | Writes out the calendar to disk in the specified \a format. |
59 | CalendarLocal takes ownership of the CalFormat object. | 59 | CalendarLocal takes ownership of the CalFormat object. |
60 | @return true, if successfull, false on error. | 60 | @return true, if successfull, false on error. |
61 | @param fileName the name of the file | 61 | @param fileName the name of the file |
62 | */ | 62 | */ |
63 | bool save( const QString &fileName, CalFormat *format = 0 ); | 63 | bool save( const QString &fileName, CalFormat *format = 0 ); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | Clears out the current calendar, freeing all used memory etc. etc. | 66 | Clears out the current calendar, freeing all used memory etc. etc. |
67 | */ | 67 | */ |
68 | void close(); | 68 | void close(); |
69 | 69 | ||
70 | void save() {} | 70 | void save() {} |
71 | 71 | ||
72 | /** | 72 | /** |
73 | Add Event to calendar. | 73 | Add Event to calendar. |
74 | */ | 74 | */ |
75 | void removeSyncInfo( QString syncProfile); | 75 | void removeSyncInfo( QString syncProfile); |
76 | bool addAnniversaryNoDup( Event *event ); | 76 | bool addAnniversaryNoDup( Event *event ); |
77 | bool addEventNoDup( Event *event ); | 77 | bool addEventNoDup( Event *event ); |
78 | bool addEvent( Event *event ); | 78 | bool addEvent( Event *event ); |
79 | /** | 79 | /** |
80 | Deletes an event from this calendar. | 80 | Deletes an event from this calendar. |
81 | */ | 81 | */ |
82 | void deleteEvent( Event *event ); | 82 | void deleteEvent( Event *event ); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | Retrieves an event on the basis of the unique string ID. | 85 | Retrieves an event on the basis of the unique string ID. |
86 | */ | 86 | */ |
87 | Event *event( const QString &uid ); | 87 | Event *event( const QString &uid ); |
88 | /** | 88 | /** |
89 | Return unfiltered list of all events in calendar. | 89 | Return unfiltered list of all events in calendar. |
90 | */ | 90 | */ |
91 | QPtrList<Event> rawEvents(); | 91 | QPtrList<Event> rawEvents(); |
92 | QPtrList<Event> getExternLastSyncEvents(); | 92 | QPtrList<Event> getExternLastSyncEvents(); |
93 | /** | 93 | /** |
94 | Add a todo to the todolist. | 94 | Add a todo to the todolist. |
95 | */ | 95 | */ |
96 | bool addTodo( Todo *todo ); | 96 | bool addTodo( Todo *todo ); |
97 | bool addTodoNoDup( Todo *todo ); | 97 | bool addTodoNoDup( Todo *todo ); |
98 | /** | 98 | /** |
99 | Remove a todo from the todolist. | 99 | Remove a todo from the todolist. |
100 | */ | 100 | */ |
101 | void deleteTodo( Todo * ); | 101 | void deleteTodo( Todo * ); |
102 | /** | 102 | /** |
103 | Searches todolist for an event with this unique string identifier, | 103 | Searches todolist for an event with this unique string identifier, |
104 | returns a pointer or null. | 104 | returns a pointer or null. |
105 | */ | 105 | */ |
106 | Todo *todo( const QString &uid ); | 106 | Todo *todo( const QString &uid ); |
107 | /** | 107 | /** |
108 | Return list of all todos. | 108 | Return list of all todos. |
109 | */ | 109 | */ |
110 | QPtrList<Todo> rawTodos(); | 110 | QPtrList<Todo> rawTodos(); |
111 | /** | 111 | /** |
112 | Returns list of todos due on the specified date. | 112 | Returns list of todos due on the specified date. |
113 | */ | 113 | */ |
114 | QPtrList<Todo> todos( const QDate &date ); | 114 | QPtrList<Todo> todos( const QDate &date ); |
115 | /** | 115 | /** |
116 | Return list of all todos. | 116 | Return list of all todos. |
117 | 117 | ||
118 | Workaround because compiler does not recognize function of base class. | 118 | Workaround because compiler does not recognize function of base class. |
119 | */ | 119 | */ |
120 | QPtrList<Todo> todos() { return Calendar::todos(); } | 120 | QPtrList<Todo> todos() { return Calendar::todos(); } |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Add a Journal entry to calendar. | 123 | Add a Journal entry to calendar. |
124 | */ | 124 | */ |
125 | bool addJournal( Journal * ); | 125 | bool addJournal( Journal * ); |
126 | /** | 126 | /** |
127 | Remove a Journal from the calendar. | 127 | Remove a Journal from the calendar. |
128 | */ | 128 | */ |
129 | void deleteJournal( Journal * ); | 129 | void deleteJournal( Journal * ); |
130 | /** | 130 | /** |
131 | Return Journal for given date. | 131 | Return Journal for given date. |
132 | */ | 132 | */ |
133 | Journal *journal( const QDate & ); | 133 | Journal *journal( const QDate & ); |
134 | QPtrList<Journal> journals4Date( const QDate & ); | ||
134 | /** | 135 | /** |
135 | Return Journal with given UID. | 136 | Return Journal with given UID. |
136 | */ | 137 | */ |
137 | Journal *journal( const QString &uid ); | 138 | Journal *journal( const QString &uid ); |
138 | /** | 139 | /** |
139 | Return list of all Journals stored in calendar. | 140 | Return list of all Journals stored in calendar. |
140 | */ | 141 | */ |
141 | QPtrList<Journal> journals(); | 142 | QPtrList<Journal> journals(); |
142 | 143 | ||
143 | /** | 144 | /** |
144 | Return all alarms, which ocur in the given time interval. | 145 | Return all alarms, which ocur in the given time interval. |
145 | */ | 146 | */ |
146 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 147 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
147 | 148 | ||
148 | /** | 149 | /** |
149 | Return all alarms, which ocur before given date. | 150 | Return all alarms, which ocur before given date. |
150 | */ | 151 | */ |
151 | Alarm::List alarmsTo( const QDateTime &to ); | 152 | Alarm::List alarmsTo( const QDateTime &to ); |
152 | 153 | ||
153 | QDateTime nextAlarm( int daysTo ) ; | 154 | QDateTime nextAlarm( int daysTo ) ; |
154 | QDateTime nextAlarmEventDateTime() const; | 155 | QDateTime nextAlarmEventDateTime() const; |
155 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 156 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
156 | void registerAlarm(); | 157 | void registerAlarm(); |
157 | void deRegisterAlarm(); | 158 | void deRegisterAlarm(); |
158 | QString getAlarmNotification(); | 159 | QString getAlarmNotification(); |
159 | QString nextSummary() const ; | 160 | QString nextSummary() const ; |
160 | /** | 161 | /** |
161 | This method should be called whenever a Event is modified directly | 162 | This method should be called whenever a Event is modified directly |
162 | via it's pointer. It makes sure that the calendar is internally | 163 | via it's pointer. It makes sure that the calendar is internally |
163 | consistent. | 164 | consistent. |
164 | */ | 165 | */ |
165 | void update( IncidenceBase *incidence ); | 166 | void update( IncidenceBase *incidence ); |
166 | 167 | ||
167 | /** | 168 | /** |
168 | Builds and then returns a list of all events that match for the | 169 | Builds and then returns a list of all events that match for the |
169 | date specified. useful for dayView, etc. etc. | 170 | date specified. useful for dayView, etc. etc. |
170 | */ | 171 | */ |
171 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 172 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
172 | /** | 173 | /** |
173 | Get unfiltered events for date \a qdt. | 174 | Get unfiltered events for date \a qdt. |
174 | */ | 175 | */ |
175 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 176 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
176 | /** | 177 | /** |
177 | Get unfiltered events in a range of dates. If inclusive is set to true, | 178 | Get unfiltered events in a range of dates. If inclusive is set to true, |
178 | only events are returned, which are completely included in the range. | 179 | only events are returned, which are completely included in the range. |
179 | */ | 180 | */ |
180 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 181 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
181 | bool inclusive = false ); | 182 | bool inclusive = false ); |
182 | Todo *todo( QString, QString ); | 183 | Todo *todo( QString, QString ); |
183 | Event *event( QString, QString ); | 184 | Event *event( QString, QString ); |
184 | 185 | ||
185 | public slots: | 186 | public slots: |
186 | void setCalendarEnabled( int id, bool enable ); | 187 | void setCalendarEnabled( int id, bool enable ); |
187 | void setAlarmEnabled( int id, bool enable ); | 188 | void setAlarmEnabled( int id, bool enable ); |
188 | void setReadOnly( int id, bool enable ); | 189 | void setReadOnly( int id, bool enable ); |
189 | void setDefaultCalendarEnabledOnly(); | 190 | void setDefaultCalendarEnabledOnly(); |
190 | void setCalendarRemove( int id ); | 191 | void setCalendarRemove( int id ); |
191 | 192 | ||
192 | protected: | 193 | protected: |
193 | 194 | ||
194 | // Event* mNextAlarmEvent; | 195 | // Event* mNextAlarmEvent; |
195 | QString mNextSummary; | 196 | QString mNextSummary; |
196 | QString mNextAlarmEventDateTimeString; | 197 | QString mNextAlarmEventDateTimeString; |
197 | QString mLastAlarmNotificationString; | 198 | QString mLastAlarmNotificationString; |
198 | QDateTime mNextAlarmEventDateTime; | 199 | QDateTime mNextAlarmEventDateTime; |
199 | QDateTime mNextAlarmDateTime; | 200 | QDateTime mNextAlarmDateTime; |
200 | void reInitAlarmSettings(); | 201 | void reInitAlarmSettings(); |
201 | 202 | ||
202 | /** Notification function of IncidenceBase::Observer. */ | 203 | /** Notification function of IncidenceBase::Observer. */ |
203 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 204 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
204 | 205 | ||
205 | /** inserts an event into its "proper place" in the calendar. */ | 206 | /** inserts an event into its "proper place" in the calendar. */ |
206 | void insertEvent( Event *event ); | 207 | void insertEvent( Event *event ); |
207 | 208 | ||
208 | /** Append alarms of incidence in interval to list of alarms. */ | 209 | /** Append alarms of incidence in interval to list of alarms. */ |
209 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 210 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
210 | const QDateTime &from, const QDateTime &to ); | 211 | const QDateTime &from, const QDateTime &to ); |
211 | 212 | ||
212 | /** Append alarms of recurring events in interval to list of alarms. */ | 213 | /** Append alarms of recurring events in interval to list of alarms. */ |
213 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 214 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
214 | const QDateTime &from, const QDateTime &to ); | 215 | const QDateTime &from, const QDateTime &to ); |
215 | 216 | ||
216 | private: | 217 | private: |
217 | void init(); | 218 | void init(); |
218 | 219 | ||
219 | QPtrList<Event> mEventList; | 220 | QPtrList<Event> mEventList; |
220 | QPtrList<Todo> mTodoList; | 221 | QPtrList<Todo> mTodoList; |
221 | QPtrList<Journal> mJournalList; | 222 | QPtrList<Journal> mJournalList; |
222 | }; | 223 | }; |
223 | 224 | ||
224 | } | 225 | } |
225 | 226 | ||
226 | #endif | 227 | #endif |