-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 3 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 6 |
3 files changed, 6 insertions, 5 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 5941337..d4173e8 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp @@ -67,193 +67,194 @@ 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 ) ) ); } void DateNavigatorContainer::setCalendar( Calendar *cal ) { mCalendar = cal; mNavigatorView->setCalendar( cal ); KDateNavigator *n; for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { n->setCalendar( cal ); } } void DateNavigatorContainer::updateDayMatrix() { mNavigatorView->updateDayMatrix(); KDateNavigator *n; for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 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(); } } void DateNavigatorContainer::updateConfig() { mNavigatorView->updateConfig(); KDateNavigator *n; for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { n->updateConfig(); } } void DateNavigatorContainer::selectDates( const DateList &dateList ) { mNavigatorView->selectDates( dateList ); setBaseDates(); if ( mExtraViews.count() ) { KDateNavigator *view = mExtraViews.at( 0 ); view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); view->dayMatrix()->repaint(); } } 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() ) { 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->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 ); bool fontchange = false; 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; 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(); } } while ( count > ( mExtraViews.count() + 1 ) ) { KDateNavigator *n = new KDateNavigator( this ); n->setMonthSignalOffset ( mExtraViews.count()+1 ); mExtraViews.append( n ); n->setCalendar( mCalendar ); setBaseDates(); 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 ( 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; } 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 ) { 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 { diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index a5dbc5d..4b50b5a 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -22,193 +22,193 @@ */ #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); - mySizeHint = sizeHint(); + mySizeHint = sizeHintTwoButtons(); mFontChanged = false; } void KDateNavigator::changeFont ( QFont fo ) { setFont( fo ); mNavigatorBar->resetFont( fo ); } QFont KDateNavigator::yourFontHint( QSize si , bool *b) { QFont fo = KOPrefs::instance()->mDateNavigatorFont; *b = false; int fontPoint = fo.pointSize(); while ( fontPoint > 5 ) { --fontPoint; fo.setPointSize( fontPoint ); setFont( fo ); mFontChanged = true; mNavigatorBar->resetFont( fo ); QSize sh = sizeHintTwoButtons(); //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); if ( si.width() > sh.width() && si.height() > sh.height()) { *b = true; //qDebug("fooooooooooooooooooooooouuuuund "); break; } } //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); return fo; } QSize KDateNavigator::sizeHint() const { QFontMetrics fm ( font() ); QSize day = daymatrix->sizeHint(); QSize nav = mNavigatorBar->sizeHint(); int wid = fm.width( "30") + day.width()+3; int hei = fm.height() +day.height()+nav.height()+2; if ( wid < nav.width() ) wid = nav.width() ; //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); return QSize ( wid, hei ); } QSize KDateNavigator::sizeHintTwoButtons() const { QFontMetrics fm ( font() ); QSize day = daymatrix->sizeHint(); QSize nav = mNavigatorBar->sizeHintTwoButtons(); int wid = fm.width( "30") + day.width()+3; int hei = fm.height() +day.height()+nav.height()+2; if ( wid < nav.width() ) wid = nav.width() ; //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); return QSize ( wid, hei ); } 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 , bool doRepaint ) // = true { m_MthYr = date; updateDates(); updateView(); KCal::DateList dates; dates.append( date ); mNavigatorBar->selectDates( dates ); daymatrix->clearSelection(); 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 : diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 582b2ef..9baff20 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -352,203 +352,203 @@ void KODayMatrix::updateViewTimed() holiStr += event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; } if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Birthday") + ": "+event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; bDays.setBit(i); } } events[i] = numEvents; //if it is a holy day then draw it red. Sundays are consider holidays, too if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || !holiStr.isEmpty()) { mHolidays[i] = holiStr; } else { mHolidays[i] = QString::null; } } if ( ! mPendingUpdateBeforeRepaint ) repaint(false); } void KODayMatrix::updateView(QDate actdate) { if ( ! actdate.isValid() ) { //qDebug("date not valid "); return; } mDayChanged = false; //flag to indicate if the starting day of the matrix has changed by this call //mDayChanged = false; // if a new startdate is to be set then apply Cornelius's calculation // of the first day to be shown if (actdate != startdate) { // reset index of selection according to shift of starting date from startdate to actdate if (mSelStart != NOSELECTION) { int tmp = actdate.daysTo(startdate); //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; // shift selection if new one would be visible at least partly ! if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { // nested if is required for next X display pushed from a different month - correction required // otherwise, for month forward and backward, it must be avoided if( mSelStart > NUMDAYS || mSelStart < 0 ) mSelStart = mSelStart + tmp; if( mSelEnd > NUMDAYS || mSelEnd < 0 ) mSelEnd = mSelEnd + tmp; } } startdate = actdate; mDayChanged = true; recalculateToday(); } //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); if ( !isVisible() ) { mPendingUpdateBeforeRepaint = true; } else { #ifdef DESKTOP_VERSION //mRepaintTimer->start( 150 ); mUpdateTimer->start( 150 ); #else mRepaintTimer->start( 350 ); mUpdateTimer->start( 1200 ); #endif } } void KODayMatrix::updateEvents() { if ( !mCalendar ) return; for( int i = 0; i < NUMDAYS; i++ ) { // if events are set for the day then remember to draw it bold QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); int numEvents = eventlist.count(); Event *event; for( event = eventlist.first(); event != 0;event=eventlist.next()) { ushort recurType = event->doesRecur(); if ( ( recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur ) || ( recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur ) ) { numEvents--; } } events[ i ] = numEvents; } } const QDate& KODayMatrix::getDate(int offset) { if (offset < 0 || offset > NUMDAYS-1) { - qDebug("Wrong offset2 "); + qDebug("Wrong offset2 %d", offset); return days[0]; } return days[offset]; } QString KODayMatrix::getHolidayLabel(int offset) { if (offset < 0 || offset > NUMDAYS-1) { - qDebug("Wrong offset1 "); - return 0; + qDebug("Wrong offset1 %d", offset); + return QString(); } return mHolidays[offset]; } int KODayMatrix::getDayIndexFrom(int x, int y) { int colModulo = (width()-2) % 7; int rowModulo = (height()-2) % 6; #if 0 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 6 - x/daysize.width() : x/daysize.width()); #endif int xVal = (x-colModulo/2-2)/daysize.width(); int yVal = (y-rowModulo/2-2)/daysize.height(); return 7*(yVal) + xVal; } // ---------------------------------------------------------------------------- // M O U S E E V E N T H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::mousePressEvent (QMouseEvent* e) { if ( e->button() == LeftButton ) mouseDown = true; mSelStart = getDayIndexFrom(e->x(), e->y()); if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; mSelInit = mSelStart; mSelEnd = mSelStart; repaint(false); } void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) { if ( e->button() == LeftButton ) if ( ! mouseDown ) { return; } else mouseDown = false; int tmp = getDayIndexFrom(e->x(), e->y()); if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; if (mSelInit > tmp) { mSelEnd = mSelInit; if (tmp != mSelStart) { mSelStart = tmp; repaint(false); } } else { mSelStart = mSelInit; //repaint only if selection has changed if (tmp != mSelEnd) { mSelEnd = tmp; repaint(false); } } DateList daylist; if ( mSelStart < 0 ) mSelStart = 0; for (int i = mSelStart; i <= mSelEnd; i++) { daylist.append(days[i]); } emit selected((const DateList)daylist); } void KODayMatrix::mouseMoveEvent (QMouseEvent* e) { if ( ! mouseDown ) { return; } int tmp = getDayIndexFrom(e->x(), e->y()); if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; if (mSelInit > tmp) { mSelEnd = mSelInit; if (tmp != mSelStart) { mSelStart = tmp; repaint(false); } } else { mSelStart = mSelInit; //repaint only if selection has changed if (tmp != mSelEnd) { mSelEnd = tmp; repaint(false); } } |