summaryrefslogtreecommitdiffabout
path: root/korganizer/datenavigatorcontainer.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 9720146..ba97fa6 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -26,48 +26,51 @@
#include <kdebug.h>
#include <klocale.h>
//#include "koglobals.h"
#include "navigatorbar.h"
#include "kdatenavigator.h"
#include <kcalendarsystem.h>
#include "datenavigatorcontainer.h"
#include "koprefs.h"
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 & ) ),
SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
#endif
connect( v, SIGNAL( weekClicked( const QDate & ) ),
SIGNAL( weekClicked( const QDate & ) ) );
connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
@@ -114,51 +117,66 @@ void DateNavigatorContainer::slotMonthSelected( int month )
QDate last = lastAvailableDate();
QDate first = firstAvailableDate();
QDate selFirst = mFirstSelectedDate;
QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
if ( selFirst >= first && selLast <= last ) {
setBaseDates();
updateDayMatrixDates();
}
else {
setBaseDates();
updateDayMatrixDates();
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::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 );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
n->dayMatrix()->repaint( false );
}
}
}
void DateNavigatorContainer::updateDayMatrix()
{
mNavigatorView->updateDayMatrix();
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
n->updateDayMatrix();
}
}
void DateNavigatorContainer::updateToday()
{
qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
@@ -197,62 +215,48 @@ QDate DateNavigatorContainer::lastAvailableDate() const
last = last.addDays( 1);
while ( iii ) {
last = last.addDays( last.daysInMonth ());
//qDebug("DATE %s ", last.toString().latin1() );
--iii;
}
if ( mLastDisplayedDN )
last = last.addDays( -1);
return last;
}
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 );
if ( mLastDisplayedDN > 1 ) {
KDateNavigator *view = mExtraViews.at( 1 );
view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
view->dayMatrix()->repaint( false );
}
}
}
void DateNavigatorContainer::setBaseDates()
{
QDate baseDate = mNavigatorView->baseDate();
bool doRepaint = true;
@@ -351,36 +355,37 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
//qDebug("COUNT %d ", mExtraViews.count());
int height = size().height() / verticalCount;
int width = size().width() / horizontalCount;
NavigatorBar *bar = mNavigatorView->navigatorBar();
if ( horizontalCount > 1 ) bar->showButtons( true, false );
else bar->showButtons( true, true );
mNavigatorView->setGeometry(0,
0, width, height );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
int x = ( i + 1 ) % horizontalCount;
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();
}