author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /korganizer/koviewmanager.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'korganizer/koviewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koviewmanager.cpp | 570 |
1 files changed, 570 insertions, 0 deletions
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp new file mode 100644 index 0000000..88d69c6 --- a/dev/null +++ b/korganizer/koviewmanager.cpp | |||
@@ -0,0 +1,570 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | |||
4 | Copyright (c) 2001 | ||
5 | Cornelius Schumacher <schumacher@kde.org> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | |||
21 | As a special exception, permission is given to link this program | ||
22 | with any edition of Qt, and distribute the resulting executable, | ||
23 | without including the source code for Qt in the source distribution. | ||
24 | */ | ||
25 | |||
26 | #include <qwidgetstack.h> | ||
27 | |||
28 | #include <kconfig.h> | ||
29 | #include <kglobal.h> | ||
30 | #ifndef DESKTOP_VERSION | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | #else | ||
33 | #include <qapplication.h> | ||
34 | #endif | ||
35 | #include "calendarview.h" | ||
36 | #include "datenavigator.h" | ||
37 | #include "kotodoview.h" | ||
38 | #include "koagendaview.h" | ||
39 | #include "kodialogmanager.h" | ||
40 | #include "komonthview.h" | ||
41 | #include "kolistview.h" | ||
42 | #include "kowhatsnextview.h" | ||
43 | #include "kojournalview.h" | ||
44 | #include "kotimespanview.h" | ||
45 | #include "koprefs.h" | ||
46 | #include "navigatorbar.h" | ||
47 | |||
48 | #include "koviewmanager.h" | ||
49 | #include "koviewmanager.moc" | ||
50 | //extern bool externFlagMonthviewBlockPainting; | ||
51 | |||
52 | //bool globalFlagBlockPainting = false; | ||
53 | int globalFlagBlockAgenda = 0; | ||
54 | int globalFlagBlockLabel = 0; | ||
55 | int globalFlagBlockAgendaItemPaint = 1; | ||
56 | int globalFlagBlockAgendaItemUpdate = 1; | ||
57 | |||
58 | |||
59 | KOViewManager::KOViewManager( CalendarView *mainView ) : | ||
60 | QObject(), mMainView( mainView ) | ||
61 | { | ||
62 | mCurrentView = 0; | ||
63 | |||
64 | mWhatsNextView = 0; | ||
65 | mTodoView = 0; | ||
66 | mAgendaView = 0; | ||
67 | mMonthView = 0; | ||
68 | mListView = 0; | ||
69 | mJournalView = 0; | ||
70 | mTimeSpanView = 0; | ||
71 | mCurrentAgendaView = 0 ; | ||
72 | mFlagShowNextxDays = false; | ||
73 | } | ||
74 | |||
75 | KOViewManager::~KOViewManager() | ||
76 | { | ||
77 | } | ||
78 | |||
79 | |||
80 | KOrg::BaseView *KOViewManager::currentView() | ||
81 | { | ||
82 | return mCurrentView; | ||
83 | } | ||
84 | |||
85 | void KOViewManager::readSettings(KConfig *config) | ||
86 | { | ||
87 | config->setGroup("General"); | ||
88 | QString view = config->readEntry("Current View"); | ||
89 | if (view == "WhatsNext") showWhatsNextView(); | ||
90 | else if (view == "Month") showMonthView(); | ||
91 | else if (view == "List") showListView(); | ||
92 | else if (view == "Journal") showJournalView(); | ||
93 | else if (view == "TimeSpan") showTimeSpanView(); | ||
94 | else if (view == "Todo") showTodoView(); | ||
95 | else { | ||
96 | showAgendaView(); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | void KOViewManager::writeSettings(KConfig *config) | ||
101 | { | ||
102 | config->setGroup("General"); | ||
103 | |||
104 | QString view; | ||
105 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | ||
106 | else if (mCurrentView == mMonthView) view = "Month"; | ||
107 | else if (mCurrentView == mListView) view = "List"; | ||
108 | else if (mCurrentView == mJournalView) view = "Journal"; | ||
109 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | ||
110 | else if (mCurrentView == mTodoView) view = "Todo"; | ||
111 | else view = "Agenda"; | ||
112 | |||
113 | config->writeEntry("Current View",view); | ||
114 | |||
115 | if (mAgendaView) { | ||
116 | mAgendaView->writeSettings(config); | ||
117 | } | ||
118 | if (mTimeSpanView) { | ||
119 | mTimeSpanView->writeSettings(config); | ||
120 | } | ||
121 | if (mListView) { | ||
122 | mListView->writeSettings(config); | ||
123 | } | ||
124 | if (mTodoView) { | ||
125 | mTodoView->saveLayout(config,"Todo View"); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | ||
130 | { | ||
131 | |||
132 | //mFlagShowNextxDays = false; | ||
133 | //if(view == mCurrentView) return; | ||
134 | if ( view == 0 ) { | ||
135 | view = mCurrentView; | ||
136 | if ( view == 0 ) | ||
137 | return; | ||
138 | } | ||
139 | bool full = fullScreen; | ||
140 | if(view == mCurrentView && view != mWhatsNextView ) { | ||
141 | if ( mCurrentAgendaView < 0 ) | ||
142 | return; | ||
143 | full = mMainView->leftFrame()->isVisible(); | ||
144 | } else { | ||
145 | mCurrentView = view; | ||
146 | |||
147 | // bool full = fullScreen; | ||
148 | bool isFull = !mMainView->leftFrame()->isVisible(); | ||
149 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | ||
150 | full = true; | ||
151 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | ||
152 | full = false; | ||
153 | } | ||
154 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | ||
155 | raiseCurrentView( full ); | ||
156 | mMainView->processIncidenceSelection( 0 ); | ||
157 | mMainView->updateView(); | ||
158 | mMainView->adaptNavigationUnits(); | ||
159 | } | ||
160 | |||
161 | void KOViewManager::raiseCurrentView( bool fullScreen ) | ||
162 | { | ||
163 | //qDebug("raiseCurrentView "); | ||
164 | mCurrentAgendaView = 0; | ||
165 | int wid = mMainView->width() ; | ||
166 | int hei = mMainView->height(); | ||
167 | if ( mCurrentView == mMonthView ) { | ||
168 | mMainView->navigatorBar()->show(); | ||
169 | hei -= mMainView->navigatorBar()->sizeHint().height(); | ||
170 | //mMainView->navigatorBar()->hide(); | ||
171 | } else { | ||
172 | mMainView->navigatorBar()->hide(); | ||
173 | } | ||
174 | if ( fullScreen ) { | ||
175 | mMainView->leftFrame()->hide(); | ||
176 | } else { | ||
177 | mMainView->leftFrame()->show(); | ||
178 | if ( KOPrefs::instance()->mVerticalScreen ) | ||
179 | hei -= mMainView->leftFrame()->height(); | ||
180 | else | ||
181 | wid -= mMainView->leftFrame()->width(); | ||
182 | } | ||
183 | |||
184 | if ( globalFlagBlockAgenda == 5 ) { | ||
185 | globalFlagBlockAgenda = 4; | ||
186 | globalFlagBlockAgendaItemPaint = 1; | ||
187 | } | ||
188 | mMainView->viewStack()->raiseWidget(mCurrentView); | ||
189 | if ( globalFlagBlockAgenda == 4 ) { | ||
190 | if ( mCurrentView == mAgendaView ) { | ||
191 | //globalFlagBlockAgenda =1 ; | ||
192 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | ||
193 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | ||
194 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | ||
195 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | ||
196 | qApp->processEvents(); | ||
197 | //qDebug("qApp->processEvents() "); | ||
198 | globalFlagBlockAgenda = 0; | ||
199 | mAgendaView->repaintAgenda(); | ||
200 | |||
201 | } | ||
202 | globalFlagBlockAgenda = 0; | ||
203 | } | ||
204 | //qDebug("raiseCurrentView ende "); | ||
205 | } | ||
206 | |||
207 | void KOViewManager::updateView() | ||
208 | { | ||
209 | // qDebug("KOViewManager::updateView() "); | ||
210 | // if we are updating mTodoView, we get endless recursion | ||
211 | if ( mTodoView == mCurrentView ) | ||
212 | return; | ||
213 | if ( mCurrentView ) mCurrentView->updateView(); | ||
214 | |||
215 | } | ||
216 | |||
217 | void KOViewManager::updateView(const QDate &start, const QDate &end) | ||
218 | { | ||
219 | // kdDebug() << "KOViewManager::updateView()" << endl; | ||
220 | |||
221 | if (mCurrentView) mCurrentView->showDates(start, end); | ||
222 | |||
223 | if (mTodoView) mTodoView->updateView(); | ||
224 | } | ||
225 | |||
226 | |||
227 | void KOViewManager::showWhatsNextView() | ||
228 | { | ||
229 | if (!mWhatsNextView) { | ||
230 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | ||
231 | "KOViewManager::WhatsNextView"); | ||
232 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | ||
233 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | ||
234 | addView(mWhatsNextView); | ||
235 | } | ||
236 | globalFlagBlockAgenda = 1; | ||
237 | showView(mWhatsNextView, true ); | ||
238 | mWhatsNextView->updateView(); | ||
239 | |||
240 | } | ||
241 | |||
242 | void KOViewManager::showListView() | ||
243 | { | ||
244 | if (!mListView) { | ||
245 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | ||
246 | addView(mListView); | ||
247 | |||
248 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | ||
249 | mMainView, SLOT(showIncidence(Incidence *))); | ||
250 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | ||
251 | mMainView, SLOT(editIncidence(Incidence *))); | ||
252 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | ||
253 | mMainView, SLOT(deleteIncidence(Incidence *))); | ||
254 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
255 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | ||
256 | connect( mListView, SIGNAL( signalNewEvent() ), | ||
257 | mMainView, SLOT( newEvent() ) ); | ||
258 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | ||
259 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | ||
260 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | ||
261 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | ||
262 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | ||
263 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | ||
264 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | ||
265 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | ||
266 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | ||
267 | } | ||
268 | // bool temp = mFlagShowNextxDays; | ||
269 | //globalFlagBlockPainting = true; | ||
270 | globalFlagBlockAgenda = 1; | ||
271 | if ( KOPrefs::instance()->mListViewMonthTimespan ) | ||
272 | mMainView->dateNavigator()->selectMonth(); | ||
273 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | ||
274 | //mFlagShowNextxDays = temp; | ||
275 | } | ||
276 | |||
277 | void KOViewManager::showAgendaView( bool fullScreen ) | ||
278 | { | ||
279 | |||
280 | mMainView->dialogManager()->hideSearchDialog(); | ||
281 | // qDebug("KOViewManager::showAgendaView "); | ||
282 | bool full; | ||
283 | full = fullScreen; | ||
284 | if (!mAgendaView) { | ||
285 | full = false; | ||
286 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | ||
287 | addView(mAgendaView); | ||
288 | #ifndef DESKTOP_VERSION | ||
289 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | ||
290 | #endif | ||
291 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | ||
292 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | ||
293 | |||
294 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | ||
295 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | ||
296 | mMainView, SLOT(newEvent(QDateTime))); | ||
297 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | ||
298 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); | ||
299 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | ||
300 | mMainView, SLOT(newEvent(QDate))); | ||
301 | |||
302 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | ||
303 | mMainView, SLOT(editIncidence(Incidence *))); | ||
304 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | ||
305 | mMainView, SLOT(showIncidence(Incidence *))); | ||
306 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | ||
307 | mMainView, SLOT(deleteIncidence(Incidence *))); | ||
308 | |||
309 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
310 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | ||
311 | |||
312 | connect(mAgendaView, SIGNAL( toggleExpand() ), | ||
313 | mMainView, SLOT( toggleExpand() ) ); | ||
314 | |||
315 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | ||
316 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | ||
317 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | ||
318 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | ||
319 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | ||
320 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | ||
321 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | ||
322 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | ||
323 | SLOT( updateTodo( Todo *, int ) ) ); | ||
324 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | ||
325 | mMainView, SIGNAL( todoModified( Todo *, int ))); | ||
326 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | ||
327 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | ||
328 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | ||
329 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | ||
330 | mAgendaView->readSettings(); | ||
331 | mAgendaView->updateConfig(); | ||
332 | } | ||
333 | |||
334 | showView( mAgendaView, full); | ||
335 | |||
336 | } | ||
337 | |||
338 | void KOViewManager::showDayView() | ||
339 | { | ||
340 | mFlagShowNextxDays = false; | ||
341 | globalFlagBlockLabel = 1; | ||
342 | globalFlagBlockAgenda = 1; | ||
343 | if ( mCurrentAgendaView != 1 ) | ||
344 | mCurrentAgendaView = -1; | ||
345 | showAgendaView(); | ||
346 | qApp->processEvents(); | ||
347 | globalFlagBlockAgenda = 2; | ||
348 | globalFlagBlockLabel = 0; | ||
349 | mMainView->dateNavigator()->selectDates( 1 ); | ||
350 | mCurrentAgendaView = 1 ; | ||
351 | |||
352 | } | ||
353 | |||
354 | void KOViewManager::showWorkWeekView() | ||
355 | { | ||
356 | mFlagShowNextxDays = false; | ||
357 | globalFlagBlockAgenda = 1; | ||
358 | globalFlagBlockLabel = 1; | ||
359 | if ( mCurrentAgendaView != 5 ) | ||
360 | mCurrentAgendaView = -1; | ||
361 | showAgendaView(); | ||
362 | qApp->processEvents(); | ||
363 | globalFlagBlockAgenda = 2; | ||
364 | globalFlagBlockLabel = 0; | ||
365 | mMainView->dateNavigator()->selectWorkWeek(); | ||
366 | mCurrentAgendaView = 5 ; | ||
367 | |||
368 | } | ||
369 | |||
370 | void KOViewManager::showWeekView() | ||
371 | { | ||
372 | /* | ||
373 | globalFlagBlockAgenda = 2; | ||
374 | qDebug("4globalFlagBlockAgenda = 2; "); | ||
375 | //globalFlagBlockPainting = true; | ||
376 | mMainView->dateNavigator()->selectWeek(); | ||
377 | showAgendaView(); | ||
378 | */ | ||
379 | |||
380 | |||
381 | mFlagShowNextxDays = false; | ||
382 | globalFlagBlockAgenda = 1; | ||
383 | globalFlagBlockLabel = 1; | ||
384 | if ( mCurrentAgendaView != 7 ) | ||
385 | mCurrentAgendaView = -1; | ||
386 | showAgendaView(); | ||
387 | qApp->processEvents(); | ||
388 | globalFlagBlockAgenda = 2; | ||
389 | globalFlagBlockLabel = 0; | ||
390 | mMainView->dateNavigator()->selectWeek(); | ||
391 | mCurrentAgendaView = 7 ; | ||
392 | } | ||
393 | |||
394 | void KOViewManager::showNextXView() | ||
395 | { | ||
396 | |||
397 | globalFlagBlockAgenda = 1; | ||
398 | if ( mCurrentAgendaView != 3 ) | ||
399 | mCurrentAgendaView = -1; | ||
400 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | ||
401 | globalFlagBlockAgenda = 2; | ||
402 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | ||
403 | KOPrefs::instance()->mNextXDays ); | ||
404 | mFlagShowNextxDays = true; | ||
405 | mCurrentAgendaView = 3 ; | ||
406 | } | ||
407 | bool KOViewManager::showsNextDays() | ||
408 | { | ||
409 | return mFlagShowNextxDays; | ||
410 | } | ||
411 | void KOViewManager::showMonthView() | ||
412 | { | ||
413 | if (!mMonthView) { | ||
414 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | ||
415 | |||
416 | addView(mMonthView); | ||
417 | // mMonthView->show(); | ||
418 | // SIGNALS/SLOTS FOR MONTH VIEW | ||
419 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | ||
420 | mMainView, SLOT(newEvent(QDateTime))); | ||
421 | |||
422 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | ||
423 | mMainView, SLOT(showIncidence(Incidence *))); | ||
424 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | ||
425 | mMainView, SLOT(editIncidence(Incidence *))); | ||
426 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | ||
427 | mMainView, SLOT(deleteIncidence(Incidence *))); | ||
428 | |||
429 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
430 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | ||
431 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | ||
432 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | ||
433 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | ||
434 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | ||
435 | |||
436 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | ||
437 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | ||
438 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | ||
439 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | ||
440 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | ||
441 | mMainView, SLOT ( selectWeekNum( int ) ) ); | ||
442 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | ||
443 | mMonthView->updateConfig(); | ||
444 | } | ||
445 | |||
446 | globalFlagBlockAgenda = 1; | ||
447 | //mFlagShowNextxDays = false; | ||
448 | // if(mMonthView == mCurrentView) return; | ||
449 | mMainView->dateNavigator()->selectMonth(); | ||
450 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | ||
451 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | ||
452 | |||
453 | showView(mMonthView, true ); | ||
454 | |||
455 | } | ||
456 | |||
457 | void KOViewManager::showTodoView() | ||
458 | { | ||
459 | //mFlagShowNextxDays = false; | ||
460 | if ( !mTodoView ) { | ||
461 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | ||
462 | "KOViewManager::TodoView" ); | ||
463 | |||
464 | addView( mTodoView ); | ||
465 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | ||
466 | |||
467 | // SIGNALS/SLOTS FOR TODO VIEW | ||
468 | connect( mTodoView, SIGNAL( newTodoSignal() ), | ||
469 | mMainView, SLOT( newTodo() ) ); | ||
470 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | ||
471 | mMainView, SLOT( newSubTodo( Todo *) ) ); | ||
472 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | ||
473 | mMainView, SLOT( showTodo( Todo * ) ) ); | ||
474 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | ||
475 | mMainView, SLOT( editTodo( Todo * ) ) ); | ||
476 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | ||
477 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | ||
478 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | ||
479 | mMainView, SLOT( purgeCompleted() ) ); | ||
480 | |||
481 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
482 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | ||
483 | |||
484 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | ||
485 | SLOT( updateConfig() ) ); | ||
486 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | ||
487 | SLOT( updateTodo( Todo *, int ) ) ); | ||
488 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | ||
489 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | ||
490 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | ||
491 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | ||
492 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | ||
493 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | ||
494 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | ||
495 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | ||
496 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | ||
497 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | ||
498 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | ||
499 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | ||
500 | KConfig *config = KOGlobals::config(); | ||
501 | mTodoView->restoreLayout(config,"Todo View"); | ||
502 | } | ||
503 | |||
504 | globalFlagBlockAgenda = 1; | ||
505 | showView( mTodoView, true ); | ||
506 | |||
507 | } | ||
508 | |||
509 | void KOViewManager::showJournalView() | ||
510 | { | ||
511 | //mFlagShowNextxDays = false; | ||
512 | if (!mJournalView) { | ||
513 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | ||
514 | "KOViewManager::JournalView"); | ||
515 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | ||
516 | SLOT( updateConfig() ) ); | ||
517 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | ||
518 | addView(mJournalView); | ||
519 | } | ||
520 | |||
521 | showView(mJournalView); | ||
522 | } | ||
523 | |||
524 | void KOViewManager::showTimeSpanView() | ||
525 | { | ||
526 | //mFlagShowNextxDays = false; | ||
527 | if (!mTimeSpanView) { | ||
528 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | ||
529 | "KOViewManager::TimeSpanView"); | ||
530 | addView(mTimeSpanView); | ||
531 | |||
532 | mTimeSpanView->readSettings(); | ||
533 | } | ||
534 | |||
535 | showView(mTimeSpanView); | ||
536 | } | ||
537 | |||
538 | Incidence *KOViewManager::currentSelection() | ||
539 | { | ||
540 | if (!mCurrentView) return 0; | ||
541 | if ( mCurrentView == mListView ) { | ||
542 | if ( mListView->currentItem() ) | ||
543 | return mListView->currentItem(); | ||
544 | } | ||
545 | return mCurrentView->selectedIncidences().first(); | ||
546 | } | ||
547 | |||
548 | QDate KOViewManager::currentSelectionDate() | ||
549 | { | ||
550 | QDate qd; | ||
551 | if (mCurrentView) { | ||
552 | DateList qvl = mCurrentView->selectedDates(); | ||
553 | if (!qvl.isEmpty()) qd = qvl.first(); | ||
554 | } | ||
555 | return qd; | ||
556 | } | ||
557 | |||
558 | void KOViewManager::addView(KOrg::BaseView *view) | ||
559 | { | ||
560 | #if QT_VERSION >= 300 | ||
561 | mMainView->viewStack()->addWidget( view ); | ||
562 | #else | ||
563 | mMainView->viewStack()->addWidget( view, 1 ); | ||
564 | #endif | ||
565 | } | ||
566 | |||
567 | void KOViewManager::setDocumentId( const QString &id ) | ||
568 | { | ||
569 | if (mTodoView) mTodoView->setDocumentId( id ); | ||
570 | } | ||