Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
STD_Application.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 #ifndef STD_APPLICATION_H
24 #define STD_APPLICATION_H
25 
26 #include "STD.h"
27 
28 #include <SUIT_Application.h>
29 
30 #include <QList>
31 
32 class QMenu;
33 class QCloseEvent;
34 class QContextMenuEvent;
35 
36 class QToolBar;
37 class QtxAction;
38 class SUIT_Operation;
39 class SUIT_ViewWindow;
40 class SUIT_ToolWindow;
41 class SUIT_Desktop;
42 class SUIT_ViewManager;
44 
46 
47 #if defined WIN32
48 #pragma warning( disable: 4251 )
49 #endif
50 
52 {
53  Q_OBJECT
54 
55 public:
56  enum { MenuFileId, FileNewId, FileOpenId, FileReopenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
57  MenuViewId, ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
58  MenuEditId, EditCutId, EditCopyId, EditPasteId,
59  MenuHelpId, HelpAboutId,
60  UserID
61  };
62 
63 public:
65  virtual ~STD_Application();
66 
67  virtual QString applicationName() const;
68 
69  virtual bool isPossibleToClose( bool& );
70  virtual bool useFile( const QString& );
71 
72  virtual void createEmptyStudy();
73 
74  void setEditEnabled( const bool );
75  bool isEditEnabled() const { return myEditEnabled; }
76 
77  void clearViewManagers();
78  virtual void addViewManager( SUIT_ViewManager* );
79  virtual void removeViewManager( SUIT_ViewManager* );
80 
81  SUIT_ViewManager* activeViewManager() const;
82  SUIT_ViewManager* viewManager( const QString& ) const;
83 
84  bool containsViewManager( SUIT_ViewManager* ) const;
85 
87  void viewManagers( ViewManagerList& ) const;
88  void viewManagers( const QString&, ViewManagerList& ) const;
89  virtual int viewManagerId (const SUIT_ViewManager* ) const;
90 
91  virtual QString getFileFilter( bool open ) const;
92  virtual QString getFileName( bool open, const QString& initial, const QString& filters,
93  const QString& caption, QWidget* parent );
94  QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
95 
96  virtual void start();
97 
98  virtual void closeApplication();
99 
100  virtual void contextMenuPopup( const QString&, QMenu*, QString& ) {}
101 
102  bool exitConfirmation() const;
103  void setExitConfirmation( const bool );
104 
105  virtual void updateDesktopTitle();
106 
107 signals:
109  void viewManagerAdded( SUIT_ViewManager* );
111  void viewManagerRemoved( SUIT_ViewManager* );
113  void viewManagerActivated( SUIT_ViewManager* );
114  void appClosed();
115 
116 public slots:
117  virtual void onNewDoc();
118  virtual bool onNewDoc( const QString& );
119 
120  virtual void onCloseDoc( bool ask = true );
121  virtual void onSaveDoc();
122  virtual bool onSaveAsDoc();
123 
124  virtual void onOpenDoc();
125  virtual bool onOpenDoc( const QString& );
126 
127  virtual bool onReopenDoc();
128 
129  virtual void onExit();
130 
131  virtual void onCopy();
132  virtual void onPaste();
133 
134  virtual void onViewStatusBar( bool );
135 
136  virtual void onHelpAbout();
137 
138  virtual void onDesktopClosing( SUIT_Desktop*, QCloseEvent* );
139  virtual void onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* );
140 
141 private slots:
142  virtual void onViewManagerActivated( SUIT_ViewManager* );
143 
144 protected:
145  enum { OpenCancel, OpenNew, OpenExist };
146  enum { CloseCancel, CloseSave, CloseDiscard };
147 
148 protected:
149  virtual void createActions();
150  virtual void updateCommandsStatus();
151 
152  virtual void setDesktop( SUIT_Desktop* );
153 
154  virtual void loadPreferences();
155  virtual void savePreferences();
156 
157  virtual void studySaved( SUIT_Study* );
158  virtual void studyOpened( SUIT_Study* );
159  virtual void studyCreated( SUIT_Study* );
160 
161  virtual void beforeCloseDoc( SUIT_Study* theDoc );
162  virtual void afterCloseDoc();
163 
164  virtual void setActiveViewManager( SUIT_ViewManager* );
165 
166  virtual int openChoice( const QString& );
167  virtual bool openAction( const int, const QString& );
168 
169  virtual int closeChoice( const QString& );
170  virtual bool closeAction( const int, bool& );
171  virtual bool closeDoc( bool ask = true );
172  virtual bool closeActiveDoc( bool permanently = true );
173 
174  virtual bool abortAllOperations();
175 
176 private:
179 
180 private:
183 };
184 
185 #if defined WIN32
186 #pragma warning( default: 4251 )
187 #endif
188 
189 #endif