summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp134
1 files changed, 72 insertions, 62 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2996acb..218396d 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -82,6 +82,8 @@ 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;
@@ -117,71 +119,78 @@ 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;
}
@@ -197,4 +206,5 @@ int TimeLabels::minimumWidth() const
void TimeLabels::updateConfig()
{
+ mRedrawNeeded = true;
// set the font
// config->setGroup("Fonts");