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