summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp78
1 files changed, 45 insertions, 33 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 6e65a03..87993ae 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -8,47 +8,59 @@
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <q3hbox.h>
25#include <qvbox.h> 25#include <q3vbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <q3frame.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <q3popupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39#include <QDesktopWidget>
40//Added by qt3to4:
41#include <QResizeEvent>
42#include <QPixmap>
43#include <QMouseEvent>
44#include <Q3GridLayout>
45#include <Q3ValueList>
46#include <QKeyEvent>
47#include <Q3HBoxLayout>
48#include <Q3VBoxLayout>
49#include <QPaintEvent>
50#include <Q3PtrList>
39 51
40#include <kapplication.h> 52#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 53#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 54#include <kdebug.h>
43#include <kstandarddirs.h> 55#include <kstandarddirs.h>
44#include <kiconloader.h> 56#include <kiconloader.h>
45#include <klocale.h> 57#include <klocale.h>
46#include <kconfig.h> 58#include <kconfig.h>
47#include <kglobal.h> 59#include <kglobal.h>
48#include "calendarview.h" 60#include "calendarview.h"
49#include "koviewmanager.h" 61#include "koviewmanager.h"
50 62
51#include <libkcal/calendar.h> 63#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 64#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 65#include <libkcal/dndfactory.h>
54 66
@@ -65,50 +77,50 @@
65#include "calprinter.h" 77#include "calprinter.h"
66#endif 78#endif
67 79
68#include "koagendaview.h" 80#include "koagendaview.h"
69//#include "koagendaview.moc" 81//#include "koagendaview.moc"
70 82
71//extern bool globalFlagBlockPainting; 83//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 84extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 85extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 86extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 87extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 88extern int globalFlagBlockLabel;
77using namespace KOrg; 89using namespace KOrg;
78 90
79#define IDLETIMEOUT 45 91#define IDLETIMEOUT 45
80 92
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 93TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,Qt::WFlags f) :
82 QScrollView(parent,name,f) 94 Q3ScrollView(parent,name,f)
83{ 95{
84 myPix.resize( 1, 1 ); 96 myPix.resize( 1, 1 );
85 mRows = rows; 97 mRows = rows;
86 98
87 mRedrawNeeded = true; 99 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 100 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 101 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 102
91 enableClipper(true); 103 enableClipper(true);
92 104
93 setHScrollBarMode(AlwaysOff); 105 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 106 setVScrollBarMode(AlwaysOff);
95 107
96 resizeContents(50,mRows * mCellHeight); 108 resizeContents(50,mRows * mCellHeight);
97 109
98 viewport()->setBackgroundMode( PaletteBackground ); 110 viewport()->setBackgroundMode( Qt::PaletteBackground );
99} 111}
100 112
101void TimeLabels::setCellHeight(int height) 113void TimeLabels::setCellHeight(int height)
102{ 114{
103 mCellHeight = height; 115 mCellHeight = height;
104} 116}
105 117
106/* 118/*
107 Optimization so that only the "dirty" portion of the scroll view 119 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 120 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 121*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 122void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 123{
112 124
113 cx = contentsX() + frameWidth()*2; 125 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 126 cw = contentsWidth() ;
@@ -270,33 +282,33 @@ void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
270} 282}
271 283
272/** This is called in response to repaint() */ 284/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 285void TimeLabels::paintEvent(QPaintEvent*)
274{ 286{
275 287
276 // kdDebug() << "paintevent..." << endl; 288 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 289 // this is another hack!
278 // QPainter painter(this); 290 // QPainter painter(this);
279 //QString c 291 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 292 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 293}
282 294
283//////////////////////////////////////////////////////////////////////////// 295////////////////////////////////////////////////////////////////////////////
284 296
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 297EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 298 : Q3Frame(parent,name)
287{ 299{
288 mColumns = 1; 300 mColumns = 1;
289 mTopBox = 0; 301 mTopBox = 0;
290 mLocation = loc; 302 mLocation = loc;
291 mTopLayout = 0; 303 mTopLayout = 0;
292 mPaintWidget = 0; 304 mPaintWidget = 0;
293 mXOffset = 0; 305 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 306 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 307 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 308 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 309 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 310 setMinimumHeight(mPixmap.height());
299} 311}
300 312
301EventIndicator::~EventIndicator() 313EventIndicator::~EventIndicator()
302{ 314{
@@ -380,105 +392,105 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
380 flag_blockfillAgenda = false; 392 flag_blockfillAgenda = false;
381 mBlockUpdating = true; 393 mBlockUpdating = true;
382 mStartHour = 8; 394 mStartHour = 8;
383 mSelectedDates.append(QDate::currentDate()); 395 mSelectedDates.append(QDate::currentDate());
384 396
385 mLayoutDayLabels = 0; 397 mLayoutDayLabels = 0;
386 mDayLabelsFrame = 0; 398 mDayLabelsFrame = 0;
387 mDayLabels = 0; 399 mDayLabels = 0;
388 bool isRTL = KOGlobals::self()->reverseLayout(); 400 bool isRTL = KOGlobals::self()->reverseLayout();
389 QPixmap expandPix; 401 QPixmap expandPix;
390 if ( KOPrefs::instance()->mVerticalScreen ) { 402 if ( KOPrefs::instance()->mVerticalScreen ) {
391 expandPix = SmallIcon( "1updownarrow" ); 403 expandPix = SmallIcon( "1updownarrow" );
392 } else { 404 } else {
393 expandPix = SmallIcon("1leftrightarrow" ); 405 expandPix = SmallIcon("1leftrightarrow" );
394 } 406 }
395 407
396 QBoxLayout *topLayout = new QVBoxLayout(this); 408 Q3BoxLayout *topLayout = new Q3VBoxLayout(this);
397 409
398 // Create day name labels for agenda columns 410 // Create day name labels for agenda columns
399 // Create agenda splitter 411 // Create agenda splitter
400 412
401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 413 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 414 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
403 topLayout->addWidget( mSplitterAgenda ); 415 topLayout->addWidget( mSplitterAgenda );
404 mAllDayFrame = new QHBox(mSplitterAgenda); 416 mAllDayFrame = new Q3HBox(mSplitterAgenda);
405 mAllDayFrame->setFocusPolicy(NoFocus); 417 mAllDayFrame->setFocusPolicy(Qt::NoFocus);
406 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 418 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
407 agendaFrame->setFocusPolicy(NoFocus); 419 agendaFrame->setFocusPolicy(Qt::NoFocus);
408 420
409 // Create all-day agenda widget 421 // Create all-day agenda widget
410 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 422 mDummyAllDayLeft = new Q3VBox( mAllDayFrame );
411 423
412 mExpandButton = new QPushButton(mDummyAllDayLeft); 424 mExpandButton = new QPushButton(mDummyAllDayLeft);
413 mExpandButton->setPixmap( expandPix ); 425 mExpandButton->setPixmap( expandPix );
414 int widebut = mExpandButton->sizeHint().width()+4; 426 int widebut = mExpandButton->sizeHint().width()+4;
415 int heibut = mExpandButton->sizeHint().height()+4; 427 int heibut = mExpandButton->sizeHint().height()+4;
416 if ( heibut > widebut ) 428 if ( heibut > widebut )
417 widebut = heibut ; 429 widebut = heibut ;
418 430
419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 431 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
420 // QSizePolicy::Fixed ) ); 432 // QSizePolicy::Fixed ) );
421 mExpandButton->setFixedSize( widebut, widebut); 433 mExpandButton->setFixedSize( widebut, widebut);
422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 434 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
423 mExpandButton->setFocusPolicy(NoFocus); 435 mExpandButton->setFocusPolicy(Qt::NoFocus);
424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 436 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
425 mAllDayAgenda->setFocusPolicy(NoFocus); 437 mAllDayAgenda->setFocusPolicy(Qt::NoFocus);
426 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 438 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
427 439
428 // Create event context menu for all day agenda 440 // Create event context menu for all day agenda
429 //mAllDayAgendaPopup = eventPopup(); 441 //mAllDayAgendaPopup = eventPopup();
430 442
431 // Create agenda frame 443 // Create agenda frame
432 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 444 Q3GridLayout *agendaLayout = new Q3GridLayout(agendaFrame,4,3);
433 // QHBox *agendaFrame = new QHBox(splitterAgenda); 445 // QHBox *agendaFrame = new QHBox(splitterAgenda);
434 446
435 // create event indicator bars 447 // create event indicator bars
436 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 448 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
437#ifndef DESKTOP_VERSION 449#ifndef DESKTOP_VERSION
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 450 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439#endif 451#endif
440 mDayLabelsFrame = new QHBox(agendaFrame); 452 mDayLabelsFrame = new Q3HBox(agendaFrame);
441 //topLayout->addWidget(mDayLabelsFrame); 453 //topLayout->addWidget(mDayLabelsFrame);
442 mDayLabels = new QFrame (mDayLabelsFrame); 454 mDayLabels = new Q3Frame (mDayLabelsFrame);
443 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 455 mLayoutDayLabels = new Q3HBoxLayout(mDayLabels);
444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 456 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
445 agendaLayout->addWidget(mEventIndicatorTop,1,1); 457 agendaLayout->addWidget(mEventIndicatorTop,1,1);
446 458
447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 459 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
448 agendaFrame); 460 agendaFrame);
449 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 461 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
450 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 462 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
451 agendaLayout->addWidget(dummyAgendaRight,1,2); 463 agendaLayout->addWidget(dummyAgendaRight,1,2);
452 464
453 // Create time labels 465 // Create time labels
454 mTimeLabels = new TimeLabels(24,agendaFrame); 466 mTimeLabels = new TimeLabels(24,agendaFrame);
455 agendaLayout->addWidget(mTimeLabels,2,0); 467 agendaLayout->addWidget(mTimeLabels,2,0);
456 connect(mTimeLabels,SIGNAL( scaleChanged()), 468 connect(mTimeLabels,SIGNAL( scaleChanged()),
457 this,SLOT(updateConfig())); 469 this,SLOT(updateConfig()));
458 470
459 // Create agenda 471 // Create agenda
460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 472 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 473 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
462 agendaLayout->setColStretch(1,1); 474 agendaLayout->setColStretch(1,1);
463 mAgenda->setFocusPolicy(NoFocus); 475 mAgenda->setFocusPolicy(Qt::NoFocus);
464 // Create event context menu for agenda 476 // Create event context menu for agenda
465 mAllAgendaPopup = eventPopup(); 477 mAllAgendaPopup = eventPopup();
466 478
467#if 0 479#if 0
468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 480 mAllAgendaPopup->addAdditionalItem(QIcon(SmallIcon("bell")),
469 i18n("Toggle Alarm"),mAgenda, 481 i18n("Toggle Alarm"),mAgenda,
470 SLOT(popupAlarm()),true); 482 SLOT(popupAlarm()),true);
471 483
472#endif 484#endif
473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 485 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 486 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
475 487
476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 488 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 489 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
478 490
479 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 491 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
480 this,SLOT(categoryChanged(Incidence *))); 492 this,SLOT(categoryChanged(Incidence *)));
481 493
482 494
483 mAgenda->setPopup( mAllAgendaPopup ); 495 mAgenda->setPopup( mAllAgendaPopup );
484 mAllDayAgenda->setPopup( mAllAgendaPopup ); 496 mAllDayAgenda->setPopup( mAllAgendaPopup );
@@ -905,35 +917,35 @@ void KOAgendaView::createDayLabels()
905 } 917 }
906 918
907 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 919 mDayLabelsFrame->setFixedHeight( newHight + 4 );
908} 920}
909 921
910int KOAgendaView::maxDatesHint() 922int KOAgendaView::maxDatesHint()
911{ 923{
912 // Not sure about the max number of events, so return 0 for now. 924 // Not sure about the max number of events, so return 0 for now.
913 return 0; 925 return 0;
914} 926}
915 927
916int KOAgendaView::currentDateCount() 928int KOAgendaView::currentDateCount()
917{ 929{
918 return mSelectedDates.count(); 930 return mSelectedDates.count();
919} 931}
920 932
921QPtrList<Incidence> KOAgendaView::selectedIncidences() 933Q3PtrList<Incidence> KOAgendaView::selectedIncidences()
922{ 934{
923 QPtrList<Incidence> selected; 935 Q3PtrList<Incidence> selected;
924 Incidence *incidence; 936 Incidence *incidence;
925 937
926 incidence = mAgenda->selectedIncidence(); 938 incidence = mAgenda->selectedIncidence();
927 if (incidence) selected.append(incidence); 939 if (incidence) selected.append(incidence);
928 940
929 incidence = mAllDayAgenda->selectedIncidence(); 941 incidence = mAllDayAgenda->selectedIncidence();
930 if (incidence) selected.append(incidence); 942 if (incidence) selected.append(incidence);
931 943
932 return selected; 944 return selected;
933} 945}
934 946
935DateList KOAgendaView::selectedDates() 947DateList KOAgendaView::selectedDates()
936{ 948{
937 DateList selected; 949 DateList selected;
938 QDate qd; 950 QDate qd;
939 951
@@ -974,34 +986,34 @@ void KOAgendaView::updateConfig()
974 986
975 // update config for children 987 // update config for children
976 mTimeLabels->updateConfig(); 988 mTimeLabels->updateConfig();
977 mAgenda->storePosition(); 989 mAgenda->storePosition();
978 mAgenda->updateConfig(); 990 mAgenda->updateConfig();
979 mAllDayAgenda->updateConfig(); 991 mAllDayAgenda->updateConfig();
980 // widget synchronization 992 // widget synchronization
981 //TODO: find a better way, maybe signal/slot 993 //TODO: find a better way, maybe signal/slot
982 mTimeLabels->positionChanged(); 994 mTimeLabels->positionChanged();
983 995
984 // for some reason, this needs to be called explicitly 996 // for some reason, this needs to be called explicitly
985 mTimeLabels->repaint(); 997 mTimeLabels->repaint();
986 998
987 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 999 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
988 1000
989 // ToolTips displaying summary of events 1001 // ToolTips displaying summary of events
990 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 1002 /* TODO:hacker: KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
991 ->mEnableToolTips); 1003 ->mEnableToolTips); */
992 1004
993 //setHolidayMasks(); 1005 //setHolidayMasks();
994 1006
995 //createDayLabels(); called by via updateView(); 1007 //createDayLabels(); called by via updateView();
996 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 1008 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
997 updateView(); 1009 updateView();
998 mAgenda->restorePosition(); 1010 mAgenda->restorePosition();
999} 1011}
1000 1012
1001 1013
1002void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 1014void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
1003{ 1015{
1004 1016
1005 1017
1006 int xxx = item->cellX(); 1018 int xxx = item->cellX();
1007 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 1019 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
@@ -1104,33 +1116,33 @@ void KOAgendaView::showDates( const QDate &start, const QDate &end )
1104{ 1116{
1105 // kdDebug() << "KOAgendaView::selectDates" << endl; 1117 // kdDebug() << "KOAgendaView::selectDates" << endl;
1106 1118
1107 mSelectedDates.clear(); 1119 mSelectedDates.clear();
1108 // qDebug("KOAgendaView::showDates "); 1120 // qDebug("KOAgendaView::showDates ");
1109 QDate d = start; 1121 QDate d = start;
1110 while (d <= end) { 1122 while (d <= end) {
1111 mSelectedDates.append(d); 1123 mSelectedDates.append(d);
1112 d = d.addDays( 1 ); 1124 d = d.addDays( 1 );
1113 } 1125 }
1114 1126
1115 // and update the view 1127 // and update the view
1116 fillAgenda(); 1128 fillAgenda();
1117} 1129}
1118 1130
1119 1131
1120void KOAgendaView::showEvents(QPtrList<Event>) 1132void KOAgendaView::showEvents(Q3PtrList<Event>)
1121{ 1133{
1122 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1134 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1123} 1135}
1124 1136
1125void KOAgendaView::changeEventDisplay(Event *, int) 1137void KOAgendaView::changeEventDisplay(Event *, int)
1126{ 1138{
1127 // qDebug("KOAgendaView::changeEventDisplay "); 1139 // qDebug("KOAgendaView::changeEventDisplay ");
1128 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1140 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1129 // this should be re-written to be MUCH smarter. Right now we 1141 // this should be re-written to be MUCH smarter. Right now we
1130 // are just playing dumb. 1142 // are just playing dumb.
1131 fillAgenda(); 1143 fillAgenda();
1132} 1144}
1133 1145
1134void KOAgendaView::fillAgenda(const QDate &) 1146void KOAgendaView::fillAgenda(const QDate &)
1135{ 1147{
1136 // qDebug("KOAgendaView::fillAgenda "); 1148 // qDebug("KOAgendaView::fillAgenda ");
@@ -1152,37 +1164,37 @@ void KOAgendaView::fillAgenda()
1152 if ( globalFlagBlockAgenda == 0 ) 1164 if ( globalFlagBlockAgenda == 0 )
1153 globalFlagBlockAgenda = 1; 1165 globalFlagBlockAgenda = 1;
1154 // clearView(); 1166 // clearView();
1155 //qDebug("fillAgenda()++++ "); 1167 //qDebug("fillAgenda()++++ ");
1156 globalFlagBlockAgendaItemPaint = 1; 1168 globalFlagBlockAgendaItemPaint = 1;
1157 1169
1158 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1170 mAllDayAgenda->changeColumns(mSelectedDates.count());
1159 mAgenda->changeColumns(mSelectedDates.count()); 1171 mAgenda->changeColumns(mSelectedDates.count());
1160 qApp->processEvents(); 1172 qApp->processEvents();
1161 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1173 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1162 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1174 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1163 setHolidayMasks(); 1175 setHolidayMasks();
1164 1176
1165 mMinY.resize(mSelectedDates.count()); 1177 mMinY.resize(mSelectedDates.count());
1166 mMaxY.resize(mSelectedDates.count()); 1178 mMaxY.resize(mSelectedDates.count());
1167 1179
1168 QPtrList<Event> dayEvents; 1180 Q3PtrList<Event> dayEvents;
1169 1181
1170 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1182 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1171 // Therefore, gtodoset all of them. 1183 // Therefore, gtodoset all of them.
1172 QPtrList<Todo> todos = calendar()->todos(); 1184 Q3PtrList<Todo> todos = calendar()->todos();
1173 1185
1174 mAgenda->setDateList(mSelectedDates); 1186 mAgenda->setDateList(mSelectedDates);
1175 1187
1176 QDate today = QDate::currentDate(); 1188 QDate today = QDate::currentDate();
1177 1189
1178 DateList::ConstIterator dit; 1190 DateList::ConstIterator dit;
1179 int curCol = 0; 1191 int curCol = 0;
1180 int maxCol = mSelectedDates.count()-1; 1192 int maxCol = mSelectedDates.count()-1;
1181 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1193 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1182 QDate currentDate = *dit; 1194 QDate currentDate = *dit;
1183 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1195 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1184 // << endl; 1196 // << endl;
1185 1197
1186 dayEvents = calendar()->events(currentDate,false); 1198 dayEvents = calendar()->events(currentDate,false);
1187 1199
1188 // Default values, which can never be reached 1200 // Default values, which can never be reached
@@ -1287,33 +1299,33 @@ void KOAgendaView::fillAgenda()
1287 if (endY < startY) endY = startY; 1299 if (endY < startY) endY = startY;
1288 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1300 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1289 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1301 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1290 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1302 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1291 } 1303 }
1292 } 1304 }
1293 // ---------- [display Todos -------------- 1305 // ---------- [display Todos --------------
1294 unsigned int numTodo; 1306 unsigned int numTodo;
1295 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1307 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1296 Todo *todo = todos.at(numTodo); 1308 Todo *todo = todos.at(numTodo);
1297 1309
1298 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1310 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1299 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1311 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1300 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1312 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1301 // Already completed items can be displayed on their original due date 1313 // Already completed items can be displayed on their original due date
1302 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1314 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1303 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1315 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < (QDateTime)today) && KOPrefs::instance()->mShowTodoInAgenda;
1304 bool fillIn = false; 1316 bool fillIn = false;
1305 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1317 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1306 fillIn = true; 1318 fillIn = true;
1307 if ( ! fillIn && !todo->hasCompletedDate() ) 1319 if ( ! fillIn && !todo->hasCompletedDate() )
1308 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1320 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1309 if ( fillIn ) { 1321 if ( fillIn ) {
1310 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1322 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1311 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1323 if ( KOPrefs::instance()->mShowTodoInAgenda )
1312 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1324 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1313 } 1325 }
1314 else { 1326 else {
1315 QDateTime dt; 1327 QDateTime dt;
1316 if ( todo->hasCompletedDate() ) 1328 if ( todo->hasCompletedDate() )
1317 dt = todo->completed(); 1329 dt = todo->completed();
1318 else 1330 else
1319 dt = todo->dtDue();; 1331 dt = todo->dtDue();;
@@ -1490,71 +1502,71 @@ void KOAgendaView::startDrag(Event *event)
1490 } 1502 }
1491#endif 1503#endif
1492} 1504}
1493 1505
1494void KOAgendaView::readSettings() 1506void KOAgendaView::readSettings()
1495{ 1507{
1496 readSettings(KOGlobals::config()); 1508 readSettings(KOGlobals::config());
1497} 1509}
1498 1510
1499void KOAgendaView::readSettings(KConfig *config) 1511void KOAgendaView::readSettings(KConfig *config)
1500{ 1512{
1501 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1513 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1502 1514
1503 config->setGroup("Views"); 1515 config->setGroup("Views");
1504 1516
1505 //#ifndef KORG_NOSPLITTER 1517 //#ifndef KORG_NOSPLITTER
1506 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1518 Q3ValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1507 if (sizes.count() == 2) { 1519 if (sizes.count() == 2) {
1508 if ( sizes[0] < 20 ) { 1520 if ( sizes[0] < 20 ) {
1509 sizes[1] = sizes[1] +20 - sizes[0]; 1521 sizes[1] = sizes[1] +20 - sizes[0];
1510 sizes[0] = 20; 1522 sizes[0] = 20;
1511 } 1523 }
1512 mSplitterAgenda->setSizes(sizes); 1524 mSplitterAgenda->setSizes(sizes);
1513 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1525 // qDebug("read %d %d ",sizes[0],sizes[1] );
1514 } 1526 }
1515 //#endif 1527 //#endif
1516 1528
1517 // updateConfig(); 1529 // updateConfig();
1518} 1530}
1519 1531
1520void KOAgendaView::writeSettings(KConfig *config) 1532void KOAgendaView::writeSettings(KConfig *config)
1521{ 1533{
1522 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1534 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1523 1535
1524 config->setGroup("Views"); 1536 config->setGroup("Views");
1525 1537
1526 //#ifndef KORG_NOSPLITTER 1538 //#ifndef KORG_NOSPLITTER
1527 QValueList<int> list = mSplitterAgenda->sizes(); 1539 Q3ValueList<int> list = mSplitterAgenda->sizes();
1528 config->writeEntry("Separator AgendaView",list); 1540 config->writeEntry("Separator AgendaView",list);
1529 //qDebug("write %d %d ", list[0],list[1] ); 1541 //qDebug("write %d %d ", list[0],list[1] );
1530 //#endif 1542 //#endif
1531} 1543}
1532 1544
1533void KOAgendaView::setHolidayMasks() 1545void KOAgendaView::setHolidayMasks()
1534{ 1546{
1535 mHolidayMask.resize(mSelectedDates.count()); 1547 mHolidayMask.resize(mSelectedDates.count());
1536 1548
1537 uint i; 1549 uint i;
1538 for(i=0;i<mSelectedDates.count();++i) { 1550 for(i=0;i<mSelectedDates.count();++i) {
1539 QDate date = mSelectedDates[i]; 1551 QDate date = mSelectedDates[i];
1540 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1552 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1541 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1553 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1542 bool showHoliday = false; 1554 bool showHoliday = false;
1543 if ( KOPrefs::instance()->mExcludeHolidays ) { 1555 if ( KOPrefs::instance()->mExcludeHolidays ) {
1544 QPtrList<Event> events = calendar()->events( date, true ); 1556 Q3PtrList<Event> events = calendar()->events( date, true );
1545 Event *event; 1557 Event *event;
1546 for( event = events.first(); event; event = events.next() ) { 1558 for( event = events.first(); event; event = events.next() ) {
1547 if ( event->isHoliday()) { 1559 if ( event->isHoliday()) {
1548 showHoliday = true; 1560 showHoliday = true;
1549 break; 1561 break;
1550 } 1562 }
1551 } 1563 }
1552 1564
1553 } 1565 }
1554 1566
1555#ifndef KORG_NOPLUGINS 1567#ifndef KORG_NOPLUGINS
1556 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1568 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1557 !KOCore::self()->holiday(date).isEmpty(); 1569 !KOCore::self()->holiday(date).isEmpty();
1558#endif 1570#endif
1559 bool showDay = showSaturday || showSunday || showHoliday; 1571 bool showDay = showSaturday || showSunday || showHoliday;
1560 1572
@@ -1650,33 +1662,33 @@ void KOAgendaView::setInitStartHour()
1650void KOAgendaView::updateTodo( Todo * t, int ) 1662void KOAgendaView::updateTodo( Todo * t, int )
1651{ 1663{
1652 if ( !isVisible() ) 1664 if ( !isVisible() )
1653 return; 1665 return;
1654 bool remove = false; 1666 bool remove = false;
1655 bool removeAD = false; 1667 bool removeAD = false;
1656 QDate da; 1668 QDate da;
1657 if ( t->hasCompletedDate() ) 1669 if ( t->hasCompletedDate() )
1658 da = t->completed().date(); 1670 da = t->completed().date();
1659 else 1671 else
1660 da = t->dtDue().date(); 1672 da = t->dtDue().date();
1661 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1673 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1662 remove = true; 1674 remove = true;
1663 removeAD = true; 1675 removeAD = true;
1664 } 1676 }
1665 else { 1677 else {
1666 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1678 bool overdue = (!t->isCompleted()) && (t->dtDue() < (QDateTime)QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1667 if ( overdue && 1679 if ( overdue &&
1668 QDate::currentDate() >= mSelectedDates.first() && 1680 QDate::currentDate() >= mSelectedDates.first() &&
1669 QDate::currentDate() <= mSelectedDates.last()) { 1681 QDate::currentDate() <= mSelectedDates.last()) {
1670 removeAD = false; 1682 removeAD = false;
1671 remove = true; 1683 remove = true;
1672 } 1684 }
1673 else { 1685 else {
1674 1686
1675 if ( da < mSelectedDates.first() || 1687 if ( da < mSelectedDates.first() ||
1676 da > mSelectedDates.last() ) { 1688 da > mSelectedDates.last() ) {
1677 remove = true; 1689 remove = true;
1678 removeAD = true; 1690 removeAD = true;
1679 } else { 1691 } else {
1680 remove = t->doesFloat() && !t->hasCompletedDate(); 1692 remove = t->doesFloat() && !t->hasCompletedDate();
1681 removeAD = !remove; 1693 removeAD = !remove;
1682 } 1694 }