Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 36 |
1 files changed, 17 insertions, 19 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 | |||
@@ -116,106 +116,106 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
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 | ||
200 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 200 | void 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 | } |
@@ -472,150 +472,150 @@ void DateBook::editEvent( const Event &e ) | |||
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 | ||
479 | void DateBook::removeEvent( const Event &e ) | 479 | void 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 | ||
497 | void DateBook::addEvent( const Event &e ) | 497 | void 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 | ||
504 | void DateBook::showDay( int year, int month, int day ) | 504 | void 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 | ||
510 | void DateBook::initDay() | 510 | void 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 | ||
528 | void DateBook::initWeek() | 528 | void 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 | ||
553 | void DateBook::initWeekLst() { | 553 | void 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 | ||
568 | void DateBook::initMonth() | 568 | void 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 | ||
579 | void DateBook::loadSettings() | 579 | void 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 | ||
607 | void DateBook::saveSettings() | 607 | void 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; |
@@ -860,120 +860,118 @@ void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const | |||
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 | ||
889 | void DateBook::setDocument( const QString &filename ) | 889 | void 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 | ||
899 | static const char * beamfile = "/tmp/obex/event.vcs"; | 899 | static const char * beamfile = "/tmp/obex/event.vcs"; |
900 | 900 | ||
901 | void DateBook::beamEvent( const Event &e ) | 901 | void 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 | ||
913 | void DateBook::beamDone( Ir *ir ) | 913 | void DateBook::beamDone( Ir *ir ) |
914 | { | 914 | { |
915 | delete ir; | 915 | delete ir; |
916 | unlink( beamfile ); | 916 | unlink( beamfile ); |
917 | } | 917 | } |
918 | 918 | ||
919 | void DateBook::slotFind() | 919 | void 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 | ||
945 | bool catComp( QArray<int> cats, int category ) | 943 | bool 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 | ||
967 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, | 965 | void 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 ) { |