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