author | zautrix <zautrix> | 2005-04-05 14:03:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-05 14:03:26 (UTC) |
commit | 637415693af8fe9974b45c355ecfdd0745617ac3 (patch) (side-by-side diff) | |
tree | f7d83828754e82b0eeb001a2837f7c3f6865d647 | |
parent | e1fd021493c30106d2a31449d620ab6eaf96f18f (diff) | |
download | kdepimpi-637415693af8fe9974b45c355ecfdd0745617ac3.zip kdepimpi-637415693af8fe9974b45c355ecfdd0745617ac3.tar.gz kdepimpi-637415693af8fe9974b45c355ecfdd0745617ac3.tar.bz2 |
minor pixel fixes
-rw-r--r-- | korganizer/komonthview.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6d6ae8a..e66ddce 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -1465,496 +1465,512 @@ void KOMonthView::updateView() QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); QDateTime incidenceEnd; int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); bool invalid = false; while( true ) { if ( incidenceStart.isValid() ) { incidenceEnd = incidenceStart.addDays( eventlen ); int st = incidenceStart.date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( incidenceEnd.date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); for ( iii = st;iii<= end;++iii) (*cells)[iii]->insertEvent( event ); } } } else { if ( invalid ) break; invalid = true; //qDebug("invalid %s", event->summary().latin1()); incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; } if ( last ) break; bool ok; incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); if ( ! ok ) break; if ( incidenceStart.date() > endDate ) break; } } else { // no recur int st = event->dtStart().date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( event->dtEnd().date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; for ( iii = st;iii<= end;++iii) (*cells)[iii]->insertEvent( event ); } } } } // insert due todos QPtrList<Todo> todos = calendar()->todos( ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { //insertTodo( todo ); if ( todo->hasDueDate() ) { int day = mStartDate.daysTo( todo->dtDue().date() ); if ( day >= 0 && day < timeSpan + 1) { (*cells)[day]->insertTodo( todo ); } } } for( i = 0; i < timeSpan+1; ++i ) { (*cells)[i]->finishUpdateCell(); } processSelectionChange(); //qApp->processEvents(); for( i = 0; i < timeSpan+1; ++i ) { (*cells)[i]->repaintfinishUpdateCell(); } setKeyBFocus(); #else // old code //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); int i; for( i = 0; i < (*cells).count(); ++i ) { (*cells)[i]->updateCell(); } //qDebug("KOMonthView::updateView() "); processSelectionChange(); // qDebug("---------------------------------------------------------------------+ "); (*cells)[0]->setFocus(); #endif //qDebug("update time %d ", ti.elapsed()); } void KOMonthView::setKeyBoardFocus() { //qDebug("KOMonthView::setKeyBoardFocus() "); bool shootAgain = false; if ( mShowWeekView ) { shootAgain = !mWeekLabelsW[1]->hasFocus(); mWeekLabelsW[1]->setFocus(); } else { shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); mWeekLabels[mNumWeeks]->setFocus(); } if ( shootAgain ) { QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); } } void KOMonthView::setKeyBFocus() { //qDebug("KOMonthView::setKeyBFocus() "); QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); } void KOMonthView::resizeEvent(QResizeEvent * e) { //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); if ( isVisible() ) { //qDebug("KOMonthView::isVisible "); slotComputeLayout(); } else mComputeLayoutTimer->start( 100 ); } void KOMonthView::slotComputeLayout() { mComputeLayoutTimer->stop(); //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); computeLayout(); clPending = true; setKeyBFocus(); } void KOMonthView::computeLayoutWeek() { static int lastWid = 0; static int lastHei = 0; 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 = 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 ) daysToShow = 2; else daysToShow = 3; mShowSatSunComp = true; combinedSatSun = true; //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); QFontMetrics fm ( mWeekLabels[0]->font() ); int weeklabelwid = fm.width( "888" ); wid -= weeklabelwid; int colWid = wid / daysToShow; int lastCol = wid - ( colWid*6 ); int dayLabelHei = mDayLabelsW[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; w = colWid; } if ( ((i) % daysToShow) >= daysToShow-colModulo ) { ++w; } - if ( i >= 5 ) { - mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); - x -= (w/2 ); + if ( i >= 5 ) { + int wi = width() - x - weeklabelwid; + if ( i == 5 ) { + mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); + } else { + mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); + } + x = x - w + wi - (wi/2 ); + } + else { + int wi = w; + if ( !(( i+1) % daysToShow)) { + wi = width() - x - weeklabelwid; + } + mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); } - else - mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); x += w; } x= 0; y= dayLabelHei; w = colWid; h = cellHei; int max = 0; for ( i = 0; i < mCellsW.count(); ++i) { if ( i > 6 ) { mCellsW[i]->hide(); continue; } w = colWid; if ( ((i) % daysToShow) >= daysToShow-colModulo ) { ++w; } if ( i == (daysToShow-1-rowModulo)*7) ++h; if ( i >= 5 ) { if ( i ==5 ) { max = h/2; mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); x -= w ;y += h/2; } else { if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { ++w; } max = h-h/2; mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); y -= h/2; } } else { max = h; mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); } x += w; if ( x + w/2 > wid ) { x = 0; y += h+dayLabelHei ; } //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); } y= dayLabelHei; h = cellHei ; mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); mWeekLabelsW[1]->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()); mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; updateDayLabels(); //bool forceUpdate = !updatePossible; updatePossible = true; //mWeekLabels[mNumWeeks]->setText( i18n("M")); //if ( forceUpdate ) // updateView(); } void KOMonthView::computeLayout() { static int lastWid = 0; static int lastHei = 0; if ( mShowWeekView ){ computeLayoutWeek(); return; } int daysToShow = 7; bool combinedSatSun = false; if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { daysToShow = 6; 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("KOMonthview::No compute layout needed "); return; } lastWid = width(); lastHei = height(); //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 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 - dayLabelHei) /6; int colModulo = wid % daysToShow; int rowModulo = (hei- dayLabelHei) % 6; //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 == daysToShow-colModulo ) ++w; if ( combinedSatSun ) { if ( i >= daysToShow-1 ) { - mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); + + if ( i == 6 ) + mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); + else + mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); x -= w/2 ; } else mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); } else mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); x += w; } x= 0; y= dayLabelHei; w = colWid; h = cellHei ; int max = 0; for ( i = 0; i < mCells.count(); ++i) { //qDebug("iii %d ", i); w = colWid; if ( ((i) % 7) >= 7-colModulo ) { ++w; } if ( i == (6-rowModulo)*7) ++h; if ( combinedSatSun ) { if ( (i)%7 >= daysToShow-1 ) { if ( (i)%7 == daysToShow-1 ) { + w = width()-x-weeklabelwid; max = h/2; mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); x -= w ;y += h/2; } else { + w = width()-x-weeklabelwid; max = h-h/2; mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); y -= h/2; } } else { max = h; mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); } } else { max = h; mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); } x += w; if ( x + w/2 > wid ) { x = 0; y += h; } //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); } y= dayLabelHei; h = cellHei ; for ( i = 0; i < 6; i++) { if ( i == (6-rowModulo)) ++h; mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); y += h; } 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()); mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; updateDayLabels(); //bool forceUpdate = !updatePossible; updatePossible = true; //mWeekLabels[mNumWeeks]->setText( i18n("W")); } void KOMonthView::showContextMenu( Incidence *incidence ) { mContextMenu->showIncidencePopup(incidence); /* if( incidence && incidence->type() == "Event" ) { Event *event = static_cast<Event *>(incidence); mContextMenu->showEventPopup(event); } else { kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; } */ } MonthViewCell * KOMonthView::selectedCell( ) { return mSelectedCell; } void KOMonthView::setSelectedCell( MonthViewCell *cell ) { //qDebug("KOMonthView::setSelectedCell "); if ( mSelectedCell && mSelectedCell != cell ) { MonthViewCell * mvc = mSelectedCell; mSelectedCell = cell; mvc->deselect(); } else mSelectedCell = cell; // if ( mSelectedCell ) // mSelectedCell->select(); if ( !mSelectedCell ) emit incidenceSelected( 0 ); else emit incidenceSelected( mSelectedCell->selectedIncidence() ); } void KOMonthView::processSelectionChange() { QPtrList<Incidence> incidences = selectedIncidences(); if (incidences.count() > 0) { emit incidenceSelected( incidences.first() ); } else { emit incidenceSelected( 0 ); clearSelection(); } } void KOMonthView::clearSelection() { if ( mSelectedCell ) { mSelectedCell->deselect(); mSelectedCell = 0; } } void KOMonthView::keyReleaseEvent ( QKeyEvent * e) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void KOMonthView::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); if ( e->isAutoRepeat() && !mFlagKeyPressed ) { //e->ignore(); e->accept(); return; } if (! e->isAutoRepeat() ) mFlagKeyPressed = true; switch(e->key()) { case Key_Up: { if ( mShowWeekView ) { emit selectWeekNum ( currentWeek() - 1 ); } else { emit prevMonth(); } } e->accept(); break; case Key_Down: { if ( mShowWeekView ) { emit selectWeekNum ( currentWeek() +1); } else { emit nextMonth(); } } e->accept(); break; case Key_Return: case Key_Enter: { selectInternalWeekNum ( currentWeek() ); } e->accept(); break; case Key_D: if ( mSelectedCell ) { mSelectedCell->showDay(); e->accept(); } else { e->ignore(); } break; default: e->ignore(); break; } } |