##// END OF EJS Templates
It's now possible to create the variable and ask data to be retreived...
perrinel -
r294:c71a61da7f3d
parent child
Show More
@@ -1,51 +1,49
1 1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 2 #define SCIQLOP_VARIABLEMODEL_H
3 3
4 4
5 5 #include <Data/SqpDateTime.h>
6 6
7 7 #include <QAbstractTableModel>
8 8 #include <QLoggingCategory>
9 9
10 10 #include <Common/spimpl.h>
11 11
12 12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
13 13
14 14 class IDataSeries;
15 15 class Variable;
16 16
17 17 /**
18 18 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
19 19 */
20 20 class VariableModel : public QAbstractTableModel {
21 21 public:
22 22 explicit VariableModel(QObject *parent = nullptr);
23 23
24 24 /**
25 25 * Creates a new variable in the model
26 26 * @param name the name of the new variable
27 27 * @param dateTime the dateTime of the new variable
28 * @param defaultDataSeries the default data of the new variable
29 28 * @return the pointer to the new variable
30 29 */
31 std::shared_ptr<Variable>
32 createVariable(const QString &name, const SqpDateTime &dateTime,
33 std::shared_ptr<IDataSeries> defaultDataSeries) noexcept;
30 std::shared_ptr<Variable> createVariable(const QString &name,
31 const SqpDateTime &dateTime) noexcept;
34 32
35 33 std::shared_ptr<Variable> variable(int index) const;
36 34
37 35 // /////////////////////////// //
38 36 // QAbstractTableModel methods //
39 37 // /////////////////////////// //
40 38 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
41 39 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
42 40 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
43 41 virtual QVariant headerData(int section, Qt::Orientation orientation,
44 42 int role = Qt::DisplayRole) const override;
45 43
46 44 private:
47 45 class VariableModelPrivate;
48 46 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
49 47 };
50 48
51 49 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -1,205 +1,204
1 1 #include "Variable/VariableCacheController.h"
2 2
3 3 #include "Variable/Variable.h"
4 4 #include <unordered_map>
5 5
6 6 Q_LOGGING_CATEGORY(LOG_VariableCacheController, "VariableCacheController")
7 7
8 8 struct VariableCacheController::VariableCacheControllerPrivate {
9 9
10 10 std::unordered_map<std::shared_ptr<Variable>, QVector<SqpDateTime> >
11 11 m_VariableToSqpDateTimeListMap;
12 12
13 13 void addInCacheDataByEnd(const SqpDateTime &dateTime, QVector<SqpDateTime> &dateTimeList,
14 14 QVector<SqpDateTime> &notInCache, int cacheIndex,
15 15 double currentTStart);
16 16
17 17 void addInCacheDataByStart(const SqpDateTime &dateTime, QVector<SqpDateTime> &dateTimeList,
18 18 QVector<SqpDateTime> &notInCache, int cacheIndex,
19 19 double currentTStart);
20 20
21 21
22 22 void addDateTimeRecurse(const SqpDateTime &dateTime, QVector<SqpDateTime> &dateTimeList,
23 23 int cacheIndex);
24 24 };
25 25
26 26
27 27 VariableCacheController::VariableCacheController(QObject *parent)
28 28 : QObject{parent}, impl{spimpl::make_unique_impl<VariableCacheControllerPrivate>()}
29 29 {
30 30 }
31 31
32 32 void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable,
33 33 const SqpDateTime &dateTime)
34 34 {
35 35 if (variable) {
36 36 auto findVariableIte = impl->m_VariableToSqpDateTimeListMap.find(variable);
37 37 if (findVariableIte == impl->m_VariableToSqpDateTimeListMap.end()) {
38 38 impl->m_VariableToSqpDateTimeListMap[variable].push_back(dateTime);
39 39 }
40 40 else {
41 41
42 42 // addDateTime modify the list<SqpDateTime> of the variable in a way to ensure
43 43 // that the list is ordered : l(0) < l(1). We assume also a < b
44 44 // (with a & b of type SqpDateTime) means ts(b) > te(a)
45 45
46 46 // The algorithm will try the merge of two interval:
47 47 // - dateTime will be compare with the first interval of the list:
48 48 // A: if it is inferior, it will be inserted and it's finished.
49 49 // B: if it is in intersection, it will be merge then the merged one
50 50 // will be compared to the next interval. The old one is remove from the list
51 51 // C: if it is superior, we do the same with the next interval of the list
52 52
53 53 try {
54 54 impl->addDateTimeRecurse(dateTime,
55 55 impl->m_VariableToSqpDateTimeListMap.at(variable), 0);
56 56 }
57 57 catch (const std::out_of_range &e) {
58 qCWarning(LOG_VariableCacheController()) << e.what();
58 qCWarning(LOG_VariableCacheController()) << "addDateTime" << e.what();
59 59 }
60 60 }
61 61 }
62 62 }
63 63
64 64 QVector<SqpDateTime>
65 65 VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
66 66 const SqpDateTime &dateTime)
67 67 {
68 68 auto notInCache = QVector<SqpDateTime>{};
69 69
70 70 // This algorithm is recursif. The idea is to localise the start time then the end time in the
71 71 // list of date time request associated to the variable
72 72 // We assume that the list is ordered in a way that l(0) < l(1). We assume also a < b
73 73 // (with a & b of type SqpDateTime) means ts(b) > te(a)
74
75 try {
76 impl->addInCacheDataByStart(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable),
77 notInCache, 0, dateTime.m_TStart);
74 auto it = impl->m_VariableToSqpDateTimeListMap.find(variable);
75 if (it != impl->m_VariableToSqpDateTimeListMap.end()) {
76 impl->addInCacheDataByStart(dateTime, it->second, notInCache, 0, dateTime.m_TStart);
78 77 }
79 catch (const std::out_of_range &e) {
80 qCWarning(LOG_VariableCacheController()) << e.what();
78 else {
79 notInCache << dateTime;
81 80 }
82 81
83 82 return notInCache;
84 83 }
85 84
86 85 QVector<SqpDateTime>
87 86 VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const noexcept
88 87 {
89 88 try {
90 89 return impl->m_VariableToSqpDateTimeListMap.at(variable);
91 90 }
92 91 catch (const std::out_of_range &e) {
93 92 qCWarning(LOG_VariableCacheController()) << e.what();
94 93 return QVector<SqpDateTime>{};
95 94 }
96 95 }
97 96
98 97 void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse(
99 98 const SqpDateTime &dateTime, QVector<SqpDateTime> &dateTimeList, int cacheIndex)
100 99 {
101 100 const auto dateTimeListSize = dateTimeList.count();
102 101 if (cacheIndex >= dateTimeListSize) {
103 102 dateTimeList.push_back(dateTime);
104 103 // there is no anymore interval to compore, we can just push_back it
105 104 return;
106 105 }
107 106
108 107 auto currentDateTime = dateTimeList[cacheIndex];
109 108
110 109 if (dateTime.m_TEnd < currentDateTime.m_TStart) {
111 110 // The compared one is < to current one compared, we can insert it
112 111 dateTimeList.insert(cacheIndex, dateTime);
113 112 }
114 113 else if (dateTime.m_TStart > currentDateTime.m_TEnd) {
115 114 // The compared one is > to current one compared we can comparet if to the next one
116 115 addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex);
117 116 }
118 117 else {
119 118 // Merge cases: we need to merge the two interval, remove the old one from the list then
120 119 // rerun the algo from this index with the merged interval
121 120 auto mTStart = std::min(dateTime.m_TStart, currentDateTime.m_TStart);
122 121 auto mTEnd = std::max(dateTime.m_TEnd, currentDateTime.m_TEnd);
123 122 auto mergeDateTime = SqpDateTime{mTStart, mTEnd};
124 123
125 124 dateTimeList.remove(cacheIndex);
126 125 addDateTimeRecurse(mergeDateTime, dateTimeList, cacheIndex);
127 126 }
128 127 }
129 128
130 129
131 130 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByEnd(
132 131 const SqpDateTime &dateTime, QVector<SqpDateTime> &dateTimeList,
133 132 QVector<SqpDateTime> &notInCache, int cacheIndex, double currentTStart)
134 133 {
135 134 const auto dateTimeListSize = dateTimeList.count();
136 135 if (cacheIndex >= dateTimeListSize) {
137 136 if (currentTStart < dateTime.m_TEnd) {
138 137
139 138 // te localised after all other interval: The last interval is [currentTsart, te]
140 139 notInCache.push_back(SqpDateTime{currentTStart, dateTime.m_TEnd});
141 140 }
142 141 return;
143 142 }
144 143
145 144 auto currentDateTimeJ = dateTimeList[cacheIndex];
146 145 if (dateTime.m_TEnd <= currentDateTimeJ.m_TStart) {
147 146 // te localised between to interval: The last interval is [currentTsart, te]
148 147 notInCache.push_back(SqpDateTime{currentTStart, dateTime.m_TEnd});
149 148 }
150 149 else {
151 150 notInCache.push_back(SqpDateTime{currentTStart, currentDateTimeJ.m_TStart});
152 151 if (dateTime.m_TEnd > currentDateTimeJ.m_TEnd) {
153 152 // te not localised before the current interval: we need to look at the next interval
154 153 addInCacheDataByEnd(dateTime, dateTimeList, notInCache, ++cacheIndex,
155 154 currentDateTimeJ.m_TEnd);
156 155 }
157 156 }
158 157 }
159 158
160 159 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByStart(
161 160 const SqpDateTime &dateTime, QVector<SqpDateTime> &dateTimeList,
162 161 QVector<SqpDateTime> &notInCache, int cacheIndex, double currentTStart)
163 162 {
164 163 const auto dateTimeListSize = dateTimeList.count();
165 164 if (cacheIndex >= dateTimeListSize) {
166 165 // ts localised after all other interval: The last interval is [ts, te]
167 166 notInCache.push_back(SqpDateTime{currentTStart, dateTime.m_TEnd});
168 167 return;
169 168 }
170 169
171 170 auto currentDateTimeI = dateTimeList[cacheIndex];
172 171 if (currentTStart < currentDateTimeI.m_TStart) {
173 172
174 173 // ts localised between to interval: let's localized te
175 174 addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart);
176 175 }
177 176 else if (currentTStart < currentDateTimeI.m_TEnd) {
178 177 if (dateTime.m_TEnd > currentDateTimeI.m_TEnd) {
179 178 // ts not localised before the current interval: we need to look at the next interval
180 179 // We can assume now current tstart is the last interval tend, because data between them
181 180 // are
182 181 // in the cache
183 182 addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex,
184 183 currentDateTimeI.m_TEnd);
185 184 }
186 185 }
187 186 else {
188 187 // ts not localised before the current interval: we need to look at the next interval
189 188 addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, currentTStart);
190 189 }
191 190 }
192 191
193 192
194 193 void VariableCacheController::displayCache(std::shared_ptr<Variable> variable) const
195 194 {
196 195 auto variableDateTimeList = impl->m_VariableToSqpDateTimeListMap.find(variable);
197 196 if (variableDateTimeList != impl->m_VariableToSqpDateTimeListMap.end()) {
198 197 qCInfo(LOG_VariableCacheController()) << tr("VariableCacheController::displayCache")
199 198 << variableDateTimeList->second;
200 199 }
201 200 else {
202 201 qCWarning(LOG_VariableCacheController())
203 202 << tr("Cannot display a variable that is not in the cache");
204 203 }
205 204 }
@@ -1,181 +1,177
1 1 #include <Variable/Variable.h>
2 2 #include <Variable/VariableCacheController.h>
3 3 #include <Variable/VariableController.h>
4 4 #include <Variable/VariableModel.h>
5 5
6 6 #include <Data/DataProviderParameters.h>
7 7 #include <Data/IDataProvider.h>
8 8 #include <Data/IDataSeries.h>
9 9 #include <Time/TimeController.h>
10 10
11 11 #include <QDateTime>
12 12 #include <QMutex>
13 13 #include <QThread>
14 14 #include <QtCore/QItemSelectionModel>
15 15
16 16 #include <unordered_map>
17 17
18 18 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
19 19
20 20 namespace {
21 21
22 22 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
23 23 /// will be deleted when the timerange is recovered from SciQlop
24 24 std::shared_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
25 25 const SqpDateTime &dateTime) noexcept
26 26 {
27 27 auto parameters = DataProviderParameters{dateTime};
28 28
29 29 return provider.retrieveData(parameters);
30 30 }
31 31
32 32 } // namespace
33 33
34 34 struct VariableController::VariableControllerPrivate {
35 35 explicit VariableControllerPrivate(VariableController *parent)
36 36 : m_WorkingMutex{},
37 37 m_VariableModel{new VariableModel{parent}},
38 38 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
39 39 m_VariableCacheController{std::make_unique<VariableCacheController>()}
40 40 {
41 41 }
42 42
43 43 QMutex m_WorkingMutex;
44 44 /// Variable model. The VariableController has the ownership
45 45 VariableModel *m_VariableModel;
46 46 QItemSelectionModel *m_VariableSelectionModel;
47 47
48 48
49 49 TimeController *m_TimeController{nullptr};
50 50 std::unique_ptr<VariableCacheController> m_VariableCacheController;
51 51
52 52 std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
53 53 m_VariableToProviderMap;
54 54 };
55 55
56 56 VariableController::VariableController(QObject *parent)
57 57 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
58 58 {
59 59 qCDebug(LOG_VariableController()) << tr("VariableController construction")
60 60 << QThread::currentThread();
61 61 }
62 62
63 63 VariableController::~VariableController()
64 64 {
65 65 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
66 66 << QThread::currentThread();
67 67 this->waitForFinish();
68 68 }
69 69
70 70 VariableModel *VariableController::variableModel() noexcept
71 71 {
72 72 return impl->m_VariableModel;
73 73 }
74 74
75 75 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
76 76 {
77 77 return impl->m_VariableSelectionModel;
78 78 }
79 79
80 80 void VariableController::setTimeController(TimeController *timeController) noexcept
81 81 {
82 82 impl->m_TimeController = timeController;
83 83 }
84 84
85 85 void VariableController::createVariable(const QString &name,
86 86 std::shared_ptr<IDataProvider> provider) noexcept
87 87 {
88 88
89 89 if (!impl->m_TimeController) {
90 90 qCCritical(LOG_VariableController())
91 91 << tr("Impossible to create variable: The time controller is null");
92 92 return;
93 93 }
94 94
95 95
96 96 /// @todo : for the moment :
97 97 /// - the provider is only used to retrieve data from the variable for its initialization, but
98 98 /// it will be retained later
99 99 /// - default data are generated for the variable, without taking into account the timerange set
100 100 /// in sciqlop
101 101 auto dateTime = impl->m_TimeController->dateTime();
102 if (auto newVariable = impl->m_VariableModel->createVariable(
103 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
102 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) {
104 103
105 104 // store the provider
106 105 impl->m_VariableToProviderMap[newVariable] = provider;
107 106
108 107 auto addDateTimeAcquired
109 108 = [this, newVariable](auto dataSeriesAcquired, auto dateTimeToPutInCache) {
110 109
111 110 impl->m_VariableCacheController->addDateTime(newVariable, dateTimeToPutInCache);
112 111 newVariable->setDataSeries(dataSeriesAcquired);
113 112
114 113 };
115 114
116 115 connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired);
117
118
119 // store in cache
120 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
116 this->onRequestDataLoading(newVariable, dateTime);
121 117
122 118 // notify the creation
123 119 emit variableCreated(newVariable);
124 120 }
125 121 }
126 122
127 123 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
128 124 {
129 125 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
130 126
131 127 for (const auto &selectedRow : qAsConst(selectedRows)) {
132 128 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
133 129 selectedVariable->setDateTime(dateTime);
134 130 this->onRequestDataLoading(selectedVariable, dateTime);
135 131 }
136 132 }
137 133 }
138 134
139 135
140 136 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
141 137 const SqpDateTime &dateTime)
142 138 {
143 139 // we want to load data of the variable for the dateTime.
144 140 // First we check if the cache contains some of them.
145 141 // For the other, we ask the provider to give them.
146 142 if (variable) {
147 143
148 144 auto dateTimeListNotInCache
149 145 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
150 146
151 147 if (!dateTimeListNotInCache.empty()) {
152 148 // Ask the provider for each data on the dateTimeListNotInCache
153 149 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
154 150 std::move(dateTimeListNotInCache));
155 151 }
156 152 else {
157 153 emit variable->updated();
158 154 }
159 155 }
160 156 else {
161 157 qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
162 158 }
163 159 }
164 160
165 161
166 162 void VariableController::initialize()
167 163 {
168 164 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
169 165 impl->m_WorkingMutex.lock();
170 166 qCDebug(LOG_VariableController()) << tr("VariableController init END");
171 167 }
172 168
173 169 void VariableController::finalize()
174 170 {
175 171 impl->m_WorkingMutex.unlock();
176 172 }
177 173
178 174 void VariableController::waitForFinish()
179 175 {
180 176 QMutexLocker locker{&impl->m_WorkingMutex};
181 177 }
@@ -1,155 +1,153
1 1 #include <Variable/Variable.h>
2 2 #include <Variable/VariableModel.h>
3 3
4 4 #include <Data/IDataSeries.h>
5 5
6 6 #include <QDateTime>
7 7 #include <QSize>
8 8
9 9 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
10 10
11 11 namespace {
12 12
13 13 // Column indexes
14 14 const auto NAME_COLUMN = 0;
15 15 const auto TSTART_COLUMN = 1;
16 16 const auto TEND_COLUMN = 2;
17 17 const auto NB_COLUMNS = 3;
18 18
19 19 // Column properties
20 20 const auto DEFAULT_HEIGHT = 25;
21 21 const auto DEFAULT_WIDTH = 100;
22 22
23 23 struct ColumnProperties {
24 24 ColumnProperties(const QString &name = {}, int width = DEFAULT_WIDTH,
25 25 int height = DEFAULT_HEIGHT)
26 26 : m_Name{name}, m_Width{width}, m_Height{height}
27 27 {
28 28 }
29 29
30 30 QString m_Name;
31 31 int m_Width;
32 32 int m_Height;
33 33 };
34 34
35 35 const auto COLUMN_PROPERTIES
36 36 = QHash<int, ColumnProperties>{{NAME_COLUMN, {QObject::tr("Name")}},
37 37 {TSTART_COLUMN, {QObject::tr("tStart"), 180}},
38 38 {TEND_COLUMN, {QObject::tr("tEnd"), 180}}};
39 39
40 40 /// Format for datetimes
41 41 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
42 42
43 43 } // namespace
44 44
45 45 struct VariableModel::VariableModelPrivate {
46 46 /// Variables created in SciQlop
47 47 std::vector<std::shared_ptr<Variable> > m_Variables;
48 48 };
49 49
50 50 VariableModel::VariableModel(QObject *parent)
51 51 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
52 52 {
53 53 }
54 54
55 std::shared_ptr<Variable>
56 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
57 std::shared_ptr<IDataSeries> defaultDataSeries) noexcept
55 std::shared_ptr<Variable> VariableModel::createVariable(const QString &name,
56 const SqpDateTime &dateTime) noexcept
58 57 {
59 58 auto insertIndex = rowCount();
60 59 beginInsertRows({}, insertIndex, insertIndex);
61 60
62 61 /// @todo For the moment, the other data of the variable is initialized with default values
63 62 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
64 63 QStringLiteral("mission"), dateTime);
65 variable->setDataSeries(std::move(defaultDataSeries));
66 64
67 65 impl->m_Variables.push_back(variable);
68 66
69 67 endInsertRows();
70 68
71 69 return variable;
72 70 }
73 71
74 72 std::shared_ptr<Variable> VariableModel::variable(int index) const
75 73 {
76 74 return (index >= 0 && index < impl->m_Variables.size()) ? impl->m_Variables[index] : nullptr;
77 75 }
78 76
79 77 int VariableModel::columnCount(const QModelIndex &parent) const
80 78 {
81 79 Q_UNUSED(parent);
82 80
83 81 return NB_COLUMNS;
84 82 }
85 83
86 84 int VariableModel::rowCount(const QModelIndex &parent) const
87 85 {
88 86 Q_UNUSED(parent);
89 87
90 88 return impl->m_Variables.size();
91 89 }
92 90
93 91 QVariant VariableModel::data(const QModelIndex &index, int role) const
94 92 {
95 93 if (!index.isValid()) {
96 94 return QVariant{};
97 95 }
98 96
99 97 if (index.row() < 0 || index.row() >= rowCount()) {
100 98 return QVariant{};
101 99 }
102 100
103 101 if (role == Qt::DisplayRole) {
104 102 if (auto variable = impl->m_Variables.at(index.row()).get()) {
105 103 /// Lambda function that builds the variant to return for a time value
106 104 auto dateTimeVariant = [](double time) {
107 105 auto dateTime = QDateTime::fromMSecsSinceEpoch(time * 1000.);
108 106 return dateTime.toString(DATETIME_FORMAT);
109 107 };
110 108
111 109 switch (index.column()) {
112 110 case NAME_COLUMN:
113 111 return variable->name();
114 112 case TSTART_COLUMN:
115 113 return dateTimeVariant(variable->dateTime().m_TStart);
116 114 case TEND_COLUMN:
117 115 return dateTimeVariant(variable->dateTime().m_TEnd);
118 116 default:
119 117 // No action
120 118 break;
121 119 }
122 120
123 121 qWarning(LOG_VariableModel())
124 122 << tr("Can't get data (unknown column %1)").arg(index.column());
125 123 }
126 124 else {
127 125 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
128 126 }
129 127 }
130 128
131 129 return QVariant{};
132 130 }
133 131
134 132 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
135 133 {
136 134 if (role != Qt::DisplayRole && role != Qt::SizeHintRole) {
137 135 return QVariant{};
138 136 }
139 137
140 138 if (orientation == Qt::Horizontal) {
141 139 auto propertiesIt = COLUMN_PROPERTIES.find(section);
142 140 if (propertiesIt != COLUMN_PROPERTIES.cend()) {
143 141 // Role is either DisplayRole or SizeHintRole
144 142 return (role == Qt::DisplayRole)
145 143 ? QVariant{propertiesIt->m_Name}
146 144 : QVariant{QSize{propertiesIt->m_Width, propertiesIt->m_Height}};
147 145 }
148 146 else {
149 147 qWarning(LOG_VariableModel())
150 148 << tr("Can't get header data (unknown column %1)").arg(section);
151 149 }
152 150 }
153 151
154 152 return QVariant{};
155 153 }
General Comments 2
Under Review
author

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 3 added
  * 0 removed

