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 TQt, and distribute the resulting executable, 00025 without including the source code for TQt 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 <tdepimmacros.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 TDEAction; 00049 class TDEActionCollection; 00050 class TDERecentFilesAction; 00051 class TDESelectAction; 00052 class TDEToggleAction; 00053 class TDEConfig; 00054 class TDEProcess; 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 00077 public: 00078 ActionManager( KXMLGUIClient *client, CalendarView *widget, 00079 TQObject *parent, KOrg::MainWindow *mainWindow, 00080 bool isPart ); 00081 virtual ~ActionManager(); 00082 00084 void init(); 00085 00086 CalendarView *view() const { return mCalendarView; } 00087 00091 void createCalendarLocal(); 00096 void createCalendarResources(); 00097 00101 void saveCalendar(); 00102 00107 bool saveResourceCalendar(); 00108 00112 void loadResourceCalendar(); 00113 00114 public slots: 00116 bool addResource( const KURL &mUrl ); 00121 bool openURL( const KURL &url, bool merge = false ); 00123 bool saveURL(); 00125 bool saveAsURL( const KURL &kurl ); 00127 bool saveModifiedURL(); 00128 00129 void exportHTML(); 00130 void exportHTML( HTMLExportSettings * ); 00131 public: 00133 KURL url() const { return mURL; } 00134 00136 static KOrg::MainWindow* findInstance( const KURL &url ); 00138 bool openURL( const TQString &url ); 00140 bool mergeURL( const TQString &url ); 00142 bool saveAsURL( const TQString &url ); 00144 void closeURL(); 00146 TQString getCurrentURLasString() const; 00153 virtual bool deleteIncidence( const TQString& uid, bool force = false ); 00154 00155 bool editIncidence( const TQString &uid ); 00156 bool editIncidence( const TQString &uid, const TQDate &date ); 00157 00163 bool addIncidence( const TQString& ical ); 00164 00166 virtual ResourceRequestReply resourceRequest( const TQValueList<TQPair<TQDateTime, TQDateTime> >& busy, 00167 const TQCString& resource, 00168 const TQString& vCalIn ); 00169 00170 void openEventEditor( const TQString& ); 00171 void openEventEditor( const TQString& summary, 00172 const TQString& description, 00173 const TQString& attachment ); 00174 void openEventEditor( const TQString& summary, 00175 const TQString& description, 00176 const TQString& attachment, 00177 const TQStringList& attendees ); 00178 void openEventEditor( const TQString& summary, 00179 const TQString& description, 00180 const TQString& uri, 00181 const TQString& file, 00182 const TQStringList& attendees, 00183 const TQString& attachmentMimetype ); 00184 00185 void openTodoEditor( const TQString& ); 00186 void openTodoEditor( const TQString& summary, 00187 const TQString& description, 00188 const TQString& attachment ); 00189 void openTodoEditor( const TQString& summary, 00190 const TQString& description, 00191 const TQString& attachment, 00192 const TQStringList& attendees ); 00193 void openTodoEditor( const TQString& summary, 00194 const TQString& description, 00195 const TQString& uri, 00196 const TQString& file, 00197 const TQStringList& attendees, 00198 const TQString& attachmentMimetype, 00199 bool isTask ); 00200 00201 void openJournalEditor( const TQDate& date ); 00202 void openJournalEditor( const TQString& text, const TQDate& date ); 00203 void openJournalEditor( const TQString& text ); 00204 //TODO: 00205 // void openJournalEditor( const TQString& summary, 00206 // const TQString& description, 00207 // const TQString& attachment ); 00208 00209 void showJournalView(); 00210 void showTodoView(); 00211 void showEventView(); 00212 00213 void goDate( const TQDate& ); 00214 void goDate( const TQString& ); 00215 void showDate( const TQDate &date ); 00216 00217 TQString localFileName(); 00218 00219 bool queryClose(); 00220 00221 void loadProfile( const TQString & path ); 00222 00223 void saveToProfile( const TQString & path ) const; 00224 00225 bool handleCommandLine(); 00226 00227 signals: 00231 void actionNew( const KURL &url = KURL() ); 00232 00238 void configChanged(); 00239 00244 void closingDown(); 00245 00247 void resourceAdded( ResourceCalendar * ); 00248 00249 public slots: 00254 void updateConfig(); 00255 00256 void setDestinationPolicy(); 00257 00258 void processIncidenceSelection( Incidence *incidence, const TQDate &date ); 00259 void keyBindings(); 00260 00265 void readSettings(); 00266 00270 void writeSettings(); 00271 00272 /* Session management */ 00273 void saveProperties( TDEConfig * ); 00274 void readProperties( TDEConfig * ); 00275 00276 void loadParts(); 00277 00278 void importCalendar( const KURL &url ); 00279 00280 protected slots: 00281 00283 void file_new(); 00284 00286 void file_open(); 00287 00290 void file_open( const KURL &url ); 00291 00293 void file_icalimport(); 00294 00296 void file_merge(); 00297 00299 void file_revert(); 00300 00302 void file_archive(); 00303 00305 void file_save(); 00306 00308 void file_saveas(); 00309 00311 void file_close(); 00312 00314 void configureDateTime(); 00315 00317 void showTip(); 00318 00320 void showTipOnStart(); 00321 00322 void downloadNewStuff(); 00323 void uploadNewStuff(); 00324 00325 void toggleResourceButtons(); 00326 00327 void toggleDateNavigator(); 00328 void toggleTodoView(); 00329 void toggleEventViewer(); 00330 void toggleResourceView(); 00331 00333 void checkAutoSave(); 00334 00336 void slotAutoArchivingSettingsModified(); 00337 00339 void slotAutoArchive(); 00340 00341 void configureDateTimeFinished(TDEProcess *); 00342 00343 void setTitle(); 00344 00345 void updateUndoAction( const TQString & ); 00346 00347 void updateRedoAction( const TQString & ); 00348 00349 void slotPreviewDialogFinished( PreviewDialog * ); 00350 00351 protected: 00353 KURL getSaveURL(); 00354 00355 void showStatusMessageOpen( const KURL &url, bool merge ); 00356 00357 void initCalendar( Calendar *cal ); 00358 00362 TQWidget *dialogParent(); 00363 00364 private slots: 00365 void dumpText( const TQString & ); // only for debugging purposes 00366 00367 private: 00368 class ActionStringsVisitor; 00369 00371 void initActions(); 00372 void enableIncidenceActions( bool enable ); 00373 00374 TQPair<ResourceCalendar *, TQString> viewSubResourceCalendar(); 00375 bool isWritable( ResourceCalendar *res, const TQString &subRes, const TQString &contentsType ); 00376 00377 KOrg::Part::List mParts; // List of parts loaded 00378 KURL mURL; // URL of calendar file 00379 TQString mFile; // Local name of calendar file 00380 TQString mLastUrl; // URL of last loaded calendar. 00381 00382 KTempFile *mTempFile; 00383 TQTimer *mAutoSaveTimer; // used if calendar is to be autosaved 00384 TQTimer *mAutoArchiveTimer; // used for the auto-archiving feature 00385 00386 // list of all existing KOrganizer instances 00387 static KOWindowList *mWindowList; 00388 00389 // Actions 00390 TDERecentFilesAction *mRecent; 00391 TDEToggleAction *mResourceButtonsAction; 00392 00393 TDEToggleAction *mDateNavigatorShowAction; 00394 TDEToggleAction *mTodoViewShowAction; 00395 TDEToggleAction *mResourceViewShowAction; 00396 TDEToggleAction *mEventViewerShowAction; 00397 // TDEToggleAction *mToggleAlarmAction; 00398 00399 TDEAction *mShowIncidenceAction; 00400 TDEAction *mEditIncidenceAction; 00401 TDEAction *mDeleteIncidenceAction; 00402 // TDEAction *mAssignResourceAction; 00403 00404 TDEAction *mCutAction; 00405 TDEAction *mCopyAction; 00406 TDEAction *mDeleteAction; 00407 TDEAction *mNextXDays; 00408 TDEAction *mPublishEvent; 00409 TDEAction *mForwardEvent; 00410 00411 TDEAction *mSendInvitation; 00412 TDEAction *mSendCancel; 00413 TDEAction *mSendStatusUpdate; 00414 00415 TDEAction *mRequestChange; 00416 TDEAction *mRequestUpdate; 00417 00418 TDEAction *mUndoAction; 00419 TDEAction *mRedoAction; 00420 00421 TDESelectAction *mFilterAction; 00422 00423 KXMLGUIClient *mGUIClient; 00424 TDEActionCollection *mACollection; 00425 CalendarView *mCalendarView; 00426 KOrg::MainWindow *mMainWindow; 00427 bool mIsPart; 00428 00429 KONewStuff *mNewStuff; 00430 bool mHtmlExportSync; 00431 00432 // Either mCalendar *or* mCalendarResources is set. 00433 Calendar *mCalendar; 00434 CalendarResources *mCalendarResources; 00435 00436 ResourceView *mResourceView; 00437 00438 bool mIsClosing; 00439 }; 00440 00441 #endif