author | zecke <zecke> | 2003-08-30 08:07:32 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-30 08:07:32 (UTC) |
commit | d9b5fcc45b1fef5ac11ef549a47561c7382ff451 (patch) (unidiff) | |
tree | 8f9e82d455e22be0285a5a8fc47e893b52c05871 | |
parent | 18cae99f1deb15213074a8fb96f79eae4b0c5a43 (diff) | |
download | opie-d9b5fcc45b1fef5ac11ef549a47561c7382ff451.zip opie-d9b5fcc45b1fef5ac11ef549a47561c7382ff451.tar.gz opie-d9b5fcc45b1fef5ac11ef549a47561c7382ff451.tar.bz2 |
do not rely on scrollbars beeing right
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index ab7e963..dad1c3f 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -124,387 +124,388 @@ void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) | |||
124 | items.clear(); | 124 | items.clear(); |
125 | QValueListIterator<EffectiveEvent> it; | 125 | QValueListIterator<EffectiveEvent> it; |
126 | for ( it = ev.begin(); it != ev.end(); ++it ) { | 126 | for ( it = ev.begin(); it != ev.end(); ++it ) { |
127 | DateBookWeekItem *i = new DateBookWeekItem( *it ); | 127 | DateBookWeekItem *i = new DateBookWeekItem( *it ); |
128 | if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) {// Skip events ending at 00:00 starting at another day. | 128 | if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) {// Skip events ending at 00:00 starting at another day. |
129 | positionItem( i ); | 129 | positionItem( i ); |
130 | items.append( i ); | 130 | items.append( i ); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | viewport()->update(); | 133 | viewport()->update(); |
134 | } | 134 | } |
135 | 135 | ||
136 | void DateBookWeekView::moveToHour( int h ) | 136 | void DateBookWeekView::moveToHour( int h ) |
137 | { | 137 | { |
138 | int offset = h*rowHeight; | 138 | int offset = h*rowHeight; |
139 | setContentsPos( 0, offset ); | 139 | setContentsPos( 0, offset ); |
140 | } | 140 | } |
141 | 141 | ||
142 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) | 142 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) |
143 | { | 143 | { |
144 | e->ignore(); | 144 | e->ignore(); |
145 | } | 145 | } |
146 | 146 | ||
147 | void DateBookWeekView::slotChangeClock( bool c ) | 147 | void DateBookWeekView::slotChangeClock( bool c ) |
148 | { | 148 | { |
149 | ampm = c; | 149 | ampm = c; |
150 | viewport()->update(); | 150 | viewport()->update(); |
151 | } | 151 | } |
152 | 152 | ||
153 | static inline int db_round30min( int m ) | 153 | static inline int db_round30min( int m ) |
154 | { | 154 | { |
155 | if ( m < 15 ) | 155 | if ( m < 15 ) |
156 | m = 0; | 156 | m = 0; |
157 | else if ( m < 45 ) | 157 | else if ( m < 45 ) |
158 | m = 1; | 158 | m = 1; |
159 | else | 159 | else |
160 | m = 2; | 160 | m = 2; |
161 | 161 | ||
162 | return m; | 162 | return m; |
163 | } | 163 | } |
164 | 164 | ||
165 | void DateBookWeekView::alterDay( int day ) | 165 | void DateBookWeekView::alterDay( int day ) |
166 | { | 166 | { |
167 | if ( !bOnMonday ) { | 167 | if ( !bOnMonday ) { |
168 | day--; | 168 | day--; |
169 | } | 169 | } |
170 | emit showDay( day ); | 170 | emit showDay( day ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) | 173 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) |
174 | { | 174 | { |
175 | const int Width = 8; | 175 | const int Width = 8; |
176 | const EffectiveEvent ev = i->event(); | 176 | const EffectiveEvent ev = i->event(); |
177 | 177 | ||
178 | // 30 minute intervals | 178 | // 30 minute intervals |
179 | int y = ev.start().hour() * 2; | 179 | int y = ev.start().hour() * 2; |
180 | y += db_round30min( ev.start().minute() ); | 180 | y += db_round30min( ev.start().minute() ); |
181 | int y2 = ev.end().hour() * 2; | 181 | int y2 = ev.end().hour() * 2; |
182 | y2 += db_round30min( ev.end().minute() ); | 182 | y2 += db_round30min( ev.end().minute() ); |
183 | if ( y > 47 ) y = 47; | 183 | if ( y > 47 ) y = 47; |
184 | if ( y2 > 48 ) y2 = 48; | 184 | if ( y2 > 48 ) y2 = 48; |
185 | y = (y * rowHeight) / 2; | 185 | y = (y * rowHeight) / 2; |
186 | y2 = (y2 * rowHeight) / 2; | 186 | y2 = (y2 * rowHeight) / 2; |
187 | 187 | ||
188 | int h; | 188 | int h; |
189 | if ( ev.event().type() == Event::AllDay ) { | 189 | if ( ev.event().type() == Event::AllDay ) { |
190 | h = (48 * rowHeight) / 2; | 190 | h = (48 * rowHeight) / 2; |
191 | y = 0; | 191 | y = 0; |
192 | } else { | 192 | } else { |
193 | h=y2-y; | 193 | h=y2-y; |
194 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; | 194 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; |
195 | } | 195 | } |
196 | 196 | ||
197 | int dow = ev.date().dayOfWeek(); | 197 | int dow = ev.date().dayOfWeek(); |
198 | if ( !bOnMonday ) { | 198 | if ( !bOnMonday ) { |
199 | if ( dow == 7 ) | 199 | if ( dow == 7 ) |
200 | dow = 1; | 200 | dow = 1; |
201 | else | 201 | else |
202 | dow++; | 202 | dow++; |
203 | } | 203 | } |
204 | int x = header->sectionPos( dow ) - 1; | 204 | int x = header->sectionPos( dow ) - 1; |
205 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); | 205 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); |
206 | DateBookWeekItem *isect = 0; | 206 | DateBookWeekItem *isect = 0; |
207 | do { | 207 | do { |
208 | i->setGeometry( x, y, Width, h ); | 208 | i->setGeometry( x, y, Width, h ); |
209 | isect = intersects( i ); | 209 | isect = intersects( i ); |
210 | x += Width - 1; | 210 | x += Width - 1; |
211 | } while ( isect && x < xlim ); | 211 | } while ( isect && x < xlim ); |
212 | } | 212 | } |
213 | 213 | ||
214 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) | 214 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) |
215 | { | 215 | { |
216 | QRect geom = item->geometry(); | 216 | QRect geom = item->geometry(); |
217 | 217 | ||
218 | // We allow the edges to overlap | 218 | // We allow the edges to overlap |
219 | geom.moveBy( 1, 1 ); | 219 | geom.moveBy( 1, 1 ); |
220 | geom.setSize( geom.size()-QSize(2,2) ); | 220 | geom.setSize( geom.size()-QSize(2,2) ); |
221 | 221 | ||
222 | QListIterator<DateBookWeekItem> it(items); | 222 | QListIterator<DateBookWeekItem> it(items); |
223 | for ( ; it.current(); ++it ) { | 223 | for ( ; it.current(); ++it ) { |
224 | DateBookWeekItem *i = it.current(); | 224 | DateBookWeekItem *i = it.current(); |
225 | if ( i != item ) { | 225 | if ( i != item ) { |
226 | if ( i->geometry().intersects( geom ) ) { | 226 | if ( i->geometry().intersects( geom ) ) { |
227 | return i; | 227 | return i; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | return 0; | 232 | return 0; |
233 | } | 233 | } |
234 | 234 | ||
235 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) | 235 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) |
236 | { | 236 | { |
237 | QListIterator<DateBookWeekItem> it(items); | 237 | QListIterator<DateBookWeekItem> it(items); |
238 | for ( ; it.current(); ++it ) { | 238 | for ( ; it.current(); ++it ) { |
239 | DateBookWeekItem *i = it.current(); | 239 | DateBookWeekItem *i = it.current(); |
240 | if ( i->geometry().contains( e->pos() ) ) { | 240 | if ( i->geometry().contains( e->pos() ) ) { |
241 | showingEvent = true; | 241 | showingEvent = true; |
242 | emit signalShowEvent( i->event() ); | 242 | emit signalShowEvent( i->event() ); |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) | 248 | void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) |
249 | { | 249 | { |
250 | if ( showingEvent ) { | 250 | if ( showingEvent ) { |
251 | showingEvent = false; | 251 | showingEvent = false; |
252 | emit signalHideEvent(); | 252 | emit signalHideEvent(); |
253 | } else { | 253 | } else { |
254 | int d = header->sectionAt( e->pos().x() ); | 254 | int d = header->sectionAt( e->pos().x() ); |
255 | if ( d > 0 ) { | 255 | if ( d > 0 ) { |
256 | // if ( !bOnMonday ) | 256 | // if ( !bOnMonday ) |
257 | // d--; | 257 | // d--; |
258 | emit showDay( d ); | 258 | emit showDay( d ); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) | 263 | void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) |
264 | { | 264 | { |
265 | QRect ur( cx, cy, cw, ch ); | 265 | QRect ur( cx, cy, cw, ch ); |
266 | p->setPen( lightGray ); | 266 | p->setPen( lightGray ); |
267 | for ( int i = 1; i <= 7; i++ ) | 267 | for ( int i = 1; i <= 7; i++ ) |
268 | p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); | 268 | p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); |
269 | 269 | ||
270 | p->setPen( black ); | 270 | p->setPen( black ); |
271 | for ( int t = 0; t < 24; t++ ) { | 271 | for ( int t = 0; t < 24; t++ ) { |
272 | int y = t*rowHeight; | 272 | int y = t*rowHeight; |
273 | if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { | 273 | if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { |
274 | QString s; | 274 | QString s; |
275 | if ( ampm ) { | 275 | if ( ampm ) { |
276 | if ( t == 0 ) | 276 | if ( t == 0 ) |
277 | s = QString::number( 12 ); | 277 | s = QString::number( 12 ); |
278 | else if ( t == 12 ) | 278 | else if ( t == 12 ) |
279 | s = QString::number(12) + tr( "p" ); | 279 | s = QString::number(12) + tr( "p" ); |
280 | else if ( t > 12 ) { | 280 | else if ( t > 12 ) { |
281 | if ( t - 12 < 10 ) | 281 | if ( t - 12 < 10 ) |
282 | s = " "; | 282 | s = " "; |
283 | else | 283 | else |
284 | s = ""; | 284 | s = ""; |
285 | s += QString::number( t - 12 ) + tr("p"); | 285 | s += QString::number( t - 12 ) + tr("p"); |
286 | } else { | 286 | } else { |
287 | if ( 12 - t < 3 ) | 287 | if ( 12 - t < 3 ) |
288 | s = ""; | 288 | s = ""; |
289 | else | 289 | else |
290 | s = " "; | 290 | s = " "; |
291 | s += QString::number( t ); | 291 | s += QString::number( t ); |
292 | } | 292 | } |
293 | } else { | 293 | } else { |
294 | s = QString::number( t ); | 294 | s = QString::number( t ); |
295 | if ( s.length() == 1 ) | 295 | if ( s.length() == 1 ) |
296 | s.prepend( "0" ); | 296 | s.prepend( "0" ); |
297 | } | 297 | } |
298 | p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); | 298 | p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | QListIterator<DateBookWeekItem> it(items); | 302 | QListIterator<DateBookWeekItem> it(items); |
303 | for ( ; it.current(); ++it ) { | 303 | for ( ; it.current(); ++it ) { |
304 | DateBookWeekItem *i = it.current(); | 304 | DateBookWeekItem *i = it.current(); |
305 | if ( i->geometry().intersects( ur ) ) { | 305 | if ( i->geometry().intersects( ur ) ) { |
306 | p->setBrush( i->color() ); | 306 | p->setBrush( i->color() ); |
307 | p->drawRect( i->geometry() ); | 307 | p->drawRect( i->geometry() ); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | void DateBookWeekView::resizeEvent( QResizeEvent *e ) | 312 | void DateBookWeekView::resizeEvent( QResizeEvent *e ) |
313 | { | 313 | { |
314 | const int hourWidth = 20; | 314 | const int hourWidth = 20; |
315 | QScrollView::resizeEvent( e ); | 315 | QScrollView::resizeEvent( e ); |
316 | int avail = width()-qApp->style().scrollBarExtent().width()-1; | 316 | int avail = visibleWidth(); |
317 | header->setGeometry( 0, 0, avail, header->sizeHint().height() ); | 317 | header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), |
318 | setMargins( 0, header->height(), 0, 0 ); | 318 | visibleWidth(), header->sizeHint().height() ); |
319 | setMargins( 0, header->sizeHint().height(), 0, 0 ); | ||
319 | header->resizeSection( 0, hourWidth ); | 320 | header->resizeSection( 0, hourWidth ); |
320 | int sw = (avail - hourWidth) / 7; | 321 | int sw = (avail - hourWidth) / 7; |
321 | for ( int i = 1; i < 7; i++ ) | 322 | for ( int i = 1; i < 7; i++ ) |
322 | header->resizeSection( i, sw ); | 323 | header->resizeSection( i, sw ); |
323 | header->resizeSection( 7, avail - hourWidth - sw*6 ); | 324 | header->resizeSection( 7, avail - hourWidth - sw*6 ); |
324 | } | 325 | } |
325 | 326 | ||
326 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) | 327 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) |
327 | { | 328 | { |
328 | bOnMonday = bStartOnMonday; | 329 | bOnMonday = bStartOnMonday; |
329 | initNames(); | 330 | initNames(); |
330 | } | 331 | } |
331 | 332 | ||
332 | //------------------------------------------------------------------- | 333 | //------------------------------------------------------------------- |
333 | 334 | ||
334 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, | 335 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, |
335 | QWidget *parent, const char *name ) | 336 | QWidget *parent, const char *name ) |
336 | : QWidget( parent, name ), | 337 | : QWidget( parent, name ), |
337 | db( newDB ), | 338 | db( newDB ), |
338 | startTime( 0 ), | 339 | startTime( 0 ), |
339 | ampm( ap ), | 340 | ampm( ap ), |
340 | bStartOnMonday( startOnMonday ) | 341 | bStartOnMonday( startOnMonday ) |
341 | { | 342 | { |
342 | setFocusPolicy(StrongFocus); | 343 | setFocusPolicy(StrongFocus); |
343 | QVBoxLayout *vb = new QVBoxLayout( this ); | 344 | QVBoxLayout *vb = new QVBoxLayout( this ); |
344 | header = new DateBookWeekHeader( bStartOnMonday, this ); | 345 | header = new DateBookWeekHeader( bStartOnMonday, this ); |
345 | view = new DateBookWeekView( ampm, startOnMonday, this ); | 346 | view = new DateBookWeekView( ampm, startOnMonday, this ); |
346 | vb->addWidget( header ); | 347 | vb->addWidget( header ); |
347 | vb->addWidget( view ); | 348 | vb->addWidget( view ); |
348 | 349 | ||
349 | lblDesc = new QLabel( this, "event label" ); | 350 | lblDesc = new QLabel( this, "event label" ); |
350 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); | 351 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); |
351 | lblDesc->setBackgroundColor( yellow ); | 352 | lblDesc->setBackgroundColor( yellow ); |
352 | lblDesc->hide(); | 353 | lblDesc->hide(); |
353 | 354 | ||
354 | tHide = new QTimer( this ); | 355 | tHide = new QTimer( this ); |
355 | 356 | ||
356 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); | 357 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); |
357 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); | 358 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); |
358 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); | 359 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); |
359 | connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); | 360 | connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); |
360 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); | 361 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); |
361 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 362 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
362 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); | 363 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); |
363 | setDate(QDate::currentDate()); | 364 | setDate(QDate::currentDate()); |
364 | } | 365 | } |
365 | 366 | ||
366 | void DateBookWeek::keyPressEvent(QKeyEvent *e) | 367 | void DateBookWeek::keyPressEvent(QKeyEvent *e) |
367 | { | 368 | { |
368 | switch(e->key()) { | 369 | switch(e->key()) { |
369 | case Key_Up: | 370 | case Key_Up: |
370 | view->scrollBy(0, -20); | 371 | view->scrollBy(0, -20); |
371 | break; | 372 | break; |
372 | case Key_Down: | 373 | case Key_Down: |
373 | view->scrollBy(0, 20); | 374 | view->scrollBy(0, 20); |
374 | break; | 375 | break; |
375 | case Key_Left: | 376 | case Key_Left: |
376 | setDate(date().addDays(-7)); | 377 | setDate(date().addDays(-7)); |
377 | break; | 378 | break; |
378 | case Key_Right: | 379 | case Key_Right: |
379 | setDate(date().addDays(7)); | 380 | setDate(date().addDays(7)); |
380 | break; | 381 | break; |
381 | default: | 382 | default: |
382 | e->ignore(); | 383 | e->ignore(); |
383 | } | 384 | } |
384 | } | 385 | } |
385 | 386 | ||
386 | void DateBookWeek::showDay( int day ) | 387 | void DateBookWeek::showDay( int day ) |
387 | { | 388 | { |
388 | QDate d=bdate; | 389 | QDate d=bdate; |
389 | 390 | ||
390 | // Calculate offset to first day of week. | 391 | // Calculate offset to first day of week. |
391 | int dayoffset=d.dayOfWeek() % 7; | 392 | int dayoffset=d.dayOfWeek() % 7; |
392 | 393 | ||
393 | if(bStartOnMonday) dayoffset--; | 394 | if(bStartOnMonday) dayoffset--; |
394 | 395 | ||
395 | day--; | 396 | day--; |
396 | d=d.addDays(day-dayoffset); | 397 | d=d.addDays(day-dayoffset); |
397 | emit showDate( d.year(), d.month(), d.day() ); | 398 | emit showDate( d.year(), d.month(), d.day() ); |
398 | } | 399 | } |
399 | 400 | ||
400 | void DateBookWeek::setDate( int y, int m, int d ) | 401 | void DateBookWeek::setDate( int y, int m, int d ) |
401 | { | 402 | { |
402 | setDate(QDate(y, m, d)); | 403 | setDate(QDate(y, m, d)); |
403 | } | 404 | } |
404 | 405 | ||
405 | void DateBookWeek::setDate(QDate newdate) | 406 | void DateBookWeek::setDate(QDate newdate) |
406 | { | 407 | { |
407 | bdate=newdate; | 408 | bdate=newdate; |
408 | dow = newdate.dayOfWeek(); | 409 | dow = newdate.dayOfWeek(); |
409 | header->setDate( newdate ); | 410 | header->setDate( newdate ); |
410 | } | 411 | } |
411 | 412 | ||
412 | void DateBookWeek::dateChanged( QDate &newdate ) | 413 | void DateBookWeek::dateChanged( QDate &newdate ) |
413 | { | 414 | { |
414 | bdate=newdate; | 415 | bdate=newdate; |
415 | getEvents(); | 416 | getEvents(); |
416 | } | 417 | } |
417 | 418 | ||
418 | QDate DateBookWeek::date() const | 419 | QDate DateBookWeek::date() const |
419 | { | 420 | { |
420 | return bdate; | 421 | return bdate; |
421 | } | 422 | } |
422 | 423 | ||
423 | void DateBookWeek::getEvents() | 424 | void DateBookWeek::getEvents() |
424 | { | 425 | { |
425 | QDate startWeek = weekDate(); | 426 | QDate startWeek = weekDate(); |
426 | 427 | ||
427 | QDate endWeek = startWeek.addDays( 6 ); | 428 | QDate endWeek = startWeek.addDays( 6 ); |
428 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); | 429 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); |
429 | view->showEvents( eventList ); | 430 | view->showEvents( eventList ); |
430 | view->moveToHour( startTime ); | 431 | view->moveToHour( startTime ); |
431 | } | 432 | } |
432 | 433 | ||
433 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | 434 | void DateBookWeek::generateAllDayTooltext( QString& text ) { |
434 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 435 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
435 | } | 436 | } |
436 | 437 | ||
437 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { | 438 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { |
438 | str += "<b>" + QObject::tr("Start") + "</b>: "; | 439 | str += "<b>" + QObject::tr("Start") + "</b>: "; |
439 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); | 440 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); |
440 | if( ev.startDate()!=ev.endDate() ) { | 441 | if( ev.startDate()!=ev.endDate() ) { |
441 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; | 442 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; |
442 | } | 443 | } |
443 | str += "<br>"; | 444 | str += "<br>"; |
444 | str += "<b>" + QObject::tr("End") + "</b>: "; | 445 | str += "<b>" + QObject::tr("End") + "</b>: "; |
445 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); | 446 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); |
446 | if( ev.startDate()!=ev.endDate() ) { | 447 | if( ev.startDate()!=ev.endDate() ) { |
447 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; | 448 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; |
448 | } | 449 | } |
449 | } | 450 | } |
450 | 451 | ||
451 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | 452 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) |
452 | { | 453 | { |
453 | if ( tHide->isActive() ) | 454 | if ( tHide->isActive() ) |
454 | tHide->stop(); | 455 | tHide->stop(); |
455 | 456 | ||
456 | // why would someone use "<"? Oh well, fix it up... | 457 | // why would someone use "<"? Oh well, fix it up... |
457 | // I wonder what other things may be messed up... | 458 | // I wonder what other things may be messed up... |
458 | QString strDesc = ev.description(); | 459 | QString strDesc = ev.description(); |
459 | int where = strDesc.find( "<" ); | 460 | int where = strDesc.find( "<" ); |
460 | while ( where != -1 ) { | 461 | while ( where != -1 ) { |
461 | strDesc.remove( where, 1 ); | 462 | strDesc.remove( where, 1 ); |
462 | strDesc.insert( where, "<" ); | 463 | strDesc.insert( where, "<" ); |
463 | where = strDesc.find( "<", where ); | 464 | where = strDesc.find( "<", where ); |
464 | } | 465 | } |
465 | 466 | ||
466 | QString strCat; | 467 | QString strCat; |
467 | // ### FIX later... | 468 | // ### FIX later... |
468 | // QString strCat = ev.category(); | 469 | // QString strCat = ev.category(); |
469 | // where = strCat.find( "<" ); | 470 | // where = strCat.find( "<" ); |
470 | // while ( where != -1 ) { | 471 | // while ( where != -1 ) { |
471 | // strCat.remove( where, 1 ); | 472 | // strCat.remove( where, 1 ); |
472 | // strCat.insert( where, "<" ); | 473 | // strCat.insert( where, "<" ); |
473 | // where = strCat.find( "<", where ); | 474 | // where = strCat.find( "<", where ); |
474 | // } | 475 | // } |
475 | 476 | ||
476 | QString strLocation = ev.location(); | 477 | QString strLocation = ev.location(); |
477 | while ( where != -1 ) { | 478 | while ( where != -1 ) { |
478 | strLocation.remove( where, 1 ); | 479 | strLocation.remove( where, 1 ); |
479 | strLocation.insert( where, "<" ); | 480 | strLocation.insert( where, "<" ); |
480 | where = strLocation.find( "<", where ); | 481 | where = strLocation.find( "<", where ); |
481 | } | 482 | } |
482 | 483 | ||
483 | QString strNote = ev.notes(); | 484 | QString strNote = ev.notes(); |
484 | where = strNote.find( "<" ); | 485 | where = strNote.find( "<" ); |
485 | while ( where != -1 ) { | 486 | while ( where != -1 ) { |
486 | strNote.remove( where, 1 ); | 487 | strNote.remove( where, 1 ); |
487 | strNote.insert( where, "<" ); | 488 | strNote.insert( where, "<" ); |
488 | where = strNote.find( "<", where ); | 489 | where = strNote.find( "<", where ); |
489 | } | 490 | } |
490 | 491 | ||
491 | QString str = "<b>" + strDesc + "</b><br>" | 492 | QString str = "<b>" + strDesc + "</b><br>" |
492 | + strLocation + "<br>" | 493 | + strLocation + "<br>" |
493 | + "<i>" + strCat + "</i>" | 494 | + "<i>" + strCat + "</i>" |
494 | + "<br>" + TimeString::longDateString( ev.date() ) | 495 | + "<br>" + TimeString::longDateString( ev.date() ) |
495 | + "<br>"; | 496 | + "<br>"; |
496 | 497 | ||
497 | if (ev.event().type() == Event::Normal ) | 498 | if (ev.event().type() == Event::Normal ) |
498 | generateNormalTooltext( str, ev ); | 499 | generateNormalTooltext( str, ev ); |
499 | else | 500 | else |
500 | generateAllDayTooltext( str ); | 501 | generateAllDayTooltext( str ); |
501 | 502 | ||
502 | str += "<br><br>" + strNote; | 503 | str += "<br><br>" + strNote; |
503 | 504 | ||
504 | lblDesc->setText( str ); | 505 | lblDesc->setText( str ); |
505 | lblDesc->resize( lblDesc->sizeHint() ); | 506 | lblDesc->resize( lblDesc->sizeHint() ); |
506 | // move the label so it is "centerd" horizontally... | 507 | // move the label so it is "centerd" horizontally... |
507 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); | 508 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); |
508 | lblDesc->show(); | 509 | lblDesc->show(); |
509 | } | 510 | } |
510 | 511 | ||