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  @brief Header of ...
35 
36  @author Aline LIBRES <aline.libres@gmail.com>
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 
87  private:
88 
89  Ui::WareSrcWidget* ui;
90 
92 
93  /**
94  * List of opened source file editors by their absolute path
95  */
96  QMap<QString, WareFileEditor*> m_WareFilesByPath;
97 
98  openfluid::ui::waresdev::TextEditMsgStream* mp_TextEditMsgStream;
99 
100  bool m_IsStandalone;
101 
102  WareSrcToolbar* mp_StandaloneToolBar = 0;
103 
104  void addNewFileTab(int Index, const QString& AbsolutePath, const QString& TabLabel, const QString& TabTooltip = "");
105 
106  /**
107  Deletes Editor
108  @return Editor index before it was removed
109  */
110  int closeFileTab(WareFileEditor* Editor);
111 
112  void clearEditorsMessages();
113 
114 
115  protected:
116 
117  bool eventFilter(QObject* Obj, QEvent* Event);
118 
119 
120  signals:
121 
122  void wareTextModified(WareSrcWidget* Widget, bool Modified);
123 
124  void editorSaved();
125 
126  void currentTabChanged(const QString& Path);
127 
128  void findReplaceRequested();
129 
130  void openTerminalRequested();
131 
132  void openExplorerRequested();
133 
134  void modifiedStatusChanged(bool CurrentEditorModified, bool WareModified);
135 
136  void openAPIDocRequested();
137 
138  void configureLaunched(openfluid::ware::WareType Type, const QString& ID);
139 
140  void configureFinished(openfluid::ware::WareType Type, const QString& ID);
141 
142  void buildLaunched(openfluid::ware::WareType Type, const QString& ID);
143 
144  void buildFinished(openfluid::ware::WareType Type, const QString& ID);
145 
146 
147  public slots:
148 
149  void setReleaseMode();
150 
151  void setDebugMode();
152 
153  void setBuildWithInstallMode();
154 
155  void setBuildNoInstallMode();
156 
157  void configure();
158 
159  void build();
160 
161  void saveCurrentEditor();
162 
163  void saveAllFileTabs();
164 
165  int closeCurrentEditor(bool WithConfirm = true);
166 
167  int onCloseFileTabRequested(int Index, bool WithConfirm = true);
168 
169  void newFile();
170 
171  void deleteCurrentFile();
172 
173  void openFile();
174 
175  /**
176  @param TopDirectory The path to the topmost directory where may be saved the file,
177  an empty string meaning this ware directory
178  @return The path where has been saved the file if it's above this ware, an empty string otherwise
179  */
180  QString saveAs(const QString& TopDirectory = "");
181 
182  void copyText();
183 
184  void cutText();
185 
186  void pasteText();
187 
188  void goToLine();
189 
190 
191  public:
192 
193  WareSrcWidget(const openfluid::waresdev::WareSrcManager::PathInfo& Info, bool IsStandalone,
195  openfluid::waresdev::WareSrcContainer::BuildMode Build, QWidget* Parent = nullptr);
196 
197  ~WareSrcWidget();
198 
199  void openFileTab(const openfluid::waresdev::WareSrcManager::PathInfo& Info, int Index = -1);
200 
201  void openDefaultFiles();
202 
203  /**
204  Set the file editor for the absolute path of Info as the current tab
205  @details Check if the file editor is already opened. If true, set this editor as the current tab.
206  Otherwise does nothing.
207  @return true if the file editor was already opened, false otherwise
208  */
209  bool setCurrent(const openfluid::waresdev::WareSrcManager::PathInfo& Info);
210 
211  openfluid::waresdev::WareSrcContainer& wareSrcContainer();
212 
213  bool isWareModified();
214 
215  void closeAllFileTabs();
216 
217  WareFileEditor* currentEditor();
218 
219  QString getCurrentFilePath();
220 
221  int closeFileTab(const QString& Path);
222 
223  void checkModifiedStatus();
224 
225  void updateEditorsSettings();
226 
227 };
228 
229 
230 } } } // namespaces
231 
232 
233 #endif /* __OPENFLUID_UIWARESDEV_WARESRCWIDGET_HPP__ */
Definition: WareSrcToolbar.hpp:53
Header of ...
#define OPENFLUID_API
Definition: dllexport.hpp:87
Definition: WareSrcWidget.hpp:63
Definition: WareSrcManager.hpp:65
WareType
Definition: TypeDefs.hpp:62
ConfigMode
Definition: WareSrcContainer.hpp:63
Definition: ApplicationException.hpp:47
Definition: WareSrcMsgParser.hpp:58
Definition: WareSrcContainer.hpp:57
Definition: AboutDialog.hpp:51
Header of ...
Definition: TextEditMsgStream.hpp:55
BuildMode
Definition: WareSrcContainer.hpp:68
Definition: WareFileEditor.hpp:54