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 <tqobject.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 TQObject, public KCalendarIface
00074 {
00075     Q_OBJECT
00076   public:
00077     ActionManager( KXMLGUIClient *client, CalendarView *widget,
00078                    TQObject *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 
00111     void loadResourceCalendar();
00112 
00113   public slots:
00115     bool addResource( const KURL &mUrl );
00120     bool openURL( const KURL &url, bool merge = false );
00122     bool saveURL();
00124     bool saveAsURL( const KURL &kurl );
00126     bool saveModifiedURL();
00127 
00128     void exportHTML();
00129     void exportHTML( HTMLExportSettings * );
00130   public:
00132     KURL url() const { return mURL; }
00133 
00135     static KOrg::MainWindow* findInstance( const KURL &url );
00137     bool openURL( const TQString &url );
00139     bool mergeURL( const TQString &url );
00141     bool saveAsURL( const TQString &url );
00143     void closeURL();
00145     TQString getCurrentURLasString() const;
00152     virtual bool deleteIncidence( const TQString& uid, bool force = false );
00153 
00154     bool editIncidence( const TQString &uid );
00155     bool editIncidence( const TQString &uid, const TQDate &date );
00156 
00162     bool addIncidence( const TQString& ical );
00163 
00165     virtual ResourceRequestReply resourceRequest( const TQValueList<QPair<TQDateTime, TQDateTime> >& busy,
00166                                                   const TQCString& resource,
00167                                                   const TQString& vCalIn );
00168 
00169     void openEventEditor( const TQString& );
00170     void openEventEditor( const TQString& summary,
00171                           const TQString& description,
00172                           const TQString& attachment );
00173     void openEventEditor( const TQString& summary,
00174                           const TQString& description,
00175                           const TQString& attachment,
00176                           const TQStringList& attendees );
00177     void openEventEditor( const TQString& summary,
00178                           const TQString& description,
00179                           const TQString& uri,
00180                           const TQString& file,
00181                           const TQStringList& attendees,
00182                           const TQString& attachmentMimetype );
00183 
00184     void openTodoEditor( const TQString& );
00185     void openTodoEditor( const TQString& summary,
00186                          const TQString& description,
00187                          const TQString& attachment );
00188     void openTodoEditor( const TQString& summary,
00189                          const TQString& description,
00190                          const TQString& attachment,
00191                          const TQStringList& attendees );
00192     void openTodoEditor( const TQString& summary,
00193                          const TQString& description,
00194                          const TQString& uri,
00195                          const TQString& file,
00196                          const TQStringList& attendees,
00197                          const TQString& attachmentMimetype,
00198                          bool isTask );
00199 
00200     void openJournalEditor( const TQDate& date );
00201     void openJournalEditor( const TQString& text, const TQDate& date );
00202     void openJournalEditor( const TQString& text );
00203    //TODO:
00204    // void openJournalEditor( const TQString& summary,
00205    //                         const TQString& description,
00206    //                         const TQString& attachment );
00207 
00208     void showJournalView();
00209     void showTodoView();
00210     void showEventView();
00211 
00212     void goDate( const TQDate& );
00213     void goDate( const TQString& );
00214     void showDate( const TQDate &date );
00215 
00216     TQString localFileName();
00217 
00218     bool queryClose();
00219 
00220     void loadProfile( const TQString & path );
00221 
00222     void saveToProfile( const TQString & path ) const;
00223 
00224     bool handleCommandLine();
00225 
00226   signals:
00230     void actionNew( const KURL &url = KURL() );
00231 
00237     void configChanged();
00238 
00243     void closingDown();
00244 
00246     void resourceAdded( ResourceCalendar * );
00247 
00248   public slots:
00253     void updateConfig();
00254 
00255     void setDestinationPolicy();
00256 
00257     void processIncidenceSelection( Incidence *incidence, const TQDate &date );
00258     void keyBindings();
00259 
00264     void readSettings();
00265 
00269     void writeSettings();
00270 
00271     /* Session management */
00272     void saveProperties( KConfig * );
00273     void readProperties( KConfig * );
00274 
00275     void loadParts();
00276 
00277     void importCalendar( const KURL &url );
00278 
00279   protected slots:
00280 
00282     void file_new();
00283 
00285     void file_open();
00286 
00289     void file_open( const KURL &url );
00290 
00292     void file_icalimport();
00293 
00295     void file_merge();
00296 
00298     void file_revert();
00299 
00301     void file_archive();
00302 
00304     void file_save();
00305 
00307     void file_saveas();
00308 
00310     void file_close();
00311 
00313     void configureDateTime();
00314 
00316     void showTip();
00317 
00319     void showTipOnStart();
00320 
00321     void downloadNewStuff();
00322     void uploadNewStuff();
00323 
00324     void toggleResourceButtons();
00325 
00326     void toggleDateNavigator();
00327     void toggleTodoView();
00328     void toggleEventViewer();
00329     void toggleResourceView();
00330 
00332     void checkAutoSave();
00333 
00335     void slotAutoArchivingSettingsModified();
00336 
00338     void slotAutoArchive();
00339 
00340     void configureDateTimeFinished(KProcess *);
00341 
00342     void setTitle();
00343 
00344     void updateUndoAction( const TQString & );
00345 
00346     void updateRedoAction( const TQString & );
00347 
00348     void slotPreviewDialogFinished( PreviewDialog * );
00349 
00350   protected:
00352     KURL getSaveURL();
00353 
00354     void showStatusMessageOpen( const KURL &url, bool merge );
00355 
00356     void initCalendar( Calendar *cal );
00357 
00361     TQWidget *dialogParent();
00362 
00363   private slots:
00364     void dumpText( const TQString & );  // only for debugging purposes
00365 
00366   private:
00367     class ActionStringsVisitor;
00368 
00370     void initActions();
00371     void enableIncidenceActions( bool enable );
00372 
00373     QPair<ResourceCalendar *, TQString> viewSubResourceCalendar();
00374     bool isWritable( ResourceCalendar *res, const TQString &subRes, const TQString &contentsType );
00375 
00376     KOrg::Part::List mParts; // List of parts loaded
00377     KURL mURL;      // URL of calendar file
00378     TQString mFile;  // Local name of calendar file
00379     TQString mLastUrl;  // URL of last loaded calendar.
00380 
00381     KTempFile *mTempFile;
00382     TQTimer *mAutoSaveTimer;   // used if calendar is to be autosaved
00383     TQTimer *mAutoArchiveTimer; // used for the auto-archiving feature
00384 
00385     // list of all existing KOrganizer instances
00386     static KOWindowList *mWindowList;
00387 
00388     // Actions
00389     KRecentFilesAction *mRecent;
00390     KToggleAction *mResourceButtonsAction;
00391 
00392     KToggleAction *mDateNavigatorShowAction;
00393     KToggleAction *mTodoViewShowAction;
00394     KToggleAction *mResourceViewShowAction;
00395     KToggleAction *mEventViewerShowAction;
00396 //     KToggleAction *mToggleAlarmAction;
00397 
00398     KAction *mShowIncidenceAction;
00399     KAction *mEditIncidenceAction;
00400     KAction *mDeleteIncidenceAction;
00401 //     KAction *mAssignResourceAction;
00402 
00403     KAction *mCutAction;
00404     KAction *mCopyAction;
00405     KAction *mDeleteAction;
00406     KAction *mNextXDays;
00407     KAction *mPublishEvent;
00408     KAction *mForwardEvent;
00409 
00410     KAction *mSendInvitation;
00411     KAction *mSendCancel;
00412     KAction *mSendStatusUpdate;
00413 
00414     KAction *mRequestChange;
00415     KAction *mRequestUpdate;
00416 
00417     KAction *mUndoAction;
00418     KAction *mRedoAction;
00419 
00420     KSelectAction *mFilterAction;
00421 
00422     KXMLGUIClient *mGUIClient;
00423     KActionCollection *mACollection;
00424     CalendarView *mCalendarView;
00425     KOrg::MainWindow *mMainWindow;
00426     bool mIsPart;
00427 
00428     KONewStuff *mNewStuff;
00429     bool mHtmlExportSync;
00430 
00431     // Either mCalendar *or* mCalendarResources is set.
00432     Calendar *mCalendar;
00433     CalendarResources *mCalendarResources;
00434 
00435     ResourceView *mResourceView;
00436 
00437     bool mIsClosing;
00438 };
00439 
00440 #endif