-rw-r--r-- | korganizer/komonthview.cpp | 124 |
1 files changed, 95 insertions, 29 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 2289977..53bbe28 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -1525,5 +1525,6 @@ void KOMonthView::updateConfig() if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) computeLayout(); - } + } else + doComputeLayoutWeek(); updateDayLabels(); //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); @@ -1816,5 +1817,6 @@ void KOMonthView::resizeEvent(QResizeEvent * e) } else mComputeLayoutTimer->start( 100 ); - KOEventView::resizeEvent( e ); + if ( e ) + KOEventView::resizeEvent( e ); } @@ -1827,8 +1829,8 @@ void KOMonthView::slotComputeLayout() setKeyBFocus(); } -void KOMonthView::computeLayoutWeek() + +void KOMonthView::doComputeLayoutWeek() { - static int lastWid = 0; - static int lastHei = 0; + int daysToShow; bool combinedSatSun = false; @@ -1837,25 +1839,15 @@ void KOMonthView::computeLayoutWeek() combinedSatSun = true; } - int tWid = topLevelWidget()->size().width(); - int tHei = topLevelWidget()->size().height(); - int wid = width();//e int hei = height()-1-mNavigatorBar->height(); - - if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) - return; - - if ( lastWid == width() && lastHei == height() ) { - //qDebug("KOListWeekView::No compute layout needed "); - return; - } - lastWid = width(); - lastHei = height(); - - - if ( wid < hei ) + if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { daysToShow = 2; - else - daysToShow = 3; + } else { + if ( wid < hei ) + daysToShow = 2; + else + daysToShow = 3; + } + bool landscape = (daysToShow == 3); mShowSatSunComp = true; combinedSatSun = true; @@ -1887,10 +1879,17 @@ void KOMonthView::computeLayoutWeek() ++w; } + int xC,yC,wC,hC; if ( i >= 5 ) { int wi = width() - x - weeklabelwid; if ( i == 5 ) { - mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); + xC = x+weeklabelwid; + yC = y; + wC = wi/2+wi%2; + hC = h; } else { - mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); + xC = x+weeklabelwid; + yC = y; + wC = wi; + hC = h; } x = x - w + wi - (wi/2 ); @@ -1901,6 +1900,12 @@ void KOMonthView::computeLayoutWeek() wi = width() - x - weeklabelwid; } - mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); + xC = x+weeklabelwid; + yC = y; + wC = wi; + hC = h; } + mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); + + x += w; } @@ -1924,8 +1929,12 @@ void KOMonthView::computeLayoutWeek() ++h; + int xC,yC,wC,hC; if ( i >= 5 ) { if ( i ==5 ) { max = h/2; - mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); + xC = x+weeklabelwid; + yC = y; + wC = w; + hC = max; x -= w ;y += h/2; } else { @@ -1934,11 +1943,18 @@ void KOMonthView::computeLayoutWeek() } max = h-h/2; - mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); + xC = x+weeklabelwid; + yC = y; + wC = w; + hC = max; y -= h/2; } } else { max = h; - mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); + xC = x+weeklabelwid; + yC = y; + wC = w; + hC = h; } + mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); @@ -1964,4 +1980,54 @@ void KOMonthView::computeLayoutWeek() // updateView(); } +void KOMonthView::computeLayoutWeek() +{ + static int lastWid = 0; + static int lastHei = 0; + int tWid = topLevelWidget()->size().width(); + int tHei = topLevelWidget()->size().height(); + int wid = width();//e + int hei = height()-1-mNavigatorBar->height(); + if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) + return; + + if ( lastWid == width() && lastHei == height() ) { + //qDebug("KOListWeekView::No compute layout needed "); + return; + } + lastWid = width(); + lastHei = height(); + doComputeLayoutWeek(); +} +int KOMonthView::mapWeekLayout( int index, bool landscape ) +{ + if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) + return index; + int diff = 0; + if ( !landscape ) diff = 1; + switch( index ) { + case 0: + case 5: + case 6: + return index; + break; + case 1: + return 2+diff; + break; + case 2: + return 4-(3*diff); + break; + case 3: + return 1+(3*diff); + break; + case 4: + return 3-diff; + break; + default: + qDebug("KO: Error in mapping week layout "); + return index; + break; + } + return index; +} void KOMonthView::computeLayout() { |