summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp35
-rw-r--r--korganizer/datenavigatorcontainer.h2
-rw-r--r--korganizer/kodaymatrix.cpp21
3 files changed, 33 insertions, 25 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 9720146..ba97fa6 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -46,8 +46,11 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
connectNavigatorView( mNavigatorView );
//setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
mLastDisplayedDN = 0;
+ mUpdateTimer;
+ mUpdateTimer = new QTimer( this );
+ connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
}
DateNavigatorContainer::~DateNavigatorContainer()
{
@@ -134,11 +137,26 @@ void DateNavigatorContainer::setCalendar( Calendar *cal )
KDateNavigator *n = mExtraViews.at( i );
n->setCalendar( cal );
}
}
-void DateNavigatorContainer::updateDayMatrixDates()
+void DateNavigatorContainer::checkUpdateDayMatrixDates()
{
+ QDate last = lastAvailableDate();
+ QDate first = firstAvailableDate();
+ QDate selFirst = mFirstSelectedDate;
+ QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
+ if ( selFirst >= first && selLast <= last ) {
+ updateDayMatrixDates();
+ }
+ else {
+ updateDayMatrixDates();
+ emit monthSelected( mFirstSelectedDate.month() );
+ }
+}
+void DateNavigatorContainer::updateDayMatrixDates()
+{
+ mUpdateTimer->stop();
QDate fDate = mFirstSelectedDate;
QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
mNavigatorView->dayMatrix()->repaint( false );
@@ -217,22 +235,8 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
return;
}
QDate fDate = dateList.first();
QDate lDate = dateList.last();
- if ( mLastDisplayedDN <= 2 ) {
- mNavigatorView->selectDates( dateList );
- KDateNavigator *view = mExtraViews.at( 0 );
- QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 );
- view->setBaseDate( bDate, false );
- view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
- if ( mLastDisplayedDN == 2 ) {
- view = mExtraViews.at( 1 );
- bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 );
- view->setBaseDate( bDate, false );
- view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
- }
- return;
- }
//qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
//qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
updateDayMatrixDates();
@@ -371,8 +375,9 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
}
view->setGeometry( x * width,
y * height, width, height );
}
+ mUpdateTimer->start( 250 );
//updateDayMatrixDates();
}
QSize DateNavigatorContainer::minimumSizeHint() const
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index d5e5adf..df8efae 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -54,8 +54,9 @@ class DateNavigatorContainer: public QWidget
void updateView();
void updateConfig();
void updateDayMatrix();
void updateDayMatrixDates();
+ void checkUpdateDayMatrixDates();
void updateToday();
void slotMonthSelected( int month );
signals:
@@ -80,8 +81,9 @@ class DateNavigatorContainer: public QWidget
void setBaseDates();
void connectNavigatorView( KDateNavigator *v );
private:
+ QTimer* mUpdateTimer;
int mLastDisplayedDN;
QDate mFirstSelectedDate;
int mSelectedDateCount;
KDateNavigator *mNavigatorView;
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 366e8b8..59618bf 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -659,17 +659,17 @@ void KODayMatrix::dropEvent(QDropEvent *e)
// ----------------------------------------------------------------------------
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
- QRect sz = frameRect();
- if ( sz.width() <= 0 || sz.height() <= 0 )
+
+ if ( width() <= 0 || height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
- if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
- myPix.resize(sz.size() );
+ if ( myPix.width() != width() || myPix.height()!=height() ) {
+ myPix.resize(size() );
}
QPainter p(&myPix);
p.setFont(font());
@@ -678,18 +678,18 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
int dwidth = daysize.width();
int row,col;
int selw, selh;
int xyOff = frameWidth();
- int colModulo = sz.width() % 7;
- int rowModulo = sz.height() % 6;
+ int colModulo = (width()-2) % 7;
+ int rowModulo = (height()-2) % 6;
//qDebug("col %d row %d ",colModulo,rowModulo );
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
- p.fillRect(pevent->rect(), mDefaultBackColor);
+ p.fillRect(0,0,width(),height(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
- p.drawRect(0, 0, sz.width()+1, sz.height()+1);
+ p.drawRect(0, 0, width(), height());
int mSelStartT = mSelStart;
int mSelEndT = mSelEnd;
if ( mSelEndT >= NUMDAYS )
mSelEndT = NUMDAYS-1;
@@ -762,9 +762,10 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
addRow = row - 5 + rowModulo;
}
if ( row == 0)
addRow = 1;
- p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo,
+ int drawWid = width()-(col*dwidth+1+addCol2)-1;
+ p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
dheight+1, selcol);
// draw full block till last line
selh = mSelEndT/7-row;
addRow = 0;
@@ -913,9 +914,9 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
myFont.setBold(false);
p.setFont(myFont);
}
}
- int off = xyOff;
+ int off = 0;//xyOff;
bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP);
//qDebug("ffffffffff %d ", off);
}