summaryrefslogtreecommitdiff
path: root/core/pim/datebook
Unidiff
Diffstat (limited to 'core/pim/datebook') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp36
-rw-r--r--core/pim/datebook/datebookday.cpp16
-rw-r--r--core/pim/datebook/datebookdayallday.cpp2
-rw-r--r--core/pim/datebook/datebookdayheaderimpl.cpp4
-rw-r--r--core/pim/datebook/datebooksettings.cpp2
-rw-r--r--core/pim/datebook/datebookweek.cpp4
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp2
-rw-r--r--core/pim/datebook/datebookweeklst.cpp28
-rw-r--r--core/pim/datebook/dateentryimpl.cpp20
-rw-r--r--core/pim/datebook/repeatentry.cpp4
10 files changed, 58 insertions, 60 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index af26302..3934411 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -68,202 +68,202 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
68{ 68{
69 bool needEvilHack= false; // if we need an Evil Hack 69 bool needEvilHack= false; // if we need an Evil Hack
70 QTime t; 70 QTime t;
71 t.start(); 71 t.start();
72 db = new DateBookDBHack; 72 db = new DateBookDBHack;
73 qDebug("loading db t=%d", t.elapsed() ); 73 qDebug("loading db t=%d", t.elapsed() );
74 loadSettings(); 74 loadSettings();
75 setCaption( tr("Calendar") ); 75 setCaption( tr("Calendar") );
76 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 76 setIcon( Resource::loadPixmap( "datebook_icon" ) );
77 77
78 setToolBarsMovable( FALSE ); 78 setToolBarsMovable( FALSE );
79 79
80 views = new QWidgetStack( this ); 80 views = new QWidgetStack( this );
81 setCentralWidget( views ); 81 setCentralWidget( views );
82 82
83 dayView = 0; 83 dayView = 0;
84 weekView = 0; 84 weekView = 0;
85 weekLstView = 0; 85 weekLstView = 0;
86 monthView = 0; 86 monthView = 0;
87 87
88// QToolBar *bar = new QToolBar( this ); 88// QToolBar *bar = new QToolBar( this );
89// bar->setHorizontalStretchable( TRUE ); 89// bar->setHorizontalStretchable( TRUE );
90 90
91// QMenuBar *mb = new QMenuBar( bar ); 91// QMenuBar *mb = new QMenuBar( bar );
92// mb->setMargin( 0 ); 92// mb->setMargin( 0 );
93 93
94// QPopupMenu *view = new QPopupMenu( this ); 94// QPopupMenu *view = new QPopupMenu( this );
95// mb->insertItem( tr( "View" ), view ); 95// mb->insertItem( tr( "View" ), view );
96 96
97 QToolBar *sub_bar = new QToolBar(this); 97 QToolBar *sub_bar = new QToolBar(this);
98 sub_bar->setHorizontalStretchable(TRUE); 98 sub_bar->setHorizontalStretchable(TRUE);
99 99
100 QActionGroup *g = new QActionGroup( this ); 100 QActionGroup *g = new QActionGroup( this );
101 g->setExclusive( TRUE ); 101 g->setExclusive( TRUE );
102 102
103 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 103 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
104 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 104 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
105 a->addTo( sub_bar ); 105 a->addTo( sub_bar );
106 106
107 sub_bar->addSeparator(); 107 sub_bar->addSeparator();
108 108
109 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 109 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
110 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 110 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
111 a->addTo( sub_bar ); 111 a->addTo( sub_bar );
112 //a->addTo( view ); 112 //a->addTo( view );
113 113
114 sub_bar->addSeparator(); 114 sub_bar->addSeparator();
115 115
116 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 116 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
117 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 117 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
118 a->addTo( sub_bar ); 118 a->addTo( sub_bar );
119// a->addTo( view ); 119// a->addTo( view );
120 a->setToggleAction( TRUE ); 120 a->setToggleAction( TRUE );
121 a->setOn( TRUE ); 121 a->setOn( TRUE );
122 dayAction = a; 122 dayAction = a;
123 123
124 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 124 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
125 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
126 a->addTo( sub_bar ); 126 a->addTo( sub_bar );
127// a->addTo( view ); 127// a->addTo( view );
128 a->setToggleAction( TRUE ); 128 a->setToggleAction( TRUE );
129 weekAction = a; 129 weekAction = a;
130 130
131 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 131 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
132 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
133 a->addTo( sub_bar ); 133 a->addTo( sub_bar );
134// a->addTo( view ); 134// a->addTo( view );
135 a->setToggleAction( TRUE ); 135 a->setToggleAction( TRUE );
136 weekLstAction = a; 136 weekLstAction = a;
137 137
138 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 138 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
139 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
140 a->addTo( sub_bar ); 140 a->addTo( sub_bar );
141// a->addTo( view ); 141// a->addTo( view );
142 a->setToggleAction( TRUE ); 142 a->setToggleAction( TRUE );
143 monthAction = a; 143 monthAction = a;
144 144
145 sub_bar->addSeparator(); 145 sub_bar->addSeparator();
146 146
147 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 147 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
149 a->addTo( sub_bar ); 149 a->addTo( sub_bar );
150 150
151 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 151 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
152 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 152 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
153 a->addTo( sub_bar ); 153 a->addTo( sub_bar );
154 154
155 if(defaultView==DAY) viewDay(); 155 if(defaultView==DAY) viewDay();
156 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 156 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
157 if(defaultView==WEEKLST) viewWeekLst(); 157 if(defaultView==WEEKLST) viewWeekLst();
158 if(defaultView==MONTH) viewMonth(); 158 if(defaultView==MONTH) viewMonth();
159 159
160 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 160 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
161 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 161 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
162 162
163#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 163#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
164 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 164 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
165#endif 165#endif
166 166
167 // listen on QPE/System 167 // listen on QPE/System
168#if defined(Q_WS_QWS) 168#if defined(Q_WS_QWS)
169#if !defined(QT_NO_COP) 169#if !defined(QT_NO_COP)
170 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 170 QCopChannel *channel = new QCopChannel( "QPE/System", this );
171 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 171 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
172 channel = new QCopChannel( "QPE/Datebook", this ); 172 channel = new QCopChannel( "QPE/Datebook", this );
173 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
174#endif 174#endif
175#endif 175#endif
176 176
177 qDebug("done t=%d", t.elapsed() ); 177 qDebug("done t=%d", t.elapsed() );
178 178
179 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 179 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
180 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 180 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
181 /* 181 /*
182 * Here is a problem description: 182 * Here is a problem description:
183 * When Weekview is the default view 183 * When Weekview is the default view
184 * a DateBookWeekView get's created 184 * a DateBookWeekView get's created
185 * redraw() get's called. So what? 185 * redraw() get's called. So what?
186 * Remember that we're still in the c'tor 186 * Remember that we're still in the c'tor
187 * and no final layout has happened? Ok 187 * and no final layout has happened? Ok
188 * now all Events get arranged. Their x 188 * now all Events get arranged. Their x
189 * position get's determined by a QHeader 189 * position get's determined by a QHeader
190 * position. But the QHeader isn't layouted or 190 * position. But the QHeader isn't layouted or
191 * at the right position. redraw() is a slot 191 * at the right position. redraw() is a slot
192 * so we'll call it then via a singleShot 192 * so we'll call it then via a singleShot
193 * from view() 193 * from view()
194 */ 194 */
195 if( needEvilHack ){ 195 if( needEvilHack ){
196 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 196 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
197 } 197 }
198} 198}
199 199
200void DateBook::receive( const QCString &msg, const QByteArray &data ) 200void DateBook::receive( const QCString &msg, const QByteArray &data )
201{ 201{
202 QDataStream stream( data, IO_ReadOnly ); 202 QDataStream stream( data, IO_ReadOnly );
203 if ( msg == "timeChange(QString)" ) { 203 if ( msg == "timeChange(QString)" ) {
204 // update active view! 204 // update active view!
205 if ( dayAction->isOn() ) 205 if ( dayAction->isOn() )
206 viewDay(); 206 viewDay();
207 else if ( weekAction->isOn() ) 207 else if ( weekAction->isOn() )
208 viewWeek(); 208 viewWeek();
209 else if ( monthAction->isOn() ) 209 else if ( monthAction->isOn() )
210 viewMonth(); 210 viewMonth();
211 } 211 }
212 else if (msg == "editEvent(int)") { 212 else if (msg == "editEvent(int)") {
213 int uid; 213 int uid;
214 stream >> uid; 214 stream >> uid;
215 Event e=db->eventByUID(uid); 215 Event e=db->eventByUID(uid);
216 editEvent(e); 216 editEvent(e);
217 }else if (msg == "viewDefault(QDate)"){ 217 }else if (msg == "viewDefault(QDate)"){
218 QDate day; 218 QDate day;
219 stream >> day; 219 stream >> day;
220 viewDefault(day); 220 viewDefault(day);
221 } 221 }
222} 222}
223 223
224DateBook::~DateBook() 224DateBook::~DateBook()
225{ 225{
226} 226}
227 227
228void DateBook::slotSettings() 228void DateBook::slotSettings()
229{ 229{
230 DateBookSettings frmSettings( ampm, this ); 230 DateBookSettings frmSettings( ampm, this );
231 frmSettings.setStartTime( startTime ); 231 frmSettings.setStartTime( startTime );
232 frmSettings.setAlarmPreset( aPreset, presetTime ); 232 frmSettings.setAlarmPreset( aPreset, presetTime );
233 frmSettings.setJumpToCurTime( bJumpToCurTime ); 233 frmSettings.setJumpToCurTime( bJumpToCurTime );
234 frmSettings.setRowStyle( rowStyle ); 234 frmSettings.setRowStyle( rowStyle );
235 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 235 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
236 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 236 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
237 237
238 bool found=false; 238 bool found=false;
239 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 239 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
240 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 240 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
241 frmSettings.comboLocation->setCurrentItem(i); 241 frmSettings.comboLocation->setCurrentItem(i);
242 found=true; 242 found=true;
243 break; 243 break;
244 } 244 }
245 } 245 }
246 if(!found) { 246 if(!found) {
247 frmSettings.comboLocation->insertItem(defaultLocation); 247 frmSettings.comboLocation->insertItem(defaultLocation);
248 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 248 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
249 } 249 }
250 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 250 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
251 251
252 if ( QPEApplication::execDialog( &frmSettings ) ) { 252 if ( QPEApplication::execDialog( &frmSettings ) ) {
253 aPreset = frmSettings.alarmPreset(); 253 aPreset = frmSettings.alarmPreset();
254 presetTime = frmSettings.presetTime(); 254 presetTime = frmSettings.presetTime();
255 startTime = frmSettings.startTime(); 255 startTime = frmSettings.startTime();
256 bJumpToCurTime = frmSettings.jumpToCurTime(); 256 bJumpToCurTime = frmSettings.jumpToCurTime();
257 rowStyle = frmSettings.rowStyle(); 257 rowStyle = frmSettings.rowStyle();
258 defaultView=frmSettings.comboDefaultView->currentItem()+1; 258 defaultView=frmSettings.comboDefaultView->currentItem()+1;
259 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 259 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
260 defaultLocation=frmSettings.comboLocation->currentText(); 260 defaultLocation=frmSettings.comboLocation->currentText();
261 defaultCategories=frmSettings.comboCategory->currentCategories(); 261 defaultCategories=frmSettings.comboCategory->currentCategories();
262 262
263 if ( dayView ) { 263 if ( dayView ) {
264 dayView->setStartViewTime( startTime ); 264 dayView->setStartViewTime( startTime );
265 dayView->setJumpToCurTime( bJumpToCurTime ); 265 dayView->setJumpToCurTime( bJumpToCurTime );
266 dayView->setRowStyle( rowStyle ); 266 dayView->setRowStyle( rowStyle );
267 } 267 }
268 if ( weekView ) { 268 if ( weekView ) {
269 weekView->setStartViewTime( startTime ); 269 weekView->setStartViewTime( startTime );
@@ -424,246 +424,246 @@ void DateBook::duplicateEvent( const Event &e )
424 } 424 }
425 /* 425 /*
426 * The problem: 426 * The problem:
427 * DateBookDB does remove repeating events not by uid but by the time 427 * DateBookDB does remove repeating events not by uid but by the time
428 * the recurrence was created 428 * the recurrence was created
429 * so we need to update that time as well 429 * so we need to update that time as well
430 */ 430 */
431 Event::RepeatPattern rp = newEv.repeatPattern(); 431 Event::RepeatPattern rp = newEv.repeatPattern();
432 rp.createTime = ::time( NULL ); 432 rp.createTime = ::time( NULL );
433 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 433 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
434 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 434 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
435 newEv.assignUid(); 435 newEv.assignUid();
436 436
437 db->addEvent(newEv); 437 db->addEvent(newEv);
438 emit newEvent(); 438 emit newEvent();
439 break; 439 break;
440 } 440 }
441} 441}
442 442
443void DateBook::editEvent( const Event &e ) 443void DateBook::editEvent( const Event &e )
444{ 444{
445 if (syncing) { 445 if (syncing) {
446 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 446 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
447 return; 447 return;
448 } 448 }
449 449
450 // workaround added for text input. 450 // workaround added for text input.
451 QDialog editDlg( this, 0, TRUE ); 451 QDialog editDlg( this, 0, TRUE );
452 DateEntry *entry; 452 DateEntry *entry;
453 editDlg.setCaption( tr("Edit Event") ); 453 editDlg.setCaption( tr("Edit Event") );
454 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 454 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
455 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 455 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
456 sv->setResizePolicy( QScrollView::AutoOneFit ); 456 sv->setResizePolicy( QScrollView::AutoOneFit );
457 // KLUDGE!!! 457 // KLUDGE!!!
458 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 458 sv->setHScrollBarMode( QScrollView::AlwaysOff );
459 vb->addWidget( sv ); 459 vb->addWidget( sv );
460 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 460 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
461 entry->timezone->setEnabled( FALSE ); 461 entry->timezone->setEnabled( FALSE );
462 sv->addChild( entry ); 462 sv->addChild( entry );
463 463
464 while ( QPEApplication::execDialog( &editDlg ) ) { 464 while ( QPEApplication::execDialog( &editDlg ) ) {
465 Event newEv = entry->event(); 465 Event newEv = entry->event();
466 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 466 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
467 break; 467 break;
468 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 468 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
469 QString error = checkEvent(newEv); 469 QString error = checkEvent(newEv);
470 if (!error.isNull()) { 470 if (!error.isNull()) {
471 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 471 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
472 } 472 }
473 db->editEvent(e, newEv); 473 db->editEvent(e, newEv);
474 emit newEvent(); 474 emit newEvent();
475 break; 475 break;
476 } 476 }
477} 477}
478 478
479void DateBook::removeEvent( const Event &e ) 479void DateBook::removeEvent( const Event &e )
480{ 480{
481 if (syncing) { 481 if (syncing) {
482 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 482 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
483 return; 483 return;
484 } 484 }
485 485
486 QString strName = e.description(); 486 QString strName = e.description();
487 487
488 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 488 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
489 return; 489 return;
490 490
491 db->removeEvent( e ); 491 db->removeEvent( e );
492 if ( views->visibleWidget() == dayView && dayView ) 492 if ( views->visibleWidget() == dayView && dayView )
493 dayView->redraw(); 493 dayView->redraw();
494 494
495} 495}
496 496
497void DateBook::addEvent( const Event &e ) 497void DateBook::addEvent( const Event &e )
498{ 498{
499 QDate d = e.start().date(); 499 QDate d = e.start().date();
500 initDay(); 500 initDay();
501 dayView->setDate( d ); 501 dayView->setDate( d );
502} 502}
503 503
504void DateBook::showDay( int year, int month, int day ) 504void DateBook::showDay( int year, int month, int day )
505{ 505{
506 QDate d(year, month, day); 506 QDate d(year, month, day);
507 view(DAY,d); 507 view(DAY,d);
508} 508}
509 509
510void DateBook::initDay() 510void DateBook::initDay()
511{ 511{
512 if ( !dayView ) { 512 if ( !dayView ) {
513 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 513 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
514 views->addWidget( dayView, DAY ); 514 views->addWidget( dayView, DAY );
515 dayView->setJumpToCurTime( bJumpToCurTime ); 515 dayView->setJumpToCurTime( bJumpToCurTime );
516 dayView->setStartViewTime( startTime ); 516 dayView->setStartViewTime( startTime );
517 dayView->setRowStyle( rowStyle ); 517 dayView->setRowStyle( rowStyle );
518 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 518 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
519 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 519 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
520 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 520 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) );
521 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 521 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
522 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 522 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) );
523 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); 523 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
524 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); 524 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) );
525 } 525 }
526} 526}
527 527
528void DateBook::initWeek() 528void DateBook::initWeek()
529{ 529{
530 if ( !weekView ) { 530 if ( !weekView ) {
531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
532 weekView->setStartViewTime( startTime ); 532 weekView->setStartViewTime( startTime );
533 views->addWidget( weekView, WEEK ); 533 views->addWidget( weekView, WEEK );
534 connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 534 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
535 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 535 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
536 } 536 }
537 537
538 //But also get it right: the year that we display can be different 538 //But also get it right: the year that we display can be different
539 //from the year of the current date. So, first find the year 539 //from the year of the current date. So, first find the year
540 //number of the current week. 540 //number of the current week.
541 int yearNumber, totWeeks; 541 int yearNumber, totWeeks;
542 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 542 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
543 543
544 QDate d = QDate( yearNumber, 12, 31 ); 544 QDate d = QDate( yearNumber, 12, 31 );
545 calcWeek( d, totWeeks, yearNumber, onMonday ); 545 calcWeek( d, totWeeks, yearNumber, onMonday );
546 546
547 while ( totWeeks == 1 ) { 547 while ( totWeeks == 1 ) {
548 d = d.addDays( -1 ); 548 d = d.addDays( -1 );
549 calcWeek( d, totWeeks, yearNumber, onMonday ); 549 calcWeek( d, totWeeks, yearNumber, onMonday );
550 } 550 }
551} 551}
552 552
553void DateBook::initWeekLst() { 553void DateBook::initWeekLst() {
554 if ( !weekLstView ) { 554 if ( !weekLstView ) {
555 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 555 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
556 views->addWidget( weekLstView, WEEKLST ); 556 views->addWidget( weekLstView, WEEKLST );
557 557
558 //weekLstView->setStartViewTime( startTime ); 558 //weekLstView->setStartViewTime( startTime );
559 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 559 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
560 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), 560 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
561 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); 561 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
562 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 562 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
563 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 563 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
564 } 564 }
565} 565}
566 566
567 567
568void DateBook::initMonth() 568void DateBook::initMonth()
569{ 569{
570 if ( !monthView ) { 570 if ( !monthView ) {
571 monthView = new DateBookMonth( views, "month view", FALSE, db ); 571 monthView = new DateBookMonth( views, "month view", FALSE, db );
572 views->addWidget( monthView, MONTH ); 572 views->addWidget( monthView, MONTH );
573 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 573 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
574 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 574 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
575 qApp->processEvents(); 575 qApp->processEvents();
576 } 576 }
577} 577}
578 578
579void DateBook::loadSettings() 579void DateBook::loadSettings()
580{ 580{
581 Config qpeconfig( "qpe" ); 581 Config qpeconfig( "qpe" );
582 qpeconfig.setGroup("Time"); 582 qpeconfig.setGroup("Time");
583 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 583 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
584 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 584 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
585 585
586 Config config("DateBook"); 586 Config config("DateBook");
587 config.setGroup("Main"); 587 config.setGroup("Main");
588 startTime = config.readNumEntry("startviewtime", 8); 588 startTime = config.readNumEntry("startviewtime", 8);
589 aPreset = config.readBoolEntry("alarmpreset"); 589 aPreset = config.readBoolEntry("alarmpreset");
590 presetTime = config.readNumEntry("presettime"); 590 presetTime = config.readNumEntry("presettime");
591 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 591 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
592 rowStyle = config.readNumEntry("rowstyle"); 592 rowStyle = config.readNumEntry("rowstyle");
593 defaultView = config.readNumEntry("defaultview",DAY); 593 defaultView = config.readNumEntry("defaultview",DAY);
594 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 594 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
595 595
596 defaultLocation=config.readEntry("defaultLocation"); 596 defaultLocation=config.readEntry("defaultLocation");
597 QString tmpString=config.readEntry("defaultCategories"); 597 QString tmpString=config.readEntry("defaultCategories");
598 QStringList tmpStringList=QStringList::split(",",tmpString); 598 QStringList tmpStringList=QStringList::split(",",tmpString);
599 defaultCategories.truncate(0); 599 defaultCategories.truncate(0);
600 600
601 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 601 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
602 defaultCategories.resize(defaultCategories.count()+1); 602 defaultCategories.resize(defaultCategories.count()+1);
603 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 603 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
604 } 604 }
605} 605}
606 606
607void DateBook::saveSettings() 607void DateBook::saveSettings()
608{ 608{
609 Config config( "qpe" ); 609 Config config( "qpe" );
610 Config configDB( "DateBook" ); 610 Config configDB( "DateBook" );
611 configDB.setGroup( "Main" ); 611 configDB.setGroup( "Main" );
612 configDB.writeEntry("startviewtime",startTime); 612 configDB.writeEntry("startviewtime",startTime);
613 configDB.writeEntry("alarmpreset",aPreset); 613 configDB.writeEntry("alarmpreset",aPreset);
614 configDB.writeEntry("presettime",presetTime); 614 configDB.writeEntry("presettime",presetTime);
615 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 615 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
616 configDB.writeEntry("rowstyle", rowStyle); 616 configDB.writeEntry("rowstyle", rowStyle);
617 configDB.writeEntry("defaultview",defaultView); 617 configDB.writeEntry("defaultview",defaultView);
618 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 618 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
619 619
620 configDB.writeEntry("defaultLocation",defaultLocation); 620 configDB.writeEntry("defaultLocation",defaultLocation);
621 QStringList tmpStringList; 621 QStringList tmpStringList;
622 for( uint i=0; i<defaultCategories.count(); i++) { 622 for( uint i=0; i<defaultCategories.count(); i++) {
623 tmpStringList << QString::number(defaultCategories[i]); 623 tmpStringList << QString::number(defaultCategories[i]);
624 } 624 }
625 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 625 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
626} 626}
627 627
628void DateBook::appMessage(const QCString& msg, const QByteArray& data) 628void DateBook::appMessage(const QCString& msg, const QByteArray& data)
629{ 629{
630 bool needShow = FALSE; 630 bool needShow = FALSE;
631 if ( msg == "alarm(QDateTime,int)" ) { 631 if ( msg == "alarm(QDateTime,int)" ) {
632 QDataStream ds(data,IO_ReadOnly); 632 QDataStream ds(data,IO_ReadOnly);
633 QDateTime when; int warn; 633 QDateTime when; int warn;
634 ds >> when >> warn; 634 ds >> when >> warn;
635 635
636 // check to make it's okay to continue, 636 // check to make it's okay to continue,
637 // this is the case that the time was set ahead, and 637 // this is the case that the time was set ahead, and
638 // we are forced given a stale alarm... 638 // we are forced given a stale alarm...
639 QDateTime current = QDateTime::currentDateTime(); 639 QDateTime current = QDateTime::currentDateTime();
640 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 640 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
641 return; 641 return;
642 642
643 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 643 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
644 if ( list.count() > 0 ) { 644 if ( list.count() > 0 ) {
645 QString msg; 645 QString msg;
646 bool bSound = FALSE; 646 bool bSound = FALSE;
647 int stopTimer = 0; 647 int stopTimer = 0;
648 bool found = FALSE; 648 bool found = FALSE;
649 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 649 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
650 if ( (*it).event().hasAlarm() ) { 650 if ( (*it).event().hasAlarm() ) {
651 found = TRUE; 651 found = TRUE;
652 msg += "<CENTER><B>" + (*it).description() + "</B>" 652 msg += "<CENTER><B>" + (*it).description() + "</B>"
653 + "<BR>" + (*it).location() + "<BR>" 653 + "<BR>" + (*it).location() + "<BR>"
654 + TimeString::dateString((*it).event().start(),ampm) 654 + TimeString::dateString((*it).event().start(),ampm)
655 + (warn 655 + (warn
656 ? tr(" (in " + QString::number(warn) 656 ? tr(" (in " + QString::number(warn)
657 + tr(" minutes)")) 657 + tr(" minutes)"))
658 : QString("")) 658 : QString(""))
659 + "<BR>" 659 + "<BR>"
660 + (*it).notes() + "</CENTER>"; 660 + (*it).notes() + "</CENTER>";
661 if ( (*it).event().alarmSound() != Event::Silent ) { 661 if ( (*it).event().alarmSound() != Event::Silent ) {
662 bSound = TRUE; 662 bSound = TRUE;
663 } 663 }
664 } 664 }
665 } 665 }
666 if ( found ) { 666 if ( found ) {
667 if ( bSound ) { 667 if ( bSound ) {
668 Sound::soundAlarm(); 668 Sound::soundAlarm();
669 alarmCounter = 0; 669 alarmCounter = 0;
@@ -812,216 +812,214 @@ void DateBook::slotNewEventFromKey( const QString &str )
812{ 812{
813 if (syncing) { 813 if (syncing) {
814 QMessageBox::warning( this, tr("Calendar"), 814 QMessageBox::warning( this, tr("Calendar"),
815 tr( "Can not edit data, currently syncing") ); 815 tr( "Can not edit data, currently syncing") );
816 return; 816 return;
817 } 817 }
818 818
819 // We get to here from a key pressed in the Day View 819 // We get to here from a key pressed in the Day View
820 // So we can assume some things. We want the string 820 // So we can assume some things. We want the string
821 // passed in to be part of the description. 821 // passed in to be part of the description.
822 QDateTime start, end; 822 QDateTime start, end;
823 if ( views->visibleWidget() == dayView ) { 823 if ( views->visibleWidget() == dayView ) {
824 dayView->selectedDates( start, end ); 824 dayView->selectedDates( start, end );
825 } else if ( views->visibleWidget() == monthView ) { 825 } else if ( views->visibleWidget() == monthView ) {
826 QDate d = monthView->selectedDate(); 826 QDate d = monthView->selectedDate();
827 start = end = d; 827 start = end = d;
828 start.setTime( QTime( 10, 0 ) ); 828 start.setTime( QTime( 10, 0 ) );
829 end.setTime( QTime( 12, 0 ) ); 829 end.setTime( QTime( 12, 0 ) );
830 } else if ( views->visibleWidget() == weekView ) { 830 } else if ( views->visibleWidget() == weekView ) {
831 QDate d = weekView->date(); 831 QDate d = weekView->date();
832 start = end = d; 832 start = end = d;
833 start.setTime( QTime( 10, 0 ) ); 833 start.setTime( QTime( 10, 0 ) );
834 end.setTime( QTime( 12, 0 ) ); 834 end.setTime( QTime( 12, 0 ) );
835 } else if ( views->visibleWidget() == weekLstView ) { 835 } else if ( views->visibleWidget() == weekLstView ) {
836 QDate d = weekLstView->date(); 836 QDate d = weekLstView->date();
837 start = end = d; 837 start = end = d;
838 start.setTime( QTime( 10, 0 ) ); 838 start.setTime( QTime( 10, 0 ) );
839 end.setTime( QTime( 12, 0 ) ); 839 end.setTime( QTime( 12, 0 ) );
840 } 840 }
841 slotNewEntry(start, end, str); 841 slotNewEntry(start, end, str);
842} 842}
843void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 843void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
844 // argh! This really needs to be encapsulated in a class 844 // argh! This really needs to be encapsulated in a class
845 // or function. 845 // or function.
846 QDialog newDlg( this, 0, TRUE ); 846 QDialog newDlg( this, 0, TRUE );
847 newDlg.setCaption( DateEntryBase::tr("New Event") ); 847 newDlg.setCaption( DateEntryBase::tr("New Event") );
848 DateEntry *e; 848 DateEntry *e;
849 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 849 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
850 QScrollView *sv = new QScrollView( &newDlg ); 850 QScrollView *sv = new QScrollView( &newDlg );
851 sv->setResizePolicy( QScrollView::AutoOneFit ); 851 sv->setResizePolicy( QScrollView::AutoOneFit );
852 sv->setFrameStyle( QFrame::NoFrame ); 852 sv->setFrameStyle( QFrame::NoFrame );
853 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 853 sv->setHScrollBarMode( QScrollView::AlwaysOff );
854 vb->addWidget( sv ); 854 vb->addWidget( sv );
855 855
856 Event ev; 856 Event ev;
857 ev.setDescription( str ); 857 ev.setDescription( str );
858 // When the new gui comes in, change this... 858 // When the new gui comes in, change this...
859 if(location==0) { 859 if(location==0) {
860 if(defaultLocation.isEmpty()) { 860 if(defaultLocation.isEmpty()) {
861 ev.setLocation(tr("(Unknown)")); 861 ev.setLocation(tr("(Unknown)"));
862 } else { 862 } else {
863 ev.setLocation( defaultLocation ); 863 ev.setLocation( defaultLocation );
864 } 864 }
865 } else { 865 } else {
866 ev.setLocation(location); 866 ev.setLocation(location);
867 } 867 }
868 ev.setCategories(defaultCategories); 868 ev.setCategories(defaultCategories);
869 ev.setStart( start ); 869 ev.setStart( start );
870 ev.setEnd( end ); 870 ev.setEnd( end );
871 871
872 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 872 e = new DateEntry( onMonday, ev, ampm, &newDlg );
873 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 873 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
874 sv->addChild( e ); 874 sv->addChild( e );
875 while ( QPEApplication::execDialog( &newDlg ) ) { 875 while ( QPEApplication::execDialog( &newDlg ) ) {
876 ev = e->event(); 876 ev = e->event();
877 ev.assignUid(); 877 ev.assignUid();
878 QString error = checkEvent( ev ); 878 QString error = checkEvent( ev );
879 if ( !error.isNull() ) { 879 if ( !error.isNull() ) {
880 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 880 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
881 continue; 881 continue;
882 } 882 }
883 db->addEvent( ev ); 883 db->addEvent( ev );
884 emit newEvent(); 884 emit newEvent();
885 break; 885 break;
886 } 886 }
887} 887}
888 888
889void DateBook::setDocument( const QString &filename ) 889void DateBook::setDocument( const QString &filename )
890{ 890{
891 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 891 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
892 892
893 QValueList<Event> tl = Event::readVCalendar( filename ); 893 QValueList<Event> tl = Event::readVCalendar( filename );
894 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 894 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
895 db->addEvent( *it ); 895 db->addEvent( *it );
896 } 896 }
897} 897}
898 898
899static const char * beamfile = "/tmp/obex/event.vcs"; 899static const char * beamfile = "/tmp/obex/event.vcs";
900 900
901void DateBook::beamEvent( const Event &e ) 901void DateBook::beamEvent( const Event &e )
902{ 902{
903 qDebug("trying to beamn"); 903 qDebug("trying to beamn");
904 unlink( beamfile ); // delete if exists 904 unlink( beamfile ); // delete if exists
905 mkdir("/tmp/obex/", 0755); 905 mkdir("/tmp/obex/", 0755);
906 Event::writeVCalendar( beamfile, e ); 906 Event::writeVCalendar( beamfile, e );
907 Ir *ir = new Ir( this ); 907 Ir *ir = new Ir( this );
908 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 908 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
909 QString description = e.description(); 909 QString description = e.description();
910 ir->send( beamfile, description, "text/x-vCalendar" ); 910 ir->send( beamfile, description, "text/x-vCalendar" );
911} 911}
912 912
913void DateBook::beamDone( Ir *ir ) 913void DateBook::beamDone( Ir *ir )
914{ 914{
915 delete ir; 915 delete ir;
916 unlink( beamfile ); 916 unlink( beamfile );
917} 917}
918 918
919void DateBook::slotFind() 919void DateBook::slotFind()
920{ 920{
921 // move it to the day view... 921 // move it to the day view...
922 viewDay(); 922 viewDay();
923 FindDialog frmFind( "Calendar", this ); // no tr needed 923 FindDialog frmFind( "Calendar", this ); // no tr needed
924 frmFind.setUseDate( true ); 924 frmFind.setUseDate( true );
925 frmFind.setDate( currentDate() ); 925 frmFind.setDate( currentDate() );
926 QObject::connect( &frmFind, 926 QObject::connect( &frmFind,
927 SIGNAL(signalFindClicked(const QString&, const QDate&, 927 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
928 bool, bool, int)),
929 this, 928 this,
930 SLOT(slotDoFind(const QString&, const QDate&, 929 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
931 bool, bool, int)) );
932 QObject::connect( this, 930 QObject::connect( this,
933 SIGNAL(signalNotFound()), 931 SIGNAL(signalNotFound()),
934 &frmFind, 932 &frmFind,
935 SLOT(slotNotFound()) ); 933 SLOT(slotNotFound()) );
936 QObject::connect( this, 934 QObject::connect( this,
937 SIGNAL(signalWrapAround()), 935 SIGNAL(signalWrapAround()),
938 &frmFind, 936 &frmFind,
939 SLOT(slotWrapAround()) ); 937 SLOT(slotWrapAround()) );
940 frmFind.move(0,0); 938 frmFind.move(0,0);
941 frmFind.exec(); 939 frmFind.exec();
942 inSearch = false; 940 inSearch = false;
943} 941}
944 942
945bool catComp( QArray<int> cats, int category ) 943bool catComp( QArray<int> cats, int category )
946{ 944{
947 bool returnMe; 945 bool returnMe;
948 int i, 946 int i,
949 count; 947 count;
950 948
951 count = int(cats.count()); 949 count = int(cats.count());
952 returnMe = false; 950 returnMe = false;
953 if ( (category == -1 && count == 0) || category == -2 ) 951 if ( (category == -1 && count == 0) || category == -2 )
954 returnMe = true; 952 returnMe = true;
955 else { 953 else {
956 for ( i = 0; i < count; i++ ) { 954 for ( i = 0; i < count; i++ ) {
957 if ( category == cats[i] ) { 955 if ( category == cats[i] ) {
958 returnMe = true; 956 returnMe = true;
959 break; 957 break;
960 } 958 }
961 } 959 }
962 } 960 }
963 return returnMe; 961 return returnMe;
964} 962}
965 963
966 964
967void DateBook::slotDoFind( const QString& txt, const QDate &dt, 965void DateBook::slotDoFind( const QString& txt, const QDate &dt,
968 bool caseSensitive, bool /*backwards*/, 966 bool caseSensitive, bool /*backwards*/,
969 int category ) 967 int category )
970{ 968{
971 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 969 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
972 next; 970 next;
973 971
974 QRegExp r( txt ); 972 QRegExp r( txt );
975 r.setCaseSensitive( caseSensitive ); 973 r.setCaseSensitive( caseSensitive );
976 974
977 975
978 static Event rev, nonrev; 976 static Event rev, nonrev;
979 if ( !inSearch ) { 977 if ( !inSearch ) {
980 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 978 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
981 nonrev.setStart( rev.start() ); 979 nonrev.setStart( rev.start() );
982 inSearch = true; 980 inSearch = true;
983 } 981 }
984 static QDate searchDate = dt; 982 static QDate searchDate = dt;
985 // if true at the end we will start at the begin again and afterwards 983 // if true at the end we will start at the begin again and afterwards
986 // we will emit string not found 984 // we will emit string not found
987 static bool wrapAround = true; 985 static bool wrapAround = true;
988 bool candidtate; 986 bool candidtate;
989 candidtate = false; 987 candidtate = false;
990 988
991 QValueList<Event> repeats = db->getRawRepeats(); 989 QValueList<Event> repeats = db->getRawRepeats();
992 990
993 // find the candidate for the first repeat that matches... 991 // find the candidate for the first repeat that matches...
994 // first check if there can ever be a match and then compute 992 // first check if there can ever be a match and then compute
995 // the next occurence from start. See if this event is closer 993 // the next occurence from start. See if this event is closer
996 // to the beginning (start. next < dtEnd) and not smaller then the last 994 // to the beginning (start. next < dtEnd) and not smaller then the last
997 // result. If we find a canditate we set the dtEnd to the time 995 // result. If we find a canditate we set the dtEnd to the time
998 // of the ocurrence and rev to this occurence. 996 // of the ocurrence and rev to this occurence.
999 // set wrap around to true because there might be more events coming 997 // set wrap around to true because there might be more events coming
1000 // and we're not at the end. 998 // and we're not at the end.
1001 QValueListConstIterator<Event> it; 999 QValueListConstIterator<Event> it;
1002 QDate start = dt; 1000 QDate start = dt;
1003 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1001 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1004 if ( catComp( (*it).categories(), category ) ) { 1002 if ( catComp( (*it).categories(), category ) ) {
1005 if ( (*it).match( r ) ) { 1003 if ( (*it).match( r ) ) {
1006 if ( nextOccurance( *it, start, next ) ) { 1004 if ( nextOccurance( *it, start, next ) ) {
1007 if ( next < dtEnd && !(next <= rev.start() ) ) { 1005 if ( next < dtEnd && !(next <= rev.start() ) ) {
1008 rev = *it; 1006 rev = *it;
1009 dtEnd = next; 1007 dtEnd = next;
1010 rev.setStart( next ); 1008 rev.setStart( next );
1011 candidtate = true; 1009 candidtate = true;
1012 wrapAround = true; 1010 wrapAround = true;
1013 } 1011 }
1014 } 1012 }
1015 } 1013 }
1016 } 1014 }
1017 } 1015 }
1018 1016
1019 // now the for first non repeat... 1017 // now the for first non repeat...
1020 // dtEnd is set by the previous iteration of repeatingEvents 1018 // dtEnd is set by the previous iteration of repeatingEvents
1021 // check if we find a closer item. Also set dtEnd to find even 1019 // check if we find a closer item. Also set dtEnd to find even
1022 // more close occurrence 1020 // more close occurrence
1023 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1021 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1024 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1022 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1025 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1023 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1026 if ( catComp( (*it).categories(), category ) ) { 1024 if ( catComp( (*it).categories(), category ) ) {
1027 if ( (*it).start() < dtEnd ) { 1025 if ( (*it).start() < dtEnd ) {
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 751a1da..ca63dc5 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -115,361 +115,361 @@ void DateBookDayView::moveUp()
115 scrollBy(0, -20); 115 scrollBy(0, -20);
116} 116}
117 117
118void DateBookDayView::moveDown() 118void DateBookDayView::moveDown()
119{ 119{
120 scrollBy(0, 20); 120 scrollBy(0, 20);
121} 121}
122 122
123void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 123void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
124{ 124{
125 int w = cr.width(); 125 int w = cr.width();
126 int h = cr.height(); 126 int h = cr.height();
127 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 127 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
128 if ( showGrid() ) { 128 if ( showGrid() ) {
129 // Draw our lines 129 // Draw our lines
130 int x2 = w - 1; 130 int x2 = w - 1;
131 int y2 = h - 1; 131 int y2 = h - 1;
132 QPen pen( p->pen() ); 132 QPen pen( p->pen() );
133 p->setPen( colorGroup().dark() ); 133 p->setPen( colorGroup().dark() );
134 p->drawLine( x2, 0, x2, y2 ); 134 p->drawLine( x2, 0, x2, y2 );
135 p->drawLine( 0, y2, x2, y2 ); 135 p->drawLine( 0, y2, x2, y2 );
136 136
137 p->setPen( colorGroup().midlight() ); 137 p->setPen( colorGroup().midlight() );
138 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 138 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
139 139
140 p->setPen( pen ); 140 p->setPen( pen );
141 } 141 }
142} 142}
143 143
144void DateBookDayView::paintFocus( QPainter *, const QRect & ) 144void DateBookDayView::paintFocus( QPainter *, const QRect & )
145{ 145{
146} 146}
147 147
148void DateBookDayView::resizeEvent( QResizeEvent *e ) 148void DateBookDayView::resizeEvent( QResizeEvent *e )
149{ 149{
150 QTable::resizeEvent( e ); 150 QTable::resizeEvent( e );
151 columnWidthChanged( 0 ); 151 columnWidthChanged( 0 );
152 emit sigColWidthChanged(); 152 emit sigColWidthChanged();
153} 153}
154 154
155void DateBookDayView::keyPressEvent( QKeyEvent *e ) 155void DateBookDayView::keyPressEvent( QKeyEvent *e )
156{ 156{
157 QString txt = e->text(); 157 QString txt = e->text();
158 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 158 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
159 // we this is some sort of thing we know about... 159 // we this is some sort of thing we know about...
160 e->accept(); 160 e->accept();
161 emit sigCapturedKey( txt ); 161 emit sigCapturedKey( txt );
162 } else { 162 } else {
163 // I don't know what this key is, do you? 163 // I don't know what this key is, do you?
164 e->ignore(); 164 e->ignore();
165 } 165 }
166} 166}
167 167
168void DateBookDayView::setRowStyle( int style ) 168void DateBookDayView::setRowStyle( int style )
169{ 169{
170 if (style<0) style = 0; 170 if (style<0) style = 0;
171 171
172 for (int i=0; i<numRows(); i++) 172 for (int i=0; i<numRows(); i++)
173 setRowHeight(i, style*10+20); 173 setRowHeight(i, style*10+20);
174} 174}
175 175
176void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) 176void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ )
177{ 177{
178 int sh=99,eh=-1; 178 int sh=99,eh=-1;
179 179
180 for(int i=0;i<this->numSelections();i++) { 180 for(int i=0;i<this->numSelections();i++) {
181 QTableSelection sel = this->selection( i ); 181 QTableSelection sel = this->selection( i );
182 sh = QMIN(sh,sel.topRow()); 182 sh = QMIN(sh,sel.topRow());
183 eh = QMAX(sh,sel.bottomRow()+1); 183 eh = QMAX(sh,sel.bottomRow()+1);
184 } 184 }
185 if (sh > 23 || eh < 1) { 185 if (sh > 23 || eh < 1) {
186 sh=8; 186 sh=8;
187 eh=9; 187 eh=9;
188 } 188 }
189 189
190 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); 190 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)); 191 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
192 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); 192 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0));
193 quickLineEdit->setFocus(); 193 quickLineEdit->setFocus();
194 quickLineEdit->show(); 194 quickLineEdit->show();
195} 195}
196 196
197//=========================================================================== 197//===========================================================================
198 198
199DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) 199DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name)
200{ 200{
201 active=1; 201 active=1;
202 quickEvent.setStart(start); 202 quickEvent.setStart(start);
203 quickEvent.setEnd(end); 203 quickEvent.setEnd(end);
204 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); 204 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
205} 205}
206 206
207void DateBookDayViewQuickLineEdit::slotReturnPressed() 207void DateBookDayViewQuickLineEdit::slotReturnPressed()
208{ 208{
209 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. 209 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times.
210 quickEvent.setDescription(this->text()); 210 quickEvent.setDescription(this->text());
211 connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); 211 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&)));
212 emit(insertEvent(quickEvent)); 212 emit(insertEvent(quickEvent));
213 active=0; 213 active=0;
214 } 214 }
215 /* we need to return to this object.. */ 215 /* we need to return to this object.. */
216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget 216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget
217} 217}
218void DateBookDayViewQuickLineEdit::finallyCallClose() { 218void DateBookDayViewQuickLineEdit::finallyCallClose() {
219 close(true); // also deletes this widget... 219 close(true); // also deletes this widget...
220} 220}
221 221
222void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) 222void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
223{ 223{
224 slotReturnPressed(); // Reuse code to add event and close this widget. 224 slotReturnPressed(); // Reuse code to add event and close this widget.
225} 225}
226 226
227//=========================================================================== 227//===========================================================================
228 228
229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) 229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name )
230 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) 230 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
231{ 231{
232 widgetList.setAutoDelete( true ); 232 widgetList.setAutoDelete( true );
233 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 233 header = new DateBookDayHeader( startOnMonday, this, "day header" );
234 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 234 header->setDate( currDate.year(), currDate.month(), currDate.day() );
235 235
236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); 236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
237 m_allDays->hide(); 237 m_allDays->hide();
238 238
239 view = new DateBookDayView( ampm, this, "day view" ); 239 view = new DateBookDayView( ampm, this, "day view" );
240 240
241 connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); 241 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 ) ) ); 242 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) );
243 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); 243 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
244 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 244 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
245 connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); 245 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) );
246 246
247 QTimer *timer = new QTimer( this ); 247 QTimer *timer = new QTimer( this );
248 248
249 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors 249 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors
250 timer->start( 1000*60*5, FALSE ); //update every 5min 250 timer->start( 1000*60*5, FALSE ); //update every 5min
251 251
252 selectedWidget = 0; 252 selectedWidget = 0;
253 253
254 timeMarker = new DateBookDayTimeMarker( this ); 254 timeMarker = new DateBookDayTimeMarker( this );
255 timeMarker->setTime( QTime::currentTime() ); 255 timeMarker->setTime( QTime::currentTime() );
256 rowStyle = -1; // initialize with bogus values 256 rowStyle = -1; // initialize with bogus values
257 jumpToCurTime = false; 257 jumpToCurTime = false;
258} 258}
259 259
260void DateBookDay::setJumpToCurTime( bool bJump ) 260void DateBookDay::setJumpToCurTime( bool bJump )
261{ 261{
262 jumpToCurTime = bJump; 262 jumpToCurTime = bJump;
263} 263}
264 264
265void DateBookDay::setRowStyle( int style ) 265void DateBookDay::setRowStyle( int style )
266{ 266{
267 if (rowStyle != style) view->setRowStyle( style ); 267 if (rowStyle != style) view->setRowStyle( style );
268 rowStyle = style; 268 rowStyle = style;
269} 269}
270 270
271void DateBookDay::updateView( void ) 271void DateBookDay::updateView( void )
272{ 272{
273 timeMarker->setTime( QTime::currentTime() ); 273 timeMarker->setTime( QTime::currentTime() );
274 //need to find a way to update all DateBookDayWidgets 274 //need to find a way to update all DateBookDayWidgets
275} 275}
276 276
277void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 277void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
278{ 278{
279 selectedWidget = w; 279 selectedWidget = w;
280} 280}
281 281
282DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 282DateBookDayWidget * DateBookDay::getSelectedWidget( void )
283{ 283{
284 return selectedWidget; 284 return selectedWidget;
285} 285}
286 286
287void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 287void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
288{ 288{
289 start.setDate( currDate ); 289 start.setDate( currDate );
290 end.setDate( currDate ); 290 end.setDate( currDate );
291 291
292 int sh=99,eh=-1; 292 int sh=99,eh=-1;
293 293
294 int n = dayView()->numSelections(); 294 int n = dayView()->numSelections();
295 295
296 for (int i=0; i<n; i++) { 296 for (int i=0; i<n; i++) {
297 QTableSelection sel = dayView()->selection( i ); 297 QTableSelection sel = dayView()->selection( i );
298 sh = QMIN(sh,sel.topRow()); 298 sh = QMIN(sh,sel.topRow());
299 eh = QMAX(sh,sel.bottomRow()+1); 299 eh = QMAX(sh,sel.bottomRow()+1);
300 } 300 }
301 301
302 if (sh > 23 || eh < 1) { 302 if (sh > 23 || eh < 1) {
303 sh=8; 303 sh=8;
304 eh=9; 304 eh=9;
305 } 305 }
306 306
307 start.setTime( QTime( sh, 0, 0 ) ); 307 start.setTime( QTime( sh, 0, 0 ) );
308 end.setTime( QTime( eh, 0, 0 ) ); 308 end.setTime( QTime( eh, 0, 0 ) );
309} 309}
310 310
311void DateBookDay::setDate( int y, int m, int d ) 311void DateBookDay::setDate( int y, int m, int d )
312{ 312{
313 header->setDate( y, m, d ); 313 header->setDate( y, m, d );
314 selectedWidget = 0; 314 selectedWidget = 0;
315} 315}
316 316
317void DateBookDay::setDate( QDate d) 317void DateBookDay::setDate( QDate d)
318{ 318{
319 header->setDate( d.year(), d.month(), d.day() ); 319 header->setDate( d.year(), d.month(), d.day() );
320 selectedWidget = 0; 320 selectedWidget = 0;
321} 321}
322 322
323void DateBookDay::dateChanged( int y, int m, int d ) 323void DateBookDay::dateChanged( int y, int m, int d )
324{ 324{
325 QDate date( y, m, d ); 325 QDate date( y, m, d );
326 if ( currDate == date ) 326 if ( currDate == date )
327 return; 327 return;
328 currDate.setYMD( y, m, d ); 328 currDate.setYMD( y, m, d );
329 relayoutPage(); 329 relayoutPage();
330 dayView()->clearSelection(); 330 dayView()->clearSelection();
331 QTableSelection ts; 331 QTableSelection ts;
332 332
333 if (jumpToCurTime && this->date() == QDate::currentDate()) 333 if (jumpToCurTime && this->date() == QDate::currentDate())
334 { 334 {
335 ts.init( QTime::currentTime().hour(), 0); 335 ts.init( QTime::currentTime().hour(), 0);
336 ts.expandTo( QTime::currentTime().hour(), 0); 336 ts.expandTo( QTime::currentTime().hour(), 0);
337 } else { 337 } else {
338 ts.init( startTime, 0 ); 338 ts.init( startTime, 0 );
339 ts.expandTo( startTime, 0 ); 339 ts.expandTo( startTime, 0 );
340 } 340 }
341 341
342 dayView()->addSelection( ts ); 342 dayView()->addSelection( ts );
343 selectedWidget = 0; 343 selectedWidget = 0;
344} 344}
345 345
346void DateBookDay::redraw() 346void DateBookDay::redraw()
347{ 347{
348 if ( isUpdatesEnabled() ) 348 if ( isUpdatesEnabled() )
349 relayoutPage(); 349 relayoutPage();
350} 350}
351 351
352void DateBookDay::getEvents() 352void DateBookDay::getEvents()
353{ 353{
354 widgetList.clear(); 354 widgetList.clear();
355 355
356 /* clear the AllDay List */ 356 /* clear the AllDay List */
357 m_allDays->hide(); // just in case 357 m_allDays->hide(); // just in case
358 m_allDays->removeAllEvents(); 358 m_allDays->removeAllEvents();
359 359
360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
361 QValueListIterator<EffectiveEvent> it; 361 QValueListIterator<EffectiveEvent> it;
362 QObject* object = 0; 362 QObject* object = 0;
363 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 363 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
364 EffectiveEvent ev=*it; 364 EffectiveEvent ev=*it;
365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 365 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 ) { 366 if (ev.event().type() == Event::AllDay ) {
367 object = m_allDays->addEvent( ev ); 367 object = m_allDays->addEvent( ev );
368 if (!object) 368 if (!object)
369 continue; 369 continue;
370 }else { 370 }else {
371 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 371 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
372 widgetList.append( w ); 372 widgetList.append( w );
373 object = w; 373 object = w;
374 } 374 }
375 375
376 connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); 376 connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) );
377 connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); 377 connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) );
378 connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); 378 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) );
379 connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); 379 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) );
380 380
381 } 381 }
382 } 382 }
383} 383}
384 384
385static int place( const DateBookDayWidget *item, bool *used, int maxn ) 385static int place( const DateBookDayWidget *item, bool *used, int maxn )
386{ 386{
387 int place = 0; 387 int place = 0;
388 int start = item->event().start().hour(); 388 int start = item->event().start().hour();
389 QTime e = item->event().end(); 389 QTime e = item->event().end();
390 int end = e.hour(); 390 int end = e.hour();
391 if ( e.minute() < 5 ) 391 if ( e.minute() < 5 )
392 end--; 392 end--;
393 if ( end < start ) 393 if ( end < start )
394 end = start; 394 end = start;
395 while ( place < maxn ) { 395 while ( place < maxn ) {
396 bool free = TRUE; 396 bool free = TRUE;
397 int s = start; 397 int s = start;
398 while( s <= end ) { 398 while( s <= end ) {
399 if ( used[10*s+place] ) { 399 if ( used[10*s+place] ) {
400 free = FALSE; 400 free = FALSE;
401 break; 401 break;
402 } 402 }
403 s++; 403 s++;
404 } 404 }
405 if ( free ) 405 if ( free )
406 break; 406 break;
407 place++; 407 place++;
408 } 408 }
409 if ( place == maxn ) { 409 if ( place == maxn ) {
410 return -1; 410 return -1;
411 } 411 }
412 while( start <= end ) { 412 while( start <= end ) {
413 used[10*start+place] = TRUE; 413 used[10*start+place] = TRUE;
414 start++; 414 start++;
415 } 415 }
416 return place; 416 return place;
417} 417}
418 418
419 419
420void DateBookDay::relayoutPage( bool fromResize ) 420void DateBookDay::relayoutPage( bool fromResize )
421{ 421{
422 setUpdatesEnabled( FALSE ); 422 setUpdatesEnabled( FALSE );
423 if ( !fromResize ) { 423 if ( !fromResize ) {
424 getEvents(); // no need we already have them! 424 getEvents(); // no need we already have them!
425 425
426 if (m_allDays->items() > 0 ) 426 if (m_allDays->items() > 0 )
427 m_allDays->show(); 427 m_allDays->show();
428 /* 428 /*
429 * else if ( m_allDays->items() == 0 ) already hide in getEvents 429 * else if ( m_allDays->items() == 0 ) already hide in getEvents
430 */ 430 */
431 } 431 }
432 432
433 widgetList.sort(); 433 widgetList.sort();
434 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 434 //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 435 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
436 436
437 int wCount = widgetList.count(); 437 int wCount = widgetList.count();
438 int wid = view->columnWidth(0)-1; 438 int wid = view->columnWidth(0)-1;
439 int wd; 439 int wd;
440 int n = 1; 440 int n = 1;
441 441
442 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 442 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
443 443
444 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 444 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
445 445
446 if ( wCount < 20 ) { 446 if ( wCount < 20 ) {
447 447
448 QArray<QRect> geometries(wCount); 448 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 449 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector
450 450
451 for ( int i = 0; i < wCount; i++) { 451 for ( int i = 0; i < wCount; i++) {
452 QValueList<int> intersectedWidgets; 452 QValueList<int> intersectedWidgets;
453 453
454 //find all widgets intersecting with widgetList.at(i) 454 //find all widgets intersecting with widgetList.at(i)
455 for ( int j = 0; j < wCount; j++) { 455 for ( int j = 0; j < wCount; j++) {
456 if (i != j) 456 if (i != j)
457 if (geometries[j].intersects(geometries[i])) 457 if (geometries[j].intersects(geometries[i]))
458 intersectedWidgets.append(j); 458 intersectedWidgets.append(j);
459 } 459 }
460 460
461 //for each of these intersecting widgets find out how many widgets are they intersecting with 461 //for each of these intersecting widgets find out how many widgets are they intersecting with
462 for ( uint j = 0; j < intersectedWidgets.count(); j++) 462 for ( uint j = 0; j < intersectedWidgets.count(); j++)
463 { 463 {
464 QArray<int> inter(wCount); 464 QArray<int> inter(wCount);
465 inter[j]=1; 465 inter[j]=1;
466 466
467 if (intersectedWidgets[j] != -1) 467 if (intersectedWidgets[j] != -1)
468 for ( uint k = j; k < intersectedWidgets.count(); k++) { 468 for ( uint k = j; k < intersectedWidgets.count(); k++) {
469 if (j != k && intersectedWidgets[k] != -1) 469 if (j != k && intersectedWidgets[k] != -1)
470 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { 470 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) {
471 inter[j]++; 471 inter[j]++;
472 intersectedWidgets[k] = -1; 472 intersectedWidgets[k] = -1;
473 } 473 }
474 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 474 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
475 } 475 }
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index d43d31a..a0aefd3 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -1,159 +1,159 @@
1/**************************************************************************** 1/****************************************************************************
2** GPL by Rajko Albrecht 2** GPL by Rajko Albrecht
3** 3**
4** 4**
5** 5**
6** 6**
7** 7**
8****************************************************************************/ 8****************************************************************************/
9#include "datebookdayallday.h" 9#include "datebookdayallday.h"
10 10
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qpe/ir.h> 12#include <qpe/ir.h>
13#include <qpopupmenu.h> 13#include <qpopupmenu.h>
14#include <qtimer.h> 14#include <qtimer.h>
15 15
16#include "datebookday.h" 16#include "datebookday.h"
17 17
18/* 18/*
19 * Constructs a DatebookdayAllday which is a child of 'parent', with the 19 * Constructs a DatebookdayAllday which is a child of 'parent', with the
20 * name 'name' and widget flags set to 'f' 20 * name 'name' and widget flags set to 'f'
21 */ 21 */
22DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) 22DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags )
23 : QScrollView( parent, name ),item_count(0),dateBook(db) 23 : QScrollView( parent, name ),item_count(0),dateBook(db)
24{ 24{
25 if ( !name ) 25 if ( !name )
26 setName( "DatebookdayAllday" ); 26 setName( "DatebookdayAllday" );
27 setMinimumSize( QSize( 0, 0 ) ); 27 setMinimumSize( QSize( 0, 0 ) );
28 setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); 28 setMaximumHeight(3* (QFontMetrics(font()).height()+4) );
29 29
30 m_MainFrame = new QFrame(viewport()); 30 m_MainFrame = new QFrame(viewport());
31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); 31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
32 setFrameStyle(QFrame::NoFrame|QFrame::Plain); 32 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
33 setResizePolicy( QScrollView::Default ); 33 setResizePolicy( QScrollView::Default );
34 setHScrollBarMode( AlwaysOff ); 34 setHScrollBarMode( AlwaysOff );
35 addChild(m_MainFrame); 35 addChild(m_MainFrame);
36 36
37 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); 37 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
38 datebookdayalldayLayout->setSpacing( 0 ); 38 datebookdayalldayLayout->setSpacing( 0 );
39 datebookdayalldayLayout->setMargin( 0 ); 39 datebookdayalldayLayout->setMargin( 0 );
40 40
41 lblDesc = new DatebookEventDesc(parent->parentWidget(),""); 41 lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
42 lblDesc->setBackgroundColor(Qt::yellow); 42 lblDesc->setBackgroundColor(Qt::yellow);
43 lblDesc->hide(); 43 lblDesc->hide();
44 subWidgets.setAutoDelete(true); 44 subWidgets.setAutoDelete(true);
45} 45}
46 46
47/* 47/*
48 * Destroys the object and frees any allocated resources 48 * Destroys the object and frees any allocated resources
49 */ 49 */
50DatebookdayAllday::~DatebookdayAllday() 50DatebookdayAllday::~DatebookdayAllday()
51{ 51{
52 // no need to delete child widgets, Qt does it all for us 52 // no need to delete child widgets, Qt does it all for us
53} 53}
54 54
55DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) 55DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
56{ 56{
57 DatebookAlldayDisp * lb; 57 DatebookAlldayDisp * lb;
58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); 58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
59 lb->show(); 59 lb->show();
60 datebookdayalldayLayout->addWidget(lb); 60 datebookdayalldayLayout->addWidget(lb);
61 subWidgets.append(lb); 61 subWidgets.append(lb);
62 62
63 connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&))); 63 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
64 ++item_count; 64 ++item_count;
65 65
66 return lb; 66 return lb;
67} 67}
68 68
69void DatebookdayAllday::removeAllEvents() 69void DatebookdayAllday::removeAllEvents()
70{ 70{
71 subWidgets.clear(); 71 subWidgets.clear();
72 item_count = 0; 72 item_count = 0;
73} 73}
74 74
75DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 75DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
76 QWidget* parent,const char* name,WFlags f) 76 QWidget* parent,const char* name,WFlags f)
77 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 77 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
78{ 78{
79 QString strDesc = m_Ev.description(); 79 QString strDesc = m_Ev.description();
80 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 80 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
81 setBackgroundColor(yellow); 81 setBackgroundColor(yellow);
82 setText(strDesc); 82 setText(strDesc);
83 setFrameStyle(QFrame::Raised|QFrame::Panel); 83 setFrameStyle(QFrame::Raised|QFrame::Panel);
84 84
85 int s = QFontMetrics(font()).height()+4; 85 int s = QFontMetrics(font()).height()+4;
86 setMaximumHeight( s ); 86 setMaximumHeight( s );
87 setMinimumSize( QSize( 0, s ) ); 87 setMinimumSize( QSize( 0, s ) );
88} 88}
89 89
90DatebookAlldayDisp::~DatebookAlldayDisp() 90DatebookAlldayDisp::~DatebookAlldayDisp()
91{ 91{
92} 92}
93 93
94void DatebookAlldayDisp::beam_single_event() 94void DatebookAlldayDisp::beam_single_event()
95{ 95{
96 // create an Event and beam it... 96 // create an Event and beam it...
97 /* 97 /*
98 * Start with the easy stuff. If start and end date is the same we can just use 98 * Start with the easy stuff. If start and end date is the same we can just use
99 * the values of effective m_Events 99 * the values of effective m_Events
100 * If it is a multi day m_Event we need to find the real start and end date... 100 * If it is a multi day m_Event we need to find the real start and end date...
101 */ 101 */
102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
103 Event m_Event( m_Ev.event() ); 103 Event m_Event( m_Ev.event() );
104 104
105 QDateTime dt( m_Ev.date(), m_Ev.start() ); 105 QDateTime dt( m_Ev.date(), m_Ev.start() );
106 m_Event.setStart( dt ); 106 m_Event.setStart( dt );
107 107
108 dt.setTime( m_Ev.end() ); 108 dt.setTime( m_Ev.end() );
109 m_Event.setEnd( dt ); 109 m_Event.setEnd( dt );
110 emit beamMe( m_Event ); 110 emit beamMe( m_Event );
111 }else { 111 }else {
112 /* 112 /*
113 * at least the the Times are right now 113 * at least the the Times are right now
114 */ 114 */
115 QDateTime start( m_Ev.event().start() ); 115 QDateTime start( m_Ev.event().start() );
116 QDateTime end ( m_Ev.event().end () ); 116 QDateTime end ( m_Ev.event().end () );
117 117
118 /* 118 /*
119 * ok we know the start date or we need to find it 119 * ok we know the start date or we need to find it
120 */ 120 */
121 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 121 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
122 start.setDate( m_Ev.date() ); 122 start.setDate( m_Ev.date() );
123 }else { 123 }else {
124 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); 124 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
125 start.setDate( dt ); 125 start.setDate( dt );
126 } 126 }
127 127
128 /* 128 /*
129 * ok we know now the end date... 129 * ok we know now the end date...
130 * else 130 * else
131 * get to know the offset btw the real start and real end 131 * get to know the offset btw the real start and real end
132 * and then add it to the new start date... 132 * and then add it to the new start date...
133 */ 133 */
134 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 134 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
135 end.setDate( m_Ev.date() ); 135 end.setDate( m_Ev.date() );
136 }else{ 136 }else{
137 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); 137 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
138 end.setDate( start.date().addDays( days ) ); 138 end.setDate( start.date().addDays( days ) );
139 } 139 }
140 Event m_Event( m_Ev.event() ); 140 Event m_Event( m_Ev.event() );
141 m_Event.setStart( start ); 141 m_Event.setStart( start );
142 m_Event.setEnd ( end ); 142 m_Event.setEnd ( end );
143 emit beamMe( m_Event ); 143 emit beamMe( m_Event );
144 } 144 }
145} 145}
146 146
147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
148{ 148{
149 Event ev = m_Ev.event(); 149 Event ev = m_Ev.event();
150 QColor b = backgroundColor(); 150 QColor b = backgroundColor();
151 setBackgroundColor(green); 151 setBackgroundColor(green);
152 update(); 152 update();
153 QPopupMenu m; 153 QPopupMenu m;
154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
158 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 158 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
159 m.insertItem( tr( "Info"),6); 159 m.insertItem( tr( "Info"),6);
diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp
index 213c843..51b78ca 100644
--- a/core/pim/datebook/datebookdayheaderimpl.cpp
+++ b/core/pim/datebook/datebookdayheaderimpl.cpp
@@ -3,194 +3,194 @@
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "datebookdayheaderimpl.h" 20#include "datebookdayheaderimpl.h"
21 21
22#include <qpe/datebookmonth.h> 22#include <qpe/datebookmonth.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qbuttongroup.h> 25#include <qbuttongroup.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27 27
28 28
29/* 29/*
30 * Constructs a DateBookDayHeader which is a child of 'parent', with the 30 * Constructs a DateBookDayHeader which is a child of 'parent', with the
31 * name 'name' and widget flags set to 'f' 31 * name 'name' and widget flags set to 'f'
32 * 32 *
33 * The dialog will by default be modeless, unless you set 'modal' to 33 * The dialog will by default be modeless, unless you set 'modal' to
34 * TRUE to construct a modal dialog. 34 * TRUE to construct a modal dialog.
35 */ 35 */
36DateBookDayHeader::DateBookDayHeader( bool useMonday, 36DateBookDayHeader::DateBookDayHeader( bool useMonday,
37 QWidget* parent, const char* name ) 37 QWidget* parent, const char* name )
38 : DateBookDayHeaderBase( parent, name ), 38 : DateBookDayHeaderBase( parent, name ),
39 bUseMonday( useMonday ) 39 bUseMonday( useMonday )
40{ 40{
41 connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); 41 connect(date,SIGNAL(pressed()),this,SLOT(pickDate()));
42 42
43 setupNames(); 43 setupNames();
44 44
45 forward->setPixmap( Resource::loadPixmap( "forward" ) ); 45 forward->setPixmap( Resource::loadPixmap( "forward" ) );
46 back->setPixmap( Resource::loadPixmap( "back" ) ); 46 back->setPixmap( Resource::loadPixmap( "back" ) );
47 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); 47 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) );
48 backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); 48 backweek->setPixmap( Resource::loadPixmap( "fastback" ) );
49 49
50 setBackgroundMode( PaletteButton ); 50 setBackgroundMode( PaletteButton );
51 grpDays->setBackgroundMode( PaletteButton ); 51 grpDays->setBackgroundMode( PaletteButton );
52} 52}
53 53
54/* 54/*
55 * Destroys the object and frees any allocated resources 55 * Destroys the object and frees any allocated resources
56 */ 56 */
57DateBookDayHeader::~DateBookDayHeader() 57DateBookDayHeader::~DateBookDayHeader()
58{ 58{
59 // no need to delete child widgets, Qt does it all for us 59 // no need to delete child widgets, Qt does it all for us
60} 60}
61 61
62void DateBookDayHeader::setStartOfWeek( bool onMonday ) 62void DateBookDayHeader::setStartOfWeek( bool onMonday )
63{ 63{
64 bUseMonday = onMonday; 64 bUseMonday = onMonday;
65 setupNames(); 65 setupNames();
66 setDate( currDate.year(), currDate.month(), currDate.day() ); 66 setDate( currDate.year(), currDate.month(), currDate.day() );
67} 67}
68 68
69void DateBookDayHeader::setupNames() 69void DateBookDayHeader::setupNames()
70{ 70{
71 if ( bUseMonday ) { 71 if ( bUseMonday ) {
72 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 72 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
73 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 73 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
74 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 74 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
75 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 75 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
76 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 76 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
77 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 77 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
78 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 78 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
79 } else { 79 } else {
80 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 80 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
81 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 81 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
82 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 82 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
83 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 83 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
84 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 84 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
85 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 85 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
86 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 86 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
87 } 87 }
88} 88}
89 89
90 90
91void DateBookDayHeader::pickDate() 91void DateBookDayHeader::pickDate()
92{ 92{
93 static QPopupMenu *m1 = 0; 93 static QPopupMenu *m1 = 0;
94 static DateBookMonth *picker = 0; 94 static DateBookMonth *picker = 0;
95 if ( !m1 ) { 95 if ( !m1 ) {
96 m1 = new QPopupMenu( this ); 96 m1 = new QPopupMenu( this );
97 picker = new DateBookMonth( m1, 0, TRUE ); 97 picker = new DateBookMonth( m1, 0, TRUE );
98 m1->insertItem( picker ); 98 m1->insertItem( picker );
99 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 99 connect( picker, SIGNAL( dateClicked(int,int,int) ),
100 this, SLOT( setDate( int, int, int ) ) ); 100 this, SLOT( setDate(int,int,int) ) );
101 connect( m1, SIGNAL( aboutToHide() ), 101 connect( m1, SIGNAL( aboutToHide() ),
102 this, SLOT( gotHide() ) ); 102 this, SLOT( gotHide() ) );
103 } 103 }
104 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 104 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
105 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); 105 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height())));
106 picker->setFocus(); 106 picker->setFocus();
107} 107}
108 108
109void DateBookDayHeader::gotHide() 109void DateBookDayHeader::gotHide()
110{ 110{
111 // we have to redo the button... 111 // we have to redo the button...
112 date->setDown( false ); 112 date->setDown( false );
113} 113}
114 114
115/* 115/*
116 * public slot 116 * public slot
117 */ 117 */
118void DateBookDayHeader::goBack() 118void DateBookDayHeader::goBack()
119{ 119{
120 currDate = currDate.addDays( -1 ); 120 currDate = currDate.addDays( -1 );
121 setDate( currDate.year(), currDate.month(), currDate.day() ); 121 setDate( currDate.year(), currDate.month(), currDate.day() );
122} 122}
123/* 123/*
124 * public slot 124 * public slot
125 */ 125 */
126void DateBookDayHeader::goForward() 126void DateBookDayHeader::goForward()
127{ 127{
128 currDate = currDate.addDays( 1 ); 128 currDate = currDate.addDays( 1 );
129 setDate( currDate.year(), currDate.month(), currDate.day() ); 129 setDate( currDate.year(), currDate.month(), currDate.day() );
130} 130}
131/* 131/*
132 * public slot 132 * public slot
133 */ 133 */
134void DateBookDayHeader::goBackWeek() 134void DateBookDayHeader::goBackWeek()
135{ 135{
136 currDate = currDate.addDays( -7 ); 136 currDate = currDate.addDays( -7 );
137 setDate( currDate.year(), currDate.month(), currDate.day() ); 137 setDate( currDate.year(), currDate.month(), currDate.day() );
138} 138}
139/* 139/*
140 * public slot 140 * public slot
141 */ 141 */
142void DateBookDayHeader::goForwardWeek() 142void DateBookDayHeader::goForwardWeek()
143{ 143{
144 currDate = currDate.addDays( 7 ); 144 currDate = currDate.addDays( 7 );
145 setDate( currDate.year(), currDate.month(), currDate.day() ); 145 setDate( currDate.year(), currDate.month(), currDate.day() );
146} 146}
147 147
148 148
149/* 149/*
150 * public slot 150 * public slot
151 */ 151 */
152void DateBookDayHeader::setDate( int y, int m, int d ) 152void DateBookDayHeader::setDate( int y, int m, int d )
153{ 153{
154 currDate.setYMD( y, m, d ); 154 currDate.setYMD( y, m, d );
155 date->setText( TimeString::shortDate( currDate ) ); 155 date->setText( TimeString::shortDate( currDate ) );
156 156
157 int iDayOfWeek = currDate.dayOfWeek(); 157 int iDayOfWeek = currDate.dayOfWeek();
158 // cleverly adjust the day depending on how we start the week 158 // cleverly adjust the day depending on how we start the week
159 if ( bUseMonday ) 159 if ( bUseMonday )
160 iDayOfWeek--; 160 iDayOfWeek--;
161 else { 161 else {
162 if ( iDayOfWeek == 7 ) // Sunday 162 if ( iDayOfWeek == 7 ) // Sunday
163 iDayOfWeek = 0; 163 iDayOfWeek = 0;
164 } 164 }
165 grpDays->setButton( iDayOfWeek ); 165 grpDays->setButton( iDayOfWeek );
166 emit dateChanged( y, m, d ); 166 emit dateChanged( y, m, d );
167} 167}
168 168
169/* 169/*
170 * public slot 170 * public slot
171 */ 171 */
172void DateBookDayHeader::setDay( int day ) 172void DateBookDayHeader::setDay( int day )
173{ 173{
174 int realDay; 174 int realDay;
175 int dayOfWeek = currDate.dayOfWeek(); 175 int dayOfWeek = currDate.dayOfWeek();
176 176
177 // a little adjustment is needed... 177 // a little adjustment is needed...
178 if ( bUseMonday ) 178 if ( bUseMonday )
179 realDay = day + 1 ; 179 realDay = day + 1 ;
180 else if ( !bUseMonday && day == 0 ) // sunday 180 else if ( !bUseMonday && day == 0 ) // sunday
181 realDay = 7; 181 realDay = 7;
182 else 182 else
183 realDay = day; 183 realDay = day;
184 // special cases first... 184 // special cases first...
185 if ( realDay == 7 && !bUseMonday ) { 185 if ( realDay == 7 && !bUseMonday ) {
186 while ( currDate.dayOfWeek() != realDay ) 186 while ( currDate.dayOfWeek() != realDay )
187 currDate = currDate.addDays( -1 ); 187 currDate = currDate.addDays( -1 );
188 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { 188 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) {
189 while ( currDate.dayOfWeek() != realDay ) 189 while ( currDate.dayOfWeek() != realDay )
190 currDate = currDate.addDays( 1 ); 190 currDate = currDate.addDays( 1 );
191 } else if ( dayOfWeek < realDay ) { 191 } else if ( dayOfWeek < realDay ) {
192 while ( currDate.dayOfWeek() < realDay ) 192 while ( currDate.dayOfWeek() < realDay )
193 currDate = currDate.addDays( 1 ); 193 currDate = currDate.addDays( 1 );
194 } else if ( dayOfWeek > realDay ) { 194 } else if ( dayOfWeek > realDay ) {
195 while ( currDate.dayOfWeek() > realDay ) 195 while ( currDate.dayOfWeek() > realDay )
196 currDate = currDate.addDays( -1 ); 196 currDate = currDate.addDays( -1 );
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index a6d04ba..cb4b73b 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,130 +1,130 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebooksettings.h" 21#include "datebooksettings.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27 27
28DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 28DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
29 const char *name, bool modal, WFlags fl ) 29 const char *name, bool modal, WFlags fl )
30 : DateBookSettingsBase( parent, name, modal, fl ), 30 : DateBookSettingsBase( parent, name, modal, fl ),
31 ampm( whichClock ) 31 ampm( whichClock )
32{ 32{
33 init(); 33 init();
34 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) ); 34 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) );
35 QArray<int> categories; 35 QArray<int> categories;
36 comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); 36 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
37} 37}
38 38
39DateBookSettings::~DateBookSettings() 39DateBookSettings::~DateBookSettings()
40{ 40{
41} 41}
42 42
43void DateBookSettings::setStartTime( int newStartViewTime ) 43void DateBookSettings::setStartTime( int newStartViewTime )
44{ 44{
45 if ( ampm ) { 45 if ( ampm ) {
46 if ( newStartViewTime >= 12 ) { 46 if ( newStartViewTime >= 12 ) {
47 newStartViewTime %= 12; 47 newStartViewTime %= 12;
48 if ( newStartViewTime == 0 ) 48 if ( newStartViewTime == 0 )
49 newStartViewTime = 12; 49 newStartViewTime = 12;
50 spinStart->setSuffix( tr(":00 PM") ); 50 spinStart->setSuffix( tr(":00 PM") );
51 } 51 }
52 else if ( newStartViewTime == 0 ) { 52 else if ( newStartViewTime == 0 ) {
53 newStartViewTime = 12; 53 newStartViewTime = 12;
54 spinStart->setSuffix( tr(":00 AM") ); 54 spinStart->setSuffix( tr(":00 AM") );
55 } 55 }
56 oldtime = newStartViewTime; 56 oldtime = newStartViewTime;
57 } 57 }
58 spinStart->setValue( newStartViewTime ); 58 spinStart->setValue( newStartViewTime );
59} 59}
60 60
61int DateBookSettings::startTime() const 61int DateBookSettings::startTime() const
62{ 62{
63 int returnMe = spinStart->value(); 63 int returnMe = spinStart->value();
64 if ( ampm ) { 64 if ( ampm ) {
65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
66 returnMe += 12; 66 returnMe += 12;
67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
68 returnMe = 0; 68 returnMe = 0;
69 } 69 }
70 return returnMe; 70 return returnMe;
71} 71}
72 72
73 73
74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
75{ 75{
76 chkAlarmPreset->setChecked( bAlarm ); 76 chkAlarmPreset->setChecked( bAlarm );
77 if ( presetTime >=5 ) 77 if ( presetTime >=5 )
78 spinPreset->setValue( presetTime ); 78 spinPreset->setValue( presetTime );
79} 79}
80 80
81bool DateBookSettings::alarmPreset() const 81bool DateBookSettings::alarmPreset() const
82{ 82{
83 return chkAlarmPreset->isChecked(); 83 return chkAlarmPreset->isChecked();
84} 84}
85 85
86int DateBookSettings::presetTime() const 86int DateBookSettings::presetTime() const
87{ 87{
88 return spinPreset->value(); 88 return spinPreset->value();
89} 89}
90 90
91 91
92void DateBookSettings::slot12Hour( int i ) 92void DateBookSettings::slot12Hour( int i )
93{ 93{
94 if ( ampm ) { 94 if ( ampm ) {
95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
97 spinStart->setSuffix( tr(":00 PM") ); 97 spinStart->setSuffix( tr(":00 PM") );
98 } else { 98 } else {
99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
100 spinStart->setSuffix( tr(":00 AM") ); 100 spinStart->setSuffix( tr(":00 AM") );
101 } 101 }
102 oldtime = i; 102 oldtime = i;
103 } 103 }
104} 104}
105 105
106void DateBookSettings::init() 106void DateBookSettings::init()
107{ 107{
108 if ( ampm ) { 108 if ( ampm ) {
109 spinStart->setMinValue( 1 ); 109 spinStart->setMinValue( 1 );
110 spinStart->setMaxValue( 12 ); 110 spinStart->setMaxValue( 12 );
111 spinStart->setValue( 12 ); 111 spinStart->setValue( 12 );
112 spinStart->setSuffix( tr(":00 AM") ); 112 spinStart->setSuffix( tr(":00 AM") );
113 oldtime = 12; 113 oldtime = 12;
114 } else { 114 } else {
115 spinStart->setMinValue( 0 ); 115 spinStart->setMinValue( 0 );
116 spinStart->setMaxValue( 23 ); 116 spinStart->setMaxValue( 23 );
117 spinStart->setSuffix( tr(":00") ); 117 spinStart->setSuffix( tr(":00") );
118 } 118 }
119} 119}
120 120
121void DateBookSettings::slotChangeClock( bool whichClock ) 121void DateBookSettings::slotChangeClock( bool whichClock )
122{ 122{
123 int saveMe; 123 int saveMe;
124 saveMe = spinStart->value(); 124 saveMe = spinStart->value();
125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
126 if ( saveMe == 12 ) 126 if ( saveMe == 12 )
127 saveMe = 0; 127 saveMe = 0;
128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
129 if ( saveMe != 12 ) 129 if ( saveMe != 12 )
130 saveMe += 12; 130 saveMe += 12;
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 933e191..7503751 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -269,196 +269,196 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
269 int y = t*rowHeight; 269 int y = t*rowHeight;
270 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { 270 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
271 QString s; 271 QString s;
272 if ( ampm ) { 272 if ( ampm ) {
273 if ( t == 0 ) 273 if ( t == 0 )
274 s = QString::number( 12 ); 274 s = QString::number( 12 );
275 else if ( t == 12 ) 275 else if ( t == 12 )
276 s = QString::number(12) + tr( "p" ); 276 s = QString::number(12) + tr( "p" );
277 else if ( t > 12 ) { 277 else if ( t > 12 ) {
278 if ( t - 12 < 10 ) 278 if ( t - 12 < 10 )
279 s = " "; 279 s = " ";
280 else 280 else
281 s = ""; 281 s = "";
282 s += QString::number( t - 12 ) + tr("p"); 282 s += QString::number( t - 12 ) + tr("p");
283 } else { 283 } else {
284 if ( 12 - t < 3 ) 284 if ( 12 - t < 3 )
285 s = ""; 285 s = "";
286 else 286 else
287 s = " "; 287 s = " ";
288 s += QString::number( t ); 288 s += QString::number( t );
289 } 289 }
290 } else { 290 } else {
291 s = QString::number( t ); 291 s = QString::number( t );
292 if ( s.length() == 1 ) 292 if ( s.length() == 1 )
293 s.prepend( "0" ); 293 s.prepend( "0" );
294 } 294 }
295 p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); 295 p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
296 } 296 }
297 } 297 }
298 298
299 QListIterator<DateBookWeekItem> it(items); 299 QListIterator<DateBookWeekItem> it(items);
300 for ( ; it.current(); ++it ) { 300 for ( ; it.current(); ++it ) {
301 DateBookWeekItem *i = it.current(); 301 DateBookWeekItem *i = it.current();
302 if ( i->geometry().intersects( ur ) ) { 302 if ( i->geometry().intersects( ur ) ) {
303 p->setBrush( i->color() ); 303 p->setBrush( i->color() );
304 p->drawRect( i->geometry() ); 304 p->drawRect( i->geometry() );
305 } 305 }
306 } 306 }
307} 307}
308 308
309void DateBookWeekView::resizeEvent( QResizeEvent *e ) 309void DateBookWeekView::resizeEvent( QResizeEvent *e )
310{ 310{
311 const int hourWidth = 20; 311 const int hourWidth = 20;
312 QScrollView::resizeEvent( e ); 312 QScrollView::resizeEvent( e );
313 313
314 314
315 //HEAD 315 //HEAD
316 /* 316 /*
317 int avail = visibleWidth(); 317 int avail = visibleWidth();
318 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), 318 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
319 visibleWidth(), header->sizeHint().height() ); 319 visibleWidth(), header->sizeHint().height() );
320 setMargins( 0, header->sizeHint().height(), 0, 0 ); 320 setMargins( 0, header->sizeHint().height(), 0, 0 );
321 */ 321 */
322 //BRANCH_1_0 322 //BRANCH_1_0
323 int avail = width()-qApp->style().scrollBarExtent().width()-1; 323 int avail = width()-qApp->style().scrollBarExtent().width()-1;
324 header->setGeometry( 0, 0, avail, header->sizeHint().height() ); 324 header->setGeometry( 0, 0, avail, header->sizeHint().height() );
325 setMargins( 0, header->height(), 0, 0 ); 325 setMargins( 0, header->height(), 0, 0 );
326 326
327 327
328 header->resizeSection( 0, hourWidth ); 328 header->resizeSection( 0, hourWidth );
329 int sw = (avail - hourWidth) / 7; 329 int sw = (avail - hourWidth) / 7;
330 for ( int i = 1; i < 7; i++ ) 330 for ( int i = 1; i < 7; i++ )
331 header->resizeSection( i, sw ); 331 header->resizeSection( i, sw );
332 header->resizeSection( 7, avail - hourWidth - sw*6 ); 332 header->resizeSection( 7, avail - hourWidth - sw*6 );
333} 333}
334 334
335void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 335void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
336{ 336{
337 bOnMonday = bStartOnMonday; 337 bOnMonday = bStartOnMonday;
338 initNames(); 338 initNames();
339} 339}
340 340
341//------------------------------------------------------------------- 341//-------------------------------------------------------------------
342 342
343DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 343DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
344 QWidget *parent, const char *name ) 344 QWidget *parent, const char *name )
345 : QWidget( parent, name ), 345 : QWidget( parent, name ),
346 db( newDB ), 346 db( newDB ),
347 startTime( 0 ), 347 startTime( 0 ),
348 ampm( ap ), 348 ampm( ap ),
349 bStartOnMonday( startOnMonday ) 349 bStartOnMonday( startOnMonday )
350{ 350{
351 setFocusPolicy(StrongFocus); 351 setFocusPolicy(StrongFocus);
352 QVBoxLayout *vb = new QVBoxLayout( this ); 352 QVBoxLayout *vb = new QVBoxLayout( this );
353 header = new DateBookWeekHeader( bStartOnMonday, this ); 353 header = new DateBookWeekHeader( bStartOnMonday, this );
354 view = new DateBookWeekView( ampm, startOnMonday, this ); 354 view = new DateBookWeekView( ampm, startOnMonday, this );
355 vb->addWidget( header ); 355 vb->addWidget( header );
356 vb->addWidget( view ); 356 vb->addWidget( view );
357 357
358 lblDesc = new QLabel( this, "event label" ); 358 lblDesc = new QLabel( this, "event label" );
359 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); 359 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
360 lblDesc->setBackgroundColor( yellow ); 360 lblDesc->setBackgroundColor( yellow );
361 lblDesc->hide(); 361 lblDesc->hide();
362 362
363 tHide = new QTimer( this ); 363 tHide = new QTimer( this );
364 364
365 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); 365 connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) );
366 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 366 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
367 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); 367 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
368 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); 368 connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) );
369 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); 369 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
370 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 370 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
371 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); 371 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
372 setDate(QDate::currentDate()); 372 setDate(QDate::currentDate());
373} 373}
374 374
375void DateBookWeek::keyPressEvent(QKeyEvent *e) 375void DateBookWeek::keyPressEvent(QKeyEvent *e)
376{ 376{
377 switch(e->key()) { 377 switch(e->key()) {
378 case Key_Up: 378 case Key_Up:
379 view->scrollBy(0, -20); 379 view->scrollBy(0, -20);
380 break; 380 break;
381 case Key_Down: 381 case Key_Down:
382 view->scrollBy(0, 20); 382 view->scrollBy(0, 20);
383 break; 383 break;
384 case Key_Left: 384 case Key_Left:
385 setDate(date().addDays(-7)); 385 setDate(date().addDays(-7));
386 break; 386 break;
387 case Key_Right: 387 case Key_Right:
388 setDate(date().addDays(7)); 388 setDate(date().addDays(7));
389 break; 389 break;
390 default: 390 default:
391 e->ignore(); 391 e->ignore();
392 } 392 }
393} 393}
394 394
395void DateBookWeek::showDay( int day ) 395void DateBookWeek::showDay( int day )
396{ 396{
397 QDate d=bdate; 397 QDate d=bdate;
398 398
399 // Calculate offset to first day of week. 399 // Calculate offset to first day of week.
400 int dayoffset=d.dayOfWeek() % 7; 400 int dayoffset=d.dayOfWeek() % 7;
401 401
402 if(bStartOnMonday) dayoffset--; 402 if(bStartOnMonday) dayoffset--;
403 403
404 day--; 404 day--;
405 d=d.addDays(day-dayoffset); 405 d=d.addDays(day-dayoffset);
406 emit showDate( d.year(), d.month(), d.day() ); 406 emit showDate( d.year(), d.month(), d.day() );
407} 407}
408 408
409void DateBookWeek::setDate( int y, int m, int d ) 409void DateBookWeek::setDate( int y, int m, int d )
410{ 410{
411 setDate(QDate(y, m, d)); 411 setDate(QDate(y, m, d));
412} 412}
413 413
414void DateBookWeek::setDate(QDate newdate) 414void DateBookWeek::setDate(QDate newdate)
415{ 415{
416 bdate=newdate; 416 bdate=newdate;
417 dow = newdate.dayOfWeek(); 417 dow = newdate.dayOfWeek();
418 header->setDate( newdate ); 418 header->setDate( newdate );
419} 419}
420 420
421void DateBookWeek::dateChanged( QDate &newdate ) 421void DateBookWeek::dateChanged( QDate &newdate )
422{ 422{
423 bdate=newdate; 423 bdate=newdate;
424 getEvents(); 424 getEvents();
425} 425}
426 426
427QDate DateBookWeek::date() const 427QDate DateBookWeek::date() const
428{ 428{
429 return bdate; 429 return bdate;
430} 430}
431 431
432void DateBookWeek::getEvents() 432void DateBookWeek::getEvents()
433{ 433{
434 QDate startWeek = weekDate(); 434 QDate startWeek = weekDate();
435 435
436 QDate endWeek = startWeek.addDays( 6 ); 436 QDate endWeek = startWeek.addDays( 6 );
437 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); 437 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
438 view->showEvents( eventList ); 438 view->showEvents( eventList );
439 view->moveToHour( startTime ); 439 view->moveToHour( startTime );
440} 440}
441 441
442void DateBookWeek::generateAllDayTooltext( QString& text ) { 442void DateBookWeek::generateAllDayTooltext( QString& text ) {
443 text += "<b>" + tr("This is an all day event.") + "</b><br>"; 443 text += "<b>" + tr("This is an all day event.") + "</b><br>";
444} 444}
445 445
446void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { 446void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
447 str += "<b>" + QObject::tr("Start") + "</b>: "; 447 str += "<b>" + QObject::tr("Start") + "</b>: ";
448 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); 448 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
449 if( ev.startDate()!=ev.endDate() ) { 449 if( ev.startDate()!=ev.endDate() ) {
450 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; 450 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
451 } 451 }
452 str += "<br>"; 452 str += "<br>";
453 str += "<b>" + QObject::tr("End") + "</b>: "; 453 str += "<b>" + QObject::tr("End") + "</b>: ";
454 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); 454 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
455 if( ev.startDate()!=ev.endDate() ) { 455 if( ev.startDate()!=ev.endDate() ) {
456 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; 456 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
457 } 457 }
458} 458}
459 459
460void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) 460void DateBookWeek::slotShowEvent( const EffectiveEvent &ev )
461{ 461{
462 if ( tHide->isActive() ) 462 if ( tHide->isActive() )
463 tHide->stop(); 463 tHide->stop();
464 464
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index eaa9730..c237b2d 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,120 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "datebookweekheaderimpl.h" 20#include "datebookweekheaderimpl.h"
21#include "datebookweek.h" 21#include "datebookweek.h"
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/datebookmonth.h> 23#include <qpe/datebookmonth.h>
24 24
25#include <qtoolbutton.h> 25#include <qtoolbutton.h>
26 26
27/* 27/*
28 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 28 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
29 * name 'name' and widget flags set to 'f' 29 * name 'name' and widget flags set to 'f'
30 */ 30 */
31DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) 31DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
32 : DateBookWeekHeaderBase( parent, name, fl ), 32 : DateBookWeekHeaderBase( parent, name, fl ),
33 bStartOnMonday( startOnMonday ) 33 bStartOnMonday( startOnMonday )
34{ 34{
35 setBackgroundMode( PaletteButton ); 35 setBackgroundMode( PaletteButton );
36 labelDate->setBackgroundMode( PaletteButton ); 36 labelDate->setBackgroundMode( PaletteButton );
37 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 37 backmonth->setPixmap( Resource::loadPixmap("fastback") );
38 backweek->setPixmap( Resource::loadPixmap("back") ); 38 backweek->setPixmap( Resource::loadPixmap("back") );
39 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 39 forwardweek->setPixmap( Resource::loadPixmap("forward") );
40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
41} 41}
42 42
43/* 43/*
44 * Destroys the object and frees any allocated resources 44 * Destroys the object and frees any allocated resources
45 */ 45 */
46DateBookWeekHeader::~DateBookWeekHeader() 46DateBookWeekHeader::~DateBookWeekHeader()
47{ 47{
48 // no need to delete child widgets, Qt does it all for us 48 // no need to delete child widgets, Qt does it all for us
49} 49}
50 50
51void DateBookWeekHeader::pickDate() 51void DateBookWeekHeader::pickDate()
52{ 52{
53 static QPopupMenu *m1 = 0; 53 static QPopupMenu *m1 = 0;
54 static DateBookMonth *picker = 0; 54 static DateBookMonth *picker = 0;
55 if ( !m1 ) { 55 if ( !m1 ) {
56 m1 = new QPopupMenu( this ); 56 m1 = new QPopupMenu( this );
57 picker = new DateBookMonth( m1, 0, TRUE ); 57 picker = new DateBookMonth( m1, 0, TRUE );
58 m1->insertItem( picker ); 58 m1->insertItem( picker );
59 connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); 59 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) );
60 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); 60 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
61 } 61 }
62 picker->setDate( date.year(), date.month(), date.day() ); 62 picker->setDate( date.year(), date.month(), date.day() );
63 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 63 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
64 picker->setFocus(); 64 picker->setFocus();
65} 65}
66 66
67void DateBookWeekHeader::nextMonth() 67void DateBookWeekHeader::nextMonth()
68{ 68{
69 qWarning("nextMonth() " ); 69 qWarning("nextMonth() " );
70 setDate(date.addDays(28)); 70 setDate(date.addDays(28));
71} 71}
72void DateBookWeekHeader::prevMonth() 72void DateBookWeekHeader::prevMonth()
73{ 73{
74 qWarning("prevMonth() " ); 74 qWarning("prevMonth() " );
75 setDate(date.addDays(-28)); 75 setDate(date.addDays(-28));
76} 76}
77void DateBookWeekHeader::nextWeek() 77void DateBookWeekHeader::nextWeek()
78{ 78{
79 qWarning("nextWeek() " ); 79 qWarning("nextWeek() " );
80 setDate(date.addDays(7)); 80 setDate(date.addDays(7));
81} 81}
82void DateBookWeekHeader::prevWeek() 82void DateBookWeekHeader::prevWeek()
83{ 83{
84 qWarning("prevWeek() "); 84 qWarning("prevWeek() ");
85 setDate(date.addDays(-7)); 85 setDate(date.addDays(-7));
86} 86}
87 87
88void DateBookWeekHeader::setDate( int y, int m, int d ) 88void DateBookWeekHeader::setDate( int y, int m, int d )
89{ 89{
90 setDate(QDate(y,m,d)); 90 setDate(QDate(y,m,d));
91} 91}
92 92
93void DateBookWeekHeader::setDate(const QDate &d) { 93void DateBookWeekHeader::setDate(const QDate &d) {
94 int year,week,dayofweek; 94 int year,week,dayofweek;
95 date=d; 95 date=d;
96 dayofweek=d.dayOfWeek(); 96 dayofweek=d.dayOfWeek();
97 if(bStartOnMonday) 97 if(bStartOnMonday)
98 dayofweek--; 98 dayofweek--;
99 else if( dayofweek == 7 ) 99 else if( dayofweek == 7 )
100 // we already have the right day -7 would lead to the current week.. 100 // we already have the right day -7 would lead to the current week..
101 dayofweek = 0; 101 dayofweek = 0;
102 102
103 date=date.addDays(-dayofweek); 103 date=date.addDays(-dayofweek);
104 calcWeek(date,week,year,bStartOnMonday); 104 calcWeek(date,week,year,bStartOnMonday);
105 QDate start=date; 105 QDate start=date;
106 QDate stop=start.addDays(6); 106 QDate stop=start.addDays(6);
107 labelDate->setText( QString::number(start.day()) + "." + 107 labelDate->setText( QString::number(start.day()) + "." +
108 Calendar::nameOfMonth( start.month()) + "-" + 108 Calendar::nameOfMonth( start.month()) + "-" +
109 QString::number(stop.day()) + "." + 109 QString::number(stop.day()) + "." +
110 Calendar::nameOfMonth( stop.month()) +" ("+ 110 Calendar::nameOfMonth( stop.month()) +" ("+
111 tr("w")+":"+QString::number( week ) +")"); 111 tr("w")+":"+QString::number( week ) +")");
112 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 112 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
113 emit dateChanged(date); 113 emit dateChanged(date);
114} 114}
115 115
116void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 116void DateBookWeekHeader::setStartOfWeek( bool onMonday )
117{ 117{
118 bStartOnMonday = onMonday; 118 bStartOnMonday = onMonday;
119 setDate( date ); 119 setDate( date );
120} 120}
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 42a1753..af40143 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,394 +1,394 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3 3
4#include "datebook.h" 4#include "datebook.h"
5 5
6#include <qpe/datebookmonth.h> 6#include <qpe/datebookmonth.h>
7#include <qpe/config.h> 7#include <qpe/config.h>
8#include <qpe/resource.h> 8#include <qpe/resource.h>
9 9
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qtoolbutton.h> 11#include <qtoolbutton.h>
12#include <qtl.h> 12#include <qtl.h>
13 13
14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
15 15
16DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 16DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
17 : DateBookWeekLstHeaderBase(parent, name, fl) 17 : DateBookWeekLstHeaderBase(parent, name, fl)
18{ 18{
19 setBackgroundMode( PaletteButton ); 19 setBackgroundMode( PaletteButton );
20 labelDate->setBackgroundMode( PaletteButton ); 20 labelDate->setBackgroundMode( PaletteButton );
21 forwardweek->setBackgroundMode( PaletteButton ); 21 forwardweek->setBackgroundMode( PaletteButton );
22 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 22 forwardweek->setPixmap( Resource::loadPixmap("forward") );
23 forwardmonth->setBackgroundMode( PaletteButton ); 23 forwardmonth->setBackgroundMode( PaletteButton );
24 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 24 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
25 backweek->setBackgroundMode( PaletteButton ); 25 backweek->setBackgroundMode( PaletteButton );
26 backweek->setPixmap( Resource::loadPixmap("back") ); 26 backweek->setPixmap( Resource::loadPixmap("back") );
27 backmonth->setBackgroundMode( PaletteButton ); 27 backmonth->setBackgroundMode( PaletteButton );
28 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 28 backmonth->setPixmap( Resource::loadPixmap("fastback") );
29 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 29 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
30 DateBookWeekLstHeaderBaseLayout->setMargin(0); 30 DateBookWeekLstHeaderBaseLayout->setMargin(0);
31 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 31 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
32 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 32 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
33 33
34 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 34 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
35 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 35 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
36 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 36 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
37 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 37 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
38 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 38 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
39 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 39 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
40 bStartOnMonday=onM; 40 bStartOnMonday=onM;
41} 41}
42DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 42DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
43 43
44void DateBookWeekLstHeader::setDate(const QDate &d) { 44void DateBookWeekLstHeader::setDate(const QDate &d) {
45 int year,week,dayofweek; 45 int year,week,dayofweek;
46 date=d; 46 date=d;
47 dayofweek=d.dayOfWeek(); 47 dayofweek=d.dayOfWeek();
48 if(bStartOnMonday) 48 if(bStartOnMonday)
49 dayofweek--; 49 dayofweek--;
50 else if( dayofweek == 7 ) 50 else if( dayofweek == 7 )
51 /* we already have the right day -7 would lead to the same week */ 51 /* we already have the right day -7 would lead to the same week */
52 dayofweek = 0; 52 dayofweek = 0;
53 53
54 date=date.addDays(-dayofweek); 54 date=date.addDays(-dayofweek);
55 55
56 calcWeek(date,week,year,bStartOnMonday); 56 calcWeek(date,week,year,bStartOnMonday);
57 QDate start=date; 57 QDate start=date;
58 QDate stop=start.addDays(6); 58 QDate stop=start.addDays(6);
59 labelDate->setText( QString::number(start.day()) + "." + 59 labelDate->setText( QString::number(start.day()) + "." +
60 Calendar::nameOfMonth( start.month() ) + "-" + 60 Calendar::nameOfMonth( start.month() ) + "-" +
61 QString::number(stop.day()) + "." + 61 QString::number(stop.day()) + "." +
62 Calendar::nameOfMonth( stop.month()) +" ("+ 62 Calendar::nameOfMonth( stop.month()) +" ("+
63 tr("w")+":"+QString::number( week ) +")"); 63 tr("w")+":"+QString::number( week ) +")");
64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
65 emit dateChanged(date); 65 emit dateChanged(date);
66} 66}
67 67
68void DateBookWeekLstHeader::pickDate() { 68void DateBookWeekLstHeader::pickDate() {
69 static QPopupMenu *m1 = 0; 69 static QPopupMenu *m1 = 0;
70 static DateBookMonth *picker = 0; 70 static DateBookMonth *picker = 0;
71 if ( !m1 ) { 71 if ( !m1 ) {
72 m1 = new QPopupMenu( this ); 72 m1 = new QPopupMenu( this );
73 picker = new DateBookMonth( m1, 0, TRUE ); 73 picker = new DateBookMonth( m1, 0, TRUE );
74 m1->insertItem( picker ); 74 m1->insertItem( picker );
75 connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); 75 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
76 //connect( m1, SIGNAL( aboutToHide() ), 76 //connect( m1, SIGNAL( aboutToHide() ),
77 //this, SLOT( gotHide() ) ); 77 //this, SLOT( gotHide() ) );
78 } 78 }
79 picker->setDate( date.year(), date.month(), date.day() ); 79 picker->setDate( date.year(), date.month(), date.day() );
80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
81 picker->setFocus(); 81 picker->setFocus();
82} 82}
83void DateBookWeekLstHeader::setDate(int y, int m, int d) { 83void DateBookWeekLstHeader::setDate(int y, int m, int d) {
84 setDate(QDate(y,m,d)); 84 setDate(QDate(y,m,d));
85} 85}
86 86
87void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
89} 89}
90void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
92} 92}
93void DateBookWeekLstHeader::nextMonth() 93void DateBookWeekLstHeader::nextMonth()
94{ 94{
95 setDate(date.addDays(28)); 95 setDate(date.addDays(28));
96} 96}
97void DateBookWeekLstHeader::prevMonth() 97void DateBookWeekLstHeader::prevMonth()
98{ 98{
99 setDate(date.addDays(-28)); 99 setDate(date.addDays(-28));
100} 100}
101 101
102DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 102DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
103 QWidget* parent, 103 QWidget* parent,
104 const char* name, 104 const char* name,
105 WFlags fl ) 105 WFlags fl )
106 : DateBookWeekLstDayHdrBase(parent, name, fl) { 106 : DateBookWeekLstDayHdrBase(parent, name, fl) {
107 107
108 date=d; 108 date=d;
109 109
110 static const QString wdays=tr("MTWTFSSM", "Week days"); 110 static const QString wdays=tr("MTWTFSSM", "Week days");
111 char day=wdays[d.dayOfWeek()-1]; 111 char day=wdays[d.dayOfWeek()-1];
112 112
113 //dont use dayOfWeek() to save space ! 113 //dont use dayOfWeek() to save space !
114 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); 114 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
115 115
116 add->setText("+"); 116 add->setText("+");
117 117
118 if (d == QDate::currentDate()) { 118 if (d == QDate::currentDate()) {
119 QPalette pal=label->palette(); 119 QPalette pal=label->palette();
120 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 120 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
121 label->setPalette(pal); 121 label->setPalette(pal);
122 122
123 /* 123 /*
124 QFont f=label->font(); 124 QFont f=label->font();
125 f.setItalic(true); 125 f.setItalic(true);
126 label->setFont(f); 126 label->setFont(f);
127 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 127 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
128 */ 128 */
129 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 129 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
130 QPalette pal=label->palette(); 130 QPalette pal=label->palette();
131 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 131 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
132 label->setPalette(pal); 132 label->setPalette(pal);
133 } 133 }
134 134
135 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 135 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
136 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 136 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
137} 137}
138 138
139void DateBookWeekLstDayHdr::showDay() { 139void DateBookWeekLstDayHdr::showDay() {
140 emit showDate(date.year(), date.month(), date.day()); 140 emit showDate(date.year(), date.month(), date.day());
141} 141}
142 142
143void DateBookWeekLstDayHdr::newEvent() { 143void DateBookWeekLstDayHdr::newEvent() {
144 QDateTime start, stop; 144 QDateTime start, stop;
145 start=stop=date; 145 start=stop=date;
146 start.setTime(QTime(10,0)); 146 start.setTime(QTime(10,0));
147 stop.setTime(QTime(12,0)); 147 stop.setTime(QTime(12,0));
148 148
149 emit addEvent(start,stop,"",0); 149 emit addEvent(start,stop,"",0);
150} 150}
151DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 151DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
152 int weeklistviewconfig, 152 int weeklistviewconfig,
153 QWidget* parent, 153 QWidget* parent,
154 const char* name, 154 const char* name,
155 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 155 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
156{ 156{
157 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 157 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
158 QString s,start,middle,end,day; 158 QString s,start,middle,end,day;
159 159
160 qDebug("weeklistviewconfig=%d",weeklistviewconfig); 160 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
161 if(weeklistviewconfig==NONE) {// No times displayed. 161 if(weeklistviewconfig==NONE) {// No times displayed.
162 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 162 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
163 // middle.sprintf("<--->"); 163 // middle.sprintf("<--->");
164 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 164 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
165 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 165 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
166 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 166 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
167 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 167 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
168 middle.sprintf(" |---"); 168 middle.sprintf(" |---");
169 end.sprintf("__|__"); 169 end.sprintf("__|__");
170 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 170 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
171 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 171 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
172 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 172 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
173 middle.sprintf("<--->"); 173 middle.sprintf("<--->");
174 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 174 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
175 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 175 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
176 } 176 }
177 177
178 if(ev.event().type() == Event::Normal) { 178 if(ev.event().type() == Event::Normal) {
179 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 179 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
180 s=day; 180 s=day;
181 } else if(ev.startDate()==ev.date()) {// start event. 181 } else if(ev.startDate()==ev.date()) {// start event.
182 s=start; 182 s=start;
183 } else if(ev.endDate()==ev.date()) { // end event. 183 } else if(ev.endDate()==ev.date()) { // end event.
184 s=end; 184 s=end;
185 } else {// middle day. 185 } else {// middle day.
186 s=middle; 186 s=middle;
187 } 187 }
188 } else { 188 } else {
189 s=""; 189 s="";
190 } 190 }
191 setText(QString(s) + " " + ev.description()); 191 setText(QString(s) + " " + ev.description());
192 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 192 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
193 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 193 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
194} 194}
195void DateBookWeekLstEvent::editMe() { 195void DateBookWeekLstEvent::editMe() {
196 emit editEvent(event.event()); 196 emit editEvent(event.event());
197} 197}
198 198
199 199
200DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 200DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
201 const QDate &d, bool onM, 201 const QDate &d, bool onM,
202 QWidget* parent, 202 QWidget* parent,
203 const char* name, WFlags fl) 203 const char* name, WFlags fl)
204 : QWidget( parent, name, fl ) 204 : QWidget( parent, name, fl )
205{ 205{
206 Config config("DateBook"); 206 Config config("DateBook");
207 config.setGroup("Main"); 207 config.setGroup("Main");
208 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 208 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
209 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); 209 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
210 210
211 bStartOnMonday=onM; 211 bStartOnMonday=onM;
212 setPalette(white); 212 setPalette(white);
213 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 213 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
214 214
215 QVBoxLayout *layout = new QVBoxLayout( this ); 215 QVBoxLayout *layout = new QVBoxLayout( this );
216 216
217 qBubbleSort(ev); 217 qBubbleSort(ev);
218 QValueListIterator<EffectiveEvent> it; 218 QValueListIterator<EffectiveEvent> it;
219 it=ev.begin(); 219 it=ev.begin();
220 220
221 int dayOrder[7]; 221 int dayOrder[7];
222 if (bStartOnMonday) { 222 if (bStartOnMonday) {
223 for (int d=0; d<7; d++) dayOrder[d]=d+1; 223 for (int d=0; d<7; d++) dayOrder[d]=d+1;
224 } else { 224 } else {
225 for (int d=0; d<7; d++) dayOrder[d]=d; 225 for (int d=0; d<7; d++) dayOrder[d]=d;
226 dayOrder[0]=7; 226 dayOrder[0]=7;
227 } 227 }
228 228
229 // Calculate offset to first day of week. 229 // Calculate offset to first day of week.
230 int dayoffset=d.dayOfWeek(); 230 int dayoffset=d.dayOfWeek();
231 if(bStartOnMonday) dayoffset--; 231 if(bStartOnMonday) dayoffset--;
232 else if( dayoffset == 7 ) dayoffset = 0; 232 else if( dayoffset == 7 ) dayoffset = 0;
233 233
234 for (int i=0; i<7; i++) { 234 for (int i=0; i<7; i++) {
235 // Header 235 // Header
236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
237 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 237 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
238 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 238 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
239 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 239 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
240 layout->addWidget(hdr); 240 layout->addWidget(hdr);
241 241
242 // Events 242 // Events
243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
244 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 244 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
246 layout->addWidget(l); 246 layout->addWidget(l);
247 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 247 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
248 } 248 }
249 it++; 249 it++;
250 } 250 }
251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
252 } 252 }
253} 253}
254DateBookWeekLstView::~DateBookWeekLstView(){} 254DateBookWeekLstView::~DateBookWeekLstView(){}
255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
256 256
257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
258 QValueList<EffectiveEvent> &ev2, 258 QValueList<EffectiveEvent> &ev2,
259 QDate &d, bool onM, 259 QDate &d, bool onM,
260 QWidget* parent, 260 QWidget* parent,
261 const char* name, WFlags fl) 261 const char* name, WFlags fl)
262 : QWidget( parent, name, fl ) 262 : QWidget( parent, name, fl )
263{ 263{
264 QHBoxLayout *layout = new QHBoxLayout( this ); 264 QHBoxLayout *layout = new QHBoxLayout( this );
265 265
266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
267 layout->addWidget(w); 267 layout->addWidget(w);
268 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 268 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
269 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 269 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
270 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), 270 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
271 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 271 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
272 272
273 273
274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
275 layout->addWidget(w); 275 layout->addWidget(w);
276 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 276 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
277 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 277 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
278 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 278 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
279 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 279 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
280} 280}
281 281
282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
283 QWidget *parent, 283 QWidget *parent,
284 const char *name ) 284 const char *name )
285 : QWidget( parent, name ), 285 : QWidget( parent, name ),
286 db( newDB ), 286 db( newDB ),
287 startTime( 0 ), 287 startTime( 0 ),
288 ampm( ap ), 288 ampm( ap ),
289 bStartOnMonday(onM) 289 bStartOnMonday(onM)
290{ 290{
291 setFocusPolicy(StrongFocus); 291 setFocusPolicy(StrongFocus);
292 layout = new QVBoxLayout( this ); 292 layout = new QVBoxLayout( this );
293 layout->setMargin(0); 293 layout->setMargin(0);
294 294
295 header=new DateBookWeekLstHeader(onM, this); 295 header=new DateBookWeekLstHeader(onM, this);
296 layout->addWidget( header ); 296 layout->addWidget( header );
297 connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); 297 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
299 299
300 scroll=new QScrollView(this); 300 scroll=new QScrollView(this);
301 scroll->setResizePolicy(QScrollView::AutoOneFit); 301 scroll->setResizePolicy(QScrollView::AutoOneFit);
302 layout->addWidget(scroll); 302 layout->addWidget(scroll);
303 303
304 view=NULL; 304 view=NULL;
305 Config config("DateBook"); 305 Config config("DateBook");
306 config.setGroup("Main"); 306 config.setGroup("Main");
307 dbl=config.readBoolEntry("weeklst_dbl", false); 307 dbl=config.readBoolEntry("weeklst_dbl", false);
308 header->dbl->setOn(dbl); 308 header->dbl->setOn(dbl);
309} 309}
310DateBookWeekLst::~DateBookWeekLst(){ 310DateBookWeekLst::~DateBookWeekLst(){
311 Config config("DateBook"); 311 Config config("DateBook");
312 config.setGroup("Main"); 312 config.setGroup("Main");
313 config.writeEntry("weeklst_dbl", dbl); 313 config.writeEntry("weeklst_dbl", dbl);
314} 314}
315 315
316void DateBookWeekLst::setDate(const QDate &d) { 316void DateBookWeekLst::setDate(const QDate &d) {
317 bdate=d; 317 bdate=d;
318 header->setDate(d); 318 header->setDate(d);
319} 319}
320 320
321void DateBookWeekLst::setDbl(bool on) { 321void DateBookWeekLst::setDbl(bool on) {
322 dbl=on; 322 dbl=on;
323 redraw(); 323 redraw();
324} 324}
325void DateBookWeekLst::redraw() {getEvents();} 325void DateBookWeekLst::redraw() {getEvents();}
326 326
327QDate DateBookWeekLst::date() { 327QDate DateBookWeekLst::date() {
328 return bdate; 328 return bdate;
329} 329}
330 330
331// return the date at the beginning of the week... 331// return the date at the beginning of the week...
332// copied from DateBookWeek 332// copied from DateBookWeek
333QDate DateBookWeekLst::weekDate() const 333QDate DateBookWeekLst::weekDate() const
334{ 334{
335 QDate d=bdate; 335 QDate d=bdate;
336 336
337 // Calculate offset to first day of week. 337 // Calculate offset to first day of week.
338 int dayoffset=d.dayOfWeek(); 338 int dayoffset=d.dayOfWeek();
339 if(bStartOnMonday) dayoffset--; 339 if(bStartOnMonday) dayoffset--;
340 else if( dayoffset == 7 ) 340 else if( dayoffset == 7 )
341 dayoffset = 0; 341 dayoffset = 0;
342 342
343 return d.addDays(-dayoffset); 343 return d.addDays(-dayoffset);
344} 344}
345 345
346void DateBookWeekLst::getEvents() { 346void DateBookWeekLst::getEvents() {
347 QDate start = weekDate(); //date(); 347 QDate start = weekDate(); //date();
348 QDate stop = start.addDays(6); 348 QDate stop = start.addDays(6);
349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
350 350
351 if (view) delete view; 351 if (view) delete view;
352 if (dbl) { 352 if (dbl) {
353 QDate start2=start.addDays(7); 353 QDate start2=start.addDays(7);
354 stop=start2.addDays(6); 354 stop=start2.addDays(6);
355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
357 } else { 357 } else {
358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
359 } 359 }
360 360
361 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 361 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
362 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 362 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
363 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 363 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
364 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 364 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
365 365
366 scroll->addChild(view); 366 scroll->addChild(view);
367 view->show(); 367 view->show();
368 scroll->updateScrollBars(); 368 scroll->updateScrollBars();
369} 369}
370 370
371void DateBookWeekLst::dateChanged(QDate &newdate) { 371void DateBookWeekLst::dateChanged(QDate &newdate) {
372 bdate=newdate; 372 bdate=newdate;
373 getEvents(); 373 getEvents();
374} 374}
375 375
376void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 376void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
377{ 377{
378 switch(e->key()) { 378 switch(e->key()) {
379 case Key_Up: 379 case Key_Up:
380 scroll->scrollBy(0, -20); 380 scroll->scrollBy(0, -20);
381 break; 381 break;
382 case Key_Down: 382 case Key_Down:
383 scroll->scrollBy(0, 20); 383 scroll->scrollBy(0, 20);
384 break; 384 break;
385 case Key_Left: 385 case Key_Left:
386 header->prevWeek(); 386 header->prevWeek();
387 break; 387 break;
388 case Key_Right: 388 case Key_Right:
389 header->nextWeek(); 389 header->nextWeek();
390 break; 390 break;
391 default: 391 default:
392 e->ignore(); 392 e->ignore();
393 } 393 }
394} 394}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 018bb5a..57bcd89 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -97,215 +97,215 @@ static void addOrPick( QComboBox* combo, const QString& t )
97 } 97 }
98 98
99 // Else add one 99 // Else add one
100 combo->insertItem(t); 100 combo->insertItem(t);
101 combo->setCurrentItem(combo->count()-1); 101 combo->setCurrentItem(combo->count()-1);
102} 102}
103 103
104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
105 QWidget* parent, const char* name ) 105 QWidget* parent, const char* name )
106 : DateEntryBase( parent, name ), 106 : DateEntryBase( parent, name ),
107 ampm( whichClock ), 107 ampm( whichClock ),
108 startWeekOnMonday( startOnMonday ), 108 startWeekOnMonday( startOnMonday ),
109 m_showStart(true) 109 m_showStart(true)
110 110
111{ 111{
112 init(); 112 init();
113 setDates(event.start(),event.end()); 113 setDates(event.start(),event.end());
114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
115 if(!event.description().isEmpty()) 115 if(!event.description().isEmpty())
116 addOrPick( comboDescription, event.description() ); 116 addOrPick( comboDescription, event.description() );
117 if(!event.location().isEmpty()) 117 if(!event.location().isEmpty())
118 addOrPick( comboLocation, event.location() ); 118 addOrPick( comboLocation, event.location() );
119 checkAlarm->setChecked( event.hasAlarm() ); 119 checkAlarm->setChecked( event.hasAlarm() );
120 checkAllDay->setChecked( event.type() == Event::AllDay ); 120 checkAllDay->setChecked( event.type() == Event::AllDay );
121 if(!event.notes().isEmpty()) noteStr=event.notes(); 121 if(!event.notes().isEmpty()) noteStr=event.notes();
122 else noteStr=""; 122 else noteStr="";
123 spinAlarm->setValue(event.alarmTime()); 123 spinAlarm->setValue(event.alarmTime());
124 if ( event.alarmSound() != Event::Silent ) 124 if ( event.alarmSound() != Event::Silent )
125 comboSound->setCurrentItem( 1 ); 125 comboSound->setCurrentItem( 1 );
126 if ( event.hasRepeat() ) { 126 if ( event.hasRepeat() ) {
127 rp = event.repeatPattern(); 127 rp = event.repeatPattern();
128 cmdRepeat->setText( tr("Repeat...") ); 128 cmdRepeat->setText( tr("Repeat...") );
129 } 129 }
130 setRepeatLabel(); 130 setRepeatLabel();
131} 131}
132 132
133void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 133void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
134{ 134{
135 startDate = s.date(); 135 startDate = s.date();
136 endDate = e.date(); 136 endDate = e.date();
137 startTime = s.time(); 137 startTime = s.time();
138 endTime = e.time(); 138 endTime = e.time();
139 139
140 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 140 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
141 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 141 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
142 142
143 updateTimeEdit(true,true); 143 updateTimeEdit(true,true);
144} 144}
145 145
146void DateEntry::updateTimeEdit(bool s, bool e) { 146void DateEntry::updateTimeEdit(bool s, bool e) {
147 147
148 // Comboboxes 148 // Comboboxes
149 QString strStart, strEnd; 149 QString strStart, strEnd;
150 int shour, ehour; 150 int shour, ehour;
151 if ( ampm ) { 151 if ( ampm ) {
152 shour = startTime.hour(); 152 shour = startTime.hour();
153 ehour = endTime.hour(); 153 ehour = endTime.hour();
154 if ( shour >= 12 ) { 154 if ( shour >= 12 ) {
155 if ( shour > 12 ) 155 if ( shour > 12 )
156 shour -= 12; 156 shour -= 12;
157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
158 } else { 158 } else {
159 if ( shour == 0 ) 159 if ( shour == 0 )
160 shour = 12; 160 shour = 12;
161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
162 } 162 }
163 if ( ehour == 24 && endTime.minute() == 0 ) { 163 if ( ehour == 24 && endTime.minute() == 0 ) {
164 strEnd = "11:59 PM"; // or "midnight" 164 strEnd = "11:59 PM"; // or "midnight"
165 } else if ( ehour >= 12 ) { 165 } else if ( ehour >= 12 ) {
166 if ( ehour > 12 ) 166 if ( ehour > 12 )
167 ehour -= 12; 167 ehour -= 12;
168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
169 } else { 169 } else {
170 if ( ehour == 0 ) 170 if ( ehour == 0 )
171 ehour = 12; 171 ehour = 12;
172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
173 } 173 }
174 } else { 174 } else {
175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
177 } 177 }
178 178
179 if (s) comboStart->setText(strStart); 179 if (s) comboStart->setText(strStart);
180 if (e) comboEnd->setText(strEnd); 180 if (e) comboEnd->setText(strEnd);
181} 181}
182 182
183void DateEntry::init() 183void DateEntry::init()
184{ 184{
185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
187 187
188 initCombos(); 188 initCombos();
189 QPopupMenu *m1 = new QPopupMenu( this ); 189 QPopupMenu *m1 = new QPopupMenu( this );
190 startPicker = new DateBookMonth( m1, 0, TRUE ); 190 startPicker = new DateBookMonth( m1, 0, TRUE );
191 m1->insertItem( startPicker ); 191 m1->insertItem( startPicker );
192 buttonStart->setPopup( m1 ); 192 buttonStart->setPopup( m1 );
193 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 193 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
194 this, SLOT( startDateChanged( int, int, int ) ) ); 194 this, SLOT( startDateChanged(int,int,int) ) );
195 195
196 //Let start button change both start and end dates 196 //Let start button change both start and end dates
197 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 197 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
198 this, SLOT( endDateChanged( int, int, int ) ) ); 198 this, SLOT( endDateChanged(int,int,int) ) );
199 connect( qApp, SIGNAL( clockChanged( bool ) ), 199 connect( qApp, SIGNAL( clockChanged(bool) ),
200 this, SLOT( slotChangeClock( bool ) ) ); 200 this, SLOT( slotChangeClock(bool) ) );
201 connect( qApp, SIGNAL(weekChanged(bool)), 201 connect( qApp, SIGNAL(weekChanged(bool)),
202 this, SLOT(slotChangeStartOfWeek(bool)) ); 202 this, SLOT(slotChangeStartOfWeek(bool)) );
203 203
204 connect( editNote, SIGNAL(clicked()), 204 connect( editNote, SIGNAL(clicked()),
205 this, SLOT(slotEditNote()) ); 205 this, SLOT(slotEditNote()) );
206 206
207 QPopupMenu *m2 = new QPopupMenu( this ); 207 QPopupMenu *m2 = new QPopupMenu( this );
208 endPicker = new DateBookMonth( m2, 0, TRUE ); 208 endPicker = new DateBookMonth( m2, 0, TRUE );
209 m2->insertItem( endPicker ); 209 m2->insertItem( endPicker );
210 buttonEnd->setPopup( m2 ); 210 buttonEnd->setPopup( m2 );
211 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), 211 connect( endPicker, SIGNAL( dateClicked(int,int,int) ),
212 this, SLOT( endDateChanged( int, int, int ) ) ); 212 this, SLOT( endDateChanged(int,int,int) ) );
213 213
214 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), 214 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ),
215 this, SLOT( startTimePicked(const QTime &) )); 215 this, SLOT( startTimePicked(const QTime&) ));
216 // install eventFilters 216 // install eventFilters
217 comboEnd->installEventFilter( this ); 217 comboEnd->installEventFilter( this );
218 comboStart->installEventFilter( this ); 218 comboStart->installEventFilter( this );
219} 219}
220 220
221/* 221/*
222 * Destroys the object and frees any allocated resources 222 * Destroys the object and frees any allocated resources
223 */ 223 */
224DateEntry::~DateEntry() 224DateEntry::~DateEntry()
225{ 225{
226 // no need to delete child widgets, Qt does it all for us 226 // no need to delete child widgets, Qt does it all for us
227 //cout << "Del: " << comboStart->currentText() << endl; 227 //cout << "Del: " << comboStart->currentText() << endl;
228} 228}
229 229
230/* 230/*
231 * public slot 231 * public slot
232 */ 232 */
233 233
234void DateEntry::slotEditNote() { 234void DateEntry::slotEditNote() {
235 QString s; 235 QString s;
236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
239 this,0,TRUE); 239 this,0,TRUE);
240 240
241 if ( QPEApplication::execDialog( &noteDlg ) ) { 241 if ( QPEApplication::execDialog( &noteDlg ) ) {
242 noteStr=noteDlg.note->text(); 242 noteStr=noteDlg.note->text();
243 } 243 }
244 244
245} 245}
246 246
247void DateEntry::endDateChanged( int y, int m, int d ) 247void DateEntry::endDateChanged( int y, int m, int d )
248{ 248{
249 endDate.setYMD( y, m, d ); 249 endDate.setYMD( y, m, d );
250 if ( endDate < startDate ) { 250 if ( endDate < startDate ) {
251 endDate = startDate; 251 endDate = startDate;
252 } 252 }
253 253
254 buttonEnd->setText( TimeString::shortDate( endDate ) ); 254 buttonEnd->setText( TimeString::shortDate( endDate ) );
255 255
256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
257} 257}
258 258
259static QTime parseTime( const QString& s, bool ampm ) 259static QTime parseTime( const QString& s, bool ampm )
260{ 260{
261 QTime tmpTime; 261 QTime tmpTime;
262 QStringList l = QStringList::split( ':', s ); 262 QStringList l = QStringList::split( ':', s );
263 int hour = l[0].toInt(); 263 int hour = l[0].toInt();
264 if ( ampm ) { 264 if ( ampm ) {
265 int i=0; 265 int i=0;
266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
267 i++; 267 i++;
268 QString digits = l[1].left(i); 268 QString digits = l[1].left(i);
269 if ( l[1].contains( "PM", FALSE ) ) { 269 if ( l[1].contains( "PM", FALSE ) ) {
270 if ( hour != 12 ) 270 if ( hour != 12 )
271 hour += 12; 271 hour += 12;
272 } else { 272 } else {
273 if ( hour == 12 ) 273 if ( hour == 12 )
274 hour = 0; 274 hour = 0;
275 } 275 }
276 l[1] = digits; 276 l[1] = digits;
277 } 277 }
278 int minute = l[1].toInt(); 278 int minute = l[1].toInt();
279 if ( minute > 59 ) 279 if ( minute > 59 )
280 minute = 59; 280 minute = 59;
281 else if ( minute < 0 ) 281 else if ( minute < 0 )
282 minute = 0; 282 minute = 0;
283 if ( hour > 23 ) { 283 if ( hour > 23 ) {
284 hour = 23; 284 hour = 23;
285 minute = 59; 285 minute = 59;
286 } else if ( hour < 0 ) 286 } else if ( hour < 0 )
287 hour = 0; 287 hour = 0;
288 tmpTime.setHMS( hour, minute, 0 ); 288 tmpTime.setHMS( hour, minute, 0 );
289 return tmpTime; 289 return tmpTime;
290} 290}
291 291
292/* 292/*
293 * public slot 293 * public slot
294 */ 294 */
295void DateEntry::endTimeChanged( const QString &s ) 295void DateEntry::endTimeChanged( const QString &s )
296{ 296{
297 endTimeChanged( parseTime(s,ampm) ); 297 endTimeChanged( parseTime(s,ampm) );
298} 298}
299 299
300void DateEntry::endTimeChanged( const QTime &t ) { 300void DateEntry::endTimeChanged( const QTime &t ) {
301 if ( endDate > startDate || t >= startTime ) { 301 if ( endDate > startDate || t >= startTime ) {
302 endTime = t; 302 endTime = t;
303 } else { 303 } else {
304 endTime = startTime; 304 endTime = startTime;
305 //comboEnd->setCurrentItem( comboStart->currentItem() ); 305 //comboEnd->setCurrentItem( comboStart->currentItem() );
306 } 306 }
307 timePickerStart->setHour(endTime.hour()); 307 timePickerStart->setHour(endTime.hour());
308 timePickerStart->setMinute(endTime.minute()); 308 timePickerStart->setMinute(endTime.minute());
309} 309}
310 310
311/* 311/*
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp
index 7cf36da..04c3cf3 100644
--- a/core/pim/datebook/repeatentry.cpp
+++ b/core/pim/datebook/repeatentry.cpp
@@ -266,194 +266,194 @@ void RepeatEntry::setupDaily()
266void RepeatEntry::setupWeekly() 266void RepeatEntry::setupWeekly()
267{ 267{
268 // reshow the buttons... 268 // reshow the buttons...
269 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") ); 269 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") );
270 fraExtra->setExclusive( FALSE ); 270 fraExtra->setExclusive( FALSE );
271 fraExtra->show(); 271 fraExtra->show();
272 if ( startWeekOnMonday ) { 272 if ( startWeekOnMonday ) {
273 cmdExtra1->setText( RepeatEntryBase::tr("Mon") ); 273 cmdExtra1->setText( RepeatEntryBase::tr("Mon") );
274 cmdExtra2->setText( RepeatEntryBase::tr("Tue") ); 274 cmdExtra2->setText( RepeatEntryBase::tr("Tue") );
275 cmdExtra3->setText( RepeatEntryBase::tr("Wed") ); 275 cmdExtra3->setText( RepeatEntryBase::tr("Wed") );
276 cmdExtra4->setText( RepeatEntryBase::tr("Thu") ); 276 cmdExtra4->setText( RepeatEntryBase::tr("Thu") );
277 cmdExtra5->setText( RepeatEntryBase::tr("Fri") ); 277 cmdExtra5->setText( RepeatEntryBase::tr("Fri") );
278 cmdExtra6->setText( RepeatEntryBase::tr("Sat") ); 278 cmdExtra6->setText( RepeatEntryBase::tr("Sat") );
279 cmdExtra7->setText( RepeatEntryBase::tr("Sun") ); 279 cmdExtra7->setText( RepeatEntryBase::tr("Sun") );
280 } else { 280 } else {
281 cmdExtra1->setText( RepeatEntryBase::tr("Sun") ); 281 cmdExtra1->setText( RepeatEntryBase::tr("Sun") );
282 cmdExtra2->setText( RepeatEntryBase::tr("Mon") ); 282 cmdExtra2->setText( RepeatEntryBase::tr("Mon") );
283 cmdExtra3->setText( RepeatEntryBase::tr("Tue") ); 283 cmdExtra3->setText( RepeatEntryBase::tr("Tue") );
284 cmdExtra4->setText( RepeatEntryBase::tr("Wed") ); 284 cmdExtra4->setText( RepeatEntryBase::tr("Wed") );
285 cmdExtra5->setText( RepeatEntryBase::tr("Thu") ); 285 cmdExtra5->setText( RepeatEntryBase::tr("Thu") );
286 cmdExtra6->setText( RepeatEntryBase::tr("Fri") ); 286 cmdExtra6->setText( RepeatEntryBase::tr("Fri") );
287 cmdExtra7->setText( RepeatEntryBase::tr("Sat") ); 287 cmdExtra7->setText( RepeatEntryBase::tr("Sat") );
288 } 288 }
289 // I hope clustering these improve performance.... 289 // I hope clustering these improve performance....
290 cmdExtra1->setOn( FALSE ); 290 cmdExtra1->setOn( FALSE );
291 cmdExtra2->setOn( FALSE ); 291 cmdExtra2->setOn( FALSE );
292 cmdExtra3->setOn( FALSE ); 292 cmdExtra3->setOn( FALSE );
293 cmdExtra4->setOn( FALSE ); 293 cmdExtra4->setOn( FALSE );
294 cmdExtra5->setOn( FALSE ); 294 cmdExtra5->setOn( FALSE );
295 cmdExtra6->setOn( FALSE ); 295 cmdExtra6->setOn( FALSE );
296 cmdExtra7->setOn( FALSE ); 296 cmdExtra7->setOn( FALSE );
297 297
298 cmdExtra1->show(); 298 cmdExtra1->show();
299 cmdExtra2->show(); 299 cmdExtra2->show();
300 cmdExtra3->show(); 300 cmdExtra3->show();
301 cmdExtra4->show(); 301 cmdExtra4->show();
302 cmdExtra5->show(); 302 cmdExtra5->show();
303 cmdExtra6->show(); 303 cmdExtra6->show();
304 cmdExtra7->show(); 304 cmdExtra7->show();
305 305
306 lblWeekVar->show(); 306 lblWeekVar->show();
307 spinFreq->setValue( 1 ); 307 spinFreq->setValue( 1 );
308 // might as well set the day too... 308 // might as well set the day too...
309 if ( startWeekOnMonday ) { 309 if ( startWeekOnMonday ) {
310 fraExtra->setButton( start.dayOfWeek() - 1 ); 310 fraExtra->setButton( start.dayOfWeek() - 1 );
311 } else { 311 } else {
312 fraExtra->setButton( start.dayOfWeek() % 7 ); 312 fraExtra->setButton( start.dayOfWeek() % 7 );
313 } 313 }
314 lblFreq->setText( tr("week(s)") ); 314 lblFreq->setText( tr("week(s)") );
315 lblVar2->show(); 315 lblVar2->show();
316 showRepeatStuff(); 316 showRepeatStuff();
317 setupRepeatLabel( 1 ); 317 setupRepeatLabel( 1 );
318} 318}
319 319
320void RepeatEntry::setupMonthly() 320void RepeatEntry::setupMonthly()
321{ 321{
322 hideExtras(); 322 hideExtras();
323 lblWeekVar->hide(); 323 lblWeekVar->hide();
324 fraExtra->setTitle( tr("Repeat By") ); 324 fraExtra->setTitle( tr("Repeat By") );
325 fraExtra->setExclusive( TRUE ); 325 fraExtra->setExclusive( TRUE );
326 fraExtra->show(); 326 fraExtra->show();
327 cmdExtra1->setText( tr("Day") ); 327 cmdExtra1->setText( tr("Day") );
328 cmdExtra1->show(); 328 cmdExtra1->show();
329 cmdExtra2->setText( tr("Date") ); 329 cmdExtra2->setText( tr("Date") );
330 cmdExtra2->show(); 330 cmdExtra2->show();
331 spinFreq->setValue( 1 ); 331 spinFreq->setValue( 1 );
332 lblFreq->setText( tr("month(s)") ); 332 lblFreq->setText( tr("month(s)") );
333 lblVar2->show(); 333 lblVar2->show();
334 showRepeatStuff(); 334 showRepeatStuff();
335 setupRepeatLabel( 1 ); 335 setupRepeatLabel( 1 );
336} 336}
337 337
338void RepeatEntry::setupYearly() 338void RepeatEntry::setupYearly()
339{ 339{
340 hideExtras(); 340 hideExtras();
341 lblWeekVar->hide(); 341 lblWeekVar->hide();
342 spinFreq->setValue( 1 ); 342 spinFreq->setValue( 1 );
343 lblFreq->setText( tr("year(s)") ); 343 lblFreq->setText( tr("year(s)") );
344 lblFreq->show(); 344 lblFreq->show();
345 lblFreq->show(); 345 lblFreq->show();
346 showRepeatStuff(); 346 showRepeatStuff();
347 lblVar2->show(); 347 lblVar2->show();
348 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); 348 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
349 lblRepeat->setText( strEvery ); 349 lblRepeat->setText( strEvery );
350 setupRepeatLabel( 1 ); 350 setupRepeatLabel( 1 );
351 351
352} 352}
353 353
354void RepeatEntry::init() 354void RepeatEntry::init()
355{ 355{
356 QPopupMenu *m1 = new QPopupMenu( this ); 356 QPopupMenu *m1 = new QPopupMenu( this );
357 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 357 repeatPicker = new DateBookMonth( m1, 0, TRUE );
358 m1->insertItem( repeatPicker ); 358 m1->insertItem( repeatPicker );
359 cmdEnd->setPopup( m1 ); 359 cmdEnd->setPopup( m1 );
360 cmdEnd->setPopupDelay( 0 ); 360 cmdEnd->setPopupDelay( 0 );
361 361
362 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), 362 QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)),
363 this, SLOT(endDateChanged(int, int, int)) ); 363 this, SLOT(endDateChanged(int,int,int)) );
364 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 364 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
365 this, SLOT(slotChangeStartOfWeek(bool)) ); 365 this, SLOT(slotChangeStartOfWeek(bool)) );
366 366
367 listRTypeButtons.setAutoDelete( TRUE ); 367 listRTypeButtons.setAutoDelete( TRUE );
368 listRTypeButtons.append( cmdNone ); 368 listRTypeButtons.append( cmdNone );
369 listRTypeButtons.append( cmdDay ); 369 listRTypeButtons.append( cmdDay );
370 listRTypeButtons.append( cmdWeek ); 370 listRTypeButtons.append( cmdWeek );
371 listRTypeButtons.append( cmdMonth ); 371 listRTypeButtons.append( cmdMonth );
372 listRTypeButtons.append( cmdYear ); 372 listRTypeButtons.append( cmdYear );
373 373
374 listExtra.setAutoDelete( TRUE ); 374 listExtra.setAutoDelete( TRUE );
375 listExtra.append( cmdExtra1 ); 375 listExtra.append( cmdExtra1 );
376 listExtra.append( cmdExtra2 ); 376 listExtra.append( cmdExtra2 );
377 listExtra.append( cmdExtra3 ); 377 listExtra.append( cmdExtra3 );
378 listExtra.append( cmdExtra4 ); 378 listExtra.append( cmdExtra4 );
379 listExtra.append( cmdExtra5 ); 379 listExtra.append( cmdExtra5 );
380 listExtra.append( cmdExtra6 ); 380 listExtra.append( cmdExtra6 );
381 listExtra.append( cmdExtra7 ); 381 listExtra.append( cmdExtra7 );
382} 382}
383 383
384void RepeatEntry::slotNoEnd( bool unused ) 384void RepeatEntry::slotNoEnd( bool unused )
385{ 385{
386 // if the item was toggled, then go ahead and set it to the maximum date 386 // if the item was toggled, then go ahead and set it to the maximum date
387 if ( unused ) { 387 if ( unused ) {
388 end.setYMD( 3000, 12, 31 ); 388 end.setYMD( 3000, 12, 31 );
389 cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); 389 cmdEnd->setText( RepeatEntryBase::tr("No End Date") );
390 } else { 390 } else {
391 end = start; 391 end = start;
392 cmdEnd->setText( TimeString::shortDate(end) ); 392 cmdEnd->setText( TimeString::shortDate(end) );
393 } 393 }
394} 394}
395 395
396void RepeatEntry::endDateChanged( int y, int m, int d ) 396void RepeatEntry::endDateChanged( int y, int m, int d )
397{ 397{
398 end.setYMD( y, m, d ); 398 end.setYMD( y, m, d );
399 if ( end < start ) 399 if ( end < start )
400 end = start; 400 end = start;
401 cmdEnd->setText( TimeString::shortDate( end ) ); 401 cmdEnd->setText( TimeString::shortDate( end ) );
402 repeatPicker->setDate( end.year(), end.month(), end.day() ); 402 repeatPicker->setDate( end.year(), end.month(), end.day() );
403} 403}
404 404
405void RepeatEntry::setupRepeatLabel( const QString &s ) 405void RepeatEntry::setupRepeatLabel( const QString &s )
406{ 406{
407 lblVar1->setText( s ); 407 lblVar1->setText( s );
408} 408}
409 409
410void RepeatEntry::setupRepeatLabel( int x ) 410void RepeatEntry::setupRepeatLabel( int x )
411{ 411{
412 // change the spelling based on the value of x 412 // change the spelling based on the value of x
413 QString strVar2; 413 QString strVar2;
414 414
415 if ( x > 1 ) 415 if ( x > 1 )
416 lblVar1->show(); 416 lblVar1->show();
417 else 417 else
418 lblVar1->hide(); 418 lblVar1->hide();
419 419
420 switch ( currInterval ) { 420 switch ( currInterval ) {
421 case NONE: 421 case NONE:
422 break; 422 break;
423 case DAY: 423 case DAY:
424 if ( x > 1 ) 424 if ( x > 1 )
425 strVar2 = tr( "days" ); 425 strVar2 = tr( "days" );
426 else 426 else
427 strVar2 = tr( "day" ); 427 strVar2 = tr( "day" );
428 break; 428 break;
429 case WEEK: 429 case WEEK:
430 if ( x > 1 ) 430 if ( x > 1 )
431 strVar2 = tr( "weeks" ); 431 strVar2 = tr( "weeks" );
432 else 432 else
433 strVar2 = tr( "week" ); 433 strVar2 = tr( "week" );
434 break; 434 break;
435 case MONTH: 435 case MONTH:
436 if ( x > 1 ) 436 if ( x > 1 )
437 strVar2 = RepeatEntryBase::tr( "months" ); 437 strVar2 = RepeatEntryBase::tr( "months" );
438 else 438 else
439 strVar2 = tr( "month" ); 439 strVar2 = tr( "month" );
440 break; 440 break;
441 case YEAR: 441 case YEAR:
442 if ( x > 1 ) 442 if ( x > 1 )
443 strVar2 = RepeatEntryBase::tr( "years" ); 443 strVar2 = RepeatEntryBase::tr( "years" );
444 else 444 else
445 strVar2 = tr( "year" ); 445 strVar2 = tr( "year" );
446 break; 446 break;
447 } 447 }
448 if ( !strVar2.isNull() ) 448 if ( !strVar2.isNull() )
449 lblVar2->setText( strVar2 ); 449 lblVar2->setText( strVar2 );
450} 450}
451 451
452void RepeatEntry::showRepeatStuff() 452void RepeatEntry::showRepeatStuff()
453{ 453{
454 cmdEnd->show(); 454 cmdEnd->show();
455 chkNoEnd->show(); 455 chkNoEnd->show();
456 lblFreq->show(); 456 lblFreq->show();
457 lblEvery->show(); 457 lblEvery->show();
458 lblFreq->show(); 458 lblFreq->show();
459 spinFreq->show(); 459 spinFreq->show();