Documentation for OpenFLUID 2.2.1
WareSrcWidget.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2021-2026, INRAE
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  @author Armel THÖNI <armel.thoni@inrae.fr>
38 */
39 
40 #ifndef __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__
41 #define __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__
42 
43 
44 #include <QWidget>
45 #include <QFileSystemWatcher>
46 
53 
54 #include <openfluid/dllexport.hpp>
55 
56 
57 namespace Ui {
58 class WareSrcWidget;
59 }
60 
61 
62 namespace openfluid { namespace ui { namespace waresdev {
63 
64 
65 class WareFileEditor;
66 class TextEditMsgStream;
67 class WareSrcToolbar;
68 
69 
70 class OPENFLUID_API WareSrcWidget: public QWidget
71 {
72  Q_OBJECT
73 
74 
75  private slots:
76 
77  void onEditorTxtModified(WareFileEditor* Editor, bool Modified);
78 
79  void onCurrentTabChanged(int Index);
80 
81  void onProcessFinished();
82 
83  void onMessageClicked(WareSrcMsgParser::WareSrcMsg& Msg);
84 
85  void notifyConfigureLaunched(openfluid::ware::WareType Type, const QString& ID);
86 
87  void notifyConfigureFinished(openfluid::ware::WareType Type, const QString& ID);
88 
89  void notifyBuildLaunched(openfluid::ware::WareType Type, const QString& ID);
90 
91  void notifyBuildFinished(openfluid::ware::WareType Type, const QString& ID);
92 
93  void loadWareOptions();
94 
95  void displayBuildOptionsDialog();
96 
97 
98  private:
99 
100  Ui::WareSrcWidget* ui;
101 
103 
104  std::map<std::string, int> m_TabIndexByName;
105 
107 
109 
111 
112  QMap<QString, QAction*> m_ExternalToolsActions;
113 
114  /**
115  * List of opened source file editors by their absolute path
116  */
117  QMap<QString, WareFileEditor*> m_WareFilesByPath;
118 
119  openfluid::ui::waresdev::TextEditMsgStream* mp_TextEditMsgStream;
120 
121  std::string m_TestFolderPath;
122 
123  QFileSystemWatcher m_TestWatcher;
124 
125  bool m_IsStandalone;
126 
127  WareSrcToolbar* mp_WareSrcToolBar = nullptr;
128 
129  void addNewFileTab(int Index, const QString& AbsolutePath, const QString& TabLabel, const QString& TabTooltip = "");
130 
131  /**
132  Check if the file of the editor was changed and close it when conditions are satisfied
133  @return Editor index before it was removed
134  */
135  int editorCheckChangeClose(WareFileEditor* Editor, bool WithConfirm);
136 
137  /**
138  Deletes Editor
139  @return Editor index before it was removed
140  */
141  int closeFileTab(WareFileEditor* Editor);
142 
143  void clearEditorsMessages();
144 
145  void enableSignatureEdition(bool Enabled);
146 
147 
148  protected:
149 
150  bool eventFilter(QObject* Obj, QEvent* Event);
151 
152 
153  signals:
154 
155  void wareTextModified(WareSrcWidget* Widget, bool Modified);
156 
157  void editorSaved();
158 
159  void currentTabChanged(const QString& Path);
160 
162 
164 
166 
167  void openExternalToolRequested(const QString& Context, const QString& Path);
168 
169  void modifiedStatusChanged(bool CurrentEditorModified, bool FileOpen, bool WareModified);
170 
171  void testStatusChanged(bool Enabled);
172 
174 
175  void configureLaunched(openfluid::ware::WareType Type, const QString& ID);
176 
177  void configureFinished(openfluid::ware::WareType Type, const QString& ID);
178 
179  void buildLaunched(openfluid::ware::WareType Type, const QString& ID);
180 
181  void buildFinished(openfluid::ware::WareType Type, const QString& ID);
182 
183  void operationRequestedOnWare(const QString& OperationCode, const QString& WarePath);
184 
185 
186  private slots:
187 
188  void updateTestAction();
189 
190 
191  public slots:
192 
194 
196 
197  void setBuildJobs(unsigned int Jobs);
198 
199  void configure();
200 
201  void build();
202 
203  void test();
204 
205  void generateDoc();
206 
208 
210 
211  int closeCurrentEditor(bool WithConfirm = true);
212 
213  int onCloseFileTabRequested(int Index, bool WithConfirm = true);
214 
216 
217  void onOperationRequested(const QString& ActionCode);
218 
219  void newFile();
220 
222 
223  void openFile();
224 
225  void onWareChange();
226 
227  void editSignature(QString Path = "");
228 
229  /**
230  @param TopDirectory The path to the topmost directory where may be saved the file,
231  an empty string meaning this ware directory
232  @return The path where has been saved the file if it's above this ware, an empty string otherwise
233  */
234  QString saveAs(const QString& TopDirectory = "");
235 
236  void copyText();
237 
238  void cutText();
239 
240  void pasteText();
241 
242  void goToLine();
243 
244 
245  public:
246 
248  QWidget* Parent = nullptr);
249 
250  virtual ~WareSrcWidget();
251 
253 
255 
256  /**
257  Set the file editor for the absolute path of Info as the current tab
258  @details Check if the file editor is already opened. If true, set this editor as the current tab.
259  Otherwise does nothing.
260  @return true if the file editor was already opened, false otherwise
261  */
263 
265 
267 
268  bool isWareProcessRunning() const;
269 
271 
272  void closeFileTabsInFolder(QString FolderPath, bool Confirm=true);
273 
275 
277 
278  int closeFileTab(const QString& Path);
279 
281 
283 
284 };
285 
286 
287 } } } // namespaces
288 
289 
290 #endif /* __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__ */
Definition: TextEditMsgStream.hpp:56
Definition: WareFileEditor.hpp:55
Definition: WareSrcActionsCollection.hpp:52
Definition: WareSrcMsgViewer.hpp:55
Definition: WareSrcToolbar.hpp:58
Definition: WareSrcUIContainer.hpp:92
Definition: WareSrcWidget.hpp:71
int onCloseFileTabRequested(int Index, bool WithConfirm=true)
void openExternalToolRequested(const QString &Context, const QString &Path)
void setBuildJobs(unsigned int Jobs)
void buildLaunched(openfluid::ware::WareType Type, const QString &ID)
void wareTextModified(WareSrcWidget *Widget, bool Modified)
bool setCurrent(const openfluid::waresdev::WareSrcEnquirer::WarePathInfo &Info)
void openFileTab(const openfluid::waresdev::WareSrcEnquirer::WarePathInfo &Info, int Index=-1)
void modifiedStatusChanged(bool CurrentEditorModified, bool FileOpen, bool WareModified)
void currentTabChanged(const QString &Path)
void configureLaunched(openfluid::ware::WareType Type, const QString &ID)
int closeFileTab(const QString &Path)
bool eventFilter(QObject *Obj, QEvent *Event)
WareSrcUIContainer & wareSrcContainer()
QString saveAs(const QString &TopDirectory="")
void closeFileTabsInFolder(QString FolderPath, bool Confirm=true)
void setBuildMode(openfluid::waresdev::WareSrcContainer::BuildMode Mode)
void operationRequestedOnWare(const QString &OperationCode, const QString &WarePath)
void onOperationRequested(const QString &ActionCode)
void configureFinished(openfluid::ware::WareType Type, const QString &ID)
WareSrcWidget(const openfluid::waresdev::WareSrcEnquirer::WarePathInfo &Info, bool IsStandalone, QWidget *Parent=nullptr)
int closeCurrentEditor(bool WithConfirm=true)
void setConfigureMode(openfluid::waresdev::WareSrcContainer::ConfigMode Mode)
void buildFinished(openfluid::ware::WareType Type, const QString &ID)
Definition: WareStatusDashboardWidget.hpp:59
BuildMode
Definition: WareSrcContainer.hpp:66
ConfigMode
Definition: WareSrcContainer.hpp:61
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: AboutDialog.hpp:51
FilesystemPath Path
Definition: FilesystemPath.hpp:308
WareType
Definition: TypeDefs.hpp:61
Definition: ApplicationException.hpp:47
Definition: WareSrcEnquirer.hpp:57