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 & );
00200     void cancelAttendees( Incidence * );
00201 
00202 
00207     void pasteEnabled( bool );
00209     void statusMessage( const QString & );
00210 
00211     void calendarViewExpanded( bool );
00212 
00214     void autoArchivingSettingsModified();
00215 
00216     void newIncidenceChanger( IncidenceChangerBase* );
00217     void exportHTML( HTMLExportSettings* );
00218 
00219     void newFilterListSignal( const QStringList & );
00220     void selectFilterSignal( int );
00221     void filterChanged();
00222 
00223   public slots:
00226     void updateConfig( const QCString& );
00229     void updateCategories();
00230 
00231 
00237     bool openCalendar( const QString &filename, bool merge = false );
00238 
00243     bool saveCalendar( const QString &filename );
00244 
00249     void closeCalendar();
00250 
00252     void archiveCalendar();
00253 
00254     void showIncidence();
00255     void editIncidence();
00256     bool editIncidence( const QString &uid );
00257     bool editIncidence( const QString &uid, const QDate &date );
00258     void deleteIncidence();
00259 
00268     bool addIncidence( const QString &ical );
00269 
00270     void connectIncidenceEditor( KOIncidenceEditor *editor );
00271 
00274     void newEvent();
00275     void newEvent( ResourceCalendar *res, const QString &subRes );
00278     void newEvent( ResourceCalendar *res, const QString &subRes,
00279                    const QDate &startDt );
00280     void newEvent( ResourceCalendar *res, const QString &subRes,
00281                    const QDateTime &startDt );
00282     void newEvent( ResourceCalendar *res, const QString &subRes,
00283                    const QDateTime &startDt, const QDateTime &EndDt,
00284                    bool allDay = false );
00289     void newEvent( ResourceCalendar *res, const QString &subRes,
00290                    const QString &summary,
00291                    const QString &description = QString::null,
00292                    const QStringList &attachment = QStringList(),
00293                    const QStringList &attendees = QStringList(),
00294                    const QStringList &attachmentMimetypes = QStringList(),
00295                    bool inlineAttachment = false );
00296 
00298     void showIncidence( Incidence *, const QDate & );
00300     bool editIncidence( Incidence *incidence, const QDate &date, bool isCounter = false );
00306     void deleteIncidence( Incidence *, bool force = false );
00310     void cutIncidence( Incidence * );
00314     void copyIncidence( Incidence *);
00318     void pasteIncidence();
00319 
00321     void deleteSubTodosIncidence ( Todo *todo );
00327     void deleteTodoIncidence ( Todo *todo, bool force = false );
00329     bool deleteEvent( Event * ) { return true; }
00331     bool deleteTodo( Todo * ) {return true; }
00333     bool deleteJournal( Journal * ) { return true; }
00340     bool deleteIncidence( const QString &uid, bool force = false );
00341 
00343     void newTodo();
00344     void newTodo( ResourceCalendar *res, const QString &subRes );
00346     void newTodo( ResourceCalendar *res, const QString &subRes,
00347                   const QDate &date );
00349     void newSubTodo();
00351     void newSubTodo( Todo * );
00352 
00353     void newTodo( ResourceCalendar *res, const QString &subRes,
00354                   const QString &summary,
00355                   const QString &description = QString::null,
00356                   const QStringList &attachments = QStringList(),
00357                   const QStringList &attendees = QStringList(),
00358                   const QStringList &attachmentMimetypes = QStringList(),
00359                   bool inlineAttachment = false, bool createTask = false );
00360 
00361     void newJournal();
00362     void newJournal( ResourceCalendar *res, const QString &subRes );
00363     void newJournal( ResourceCalendar *res, const QString &subRes,
00364                      const QDate &date );
00365     void newJournal( ResourceCalendar *res, const QString &subRes,
00366                      const QString &text, const QDate &date = QDate() );
00367 
00368     void toggleAlarm( Incidence * );
00369     void dissociateOccurrence( Incidence *, const QDate & );
00370     void dissociateFutureOccurrence( Incidence *, const QDate & );
00371 
00372 
00377     void checkClipboard();
00378 
00385     void readSettings();
00386 
00388     void writeSettings();
00389 
00391     void readFilterSettings( KConfig *config );
00392 
00394     void writeFilterSettings( KConfig *config );
00395 
00398     void changeIncidenceDisplay( Incidence *, int );
00399 
00400     void incidenceAdded( Incidence * );
00401     void incidenceChanged( Incidence *oldEvent, Incidence *newEvent,
00402                            KOGlobals::WhatChanged modification );
00403     void incidenceToBeDeleted( Incidence *incidence );
00404     void incidenceDeleted( Incidence * );
00405     void startMultiModify( const QString &text );
00406     void endMultiModify();
00407 
00408     void editCanceled( Incidence * );
00409 
00410     void updateView( const QDate &start, const QDate &end );
00411     void updateView();
00412 
00413     void updateUnmanagedViews();
00414 
00416     void edit_cut();
00417 
00419     void edit_copy();
00420 
00422     void edit_paste();
00423 
00425     void edit_options();
00426 
00431     void print();
00432 
00434     void exportWeb();
00435 
00437     void exportICalendar();
00438 
00440     void exportVCalendar();
00441 
00443     void appointment_show();
00449     void appointment_edit();
00454     void appointment_delete();
00455 
00456     /* frees a subtodo from it's relation, update the view */
00457     void todo_unsub();
00458     /* Free a subtodo from it's relation, without update the view */
00459     bool todo_unsub( Todo *todo );
00461     bool makeSubTodosIndependents ( );
00463     bool makeSubTodosIndependents ( Todo *todo );
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:
00555     void showDates( const KCal::DateList & );
00556 
00557   public:
00558     // show a standard warning
00559     // returns KMsgBox::yesNoCancel()
00560     int msgCalModified();
00561 
00565     void adaptNavigationUnits();
00566 
00573     QDate activeIncidenceDate();
00574 
00585     QDate activeDate( bool fallbackToToday = false );
00586 
00608     Incidence* singleOccurrenceOrAll( Incidence *inc,
00609                                       KOGlobals::OccurrenceAction userAction,
00610                                       KOGlobals::WhichOccurrences &chosenOption,
00611                                       const QDate &itemDate = QDate(),
00612                                       const bool commitToCalendar = false );
00613 
00614   protected:
00615     void setIncidenceChanger( IncidenceChangerBase *changer );
00616 
00617 //     // returns KMsgBox::OKCancel()
00618     int msgItemDelete( Incidence *incidence );
00619 
00620     Todo *selectedTodo();
00621 
00622     void warningChangeFailed( Incidence * );
00623     void checkForFilteredChange( Incidence *incidence );
00627     void dateTimesForNewEvent( QDateTime &startDt, QDateTime &endDt, bool &allDay );
00628     KOEventEditor *newEventEditor( ResourceCalendar *res, const QString &subRes,
00629                                    const QDateTime &startDtParam = QDateTime(),
00630                                    const QDateTime &endDtParam = QDateTime() ,
00631                                    bool allDayParam = false );
00632 
00633   private:
00634     void init();
00635 
00642     Incidence *incToSendToClipboard( bool cut );
00643 
00644     void calendarModified( bool, Calendar * );
00645     // Helper function for purgeCompleted that recursively purges a todo and
00646     // its subitems. If it cannot delete a completed todo (because it has
00647     // uncompleted subitems), notAllPurged is set to true.
00648     bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
00649 
00650     KOrg::History *mHistory;
00651 
00652     QSplitter    *mPanner;
00653     QSplitter    *mLeftSplitter;
00654     QWidget      *mLeftFrame;
00655     QWidgetStack *mRightFrame;
00656 
00657     NavigatorBar *mNavigatorBar;
00658 
00659     DateNavigatorContainer *mDateNavigatorContainer;
00660 
00661 
00662     QPtrList<CalendarViewExtension> mExtensions;
00663 
00664     Calendar *mCalendar;
00665 
00666     DateNavigator *mDateNavigator;
00667     DateChecker *mDateChecker;
00668 
00669     KOEventViewer *mEventViewer;
00670     KOViewManager *mViewManager;
00671     KODialogManager *mDialogManager;
00672 
00673     // Calendar filters
00674     QPtrList<CalFilter> mFilters;
00675     CalFilter *mCurrentFilter;
00676 
00677     // various housekeeping variables.
00678     bool            mModified; // flag indicating if calendar is modified
00679     bool            mReadOnly; // flag indicating if calendar is read-only
00680 
00681     Incidence *mSelectedIncidence;
00682     QDate mSaveDate;
00683 
00684     KOTodoView *mTodoList;
00685     QMap<Incidence*,KOIncidenceEditor*> mDialogList;
00686 
00687     KOrg::IncidenceChangerBase *mChanger;
00688 };
00689 
00690 
00691 
00692 
00693 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys