author | zautrix <zautrix> | 2005-04-05 10:34:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-05 10:34:37 (UTC) |
commit | 854e1b46d7895bf4860d914abb5f1e954dfbfe6a (patch) (unidiff) | |
tree | 0636047ee54238f5d2b864bb0b0419e65311c91b | |
parent | 141c73d9ee02cff6fc2a56289bd8c85bbf60df02 (diff) | |
download | kdepimpi-854e1b46d7895bf4860d914abb5f1e954dfbfe6a.zip kdepimpi-854e1b46d7895bf4860d914abb5f1e954dfbfe6a.tar.gz kdepimpi-854e1b46d7895bf4860d914abb5f1e954dfbfe6a.tar.bz2 |
fix
-rw-r--r-- | korganizer/komonthview.cpp | 3 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 1 |
2 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 425496a..6d6ae8a 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -204,400 +204,399 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
204 | e->ignore(); | 204 | e->ignore(); |
205 | break; | 205 | break; |
206 | case Key_Return: | 206 | case Key_Return: |
207 | case Key_Enter: | 207 | case Key_Enter: |
208 | { | 208 | { |
209 | if ( currentItem() >= 0 ) { | 209 | if ( currentItem() >= 0 ) { |
210 | emit doubleClicked( item( currentItem() ) ); | 210 | emit doubleClicked( item( currentItem() ) ); |
211 | e->accept(); | 211 | e->accept(); |
212 | } else { | 212 | } else { |
213 | e->ignore(); | 213 | e->ignore(); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | break; | 216 | break; |
217 | case Key_Shift: | 217 | case Key_Shift: |
218 | emit shiftDown(); | 218 | emit shiftDown(); |
219 | break; | 219 | break; |
220 | default: | 220 | default: |
221 | e->ignore(); | 221 | e->ignore(); |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | void KNoScrollListBox::oneDown() | 226 | void KNoScrollListBox::oneDown() |
227 | { | 227 | { |
228 | if ( count () ) { | 228 | if ( count () ) { |
229 | resetOnFocusIn = false; | 229 | resetOnFocusIn = false; |
230 | setCurrentItem((currentItem()+1)%count()); | 230 | setCurrentItem((currentItem()+1)%count()); |
231 | if(!itemVisible(currentItem())) { | 231 | if(!itemVisible(currentItem())) { |
232 | if(currentItem() == 0) { | 232 | if(currentItem() == 0) { |
233 | setTopItem(0); | 233 | setTopItem(0); |
234 | } else { | 234 | } else { |
235 | setTopItem(topItem()+1); | 235 | setTopItem(topItem()+1); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 240 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
241 | { | 241 | { |
242 | switch(e->key()) { | 242 | switch(e->key()) { |
243 | case Key_Shift: | 243 | case Key_Shift: |
244 | emit shiftUp(); | 244 | emit shiftUp(); |
245 | break; | 245 | break; |
246 | default: | 246 | default: |
247 | break; | 247 | break; |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 251 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
252 | { | 252 | { |
253 | QListBox::mousePressEvent(e); | 253 | QListBox::mousePressEvent(e); |
254 | 254 | ||
255 | if(e->button() == RightButton) { | 255 | if(e->button() == RightButton) { |
256 | emit rightClick(); | 256 | emit rightClick(); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 260 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
261 | : QListBoxItem() | 261 | : QListBoxItem() |
262 | { | 262 | { |
263 | mblockRepaint = true; | 263 | mblockRepaint = true; |
264 | setText( s ); | 264 | setText( s ); |
265 | mMultiday = 0; | 265 | mMultiday = 0; |
266 | mIncidence = incidence; | 266 | mIncidence = incidence; |
267 | mDate = qd; | 267 | mDate = qd; |
268 | mRecur = false; | 268 | mRecur = false; |
269 | mAlarm = false; | 269 | mAlarm = false; |
270 | mReply = false; | 270 | mReply = false; |
271 | mInfo = false; | 271 | mInfo = false; |
272 | mdayPos = 0; | 272 | mdayPos = 0; |
273 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 273 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
274 | //qDebug("NEWWWWWWWWWWWWW "); | 274 | //qDebug("NEWWWWWWWWWWWWW "); |
275 | } | 275 | } |
276 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 276 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
277 | { | 277 | { |
278 | setText( s ); | 278 | setText( s ); |
279 | mMultiday = 0; | 279 | mMultiday = 0; |
280 | mIncidence = incidence; | 280 | mIncidence = incidence; |
281 | mDate = qd; | 281 | mDate = qd; |
282 | mRecur = false; | 282 | mRecur = false; |
283 | mAlarm = false; | 283 | mAlarm = false; |
284 | mReply = false; | 284 | mReply = false; |
285 | mInfo = false; | 285 | mInfo = false; |
286 | mdayPos = 0; | 286 | mdayPos = 0; |
287 | //qDebug("recucleeeeeeeeeeeeeeeee "); | 287 | //qDebug("recucleeeeeeeeeeeeeeeee "); |
288 | } | 288 | } |
289 | 289 | ||
290 | void MonthViewItem::paint(QPainter *p) | 290 | void MonthViewItem::paint(QPainter *p) |
291 | { | 291 | { |
292 | if ( mblockRepaint ) { | 292 | if ( mblockRepaint ) { |
293 | //qDebug("block "); | 293 | //qDebug("block "); |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | //qDebug("NON block "); | 296 | //qDebug("NON block "); |
297 | #if QT_VERSION >= 0x030000 | 297 | #if QT_VERSION >= 0x030000 |
298 | bool sel = isSelected(); | 298 | bool sel = isSelected(); |
299 | #else | 299 | #else |
300 | bool sel = selected(); | 300 | bool sel = selected(); |
301 | #endif | 301 | #endif |
302 | 302 | ||
303 | 303 | ||
304 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 304 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
305 | { | 305 | { |
306 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 306 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
307 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 307 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
308 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 308 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
309 | } | 309 | } |
310 | int x = 1; | 310 | int x = 1; |
311 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 311 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
312 | int size = PIXMAP_SIZE; | 312 | int size = PIXMAP_SIZE; |
313 | if ( QApplication::desktop()->width() < 300 ) | 313 | if ( QApplication::desktop()->width() < 300 ) |
314 | size = 3; | 314 | size = 3; |
315 | int heihei = height( listBox () ); | 315 | int heihei = height( listBox () ); |
316 | int y = (heihei - size -1 ) /2; | 316 | int y = (heihei - size -1 ) /2; |
317 | 317 | ||
318 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 318 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
319 | if ( mInfo ) { | 319 | if ( mInfo ) { |
320 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 320 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
321 | x += size + 1; | 321 | x += size + 1; |
322 | } | 322 | } |
323 | if ( mRecur ) { | 323 | if ( mRecur ) { |
324 | p->fillRect ( x, y,size,size, Qt::blue ); | 324 | p->fillRect ( x, y,size,size, Qt::blue ); |
325 | x += size + 1; | 325 | x += size + 1; |
326 | } | 326 | } |
327 | if ( mAlarm ) { | 327 | if ( mAlarm ) { |
328 | p->fillRect ( x, y,size,size, Qt::red ); | 328 | p->fillRect ( x, y,size,size, Qt::red ); |
329 | x += size + 1; | 329 | x += size + 1; |
330 | } | 330 | } |
331 | if ( mReply ) { | 331 | if ( mReply ) { |
332 | p->fillRect ( x, y,size,size, Qt::yellow ); | 332 | p->fillRect ( x, y,size,size, Qt::yellow ); |
333 | x += size + 1; | 333 | x += size + 1; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | if ( mMultiday ) { | 336 | if ( mMultiday ) { |
337 | int yyy = y+(size/2); | 337 | int yyy = y+(size/2); |
338 | int sizeM = size+2; | 338 | int sizeM = size+2; |
339 | p->setBrush( QBrush::SolidPattern ); | 339 | p->setBrush( QBrush::SolidPattern ); |
340 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 340 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
341 | if ( mMultiday == 2 || mMultiday == 3 ) { | 341 | if ( mMultiday == 2 || mMultiday == 3 ) { |
342 | QPointArray pa ( 3 ); | 342 | QPointArray pa ( 3 ); |
343 | pa.setPoint (0, x, yyy ); | 343 | pa.setPoint (0, x, yyy ); |
344 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 344 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
345 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 345 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
346 | p->drawPolygon( pa ); | 346 | p->drawPolygon( pa ); |
347 | } | 347 | } |
348 | if ( mMultiday == 2 || mMultiday == 1 ) { | 348 | if ( mMultiday == 2 || mMultiday == 1 ) { |
349 | QPointArray pa ( 3 ); | 349 | QPointArray pa ( 3 ); |
350 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 350 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
351 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 351 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
352 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 352 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
353 | p->drawPolygon( pa ); | 353 | p->drawPolygon( pa ); |
354 | } | 354 | } |
355 | if ( mMultiday == 1 ) { | 355 | if ( mMultiday == 1 ) { |
356 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 356 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
357 | 357 | ||
358 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 358 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
359 | } | 359 | } |
360 | if ( mMultiday == 3 ) { | 360 | if ( mMultiday == 3 ) { |
361 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 361 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
362 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 362 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
363 | 363 | ||
364 | } | 364 | } |
365 | x += sizeM/2 + 1; | 365 | x += sizeM/2 + 1; |
366 | x += sizeM + 1; | 366 | x += sizeM + 1; |
367 | } | 367 | } |
368 | 368 | ||
369 | if ( mIncidence->type() == "Todo" ){ | 369 | if ( mIncidence->type() == "Todo" ){ |
370 | Todo* td = ( Todo* ) mIncidence; | 370 | Todo* td = ( Todo* ) mIncidence; |
371 | if ( td->isCompleted() ) { | 371 | if ( td->isCompleted() ) { |
372 | int half = size/2; | 372 | int half = size/2; |
373 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 373 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
374 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 374 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
375 | x += half+half + 4; | 375 | x += half+half + 4; |
376 | 376 | ||
377 | } else { | 377 | } else { |
378 | int val = td->percentComplete()/20; | 378 | int val = td->percentComplete()/20; |
379 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 379 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); |
380 | p->drawRect ( x, y-2,7,size+4); | 380 | p->drawRect ( x, y-2,7,size+4); |
381 | x += size + 3; | 381 | x += size + 3; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | QFontMetrics fm = p->fontMetrics(); | 384 | QFontMetrics fm = p->fontMetrics(); |
385 | int yPos; | 385 | int yPos; |
386 | int pmheight = size; | 386 | int pmheight = size; |
387 | if( pmheight < fm.height() ) | 387 | if( pmheight < fm.height() ) |
388 | yPos = fm.ascent() + fm.leading()/2; | 388 | yPos = fm.ascent() + fm.leading()/2; |
389 | else | 389 | else |
390 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 390 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
391 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 391 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
392 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 392 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
393 | p->drawText( x, yPos, text() ); | 393 | p->drawText( x, yPos, text() ); |
394 | if ( mIncidence->cancelled() ) { | 394 | if ( mIncidence->cancelled() ) { |
395 | int wid = fm.width( text() ); | 395 | int wid = fm.width( text() ); |
396 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 396 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
397 | } | 397 | } |
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | int MonthViewItem::height(const QListBox *lb) const | 401 | int MonthViewItem::height(const QListBox *lb) const |
402 | { | 402 | { |
403 | int ret = 10; | 403 | int ret = 10; |
404 | if ( lb ) | 404 | if ( lb ) |
405 | ret = lb->fontMetrics().lineSpacing()+1; | 405 | ret = lb->fontMetrics().lineSpacing()+1; |
406 | return ret; | 406 | return ret; |
407 | } | 407 | } |
408 | 408 | ||
409 | int MonthViewItem::width(const QListBox *lb) const | 409 | int MonthViewItem::width(const QListBox *lb) const |
410 | { | 410 | { |
411 | |||
412 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 411 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
413 | int size = PIXMAP_SIZE; | 412 | int size = PIXMAP_SIZE; |
414 | if ( QApplication::desktop()->width() < 300 ) | 413 | if ( QApplication::desktop()->width() < 300 ) |
415 | size = 3; | 414 | size = 3; |
416 | int x = 1; | 415 | int x = 1; |
417 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 416 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
418 | if ( mInfo ) { | 417 | if ( mInfo ) { |
419 | x += size + 1; | 418 | x += size + 1; |
420 | } | 419 | } |
421 | if( mRecur ) { | 420 | if( mRecur ) { |
422 | x += size+1; | 421 | x += size+1; |
423 | } | 422 | } |
424 | if( mAlarm ) { | 423 | if( mAlarm ) { |
425 | x += size+1; | 424 | x += size+1; |
426 | } | 425 | } |
427 | if( mReply ) { | 426 | if( mReply ) { |
428 | x += size+1; | 427 | x += size+1; |
429 | } | 428 | } |
430 | } | 429 | } |
431 | if( mMultiday ) { | 430 | if( mMultiday ) { |
432 | x += size+1+2+size/2; | 431 | x += size+1+2+size/2; |
433 | } | 432 | } |
434 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 433 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
435 | } | 434 | } |
436 | if ( ! lb ) | 435 | if ( ! lb ) |
437 | return 10; | 436 | return 10; |
438 | //qDebug("ret wid %d ", lb->width()); | 437 | //qDebug("ret wid %d ", lb->width()); |
439 | return lb->width(); | 438 | return lb->width(); |
440 | } | 439 | } |
441 | 440 | ||
442 | 441 | ||
443 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 442 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
444 | : KNoScrollListBox( par ), | 443 | : KNoScrollListBox( par ), |
445 | mMonthView( parent ) | 444 | mMonthView( parent ) |
446 | { | 445 | { |
447 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 446 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
448 | currentPalette = 0; | 447 | currentPalette = 0; |
449 | // mLabel = new QLabel( this );QPushButton | 448 | // mLabel = new QLabel( this );QPushButton |
450 | mLabel = new QPushButton( this ); | 449 | mLabel = new QPushButton( this ); |
451 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 450 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
452 | //mLabel->setLineWidth( 1 ); | 451 | //mLabel->setLineWidth( 1 ); |
453 | //mLabel->setAlignment( AlignCenter ); | 452 | //mLabel->setAlignment( AlignCenter ); |
454 | mLabel->setFlat( true ); | 453 | mLabel->setFlat( true ); |
455 | mLabel->setFocusPolicy(NoFocus); | 454 | mLabel->setFocusPolicy(NoFocus); |
456 | //mItemList = new KNoScrollListBox( this ); | 455 | //mItemList = new KNoScrollListBox( this ); |
457 | setMinimumSize( 10, 10 ); | 456 | setMinimumSize( 10, 10 ); |
458 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 457 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
459 | setLineWidth( 1 ); | 458 | setLineWidth( 1 ); |
460 | //topLayout->addWidget( mItemList ); | 459 | //topLayout->addWidget( mItemList ); |
461 | mLabel->raise(); | 460 | mLabel->raise(); |
462 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 461 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
463 | mStandardPalette = palette(); | 462 | mStandardPalette = palette(); |
464 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 463 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
465 | 464 | ||
466 | enableScrollBars( false ); | 465 | enableScrollBars( false ); |
467 | updateConfig(); | 466 | updateConfig(); |
468 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 467 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
469 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 468 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
470 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 469 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
471 | SLOT( defaultAction( QListBoxItem * ) ) ); | 470 | SLOT( defaultAction( QListBoxItem * ) ) ); |
472 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 471 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
473 | const QPoint &) ), | 472 | const QPoint &) ), |
474 | SLOT( contextMenu( QListBoxItem * ) ) ); | 473 | SLOT( contextMenu( QListBoxItem * ) ) ); |
475 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 474 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
476 | SLOT( selection( QListBoxItem * ) ) ); | 475 | SLOT( selection( QListBoxItem * ) ) ); |
477 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 476 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
478 | SLOT( cellClicked( QListBoxItem * ) ) ); | 477 | SLOT( cellClicked( QListBoxItem * ) ) ); |
479 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 478 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
480 | SLOT( selection( QListBoxItem * ) ) ); | 479 | SLOT( selection( QListBoxItem * ) ) ); |
481 | } | 480 | } |
482 | #ifdef DESKTOP_VERSION | 481 | #ifdef DESKTOP_VERSION |
483 | QToolTipGroup *MonthViewCell::toolTipGroup() | 482 | QToolTipGroup *MonthViewCell::toolTipGroup() |
484 | { | 483 | { |
485 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 484 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
486 | return mToolTipGroup; | 485 | return mToolTipGroup; |
487 | } | 486 | } |
488 | #endif | 487 | #endif |
489 | 488 | ||
490 | void MonthViewCell::setDate( const QDate &date ) | 489 | void MonthViewCell::setDate( const QDate &date ) |
491 | { | 490 | { |
492 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 491 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
493 | mDate = date; | 492 | mDate = date; |
494 | 493 | ||
495 | 494 | ||
496 | 495 | ||
497 | //resizeEvent( 0 ); | 496 | //resizeEvent( 0 ); |
498 | } | 497 | } |
499 | 498 | ||
500 | QDate MonthViewCell::date() const | 499 | QDate MonthViewCell::date() const |
501 | { | 500 | { |
502 | return mDate; | 501 | return mDate; |
503 | } | 502 | } |
504 | 503 | ||
505 | void MonthViewCell::setPrimary( bool primary ) | 504 | void MonthViewCell::setPrimary( bool primary ) |
506 | { | 505 | { |
507 | mPrimary = primary; | 506 | mPrimary = primary; |
508 | //setMyPalette(); | 507 | //setMyPalette(); |
509 | } | 508 | } |
510 | void MonthViewCell::setMyPalette() | 509 | void MonthViewCell::setMyPalette() |
511 | { | 510 | { |
512 | 511 | ||
513 | if ( mHoliday) { | 512 | if ( mHoliday) { |
514 | if ( currentPalette == 1 ) return; | 513 | if ( currentPalette == 1 ) return; |
515 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 514 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
516 | setPalette( mHolidayPalette ); | 515 | setPalette( mHolidayPalette ); |
517 | //mLabel->setPalette( mHolidayPalette ); | 516 | //mLabel->setPalette( mHolidayPalette ); |
518 | currentPalette = 1; | 517 | currentPalette = 1; |
519 | 518 | ||
520 | } else { | 519 | } else { |
521 | if ( mPrimary ) { | 520 | if ( mPrimary ) { |
522 | if ( currentPalette == 2 ) return; | 521 | if ( currentPalette == 2 ) return; |
523 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 522 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
524 | //mLabel->setPalette( mPrimaryPalette ); | 523 | //mLabel->setPalette( mPrimaryPalette ); |
525 | setPalette( mPrimaryPalette ); | 524 | setPalette( mPrimaryPalette ); |
526 | currentPalette = 2; | 525 | currentPalette = 2; |
527 | 526 | ||
528 | } else { | 527 | } else { |
529 | if ( currentPalette == 3 ) return; | 528 | if ( currentPalette == 3 ) return; |
530 | setPalette( mNonPrimaryPalette ); | 529 | setPalette( mNonPrimaryPalette ); |
531 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 530 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
532 | //mLabel->setPalette( mNonPrimaryPalette );; | 531 | //mLabel->setPalette( mNonPrimaryPalette );; |
533 | currentPalette = 3; | 532 | currentPalette = 3; |
534 | } | 533 | } |
535 | } | 534 | } |
536 | //QPalette pal = palette(); | 535 | //QPalette pal = palette(); |
537 | 536 | ||
538 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 537 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
539 | } | 538 | } |
540 | QPalette MonthViewCell::getPalette () | 539 | QPalette MonthViewCell::getPalette () |
541 | { | 540 | { |
542 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 541 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
543 | return mStandardPalette; | 542 | return mStandardPalette; |
544 | if ( mHoliday) { | 543 | if ( mHoliday) { |
545 | return mHolidayPalette ; | 544 | return mHolidayPalette ; |
546 | } else { | 545 | } else { |
547 | if ( mPrimary ) { | 546 | if ( mPrimary ) { |
548 | return mPrimaryPalette ; | 547 | return mPrimaryPalette ; |
549 | } | 548 | } |
550 | } | 549 | } |
551 | return mNonPrimaryPalette; | 550 | return mNonPrimaryPalette; |
552 | } | 551 | } |
553 | bool MonthViewCell::isPrimary() const | 552 | bool MonthViewCell::isPrimary() const |
554 | { | 553 | { |
555 | return mPrimary; | 554 | return mPrimary; |
556 | } | 555 | } |
557 | 556 | ||
558 | void MonthViewCell::setHoliday( bool holiday ) | 557 | void MonthViewCell::setHoliday( bool holiday ) |
559 | { | 558 | { |
560 | mHoliday = holiday; | 559 | mHoliday = holiday; |
561 | //setMyPalette(); | 560 | //setMyPalette(); |
562 | } | 561 | } |
563 | 562 | ||
564 | void MonthViewCell::setHoliday( const QString &holiday ) | 563 | void MonthViewCell::setHoliday( const QString &holiday ) |
565 | { | 564 | { |
566 | mHolidayString = holiday; | 565 | mHolidayString = holiday; |
567 | 566 | ||
568 | if ( !holiday.isEmpty() ) { | 567 | if ( !holiday.isEmpty() ) { |
569 | setHoliday( true ); | 568 | setHoliday( true ); |
570 | } | 569 | } |
571 | } | 570 | } |
572 | 571 | ||
573 | void MonthViewCell::startUpdateCell() | 572 | void MonthViewCell::startUpdateCell() |
574 | { | 573 | { |
575 | mdayCount = 0; | 574 | mdayCount = 0; |
576 | setFocusPolicy(NoFocus); | 575 | setFocusPolicy(NoFocus); |
577 | if ( !mMonthView->isUpdatePossible() ) | 576 | if ( !mMonthView->isUpdatePossible() ) |
578 | return; | 577 | return; |
579 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 578 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
580 | while ( mitem ) { | 579 | while ( mitem ) { |
581 | mitem->setBlockRepaint( true ); | 580 | mitem->setBlockRepaint( true ); |
582 | mitem = (MonthViewItem *)mitem->next(); | 581 | mitem = (MonthViewItem *)mitem->next(); |
583 | } | 582 | } |
584 | if ( mAvailItemList.count() > 20 ) { | 583 | if ( mAvailItemList.count() > 20 ) { |
585 | mAvailItemList.setAutoDelete( true ); | 584 | mAvailItemList.setAutoDelete( true ); |
586 | mAvailItemList.clear(); | 585 | mAvailItemList.clear(); |
587 | mAvailItemList.setAutoDelete( false ); | 586 | mAvailItemList.setAutoDelete( false ); |
588 | } | 587 | } |
589 | /* | 588 | /* |
590 | if ( !isVisible() ){ | 589 | if ( !isVisible() ){ |
591 | return; | 590 | return; |
592 | } | 591 | } |
593 | */ | 592 | */ |
594 | // qDebug("MonthViewCell::updateCell() "); | 593 | // qDebug("MonthViewCell::updateCell() "); |
595 | setPrimary( mDate.month()%2 ); | 594 | setPrimary( mDate.month()%2 ); |
596 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 595 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
597 | if ( mDate == QDate::currentDate() ) { | 596 | if ( mDate == QDate::currentDate() ) { |
598 | setLineWidth( 3 ); | 597 | setLineWidth( 3 ); |
599 | } else { | 598 | } else { |
600 | setLineWidth( 1 ); | 599 | setLineWidth( 1 ); |
601 | } | 600 | } |
602 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 601 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
603 | //clear(); | 602 | //clear(); |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 9a36939..a312ba5 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -59,384 +59,385 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | |||
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | mAttachments = i.mAttachments; | 62 | mAttachments = i.mAttachments; |
63 | mResources = i.mResources; | 63 | mResources = i.mResources; |
64 | mSecrecy = i.mSecrecy; | 64 | mSecrecy = i.mSecrecy; |
65 | mPriority = i.mPriority; | 65 | mPriority = i.mPriority; |
66 | mLocation = i.mLocation; | 66 | mLocation = i.mLocation; |
67 | mCancelled = i.mCancelled; | 67 | mCancelled = i.mCancelled; |
68 | mHasStartDate = i.mHasStartDate; | 68 | mHasStartDate = i.mHasStartDate; |
69 | QPtrListIterator<Alarm> it( i.mAlarms ); | 69 | QPtrListIterator<Alarm> it( i.mAlarms ); |
70 | const Alarm *a; | 70 | const Alarm *a; |
71 | while( (a = it.current()) ) { | 71 | while( (a = it.current()) ) { |
72 | Alarm *b = new Alarm( *a ); | 72 | Alarm *b = new Alarm( *a ); |
73 | b->setParent( this ); | 73 | b->setParent( this ); |
74 | mAlarms.append( b ); | 74 | mAlarms.append( b ); |
75 | 75 | ||
76 | ++it; | 76 | ++it; |
77 | } | 77 | } |
78 | mAlarms.setAutoDelete(true); | 78 | mAlarms.setAutoDelete(true); |
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 79 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 80 | mRecurrenceID = i.mRecurrenceID; |
81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
82 | mHoliday = i.mHoliday ; | 82 | mHoliday = i.mHoliday ; |
83 | mBirthday = i.mBirthday; | 83 | mBirthday = i.mBirthday; |
84 | mAnniversary = i.mAnniversary; | 84 | mAnniversary = i.mAnniversary; |
85 | } | 85 | } |
86 | 86 | ||
87 | Incidence::~Incidence() | 87 | Incidence::~Incidence() |
88 | { | 88 | { |
89 | 89 | ||
90 | Incidence *ev; | 90 | Incidence *ev; |
91 | QPtrList<Incidence> Relations = relations(); | 91 | QPtrList<Incidence> Relations = relations(); |
92 | for (ev=Relations.first();ev;ev=Relations.next()) { | 92 | for (ev=Relations.first();ev;ev=Relations.next()) { |
93 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 93 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
94 | } | 94 | } |
95 | if (relatedTo()) relatedTo()->removeRelation(this); | 95 | if (relatedTo()) relatedTo()->removeRelation(this); |
96 | delete mRecurrence; | 96 | delete mRecurrence; |
97 | 97 | ||
98 | } | 98 | } |
99 | 99 | ||
100 | bool Incidence::isHoliday() const | 100 | bool Incidence::isHoliday() const |
101 | { | 101 | { |
102 | return mHoliday; | 102 | return mHoliday; |
103 | } | 103 | } |
104 | bool Incidence::isBirthday() const | 104 | bool Incidence::isBirthday() const |
105 | { | 105 | { |
106 | 106 | ||
107 | return mBirthday ; | 107 | return mBirthday ; |
108 | } | 108 | } |
109 | bool Incidence::isAnniversary() const | 109 | bool Incidence::isAnniversary() const |
110 | { | 110 | { |
111 | return mAnniversary ; | 111 | return mAnniversary ; |
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | bool Incidence::hasRecurrenceID() const | 115 | bool Incidence::hasRecurrenceID() const |
116 | { | 116 | { |
117 | return mHasRecurrenceID; | 117 | return mHasRecurrenceID; |
118 | } | 118 | } |
119 | 119 | ||
120 | void Incidence::setHasRecurrenceID( bool b ) | 120 | void Incidence::setHasRecurrenceID( bool b ) |
121 | { | 121 | { |
122 | mHasRecurrenceID = b; | 122 | mHasRecurrenceID = b; |
123 | } | 123 | } |
124 | 124 | ||
125 | void Incidence::setRecurrenceID(QDateTime d) | 125 | void Incidence::setRecurrenceID(QDateTime d) |
126 | { | 126 | { |
127 | mRecurrenceID = d; | 127 | mRecurrenceID = d; |
128 | mHasRecurrenceID = true; | 128 | mHasRecurrenceID = true; |
129 | updated(); | 129 | updated(); |
130 | } | 130 | } |
131 | QDateTime Incidence::recurrenceID () const | 131 | QDateTime Incidence::recurrenceID () const |
132 | { | 132 | { |
133 | return mRecurrenceID; | 133 | return mRecurrenceID; |
134 | } | 134 | } |
135 | 135 | ||
136 | bool Incidence::cancelled() const | 136 | bool Incidence::cancelled() const |
137 | { | 137 | { |
138 | return mCancelled; | 138 | return mCancelled; |
139 | } | 139 | } |
140 | void Incidence::setCancelled( bool b ) | 140 | void Incidence::setCancelled( bool b ) |
141 | { | 141 | { |
142 | mCancelled = b; | 142 | mCancelled = b; |
143 | updated(); | 143 | updated(); |
144 | } | 144 | } |
145 | bool Incidence::hasStartDate() const | 145 | bool Incidence::hasStartDate() const |
146 | { | 146 | { |
147 | return mHasStartDate; | 147 | return mHasStartDate; |
148 | } | 148 | } |
149 | 149 | ||
150 | void Incidence::setHasStartDate(bool f) | 150 | void Incidence::setHasStartDate(bool f) |
151 | { | 151 | { |
152 | if (mReadOnly) return; | 152 | if (mReadOnly) return; |
153 | mHasStartDate = f; | 153 | mHasStartDate = f; |
154 | updated(); | 154 | updated(); |
155 | } | 155 | } |
156 | 156 | ||
157 | // A string comparison that considers that null and empty are the same | 157 | // A string comparison that considers that null and empty are the same |
158 | static bool stringCompare( const QString& s1, const QString& s2 ) | 158 | static bool stringCompare( const QString& s1, const QString& s2 ) |
159 | { | 159 | { |
160 | if ( s1.isEmpty() && s2.isEmpty() ) | 160 | if ( s1.isEmpty() && s2.isEmpty() ) |
161 | return true; | 161 | return true; |
162 | return s1 == s2; | 162 | return s1 == s2; |
163 | } | 163 | } |
164 | 164 | ||
165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
166 | { | 166 | { |
167 | 167 | ||
168 | if( i1.alarms().count() != i2.alarms().count() ) { | 168 | if( i1.alarms().count() != i2.alarms().count() ) { |
169 | return false; // no need to check further | 169 | return false; // no need to check further |
170 | } | 170 | } |
171 | if ( i1.alarms().count() > 0 ) { | 171 | if ( i1.alarms().count() > 0 ) { |
172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
173 | { | 173 | { |
174 | qDebug("alarm not equal "); | 174 | qDebug("alarm not equal "); |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | #if 0 | 178 | #if 0 |
179 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 179 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
180 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 180 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
182 | if( *a1.current() == *a2.current() ) { | 182 | if( *a1.current() == *a2.current() ) { |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | else { | 185 | else { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
192 | if ( i1.hasRecurrenceID() ) { | 192 | if ( i1.hasRecurrenceID() ) { |
193 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 193 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | 200 | ||
201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
202 | return false; | 202 | return false; |
203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
204 | if ( i1.hasStartDate() ) { | 204 | if ( i1.hasStartDate() ) { |
205 | if ( i1.dtStart() != i2.dtStart() ) | 205 | if ( i1.dtStart() != i2.dtStart() ) |
206 | return false; | 206 | return false; |
207 | } | 207 | } |
208 | } else { | 208 | } else { |
209 | return false; | 209 | return false; |
210 | } | 210 | } |
211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
212 | qDebug("recurrence is NOT equal "); | 212 | qDebug("recurrence is NOT equal "); |
213 | return false; | 213 | return false; |
214 | } | 214 | } |
215 | return | 215 | return |
216 | // i1.created() == i2.created() && | 216 | // i1.created() == i2.created() && |
217 | stringCompare( i1.description(), i2.description() ) && | 217 | stringCompare( i1.description(), i2.description() ) && |
218 | stringCompare( i1.summary(), i2.summary() ) && | 218 | stringCompare( i1.summary(), i2.summary() ) && |
219 | i1.categories() == i2.categories() && | 219 | i1.categories() == i2.categories() && |
220 | // no need to compare mRelatedTo | 220 | // no need to compare mRelatedTo |
221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
222 | // i1.relations() == i2.relations() && | 222 | // i1.relations() == i2.relations() && |
223 | i1.exDates() == i2.exDates() && | 223 | i1.exDates() == i2.exDates() && |
224 | i1.attachments() == i2.attachments() && | 224 | i1.attachments() == i2.attachments() && |
225 | i1.resources() == i2.resources() && | 225 | i1.resources() == i2.resources() && |
226 | i1.secrecy() == i2.secrecy() && | 226 | i1.secrecy() == i2.secrecy() && |
227 | i1.priority() == i2.priority() && | 227 | i1.priority() == i2.priority() && |
228 | i1.cancelled() == i2.cancelled() && | 228 | i1.cancelled() == i2.cancelled() && |
229 | stringCompare( i1.location(), i2.location() ); | 229 | stringCompare( i1.location(), i2.location() ); |
230 | } | 230 | } |
231 | 231 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* Incidence::recreateCloneException( QDate d ) |
233 | { | 233 | { |
234 | Incidence* newInc = clone(); | 234 | Incidence* newInc = clone(); |
235 | newInc->recreate(); | 235 | newInc->recreate(); |
236 | if ( doesRecur() ) { | 236 | if ( doesRecur() ) { |
237 | addExDate( d ); | 237 | addExDate( d ); |
238 | newInc->recurrence()->unsetRecurs(); | 238 | newInc->recurrence()->unsetRecurs(); |
239 | if ( type() == "Event") { | 239 | if ( type() == "Event") { |
240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
241 | QTime tim = dtStart().time(); | 241 | QTime tim = dtStart().time(); |
242 | newInc->setDtStart( QDateTime(d, tim) ); | 242 | newInc->setDtStart( QDateTime(d, tim) ); |
243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
244 | } else { | 244 | } else { |
245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
246 | QTime tim = ((Todo*)this)->dtDue().time(); | 246 | QTime tim = ((Todo*)this)->dtDue().time(); |
247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
249 | ((Todo*)this)->setRecurDates(); | 249 | ((Todo*)this)->setRecurDates(); |
250 | } | 250 | } |
251 | newInc->setExDates( DateList () ); | ||
251 | } | 252 | } |
252 | return newInc; | 253 | return newInc; |
253 | } | 254 | } |
254 | 255 | ||
255 | void Incidence::recreate() | 256 | void Incidence::recreate() |
256 | { | 257 | { |
257 | setCreated(QDateTime::currentDateTime()); | 258 | setCreated(QDateTime::currentDateTime()); |
258 | 259 | ||
259 | setUid(CalFormat::createUniqueId()); | 260 | setUid(CalFormat::createUniqueId()); |
260 | 261 | ||
261 | setRevision(0); | 262 | setRevision(0); |
262 | setIDStr( ":" ); | 263 | setIDStr( ":" ); |
263 | setLastModified(QDateTime::currentDateTime()); | 264 | setLastModified(QDateTime::currentDateTime()); |
264 | } | 265 | } |
265 | 266 | ||
266 | void Incidence::setReadOnly( bool readOnly ) | 267 | void Incidence::setReadOnly( bool readOnly ) |
267 | { | 268 | { |
268 | IncidenceBase::setReadOnly( readOnly ); | 269 | IncidenceBase::setReadOnly( readOnly ); |
269 | recurrence()->setRecurReadOnly( readOnly); | 270 | recurrence()->setRecurReadOnly( readOnly); |
270 | } | 271 | } |
271 | 272 | ||
272 | void Incidence::setCreated(QDateTime created) | 273 | void Incidence::setCreated(QDateTime created) |
273 | { | 274 | { |
274 | if (mReadOnly) return; | 275 | if (mReadOnly) return; |
275 | mCreated = getEvenTime(created); | 276 | mCreated = getEvenTime(created); |
276 | } | 277 | } |
277 | 278 | ||
278 | QDateTime Incidence::created() const | 279 | QDateTime Incidence::created() const |
279 | { | 280 | { |
280 | return mCreated; | 281 | return mCreated; |
281 | } | 282 | } |
282 | 283 | ||
283 | void Incidence::setRevision(int rev) | 284 | void Incidence::setRevision(int rev) |
284 | { | 285 | { |
285 | if (mReadOnly) return; | 286 | if (mReadOnly) return; |
286 | mRevision = rev; | 287 | mRevision = rev; |
287 | 288 | ||
288 | updated(); | 289 | updated(); |
289 | } | 290 | } |
290 | 291 | ||
291 | int Incidence::revision() const | 292 | int Incidence::revision() const |
292 | { | 293 | { |
293 | return mRevision; | 294 | return mRevision; |
294 | } | 295 | } |
295 | 296 | ||
296 | void Incidence::setDtStart(const QDateTime &dtStart) | 297 | void Incidence::setDtStart(const QDateTime &dtStart) |
297 | { | 298 | { |
298 | 299 | ||
299 | QDateTime dt = getEvenTime(dtStart); | 300 | QDateTime dt = getEvenTime(dtStart); |
300 | recurrence()->setRecurStart( dt); | 301 | recurrence()->setRecurStart( dt); |
301 | IncidenceBase::setDtStart( dt ); | 302 | IncidenceBase::setDtStart( dt ); |
302 | } | 303 | } |
303 | 304 | ||
304 | void Incidence::setDescription(const QString &description) | 305 | void Incidence::setDescription(const QString &description) |
305 | { | 306 | { |
306 | if (mReadOnly) return; | 307 | if (mReadOnly) return; |
307 | mDescription = description; | 308 | mDescription = description; |
308 | updated(); | 309 | updated(); |
309 | } | 310 | } |
310 | 311 | ||
311 | QString Incidence::description() const | 312 | QString Incidence::description() const |
312 | { | 313 | { |
313 | return mDescription; | 314 | return mDescription; |
314 | } | 315 | } |
315 | 316 | ||
316 | 317 | ||
317 | void Incidence::setSummary(const QString &summary) | 318 | void Incidence::setSummary(const QString &summary) |
318 | { | 319 | { |
319 | if (mReadOnly) return; | 320 | if (mReadOnly) return; |
320 | mSummary = summary; | 321 | mSummary = summary; |
321 | updated(); | 322 | updated(); |
322 | } | 323 | } |
323 | 324 | ||
324 | QString Incidence::summary() const | 325 | QString Incidence::summary() const |
325 | { | 326 | { |
326 | return mSummary; | 327 | return mSummary; |
327 | } | 328 | } |
328 | void Incidence::checkCategories() | 329 | void Incidence::checkCategories() |
329 | { | 330 | { |
330 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 331 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
331 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 332 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
332 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 333 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
333 | } | 334 | } |
334 | 335 | ||
335 | void Incidence::setCategories(const QStringList &categories) | 336 | void Incidence::setCategories(const QStringList &categories) |
336 | { | 337 | { |
337 | if (mReadOnly) return; | 338 | if (mReadOnly) return; |
338 | mCategories = categories; | 339 | mCategories = categories; |
339 | checkCategories(); | 340 | checkCategories(); |
340 | updated(); | 341 | updated(); |
341 | } | 342 | } |
342 | 343 | ||
343 | // TODO: remove setCategories(QString) function | 344 | // TODO: remove setCategories(QString) function |
344 | void Incidence::setCategories(const QString &catStr) | 345 | void Incidence::setCategories(const QString &catStr) |
345 | { | 346 | { |
346 | if (mReadOnly) return; | 347 | if (mReadOnly) return; |
347 | mCategories.clear(); | 348 | mCategories.clear(); |
348 | 349 | ||
349 | if (catStr.isEmpty()) return; | 350 | if (catStr.isEmpty()) return; |
350 | 351 | ||
351 | mCategories = QStringList::split(",",catStr); | 352 | mCategories = QStringList::split(",",catStr); |
352 | 353 | ||
353 | QStringList::Iterator it; | 354 | QStringList::Iterator it; |
354 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 355 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
355 | *it = (*it).stripWhiteSpace(); | 356 | *it = (*it).stripWhiteSpace(); |
356 | } | 357 | } |
357 | checkCategories(); | 358 | checkCategories(); |
358 | updated(); | 359 | updated(); |
359 | } | 360 | } |
360 | 361 | ||
361 | QStringList Incidence::categories() const | 362 | QStringList Incidence::categories() const |
362 | { | 363 | { |
363 | return mCategories; | 364 | return mCategories; |
364 | } | 365 | } |
365 | 366 | ||
366 | QString Incidence::categoriesStr() | 367 | QString Incidence::categoriesStr() |
367 | { | 368 | { |
368 | return mCategories.join(","); | 369 | return mCategories.join(","); |
369 | } | 370 | } |
370 | 371 | ||
371 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 372 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
372 | { | 373 | { |
373 | if (mReadOnly) return; | 374 | if (mReadOnly) return; |
374 | mRelatedToUid = relatedToUid; | 375 | mRelatedToUid = relatedToUid; |
375 | } | 376 | } |
376 | 377 | ||
377 | QString Incidence::relatedToUid() const | 378 | QString Incidence::relatedToUid() const |
378 | { | 379 | { |
379 | return mRelatedToUid; | 380 | return mRelatedToUid; |
380 | } | 381 | } |
381 | 382 | ||
382 | void Incidence::setRelatedTo(Incidence *relatedTo) | 383 | void Incidence::setRelatedTo(Incidence *relatedTo) |
383 | { | 384 | { |
384 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 385 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
385 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 386 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
386 | if (mReadOnly || mRelatedTo == relatedTo) return; | 387 | if (mReadOnly || mRelatedTo == relatedTo) return; |
387 | if(mRelatedTo) { | 388 | if(mRelatedTo) { |
388 | // updated(); | 389 | // updated(); |
389 | mRelatedTo->removeRelation(this); | 390 | mRelatedTo->removeRelation(this); |
390 | } | 391 | } |
391 | mRelatedTo = relatedTo; | 392 | mRelatedTo = relatedTo; |
392 | if (mRelatedTo) mRelatedTo->addRelation(this); | 393 | if (mRelatedTo) mRelatedTo->addRelation(this); |
393 | } | 394 | } |
394 | 395 | ||
395 | Incidence *Incidence::relatedTo() const | 396 | Incidence *Incidence::relatedTo() const |
396 | { | 397 | { |
397 | return mRelatedTo; | 398 | return mRelatedTo; |
398 | } | 399 | } |
399 | 400 | ||
400 | QPtrList<Incidence> Incidence::relations() const | 401 | QPtrList<Incidence> Incidence::relations() const |
401 | { | 402 | { |
402 | return mRelations; | 403 | return mRelations; |
403 | } | 404 | } |
404 | 405 | ||
405 | void Incidence::addRelation(Incidence *event) | 406 | void Incidence::addRelation(Incidence *event) |
406 | { | 407 | { |
407 | if( mRelations.findRef( event ) == -1 ) { | 408 | if( mRelations.findRef( event ) == -1 ) { |
408 | mRelations.append(event); | 409 | mRelations.append(event); |
409 | //updated(); | 410 | //updated(); |
410 | } | 411 | } |
411 | } | 412 | } |
412 | 413 | ||
413 | void Incidence::removeRelation(Incidence *event) | 414 | void Incidence::removeRelation(Incidence *event) |
414 | { | 415 | { |
415 | 416 | ||
416 | mRelations.removeRef(event); | 417 | mRelations.removeRef(event); |
417 | 418 | ||
418 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 419 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
419 | } | 420 | } |
420 | 421 | ||
421 | bool Incidence::recursOn(const QDate &qd) const | 422 | bool Incidence::recursOn(const QDate &qd) const |
422 | { | 423 | { |
423 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 424 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
424 | else return false; | 425 | else return false; |
425 | } | 426 | } |
426 | 427 | ||
427 | void Incidence::setExDates(const DateList &exDates) | 428 | void Incidence::setExDates(const DateList &exDates) |
428 | { | 429 | { |
429 | if (mReadOnly) return; | 430 | if (mReadOnly) return; |
430 | mExDates = exDates; | 431 | mExDates = exDates; |
431 | 432 | ||
432 | recurrence()->setRecurExDatesCount(mExDates.count()); | 433 | recurrence()->setRecurExDatesCount(mExDates.count()); |
433 | 434 | ||
434 | updated(); | 435 | updated(); |
435 | } | 436 | } |
436 | 437 | ||
437 | void Incidence::addExDate(const QDate &date) | 438 | void Incidence::addExDate(const QDate &date) |
438 | { | 439 | { |
439 | if (mReadOnly) return; | 440 | if (mReadOnly) return; |
440 | mExDates.append(date); | 441 | mExDates.append(date); |
441 | 442 | ||
442 | recurrence()->setRecurExDatesCount(mExDates.count()); | 443 | recurrence()->setRecurExDatesCount(mExDates.count()); |