summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-01 14:41:00 (UTC)
committer zautrix <zautrix>2005-04-01 14:41:00 (UTC)
commite5ec0ef6a256b96a758815ef861526f53d1ad7a5 (patch) (unidiff)
tree3fa188da9108c867c1437157731c7b7a3d4e641d
parent93003b1f8348f112648d3cc20acb21b062220e21 (diff)
downloadkdepimpi-e5ec0ef6a256b96a758815ef861526f53d1ad7a5.zip
kdepimpi-e5ec0ef6a256b96a758815ef861526f53d1ad7a5.tar.gz
kdepimpi-e5ec0ef6a256b96a758815ef861526f53d1ad7a5.tar.bz2
fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp10
-rw-r--r--korganizer/koagendaview.h2
-rw-r--r--korganizer/kodaymatrix.cpp17
-rw-r--r--korganizer/kodaymatrix.h1
4 files changed, 26 insertions, 4 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2996acb..218396d 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -60,83 +60,86 @@
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 );
84 mRows = rows; 85 mRows = rows;
85 86
87 mRedrawNeeded = true;
86 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 90
89 enableClipper(true); 91 enableClipper(true);
90 92
91 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
93 95
94 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
95 97
96 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
97} 99}
98 100
99void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
100{ 102{
101 mCellHeight = height; 103 mCellHeight = height;
102} 104}
103 105
104/* 106/*
105 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 109*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 111{
110 112
111 // if ( globalFlagBlockAgenda ) 113 // if ( globalFlagBlockAgenda )
112 // return; 114 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 115 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 116 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 117 // code assumes the latter...
116 118
117 // now, for a workaround... 119 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 120 // these two assignments fix the weird redraw bug
121 if ( mRedrawNeeded ) {
119 cx = contentsX() + 2; 122 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 123 cw = contentsWidth() - 2;
121 // end of workaround 124 // end of workaround
122 125
123 int cell = ((int)(cy/mCellHeight)); 126 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 127 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 128 QFontMetrics fm = fontMetrics();
126 QString hour; 129 QString hour;
127 QString suffix; 130 QString suffix;
128 int tW = fm.width("24:00i"); 131 int tW = fm.width("24:00i");
129 int timeHeight = fm.height(); 132 int timeHeight = fm.height();
130 //timeHeight -= (timeHeight/4-2); 133 //timeHeight -= (timeHeight/4-2);
131 int borderWidth = 0; 134 int borderWidth = 0;
132 QFont nFont = p->font(); 135 QFont nFont = p->font();
133 136
134 if (!KGlobal::locale()->use12Clock()) 137 if (!KGlobal::locale()->use12Clock())
135 suffix = "00"; 138 suffix = "00";
136 else 139 else
137 borderWidth = 0; 140 borderWidth = 0;
138 if ( timeHeight > mCellHeight ) { 141 if ( timeHeight > mCellHeight ) {
139 timeHeight = mCellHeight-1; 142 timeHeight = mCellHeight-1;
140 int pointS = nFont.pointSize(); 143 int pointS = nFont.pointSize();
141 while ( pointS > 4 ) { 144 while ( pointS > 4 ) {
142 nFont.setPointSize( pointS ); 145 nFont.setPointSize( pointS );
@@ -162,61 +165,68 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
162 165
163 // handle 24h and am/pm time formats 166 // handle 24h and am/pm time formats
164 if (KGlobal::locale()->use12Clock()) { 167 if (KGlobal::locale()->use12Clock()) {
165 if (cell > 11) suffix = "pm"; 168 if (cell > 11) suffix = "pm";
166 else 169 else
167 suffix = "am"; 170 suffix = "am";
168 if (cell == 0) hour.setNum(12); 171 if (cell == 0) hour.setNum(12);
169 if (cell > 12) hour.setNum(cell - 12); 172 if (cell > 12) hour.setNum(cell - 12);
170 } 173 }
171 174
172 // center and draw the time label 175 // center and draw the time label
173 int timeWidth = fm.width(hour+"i"); 176 int timeWidth = fm.width(hour+"i");
174 int tw2 = fm.width(suffix); 177 int tw2 = fm.width(suffix);
175 int offset = startW - timeWidth - tw2 ; 178 int offset = startW - timeWidth - tw2 ;
176 p->setFont( nFont ); 179 p->setFont( nFont );
177 p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); 180 p->drawText(cx - borderWidth + offset, y+ timeHeight, hour);
178 p->setFont( sFont ); 181 p->setFont( sFont );
179 offset = startW - tw2-1; 182 offset = startW - tw2-1;
180 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 183 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
181 184
182 // increment indices 185 // increment indices
183 y += mCellHeight; 186 y += mCellHeight;
184 cell++; 187 cell++;
185 } 188 }
189 } else {
190 //qDebug("NO redraw ");
191 }
192 // double buffer not yet implemented
193 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
194 //mRedrawNeeded = false;
186} 195}
187 196
188/** 197/**
189 Calculates the minimum width. 198 Calculates the minimum width.
190*/ 199*/
191int TimeLabels::minimumWidth() const 200int TimeLabels::minimumWidth() const
192{ 201{
193 return mMiniWidth; 202 return mMiniWidth;
194} 203}
195 204
196/** updates widget's internal state */ 205/** updates widget's internal state */
197void TimeLabels::updateConfig() 206void TimeLabels::updateConfig()
198{ 207{
208 mRedrawNeeded = true;
199 // set the font 209 // set the font
200 // config->setGroup("Fonts"); 210 // config->setGroup("Fonts");
201 // QFont font = config->readFontEntry("TimeBar Font"); 211 // QFont font = config->readFontEntry("TimeBar Font");
202 setFont(KOPrefs::instance()->mTimeBarFont); 212 setFont(KOPrefs::instance()->mTimeBarFont);
203 QString test = "88:88"; 213 QString test = "88:88";
204 if (KGlobal::locale()->use12Clock()) 214 if (KGlobal::locale()->use12Clock())
205 test += "i"; 215 test += "i";
206 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; 216 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ;
207 // update geometry restrictions based on new settings 217 // update geometry restrictions based on new settings
208 setFixedWidth(minimumWidth()); 218 setFixedWidth(minimumWidth());
209 219
210 // update HourSize 220 // update HourSize
211 mCellHeight = KOPrefs::instance()->mHourSize*4; 221 mCellHeight = KOPrefs::instance()->mHourSize*4;
212 resizeContents(50,mRows * mCellHeight); 222 resizeContents(50,mRows * mCellHeight);
213} 223}
214 224
215/** update time label positions */ 225/** update time label positions */
216void TimeLabels::positionChanged() 226void TimeLabels::positionChanged()
217{ 227{
218 int adjustment = mAgenda->contentsY(); 228 int adjustment = mAgenda->contentsY();
219 setContentsPos(0, adjustment); 229 setContentsPos(0, adjustment);
220} 230}
221 231
222/** */ 232/** */
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 6dc81c6..30c9b05 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -80,48 +80,50 @@ class TimeLabels : public QScrollView {
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix;
105 bool mRedrawNeeded;
104 int mMiniWidth; 106 int mMiniWidth;
105 int mMouseDownY; 107 int mMouseDownY;
106 QString mOrgCap; 108 QString mOrgCap;
107 int mRows; 109 int mRows;
108 int mCellHeight; 110 int mCellHeight;
109 111
110 /** */ 112 /** */
111 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
112}; 114};
113 115
114class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
115 Q_OBJECT 117 Q_OBJECT
116 public: 118 public:
117 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
118 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
119 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
120 122
121 void changeColumns(int columns); 123 void changeColumns(int columns);
122 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
123 void setXOffset( int ); 125 void setXOffset( int );
124 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
125 127
126 protected: 128 protected:
127 void drawContents(QPainter *); 129 void drawContents(QPainter *);
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index d543aaf..dfc6af7 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -89,48 +89,49 @@ void DynamicTip::maybeTip( const QPoint &pos )
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 mRedrawNeeded = true;
113 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 114 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
114 mPendingUpdateBeforeRepaint = false; 115 mPendingUpdateBeforeRepaint = false;
115 mouseDown = false; 116 mouseDown = false;
116 // initialize dynamic arrays 117 // initialize dynamic arrays
117 bDays.resize ( NUMDAYS ); 118 bDays.resize ( NUMDAYS );
118 hDays.resize ( NUMDAYS );; 119 hDays.resize ( NUMDAYS );;
119 eDays.resize ( NUMDAYS );; 120 eDays.resize ( NUMDAYS );;
120 days = new QDate[NUMDAYS]; 121 days = new QDate[NUMDAYS];
121 daylbls = new QString[NUMDAYS]; 122 daylbls = new QString[NUMDAYS];
122 //events = new int[NUMDAYS]; 123 //events = new int[NUMDAYS];
123 mToolTip = new DynamicTip(this); 124 mToolTip = new DynamicTip(this);
124 125
125 // set default values used for drawing the matrix 126 // set default values used for drawing the matrix
126 mDefaultBackColor = palette().active().base(); 127 mDefaultBackColor = palette().active().base();
127 mDefaultTextColor = palette().active().foreground(); 128 mDefaultTextColor = palette().active().foreground();
128 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 129 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
129 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 130 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
130 mSelectedDaysColor = QColor("white"); 131 mSelectedDaysColor = QColor("white");
131 mTodayMarginWidth = 2; 132 mTodayMarginWidth = 2;
132 mSelEnd = mSelStart = NOSELECTION; 133 mSelEnd = mSelStart = NOSELECTION;
133 134
134 setAcceptDrops(true); 135 setAcceptDrops(true);
135 //setFont( QFont("Arial", 10) ); 136 //setFont( QFont("Arial", 10) );
136 137
@@ -365,91 +366,93 @@ void KODayMatrix::updateViewTimed()
365 holiStr += "\n"; 366 holiStr += "\n";
366 holiStr += event->summary(); 367 holiStr += event->summary();
367 if ( !event->location().isEmpty() ) 368 if ( !event->location().isEmpty() )
368 holiStr += " (" + event->location() + ")"; 369 holiStr += " (" + event->location() + ")";
369 } 370 }
370 if ( event->isBirthday()) { 371 if ( event->isBirthday()) {
371 if ( !holiStr.isEmpty() ) 372 if ( !holiStr.isEmpty() )
372 holiStr += "\n"; 373 holiStr += "\n";
373 holiStr += i18n("Birthday") + ": "+event->summary(); 374 holiStr += i18n("Birthday") + ": "+event->summary();
374 if ( !event->location().isEmpty() ) 375 if ( !event->location().isEmpty() )
375 holiStr += " (" + event->location() + ")"; 376 holiStr += " (" + event->location() + ")";
376 bDays.setBit(i); 377 bDays.setBit(i);
377 } 378 }
378 } 379 }
379 if ( numEvents ) 380 if ( numEvents )
380 eDays.setBit(i); 381 eDays.setBit(i);
381 //if it is a holy day then draw it red. Sundays are consider holidays, too 382 //if it is a holy day then draw it red. Sundays are consider holidays, too
382 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 383 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
383 !holiStr.isEmpty()) { 384 !holiStr.isEmpty()) {
384 mHolidays[i] = holiStr; 385 mHolidays[i] = holiStr;
385 } else { 386 } else {
386 mHolidays[i] = QString::null; 387 mHolidays[i] = QString::null;
387 } 388 }
388 } 389 }
390 mRedrawNeeded = true;
389 if ( ! mPendingUpdateBeforeRepaint ) 391 if ( ! mPendingUpdateBeforeRepaint )
390 repaint(false); 392 repaint(false);
391} 393}
392void KODayMatrix::updateView(QDate actdate) 394void KODayMatrix::updateView(QDate actdate)
393{ 395{
394 396
395 if ( ! actdate.isValid() ) { 397 if ( ! actdate.isValid() ) {
396 //qDebug("date not valid "); 398 //qDebug("date not valid ");
397 return; 399 return;
398 } 400 }
399 mDayChanged = false; 401 mDayChanged = false;
400 //flag to indicate if the starting day of the matrix has changed by this call 402 //flag to indicate if the starting day of the matrix has changed by this call
401 //mDayChanged = false; 403 //mDayChanged = false;
402 // if a new startdate is to be set then apply Cornelius's calculation 404 // if a new startdate is to be set then apply Cornelius's calculation
403 // of the first day to be shown 405 // of the first day to be shown
404 if (actdate != startdate) { 406 if (actdate != startdate) {
405 // reset index of selection according to shift of starting date from startdate to actdate 407 // reset index of selection according to shift of starting date from startdate to actdate
406 if (mSelStart != NOSELECTION) { 408 if (mSelStart != NOSELECTION) {
407 int tmp = actdate.daysTo(startdate); 409 int tmp = actdate.daysTo(startdate);
408 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 410 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
409 // shift selection if new one would be visible at least partly ! 411 // shift selection if new one would be visible at least partly !
410 412
411 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 413 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
412 // nested if is required for next X display pushed from a different month - correction required 414 // nested if is required for next X display pushed from a different month - correction required
413 // otherwise, for month forward and backward, it must be avoided 415 // otherwise, for month forward and backward, it must be avoided
414 if( mSelStart > NUMDAYS || mSelStart < 0 ) 416 if( mSelStart > NUMDAYS || mSelStart < 0 )
415 mSelStart = mSelStart + tmp; 417 mSelStart = mSelStart + tmp;
416 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 418 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
417 mSelEnd = mSelEnd + tmp; 419 mSelEnd = mSelEnd + tmp;
418 } 420 }
419 } 421 }
420 startdate = actdate; 422 startdate = actdate;
421 mDayChanged = true; 423 mDayChanged = true;
422 recalculateToday(); 424 recalculateToday();
425 mRedrawNeeded = true;
423 } 426 }
424 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 427 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
425 if ( !isVisible() ) { 428 if ( !isVisible() ) {
426 mPendingUpdateBeforeRepaint = true; 429 mPendingUpdateBeforeRepaint = true;
427 } else { 430 } else {
428#ifdef DESKTOP_VERSION 431#ifdef DESKTOP_VERSION
429 //mRepaintTimer->start( 100 ); 432 //mRepaintTimer->start( 100 );
430 //updateViewTimed(); 433 //updateViewTimed();
431 mUpdateTimer->start( 20 ); 434 mUpdateTimer->start( 50 );
432#else 435#else
433 mRepaintTimer->start( 350 ); 436 mRepaintTimer->start( 350 );
434 mUpdateTimer->start( 1200 ); 437 mUpdateTimer->start( 1200 );
435#endif 438#endif
436 } 439 }
437} 440}
438void KODayMatrix::updateEvents() 441void KODayMatrix::updateEvents()
439{ 442{
440 if ( !mCalendar ) return; 443 if ( !mCalendar ) return;
441 444
442 for( int i = 0; i < NUMDAYS; i++ ) { 445 for( int i = 0; i < NUMDAYS; i++ ) {
443 // if events are set for the day then remember to draw it bold 446 // if events are set for the day then remember to draw it bold
444 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 447 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
445 int numEvents = eventlist.count(); 448 int numEvents = eventlist.count();
446 Event *event; 449 Event *event;
447 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 450 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
448 ushort recurType = event->doesRecur(); 451 ushort recurType = event->doesRecur();
449 452
450 if ( ( recurType == Recurrence::rDaily && 453 if ( ( recurType == Recurrence::rDaily &&
451 !KOPrefs::instance()->mDailyRecur ) || 454 !KOPrefs::instance()->mDailyRecur ) ||
452 ( recurType == Recurrence::rWeekly && 455 ( recurType == Recurrence::rWeekly &&
453 !KOPrefs::instance()->mWeeklyRecur ) ) { 456 !KOPrefs::instance()->mWeeklyRecur ) ) {
454 numEvents--; 457 numEvents--;
455 } 458 }
@@ -657,49 +660,53 @@ void KODayMatrix::dropEvent(QDropEvent *e)
657 660
658 emit eventDropped(event); 661 emit eventDropped(event);
659 } else { 662 } else {
660// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 663// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
661 e->ignore(); 664 e->ignore();
662 } 665 }
663#endif 666#endif
664} 667}
665 668
666// ---------------------------------------------------------------------------- 669// ----------------------------------------------------------------------------
667// P A I N T E V E N T H A N D L I N G 670// P A I N T E V E N T H A N D L I N G
668// ---------------------------------------------------------------------------- 671// ----------------------------------------------------------------------------
669 672
670void KODayMatrix::paintEvent(QPaintEvent * pevent) 673void KODayMatrix::paintEvent(QPaintEvent * pevent)
671{ 674{
672 675
673 if ( width() <= 0 || height() <= 0 ) 676 if ( width() <= 0 || height() <= 0 )
674 return; 677 return;
675 if ( mPendingUpdateBeforeRepaint ) { 678 if ( mPendingUpdateBeforeRepaint ) {
676 updateViewTimed(); 679 updateViewTimed();
677 mPendingUpdateBeforeRepaint = false; 680 mPendingUpdateBeforeRepaint = false;
678 } 681 }
679 if ( myPix.width() != width() || myPix.height()!=height() ) { 682 if ( myPix.width() != width() || myPix.height()!=height() ) {
680 myPix.resize(size() ); 683 myPix.resize(size() );
684 mRedrawNeeded = true;
681 } 685 }
686
687 if ( mRedrawNeeded ) {
688 //qDebug("REDRAW ");
682 QPainter p(&myPix); 689 QPainter p(&myPix);
683 p.setFont(font()); 690 p.setFont(font());
684 691
685 692
686 int dheight = daysize.height(); 693 int dheight = daysize.height();
687 int dwidth = daysize.width(); 694 int dwidth = daysize.width();
688 int row,col; 695 int row,col;
689 int selw, selh; 696 int selw, selh;
690 int xyOff = frameWidth(); 697 int xyOff = frameWidth();
691 int colModulo = (width()-2) % 7; 698 int colModulo = (width()-2) % 7;
692 int rowModulo = (height()-2) % 6; 699 int rowModulo = (height()-2) % 6;
693 //qDebug("col %d row %d ",colModulo,rowModulo ); 700 //qDebug("col %d row %d ",colModulo,rowModulo );
694 701
695 bool isRTL = KOGlobals::self()->reverseLayout(); 702 bool isRTL = KOGlobals::self()->reverseLayout();
696 703
697 // draw background and topleft frame 704 // draw background and topleft frame
698 p.fillRect(0,0,width(),height(), mDefaultBackColor); 705 p.fillRect(0,0,width(),height(), mDefaultBackColor);
699 p.setPen(mDefaultTextColor); 706 p.setPen(mDefaultTextColor);
700 p.drawRect(0, 0, width(), height()); 707 p.drawRect(0, 0, width(), height());
701 int mSelStartT = mSelStart; 708 int mSelStartT = mSelStart;
702 int mSelEndT = mSelEnd; 709 int mSelEndT = mSelEnd;
703 if ( mSelEndT >= NUMDAYS ) 710 if ( mSelEndT >= NUMDAYS )
704 mSelEndT = NUMDAYS-1; 711 mSelEndT = NUMDAYS-1;
705 // draw selected days with highlighted background color 712 // draw selected days with highlighted background color
@@ -906,50 +913,52 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
906 addCol = col - 7 + colModulo; 913 addCol = col - 7 + colModulo;
907 } 914 }
908 if ( rowModulo ) { 915 if ( rowModulo ) {
909 if ( row >= 6 - rowModulo ) 916 if ( row >= 6 - rowModulo )
910 addRow = row - 5 + rowModulo; 917 addRow = row - 5 + rowModulo;
911 } 918 }
912 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 919 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
913 ++addCol;//++addCol; 920 ++addCol;//++addCol;
914 if ( row == 0) 921 if ( row == 0)
915 addRow = 1; 922 addRow = 1;
916 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 923 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
917 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 924 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
918 925
919 // reset color to actual color 926 // reset color to actual color
920 if (!mHolidays[i].isNull()) { 927 if (!mHolidays[i].isNull()) {
921 p.setPen(actcol); 928 p.setPen(actcol);
922 } 929 }
923 // reset bold font to plain font 930 // reset bold font to plain font
924 if ( eDays.testBit(i)) { 931 if ( eDays.testBit(i)) {
925 QFont myFont = font(); 932 QFont myFont = font();
926 myFont.setBold(false); 933 myFont.setBold(false);
927 p.setFont(myFont); 934 p.setFont(myFont);
928 } 935 }
929 } 936 }
930 int off = 0;//xyOff; 937 } else {
931 bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); 938 //qDebug("NO redraw ");
932 //qDebug("ffffffffff %d ", off); 939 }
940 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
941 mRedrawNeeded = false;
933} 942}
934 943
935// ---------------------------------------------------------------------------- 944// ----------------------------------------------------------------------------
936// R E SI Z E E V E N T H A N D L I N G 945// R E SI Z E E V E N T H A N D L I N G
937// ---------------------------------------------------------------------------- 946// ----------------------------------------------------------------------------
938 947
939void KODayMatrix::resizeEvent(QResizeEvent *) 948void KODayMatrix::resizeEvent(QResizeEvent *)
940{ 949{
941 QRect sz = frameRect(); 950 QRect sz = frameRect();
942 daysize.setHeight(sz.height()*7 / NUMDAYS); 951 daysize.setHeight(sz.height()*7 / NUMDAYS);
943 daysize.setWidth(sz.width() / 7); 952 daysize.setWidth(sz.width() / 7);
944} 953}
945 954
946QSize KODayMatrix::sizeHint() const 955QSize KODayMatrix::sizeHint() const
947{ 956{
948 957
949 QFontMetrics fm ( font() ); 958 QFontMetrics fm ( font() );
950 int wid = fm.width( "30") *7+3; 959 int wid = fm.width( "30") *7+3;
951 int hei = fm.height() * 6+3; 960 int hei = fm.height() * 6+3;
952 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 961 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
953 return QSize ( wid, hei ); 962 return QSize ( wid, hei );
954 963
955} 964}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 38a7f92..731117c 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -206,48 +206,49 @@ signals:
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 bool mRedrawNeeded;
230 KODaymatrixWhatsThis* mKODaymatrixWhatsThis; 231 KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
231 bool mouseDown; 232 bool mouseDown;
232 QBitArray bDays; 233 QBitArray bDays;
233 QBitArray hDays; 234 QBitArray hDays;
234 QBitArray eDays; 235 QBitArray eDays;
235 QPixmap myPix; 236 QPixmap myPix;
236 QTimer* mUpdateTimer; 237 QTimer* mUpdateTimer;
237 QTimer* mRepaintTimer; 238 QTimer* mRepaintTimer;
238 bool mDayChanged; 239 bool mDayChanged;
239 bool mPendingUpdateBeforeRepaint; 240 bool mPendingUpdateBeforeRepaint;
240 241
241 /** returns the index of the day located at the matrix's widget (x,y) position. 242 /** returns the index of the day located at the matrix's widget (x,y) position.
242 * 243 *
243 * @param x horizontal coordinate 244 * @param x horizontal coordinate
244 * @param y vertical coordinate 245 * @param y vertical coordinate
245 */ 246 */
246 int getDayIndexFrom(int x, int y); 247 int getDayIndexFrom(int x, int y);
247 248
248 /** calculates a "shaded" color from the supplied color object. 249 /** calculates a "shaded" color from the supplied color object.
249 * (Copied from Cornelius's kdpdatebutton.cpp) 250 * (Copied from Cornelius's kdpdatebutton.cpp)
250 * 251 *
251 * @param color source based on which a shaded color should be calculated. 252 * @param color source based on which a shaded color should be calculated.
252 */ 253 */
253 QColor getShadedColor(QColor color); 254 QColor getShadedColor(QColor color);