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 | |||
@@ -83,84 +83,87 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
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 | ||
@@ -172,6 +175,6 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
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 |
@@ -181,7 +184,7 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
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 |
@@ -189,3 +192,3 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
189 | 192 | ||
190 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
191 | 194 | ||
@@ -375,9 +378,2 @@ void DateBook::view(int v, const QDate &d) { | |||
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); |
@@ -386,3 +382,3 @@ void DateBook::viewDefault(const QDate &d) { | |||
386 | void DateBook::viewDay() { | 382 | void DateBook::viewDay() { |
387 | view(DAY,currentDate()); | 383 | view(DAY,currentDate()); |
388 | } | 384 | } |
@@ -390,3 +386,3 @@ void DateBook::viewDay() { | |||
390 | void DateBook::viewWeek() { | 386 | void DateBook::viewWeek() { |
391 | view(WEEK,currentDate()); | 387 | view(WEEK,currentDate()); |
392 | } | 388 | } |
@@ -394,3 +390,3 @@ void DateBook::viewWeek() { | |||
394 | void DateBook::viewWeekLst() { | 390 | void DateBook::viewWeekLst() { |
395 | view(WEEKLST,currentDate()); | 391 | view(WEEKLST,currentDate()); |
396 | } | 392 | } |
@@ -398,3 +394,3 @@ void DateBook::viewWeekLst() { | |||
398 | void DateBook::viewMonth() { | 394 | void DateBook::viewMonth() { |
399 | view(MONTH,currentDate()); | 395 | view(MONTH,currentDate()); |
400 | } | 396 | } |
@@ -528,17 +524,10 @@ void DateBook::initDay() | |||
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 | } |
@@ -551,6 +540,4 @@ void DateBook::initWeek() | |||
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 | } |
@@ -570,4 +557,2 @@ void DateBook::initWeek() | |||
570 | } | 557 | } |
571 | if ( totWeeks != weekView->totalWeeks() ) | ||
572 | weekView->setTotalWeeks( totWeeks ); | ||
573 | } | 558 | } |
@@ -575,21 +560,13 @@ void DateBook::initWeek() | |||
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 | } |
@@ -599,11 +576,9 @@ 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 | } |
@@ -631,2 +606,3 @@ void DateBook::loadSettings() | |||
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++) { |