author | zautrix <zautrix> | 2005-04-02 08:36:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-02 08:36:37 (UTC) |
commit | e7cb4c20af8b07bf923c864026481ce316c40e1d (patch) (side-by-side diff) | |
tree | c88b2d0c01ce683e73ea9f4657f4d5c6fbe6f922 /korganizer | |
parent | 7aefe488d1fe0c34cf29460f48a9a97d632f615e (diff) | |
download | kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.zip kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.gz kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.bz2 |
more fixes
-rw-r--r-- | korganizer/koagendaview.cpp | 86 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 |
2 files changed, 81 insertions, 13 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 2b05d37..8d32152 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -107,20 +107,83 @@ void TimeLabels::setCellHeight(int height) Optimization so that only the "dirty" portion of the scroll view is redrawn. Unfortunately, this is not called by default paintEvent() method. */ 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; cw = contentsWidth() ; // end of workaround @@ -189,12 +252,13 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) } else { //qDebug("NO redraw "); } // double buffer not yet implemented //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); //mRedrawNeeded = false; +#endif } /** Calculates the minimum width. */ int TimeLabels::minimumWidth() const @@ -215,13 +279,13 @@ void TimeLabels::updateConfig() test = "12"; mMiniWidth = fontMetrics().width(test); if (KGlobal::locale()->use12Clock()) test = "pm"; else { if ( QApplication::desktop()->width() <= 320 ) - test = ""; + test = "00"; else test = "00"; } QFont sFont = font(); sFont.setPointSize( sFont.pointSize()/2 ); QFontMetrics fmS( sFont ); @@ -671,12 +735,14 @@ void KOAgendaView::createDayLabels() // ### 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 ) maxWid = 20; QFont dlf = KOPrefs::instance()->mTimeLabelsFont; QFontMetrics fm ( dlf ); @@ -729,15 +795,17 @@ void KOAgendaView::createDayLabels() dayLabel = getNewDaylabel(); } dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 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; bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); int counter = -1; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index b8a0f09..8affe50 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -764,28 +764,28 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) if ( colt >= 7 - colModulo ) addCol2 = colt - 7 + colModulo; addCol -= addCol2; //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); } // Single row selection - if ( row == 0) - addRow = 1; + //if ( row == 0) + // addRow = 1; p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); } else { // draw first row to the right if ( colModulo ) { if ( col >= 7 - colModulo ) addCol2 = col - 7 + colModulo; } if ( rowModulo ) { if ( row >= 6 - rowModulo ) addRow = row - 5 + rowModulo; } - if ( row == 0) - addRow = 1; + //if ( row == 0) + // addRow = 1; int drawWid = width()-(col*dwidth+1+addCol2)-1; p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, dheight+1, selcol); // draw full block till last line selh = mSelEndT/7-row; addRow = 0; |