author | umopapisdn <umopapisdn> | 2003-05-13 23:05:10 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-05-13 23:05:10 (UTC) |
commit | 3cd39cd981c4691c559042075c5223d09c87007e (patch) (unidiff) | |
tree | 729ffa45a15a09f744860829e2ae0839871157f7 | |
parent | 1e0e2f57472538bd880967ebe061c8f39a7e270b (diff) | |
download | opie-3cd39cd981c4691c559042075c5223d09c87007e.zip opie-3cd39cd981c4691c559042075c5223d09c87007e.tar.gz opie-3cd39cd981c4691c559042075c5223d09c87007e.tar.bz2 |
Bugfix: (Bug #0000862) The red time marker should only be visible if we are showing today's date.
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 8232a51..0b213e9 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -133,688 +133,690 @@ void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | |||
133 | p->drawLine( x2, 0, x2, y2 ); | 133 | p->drawLine( x2, 0, x2, y2 ); |
134 | p->drawLine( 0, y2, x2, y2 ); | 134 | p->drawLine( 0, y2, x2, y2 ); |
135 | 135 | ||
136 | p->setPen( colorGroup().midlight() ); | 136 | p->setPen( colorGroup().midlight() ); |
137 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 137 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
138 | 138 | ||
139 | p->setPen( pen ); | 139 | p->setPen( pen ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 143 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
144 | { | 144 | { |
145 | } | 145 | } |
146 | 146 | ||
147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
148 | { | 148 | { |
149 | QTable::resizeEvent( e ); | 149 | QTable::resizeEvent( e ); |
150 | columnWidthChanged( 0 ); | 150 | columnWidthChanged( 0 ); |
151 | emit sigColWidthChanged(); | 151 | emit sigColWidthChanged(); |
152 | } | 152 | } |
153 | 153 | ||
154 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 154 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
155 | { | 155 | { |
156 | QString txt = e->text(); | 156 | QString txt = e->text(); |
157 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 157 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
158 | // we this is some sort of thing we know about... | 158 | // we this is some sort of thing we know about... |
159 | e->accept(); | 159 | e->accept(); |
160 | emit sigCapturedKey( txt ); | 160 | emit sigCapturedKey( txt ); |
161 | } else { | 161 | } else { |
162 | // I don't know what this key is, do you? | 162 | // I don't know what this key is, do you? |
163 | e->ignore(); | 163 | e->ignore(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | void DateBookDayView::setRowStyle( int style ) | 167 | void DateBookDayView::setRowStyle( int style ) |
168 | { | 168 | { |
169 | if (style<0) style = 0; | 169 | if (style<0) style = 0; |
170 | 170 | ||
171 | for (int i=0; i<numRows(); i++) | 171 | for (int i=0; i<numRows(); i++) |
172 | setRowHeight(i, style*10+20); | 172 | setRowHeight(i, style*10+20); |
173 | } | 173 | } |
174 | 174 | ||
175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) | 175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) |
176 | { | 176 | { |
177 | int sh=99,eh=-1; | 177 | int sh=99,eh=-1; |
178 | 178 | ||
179 | for(int i=0;i<this->numSelections();i++) { | 179 | for(int i=0;i<this->numSelections();i++) { |
180 | QTableSelection sel = this->selection( i ); | 180 | QTableSelection sel = this->selection( i ); |
181 | sh = QMIN(sh,sel.topRow()); | 181 | sh = QMIN(sh,sel.topRow()); |
182 | eh = QMAX(sh,sel.bottomRow()+1); | 182 | eh = QMAX(sh,sel.bottomRow()+1); |
183 | } | 183 | } |
184 | if (sh > 23 || eh < 1) { | 184 | if (sh > 23 || eh < 1) { |
185 | sh=8; | 185 | sh=8; |
186 | eh=9; | 186 | eh=9; |
187 | } | 187 | } |
188 | 188 | ||
189 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); | 189 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); |
190 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | 190 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); |
191 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); | 191 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); |
192 | quickLineEdit->setFocus(); | 192 | quickLineEdit->setFocus(); |
193 | quickLineEdit->show(); | 193 | quickLineEdit->show(); |
194 | } | 194 | } |
195 | 195 | ||
196 | //=========================================================================== | 196 | //=========================================================================== |
197 | 197 | ||
198 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) | 198 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) |
199 | { | 199 | { |
200 | active=1; | 200 | active=1; |
201 | quickEvent.setStart(start); | 201 | quickEvent.setStart(start); |
202 | quickEvent.setEnd(end); | 202 | quickEvent.setEnd(end); |
203 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); | 203 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
204 | } | 204 | } |
205 | 205 | ||
206 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | 206 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
207 | { | 207 | { |
208 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | 208 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. |
209 | quickEvent.setDescription(this->text()); | 209 | quickEvent.setDescription(this->text()); |
210 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); | 210 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); |
211 | emit(insertEvent(quickEvent)); | 211 | emit(insertEvent(quickEvent)); |
212 | active=0; | 212 | active=0; |
213 | } | 213 | } |
214 | this->close(true);// Close and also delete this widget | 214 | this->close(true);// Close and also delete this widget |
215 | } | 215 | } |
216 | 216 | ||
217 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) | 217 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) |
218 | { | 218 | { |
219 | slotReturnPressed(); // Reuse code to add event and close this widget. | 219 | slotReturnPressed(); // Reuse code to add event and close this widget. |
220 | } | 220 | } |
221 | 221 | ||
222 | //=========================================================================== | 222 | //=========================================================================== |
223 | 223 | ||
224 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | 224 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) |
225 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | 225 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) |
226 | { | 226 | { |
227 | widgetList.setAutoDelete( true ); | 227 | widgetList.setAutoDelete( true ); |
228 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 228 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
229 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 229 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
230 | view = new DateBookDayView( ampm, this, "day view" ); | 230 | view = new DateBookDayView( ampm, this, "day view" ); |
231 | 231 | ||
232 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); | 232 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); |
233 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); | 233 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); |
234 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); | 234 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
235 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 235 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
236 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); | 236 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); |
237 | 237 | ||
238 | QTimer *timer = new QTimer( this ); | 238 | QTimer *timer = new QTimer( this ); |
239 | 239 | ||
240 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | 240 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
241 | timer->start( 1000*60*5, FALSE ); //update every 5min | 241 | timer->start( 1000*60*5, FALSE ); //update every 5min |
242 | 242 | ||
243 | selectedWidget = 0; | 243 | selectedWidget = 0; |
244 | 244 | ||
245 | timeMarker = new DateBookDayTimeMarker( this ); | 245 | timeMarker = new DateBookDayTimeMarker( this ); |
246 | timeMarker->setTime( QTime::currentTime() ); | 246 | timeMarker->setTime( QTime::currentTime() ); |
247 | rowStyle = -1; // initialize with bogus values | 247 | rowStyle = -1; // initialize with bogus values |
248 | } | 248 | } |
249 | 249 | ||
250 | void DateBookDay::setJumpToCurTime( bool bJump ) | 250 | void DateBookDay::setJumpToCurTime( bool bJump ) |
251 | { | 251 | { |
252 | jumpToCurTime = bJump; | 252 | jumpToCurTime = bJump; |
253 | } | 253 | } |
254 | 254 | ||
255 | void DateBookDay::setRowStyle( int style ) | 255 | void DateBookDay::setRowStyle( int style ) |
256 | { | 256 | { |
257 | if (rowStyle != style) view->setRowStyle( style ); | 257 | if (rowStyle != style) view->setRowStyle( style ); |
258 | rowStyle = style; | 258 | rowStyle = style; |
259 | } | 259 | } |
260 | 260 | ||
261 | void DateBookDay::updateView( void ) | 261 | void DateBookDay::updateView( void ) |
262 | { | 262 | { |
263 | timeMarker->setTime( QTime::currentTime() ); | 263 | timeMarker->setTime( QTime::currentTime() ); |
264 | //need to find a way to update all DateBookDayWidgets | 264 | //need to find a way to update all DateBookDayWidgets |
265 | } | 265 | } |
266 | 266 | ||
267 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | 267 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) |
268 | { | 268 | { |
269 | selectedWidget = w; | 269 | selectedWidget = w; |
270 | } | 270 | } |
271 | 271 | ||
272 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | 272 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) |
273 | { | 273 | { |
274 | return selectedWidget; | 274 | return selectedWidget; |
275 | } | 275 | } |
276 | 276 | ||
277 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 277 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
278 | { | 278 | { |
279 | start.setDate( currDate ); | 279 | start.setDate( currDate ); |
280 | end.setDate( currDate ); | 280 | end.setDate( currDate ); |
281 | 281 | ||
282 | int sh=99,eh=-1; | 282 | int sh=99,eh=-1; |
283 | 283 | ||
284 | int n = dayView()->numSelections(); | 284 | int n = dayView()->numSelections(); |
285 | 285 | ||
286 | for (int i=0; i<n; i++) { | 286 | for (int i=0; i<n; i++) { |
287 | QTableSelection sel = dayView()->selection( i ); | 287 | QTableSelection sel = dayView()->selection( i ); |
288 | sh = QMIN(sh,sel.topRow()); | 288 | sh = QMIN(sh,sel.topRow()); |
289 | eh = QMAX(sh,sel.bottomRow()+1); | 289 | eh = QMAX(sh,sel.bottomRow()+1); |
290 | } | 290 | } |
291 | 291 | ||
292 | if (sh > 23 || eh < 1) { | 292 | if (sh > 23 || eh < 1) { |
293 | sh=8; | 293 | sh=8; |
294 | eh=9; | 294 | eh=9; |
295 | } | 295 | } |
296 | 296 | ||
297 | start.setTime( QTime( sh, 0, 0 ) ); | 297 | start.setTime( QTime( sh, 0, 0 ) ); |
298 | end.setTime( QTime( eh, 0, 0 ) ); | 298 | end.setTime( QTime( eh, 0, 0 ) ); |
299 | } | 299 | } |
300 | 300 | ||
301 | void DateBookDay::setDate( int y, int m, int d ) | 301 | void DateBookDay::setDate( int y, int m, int d ) |
302 | { | 302 | { |
303 | header->setDate( y, m, d ); | 303 | header->setDate( y, m, d ); |
304 | selectedWidget = 0; | 304 | selectedWidget = 0; |
305 | } | 305 | } |
306 | 306 | ||
307 | void DateBookDay::setDate( QDate d) | 307 | void DateBookDay::setDate( QDate d) |
308 | { | 308 | { |
309 | header->setDate( d.year(), d.month(), d.day() ); | 309 | header->setDate( d.year(), d.month(), d.day() ); |
310 | selectedWidget = 0; | 310 | selectedWidget = 0; |
311 | } | 311 | } |
312 | 312 | ||
313 | void DateBookDay::dateChanged( int y, int m, int d ) | 313 | void DateBookDay::dateChanged( int y, int m, int d ) |
314 | { | 314 | { |
315 | QDate date( y, m, d ); | 315 | QDate date( y, m, d ); |
316 | if ( currDate == date ) | 316 | if ( currDate == date ) |
317 | return; | 317 | return; |
318 | currDate.setYMD( y, m, d ); | 318 | currDate.setYMD( y, m, d ); |
319 | relayoutPage(); | 319 | relayoutPage(); |
320 | dayView()->clearSelection(); | 320 | dayView()->clearSelection(); |
321 | QTableSelection ts; | 321 | QTableSelection ts; |
322 | 322 | ||
323 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 323 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
324 | { | 324 | { |
325 | ts.init( QTime::currentTime().hour(), 0); | 325 | ts.init( QTime::currentTime().hour(), 0); |
326 | ts.expandTo( QTime::currentTime().hour(), 0); | 326 | ts.expandTo( QTime::currentTime().hour(), 0); |
327 | } else { | 327 | } else { |
328 | ts.init( startTime, 0 ); | 328 | ts.init( startTime, 0 ); |
329 | ts.expandTo( startTime, 0 ); | 329 | ts.expandTo( startTime, 0 ); |
330 | } | 330 | } |
331 | 331 | ||
332 | dayView()->addSelection( ts ); | 332 | dayView()->addSelection( ts ); |
333 | selectedWidget = 0; | 333 | selectedWidget = 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void DateBookDay::redraw() | 336 | void DateBookDay::redraw() |
337 | { | 337 | { |
338 | if ( isUpdatesEnabled() ) | 338 | if ( isUpdatesEnabled() ) |
339 | relayoutPage(); | 339 | relayoutPage(); |
340 | } | 340 | } |
341 | 341 | ||
342 | void DateBookDay::getEvents() | 342 | void DateBookDay::getEvents() |
343 | { | 343 | { |
344 | widgetList.clear(); | 344 | widgetList.clear(); |
345 | 345 | ||
346 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 346 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); |
347 | QValueListIterator<EffectiveEvent> it; | 347 | QValueListIterator<EffectiveEvent> it; |
348 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 348 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { |
349 | EffectiveEvent ev=*it; | 349 | EffectiveEvent ev=*it; |
350 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 350 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. |
351 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 351 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
352 | connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); | 352 | connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); |
353 | connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); | 353 | connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); |
354 | connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); | 354 | connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); |
355 | connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); | 355 | connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); |
356 | widgetList.append( w ); | 356 | widgetList.append( w ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 361 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
362 | { | 362 | { |
363 | int place = 0; | 363 | int place = 0; |
364 | int start = item->event().start().hour(); | 364 | int start = item->event().start().hour(); |
365 | QTime e = item->event().end(); | 365 | QTime e = item->event().end(); |
366 | int end = e.hour(); | 366 | int end = e.hour(); |
367 | if ( e.minute() < 5 ) | 367 | if ( e.minute() < 5 ) |
368 | end--; | 368 | end--; |
369 | if ( end < start ) | 369 | if ( end < start ) |
370 | end = start; | 370 | end = start; |
371 | while ( place < maxn ) { | 371 | while ( place < maxn ) { |
372 | bool free = TRUE; | 372 | bool free = TRUE; |
373 | int s = start; | 373 | int s = start; |
374 | while( s <= end ) { | 374 | while( s <= end ) { |
375 | if ( used[10*s+place] ) { | 375 | if ( used[10*s+place] ) { |
376 | free = FALSE; | 376 | free = FALSE; |
377 | break; | 377 | break; |
378 | } | 378 | } |
379 | s++; | 379 | s++; |
380 | } | 380 | } |
381 | if ( free ) | 381 | if ( free ) |
382 | break; | 382 | break; |
383 | place++; | 383 | place++; |
384 | } | 384 | } |
385 | if ( place == maxn ) { | 385 | if ( place == maxn ) { |
386 | return -1; | 386 | return -1; |
387 | } | 387 | } |
388 | while( start <= end ) { | 388 | while( start <= end ) { |
389 | used[10*start+place] = TRUE; | 389 | used[10*start+place] = TRUE; |
390 | start++; | 390 | start++; |
391 | } | 391 | } |
392 | return place; | 392 | return place; |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | void DateBookDay::relayoutPage( bool fromResize ) | 396 | void DateBookDay::relayoutPage( bool fromResize ) |
397 | { | 397 | { |
398 | setUpdatesEnabled( FALSE ); | 398 | setUpdatesEnabled( FALSE ); |
399 | if ( !fromResize ) | 399 | if ( !fromResize ) |
400 | getEvents(); // no need we already have them! | 400 | getEvents(); // no need we already have them! |
401 | 401 | ||
402 | widgetList.sort(); | 402 | widgetList.sort(); |
403 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning | 403 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning |
404 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view | 404 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view |
405 | 405 | ||
406 | int wCount = widgetList.count(); | 406 | int wCount = widgetList.count(); |
407 | int wid = view->columnWidth(0)-1; | 407 | int wid = view->columnWidth(0)-1; |
408 | int wd; | 408 | int wd; |
409 | int n = 1; | 409 | int n = 1; |
410 | 410 | ||
411 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget | 411 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget |
412 | 412 | ||
413 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); | 413 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); |
414 | 414 | ||
415 | if ( wCount < 20 ) { | 415 | if ( wCount < 20 ) { |
416 | 416 | ||
417 | QArray<QRect> geometries(wCount); | 417 | QArray<QRect> geometries(wCount); |
418 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 418 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector |
419 | 419 | ||
420 | for ( int i = 0; i < wCount; i++) { | 420 | for ( int i = 0; i < wCount; i++) { |
421 | QValueList<int> intersectedWidgets; | 421 | QValueList<int> intersectedWidgets; |
422 | 422 | ||
423 | //find all widgets intersecting with widgetList.at(i) | 423 | //find all widgets intersecting with widgetList.at(i) |
424 | for ( int j = 0; j < wCount; j++) { | 424 | for ( int j = 0; j < wCount; j++) { |
425 | if (i != j) | 425 | if (i != j) |
426 | if (geometries[j].intersects(geometries[i])) | 426 | if (geometries[j].intersects(geometries[i])) |
427 | intersectedWidgets.append(j); | 427 | intersectedWidgets.append(j); |
428 | } | 428 | } |
429 | 429 | ||
430 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 430 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
431 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 431 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
432 | { | 432 | { |
433 | QArray<int> inter(wCount); | 433 | QArray<int> inter(wCount); |
434 | inter[j]=1; | 434 | inter[j]=1; |
435 | 435 | ||
436 | if (intersectedWidgets[j] != -1) | 436 | if (intersectedWidgets[j] != -1) |
437 | for ( uint k = j; k < intersectedWidgets.count(); k++) { | 437 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
438 | if (j != k && intersectedWidgets[k] != -1) | 438 | if (j != k && intersectedWidgets[k] != -1) |
439 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { | 439 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
440 | inter[j]++; | 440 | inter[j]++; |
441 | intersectedWidgets[k] = -1; | 441 | intersectedWidgets[k] = -1; |
442 | } | 442 | } |
443 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 443 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 446 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | for ( int i = 0; i < wCount; i++) { | 450 | for ( int i = 0; i < wCount; i++) { |
451 | DateBookDayWidget *w = widgetList.at(i); | 451 | DateBookDayWidget *w = widgetList.at(i); |
452 | QRect geom = w->geometry(); | 452 | QRect geom = w->geometry(); |
453 | geom.setX( 0 ); | 453 | geom.setX( 0 ); |
454 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 454 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
455 | geom.setWidth( wd ); | 455 | geom.setWidth( wd ); |
456 | while ( intersects( w, geom ) ) { | 456 | while ( intersects( w, geom ) ) { |
457 | geom.moveBy( wd + 2 + 1, 0 ); | 457 | geom.moveBy( wd + 2 + 1, 0 ); |
458 | } | 458 | } |
459 | w->setGeometry( geom ); | 459 | w->setGeometry( geom ); |
460 | } | 460 | } |
461 | 461 | ||
462 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 462 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
463 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 463 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
464 | } else { | 464 | } else { |
465 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 465 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
466 | } | 466 | } |
467 | } else { | 467 | } else { |
468 | int hours[24]; | 468 | int hours[24]; |
469 | memset( hours, 0, 24*sizeof( int ) ); | 469 | memset( hours, 0, 24*sizeof( int ) ); |
470 | bool overFlow = FALSE; | 470 | bool overFlow = FALSE; |
471 | for ( int i = 0; i < wCount; i++ ) { | 471 | for ( int i = 0; i < wCount; i++ ) { |
472 | DateBookDayWidget *w = widgetList.at(i); | 472 | DateBookDayWidget *w = widgetList.at(i); |
473 | int start = w->event().start().hour(); | 473 | int start = w->event().start().hour(); |
474 | QTime e = w->event().end(); | 474 | QTime e = w->event().end(); |
475 | int end = e.hour(); | 475 | int end = e.hour(); |
476 | if ( e.minute() < 5 ) | 476 | if ( e.minute() < 5 ) |
477 | end--; | 477 | end--; |
478 | if ( end < start ) | 478 | if ( end < start ) |
479 | end = start; | 479 | end = start; |
480 | while( start <= end ) { | 480 | while( start <= end ) { |
481 | hours[start]++; | 481 | hours[start]++; |
482 | if ( hours[start] >= 10 ) | 482 | if ( hours[start] >= 10 ) |
483 | overFlow = TRUE; | 483 | overFlow = TRUE; |
484 | ++start; | 484 | ++start; |
485 | } | 485 | } |
486 | if ( overFlow ) | 486 | if ( overFlow ) |
487 | break; | 487 | break; |
488 | } | 488 | } |
489 | for ( int i = 0; i < 24; i++ ) { | 489 | for ( int i = 0; i < 24; i++ ) { |
490 | n = QMAX( n, hours[i] ); | 490 | n = QMAX( n, hours[i] ); |
491 | } | 491 | } |
492 | wid = ( view->columnWidth(0)-1 ) / n; | 492 | wid = ( view->columnWidth(0)-1 ) / n; |
493 | 493 | ||
494 | bool used[24*10]; | 494 | bool used[24*10]; |
495 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 495 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
496 | 496 | ||
497 | for ( int i = 0; i < wCount; i++ ) { | 497 | for ( int i = 0; i < wCount; i++ ) { |
498 | DateBookDayWidget *w = widgetList.at(i); | 498 | DateBookDayWidget *w = widgetList.at(i); |
499 | int xp = place( w, used, n ); | 499 | int xp = place( w, used, n ); |
500 | if ( xp != -1 ) { | 500 | if ( xp != -1 ) { |
501 | QRect geom = w->geometry(); | 501 | QRect geom = w->geometry(); |
502 | geom.setX( xp*(wid+2) ); | 502 | geom.setX( xp*(wid+2) ); |
503 | geom.setWidth( wid ); | 503 | geom.setWidth( wid ); |
504 | w->setGeometry( geom ); | 504 | w->setGeometry( geom ); |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 508 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
509 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 509 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
510 | } else { | 510 | } else { |
511 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 511 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 515 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
516 | timeMarker->raise(); //on top of all widgets | 516 | timeMarker->raise(); //on top of all widgets |
517 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day | 517 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day |
518 | timeMarker->show(); else timeMarker->hide(); | 518 | timeMarker->show(); |
519 | 519 | } else { | |
520 | timeMarker->hide(); | ||
521 | } | ||
520 | setUpdatesEnabled( TRUE ); | 522 | setUpdatesEnabled( TRUE ); |
521 | return; | 523 | return; |
522 | } | 524 | } |
523 | 525 | ||
524 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 526 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
525 | { | 527 | { |
526 | int i = 0; | 528 | int i = 0; |
527 | DateBookDayWidget *w = widgetList.at(i); | 529 | DateBookDayWidget *w = widgetList.at(i); |
528 | int wCount = widgetList.count(); | 530 | int wCount = widgetList.count(); |
529 | while ( i < wCount && w != item ) { | 531 | while ( i < wCount && w != item ) { |
530 | if ( w->geometry().intersects( geom ) ) { | 532 | if ( w->geometry().intersects( geom ) ) { |
531 | return w; | 533 | return w; |
532 | } | 534 | } |
533 | w = widgetList.at(++i); | 535 | w = widgetList.at(++i); |
534 | } | 536 | } |
535 | 537 | ||
536 | return 0; | 538 | return 0; |
537 | } | 539 | } |
538 | 540 | ||
539 | 541 | ||
540 | QDate DateBookDay::date() const | 542 | QDate DateBookDay::date() const |
541 | { | 543 | { |
542 | return currDate; | 544 | return currDate; |
543 | } | 545 | } |
544 | 546 | ||
545 | void DateBookDay::setStartViewTime( int startHere ) | 547 | void DateBookDay::setStartViewTime( int startHere ) |
546 | { | 548 | { |
547 | startTime = startHere; | 549 | startTime = startHere; |
548 | dayView()->clearSelection(); | 550 | dayView()->clearSelection(); |
549 | QTableSelection ts; | 551 | QTableSelection ts; |
550 | 552 | ||
551 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? | 553 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? |
552 | ts.init( QTime::currentTime().hour(), 0); | 554 | ts.init( QTime::currentTime().hour(), 0); |
553 | ts.expandTo( QTime::currentTime().hour(), 0); | 555 | ts.expandTo( QTime::currentTime().hour(), 0); |
554 | } else { | 556 | } else { |
555 | ts.init( startTime, 0 ); | 557 | ts.init( startTime, 0 ); |
556 | ts.expandTo( startTime, 0 ); | 558 | ts.expandTo( startTime, 0 ); |
557 | } | 559 | } |
558 | 560 | ||
559 | dayView()->addSelection( ts ); | 561 | dayView()->addSelection( ts ); |
560 | } | 562 | } |
561 | 563 | ||
562 | int DateBookDay::startViewTime() const | 564 | int DateBookDay::startViewTime() const |
563 | { | 565 | { |
564 | return startTime; | 566 | return startTime; |
565 | } | 567 | } |
566 | 568 | ||
567 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 569 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
568 | { | 570 | { |
569 | header->setStartOfWeek( bStartOnMonday ); | 571 | header->setStartOfWeek( bStartOnMonday ); |
570 | //redraw(); | 572 | //redraw(); |
571 | } | 573 | } |
572 | 574 | ||
573 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 575 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
574 | { | 576 | { |
575 | switch(e->key()) { | 577 | switch(e->key()) { |
576 | case Key_Up: | 578 | case Key_Up: |
577 | view->moveUp(); | 579 | view->moveUp(); |
578 | break; | 580 | break; |
579 | case Key_Down: | 581 | case Key_Down: |
580 | view->moveDown(); | 582 | view->moveDown(); |
581 | break; | 583 | break; |
582 | case Key_Left: | 584 | case Key_Left: |
583 | setDate(QDate(currDate).addDays(-1)); | 585 | setDate(QDate(currDate).addDays(-1)); |
584 | break; | 586 | break; |
585 | case Key_Right: | 587 | case Key_Right: |
586 | setDate(QDate(currDate).addDays(1)); | 588 | setDate(QDate(currDate).addDays(1)); |
587 | break; | 589 | break; |
588 | default: | 590 | default: |
589 | e->ignore(); | 591 | e->ignore(); |
590 | } | 592 | } |
591 | } | 593 | } |
592 | 594 | ||
593 | //=========================================================================== | 595 | //=========================================================================== |
594 | 596 | ||
595 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) | 597 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
596 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 598 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
597 | { | 599 | { |
598 | // why would someone use "<"? Oh well, fix it up... | 600 | // why would someone use "<"? Oh well, fix it up... |
599 | // I wonder what other things may be messed up... | 601 | // I wonder what other things may be messed up... |
600 | QString strDesc = ev.description(); | 602 | QString strDesc = ev.description(); |
601 | int where = strDesc.find( "<" ); | 603 | int where = strDesc.find( "<" ); |
602 | while ( where != -1 ) { | 604 | while ( where != -1 ) { |
603 | strDesc.remove( where, 1 ); | 605 | strDesc.remove( where, 1 ); |
604 | strDesc.insert( where, "<" ); | 606 | strDesc.insert( where, "<" ); |
605 | where = strDesc.find( "<", where ); | 607 | where = strDesc.find( "<", where ); |
606 | } | 608 | } |
607 | 609 | ||
608 | QString strCat; | 610 | QString strCat; |
609 | // ### Fix later... | 611 | // ### Fix later... |
610 | // QString strCat = ev.category(); | 612 | // QString strCat = ev.category(); |
611 | // where = strCat.find( "<" ); | 613 | // where = strCat.find( "<" ); |
612 | // while ( where != -1 ) { | 614 | // while ( where != -1 ) { |
613 | // strCat.remove( where, 1 ); | 615 | // strCat.remove( where, 1 ); |
614 | // strCat.insert( where, "<" ); | 616 | // strCat.insert( where, "<" ); |
615 | // where = strCat.find( "<", where ); | 617 | // where = strCat.find( "<", where ); |
616 | // } | 618 | // } |
617 | 619 | ||
618 | QString strNote = ev.notes(); | 620 | QString strNote = ev.notes(); |
619 | where = strNote.find( "<" ); | 621 | where = strNote.find( "<" ); |
620 | while ( where != -1 ) { | 622 | while ( where != -1 ) { |
621 | strNote.remove( where, 1 ); | 623 | strNote.remove( where, 1 ); |
622 | strNote.insert( where, "<" ); | 624 | strNote.insert( where, "<" ); |
623 | where = strNote.find( "<", where ); | 625 | where = strNote.find( "<", where ); |
624 | } | 626 | } |
625 | 627 | ||
626 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 628 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
627 | if ( !strCat.isEmpty() ) { | 629 | if ( !strCat.isEmpty() ) { |
628 | text += strCat + "</i><br>"; | 630 | text += strCat + "</i><br>"; |
629 | } | 631 | } |
630 | if (ev.event().type() == Event::Normal ) { | 632 | if (ev.event().type() == Event::Normal ) { |
631 | setEventText( text ); | 633 | setEventText( text ); |
632 | } else { | 634 | } else { |
633 | setAllDayText( text ); | 635 | setAllDayText( text ); |
634 | } | 636 | } |
635 | 637 | ||
636 | text += "<br><br>" + strNote; | 638 | text += "<br><br>" + strNote; |
637 | 639 | ||
638 | setBackgroundMode( PaletteBase ); | 640 | setBackgroundMode( PaletteBase ); |
639 | 641 | ||
640 | QTime start = ev.start(); | 642 | QTime start = ev.start(); |
641 | QTime end = ev.end(); | 643 | QTime end = ev.end(); |
642 | int y = start.hour()*60+start.minute(); | 644 | int y = start.hour()*60+start.minute(); |
643 | int h = end.hour()*60+end.minute()-y; | 645 | int h = end.hour()*60+end.minute()-y; |
644 | int rh = dateBook->dayView()->rowHeight(0); | 646 | int rh = dateBook->dayView()->rowHeight(0); |
645 | y = y*rh/60; | 647 | y = y*rh/60; |
646 | h = h*rh/60; | 648 | h = h*rh/60; |
647 | 649 | ||
648 | if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. | 650 | if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. |
649 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. | 651 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. |
650 | geom.setY( y ); | 652 | geom.setY( y ); |
651 | geom.setHeight( h ); | 653 | geom.setHeight( h ); |
652 | geom.setX( 0 ); | 654 | geom.setX( 0 ); |
653 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 655 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
654 | 656 | ||
655 | } | 657 | } |
656 | 658 | ||
657 | void DateBookDayWidget::setAllDayText( QString &text ) { | 659 | void DateBookDayWidget::setAllDayText( QString &text ) { |
658 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 660 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
659 | } | 661 | } |
660 | 662 | ||
661 | void DateBookDayWidget::setEventText( QString& text ) { | 663 | void DateBookDayWidget::setEventText( QString& text ) { |
662 | bool whichClock = dateBook->dayView()->whichClock(); | 664 | bool whichClock = dateBook->dayView()->whichClock(); |
663 | if ( ev.startDate() != ev.endDate() ) { | 665 | if ( ev.startDate() != ev.endDate() ) { |
664 | text += "<b>" + tr("Start") + "</b>: "; | 666 | text += "<b>" + tr("Start") + "</b>: "; |
665 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); | 667 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
666 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; | 668 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
667 | text += "<b>" + tr("End") + "</b>: "; | 669 | text += "<b>" + tr("End") + "</b>: "; |
668 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); | 670 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); |
669 | text += " - " + TimeString::longDateString( ev.endDate() ); | 671 | text += " - " + TimeString::longDateString( ev.endDate() ); |
670 | } else { | 672 | } else { |
671 | text += "<b>" + tr("Time") + "</b>: "; | 673 | text += "<b>" + tr("Time") + "</b>: "; |
672 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 674 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
673 | text += "<b>" + tr(" - ") + "</b>"; | 675 | text += "<b>" + tr(" - ") + "</b>"; |
674 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 676 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
675 | } | 677 | } |
676 | } | 678 | } |
677 | 679 | ||
678 | DateBookDayWidget::~DateBookDayWidget() | 680 | DateBookDayWidget::~DateBookDayWidget() |
679 | { | 681 | { |
680 | } | 682 | } |
681 | 683 | ||
682 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 684 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
683 | { | 685 | { |
684 | QPainter p( this ); | 686 | QPainter p( this ); |
685 | 687 | ||
686 | if (dateBook->getSelectedWidget() == this) { | 688 | if (dateBook->getSelectedWidget() == this) { |
687 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 689 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
688 | } else { | 690 | } else { |
689 | if (dateBook->date() == QDate::currentDate()) { | 691 | if (dateBook->date() == QDate::currentDate()) { |
690 | QTime curTime = QTime::currentTime(); | 692 | QTime curTime = QTime::currentTime(); |
691 | if (ev.end() < curTime) { | 693 | if (ev.end() < curTime) { |
692 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 694 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
693 | } else { | 695 | } else { |
694 | //change color in dependence of the time till the event starts | 696 | //change color in dependence of the time till the event starts |
695 | int duration = curTime.secsTo(ev.start()); | 697 | int duration = curTime.secsTo(ev.start()); |
696 | if (duration < 0) duration = 0; | 698 | if (duration < 0) duration = 0; |
697 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 699 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
698 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 700 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
699 | } | 701 | } |
700 | } else { | 702 | } else { |
701 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 703 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
702 | //perhaps make a distinction between future/past dates | 704 | //perhaps make a distinction between future/past dates |
703 | } | 705 | } |
704 | } | 706 | } |
705 | 707 | ||
706 | p.setPen( QColor(100, 100, 100) ); | 708 | p.setPen( QColor(100, 100, 100) ); |
707 | p.drawRect(rect()); | 709 | p.drawRect(rect()); |
708 | 710 | ||
709 | // p.drawRect(0,0, 5, height()); | 711 | // p.drawRect(0,0, 5, height()); |
710 | 712 | ||
711 | int y = 0; | 713 | int y = 0; |
712 | int d = 0; | 714 | int d = 0; |
713 | 715 | ||
714 | if ( ev.event().hasAlarm() ) { | 716 | if ( ev.event().hasAlarm() ) { |
715 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 717 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
716 | y = 20; | 718 | y = 20; |
717 | d = 20; | 719 | d = 20; |
718 | } | 720 | } |
719 | 721 | ||
720 | if ( ev.event().hasRepeat() ) { | 722 | if ( ev.event().hasRepeat() ) { |
721 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 723 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
722 | d = 20; | 724 | d = 20; |
723 | y += 20; | 725 | y += 20; |
724 | } | 726 | } |
725 | 727 | ||
726 | QSimpleRichText rt( text, font() ); | 728 | QSimpleRichText rt( text, font() ); |
727 | rt.setWidth( geom.width() - d - 6 ); | 729 | rt.setWidth( geom.width() - d - 6 ); |
728 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 730 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
729 | } | 731 | } |
730 | 732 | ||
731 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 733 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
732 | { | 734 | { |
733 | DateBookDayWidget *item; | 735 | DateBookDayWidget *item; |
734 | 736 | ||
735 | item = dateBook->getSelectedWidget(); | 737 | item = dateBook->getSelectedWidget(); |
736 | if (item) | 738 | if (item) |
737 | item->update(); | 739 | item->update(); |
738 | 740 | ||
739 | dateBook->setSelectedWidget(this); | 741 | dateBook->setSelectedWidget(this); |
740 | update(); | 742 | update(); |
741 | dateBook->repaint(); | 743 | dateBook->repaint(); |
742 | 744 | ||
743 | QPopupMenu m; | 745 | QPopupMenu m; |
744 | m.insertItem( tr( "Edit" ), 1 ); | 746 | m.insertItem( tr( "Edit" ), 1 ); |
745 | m.insertItem( tr( "Duplicate" ), 4 ); | 747 | m.insertItem( tr( "Duplicate" ), 4 ); |
746 | m.insertItem( tr( "Delete" ), 2 ); | 748 | m.insertItem( tr( "Delete" ), 2 ); |
747 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 749 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
748 | int r = m.exec( e->globalPos() ); | 750 | int r = m.exec( e->globalPos() ); |
749 | if ( r == 1 ) { | 751 | if ( r == 1 ) { |
750 | emit editMe( ev.event() ); | 752 | emit editMe( ev.event() ); |
751 | } else if ( r == 2 ) { | 753 | } else if ( r == 2 ) { |
752 | emit deleteMe( ev.event() ); | 754 | emit deleteMe( ev.event() ); |
753 | } else if ( r == 3 ) { | 755 | } else if ( r == 3 ) { |
754 | emit beamMe( ev.event() ); | 756 | emit beamMe( ev.event() ); |
755 | } else if ( r == 4 ) { | 757 | } else if ( r == 4 ) { |
756 | emit duplicateMe( ev.event() ); | 758 | emit duplicateMe( ev.event() ); |
757 | } | 759 | } |
758 | } | 760 | } |
759 | 761 | ||
760 | void DateBookDayWidget::setGeometry( const QRect &r ) | 762 | void DateBookDayWidget::setGeometry( const QRect &r ) |
761 | { | 763 | { |
762 | geom = r; | 764 | geom = r; |
763 | setFixedSize( r.width()+1, r.height()+1 ); | 765 | setFixedSize( r.width()+1, r.height()+1 ); |
764 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 766 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
765 | show(); | 767 | show(); |
766 | } | 768 | } |
767 | 769 | ||
768 | 770 | ||
769 | //--------------------------------------------------------------------------------------------- | 771 | //--------------------------------------------------------------------------------------------- |
770 | //--------------------------------------------------------------------------------------------- | 772 | //--------------------------------------------------------------------------------------------- |
771 | 773 | ||
772 | 774 | ||
773 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 775 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
774 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 776 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
775 | { | 777 | { |
776 | setBackgroundMode( PaletteBase ); | 778 | setBackgroundMode( PaletteBase ); |
777 | } | 779 | } |
778 | 780 | ||
779 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 781 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
780 | { | 782 | { |
781 | } | 783 | } |
782 | 784 | ||
783 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 785 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
784 | { | 786 | { |
785 | QPainter p( this ); | 787 | QPainter p( this ); |
786 | p.setBrush( QColor( 255, 0, 0 ) ); | 788 | p.setBrush( QColor( 255, 0, 0 ) ); |
787 | 789 | ||
788 | QPen pen; | 790 | QPen pen; |
789 | pen.setStyle(NoPen); | 791 | pen.setStyle(NoPen); |
790 | 792 | ||
791 | p.setPen( pen ); | 793 | p.setPen( pen ); |
792 | p.drawRect(rect()); | 794 | p.drawRect(rect()); |
793 | } | 795 | } |
794 | 796 | ||
795 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 797 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
796 | { | 798 | { |
797 | int y = t.hour()*60+t.minute(); | 799 | int y = t.hour()*60+t.minute(); |
798 | int rh = dateBook->dayView()->rowHeight(0); | 800 | int rh = dateBook->dayView()->rowHeight(0); |
799 | y = y*rh/60; | 801 | y = y*rh/60; |
800 | 802 | ||
801 | geom.setX( 0 ); | 803 | geom.setX( 0 ); |
802 | 804 | ||
803 | int x = dateBook->dayView()->columnWidth(0)-1; | 805 | int x = dateBook->dayView()->columnWidth(0)-1; |
804 | geom.setWidth( x ); | 806 | geom.setWidth( x ); |
805 | 807 | ||
806 | geom.setY( y ); | 808 | geom.setY( y ); |
807 | geom.setHeight( 1 ); | 809 | geom.setHeight( 1 ); |
808 | 810 | ||
809 | setGeometry( geom ); | 811 | setGeometry( geom ); |
810 | 812 | ||
811 | time = t; | 813 | time = t; |
812 | } | 814 | } |
813 | 815 | ||
814 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | 816 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) |
815 | { | 817 | { |
816 | geom = r; | 818 | geom = r; |
817 | setFixedSize( r.width()+1, r.height()+1 ); | 819 | setFixedSize( r.width()+1, r.height()+1 ); |
818 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 820 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
819 | show(); | 821 | show(); |
820 | } | 822 | } |