summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookday.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookday.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp1084
1 files changed, 547 insertions, 537 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index ca63dc5..dfe39e5 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -24,2 +24,3 @@
24 24
25#include <opie2/oholidayplugin.h>
25#include <qpe/resource.h> 26#include <qpe/resource.h>
@@ -37,23 +38,23 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *
37{ 38{
38 enableClipper(TRUE); 39 enableClipper(TRUE);
39 setTopMargin( 0 ); 40 setTopMargin( 0 );
40 horizontalHeader()->hide(); 41 horizontalHeader()->hide();
41 setLeftMargin(38); 42 setLeftMargin(38);
42 setColumnStretchable( 0, TRUE ); 43 setColumnStretchable( 0, TRUE );
43 setHScrollBarMode( QScrollView::AlwaysOff ); 44 setHScrollBarMode( QScrollView::AlwaysOff );
44 verticalHeader()->setPalette(white); 45 verticalHeader()->setPalette(white);
45 verticalHeader()->setResizeEnabled(FALSE); 46 verticalHeader()->setResizeEnabled(FALSE);
46 setSelectionMode( Single ); 47 setSelectionMode( Single );
47 48
48 // get rid of being able to edit things... 49 // get rid of being able to edit things...
49 QTableItem *tmp; 50 QTableItem *tmp;
50 int row; 51 int row;
51 for ( row = 0; row < numRows(); row++ ) { 52 for ( row = 0; row < numRows(); row++ ) {
52 tmp = new QTableItem( this, QTableItem::Never, QString::null); 53 tmp = new QTableItem( this, QTableItem::Never, QString::null);
53 setItem( row, 0, tmp ); 54 setItem( row, 0, tmp );
54 //setRowHeight( row, 40); 55 //setRowHeight( row, 40);
55 } 56 }
56 57
57 initHeader(); 58 initHeader();
58 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); 59 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) );
59} 60}
@@ -62,34 +63,34 @@ void DateBookDayView::initHeader()
62{ 63{
63 QString strTmp; 64 QString strTmp;
64 int preferredWidth = 0; 65 int preferredWidth = 0;
65 for ( int i = 0; i < 24; ++i ) { 66 for ( int i = 0; i < 24; ++i ) {
66 if ( ampm ) { 67 if ( ampm ) {
67 if ( i == 0 ) 68 if ( i == 0 )
68 strTmp = QString::number(12) + ":00"; 69 strTmp = QString::number(12) + ":00";
69 else if ( i == 12 ) 70 else if ( i == 12 )
70 strTmp = QString::number(12) + tr(":00p"); 71 strTmp = QString::number(12) + tr(":00p");
71 else if ( i > 12 ) 72 else if ( i > 12 )
72 strTmp = QString::number( i - 12 ) + tr(":00p"); 73 strTmp = QString::number( i - 12 ) + tr(":00p");
73 else 74 else
74 strTmp = QString::number(i) + ":00"; 75 strTmp = QString::number(i) + ":00";
75 } else { 76 } else {
76 if ( i < 10 ) 77 if ( i < 10 )
77 strTmp = "0" + QString::number(i) + ":00"; 78 strTmp = "0" + QString::number(i) + ":00";
78 else 79 else
79 strTmp = QString::number(i) + ":00"; 80 strTmp = QString::number(i) + ":00";
80 } 81 }
81 strTmp = strTmp.rightJustify( 6, ' ' ); 82 strTmp = strTmp.rightJustify( 6, ' ' );
82 verticalHeader()->setLabel( i, strTmp ); 83 verticalHeader()->setLabel( i, strTmp );
83 84
84 // Compute correct width for current Font (Add some space right) 85 // Compute correct width for current Font (Add some space right)
85 int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); 86 int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") );
86 if ( preferredWidth < actWidth ) 87 if ( preferredWidth < actWidth )
87 preferredWidth = actWidth; 88 preferredWidth = actWidth;
88 setRowStretchable( i, FALSE ); 89 setRowStretchable( i, FALSE );
89 } 90 }
90 91
91 // It seems as if the header has a bug. It does not resize 92 // It seems as if the header has a bug. It does not resize
92 // correct horizontally if it is used vertical.. 93 // correct horizontally if it is used vertical..
93 // Thus, we do it manually.. 94 // Thus, we do it manually..
94 setLeftMargin( preferredWidth ); 95 setLeftMargin( preferredWidth );
95} 96}
@@ -98,3 +99,3 @@ void DateBookDayView::slotDateChanged( int y, int m, int d )
98{ 99{
99 currDate.setYMD(y,m,d); 100 currDate.setYMD(y,m,d);
100} 101}
@@ -103,4 +104,4 @@ void DateBookDayView::slotChangeClock( bool newClock )
103{ 104{
104 ampm = newClock; 105 ampm = newClock;
105 initHeader(); 106 initHeader();
106} 107}
@@ -109,3 +110,3 @@ bool DateBookDayView::whichClock() const
109{ 110{
110 return ampm; 111 return ampm;
111} 112}
@@ -114,3 +115,3 @@ void DateBookDayView::moveUp()
114{ 115{
115 scrollBy(0, -20); 116 scrollBy(0, -20);
116} 117}
@@ -119,3 +120,3 @@ void DateBookDayView::moveDown()
119{ 120{
120 scrollBy(0, 20); 121 scrollBy(0, 20);
121} 122}
@@ -124,18 +125,18 @@ void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
124{ 125{
125 int w = cr.width(); 126 int w = cr.width();
126 int h = cr.height(); 127 int h = cr.height();
127 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 128 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
128 if ( showGrid() ) { 129 if ( showGrid() ) {
129 // Draw our lines 130 // Draw our lines
130 int x2 = w - 1; 131 int x2 = w - 1;
131 int y2 = h - 1; 132 int y2 = h - 1;
132 QPen pen( p->pen() ); 133 QPen pen( p->pen() );
133 p->setPen( colorGroup().dark() ); 134 p->setPen( colorGroup().dark() );
134 p->drawLine( x2, 0, x2, y2 ); 135 p->drawLine( x2, 0, x2, y2 );
135 p->drawLine( 0, y2, x2, y2 ); 136 p->drawLine( 0, y2, x2, y2 );
136 137
137 p->setPen( colorGroup().midlight() ); 138 p->setPen( colorGroup().midlight() );
138 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 139 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
139 140
140 p->setPen( pen ); 141 p->setPen( pen );
141 } 142 }
@@ -149,5 +150,5 @@ void DateBookDayView::resizeEvent( QResizeEvent *e )
149{ 150{
150 QTable::resizeEvent( e ); 151 QTable::resizeEvent( e );
151 columnWidthChanged( 0 ); 152 columnWidthChanged( 0 );
152 emit sigColWidthChanged(); 153 emit sigColWidthChanged();
153} 154}
@@ -156,11 +157,11 @@ void DateBookDayView::keyPressEvent( QKeyEvent *e )
156{ 157{
157 QString txt = e->text(); 158 QString txt = e->text();
158 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 159 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
159 // we this is some sort of thing we know about... 160 // we this is some sort of thing we know about...
160 e->accept(); 161 e->accept();
161 emit sigCapturedKey( txt ); 162 emit sigCapturedKey( txt );
162 } else { 163 } else {
163 // I don't know what this key is, do you? 164 // I don't know what this key is, do you?
164 e->ignore(); 165 e->ignore();
165 } 166 }
166} 167}
@@ -169,6 +170,6 @@ void DateBookDayView::setRowStyle( int style )
169{ 170{
170 if (style<0) style = 0; 171 if (style<0) style = 0;
171 172
172 for (int i=0; i<numRows(); i++) 173 for (int i=0; i<numRows(); i++)
173 setRowHeight(i, style*10+20); 174 setRowHeight(i, style*10+20);
174} 175}
@@ -177,19 +178,19 @@ void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ )
177{ 178{
178 int sh=99,eh=-1; 179 int sh=99,eh=-1;
179 180
180 for(int i=0;i<this->numSelections();i++) { 181 for(int i=0;i<this->numSelections();i++) {
181 QTableSelection sel = this->selection( i ); 182 QTableSelection sel = this->selection( i );
182 sh = QMIN(sh,sel.topRow()); 183 sh = QMIN(sh,sel.topRow());
183 eh = QMAX(sh,sel.bottomRow()+1); 184 eh = QMAX(sh,sel.bottomRow()+1);
184 } 185 }
185 if (sh > 23 || eh < 1) { 186 if (sh > 23 || eh < 1) {
186 sh=8; 187 sh=8;
187 eh=9; 188 eh=9;
188 } 189 }
189 190
190 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); 191 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit");
191 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); 192 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
192 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); 193 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0));
193 quickLineEdit->setFocus(); 194 quickLineEdit->setFocus();
194 quickLineEdit->show(); 195 quickLineEdit->show();
195} 196}
@@ -200,6 +201,6 @@ DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &star
200{ 201{
201 active=1; 202 active=1;
202 quickEvent.setStart(start); 203 quickEvent.setStart(start);
203 quickEvent.setEnd(end); 204 quickEvent.setEnd(end);
204 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); 205 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
205} 206}
@@ -208,10 +209,10 @@ void DateBookDayViewQuickLineEdit::slotReturnPressed()
208{ 209{
209 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. 210 if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times.
210 quickEvent.setDescription(this->text()); 211 quickEvent.setDescription(this->text());
211 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); 212 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&)));
212 emit(insertEvent(quickEvent)); 213 emit(insertEvent(quickEvent));
213 active=0; 214 active=0;
214 } 215 }
215 /* we need to return to this object.. */ 216 /* we need to return to this object.. */
216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget 217 QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget
217} 218}
@@ -223,3 +224,3 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
223{ 224{
224 slotReturnPressed(); // Reuse code to add event and close this widget. 225 slotReturnPressed(); // Reuse code to add event and close this widget.
225} 226}
@@ -228,30 +229,31 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
228 229
229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) 230DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name )
230 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) 231 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
231{ 232{
232 widgetList.setAutoDelete( true ); 233 widgetList.setAutoDelete( true );
233 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 234 _holiday_db = newHdb;
234 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 235 header = new DateBookDayHeader( startOnMonday, this, "day header" );
236 header->setDate( currDate.year(), currDate.month(), currDate.day() );
235 237
236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); 238 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
237 m_allDays->hide(); 239 m_allDays->hide();
238 240
239 view = new DateBookDayView( ampm, this, "day view" ); 241 view = new DateBookDayView( ampm, this, "day view" );
240 242
241 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) ); 243 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) );
242 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) ); 244 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) );
243 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); 245 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
244 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 246 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
245 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) ); 247 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) );
246 248
247 QTimer *timer = new QTimer( this ); 249 QTimer *timer = new QTimer( this );
248 250
249 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors 251 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) ); //connect timer for updating timeMarker & daywidgetcolors
250 timer->start( 1000*60*5, FALSE ); //update every 5min 252 timer->start( 1000*60*5, FALSE ); //update every 5min
251 253
252 selectedWidget = 0; 254 selectedWidget = 0;
253 255
254 timeMarker = new DateBookDayTimeMarker( this ); 256 timeMarker = new DateBookDayTimeMarker( this );
255 timeMarker->setTime( QTime::currentTime() ); 257 timeMarker->setTime( QTime::currentTime() );
256 rowStyle = -1; // initialize with bogus values 258 rowStyle = -1; // initialize with bogus values
257 jumpToCurTime = false; 259 jumpToCurTime = false;
@@ -261,3 +263,3 @@ void DateBookDay::setJumpToCurTime( bool bJump )
261{ 263{
262 jumpToCurTime = bJump; 264 jumpToCurTime = bJump;
263} 265}
@@ -266,4 +268,4 @@ void DateBookDay::setRowStyle( int style )
266{ 268{
267 if (rowStyle != style) view->setRowStyle( style ); 269 if (rowStyle != style) view->setRowStyle( style );
268 rowStyle = style; 270 rowStyle = style;
269} 271}
@@ -272,4 +274,4 @@ void DateBookDay::updateView( void )
272{ 274{
273 timeMarker->setTime( QTime::currentTime() ); 275 timeMarker->setTime( QTime::currentTime() );
274 //need to find a way to update all DateBookDayWidgets 276 //need to find a way to update all DateBookDayWidgets
275} 277}
@@ -278,3 +280,3 @@ void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
278{ 280{
279 selectedWidget = w; 281 selectedWidget = w;
280} 282}
@@ -283,3 +285,3 @@ DateBookDayWidget * DateBookDay::getSelectedWidget( void )
283{ 285{
284 return selectedWidget; 286 return selectedWidget;
285} 287}
@@ -288,22 +290,22 @@ void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
288{ 290{
289 start.setDate( currDate ); 291 start.setDate( currDate );
290 end.setDate( currDate ); 292 end.setDate( currDate );
291 293
292 int sh=99,eh=-1; 294 int sh=99,eh=-1;
293 295
294 int n = dayView()->numSelections(); 296 int n = dayView()->numSelections();
295 297
296 for (int i=0; i<n; i++) { 298 for (int i=0; i<n; i++) {
297 QTableSelection sel = dayView()->selection( i ); 299 QTableSelection sel = dayView()->selection( i );
298 sh = QMIN(sh,sel.topRow()); 300 sh = QMIN(sh,sel.topRow());
299 eh = QMAX(sh,sel.bottomRow()+1); 301 eh = QMAX(sh,sel.bottomRow()+1);
300 } 302 }
301 303
302 if (sh > 23 || eh < 1) { 304 if (sh > 23 || eh < 1) {
303 sh=8; 305 sh=8;
304 eh=9; 306 eh=9;
305 } 307 }
306 308
307 start.setTime( QTime( sh, 0, 0 ) ); 309 start.setTime( QTime( sh, 0, 0 ) );
308 end.setTime( QTime( eh, 0, 0 ) ); 310 end.setTime( QTime( eh, 0, 0 ) );
309} 311}
@@ -312,4 +314,4 @@ void DateBookDay::setDate( int y, int m, int d )
312{ 314{
313 header->setDate( y, m, d ); 315 header->setDate( y, m, d );
314 selectedWidget = 0; 316 selectedWidget = 0;
315} 317}
@@ -318,4 +320,4 @@ void DateBookDay::setDate( QDate d)
318{ 320{
319 header->setDate( d.year(), d.month(), d.day() ); 321 header->setDate( d.year(), d.month(), d.day() );
320 selectedWidget = 0; 322 selectedWidget = 0;
321} 323}
@@ -324,21 +326,21 @@ void DateBookDay::dateChanged( int y, int m, int d )
324{ 326{
325 QDate date( y, m, d ); 327 QDate date( y, m, d );
326 if ( currDate == date ) 328 if ( currDate == date )
327 return; 329 return;
328 currDate.setYMD( y, m, d ); 330 currDate.setYMD( y, m, d );
329 relayoutPage(); 331 relayoutPage();
330 dayView()->clearSelection(); 332 dayView()->clearSelection();
331 QTableSelection ts; 333 QTableSelection ts;
332 334
333 if (jumpToCurTime && this->date() == QDate::currentDate()) 335 if (jumpToCurTime && this->date() == QDate::currentDate())
334 { 336 {
335 ts.init( QTime::currentTime().hour(), 0); 337 ts.init( QTime::currentTime().hour(), 0);
336 ts.expandTo( QTime::currentTime().hour(), 0); 338 ts.expandTo( QTime::currentTime().hour(), 0);
337 } else { 339 } else {
338 ts.init( startTime, 0 ); 340 ts.init( startTime, 0 );
339 ts.expandTo( startTime, 0 ); 341 ts.expandTo( startTime, 0 );
340 } 342 }
341 343
342 dayView()->addSelection( ts ); 344 dayView()->addSelection( ts );
343 selectedWidget = 0; 345 selectedWidget = 0;
344} 346}
@@ -347,4 +349,4 @@ void DateBookDay::redraw()
347{ 349{
348 if ( isUpdatesEnabled() ) 350 if ( isUpdatesEnabled() )
349 relayoutPage(); 351 relayoutPage();
350} 352}
@@ -353,3 +355,3 @@ void DateBookDay::getEvents()
353{ 355{
354 widgetList.clear(); 356 widgetList.clear();
355 357
@@ -359,8 +361,16 @@ void DateBookDay::getEvents()
359 361
360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 362 QStringList hdays = _holiday_db->holidaylist(currDate);
361 QValueListIterator<EffectiveEvent> it; 363 QStringList::Iterator sit;
362 QObject* object = 0; 364 QObject* object = 0;
363 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 365 for (sit=hdays.begin();sit!=hdays.end();++sit) {
364 EffectiveEvent ev=*it; 366 object = m_allDays->addHoliday(*sit);
365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 367 if (!object) continue;
368 /* not to do something with it */
369 }
370 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
371 QValueListIterator<EffectiveEvent> it;
372
373 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
374 EffectiveEvent ev=*it;
375 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day.
366 if (ev.event().type() == Event::AllDay ) { 376 if (ev.event().type() == Event::AllDay ) {
@@ -370,3 +380,3 @@ void DateBookDay::getEvents()
370 }else { 380 }else {
371 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 381 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
372 widgetList.append( w ); 382 widgetList.append( w );
@@ -380,4 +390,4 @@ void DateBookDay::getEvents()
380 390
381 } 391 }
382 } 392 }
383} 393}
@@ -386,32 +396,32 @@ static int place( const DateBookDayWidget *item, bool *used, int maxn )
386{ 396{
387 int place = 0; 397 int place = 0;
388 int start = item->event().start().hour(); 398 int start = item->event().start().hour();
389 QTime e = item->event().end(); 399 QTime e = item->event().end();
390 int end = e.hour(); 400 int end = e.hour();
391 if ( e.minute() < 5 ) 401 if ( e.minute() < 5 )
392 end--; 402 end--;
393 if ( end < start ) 403 if ( end < start )
394 end = start; 404 end = start;
395 while ( place < maxn ) { 405 while ( place < maxn ) {
396 bool free = TRUE; 406 bool free = TRUE;
397 int s = start; 407 int s = start;
398 while( s <= end ) { 408 while( s <= end ) {
399 if ( used[10*s+place] ) { 409 if ( used[10*s+place] ) {
400 free = FALSE; 410 free = FALSE;
401 break; 411 break;
402 } 412 }
403 s++; 413 s++;
404 } 414 }
405 if ( free ) 415 if ( free )
406 break; 416 break;
407 place++; 417 place++;
408 } 418 }
409 if ( place == maxn ) { 419 if ( place == maxn ) {
410 return -1; 420 return -1;
411 } 421 }
412 while( start <= end ) { 422 while( start <= end ) {
413 used[10*start+place] = TRUE; 423 used[10*start+place] = TRUE;
414 start++; 424 start++;
415 } 425 }
416 return place; 426 return place;
417} 427}
@@ -421,5 +431,5 @@ void DateBookDay::relayoutPage( bool fromResize )
421{ 431{
422 setUpdatesEnabled( FALSE ); 432 setUpdatesEnabled( FALSE );
423 if ( !fromResize ) { 433 if ( !fromResize ) {
424 getEvents(); // no need we already have them! 434 getEvents(); // no need we already have them!
425 435
@@ -432,124 +442,124 @@ void DateBookDay::relayoutPage( bool fromResize )
432 442
433 widgetList.sort(); 443 widgetList.sort();
434 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 444 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
435 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 445 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
436 446
437 int wCount = widgetList.count(); 447 int wCount = widgetList.count();
438 int wid = view->columnWidth(0)-1; 448 int wid = view->columnWidth(0)-1;
439 int wd; 449 int wd;
440 int n = 1; 450 int n = 1;
441 451
442 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 452 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
443 453
444 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 454 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
445 455
446 if ( wCount < 20 ) { 456 if ( wCount < 20 ) {
447 457
448 QArray<QRect> geometries(wCount); 458 QArray<QRect> geometries(wCount);
449 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector 459 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector
450 460
451 for ( int i = 0; i < wCount; i++) { 461 for ( int i = 0; i < wCount; i++) {
452 QValueList<int> intersectedWidgets; 462 QValueList<int> intersectedWidgets;
453 463
454 //find all widgets intersecting with widgetList.at(i) 464 //find all widgets intersecting with widgetList.at(i)
455 for ( int j = 0; j < wCount; j++) { 465 for ( int j = 0; j < wCount; j++) {
456 if (i != j) 466 if (i != j)
457 if (geometries[j].intersects(geometries[i])) 467 if (geometries[j].intersects(geometries[i]))
458 intersectedWidgets.append(j); 468 intersectedWidgets.append(j);
459 } 469 }
460 470
461 //for each of these intersecting widgets find out how many widgets are they intersecting with 471 //for each of these intersecting widgets find out how many widgets are they intersecting with
462 for ( uint j = 0; j < intersectedWidgets.count(); j++) 472 for ( uint j = 0; j < intersectedWidgets.count(); j++)
463 { 473 {
464 QArray<int> inter(wCount); 474 QArray<int> inter(wCount);
465 inter[j]=1; 475 inter[j]=1;
466 476
467 if (intersectedWidgets[j] != -1) 477 if (intersectedWidgets[j] != -1)
468 for ( uint k = j; k < intersectedWidgets.count(); k++) { 478 for ( uint k = j; k < intersectedWidgets.count(); k++) {
469 if (j != k && intersectedWidgets[k] != -1) 479 if (j != k && intersectedWidgets[k] != -1)
470 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { 480 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) {
471 inter[j]++; 481 inter[j]++;
472 intersectedWidgets[k] = -1; 482 intersectedWidgets[k] = -1;
473 } 483 }
474 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 484 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
475 } 485 }
476 } 486 }
477 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; 487 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++;
478 } 488 }
479 489
480 490
481 for ( int i = 0; i < wCount; i++) { 491 for ( int i = 0; i < wCount; i++) {
482 DateBookDayWidget *w = widgetList.at(i); 492 DateBookDayWidget *w = widgetList.at(i);
483 QRect geom = w->geometry(); 493 QRect geom = w->geometry();
484 geom.setX( 0 ); 494 geom.setX( 0 );
485 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); 495 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0);
486 geom.setWidth( wd ); 496 geom.setWidth( wd );
487 while ( intersects( w, geom ) ) { 497 while ( intersects( w, geom ) ) {
488 geom.moveBy( wd + 2 + 1, 0 ); 498 geom.moveBy( wd + 2 + 1, 0 );
489 } 499 }
490 w->setGeometry( geom ); 500 w->setGeometry( geom );
491 } 501 }
492 502
493 if (jumpToCurTime && this->date() == QDate::currentDate()) { 503 if (jumpToCurTime && this->date() == QDate::currentDate()) {
494 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 504 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
495 } else { 505 } else {
496 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 506 view->setContentsPos( 0, startTime * view->rowHeight(0) );
497 } 507 }
498 } else { 508 } else {
499 int hours[24]; 509 int hours[24];
500 memset( hours, 0, 24*sizeof( int ) ); 510 memset( hours, 0, 24*sizeof( int ) );
501 bool overFlow = FALSE; 511 bool overFlow = FALSE;
502 for ( int i = 0; i < wCount; i++ ) { 512 for ( int i = 0; i < wCount; i++ ) {
503 DateBookDayWidget *w = widgetList.at(i); 513 DateBookDayWidget *w = widgetList.at(i);
504 int start = w->event().start().hour(); 514 int start = w->event().start().hour();
505 QTime e = w->event().end(); 515 QTime e = w->event().end();
506 int end = e.hour(); 516 int end = e.hour();
507 if ( e.minute() < 5 ) 517 if ( e.minute() < 5 )
508 end--; 518 end--;
509 if ( end < start ) 519 if ( end < start )
510 end = start; 520 end = start;
511 while( start <= end ) { 521 while( start <= end ) {
512 hours[start]++; 522 hours[start]++;
513 if ( hours[start] >= 10 ) 523 if ( hours[start] >= 10 )
514 overFlow = TRUE; 524 overFlow = TRUE;
515 ++start; 525 ++start;
516 } 526 }
517 if ( overFlow ) 527 if ( overFlow )
518 break; 528 break;
519 } 529 }
520 for ( int i = 0; i < 24; i++ ) { 530 for ( int i = 0; i < 24; i++ ) {
521 n = QMAX( n, hours[i] ); 531 n = QMAX( n, hours[i] );
522 } 532 }
523 wid = ( view->columnWidth(0)-1 ) / n; 533 wid = ( view->columnWidth(0)-1 ) / n;
524 534
525 bool used[24*10]; 535 bool used[24*10];
526 memset( used, FALSE, 24*10*sizeof( bool ) ); 536 memset( used, FALSE, 24*10*sizeof( bool ) );
527 537
528 for ( int i = 0; i < wCount; i++ ) { 538 for ( int i = 0; i < wCount; i++ ) {
529 DateBookDayWidget *w = widgetList.at(i); 539 DateBookDayWidget *w = widgetList.at(i);
530 int xp = place( w, used, n ); 540 int xp = place( w, used, n );
531 if ( xp != -1 ) { 541 if ( xp != -1 ) {
532 QRect geom = w->geometry(); 542 QRect geom = w->geometry();
533 geom.setX( xp*(wid+2) ); 543 geom.setX( xp*(wid+2) );
534 geom.setWidth( wid ); 544 geom.setWidth( wid );
535 w->setGeometry( geom ); 545 w->setGeometry( geom );
536 } 546 }
537 } 547 }
538 548
539 if (jumpToCurTime && this->date() == QDate::currentDate()) { 549 if (jumpToCurTime && this->date() == QDate::currentDate()) {
540 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 550 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
541 } else { 551 } else {
542 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 552 view->setContentsPos( 0, startTime * view->rowHeight(0) );
543 } 553 }
544 } 554 }
545 555
546 timeMarker->setTime( QTime::currentTime() );//display timeMarker 556 timeMarker->setTime( QTime::currentTime() ); //display timeMarker
547 timeMarker->raise(); //on top of all widgets 557 timeMarker->raise(); //on top of all widgets
548 if (this->date() == QDate::currentDate()) { //only show timeMarker on current day 558 if (this->date() == QDate::currentDate()) { //only show timeMarker on current day
549 timeMarker->show(); 559 timeMarker->show();
550 } else { 560 } else {
551 timeMarker->hide(); 561 timeMarker->hide();
552 } 562 }
553 setUpdatesEnabled( TRUE ); 563 setUpdatesEnabled( TRUE );
554 return; 564 return;
555} 565}
@@ -558,13 +568,13 @@ DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const
558{ 568{
559 int i = 0; 569 int i = 0;
560 DateBookDayWidget *w = widgetList.at(i); 570 DateBookDayWidget *w = widgetList.at(i);
561 int wCount = widgetList.count(); 571 int wCount = widgetList.count();
562 while ( i < wCount && w != item ) { 572 while ( i < wCount && w != item ) {
563 if ( w->geometry().intersects( geom ) ) { 573 if ( w->geometry().intersects( geom ) ) {
564 return w; 574 return w;
565 } 575 }
566 w = widgetList.at(++i); 576 w = widgetList.at(++i);
567 } 577 }
568 578
569 return 0; 579 return 0;
570} 580}
@@ -574,3 +584,3 @@ QDate DateBookDay::date() const
574{ 584{
575 return currDate; 585 return currDate;
576} 586}
@@ -579,15 +589,15 @@ void DateBookDay::setStartViewTime( int startHere )
579{ 589{
580 startTime = startHere; 590 startTime = startHere;
581 dayView()->clearSelection(); 591 dayView()->clearSelection();
582 QTableSelection ts; 592 QTableSelection ts;
583 593
584 if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? 594 if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called?
585 ts.init( QTime::currentTime().hour(), 0); 595 ts.init( QTime::currentTime().hour(), 0);
586 ts.expandTo( QTime::currentTime().hour(), 0); 596 ts.expandTo( QTime::currentTime().hour(), 0);
587 } else { 597 } else {
588 ts.init( startTime, 0 ); 598 ts.init( startTime, 0 );
589 ts.expandTo( startTime, 0 ); 599 ts.expandTo( startTime, 0 );
590 } 600 }
591 601
592 dayView()->addSelection( ts ); 602 dayView()->addSelection( ts );
593} 603}
@@ -596,3 +606,3 @@ int DateBookDay::startViewTime() const
596{ 606{
597 return startTime; 607 return startTime;
598} 608}
@@ -601,4 +611,4 @@ void DateBookDay::slotWeekChanged( bool bStartOnMonday )
601{ 611{
602 header->setStartOfWeek( bStartOnMonday ); 612 header->setStartOfWeek( bStartOnMonday );
603 //redraw(); 613// redraw();
604} 614}
@@ -607,18 +617,18 @@ void DateBookDay::keyPressEvent(QKeyEvent *e)
607{ 617{
608 switch(e->key()) { 618 switch(e->key()) {
609 case Key_Up: 619 case Key_Up:
610 view->moveUp(); 620 view->moveUp();
611 break; 621 break;
612 case Key_Down: 622 case Key_Down:
613 view->moveDown(); 623 view->moveDown();
614 break; 624 break;
615 case Key_Left: 625 case Key_Left:
616 setDate(QDate(currDate).addDays(-1)); 626 setDate(QDate(currDate).addDays(-1));
617 break; 627 break;
618 case Key_Right: 628 case Key_Right:
619 setDate(QDate(currDate).addDays(1)); 629 setDate(QDate(currDate).addDays(1));
620 break; 630 break;
621 default: 631 default:
622 e->ignore(); 632 e->ignore();
623 } 633 }
624} 634}
@@ -628,3 +638,3 @@ void DateBookDay::keyPressEvent(QKeyEvent *e)
628DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) 638DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
629 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) 639 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
630{ 640{
@@ -632,11 +642,11 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
632 // I wonder what other things may be messed up... 642 // I wonder what other things may be messed up...
633 QString strDesc = ev.description(); 643 QString strDesc = ev.description();
634 int where = strDesc.find( "<" ); 644 int where = strDesc.find( "<" );
635 while ( where != -1 ) { 645 while ( where != -1 ) {
636 strDesc.remove( where, 1 ); 646 strDesc.remove( where, 1 );
637 strDesc.insert( where, "&#60;" ); 647 strDesc.insert( where, "&#60;" );
638 where = strDesc.find( "<", where ); 648 where = strDesc.find( "<", where );
639 } 649 }
640 650
641 QString strCat; 651 QString strCat;
642// ### Fix later... 652// ### Fix later...
@@ -645,43 +655,43 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
645// while ( where != -1 ) { 655// while ( where != -1 ) {
646 // strCat.remove( where, 1 ); 656// strCat.remove( where, 1 );
647 // strCat.insert( where, "&#60;" ); 657// strCat.insert( where, "&#60;" );
648 // where = strCat.find( "<", where ); 658// where = strCat.find( "<", where );
649// } 659// }
650 660
651 QString strNote = ev.notes(); 661 QString strNote = ev.notes();
652 where = strNote.find( "<" ); 662 where = strNote.find( "<" );
653 while ( where != -1 ) { 663 while ( where != -1 ) {
654 strNote.remove( where, 1 ); 664 strNote.remove( where, 1 );
655 strNote.insert( where, "&#60;" ); 665 strNote.insert( where, "&#60;" );
656 where = strNote.find( "<", where ); 666 where = strNote.find( "<", where );
657 } 667 }
658 668
659 text = "<b>" + strDesc + "</b><br>" + "<i>"; 669 text = "<b>" + strDesc + "</b><br>" + "<i>";
660 if ( !strCat.isEmpty() ) { 670 if ( !strCat.isEmpty() ) {
661 text += strCat + "</i><br>"; 671 text += strCat + "</i><br>";
662 } 672 }
663 if (ev.event().type() == Event::Normal ) { 673 if (ev.event().type() == Event::Normal ) {
664 setEventText( text ); 674 setEventText( text );
665 } else { 675 } else {
666 setAllDayText( text ); 676 setAllDayText( text );
667 } 677 }
668 678
669 text += "<br><br>" + strNote; 679 text += "<br><br>" + strNote;
670 680
671 setBackgroundMode( PaletteBase ); 681 setBackgroundMode( PaletteBase );
672 682
673 QTime start = ev.start(); 683 QTime start = ev.start();
674 QTime end = ev.end(); 684 QTime end = ev.end();
675 int y = start.hour()*60+start.minute(); 685 int y = start.hour()*60+start.minute();
676 int h = end.hour()*60+end.minute()-y; 686 int h = end.hour()*60+end.minute()-y;
677 int rh = dateBook->dayView()->rowHeight(0); 687 int rh = dateBook->dayView()->rowHeight(0);
678 y = y*rh/60; 688 y = y*rh/60;
679 h = h*rh/60; 689 h = h*rh/60;
680 690
681 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. 691 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.
682 if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. 692 if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview.
683 geom.setY( y ); 693 geom.setY( y );
684 geom.setHeight( h ); 694 geom.setHeight( h );
685 geom.setX( 0 ); 695 geom.setX( 0 );
686 geom.setWidth(dateBook->dayView()->columnWidth(0)-1); 696 geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
687 697
@@ -690,3 +700,3 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
690void DateBookDayWidget::setAllDayText( QString &text ) { 700void DateBookDayWidget::setAllDayText( QString &text ) {
691 text += "<b>" + tr("This is an all day event.") + "</b>"; 701 text += "<b>" + tr("This is an all day event.") + "</b>";
692} 702}
@@ -694,16 +704,16 @@ void DateBookDayWidget::setAllDayText( QString &text ) {
694void DateBookDayWidget::setEventText( QString& text ) { 704void DateBookDayWidget::setEventText( QString& text ) {
695 bool whichClock = dateBook->dayView()->whichClock(); 705 bool whichClock = dateBook->dayView()->whichClock();
696 if ( ev.startDate() != ev.endDate() ) { 706 if ( ev.startDate() != ev.endDate() ) {
697 text += "<b>" + tr("Start") + "</b>: "; 707 text += "<b>" + tr("Start") + "</b>: ";
698 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); 708 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE );
699 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; 709 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>";
700 text += "<b>" + tr("End") + "</b>: "; 710 text += "<b>" + tr("End") + "</b>: ";
701 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); 711 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE );
702 text += " - " + TimeString::longDateString( ev.endDate() ); 712 text += " - " + TimeString::longDateString( ev.endDate() );
703 } else { 713 } else {
704 text += "<b>" + tr("Time") + "</b>: "; 714 text += "<b>" + tr("Time") + "</b>: ";
705 text += TimeString::timeString( ev.start(), whichClock, FALSE ); 715 text += TimeString::timeString( ev.start(), whichClock, FALSE );
706 text += "<b>" + tr(" - ") + "</b>"; 716 text += "<b>" + tr(" - ") + "</b>";
707 text += TimeString::timeString( ev.end(), whichClock, FALSE ); 717 text += TimeString::timeString( ev.end(), whichClock, FALSE );
708 } 718 }
709} 719}
@@ -716,26 +726,26 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
716{ 726{
717 QPainter p( this ); 727 QPainter p( this );
718 728
719 if (dateBook->getSelectedWidget() == this) { 729 if (dateBook->getSelectedWidget() == this) {
720 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 730 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
721 } else { 731 } else {
722 if (dateBook->date() == QDate::currentDate()) { 732 if (dateBook->date() == QDate::currentDate()) {
723 QTime curTime = QTime::currentTime(); 733 QTime curTime = QTime::currentTime();
724 if (ev.end() < curTime) { 734 if (ev.end() < curTime) {
725 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 735 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
726 } else { 736 } else {
727 //change color in dependence of the time till the event starts 737 //change color in dependence of the time till the event starts
728 int duration = curTime.secsTo(ev.start()); 738 int duration = curTime.secsTo(ev.start());
729 if (duration < 0) duration = 0; 739 if (duration < 0) duration = 0;
730 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 740 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
731 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue 741 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
732 } 742 }
733 } else { 743 } else {
734 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) 744 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
735 //perhaps make a distinction between future/past dates 745 //perhaps make a distinction between future/past dates
736 } 746 }
737 } 747 }
738 748
739 p.setPen( QColor(100, 100, 100) ); 749 p.setPen( QColor(100, 100, 100) );
740 p.drawRect(rect()); 750 p.drawRect(rect());
741 751
@@ -743,20 +753,20 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
743 753
744 int y = 0; 754 int y = 0;
745 int d = 0; 755 int d = 0;
746 756
747 if ( ev.event().hasAlarm() ) { 757 if ( ev.event().hasAlarm() ) {
748 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 758 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
749 y = 20; 759 y = 20;
750 d = 20; 760 d = 20;
751 } 761 }
752 762
753 if ( ev.event().hasRepeat() ) { 763 if ( ev.event().hasRepeat() ) {
754 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 764 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
755 d = 20; 765 d = 20;
756 y += 20; 766 y += 20;
757 } 767 }
758 768
759 QSimpleRichText rt( text, font() ); 769 QSimpleRichText rt( text, font() );
760 rt.setWidth( geom.width() - d - 6 ); 770 rt.setWidth( geom.width() - d - 6 );
761 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 771 rt.draw( &p, 7, 0, e->region(), colorGroup() );
762} 772}
@@ -787,11 +797,11 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
787{ 797{
788 DateBookDayWidget *item; 798 DateBookDayWidget *item;
789 799
790 item = dateBook->getSelectedWidget(); 800 item = dateBook->getSelectedWidget();
791 if (item) 801 if (item)
792 item->update(); 802 item->update();
793 803
794 dateBook->setSelectedWidget(this); 804 dateBook->setSelectedWidget(this);
795 update(); 805 update();
796 dateBook->repaint(); 806 dateBook->repaint();
797 807
@@ -799,18 +809,18 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
799 809
800 QPopupMenu m; 810 QPopupMenu m;
801 m.insertItem( tr( "Edit" ), 1 ); 811 m.insertItem( tr( "Edit" ), 1 );
802 m.insertItem( tr( "Duplicate" ), 4 ); 812 m.insertItem( tr( "Duplicate" ), 4 );
803 m.insertItem( tr( "Delete" ), 2 ); 813 m.insertItem( tr( "Delete" ), 2 );
804 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); 814 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
805 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); 815 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 );
806 int r = m.exec( e->globalPos() ); 816 int r = m.exec( e->globalPos() );
807 if ( r == 1 ) { 817 if ( r == 1 ) {
808 emit editMe( eve ); 818 emit editMe( eve );
809 } else if ( r == 2 ) { 819 } else if ( r == 2 ) {
810 emit deleteMe( eve ); 820 emit deleteMe( eve );
811 } else if ( r == 3 ) { 821 } else if ( r == 3 ) {
812 emit beamMe( eve ); 822 emit beamMe( eve );
813 } else if ( r == 4 ) { 823 } else if ( r == 4 ) {
814 emit duplicateMe( eve ); 824 emit duplicateMe( eve );
815 } else if ( r == 5 ) { 825 } else if ( r == 5 ) {
816 // create an Event and beam it... 826 // create an Event and beam it...
@@ -876,6 +886,6 @@ void DateBookDayWidget::setGeometry( const QRect &r )
876{ 886{
877 geom = r; 887 geom = r;
878 setFixedSize( r.width()+1, r.height()+1 ); 888 setFixedSize( r.width()+1, r.height()+1 );
879 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 889 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
880 show(); 890 show();
881} 891}
@@ -888,5 +898,5 @@ void DateBookDayWidget::setGeometry( const QRect &r )
888DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) 898DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
889 : QWidget( db->dayView()->viewport() ), dateBook( db ) 899 : QWidget( db->dayView()->viewport() ), dateBook( db )
890{ 900{
891 setBackgroundMode( PaletteBase ); 901 setBackgroundMode( PaletteBase );
892} 902}
@@ -899,10 +909,10 @@ void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
899{ 909{
900 QPainter p( this ); 910 QPainter p( this );
901 p.setBrush( QColor( 255, 0, 0 ) ); 911 p.setBrush( QColor( 255, 0, 0 ) );
902 912
903 QPen pen; 913 QPen pen;
904 pen.setStyle(NoPen); 914 pen.setStyle(NoPen);
905 915
906 p.setPen( pen ); 916 p.setPen( pen );
907 p.drawRect(rect()); 917 p.drawRect(rect());
908} 918}
@@ -911,17 +921,17 @@ void DateBookDayTimeMarker::setTime( const QTime &t )
911{ 921{
912 int y = t.hour()*60+t.minute(); 922 int y = t.hour()*60+t.minute();
913 int rh = dateBook->dayView()->rowHeight(0); 923 int rh = dateBook->dayView()->rowHeight(0);
914 y = y*rh/60; 924 y = y*rh/60;
915 925
916 geom.setX( 0 ); 926 geom.setX( 0 );
917 927
918 int x = dateBook->dayView()->columnWidth(0)-1; 928 int x = dateBook->dayView()->columnWidth(0)-1;
919 geom.setWidth( x ); 929 geom.setWidth( x );
920 930
921 geom.setY( y ); 931 geom.setY( y );
922 geom.setHeight( 1 ); 932 geom.setHeight( 1 );
923 933
924 setGeometry( geom ); 934 setGeometry( geom );
925 935
926 time = t; 936 time = t;
927} 937}
@@ -930,6 +940,6 @@ void DateBookDayTimeMarker::setGeometry( const QRect &r )
930{ 940{
931 geom = r; 941 geom = r;
932 setFixedSize( r.width()+1, r.height()+1 ); 942 setFixedSize( r.width()+1, r.height()+1 );
933 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 943 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
934 show(); 944 show();
935} 945}