Manual for OpenFLUID 2.1.10

WareSrcWidget.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30  */
31 
32 /**
33  @file WareSrcWidget.hpp
34 
35  @author Aline LIBRES <aline.libres@gmail.com>
36  @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
37 */
38 
39 #ifndef __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__
40 #define __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__
41 
42 
43 #include <QWidget>
44 
45 #include <openfluid/dllexport.hpp>
48 
49 
50 namespace Ui {
51 class WareSrcWidget;
52 }
53 
54 
55 namespace openfluid { namespace ui { namespace waresdev {
56 
57 
58 class WareFileEditor;
59 class TextEditMsgStream;
60 class WareSrcToolbar;
61 
62 
63 class OPENFLUID_API WareSrcWidget: public QWidget
64 {
65  Q_OBJECT
66 
67 
68  private slots:
69 
70  void onEditorTxtModified(WareFileEditor* Editor, bool Modified);
71 
72  void onCurrentTabChanged(int Index);
73 
74  void onProcessFinished();
75 
76  void onMessageClicked(openfluid::waresdev::WareSrcMsgParser::WareSrcMsg& Msg);
77 
78  void notifyConfigureLaunched(openfluid::ware::WareType Type, const QString& ID);
79 
80  void notifyConfigureFinished(openfluid::ware::WareType Type, const QString& ID);
81 
82  void notifyBuildLaunched(openfluid::ware::WareType Type, const QString& ID);
83 
84  void notifyBuildFinished(openfluid::ware::WareType Type, const QString& ID);
85 
86  void updateWareOptions();
87 
88 
89  private:
90 
91  Ui::WareSrcWidget* ui;
92 
94 
95  QMap<QString, QAction*> m_ExternalToolsActions;
96 
97  /**
98  * List of opened source file editors by their absolute path
99  */
100  QMap<QString, WareFileEditor*> m_WareFilesByPath;
101 
102  openfluid::ui::waresdev::TextEditMsgStream* mp_TextEditMsgStream;
103 
104  bool m_IsStandalone;
105 
106  WareSrcToolbar* mp_StandaloneToolBar = 0;
107 
108  void addNewFileTab(int Index, const QString& AbsolutePath, const QString& TabLabel, const QString& TabTooltip = "");
109 
110  /**
111  Deletes Editor
112  @return Editor index before it was removed
113  */
114  int closeFileTab(WareFileEditor* Editor);
115 
116  void clearEditorsMessages();
117 
118 
119  protected:
120 
121  bool eventFilter(QObject* Obj, QEvent* Event);
122 
123 
124  signals:
125 
126  void wareTextModified(WareSrcWidget* Widget, bool Modified);
127 
128  void editorSaved();
129 
130  void currentTabChanged(const QString& Path);
131 
132  void findReplaceRequested();
133 
134  void openTerminalRequested();
135 
136  void openExplorerRequested();
137 
138  void openExternalToolRequested(const QString& Context, const QString& Path);
139 
140  void modifiedStatusChanged(bool CurrentEditorModified, bool WareModified);
141 
142  void openAPIDocRequested();
143 
144  void configureLaunched(openfluid::ware::WareType Type, const QString& ID);
145 
146  void configureFinished(openfluid::ware::WareType Type, const QString& ID);
147 
148  void buildLaunched(openfluid::ware::WareType Type, const QString& ID);
149 
150  void buildFinished(openfluid::ware::WareType Type, const QString& ID);
151 
152 
153  public slots:
154 
155  void setConfigureMode(openfluid::waresdev::WareSrcContainer::ConfigMode Mode);
156 
157  void setBuildMode(openfluid::waresdev::WareSrcContainer::BuildMode Mode);
158 
159  void setBuildJobs(unsigned int Jobs);
160 
161  void configure();
162 
163  void build();
164 
165  void generateDoc();
166 
167  void saveCurrentEditor();
168 
169  void saveAllFileTabs();
170 
171  int closeCurrentEditor(bool WithConfirm = true);
172 
173  int onCloseFileTabRequested(int Index, bool WithConfirm = true);
174 
175  void onOpenExternalToolRequested();
176 
177  void newFile();
178 
179  void deleteCurrentFile();
180 
181  void openFile();
182 
183  /**
184  @param TopDirectory The path to the topmost directory where may be saved the file,
185  an empty string meaning this ware directory
186  @return The path where has been saved the file if it's above this ware, an empty string otherwise
187  */
188  QString saveAs(const QString& TopDirectory = "");
189 
190  void copyText();
191 
192  void cutText();
193 
194  void pasteText();
195 
196  void goToLine();
197 
198 
199  public:
200 
201  WareSrcWidget(const openfluid::waresdev::WareSrcManager::PathInfo& Info, bool IsStandalone,
204  unsigned int Jobs,
205  QWidget* Parent = nullptr);
206 
207  virtual ~WareSrcWidget();
208 
209  void openFileTab(const openfluid::waresdev::WareSrcManager::PathInfo& Info, int Index = -1);
210 
211  void openDefaultFiles();
212 
213  /**
214  Set the file editor for the absolute path of Info as the current tab
215  @details Check if the file editor is already opened. If true, set this editor as the current tab.
216  Otherwise does nothing.
217  @return true if the file editor was already opened, false otherwise
218  */
219  bool setCurrent(const openfluid::waresdev::WareSrcManager::PathInfo& Info);
220 
221  openfluid::waresdev::WareSrcContainer& wareSrcContainer();
222 
223  bool isWareModified();
224 
225  bool isWareProcessRunning() const;
226 
227  void closeAllFileTabs();
228 
229  WareFileEditor* currentEditor();
230 
231  QString getCurrentFilePath();
232 
233  int closeFileTab(const QString& Path);
234 
235  void checkModifiedStatus();
236 
237  void updateEditorsSettings();
238 
239 };
240 
241 
242 } } } // namespaces
243 
244 
245 #endif /* __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__ */
Definition: ApplicationException.hpp:47
Definition: WareSrcToolbar.hpp:55
Definition: WareSrcManager.hpp:65
BuildMode
Definition: WareSrcContainer.hpp:69
Definition: WareSrcMsgParser.hpp:58
Definition: WareFileEditor.hpp:54
Definition: TextEditMsgStream.hpp:55
WareType
Definition: TypeDefs.hpp:60
Definition: AboutDialog.hpp:50
Header of ...
ConfigMode
Definition: WareSrcContainer.hpp:64
Definition: WareSrcContainer.hpp:58
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: WareSrcWidget.hpp:63
Header of ...