1 // File : QAD_Application.h
2 // Created : UI team, 22.09.00
3 // Descr : Study manager of QAD-based application
5 // Modified : Mon Dec 03 13:21:50 2001
6 // Author : Nicolas REJNERI
9 // Copyright : Open CASCADE 2001
13 #ifndef QAD_Application_H
14 #define QAD_Application_H
17 #include "QAD_Popup.h"
18 #include "QAD_Study.h"
20 #include "SALOME_NamingService.hxx"
26 #include <qstringlist.h>
27 #include <qtranslator.h>
33 class QAD_EXPORT QAD_Application : public QObject, public QAD_PopupServer
36 enum { EditUndoId, EditRedoId, EditCopyId, EditPasteId };
38 friend class QAD_Desktop;
41 QAD_Application ( const QString& format, const QString& description,
42 const QString& filter);
47 static bool addToDesktop( QAD_Application* app, SALOME_NamingService* name_service );
48 static QAD_Desktop* getDesktop();
50 static QPalette getPalette(bool alternative = false);
52 const QString& getApplicationName() const;
53 const QPixmap& getApplicationIcon() const;
55 /* studies management */
56 const QString& getStudyFormat() const;
57 const QString& getStudyExtension() const;
58 const QString& getStudyDescription() const;
61 bool isStudyOpened( const QString& studyname );
62 QAD_Study* getStudyByName( const QString& studyname );
63 QAD_Study* getActiveStudy() const;
64 QList<QAD_Study>& getStudies();
66 QAD_Study* newStudy();
67 QAD_Study* loadStudy( const QString& fileName);
68 QAD_Study* openStudy( const QString& fileName);
69 bool saveStudy( QAD_Study* study );
70 bool saveAsStudy( QAD_Study* study, const QString& fileName );
71 bool closeStudy( QAD_Study* study, bool permanently = false );
74 void updateFilePopup( QPopupMenu* menu, bool add, int index = -1 );
75 void updateEditPopup( QPopupMenu* menu, bool add, int index = -1 );
76 void updateViewPopup( QPopupMenu* menu, bool add, int index = -1 );
77 void updateHelpPopup( QPopupMenu* menu, bool add, int index = -1 );
78 void updateMainMenu( QMenuBar* menu, bool add, int index = -1 );
79 void updateStatusBar( QStatusBar*, bool add );
80 void updateToolBars( bool add );
83 QToolBar* createToolBar( int id,
84 const QString& label, Dock dock = DockTop,
85 bool dockTop = true, bool dockBottom = true,
86 bool dockLeft = true, bool dockRight = true,
87 bool dockMinimized = true, bool dockTornOff = true );
88 void removeToolBar( int id );
89 QToolBar* getToolBar( int id );
90 QList<QToolBar> getToolBars();
92 virtual void onStudyActivated( QAD_Study* );
93 virtual void onStudyDeactivated( QAD_Study* );
94 virtual void startOperation( QAD_Operation* op );
96 virtual void helpAbout();
97 virtual void helpSearch();
98 virtual void helpContents();
101 void updateActions();
104 void appActivated ( QAD_Application* );
105 void appDeactivated ( QAD_Application* );
106 void desktopCreated();
109 virtual bool onUndo();
110 virtual bool onRedo();
111 virtual bool onCopy();
112 virtual bool onPaste();
113 virtual void onOperationTerminated( bool );
116 void onDesktopCreated();
120 virtual int onUpdateMainMenuItems ( QMenuBar*, bool add, int index );
121 virtual int onUpdateFileActions ( QPopupMenu*, bool add, int index );
122 virtual int onUpdateEditActions ( QPopupMenu*, bool add, int index );
123 virtual int onUpdateViewActions ( QPopupMenu*, bool add, int index );
124 virtual int onUpdateHelpActions ( QPopupMenu*, bool add, int index );
125 virtual void onUpdateStatusBar( QStatusBar*, bool activate );
126 virtual void onUpdateToolBars( bool activate );
129 virtual void onStudyCreated( QAD_Study* );
130 virtual void onStudyOpened( QAD_Study* );
131 virtual void onStudyClosed( QAD_Study* );
132 virtual void onStudyShown( QAD_Study* );
133 virtual void onActiveStudyChanged( QAD_Study* oldActiveStudy,
134 QAD_Study* newActiveStudy );
135 /* specific initialization ( CAF etc. ) */
136 virtual bool initApp(SALOME_NamingService* name_service) = 0;
137 virtual bool createDesktop(SALOME_NamingService* name_service);
140 virtual bool undo( QAD_Study* study );
141 virtual bool redo( QAD_Study* study );
147 void onCreatePopup();
151 SALOMEDS::StudyManager_var myStudyMgr;
153 QAD_Study* myActiveStudy;
154 QList<QAD_Study> myStudies;
158 QString myStudyFormat;
159 QString myStudyExtension;
160 QString myStudyDescription;
163 /* SUN C++ v4.1 compiler BUG ?
164 Error when using protected 'desktop' in subclasses.
168 static QAD_Desktop* desktop; /* the only QAD desktop */
171 void createActions();
173 void addStudy( QAD_Study* study );
174 void removeStudy( QAD_Study* study );
177 QList<QAction> myEditActions;
178 QList<QAction> myViewActions;
179 QList<QAction> myHelpActions;
180 QMap<int, QToolBar*> myToolBars;