44 #include <KActionCollection>
45 #include <KMessageBox>
49 #include <QStackedWidget>
52 :
QObject(), mMainView( mainView )
59 mAgendaSideBySideView = 0;
64 mAgendaViewTabIndex = 0;
81 KConfigGroup generalConfig( config,
"General" );
82 const QString view = generalConfig.readEntry(
"Current View" );
84 if ( view == QLatin1String(
"WhatsNext" ) ) {
86 }
else if ( view == QLatin1String(
"OldMonth" ) ) {
89 }
else if ( view == QLatin1String(
"List" ) ) {
92 }
else if ( view == QLatin1String(
"Journal" ) ) {
94 }
else if ( view == QLatin1String(
"Todo" ) ) {
96 }
else if ( view == QLatin1String(
"Timeline" ) ) {
98 }
else if ( view == QLatin1String(
"TimeSpent" ) ) {
100 }
else if ( view == QLatin1String(
"Month" ) ) {
108 switch ( mRangeMode ) {
130 KConfigGroup generalConfig( config,
"General" );
132 if ( mCurrentView == mWhatsNextView ) {
133 view = QLatin1String(
"WhatsNext" );
134 }
else if ( mCurrentView == mListView ) {
135 view = QLatin1String(
"List" );
136 }
else if ( mCurrentView == mJournalView ) {
137 view = QLatin1String(
"Journal" );
138 }
else if ( mCurrentView == mTodoView ) {
139 view = QLatin1String(
"Todo" );
140 }
else if ( mCurrentView == mTimelineView ) {
141 view = QLatin1String(
"Timeline" );
142 }
else if ( mCurrentView == mTimeSpentView ) {
143 view = QLatin1String(
"TimeSpent" );
144 }
else if ( mCurrentView == mMonthView ) {
145 view = QLatin1String(
"Month" );
147 view = QLatin1String(
"Agenda" );
150 generalConfig.writeEntry(
"Current View", view );
159 mTodoView->
saveLayout( config, QLatin1String(
"Todo View") );
164 KConfigGroup group = KGlobal::config()->group( view->
identifier() );
168 generalConfig.writeEntry(
"Range Mode",
int( mRangeMode ) );
173 if ( view == mCurrentView ) {
180 if ( mCurrentView && mCurrentView->
isEventView() ) {
181 mLastEventView = mCurrentView;
197 if ( QAction *action = ac->action( QLatin1String(
"configure_view") ) ) {
201 QStringList zoomActions;
202 QStringList rangeActions;
204 zoomActions << QLatin1String(
"zoom_in_horizontally")
205 << QLatin1String(
"zoom_out_horizontally")
206 << QLatin1String(
"zoom_in_vertically")
207 << QLatin1String(
"zoom_out_vertically");
208 rangeActions << QLatin1String(
"select_workweek")
209 << QLatin1String(
"select_week")
210 << QLatin1String(
"select_day")
211 << QLatin1String(
"select_nextx");
213 for (
int i = 0; i < zoomActions.size(); ++i ) {
214 if ( QAction *action = ac->action( zoomActions[i] ) ) {
219 for (
int i = 0; i < rangeActions.size(); ++i ) {
220 if ( QAction *action = ac->action( rangeActions[i] ) ) {
235 action = ac->action( QLatin1String(
"go_today") );
237 action->setEnabled( enable );
239 action = ac->action( QLatin1String(
"go_previous") );
241 action->setEnabled( enable );
243 action = ac->action( QLatin1String(
"go_next") );
245 action->setEnabled( enable );
255 if ( mCurrentView == mTodoView ) {
264 mMainView->
viewStack()->setCurrentWidget( widgetForView( mCurrentView ) );
269 if ( mCurrentView ) {
276 if ( mCurrentView && mCurrentView != mTodoView ) {
277 mCurrentView->
setDateRange( KDateTime( start ), KDateTime( end ), preferredMonth );
278 }
else if ( mTodoView ) {
295 connect( view, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
296 mMainView, SLOT(processMainViewSelection(Akonadi::Item,QDate)) );
299 connect( view, SIGNAL(showIncidenceSignal(Akonadi::Item)),
300 mMainView, SLOT(showIncidence(Akonadi::Item)) );
301 connect( view, SIGNAL(editIncidenceSignal(Akonadi::Item)),
302 mMainView, SLOT(editIncidence(Akonadi::Item)) );
303 connect( view, SIGNAL(deleteIncidenceSignal(Akonadi::Item)),
304 mMainView, SLOT(deleteIncidence(Akonadi::Item)) );
305 connect( view, SIGNAL(copyIncidenceSignal(Akonadi::Item)),
306 mMainView, SLOT(copyIncidence(Akonadi::Item)) );
307 connect( view, SIGNAL(cutIncidenceSignal(Akonadi::Item)),
308 mMainView, SLOT(cutIncidence(Akonadi::Item)) );
309 connect( view, SIGNAL(pasteIncidenceSignal()),
310 mMainView, SLOT(pasteIncidence()) );
311 connect( view, SIGNAL(toggleAlarmSignal(Akonadi::Item)),
312 mMainView, SLOT(toggleAlarm(Akonadi::Item)) );
313 connect( view, SIGNAL(toggleTodoCompletedSignal(Akonadi::Item)),
314 mMainView, SLOT(toggleTodoCompleted(Akonadi::Item)) );
315 connect( view, SIGNAL(copyIncidenceToResourceSignal(Akonadi::Item,QString)),
316 mMainView, SLOT(copyIncidenceToResource(Akonadi::Item,QString)) );
317 connect( view, SIGNAL(moveIncidenceToResourceSignal(Akonadi::Item,QString)),
318 mMainView, SLOT(moveIncidenceToResource(Akonadi::Item,QString)) );
319 connect( view, SIGNAL(dissociateOccurrencesSignal(Akonadi::Item,QDate)),
320 mMainView, SLOT(dissociateOccurrences(Akonadi::Item,QDate)) );
323 connect( view, SIGNAL(newEventSignal()),
324 mMainView, SLOT(newEvent()) );
325 connect( view, SIGNAL(newEventSignal(QDateTime)),
326 mMainView, SLOT(newEvent(QDateTime)) );
327 connect( view, SIGNAL(newEventSignal(QDateTime,QDateTime)),
328 mMainView, SLOT(newEvent(QDateTime,QDateTime)) );
329 connect( view, SIGNAL(newEventSignal(QDate)),
330 mMainView, SLOT(newEvent(QDate)) );
332 connect( view, SIGNAL(newTodoSignal(QDate)),
333 mMainView, SLOT(newTodo(QDate)) );
334 connect( view, SIGNAL(newSubTodoSignal(Akonadi::Item)),
335 mMainView, SLOT(newSubTodo(Akonadi::Item)) );
336 connect( view, SIGNAL(newJournalSignal(QDate)),
337 mMainView, SLOT(newJournal(QDate)) );
340 connect( mMainView, SIGNAL(
configChanged()), view, SLOT(updateConfig()) );
343 connect( mMainView, SIGNAL(dayPassed(QDate)),
344 view, SLOT(dayPassed(QDate)) );
345 connect( view, SIGNAL(startMultiModify(QString)),
346 mMainView, SLOT(startMultiModify(QString)) );
347 connect( view, SIGNAL(endMultiModify()),
348 mMainView, SLOT(endMultiModify()) );
350 connect( mMainView, SIGNAL(newIncidenceChanger(Akonadi::IncidenceChanger*)),
351 view, SLOT(setIncidenceChanger(Akonadi::IncidenceChanger*)) );
363 connect( todoView, SIGNAL(purgeCompletedSignal()),
364 mMainView, SLOT(purgeCompleted()) );
365 connect( todoView, SIGNAL(unSubTodoSignal()),
366 mMainView, SLOT(todo_unsub()) );
367 connect( todoView, SIGNAL(unAllSubTodoSignal()),
368 mMainView, SLOT(makeSubTodosIndependent()) );
369 connect( mMainView, SIGNAL(categoryConfigChanged()),
370 todoView, SLOT(updateCategories()) );
372 connect( todoView, SIGNAL(fullViewChanged(
bool)),
373 mMainView, SLOT(changeFullView(
bool)) );
378 if ( mAgendaView == mCurrentView ) {
385 if ( mAgendaView == mCurrentView ) {
392 if ( mAgendaView == mCurrentView ) {
399 if ( mAgendaView == mCurrentView ) {
407 mViews.append( view );
408 const KConfigGroup group = KGlobal::config()->group( view->
identifier() );
411 mMainView->
viewStack()->addWidget( view );
417 if ( !mTimeSpentView ) {
434 connect( mMonthView, SIGNAL(fullViewChanged(
bool)),
435 mMainView, SLOT(changeFullView(
bool)) );
443 if ( !mWhatsNextView ) {
466 const bool showBoth =
468 const bool showMerged =
470 const bool showSideBySide =
475 if ( !mAgendaViewTabs && showBoth ) {
476 mAgendaViewTabs =
new KTabWidget( mMainView->
viewStack() );
477 connect( mAgendaViewTabs, SIGNAL(currentChanged(
QWidget*)),
478 this, SLOT(currentAgendaViewTabChanged(
QWidget*)) );
479 mMainView->
viewStack()->addWidget( mAgendaViewTabs );
482 KConfigGroup viewConfig( config,
"Views" );
483 mAgendaViewTabIndex = viewConfig.readEntry(
"Agenda View Tab Index", 0 );
485 parent = mAgendaViewTabs;
489 if ( !mAgendaView ) {
494 addView( mAgendaView, showBoth );
496 connect( mAgendaView,SIGNAL(zoomViewHorizontally(QDate,
int)),
500 if ( showBoth && mAgendaViewTabs->indexOf( mAgendaView ) < 0 ) {
501 mAgendaViewTabs->addTab( mAgendaView, i18n(
"Merged calendar" ) );
502 }
else if ( !showBoth && mMainView->
viewStack()->indexOf( mAgendaView ) < 0 ) {
503 mAgendaView->setParent( parent );
504 mMainView->
viewStack()->addWidget( mAgendaView );
508 if ( showSideBySide ) {
509 if ( !mAgendaSideBySideView ) {
511 mAgendaSideBySideView->
setIdentifier(
"DefaultAgendaSideBySideView" );
513 addView( mAgendaSideBySideView, showBoth );
519 if ( showBoth && mAgendaViewTabs->indexOf( mAgendaSideBySideView ) < 0 ) {
520 mAgendaViewTabs->addTab( mAgendaSideBySideView, i18n(
"Calendars Side by Side" ) );
521 mAgendaViewTabs->setCurrentIndex( mAgendaViewTabIndex );
522 }
else if ( !showBoth && mMainView->
viewStack()->indexOf( mAgendaSideBySideView ) < 0 ) {
523 mAgendaSideBySideView->setParent( parent );
524 mMainView->
viewStack()->addWidget( mAgendaSideBySideView );
530 showView( static_cast<KOrg::BaseView*>( mAgendaViewTabs->currentWidget() ) );
531 }
else if ( showMerged ) {
533 }
else if ( showSideBySide ) {
554 i18n(
"Unable to display the work week since there are no work days configured. "
555 "Please properly configure at least 1 work day in the Time and Date preferences." ) );
584 mTodoView->
restoreLayout( config, QLatin1String(
"Todo View"),
false );
592 if ( !mJournalView ) {
604 if ( !mTimelineView ) {
616 if ( mLastEventView ) {
627 if ( !mCurrentView ) {
628 return Akonadi::Item();
632 if ( incidenceList.isEmpty() ) {
633 return Akonadi::Item();
635 return incidenceList.first();
641 if ( mCurrentView ) {
643 if ( !qvl.isEmpty() ) {
659 if ( mAgendaViewTabs && mAgendaViewTabs->indexOf( view ) >= 0 ) {
660 return mAgendaViewTabs;
665 void KOViewManager::currentAgendaViewTabChanged(
QWidget *widget )
668 KConfigGroup viewConfig( config,
"Views" );
669 viewConfig.writeEntry(
"Agenda View Tab Index", mAgendaViewTabs->currentIndex() );
673 showView( static_cast<KOrg::BaseView*>( widget ) );
679 foreach (
BaseView *view, mViews ) {
697 return mCurrentView == mAgendaView ||
698 mCurrentView == mAgendaSideBySideView ||
699 ( mAgendaViewTabs && mCurrentView == mAgendaViewTabs->currentWidget() );
702 #include "koviewmanager.moc"
void setDocumentId(const QString &)
virtual bool supportsDateRangeSelection()
returns whether this view supports date range selection Base implementation returns true...
bool agendaIsSelected() const
Returns true if agenda is the current view.
void showLeftFrame(bool show=true)
virtual void updateView()
void writeSettings(KConfig *)
void connectView(KOrg::BaseView *)
KOAgendaView is the agenda-like view that displays events in a single or multi-day view...
void setCalendar(const Akonadi::ETMCalendar::Ptr &cal)
QByteArray identifier() const
virtual Akonadi::IncidenceChanger * incidenceChanger() const
QStackedWidget * viewStack() const
This view show the time spent on each category.
Shows one agenda for every resource side-by-side.
void addView(KOrg::BaseView *, bool isTab=false)
virtual void restoreConfig(const KConfigGroup &configGroup)
reads the view configuration.
virtual void setDateRange(const KDateTime &start, const KDateTime &end, const QDate &preferredMonth=QDate())
Show incidences for the given date range.
void selectDate(const QDate &)
void zoomOutHorizontally()
virtual bool usesFullWindow()
returns whether this view should be displayed full window.
NavigatorBar * navigatorBar() const
void setCalendar(const Akonadi::ETMCalendar::Ptr &)
void writeSettings(KConfig *config)
virtual bool isEventView()
Returns if this view is a view for displaying events.
virtual bool hasConfigurationDialog() const
void addChange(EventViews::EventView::Change change)
Notifies all views that an update is needed.
virtual void setCalendar(const Akonadi::ETMCalendar::Ptr &cal)
int agendaViewCalendarDisplay() const
Get Multiple Calendar Display.
void updateView(const QDate &start, const QDate &end, const QDate &preferredMonth, const bool updateTodos=true)
This class provides a view of the next events and todos.
virtual void setIdentifier(const QByteArray &identifier)
This is the main calendar widget.
Akonadi::ETMCalendar::Ptr calendar() const
void connectTodoView(KOTodoView *todoView)
void selectDates(const KCalCore::DateList &, const QDate &preferredMonth=QDate())
static KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
KOrg::BaseView * currentView()
DateNavigator * dateNavigator() const
void zoomInHorizontally()
void updateMultiCalendarDisplay()
void zoomInHorizontally(const QDate &date=QDate())
void setCalendar(const Akonadi::ETMCalendar::Ptr &)
virtual KActionCollection * getActionCollection() const =0
Return actionCollection of this main window.
This class provides a journal view.
virtual void setCalendar(const Akonadi::ETMCalendar::Ptr &)
QDate activeDate(bool fallbackToToday=false)
Returns the best guess at the current active date in the view.
interface for korganizer main window
virtual Akonadi::Item::List selectedIncidences()=0
void updateHighlightModes()
Informs the date navigator which incidence types should be used to embolden days, this function is ma...
void processIncidenceSelection(const Akonadi::Item &incidence, const QDate &date)
void saveLayout(KConfig *config, const QString &group) const
virtual void updateView()=0
Updates the current display to reflect changes that may have happened in the calendar since the last ...
void deleteSelectedDateTime()
make selected start/end invalid
This class provides a view ....
EventViews::EventView::Changes changes() const
Returns if there are pending changes and a redraw is needed.
KOViewManager(CalendarView *)
static KOGlobals * self()
void showView(KOrg::BaseView *)
changes the view to be the currently selected view
This class provides an interface for all views being displayed within the main calendar view...
void setDocumentId(const QString &)
QDate currentSelectionDate()
If there's a selected incidence, it's date is returned, otherwise an invalid QDate is returned...
void readSettings(KConfig *config)
Akonadi::Item currentSelection()
void datesSelected(const KCalCore::DateList &)
void zoomOutHorizontally(const QDate &date=QDate())
void readSettings(KConfig *config)
virtual void setChanges(EventViews::EventView::Changes changes)
Notifies the view that there are pending changes so a redraw is needed.
static KOPrefs * instance()
Get instance of KOPrefs.
virtual void setIncidenceChanger(Akonadi::IncidenceChanger *changer)
Assign a new incidence change helper object.
virtual bool supportsZoom()
returns whether this view supports zoom.
void restoreLayout(KConfig *config, const QString &group, bool minimalDefaults)
void adaptNavigationUnits()
Adapts navigation units according to the current view's navigation step size.
virtual KCalCore::DateList selectedIncidenceDates()=0
Returns a list of the dates of selected events.
virtual void setCalendar(const Akonadi::ETMCalendar::Ptr &cal)
void writeSettings(KConfig *config)
void setCalendar(const Akonadi::ETMCalendar::Ptr &cal)
void setCalendar(const Akonadi::ETMCalendar::Ptr &cal)
virtual void saveConfig(KConfigGroup &configGroup)
writes out the view configuration.