summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore 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
@@ -38,24 +38,27 @@
DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
const char *name )
: QWidget( parent, name ), mCalendar( 0 ),
mHorizontalCount( 1 ), mVerticalCount( 1 )
{
mExtraViews.setAutoDelete( true );
mNavigatorView = new KDateNavigator( this, name );
connectNavigatorView( mNavigatorView );
//setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
mLastDisplayedDN = 0;
+ mUpdateTimer;
+ mUpdateTimer = new QTimer( this );
+ connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
}
DateNavigatorContainer::~DateNavigatorContainer()
{
}
void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
{
connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
SIGNAL( datesSelected( const KCal::DateList & ) ) );
#if 0
connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
@@ -126,27 +129,42 @@ void DateNavigatorContainer::slotMonthSelected( int month )
emit monthSelected( month );
}
}
void DateNavigatorContainer::setCalendar( Calendar *cal )
{
mCalendar = cal;
mNavigatorView->setCalendar( cal );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
n->setCalendar( cal );
}
}
+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 );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
n->dayMatrix()->repaint( false );
}
}
}
@@ -209,38 +227,24 @@ QDate DateNavigatorContainer::firstAvailableDate() const
return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
}
void DateNavigatorContainer::selectDates( const DateList &dateList )
{
mFirstSelectedDate = dateList.first() ;
mSelectedDateCount = dateList.count() ;
if ( !mLastDisplayedDN ) {
mNavigatorView->selectDates( 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();
return;
}
mNavigatorView->selectDates( dateList );
setBaseDates();
if ( mLastDisplayedDN ) {
KDateNavigator *view = mExtraViews.at( 0 );
view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
view->dayMatrix()->repaint( false );
@@ -363,24 +367,25 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
int y = ( i + 1 ) / horizontalCount;
KDateNavigator *view = mExtraViews.at( i );
bar = view->navigatorBar();
if ( y > 0 ) bar->showButtons( false, false );
else {
if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
else bar->showButtons( false, false );
}
view->setGeometry( x * width,
y * height, width, height );
}
+ mUpdateTimer->start( 250 );
//updateDayMatrixDates();
}
QSize DateNavigatorContainer::minimumSizeHint() const
{
return mNavigatorView->minimumSizeHint();
}
QSize DateNavigatorContainer::sizeHint() const
{
return mNavigatorView->yourSizeHint();
}
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index d5e5adf..df8efae 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -46,24 +46,25 @@ class DateNavigatorContainer: public QWidget
QSize minimumSizeHint() const;
QSize sizeHint() const;
KDateNavigator * navigatorView() { return mNavigatorView;}
QDate lastAvailableDate() const ;
QDate firstAvailableDate() const ;
public slots:
void selectDates( const KCal::DateList & );
void updateView();
void updateConfig();
void updateDayMatrix();
void updateDayMatrixDates();
+ void checkUpdateDayMatrixDates();
void updateToday();
void slotMonthSelected( int month );
signals:
void datesSelected( const KCal::DateList & );
void incidenceDropped( Incidence *, const QDate & );
void incidenceDroppedMove( Incidence *, const QDate & );
void weekClicked( const QDate &);
void goPrevious();
void goNext();
@@ -72,24 +73,25 @@ class DateNavigatorContainer: public QWidget
void goNextYear();
void goPrevYear();
void monthSelected( int month );
protected:
void resizeEvent( QResizeEvent * );
void setBaseDates();
void connectNavigatorView( KDateNavigator *v );
private:
+ QTimer* mUpdateTimer;
int mLastDisplayedDN;
QDate mFirstSelectedDate;
int mSelectedDateCount;
KDateNavigator *mNavigatorView;
KCal::Calendar *mCalendar;
QPtrList<KDateNavigator> mExtraViews;
int mHorizontalCount;
int mVerticalCount;
};
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 366e8b8..59618bf 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -651,53 +651,53 @@ void KODayMatrix::dropEvent(QDropEvent *e)
// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
e->ignore();
}
#endif
}
// ----------------------------------------------------------------------------
// P A I N T E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
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());
int dheight = daysize.height();
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;
// draw selected days with highlighted background color
if (mSelStart != NOSELECTION) {
bool skip = false;
if ( ! mouseDown ) {
int mo = days[20].month();
//qDebug("-- %d %d ", mSelStartT, mSelEndT);
//qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
int startMo = days[mSelStartT].month();
@@ -754,25 +754,26 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
} else {
// draw first row to the right
if ( colModulo ) {
if ( col >= 7 - colModulo )
addCol2 = col - 7 + colModulo;
}
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
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;
if ( rowModulo ) {
if ( mSelEndT/7 >= 6 - rowModulo )
addRow = mSelEndT/7 - 5 + rowModulo;
}
if (selh > 1) {
p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
}
// draw last block from left to mSelEndT
@@ -905,25 +906,25 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
// reset color to actual color
if (!mHolidays[i].isNull()) {
p.setPen(actcol);
}
// reset bold font to plain font
if (events[i] > 0) {
QFont myFont = font();
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);
}
// ----------------------------------------------------------------------------
// R E SI Z E E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::resizeEvent(QResizeEvent *)
{
QRect sz = frameRect();
daysize.setHeight(sz.height()*7 / NUMDAYS);