##// END OF EJS Templates
Changes Variable from struct to class
Alexandre Leroux -
r151:8de0b7c96d22
parent child
Show More
@@ -0,0 +1,32
1 #include "Variable/Variable.h"
2
3 struct Variable::VariablePrivate {
4 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission)
5 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
6 {
7 }
8
9 QString m_Name;
10 QString m_Unit;
11 QString m_Mission;
12 };
13
14 Variable::Variable(const QString &name, const QString &unit, const QString &mission)
15 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission)}
16 {
17 }
18
19 QString Variable::name() const noexcept
20 {
21 return impl->m_Name;
22 }
23
24 QString Variable::mission() const noexcept
25 {
26 return impl->m_Mission;
27 }
28
29 QString Variable::unit() const noexcept
30 {
31 return impl->m_Unit;
32 }
@@ -1,20 +1,24
1 #ifndef SCIQLOP_VARIABLE_H
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
3
4 #include <QString>
4 #include <Common/spimpl.h>
5
6 class QString;
5
7
6 /**
8 /**
7 * @brief The Variable struct represents a variable in SciQlop.
9 * @brief The Variable class represents a variable in SciQlop.
8 */
10 */
9 struct Variable {
11 class Variable {
10 explicit Variable(const QString &name, const QString &unit, const QString &mission)
12 public:
11 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
13 explicit Variable(const QString &name, const QString &unit, const QString &mission);
12 {
14
13 }
15 QString name() const noexcept;
16 QString mission() const noexcept;
17 QString unit() const noexcept;
14
18
15 QString m_Name;
19 private:
16 QString m_Unit;
20 class VariablePrivate;
17 QString m_Mission;
21 spimpl::unique_impl_ptr<VariablePrivate> impl;
18 };
22 };
19
23
20 #endif // SCIQLOP_VARIABLE_H
24 #endif // SCIQLOP_VARIABLE_H
@@ -1,6 +1,6
1 #include <Variable/Variable.h>
1 #include <Variable/VariableModel.h>
2 #include <Variable/VariableModel.h>
2
3
3 #include <Variable/Variable.h>
4
4
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6
6
@@ -67,11 +67,11 QVariant VariableModel::data(const QModelIndex &index, int role) const
67 if (auto variable = impl->m_Variables.at(index.row()).get()) {
67 if (auto variable = impl->m_Variables.at(index.row()).get()) {
68 switch (index.column()) {
68 switch (index.column()) {
69 case NAME_COLUMN:
69 case NAME_COLUMN:
70 return variable->m_Name;
70 return variable->name();
71 case UNIT_COLUMN:
71 case UNIT_COLUMN:
72 return variable->m_Unit;
72 return variable->unit();
73 case MISSION_COLUMN:
73 case MISSION_COLUMN:
74 return variable->m_Mission;
74 return variable->mission();
75 default:
75 default:
76 // No action
76 // No action
77 break;
77 break;
General Comments 0
You need to be logged in to leave comments. Login now