1 #ifndef SUIT_APPLICATION_H
2 #define SUIT_APPLICATION_H
5 #include "SUIT_Study.h"
14 class SUIT_ResourceMgr;
19 * \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
22 An <b>Application</b> is a class which defines application configuration and behaviour.
23 For example Application object defines what Viewers are used in this application, what auxilliary windows
24 are present, how user can dial with them. Also Application object defines an sertain type of data structure by
25 holding of pointer on an instance of SUIT_Study class (which represents Document data structure). In other words
26 Application defines type of sata structure, type of used Viewers, type of main GUI widget (Desktop),
27 and other auxilliary tools.
30 class SUIT_EXPORT SUIT_Application : public QObject
36 virtual ~SUIT_Application();
38 //! Returns main widget (Desktop) of the application (if it exists)
39 virtual SUIT_Desktop* desktop();
41 /*! Returns FALSE if applic ation can not be closed (because of non saved data for example).
42 This method called by SUIT_Session whin closing of application was requested. */
43 virtual bool isPossibleToClose();
45 virtual void closeApplication();
47 //! Returns active Study. If Application supports wirking with several studies this method should be redefined
48 virtual SUIT_Study* activeStudy() const;
50 //! Returns Name of application. Using is not defined.
51 virtual QString applicationName() const = 0;
53 virtual QString applicationVersion() const;
55 //! Shows the application's main widget. For non GUI application must be redefined.
58 //! Opens document <theFileName> into active Study. If Study is empty - creates it.
59 virtual bool useFile( const QString& theFileName);
61 //! Loads document <theName> into active Study. If Study is empty - creates it.
62 virtual bool useStudy( const QString& theName);
64 //! Creates new empty Study if active Study = 0
65 virtual void createEmptyStudy();
67 /*! Returns number of Studies.
68 * Must be redefined in Applications which support several studies for one Application instance. */
69 virtual int getNbStudies() const;
71 SUIT_ResourceMgr* resourceMgr() const;
73 /*! Returns instance of data object Convertor class according to given Viewer.
74 If convertation is not supported returns 0. */
75 virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; }
77 //! Puts the message to the status bar
78 void putInfo ( const QString&, const int = 0 );
80 //! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
81 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
82 const QString& caption, QWidget* parent ) = 0;
84 //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
85 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
88 void applicationClosed( SUIT_Application* );
89 void activated( SUIT_Application* );
92 SUIT_Application* startApplication( int, char** ) const;
93 SUIT_Application* startApplication( const QString&, int, char** ) const;
95 virtual void setDesktop( SUIT_Desktop* );
97 //! Creates a new Study instance. Must be redefined in new application according to its Study type.
98 virtual SUIT_Study* createNewStudy();
99 virtual void setActiveStudy( SUIT_Study* );
101 /** @name Create tool functions*/ //@{
102 int createTool( const QString& );
103 int createTool( const int, const int, const int = -1 );
104 int createTool( const int, const QString&, const int = -1 );
105 int createTool( QAction*, const int, const int = -1, const int = -1 );
106 int createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
108 /** @name Create menu functions*/ //@{
109 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
110 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
111 int createMenu( const int, const int, const int = -1, const int = -1 );
112 int createMenu( const int, const QString&, const int = -1, const int = -1 );
113 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
114 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
116 /** @name Set menu shown functions*/ //@{
117 void setMenuShown( QAction*, const bool );
118 void setMenuShown( const int, const bool );//@}
119 /** @name Set tool shown functions*/ //@{
120 void setToolShown( QAction*, const bool );
121 void setToolShown( const int, const bool );//@}
123 void setActionShown( QAction*, const bool );
124 void setActionShown( const int, const bool );
126 static QAction* separator();
127 QAction* action( const int ) const;
128 int actionId( const QAction* ) const;
129 void registerAction( const int, QAction* );
130 QAction* createAction( const int, const QString&, const QIconSet&, const QString&,
131 const QString&, const int, QObject* = 0,
132 const bool = false, QObject* = 0, const char* = 0 );
135 virtual void onDesktopActivated();
139 SUIT_Desktop* myDesktop;
141 QLabel* myStatusLabel;
144 //! This function must return a new application instance.
147 //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
148 typedef SUIT_Application* (*APP_CREATE_FUNC)();
151 #define APP_CREATE_NAME "createApplication"