##// END OF EJS Templates
Review fixes
Alexandre Leroux -
r372:c0501a972eb4
parent child
Show More
@@ -23,18 +23,15 public:
23 template <int D = Dim, typename = std::enable_if_t<D == 1> >
23 template <int D = Dim, typename = std::enable_if_t<D == 1> >
24 explicit ArrayData(int nbColumns) : m_Data{1, QVector<double>{}}
24 explicit ArrayData(int nbColumns) : m_Data{1, QVector<double>{}}
25 {
25 {
26 QWriteLocker locker(&m_Lock);
26 QWriteLocker locker{&m_Lock};
27 m_Data[0].resize(nbColumns);
27 m_Data[0].resize(nbColumns);
28 }
28 }
29
29
30 /**
30 /// Copy ctor
31 * Ctor for a unidimensional ArrayData
32 * @param nbColumns the number of values the ArrayData will hold
33 */
34 explicit ArrayData(const ArrayData &other)
31 explicit ArrayData(const ArrayData &other)
35 {
32 {
36 QReadLocker otherLocker(&other.m_Lock);
33 QReadLocker otherLocker{&other.m_Lock};
37 QWriteLocker locker(&m_Lock);
34 QWriteLocker locker{&m_Lock};
38 m_Data = other.m_Data;
35 m_Data = other.m_Data;
39 }
36 }
40
37
@@ -47,7 +44,7 public:
47 template <int D = Dim, typename = std::enable_if_t<D == 1> >
44 template <int D = Dim, typename = std::enable_if_t<D == 1> >
48 void setData(int index, double data) noexcept
45 void setData(int index, double data) noexcept
49 {
46 {
50 QWriteLocker locker(&m_Lock);
47 QWriteLocker locker{&m_Lock};
51 if (index >= 0 && index < m_Data.at(0).size()) {
48 if (index >= 0 && index < m_Data.at(0).size()) {
52 m_Data[0].replace(index, data);
49 m_Data[0].replace(index, data);
53 }
50 }
@@ -60,7 +57,7 public:
60 template <int D = Dim, typename = std::enable_if_t<D == 1> >
57 template <int D = Dim, typename = std::enable_if_t<D == 1> >
61 QVector<double> data() const noexcept
58 QVector<double> data() const noexcept
62 {
59 {
63 QReadLocker locker(&m_Lock);
60 QReadLocker locker{&m_Lock};
64 return m_Data[0];
61 return m_Data[0];
65 }
62 }
66
63
@@ -71,7 +68,7 public:
71 template <int D = Dim, typename = std::enable_if_t<D == 1> >
68 template <int D = Dim, typename = std::enable_if_t<D == 1> >
72 QVector<double> data(double tStart, double tEnd) const noexcept
69 QVector<double> data(double tStart, double tEnd) const noexcept
73 {
70 {
74 QReadLocker locker(&m_Lock);
71 QReadLocker locker{&m_Lock};
75 return m_Data.at(tStart);
72 return m_Data.at(tStart);
76 }
73 }
77
74
@@ -79,9 +76,9 public:
79 template <int D = Dim, typename = std::enable_if_t<D == 1> >
76 template <int D = Dim, typename = std::enable_if_t<D == 1> >
80 void merge(const ArrayData<1> &arrayData)
77 void merge(const ArrayData<1> &arrayData)
81 {
78 {
82 QWriteLocker locker(&m_Lock);
79 QWriteLocker locker{&m_Lock};
83 if (!m_Data.empty()) {
80 if (!m_Data.empty()) {
84 QReadLocker otherLocker(&arrayData.m_Lock);
81 QReadLocker otherLocker{&arrayData.m_Lock};
85 m_Data[0] += arrayData.data();
82 m_Data[0] += arrayData.data();
86 }
83 }
87 }
84 }
@@ -89,13 +86,13 public:
89 template <int D = Dim, typename = std::enable_if_t<D == 1> >
86 template <int D = Dim, typename = std::enable_if_t<D == 1> >
90 int size() const
87 int size() const
91 {
88 {
92 QReadLocker locker(&m_Lock);
89 QReadLocker locker{&m_Lock};
93 return m_Data[0].size();
90 return m_Data[0].size();
94 }
91 }
95
92
96 void clear()
93 void clear()
97 {
94 {
98 QWriteLocker locker(&m_Lock);
95 QWriteLocker locker{&m_Lock};
99 m_Data.clear();
96 m_Data.clear();
100 }
97 }
101
98
@@ -190,6 +190,8 void VariableModel::onVariableUpdated() noexcept
190 });
190 });
191
191
192 if (it != end) {
192 if (it != end) {
193 // Gets the index of the variable in the model: we assume here that views have the same
194 // order as the model
193 auto updateVariableIndex = std::distance(begin, it);
195 auto updateVariableIndex = std::distance(begin, it);
194 emit dataChanged(createIndex(updateVariableIndex, 0),
196 emit dataChanged(createIndex(updateVariableIndex, 0),
195 createIndex(updateVariableIndex, columnCount() - 1));
197 createIndex(updateVariableIndex, columnCount() - 1));
General Comments 0
You need to be logged in to leave comments. Login now