author | zautrix <zautrix> | 2005-03-22 12:05:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-22 12:05:42 (UTC) |
commit | 345c70e057e730850493689185b5c358607566f9 (patch) (side-by-side diff) | |
tree | 5081ceed28a61012c1c4d2c7200205fdbedc6435 /korganizer/datenavigatorcontainer.cpp | |
parent | dfd7d8d53c7ab916dee820c2371195a5dce134a4 (diff) | |
download | kdepimpi-345c70e057e730850493689185b5c358607566f9.zip kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.gz kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.bz2 |
more layout fixes
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 83 |
1 files changed, 63 insertions, 20 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 18756f0..bb27bce 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp @@ -25,153 +25,191 @@ #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) ); + mDisplayedEndDate = QDate::currentDate(); + mLastDisplayedDN = 0; } 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() ) ); connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); } void DateNavigatorContainer::setCalendar( Calendar *cal ) { mCalendar = cal; mNavigatorView->setCalendar( cal ); - KDateNavigator *n; - for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { - n->setCalendar( cal ); + for( uint i = 0; i < mLastDisplayedDN; ++i ) { + KDateNavigator *n = mExtraViews.at( i ); + n->setCalendar( cal ); } } void DateNavigatorContainer::updateDayMatrix() { mNavigatorView->updateDayMatrix(); - KDateNavigator *n; - for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { - n->updateDayMatrix(); + for( uint i = 0; i < mLastDisplayedDN; ++i ) { + KDateNavigator *n = mExtraViews.at( i ); + n->updateDayMatrix(); } } void DateNavigatorContainer::updateToday() { qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); #if 0 mNavigatorView->updateToday(); KDateNavigator *n; for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { n->updateToday(); } #endif } void DateNavigatorContainer::updateView() { mNavigatorView->updateView(); - KDateNavigator *n; - for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { - n->updateView(); + for( uint i = 0; i < mLastDisplayedDN; ++i ) { + KDateNavigator *n = mExtraViews.at( i ); + n->updateView(); } } void DateNavigatorContainer::updateConfig() { mNavigatorView->updateConfig(); - KDateNavigator *n; - for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { - n->updateConfig(); + for( uint i = 0; i < mLastDisplayedDN; ++i ) { + KDateNavigator *n = mExtraViews.at( i ); + n->updateConfig(); } } void DateNavigatorContainer::selectDates( const DateList &dateList ) { - mNavigatorView->selectDates( dateList ); - setBaseDates(); - if ( mExtraViews.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; + } + KDateNavigator *view = mExtraViews.at( 0 ); + QDate date = view->baseDate(); + + QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7); + //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); + if ( lDate < curEnd && date.addDays( -30 ) < fDate) { + 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 ); + } + } + return; + } + mNavigatorView->selectDates( dateList ); + setBaseDates(); + if ( mLastDisplayedDN ) { KDateNavigator *view = mExtraViews.at( 0 ); view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); view->dayMatrix()->repaint( false ); - if ( mExtraViews.count() > 1 ) { + if ( mLastDisplayedDN > 1 ) { KDateNavigator *view = mExtraViews.at( 1 ); view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); view->dayMatrix()->repaint( false ); } } } void DateNavigatorContainer::setBaseDates() { KCal::DateList dateList = mNavigatorView->selectedDates(); if ( dateList.isEmpty() ) { kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; } QDate baseDate = dateList.first(); - KDateNavigator *n; bool doRepaint = false; // skip first repaint - for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { + for( uint i = 0; i < mLastDisplayedDN; ++i ) { + KDateNavigator *n = mExtraViews.at( i ); baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); n->setBaseDate( baseDate, doRepaint ); doRepaint = true; } } void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) { #if 0 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; kdDebug(5850) << " CURRENT SIZE: " << size() << endl; kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; #endif //QSize minSize = mNavigatorView->sizeHintTwoButtons(); QSize minSize = mNavigatorView->yourSizeHint(); // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; int verticalCount = size().height() / minSize.height(); int horizontalCount = size().width() / minSize.width(); //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); @@ -190,87 +228,92 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) // return; int butt = 2; horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); if ( horizontalCount <= 1 ) minSize = mNavigatorView->sizeHintTwoButtons( 4 ); else minSize = mNavigatorView->sizeHintTwoButtons(); verticalCount = size().height() / minSize.height(); horizontalCount = size().width() / minSize.width(); if ( horizontalCount == 0 ) horizontalCount = 1; if ( verticalCount == 0 ) verticalCount = 1; fontchange = true; count = horizontalCount * verticalCount; } else { if ( mNavigatorView->fontChanged() ) { fontchange = true; fo = KOPrefs::instance()->mDateNavigatorFont; mNavigatorView->changeFont( fo ); mNavigatorView->unsetFontChanged(); } } + mLastDisplayedDN = horizontalCount*verticalCount-1; + bool setBaseD = false; while ( count > ( mExtraViews.count() + 1 ) ) { KDateNavigator *n = new KDateNavigator( this ); n->setMonthSignalOffset ( mExtraViews.count()+1 ); mExtraViews.append( n ); n->setCalendar( mCalendar ); - setBaseDates(); + setBaseD = true; connectNavigatorView( n ); n->show(); } int iii = 0; while ( iii < ( mExtraViews.count() ) ) { if ( iii < count-1 ) mExtraViews.at( iii )->show(); else mExtraViews.at( iii )->hide(); ++iii; } + if ( setBaseD ) + setBaseDates(); if ( fontchange ) { //mNavigatorView->changeFont( fo ); uint i; for( i = 0; i < mExtraViews.count(); ++i ) { KDateNavigator *view = mExtraViews.at( i ); view->changeFont( fo ); } } mHorizontalCount = horizontalCount; mVerticalCount = verticalCount; + } //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 < mExtraViews.count(); ++i ) { + 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 ); } } QSize DateNavigatorContainer::minimumSizeHint() const { return mNavigatorView->minimumSizeHint(); } QSize DateNavigatorContainer::sizeHint() const { return mNavigatorView->yourSizeHint(); } |