summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp100
1 files changed, 69 insertions, 31 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index fc00828..060b4c4 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -105,13 +105,19 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
mSelectedDaysColor = QColor("white");
mTodayMarginWidth = 2;
mSelEnd = mSelStart = NOSELECTION;
setAcceptDrops(true);
//setFont( QFont("Arial", 10) );
- updateView(date);
+
+ mUpdateTimer = new QTimer( this );
+ connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
+ mRepaintTimer = new QTimer( this );
+ connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
+ mDayChanged = false;
+ updateView();
}
QColor KODayMatrix::getShadedColor(QColor color)
{
QColor shaded;
int h=0;
@@ -199,45 +205,30 @@ void KODayMatrix::recalculateToday()
}
void KODayMatrix::updateView()
{
updateView(startdate);
}
-
-void KODayMatrix::updateView(QDate actdate)
+void KODayMatrix::repaintViewTimed()
{
-
-// kdDebug() << "KODayMatrix::updateView() " << actdate.toString() << endl;
-
- //flag to indicate if the starting day of the matrix has changed by this call
- bool daychanged = 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);
- //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
- // shift selection if new one would be visible at least partly !
-
- if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
- // 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;
- }
+ qDebug("KODayMatrix::repaintViewTimed ");
+ mRepaintTimer->stop();
+ repaint(false);
}
+void KODayMatrix::updateViewTimed()
+{
- startdate = actdate;
- daychanged = true;
- }
+ mUpdateTimer->stop();
+ //QDate actdate = mPendingNewDate;
+
+ static int iii = 0;
+ qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii );
- if (daychanged) {
+ if (mDayChanged) {
recalculateToday();
+ mDayChanged = false;
}
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]);
@@ -266,27 +257,74 @@ void KODayMatrix::updateView(QDate actdate)
mHolidays[i] = holiStr;
} else {
mHolidays[i] = QString::null;
}
}
+ repaint(false);
+ }
+void KODayMatrix::updateView(QDate actdate)
+{
+
+ //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);
+ //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
+ // shift selection if new one would be visible at least partly !
+
+ if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
+ // 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;
+ }
+ qDebug("restart Timer %d", mDayChanged );
+ static int iii = 0;
+ if ( iii < 5 ) {
+ ++iii;
+ updateViewTimed();
+ } else {
+ if ( !isVisible() ) {
+ mUpdateTimer->start( 2000 );
+ } else {
+ if ( mDayChanged ) {
+ mUpdateTimer->start( 250 );
+ } else {
+ mRepaintTimer->start( 250 );
+ mUpdateTimer->start( 2000 );
+ }
+ }
+ }
+
}
const QDate& KODayMatrix::getDate(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
- kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getDate(int)" << endl;
+ qDebug("Wrong offset2 ");
return days[0];
}
return days[offset];
}
QString KODayMatrix::getHolidayLabel(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
- kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getHolidayLabel(int)" << endl;
+ qDebug("Wrong offset1 ");
return 0;
}
return mHolidays[offset];
}
int KODayMatrix::getDayIndexFrom(int x, int y)