Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
WareSrcWidgetCollection.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/**
34 @file WareSrcWidgetCollection.hpp
35
36 @author Aline LIBRES <aline.libres@gmail.com>
37 @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
38 @author Armel THÖNI <armel.thoni@inrae.fr>
39*/
40
41
42#ifndef __OPENFLUID_UIWARESDEV_WARESRCWIDGETCOLLECTION_HPP__
43#define __OPENFLUID_UIWARESDEV_WARESRCWIDGETCOLLECTION_HPP__
44
45
46#include <QObject>
47#include <QMap>
48#include <QString>
49#include <QTextDocument>
50
59
60
61class QTabWidget;
62
63
64namespace openfluid {
65
66namespace waresdev {
67class WareSrcEnquirer;
68}
69
70
71namespace ui { namespace waresdev {
72
73class WareSrcWidget;
74class FindReplaceDialog;
75
76
77class MigrationWorker : public QObject
78{
79 Q_OBJECT
80
81 private:
82
83 QString m_WarePath;
84
85 bool m_Verbose;
86
87 bool m_CheckoutNew;
88
89
90 signals:
91
92 void finished(bool Ok, const QString& Message);
93
94 void info(const QString& Message);
95
96 void warning(const QString& Message);
97
98 void error(const QString& Message);
99
100 void progressed(int Value);
101
102 public slots :
103
104 void run()
105 {
106 auto Listener = std::make_unique<WareMigrationListener>();
107
108 Listener->setVerbose(m_Verbose);
109
110 connect(Listener.get(), SIGNAL(info(const QString&)), this,
111 SIGNAL(info(const QString&)));
112 connect(Listener.get(), SIGNAL(warning(const QString&)), this,
113 SIGNAL(warning(const QString&)));
114 connect(Listener.get(), SIGNAL(error(const QString&)), this,
115 SIGNAL(error(const QString&)));
116 connect(Listener.get(), SIGNAL(progressed(int)), this,
117 SIGNAL(progressed(int)));
118
119 auto Migrator = openfluid::waresdev::WareSrcMigrator(m_WarePath.toStdString(),
120 Listener.get());
121
122 try
123 {
124 Migrator.performMigration();
125
126 // no thrown exception means that migration is successful
127 if (m_CheckoutNew)
128 {
129 GitUIProxy Git;
130 bool SuccessfulCheckout = false;
131 if (Git.checkout(m_WarePath, GitUIProxy::getCurrentOpenFLUIDBranchName(), false))
132 {
133 SuccessfulCheckout = true;
134 }
135 else
136 {
137 if (Git.checkout(m_WarePath, GitUIProxy::getCurrentOpenFLUIDBranchName(), true))
138 {
139 SuccessfulCheckout = true;
140 }
141 }
142
143 if(SuccessfulCheckout)
144 {
145 emit info(tr("Successful checkout of the current OpenFLUID version branch"));
146 }
147 else
148 {
149 emit error(tr("Unable to checkout branch corresponding to current OpenFLUID version branch."));
150 }
151 }
152 emit finished(true, "Migration succeeded");
153 }
154 catch (std::exception& e)
155 {
156 emit error(e.what());
157 emit finished(false, "Migration failed");
158 }
159 }
160
161
162 public:
163
164 explicit MigrationWorker(const QString& WarePath, bool Verbose=false, bool CheckoutNew=false):
165 m_WarePath(WarePath), m_Verbose(Verbose), m_CheckoutNew(CheckoutNew)
166 {
167 }
168
169};
170
171
173{
174 Q_OBJECT
175
176
177 private slots:
178
179 void onWareTxtModified(WareSrcWidget* Widget, bool Modified);
180
181 void onCloseWareTabRequested(int Index);
182
183 void onCurrentTabChanged(int Index);
184
185 void onFindReplaceRequested(FindReplaceDialog::FindReplaceAction Action, const QString& StringToFind,
186 const QString& StringForReplace, QTextDocument::FindFlags Options);
187
188 void checkModifiedStatus();
189
190 void notifyConfigureLaunched(openfluid::ware::WareType Type, const QString& ID);
191
192 void notifyConfigureFinished(openfluid::ware::WareType Type, const QString& ID);
193
194 void notifyBuildLaunched(openfluid::ware::WareType Type, const QString& ID);
195
196 void notifyBuildFinished(openfluid::ware::WareType Type, const QString& ID);
197
198 void onOperationRequestedOnWare(const QString& OperationCode, const QString& WarePath);
199
200
201 private:
202
203 QTabWidget* mp_TabWidget;
204
205 bool m_IsStandalone;
206
207 openfluid::waresdev::WareBuildOptions m_DefaultWareBuildOptions;
208
209 const openfluid::base::WorkspaceManager* mp_Manager;
210
211 /**
212 * List of opened ware widgets by their absolute path
213 */
214 QMap<QString, WareSrcWidget*> m_WareSrcWidgetByPath;
215
218 unsigned int m_DefaultBuildJobs;
219
220 FindReplaceDialog* mp_FindReplaceDialog;
221
222 WareSrcWidget* currentWareWidget();
223
224 bool isModified() const;
225
226 bool isProcessRunning() const;
227
228 void closeWareTab(WareSrcWidget* Ware);
229
230 void openWare(openfluid::ware::WareType Type, const QString& Title);
231
232 void newWare(openfluid::ware::WareType Type);
233
234 bool requestWareTabClosing(WareSrcWidget* Ware);
235
236
237 signals:
238
240
241 void currentTabChanged(const QString& Path);
242
243 void modifiedStatusChanged(bool CurrentEditorModified, bool FileOpen, bool CurrentWareModified);
244
245 void configureLaunched(openfluid::ware::WareType Type, const QString& ID);
246
247 void configureFinished(openfluid::ware::WareType Type, const QString& ID);
248
249 void buildLaunched(openfluid::ware::WareType Type, const QString& ID);
250
251 void buildFinished(openfluid::ware::WareType Type, const QString& ID);
252
253
254 public slots:
255
256 void editSignatureRequested(const QString& Path="");
257
258 bool openPath(const QString& Path);
259
260 // generates ware widget and opens signature dialog if asked
261 void openWarePath(const std::string& WarePath, bool EditSignature);
262
263 void setCurrent(const QString& Path);
264
265 QString getContextualPath(const QString& Path);
266
268
269 void openExplorer(const QString& Path = "");
270
272
273 void openTerminal(const QString& Path = "");
274
275 void openExternalTool(const QString& Command, const QString& Path = "");
276
278
280
281 void setBuildJobs(unsigned int Jobs);
282
283 void configure();
284
285 void build();
286
287 void test();
288
290
292
293 /**
294 @param TopDirectory The path to the topmost directory where may be saved the file,
295 an empty string meaning the current ware directory
296 @return The path where has been saved the file if it's above this ware, an empty string otherwise
297 */
298 QString saveAs(const QString& TopDirectory = "");
299
301
303
304 void openFile();
305
307
309
311
312 void newFile();
313
315
317
319
321
323
325
326 void copyText();
327
328 void cutText();
329
330 void pasteText();
331
333
334 void goToLine();
335
336 void closeEditor(const QString& FilePath);
337
338 void closeEditorsInFolderFromWare(const QString& WarePath, const QString& FolderPath, const bool Confirm);
339
341
342 void onWareChange(const QString& WarePath);
343
344
345 public:
346
347 WareSrcWidgetCollection(QTabWidget* TabWidget, bool IsStandalone);
348
350
351 /**
352 Returns false is there is unchanged modifications and user chooses to cancel closing, true otherwise
353 */
355
356 QStringList getOpenWarePaths();
357
359
361
363
365
366 bool duplicateWare(const QString& WarePath, const QString& NewWareName);
367
368 void deleteWare(const QString& WarePath);
369
370};
371
372
373} } } // namespaces
374
375
376#endif /* __OPENFLUID_UIWARESDEV_WARESRCWIDGETCOLLECTION_HPP__ */
Definition WorkspaceManager.hpp:55
Definition FindReplaceDialog.hpp:62
FindReplaceAction
Definition FindReplaceDialog.hpp:68
Definition GitUIProxy.hpp:64
bool checkout(const QString &Path, const QString &BranchName, bool New=false)
static QString getCurrentOpenFLUIDBranchName()
Definition WareSrcWidgetCollection.hpp:78
void warning(const QString &Message)
void error(const QString &Message)
void info(const QString &Message)
MigrationWorker(const QString &WarePath, bool Verbose=false, bool CheckoutNew=false)
Definition WareSrcWidgetCollection.hpp:164
void run()
Definition WareSrcWidgetCollection.hpp:104
void finished(bool Ok, const QString &Message)
Definition WareSrcWidgetCollection.hpp:173
void configureFinished(openfluid::ware::WareType Type, const QString &ID)
void setBuildMode(openfluid::waresdev::WareSrcContainer::BuildMode Mode)
void onWareChange(const QString &WarePath)
QString saveAs(const QString &TopDirectory="")
void closeEditor(const QString &FilePath)
void modifiedStatusChanged(bool CurrentEditorModified, bool FileOpen, bool CurrentWareModified)
void openWarePath(const std::string &WarePath, bool EditSignature)
QString getContextualPath(const QString &Path)
WareSrcWidgetCollection(QTabWidget *TabWidget, bool IsStandalone)
void buildLaunched(openfluid::ware::WareType Type, const QString &ID)
void setConfigureMode(openfluid::waresdev::WareSrcContainer::ConfigMode Mode)
void buildFinished(openfluid::ware::WareType Type, const QString &ID)
bool duplicateWare(const QString &WarePath, const QString &NewWareName)
void newSimulatorFromGhost(const openfluid::ware::SimulatorSignature &Signature)
void configureLaunched(openfluid::ware::WareType Type, const QString &ID)
void deleteWare(const QString &WarePath)
void editSignatureRequested(const QString &Path="")
void closeEditorsInFolderFromWare(const QString &WarePath, const QString &FolderPath, const bool Confirm)
void openExternalTool(const QString &Command, const QString &Path="")
Definition WareSrcWidget.hpp:71
Definition SimulatorSignature.hpp:262
BuildMode
Definition WareSrcContainer.hpp:66
ConfigMode
Definition WareSrcContainer.hpp:61
Definition WareSrcMigrator.hpp:58
#define OPENFLUID_API
Definition dllexport.hpp:86
WareType
Definition TypeDefs.hpp:61
Definition ApplicationException.hpp:47
Definition WareBuildOptions.hpp:60