Documentation for OpenFLUID 2.2.0
SignatureEditorWidget.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 SignatureEditorWidget.hpp
34 
35  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
36  @author Armel THÖNI <armel.thoni@inrae.fr>
37  @author Dorian GERARDIN <dorian.gerardin@inrae.fr>
38 */
39 
40 
41 #ifndef __OPENFLUID_UICOMMON_SIGNATUREEDITORWIDGET_HPP__
42 #define __OPENFLUID_UICOMMON_SIGNATUREEDITORWIDGET_HPP__
43 
44 
45 #include <QTabWidget>
46 #include <QTableWidget>
47 #include <QRegularExpressionValidator>
48 #if (QT_VERSION_MAJOR < 6)
49 #include <QRegExp>
50 #else
51 #include <QRegularExpression>
52 #endif
53 
56 #include <openfluid/dllexport.hpp>
64 
65 
66 namespace Ui
67 {
68  class SignatureEditorWidget;
69 }
70 
71 
72 namespace openfluid { namespace ui { namespace common {
73 
74 
75 class OPENFLUID_API SignatureEditorWidget : public QTabWidget
76 {
77  Q_OBJECT;
78 
79  private slots:
80 
81  void notifyChanged();
82 
83  void addAuthorLine();
84 
85  void removeAuthorLine();
86 
87  void addContactLine();
88 
89  void removeContactLine();
90 
91  void addDependencyLine();
92 
93  void removeDependencyLine();
94 
95  private:
96 
97 
98  Ui::SignatureEditorWidget* ui;
99 
100  void removeLine(QTableWidget* Table);
101 
102  bool m_StaticID;
103 
105 
106  void initializeCommon(const openfluid::ware::WareSignature* Signature);
107 
108  void initializeID(const QString& ID);
109 
110  void initializeIssuesUIFromSignature(const openfluid::ware::WareSignature& Signature);
111 
112  void initializeParametersUIFromSignature(const openfluid::ware::DataWareSignature& Signature);
113 
114  void initializeExtrafilesUIFromSignature(const openfluid::ware::DataWareSignature& Signature);
115 
116  void initializeInputAttributesUIFromSignature(const openfluid::ware::DataWareSignature& Signature, bool IsRW=true);
117 
118  void initializeAttributesUIFromSignature(const openfluid::ware::SimulatorSignature& Signature, bool IsRW=true);
119 
120  void initializeEventsUIFromSignature(const openfluid::ware::SimulatorSignature& Signature);
121 
122  void initializeInputVariablesUIFromSignature(const openfluid::ware::DataWareSignature& Signature, bool IsRW=true);
123 
124  void initializeVariablesUIFromSignature(const openfluid::ware::SimulatorSignature& Signature, bool IsRW=true);
125 
126  void initializeDynamicsUIFromSignature(const openfluid::ware::SimulatorSignature& Signature);
127 
128  void initializeIntegrationUIFromSignature(const openfluid::builderext::BuilderExtensionSignature& Signature);
129 
130  void updateSignatureFromCommonsUI(openfluid::ware::WareSignature& Signature) const;
131 
132  void updateSignatureFromParametersUI(openfluid::ware::DataWareSignature& Signature) const;
133 
134  void updateSignatureFromExtrafilesUI(openfluid::ware::DataWareSignature& Signature) const;
135 
136  void updateSignatureFromReadAttributesUI(openfluid::ware::DataWareSignature& Signature) const;
137 
138  void updateSignatureFromAttributesUI(openfluid::ware::SimulatorSignature& Signature) const;
139 
140  void updateSignatureFromEventsUI(openfluid::ware::SimulatorSignature& Signature) const;
141 
142  void updateSignatureFromReadVariablesUI(openfluid::ware::DataWareSignature& Signature) const;
143 
144  void updateSignatureFromVariablesUI(openfluid::ware::SimulatorSignature& Signature) const;
145 
146  void updateSignatureFromDynamicsUI(openfluid::ware::SimulatorSignature& Signature) const;
147 
148  void updateSignatureFromIntegrationUI(openfluid::builderext::BuilderExtensionSignature& Signature) const;
149 
150 
151  signals:
152 
153  void changed();
154 
156 
157 
158  public:
159 
160  explicit SignatureEditorWidget(QWidget* Parent = nullptr);
161 
163 
164  void initializeSimulator(const openfluid::ware::SimulatorSignature& Signature); // used by ghosts
165 
167 
169 
170  void initialize(const QString& SignaturePath);
171 
173 
174  bool exportSignature(const QString& SignaturePath) const;
175 
176  bool isEmptyID() const;
177 
178  QString getEditedID() const;
179 
180  bool areAllCellsValid(const QString& Header, const DataTableType& HandledDataType);
181 
182  bool areAllCellsEmpty(const QString& Header, const DataTableType& HandledDataType);
183 
184 };
185 
186 
187 // =====================================================================
188 // =====================================================================
189 
190 
191 #if (QT_VERSION_MAJOR < 6)
192 inline QRegExp getWareIdRegExp(QString& Tooltip)
193 #else
194 inline QRegularExpression getWareIdRegExp(QString& Tooltip)
195 #endif
196 {
197  Tooltip = QObject::tr("Accepts only letters, digits, dashes ('-'), underscores ('_') and dots ('.').");
198 #if (QT_VERSION_MAJOR < 6)
199  return QRegExp(QString::fromStdString(openfluid::tools::WareIDRuleStringAndTpl));
200 #else
201  return QRegularExpression(QString::fromStdString(openfluid::tools::WareIDRuleStringAndTpl));
202 #endif
203 }
204 
205 } } } // namespaces
206 
207 
208 #endif /* __OPENFLUID_UICOMMON_SIGNATUREEDITORWIDGET_HPP__ */
Definition: BuilderExtensionSignature.hpp:60
Definition: SignatureEditorWidget.hpp:76
bool areAllCellsValid(const QString &Header, const DataTableType &HandledDataType)
void initializeSimulator(const openfluid::ware::SimulatorSignature &Signature)
bool exportSignature(const QString &SignaturePath) const
void initializeBuilderext(const openfluid::builderext::BuilderExtensionSignature &Signature)
openfluid::ware::SimulatorSignature getSignature() const
void initialize(const QString &SignaturePath)
SignatureEditorWidget(QWidget *Parent=nullptr)
bool areAllCellsEmpty(const QString &Header, const DataTableType &HandledDataType)
void initializeObserver(const openfluid::ware::ObserverSignature &Observer)
Definition: WareIssuesManagerWidget.hpp:63
Definition: WareSignature.hpp:331
Definition: ObserverSignature.hpp:54
Definition: SimulatorSignature.hpp:237
Definition: WareSignature.hpp:56
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: AboutDialog.hpp:51
constexpr auto WareIDRuleStringAndTpl("[A-Za-z0-9]+([A-Za-z0-9_@\\.\\-]*)")
DataTableType
Definition: SignatureDataEditDefs.hpp:46
QRegExp getWareIdRegExp(QString &Tooltip)
Definition: SignatureEditorWidget.hpp:192
Definition: ApplicationException.hpp:47