korganizer

actionmanager.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
00005     Copyright (c) 2002 Don Sanders <sanders@kde.org>
00006     Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
00007     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; if not, write to the Free Software
00021     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00022 
00023     As a special exception, permission is given to link this program
00024     with any edition of Qt, and distribute the resulting executable,
00025     without including the source code for Qt in the source distribution.
00026 */
00027 #ifndef KORG_ACTIONMANAGER_H
00028 #define KORG_ACTIONMANAGER_H
00029 
00030 #include <qobject.h>
00031 #include <kurl.h>
00032 #include <korganizer/part.h>
00033 #include <kdepimmacros.h>
00034 
00035 #include "kcalendariface.h"
00036 
00037 namespace KCal
00038 {
00039   class Calendar;
00040   class CalendarResources;
00041   class Incidence;
00042   class ResourceCalendar;
00043 }
00044 namespace KOrg {
00045   class MainWindow;
00046 }
00047 
00048 class KAction;
00049 class KActionCollection;
00050 class KRecentFilesAction;
00051 class KSelectAction;
00052 class KToggleAction;
00053 class KConfig;
00054 class KProcess;
00055 class KTempFile;
00056 class KXMLGUIClient;
00057 class CalendarView;
00058 class KOrganizer;
00059 class KONewStuff;
00060 class KOWindowList;
00061 class PreviewDialog;
00062 class ResourceView;
00063 class HTMLExportSettings;
00064 
00065 using namespace KCal;
00066 
00073 class KDE_EXPORT ActionManager : public QObject, public KCalendarIface
00074 {
00075     Q_OBJECT
00076   public:
00077     ActionManager( KXMLGUIClient *client, CalendarView *widget,
00078                    QObject *parent, KOrg::MainWindow *mainWindow,
00079                    bool isPart );
00080     virtual ~ActionManager();
00081 
00083     void init();
00084 
00085     CalendarView *view() const { return mCalendarView; }
00086 
00090     void createCalendarLocal();
00095     void createCalendarResources();
00096 
00100     void saveCalendar();
00101 
00106     bool saveResourceCalendar();
00107 
00108   public slots:
00110     bool addResource( const KURL &mUrl );
00115     bool openURL( const KURL &url, bool merge = false );
00117     bool saveURL();
00119     bool saveAsURL( const KURL &kurl );
00121     bool saveModifiedURL();
00122 
00123     void exportHTML();
00124     void exportHTML( HTMLExportSettings * );
00125   public:
00127     KURL url() const { return mURL; }
00128 
00130     static KOrg::MainWindow* findInstance( const KURL &url );
00132     bool openURL( const QString &url );
00134     bool mergeURL( const QString &url );
00136     bool saveAsURL( const QString &url );
00138     void closeURL();
00140     QString getCurrentURLasString() const;
00147     virtual bool deleteIncidence( const QString& uid, bool force = false );
00148 
00149     bool editIncidence( const QString &uid );
00150     bool editIncidence( const QString &uid, const QDate &date );
00151 
00157     bool addIncidence( const QString& ical );
00158 
00160     virtual ResourceRequestReply resourceRequest( const QValueList<QPair<QDateTime, QDateTime> >& busy,
00161                                                   const QCString& resource,
00162                                                   const QString& vCalIn );
00163 
00164     void openEventEditor( const QString& );
00165     void openEventEditor( const QString& summary,
00166                           const QString& description,
00167                           const QString& attachment );
00168     void openEventEditor( const QString& summary,
00169                           const QString& description,
00170                           const QString& attachment,
00171                           const QStringList& attendees );
00172     void openEventEditor( const QString& summary,
00173                           const QString& description,
00174                           const QString& uri,
00175                           const QString& file,
00176                           const QStringList& attendees,
00177                           const QString& attachmentMimetype );
00178 
00179     void openTodoEditor( const QString& );
00180     void openTodoEditor( const QString& summary,
00181                          const QString& description,
00182                          const QString& attachment );
00183     void openTodoEditor( const QString& summary,
00184                          const QString& description,
00185                          const QString& attachment,
00186                          const QStringList& attendees );
00187     void openTodoEditor( const QString& summary,
00188                          const QString& description,
00189                          const QString& uri,
00190                          const QString& file,
00191                          const QStringList& attendees,
00192                          const QString& attachmentMimetype,
00193                          bool isTask );
00194 
00195     void openJournalEditor( const QDate& date );
00196     void openJournalEditor( const QString& text, const QDate& date );
00197     void openJournalEditor( const QString& text );
00198    //TODO:
00199    // void openJournalEditor( const QString& summary,
00200    //                         const QString& description,
00201    //                         const QString& attachment );
00202 
00203     void showJournalView();
00204     void showTodoView();
00205     void showEventView();
00206 
00207     void goDate( const QDate& );
00208     void goDate( const QString& );
00209     void showDate( const QDate &date );
00210 
00211     QString localFileName();
00212 
00213     bool queryClose();
00214 
00215     void loadProfile( const QString & path );
00216 
00217     void saveToProfile( const QString & path ) const;
00218 
00219     bool handleCommandLine();
00220 
00221   signals:
00225     void actionNew( const KURL &url = KURL() );
00226 
00232     void configChanged();
00233 
00238     void closingDown();
00239 
00241     void resourceAdded( ResourceCalendar * );
00242 
00243   public slots:
00248     void updateConfig();
00249 
00250     void setDestinationPolicy();
00251 
00252     void processIncidenceSelection( Incidence *incidence, const QDate &date );
00253     void keyBindings();
00254 
00259     void readSettings();
00260 
00264     void writeSettings();
00265 
00266     /* Session management */
00267     void saveProperties( KConfig * );
00268     void readProperties( KConfig * );
00269 
00270     void loadParts();
00271 
00272     void importCalendar( const KURL &url );
00273 
00274   protected slots:
00275 
00277     void file_new();
00278 
00280     void file_open();
00281 
00284     void file_open( const KURL &url );
00285 
00287     void file_icalimport();
00288 
00290     void file_merge();
00291 
00293     void file_revert();
00294 
00296     void file_archive();
00297 
00299     void file_save();
00300 
00302     void file_saveas();
00303 
00305     void file_close();
00306 
00308     void configureDateTime();
00309 
00311     void showTip();
00312 
00314     void showTipOnStart();
00315 
00316     void downloadNewStuff();
00317     void uploadNewStuff();
00318 
00319     void toggleResourceButtons();
00320 
00321     void toggleDateNavigator();
00322     void toggleTodoView();
00323     void toggleEventViewer();
00324     void toggleResourceView();
00325 
00327     void checkAutoSave();
00328 
00330     void slotAutoArchivingSettingsModified();
00331 
00333     void slotAutoArchive();
00334 
00335     void configureDateTimeFinished(KProcess *);
00336 
00337     void setTitle();
00338 
00339     void updateUndoAction( const QString & );
00340 
00341     void updateRedoAction( const QString & );
00342 
00343     void slotPreviewDialogFinished( PreviewDialog * );
00344 
00345   protected:
00347     KURL getSaveURL();
00348 
00349     void showStatusMessageOpen( const KURL &url, bool merge );
00350 
00351     void initCalendar( Calendar *cal );
00352 
00356     QWidget *dialogParent();
00357 
00358   private slots:
00359     void dumpText( const QString & );  // only for debugging purposes
00360 
00361   private:
00362     class ActionStringsVisitor;
00363 
00365     void initActions();
00366     void enableIncidenceActions( bool enable );
00367 
00368     QPair<ResourceCalendar *, QString> viewSubResourceCalendar();
00369     bool isWritable( ResourceCalendar *res, const QString &subRes, const QString &contentsType );
00370 
00371     KOrg::Part::List mParts; // List of parts loaded
00372     KURL mURL;      // URL of calendar file
00373     QString mFile;  // Local name of calendar file
00374     QString mLastUrl;  // URL of last loaded calendar.
00375 
00376     KTempFile *mTempFile;
00377     QTimer *mAutoSaveTimer;   // used if calendar is to be autosaved
00378     QTimer *mAutoArchiveTimer; // used for the auto-archiving feature
00379 
00380     // list of all existing KOrganizer instances
00381     static KOWindowList *mWindowList;
00382 
00383     // Actions
00384     KRecentFilesAction *mRecent;
00385     KToggleAction *mResourceButtonsAction;
00386 
00387     KToggleAction *mDateNavigatorShowAction;
00388     KToggleAction *mTodoViewShowAction;
00389     KToggleAction *mResourceViewShowAction;
00390     KToggleAction *mEventViewerShowAction;
00391 //     KToggleAction *mToggleAlarmAction;
00392 
00393     KAction *mShowIncidenceAction;
00394     KAction *mEditIncidenceAction;
00395     KAction *mDeleteIncidenceAction;
00396 //     KAction *mAssignResourceAction;
00397 
00398     KAction *mCutAction;
00399     KAction *mCopyAction;
00400     KAction *mDeleteAction;
00401     KAction *mNextXDays;
00402     KAction *mPublishEvent;
00403     KAction *mForwardEvent;
00404 
00405     KAction *mSendInvitation;
00406     KAction *mSendCancel;
00407     KAction *mSendStatusUpdate;
00408 
00409     KAction *mRequestChange;
00410     KAction *mRequestUpdate;
00411 
00412     KAction *mUndoAction;
00413     KAction *mRedoAction;
00414 
00415     KSelectAction *mFilterAction;
00416 
00417     KXMLGUIClient *mGUIClient;
00418     KActionCollection *mACollection;
00419     CalendarView *mCalendarView;
00420     KOrg::MainWindow *mMainWindow;
00421     bool mIsPart;
00422 
00423     KONewStuff *mNewStuff;
00424     bool mHtmlExportSync;
00425 
00426     // Either mCalendar *or* mCalendarResources is set.
00427     Calendar *mCalendar;
00428     CalendarResources *mCalendarResources;
00429 
00430     ResourceView *mResourceView;
00431 
00432     bool mIsClosing;
00433 };
00434 
00435 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys