summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 99f547a..667ff2a 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -133,49 +133,49 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
133 QFont nFont = p->font(); 133 QFont nFont = p->font();
134 134
135 if (!KGlobal::locale()->use12Clock()) 135 if (!KGlobal::locale()->use12Clock())
136 suffix = "00"; 136 suffix = "00";
137 137
138 if ( timeHeight > mCellHeight ) { 138 if ( timeHeight > mCellHeight ) {
139 timeHeight = mCellHeight-1; 139 timeHeight = mCellHeight-1;
140 int pointS = nFont.pointSize(); 140 int pointS = nFont.pointSize();
141 while ( pointS > 4 ) { 141 while ( pointS > 4 ) {
142 nFont.setPointSize( pointS ); 142 nFont.setPointSize( pointS );
143 fm = QFontMetrics( nFont ); 143 fm = QFontMetrics( nFont );
144 if ( fm.ascent() < mCellHeight ) 144 if ( fm.ascent() < mCellHeight )
145 break; 145 break;
146 -- pointS; 146 -- pointS;
147 } 147 }
148 fm = QFontMetrics( nFont ); 148 fm = QFontMetrics( nFont );
149 timeHeight = fm.ascent(); 149 timeHeight = fm.ascent();
150 } 150 }
151 //timeHeight -= (timeHeight/4-2); 151 //timeHeight -= (timeHeight/4-2);
152 QFont sFont = nFont; 152 QFont sFont = nFont;
153 sFont.setPointSize( sFont.pointSize()/2 ); 153 sFont.setPointSize( sFont.pointSize()/2 );
154 QFontMetrics fmS( sFont ); 154 QFontMetrics fmS( sFont );
155 int sHei = fmS.ascent() ; 155 int sHei = fmS.ascent() ;
156 //sHei -= (sHei/4-2); 156 //sHei -= (sHei/4-2);
157 int startW = this->width() - 2*frameWidth()-1; 157 int startW = this->width() - frameWidth()-2;
158 int tw2 = fmS.width(suffix); 158 int tw2 = fmS.width(suffix);
159 while (y < cy + ch) { 159 while (y < cy + ch) {
160 p->drawLine(cx,y,cw,y); 160 p->drawLine(cx,y,cw,y);
161 hour.setNum(cell); 161 hour.setNum(cell);
162 162
163 // handle 24h and am/pm time formats 163 // handle 24h and am/pm time formats
164 if (KGlobal::locale()->use12Clock()) { 164 if (KGlobal::locale()->use12Clock()) {
165 if (cell > 11) suffix = "pm"; 165 if (cell > 11) suffix = "pm";
166 else 166 else
167 suffix = "am"; 167 suffix = "am";
168 if (cell == 0) hour.setNum(12); 168 if (cell == 0) hour.setNum(12);
169 if (cell > 12) hour.setNum(cell - 12); 169 if (cell > 12) hour.setNum(cell - 12);
170 tw2 = fmS.width(suffix); 170 tw2 = fmS.width(suffix);
171 } 171 }
172 172
173 // center and draw the time label 173 // center and draw the time label
174 int timeWidth = fm.width(hour); 174 int timeWidth = fm.width(hour);
175 int offset = startW - timeWidth - tw2 ; 175 int offset = startW - timeWidth - tw2 ;
176 p->setFont( nFont ); 176 p->setFont( nFont );
177 p->drawText( offset, y+ timeHeight, hour); 177 p->drawText( offset, y+ timeHeight, hour);
178 p->setFont( sFont ); 178 p->setFont( sFont );
179 offset = startW - tw2+1; 179 offset = startW - tw2+1;
180 p->drawText( offset, y+ sHei, suffix); 180 p->drawText( offset, y+ sHei, suffix);
181 181
@@ -186,52 +186,60 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
186 } else { 186 } else {
187 //qDebug("NO redraw "); 187 //qDebug("NO redraw ");
188 } 188 }
189 // double buffer not yet implemented 189 // double buffer not yet implemented
190 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 190 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
191 //mRedrawNeeded = false; 191 //mRedrawNeeded = false;
192} 192}
193 193
194/** 194/**
195 Calculates the minimum width. 195 Calculates the minimum width.
196*/ 196*/
197int TimeLabels::minimumWidth() const 197int TimeLabels::minimumWidth() const
198{ 198{
199 return mMiniWidth; 199 return mMiniWidth;
200} 200}
201 201
202/** updates widget's internal state */ 202/** updates widget's internal state */
203void TimeLabels::updateConfig() 203void TimeLabels::updateConfig()
204{ 204{
205 mRedrawNeeded = true; 205 mRedrawNeeded = true;
206 // set the font 206 // set the font
207 // config->setGroup("Fonts"); 207 // config->setGroup("Fonts");
208 // QFont font = config->readFontEntry("TimeBar Font"); 208 // QFont font = config->readFontEntry("TimeBar Font");
209 setFont(KOPrefs::instance()->mTimeBarFont); 209 setFont(KOPrefs::instance()->mTimeBarFont);
210 QString test = "20oo"; 210 QString test = "20";
211 if (KGlobal::locale()->use12Clock()) 211 if (KGlobal::locale()->use12Clock())
212 test = "12mi"; 212 test = "12";
213 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; 213 mMiniWidth = fontMetrics().width(test);
214 if (KGlobal::locale()->use12Clock())
215 test = "pm";
216 else
217 test = "00";
218 QFont sFont = font();
219 sFont.setPointSize( sFont.pointSize()/2 );
220 QFontMetrics fmS( sFont );
221 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ;
214 // update geometry restrictions based on new settings 222 // update geometry restrictions based on new settings
215 setFixedWidth( mMiniWidth ); 223 setFixedWidth( mMiniWidth );
216 224
217 // update HourSize 225 // update HourSize
218 mCellHeight = KOPrefs::instance()->mHourSize*4; 226 mCellHeight = KOPrefs::instance()->mHourSize*4;
219 resizeContents(50,mRows * mCellHeight); 227 resizeContents(50,mRows * mCellHeight);
220} 228}
221 229
222/** update time label positions */ 230/** update time label positions */
223void TimeLabels::positionChanged() 231void TimeLabels::positionChanged()
224{ 232{
225 int adjustment = mAgenda->contentsY(); 233 int adjustment = mAgenda->contentsY();
226 setContentsPos(0, adjustment); 234 setContentsPos(0, adjustment);
227} 235}
228 236
229/** */ 237/** */
230void TimeLabels::setAgenda(KOAgenda* agenda) 238void TimeLabels::setAgenda(KOAgenda* agenda)
231{ 239{
232 mAgenda = agenda; 240 mAgenda = agenda;
233} 241}
234 242
235void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 243void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
236{ 244{
237 mMouseDownY = e->pos().y(); 245 mMouseDownY = e->pos().y();