26 #include <tqwidgetstack.h>
27 #include <tqtabwidget.h>
30 #include <tdeactioncollection.h>
31 #include <tdeconfig.h>
32 #include <tdeglobal.h>
34 #include "actionmanager.h"
35 #include "calendarview.h"
36 #include "datenavigator.h"
37 #include "kotodoview.h"
38 #include "koagendaview.h"
39 #include "komonthview.h"
40 #include "kolistview.h"
41 #include "kowhatsnextview.h"
42 #include "kojournalview.h"
43 #include "kotimelineview.h"
45 #include "koglobals.h"
46 #include "navigatorbar.h"
47 #include "multiagendaview.h"
48 #include <korganizer/mainwindow.h>
50 #include "koviewmanager.h"
51 #include "koviewmanager.moc"
54 TQObject(), mMainView( mainView )
63 mAgendaSideBySideView = 0;
69 mAgendaViewTabIndex = 0;
70 mAgendaMode = AGENDA_NONE;
73 KOViewManager::~KOViewManager()
83 void KOViewManager::readSettings(TDEConfig *config)
85 config->setGroup(
"General");
86 TQString
view = config->readEntry(
"Current View");
88 if (view ==
"WhatsNext") showWhatsNextView();
89 else if (view ==
"Month") showMonthView();
90 else if (view ==
"List") showListView();
91 else if (view ==
"Journal") showJournalView();
92 else if (view ==
"Todo") showTodoView();
93 else if (view ==
"Timeline") showTimelineView();
95 mAgendaMode = AgendaMode( config->readNumEntry(
"Agenda Mode", AGENDA_OTHER ) );
97 switch ( mAgendaMode ) {
98 case AGENDA_WORK_WEEK:
113 mAgendaMode = AGENDA_OTHER;
119 void KOViewManager::writeSettings(TDEConfig *config)
121 config->setGroup(
"General");
124 if (mCurrentView == mWhatsNextView)
view =
"WhatsNext";
125 else if (mCurrentView == mMonthView)
view =
"Month";
126 else if (mCurrentView == mListView)
view =
"List";
127 else if (mCurrentView == mJournalView)
view =
"Journal";
128 else if (mCurrentView == mTodoView)
view =
"Todo";
129 else if (mCurrentView == mTimelineView)
view =
"Timeline";
132 config->writeEntry(
"Agenda Mode", mAgendaMode );
135 config->writeEntry(
"Current View",view);
138 mAgendaView->writeSettings(config);
141 mListView->writeSettings(config);
144 mTodoView->saveLayout(config,
"Todo View");
150 if(
view == mCurrentView )
return;
154 if ( mCurrentView && mCurrentView->
isEventView() ) {
155 mLastEventView = mCurrentView;
162 mMainView->processIncidenceSelection( 0, TQDate() );
164 mMainView->updateView();
169 void KOViewManager::goMenu(
bool enable )
176 action = ac->action(
"go_today" );
178 action->setEnabled( enable );
180 action = ac->action(
"go_previous" );
182 action->setEnabled( enable );
184 action = ac->action(
"go_next" );
186 action->setEnabled( enable );
192 void KOViewManager::raiseCurrentView()
194 if ((mMonthView && KOPrefs::instance()->mFullViewMonth && mCurrentView == mMonthView) ||
195 (mTodoView && KOPrefs::instance()->mFullViewTodo && mCurrentView == mTodoView)) {
196 mMainView->showLeftFrame(
false );
197 if ( mCurrentView == mTodoView ) {
198 mMainView->navigatorBar()->hide();
200 mMainView->navigatorBar()->show();
203 mMainView->showLeftFrame(
true );
204 mMainView->navigatorBar()->hide();
206 mMainView->viewStack()->raiseWidget( widgetForView( mCurrentView ) );
209 void KOViewManager::updateView()
211 if ( mCurrentView ) mCurrentView->
updateView();
214 void KOViewManager::updateView(
const TQDate &start,
const TQDate &end)
218 if (mCurrentView) mCurrentView->
showDates(start, end);
220 if (mTodoView) mTodoView->updateView();
228 connect( view, TQ_SIGNAL( incidenceSelected(
Incidence *,
const TQDate & ) ),
229 mMainView, TQ_SLOT( processMainViewSelection(
Incidence *,
const TQDate & ) ) );
232 connect( view, TQ_SIGNAL(showIncidenceSignal(
Incidence *,
const TQDate &)),
233 mMainView, TQ_SLOT(showIncidence(
Incidence *,
const TQDate &)) );
234 connect( view, TQ_SIGNAL(editIncidenceSignal(
Incidence *,
const TQDate &)),
235 mMainView, TQ_SLOT(editIncidence(
Incidence *,
const TQDate &)) );
236 connect( view, TQ_SIGNAL(deleteIncidenceSignal(
Incidence *)),
237 mMainView, TQ_SLOT(deleteIncidence(
Incidence *)) );
238 connect( view, TQ_SIGNAL(copyIncidenceSignal(
Incidence *)),
239 mMainView, TQ_SLOT(copyIncidence(
Incidence *)) );
240 connect( view, TQ_SIGNAL(cutIncidenceSignal(
Incidence *)),
241 mMainView, TQ_SLOT(cutIncidence(
Incidence *)) );
242 connect( view, TQ_SIGNAL(pasteIncidenceSignal()),
243 mMainView, TQ_SLOT(pasteIncidence()));
244 connect( view, TQ_SIGNAL(toggleAlarmSignal(
Incidence *)),
245 mMainView, TQ_SLOT(toggleAlarm(
Incidence *)) );
246 connect( view,TQ_SIGNAL(dissociateOccurrenceSignal(
Incidence *,
const TQDate &)),
247 mMainView, TQ_SLOT(dissociateOccurrence(
Incidence *,
const TQDate &)) );
248 connect( view,TQ_SIGNAL(dissociateFutureOccurrenceSignal(
Incidence *,
const TQDate &)),
249 mMainView, TQ_SLOT(dissociateFutureOccurrence(
Incidence *,
const TQDate &)) );
252 connect( view, TQ_SIGNAL(newEventSignal(
ResourceCalendar *,
const TQString &)),
254 connect( view, TQ_SIGNAL(newEventSignal(
ResourceCalendar *,
const TQString &,
const TQDate &)),
255 mMainView, TQ_SLOT(newEvent(
ResourceCalendar *,
const TQString &,
const TQDate &)) );
256 connect( view, TQ_SIGNAL(newEventSignal(
ResourceCalendar *,
const TQString &,
const TQDateTime &)),
257 mMainView, TQ_SLOT(newEvent(
ResourceCalendar *,
const TQString &,
const TQDateTime &)) );
258 connect( view, TQ_SIGNAL(newEventSignal(
ResourceCalendar *,
const TQString &,
const TQDateTime &,
const TQDateTime &)),
259 mMainView, TQ_SLOT(newEvent(
ResourceCalendar *,
const TQString &,
const TQDateTime &,
const TQDateTime &)) );
261 connect( view, TQ_SIGNAL(newTodoSignal(
ResourceCalendar *,
const TQString &,
const TQDate &)),
262 mMainView, TQ_SLOT(newTodo(
ResourceCalendar *,
const TQString &,
const TQDate &)) );
263 connect( view, TQ_SIGNAL(newSubTodoSignal(
Todo *)),
264 mMainView, TQ_SLOT(newSubTodo(
Todo *)) );
266 connect( view, TQ_SIGNAL(newJournalSignal(
ResourceCalendar *,
const TQString &,
const TQDate &)),
267 mMainView, TQ_SLOT(newJournal(
ResourceCalendar *,
const TQString &,
const TQDate &)) );
270 connect(mMainView, TQ_SIGNAL(configChanged()), view, TQ_SLOT(updateConfig()));
273 connect( mMainView, TQ_SIGNAL( dayPassed(
const TQDate & ) ),
274 view, TQ_SLOT( dayPassed(
const TQDate & ) ) );
275 connect( view, TQ_SIGNAL( startMultiModify(
const TQString & ) ),
276 mMainView, TQ_SLOT( startMultiModify(
const TQString & ) ) );
277 connect( view, TQ_SIGNAL( endMultiModify() ),
278 mMainView, TQ_SLOT( endMultiModify() ) );
280 connect( mMainView, TQ_SIGNAL( newIncidenceChanger( IncidenceChangerBase* ) ),
281 view, TQ_SLOT( setIncidenceChanger( IncidenceChangerBase * ) ) );
282 view->setIncidenceChanger( mMainView->incidenceChanger() );
285 void KOViewManager::connectTodoView(
KOTodoView* todoView )
287 if (!todoView)
return;
290 connect( todoView, TQ_SIGNAL( purgeCompletedSignal() ),
291 mMainView, TQ_SLOT( purgeCompleted() ) );
292 connect( todoView, TQ_SIGNAL( unSubTodoSignal() ),
293 mMainView, TQ_SLOT( todo_unsub() ) );
294 connect( todoView, TQ_SIGNAL( unAllSubTodoSignal() ),
295 mMainView, TQ_SLOT( makeSubTodosIndependent() ) );
298 void KOViewManager::zoomInHorizontally()
300 if( mAgendaView == mCurrentView ) mAgendaView->zoomInHorizontally();
302 void KOViewManager::zoomOutHorizontally()
304 if( mAgendaView== mCurrentView ) mAgendaView->zoomOutHorizontally();
306 void KOViewManager::zoomInVertically()
308 if( mAgendaView== mCurrentView ) mAgendaView->zoomInVertically();
310 void KOViewManager::zoomOutVertically()
312 if( mAgendaView== mCurrentView ) mAgendaView->zoomOutVertically();
318 mMainView->viewStack()->addWidget( view );
321 void KOViewManager::showWhatsNextView()
323 if (!mWhatsNextView) {
324 mWhatsNextView =
new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
325 "KOViewManager::WhatsNextView");
326 addView(mWhatsNextView);
332 void KOViewManager::showListView()
335 mListView =
new KOListView(mMainView->calendar(), mMainView->viewStack(),
"KOViewManager::ListView");
342 void KOViewManager::showAgendaView()
347 bool isLocalFile = !calres;
349 int mode = KOPrefs::instance()->agendaViewCalendarDisplay();
351 const bool showBoth = ( mode == KOPrefs::AllCalendarViews && !isLocalFile );
353 const bool showMerged = showBoth || mode == KOPrefs::CalendarsMerged || isLocalFile;
355 const bool showSideBySide = !isLocalFile && ( showBoth || mode == KOPrefs::CalendarsSideBySide );
357 TQWidget *parent = mMainView->viewStack();
358 if ( !mAgendaViewTabs && showBoth ) {
359 mAgendaViewTabs =
new TQTabWidget( mMainView->viewStack() );
360 connect( mAgendaViewTabs, TQ_SIGNAL( currentChanged( TQWidget* ) ),
361 this, TQ_SLOT( currentAgendaViewTabChanged( TQWidget* ) ) );
362 parent = mAgendaViewTabs;
364 TDEConfig *config = KOGlobals::self()->config();
365 config->setGroup(
"Views" );
366 mAgendaViewTabIndex = config->readNumEntry(
"Agenda View Tab Index", 0 );
369 if ( !mAgendaView && showMerged ) {
373 "KOViewManager::AgendaView" );
375 addView(mAgendaView);
377 connect(mAgendaView, TQ_SIGNAL( toggleExpand() ),
378 mMainView, TQ_SLOT( toggleExpand() ) );
379 connect(mMainView, TQ_SIGNAL( calendarViewExpanded(
bool ) ),
380 mAgendaView, TQ_SLOT( setExpandedButton(
bool ) ) );
382 connect( mAgendaView,TQ_SIGNAL( zoomViewHorizontally(
const TQDate &,
int )),
383 mMainView->dateNavigator(),TQ_SLOT( selectDates(
const TQDate &,
int ) ) );
384 mAgendaView->readSettings();
387 if ( !mAgendaSideBySideView && showSideBySide ) {
388 mAgendaSideBySideView =
390 "KOViewManager::AgendaSideBySideView" );
392 addView(mAgendaSideBySideView);
403 if ( showBoth && mAgendaViewTabs ) {
404 if ( mAgendaView && mAgendaViewTabs->indexOf( mAgendaView ) < 0 )
405 mAgendaViewTabs->addTab( mAgendaView, i18n(
"Merged calendar") );
406 if ( mAgendaSideBySideView && mAgendaViewTabs->indexOf( mAgendaSideBySideView ) < 0 )
407 mAgendaViewTabs->addTab( mAgendaSideBySideView, i18n(
"Calendars Side by Side") );
408 mAgendaViewTabs->setCurrentPage( mAgendaViewTabIndex );
410 if ( mAgendaView && mMainView->viewStack()->id( mAgendaView ) < 0 )
411 mMainView->viewStack()->addWidget( mAgendaView );
412 if ( mAgendaSideBySideView && mMainView->viewStack()->id( mAgendaSideBySideView ) < 0 )
413 mMainView->viewStack()->addWidget( mAgendaSideBySideView );
417 if ( mAgendaViewTabs && showBoth )
419 else if ( mAgendaView && showMerged )
421 else if ( mAgendaSideBySideView && showSideBySide )
425 void KOViewManager::showDayView()
427 mAgendaMode = AGENDA_DAY;
429 mMainView->dateNavigator()->selectDates( 1 );
432 void KOViewManager::showWorkWeekView()
434 mAgendaMode = AGENDA_WORK_WEEK;
436 mMainView->dateNavigator()->selectWorkWeek();
439 void KOViewManager::showWeekView()
441 mAgendaMode = AGENDA_WEEK;
443 mMainView->dateNavigator()->selectWeek();
446 void KOViewManager::showNextXView()
448 mAgendaMode = AGENDA_NEXTX;
450 mMainView->dateNavigator()->selectDates( TQDate::currentDate(),
451 KOPrefs::instance()->mNextXDays );
454 void KOViewManager::showMonthView()
457 mMonthView =
new KOMonthView(mMainView->calendar(), mMainView->viewStack(),
"KOViewManager::MonthView");
465 void KOViewManager::showTodoView()
468 mTodoView =
new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
469 "KOViewManager::TodoView" );
470 mTodoView->setCalendar( mMainView->calendar() );
471 addView( mTodoView );
472 connectTodoView( mTodoView );
474 TDEConfig *config = KOGlobals::self()->config();
475 mTodoView->restoreLayout( config,
"Todo View" );
482 void KOViewManager::showJournalView()
485 mJournalView =
new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
486 "KOViewManager::JournalView");
487 addView(mJournalView);
495 void KOViewManager::showTimelineView()
497 if (!mTimelineView) {
498 mTimelineView =
new KOTimelineView(mMainView->calendar(),mMainView->viewStack(),
499 "KOViewManager::TimelineView");
500 addView(mTimelineView);
506 void KOViewManager::showEventView()
508 if ( mLastEventView ) {
516 Incidence *KOViewManager::currentSelection()
518 if ( !mCurrentView )
return 0;
520 if ( incidenceList.isEmpty() )
return 0;
522 return incidenceList.first();
525 TQDate KOViewManager::currentSelectionDate()
530 if (!qvl.isEmpty()) qd = qvl.first();
535 void KOViewManager::setDocumentId(
const TQString &
id )
537 if (mTodoView) mTodoView->setDocumentId(
id );
541 TQWidget* KOViewManager::widgetForView(
KOrg::BaseView* view )
const
543 const bool showBoth = KOPrefs::instance()->agendaViewCalendarDisplay() == KOPrefs::AllCalendarViews;
544 if ( (view == mAgendaView || view == mAgendaSideBySideView) && mAgendaViewTabs && showBoth ) {
545 return mAgendaViewTabs;
551 void KOViewManager::currentAgendaViewTabChanged( TQWidget* widget )
553 TDEConfig *config = KOGlobals::self()->config();
554 config->setGroup(
"Views" );
555 config->writeEntry(
"Agenda View Tab Index", mAgendaViewTabs->currentPageIndex() );
561 void KOViewManager::resourcesChanged()
564 mAgendaView->resourcesChanged();
565 if ( mAgendaSideBySideView )
566 mAgendaSideBySideView->resourcesChanged();
569 void KOViewManager::updateMultiCalendarDisplay()
571 if ( agendaIsSelected() ) {
578 bool KOViewManager::agendaIsSelected()
const
580 return mCurrentView == mAgendaView ||
581 mCurrentView == mAgendaSideBySideView ||
582 ( mAgendaViewTabs && mCurrentView == mAgendaViewTabs->currentPage() );
static KOrg::MainWindow * findInstance(const KURL &url)
Is there a instance with this URL?
This is the main calendar widget.
void adaptNavigationUnits()
Adapt navigation units corresponding to step size of navigation of the current view.
KOAgendaView is the agenda-like view used to display events in a single one or multi-day view.
void deleteSelectedDateTime()
make selected start/end invalid
This class provides a journal view.
This class provides a multi-column list view of events.
The class KOMonthView represents the monthly view in KOrganizer.
This class provides a view ....
This class provides a multi-column list view of todo events.
void showView(KOrg::BaseView *)
changes the view to be the currently selected view
This class provides a view of the next events and todos.
This class provides an interface for all views being displayed within the main calendar view.
virtual void showDates(const TQDate &start, const TQDate &end)=0
Show incidences for the given date range.
virtual void updateView()=0
Updates the current display to reflect changes that may have happened in the calendar since the last ...
virtual DateList selectedIncidenceDates()=0
virtual bool isEventView()
Return if this view is a view for displaying events.
virtual Incidence::List selectedIncidences()=0
interface for korganizer main window
virtual TDEActionCollection * getActionCollection() const =0
Return actionCollection of this main window.
Shows one agenda for every resource side-by-side.
bool view(TQWidget *parent, Attachment *attachment)