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