Diffstat (limited to 'korganizer/koeventviewerdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index 23e62d3..8bada3b 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,74 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | 21 | ||
22 | #include <libkcal/event.h> | 22 | #include <libkcal/event.h> |
23 | #include <qtimer.h> | ||
23 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
24 | 25 | ||
25 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
26 | #include "koprefs.h" | 27 | #include "koprefs.h" |
27 | #include <libkcal/todo.h> | 28 | #include <libkcal/todo.h> |
28 | #include "qapp.h" | 29 | #include "qapp.h" |
29 | 30 | ||
30 | #include "koeventviewerdialog.h" | 31 | #include "koeventviewerdialog.h" |
31 | extern int globalFlagBlockAgenda; | 32 | extern int globalFlagBlockAgenda; |
32 | 33 | ||
33 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 34 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
34 | : KDialogBase(parent,name, | 35 | : KDialogBase(parent,name, |
35 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
36 | true , | 37 | true , |
37 | #else | 38 | #else |
38 | false, | 39 | false, |
39 | #endif | 40 | #endif |
40 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 41 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
41 | { | 42 | { |
42 | 43 | sendSignalViewerClosed = true; | |
43 | mEventViewer = new KOEventViewer(this); | 44 | mEventViewer = new KOEventViewer(this); |
44 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 45 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
45 | setMainWidget(mEventViewer); | 46 | setMainWidget(mEventViewer); |
46 | setButtonText(Ok, i18n("Edit") ); | 47 | setButtonText(Ok, i18n("Edit") ); |
47 | 48 | ||
48 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 49 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
49 | SLOT(editIncidence())); | 50 | SLOT(editIncidence())); |
50 | QObject::connect(this,SIGNAL(user1Clicked()), | 51 | QObject::connect(this,SIGNAL(user1Clicked()), |
51 | SLOT(showIncidence())); | 52 | SLOT(showIncidence())); |
52 | mIncidence = 0; | 53 | mIncidence = 0; |
53 | // TODO: Set a sensible size (based on the content?). | 54 | // TODO: Set a sensible size (based on the content?). |
54 | //showMaximized(); | 55 | //showMaximized(); |
55 | //qDebug("++++++++++++KOEventViewerDialog() "); | 56 | //qDebug("++++++++++++KOEventViewerDialog() "); |
56 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 57 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
57 | // setFixedSize( 240,284 ); | 58 | // setFixedSize( 240,284 ); |
58 | // move( 0, 15 ); | 59 | // move( 0, 15 ); |
59 | // } else { | 60 | // } else { |
60 | // setMinimumSize(300,200); | 61 | // setMinimumSize(300,200); |
61 | // resize(320,300); | 62 | // resize(320,300); |
62 | // } | 63 | // } |
63 | mSyncMode = false; | 64 | mSyncMode = false; |
64 | mSyncResult = 0; | 65 | mSyncResult = 0; |
65 | 66 | ||
66 | } | 67 | } |
67 | 68 | ||
68 | KOEventViewerDialog::~KOEventViewerDialog() | 69 | KOEventViewerDialog::~KOEventViewerDialog() |
69 | { | 70 | { |
70 | //qDebug("-------~KOEventViewerDialog() "); | 71 | //qDebug("-------~KOEventViewerDialog() "); |
71 | } | 72 | } |
72 | void KOEventViewerDialog::showMe() | 73 | void KOEventViewerDialog::showMe() |
73 | { | 74 | { |
74 | 75 | ||
@@ -160,107 +161,123 @@ void KOEventViewerDialog::addEvent(Event *event) | |||
160 | } | 161 | } |
161 | } | 162 | } |
162 | 163 | ||
163 | void KOEventViewerDialog::setTodo(Todo *event) | 164 | void KOEventViewerDialog::setTodo(Todo *event) |
164 | { | 165 | { |
165 | mEventViewer->setTodo(event); | 166 | mEventViewer->setTodo(event); |
166 | mIncidence = (Incidence*)event; | 167 | mIncidence = (Incidence*)event; |
167 | mEventViewer->setFocus(); | 168 | mEventViewer->setFocus(); |
168 | //findButton( Close )->setFocus(); | 169 | //findButton( Close )->setFocus(); |
169 | if ( !mSyncMode ) { | 170 | if ( !mSyncMode ) { |
170 | findButton( User1 )->setText( i18n("Set complete")); | 171 | findButton( User1 )->setText( i18n("Set complete")); |
171 | } | 172 | } |
172 | } | 173 | } |
173 | void KOEventViewerDialog::setJournal(Journal *j) | 174 | void KOEventViewerDialog::setJournal(Journal *j) |
174 | { | 175 | { |
175 | mEventViewer->setJournal(j); | 176 | mEventViewer->setJournal(j); |
176 | mIncidence = (Incidence*)j; | 177 | mIncidence = (Incidence*)j; |
177 | mEventViewer->setFocus(); | 178 | mEventViewer->setFocus(); |
178 | //findButton( Close )->setFocus(); | 179 | //findButton( Close )->setFocus(); |
179 | if ( !mSyncMode ) { | 180 | if ( !mSyncMode ) { |
180 | findButton( User1 )->setText( i18n("Agenda")); | 181 | findButton( User1 )->setText( i18n("Agenda")); |
181 | } | 182 | } |
182 | } | 183 | } |
183 | 184 | ||
184 | void KOEventViewerDialog::addText(QString text) | 185 | void KOEventViewerDialog::addText(QString text) |
185 | { | 186 | { |
186 | mEventViewer->addText(text); | 187 | mEventViewer->addText(text); |
187 | mEventViewer->setFocus(); | 188 | mEventViewer->setFocus(); |
188 | //findButton( Close )->setFocus(); | 189 | //findButton( Close )->setFocus(); |
189 | } | 190 | } |
190 | void KOEventViewerDialog::editIncidence() | 191 | void KOEventViewerDialog::editIncidence() |
191 | { | 192 | { |
193 | sendSignalViewerClosed = false; | ||
192 | if ( mSyncMode ) { | 194 | if ( mSyncMode ) { |
193 | mSyncResult = 2; | 195 | mSyncResult = 2; |
194 | accept(); | 196 | accept(); |
195 | return; | 197 | return; |
196 | } | 198 | } |
197 | if ( mIncidence ){ | 199 | if ( mIncidence ){ |
198 | #ifndef DESKTOP_VERSION | 200 | #ifndef DESKTOP_VERSION |
199 | hide(); | 201 | hide(); |
200 | #endif | 202 | #endif |
201 | emit editIncidence( mIncidence ); | 203 | emit editIncidence( mIncidence ); |
202 | } | 204 | } |
203 | } | 205 | } |
204 | void KOEventViewerDialog::showIncidence() | 206 | void KOEventViewerDialog::showIncidence() |
205 | { | 207 | { |
206 | 208 | sendSignalViewerClosed = false; | |
207 | if ( mSyncMode ) { | 209 | if ( mSyncMode ) { |
208 | mSyncResult = 1; | 210 | mSyncResult = 1; |
209 | accept(); | 211 | accept(); |
210 | return; | 212 | return; |
211 | } | 213 | } |
212 | 214 | ||
213 | if ( mIncidence ){ | 215 | if ( mIncidence ){ |
214 | #ifndef DESKTOP_VERSION | 216 | #ifndef DESKTOP_VERSION |
215 | hide(); | 217 | hide(); |
216 | #endif | 218 | #endif |
217 | QDate date; | 219 | QDate date; |
218 | if ( mIncidence->type() == "Todo" ) { | 220 | if ( mIncidence->type() == "Todo" ) { |
219 | /* | 221 | /* |
220 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 222 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
221 | date = ((Todo*)mIncidence)->dtDue().date(); | 223 | date = ((Todo*)mIncidence)->dtDue().date(); |
222 | else { | 224 | else { |
223 | globalFlagBlockAgenda = 2; | 225 | globalFlagBlockAgenda = 2; |
224 | emit showAgendaView( false ); | 226 | emit showAgendaView( false ); |
225 | return; | 227 | return; |
226 | } | 228 | } |
227 | */ | 229 | */ |
228 | ((Todo*)mIncidence)->setCompleted( true ); | 230 | ((Todo*)mIncidence)->setCompleted( true ); |
229 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 231 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
230 | hide(); | 232 | hide(); |
231 | emit todoCompleted(((Todo*)mIncidence)); | 233 | emit todoCompleted(((Todo*)mIncidence)); |
232 | return; | 234 | return; |
233 | 235 | ||
234 | } else | 236 | } else |
235 | date = mIncidence->dtStart().date(); | 237 | date = mIncidence->dtStart().date(); |
236 | globalFlagBlockAgenda = 1; | 238 | globalFlagBlockAgenda = 1; |
237 | emit showAgendaView( false ); | 239 | emit showAgendaView( false ); |
238 | globalFlagBlockAgenda = 2; | 240 | globalFlagBlockAgenda = 2; |
239 | emit jumpToTime( date ); | 241 | emit jumpToTime( date ); |
240 | } | 242 | } |
241 | } | 243 | } |
242 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 244 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
243 | { | 245 | { |
244 | switch ( e->key() ) { | 246 | switch ( e->key() ) { |
245 | 247 | ||
246 | case Qt::Key_A : | 248 | case Qt::Key_A : |
247 | case Qt::Key_L : | 249 | case Qt::Key_L : |
248 | showIncidence(); | 250 | showIncidence(); |
249 | break; | 251 | break; |
250 | case Qt::Key_E : | 252 | case Qt::Key_E : |
251 | case Qt::Key_R : | 253 | case Qt::Key_R : |
252 | editIncidence(); | 254 | editIncidence(); |
253 | break; | 255 | break; |
254 | case Qt::Key_C: | 256 | case Qt::Key_C: |
255 | case Qt::Key_Escape: | 257 | case Qt::Key_Escape: |
256 | close(); | 258 | close(); |
257 | break; | 259 | break; |
258 | case Qt::Key_I: | 260 | case Qt::Key_I: |
259 | accept(); | 261 | accept(); |
260 | break; | 262 | break; |
261 | default: | 263 | default: |
262 | KDialogBase::keyPressEvent ( e ); | 264 | KDialogBase::keyPressEvent ( e ); |
263 | break; | 265 | break; |
264 | } | 266 | } |
265 | 267 | ||
266 | } | 268 | } |
269 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | ||
270 | { | ||
271 | KDialogBase::hideEvent ( e ); | ||
272 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | ||
273 | } | ||
274 | |||
275 | void KOEventViewerDialog::slotViewerClosed() | ||
276 | { | ||
277 | if ( sendSignalViewerClosed ) { | ||
278 | //qDebug("KOEventViewerDialog::hideEvent "); | ||
279 | emit signalViewerClosed(); | ||
280 | } | ||
281 | sendSignalViewerClosed = true; | ||
282 | } | ||
283 | |||