korganizer

calendarview.h
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2000,2001,2003,2004 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of TQt, and distribute the resulting executable,
23  without including the source code for TQt in the source distribution.
24 */
25 #ifndef CALENDARVIEW_H
26 #define CALENDARVIEW_H
27 
28 #include <tqwidget.h>
29 #include <tqptrlist.h>
30 #include <tqmap.h>
31 #include <tdefile.h>
32 #include <korganizer/koeventviewer.h>
33 #include <libkcal/scheduler.h>
34 #include <kdemacros.h>
35 
36 #include "koglobals.h"
37 #include "interfaces/korganizer/calendarviewbase.h"
38 
39 class TQWidgetStack;
40 class TQSplitter;
41 
42 class KOViewManager;
43 class KODialogManager;
44 class KOTodoView;
45 class KOEventEditor;
46 class DateNavigatorContainer;
47 class DateNavigator;
48 class KOIncidenceEditor;
49 class ResourceView;
50 class NavigatorBar;
51 class DateChecker;
52 
53 namespace KOrg { class History; class IncidenceChangerBase; }
54 class HTMLExportSettings;
55 
56 using namespace KOrg;
57 using namespace KCal;
58 
59 class CalendarViewExtension : public TQWidget
60 {
61  public:
62  CalendarViewExtension( TQWidget *parent, const char *name = 0 )
63  : TQWidget( parent, name ) {}
64 
65  class Factory
66  {
67  public:
68  virtual CalendarViewExtension *create( TQWidget *parent ) = 0;
69  };
70 };
71 
81 class TDE_EXPORT CalendarView : public KOrg::CalendarViewBase, public Calendar::Observer
82 {
83  TQ_OBJECT
84 
85  public:
92  CalendarView( TQWidget *parent = 0, const char *name = 0 );
93  virtual ~CalendarView();
94 
95  class CalendarViewVisitor : public IncidenceBase::Visitor
96  {
97  public:
98  CalendarViewVisitor() : mView( 0 ) {}
99  bool act( IncidenceBase *incidence, CalendarView *view )
100  {
101  mView = view;
102  return incidence->accept( *this );
103  }
104  protected:
105  CalendarView *mView;
106  };
107 
108  class CanDeleteIncidenceVisitor : public CalendarViewVisitor
109  {
110  protected:
111  bool visit( Event *event ) { return mView->deleteEvent( event ); }
112  bool visit( Todo *todo ) { return mView->deleteTodo( todo ); }
113  bool visit( Journal *journal ) { return mView->deleteJournal( journal ); }
114  };
115 
116  void setCalendar( Calendar * );
117  Calendar *calendar();
118 
119  TQPair<ResourceCalendar *, TQString> viewSubResourceCalendar();
120 
121  KOrg::History *history() const { return mHistory; }
122 
123  KOViewManager *viewManager() const { return mViewManager; }
124  KODialogManager *dialogManager() const { return mDialogManager; }
125 
126  TQWidgetStack *viewStack() const { return mRightFrame; }
127  TQWidget *leftFrame() const { return mLeftFrame; }
128  NavigatorBar *navigatorBar() const { return mNavigatorBar; }
129  DateNavigator *dateNavigator() const { return mDateNavigator; }
130 
131  KOIncidenceEditor *editorDialog( Incidence* ) const;
132  IncidenceChangerBase *incidenceChanger() const { return mChanger; }
133 
134  TQDate startDate();
135  TQDate endDate();
136 
137 
138  void addView( KOrg::BaseView * );
139  void showView( KOrg::BaseView * );
140 
145  void addExtension( CalendarViewExtension::Factory * );
146 
148  Incidence *currentSelection();
151  Incidence *selectedIncidence();
153  TQString currentFilterName() const;
154 
155  signals:
165  void closingDown();
167  void closed( TQWidget * );
168 
170  void modifiedChanged( bool );
171 
173  void readOnlyChanged( bool );
174 
176  void changeNavStringPrev( const TQString & );
177  void changeNavStringNext( const TQString & );
178 
182  void groupEventsSelected( bool );
187  void incidenceSelected( Incidence *incidence, const TQDate &date );
190  void todoSelected( bool );
191  void subtodoSelected( bool );
192 
195  void dayPassed( const TQDate & );
202 
203 
208  void pasteEnabled( bool );
210  void statusMessage( const TQString & );
211 
212  void calendarViewExpanded( bool );
213 
216 
217  void newIncidenceChanger( IncidenceChangerBase* );
218  void exportHTML( HTMLExportSettings* );
219 
220  void newFilterListSignal( const TQStringList & );
221  void selectFilterSignal( int );
222  void filterChanged();
223 
224  public slots:
227  void updateConfig( const TQCString& );
230  void updateCategories();
231 
232 
238  bool openCalendar( const TQString &filename, bool merge = false );
239 
244  bool saveCalendar( const TQString &filename );
245 
250  void closeCalendar();
251 
253  void archiveCalendar();
254 
255  void showIncidence();
256  void editIncidence();
257  bool editIncidence( const TQString &uid );
258  bool editIncidence( const TQString &uid, const TQDate &date );
259  void deleteIncidence();
260 
269  bool addIncidence( const TQString &ical );
270 
271  void connectIncidenceEditor( KOIncidenceEditor *editor );
272 
275  void newEvent();
276  void newEvent( ResourceCalendar *res, const TQString &subRes );
279  void newEvent( ResourceCalendar *res, const TQString &subRes,
280  const TQDate &startDt );
281  void newEvent( ResourceCalendar *res, const TQString &subRes,
282  const TQDateTime &startDt );
283  void newEvent( ResourceCalendar *res, const TQString &subRes,
284  const TQDateTime &startDt, const TQDateTime &EndDt,
285  bool allDay = false );
290  void newEvent( ResourceCalendar *res, const TQString &subRes,
291  const TQString &summary,
292  const TQString &description = TQString(),
293  const TQStringList &attachment = TQStringList(),
294  const TQStringList &attendees = TQStringList(),
295  const TQStringList &attachmentMimetypes = TQStringList(),
296  bool inlineAttachment = false );
297 
299  void showIncidence( Incidence *, const TQDate & );
301  bool editIncidence( Incidence *incidence, const TQDate &date, bool isCounter = false );
307  void deleteIncidence( Incidence *, bool force = false );
311  void cutIncidence( Incidence * );
315  void copyIncidence( Incidence *);
319  void pasteIncidence();
320 
322  void deleteSubTodosIncidence ( Todo *todo );
328  void deleteTodoIncidence ( Todo *todo, bool force = false );
330  bool deleteEvent( Event * ) { return true; }
332  bool deleteTodo( Todo * ) {return true; }
334  bool deleteJournal( Journal * ) { return true; }
341  bool deleteIncidence( const TQString &uid, bool force = false );
342 
344  void newTodo();
345  void newTodo( ResourceCalendar *res, const TQString &subRes );
347  void newTodo( ResourceCalendar *res, const TQString &subRes,
348  const TQDate &date );
350  void newSubTodo();
352  void newSubTodo( Todo * );
353 
354  void newTodo( ResourceCalendar *res, const TQString &subRes,
355  const TQString &summary,
356  const TQString &description = TQString(),
357  const TQStringList &attachments = TQStringList(),
358  const TQStringList &attendees = TQStringList(),
359  const TQStringList &attachmentMimetypes = TQStringList(),
360  bool inlineAttachment = false, bool createTask = false );
361 
362  void newJournal();
363  void newJournal( ResourceCalendar *res, const TQString &subRes );
364  void newJournal( ResourceCalendar *res, const TQString &subRes,
365  const TQDate &date );
366  void newJournal( ResourceCalendar *res, const TQString &subRes,
367  const TQString &text, const TQDate &date = TQDate() );
368 
369  void toggleAlarm( Incidence * );
370  void dissociateOccurrence( Incidence *, const TQDate & );
371  void dissociateFutureOccurrence( Incidence *, const TQDate & );
372 
373 
378  void checkClipboard();
379 
386  void readSettings();
387 
389  void writeSettings();
390 
392  void readFilterSettings( TDEConfig *config );
393 
395  void writeFilterSettings( TDEConfig *config );
396 
399  void changeIncidenceDisplay( Incidence *, int );
400 
401  void incidenceAdded( Incidence * );
402  void incidenceChanged( Incidence *oldEvent, Incidence *newEvent,
403  KOGlobals::WhatChanged modification );
404  void incidenceToBeDeleted( Incidence *incidence );
405  void incidenceDeleted( Incidence * );
406  void startMultiModify( const TQString &text );
407  void endMultiModify();
408 
409  void editCanceled( Incidence * );
410 
411  void updateView( const TQDate &start, const TQDate &end );
412  void updateView();
413 
414  void updateUnmanagedViews();
415 
417  void edit_cut();
418 
420  void edit_copy();
421 
423  void edit_paste();
424 
426  void edit_options();
427 
432  void print();
433 
435  void exportWeb();
436 
438  void exportICalendar();
439 
441  void exportVCalendar();
442 
444  void appointment_show();
450  void appointment_edit();
455  void appointment_delete();
456 
457  /* frees the selected to-do's children from it's relation, update the view */
458  void todo_unsub();
459 
460  /* frees an incidence's children from it's relation, without update the view
461  Works with any incidence type, although currently we only pass to-dos
462  */
463  bool incidence_unsub( Incidence *inc );
464 
466  bool makeSubTodosIndependent ( );
467 
471  bool makeChildrenIndependent( Incidence *inc );
472 
474  void takeOverEvent();
475 
477  void takeOverCalendar();
478 
480  bool isModified();
482  void setModified( bool modified = true );
483 
485  bool isReadOnly();
487  void setReadOnly( bool readOnly = true );
488 
489  void eventUpdated( Incidence * );
490 
491  /* iTIP scheduling actions */
492  void schedule_publish( Incidence *incidence = 0 );
493  void schedule_request( Incidence *incidence = 0 );
494  void schedule_refresh( Incidence *incidence = 0 );
495  void schedule_cancel( Incidence *incidence = 0 );
496  void schedule_add( Incidence *incidence = 0 );
497  void schedule_reply( Incidence *incidence = 0 );
498  void schedule_counter( Incidence *incidence = 0 );
499  void schedule_declinecounter( Incidence *incidence = 0 );
500  void schedule_forward( Incidence *incidence = 0 );
501  void mailFreeBusy( int daysToPublish = 30 );
502  void uploadFreeBusy();
503 
504  void openAddressbook();
505 
506  void editFilters();
507 
508  void updateFilter();
509 
510  void showIntro();
511 
512  void showDateNavigator( bool );
513  void showTodoView( bool );
514  void showEventViewer( bool );
515 
517  void goDate( const TQDate& date );
518 
520  void showDate( const TQDate &date );
521 
523  void goToday();
524 
526  void goNext();
527 
529  void goPrevious();
530 
531  void toggleExpand();
532  void showLeftFrame( bool show = true );
533 
534  void dialogClosing( Incidence * );
535 
536  void processMainViewSelection( Incidence *incidence, const TQDate &date );
537  void processTodoListSelection( Incidence *incidence, const TQDate &date );
538 
539  void processIncidenceSelection( Incidence *incidence, const TQDate &date );
540 
541  void purgeCompleted();
542 
543  void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); }
544 
545  void showErrorMessage( const TQString & );
546  void schedule( Scheduler::Method, Incidence *incidence );
547  void addIncidenceOn( Incidence *, const TQDate & );
548  void moveIncidenceTo( Incidence *, const TQDate & );
549  void filterActivated( int filterNum );
550 
551  void resourcesChanged();
552 
559  void selectWeek( const TQDate & );
560 
561  protected slots:
566  void showDates( const KCal::DateList &, const TQDate &preferredMonth = TQDate() );
567 
568  public:
569  // show a standard warning
570  // returns KMsgBox::yesNoCancel()
571  int msgCalModified();
572 
576  void adaptNavigationUnits();
577 
584  TQDate activeIncidenceDate();
585 
596  TQDate activeDate( bool fallbackToToday = false );
597 
619  Incidence* singleOccurrenceOrAll( Incidence *inc,
620  KOGlobals::OccurrenceAction userAction,
621  KOGlobals::WhichOccurrences &chosenOption,
622  const TQDate &itemDate = TQDate(),
623  const bool commitToCalendar = false );
624 
625  protected:
626  void setIncidenceChanger( IncidenceChangerBase *changer );
627 
628 // // returns KMsgBox::OKCancel()
629  int msgItemDelete( Incidence *incidence );
630 
631  Todo *selectedTodo();
632 
633  void warningChangeFailed( Incidence * );
634  void checkForFilteredChange( Incidence *incidence );
638  void dateTimesForNewEvent( TQDateTime &startDt, TQDateTime &endDt, bool &allDay );
639  KOEventEditor *newEventEditor( ResourceCalendar *res, const TQString &subRes,
640  const TQDateTime &startDtParam = TQDateTime(),
641  const TQDateTime &endDtParam = TQDateTime() ,
642  bool allDayParam = false );
643 
644  private:
645  void init();
646 
653  Incidence *incToSendToClipboard( bool cut );
654 
655  void calendarModified( bool, Calendar * );
656  // Helper function for purgeCompleted that recursively purges a todo and
657  // its subitems. If it cannot delete a completed todo (because it has
658  // uncompleted subitems), notAllPurged is set to true.
659  bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
660 
664  void getIncidenceHierarchy( Incidence *inc, Incidence::List &incidences );
665 
666  KOrg::History *mHistory;
667 
668  TQSplitter *mPanner;
669  TQSplitter *mLeftSplitter;
670  TQWidget *mLeftFrame;
671  TQWidgetStack *mRightFrame;
672 
673  // This navigator bar is used when in full window month view
674  // It has nothing to do with the date navigator
675  NavigatorBar *mNavigatorBar;
676 
677  DateNavigatorContainer *mDateNavigatorContainer;
678 
679 
680  TQPtrList<CalendarViewExtension> mExtensions;
681 
682  Calendar *mCalendar;
683 
684  DateNavigator *mDateNavigator;
685  DateChecker *mDateChecker;
686 
687  KOEventViewer *mEventViewer;
688  KOViewManager *mViewManager;
689  KODialogManager *mDialogManager;
690 
691  // Calendar filters
692  TQPtrList<CalFilter> mFilters;
693  CalFilter *mCurrentFilter;
694 
695  // various housekeeping variables.
696  bool mModified; // flag indicating if calendar is modified
697  bool mReadOnly; // flag indicating if calendar is read-only
698 
699  Incidence *mSelectedIncidence;
700  TQDate mSaveDate;
701 
702  KOTodoView *mTodoList;
703  TQMap<Incidence*,KOIncidenceEditor*> mDialogList;
704 
705  KOrg::IncidenceChangerBase *mChanger;
706 };
707 
708 
709 
710 
711 #endif
This is the main calendar widget.
Definition: calendarview.h:82
void groupEventsSelected(bool)
Emitted when state of events selection has changed and user is attendee.
void statusMessage(const TQString &)
Send status message, which can e.g.
bool deleteTodo(Todo *)
Check if deleting the todo is allowed.
Definition: calendarview.h:332
void dayPassed(const TQDate &)
Emitted, when a day changed (i.e.
void pasteEnabled(bool)
Emitted, when clipboard content changes.
bool deleteEvent(Event *)
Check if deleting the supplied event is allowed.
Definition: calendarview.h:330
void modifiedChanged(bool)
Emitted when state of modified flag changes.
void cancelAttendees(Incidence *)
Attendees were removed from this incidence.
void organizerEventsSelected(bool)
Emitted when state of events selection has changed and user is organizer.
bool deleteJournal(Journal *)
Check if deleting the supplied journal is allowed.
Definition: calendarview.h:334
void incidenceSelected(Incidence *incidence, const TQDate &date)
Emitted when an incidence gets selected.
void closed(TQWidget *)
emitted right before we die
void configChanged()
when change is made to options dialog, the topwidget will catch this and emit this signal which notif...
void changeNavStringPrev(const TQString &)
Emitted when the unit of navigation changes.
void readOnlyChanged(bool)
Emitted when state of read-only flag changes.
void categoriesChanged()
Emitted when the categories were updated, and thus the categories editor dialog needs to reload the l...
void closingDown()
emitted when the topwidget is closing down, so that any attached child windows can also close.
void todoSelected(bool)
Emitted, when a todoitem is selected or deselected.
void autoArchivingSettingsModified()
Emitted when auto-archiving options were modified.
This class controls date navigation.
Definition: datenavigator.h:37
virtual bool accept(Visitor &)
This class manages the dialogs used by the calendar view.
This class provides a dialog for editing an event.
Definition: koeventeditor.h:49
Viewer widget for events.
Definition: koeventviewer.h:41
This is the base class for the calendar component editors.
This class provides a multi-column list view of todo events.
Definition: kotodoview.h:114
This class manages the views of the calendar.
Definition: koviewmanager.h:53
This class provides an interface for all views being displayed within the main calendar view.
Definition: baseview.h:60
interface for main calendar view widget
This class provides a view of calendar resources.
Definition: resourceview.h:96
bool view(TQWidget *parent, Attachment *attachment)