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 <korganizer/calendarviewbase.h>
00037 
00038 class QWidgetStack;
00039 class QSplitter;
00040 
00041 class KOViewManager;
00042 class KODialogManager;
00043 class KOTodoView;
00044 class KOEventEditor;
00045 class DateNavigatorContainer;
00046 class DateNavigator;
00047 class KOIncidenceEditor;
00048 class ResourceView;
00049 class NavigatorBar;
00050 class DateChecker;
00051 
00052 namespace KOrg { class History; class IncidenceChangerBase; }
00053 class HTMLExportSettings;
00054 
00055 using namespace KOrg;
00056 using namespace KCal;
00057 
00058 class CalendarViewExtension : public QWidget
00059 {
00060   public:
00061     CalendarViewExtension( QWidget *parent, const char *name = 0 )
00062       : QWidget( parent, name ) {}
00063 
00064     class Factory
00065     {
00066       public:
00067         virtual CalendarViewExtension *create( QWidget *parent ) = 0;
00068     };
00069 };
00070 
00080 class KDE_EXPORT CalendarView : public KOrg::CalendarViewBase, public Calendar::Observer
00081 {
00082     Q_OBJECT
00083   public:
00090     CalendarView( QWidget *parent = 0, const char *name = 0 );
00091     virtual ~CalendarView();
00092 
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 
00116     void setCalendar( Calendar * );
00117     Calendar *calendar();
00118 
00119     KOrg::History *history() const { return mHistory; }
00120 
00121     KOViewManager *viewManager() const { return mViewManager; }
00122     KODialogManager *dialogManager() const { return mDialogManager; }
00123 
00124     QWidgetStack *viewStack() const { return mRightFrame; }
00125     QWidget *leftFrame() const { return mLeftFrame; }
00126     NavigatorBar *navigatorBar() const { return mNavigatorBar; }
00127     DateNavigator *dateNavigator() const { return mNavigator; }
00128 
00129     KOIncidenceEditor *editorDialog( Incidence* ) const;
00130     IncidenceChangerBase *incidenceChanger() const { return mChanger; }
00131 
00132     QDate startDate();
00133     QDate endDate();
00134 
00135 
00136     void addView( KOrg::BaseView * );
00137     void showView( KOrg::BaseView * );
00138 
00143     void addExtension( CalendarViewExtension::Factory * );
00144 
00146     Incidence *currentSelection();
00149     Incidence *selectedIncidence();
00151     QString currentFilterName() const;
00152 
00153   signals:
00157     void configChanged();
00160     void categoriesChanged();
00163     void closingDown();
00165     void closed( QWidget * );
00166 
00168     void modifiedChanged( bool );
00169 
00171     void readOnlyChanged( bool );
00172 
00174     void changeNavStringPrev( const QString & );
00175     void changeNavStringNext( const QString & );
00176 
00178     void organizerEventsSelected( bool );
00180     void groupEventsSelected( bool );
00185     void incidenceSelected( Incidence * );
00188     void todoSelected( bool );
00189     void subtodoSelected( bool );
00190 
00193     void dayPassed( const QDate & );
00199     void cancelAttendees( Incidence * );
00200 
00201 
00206     void pasteEnabled( bool );
00208     void statusMessage( const QString & );
00209 
00210     void calendarViewExpanded( bool );
00211 
00213     void autoArchivingSettingsModified();
00214 
00215     void newIncidenceChanger( IncidenceChangerBase* );
00216     void exportHTML( HTMLExportSettings* );
00217 
00218     void newFilterListSignal( const QStringList & );
00219     void selectFilterSignal( int );
00220     void filterChanged();
00221 
00222   public slots:
00225     void updateConfig( const QCString& );
00228     void updateCategories();
00229 
00230 
00236     bool openCalendar( const QString &filename, bool merge = false );
00237 
00242     bool saveCalendar( const QString &filename );
00243 
00248     void closeCalendar();
00249 
00251     void archiveCalendar();
00252 
00253     void showIncidence();
00254     void editIncidence();
00255     bool editIncidence( const QString& uid );
00256     void deleteIncidence();
00257 
00266     bool addIncidence( const QString &ical );
00267 
00268     void connectIncidenceEditor( KOIncidenceEditor * );
00269 
00272     void newEvent();
00275     void newEvent( const QDate &startDt );
00276     void newEvent( const QDateTime &startDt );
00277     void newEvent( const QDateTime &startDt, const QDateTime &EndDt, bool allDay = false );
00282     void newEvent( const QString &summary, const QString &description = QString::null,
00283                    const QStringList &attachment = QStringList(), const QStringList &attendees = QStringList() );
00284     void newFloatingEvent();
00285 
00287     void showIncidence( Incidence * );
00289     bool editIncidence( Incidence * );
00295     void deleteIncidence( Incidence *, bool force = false );
00299     void cutIncidence( Incidence * );
00303     void copyIncidence( Incidence *);
00305     void deleteSubTodosIncidence ( Todo *todo );
00311     void deleteTodoIncidence ( Todo *todo, bool force = false );
00313     bool deleteEvent( Event * ) { return true; }
00315     bool deleteTodo( Todo * ) {return true; }
00317     bool deleteJournal( Journal * ) { return true; }
00324     bool deleteIncidence( const QString &uid, bool force = false );
00325 
00327     void newTodo();
00329     void newTodo( const QDate &date );
00331     void newSubTodo();
00333     void newSubTodo( Todo * );
00334 
00335     void newTodo( const QString &summary, const QString &description = QString::null,
00336                   const QStringList &attachments = QStringList(), const QStringList &attendees = QStringList() );
00337 
00338     void newJournal();
00339     void newJournal( const QDate &date );
00340     void newJournal( const QString &text, const QDate &date = QDate() );
00341 
00342     void toggleAlarm( Incidence * );
00343     void dissociateOccurrence( Incidence *, const QDate & );
00344     void dissociateFutureOccurrence( Incidence *, const QDate & );
00345 
00346 
00351     void checkClipboard();
00352 
00359     void readSettings();
00360 
00362     void writeSettings();
00363 
00365     void readFilterSettings( KConfig *config );
00366 
00368     void writeFilterSettings( KConfig *config );
00369 
00372     void changeIncidenceDisplay( Incidence *, int );
00373 
00374     void incidenceAdded( Incidence * );
00375     void incidenceChanged( Incidence *oldEvent, Incidence *newEvent );
00376     void incidenceChanged( Incidence *oldEvent, Incidence *newEvent, int what );
00377     void incidenceToBeDeleted( Incidence *incidence );
00378     void incidenceDeleted( Incidence * );
00379     void startMultiModify( const QString &text );
00380     void endMultiModify();
00381 
00382     void editCanceled( Incidence * );
00383 
00384     void updateView( const QDate &start, const QDate &end );
00385     void updateView();
00386 
00387     void updateUnmanagedViews();
00388 
00390     void edit_cut();
00391 
00393     void edit_copy();
00394 
00396     void edit_paste();
00397 
00399     void edit_options();
00400 
00405     void print();
00406 
00408     void exportWeb();
00409 
00411     void exportICalendar();
00412 
00414     void exportVCalendar();
00415 
00417     void appointment_show();
00423     void appointment_edit();
00428     void appointment_delete();
00429 
00430     /* frees a subtodo from it's relation, update the view */
00431     void todo_unsub();
00432     /* Free a subtodo from it's relation, without update the view */
00433     bool todo_unsub( Todo *todo );
00435     bool makeSubTodosIndependents ( );
00437     bool makeSubTodosIndependents ( Todo *todo );
00438 
00440     void takeOverEvent();
00441 
00443     void takeOverCalendar();
00444 
00446     bool isModified();
00448     void setModified( bool modified = true );
00449 
00451     bool isReadOnly();
00453     void setReadOnly( bool readOnly = true );
00454 
00455     void eventUpdated( Incidence * );
00456 
00457     /* iTIP scheduling actions */
00458     void schedule_publish( Incidence *incidence = 0 );
00459     void schedule_request( Incidence *incidence = 0 );
00460     void schedule_refresh( Incidence *incidence = 0 );
00461     void schedule_cancel( Incidence *incidence = 0 );
00462     void schedule_add( Incidence *incidence = 0 );
00463     void schedule_reply( Incidence *incidence = 0 );
00464     void schedule_counter( Incidence *incidence = 0 );
00465     void schedule_declinecounter( Incidence *incidence = 0 );
00466     void mailFreeBusy( int daysToPublish = 30 );
00467     void uploadFreeBusy();
00468 
00469     void openAddressbook();
00470 
00471     void editFilters();
00472 
00473     void updateFilter();
00474 
00475     void showIntro();
00476 
00477     void showDateNavigator( bool );
00478     void showTodoView( bool );
00479     void showEventViewer( bool );
00480 
00482     void goDate( const QDate& date );
00483 
00485     void goToday();
00486 
00488     void goNext();
00489 
00491     void goPrevious();
00492 
00493     void toggleExpand();
00494     void showLeftFrame( bool show = true );
00495 
00496     void dialogClosing( Incidence * );
00497 
00498     void processMainViewSelection( Incidence * );
00499     void processTodoListSelection( Incidence * );
00500 
00501     void processIncidenceSelection( Incidence * );
00502 
00503     void purgeCompleted();
00504 
00505     void slotCalendarChanged();
00506 
00507     void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); }
00508 
00509     void showErrorMessage( const QString & );
00510     void schedule( Scheduler::Method, Incidence *incidence );
00511     void addIncidenceOn( Incidence *, const QDate & );
00512     void moveIncidenceTo( Incidence *, const QDate & );
00513     void filterActivated( int filterNum );
00514   protected slots:
00516     void showDates( const KCal::DateList & );
00517 
00518   public:
00519     // show a standard warning
00520     // returns KMsgBox::yesNoCancel()
00521     int msgCalModified();
00522 
00526     void adaptNavigationUnits();
00527 
00528     //Attendee* getYourAttendee( Event *event );
00529 
00530   protected:
00531     void setIncidenceChanger( IncidenceChangerBase *changer );
00532 
00533 //     // returns KMsgBox::OKCancel()
00534     int msgItemDelete( Incidence *incidence );
00535 
00536     Todo *selectedTodo();
00537 
00538     void warningChangeFailed( Incidence * );
00539     void checkForFilteredChange( Incidence *incidence );
00543     void dateTimesForNewEvent( QDateTime &startDt, QDateTime &endDt, bool &allDay );
00544     KOEventEditor *newEventEditor( const QDateTime &startDtParam = QDateTime(),
00545          const QDateTime &endDtParam = QDateTime() , bool allDayParam = false );
00546 
00547   private:
00548     void init();
00549 
00550     void calendarModified( bool, Calendar * );
00551     // Helper function for purgeCompleted that recursively purges a todo and
00552     // its subitems. If it cannot delete a completed todo (because it has
00553     // uncompleted subitems), notAllPurged is set to true.
00554     bool purgeCompletedSubTodos( Todo* todo, bool &notAllPurged );
00555 
00556     KOrg::History *mHistory;
00557 
00558     QSplitter    *mPanner;
00559     QSplitter    *mLeftSplitter;
00560     QWidget      *mLeftFrame;
00561     QWidgetStack *mRightFrame;
00562 
00563     NavigatorBar *mNavigatorBar;
00564 
00565     DateNavigatorContainer *mDateNavigator;
00566 
00567 
00568     QPtrList<CalendarViewExtension> mExtensions;
00569 
00570     Calendar *mCalendar;
00571 
00572     DateNavigator *mNavigator;
00573     DateChecker *mDateChecker;
00574 
00575     KOEventViewer *mEventViewer;
00576     KOViewManager *mViewManager;
00577     KODialogManager *mDialogManager;
00578 
00579     // Calendar filters
00580     QPtrList<CalFilter> mFilters;
00581     CalFilter *mCurrentFilter;
00582 
00583     // various housekeeping variables.
00584     bool            mModified; // flag indicating if calendar is modified
00585     bool            mReadOnly; // flag indicating if calendar is read-only
00586     QDate mSaveSingleDate;
00587 
00588     Incidence *mSelectedIncidence;
00589 
00590     KOTodoView *mTodoList;
00591     QMap<Incidence*,KOIncidenceEditor*> mDialogList;
00592 
00593     KOrg::IncidenceChangerBase *mChanger;
00594 };
00595 
00596 
00597 
00598 
00599 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys