-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 57 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 1 |
3 files changed, 29 insertions, 31 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 8b79788..8e9add3 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1502,16 +1502,18 @@ void KOAgendaView::scrollOneHourDown() void KOAgendaView::setStartHour( int h ) { mAgenda->setStartHour( h ); } void KOAgendaView::updateTodo( Todo * t, int ) { + if ( !isVisible() ) + return; bool remove = false; bool removeAD = false; QDate da; if ( t->hasCompletedDate() ) da = t->completed().date(); else da = t->dtDue().date(); if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 9c3621e..be5a775 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -14,17 +14,17 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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> #include <qpainter.h> #include <qptrlist.h> #include <qtimer.h> #include <kglobal.h> @@ -86,16 +86,17 @@ void DynamicTip::maybeTip( const QPoint &pos ) const int KODayMatrix::NOSELECTION = -1000; const int KODayMatrix::NUMDAYS = 42; KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : QFrame(parent, name) { mCalendar = calendar; + mPendingUpdateBeforeRepaint = false; // initialize dynamic arrays days = new QDate[NUMDAYS]; daylbls = new QString[NUMDAYS]; events = new int[NUMDAYS]; mToolTip = new DynamicTip(this); // set default values used for drawing the matrix @@ -186,16 +187,17 @@ void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) mSelEnd = startdate.daysTo(end); } 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] )); // if today is in the currently displayed month, hilight today if (days[i].year() == QDate::currentDate().year() && days[i].month() == QDate::currentDate().month() && days[i].day() == QDate::currentDate().day()) { today = i; @@ -205,34 +207,25 @@ void KODayMatrix::recalculateToday() } void KODayMatrix::updateView() { updateView(startdate); } void KODayMatrix::repaintViewTimed() { - qDebug("KODayMatrix::repaintViewTimed "); + //qDebug("KODayMatrix::repaintViewTimed "); mRepaintTimer->stop(); repaint(false); } 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 QPtrList<Event> eventlist = mCalendar->events(days[i]); Event *event; int numEvents = eventlist.count(); for(event=eventlist.first();event != 0;event=eventlist.next()) { @@ -255,21 +248,27 @@ void KODayMatrix::updateViewTimed() !holiStr.isEmpty()) { if (holiStr.isNull()) holiStr = ""; mHolidays[i] = holiStr; } else { mHolidays[i] = QString::null; } } - repaint(false); + 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 // of the first day to be shown if (actdate != startdate) { // reset index of selection according to shift of starting date from startdate to actdate if (mSelStart != NOSELECTION) { int tmp = actdate.daysTo(startdate); @@ -280,38 +279,31 @@ void KODayMatrix::updateView(QDate actdate) // nested if is required for next X display pushed from a different month - correction required // otherwise, for month forward and backward, it must be avoided if( mSelStart > NUMDAYS || mSelStart < 0 ) mSelStart = mSelStart + tmp; if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 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(); + //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); + if ( !isVisible() ) { + mPendingUpdateBeforeRepaint = true; } else { - if ( !isVisible() ) { - mUpdateTimer->start( 2000 ); - } else { - if ( mDayChanged ) { - mUpdateTimer->start( 250 ); - } else { - mRepaintTimer->start( 250 ); - mUpdateTimer->start( 2000 ); - } - } + mRepaintTimer->start( 250 ); +#ifdef DESKTOP_VERSION + mUpdateTimer->start( 2000 ); +#else + mUpdateTimer->start( 4000 ); +#endif } - } const QDate& KODayMatrix::getDate(int offset) { if (offset < 0 || offset > NUMDAYS-1) { qDebug("Wrong offset2 "); return days[0]; } @@ -490,17 +482,20 @@ void KODayMatrix::dropEvent(QDropEvent *e) // ---------------------------------------------------------------------------- // P A I N T E V E N T H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::paintEvent(QPaintEvent * pevent) { //kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; - + if ( mPendingUpdateBeforeRepaint ) { + updateViewTimed(); + mPendingUpdateBeforeRepaint = false; + } QPainter p(this); QRect sz = frameRect(); int dheight = daysize.height(); int dwidth = daysize.width(); int row,col; int selw, selh; bool isRTL = KOGlobals::self()->reverseLayout(); diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 0e9640a..ac2f59c 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h @@ -219,16 +219,17 @@ protected: void dropEvent(QDropEvent *); void resizeEvent(QResizeEvent *); private: QTimer* mUpdateTimer; QTimer* mRepaintTimer; bool mDayChanged; + bool mPendingUpdateBeforeRepaint; /** returns the index of the day located at the matrix's widget (x,y) position. * * @param x horizontal coordinate * @param y vertical coordinate */ int getDayIndexFrom(int x, int y); |