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 the selected to-do's children from it's relation, update the view */
00457     void todo_unsub();
00458 
00459     /* frees an incidence's children from it's relation, without update the view
00460        Works with any incidence type, although currently we only pass to-dos
00461     */
00462     bool incidence_unsub( Incidence *inc );
00463 
00465     bool makeSubTodosIndependent ( );
00466 
00470     bool makeChildrenIndependent( Incidence *inc );
00471 
00473     void takeOverEvent();
00474 
00476     void takeOverCalendar();
00477 
00479     bool isModified();
00481     void setModified( bool modified = true );
00482 
00484     bool isReadOnly();
00486     void setReadOnly( bool readOnly = true );
00487 
00488     void eventUpdated( Incidence * );
00489 
00490     /* iTIP scheduling actions */
00491     void schedule_publish( Incidence *incidence = 0 );
00492     void schedule_request( Incidence *incidence = 0 );
00493     void schedule_refresh( Incidence *incidence = 0 );
00494     void schedule_cancel( Incidence *incidence = 0 );
00495     void schedule_add( Incidence *incidence = 0 );
00496     void schedule_reply( Incidence *incidence = 0 );
00497     void schedule_counter( Incidence *incidence = 0 );
00498     void schedule_declinecounter( Incidence *incidence = 0 );
00499     void schedule_forward( Incidence *incidence = 0 );
00500     void mailFreeBusy( int daysToPublish = 30 );
00501     void uploadFreeBusy();
00502 
00503     void openAddressbook();
00504 
00505     void editFilters();
00506 
00507     void updateFilter();
00508 
00509     void showIntro();
00510 
00511     void showDateNavigator( bool );
00512     void showTodoView( bool );
00513     void showEventViewer( bool );
00514 
00516     void goDate( const QDate& date );
00517 
00519     void showDate( const QDate &date );
00520 
00522     void goToday();
00523 
00525     void goNext();
00526 
00528     void goPrevious();
00529 
00530     void toggleExpand();
00531     void showLeftFrame( bool show = true );
00532 
00533     void dialogClosing( Incidence * );
00534 
00535     void processMainViewSelection( Incidence *incidence, const QDate &date );
00536     void processTodoListSelection( Incidence *incidence, const QDate &date );
00537 
00538     void processIncidenceSelection( Incidence *incidence, const QDate &date );
00539 
00540     void purgeCompleted();
00541 
00542     void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); }
00543 
00544     void showErrorMessage( const QString & );
00545     void schedule( Scheduler::Method, Incidence *incidence );
00546     void addIncidenceOn( Incidence *, const QDate & );
00547     void moveIncidenceTo( Incidence *, const QDate & );
00548     void filterActivated( int filterNum );
00549 
00550     void resourcesChanged();
00551 
00558     void selectWeek( const QDate & );
00559 
00560   protected slots:
00565     void showDates( const KCal::DateList &, const QDate &preferredMonth = QDate() );
00566 
00567   public:
00568     // show a standard warning
00569     // returns KMsgBox::yesNoCancel()
00570     int msgCalModified();
00571 
00575     void adaptNavigationUnits();
00576 
00583     QDate activeIncidenceDate();
00584 
00595     QDate activeDate( bool fallbackToToday = false );
00596 
00618     Incidence* singleOccurrenceOrAll( Incidence *inc,
00619                                       KOGlobals::OccurrenceAction userAction,
00620                                       KOGlobals::WhichOccurrences &chosenOption,
00621                                       const QDate &itemDate = QDate(),
00622                                       const bool commitToCalendar = false );
00623 
00624   protected:
00625     void setIncidenceChanger( IncidenceChangerBase *changer );
00626 
00627 //     // returns KMsgBox::OKCancel()
00628     int msgItemDelete( Incidence *incidence );
00629 
00630     Todo *selectedTodo();
00631 
00632     void warningChangeFailed( Incidence * );
00633     void checkForFilteredChange( Incidence *incidence );
00637     void dateTimesForNewEvent( QDateTime &startDt, QDateTime &endDt, bool &allDay );
00638     KOEventEditor *newEventEditor( ResourceCalendar *res, const QString &subRes,
00639                                    const QDateTime &startDtParam = QDateTime(),
00640                                    const QDateTime &endDtParam = QDateTime() ,
00641                                    bool allDayParam = false );
00642 
00643   private:
00644     void init();
00645 
00652     Incidence *incToSendToClipboard( bool cut );
00653 
00654     void calendarModified( bool, Calendar * );
00655     // Helper function for purgeCompleted that recursively purges a todo and
00656     // its subitems. If it cannot delete a completed todo (because it has
00657     // uncompleted subitems), notAllPurged is set to true.
00658     bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
00659 
00663     void getIncidenceHierarchy( Incidence *inc, Incidence::List &incidences );
00664 
00665     KOrg::History *mHistory;
00666 
00667     QSplitter    *mPanner;
00668     QSplitter    *mLeftSplitter;
00669     QWidget      *mLeftFrame;
00670     QWidgetStack *mRightFrame;
00671 
00672     // This navigator bar is used when in full window month view
00673     // It has nothing to do with the date navigator
00674     NavigatorBar *mNavigatorBar;
00675 
00676     DateNavigatorContainer *mDateNavigatorContainer;
00677 
00678 
00679     QPtrList<CalendarViewExtension> mExtensions;
00680 
00681     Calendar *mCalendar;
00682 
00683     DateNavigator *mDateNavigator;
00684     DateChecker *mDateChecker;
00685 
00686     KOEventViewer *mEventViewer;
00687     KOViewManager *mViewManager;
00688     KODialogManager *mDialogManager;
00689 
00690     // Calendar filters
00691     QPtrList<CalFilter> mFilters;
00692     CalFilter *mCurrentFilter;
00693 
00694     // various housekeeping variables.
00695     bool            mModified; // flag indicating if calendar is modified
00696     bool            mReadOnly; // flag indicating if calendar is read-only
00697 
00698     Incidence *mSelectedIncidence;
00699     QDate mSaveDate;
00700 
00701     KOTodoView *mTodoList;
00702     QMap<Incidence*,KOIncidenceEditor*> mDialogList;
00703 
00704     KOrg::IncidenceChangerBase *mChanger;
00705 };
00706 
00707 
00708 
00709 
00710 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys