From f3c3a836ae97ef3e65cfbcd22156b0ba6eaae578 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 02 Apr 2005 17:04:37 +0000 Subject: fixes --- (limited to 'korganizer/koagendaview.cpp') diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 95388ef..880d399 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -120,14 +120,13 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) QString hour; QString suffix = "am"; int timeHeight = fm.ascent(); - QFont nFont = p->font(); + QFont nFont = font(); + p->setFont( font()); if (!KGlobal::locale()->use12Clock()) { - if ( QApplication::desktop()->width() <= 320 ) suffix = "00"; - else - suffix = "00"; - } + } else + if (cell > 11) suffix = "pm"; if ( timeHeight > mCellHeight ) { timeHeight = mCellHeight-1; @@ -148,28 +147,28 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) QFontMetrics fmS( sFont ); int sHei = fmS.ascent() ; //sHei -= (sHei/4-2); - int startW = this->width() - frameWidth()-2; + int startW = mMiniWidth - frameWidth()-2 ; int tw2 = fmS.width(suffix); - timeHeight = (timeHeight-1) /2 -1; + timeHeight = (timeHeight-1) /2 -1; + //testline + //p->drawLine(0,0,0,contentsHeight()); while (y < cy + ch+mCellHeight) { - p->drawLine(startW-tw2+1 ,y,cw,y); + p->drawLine(startW-tw2 ,y,cw+2,y); hour.setNum(cell); // handle 24h and am/pm time formats if (KGlobal::locale()->use12Clock()) { - if (cell > 11) suffix = "pm"; - else - suffix = "am"; + if (cell == 12) suffix = "pm"; if (cell == 0) hour.setNum(12); if (cell > 12) hour.setNum(cell - 12); } // center and draw the time label int timeWidth = fm.width(hour); - int offset = startW - timeWidth - tw2 ; + int offset = startW - timeWidth - tw2 -1 ; p->setFont( nFont ); p->drawText( offset, y+ timeHeight, hour); p->setFont( sFont ); - offset = startW - tw2+1; + offset = startW - tw2; p->drawText( offset, y -1, suffix); // increment indices @@ -180,82 +179,6 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) -#if 0 - mRedrawNeeded = true; - if ( mRedrawNeeded ) { - cx = contentsX() + frameWidth()*2; - cw = contentsWidth() ; - // end of workaround - - int cell = ((int)(cy/mCellHeight)); - int y = cell * mCellHeight; - QFontMetrics fm = fontMetrics(); - QString hour; - QString suffix; - int timeHeight = fm.ascent(); - QFont nFont = p->font(); - - if (!KGlobal::locale()->use12Clock()) { - if ( QApplication::desktop()->width() <= 320 ) - suffix = ""; - else - suffix = "00"; - } - - if ( timeHeight > mCellHeight ) { - timeHeight = mCellHeight-1; - int pointS = nFont.pointSize(); - while ( pointS > 4 ) { - nFont.setPointSize( pointS ); - fm = QFontMetrics( nFont ); - if ( fm.ascent() < mCellHeight ) - break; - -- pointS; - } - fm = QFontMetrics( nFont ); - timeHeight = fm.ascent(); - } - //timeHeight -= (timeHeight/4-2); - QFont sFont = nFont; - sFont.setPointSize( sFont.pointSize()/2 ); - QFontMetrics fmS( sFont ); - int sHei = fmS.ascent() ; - //sHei -= (sHei/4-2); - int startW = this->width() - frameWidth()-2; - int tw2 = fmS.width(suffix); - while (y < cy + ch) { - p->drawLine(cx,y,cw,y); - hour.setNum(cell); - // handle 24h and am/pm time formats - if (KGlobal::locale()->use12Clock()) { - if (cell > 11) suffix = "pm"; - else - suffix = "am"; - if (cell == 0) hour.setNum(12); - if (cell > 12) hour.setNum(cell - 12); - tw2 = fmS.width(suffix); - } - - // center and draw the time label - int timeWidth = fm.width(hour); - int offset = startW - timeWidth - tw2 ; - p->setFont( nFont ); - p->drawText( offset, y+ timeHeight, hour); - p->setFont( sFont ); - offset = startW - tw2+1; - p->drawText( offset, y+ sHei, suffix); - - // increment indices - y += mCellHeight; - cell++; - } - } else { - //qDebug("NO redraw "); - } - // double buffer not yet implemented - //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); - //mRedrawNeeded = false; -#endif } /** @@ -281,15 +204,13 @@ void TimeLabels::updateConfig() if (KGlobal::locale()->use12Clock()) test = "pm"; else { - if ( QApplication::desktop()->width() <= 320 ) - test = "00"; - else - test = "00"; + test = "00"; } QFont sFont = font(); sFont.setPointSize( sFont.pointSize()/2 ); QFontMetrics fmS( sFont ); - mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; + mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; + qDebug("testwid %d %d", mMiniWidth ,fmS.width( test )); // update geometry restrictions based on new settings setFixedWidth( mMiniWidth ); @@ -734,26 +655,30 @@ void KOAgendaView::createDayLabels() } int newHight; + if ( !mSelectedDates.count()) + return; // ### Before deleting and recreating we could check if mSelectedDates changed... // It would remove some flickering and gain speed (since this is called by // each updateView() call) int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; - if ( QApplication::desktop()->width() <= 320 ) - maxWid -= 10; mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); - if ( maxWid < 0 ) + if ( maxWid < 20 ) maxWid = 20; QFont dlf = KOPrefs::instance()->mTimeLabelsFont; QFontMetrics fm ( dlf ); int selCount = mSelectedDates.count(); + int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; QString dayTest = "Mon 20"; //QString dayTest = "Mon 20"; int wid = fm.width( dayTest ); //maxWid -= ( selCount * 3 ); //working for QLabels - maxWid -= ( selCount * 3 ); //working for QPushButton + if ( QApplication::desktop()->width() <= 320 ) + maxWid -= ( selCount * 3 ); //working for QPushButton + else + maxWid -= ( selCount * 3 ); //working for QPushButton if ( maxWid < 0 ) maxWid = 20; int needWid = wid * selCount; @@ -912,17 +837,14 @@ void KOAgendaView::createDayLabels() dayLabel = getNewDaylabel(); } //dayLabel->hide();//test only - int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; - if ( offset < 0 ) offset = 0; - //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); - dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); + + dayLabel->setText(">"); dayLabel->setFont( dlf ); dayLabel->setAutoRepeat( true ); dayLabel->show(); dayLabel->setNum( -2 ); - dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); + dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); - //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); if ( !appendLabels ) { dayLabel = mDayLabelsList.next(); -- cgit v0.9.0.2