Changed files:
  * M core/include/Data/SqpDateTime.h
  * M core/include/Variable/Variable.h
  * M core/include/Variable/VariableModel.h
  * M core/src/Variable/Variable.cpp
  * M core/src/Variable/VariableCacheController.cpp
  * M core/src/Variable/VariableController.cpp
  * M core/src/Variable/VariableModel.cpp
  * M gui/include/Visualization/VisualizationGraphWidget.h
  * M gui/src/Visualization/VisualizationGraphHelper.cpp
  * M gui/src/Visualization/VisualizationGraphWidget.cpp
  * M gui/src/Visualization/operations/GenerateVariableMenuOperation.cpp
  * R COPYING
  * R app/src/MainWindow.cpp
  * R app/ui/MainWindow.ui
  * R cmake/sciqlop_package_qt.cmake
  * R core/include/Common/MetaTypes.h
  * R core/include/Data/ArrayData.h
  * R core/include/Data/DataProviderParameters.h
  * R core/include/Data/DataSeries.h
  * R core/include/Data/IDataProvider.h
  * R core/include/Data/IDataSeries.h
  * R core/include/Data/ScalarSeries.h
  * R core/include/DataSource/DataSourceItemAction.h
  * R core/include/Plugin/PluginManager.h
  * R core/include/Time/TimeController.h
  * R core/include/Variable/VariableCacheController.h
  * R core/include/Variable/VariableController.h
  * R core/include/Visualization/VisualizationController.h
  * R core/src/Data/ScalarSeries.cpp
  * R core/src/DataSource/DataSourceItemAction.cpp
  * R core/src/Plugin/PluginManager.cpp
  * R core/src/Time/TimeController.cpp
  * R core/src/Visualization/VisualizationController.cpp
  * R core/tests/Variable/TestVariableCacheController.cpp
  * R gui/include/DataSource/DataSourceTreeWidgetItem.h
  * R gui/include/DataSource/DataSourceWidget.h
  * R gui/include/SidePane/SqpSidePane.h
  * R gui/include/TimeWidget/TimeWidget.h
  * R gui/include/Variable/VariableInspectorWidget.h
  * R gui/include/Variable/VariableMenuHeaderWidget.h
  * R gui/include/Visualization/IVariableContainer.h
  * R gui/include/Visualization/IVisualizationWidget.h
  * R gui/include/Visualization/IVisualizationWidgetVisitor.h
  * R gui/include/Visualization/VisualizationGraphHelper.h
  * R gui/include/Visualization/VisualizationTabWidget.h
  * R gui/include/Visualization/VisualizationWidget.h
  * R gui/include/Visualization/VisualizationZoneWidget.h
  * R gui/include/Visualization/operations/GenerateVariableMenuOperation.h
  * R gui/include/Visualization/operations/MenuBuilder.h
  * R gui/include/Visualization/qcustomplot.h
  * R gui/resources/icones/delete.png
  * R gui/resources/icones/next.png
  * R gui/resources/icones/openInspector.png
  * R gui/resources/icones/previous.png
  * R gui/resources/icones/sciqlop2PNG_1024.png
  * R gui/resources/sqpguiresources.qrc
  * R gui/src/DataSource/DataSourceTreeWidgetItem.cpp
  * R gui/src/DataSource/DataSourceWidget.cpp
  * R gui/src/SidePane/SqpSidePane.cpp
  * R gui/src/TimeWidget/TimeWidget.cpp
  * R gui/src/Variable/VariableInspectorWidget.cpp
  * R gui/src/Variable/VariableMenuHeaderWidget.cpp
  * R gui/src/Visualization/VisualizationTabWidget.cpp
  * R gui/src/Visualization/VisualizationWidget.cpp
  * R gui/src/Visualization/VisualizationZoneWidget.cpp
  * R gui/src/Visualization/operations/MenuBuilder.cpp
  * R gui/src/Visualization/qcustomplot.cpp
  * R gui/ui/DataSource/DataSourceWidget.ui
  * R gui/ui/SidePane/SqpSidePane.ui
  * R gui/ui/TimeWidget/TimeWidget.ui
  * R gui/ui/Variable/VariableInspectorWidget.ui
  * R gui/ui/Variable/VariableMenuHeaderWidget.ui
  * R gui/ui/Visualization/VisualizationGraphWidget.ui
  * R gui/ui/Visualization/VisualizationTabWidget.ui
  * R gui/ui/Visualization/VisualizationWidget.ui
  * R gui/ui/Visualization/VisualizationZoneWidget.ui
  * R gui/vera-exclusions/exclusions.txt
  * R plugin/CMakeLists.txt
  * R plugin/cmake/Findsciqlop-plugin.cmake
  * R plugin/include/Plugin/IPlugin.h
  * R plugins/mockplugin/CMakeLists.txt
  * R plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake
  * R plugins/mockplugin/include/CosinusProvider.h
  * R plugins/mockplugin/include/MockPlugin.h
  * R plugins/mockplugin/resources/mockplugin.json
  * R plugins/mockplugin/src/CosinusProvider.cpp
  * R plugins/mockplugin/src/MockPlugin.cpp
  * R README.md
  * R app/CMakeLists.txt
  * R app/include/MainWindow.h
  * R app/src/Main.cpp
  * R app/vera-exclusions/exclusions.txt
  * R cmake/sciqlop.cmake
  * R cmake/sciqlop_applications.cmake
  * R cmake/sciqlop_package.cmake
  * R cmake/sciqlop_params.cmake
  * R core/CMakeLists.txt
  * R core/include/Common/spimpl.h
  * R core/include/DataSource/DataSourceController.h
  * R core/include/DataSource/DataSourceItem.h
  * R core/src/DataSource/DataSourceController.cpp
  * R core/src/DataSource/DataSourceItem.cpp
  * R core/tests/DataSource/TestDataSourceController.cpp
  * R core/vera-exclusions/exclusions.txt
  * R formatting/cmake/use_clangformat.cmake
  * R formatting/vera-exclusions/exclusions.txt
  * R gui/CMakeLists.txt
  * R gui/include/SqpApplication.h
  * R gui/src/SqpApplication.cpp
  * R LICENSE
  * R app/src/mainwindow.cpp
  * R app/src/mainwindow.ui
You need to be logged in to leave comments. Login now