summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-03-28 11:58:29 (UTC)
committer umopapisdn <umopapisdn>2003-03-28 11:58:29 (UTC)
commit6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a (patch) (unidiff)
tree4b25e548986b560f2fbe5f91ce61491046dcc361
parent469731b3a6cb94037330d1f40398bede57a7c0f2 (diff)
downloadopie-6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a.zip
opie-6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a.tar.gz
opie-6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a.tar.bz2
Bugfix: (Bug #000782) Display events with no duration, unless it's an "effective event" ending at 00:00 starting at a previous day. (i.e ending at midnight)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp2
-rw-r--r--core/pim/datebook/datebookweek.cpp2
-rw-r--r--core/pim/datebook/datebookweeklst.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 5d472a6..af98e06 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -216,193 +216,193 @@ void DateBookDay::setRowStyle( int style )
216 rowStyle = style; 216 rowStyle = style;
217} 217}
218 218
219void DateBookDay::updateView( void ) 219void 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
225void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 225void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
226{ 226{
227 selectedWidget = w; 227 selectedWidget = w;
228} 228}
229 229
230DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 230DateBookDayWidget * DateBookDay::getSelectedWidget( void )
231{ 231{
232 return selectedWidget; 232 return selectedWidget;
233} 233}
234 234
235void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 235void 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
258void DateBookDay::setDate( int y, int m, int d ) 258void 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
265void DateBookDay::setDate( QDate d) 265void 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
272void DateBookDay::dateChanged( int y, int m, int d ) 272void 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
298void DateBookDay::redraw() 298void DateBookDay::redraw()
299{ 299{
300 if ( isUpdatesEnabled() ) 300 if ( isUpdatesEnabled() )
301 relayoutPage(); 301 relayoutPage();
302} 302}
303 303
304void DateBookDay::getEvents() 304void 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()==ev.start().hour() && ev.end().minute()==ev.start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00) 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
328static int place( const DateBookDayWidget *item, bool *used, int maxn ) 328static 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
362void DateBookDay::relayoutPage( bool fromResize ) 362void 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;
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 5bbf86a..874cf24 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -46,193 +46,193 @@ DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e )
46 if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { 46 if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) {
47 c = Qt::green; 47 c = Qt::green;
48 } else { 48 } else {
49 c = ev.event().hasAlarm() ? Qt::red : Qt::blue; 49 c = ev.event().hasAlarm() ? Qt::red : Qt::blue;
50 } 50 }
51} 51}
52 52
53void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) 53void DateBookWeekItem::setGeometry( int x, int y, int w, int h )
54{ 54{
55 r.setRect( x, y, w, h ); 55 r.setRect( x, y, w, h );
56} 56}
57 57
58 58
59//------------------=--------------------------------------------- 59//------------------=---------------------------------------------
60 60
61DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, 61DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
62 QWidget *parent, const char *name ) 62 QWidget *parent, const char *name )
63 : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), 63 : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ),
64 showingEvent( false ) 64 showingEvent( false )
65{ 65{
66 items.setAutoDelete( true ); 66 items.setAutoDelete( true );
67 67
68 viewport()->setBackgroundMode( PaletteBase ); 68 viewport()->setBackgroundMode( PaletteBase );
69 69
70 header = new QHeader( this ); 70 header = new QHeader( this );
71 header->addLabel( "" ); 71 header->addLabel( "" );
72 72
73 header->setMovingEnabled( false ); 73 header->setMovingEnabled( false );
74 header->setResizeEnabled( false ); 74 header->setResizeEnabled( false );
75 header->setClickEnabled( false, 0 ); 75 header->setClickEnabled( false, 0 );
76 initNames(); 76 initNames();
77 77
78 78
79 connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); 79 connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) );
80 80
81 QObject::connect(qApp, SIGNAL(clockChanged(bool)), 81 QObject::connect(qApp, SIGNAL(clockChanged(bool)),
82 this, SLOT(slotChangeClock(bool))); 82 this, SLOT(slotChangeClock(bool)));
83 83
84 QFontMetrics fm( font() ); 84 QFontMetrics fm( font() );
85 rowHeight = fm.height()+2; 85 rowHeight = fm.height()+2;
86 86
87 resizeContents( width(), 24*rowHeight ); 87 resizeContents( width(), 24*rowHeight );
88} 88}
89 89
90void DateBookWeekView::initNames() 90void DateBookWeekView::initNames()
91{ 91{
92 static bool bFirst = true; 92 static bool bFirst = true;
93 if ( bFirst ) { 93 if ( bFirst ) {
94 if ( bOnMonday ) { 94 if ( bOnMonday ) {
95 header->addLabel( tr("M", "Monday" ) ); 95 header->addLabel( tr("M", "Monday" ) );
96 header->addLabel( tr("T", "Tuesday") ); 96 header->addLabel( tr("T", "Tuesday") );
97 header->addLabel( tr("W", "Wednesday" ) ); 97 header->addLabel( tr("W", "Wednesday" ) );
98 header->addLabel( tr("T", "Thursday" ) ); 98 header->addLabel( tr("T", "Thursday" ) );
99 header->addLabel( tr("F", "Friday" ) ); 99 header->addLabel( tr("F", "Friday" ) );
100 header->addLabel( tr("S", "Saturday" ) ); 100 header->addLabel( tr("S", "Saturday" ) );
101 header->addLabel( tr("S", "Sunday" ) ); 101 header->addLabel( tr("S", "Sunday" ) );
102 } else { 102 } else {
103 header->addLabel( tr("S", "Sunday" ) ); 103 header->addLabel( tr("S", "Sunday" ) );
104 header->addLabel( tr("M", "Monday") ); 104 header->addLabel( tr("M", "Monday") );
105 header->addLabel( tr("T", "Tuesday") ); 105 header->addLabel( tr("T", "Tuesday") );
106 header->addLabel( tr("W", "Wednesday" ) ); 106 header->addLabel( tr("W", "Wednesday" ) );
107 header->addLabel( tr("T", "Thursday" ) ); 107 header->addLabel( tr("T", "Thursday" ) );
108 header->addLabel( tr("F", "Friday" ) ); 108 header->addLabel( tr("F", "Friday" ) );
109 header->addLabel( tr("S", "Saturday" ) ); 109 header->addLabel( tr("S", "Saturday" ) );
110 } 110 }
111 bFirst = false; 111 bFirst = false;
112 } else { 112 } else {
113 // we are change things... 113 // we are change things...
114 if ( bOnMonday ) { 114 if ( bOnMonday ) {
115 header->setLabel( 1, tr("M", "Monday") ); 115 header->setLabel( 1, tr("M", "Monday") );
116 header->setLabel( 2, tr("T", "Tuesday") ); 116 header->setLabel( 2, tr("T", "Tuesday") );
117 header->setLabel( 3, tr("W", "Wednesday" ) ); 117 header->setLabel( 3, tr("W", "Wednesday" ) );
118 header->setLabel( 4, tr("T", "Thursday" ) ); 118 header->setLabel( 4, tr("T", "Thursday" ) );
119 header->setLabel( 5, tr("F", "Friday" ) ); 119 header->setLabel( 5, tr("F", "Friday" ) );
120 header->setLabel( 6, tr("S", "Saturday" ) ); 120 header->setLabel( 6, tr("S", "Saturday" ) );
121 header->setLabel( 7, tr("S", "Sunday" ) ); 121 header->setLabel( 7, tr("S", "Sunday" ) );
122 } else { 122 } else {
123 header->setLabel( 1, tr("S", "Sunday" ) ); 123 header->setLabel( 1, tr("S", "Sunday" ) );
124 header->setLabel( 2, tr("M", "Monday") ); 124 header->setLabel( 2, tr("M", "Monday") );
125 header->setLabel( 3, tr("T", "Tuesday") ); 125 header->setLabel( 3, tr("T", "Tuesday") );
126 header->setLabel( 4, tr("W", "Wednesday" ) ); 126 header->setLabel( 4, tr("W", "Wednesday" ) );
127 header->setLabel( 5, tr("T", "Thursday" ) ); 127 header->setLabel( 5, tr("T", "Thursday" ) );
128 header->setLabel( 6, tr("F", "Friday" ) ); 128 header->setLabel( 6, tr("F", "Friday" ) );
129 header->setLabel( 7, tr("S", "Saturday" ) ); 129 header->setLabel( 7, tr("S", "Saturday" ) );
130 } 130 }
131 } 131 }
132} 132}
133 133
134 134
135 135
136void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) 136void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev )
137{ 137{
138 items.clear(); 138 items.clear();
139 QValueListIterator<EffectiveEvent> it; 139 QValueListIterator<EffectiveEvent> it;
140 for ( it = ev.begin(); it != ev.end(); ++it ) { 140 for ( it = ev.begin(); it != ev.end(); ++it ) {
141 DateBookWeekItem *i = new DateBookWeekItem( *it ); 141 DateBookWeekItem *i = new DateBookWeekItem( *it );
142 if(!(i->event().end().hour()==i->event().start().hour() && i->event().end().minute()==i->event().start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00) 142 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.
143 positionItem( i ); 143 positionItem( i );
144 items.append( i ); 144 items.append( i );
145 } 145 }
146 } 146 }
147 viewport()->update(); 147 viewport()->update();
148} 148}
149 149
150void DateBookWeekView::moveToHour( int h ) 150void DateBookWeekView::moveToHour( int h )
151{ 151{
152 int offset = h*rowHeight; 152 int offset = h*rowHeight;
153 setContentsPos( 0, offset ); 153 setContentsPos( 0, offset );
154} 154}
155 155
156void DateBookWeekView::keyPressEvent( QKeyEvent *e ) 156void DateBookWeekView::keyPressEvent( QKeyEvent *e )
157{ 157{
158 e->ignore(); 158 e->ignore();
159} 159}
160 160
161void DateBookWeekView::slotChangeClock( bool c ) 161void DateBookWeekView::slotChangeClock( bool c )
162{ 162{
163 ampm = c; 163 ampm = c;
164 viewport()->update(); 164 viewport()->update();
165} 165}
166 166
167static inline int db_round30min( int m ) 167static inline int db_round30min( int m )
168{ 168{
169 if ( m < 15 ) 169 if ( m < 15 )
170 m = 0; 170 m = 0;
171 else if ( m < 45 ) 171 else if ( m < 45 )
172 m = 1; 172 m = 1;
173 else 173 else
174 m = 2; 174 m = 2;
175 175
176 return m; 176 return m;
177} 177}
178 178
179void DateBookWeekView::alterDay( int day ) 179void DateBookWeekView::alterDay( int day )
180{ 180{
181 if ( !bOnMonday ) { 181 if ( !bOnMonday ) {
182 day--; 182 day--;
183 } 183 }
184 emit showDay( day ); 184 emit showDay( day );
185} 185}
186 186
187void DateBookWeekView::positionItem( DateBookWeekItem *i ) 187void DateBookWeekView::positionItem( DateBookWeekItem *i )
188{ 188{
189 const int Width = 8; 189 const int Width = 8;
190 const EffectiveEvent ev = i->event(); 190 const EffectiveEvent ev = i->event();
191 191
192 // 30 minute intervals 192 // 30 minute intervals
193 int y = ev.start().hour() * 2; 193 int y = ev.start().hour() * 2;
194 y += db_round30min( ev.start().minute() ); 194 y += db_round30min( ev.start().minute() );
195 int y2 = ev.end().hour() * 2; 195 int y2 = ev.end().hour() * 2;
196 y2 += db_round30min( ev.end().minute() ); 196 y2 += db_round30min( ev.end().minute() );
197 if ( y > 47 ) 197 if ( y > 47 )
198 y = 47; 198 y = 47;
199 if ( y2 > 48 ) 199 if ( y2 > 48 )
200 y2 = 48; 200 y2 = 48;
201 y = y * rowHeight / 2; 201 y = y * rowHeight / 2;
202 y2 = y2 * rowHeight / 2; 202 y2 = y2 * rowHeight / 2;
203 203
204 int h; 204 int h;
205 if ( ev.event().type() == Event::AllDay ) { 205 if ( ev.event().type() == Event::AllDay ) {
206 h = 48 * rowHeight / 2; 206 h = 48 * rowHeight / 2;
207 y = 0; 207 y = 0;
208 } else { 208 } else {
209 h=y2-y; 209 h=y2-y;
210 if ( h < 1 ) h = 1; 210 if ( h < 1 ) h = 1;
211 } 211 }
212 212
213 int dow = ev.date().dayOfWeek(); 213 int dow = ev.date().dayOfWeek();
214 if ( !bOnMonday ) { 214 if ( !bOnMonday ) {
215 if ( dow == 7 ) 215 if ( dow == 7 )
216 dow = 1; 216 dow = 1;
217 else 217 else
218 dow++; 218 dow++;
219 } 219 }
220 int x = header->sectionPos( dow ) - 1; 220 int x = header->sectionPos( dow ) - 1;
221 int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); 221 int xlim = header->sectionPos( dow ) + header->sectionSize( dow );
222 DateBookWeekItem *isect = 0; 222 DateBookWeekItem *isect = 0;
223 do { 223 do {
224 i->setGeometry( x, y, Width, h ); 224 i->setGeometry( x, y, Width, h );
225 isect = intersects( i ); 225 isect = intersects( i );
226 x += Width - 1; 226 x += Width - 1;
227 } while ( isect && x < xlim ); 227 } while ( isect && x < xlim );
228} 228}
229 229
230DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) 230DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item )
231{ 231{
232 QRect geom = item->geometry(); 232 QRect geom = item->geometry();
233 233
234 // We allow the edges to overlap 234 // We allow the edges to overlap
235 geom.moveBy( 1, 1 ); 235 geom.moveBy( 1, 1 );
236 geom.setSize( geom.size()-QSize(2,2) ); 236 geom.setSize( geom.size()-QSize(2,2) );
237 237
238 QListIterator<DateBookWeekItem> it(items); 238 QListIterator<DateBookWeekItem> it(items);
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 4ceb360..3d6a029 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -118,193 +118,193 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
118 QFont f=label->font(); 118 QFont f=label->font();
119 f.setItalic(true); 119 f.setItalic(true);
120 label->setFont(f); 120 label->setFont(f);
121 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 121 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
122 */ 122 */
123 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 123 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
124 QPalette pal=label->palette(); 124 QPalette pal=label->palette();
125 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 125 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
126 label->setPalette(pal); 126 label->setPalette(pal);
127 } 127 }
128 128
129 129
130 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 130 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
131 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 131 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
132} 132}
133 133
134void DateBookWeekLstDayHdr::showDay() { 134void DateBookWeekLstDayHdr::showDay() {
135 emit showDate(date.year(), date.month(), date.day()); 135 emit showDate(date.year(), date.month(), date.day());
136} 136}
137void DateBookWeekLstDayHdr::newEvent() { 137void DateBookWeekLstDayHdr::newEvent() {
138 QDateTime start, stop; 138 QDateTime start, stop;
139 start=stop=date; 139 start=stop=date;
140 start.setTime(QTime(10,0)); 140 start.setTime(QTime(10,0));
141 stop.setTime(QTime(12,0)); 141 stop.setTime(QTime(12,0));
142 142
143 emit addEvent(start,stop,"",0); 143 emit addEvent(start,stop,"",0);
144} 144}
145DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 145DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
146 QWidget* parent, 146 QWidget* parent,
147 const char* name, 147 const char* name,
148 WFlags fl) : 148 WFlags fl) :
149 OClickableLabel(parent,name,fl), 149 OClickableLabel(parent,name,fl),
150 event(ev) 150 event(ev)
151{ 151{
152 char s[10]; 152 char s[10];
153 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 153 if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
154 if ( ev.endDate() == ev.date() ) { // last day 154 if ( ev.endDate() == ev.date() ) { // last day
155 strcpy(s, "__|__"); 155 strcpy(s, "__|__");
156 } else { 156 } else {
157 strcpy(s, " |---"); 157 strcpy(s, " |---");
158 } 158 }
159 } else { 159 } else {
160 if(ev.event().type() == Event::Normal ) 160 if(ev.event().type() == Event::Normal )
161 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); 161 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
162 else 162 else
163 sprintf(s," "); 163 sprintf(s," ");
164 } 164 }
165 setText(QString(s) + " " + ev.description()); 165 setText(QString(s) + " " + ev.description());
166 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 166 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
167 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 167 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
168} 168}
169void DateBookWeekLstEvent::editMe() { 169void DateBookWeekLstEvent::editMe() {
170 emit editEvent(event.event()); 170 emit editEvent(event.event());
171} 171}
172 172
173 173
174DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 174DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
175 const QDate &d, bool onM, 175 const QDate &d, bool onM,
176 QWidget* parent, 176 QWidget* parent,
177 const char* name, WFlags fl) 177 const char* name, WFlags fl)
178 : QWidget( parent, name, fl ) 178 : QWidget( parent, name, fl )
179{ 179{
180 onMonday=onM; 180 onMonday=onM;
181 setPalette(white); 181 setPalette(white);
182 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 182 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
183 183
184 QVBoxLayout *layout = new QVBoxLayout( this ); 184 QVBoxLayout *layout = new QVBoxLayout( this );
185 185
186 qBubbleSort(ev); 186 qBubbleSort(ev);
187 QValueListIterator<EffectiveEvent> it; 187 QValueListIterator<EffectiveEvent> it;
188 it=ev.begin(); 188 it=ev.begin();
189 189
190 int dayOrder[7]; 190 int dayOrder[7];
191 if (onMonday) 191 if (onMonday)
192 for (int d=0; d<7; d++) dayOrder[d]=d+1; 192 for (int d=0; d<7; d++) dayOrder[d]=d+1;
193 else { 193 else {
194 for (int d=0; d<7; d++) dayOrder[d]=d; 194 for (int d=0; d<7; d++) dayOrder[d]=d;
195 dayOrder[0]=7; 195 dayOrder[0]=7;
196 } 196 }
197 197
198 for (int i=0; i<7; i++) { 198 for (int i=0; i<7; i++) {
199 // Header 199 // Header
200 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 200 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i),
201 onMonday,this); 201 onMonday,this);
202 connect(hdr, SIGNAL(showDate(int,int,int)), 202 connect(hdr, SIGNAL(showDate(int,int,int)),
203 this, SIGNAL(showDate(int,int,int))); 203 this, SIGNAL(showDate(int,int,int)));
204 connect(hdr, SIGNAL(addEvent(const QDateTime &, 204 connect(hdr, SIGNAL(addEvent(const QDateTime &,
205 const QDateTime &, 205 const QDateTime &,
206 const QString &, const QString &)), 206 const QString &, const QString &)),
207 this, SIGNAL(addEvent(const QDateTime &, 207 this, SIGNAL(addEvent(const QDateTime &,
208 const QDateTime &, 208 const QDateTime &,
209 const QString &, const QString &))); 209 const QString &, const QString &)));
210 layout->addWidget(hdr); 210 layout->addWidget(hdr);
211 211
212 // Events 212 // Events
213 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 213 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
214 if(!((*it).end().hour()==(*it).start().hour() && (*it).end().minute()==(*it).start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00) 214 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
215 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 215 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this);
216 layout->addWidget(l); 216 layout->addWidget(l);
217 connect (l, SIGNAL(editEvent(const Event &)), 217 connect (l, SIGNAL(editEvent(const Event &)),
218 this, SIGNAL(editEvent(const Event &))); 218 this, SIGNAL(editEvent(const Event &)));
219 } 219 }
220 it++; 220 it++;
221 } 221 }
222 222
223 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 223 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
224 } 224 }
225} 225}
226DateBookWeekLstView::~DateBookWeekLstView(){} 226DateBookWeekLstView::~DateBookWeekLstView(){}
227void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 227void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
228 228
229DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 229DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
230 QValueList<EffectiveEvent> &ev2, 230 QValueList<EffectiveEvent> &ev2,
231 QDate &d, bool onM, 231 QDate &d, bool onM,
232 QWidget* parent, 232 QWidget* parent,
233 const char* name, WFlags fl) 233 const char* name, WFlags fl)
234 : QWidget( parent, name, fl ) 234 : QWidget( parent, name, fl )
235{ 235{
236 QHBoxLayout *layout = new QHBoxLayout( this ); 236 QHBoxLayout *layout = new QHBoxLayout( this );
237 237
238 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 238 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
239 layout->addWidget(w); 239 layout->addWidget(w);
240 connect (w, SIGNAL(editEvent(const Event &)), 240 connect (w, SIGNAL(editEvent(const Event &)),
241 this, SIGNAL(editEvent(const Event &))); 241 this, SIGNAL(editEvent(const Event &)));
242 connect (w, SIGNAL(showDate(int,int,int)), 242 connect (w, SIGNAL(showDate(int,int,int)),
243 this, SIGNAL(showDate(int,int,int))); 243 this, SIGNAL(showDate(int,int,int)));
244 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 244 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
245 const QString &,const QString &)), 245 const QString &,const QString &)),
246 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 246 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
247 const QString &, const QString &))); 247 const QString &, const QString &)));
248 248
249 249
250 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 250 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
251 layout->addWidget(w); 251 layout->addWidget(w);
252 connect (w, SIGNAL(editEvent(const Event &)), 252 connect (w, SIGNAL(editEvent(const Event &)),
253 this, SIGNAL(editEvent(const Event &))); 253 this, SIGNAL(editEvent(const Event &)));
254 connect (w, SIGNAL(showDate(int,int,int)), 254 connect (w, SIGNAL(showDate(int,int,int)),
255 this, SIGNAL(showDate(int,int,int))); 255 this, SIGNAL(showDate(int,int,int)));
256 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 256 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
257 const QString &, const QString &)), 257 const QString &, const QString &)),
258 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 258 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
259 const QString &, const QString &))); 259 const QString &, const QString &)));
260} 260}
261 261
262DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 262DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
263 QWidget *parent, 263 QWidget *parent,
264 const char *name ) 264 const char *name )
265 : QWidget( parent, name ), 265 : QWidget( parent, name ),
266 db( newDB ), 266 db( newDB ),
267 startTime( 0 ), 267 startTime( 0 ),
268 ampm( ap ), 268 ampm( ap ),
269 onMonday(onM) 269 onMonday(onM)
270{ 270{
271 setFocusPolicy(StrongFocus); 271 setFocusPolicy(StrongFocus);
272 layout = new QVBoxLayout( this ); 272 layout = new QVBoxLayout( this );
273 layout->setMargin(0); 273 layout->setMargin(0);
274 274
275 header=new DateBookWeekLstHeader(onM, this); 275 header=new DateBookWeekLstHeader(onM, this);
276 layout->addWidget( header ); 276 layout->addWidget( header );
277 connect(header, SIGNAL(dateChanged(int,int)), 277 connect(header, SIGNAL(dateChanged(int,int)),
278 this, SLOT(dateChanged(int,int))); 278 this, SLOT(dateChanged(int,int)));
279 connect(header, SIGNAL(setDbl(bool)), 279 connect(header, SIGNAL(setDbl(bool)),
280 this, SLOT(setDbl(bool))); 280 this, SLOT(setDbl(bool)));
281 281
282 scroll=new QScrollView(this); 282 scroll=new QScrollView(this);
283 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 283 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
284 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 284 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
285 scroll->setResizePolicy(QScrollView::AutoOneFit); 285 scroll->setResizePolicy(QScrollView::AutoOneFit);
286 layout->addWidget(scroll); 286 layout->addWidget(scroll);
287 287
288 view=NULL; 288 view=NULL;
289 Config config("DateBook"); 289 Config config("DateBook");
290 config.setGroup("Main"); 290 config.setGroup("Main");
291 dbl=config.readBoolEntry("weeklst_dbl", false); 291 dbl=config.readBoolEntry("weeklst_dbl", false);
292 header->dbl->setOn(dbl); 292 header->dbl->setOn(dbl);
293} 293}
294DateBookWeekLst::~DateBookWeekLst(){ 294DateBookWeekLst::~DateBookWeekLst(){
295 Config config("DateBook"); 295 Config config("DateBook");
296 config.setGroup("Main"); 296 config.setGroup("Main");
297 config.writeEntry("weeklst_dbl", dbl); 297 config.writeEntry("weeklst_dbl", dbl);
298} 298}
299 299
300void DateBookWeekLst::setDate(const QDate &d) { 300void DateBookWeekLst::setDate(const QDate &d) {
301 int w,y; 301 int w,y;
302 calcWeek(d,w,y,onMonday); 302 calcWeek(d,w,y,onMonday);
303 year=y; 303 year=y;
304 _week=w; 304 _week=w;
305 header->setDate(date()); 305 header->setDate(date());
306} 306}
307void DateBookWeekLst::setDbl(bool on) { 307void DateBookWeekLst::setDbl(bool on) {
308 dbl=on; 308 dbl=on;
309 redraw(); 309 redraw();
310} 310}