00001 /* -*- c++ -*- (for Emacs) 00002 * 00003 * digestapplication.h 00004 * Nodal 00005 * 00006 * Imported into Nodal by Aidan Lane on Thu Feb 24 2005. 00007 * Copyright (c) 2005 CEMA, Monash University. All rights reserved. 00008 * 00009 * Original file: 00010 * 00011 * digestapplication.h 00012 * EverGreen 00013 * 00014 * Created by Aidan Lane on Mon Jul 19 2004. 00015 * Copyright (c) 2004 Aidan Lane. All rights reserved. 00016 * 00017 * This program is free software; you can redistribute it and/or modify 00018 * it under the terms of the GNU General Public License as published by 00019 * the Free Software Foundation; either version 2 of the License, or 00020 * (at your option) any later version. 00021 * 00022 * This program is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU General Public License for more details. 00026 * 00027 * You should have received a copy of the GNU General Public License 00028 * along with this program; if not, write to the Free Software 00029 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00030 */ 00031 00032 #ifndef DIGESTAPPLICATION_H 00033 #define DIGESTAPPLICATION_H 00034 00035 00036 #include "mdiapplication.h" 00037 00038 #include <QHash> 00039 #include <QPointer> 00040 #include <QSqlDatabase> 00041 00042 #include <jni.h> 00043 00044 #include "digest.h" // Digest namespace 00045 #include "digestprefsdialog.h" 00046 00047 class QActionGroup; 00048 class QAction; 00049 class QDialog; 00050 class QMenuBar; 00051 class QThread; 00052 00053 class Diagram; 00054 class DigestActionManager; 00055 class DigestDbModel; 00056 class DigestDbController; 00057 class ElementInspector; 00058 class GuiDiagramController; 00059 class MDIDiagramWindow; 00060 class SettingsModel; 00061 class SettingsController; 00062 00063 00070 class DigestApplication : public MDIApplication { 00071 00072 Q_OBJECT 00073 00074 public: 00075 // TODO: rename this to something more intuitive - MDI view is stored as the hash key of m_managedDiagrams 00076 struct DiagramMvcStruct { 00077 DiagramMvcStruct( Diagram* model = 0, 00078 QThread* controllerThreadHost = 0, 00079 GuiDiagramController* cached_controller = 0 ) 00080 : model(model), 00081 controllerThreadHost(controllerThreadHost), 00082 cached_controller(cached_controller) {} 00083 Diagram* model; 00084 QThread* controllerThreadHost; 00085 GuiDiagramController* cached_controller; 00086 }; 00087 00088 DigestApplication( int& argc, char** argv ); 00089 virtual ~DigestApplication(); 00090 00091 bool event( QEvent* e ); 00092 00093 const QHash<MDIDiagramWindow*, DiagramMvcStruct>& managedDiagrams() const { 00094 return m_managedDiagrams; 00095 } 00096 00097 bool isElementInspectorVisible() const; 00098 00099 virtual bool childWindowCloseRequest( MDIChildBase* child ); 00100 virtual void setActiveChild( MDIChildBase* child ); 00101 00102 static QString saneDefaultPath(); 00103 00104 00105 signals: 00109 void activeChildChanged( MDIChildBase* child ); 00110 00111 void elementInspectorVisibilityToggled(); 00112 00113 00114 public slots: 00115 /* We only implement slots for actions that this manager is actually 00116 * responsible for. 00117 * 00118 * I have chosen to provide all diagram _management_ in this class (sometimes 00119 * telling the diagram controllers what to do), as we are the actual owners of 00120 * each of the model/view/controller components and the fact that 00121 * MDIDiagramWindow is just a view (so don't get it to do it). 00122 */ 00123 void newDiagram(); 00124 void openDiagram(); 00125 void closeDiagram( MDIChildBase* child = 0 ); 00126 bool saveDiagram( MDIChildBase* child = 0 ); 00127 bool saveDiagramAs( MDIChildBase* child = 0 ); 00128 bool saveAllDiagrams(); 00129 00130 void closeActiveWindow(); 00131 00132 void setElementInspectorVisible( bool visible ); 00133 00134 void showAppPrefs(); 00135 void showAppHelp(); 00136 void showAppAbout(); 00137 void appQuit(); 00138 00139 00140 private: 00141 void setupUi(); 00142 void createMenuBar(); 00143 MDIDiagramWindow* createNewMvcSet(); 00144 00145 00146 private: 00147 void init(); 00148 void initJvm(); 00149 00150 JavaVM* m_jvm; 00151 00152 QSqlDatabase m_db; 00153 QString m_dbConnectionName; 00154 00155 DigestDbModel* m_dbModel; 00156 DigestDbController* m_dbController; 00157 00158 SettingsModel* m_settingsModel; 00159 SettingsController* m_settingsController; 00160 00161 QHash<MDIDiagramWindow*, DiagramMvcStruct> m_managedDiagrams; // TODO: rename this to something more intuitive 00162 DigestActionManager* m_actionManager; 00163 00164 // The following are used to point to modal-less, single instance dialogs 00165 // that will remain allocated until closed by user. 00166 QPointer<ElementInspector> m_elementInspector; 00167 QPointer<DigestPrefsDialog> prefsDlg; 00168 QPointer<QDialog> aboutBoxDlg; 00169 00170 QMenuBar* m_globalMenuBar; // application-wide / global menu bar 00171 00172 QMenu* m_fileMenu; 00173 QMenu* m_recentFilesMenu;//TODO: remove me 00174 QMenu* m_editMenu; 00175 QMenu* m_viewMenu; 00176 QMenu* m_toolMenu; 00177 QMenu* m_windowMenu; 00178 QMenu* m_helpMenu; 00179 00180 QString m_prevPath; 00181 }; 00182 00183 00184 #endif // ! DIGESTAPPLICATION_H
1.5.2