Diffstat (limited to 'korganizer/kdatenavigator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kdatenavigator.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index ab9a40f..b097dc1 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -22,220 +22,221 @@ */ #include <qstring.h> #include <qkeycode.h> #include <qlayout.h> #include <qtimer.h> #include <qframe.h> #include <qlabel.h> #include <qapplication.h> #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, const char *name ) : QFrame(parent, name), updateTimer(0L) { setFrameStyle(QFrame::NoFrame); QDate startDate = QDate::currentDate(); QGridLayout *topLayout = new QGridLayout(this,8,8); if (! startDate.isValid()) { qDebug("KDateNavigator::invalid startdate "); startDate = QDate::currentDate(); } mMonthSignalOffset = 0; mSelectedDates.append(startDate); m_MthYr = startDate; 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 ) ), SLOT( slotMonthSelected( 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(!m_bShowWeekNums) { weeknos[i]->hide(); } weeknos[i]->installEventFilter(this); topLayout->addWidget(weeknos[i],i+2,0); } 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() ); + mySizeHint = sizeHint(); } void KDateNavigator::slotMonthSelected( int m ) { if ( m_MthYr.month() <= mMonthSignalOffset) m += 12; int mo = m - mMonthSignalOffset; emit monthSelected( m - mMonthSignalOffset ); } void KDateNavigator::setCalendar( Calendar *cal ) { daymatrix->setCalendar( cal ); } -void KDateNavigator::setBaseDate( const QDate &date ) +void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true { m_MthYr = date; updateDates(); updateView(); KCal::DateList dates; dates.append( date ); mNavigatorBar->selectDates( dates ); daymatrix->clearSelection(); - daymatrix->repaint(); + if ( doRepaint ) + daymatrix->repaint(); } void KDateNavigator::enableRollover(RolloverType r) { switch(r) { case None : if (updateTimer) { updateTimer->stop(); delete updateTimer; updateTimer=0L; } break; case FollowDay : case FollowMonth : if (!updateTimer) { updateTimer = new QTimer(this); QObject::connect(updateTimer,SIGNAL(timeout()), this,SLOT(possiblyPastMidnight())); } updateTimer->start(0,true); lastDayChecked = QDate::currentDate(); } updateRollover=r; } KDateNavigator::~KDateNavigator() { } void KDateNavigator::passedMidnight() { QDate today = QDate::currentDate(); bool emitMonth = false; if (today.month() != lastDayChecked.month()) { if (updateRollover==FollowMonth && daymatrix->isEndOfMonth()) { goNextMonth(); emitMonth=true; } } daymatrix->recalculateToday(); daymatrix->repaint(); emit dayPassed(today); if (emitMonth) { emit monthPassed(today); } } /* slot */ void KDateNavigator::possiblyPastMidnight() { if (lastDayChecked!=QDate::currentDate()) { passedMidnight(); lastDayChecked=QDate::currentDate(); } // Set the timer to go off 1 second after midnight // or after 8 minutes, whichever comes first. if (updateTimer) { QTime now = QTime::currentTime(); QTime midnight = QTime(23,59,59); int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) // .arg(now.toString()).arg(midnight.toString())); updateTimer->stop(); updateTimer->start(msecsWait,true); } } void KDateNavigator::updateDates() { // Find the first day of the week of the current month. //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); //int di = d1 - d2 + 1; dayone = dayone.addDays( -d2 + 1 ); int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); // If month begins on Monday and Monday is first day of week, // month should begin on second line. Sunday doesn't have this problem. int nextLine = ( ( m_fstDayOfWkCalsys == 1) && ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; // update the matrix dates int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |