korganizer

calendarview.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001,2003,2004 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 #ifndef CALENDARVIEW_H
00026 #define CALENDARVIEW_H
00027 
00028 #include <qwidget.h>
00029 #include <qptrlist.h>
00030 #include <qmap.h>
00031 #include <kfile.h>
00032 #include <korganizer/koeventviewer.h>
00033 #include <libkcal/scheduler.h>
00034 #include <kdepimmacros.h>
00035 
00036 #include "koglobals.h"
00037 #include "interfaces/korganizer/calendarviewbase.h"
00038 
00039 class QWidgetStack;
00040 class QSplitter;
00041 
00042 class KOViewManager;
00043 class KODialogManager;
00044 class KOTodoView;
00045 class KOEventEditor;
00046 class DateNavigatorContainer;
00047 class DateNavigator;
00048 class KOIncidenceEditor;
00049 class ResourceView;
00050 class NavigatorBar;
00051 class DateChecker;
00052 
00053 namespace KOrg { class History; class IncidenceChangerBase; }
00054 class HTMLExportSettings;
00055 
00056 using namespace KOrg;
00057 using namespace KCal;
00058 
00059 class CalendarViewExtension : public QWidget
00060 {
00061   public:
00062     CalendarViewExtension( QWidget *parent, const char *name = 0 )
00063       : QWidget( parent, name ) {}
00064 
00065     class Factory
00066     {
00067       public:
00068         virtual CalendarViewExtension *create( QWidget *parent ) = 0;
00069     };
00070 };
00071 
00081 class KDE_EXPORT CalendarView : public KOrg::CalendarViewBase, public Calendar::Observer
00082 {
00083     Q_OBJECT
00084   public:
00091     CalendarView( QWidget *parent = 0, const char *name = 0 );
00092     virtual ~CalendarView();
00093 
00094     class CalendarViewVisitor : public IncidenceBase::Visitor
00095     {
00096       public:
00097         CalendarViewVisitor() : mView( 0 ) {}
00098         bool act( IncidenceBase *incidence, CalendarView *view )
00099         {
00100           mView = view;
00101           return incidence->accept( *this );
00102         }
00103       protected:
00104         CalendarView *mView;
00105     };
00106 
00107     class CanDeleteIncidenceVisitor : public CalendarViewVisitor
00108     {
00109       protected:
00110         bool visit( Event *event ) { return mView->deleteEvent( event ); }
00111         bool visit( Todo *todo ) { return mView->deleteTodo( todo ); }
00112         bool visit( Journal *journal ) { return mView->deleteJournal( journal ); }
00113     };
00114 
00115     void setCalendar( Calendar * );
00116     Calendar *calendar();
00117 
00118     QPair<ResourceCalendar *, QString> viewSubResourceCalendar();
00119 
00120     KOrg::History *history() const { return mHistory; }
00121 
00122     KOViewManager *viewManager() const { return mViewManager; }
00123     KODialogManager *dialogManager() const { return mDialogManager; }
00124 
00125     QWidgetStack *viewStack() const { return mRightFrame; }
00126     QWidget *leftFrame() const { return mLeftFrame; }
00127     NavigatorBar *navigatorBar() const { return mNavigatorBar; }
00128     DateNavigator *dateNavigator() const { return mDateNavigator; }
00129 
00130     KOIncidenceEditor *editorDialog( Incidence* ) const;
00131     IncidenceChangerBase *incidenceChanger() const { return mChanger; }
00132 
00133     QDate startDate();
00134     QDate endDate();
00135 
00136 
00137     void addView( KOrg::BaseView * );
00138     void showView( KOrg::BaseView * );
00139 
00144     void addExtension( CalendarViewExtension::Factory * );
00145 
00147     Incidence *currentSelection();
00150     Incidence *selectedIncidence();
00152     QString currentFilterName() const;
00153 
00154   signals:
00158     void configChanged();
00161     void categoriesChanged();
00164     void closingDown();
00166     void closed( QWidget * );
00167 
00169     void modifiedChanged( bool );
00170 
00172     void readOnlyChanged( bool );
00173 
00175     void changeNavStringPrev( const QString & );
00176     void changeNavStringNext( const QString & );
00177 
00179     void organizerEventsSelected( bool );
00181     void groupEventsSelected( bool );
00186     void incidenceSelected( Incidence *incidence, const QDate &date );
00189     void todoSelected( bool );
00190     void subtodoSelected( bool );
00191 
00194     void dayPassed( const QDate & );
00195 
00200     void pasteEnabled( bool );
00202     void statusMessage( const QString & );
00203 
00204     void calendarViewExpanded( bool );
00205 
00207     void autoArchivingSettingsModified();
00208 
00209     void newIncidenceChanger( IncidenceChangerBase* );
00210     void exportHTML( HTMLExportSettings* );
00211 
00212     void newFilterListSignal( const QStringList & );
00213     void selectFilterSignal( int );
00214     void filterChanged();
00215 
00216   public slots:
00219     void updateConfig( const QCString& );
00222     void updateCategories();
00223 
00224 
00230     bool openCalendar( const QString &filename, bool merge = false );
00231 
00236     bool saveCalendar( const QString &filename );
00237 
00242     void closeCalendar();
00243 
00245     void archiveCalendar();
00246 
00247     void showIncidence();
00248     void editIncidence();
00249     bool editIncidence( const QString &uid );
00250     bool editIncidence( const QString &uid, const QDate &date );
00251     void deleteIncidence();
00252 
00261     bool addIncidence( const QString &ical );
00262 
00263     void connectIncidenceEditor( KOIncidenceEditor *editor );
00264 
00267     void newEvent();
00268     void newEvent( ResourceCalendar *res, const QString &subRes );
00271     void newEvent( ResourceCalendar *res, const QString &subRes,
00272                    const QDate &startDt );
00273     void newEvent( ResourceCalendar *res, const QString &subRes,
00274                    const QDateTime &startDt );
00275     void newEvent( ResourceCalendar *res, const QString &subRes,
00276                    const QDateTime &startDt, const QDateTime &EndDt,
00277                    bool allDay = false );
00282     void newEvent( ResourceCalendar *res, const QString &subRes,
00283                    const QString &summary,
00284                    const QString &description = QString::null,
00285                    const QStringList &attachment = QStringList(),
00286                    const QStringList &attendees = QStringList(),
00287                    const QStringList &attachmentMimetypes = QStringList(),
00288                    bool inlineAttachment = false );
00289 
00291     void showIncidence( Incidence *, const QDate & );
00293     bool editIncidence( Incidence *incidence, const QDate &date, bool isCounter = false );
00299     void deleteIncidence( Incidence *, bool force = false );
00303     void cutIncidence( Incidence * );
00307     void copyIncidence( Incidence *);
00311     void pasteIncidence();
00312 
00314     void deleteSubTodosIncidence ( Todo *todo );
00320     void deleteTodoIncidence ( Todo *todo, bool force = false );
00322     bool deleteEvent( Event * ) { return true; }
00324     bool deleteTodo( Todo * ) {return true; }
00326     bool deleteJournal( Journal * ) { return true; }
00333     bool deleteIncidence( const QString &uid, bool force = false );
00334 
00336     void newTodo();
00337     void newTodo( ResourceCalendar *res, const QString &subRes );
00339     void newTodo( ResourceCalendar *res, const QString &subRes,
00340                   const QDate &date );
00342     void newSubTodo();
00344     void newSubTodo( Todo * );
00345 
00346     void newTodo( ResourceCalendar *res, const QString &subRes,
00347                   const QString &summary,
00348                   const QString &description = QString::null,
00349                   const QStringList &attachments = QStringList(),
00350                   const QStringList &attendees = QStringList(),
00351                   const QStringList &attachmentMimetypes = QStringList(),
00352                   bool inlineAttachment = false, bool createTask = false );
00353 
00354     void newJournal();
00355     void newJournal( ResourceCalendar *res, const QString &subRes );
00356     void newJournal( ResourceCalendar *res, const QString &subRes,
00357                      const QDate &date );
00358     void newJournal( ResourceCalendar *res, const QString &subRes,
00359                      const QString &text, const QDate &date = QDate() );
00360 
00361     void toggleAlarm( Incidence * );
00362     void dissociateOccurrence( Incidence *, const QDate & );
00363     void dissociateFutureOccurrence( Incidence *, const QDate & );
00364 
00365 
00370     void checkClipboard();
00371 
00378     void readSettings();
00379 
00381     void writeSettings();
00382 
00384     void readFilterSettings( KConfig *config );
00385 
00387     void writeFilterSettings( KConfig *config );
00388 
00391     void changeIncidenceDisplay( Incidence *, int );
00392 
00393     void incidenceAdded( Incidence * );
00394     void incidenceChanged( Incidence *oldEvent, Incidence *newEvent,
00395                            KOGlobals::WhatChanged modification );
00396     void incidenceToBeDeleted( Incidence *incidence );
00397     void incidenceDeleted( Incidence * );
00398     void startMultiModify( const QString &text );
00399     void endMultiModify();
00400 
00401     void editCanceled( Incidence * );
00402 
00403     void updateView( const QDate &start, const QDate &end );
00404     void updateView();
00405 
00406     void updateUnmanagedViews();
00407 
00409     void edit_cut();
00410 
00412     void edit_copy();
00413 
00415     void edit_paste();
00416 
00418     void edit_options();
00419 
00424     void print();
00425 
00427     void exportWeb();
00428 
00430     void exportICalendar();
00431 
00433     void exportVCalendar();
00434 
00436     void appointment_show();
00442     void appointment_edit();
00447     void appointment_delete();
00448 
00449     /* frees the selected to-do's children from it's relation, update the view */
00450     void todo_unsub();
00451 
00452     /* frees an incidence's children from it's relation, without update the view
00453        Works with any incidence type, although currently we only pass to-dos
00454     */
00455     bool incidence_unsub( Incidence *inc );
00456 
00458     bool makeSubTodosIndependent ( );
00459 
00463     bool makeChildrenIndependent( Incidence *inc );
00464 
00466     void takeOverEvent();
00467 
00469     void takeOverCalendar();
00470 
00472     bool isModified();
00474     void setModified( bool modified = true );
00475 
00477     bool isReadOnly();
00479     void setReadOnly( bool readOnly = true );
00480 
00481     void eventUpdated( Incidence * );
00482 
00483     /* iTIP scheduling actions */
00484     void schedule_publish( Incidence *incidence = 0 );
00485     void schedule_request( Incidence *incidence = 0 );
00486     void schedule_refresh( Incidence *incidence = 0 );
00487     void schedule_cancel( Incidence *incidence = 0 );
00488     void schedule_add( Incidence *incidence = 0 );
00489     void schedule_reply( Incidence *incidence = 0 );
00490     void schedule_counter( Incidence *incidence = 0 );
00491     void schedule_declinecounter( Incidence *incidence = 0 );
00492     void schedule_forward( Incidence *incidence = 0 );
00493     void mailFreeBusy( int daysToPublish = 30 );
00494     void uploadFreeBusy();
00495 
00496     void openAddressbook();
00497 
00498     void editFilters();
00499 
00500     void updateFilter();
00501 
00502     void showIntro();
00503 
00504     void showDateNavigator( bool );
00505     void showTodoView( bool );
00506     void showEventViewer( bool );
00507 
00509     void goDate( const QDate& date );
00510 
00512     void showDate( const QDate &date );
00513 
00515     void goToday();
00516 
00518     void goNext();
00519 
00521     void goPrevious();
00522 
00523     void toggleExpand();
00524     void showLeftFrame( bool show = true );
00525 
00526     void dialogClosing( Incidence * );
00527 
00528     void processMainViewSelection( Incidence *incidence, const QDate &date );
00529     void processTodoListSelection( Incidence *incidence, const QDate &date );
00530 
00531     void processIncidenceSelection( Incidence *incidence, const QDate &date );
00532 
00533     void purgeCompleted();
00534 
00535     void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); }
00536 
00537     void showErrorMessage( const QString & );
00538     void schedule( Scheduler::Method, Incidence *incidence );
00539     void addIncidenceOn( Incidence *, const QDate & );
00540     void moveIncidenceTo( Incidence *, const QDate & );
00541     void filterActivated( int filterNum );
00542 
00543     void resourcesChanged();
00544 
00551     void selectWeek( const QDate & );
00552 
00553   protected slots:
00558     void showDates( const KCal::DateList &, const QDate &preferredMonth = QDate() );
00559 
00560   public:
00561     // show a standard warning
00562     // returns KMsgBox::yesNoCancel()
00563     int msgCalModified();
00564 
00568     void adaptNavigationUnits();
00569 
00576     QDate activeIncidenceDate();
00577 
00588     QDate activeDate( bool fallbackToToday = false );
00589 
00611     Incidence* singleOccurrenceOrAll( Incidence *inc,
00612                                       KOGlobals::OccurrenceAction userAction,
00613                                       KOGlobals::WhichOccurrences &chosenOption,
00614                                       const QDate &itemDate = QDate(),
00615                                       const bool commitToCalendar = false );
00616 
00617   protected:
00618     void setIncidenceChanger( IncidenceChangerBase *changer );
00619 
00620 //     // returns KMsgBox::OKCancel()
00621     int msgItemDelete( Incidence *incidence );
00622 
00623     Todo *selectedTodo();
00624 
00625     void warningChangeFailed( Incidence * );
00626     void checkForFilteredChange( Incidence *incidence );
00630     void dateTimesForNewEvent( QDateTime &startDt, QDateTime &endDt, bool &allDay );
00631     KOEventEditor *newEventEditor( ResourceCalendar *res, const QString &subRes,
00632                                    const QDateTime &startDtParam = QDateTime(),
00633                                    const QDateTime &endDtParam = QDateTime() ,
00634                                    bool allDayParam = false );
00635 
00636   private:
00637     void init();
00638 
00645     Incidence *incToSendToClipboard( bool cut );
00646 
00647     void calendarModified( bool, Calendar * );
00648     // Helper function for purgeCompleted that recursively purges a todo and
00649     // its subitems. If it cannot delete a completed todo (because it has
00650     // uncompleted subitems), notAllPurged is set to true.
00651     bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
00652 
00656     void getIncidenceHierarchy( Incidence *inc, Incidence::List &incidences );
00657 
00658     KOrg::History *mHistory;
00659 
00660     QSplitter    *mPanner;
00661     QSplitter    *mLeftSplitter;
00662     QWidget      *mLeftFrame;
00663     QWidgetStack *mRightFrame;
00664 
00665     // This navigator bar is used when in full window month view
00666     // It has nothing to do with the date navigator
00667     NavigatorBar *mNavigatorBar;
00668 
00669     DateNavigatorContainer *mDateNavigatorContainer;
00670 
00671 
00672     QPtrList<CalendarViewExtension> mExtensions;
00673 
00674     Calendar *mCalendar;
00675 
00676     DateNavigator *mDateNavigator;
00677     DateChecker *mDateChecker;
00678 
00679     KOEventViewer *mEventViewer;
00680     KOViewManager *mViewManager;
00681     KODialogManager *mDialogManager;
00682 
00683     // Calendar filters
00684     QPtrList<CalFilter> mFilters;
00685     CalFilter *mCurrentFilter;
00686 
00687     // various housekeeping variables.
00688     bool            mModified; // flag indicating if calendar is modified
00689     bool            mReadOnly; // flag indicating if calendar is read-only
00690 
00691     Incidence *mSelectedIncidence;
00692     QDate mSaveDate;
00693 
00694     KOTodoView *mTodoList;
00695     QMap<Incidence*,KOIncidenceEditor*> mDialogList;
00696 
00697     KOrg::IncidenceChangerBase *mChanger;
00698 };
00699 
00700 
00701 
00702 
00703 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys