summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index fa6b951..18f242c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -107,63 +107,75 @@ 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() + 2;
cw = contentsWidth() - 2;
// end of workaround
int cell = ((int)(cy/mCellHeight));
int y = cell * mCellHeight;
QFontMetrics fm = fontMetrics();
QString hour;
QString suffix;
QString fullTime;
int tW = fm.width("24:00i");
int timeHeight = fm.height();
- timeHeight -= (timeHeight/4-2);
+ //timeHeight -= (timeHeight/4-2);
int borderWidth = 0;
QFont nFont = p->font();
- QFont sFont = nFont;
- sFont.setPointSize( sFont.pointSize()/2+2 );
+
if (!KGlobal::locale()->use12Clock())
suffix = "00";
else
borderWidth = 0;
- QFontMetrics fmS( sFont );
- int sHei = fmS.height();
if ( timeHeight > mCellHeight ) {
timeHeight = mCellHeight-1;
- sHei -= 2;
+ int pointS = nFont.pointSize();
+ while ( pointS > 4 ) {
+ nFont.setPointSize( 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();
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);
}
// create string in format of "XX:XX" or "XXpm/am"
fullTime = hour;// + suffix;
// center and draw the time label
int timeWidth = fm.width(fullTime+"i");
int tw2 = fm.width(suffix);
int offset = this->width() - timeWidth - tw2;
p->setFont( nFont );
p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
p->setFont( sFont );
@@ -868,48 +880,54 @@ DateList KOAgendaView::selectedDates()
if (qd.isValid()) selected.append(qd);
return selected;
}
void KOAgendaView::updateView()
{
if ( mBlockUpdating )
return;
// kdDebug() << "KOAgendaView::updateView()" << endl;
fillAgenda();
}
/*
Update configuration settings for the agenda view. This method is not
complete.
*/
void KOAgendaView::updateConfig()
{
if ( mBlockUpdating )
return;
+ if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
+ int old = KOPrefs::instance()->mHourSize;
+ KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
+ qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
+ }
+
// update config for children
mTimeLabels->updateConfig();
mAgenda->storePosition();
mAgenda->updateConfig();
mAllDayAgenda->updateConfig();
// widget synchronization
//TODO: find a better way, maybe signal/slot
mTimeLabels->positionChanged();
// for some reason, this needs to be called explicitly
mTimeLabels->repaint();
mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
// ToolTips displaying summary of events
KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
->mEnableToolTips);
//setHolidayMasks();
//createDayLabels(); called by via updateView();
mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
updateView();