Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 106 |
1 files changed, 41 insertions, 65 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index cf1eeca..b7e89b0 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -91,87 +91,90 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
92 | 92 | ||
93 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
94 | 94 | ||
95 | views = new QWidgetStack( this ); | 95 | views = new QWidgetStack( this ); |
96 | setCentralWidget( views ); | 96 | setCentralWidget( views ); |
97 | 97 | ||
98 | dayView = 0; | 98 | dayView = 0; |
99 | weekView = 0; | 99 | weekView = 0; |
100 | weekLstView = 0; | 100 | weekLstView = 0; |
101 | monthView = 0; | 101 | monthView = 0; |
102 | 102 | ||
103 | QPEToolBar *bar = new QPEToolBar( this ); | 103 | // QPEToolBar *bar = new QPEToolBar( this ); |
104 | bar->setHorizontalStretchable( TRUE ); | 104 | // bar->setHorizontalStretchable( TRUE ); |
105 | 105 | ||
106 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 106 | // QPEMenuBar *mb = new QPEMenuBar( bar ); |
107 | mb->setMargin( 0 ); | 107 | // mb->setMargin( 0 ); |
108 | 108 | ||
109 | QPEToolBar *sub_bar = new QPEToolBar(this); | 109 | // QPopupMenu *view = new QPopupMenu( this ); |
110 | 110 | // mb->insertItem( tr( "View" ), view ); | |
111 | QPopupMenu *view = new QPopupMenu( this ); | ||
112 | QPopupMenu *settings = new QPopupMenu( this ); | ||
113 | 111 | ||
114 | mb->insertItem( tr( "View" ), view ); | 112 | QPEToolBar *sub_bar = new QPEToolBar(this); |
115 | mb->insertItem( tr( "Settings" ), settings ); | 113 | sub_bar->setHorizontalStretchable(TRUE); |
116 | 114 | ||
117 | QActionGroup *g = new QActionGroup( this ); | 115 | QActionGroup *g = new QActionGroup( this ); |
118 | g->setExclusive( TRUE ); | 116 | g->setExclusive( TRUE ); |
119 | 117 | ||
120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
121 | QString::null, 0, this, 0 ); | ||
122 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
123 | a->addTo( sub_bar ); | 120 | a->addTo( sub_bar ); |
124 | 121 | ||
122 | sub_bar->addSeparator(); | ||
123 | |||
125 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
127 | a->addTo( sub_bar ); | 126 | a->addTo( sub_bar ); |
128 | a->addTo( view ); | 127 | //a->addTo( view ); |
128 | |||
129 | sub_bar->addSeparator(); | ||
129 | 130 | ||
130 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
131 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
132 | a->addTo( sub_bar ); | 133 | a->addTo( sub_bar ); |
133 | a->addTo( view ); | 134 | // a->addTo( view ); |
134 | a->setToggleAction( TRUE ); | 135 | a->setToggleAction( TRUE ); |
135 | a->setOn( TRUE ); | 136 | a->setOn( TRUE ); |
136 | dayAction = a; | 137 | dayAction = a; |
137 | 138 | ||
138 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
139 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
140 | a->addTo( sub_bar ); | 141 | a->addTo( sub_bar ); |
141 | a->addTo( view ); | 142 | // a->addTo( view ); |
142 | a->setToggleAction( TRUE ); | 143 | a->setToggleAction( TRUE ); |
143 | weekAction = a; | 144 | weekAction = a; |
144 | 145 | ||
145 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
146 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
147 | a->addTo( sub_bar ); | 148 | a->addTo( sub_bar ); |
148 | a->addTo( view ); | 149 | // a->addTo( view ); |
149 | a->setToggleAction( TRUE ); | 150 | a->setToggleAction( TRUE ); |
150 | weekLstAction = a; | 151 | weekLstAction = a; |
151 | 152 | ||
152 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
153 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
154 | a->addTo( sub_bar ); | 155 | a->addTo( sub_bar ); |
155 | a->addTo( view ); | 156 | // a->addTo( view ); |
156 | a->setToggleAction( TRUE ); | 157 | a->setToggleAction( TRUE ); |
157 | monthAction = a; | 158 | monthAction = a; |
158 | 159 | ||
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); | 160 | sub_bar->addSeparator(); |
161 | |||
162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | ||
160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
161 | a->addTo( sub_bar ); | 164 | a->addTo( sub_bar ); |
162 | 165 | ||
163 | a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); | 166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
165 | a->addTo( settings ); | 168 | a->addTo( sub_bar ); |
166 | 169 | ||
167 | if(defaultView==DAY) viewDay(); | 170 | if(defaultView==DAY) viewDay(); |
168 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); |
169 | if(defaultView==WEEKLST) viewWeekLst(); | 172 | if(defaultView==WEEKLST) viewWeekLst(); |
170 | if(defaultView==MONTH) viewMonth(); | 173 | if(defaultView==MONTH) viewMonth(); |
171 | 174 | ||
172 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
173 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
174 | 177 | ||
175 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
176 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
177 | #endif | 180 | #endif |
@@ -364,31 +367,24 @@ void DateBook::view(int v, const QDate &d) { | |||
364 | views->raiseWidget( weekLstView ); | 367 | views->raiseWidget( weekLstView ); |
365 | weekLstView->redraw(); | 368 | weekLstView->redraw(); |
366 | } else if (v==MONTH) { | 369 | } else if (v==MONTH) { |
367 | initMonth(); | 370 | initMonth(); |
368 | monthAction->setOn( TRUE ); | 371 | monthAction->setOn( TRUE ); |
369 | monthView->setDate( d.year(), d.month(), d.day() ); | 372 | monthView->setDate( d.year(), d.month(), d.day() ); |
370 | views->raiseWidget( monthView ); | 373 | views->raiseWidget( monthView ); |
371 | monthView->redraw(); | 374 | monthView->redraw(); |
372 | } | 375 | } |
373 | } | 376 | } |
374 | 377 | ||
375 | void DateBook::viewDefault(const QDate &d) { | 378 | void DateBook::viewDefault(const QDate &d) { |
376 | /* | ||
377 | Config config("DateBook"); | ||
378 | config.setGroup("Main"); | ||
379 | int current=config.readNumEntry("defaultview", DAY); | ||
380 | |||
381 | view(current,d); | ||
382 | */ | ||
383 | view(defaultView,d); | 379 | view(defaultView,d); |
384 | } | 380 | } |
385 | 381 | ||
386 | void DateBook::viewDay() { | 382 | void DateBook::viewDay() { |
387 | view(DAY,currentDate()); | 383 | view(DAY,currentDate()); |
388 | } | 384 | } |
389 | 385 | ||
390 | void DateBook::viewWeek() { | 386 | void DateBook::viewWeek() { |
391 | view(WEEK,currentDate()); | 387 | view(WEEK,currentDate()); |
392 | } | 388 | } |
393 | 389 | ||
394 | void DateBook::viewWeekLst() { | 390 | void DateBook::viewWeekLst() { |
@@ -517,102 +513,81 @@ void DateBook::showDay( int year, int month, int day ) | |||
517 | QDate d(year, month, day); | 513 | QDate d(year, month, day); |
518 | view(DAY,d); | 514 | view(DAY,d); |
519 | } | 515 | } |
520 | 516 | ||
521 | void DateBook::initDay() | 517 | void DateBook::initDay() |
522 | { | 518 | { |
523 | if ( !dayView ) { | 519 | if ( !dayView ) { |
524 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 520 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
525 | views->addWidget( dayView, DAY ); | 521 | views->addWidget( dayView, DAY ); |
526 | dayView->setStartViewTime( startTime ); | 522 | dayView->setStartViewTime( startTime ); |
527 | dayView->setJumpToCurTime( bJumpToCurTime ); | 523 | dayView->setJumpToCurTime( bJumpToCurTime ); |
528 | dayView->setRowStyle( rowStyle ); | 524 | dayView->setRowStyle( rowStyle ); |
529 | connect( this, SIGNAL( newEvent() ), | 525 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
530 | dayView, SLOT( redraw() ) ); | 526 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
531 | connect( dayView, SIGNAL( newEvent() ), | 527 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); |
532 | this, SLOT( fileNew() ) ); | 528 | connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
533 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 529 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); |
534 | this, SLOT( removeEvent( const Event & ) ) ); | 530 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); |
535 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 531 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); |
536 | this, SLOT( editEvent( const Event & ) ) ); | ||
537 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), | ||
538 | this, SLOT( duplicateEvent( const Event & ) ) ); | ||
539 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | ||
540 | this, SLOT( beamEvent( const Event & ) ) ); | ||
541 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | ||
542 | this, SLOT(slotNewEventFromKey(const QString &)) ); | ||
543 | } | 532 | } |
544 | } | 533 | } |
545 | 534 | ||
546 | void DateBook::initWeek() | 535 | void DateBook::initWeek() |
547 | { | 536 | { |
548 | if ( !weekView ) { | 537 | if ( !weekView ) { |
549 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 538 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
550 | weekView->setStartViewTime( startTime ); | 539 | weekView->setStartViewTime( startTime ); |
551 | views->addWidget( weekView, WEEK ); | 540 | views->addWidget( weekView, WEEK ); |
552 | connect( weekView, SIGNAL( showDate( int, int, int ) ), | 541 | connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
553 | this, SLOT( showDay( int, int, int ) ) ); | 542 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
554 | connect( this, SIGNAL( newEvent() ), | ||
555 | weekView, SLOT( redraw() ) ); | ||
556 | } | 543 | } |
557 | 544 | ||
558 | //But also get it right: the year that we display can be different | 545 | //But also get it right: the year that we display can be different |
559 | //from the year of the current date. So, first find the year | 546 | //from the year of the current date. So, first find the year |
560 | //number of the current week. | 547 | //number of the current week. |
561 | int yearNumber, totWeeks; | 548 | int yearNumber, totWeeks; |
562 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 549 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
563 | 550 | ||
564 | QDate d = QDate( yearNumber, 12, 31 ); | 551 | QDate d = QDate( yearNumber, 12, 31 ); |
565 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 552 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
566 | 553 | ||
567 | while ( totWeeks == 1 ) { | 554 | while ( totWeeks == 1 ) { |
568 | d = d.addDays( -1 ); | 555 | d = d.addDays( -1 ); |
569 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 556 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
570 | } | 557 | } |
571 | if ( totWeeks != weekView->totalWeeks() ) | ||
572 | weekView->setTotalWeeks( totWeeks ); | ||
573 | } | 558 | } |
574 | 559 | ||
575 | void DateBook::initWeekLst() { | 560 | void DateBook::initWeekLst() { |
576 | if ( !weekLstView ) { | 561 | if ( !weekLstView ) { |
577 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 562 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
578 | views, "weeklst view" ); | ||
579 | views->addWidget( weekLstView, WEEKLST ); | 563 | views->addWidget( weekLstView, WEEKLST ); |
580 | 564 | ||
581 | //weekLstView->setStartViewTime( startTime ); | 565 | //weekLstView->setStartViewTime( startTime ); |
582 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 566 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
583 | this, SLOT( showDay( int, int, int ) ) ); | 567 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), |
584 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 568 | this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); |
585 | const QDateTime &, | 569 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
586 | const QString & , const QString &) ), | 570 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
587 | this, SLOT( slotNewEntry( const QDateTime &, | ||
588 | const QDateTime &, | ||
589 | const QString & , const QString &) ) ); | ||
590 | connect( this, SIGNAL( newEvent() ), | ||
591 | weekLstView, SLOT( redraw() ) ); | ||
592 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | ||
593 | this, SLOT( editEvent( const Event & ) ) ); | ||
594 | } | 571 | } |
595 | } | 572 | } |
596 | 573 | ||
597 | 574 | ||
598 | void DateBook::initMonth() | 575 | void DateBook::initMonth() |
599 | { | 576 | { |
600 | if ( !monthView ) { | 577 | if ( !monthView ) { |
601 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 578 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
602 | views->addWidget( monthView, MONTH ); | 579 | views->addWidget( monthView, MONTH ); |
603 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), | 580 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
604 | this, SLOT( showDay( int, int, int ) ) ); | 581 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
605 | connect( this, SIGNAL( newEvent() ), | ||
606 | monthView, SLOT( redraw() ) ); | ||
607 | qApp->processEvents(); | 582 | qApp->processEvents(); |
608 | } | 583 | } |
609 | } | 584 | } |
610 | 585 | ||
611 | void DateBook::loadSettings() | 586 | void DateBook::loadSettings() |
612 | { | 587 | { |
613 | Config qpeconfig( "qpe" ); | 588 | Config qpeconfig( "qpe" ); |
614 | qpeconfig.setGroup("Time"); | 589 | qpeconfig.setGroup("Time"); |
615 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 590 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
616 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 591 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
617 | 592 | ||
618 | Config config("DateBook"); | 593 | Config config("DateBook"); |
@@ -620,24 +595,25 @@ void DateBook::loadSettings() | |||
620 | startTime = config.readNumEntry("startviewtime", 8); | 595 | startTime = config.readNumEntry("startviewtime", 8); |
621 | aPreset = config.readBoolEntry("alarmpreset"); | 596 | aPreset = config.readBoolEntry("alarmpreset"); |
622 | presetTime = config.readNumEntry("presettime"); | 597 | presetTime = config.readNumEntry("presettime"); |
623 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 598 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
624 | rowStyle = config.readNumEntry("rowstyle"); | 599 | rowStyle = config.readNumEntry("rowstyle"); |
625 | defaultView = config.readNumEntry("defaultview",DAY); | 600 | defaultView = config.readNumEntry("defaultview",DAY); |
626 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 601 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
627 | 602 | ||
628 | defaultLocation=config.readEntry("defaultLocation"); | 603 | defaultLocation=config.readEntry("defaultLocation"); |
629 | QString tmpString=config.readEntry("defaultCategories"); | 604 | QString tmpString=config.readEntry("defaultCategories"); |
630 | QStringList tmpStringList=QStringList::split(",",tmpString); | 605 | QStringList tmpStringList=QStringList::split(",",tmpString); |
631 | defaultCategories.truncate(0); | 606 | defaultCategories.truncate(0); |
607 | |||
632 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 608 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
633 | defaultCategories.resize(defaultCategories.count()+1); | 609 | defaultCategories.resize(defaultCategories.count()+1); |
634 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 610 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
635 | } | 611 | } |
636 | } | 612 | } |
637 | 613 | ||
638 | void DateBook::saveSettings() | 614 | void DateBook::saveSettings() |
639 | { | 615 | { |
640 | Config config( "qpe" ); | 616 | Config config( "qpe" ); |
641 | Config configDB( "DateBook" ); | 617 | Config configDB( "DateBook" ); |
642 | configDB.setGroup( "Main" ); | 618 | configDB.setGroup( "Main" ); |
643 | configDB.writeEntry("startviewtime",startTime); | 619 | configDB.writeEntry("startviewtime",startTime); |