##// END OF EJS Templates
A variable is now created with its dateTime too....
perrinel -
r212:8e4faeed90b4
parent child
Show More
@@ -1,14 +1,19
1 #ifndef SCIQLOP_SQPDATETIME_H
1 #ifndef SCIQLOP_SQPDATETIME_H
2 #define SCIQLOP_SQPDATETIME_H
2 #define SCIQLOP_SQPDATETIME_H
3
3
4 /**
4 /**
5 * @brief The SqpDateTime struct holds the information of time parameters
5 * @brief The SqpDateTime struct holds the information of time parameters
6 */
6 */
7 struct SqpDateTime {
7 struct SqpDateTime {
8 /// Start time
8 /// Start time
9 double m_TStart;
9 double m_TStart;
10 /// End time
10 /// End time
11 double m_TEnd;
11 double m_TEnd;
12
13 bool contains(const SqpDateTime &dateTime)
14 {
15 return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
16 }
12 };
17 };
13
18
14 #endif // SCIQLOP_SQPDATETIME_H
19 #endif // SCIQLOP_SQPDATETIME_H
@@ -1,44 +1,45
1 #ifndef SCIQLOP_VARIABLE_H
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
3
4 #include <Data/SqpDateTime.h>
4 #include <Data/SqpDateTime.h>
5
5
6
6
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8 #include <QObject>
8 #include <QObject>
9
9
10 #include <Common/spimpl.h>
10 #include <Common/spimpl.h>
11
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
13
13
14 class IDataSeries;
14 class IDataSeries;
15 class QString;
15 class QString;
16
16
17 /**
17 /**
18 * @brief The Variable class represents a variable in SciQlop.
18 * @brief The Variable class represents a variable in SciQlop.
19 */
19 */
20 class Variable {
20 class Variable {
21 public:
21 public:
22 explicit Variable(const QString &name, const QString &unit, const QString &mission);
22 explicit Variable(const QString &name, const QString &unit, const QString &mission,
23 const SqpDateTime &dateTime);
23
24
24 QString name() const noexcept;
25 QString name() const noexcept;
25 QString mission() const noexcept;
26 QString mission() const noexcept;
26 QString unit() const noexcept;
27 QString unit() const noexcept;
27
28
28 void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
29 void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
29
30
30 /// @return the data of the variable, nullptr if there is no data
31 /// @return the data of the variable, nullptr if there is no data
31 IDataSeries *dataSeries() const noexcept;
32 IDataSeries *dataSeries() const noexcept;
32
33
33 public slots:
34 public slots:
34 void onXRangeChanged(SqpDateTime dateTime);
35 void onXRangeChanged(SqpDateTime dateTime);
35
36
36 private:
37 private:
37 class VariablePrivate;
38 class VariablePrivate;
38 spimpl::unique_impl_ptr<VariablePrivate> impl;
39 spimpl::unique_impl_ptr<VariablePrivate> impl;
39 };
40 };
40
41
41 // Required for using shared_ptr in signals/slots
42 // Required for using shared_ptr in signals/slots
42 Q_DECLARE_METATYPE(std::shared_ptr<Variable>)
43 Q_DECLARE_METATYPE(std::shared_ptr<Variable>)
43
44
44 #endif // SCIQLOP_VARIABLE_H
45 #endif // SCIQLOP_VARIABLE_H
@@ -1,44 +1,49
1 #ifndef SCIQLOP_VARIABLEMODEL_H
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
3
4 #include <Common/spimpl.h>
4
5 #include <Data/SqpDateTime.h>
5
6
6 #include <QAbstractTableModel>
7 #include <QAbstractTableModel>
7 #include <QLoggingCategory>
8 #include <QLoggingCategory>
8
9
10 #include <Common/spimpl.h>
11
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
10
13
11 class IDataSeries;
14 class IDataSeries;
12 class Variable;
15 class Variable;
13
16
14 /**
17 /**
15 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
18 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
16 */
19 */
17 class VariableModel : public QAbstractTableModel {
20 class VariableModel : public QAbstractTableModel {
18 public:
21 public:
19 explicit VariableModel(QObject *parent = nullptr);
22 explicit VariableModel(QObject *parent = nullptr);
20
23
21 /**
24 /**
22 * Creates a new variable in the model
25 * Creates a new variable in the model
23 * @param name the name of the new variable
26 * @param name the name of the new variable
27 * @param dateTime the dateTime of the new variable
24 * @param defaultDataSeries the default data of the new variable
28 * @param defaultDataSeries the default data of the new variable
25 * @return the pointer to the new variable
29 * @return the pointer to the new variable
26 */
30 */
27 std::shared_ptr<Variable>
31 std::shared_ptr<Variable>
28 createVariable(const QString &name, std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
32 createVariable(const QString &name, const SqpDateTime &dateTime,
33 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
29
34
30 // /////////////////////////// //
35 // /////////////////////////// //
31 // QAbstractTableModel methods //
36 // QAbstractTableModel methods //
32 // /////////////////////////// //
37 // /////////////////////////// //
33 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
38 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
34 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
39 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
35 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
40 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
36 virtual QVariant headerData(int section, Qt::Orientation orientation,
41 virtual QVariant headerData(int section, Qt::Orientation orientation,
37 int role = Qt::DisplayRole) const override;
42 int role = Qt::DisplayRole) const override;
38
43
39 private:
44 private:
40 class VariableModelPrivate;
45 class VariableModelPrivate;
41 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
46 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
42 };
47 };
43
48
44 #endif // SCIQLOP_VARIABLEMODEL_H
49 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -1,58 +1,74
1 #include "Variable/Variable.h"
1 #include "Variable/Variable.h"
2
2
3 #include <Data/IDataSeries.h>
3 #include <Data/IDataSeries.h>
4 #include <Data/SqpDateTime.h>
4 #include <Data/SqpDateTime.h>
5
5
6 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
6 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
7
7
8 struct Variable::VariablePrivate {
8 struct Variable::VariablePrivate {
9 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission)
9 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission,
10 : m_Name{name}, m_Unit{unit}, m_Mission{mission}, m_DataSeries{nullptr}
10 const SqpDateTime &dateTime)
11 : m_Name{name},
12 m_Unit{unit},
13 m_Mission{mission},
14 m_DateTime{dateTime},
15 m_DataSeries{nullptr}
11 {
16 {
12 }
17 }
13
18
14 QString m_Name;
19 QString m_Name;
15 QString m_Unit;
20 QString m_Unit;
16 QString m_Mission;
21 QString m_Mission;
17
22
18 SqpDateTime m_DateTime; // The dateTime available in the view and loaded. not the cache.
23 SqpDateTime m_DateTime; // The dateTime available in the view and loaded. not the cache.
19 std::unique_ptr<IDataSeries> m_DataSeries;
24 std::unique_ptr<IDataSeries> m_DataSeries;
20 };
25 };
21
26
22 Variable::Variable(const QString &name, const QString &unit, const QString &mission)
27 Variable::Variable(const QString &name, const QString &unit, const QString &mission,
23 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission)}
28 const SqpDateTime &dateTime)
29 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission, dateTime)}
24 {
30 {
25 }
31 }
26
32
27 QString Variable::name() const noexcept
33 QString Variable::name() const noexcept
28 {
34 {
29 return impl->m_Name;
35 return impl->m_Name;
30 }
36 }
31
37
32 QString Variable::mission() const noexcept
38 QString Variable::mission() const noexcept
33 {
39 {
34 return impl->m_Mission;
40 return impl->m_Mission;
35 }
41 }
36
42
37 QString Variable::unit() const noexcept
43 QString Variable::unit() const noexcept
38 {
44 {
39 return impl->m_Unit;
45 return impl->m_Unit;
40 }
46 }
41
47
42 void Variable::addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept
48 void Variable::addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept
43 {
49 {
44 if (!impl->m_DataSeries) {
50 if (!impl->m_DataSeries) {
45 impl->m_DataSeries = std::move(dataSeries);
51 impl->m_DataSeries = std::move(dataSeries);
46 }
52 }
47 /// @todo : else, merge the two data series (if possible)
53 /// @todo : else, merge the two data series (if possible)
48 }
54 }
49
55
50 IDataSeries *Variable::dataSeries() const noexcept
56 IDataSeries *Variable::dataSeries() const noexcept
51 {
57 {
52 return impl->m_DataSeries.get();
58 return impl->m_DataSeries.get();
53 }
59 }
54
60
55 void Variable::onXRangeChanged(SqpDateTime dateTime)
61 void Variable::onXRangeChanged(SqpDateTime dateTime)
56 {
62 {
57 qCInfo(LOG_Variable()) << "onXRangeChanged detected";
63 qCInfo(LOG_Variable()) << "onXRangeChanged detected";
64
65 if (!impl->m_DateTime.contains(dateTime)) {
66 // The current variable dateTime isn't enough to display the dateTime requested.
67 // We have to update it to the new dateTime requested.
68 // the correspondant new data to display will be given by the cache if possible and the
69 // provider if necessary.
70 qCInfo(LOG_Variable()) << "NEW DATE NEEDED";
71
72 impl->m_DateTime = dateTime;
73 }
58 }
74 }
@@ -1,123 +1,123
1 #include <Variable/VariableCacheController.h>
1 #include <Variable/VariableCacheController.h>
2 #include <Variable/VariableController.h>
2 #include <Variable/VariableController.h>
3 #include <Variable/VariableModel.h>
3 #include <Variable/VariableModel.h>
4
4
5 #include <Data/DataProviderParameters.h>
5 #include <Data/DataProviderParameters.h>
6 #include <Data/IDataProvider.h>
6 #include <Data/IDataProvider.h>
7 #include <Data/IDataSeries.h>
7 #include <Data/IDataSeries.h>
8 #include <Time/TimeController.h>
8 #include <Time/TimeController.h>
9
9
10 #include <QDateTime>
10 #include <QDateTime>
11 #include <QMutex>
11 #include <QMutex>
12 #include <QThread>
12 #include <QThread>
13
13
14 #include <unordered_map>
14 #include <unordered_map>
15
15
16 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
16 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
17
17
18 namespace {
18 namespace {
19
19
20 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
20 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
21 /// will be deleted when the timerange is recovered from SciQlop
21 /// will be deleted when the timerange is recovered from SciQlop
22 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
22 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
23 const SqpDateTime &dateTime) noexcept
23 const SqpDateTime &dateTime) noexcept
24 {
24 {
25 auto parameters = DataProviderParameters{dateTime};
25 auto parameters = DataProviderParameters{dateTime};
26
26
27 return provider.retrieveData(parameters);
27 return provider.retrieveData(parameters);
28 }
28 }
29
29
30 } // namespace
30 } // namespace
31
31
32 struct VariableController::VariableControllerPrivate {
32 struct VariableController::VariableControllerPrivate {
33 explicit VariableControllerPrivate(VariableController *parent)
33 explicit VariableControllerPrivate(VariableController *parent)
34 : m_WorkingMutex{},
34 : m_WorkingMutex{},
35 m_VariableModel{new VariableModel{parent}},
35 m_VariableModel{new VariableModel{parent}},
36 m_VariableCacheController{std::make_unique<VariableCacheController>()}
36 m_VariableCacheController{std::make_unique<VariableCacheController>()}
37 {
37 {
38 }
38 }
39
39
40 QMutex m_WorkingMutex;
40 QMutex m_WorkingMutex;
41 /// Variable model. The VariableController has the ownership
41 /// Variable model. The VariableController has the ownership
42 VariableModel *m_VariableModel;
42 VariableModel *m_VariableModel;
43
43
44
44
45 TimeController *m_TimeController{nullptr};
45 TimeController *m_TimeController{nullptr};
46 std::unique_ptr<VariableCacheController> m_VariableCacheController;
46 std::unique_ptr<VariableCacheController> m_VariableCacheController;
47 };
47 };
48
48
49 VariableController::VariableController(QObject *parent)
49 VariableController::VariableController(QObject *parent)
50 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
50 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
51 {
51 {
52 qCDebug(LOG_VariableController()) << tr("VariableController construction")
52 qCDebug(LOG_VariableController()) << tr("VariableController construction")
53 << QThread::currentThread();
53 << QThread::currentThread();
54 }
54 }
55
55
56 VariableController::~VariableController()
56 VariableController::~VariableController()
57 {
57 {
58 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
58 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
59 << QThread::currentThread();
59 << QThread::currentThread();
60 this->waitForFinish();
60 this->waitForFinish();
61 }
61 }
62
62
63 VariableModel *VariableController::variableModel() noexcept
63 VariableModel *VariableController::variableModel() noexcept
64 {
64 {
65 return impl->m_VariableModel;
65 return impl->m_VariableModel;
66 }
66 }
67
67
68 void VariableController::setTimeController(TimeController *timeController) noexcept
68 void VariableController::setTimeController(TimeController *timeController) noexcept
69 {
69 {
70 impl->m_TimeController = timeController;
70 impl->m_TimeController = timeController;
71 }
71 }
72
72
73 void VariableController::createVariable(const QString &name,
73 void VariableController::createVariable(const QString &name,
74 std::shared_ptr<IDataProvider> provider) noexcept
74 std::shared_ptr<IDataProvider> provider) noexcept
75 {
75 {
76 // TORM
76 // TORM
77 // auto dateTime = SqpDateTime{
77 // auto dateTime = SqpDateTime{
78 // // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
78 // // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
79 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
79 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
80 // / 1000.),
80 // / 1000.),
81 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
81 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
82 // / 1000.};
82 // / 1000.};
83
83
84 if (!impl->m_TimeController) {
84 if (!impl->m_TimeController) {
85 qCCritical(LOG_VariableController())
85 qCCritical(LOG_VariableController())
86 << tr("Impossible to create variable: The time controller is null");
86 << tr("Impossible to create variable: The time controller is null");
87 return;
87 return;
88 }
88 }
89
89
90
90
91 /// @todo : for the moment :
91 /// @todo : for the moment :
92 /// - the provider is only used to retrieve data from the variable for its initialization, but
92 /// - the provider is only used to retrieve data from the variable for its initialization, but
93 /// it will be retained later
93 /// it will be retained later
94 /// - default data are generated for the variable, without taking into account the timerange set
94 /// - default data are generated for the variable, without taking into account the timerange set
95 /// in sciqlop
95 /// in sciqlop
96 auto dateTime = impl->m_TimeController->dateTime();
96 auto dateTime = impl->m_TimeController->dateTime();
97 if (auto newVariable = impl->m_VariableModel->createVariable(
97 if (auto newVariable = impl->m_VariableModel->createVariable(
98 name, generateDefaultDataSeries(*provider, dateTime))) {
98 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
99
99
100 // store in cache
100 // store in cache
101 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
101 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
102
102
103 // notify the creation
103 // notify the creation
104 emit variableCreated(newVariable);
104 emit variableCreated(newVariable);
105 }
105 }
106 }
106 }
107
107
108 void VariableController::initialize()
108 void VariableController::initialize()
109 {
109 {
110 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
110 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
111 impl->m_WorkingMutex.lock();
111 impl->m_WorkingMutex.lock();
112 qCDebug(LOG_VariableController()) << tr("VariableController init END");
112 qCDebug(LOG_VariableController()) << tr("VariableController init END");
113 }
113 }
114
114
115 void VariableController::finalize()
115 void VariableController::finalize()
116 {
116 {
117 impl->m_WorkingMutex.unlock();
117 impl->m_WorkingMutex.unlock();
118 }
118 }
119
119
120 void VariableController::waitForFinish()
120 void VariableController::waitForFinish()
121 {
121 {
122 QMutexLocker locker{&impl->m_WorkingMutex};
122 QMutexLocker locker{&impl->m_WorkingMutex};
123 }
123 }
@@ -1,120 +1,120
1 #include <Variable/Variable.h>
1 #include <Variable/Variable.h>
2 #include <Variable/VariableModel.h>
2 #include <Variable/VariableModel.h>
3
3
4 #include <Data/IDataSeries.h>
4 #include <Data/IDataSeries.h>
5
5
6 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
7
7
8 namespace {
8 namespace {
9
9
10 // Column indexes
10 // Column indexes
11 const auto NAME_COLUMN = 0;
11 const auto NAME_COLUMN = 0;
12 const auto UNIT_COLUMN = 1;
12 const auto UNIT_COLUMN = 1;
13 const auto MISSION_COLUMN = 2;
13 const auto MISSION_COLUMN = 2;
14 const auto NB_COLUMNS = 3;
14 const auto NB_COLUMNS = 3;
15
15
16 } // namespace
16 } // namespace
17
17
18 struct VariableModel::VariableModelPrivate {
18 struct VariableModel::VariableModelPrivate {
19 /// Variables created in SciQlop
19 /// Variables created in SciQlop
20 std::vector<std::shared_ptr<Variable> > m_Variables;
20 std::vector<std::shared_ptr<Variable> > m_Variables;
21 };
21 };
22
22
23 VariableModel::VariableModel(QObject *parent)
23 VariableModel::VariableModel(QObject *parent)
24 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
24 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
25 {
25 {
26 }
26 }
27
27
28 std::shared_ptr<Variable>
28 std::shared_ptr<Variable>
29 VariableModel::createVariable(const QString &name,
29 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
31 {
31 {
32 auto insertIndex = rowCount();
32 auto insertIndex = rowCount();
33 beginInsertRows({}, insertIndex, insertIndex);
33 beginInsertRows({}, insertIndex, insertIndex);
34
34
35 /// @todo For the moment, the other data of the variable is initialized with default values
35 /// @todo For the moment, the other data of the variable is initialized with default values
36 auto variable
36 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
37 = std::make_shared<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
37 QStringLiteral("mission"), dateTime);
38 variable->addDataSeries(std::move(defaultDataSeries));
38 variable->addDataSeries(std::move(defaultDataSeries));
39
39
40 impl->m_Variables.push_back(variable);
40 impl->m_Variables.push_back(variable);
41
41
42 endInsertRows();
42 endInsertRows();
43
43
44 return variable;
44 return variable;
45 }
45 }
46
46
47 int VariableModel::columnCount(const QModelIndex &parent) const
47 int VariableModel::columnCount(const QModelIndex &parent) const
48 {
48 {
49 Q_UNUSED(parent);
49 Q_UNUSED(parent);
50
50
51 return NB_COLUMNS;
51 return NB_COLUMNS;
52 }
52 }
53
53
54 int VariableModel::rowCount(const QModelIndex &parent) const
54 int VariableModel::rowCount(const QModelIndex &parent) const
55 {
55 {
56 Q_UNUSED(parent);
56 Q_UNUSED(parent);
57
57
58 return impl->m_Variables.size();
58 return impl->m_Variables.size();
59 }
59 }
60
60
61 QVariant VariableModel::data(const QModelIndex &index, int role) const
61 QVariant VariableModel::data(const QModelIndex &index, int role) const
62 {
62 {
63 if (!index.isValid()) {
63 if (!index.isValid()) {
64 return QVariant{};
64 return QVariant{};
65 }
65 }
66
66
67 if (index.row() < 0 || index.row() >= rowCount()) {
67 if (index.row() < 0 || index.row() >= rowCount()) {
68 return QVariant{};
68 return QVariant{};
69 }
69 }
70
70
71 if (role == Qt::DisplayRole) {
71 if (role == Qt::DisplayRole) {
72 if (auto variable = impl->m_Variables.at(index.row()).get()) {
72 if (auto variable = impl->m_Variables.at(index.row()).get()) {
73 switch (index.column()) {
73 switch (index.column()) {
74 case NAME_COLUMN:
74 case NAME_COLUMN:
75 return variable->name();
75 return variable->name();
76 case UNIT_COLUMN:
76 case UNIT_COLUMN:
77 return variable->unit();
77 return variable->unit();
78 case MISSION_COLUMN:
78 case MISSION_COLUMN:
79 return variable->mission();
79 return variable->mission();
80 default:
80 default:
81 // No action
81 // No action
82 break;
82 break;
83 }
83 }
84
84
85 qWarning(LOG_VariableModel())
85 qWarning(LOG_VariableModel())
86 << tr("Can't get data (unknown column %1)").arg(index.column());
86 << tr("Can't get data (unknown column %1)").arg(index.column());
87 }
87 }
88 else {
88 else {
89 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
89 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
90 }
90 }
91 }
91 }
92
92
93 return QVariant{};
93 return QVariant{};
94 }
94 }
95
95
96 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
96 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
97 {
97 {
98 if (role != Qt::DisplayRole) {
98 if (role != Qt::DisplayRole) {
99 return QVariant{};
99 return QVariant{};
100 }
100 }
101
101
102 if (orientation == Qt::Horizontal) {
102 if (orientation == Qt::Horizontal) {
103 switch (section) {
103 switch (section) {
104 case NAME_COLUMN:
104 case NAME_COLUMN:
105 return tr("Name");
105 return tr("Name");
106 case UNIT_COLUMN:
106 case UNIT_COLUMN:
107 return tr("Unit");
107 return tr("Unit");
108 case MISSION_COLUMN:
108 case MISSION_COLUMN:
109 return tr("Mission");
109 return tr("Mission");
110 default:
110 default:
111 // No action
111 // No action
112 break;
112 break;
113 }
113 }
114
114
115 qWarning(LOG_VariableModel())
115 qWarning(LOG_VariableModel())
116 << tr("Can't get header data (unknown column %1)").arg(section);
116 << tr("Can't get header data (unknown column %1)").arg(section);
117 }
117 }
118
118
119 return QVariant{};
119 return QVariant{};
120 }
120 }
General Comments 0
You need to be logged in to leave comments. Login now