Diffstat (limited to 'korganizer/kdatenavigator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kdatenavigator.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index c08f44f..e76a85a 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -32,108 +32,122 @@ #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include "koglobals.h" #include "koprefs.h" #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include <kcalendarsystem.h> #include "navigatorbar.h" #include "kdatenavigator.h" -KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, - bool show_week_nums, const char *name, - QDate startDate ) +KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) : QFrame(parent, name), updateTimer(0L) { - mCalendar = calendar; - - setFrameStyle(QFrame::NoFrame); - + setFrameStyle(QFrame::NoFrame); + QDate startDate = QDate::currentDate(); QGridLayout *topLayout = new QGridLayout(this,8,8); if (! startDate.isValid()) { qDebug("KDateNavigator::invalid startdate "); startDate = QDate::currentDate(); } mSelectedDates.append(startDate); m_MthYr = startDate; - m_bShowWeekNums = show_week_nums; + m_bShowWeekNums = true; setFont( KOPrefs::instance()->mDateNavigatorFont ); mNavigatorBar = new NavigatorBar( startDate, this ); topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); //mNavigatorBar->resize( 1,1); connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); // get the day of the week on the first day QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); m_fstDayOfWk = dayone.dayOfWeek(); int i; // Set up the heading fields. for( i = 0; i < 7; i++ ) { headings[i] = new QLabel("",this); //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); headings[i]->setAlignment(AlignCenter); topLayout->addWidget(headings[i],1,i+1); } // Create the weeknumber labels for( i = 0; i < 6; i++ ) { weeknos[i] = new QLabel(this); weeknos[i]->setAlignment(AlignCenter); //weeknos[i]->setFont(QFont("Arial", 10)); - if(!show_week_nums) { + if(!m_bShowWeekNums) { weeknos[i]->hide(); } weeknos[i]->installEventFilter(this); topLayout->addWidget(weeknos[i],i+2,0); } - daymatrix = new KODayMatrix( this, mCalendar, dayone, - "KDateNavigator::DayMatrix"); + daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); daymatrix->setLineWidth(1); connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), SIGNAL( datesSelected( const KCal::DateList & ) ) ); connect( daymatrix, SIGNAL( eventDropped( Event * ) ), SIGNAL( eventDropped( Event * ) ) ); topLayout->addMultiCellWidget(daymatrix,2,7,1,7); // read settings from configuration file. updateConfig(); enableRollover(FollowMonth); - setFixedSize ( sizeHint() ); + //setFixedSize ( sizeHint() ); +} +void KDateNavigator::setCalendar( Calendar *cal ) +{ + daymatrix->setCalendar( cal ); +} + +void KDateNavigator::setBaseDate( const QDate &date ) +{ + m_MthYr = date; + + updateDates(); + updateView(); + + KCal::DateList dates; + dates.append( date ); + mNavigatorBar->selectDates( dates ); + + daymatrix->clearSelection(); + daymatrix->repaint(); } void KDateNavigator::enableRollover(RolloverType r) { switch(r) { case None : if (updateTimer) { updateTimer->stop(); delete updateTimer; updateTimer=0L; } break; case FollowDay : case FollowMonth : |