author | zautrix <zautrix> | 2005-04-02 17:24:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-02 17:24:28 (UTC) |
commit | 40e5edc1ab153144f0e824ad2d3a0ab37357e408 (patch) (unidiff) | |
tree | 25b1d980554303d99d41960267d57872a338960d /korganizer | |
parent | f3c3a836ae97ef3e65cfbcd22156b0ba6eaae578 (diff) | |
download | kdepimpi-40e5edc1ab153144f0e824ad2d3a0ab37357e408.zip kdepimpi-40e5edc1ab153144f0e824ad2d3a0ab37357e408.tar.gz kdepimpi-40e5edc1ab153144f0e824ad2d3a0ab37357e408.tar.bz2 |
commit
-rw-r--r-- | korganizer/koagendaview.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 880d399..d450a97 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -149,129 +149,128 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
149 | //sHei -= (sHei/4-2); | 149 | //sHei -= (sHei/4-2); |
150 | int startW = mMiniWidth - frameWidth()-2 ; | 150 | int startW = mMiniWidth - frameWidth()-2 ; |
151 | int tw2 = fmS.width(suffix); | 151 | int tw2 = fmS.width(suffix); |
152 | timeHeight = (timeHeight-1) /2 -1; | 152 | timeHeight = (timeHeight-1) /2 -1; |
153 | //testline | 153 | //testline |
154 | //p->drawLine(0,0,0,contentsHeight()); | 154 | //p->drawLine(0,0,0,contentsHeight()); |
155 | while (y < cy + ch+mCellHeight) { | 155 | while (y < cy + ch+mCellHeight) { |
156 | p->drawLine(startW-tw2 ,y,cw+2,y); | 156 | p->drawLine(startW-tw2 ,y,cw+2,y); |
157 | hour.setNum(cell); | 157 | hour.setNum(cell); |
158 | // handle 24h and am/pm time formats | 158 | // handle 24h and am/pm time formats |
159 | if (KGlobal::locale()->use12Clock()) { | 159 | if (KGlobal::locale()->use12Clock()) { |
160 | if (cell == 12) suffix = "pm"; | 160 | if (cell == 12) suffix = "pm"; |
161 | if (cell == 0) hour.setNum(12); | 161 | if (cell == 0) hour.setNum(12); |
162 | if (cell > 12) hour.setNum(cell - 12); | 162 | if (cell > 12) hour.setNum(cell - 12); |
163 | } | 163 | } |
164 | 164 | ||
165 | // center and draw the time label | 165 | // center and draw the time label |
166 | int timeWidth = fm.width(hour); | 166 | int timeWidth = fm.width(hour); |
167 | int offset = startW - timeWidth - tw2 -1 ; | 167 | int offset = startW - timeWidth - tw2 -1 ; |
168 | p->setFont( nFont ); | 168 | p->setFont( nFont ); |
169 | p->drawText( offset, y+ timeHeight, hour); | 169 | p->drawText( offset, y+ timeHeight, hour); |
170 | p->setFont( sFont ); | 170 | p->setFont( sFont ); |
171 | offset = startW - tw2; | 171 | offset = startW - tw2; |
172 | p->drawText( offset, y -1, suffix); | 172 | p->drawText( offset, y -1, suffix); |
173 | 173 | ||
174 | // increment indices | 174 | // increment indices |
175 | y += mCellHeight; | 175 | y += mCellHeight; |
176 | cell++; | 176 | cell++; |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | 180 | ||
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | /** | 184 | /** |
185 | Calculates the minimum width. | 185 | Calculates the minimum width. |
186 | */ | 186 | */ |
187 | int TimeLabels::minimumWidth() const | 187 | int TimeLabels::minimumWidth() const |
188 | { | 188 | { |
189 | return mMiniWidth; | 189 | return mMiniWidth; |
190 | } | 190 | } |
191 | 191 | ||
192 | /** updates widget's internal state */ | 192 | /** updates widget's internal state */ |
193 | void TimeLabels::updateConfig() | 193 | void TimeLabels::updateConfig() |
194 | { | 194 | { |
195 | mRedrawNeeded = true; | 195 | mRedrawNeeded = true; |
196 | // set the font | 196 | // set the font |
197 | // config->setGroup("Fonts"); | 197 | // config->setGroup("Fonts"); |
198 | // QFont font = config->readFontEntry("TimeBar Font"); | 198 | // QFont font = config->readFontEntry("TimeBar Font"); |
199 | setFont(KOPrefs::instance()->mTimeBarFont); | 199 | setFont(KOPrefs::instance()->mTimeBarFont); |
200 | QString test = "20"; | 200 | QString test = "20"; |
201 | if (KGlobal::locale()->use12Clock()) | 201 | if (KGlobal::locale()->use12Clock()) |
202 | test = "12"; | 202 | test = "12"; |
203 | mMiniWidth = fontMetrics().width(test); | 203 | mMiniWidth = fontMetrics().width(test); |
204 | if (KGlobal::locale()->use12Clock()) | 204 | if (KGlobal::locale()->use12Clock()) |
205 | test = "pm"; | 205 | test = "pm"; |
206 | else { | 206 | else { |
207 | test = "00"; | 207 | test = "00"; |
208 | } | 208 | } |
209 | QFont sFont = font(); | 209 | QFont sFont = font(); |
210 | sFont.setPointSize( sFont.pointSize()/2 ); | 210 | sFont.setPointSize( sFont.pointSize()/2 ); |
211 | QFontMetrics fmS( sFont ); | 211 | QFontMetrics fmS( sFont ); |
212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; | 212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; |
213 | qDebug("testwid %d %d", mMiniWidth ,fmS.width( test )); | ||
214 | // update geometry restrictions based on new settings | 213 | // update geometry restrictions based on new settings |
215 | setFixedWidth( mMiniWidth ); | 214 | setFixedWidth( mMiniWidth ); |
216 | 215 | ||
217 | // update HourSize | 216 | // update HourSize |
218 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 217 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
219 | resizeContents(50,mRows * mCellHeight); | 218 | resizeContents(50,mRows * mCellHeight); |
220 | } | 219 | } |
221 | 220 | ||
222 | /** update time label positions */ | 221 | /** update time label positions */ |
223 | void TimeLabels::positionChanged() | 222 | void TimeLabels::positionChanged() |
224 | { | 223 | { |
225 | int adjustment = mAgenda->contentsY(); | 224 | int adjustment = mAgenda->contentsY(); |
226 | setContentsPos(0, adjustment); | 225 | setContentsPos(0, adjustment); |
227 | } | 226 | } |
228 | 227 | ||
229 | /** */ | 228 | /** */ |
230 | void TimeLabels::setAgenda(KOAgenda* agenda) | 229 | void TimeLabels::setAgenda(KOAgenda* agenda) |
231 | { | 230 | { |
232 | mAgenda = agenda; | 231 | mAgenda = agenda; |
233 | } | 232 | } |
234 | 233 | ||
235 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
236 | { | 235 | { |
237 | mMouseDownY = e->pos().y(); | 236 | mMouseDownY = e->pos().y(); |
238 | mOrgCap = topLevelWidget()->caption(); | 237 | mOrgCap = topLevelWidget()->caption(); |
239 | } | 238 | } |
240 | 239 | ||
241 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
242 | { | 241 | { |
243 | int diff = mMouseDownY - e->pos().y(); | 242 | int diff = mMouseDownY - e->pos().y(); |
244 | if ( diff < 10 && diff > -10 ) | 243 | if ( diff < 10 && diff > -10 ) |
245 | return; | 244 | return; |
246 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
247 | if ( tSize < 4 ) | 246 | if ( tSize < 4 ) |
248 | tSize = 4; | 247 | tSize = 4; |
249 | if ( tSize > 22 ) | 248 | if ( tSize > 22 ) |
250 | tSize = 22; | 249 | tSize = 22; |
251 | tSize = (tSize-2)/2; | 250 | tSize = (tSize-2)/2; |
252 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
253 | 252 | ||
254 | } | 253 | } |
255 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
256 | { | 255 | { |
257 | topLevelWidget()->setCaption( mOrgCap ); | 256 | topLevelWidget()->setCaption( mOrgCap ); |
258 | int diff = mMouseDownY - e->pos().y(); | 257 | int diff = mMouseDownY - e->pos().y(); |
259 | if ( diff < 10 && diff > -10 ) | 258 | if ( diff < 10 && diff > -10 ) |
260 | return; | 259 | return; |
261 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
262 | if ( tSize < 4 ) | 261 | if ( tSize < 4 ) |
263 | tSize = 4; | 262 | tSize = 4; |
264 | if ( tSize > 22 ) | 263 | if ( tSize > 22 ) |
265 | tSize = 22; | 264 | tSize = 22; |
266 | tSize = (tSize/2)*2; | 265 | tSize = (tSize/2)*2; |
267 | if ( tSize == KOPrefs::instance()->mHourSize ) | 266 | if ( tSize == KOPrefs::instance()->mHourSize ) |
268 | return; | 267 | return; |
269 | KOPrefs::instance()->mHourSize = tSize; | 268 | KOPrefs::instance()->mHourSize = tSize; |
270 | emit scaleChanged(); | 269 | emit scaleChanged(); |
271 | } | 270 | } |
272 | 271 | ||
273 | /** This is called in response to repaint() */ | 272 | /** This is called in response to repaint() */ |
274 | void TimeLabels::paintEvent(QPaintEvent*) | 273 | void TimeLabels::paintEvent(QPaintEvent*) |
275 | { | 274 | { |
276 | 275 | ||
277 | // kdDebug() << "paintevent..." << endl; | 276 | // kdDebug() << "paintevent..." << endl; |