Documentation for OpenFLUID 2.2.0
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  @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 
52 
53 #include <openfluid/dllexport.hpp>
54 
55 
56 namespace Ui {
57 class WareSrcWidget;
58 }
59 
60 
61 namespace openfluid { namespace ui { namespace waresdev {
62 
63 
64 class WareFileEditor;
65 class TextEditMsgStream;
66 class WareSrcToolbar;
67 
68 
69 class OPENFLUID_API WareSrcWidget: public QWidget
70 {
71  Q_OBJECT
72 
73 
74  private slots:
75 
76  void onEditorTxtModified(WareFileEditor* Editor, bool Modified);
77 
78  void onCurrentTabChanged(int Index);
79 
80  void onProcessFinished();
81 
82  void onMessageClicked(WareSrcMsgParser::WareSrcMsg& Msg);
83 
84  void notifyConfigureLaunched(openfluid::ware::WareType Type, const QString& ID);
85 
86  void notifyConfigureFinished(openfluid::ware::WareType Type, const QString& ID);
87 
88  void notifyBuildLaunched(openfluid::ware::WareType Type, const QString& ID);
89 
90  void notifyBuildFinished(openfluid::ware::WareType Type, const QString& ID);
91 
92  void loadWareOptions();
93 
94  void displayBuildOptionsDialog();
95 
96 
97  private:
98 
99  Ui::WareSrcWidget* ui;
100 
102 
103  std::map<std::string, int> m_TabIndexByName;
104 
106 
108 
110 
111  QMap<QString, QAction*> m_ExternalToolsActions;
112 
113  /**
114  * List of opened source file editors by their absolute path
115  */
116  QMap<QString, WareFileEditor*> m_WareFilesByPath;
117 
118  openfluid::ui::waresdev::TextEditMsgStream* mp_TextEditMsgStream;
119 
120  bool m_IsStandalone;
121 
122  WareSrcToolbar* mp_WareSrcToolBar = nullptr;
123 
124  void addNewFileTab(int Index, const QString& AbsolutePath, const QString& TabLabel, const QString& TabTooltip = "");
125 
126  /**
127  Check if the file of the editor was changed and close it when conditions are satisfied
128  @return Editor index before it was removed
129  */
130  int editorCheckChangeClose(WareFileEditor* Editor, bool WithConfirm);
131 
132  /**
133  Deletes Editor
134  @return Editor index before it was removed
135  */
136  int closeFileTab(WareFileEditor* Editor);
137 
138  void clearEditorsMessages();
139 
140  void enableSignatureEdition(bool Enabled);
141 
142 
143  protected:
144 
145  bool eventFilter(QObject* Obj, QEvent* Event);
146 
147 
148  signals:
149 
150  void wareTextModified(WareSrcWidget* Widget, bool Modified);
151 
152  void editorSaved();
153 
154  void currentTabChanged(const QString& Path);
155 
157 
159 
161 
162  void openExternalToolRequested(const QString& Context, const QString& Path);
163 
164  void modifiedStatusChanged(bool CurrentEditorModified, bool FileOpen, bool WareModified);
165 
167 
168  void configureLaunched(openfluid::ware::WareType Type, const QString& ID);
169 
170  void configureFinished(openfluid::ware::WareType Type, const QString& ID);
171 
172  void buildLaunched(openfluid::ware::WareType Type, const QString& ID);
173 
174  void buildFinished(openfluid::ware::WareType Type, const QString& ID);
175 
176  void operationRequestedOnWare(const QString& OperationCode, const QString& WarePath);
177 
178 
179  public slots:
180 
182 
184 
185  void setBuildJobs(unsigned int Jobs);
186 
187  void configure();
188 
189  void build();
190 
191  void generateDoc();
192 
194 
196 
197  int closeCurrentEditor(bool WithConfirm = true);
198 
199  int onCloseFileTabRequested(int Index, bool WithConfirm = true);
200 
202 
203  void onOperationRequested(const QString& ActionCode);
204 
205  void newFile();
206 
208 
209  void openFile();
210 
211  void onWareChange();
212 
213  void editSignature(QString Path = "");
214 
215  /**
216  @param TopDirectory The path to the topmost directory where may be saved the file,
217  an empty string meaning this ware directory
218  @return The path where has been saved the file if it's above this ware, an empty string otherwise
219  */
220  QString saveAs(const QString& TopDirectory = "");
221 
222  void copyText();
223 
224  void cutText();
225 
226  void pasteText();
227 
228  void goToLine();
229 
230 
231  public:
232 
234  QWidget* Parent = nullptr);
235 
236  virtual ~WareSrcWidget();
237 
239 
241 
242  /**
243  Set the file editor for the absolute path of Info as the current tab
244  @details Check if the file editor is already opened. If true, set this editor as the current tab.
245  Otherwise does nothing.
246  @return true if the file editor was already opened, false otherwise
247  */
249 
251 
253 
254  bool isWareProcessRunning() const;
255 
257 
258  void closeFileTabsInFolder(QString FolderPath, bool Confirm=true);
259 
261 
263 
264  int closeFileTab(const QString& Path);
265 
267 
269 
270 };
271 
272 
273 } } } // namespaces
274 
275 
276 #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:70
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