From e5ec0ef6a256b96a758815ef861526f53d1ad7a5 Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 01 Apr 2005 14:41:00 +0000 Subject: fix --- (limited to 'korganizer/koagendaview.cpp') diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 2996acb..218396d 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -81,8 +81,10 @@ using namespace KOrg; TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { + myPix.resize( 1, 1 ); mRows = rows; + mRedrawNeeded = true; setMinimumHeight( 20 ); mCellHeight = KOPrefs::instance()->mHourSize*4; @@ -116,73 +118,80 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) // now, for a workaround... // these two assignments fix the weird redraw bug - cx = contentsX() + 2; - cw = contentsWidth() - 2; - // end of workaround - - int cell = ((int)(cy/mCellHeight)); - int y = cell * mCellHeight; - QFontMetrics fm = fontMetrics(); - QString hour; - QString suffix; - int tW = fm.width("24:00i"); - int timeHeight = fm.height(); - //timeHeight -= (timeHeight/4-2); - int borderWidth = 0; - QFont nFont = p->font(); + if ( mRedrawNeeded ) { + cx = contentsX() + 2; + cw = contentsWidth() - 2; + // end of workaround + + int cell = ((int)(cy/mCellHeight)); + int y = cell * mCellHeight; + QFontMetrics fm = fontMetrics(); + QString hour; + QString suffix; + int tW = fm.width("24:00i"); + int timeHeight = fm.height(); + //timeHeight -= (timeHeight/4-2); + int borderWidth = 0; + QFont nFont = p->font(); - if (!KGlobal::locale()->use12Clock()) - suffix = "00"; - else - borderWidth = 0; - if ( timeHeight > mCellHeight ) { - timeHeight = mCellHeight-1; - int pointS = nFont.pointSize(); - while ( pointS > 4 ) { - nFont.setPointSize( pointS ); + if (!KGlobal::locale()->use12Clock()) + suffix = "00"; + else + borderWidth = 0; + if ( timeHeight > mCellHeight ) { + timeHeight = mCellHeight-1; + int pointS = nFont.pointSize(); + while ( pointS > 4 ) { + nFont.setPointSize( pointS ); + fm = QFontMetrics( nFont ); + if ( fm.height() < mCellHeight ) + break; + -- pointS; + } fm = QFontMetrics( nFont ); - if ( fm.height() < mCellHeight ) - break; - -- pointS; - } - fm = QFontMetrics( nFont ); - borderWidth = 4; - timeHeight = fm.height(); - } - timeHeight -= (timeHeight/4-2); - QFont sFont = nFont; - sFont.setPointSize( sFont.pointSize()/2+2 ); - QFontMetrics fmS( sFont ); - int sHei = fmS.height(); - sHei -= (sHei/4-2); - int startW = this->width() - frameWidth(); - while (y < cy + ch) { - p->drawLine(cx,y,cx+tW,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); + borderWidth = 4; + timeHeight = fm.height(); } + timeHeight -= (timeHeight/4-2); + QFont sFont = nFont; + sFont.setPointSize( sFont.pointSize()/2+2 ); + QFontMetrics fmS( sFont ); + int sHei = fmS.height(); + sHei -= (sHei/4-2); + int startW = this->width() - frameWidth(); + while (y < cy + ch) { + p->drawLine(cx,y,cx+tW,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); + } - // center and draw the time label - int timeWidth = fm.width(hour+"i"); - int tw2 = fm.width(suffix); - int offset = startW - timeWidth - tw2 ; - p->setFont( nFont ); - p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); - p->setFont( sFont ); - offset = startW - tw2-1; - p->drawText(cx - borderWidth + offset, y+ sHei, suffix); - - // increment indices - y += mCellHeight; - cell++; + // center and draw the time label + int timeWidth = fm.width(hour+"i"); + int tw2 = fm.width(suffix); + int offset = startW - timeWidth - tw2 ; + p->setFont( nFont ); + p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); + p->setFont( sFont ); + offset = startW - tw2-1; + p->drawText(cx - borderWidth + 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; } /** @@ -196,6 +205,7 @@ int TimeLabels::minimumWidth() const /** updates widget's internal state */ void TimeLabels::updateConfig() { + mRedrawNeeded = true; // set the font // config->setGroup("Fonts"); // QFont font = config->readFontEntry("TimeBar Font"); -- cgit v0.9.0.2