summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
authorzautrix <zautrix>2005-04-02 08:36:37 (UTC)
committer zautrix <zautrix>2005-04-02 08:36:37 (UTC)
commite7cb4c20af8b07bf923c864026481ce316c40e1d (patch) (side-by-side diff)
treec88b2d0c01ce683e73ea9f4657f4d5c6fbe6f922 /korganizer/koagendaview.cpp
parent7aefe488d1fe0c34cf29460f48a9a97d632f615e (diff)
downloadkdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.zip
kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.gz
kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.bz2
more fixes
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp86
1 files changed, 77 insertions, 9 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2b05d37..8d32152 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -110,14 +110,77 @@ void TimeLabels::setCellHeight(int height)
void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
{
- // if ( globalFlagBlockAgenda )
- // return;
- // bug: the parameters cx, cy, cw, ch are the areas that need to be
- // redrawn, not the area of the widget. unfortunately, this
- // code assumes the latter...
-
- // now, for a workaround...
- // these two assignments fix the weird redraw bug
+ 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 = "am";
+ int timeHeight = fm.ascent();
+ QFont nFont = p->font();
+
+ if (!KGlobal::locale()->use12Clock()) {
+ if ( QApplication::desktop()->width() <= 320 )
+ suffix = "00";
+ 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);
+ timeHeight = (timeHeight-1) /2 -1;
+ while (y < cy + ch+mCellHeight) {
+ p->drawLine(startW-tw2+1 ,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);
+ }
+
+ // 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 -1, suffix);
+
+ // increment indices
+ y += mCellHeight;
+ cell++;
+ }
+
+
+
+
+#if 0
mRedrawNeeded = true;
if ( mRedrawNeeded ) {
cx = contentsX() + frameWidth()*2;
@@ -192,6 +255,7 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
// double buffer not yet implemented
//bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
//mRedrawNeeded = false;
+#endif
}
/**
@@ -218,7 +282,7 @@ void TimeLabels::updateConfig()
test = "pm";
else {
if ( QApplication::desktop()->width() <= 320 )
- test = "";
+ test = "00";
else
test = "00";
}
@@ -674,6 +738,8 @@ void KOAgendaView::createDayLabels()
// 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 )
maxWid = 20;
@@ -732,9 +798,11 @@ void KOAgendaView::createDayLabels()
dayLabel->setFont( dlf );
dayLabel->setNum( -1 );
//dayLabel->setAlignment(QLabel::AlignHCenter);
+#if 0
if ( QApplication::desktop()->width() <= 320 )
dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
else
+#endif
dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
dayLabel->show();
DateList::ConstIterator dit;