summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp6
-rw-r--r--korganizer/kdatenavigator.cpp2
-rw-r--r--korganizer/kodaymatrix.cpp32
-rw-r--r--korganizer/kodaymatrix.h1
4 files changed, 33 insertions, 8 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 92abae6..e57daa4 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -362,78 +362,82 @@ QDate DateNavigatorContainer::lastAvailableDate() const
362 if ( mLastDisplayedDN ) 362 if ( mLastDisplayedDN )
363 last = last.addDays( -1); 363 last = last.addDays( -1);
364 return last; 364 return last;
365} 365}
366QDate DateNavigatorContainer::firstAvailableDate() const 366QDate DateNavigatorContainer::firstAvailableDate() const
367{ 367{
368 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); 368 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
369} 369}
370void DateNavigatorContainer::selectDates( const DateList &dateList ) 370void DateNavigatorContainer::selectDates( const DateList &dateList )
371{ 371{
372 mFirstSelectedDate = dateList.first() ; 372 mFirstSelectedDate = dateList.first() ;
373 mSelectedDateCount = dateList.count() ; 373 mSelectedDateCount = dateList.count() ;
374 if ( !mLastDisplayedDN ) { 374 if ( !mLastDisplayedDN ) {
375 mNavigatorView->selectDates( dateList ); 375 mNavigatorView->selectDates( dateList );
376 return; 376 return;
377 } 377 }
378 QDate fDate = dateList.first(); 378 QDate fDate = dateList.first();
379 QDate lDate = dateList.last(); 379 QDate lDate = dateList.last();
380 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); 380 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
381 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 381 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
382 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 382 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
383 updateDayMatrixDates(); 383 updateDayMatrixDates();
384 return; 384 return;
385 } 385 }
386 mNavigatorView->selectDates( dateList ); 386 mNavigatorView->selectDates( dateList );
387 setBaseDates(); 387 setBaseDates();
388 if ( mLastDisplayedDN ) { 388 if ( mLastDisplayedDN ) {
389 KDateNavigator *view = mExtraViews.at( 0 ); 389 KDateNavigator *view = mExtraViews.at( 0 );
390 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 390 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
391 view->dayMatrix()->repaint( false ); 391 view->dayMatrix()->repaint( false );
392 if ( mLastDisplayedDN > 1 ) { 392 if ( mLastDisplayedDN > 1 ) {
393 KDateNavigator *view = mExtraViews.at( 1 ); 393 KDateNavigator *view = mExtraViews.at( 1 );
394 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 394 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
395 view->dayMatrix()->repaint( false ); 395 view->dayMatrix()->repaint( false );
396 } 396 }
397 } 397 }
398} 398}
399 399
400void DateNavigatorContainer::setBaseDates() 400void DateNavigatorContainer::setBaseDates()
401{ 401{
402 QDate baseDate = mNavigatorView->baseDate(); 402 QDate baseDate = mNavigatorView->baseDate();
403 bool doRepaint = true; 403 bool doRepaint = true;
404 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 404 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
405 KDateNavigator *n = mExtraViews.at( i ); 405 KDateNavigator *n = mExtraViews.at( i );
406 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 406 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
407 n->setBaseDate( baseDate, doRepaint ); 407 n->setBaseDate( baseDate, doRepaint );
408 } 408 }
409} 409}
410void DateNavigatorContainer::setResizeEnabled() 410void DateNavigatorContainer::setResizeEnabled()
411{ 411{
412 mResizeEnabled = true; 412 mResizeEnabled = true;
413 //qDebug("DateNavigatorContainer::setResizeEnabled "); 413 //qDebug("DateNavigatorContainer::setResizeEnabled ");
414 checkUpdateDayMatrixDates(); 414 checkUpdateDayMatrixDates();
415} 415}
416void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 416void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
417{ 417{
418 418
419 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); 419 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height());
420 //qDebug("COUNT %d ", mExtraViews.count()); 420 //qDebug("COUNT %d ", mExtraViews.count());
421 if ( ! mResizeEnabled ) { 421 if ( ! mResizeEnabled ) {
422 //qDebug("NOT ResizeEnabled"); 422 //qDebug("NOT ResizeEnabled");
423 return; 423 return;
424 } 424 }
425 else 425 else
426 mUpdateTimer->start( 250 ); 426#ifdef DESKTOP_VERSION
427 mUpdateTimer->start( 100 );
428#else
429 mUpdateTimer->start( 50 );
430#endif
427 431
428 //updateDayMatrixDates(); 432 //updateDayMatrixDates();
429} 433}
430 434
431QSize DateNavigatorContainer::minimumSizeHint() const 435QSize DateNavigatorContainer::minimumSizeHint() const
432{ 436{
433 return mNavigatorView->minimumSizeHint(); 437 return mNavigatorView->minimumSizeHint();
434} 438}
435 439
436QSize DateNavigatorContainer::sizeHint() const 440QSize DateNavigatorContainer::sizeHint() const
437{ 441{
438 return mNavigatorView->yourSizeHint(); 442 return mNavigatorView->yourSizeHint();
439} 443}
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 1d09f40..5aa1c9b 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -29,129 +29,129 @@
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 48KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 49 : QFrame(parent, name),
50 updateTimer(0L) 50 updateTimer(0L)
51{ 51{
52 setFrameStyle(QFrame::NoFrame); 52 setFrameStyle(QFrame::NoFrame);
53 QDate startDate = QDate::currentDate(); 53 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 54 QGridLayout *topLayout = new QGridLayout(this,8,8);
55 55
56 if (! startDate.isValid()) { 56 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 57 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 58 startDate = QDate::currentDate();
59 } 59 }
60 mMonthSignalOffset = 0; 60 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 61 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 62 m_MthYr = startDate;
63 m_bShowWeekNums = true; 63 m_bShowWeekNums = true;
64 setFont( KOPrefs::instance()->mDateNavigatorFont ); 64 setFont( KOPrefs::instance()->mDateNavigatorFont );
65 mNavigatorBar = new NavigatorBar( startDate, this ); 65 mNavigatorBar = new NavigatorBar( startDate, this );
66 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 66 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
67 //mNavigatorBar->resize( 1,1); 67 //mNavigatorBar->resize( 1,1);
68 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 68 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
69 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
70 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
72 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 72 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
73 73
74 // get the day of the week on the first day 74 // get the day of the week on the first day
75 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 75 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
76 m_fstDayOfWk = dayone.dayOfWeek(); 76 m_fstDayOfWk = dayone.dayOfWeek();
77 77
78 int i; 78 int i;
79 79
80 // Set up the heading fields. 80 // Set up the heading fields.
81 for( i = 0; i < 7; i++ ) { 81 for( i = 0; i < 7; i++ ) {
82 headings[i] = new QLabel("",this); 82 headings[i] = new QLabel("",this);
83 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 83 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
84 headings[i]->setAlignment(AlignCenter); 84 headings[i]->setAlignment(AlignCenter);
85 headings[i]->installEventFilter(this); 85 headings[i]->installEventFilter(this);
86 86
87 topLayout->addWidget(headings[i],1,i+1); 87 topLayout->addWidget(headings[i],1,i+1);
88 } 88 }
89 89
90 // Create the weeknumber labels 90 // Create the weeknumber labels
91 for( i = 0; i < 6; i++ ) { 91 for( i = 0; i < 6; i++ ) {
92 weeknos[i] = new QLabel(this); 92 weeknos[i] = new QLabel(this);
93 weeknos[i]->setAlignment(AlignCenter); 93 weeknos[i]->setAlignment(AlignCenter );
94 //weeknos[i]->setFont(QFont("Arial", 10)); 94 //weeknos[i]->setFont(QFont("Arial", 10));
95 if(!m_bShowWeekNums) { 95 if(!m_bShowWeekNums) {
96 weeknos[i]->hide(); 96 weeknos[i]->hide();
97 } 97 }
98 weeknos[i]->installEventFilter(this); 98 weeknos[i]->installEventFilter(this);
99 99
100 topLayout->addWidget(weeknos[i],i+2,0); 100 topLayout->addWidget(weeknos[i],i+2,0);
101 } 101 }
102 102
103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
105 daymatrix->setLineWidth(1); 105 daymatrix->setLineWidth(1);
106 106
107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
108 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 108 SIGNAL( datesSelected( const KCal::DateList & ) ) );
109 109
110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
111 SIGNAL( eventDropped( Event * ) ) ); 111 SIGNAL( eventDropped( Event * ) ) );
112 112
113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
114 114
115 // read settings from configuration file. 115 // read settings from configuration file.
116 updateConfig(); 116 updateConfig();
117 enableRollover(FollowMonth); 117 enableRollover(FollowMonth);
118 mySizeHint = sizeHintTwoButtons(); 118 mySizeHint = sizeHintTwoButtons();
119 myFullSizeHint = sizeHintTwoButtons( 4 ); 119 myFullSizeHint = sizeHintTwoButtons( 4 );
120 mFontChanged = false; 120 mFontChanged = false;
121 //resize ( 3,3 ); 121 //resize ( 3,3 );
122 122
123} 123}
124void KDateNavigator::changeFont ( QFont fo ) 124void KDateNavigator::changeFont ( QFont fo )
125{ 125{
126 setFont( fo ); 126 setFont( fo );
127 mNavigatorBar->resetFont( fo ); 127 mNavigatorBar->resetFont( fo );
128} 128}
129QFont KDateNavigator::yourFontHint( QSize si , bool *b) 129QFont KDateNavigator::yourFontHint( QSize si , bool *b)
130{ 130{
131 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 131 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
132 *b = false; 132 *b = false;
133 int fontPoint = fo.pointSize(); 133 int fontPoint = fo.pointSize();
134 while ( fontPoint > 5 ) { 134 while ( fontPoint > 5 ) {
135 --fontPoint; 135 --fontPoint;
136 fo.setPointSize( fontPoint ); 136 fo.setPointSize( fontPoint );
137 setFont( fo ); 137 setFont( fo );
138 mFontChanged = true; 138 mFontChanged = true;
139 mNavigatorBar->resetFont( fo ); 139 mNavigatorBar->resetFont( fo );
140 QSize sh = sizeHintTwoButtons( 2 ); 140 QSize sh = sizeHintTwoButtons( 2 );
141 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 141 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
142 if ( si.width() > sh.width() && si.height() > sh.height()) { 142 if ( si.width() > sh.width() && si.height() > sh.height()) {
143 if ( si.width() / sh.width() == 1 ) { 143 if ( si.width() / sh.width() == 1 ) {
144 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 144 if ( si.width() < sizeHintTwoButtons( 4 ).width())
145 continue; 145 continue;
146 } 146 }
147 *b = true; 147 *b = true;
148 //qDebug("fooooooooooooooooooooooouuuuund "); 148 //qDebug("fooooooooooooooooooooooouuuuund ");
149 break; 149 break;
150 } 150 }
151 } 151 }
152 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 152 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
153 return fo; 153 return fo;
154} 154}
155QSize KDateNavigator::sizeHint() const 155QSize KDateNavigator::sizeHint() const
156{ 156{
157 QFontMetrics fm ( font() ); 157 QFontMetrics fm ( font() );
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 8affe50..c7e1b45 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -48,137 +48,140 @@
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108#if 0 108#if 0
109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
110 QFrame(parent, name) 110 QFrame(parent, name)
111#endif 111#endif
112{ 112{
113 oldW = 0;
114 oldH = 0;
115 myPix.resize( 150, 120 );
113 mRedrawNeeded = true; 116 mRedrawNeeded = true;
114 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
115 mPendingUpdateBeforeRepaint = false; 118 mPendingUpdateBeforeRepaint = false;
116 mouseDown = false; 119 mouseDown = false;
117 // initialize dynamic arrays 120 // initialize dynamic arrays
118 bDays.resize ( NUMDAYS ); 121 bDays.resize ( NUMDAYS );
119 hDays.resize ( NUMDAYS );; 122 hDays.resize ( NUMDAYS );
120 eDays.resize ( NUMDAYS );; 123 eDays.resize ( NUMDAYS );
121 days = new QDate[NUMDAYS]; 124 days = new QDate[NUMDAYS];
122 daylbls = new QString[NUMDAYS]; 125 daylbls = new QString[NUMDAYS];
123 //events = new int[NUMDAYS]; 126 //events = new int[NUMDAYS];
124 mToolTip = new DynamicTip(this); 127 mToolTip = new DynamicTip(this);
125 128
126 // set default values used for drawing the matrix 129 // set default values used for drawing the matrix
127 mDefaultBackColor = palette().active().base(); 130 mDefaultBackColor = palette().active().base();
128 mDefaultTextColor = palette().active().foreground(); 131 mDefaultTextColor = palette().active().foreground();
129 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 132 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
130 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 133 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
131 mSelectedDaysColor = QColor("white"); 134 mSelectedDaysColor = QColor("white");
132 mTodayMarginWidth = 2; 135 mTodayMarginWidth = 2;
133 mSelEnd = mSelStart = NOSELECTION; 136 mSelEnd = mSelStart = NOSELECTION;
134 137
135 setAcceptDrops(true); 138 setAcceptDrops(true);
136 //setFont( QFont("Arial", 10) ); 139 //setFont( QFont("Arial", 10) );
137 140
138 mUpdateTimer = new QTimer( this ); 141 mUpdateTimer = new QTimer( this );
139 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 142 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
140 mRepaintTimer = new QTimer( this ); 143 mRepaintTimer = new QTimer( this );
141 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 144 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
142 mDayChanged = false; 145 mDayChanged = false;
143 updateView(); 146 updateView();
144} 147}
145QString KODayMatrix::getWhatsThisText( QPoint p ) 148QString KODayMatrix::getWhatsThisText( QPoint p )
146{ 149{
147 150
148 int tmp = getDayIndexFrom(p.x(), p.y()); 151 int tmp = getDayIndexFrom(p.x(), p.y());
149 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 152 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
150 return QString(); 153 return QString();
151 QDate mDate = days[tmp]; 154 QDate mDate = days[tmp];
152 QPtrList<Event> eventlist = mCalendar->events(mDate); 155 QPtrList<Event> eventlist = mCalendar->events(mDate);
153 Event *event; 156 Event *event;
154 QStringList mToolTip; 157 QStringList mToolTip;
155 for(event=eventlist.first();event != 0;event=eventlist.next()) { 158 for(event=eventlist.first();event != 0;event=eventlist.next()) {
156 QString mToolTipText; 159 QString mToolTipText;
157 QString text; 160 QString text;
158 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 161 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
159 if (event->isMultiDay()) { 162 if (event->isMultiDay()) {
160 QString prefix = "<->";multiday = 2; 163 QString prefix = "<->";multiday = 2;
161 QString time; 164 QString time;
162 if ( event->doesRecur() ) { 165 if ( event->doesRecur() ) {
163 if ( event->recursOn( mDate) ) { 166 if ( event->recursOn( mDate) ) {
164 prefix ="->" ;multiday = 1; 167 prefix ="->" ;multiday = 1;
165 } 168 }
166 else { 169 else {
167 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 170 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
168 if ( event->recursOn( mDate.addDays( -days)) ) { 171 if ( event->recursOn( mDate.addDays( -days)) ) {
169 prefix ="<-" ;multiday = 3; 172 prefix ="<-" ;multiday = 3;
170 } 173 }
171 } 174 }
172 } else { 175 } else {
173 if (mDate == event->dtStart().date()) { 176 if (mDate == event->dtStart().date()) {
174 prefix ="->" ;multiday = 1; 177 prefix ="->" ;multiday = 1;
175 } else if (mDate == event->dtEnd().date()) { 178 } else if (mDate == event->dtEnd().date()) {
176 prefix ="<-" ;multiday = 3; 179 prefix ="<-" ;multiday = 3;
177 } 180 }
178 } 181 }
179 if ( !event->doesFloat() ) { 182 if ( !event->doesFloat() ) {
180 if ( mDate == event->dtStart().date () ) 183 if ( mDate == event->dtStart().date () )
181 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 184 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
182 else if ( mDate == event->dtEnd().date () ) 185 else if ( mDate == event->dtEnd().date () )
183 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 186 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
184 187
@@ -273,129 +276,133 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays)
273 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 276 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
274 if (mSelEnd > NUMDAYS-1) { 277 if (mSelEnd > NUMDAYS-1) {
275 for (int i = i0; i <= NUMDAYS-1; i++) { 278 for (int i = i0; i <= NUMDAYS-1; i++) {
276 selDays.append(days[i]); 279 selDays.append(days[i]);
277 } 280 }
278 for (int i = NUMDAYS; i < mSelEnd; i++) { 281 for (int i = NUMDAYS; i < mSelEnd; i++) {
279 selDays.append(days[0].addDays(i)); 282 selDays.append(days[0].addDays(i));
280 } 283 }
281 284
282 // apply normal routine to selection being entirely within matrix limits 285 // apply normal routine to selection being entirely within matrix limits
283 } else { 286 } else {
284 for (int i = i0; i <= mSelEnd; i++) { 287 for (int i = i0; i <= mSelEnd; i++) {
285 selDays.append(days[i]); 288 selDays.append(days[i]);
286 } 289 }
287 } 290 }
288} 291}
289 292
290bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 293bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
291{ 294{
292 mRedrawNeeded = true; 295 mRedrawNeeded = true;
293 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); 296 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
294 mSelStart = startdate.daysTo(start); 297 mSelStart = startdate.daysTo(start);
295 if ( mSelStart < 0 ) 298 if ( mSelStart < 0 )
296 mSelStart = 0; 299 mSelStart = 0;
297 mSelEnd = startdate.daysTo(end); 300 mSelEnd = startdate.daysTo(end);
298 if ( mSelEnd > NUMDAYS-1 ) 301 if ( mSelEnd > NUMDAYS-1 )
299 mSelEnd = NUMDAYS-1; 302 mSelEnd = NUMDAYS-1;
300 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 303 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
301 clearSelection(); 304 clearSelection();
302 if ( noSel ) 305 if ( noSel )
303 return false; 306 return false;
304 } 307 }
305 308
306 return true; 309 return true;
307} 310}
308void KODayMatrix::clearSelection() 311void KODayMatrix::clearSelection()
309{ 312{
310 mSelEnd = mSelStart = NOSELECTION; 313 mSelEnd = mSelStart = NOSELECTION;
311} 314}
312 315
313 316
314void KODayMatrix::recalculateToday() 317void KODayMatrix::recalculateToday()
315{ 318{
316 today = -1; 319 today = -1;
317 for (int i=0; i<NUMDAYS; i++) { 320 for (int i=0; i<NUMDAYS; i++) {
318 //events[i] = 0; 321 //events[i] = 0;
319 days[i] = startdate.addDays(i); 322 days[i] = startdate.addDays(i);
320 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 323 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
321 324
322 // if today is in the currently displayed month, hilight today 325 // if today is in the currently displayed month, hilight today
323 if (days[i].year() == QDate::currentDate().year() && 326 if (days[i].year() == QDate::currentDate().year() &&
324 days[i].month() == QDate::currentDate().month() && 327 days[i].month() == QDate::currentDate().month() &&
325 days[i].day() == QDate::currentDate().day()) { 328 days[i].day() == QDate::currentDate().day()) {
326 today = i; 329 today = i;
327 } 330 }
328 } 331 }
329 // qDebug(QString("Today is visible at %1.").arg(today)); 332 // qDebug(QString("Today is visible at %1.").arg(today));
330} 333}
331 334
332void KODayMatrix::updateView() 335void KODayMatrix::updateView()
333{ 336{
334 updateView(startdate); 337 updateView(startdate);
335} 338}
336void KODayMatrix::repaintViewTimed() 339void KODayMatrix::repaintViewTimed()
337{ 340{
341 mRedrawNeeded = true;
342 bDays.fill( false);
343 hDays.fill( false);
344 eDays.fill( false);
338 mRepaintTimer->stop(); 345 mRepaintTimer->stop();
339 repaint(false); 346 repaint(false);
340} 347}
341void KODayMatrix::updateViewTimed() 348void KODayMatrix::updateViewTimed()
342{ 349{
343 mUpdateTimer->stop(); 350 mUpdateTimer->stop();
344 if ( !mCalendar ) { 351 if ( !mCalendar ) {
345 qDebug("NOT CAL "); 352 qDebug("NOT CAL ");
346 return; 353 return;
347 } 354 }
348 //qDebug("KODayMatrix::updateViewTimed "); 355 //qDebug("KODayMatrix::updateViewTimed ");
349 for(int i = 0; i < NUMDAYS; i++) { 356 for(int i = 0; i < NUMDAYS; i++) {
350 // if events are set for the day then remember to draw it bold 357 // if events are set for the day then remember to draw it bold
351 QPtrList<Event> eventlist = mCalendar->events(days[i]); 358 QPtrList<Event> eventlist = mCalendar->events(days[i]);
352 Event *event; 359 Event *event;
353 int numEvents = eventlist.count(); 360 int numEvents = eventlist.count();
354 QString holiStr = ""; 361 QString holiStr = "";
355 bDays.clearBit(i); 362 bDays.clearBit(i);
356 hDays.clearBit(i); 363 hDays.clearBit(i);
357 eDays.clearBit(i); 364 eDays.clearBit(i);
358 for(event=eventlist.first();event != 0;event=eventlist.next()) { 365 for(event=eventlist.first();event != 0;event=eventlist.next()) {
359 ushort recurType = event->recurrence()->doesRecur(); 366 ushort recurType = event->recurrence()->doesRecur();
360 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 367 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
361 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 368 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
362 numEvents--; 369 numEvents--;
363 } 370 }
364 if ( event->isHoliday()) { 371 if ( event->isHoliday()) {
365 hDays.setBit(i); 372 hDays.setBit(i);
366 if ( !holiStr.isEmpty() ) 373 if ( !holiStr.isEmpty() )
367 holiStr += "\n"; 374 holiStr += "\n";
368 holiStr += event->summary(); 375 holiStr += event->summary();
369 if ( !event->location().isEmpty() ) 376 if ( !event->location().isEmpty() )
370 holiStr += " (" + event->location() + ")"; 377 holiStr += " (" + event->location() + ")";
371 } 378 }
372 if ( event->isBirthday()) { 379 if ( event->isBirthday()) {
373 if ( !holiStr.isEmpty() ) 380 if ( !holiStr.isEmpty() )
374 holiStr += "\n"; 381 holiStr += "\n";
375 holiStr += i18n("Birthday") + ": "+event->summary(); 382 holiStr += i18n("Birthday") + ": "+event->summary();
376 if ( !event->location().isEmpty() ) 383 if ( !event->location().isEmpty() )
377 holiStr += " (" + event->location() + ")"; 384 holiStr += " (" + event->location() + ")";
378 bDays.setBit(i); 385 bDays.setBit(i);
379 } 386 }
380 } 387 }
381 if ( numEvents ) 388 if ( numEvents )
382 eDays.setBit(i); 389 eDays.setBit(i);
383 //if it is a holy day then draw it red. Sundays are consider holidays, too 390 //if it is a holy day then draw it red. Sundays are consider holidays, too
384 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 391 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
385 !holiStr.isEmpty()) { 392 !holiStr.isEmpty()) {
386 mHolidays[i] = holiStr; 393 mHolidays[i] = holiStr;
387 } else { 394 } else {
388 mHolidays[i] = QString::null; 395 mHolidays[i] = QString::null;
389 } 396 }
390 } 397 }
391 mRedrawNeeded = true; 398 mRedrawNeeded = true;
392 if ( ! mPendingUpdateBeforeRepaint ) 399 if ( ! mPendingUpdateBeforeRepaint )
393 repaint(false); 400 repaint(false);
394} 401}
395void KODayMatrix::updateView(QDate actdate) 402void KODayMatrix::updateView(QDate actdate)
396{ 403{
397 404
398 if ( ! actdate.isValid() ) { 405 if ( ! actdate.isValid() ) {
399 //qDebug("date not valid "); 406 //qDebug("date not valid ");
400 return; 407 return;
401 } 408 }
@@ -622,133 +629,145 @@ void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
622void KODayMatrix::dropEvent(QDropEvent *e) 629void KODayMatrix::dropEvent(QDropEvent *e)
623{ 630{
624#ifndef KORG_NODND 631#ifndef KORG_NODND
625// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 632// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
626 633
627 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 634 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
628 e->ignore(); 635 e->ignore();
629 return; 636 return;
630 } 637 }
631 638
632 DndFactory factory( mCalendar ); 639 DndFactory factory( mCalendar );
633 Event *event = factory.createDrop(e); 640 Event *event = factory.createDrop(e);
634 641
635 if (event) { 642 if (event) {
636 e->acceptAction(); 643 e->acceptAction();
637 644
638 Event *existingEvent = mCalendar->event(event->uid()); 645 Event *existingEvent = mCalendar->event(event->uid());
639 646
640 if(existingEvent) { 647 if(existingEvent) {
641 // uniquify event 648 // uniquify event
642 event->recreate(); 649 event->recreate();
643/* 650/*
644 KMessageBox::sorry(this, 651 KMessageBox::sorry(this,
645 i18n("Event already exists in this calendar."), 652 i18n("Event already exists in this calendar."),
646 i18n("Drop Event")); 653 i18n("Drop Event"));
647 delete event; 654 delete event;
648 return; 655 return;
649*/ 656*/
650 } 657 }
651// kdDebug() << "Drop new Event" << endl; 658// kdDebug() << "Drop new Event" << endl;
652 // Adjust date 659 // Adjust date
653 QDateTime start = event->dtStart(); 660 QDateTime start = event->dtStart();
654 QDateTime end = event->dtEnd(); 661 QDateTime end = event->dtEnd();
655 int duration = start.daysTo(end); 662 int duration = start.daysTo(end);
656 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 663 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
657 664
658 start.setDate(days[idx]); 665 start.setDate(days[idx]);
659 end.setDate(days[idx].addDays(duration)); 666 end.setDate(days[idx].addDays(duration));
660 667
661 event->setDtStart(start); 668 event->setDtStart(start);
662 event->setDtEnd(end); 669 event->setDtEnd(end);
663 mCalendar->addEvent(event); 670 mCalendar->addEvent(event);
664 671
665 emit eventDropped(event); 672 emit eventDropped(event);
666 } else { 673 } else {
667// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 674// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
668 e->ignore(); 675 e->ignore();
669 } 676 }
670#endif 677#endif
671} 678}
672 679
673// ---------------------------------------------------------------------------- 680// ----------------------------------------------------------------------------
674// P A I N T E V E N T H A N D L I N G 681// P A I N T E V E N T H A N D L I N G
675// ---------------------------------------------------------------------------- 682// ----------------------------------------------------------------------------
676 683
677void KODayMatrix::paintEvent(QPaintEvent * pevent) 684void KODayMatrix::paintEvent(QPaintEvent * pevent)
678{ 685{
679 686
680 if ( width() <= 0 || height() <= 0 ) 687 if ( width() <= 0 || height() <= 0 )
681 return; 688 return;
682 if ( mPendingUpdateBeforeRepaint ) { 689 if ( mPendingUpdateBeforeRepaint ) {
683 updateViewTimed(); 690 updateViewTimed();
684 mPendingUpdateBeforeRepaint = false; 691 mPendingUpdateBeforeRepaint = false;
685 } 692 }
693#if 0
686 if ( myPix.width() != width() || myPix.height()!=height() ) { 694 if ( myPix.width() != width() || myPix.height()!=height() ) {
687 myPix.resize(size() ); 695 myPix.resize(size() );
688 mRedrawNeeded = true; 696 mRedrawNeeded = true;
689 } 697 }
690 698#endif
699 if ( oldW != width() || oldH !=height() )
700 mRedrawNeeded = true;
701
702 oldH = height() ;
703 oldW = width();
704 if ( myPix.width() < width() || myPix.height() < height() ) {
705 myPix.resize(size() );
706 mRedrawNeeded = true;
707
708 }
709
691 if ( mRedrawNeeded ) { 710 if ( mRedrawNeeded ) {
692 //qDebug("REDRAW "); 711 //qDebug("REDRAW ");
693 QPainter p(&myPix); 712 QPainter p(&myPix);
694 p.setFont(font()); 713 p.setFont(font());
695 714
696 715
697 int dheight = daysize.height(); 716 int dheight = daysize.height();
698 int dwidth = daysize.width(); 717 int dwidth = daysize.width();
699 int row,col; 718 int row,col;
700 int selw, selh; 719 int selw, selh;
701 int xyOff = frameWidth(); 720 int xyOff = frameWidth();
702 int colModulo = (width()-2) % 7; 721 int colModulo = (width()-2) % 7;
703 int rowModulo = (height()-2) % 6; 722 int rowModulo = (height()-2) % 6;
704 //qDebug("col %d row %d ",colModulo,rowModulo ); 723 //qDebug("col %d row %d ",colModulo,rowModulo );
705 724
706 bool isRTL = KOGlobals::self()->reverseLayout(); 725 bool isRTL = KOGlobals::self()->reverseLayout();
707 726
708 // draw background and topleft frame 727 // draw background and topleft frame
709 p.fillRect(0,0,width(),height(), mDefaultBackColor); 728 p.fillRect(0,0,width(),height(), mDefaultBackColor);
710 p.setPen(mDefaultTextColor); 729 p.setPen(mDefaultTextColor);
711 p.drawRect(0, 0, width(), height()); 730 p.drawRect(0, 0, width(), height());
712 int mSelStartT = mSelStart; 731 int mSelStartT = mSelStart;
713 int mSelEndT = mSelEnd; 732 int mSelEndT = mSelEnd;
714 if ( mSelEndT >= NUMDAYS ) 733 if ( mSelEndT >= NUMDAYS )
715 mSelEndT = NUMDAYS-1; 734 mSelEndT = NUMDAYS-1;
716 // draw selected days with highlighted background color 735 // draw selected days with highlighted background color
717 if (mSelStart != NOSELECTION) { 736 if (mSelStart != NOSELECTION) {
718 bool skip = false; 737 bool skip = false;
719 if ( ! mouseDown ) { 738 if ( ! mouseDown ) {
720 int mo = days[20].month(); 739 int mo = days[20].month();
721 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 740 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
722 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 741 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
723 int startMo = days[mSelStartT].month(); 742 int startMo = days[mSelStartT].month();
724 int endMo = days[mSelEndT].month(); 743 int endMo = days[mSelEndT].month();
725 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 744 if ( startMo == 12 && mo == 1 && endMo <= 2 )
726 startMo = 1; 745 startMo = 1;
727 if ( endMo == 1 && mo == 12 ) 746 if ( endMo == 1 && mo == 12 )
728 endMo = 12; 747 endMo = 12;
729 if ( mo == 12 && startMo == 1 ) 748 if ( mo == 12 && startMo == 1 )
730 startMo = 13; 749 startMo = 13;
731 if ( (startMo > mo || endMo < mo) ) { 750 if ( (startMo > mo || endMo < mo) ) {
732 skip = true; 751 skip = true;
733 } else { 752 } else {
734 if ( days[mSelStartT].month() != mo ) { 753 if ( days[mSelStartT].month() != mo ) {
735 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 754 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
736 mSelStartT += add +1; 755 mSelStartT += add +1;
737 } 756 }
738 if ( days[mSelEndT].month() != mo ) { 757 if ( days[mSelEndT].month() != mo ) {
739 int sub = days[mSelEndT].day(); 758 int sub = days[mSelEndT].day();
740 mSelEndT -= sub ; 759 mSelEndT -= sub ;
741 } 760 }
742 } 761 }
743 } 762 }
744 //qDebug("SKIP %d ", skip); 763 //qDebug("SKIP %d ", skip);
745 if ( ! skip ) { 764 if ( ! skip ) {
746 row = mSelStartT/7; 765 row = mSelStartT/7;
747 col = mSelStartT -row*7; 766 col = mSelStartT -row*7;
748 QColor selcol = KOPrefs::instance()->mHighlightColor; 767 QColor selcol = KOPrefs::instance()->mHighlightColor;
749 int addCol = 0; 768 int addCol = 0;
750 int addRow = 0; 769 int addRow = 0;
751 int addRow2 = 0; 770 int addRow2 = 0;
752 int addCol2 = 0; 771 int addCol2 = 0;
753 if (row == mSelEndT/7) { 772 if (row == mSelEndT/7) {
754 if ( rowModulo ) { 773 if ( rowModulo ) {
@@ -886,89 +905,90 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
886 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 905 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
887 p.setPen(tmppen); 906 p.setPen(tmppen);
888 } 907 }
889 908
890 // if any events are on that day then draw it using a bold font 909 // if any events are on that day then draw it using a bold font
891 if ( eDays.testBit(i) ) { 910 if ( eDays.testBit(i) ) {
892 QFont myFont = font(); 911 QFont myFont = font();
893 myFont.setBold(true); 912 myFont.setBold(true);
894 p.setFont(myFont); 913 p.setFont(myFont);
895 } 914 }
896 915
897 // if it is a holiday then use the default holiday color 916 // if it is a holiday then use the default holiday color
898 if ( !mHolidays[i].isNull()) { 917 if ( !mHolidays[i].isNull()) {
899 if ( bDays.testBit(i) ) { 918 if ( bDays.testBit(i) ) {
900 if ( hDays.testBit(i) ) 919 if ( hDays.testBit(i) )
901 p.setPen(QColor(Qt::green)); 920 p.setPen(QColor(Qt::green));
902 else 921 else
903 p.setPen(QColor(Qt::green).dark()); 922 p.setPen(QColor(Qt::green).dark());
904 } else { 923 } else {
905 if (actcol == mDefaultTextColor ) { 924 if (actcol == mDefaultTextColor ) {
906 p.setPen(KOPrefs::instance()->mHolidayColor); 925 p.setPen(KOPrefs::instance()->mHolidayColor);
907 } else { 926 } else {
908 p.setPen(mHolidayColorShaded); 927 p.setPen(mHolidayColorShaded);
909 } 928 }
910 } 929 }
911 } 930 }
912 931
913 // draw selected days with special color 932 // draw selected days with special color
914 // DO NOT specially highlight holidays in selection ! 933 // DO NOT specially highlight holidays in selection !
915 if (i >= mSelStartT && i <= mSelEndT) { 934 if (i >= mSelStartT && i <= mSelEndT) {
916 ;//p.setPen(mSelectedDaysColor); 935 ;//p.setPen(mSelectedDaysColor);
917 } 936 }
918 937
919 int addCol = 0; 938 int addCol = 0;
920 int addRow = 0; 939 int addRow = 0;
921 if ( colModulo ) { 940 if ( colModulo ) {
922 if ( col >= 7 - colModulo ) 941 if ( col >= 7 - colModulo )
923 addCol = col - 7 + colModulo; 942 addCol = col - 7 + colModulo;
924 } 943 }
925 if ( rowModulo ) { 944 if ( rowModulo ) {
926 if ( row >= 6 - rowModulo ) 945 if ( row >= 6 - rowModulo )
927 addRow = row - 5 + rowModulo; 946 addRow = row - 5 + rowModulo;
928 } 947 }
929 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 948 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
930 ++addCol;//++addCol; 949 ++addCol;//++addCol;
931 if ( row == 0) 950 if ( row == 0)
932 addRow = 1; 951 addRow = 1;
933 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 952 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
934 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 953 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
935 954
936 // reset color to actual color 955 // reset color to actual color
937 if (!mHolidays[i].isNull()) { 956 if (!mHolidays[i].isNull()) {
938 p.setPen(actcol); 957 p.setPen(actcol);
939 } 958 }
940 // reset bold font to plain font 959 // reset bold font to plain font
941 if ( eDays.testBit(i)) { 960 if ( eDays.testBit(i)) {
942 QFont myFont = font(); 961 QFont myFont = font();
943 myFont.setBold(false); 962 myFont.setBold(false);
944 p.setFont(myFont); 963 p.setFont(myFont);
945 } 964 }
946 } 965 }
947 } else { 966 } else {
948 //qDebug("NO redraw "); 967 //qDebug("NO redraw ");
949 } 968 }
950 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 969
970 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
951 mRedrawNeeded = false; 971 mRedrawNeeded = false;
952} 972}
953 973
954// ---------------------------------------------------------------------------- 974// ----------------------------------------------------------------------------
955// R E SI Z E E V E N T H A N D L I N G 975// R E SI Z E E V E N T H A N D L I N G
956// ---------------------------------------------------------------------------- 976// ----------------------------------------------------------------------------
957 977
958void KODayMatrix::resizeEvent(QResizeEvent *) 978void KODayMatrix::resizeEvent(QResizeEvent *)
959{ 979{
960 QRect sz = frameRect(); 980 QRect sz = frameRect();
961 daysize.setHeight(sz.height()*7 / NUMDAYS); 981 daysize.setHeight(sz.height()*7 / NUMDAYS);
962 daysize.setWidth(sz.width() / 7); 982 daysize.setWidth(sz.width() / 7);
963} 983}
964 984
965QSize KODayMatrix::sizeHint() const 985QSize KODayMatrix::sizeHint() const
966{ 986{
967 987
968 QFontMetrics fm ( font() ); 988 QFontMetrics fm ( font() );
969 int wid = fm.width( "30") *7+3; 989 int wid = fm.width( "30") *7+3;
970 int hei = fm.height() * 6+3; 990 int hei = fm.height() * 6+3;
971 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 991 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
972 return QSize ( wid, hei ); 992 return QSize ( wid, hei );
973 993
974} 994}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 731117c..d725ead 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -166,128 +166,129 @@ public:
166 * near the beginning or the end of the month. 166 * near the beginning or the end of the month.
167 * This is dependent on today remaining the index 167 * This is dependent on today remaining the index
168 * in the array of visible dates and going from 168 * in the array of visible dates and going from
169 * top left (0) to bottom right (41). 169 * top left (0) to bottom right (41).
170 */ 170 */
171 bool isBeginningOfMonth() const { return today<=8; } ; 171 bool isBeginningOfMonth() const { return today<=8; } ;
172 bool isEndOfMonth() const { return today>=27; } ; 172 bool isEndOfMonth() const { return today>=27; } ;
173 QString getWhatsThisText( QPoint ) ; 173 QString getWhatsThisText( QPoint ) ;
174 QSize sizeHint() const; 174 QSize sizeHint() const;
175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} 175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);}
176public slots: 176public slots:
177 /** Recalculates all the flags of the days in the matrix like holidays or events 177 /** Recalculates all the flags of the days in the matrix like holidays or events
178 * on a day (Actually calls above method with the actual startdate). 178 * on a day (Actually calls above method with the actual startdate).
179 */ 179 */
180 void updateView(); 180 void updateView();
181 void updateViewTimed(); 181 void updateViewTimed();
182 void repaintViewTimed(); 182 void repaintViewTimed();
183 183
184 /** 184 /**
185 * Calculate which square in the matrix should be 185 * Calculate which square in the matrix should be
186 * hilighted to indicate it's today. 186 * hilighted to indicate it's today.
187 */ 187 */
188 void recalculateToday(); 188 void recalculateToday();
189 189
190/* 190/*
191 void setStartDate(QDate); 191 void setStartDate(QDate);
192*/ 192*/
193 193
194signals: 194signals:
195 195
196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
197 * inside the matrix 197 * inside the matrix
198 * 198 *
199 * @param daylist list of days that have been selected by the user 199 * @param daylist list of days that have been selected by the user
200 */ 200 */
201 void selected( const KCal::DateList &daylist ); 201 void selected( const KCal::DateList &daylist );
202 202
203 /** emitted if the user has dropped an event inside the matrix 203 /** emitted if the user has dropped an event inside the matrix
204 * 204 *
205 * @param event the dropped calendar event 205 * @param event the dropped calendar event
206 */ 206 */
207 void eventDropped(Event *event); 207 void eventDropped(Event *event);
208 208
209protected: 209protected:
210 210
211 void paintEvent(QPaintEvent *ev); 211 void paintEvent(QPaintEvent *ev);
212 212
213 void mousePressEvent (QMouseEvent* e); 213 void mousePressEvent (QMouseEvent* e);
214 214
215 void mouseReleaseEvent (QMouseEvent* e); 215 void mouseReleaseEvent (QMouseEvent* e);
216 216
217 void mouseMoveEvent (QMouseEvent* e); 217 void mouseMoveEvent (QMouseEvent* e);
218 218
219 void dragEnterEvent(QDragEnterEvent *); 219 void dragEnterEvent(QDragEnterEvent *);
220 220
221 void dragMoveEvent(QDragMoveEvent *); 221 void dragMoveEvent(QDragMoveEvent *);
222 222
223 void dragLeaveEvent(QDragLeaveEvent *); 223 void dragLeaveEvent(QDragLeaveEvent *);
224 224
225 void dropEvent(QDropEvent *); 225 void dropEvent(QDropEvent *);
226 226
227 void resizeEvent(QResizeEvent *); 227 void resizeEvent(QResizeEvent *);
228 228
229private: 229private:
230 int oldW, oldH;
230 bool mRedrawNeeded; 231 bool mRedrawNeeded;
231 KODaymatrixWhatsThis* mKODaymatrixWhatsThis; 232 KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
232 bool mouseDown; 233 bool mouseDown;
233 QBitArray bDays; 234 QBitArray bDays;
234 QBitArray hDays; 235 QBitArray hDays;
235 QBitArray eDays; 236 QBitArray eDays;
236 QPixmap myPix; 237 QPixmap myPix;
237 QTimer* mUpdateTimer; 238 QTimer* mUpdateTimer;
238 QTimer* mRepaintTimer; 239 QTimer* mRepaintTimer;
239 bool mDayChanged; 240 bool mDayChanged;
240 bool mPendingUpdateBeforeRepaint; 241 bool mPendingUpdateBeforeRepaint;
241 242
242 /** returns the index of the day located at the matrix's widget (x,y) position. 243 /** returns the index of the day located at the matrix's widget (x,y) position.
243 * 244 *
244 * @param x horizontal coordinate 245 * @param x horizontal coordinate
245 * @param y vertical coordinate 246 * @param y vertical coordinate
246 */ 247 */
247 int getDayIndexFrom(int x, int y); 248 int getDayIndexFrom(int x, int y);
248 249
249 /** calculates a "shaded" color from the supplied color object. 250 /** calculates a "shaded" color from the supplied color object.
250 * (Copied from Cornelius's kdpdatebutton.cpp) 251 * (Copied from Cornelius's kdpdatebutton.cpp)
251 * 252 *
252 * @param color source based on which a shaded color should be calculated. 253 * @param color source based on which a shaded color should be calculated.
253 */ 254 */
254 QColor getShadedColor(QColor color); 255 QColor getShadedColor(QColor color);
255 256
256 /** number of days to be displayed. For now there is no support for any other number then 42. 257 /** number of days to be displayed. For now there is no support for any other number then 42.
257 so change it at your own risk :o) */ 258 so change it at your own risk :o) */
258 static const int NUMDAYS; 259 static const int NUMDAYS;
259 260
260 /** calendar instance to be queried for holidays, events, ... */ 261 /** calendar instance to be queried for holidays, events, ... */
261 Calendar *mCalendar; 262 Calendar *mCalendar;
262 263
263 /** starting date of the matrix */ 264 /** starting date of the matrix */
264 QDate startdate; 265 QDate startdate;
265 266
266 /** array of day labels to optimeize drawing performance. */ 267 /** array of day labels to optimeize drawing performance. */
267 QString *daylbls; 268 QString *daylbls;
268 269
269 /** array of days displayed to reduce memory consumption by 270 /** array of days displayed to reduce memory consumption by
270 subsequently calling QDate::addDays(). */ 271 subsequently calling QDate::addDays(). */
271 QDate *days; 272 QDate *days;
272 273
273 /** array of storing the number of events on a given day. 274 /** array of storing the number of events on a given day.
274 * used for drawing a bold font if there is at least one event on that day. 275 * used for drawing a bold font if there is at least one event on that day.
275 */ 276 */
276 //int *events; 277 //int *events;
277 278
278 /** stores holiday names of the days shown in the matrix. */ 279 /** stores holiday names of the days shown in the matrix. */
279 QMap<int,QString> mHolidays; 280 QMap<int,QString> mHolidays;
280 281
281 /** indey of today or -1 if today is not visible in the matrix. */ 282 /** indey of today or -1 if today is not visible in the matrix. */
282 int today; 283 int today;
283 284
284 /** index of day where dragged selection was initiated. 285 /** index of day where dragged selection was initiated.
285 used to detect "negative" timely selections */ 286 used to detect "negative" timely selections */
286 int mSelInit; 287 int mSelInit;
287 288
288 /** if mSelStart has this value it indicates that there is no 289 /** if mSelStart has this value it indicates that there is no
289 actual selection in the matrix. */ 290 actual selection in the matrix. */
290 static const int NOSELECTION; 291 static const int NOSELECTION;
291 292
292 /** index of first selected day. */ 293 /** index of first selected day. */
293 int mSelStart; 294 int mSelStart;