Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 276 |
1 files changed, 126 insertions, 150 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 | |||
@@ -81,88 +81,91 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
81 | inSearch(FALSE), | 81 | inSearch(FALSE), |
82 | alarmCounter(0) | 82 | alarmCounter(0) |
83 | { | 83 | { |
84 | bool needEvilHack= false; // if we need an Evil Hack | 84 | bool needEvilHack= false; // if we need an Evil Hack |
85 | QTime t; | 85 | QTime t; |
86 | t.start(); | 86 | t.start(); |
87 | db = new DateBookDBHack; | 87 | db = new DateBookDBHack; |
88 | qDebug("loading db t=%d", t.elapsed() ); | 88 | qDebug("loading db t=%d", t.elapsed() ); |
89 | loadSettings(); | 89 | loadSettings(); |
90 | setCaption( tr("Calendar") ); | 90 | setCaption( tr("Calendar") ); |
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 ); | 111 | |
112 | QPopupMenu *settings = new QPopupMenu( this ); | 112 | QPEToolBar *sub_bar = new QPEToolBar(this); |
113 | 113 | sub_bar->setHorizontalStretchable(TRUE); | |
114 | mb->insertItem( tr( "View" ), view ); | 114 | |
115 | mb->insertItem( tr( "Settings" ), settings ); | 115 | QActionGroup *g = new QActionGroup( this ); |
116 | 116 | g->setExclusive( TRUE ); | |
117 | QActionGroup *g = new QActionGroup( this ); | 117 | |
118 | g->setExclusive( TRUE ); | 118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
119 | 119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | |
120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 120 | a->addTo( sub_bar ); |
121 | QString::null, 0, this, 0 ); | 121 | |
122 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 122 | sub_bar->addSeparator(); |
123 | a->addTo( sub_bar ); | 123 | |
124 | 124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | |
125 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 126 | a->addTo( sub_bar ); |
127 | a->addTo( sub_bar ); | 127 | //a->addTo( view ); |
128 | a->addTo( view ); | 128 | |
129 | 129 | sub_bar->addSeparator(); | |
130 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 130 | |
131 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
132 | a->addTo( sub_bar ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
133 | a->addTo( view ); | 133 | a->addTo( sub_bar ); |
134 | a->setToggleAction( TRUE ); | 134 | // a->addTo( view ); |
135 | a->setOn( TRUE ); | 135 | a->setToggleAction( TRUE ); |
136 | dayAction = a; | 136 | a->setOn( TRUE ); |
137 | 137 | dayAction = a; | |
138 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 138 | |
139 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
140 | a->addTo( sub_bar ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
141 | a->addTo( view ); | 141 | a->addTo( sub_bar ); |
142 | a->setToggleAction( TRUE ); | 142 | // a->addTo( view ); |
143 | weekAction = a; | 143 | a->setToggleAction( TRUE ); |
144 | 144 | weekAction = a; | |
145 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 145 | |
146 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
147 | a->addTo( sub_bar ); | 147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
148 | a->addTo( view ); | 148 | a->addTo( sub_bar ); |
149 | a->setToggleAction( TRUE ); | 149 | // a->addTo( view ); |
150 | weekLstAction = a; | 150 | a->setToggleAction( TRUE ); |
151 | 151 | weekLstAction = a; | |
152 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 152 | |
153 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
154 | a->addTo( sub_bar ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
155 | a->addTo( view ); | 155 | a->addTo( sub_bar ); |
156 | a->setToggleAction( TRUE ); | 156 | // a->addTo( view ); |
157 | monthAction = a; | 157 | a->setToggleAction( TRUE ); |
158 | 158 | monthAction = a; | |
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); | 159 | |
160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 160 | sub_bar->addSeparator(); |
161 | a->addTo( sub_bar ); | 161 | |
162 | 162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | |
163 | a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); | 163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 164 | a->addTo( sub_bar ); |
165 | a->addTo( settings ); | 165 | |
166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | ||
167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | ||
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(); |
@@ -170,24 +173,24 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
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 |
178 | 181 | ||
179 | // listen on QPE/System | 182 | // listen on QPE/System |
180 | #if defined(Q_WS_QWS) | 183 | #if defined(Q_WS_QWS) |
181 | #if !defined(QT_NO_COP) | 184 | #if !defined(QT_NO_COP) |
182 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
183 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
184 | channel = new QCopChannel( "QPE/Datebook", this ); | 187 | channel = new QCopChannel( "QPE/Datebook", this ); |
185 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
186 | qDebug("olle\n"); | 189 | qDebug("olle\n"); |
187 | #endif | 190 | #endif |
188 | #endif | 191 | #endif |
189 | 192 | ||
190 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
191 | 194 | ||
192 | /* | 195 | /* |
193 | * Here is a problem description: | 196 | * Here is a problem description: |
@@ -373,30 +376,23 @@ void DateBook::view(int v, const QDate &d) { | |||
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() { |
395 | view(WEEKLST,currentDate()); | 391 | view(WEEKLST,currentDate()); |
396 | } | 392 | } |
397 | 393 | ||
398 | void DateBook::viewMonth() { | 394 | void DateBook::viewMonth() { |
399 | view(MONTH,currentDate()); | 395 | view(MONTH,currentDate()); |
400 | } | 396 | } |
401 | 397 | ||
402 | void DateBook::insertEvent( const Event &e ) | 398 | void DateBook::insertEvent( const Event &e ) |
@@ -526,21 +522,14 @@ void DateBook::initDay() | |||
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 & ) ) ); | 532 | } |
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 | } | ||
544 | } | 533 | } |
545 | 534 | ||
546 | void DateBook::initWeek() | 535 | void DateBook::initWeek() |
@@ -549,10 +538,8 @@ void DateBook::initWeek() | |||
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 |
@@ -568,44 +555,32 @@ void DateBook::initWeek() | |||
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" ); | 563 | views->addWidget( weekLstView, WEEKLST ); |
579 | views->addWidget( weekLstView, WEEKLST ); | 564 | |
580 | 565 | //weekLstView->setStartViewTime( startTime ); | |
581 | //weekLstView->setStartViewTime( startTime ); | 566 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
582 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 567 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), |
583 | this, SLOT( showDay( int, int, int ) ) ); | 568 | this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); |
584 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 569 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
585 | const QDateTime &, | 570 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
586 | const QString & , const QString &) ), | 571 | } |
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 | } | ||
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() ), | 582 | qApp->processEvents(); |
606 | monthView, SLOT( redraw() ) ); | 583 | } |
607 | qApp->processEvents(); | ||
608 | } | ||
609 | } | 584 | } |
610 | 585 | ||
611 | void DateBook::loadSettings() | 586 | void DateBook::loadSettings() |
@@ -629,6 +604,7 @@ void DateBook::loadSettings() | |||
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(); |