summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-22 14:37:47 (UTC)
committer zautrix <zautrix>2005-03-22 14:37:47 (UTC)
commit03b3e902ed6362d8f72d0acfc5a9be9d9ee1ef21 (patch) (side-by-side diff)
tree0c3f06e4a3c73acebd8b9f80271010ee5b8d26e1
parent345c70e057e730850493689185b5c358607566f9 (diff)
downloadkdepimpi-03b3e902ed6362d8f72d0acfc5a9be9d9ee1ef21.zip
kdepimpi-03b3e902ed6362d8f72d0acfc5a9be9d9ee1ef21.tar.gz
kdepimpi-03b3e902ed6362d8f72d0acfc5a9be9d9ee1ef21.tar.bz2
more layout fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp114
-rw-r--r--korganizer/datenavigatorcontainer.h7
-rw-r--r--korganizer/kdatenavigator.cpp1
3 files changed, 98 insertions, 24 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index bb27bce..6de7c45 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -41,17 +41,16 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
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 )
@@ -70,28 +69,91 @@ void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
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 ) ) );
+ connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
}
+void DateNavigatorContainer::slotMonthSelected( int month )
+{
+ //qDebug("slotMonthSelected %d ", month);
+ QDate baseDate = mNavigatorView->baseDate();
+ if ( baseDate.month() == month )
+ return;
+ //qDebug("month %d %d ",baseDate.month(),month);
+ QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
+ date = date.addDays( -(baseDate.month()-month ) *30 );
+ QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
+
+#if 0
+ mFirstSelectedDate = dateList.first() ;
+ mSelectedDateCount = dateList.count() ;
+
+ 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;
+ }
+#endif
+ //qDebug("NEW BASE %s", newBase.toString().latin1());
+ mNavigatorView->setBaseDate( newBase );
+ 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()
+{
+
+ 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();
}
@@ -121,19 +183,40 @@ void DateNavigatorContainer::updateView()
void DateNavigatorContainer::updateConfig()
{
mNavigatorView->updateConfig();
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
n->updateConfig();
}
}
-
+QDate DateNavigatorContainer::lastAvailableDate() const
+{
+ QDate date = mNavigatorView->baseDate();
+ QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
+ int iii = mLastDisplayedDN;
+ if ( mLastDisplayedDN )
+ 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 );
@@ -144,30 +227,20 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
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("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
//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 );
- }
- }
+ 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 );
@@ -176,27 +249,22 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
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();
- bool doRepaint = false; // skip first repaint
+ QDate baseDate = mNavigatorView->baseDate();
+ bool doRepaint = true;
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;
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index f45af20..d5e5adf 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -41,23 +41,27 @@ class DateNavigatorContainer: public QWidget
/**
Associate date navigator with a calendar. It is used by KODayMatrix.
*/
void setCalendar( Calendar * );
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 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();
@@ -73,17 +77,18 @@ class DateNavigatorContainer: public QWidget
protected:
void resizeEvent( QResizeEvent * );
void setBaseDates();
void connectNavigatorView( KDateNavigator *v );
private:
int mLastDisplayedDN;
- QDate mDisplayedEndDate;
+ QDate mFirstSelectedDate;
+ int mSelectedDateCount;
KDateNavigator *mNavigatorView;
KCal::Calendar *mCalendar;
QPtrList<KDateNavigator> mExtraViews;
int mHorizontalCount;
int mVerticalCount;
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 231095f..83a57ca 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -185,16 +185,17 @@ void KDateNavigator::slotMonthSelected( int m )
void KDateNavigator::setCalendar( Calendar *cal )
{
daymatrix->setCalendar( cal );
}
void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
{
m_MthYr = date;
+ //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
updateDates();
updateView();
KCal::DateList dates;
dates.append( date );
mNavigatorBar->selectDates( dates );