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 
00095     class CalendarViewVisitor : public IncidenceBase::Visitor
00096     {
00097       public:
00098         CalendarViewVisitor() : mView( 0 ) {}
00099         bool act( IncidenceBase *incidence, CalendarView *view )
00100         {
00101           mView = view;
00102           return incidence->accept( *this );
00103         }
00104       protected:
00105         CalendarView *mView;
00106     };
00107 
00108     class CanDeleteIncidenceVisitor : public CalendarViewVisitor
00109     {
00110       protected:
00111         bool visit( Event *event ) { return mView->deleteEvent( event ); }
00112         bool visit( Todo *todo ) { return mView->deleteTodo( todo ); }
00113         bool visit( Journal *journal ) { return mView->deleteJournal( journal ); }
00114     };
00115 
00116 
00117     void setCalendar( Calendar * );
00118     Calendar *calendar();
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 * );
00270 
00273     void newEvent();
00276     void newEvent( const QDate &startDt );
00277     void newEvent( const QDateTime &startDt );
00278     void newEvent( const QDateTime &startDt, const QDateTime &EndDt, bool allDay = false );
00283     void newEvent( const QString &summary, const QString &description = QString::null,
00284                    const QStringList &attachment = QStringList(), const QStringList &attendees = QStringList(),
00285                    const QStringList &attachmentMimetypes = QStringList(), bool inlineAttachment = false );
00286     void newFloatingEvent();
00287 
00289     void showIncidence( Incidence * );
00291     bool editIncidence( Incidence *incidence, bool isCounter = false );
00297     void deleteIncidence( Incidence *, bool force = false );
00301     void cutIncidence( Incidence * );
00305     void copyIncidence( Incidence *);
00309     void pasteIncidence();
00310 
00312     void deleteSubTodosIncidence ( Todo *todo );
00318     void deleteTodoIncidence ( Todo *todo, bool force = false );
00320     bool deleteEvent( Event * ) { return true; }
00322     bool deleteTodo( Todo * ) {return true; }
00324     bool deleteJournal( Journal * ) { return true; }
00331     bool deleteIncidence( const QString &uid, bool force = false );
00332 
00334     void newTodo();
00336     void newTodo( const QDate &date );
00338     void newSubTodo();
00340     void newSubTodo( Todo * );
00341 
00342     void newTodo( const QString &summary, const QString &description = QString::null,
00343                   const QStringList &attachments = QStringList(), const QStringList &attendees = QStringList(),
00344                   const QStringList &attachmentMimetypes = QStringList(),
00345                   bool inlineAttachment = false, bool createTask = false );
00346 
00347     void newJournal();
00348     void newJournal( const QDate &date );
00349     void newJournal( const QString &text, const QDate &date = QDate() );
00350 
00351     void toggleAlarm( Incidence * );
00352     void dissociateOccurrence( Incidence *, const QDate & );
00353     void dissociateFutureOccurrence( Incidence *, const QDate & );
00354 
00355 
00360     void checkClipboard();
00361 
00368     void readSettings();
00369 
00371     void writeSettings();
00372 
00374     void readFilterSettings( KConfig *config );
00375 
00377     void writeFilterSettings( KConfig *config );
00378 
00381     void changeIncidenceDisplay( Incidence *, int );
00382 
00383     void incidenceAdded( Incidence * );
00384     void incidenceChanged( Incidence *oldEvent, Incidence *newEvent,
00385                            KOGlobals::WhatChanged modification );
00386     void incidenceToBeDeleted( Incidence *incidence );
00387     void incidenceDeleted( Incidence * );
00388     void startMultiModify( const QString &text );
00389     void endMultiModify();
00390 
00391     void editCanceled( Incidence * );
00392 
00393     void updateView( const QDate &start, const QDate &end );
00394     void updateView();
00395 
00396     void updateUnmanagedViews();
00397 
00399     void edit_cut();
00400 
00402     void edit_copy();
00403 
00405     void edit_paste();
00406 
00408     void edit_options();
00409 
00414     void print();
00415 
00417     void exportWeb();
00418 
00420     void exportICalendar();
00421 
00423     void exportVCalendar();
00424 
00426     void appointment_show();
00432     void appointment_edit();
00437     void appointment_delete();
00438 
00439     /* frees a subtodo from it's relation, update the view */
00440     void todo_unsub();
00441     /* Free a subtodo from it's relation, without update the view */
00442     bool todo_unsub( Todo *todo );
00444     bool makeSubTodosIndependents ( );
00446     bool makeSubTodosIndependents ( Todo *todo );
00447 
00449     void takeOverEvent();
00450 
00452     void takeOverCalendar();
00453 
00455     bool isModified();
00457     void setModified( bool modified = true );
00458 
00460     bool isReadOnly();
00462     void setReadOnly( bool readOnly = true );
00463 
00464     void eventUpdated( Incidence * );
00465 
00466     /* iTIP scheduling actions */
00467     void schedule_publish( Incidence *incidence = 0 );
00468     void schedule_request( Incidence *incidence = 0 );
00469     void schedule_refresh( Incidence *incidence = 0 );
00470     void schedule_cancel( Incidence *incidence = 0 );
00471     void schedule_add( Incidence *incidence = 0 );
00472     void schedule_reply( Incidence *incidence = 0 );
00473     void schedule_counter( Incidence *incidence = 0 );
00474     void schedule_declinecounter( Incidence *incidence = 0 );
00475     void schedule_forward( Incidence *incidence = 0 );
00476     void mailFreeBusy( int daysToPublish = 30 );
00477     void uploadFreeBusy();
00478 
00479     void openAddressbook();
00480 
00481     void editFilters();
00482 
00483     void updateFilter();
00484 
00485     void showIntro();
00486 
00487     void showDateNavigator( bool );
00488     void showTodoView( bool );
00489     void showEventViewer( bool );
00490 
00492     void goDate( const QDate& date );
00493 
00495     void showDate( const QDate &date );
00496 
00498     void goToday();
00499 
00501     void goNext();
00502 
00504     void goPrevious();
00505 
00506     void toggleExpand();
00507     void showLeftFrame( bool show = true );
00508 
00509     void dialogClosing( Incidence * );
00510 
00511     void processMainViewSelection( Incidence *incidence, const QDate &date );
00512     void processTodoListSelection( Incidence *incidence, const QDate &date );
00513 
00514     void processIncidenceSelection( Incidence *incidence, const QDate &date );
00515 
00516     void purgeCompleted();
00517 
00518     void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); }
00519 
00520     void showErrorMessage( const QString & );
00521     void schedule( Scheduler::Method, Incidence *incidence );
00522     void addIncidenceOn( Incidence *, const QDate & );
00523     void moveIncidenceTo( Incidence *, const QDate & );
00524     void filterActivated( int filterNum );
00525 
00526     void resourcesChanged();
00527 
00528   protected slots:
00530     void showDates( const KCal::DateList & );
00531 
00532   public:
00533     // show a standard warning
00534     // returns KMsgBox::yesNoCancel()
00535     int msgCalModified();
00536 
00540     void adaptNavigationUnits();
00541 
00549     QDate activeDate( bool fallbackToToday = false );
00550 
00551   protected:
00552     void setIncidenceChanger( IncidenceChangerBase *changer );
00553 
00554 //     // returns KMsgBox::OKCancel()
00555     int msgItemDelete( Incidence *incidence );
00556 
00557     Todo *selectedTodo();
00558 
00559     void warningChangeFailed( Incidence * );
00560     void checkForFilteredChange( Incidence *incidence );
00564     void dateTimesForNewEvent( QDateTime &startDt, QDateTime &endDt, bool &allDay );
00565     KOEventEditor *newEventEditor( const QDateTime &startDtParam = QDateTime(),
00566          const QDateTime &endDtParam = QDateTime() , bool allDayParam = false );
00567 
00568   private:
00569     void init();
00570 
00571     void calendarModified( bool, Calendar * );
00572     // Helper function for purgeCompleted that recursively purges a todo and
00573     // its subitems. If it cannot delete a completed todo (because it has
00574     // uncompleted subitems), notAllPurged is set to true.
00575     bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
00576 
00577     KOrg::History *mHistory;
00578 
00579     QSplitter    *mPanner;
00580     QSplitter    *mLeftSplitter;
00581     QWidget      *mLeftFrame;
00582     QWidgetStack *mRightFrame;
00583 
00584     NavigatorBar *mNavigatorBar;
00585 
00586     DateNavigatorContainer *mDateNavigator;
00587 
00588 
00589     QPtrList<CalendarViewExtension> mExtensions;
00590 
00591     Calendar *mCalendar;
00592 
00593     DateNavigator *mNavigator;
00594     DateChecker *mDateChecker;
00595 
00596     KOEventViewer *mEventViewer;
00597     KOViewManager *mViewManager;
00598     KODialogManager *mDialogManager;
00599 
00600     // Calendar filters
00601     QPtrList<CalFilter> mFilters;
00602     CalFilter *mCurrentFilter;
00603 
00604     // various housekeeping variables.
00605     bool            mModified; // flag indicating if calendar is modified
00606     bool            mReadOnly; // flag indicating if calendar is read-only
00607 
00608     Incidence *mSelectedIncidence;
00609     QDate mSaveDate;
00610 
00611     KOTodoView *mTodoList;
00612     QMap<Incidence*,KOIncidenceEditor*> mDialogList;
00613 
00614     KOrg::IncidenceChangerBase *mChanger;
00615 };
00616 
00617 
00618 
00619 
00620 #endif