author | zautrix <zautrix> | 2005-02-01 22:10:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-01 22:10:26 (UTC) |
commit | 8f1bdf1bd37e77ba63a1959c70cc23f6e6e499eb (patch) (side-by-side diff) | |
tree | e7a15a0425040d60f81576da5f042f4e2e988a9f /korganizer/komonthview.cpp | |
parent | 0eca34f0a8a02787dccad1b37e0c2e01af734e56 (diff) | |
download | kdepimpi-8f1bdf1bd37e77ba63a1959c70cc23f6e6e499eb.zip kdepimpi-8f1bdf1bd37e77ba63a1959c70cc23f6e6e499eb.tar.gz kdepimpi-8f1bdf1bd37e77ba63a1959c70cc23f6e6e499eb.tar.bz2 |
fixi
-rw-r--r-- | korganizer/komonthview.cpp | 163 |
1 files changed, 151 insertions, 12 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6411156..9888566 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -466,4 +466,11 @@ void MonthViewCell::insertEvent(Event *event) } } + if ( !event->doesFloat() ) { + if ( mDate == event->dtStart().date () ) + prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; + else if ( mDate == event->dtEnd().date () ) + prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; + + } text = prefix + event->summary(); mToolTip += text; @@ -568,10 +575,10 @@ void MonthViewCell::finishUpdateCell() QToolTip::add(this,mToolTip,toolTipGroup(),""); #endif - + mItemList->sort(); //setMyPalette(); setMyPalette(); QString text; bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; - if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { + if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; mLabel->resize( mLabelBigSize ); @@ -689,8 +696,8 @@ void MonthViewCell::resizeEvent ( QResizeEvent * ) } #endif - int size = height() - mLabel->height(); + int size = height() - mLabel->height() - 2; if ( size > 0 ) mItemList->verticalScrollBar()->setMaximumHeight( size ); - size = width() - mLabel->width(); + size = width() - mLabel->width() -2; if ( size > 0 ) mItemList->horizontalScrollBar()->setMaximumWidth( size ); @@ -733,5 +740,5 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) mMonthView->setSelectedCell( this ); - if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); + if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); select(); } @@ -764,5 +771,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) { - + mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); + mShowWeekView = KOPrefs::instance()->mMonthViewWeek; + if ( mShowWeekView ) + mWeekStartsMonday = true; updatePossible = false; mCells.setAutoDelete( true ); @@ -818,4 +828,6 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) } + connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), + SLOT( switchView() ) ); mContextMenu = eventPopup(); // updateConfig(); //useless here @@ -828,4 +840,12 @@ KOMonthView::~KOMonthView() delete mContextMenu; } +void KOMonthView::switchView() +{ + mShowWeekView = !mShowWeekView; + KOPrefs::instance()->mMonthViewWeek = mShowWeekView; + emit showNavigator( !mShowWeekView ); + computeLayout(); + updateConfig(); +} int KOMonthView::maxDatesHint() @@ -876,4 +896,6 @@ void KOMonthView::updateConfig() mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); + if ( mShowWeekView ) + mWeekStartsMonday = true; QFontMetrics fontmetric(mDayLabels[0]->font()); mWidthLongDayLabel = 0; @@ -981,5 +1003,8 @@ void KOMonthView::updateView() #if 1 int i; - for( i = 0; i < mCells.count(); ++i ) { + int timeSpan = mCells.size()-1; + if ( KOPrefs::instance()->mMonthViewWeek ) + timeSpan = 6; + for( i = 0; i < timeSpan + 1; ++i ) { mCells[i]->startUpdateCell(); } @@ -989,5 +1014,4 @@ void KOMonthView::updateView() QDateTime dt; bool ok; - int timeSpan = mCells.size()-1; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event @@ -1054,5 +1078,5 @@ void KOMonthView::updateView() if ( todo->hasDueDate() ) { int day = mStartDate.daysTo( todo->dtDue().date() ); - if ( day >= 0 && day < mCells.size() ) { + if ( day >= 0 && day < timeSpan + 1) { mCells[day]->insertTodo( todo ); } @@ -1060,5 +1084,5 @@ void KOMonthView::updateView() } - for( i = 0; i < mCells.count(); ++i ) { + for( i = 0; i < timeSpan+1; ++i ) { mCells[i]->finishUpdateCell(); } @@ -1089,4 +1113,114 @@ void KOMonthView::resizeEvent(QResizeEvent * e) mCells[0]->setFocus(); } +void KOMonthView::computeLayoutWeek() +{ + + int daysToShow; + bool combinedSatSun = false; + if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { + daysToShow = 6; + combinedSatSun = true; + } + int tWid = topLevelWidget()->size().width(); + int tHei = topLevelWidget()->size().height(); + + int wid = size().width();//e + int hei = size().height()-1; + + if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) + return; + + if ( wid < hei ) + daysToShow = 2; + else + daysToShow = 3; + mShowSatSunComp = true; + combinedSatSun = true; + + //qDebug("KOMonthView::computeLayout()------------------------------------ "); + QFontMetrics fm ( mWeekLabels[0]->font() ); + int weeklabelwid = fm.width( "888" ); + wid -= weeklabelwid; + + int colWid = wid / daysToShow; + int lastCol = wid - ( colWid*6 ); + int dayLabelHei = mDayLabels[0]->sizeHint().height(); + int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); + int colModulo = wid % daysToShow; + int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; + //qDebug("rowmod %d ", rowModulo); + int i; + int x,y,w,h; + x= 0; + y= 0; + w = colWid; + h = dayLabelHei ; + for ( i = 0; i < 7; i++) { + if ( i && !( i % daysToShow) && i < 6) { + y += hei/(5-daysToShow); + x = 0; + } + if ( i == daysToShow-colModulo ) + ++w; + if ( i >= 5 ) { + mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); + x -= w/2 ; + } + else + mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); + x += w; + } + x= 0; + y= dayLabelHei; + w = colWid; + h = cellHei; + for ( i = 0; i < mCells.count(); ++i) { + if ( i > 6 ) { + mCells[i]->hide(); + continue; + } + + w = colWid; + if ( ((i) % daysToShow) >= daysToShow-colModulo ) { + ++w; + } + if ( i == (daysToShow-1-rowModulo)*7) + ++h; + + if ( i >= 5 ) { + if ( i ==5 ) { + mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); + x -= w ;y += h/2; + } else { + mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); + y -= h/2; + } + } else + mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); + + + x += w; + if ( x + w/2 > wid ) { + x = 0; + y += h+dayLabelHei ; + } + } + y= dayLabelHei; + h = cellHei ; + mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); + for ( i = 1; i < 6; i++) { + mWeekLabels[i]->hide(); + } + mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); + // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); + //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); + mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; + updateDayLabels(); + bool forceUpdate = !updatePossible; + updatePossible = true; + mWeekLabels[mNumWeeks]->setText( i18n("M")); + if ( forceUpdate ) + updateView(); +} void KOMonthView::computeLayout() { @@ -1095,5 +1229,8 @@ void KOMonthView::computeLayout() // threshold between big enough to support the full name and not big // enough. - + if ( mShowWeekView ){ + computeLayoutWeek(); + return; + } int daysToShow = 7; bool combinedSatSun = false; @@ -1147,5 +1284,5 @@ void KOMonthView::computeLayout() h = cellHei ; for ( i = 0; i < mCells.count(); ++i) { - + mCells[i]->show(); w = colWid; if ( ((i) % 7) >= 7-colModulo ) { @@ -1178,4 +1315,5 @@ void KOMonthView::computeLayout() h = cellHei ; for ( i = 0; i < 6; i++) { + mWeekLabels[i]->show(); if ( i == (6-rowModulo)) ++h; @@ -1190,4 +1328,5 @@ void KOMonthView::computeLayout() bool forceUpdate = !updatePossible; updatePossible = true; + mWeekLabels[mNumWeeks]->setText( i18n("W")); if ( forceUpdate ) updateView(); |