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 mNavigator; }
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     void deleteIncidence();
00258 
00267     bool addIncidence( const QString &ical );
00268 
00269     void connectIncidenceEditor( KOIncidenceEditor *editor );
00270 
00273     void newEvent();
00274     void newEvent( ResourceCalendar *res, const QString &subRes );
00277     void newEvent( ResourceCalendar *res, const QString &subRes,
00278                    const QDate &startDt );
00279     void newEvent( ResourceCalendar *res, const QString &subRes,
00280                    const QDateTime &startDt );
00281     void newEvent( ResourceCalendar *res, const QString &subRes,
00282                    const QDateTime &startDt, const QDateTime &EndDt,
00283                    bool allDay = false );
00288     void newEvent( ResourceCalendar *res, const QString &subRes,
00289                    const QString &summary,
00290                    const QString &description = QString::null,
00291                    const QStringList &attachment = QStringList(),
00292                    const QStringList &attendees = QStringList(),
00293                    const QStringList &attachmentMimetypes = QStringList(),
00294                    bool inlineAttachment = false );
00295 
00297     void showIncidence( Incidence * );
00299     bool editIncidence( Incidence *incidence, bool isCounter = false );
00305     void deleteIncidence( Incidence *, bool force = false );
00309     void cutIncidence( Incidence * );
00313     void copyIncidence( Incidence *);
00317     void pasteIncidence();
00318 
00320     void deleteSubTodosIncidence ( Todo *todo );
00326     void deleteTodoIncidence ( Todo *todo, bool force = false );
00328     bool deleteEvent( Event * ) { return true; }
00330     bool deleteTodo( Todo * ) {return true; }
00332     bool deleteJournal( Journal * ) { return true; }
00339     bool deleteIncidence( const QString &uid, bool force = false );
00340 
00342     void newTodo();
00343     void newTodo( ResourceCalendar *res, const QString &subRes );
00345     void newTodo( ResourceCalendar *res, const QString &subRes,
00346                   const QDate &date );
00348     void newSubTodo();
00350     void newSubTodo( Todo * );
00351 
00352     void newTodo( ResourceCalendar *res, const QString &subRes,
00353                   const QString &summary,
00354                   const QString &description = QString::null,
00355                   const QStringList &attachments = QStringList(),
00356                   const QStringList &attendees = QStringList(),
00357                   const QStringList &attachmentMimetypes = QStringList(),
00358                   bool inlineAttachment = false, bool createTask = false );
00359 
00360     void newJournal();
00361     void newJournal( ResourceCalendar *res, const QString &subRes );
00362     void newJournal( ResourceCalendar *res, const QString &subRes,
00363                      const QDate &date );
00364     void newJournal( ResourceCalendar *res, const QString &subRes,
00365                      const QString &text, const QDate &date = QDate() );
00366 
00367     void toggleAlarm( Incidence * );
00368     void dissociateOccurrence( Incidence *, const QDate & );
00369     void dissociateFutureOccurrence( Incidence *, const QDate & );
00370 
00371 
00376     void checkClipboard();
00377 
00384     void readSettings();
00385 
00387     void writeSettings();
00388 
00390     void readFilterSettings( KConfig *config );
00391 
00393     void writeFilterSettings( KConfig *config );
00394 
00397     void changeIncidenceDisplay( Incidence *, int );
00398 
00399     void incidenceAdded( Incidence * );
00400     void incidenceChanged( Incidence *oldEvent, Incidence *newEvent,
00401                            KOGlobals::WhatChanged modification );
00402     void incidenceToBeDeleted( Incidence *incidence );
00403     void incidenceDeleted( Incidence * );
00404     void startMultiModify( const QString &text );
00405     void endMultiModify();
00406 
00407     void editCanceled( Incidence * );
00408 
00409     void updateView( const QDate &start, const QDate &end );
00410     void updateView();
00411 
00412     void updateUnmanagedViews();
00413 
00415     void edit_cut();
00416 
00418     void edit_copy();
00419 
00421     void edit_paste();
00422 
00424     void edit_options();
00425 
00430     void print();
00431 
00433     void exportWeb();
00434 
00436     void exportICalendar();
00437 
00439     void exportVCalendar();
00440 
00442     void appointment_show();
00448     void appointment_edit();
00453     void appointment_delete();
00454 
00455     /* frees a subtodo from it's relation, update the view */
00456     void todo_unsub();
00457     /* Free a subtodo from it's relation, without update the view */
00458     bool todo_unsub( Todo *todo );
00460     bool makeSubTodosIndependents ( );
00462     bool makeSubTodosIndependents ( Todo *todo );
00463 
00465     void takeOverEvent();
00466 
00468     void takeOverCalendar();
00469 
00471     bool isModified();
00473     void setModified( bool modified = true );
00474 
00476     bool isReadOnly();
00478     void setReadOnly( bool readOnly = true );
00479 
00480     void eventUpdated( Incidence * );
00481 
00482     /* iTIP scheduling actions */
00483     void schedule_publish( Incidence *incidence = 0 );
00484     void schedule_request( Incidence *incidence = 0 );
00485     void schedule_refresh( Incidence *incidence = 0 );
00486     void schedule_cancel( Incidence *incidence = 0 );
00487     void schedule_add( Incidence *incidence = 0 );
00488     void schedule_reply( Incidence *incidence = 0 );
00489     void schedule_counter( Incidence *incidence = 0 );
00490     void schedule_declinecounter( Incidence *incidence = 0 );
00491     void schedule_forward( Incidence *incidence = 0 );
00492     void mailFreeBusy( int daysToPublish = 30 );
00493     void uploadFreeBusy();
00494 
00495     void openAddressbook();
00496 
00497     void editFilters();
00498 
00499     void updateFilter();
00500 
00501     void showIntro();
00502 
00503     void showDateNavigator( bool );
00504     void showTodoView( bool );
00505     void showEventViewer( bool );
00506 
00508     void goDate( const QDate& date );
00509 
00511     void showDate( const QDate &date );
00512 
00514     void goToday();
00515 
00517     void goNext();
00518 
00520     void goPrevious();
00521 
00522     void toggleExpand();
00523     void showLeftFrame( bool show = true );
00524 
00525     void dialogClosing( Incidence * );
00526 
00527     void processMainViewSelection( Incidence *incidence, const QDate &date );
00528     void processTodoListSelection( Incidence *incidence, const QDate &date );
00529 
00530     void processIncidenceSelection( Incidence *incidence, const QDate &date );
00531 
00532     void purgeCompleted();
00533 
00534     void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); }
00535 
00536     void showErrorMessage( const QString & );
00537     void schedule( Scheduler::Method, Incidence *incidence );
00538     void addIncidenceOn( Incidence *, const QDate & );
00539     void moveIncidenceTo( Incidence *, const QDate & );
00540     void filterActivated( int filterNum );
00541 
00542     void resourcesChanged();
00543 
00544   protected slots:
00546     void showDates( const KCal::DateList & );
00547 
00548   public:
00549     // show a standard warning
00550     // returns KMsgBox::yesNoCancel()
00551     int msgCalModified();
00552 
00556     void adaptNavigationUnits();
00557 
00565     QDate activeDate( bool fallbackToToday = false );
00566 
00567   protected:
00568     void setIncidenceChanger( IncidenceChangerBase *changer );
00569 
00570 //     // returns KMsgBox::OKCancel()
00571     int msgItemDelete( Incidence *incidence );
00572 
00573     Todo *selectedTodo();
00574 
00575     void warningChangeFailed( Incidence * );
00576     void checkForFilteredChange( Incidence *incidence );
00580     void dateTimesForNewEvent( QDateTime &startDt, QDateTime &endDt, bool &allDay );
00581     KOEventEditor *newEventEditor( ResourceCalendar *res, const QString &subRes,
00582                                    const QDateTime &startDtParam = QDateTime(),
00583                                    const QDateTime &endDtParam = QDateTime() ,
00584                                    bool allDayParam = false );
00585 
00586   private:
00587     void init();
00588 
00589     void calendarModified( bool, Calendar * );
00590     // Helper function for purgeCompleted that recursively purges a todo and
00591     // its subitems. If it cannot delete a completed todo (because it has
00592     // uncompleted subitems), notAllPurged is set to true.
00593     bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
00594 
00595     KOrg::History *mHistory;
00596 
00597     QSplitter    *mPanner;
00598     QSplitter    *mLeftSplitter;
00599     QWidget      *mLeftFrame;
00600     QWidgetStack *mRightFrame;
00601 
00602     NavigatorBar *mNavigatorBar;
00603 
00604     DateNavigatorContainer *mDateNavigator;
00605 
00606 
00607     QPtrList<CalendarViewExtension> mExtensions;
00608 
00609     Calendar *mCalendar;
00610 
00611     DateNavigator *mNavigator;
00612     DateChecker *mDateChecker;
00613 
00614     KOEventViewer *mEventViewer;
00615     KOViewManager *mViewManager;
00616     KODialogManager *mDialogManager;
00617 
00618     // Calendar filters
00619     QPtrList<CalFilter> mFilters;
00620     CalFilter *mCurrentFilter;
00621 
00622     // various housekeeping variables.
00623     bool            mModified; // flag indicating if calendar is modified
00624     bool            mReadOnly; // flag indicating if calendar is read-only
00625 
00626     Incidence *mSelectedIncidence;
00627     QDate mSaveDate;
00628 
00629     KOTodoView *mTodoList;
00630     QMap<Incidence*,KOIncidenceEditor*> mDialogList;
00631 
00632     KOrg::IncidenceChangerBase *mChanger;
00633 };
00634 
00635 
00636 
00637 
00638 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys