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.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 548c364..d1caff3 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -5,195 +5,197 @@
Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#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() ));
+ mFirstSelectedDate = QDate::currentDate();
+ mSelectedDateCount = 1;
}
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 ) ), 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::checkUpdateDayMatrixDates()
{
- qDebug("wid %d hei %d ", width(), height());
+ //qDebug("KODNC: wid %d hei %d ", width(), height());
mUpdateTimer->stop();
//return;
if ( width() < 3 || height() < 3 )
return;
static int lastWid = 0;
static int lastHei = 0;
if ( lastWid == width() && height() == lastHei ) {
- qDebug("no layout computing needed. ");
+ qDebug("KODNC: No layout computing needed. ");
} else {
lastWid = width();
lastHei = height();
QSize minSize = mNavigatorView->yourSizeHint();
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 );
bool fontchange = false;
if ( horizontalCount == 1)
horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
QFont fo;
if ( horizontalCount != mHorizontalCount ||
verticalCount != mVerticalCount ) {
uint count = horizontalCount * verticalCount;
if ( count == 0 ) {
bool ok;
fo = mNavigatorView->yourFontHint( size() , &ok );
//mNavigatorView->resize( size() );
//if ( ! ok )
// 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;
while ( count > ( mExtraViews.count() + 1 ) ) {