-rw-r--r-- | korganizer/kodaymatrix.cpp | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 9c3621e..be5a775 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -19,7 +19,7 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. + without including the source ode for Qt in the source distribution. */ #include <qevent.h> @@ -91,6 +91,7 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const QFrame(parent, name) { mCalendar = calendar; + mPendingUpdateBeforeRepaint = false; // initialize dynamic arrays days = new QDate[NUMDAYS]; @@ -191,6 +192,7 @@ void KODayMatrix::recalculateToday() { today = -1; for (int i=0; i<NUMDAYS; i++) { + events[i] = 0; days[i] = startdate.addDays(i); daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); @@ -210,7 +212,7 @@ void KODayMatrix::updateView() } void KODayMatrix::repaintViewTimed() { - qDebug("KODayMatrix::repaintViewTimed "); + //qDebug("KODayMatrix::repaintViewTimed "); mRepaintTimer->stop(); repaint(false); } @@ -218,16 +220,7 @@ void KODayMatrix::updateViewTimed() { mUpdateTimer->stop(); - //QDate actdate = mPendingNewDate; - - static int iii = 0; - qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); - - if (mDayChanged) { - recalculateToday(); - mDayChanged = false; - } - + //qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); for(int i = 0; i < NUMDAYS; i++) { // if events are set for the day then remember to draw it bold @@ -260,11 +253,17 @@ void KODayMatrix::updateViewTimed() mHolidays[i] = QString::null; } } + if ( ! mPendingUpdateBeforeRepaint ) repaint(false); } void KODayMatrix::updateView(QDate actdate) { + if ( ! actdate.isValid() ) { + //qDebug("date not valid "); + return; + } + mDayChanged = false; //flag to indicate if the starting day of the matrix has changed by this call //mDayChanged = false; // if a new startdate is to be set then apply Cornelius's calculation @@ -285,29 +284,22 @@ void KODayMatrix::updateView(QDate actdate) mSelEnd = mSelEnd + tmp; } } - startdate = actdate; mDayChanged = true; + recalculateToday(); } - qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); - static int iii = 0; - if ( iii < 2 ) { - ++iii; - updateViewTimed(); - } else { + //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); if ( !isVisible() ) { - mUpdateTimer->start( 2000 ); - } else { - if ( mDayChanged ) { - mUpdateTimer->start( 250 ); + mPendingUpdateBeforeRepaint = true; } else { mRepaintTimer->start( 250 ); +#ifdef DESKTOP_VERSION mUpdateTimer->start( 2000 ); +#else + mUpdateTimer->start( 4000 ); +#endif } } - } - -} const QDate& KODayMatrix::getDate(int offset) { @@ -495,7 +487,10 @@ void KODayMatrix::dropEvent(QDropEvent *e) void KODayMatrix::paintEvent(QPaintEvent * pevent) { //kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; - + if ( mPendingUpdateBeforeRepaint ) { + updateViewTimed(); + mPendingUpdateBeforeRepaint = false; + } QPainter p(this); QRect sz = frameRect(); |