summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp12
-rw-r--r--core/pim/datebook/dateentryimpl.cpp2
-rw-r--r--core/pim/datebook/timepicker.cpp1
3 files changed, 9 insertions, 6 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 2deb96f..97c305c 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -149,154 +149,153 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
149 a->setToggleAction( TRUE ); 149 a->setToggleAction( TRUE );
150 weekLstAction = a; 150 weekLstAction = a;
151 151
152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
154 a->addTo( sub_bar ); 154 a->addTo( sub_bar );
155 a->addTo( view ); 155 a->addTo( view );
156 a->setToggleAction( TRUE ); 156 a->setToggleAction( TRUE );
157 monthAction = a; 157 monthAction = a;
158 158
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
161 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
162 162
163 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
165 a->addTo( settings ); 165 a->addTo( settings );
166 166
167 QPopupMenu *default_view = new QPopupMenu(this); 167 QPopupMenu *default_view = new QPopupMenu(this);
168 settings->insertItem( tr( "Default View" ),default_view ); 168 settings->insertItem( tr( "Default View" ),default_view );
169 default_view->setCheckable(TRUE); 169 default_view->setCheckable(TRUE);
170 170
171 Config config("DateBook"); 171 Config config("DateBook");
172 config.setGroup("Main"); 172 config.setGroup("Main");
173 int current=config.readNumEntry("defaultview", DAY); 173 int current=config.readNumEntry("defaultview", DAY);
174 174
175 QActionGroup *ag = new QActionGroup(this); 175 QActionGroup *ag = new QActionGroup(this);
176 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); 176 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
177 if (current==DAY) a->setOn(true), viewDay(); 177 if (current==DAY) a->setOn(true), viewDay();
178 ag->insert(a); 178 ag->insert(a);
179 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); 179 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
180 if (current==WEEK) a->setOn(true), viewWeek(); 180 if (current==WEEK) a->setOn(true), viewWeek();
181 ag->insert(a); 181 ag->insert(a);
182 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); 182 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
183 if (current==WEEKLST) a->setOn(true), viewWeekLst(); 183 if (current==WEEKLST) a->setOn(true), viewWeekLst();
184 ag->insert(a); 184 ag->insert(a);
185 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); 185 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
186 if (current==MONTH) a->setOn(true), viewMonth(); 186 if (current==MONTH) a->setOn(true), viewMonth();
187 ag->insert(a); 187 ag->insert(a);
188 188
189 ag->addTo(default_view); 189 ag->addTo(default_view);
190 connect(ag, SIGNAL( selected ( QAction * ) ), 190 connect(ag, SIGNAL( selected ( QAction * ) ),
191 this, SLOT( newDefaultView(QAction *) ) 191 this, SLOT( newDefaultView(QAction *) )
192 ); 192 );
193 193
194 connect( qApp, SIGNAL(clockChanged(bool)), 194 connect( qApp, SIGNAL(clockChanged(bool)),
195 this, SLOT(changeClock(bool)) ); 195 this, SLOT(changeClock(bool)) );
196 connect( qApp, SIGNAL(weekChanged(bool)), 196 connect( qApp, SIGNAL(weekChanged(bool)),
197 this, SLOT(changeWeek(bool)) ); 197 this, SLOT(changeWeek(bool)) );
198 198
199#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 199#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
200 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 200 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
201 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 201 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
202#endif 202#endif
203 203
204 // listen on QPE/System 204 // listen on QPE/System
205#if defined(Q_WS_QWS) 205#if defined(Q_WS_QWS)
206#if !defined(QT_NO_COP) 206#if !defined(QT_NO_COP)
207 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 207 QCopChannel *channel = new QCopChannel( "QPE/System", this );
208 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 208 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
209 this, SLOT(receive(const QCString&, const QByteArray&)) ); 209 this, SLOT(receive(const QCString&, const QByteArray&)) );
210 channel = new QCopChannel( "QPE/Datebook", this ); 210 channel = new QCopChannel( "QPE/Datebook", this );
211 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 211 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
212 this, SLOT(receive(const QCString&, const QByteArray&)) ); 212 this, SLOT(receive(const QCString&, const QByteArray&)) );
213 qDebug("olle\n");
213#endif 214#endif
214#endif 215#endif
215 216
216 qDebug("done t=%d", t.elapsed() ); 217 qDebug("done t=%d", t.elapsed() );
217 218
218} 219}
219 220
220void DateBook::receive( const QCString &msg, const QByteArray &data ) 221void DateBook::receive( const QCString &msg, const QByteArray &data )
221{ 222{
222 QDataStream stream( data, IO_ReadOnly ); 223 QDataStream stream( data, IO_ReadOnly );
223 if ( msg == "timeChange(QString)" ) { 224 if ( msg == "timeChange(QString)" ) {
224 // update active view! 225 // update active view!
225 if ( dayAction->isOn() ) 226 if ( dayAction->isOn() )
226 viewDay(); 227 viewDay();
227 else if ( weekAction->isOn() ) 228 else if ( weekAction->isOn() )
228 viewWeek(); 229 viewWeek();
229 else if ( monthAction->isOn() ) 230 else if ( monthAction->isOn() )
230 viewMonth(); 231 viewMonth();
231 } 232 }
232 else if (msg == "editEvent(int)") { 233 else if (msg == "editEvent(int)") {
233 /* Not yet working... 234 int uid;
234 int uid; 235 stream >> uid;
235 stream >> uid; 236 Event e=db->getEvent(uid);
236 Event e=db->getEvent(uid); 237 editEvent(e);
237 editEvent(e);
238 */
239 } 238 }
240} 239}
241 240
242DateBook::~DateBook() 241DateBook::~DateBook()
243{ 242{
244} 243}
245 244
246void DateBook::slotSettings() 245void DateBook::slotSettings()
247{ 246{
248 DateBookSettings frmSettings( ampm, this ); 247 DateBookSettings frmSettings( ampm, this );
249 frmSettings.setStartTime( startTime ); 248 frmSettings.setStartTime( startTime );
250 frmSettings.setAlarmPreset( aPreset, presetTime ); 249 frmSettings.setAlarmPreset( aPreset, presetTime );
251#if defined (Q_WS_QWS) || defined(_WS_QWS_) 250#if defined (Q_WS_QWS) || defined(_WS_QWS_)
252 frmSettings.showMaximized(); 251 frmSettings.showMaximized();
253#endif 252#endif
254 253
255 if ( frmSettings.exec() ) { 254 if ( frmSettings.exec() ) {
256 aPreset = frmSettings.alarmPreset(); 255 aPreset = frmSettings.alarmPreset();
257 presetTime = frmSettings.presetTime(); 256 presetTime = frmSettings.presetTime();
258 startTime = frmSettings.startTime(); 257 startTime = frmSettings.startTime();
259 if ( dayView ) 258 if ( dayView )
260 dayView->setStartViewTime( startTime ); 259 dayView->setStartViewTime( startTime );
261 if ( weekView ) 260 if ( weekView )
262 weekView->setStartViewTime( startTime ); 261 weekView->setStartViewTime( startTime );
263 saveSettings(); 262 saveSettings();
264 263
265 // make the change obvious 264 // make the change obvious
266 if ( views->visibleWidget() ) { 265 if ( views->visibleWidget() ) {
267 if ( views->visibleWidget() == dayView ) 266 if ( views->visibleWidget() == dayView )
268 dayView->redraw(); 267 dayView->redraw();
269 else if ( views->visibleWidget() == weekView ) 268 else if ( views->visibleWidget() == weekView )
270 weekView->redraw(); 269 weekView->redraw();
271 } 270 }
272 } 271 }
273} 272}
274 273
275void DateBook::fileNew() 274void DateBook::fileNew()
276{ 275{
277 slotNewEventFromKey(""); 276 slotNewEventFromKey("");
278} 277}
279 278
280QString DateBook::checkEvent(const Event &e) 279QString DateBook::checkEvent(const Event &e)
281{ 280{
282 /* check if overlaps with itself */ 281 /* check if overlaps with itself */
283 bool checkFailed = FALSE; 282 bool checkFailed = FALSE;
284 283
285 /* check the next 12 repeats. should catch most problems */ 284 /* check the next 12 repeats. should catch most problems */
286 QDate current_date = e.start().date(); 285 QDate current_date = e.start().date();
287 Event previous = e; 286 Event previous = e;
288 for(int i = 0; i < 12; i++) 287 for(int i = 0; i < 12; i++)
289 { 288 {
290 QDateTime next; 289 QDateTime next;
291 if (!nextOccurance(previous, current_date.addDays(1), next)) { 290 if (!nextOccurance(previous, current_date.addDays(1), next)) {
292 break; // no more repeats 291 break; // no more repeats
293 } 292 }
294 if(next < previous.end()) { 293 if(next < previous.end()) {
295 checkFailed = TRUE; 294 checkFailed = TRUE;
296 break; 295 break;
297 } 296 }
298 current_date = next.date(); 297 current_date = next.date();
299 } 298 }
300 299
301 if(checkFailed) 300 if(checkFailed)
302 return tr("Event duration is potentially longer\n" 301 return tr("Event duration is potentially longer\n"
@@ -340,128 +339,129 @@ void DateBook::view(int v, const QDate &d) {
340 weekLstAction->setOn( TRUE ); 339 weekLstAction->setOn( TRUE );
341 weekLstView->setDate(d); 340 weekLstView->setDate(d);
342 views->raiseWidget( weekLstView ); 341 views->raiseWidget( weekLstView );
343 weekLstView->redraw(); 342 weekLstView->redraw();
344 } else if (v==MONTH) { 343 } else if (v==MONTH) {
345 initMonth(); 344 initMonth();
346 monthAction->setOn( TRUE ); 345 monthAction->setOn( TRUE );
347 monthView->setDate( d.year(), d.month(), d.day() ); 346 monthView->setDate( d.year(), d.month(), d.day() );
348 views->raiseWidget( monthView ); 347 views->raiseWidget( monthView );
349 monthView->redraw(); 348 monthView->redraw();
350 } 349 }
351} 350}
352 351
353void DateBook::viewDefault(const QDate &d) { 352void DateBook::viewDefault(const QDate &d) {
354 Config config("DateBook"); 353 Config config("DateBook");
355 config.setGroup("Main"); 354 config.setGroup("Main");
356 int current=config.readNumEntry("defaultview", DAY); 355 int current=config.readNumEntry("defaultview", DAY);
357 356
358 view(current,d); 357 view(current,d);
359} 358}
360 359
361void DateBook::viewDay() { 360void DateBook::viewDay() {
362 view(DAY,currentDate()); 361 view(DAY,currentDate());
363} 362}
364 363
365void DateBook::viewWeek() { 364void DateBook::viewWeek() {
366 view(WEEK,currentDate()); 365 view(WEEK,currentDate());
367} 366}
368 367
369void DateBook::viewWeekLst() { 368void DateBook::viewWeekLst() {
370 view(WEEKLST,currentDate()); 369 view(WEEKLST,currentDate());
371} 370}
372 371
373void DateBook::viewMonth() { 372void DateBook::viewMonth() {
374 view(MONTH,currentDate()); 373 view(MONTH,currentDate());
375} 374}
376 375
377void DateBook::editEvent( const Event &e ) 376void DateBook::editEvent( const Event &e )
378{ 377{
379 if (syncing) { 378 if (syncing) {
380 QMessageBox::warning( this, tr("Calendar"), 379 QMessageBox::warning( this, tr("Calendar"),
381 tr( "Can not edit data, currently syncing") ); 380 tr( "Can not edit data, currently syncing") );
382 return; 381 return;
383 } 382 }
384 383
385 // workaround added for text input. 384 // workaround added for text input.
386 QDialog editDlg( this, 0, TRUE ); 385 QDialog editDlg( this, 0, TRUE );
387 DateEntry *entry; 386 DateEntry *entry;
388 editDlg.setCaption( tr("Edit Event") ); 387 editDlg.setCaption( tr("Edit Event") );
389 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 388 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
390 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 389 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
391 sv->setResizePolicy( QScrollView::AutoOneFit ); 390 sv->setResizePolicy( QScrollView::AutoOneFit );
392 // KLUDGE!!! 391 // KLUDGE!!!
393 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 392 sv->setHScrollBarMode( QScrollView::AlwaysOff );
394 vb->addWidget( sv ); 393 vb->addWidget( sv );
395 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 394 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
396 entry->timezone->setEnabled( FALSE ); 395 entry->timezone->setEnabled( FALSE );
397 sv->addChild( entry ); 396 sv->addChild( entry );
398 397
399#if defined(Q_WS_QWS) || defined(_WS_QWS_) 398#if defined(Q_WS_QWS) || defined(_WS_QWS_)
400 editDlg.showMaximized(); 399 editDlg.showMaximized();
401#endif 400#endif
402 while (editDlg.exec() ) { 401 while (editDlg.exec() ) {
403 Event newEv = entry->event(); 402 Event newEv = entry->event();
403 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
404 QString error = checkEvent(newEv); 404 QString error = checkEvent(newEv);
405 if (!error.isNull()) { 405 if (!error.isNull()) {
406 if (QMessageBox::warning(this, "error box", 406 if (QMessageBox::warning(this, "error box",
407 error, "Fix it", "Continue", 407 error, "Fix it", "Continue",
408 0, 0, 1) == 0) 408 0, 0, 1) == 0)
409 continue; 409 continue;
410 } 410 }
411 db->editEvent(e, newEv); 411 db->editEvent(e, newEv);
412 emit newEvent(); 412 emit newEvent();
413 break; 413 break;
414 } 414 }
415} 415}
416 416
417void DateBook::removeEvent( const Event &e ) 417void DateBook::removeEvent( const Event &e )
418{ 418{
419 if (syncing) { 419 if (syncing) {
420 QMessageBox::warning( this, tr("Calendar"), 420 QMessageBox::warning( this, tr("Calendar"),
421 tr( "Can not edit data, currently syncing") ); 421 tr( "Can not edit data, currently syncing") );
422 return; 422 return;
423 } 423 }
424 424
425 QString strName = e.description(); 425 QString strName = e.description();
426 426
427 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 427 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
428 return; 428 return;
429 429
430 db->removeEvent( e ); 430 db->removeEvent( e );
431 if ( views->visibleWidget() == dayView && dayView ) 431 if ( views->visibleWidget() == dayView && dayView )
432 dayView->redraw(); 432 dayView->redraw();
433} 433}
434 434
435void DateBook::addEvent( const Event &e ) 435void DateBook::addEvent( const Event &e )
436{ 436{
437 QDate d = e.start().date(); 437 QDate d = e.start().date();
438 initDay(); 438 initDay();
439 dayView->setDate( d ); 439 dayView->setDate( d );
440} 440}
441 441
442void DateBook::showDay( int year, int month, int day ) 442void DateBook::showDay( int year, int month, int day )
443{ 443{
444 QDate d(year, month, day); 444 QDate d(year, month, day);
445 view(DAY,d); 445 view(DAY,d);
446} 446}
447 447
448void DateBook::initDay() 448void DateBook::initDay()
449{ 449{
450 if ( !dayView ) { 450 if ( !dayView ) {
451 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 451 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
452 views->addWidget( dayView, DAY ); 452 views->addWidget( dayView, DAY );
453 dayView->setStartViewTime( startTime ); 453 dayView->setStartViewTime( startTime );
454 connect( this, SIGNAL( newEvent() ), 454 connect( this, SIGNAL( newEvent() ),
455 dayView, SLOT( redraw() ) ); 455 dayView, SLOT( redraw() ) );
456 connect( dayView, SIGNAL( newEvent() ), 456 connect( dayView, SIGNAL( newEvent() ),
457 this, SLOT( fileNew() ) ); 457 this, SLOT( fileNew() ) );
458 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 458 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
459 this, SLOT( removeEvent( const Event & ) ) ); 459 this, SLOT( removeEvent( const Event & ) ) );
460 connect( dayView, SIGNAL( editEvent( const Event & ) ), 460 connect( dayView, SIGNAL( editEvent( const Event & ) ),
461 this, SLOT( editEvent( const Event & ) ) ); 461 this, SLOT( editEvent( const Event & ) ) );
462 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 462 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
463 this, SLOT( beamEvent( const Event & ) ) ); 463 this, SLOT( beamEvent( const Event & ) ) );
464 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 464 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
465 this, SLOT(slotNewEventFromKey(const QString &)) ); 465 this, SLOT(slotNewEventFromKey(const QString &)) );
466 } 466 }
467} 467}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 1c43363..e563db0 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -52,130 +52,132 @@
52 * The dialog will by default be modeless, unless you set 'modal' to 52 * The dialog will by default be modeless, unless you set 'modal' to
53 * TRUE to construct a modal dialog. 53 * TRUE to construct a modal dialog.
54 */ 54 */
55 55
56DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 56DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
57 const QDateTime &end, bool whichClock, QWidget* parent, 57 const QDateTime &end, bool whichClock, QWidget* parent,
58 const char* name ) 58 const char* name )
59 : DateEntryBase( parent, name ), 59 : DateEntryBase( parent, name ),
60 ampm( whichClock ), 60 ampm( whichClock ),
61 startWeekOnMonday( startOnMonday ) 61 startWeekOnMonday( startOnMonday )
62{ 62{
63 init(); 63 init();
64 setDates(start,end); 64 setDates(start,end);
65 setFocusProxy(comboDescription); 65 setFocusProxy(comboDescription);
66} 66}
67 67
68static void addOrPick( QComboBox* combo, const QString& t ) 68static void addOrPick( QComboBox* combo, const QString& t )
69{ 69{
70 // Pick an item if one excists 70 // Pick an item if one excists
71 for (int i=0; i<combo->count(); i++) { 71 for (int i=0; i<combo->count(); i++) {
72 if ( combo->text(i) == t ) { 72 if ( combo->text(i) == t ) {
73 combo->setCurrentItem(i); 73 combo->setCurrentItem(i);
74 return; 74 return;
75 } 75 }
76 } 76 }
77 77
78 // Else add one 78 // Else add one
79 combo->insertItem(t); 79 combo->insertItem(t);
80 combo->setCurrentItem(combo->count()-1); 80 combo->setCurrentItem(combo->count()-1);
81} 81}
82 82
83DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 83DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
84 QWidget* parent, const char* name ) 84 QWidget* parent, const char* name )
85 : DateEntryBase( parent, name ), 85 : DateEntryBase( parent, name ),
86 ampm( whichClock ), 86 ampm( whichClock ),
87 startWeekOnMonday( startOnMonday ) 87 startWeekOnMonday( startOnMonday )
88{ 88{
89 init(); 89 init();
90 setDates(event.start(),event.end()); 90 setDates(event.start(),event.end());
91 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 91 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
92 if(!event.description().isEmpty()) 92 if(!event.description().isEmpty())
93 addOrPick( comboDescription, event.description() ); 93 addOrPick( comboDescription, event.description() );
94 if(!event.location().isEmpty()) 94 if(!event.location().isEmpty())
95 addOrPick( comboLocation, event.location() ); 95 addOrPick( comboLocation, event.location() );
96 checkAlarm->setChecked( event.hasAlarm() ); 96 checkAlarm->setChecked( event.hasAlarm() );
97 checkAllDay->setChecked( event.type() == Event::AllDay ); 97 checkAllDay->setChecked( event.type() == Event::AllDay );
98 if(!event.notes().isEmpty()) 98 if(!event.notes().isEmpty())
99 editNote->setText(event.notes()); 99 editNote->setText(event.notes());
100 spinAlarm->setValue(event.alarmTime()); 100 spinAlarm->setValue(event.alarmTime());
101 if ( event.alarmSound() != Event::Silent ) 101 if ( event.alarmSound() != Event::Silent )
102 comboSound->setCurrentItem( 1 ); 102 comboSound->setCurrentItem( 1 );
103 if ( event.hasRepeat() ) { 103 if ( event.hasRepeat() ) {
104 rp = event.repeatPattern(); 104 rp = event.repeatPattern();
105 cmdRepeat->setText( tr("Repeat...") ); 105 cmdRepeat->setText( tr("Repeat...") );
106 } 106 }
107 setRepeatLabel(); 107 setRepeatLabel();
108} 108}
109 109
110void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 110void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
111{ 111{
112 startDate = s.date(); 112 startDate = s.date();
113 endDate = e.date(); 113 endDate = e.date();
114 startTime = s.time(); 114 startTime = s.time();
115 endTime = e.time(); 115 endTime = e.time();
116
116 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 117 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
117 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 118 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
119
118 updateTimeEdit(true,true); 120 updateTimeEdit(true,true);
119} 121}
120 122
121void DateEntry::updateTimeEdit(bool s, bool e) { 123void DateEntry::updateTimeEdit(bool s, bool e) {
122 124
123 // Comboboxes 125 // Comboboxes
124 QString strStart, strEnd; 126 QString strStart, strEnd;
125 int shour, ehour; 127 int shour, ehour;
126 if ( ampm ) { 128 if ( ampm ) {
127 shour = startTime.hour(); 129 shour = startTime.hour();
128 ehour = endTime.hour(); 130 ehour = endTime.hour();
129 if ( shour >= 12 ) { 131 if ( shour >= 12 ) {
130 if ( shour > 12 ) 132 if ( shour > 12 )
131 shour -= 12; 133 shour -= 12;
132 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 134 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
133 } else { 135 } else {
134 if ( shour == 0 ) 136 if ( shour == 0 )
135 shour = 12; 137 shour = 12;
136 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 138 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
137 } 139 }
138 if ( ehour == 24 && endTime.minute() == 0 ) { 140 if ( ehour == 24 && endTime.minute() == 0 ) {
139 strEnd = "11:59 PM"; // or "midnight" 141 strEnd = "11:59 PM"; // or "midnight"
140 } else if ( ehour >= 12 ) { 142 } else if ( ehour >= 12 ) {
141 if ( ehour > 12 ) 143 if ( ehour > 12 )
142 ehour -= 12; 144 ehour -= 12;
143 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 145 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
144 } else { 146 } else {
145 if ( ehour == 0 ) 147 if ( ehour == 0 )
146 ehour = 12; 148 ehour = 12;
147 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 149 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
148 } 150 }
149 } else { 151 } else {
150 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 152 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
151 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 153 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
152 } 154 }
153 155
154 if (s) comboStart->setText(strStart); 156 if (s) comboStart->setText(strStart);
155 if (e) comboEnd->setText(strEnd); 157 if (e) comboEnd->setText(strEnd);
156} 158}
157 159
158void DateEntry::init() 160void DateEntry::init()
159{ 161{
160 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 162 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
161 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 163 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
162 164
163 initCombos(); 165 initCombos();
164 QPopupMenu *m1 = new QPopupMenu( this ); 166 QPopupMenu *m1 = new QPopupMenu( this );
165 startPicker = new DateBookMonth( m1, 0, TRUE ); 167 startPicker = new DateBookMonth( m1, 0, TRUE );
166 m1->insertItem( startPicker ); 168 m1->insertItem( startPicker );
167 buttonStart->setPopup( m1 ); 169 buttonStart->setPopup( m1 );
168 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 170 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
169 this, SLOT( startDateChanged( int, int, int ) ) ); 171 this, SLOT( startDateChanged( int, int, int ) ) );
170 172
171 //Let start button change both start and end dates 173 //Let start button change both start and end dates
172 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 174 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
173 this, SLOT( endDateChanged( int, int, int ) ) ); 175 this, SLOT( endDateChanged( int, int, int ) ) );
174 connect( qApp, SIGNAL( clockChanged( bool ) ), 176 connect( qApp, SIGNAL( clockChanged( bool ) ),
175 this, SLOT( slotChangeClock( bool ) ) ); 177 this, SLOT( slotChangeClock( bool ) ) );
176 connect( qApp, SIGNAL(weekChanged(bool)), 178 connect( qApp, SIGNAL(weekChanged(bool)),
177 this, SLOT(slotChangeStartOfWeek(bool)) ); 179 this, SLOT(slotChangeStartOfWeek(bool)) );
178 180
179 QPopupMenu *m2 = new QPopupMenu( this ); 181 QPopupMenu *m2 = new QPopupMenu( this );
180 endPicker = new DateBookMonth( m2, 0, TRUE ); 182 endPicker = new DateBookMonth( m2, 0, TRUE );
181 m2->insertItem( endPicker ); 183 m2->insertItem( endPicker );
diff --git a/core/pim/datebook/timepicker.cpp b/core/pim/datebook/timepicker.cpp
index 5f08a05..9097e1b 100644
--- a/core/pim/datebook/timepicker.cpp
+++ b/core/pim/datebook/timepicker.cpp
@@ -1,71 +1,72 @@
1#include "timepicker.h" 1#include "timepicker.h"
2 2
3#include <qbuttongroup.h> 3#include <qbuttongroup.h>
4#include <qtoolbutton.h> 4#include <qtoolbutton.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include "clickablelabel.h" 6#include "clickablelabel.h"
7#include <qstring.h> 7#include <qstring.h>
8#include <stdio.h>
8 9
9TimePicker::TimePicker(QWidget* parent = 0, const char* name = 0, 10TimePicker::TimePicker(QWidget* parent = 0, const char* name = 0,
10 WFlags fl = 0) : 11 WFlags fl = 0) :
11 QWidget(parent,name,fl) 12 QWidget(parent,name,fl)
12{ 13{
13 QVBoxLayout *vbox=new QVBoxLayout(this); 14 QVBoxLayout *vbox=new QVBoxLayout(this);
14 15
15 ClickableLabel *r; 16 ClickableLabel *r;
16 QString s; 17 QString s;
17 18
18 // Hour Row 19 // Hour Row
19 QWidget *row=new QWidget(this); 20 QWidget *row=new QWidget(this);
20 QHBoxLayout *l=new QHBoxLayout(row); 21 QHBoxLayout *l=new QHBoxLayout(row);
21 vbox->addWidget(row); 22 vbox->addWidget(row);
22 23
23 24
24 for (int i=0; i<24; i++) { 25 for (int i=0; i<24; i++) {
25 r=new ClickableLabel(row); 26 r=new ClickableLabel(row);
26 hourLst.append(r); 27 hourLst.append(r);
27 s.sprintf("%.2d",i); 28 s.sprintf("%.2d",i);
28 r->setText(s); 29 r->setText(s);
29 r->setToggleButton(true); 30 r->setToggleButton(true);
30 r->setAlignment(AlignHCenter | AlignVCenter); 31 r->setAlignment(AlignHCenter | AlignVCenter);
31 l->addWidget(r); 32 l->addWidget(r);
32 connect(r, SIGNAL(toggled(bool)), 33 connect(r, SIGNAL(toggled(bool)),
33 this, SLOT(slotHour(bool))); 34 this, SLOT(slotHour(bool)));
34 35
35 if (i==11) { // Second row 36 if (i==11) { // Second row
36 row=new QWidget(this); 37 row=new QWidget(this);
37 l=new QHBoxLayout(row); 38 l=new QHBoxLayout(row);
38 vbox->addWidget(row); 39 vbox->addWidget(row);
39 } 40 }
40 } 41 }
41 42
42 // Minute Row 43 // Minute Row
43 row=new QWidget(this); 44 row=new QWidget(this);
44 l=new QHBoxLayout(row); 45 l=new QHBoxLayout(row);
45 vbox->addWidget(row); 46 vbox->addWidget(row);
46 47
47 for (int i=0; i<60; i+=5) { 48 for (int i=0; i<60; i+=5) {
48 r=new ClickableLabel(row); 49 r=new ClickableLabel(row);
49 minuteLst.append(r); 50 minuteLst.append(r);
50 s.sprintf("%.2d",i); 51 s.sprintf("%.2d",i);
51 r->setText(s); 52 r->setText(s);
52 r->setToggleButton(true); 53 r->setToggleButton(true);
53 r->setAlignment(AlignHCenter | AlignVCenter); 54 r->setAlignment(AlignHCenter | AlignVCenter);
54 l->addWidget(r); 55 l->addWidget(r);
55 connect(r, SIGNAL(toggled(bool)), 56 connect(r, SIGNAL(toggled(bool)),
56 this, SLOT(slotMinute(bool))); 57 this, SLOT(slotMinute(bool)));
57 } 58 }
58} 59}
59 60
60void TimePicker::slotHour(bool b) { 61void TimePicker::slotHour(bool b) {
61 62
62 ClickableLabel *r = (ClickableLabel *) sender(); 63 ClickableLabel *r = (ClickableLabel *) sender();
63 64
64 if (b) { 65 if (b) {
65 QValueListIterator<ClickableLabel *> it; 66 QValueListIterator<ClickableLabel *> it;
66 for (it=hourLst.begin(); it!=hourLst.end(); it++) { 67 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
67 if (*it != r) (*it)->setOn(false); 68 if (*it != r) (*it)->setOn(false);
68 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); 69 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
69 } 70 }
70 emit timeChanged(tm); 71 emit timeChanged(tm);
71 } else { 72 } else {