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 {
00046   class MainWindow;
00047 }
00048 
00049 class KAction;
00050 class KActionCollection;
00051 class KRecentFilesAction;
00052 class KSelectAction;
00053 class KToggleAction;
00054 class KConfig;
00055 class KProcess;
00056 class KTempFile;
00057 class KXMLGUIClient;
00058 class CalendarView;
00059 class KOrganizer;
00060 class KONewStuff;
00061 class KOWindowList;
00062 class ImportDialog;
00063 class ResourceView;
00064 class HTMLExportSettings;
00065 
00066 using namespace KCal;
00067 
00074 class KDE_EXPORT ActionManager : public QObject, public KCalendarIface
00075 {
00076     Q_OBJECT
00077   public:
00078     ActionManager( KXMLGUIClient *client, CalendarView *widget,
00079                    QObject *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 
00109   public slots:
00111     bool addResource( const KURL &mUrl );
00116     bool openURL( const KURL &url, bool merge = false );
00118     bool saveURL();
00120     bool saveAsURL( const KURL &kurl );
00122     bool saveModifiedURL();
00123 
00124     void exportHTML();
00125     void exportHTML( HTMLExportSettings * );
00126   public:
00128     KURL url() const { return mURL; }
00129 
00131     static KOrg::MainWindow* findInstance( const KURL &url );
00133     bool openURL( const QString &url );
00135     bool mergeURL( const QString &url );
00137     bool saveAsURL( const QString &url );
00139     void closeURL();
00141     QString getCurrentURLasString() const;
00148     virtual bool deleteIncidence( const QString& uid, bool force = false );
00149 
00150     bool editIncidence( const QString& uid );
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 
00173     void openTodoEditor( const QString& );
00174     void openTodoEditor( const QString& summary,
00175                          const QString& description,
00176                          const QString& attachment );
00177     void openTodoEditor( const QString& summary,
00178                          const QString& description,
00179                          const QString& attachment,
00180                          const QStringList& attendees );
00181 
00182     void openJournalEditor( const QDate& date );
00183     void openJournalEditor( const QString& text, const QDate& date );
00184     void openJournalEditor( const QString& text );
00185    //TODO:
00186    // void openJournalEditor( const QString& summary,
00187    //                         const QString& description,
00188    //                         const QString& attachment );
00189 
00190     void showJournalView();
00191     void showTodoView();
00192     void showEventView();
00193 
00194     void goDate( const QDate& );
00195     void goDate( const QString& );
00196 
00197     QString localFileName();
00198 
00199     bool queryClose();
00200 
00201   signals:
00205     void actionNew( const KURL &url = KURL() );
00206 
00212     void configChanged();
00213 
00218     void closingDown();
00219 
00221     void resourceAdded( ResourceCalendar * );
00222 
00223   public slots:
00228     void updateConfig();
00229 
00230     void setDestinationPolicy();
00231 
00232     void processIncidenceSelection( Incidence * );
00233     void keyBindings();
00234 
00239     void readSettings();
00240 
00244     void writeSettings();
00245 
00246     /* Session management */
00247     void saveProperties( KConfig * );
00248     void readProperties( KConfig * );
00249 
00250     void loadParts();
00251 
00252     void importCalendar( const KURL &url );
00253 
00254   protected slots:
00255 
00257     void file_new();
00258 
00260     void file_open();
00261 
00264     void file_open( const KURL &url );
00265 
00267     void file_icalimport();
00268 
00270     void file_merge();
00271 
00273     void file_revert();
00274 
00276     void file_archive();
00277 
00279     void file_save();
00280 
00282     void file_saveas();
00283 
00285     void file_close();
00286 
00288     void configureDateTime();
00289 
00291     void showTip();
00292 
00294     void showTipOnStart();
00295 
00296     void downloadNewStuff();
00297     void uploadNewStuff();
00298 
00299     void toggleResourceButtons();
00300 
00301     void toggleDateNavigator();
00302     void toggleTodoView();
00303     void toggleEventViewer();
00304     void toggleResourceView();
00305 
00307     void checkAutoSave();
00308 
00310     void slotAutoArchivingSettingsModified();
00311 
00313     void slotAutoArchive();
00314 
00315     void configureDateTimeFinished(KProcess *);
00316 
00317     void setTitle();
00318 
00319     void updateUndoAction( const QString & );
00320 
00321     void updateRedoAction( const QString & );
00322 
00323     void slotImportDialogFinished( ImportDialog * );
00324 
00325   protected:
00327     KURL getSaveURL();
00328 
00329     void showStatusMessageOpen( const KURL &url, bool merge );
00330 
00331     void initCalendar( Calendar *cal );
00332 
00336     QWidget *dialogParent();
00337 
00338   private slots:
00339     void dumpText( const QString & );  // only for debugging purposes
00340 
00341   private:
00342     class ActionStringsVisitor;
00343 
00345     void initActions();
00346     void enableIncidenceActions( bool enable );
00347 
00348     KOrg::Part::List mParts; // List of parts loaded
00349     KURL mURL;      // URL of calendar file
00350     QString mFile;  // Local name of calendar file
00351     QString mLastUrl;  // URL of last loaded calendar.
00352 
00353     KTempFile *mTempFile;
00354     QTimer *mAutoSaveTimer;   // used if calendar is to be autosaved
00355     QTimer *mAutoArchiveTimer; // used for the auto-archiving feature
00356 
00357     // list of all existing KOrganizer instances
00358     static KOWindowList *mWindowList;
00359 
00360     // Actions
00361     KRecentFilesAction *mRecent;
00362     KToggleAction *mResourceButtonsAction;
00363 
00364     KToggleAction *mDateNavigatorShowAction;
00365     KToggleAction *mTodoViewShowAction;
00366     KToggleAction *mResourceViewShowAction;
00367     KToggleAction *mEventViewerShowAction;
00368 //     KToggleAction *mToggleAlarmAction;
00369 
00370     KAction *mShowIncidenceAction;
00371     KAction *mEditIncidenceAction;
00372     KAction *mDeleteIncidenceAction;
00373 //     KAction *mAssignResourceAction;
00374 
00375     KAction *mCutAction;
00376     KAction *mCopyAction;
00377     KAction *mDeleteAction;
00378     KAction *mNextXDays;
00379     KAction *mPublishEvent;
00380 
00381     KAction *mUndoAction;
00382     KAction *mRedoAction;
00383 
00384     KSelectAction *mFilterAction;
00385 
00386     KXMLGUIClient *mGUIClient;
00387     KActionCollection *mACollection;
00388     CalendarView *mCalendarView;
00389     KOrg::MainWindow *mMainWindow;
00390     bool mIsPart;
00391 
00392     KONewStuff *mNewStuff;
00393     bool mHtmlExportSync;
00394 
00395     // Either mCalendar *or* mCalendarResources is set.
00396     Calendar *mCalendar;
00397     CalendarResources *mCalendarResources;
00398 
00399     ResourceView *mResourceView;
00400 
00401     bool mIsClosing;
00402 };
00403 
00404 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys