Diffstat (limited to 'korganizer/koeventviewerdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index 35d084d..1dce841 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,308 +1,314 @@ | |||
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 <qtimer.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | 25 | ||
26 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
27 | #include <kmessagebox.h> | 27 | #include <kmessagebox.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | #include <libkcal/todo.h> | 29 | #include <libkcal/todo.h> |
30 | #include "qapp.h" | 30 | #include "qapp.h" |
31 | 31 | ||
32 | #include "koeventviewerdialog.h" | 32 | #include "koeventviewerdialog.h" |
33 | extern int globalFlagBlockAgenda; | 33 | extern int globalFlagBlockAgenda; |
34 | 34 | ||
35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
36 | : KDialogBase(parent,name, | 36 | : KDialogBase(parent,name, |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | true , | 38 | true , |
39 | #else | 39 | #else |
40 | false, | 40 | false, |
41 | #endif | 41 | #endif |
42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
43 | { | 43 | { |
44 | sendSignalViewerClosed = true; | 44 | sendSignalViewerClosed = true; |
45 | mEventViewer = new KOEventViewer(this); | 45 | mEventViewer = new KOEventViewer(this); |
46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
47 | setMainWidget(mEventViewer); | 47 | setMainWidget(mEventViewer); |
48 | setButtonText(Ok, i18n("Edit") ); | 48 | setButtonText(Ok, i18n("Edit") ); |
49 | 49 | ||
50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
51 | SLOT(editIncidence())); | 51 | SLOT(editIncidence())); |
52 | QObject::connect(this,SIGNAL(user1Clicked()), | 52 | QObject::connect(this,SIGNAL(user1Clicked()), |
53 | SLOT(showIncidence())); | 53 | SLOT(showIncidence())); |
54 | mIncidence = 0; | 54 | mIncidence = 0; |
55 | // TODO: Set a sensible size (based on the content?). | 55 | // TODO: Set a sensible size (based on the content?). |
56 | //showMaximized(); | 56 | //showMaximized(); |
57 | //qDebug("++++++++++++KOEventViewerDialog() "); | 57 | //qDebug("++++++++++++KOEventViewerDialog() "); |
58 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 58 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
59 | // setFixedSize( 240,284 ); | 59 | // setFixedSize( 240,284 ); |
60 | // move( 0, 15 ); | 60 | // move( 0, 15 ); |
61 | // } else { | 61 | // } else { |
62 | // setMinimumSize(300,200); | 62 | // setMinimumSize(300,200); |
63 | // resize(320,300); | 63 | // resize(320,300); |
64 | // } | 64 | // } |
65 | mSyncMode = false; | 65 | mSyncMode = false; |
66 | mSyncResult = 0; | 66 | mSyncResult = 0; |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | KOEventViewerDialog::~KOEventViewerDialog() | 70 | KOEventViewerDialog::~KOEventViewerDialog() |
71 | { | 71 | { |
72 | //qDebug("-------~KOEventViewerDialog() "); | 72 | //qDebug("-------~KOEventViewerDialog() "); |
73 | } | 73 | } |
74 | void KOEventViewerDialog::showMe() | 74 | void KOEventViewerDialog::showMe() |
75 | { | 75 | { |
76 | 76 | ||
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | int x,y,w,h; | 78 | int x,y,w,h; |
79 | x = geometry().x(); | 79 | x = geometry().x(); |
80 | y = geometry().y(); | 80 | y = geometry().y(); |
81 | w = width(); | 81 | w = width(); |
82 | h = height(); | 82 | h = height(); |
83 | show(); | 83 | show(); |
84 | setGeometry(x,y,w,h); | 84 | setGeometry(x,y,w,h); |
85 | raise(); | ||
85 | #else | 86 | #else |
86 | showMaximized(); | 87 | showMaximized(); |
87 | #endif | 88 | #endif |
88 | raise(); | 89 | QTimer::singleShot( 1, this, SLOT ( setMyFocus() ) ); |
90 | |||
91 | } | ||
92 | void KOEventViewerDialog::setMyFocus() | ||
93 | { | ||
94 | |||
89 | setActiveWindow(); | 95 | setActiveWindow(); |
90 | mEventViewer->setFocus(); | 96 | mEventViewer->setFocus(); |
91 | //raise(); | ||
92 | 97 | ||
93 | } | 98 | } |
94 | void KOEventViewerDialog::print() | 99 | void KOEventViewerDialog::print() |
95 | { | 100 | { |
96 | mEventViewer->printMe(); | 101 | mEventViewer->printMe(); |
97 | 102 | ||
98 | } | 103 | } |
99 | void KOEventViewerDialog::setSyncMode( bool b ) | 104 | void KOEventViewerDialog::setSyncMode( bool b ) |
100 | { | 105 | { |
101 | mSyncMode = b; | 106 | mSyncMode = b; |
102 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 107 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
103 | if ( mSyncMode ) { | 108 | if ( mSyncMode ) { |
104 | findButton( Close )->setText( i18n("Cancel Sync")); | 109 | findButton( Close )->setText( i18n("Cancel Sync")); |
105 | findButton( Ok )->setText( i18n("Remote")); | 110 | findButton( Ok )->setText( i18n("Remote")); |
106 | findButton( User1 )->setText( i18n("Local")); | 111 | findButton( User1 )->setText( i18n("Local")); |
107 | } else { | 112 | } else { |
108 | findButton( Close )->setText( i18n("Close")); | 113 | findButton( Close )->setText( i18n("Close")); |
109 | findButton( Ok )->setText( i18n("Edit")); | 114 | findButton( Ok )->setText( i18n("Edit")); |
110 | findButton( User1 )->setText( i18n("Agenda")); | 115 | findButton( User1 )->setText( i18n("Agenda")); |
111 | } | 116 | } |
112 | mEventViewer->setSyncMode( b ); | 117 | mEventViewer->setSyncMode( b ); |
113 | } | 118 | } |
114 | void KOEventViewerDialog::setColorMode( int m ) | 119 | void KOEventViewerDialog::setColorMode( int m ) |
115 | { | 120 | { |
116 | mEventViewer->setColorMode( m ); | 121 | mEventViewer->setColorMode( m ); |
117 | } | 122 | } |
118 | int KOEventViewerDialog::executeS( bool local ) | 123 | int KOEventViewerDialog::executeS( bool local ) |
119 | { | 124 | { |
120 | mSyncResult = 3; | 125 | mSyncResult = 3; |
121 | if ( local ) | 126 | if ( local ) |
122 | findButton( User1 )->setFocus(); | 127 | findButton( User1 )->setFocus(); |
123 | else | 128 | else |
124 | findButton( Ok )->setFocus(); | 129 | findButton( Ok )->setFocus(); |
125 | exec(); | 130 | exec(); |
126 | return mSyncResult; | 131 | return mSyncResult; |
127 | } | 132 | } |
128 | 133 | ||
129 | void KOEventViewerDialog::updateConfig() | 134 | void KOEventViewerDialog::updateConfig() |
130 | { | 135 | { |
131 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 136 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
132 | 137 | ||
133 | } | 138 | } |
134 | void KOEventViewerDialog::setEvent(Event *event) | 139 | void KOEventViewerDialog::setEvent(Event *event) |
135 | { | 140 | { |
136 | mEventViewer->setEvent(event); | 141 | mEventViewer->setEvent(event); |
137 | mIncidence = event; | 142 | mIncidence = event; |
138 | mEventViewer->setFocus(); | 143 | mEventViewer->setFocus(); |
139 | //findButton( Close )->setFocus(); | 144 | //findButton( Close )->setFocus(); |
140 | if ( !mSyncMode ) { | 145 | if ( !mSyncMode ) { |
141 | findButton( User1 )->setText( i18n("Agenda")); | 146 | findButton( User1 )->setText( i18n("Agenda")); |
142 | } | 147 | } |
143 | } | 148 | } |
144 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 149 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
145 | { | 150 | { |
146 | if ( in->type() == "Event" ) | 151 | if ( in->type() == "Event" ) |
147 | setEvent( (Event*) in ); | 152 | setEvent( (Event*) in ); |
148 | else if ( in->type() =="Todo" ) | 153 | else if ( in->type() =="Todo" ) |
149 | setTodo( (Todo*) in ); | 154 | setTodo( (Todo*) in ); |
150 | else if ( in->type() =="Journal" ) | 155 | else if ( in->type() =="Journal" ) |
151 | setJournal( (Journal*) in ); | 156 | setJournal( (Journal*) in ); |
152 | } | 157 | } |
153 | void KOEventViewerDialog::addIncidence(Incidence *in) | 158 | void KOEventViewerDialog::addIncidence(Incidence *in) |
154 | { | 159 | { |
155 | if ( in->type() == "Event" ) | 160 | if ( in->type() == "Event" ) |
156 | addEvent( (Event*) in ); | 161 | addEvent( (Event*) in ); |
157 | else if ( in->type() =="Todo" ) | 162 | else if ( in->type() =="Todo" ) |
158 | mEventViewer->setTodo( (Todo*) in, false ); | 163 | mEventViewer->setTodo( (Todo*) in, false ); |
159 | else if ( in->type() =="Journal" ) | 164 | else if ( in->type() =="Journal" ) |
160 | mEventViewer->setJournal( (Journal*) in, false ); | 165 | mEventViewer->setJournal( (Journal*) in, false ); |
161 | if ( mSyncMode ) { | 166 | if ( mSyncMode ) { |
162 | findButton( User1 )->setFocus(); | 167 | findButton( User1 )->setFocus(); |
163 | setCaption(i18n("Conflict! Please choose entry")); | 168 | setCaption(i18n("Conflict! Please choose entry")); |
164 | } | 169 | } |
165 | } | 170 | } |
166 | 171 | ||
167 | void KOEventViewerDialog::addEvent(Event *event) | 172 | void KOEventViewerDialog::addEvent(Event *event) |
168 | { | 173 | { |
169 | mEventViewer->addEvent(event); | 174 | mEventViewer->addEvent(event); |
170 | mIncidence = event; | 175 | mIncidence = event; |
171 | mEventViewer->setFocus(); | 176 | mEventViewer->setFocus(); |
172 | //findButton( Close )->setFocus(); | 177 | //findButton( Close )->setFocus(); |
173 | if ( !mSyncMode ) { | 178 | if ( !mSyncMode ) { |
174 | findButton( User1 )->setText( i18n("Agenda")); | 179 | findButton( User1 )->setText( i18n("Agenda")); |
175 | } | 180 | } |
176 | } | 181 | } |
177 | 182 | ||
178 | void KOEventViewerDialog::setTodo(Todo *event) | 183 | void KOEventViewerDialog::setTodo(Todo *event) |
179 | { | 184 | { |
180 | mEventViewer->setTodo(event); | 185 | mEventViewer->setTodo(event); |
181 | mIncidence = (Incidence*)event; | 186 | mIncidence = (Incidence*)event; |
182 | mEventViewer->setFocus(); | 187 | mEventViewer->setFocus(); |
183 | //findButton( Close )->setFocus(); | 188 | //findButton( Close )->setFocus(); |
184 | if ( !mSyncMode ) { | 189 | if ( !mSyncMode ) { |
185 | findButton( User1 )->setText( i18n("Set complete")); | 190 | findButton( User1 )->setText( i18n("Set complete")); |
186 | } | 191 | } |
187 | } | 192 | } |
188 | void KOEventViewerDialog::setJournal(Journal *j) | 193 | void KOEventViewerDialog::setJournal(Journal *j) |
189 | { | 194 | { |
190 | mEventViewer->setJournal(j); | 195 | mEventViewer->setJournal(j); |
191 | mIncidence = (Incidence*)j; | 196 | mIncidence = (Incidence*)j; |
192 | mEventViewer->setFocus(); | 197 | mEventViewer->setFocus(); |
193 | //findButton( Close )->setFocus(); | 198 | //findButton( Close )->setFocus(); |
194 | if ( !mSyncMode ) { | 199 | if ( !mSyncMode ) { |
195 | findButton( User1 )->setText( i18n("Agenda")); | 200 | findButton( User1 )->setText( i18n("Agenda")); |
196 | } | 201 | } |
197 | } | 202 | } |
198 | 203 | ||
199 | void KOEventViewerDialog::addText(QString text) | 204 | void KOEventViewerDialog::addText(QString text) |
200 | { | 205 | { |
201 | mEventViewer->addText(text); | 206 | mEventViewer->addText(text); |
202 | mEventViewer->setFocus(); | 207 | mEventViewer->setFocus(); |
203 | //findButton( Close )->setFocus(); | 208 | //findButton( Close )->setFocus(); |
204 | } | 209 | } |
205 | void KOEventViewerDialog::editIncidence() | 210 | void KOEventViewerDialog::editIncidence() |
206 | { | 211 | { |
207 | sendSignalViewerClosed = false; | 212 | sendSignalViewerClosed = false; |
208 | if ( mSyncMode ) { | 213 | if ( mSyncMode ) { |
209 | mSyncResult = 2; | 214 | mSyncResult = 2; |
210 | accept(); | 215 | accept(); |
211 | return; | 216 | return; |
212 | } | 217 | } |
213 | if ( mIncidence ){ | 218 | if ( mIncidence ){ |
214 | #ifndef DESKTOP_VERSION | 219 | #ifndef DESKTOP_VERSION |
215 | hide(); | 220 | //hide(); |
221 | close(); | ||
216 | #endif | 222 | #endif |
217 | emit editIncidence( mIncidence ); | 223 | emit editIncidence( mIncidence ); |
218 | } | 224 | } |
219 | } | 225 | } |
220 | void KOEventViewerDialog::showIncidence() | 226 | void KOEventViewerDialog::showIncidence() |
221 | { | 227 | { |
222 | sendSignalViewerClosed = false; | 228 | sendSignalViewerClosed = false; |
223 | if ( mSyncMode ) { | 229 | if ( mSyncMode ) { |
224 | mSyncResult = 1; | 230 | mSyncResult = 1; |
225 | accept(); | 231 | accept(); |
226 | return; | 232 | return; |
227 | } | 233 | } |
228 | 234 | ||
229 | if ( mIncidence ){ | 235 | if ( mIncidence ){ |
230 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
231 | hide(); | 237 | hide(); |
232 | #endif | 238 | #endif |
233 | QDate date; | 239 | QDate date; |
234 | if ( mIncidence->type() == "Todo" ) { | 240 | if ( mIncidence->type() == "Todo" ) { |
235 | /* | 241 | /* |
236 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 242 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
237 | date = ((Todo*)mIncidence)->dtDue().date(); | 243 | date = ((Todo*)mIncidence)->dtDue().date(); |
238 | else { | 244 | else { |
239 | globalFlagBlockAgenda = 2; | 245 | globalFlagBlockAgenda = 2; |
240 | emit showAgendaView( false ); | 246 | emit showAgendaView( false ); |
241 | return; | 247 | return; |
242 | } | 248 | } |
243 | */ | 249 | */ |
244 | ((Todo*)mIncidence)->setCompleted( true ); | 250 | ((Todo*)mIncidence)->setCompleted( true ); |
245 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 251 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
246 | hide(); | 252 | hide(); |
247 | emit todoCompleted(((Todo*)mIncidence)); | 253 | emit todoCompleted(((Todo*)mIncidence)); |
248 | return; | 254 | return; |
249 | 255 | ||
250 | } else | 256 | } else |
251 | date = mIncidence->dtStart().date(); | 257 | date = mIncidence->dtStart().date(); |
252 | globalFlagBlockAgenda = 1; | 258 | globalFlagBlockAgenda = 1; |
253 | emit showAgendaView( false ); | 259 | emit showAgendaView( false ); |
254 | globalFlagBlockAgenda = 2; | 260 | globalFlagBlockAgenda = 2; |
255 | emit jumpToTime( date ); | 261 | emit jumpToTime( date ); |
256 | } | 262 | } |
257 | } | 263 | } |
258 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 264 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
259 | { | 265 | { |
260 | switch ( e->key() ) { | 266 | switch ( e->key() ) { |
261 | 267 | ||
262 | case Qt::Key_A : | 268 | case Qt::Key_A : |
263 | case Qt::Key_L : | 269 | case Qt::Key_L : |
264 | showIncidence(); | 270 | showIncidence(); |
265 | break; | 271 | break; |
266 | case Qt::Key_E : | 272 | case Qt::Key_E : |
267 | case Qt::Key_R : | 273 | case Qt::Key_R : |
268 | editIncidence(); | 274 | editIncidence(); |
269 | break; | 275 | break; |
270 | case Qt::Key_C: | 276 | case Qt::Key_C: |
271 | case Qt::Key_Escape: | 277 | case Qt::Key_Escape: |
272 | sendSignalViewerClosed = true; | 278 | sendSignalViewerClosed = true; |
273 | close(); | 279 | close(); |
274 | break; | 280 | break; |
275 | case Qt::Key_I: | 281 | case Qt::Key_I: |
276 | #ifndef DESKTOP_VERSION | 282 | #ifndef DESKTOP_VERSION |
277 | sendSignalViewerClosed = true; | 283 | sendSignalViewerClosed = true; |
278 | close(); | 284 | close(); |
279 | #else | 285 | #else |
280 | sendSignalViewerClosed = true; | 286 | sendSignalViewerClosed = true; |
281 | slotViewerClosed(); | 287 | slotViewerClosed(); |
282 | //accept(); | 288 | //accept(); |
283 | #endif | 289 | #endif |
284 | break; | 290 | break; |
285 | default: | 291 | default: |
286 | KDialogBase::keyPressEvent ( e ); | 292 | KDialogBase::keyPressEvent ( e ); |
287 | break; | 293 | break; |
288 | } | 294 | } |
289 | 295 | ||
290 | } | 296 | } |
291 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | 297 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) |
292 | { | 298 | { |
293 | KDialogBase::hideEvent ( e ); | 299 | KDialogBase::hideEvent ( e ); |
294 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | 300 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); |
295 | } | 301 | } |
296 | 302 | ||
297 | void KOEventViewerDialog::slotViewerClosed() | 303 | void KOEventViewerDialog::slotViewerClosed() |
298 | { | 304 | { |
299 | if ( mSyncMode ) | 305 | if ( mSyncMode ) |
300 | return; | 306 | return; |
301 | 307 | ||
302 | if ( sendSignalViewerClosed ) { | 308 | if ( sendSignalViewerClosed ) { |
303 | //qDebug("KOEventViewerDialog::hideEvent "); | 309 | //qDebug("KOEventViewerDialog::hideEvent "); |
304 | emit signalViewerClosed(); | 310 | emit signalViewerClosed(); |
305 | } | 311 | } |
306 | sendSignalViewerClosed = true; | 312 | sendSignalViewerClosed = true; |
307 | } | 313 | } |
308 | 314 | ||