##// END OF EJS Templates
Fix format for linux
perrinel -
r912:fedc6e2cf64d
parent child
Show More
@@ -1,151 +1,151
1 #include <Data/ArrayData.h>
1 #include <Data/ArrayData.h>
2 #include <Data/OptionalAxis.h>
2 #include <Data/OptionalAxis.h>
3
3
4 #include <QObject>
4 #include <QObject>
5 #include <QtTest>
5 #include <QtTest>
6
6
7 Q_DECLARE_METATYPE(OptionalAxis)
7 Q_DECLARE_METATYPE(OptionalAxis)
8 Q_DECLARE_METATYPE(Unit)
8 Q_DECLARE_METATYPE(Unit)
9
9
10 class TestOptionalAxis : public QObject {
10 class TestOptionalAxis : public QObject {
11 Q_OBJECT
11 Q_OBJECT
12
12
13 private slots:
13 private slots:
14 /// Tests the creation of a undefined axis
14 /// Tests the creation of a undefined axis
15 void testNotDefinedAxisCtor();
15 void testNotDefinedAxisCtor();
16
16
17 /// Tests the creation of a undefined axis
17 /// Tests the creation of a undefined axis
18 void testDefinedAxisCtor_data();
18 void testDefinedAxisCtor_data();
19 void testDefinedAxisCtor();
19 void testDefinedAxisCtor();
20
20
21 /// Tests @sa OptionalAxis::at() method
21 /// Tests @sa OptionalAxis::at() method
22 void testAt_data();
22 void testAt_data();
23 void testAt();
23 void testAt();
24
24
25 /// Tests @sa OptionalAxis::size() method
25 /// Tests @sa OptionalAxis::size() method
26 void testSize_data();
26 void testSize_data();
27 void testSize();
27 void testSize();
28
28
29 /// Tests @sa OptionalAxis::unit() method
29 /// Tests @sa OptionalAxis::unit() method
30 void testUnit_data();
30 void testUnit_data();
31 void testUnit();
31 void testUnit();
32 };
32 };
33
33
34 void TestOptionalAxis::testNotDefinedAxisCtor()
34 void TestOptionalAxis::testNotDefinedAxisCtor()
35 {
35 {
36 OptionalAxis notDefinedAxis{};
36 OptionalAxis notDefinedAxis{};
37 QVERIFY(!notDefinedAxis.isDefined());
37 QVERIFY(!notDefinedAxis.isDefined());
38 }
38 }
39
39
40 void TestOptionalAxis::testDefinedAxisCtor_data()
40 void TestOptionalAxis::testDefinedAxisCtor_data()
41 {
41 {
42 QTest::addColumn<bool>("noData"); // If set to true, nullptr is passed as data of the axis
42 QTest::addColumn<bool>("noData"); // If set to true, nullptr is passed as data of the axis
43 QTest::addColumn<std::vector<double> >(
43 QTest::addColumn<std::vector<double> >(
44 "data"); // Values assigned to the axis when 'noData' flag is set to false
44 "data"); // Values assigned to the axis when 'noData' flag is set to false
45 QTest::addColumn<Unit>("unit"); // Unit assigned to the axis
45 QTest::addColumn<Unit>("unit"); // Unit assigned to the axis
46
46
47 QTest::newRow("validData") << false << std::vector<double>{1, 2, 3} << Unit{"Hz"};
47 QTest::newRow("validData") << false << std::vector<double>{1, 2, 3} << Unit{"Hz"};
48 QTest::newRow("invalidData") << true << std::vector<double>{} << Unit{"Hz"};
48 QTest::newRow("invalidData") << true << std::vector<double>{} << Unit{"Hz"};
49 }
49 }
50
50
51 void TestOptionalAxis::testDefinedAxisCtor()
51 void TestOptionalAxis::testDefinedAxisCtor()
52 {
52 {
53 QFETCH(bool, noData);
53 QFETCH(bool, noData);
54 QFETCH(Unit, unit);
54 QFETCH(Unit, unit);
55
55
56 // When there is no data, we expect that the constructor returns exception
56 // When there is no data, we expect that the constructor returns exception
57 if (noData) {
57 if (noData) {
58 QVERIFY_EXCEPTION_THROWN(OptionalAxis(nullptr, unit), std::invalid_argument);
58 QVERIFY_EXCEPTION_THROWN(OptionalAxis(nullptr, unit), std::invalid_argument);
59 }
59 }
60 else {
60 else {
61 QFETCH(std::vector<double>, data);
61 QFETCH(std::vector<double>, data);
62
62
63 OptionalAxis axis{std::make_shared<ArrayData<1> >(data), unit};
63 OptionalAxis axis{std::make_shared<ArrayData<1> >(data), unit};
64 QVERIFY(axis.isDefined());
64 QVERIFY(axis.isDefined());
65 }
65 }
66 }
66 }
67
67
68 void TestOptionalAxis::testAt_data()
68 void TestOptionalAxis::testAt_data()
69 {
69 {
70 QTest::addColumn<OptionalAxis>("axis"); // Axis used for test case (defined or not)
70 QTest::addColumn<OptionalAxis>("axis"); // Axis used for test case (defined or not)
71 QTest::addColumn<int>("index"); // Index to test in the axis
71 QTest::addColumn<int>("index"); // Index to test in the axis
72 QTest::addColumn<double>("expectedValue"); // Expected axis value for the index
72 QTest::addColumn<double>("expectedValue"); // Expected axis value for the index
73
73
74 OptionalAxis definedAxis{std::make_shared<ArrayData<1> >(std::vector<double>{1, 2, 3}),
74 OptionalAxis definedAxis{std::make_shared<ArrayData<1> >(std::vector<double>{1, 2, 3}),
75 Unit{"Hz"}};
75 Unit{"Hz"}};
76
76
77 QTest::newRow("data1") << definedAxis << 0 << 1.;
77 QTest::newRow("data1") << definedAxis << 0 << 1.;
78 QTest::newRow("data2") << definedAxis << 1 << 2.;
78 QTest::newRow("data2") << definedAxis << 1 << 2.;
79 QTest::newRow("data3") << definedAxis << 2 << 3.;
79 QTest::newRow("data3") << definedAxis << 2 << 3.;
80 QTest::newRow("data4 (index out of bounds)")
80 QTest::newRow("data4 (index out of bounds)")
81 << definedAxis << 3
81 << definedAxis << 3
82 << std::numeric_limits<double>::quiet_NaN(); // Expects NaN for out of bounds index
82 << std::numeric_limits<double>::quiet_NaN(); // Expects NaN for out of bounds index
83 QTest::newRow("data5 (index out of bounds)")
83 QTest::newRow("data5 (index out of bounds)")
84 << definedAxis << -1
84 << definedAxis << -1
85 << std::numeric_limits<double>::quiet_NaN(); // Expects NaN for out of bounds index
85 << std::numeric_limits<double>::quiet_NaN(); // Expects NaN for out of bounds index
86 QTest::newRow("data6 (axis not defined)")
86 QTest::newRow("data6 (axis not defined)")
87 << OptionalAxis{} << 0
87 << OptionalAxis{} << 0
88 << std::numeric_limits<double>::quiet_NaN(); // Expects NaN for undefined axis
88 << std::numeric_limits<double>::quiet_NaN(); // Expects NaN for undefined axis
89 }
89 }
90
90
91 void TestOptionalAxis::testAt()
91 void TestOptionalAxis::testAt()
92 {
92 {
93 QFETCH(OptionalAxis, axis);
93 QFETCH(OptionalAxis, axis);
94 QFETCH(int, index);
94 QFETCH(int, index);
95 QFETCH(double, expectedValue);
95 QFETCH(double, expectedValue);
96
96
97 auto value = axis.at(index);
97 auto value = axis.at(index);
98 QVERIFY((std::isnan(value) && std::isnan(expectedValue)) || value == expectedValue);
98 QVERIFY((std::isnan(value) && std::isnan(expectedValue)) || value == expectedValue);
99 }
99 }
100
100
101 void TestOptionalAxis::testSize_data()
101 void TestOptionalAxis::testSize_data()
102 {
102 {
103 QTest::addColumn<OptionalAxis>("axis"); // Axis used for test case (defined or not)
103 QTest::addColumn<OptionalAxis>("axis"); // Axis used for test case (defined or not)
104 QTest::addColumn<int>("expectedSize"); // Expected number of data in the axis
104 QTest::addColumn<int>("expectedSize"); // Expected number of data in the axis
105
105
106 // Lambda that creates default defined axis (with the values passed in parameter)
106 // Lambda that creates default defined axis (with the values passed in parameter)
107 auto axis = [](std::vector<double> values) {
107 auto axis = [](std::vector<double> values) {
108 return OptionalAxis{std::make_shared<ArrayData<1> >(std::move(values)), Unit{"Hz"}};
108 return OptionalAxis{std::make_shared<ArrayData<1> >(std::move(values)), Unit{"Hz"}};
109 };
109 };
110
110
111 QTest::newRow("data1") << axis({}) << 0;
111 QTest::newRow("data1") << axis({}) << 0;
112 QTest::newRow("data2") << axis({1, 2, 3}) << 3;
112 QTest::newRow("data2") << axis({1, 2, 3}) << 3;
113 QTest::newRow("data3") << axis({1, 2, 3, 4}) << 4;
113 QTest::newRow("data3") << axis({1, 2, 3, 4}) << 4;
114 QTest::newRow("data4 (axis not defined)")
114 QTest::newRow("data4 (axis not defined)") << OptionalAxis{}
115 << OptionalAxis{} << 0; // Expects 0 for undefined axis
115 << 0; // Expects 0 for undefined axis
116 }
116 }
117
117
118 void TestOptionalAxis::testSize()
118 void TestOptionalAxis::testSize()
119 {
119 {
120 QFETCH(OptionalAxis, axis);
120 QFETCH(OptionalAxis, axis);
121 QFETCH(int, expectedSize);
121 QFETCH(int, expectedSize);
122
122
123 QCOMPARE(axis.size(), expectedSize);
123 QCOMPARE(axis.size(), expectedSize);
124 }
124 }
125
125
126 void TestOptionalAxis::testUnit_data()
126 void TestOptionalAxis::testUnit_data()
127 {
127 {
128 QTest::addColumn<OptionalAxis>("axis"); // Axis used for test case (defined or not)
128 QTest::addColumn<OptionalAxis>("axis"); // Axis used for test case (defined or not)
129 QTest::addColumn<Unit>("expectedUnit"); // Expected unit for the axis
129 QTest::addColumn<Unit>("expectedUnit"); // Expected unit for the axis
130
130
131 // Lambda that creates default defined axis (with the unit passed in parameter)
131 // Lambda that creates default defined axis (with the unit passed in parameter)
132 auto axis = [](Unit unit) {
132 auto axis = [](Unit unit) {
133 return OptionalAxis{std::make_shared<ArrayData<1> >(std::vector<double>{1, 2, 3}), unit};
133 return OptionalAxis{std::make_shared<ArrayData<1> >(std::vector<double>{1, 2, 3}), unit};
134 };
134 };
135
135
136 QTest::newRow("data1") << axis(Unit{"Hz"}) << Unit{"Hz"};
136 QTest::newRow("data1") << axis(Unit{"Hz"}) << Unit{"Hz"};
137 QTest::newRow("data2") << axis(Unit{"t", true}) << Unit{"t", true};
137 QTest::newRow("data2") << axis(Unit{"t", true}) << Unit{"t", true};
138 QTest::newRow("data3 (axis not defined)")
138 QTest::newRow("data3 (axis not defined)") << OptionalAxis{}
139 << OptionalAxis{} << Unit{}; // Expects default unit for undefined axis
139 << Unit{}; // Expects default unit for undefined axis
140 }
140 }
141
141
142 void TestOptionalAxis::testUnit()
142 void TestOptionalAxis::testUnit()
143 {
143 {
144 QFETCH(OptionalAxis, axis);
144 QFETCH(OptionalAxis, axis);
145 QFETCH(Unit, expectedUnit);
145 QFETCH(Unit, expectedUnit);
146
146
147 QCOMPARE(axis.unit(), expectedUnit);
147 QCOMPARE(axis.unit(), expectedUnit);
148 }
148 }
149
149
150 QTEST_MAIN(TestOptionalAxis)
150 QTEST_MAIN(TestOptionalAxis)
151 #include "TestOptionalAxis.moc"
151 #include "TestOptionalAxis.moc"
@@ -1,426 +1,426
1 #include "Data/ScalarSeries.h"
1 #include "Data/ScalarSeries.h"
2
2
3 #include "DataSeriesBuilders.h"
3 #include "DataSeriesBuilders.h"
4 #include "DataSeriesUtils.h"
4 #include "DataSeriesUtils.h"
5
5
6 #include <QObject>
6 #include <QObject>
7 #include <QtTest>
7 #include <QtTest>
8
8
9 /**
9 /**
10 * @brief The TestScalarSeries class defines unit tests on scalar series.
10 * @brief The TestScalarSeries class defines unit tests on scalar series.
11 *
11 *
12 * Most of these unit tests use generic tests defined for DataSeries (@sa DataSeriesUtils)
12 * Most of these unit tests use generic tests defined for DataSeries (@sa DataSeriesUtils)
13 */
13 */
14 class TestScalarSeries : public QObject {
14 class TestScalarSeries : public QObject {
15 Q_OBJECT
15 Q_OBJECT
16 private slots:
16 private slots:
17 /// Tests construction of a scalar series
17 /// Tests construction of a scalar series
18 void testCtor_data();
18 void testCtor_data();
19 void testCtor();
19 void testCtor();
20
20
21 /// Tests merge of two scalar series
21 /// Tests merge of two scalar series
22 void testMerge_data();
22 void testMerge_data();
23 void testMerge();
23 void testMerge();
24
24
25 /// Tests merge of a vector series in a scalar series
25 /// Tests merge of a vector series in a scalar series
26 void testMergeWithVector_data();
26 void testMergeWithVector_data();
27 void testMergeWithVector();
27 void testMergeWithVector();
28
28
29 /// Tests get min x-axis data of a scalar series
29 /// Tests get min x-axis data of a scalar series
30 void testMinXAxisData_data();
30 void testMinXAxisData_data();
31 void testMinXAxisData();
31 void testMinXAxisData();
32
32
33 /// Tests get max x-axis data of a scalar series
33 /// Tests get max x-axis data of a scalar series
34 void testMaxXAxisData_data();
34 void testMaxXAxisData_data();
35 void testMaxXAxisData();
35 void testMaxXAxisData();
36
36
37 /// Tests purge of a scalar series
37 /// Tests purge of a scalar series
38 void testPurge_data();
38 void testPurge_data();
39 void testPurge();
39 void testPurge();
40
40
41 /// Tests get x-axis range of a scalar series
41 /// Tests get x-axis range of a scalar series
42 void testXAxisRange_data();
42 void testXAxisRange_data();
43 void testXAxisRange();
43 void testXAxisRange();
44
44
45 /// Tests get values bounds of a scalar series
45 /// Tests get values bounds of a scalar series
46 void testValuesBounds_data();
46 void testValuesBounds_data();
47 void testValuesBounds();
47 void testValuesBounds();
48 };
48 };
49
49
50 void TestScalarSeries::testCtor_data()
50 void TestScalarSeries::testCtor_data()
51 {
51 {
52 // x-axis data
52 // x-axis data
53 QTest::addColumn<DataContainer>("xAxisData");
53 QTest::addColumn<DataContainer>("xAxisData");
54 // values data
54 // values data
55 QTest::addColumn<DataContainer>("valuesData");
55 QTest::addColumn<DataContainer>("valuesData");
56
56
57 // construction expected to be valid
57 // construction expected to be valid
58 QTest::addColumn<bool>("expectOK");
58 QTest::addColumn<bool>("expectOK");
59 // expected x-axis data (when construction is valid)
59 // expected x-axis data (when construction is valid)
60 QTest::addColumn<DataContainer>("expectedXAxisData");
60 QTest::addColumn<DataContainer>("expectedXAxisData");
61 // expected values data (when construction is valid)
61 // expected values data (when construction is valid)
62 QTest::addColumn<DataContainer>("expectedValuesData");
62 QTest::addColumn<DataContainer>("expectedValuesData");
63
63
64 QTest::newRow("invalidData (different sizes of vectors)")
64 QTest::newRow("invalidData (different sizes of vectors)")
65 << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 200., 300.} << false
65 << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 200., 300.} << false
66 << DataContainer{} << DataContainer{};
66 << DataContainer{} << DataContainer{};
67
67
68 QTest::newRow("sortedData") << DataContainer{1., 2., 3., 4., 5.}
68 QTest::newRow("sortedData") << DataContainer{1., 2., 3., 4., 5.}
69 << DataContainer{100., 200., 300., 400., 500.} << true
69 << DataContainer{100., 200., 300., 400., 500.} << true
70 << DataContainer{1., 2., 3., 4., 5.}
70 << DataContainer{1., 2., 3., 4., 5.}
71 << DataContainer{100., 200., 300., 400., 500.};
71 << DataContainer{100., 200., 300., 400., 500.};
72
72
73 QTest::newRow("unsortedData") << DataContainer{5., 4., 3., 2., 1.}
73 QTest::newRow("unsortedData") << DataContainer{5., 4., 3., 2., 1.}
74 << DataContainer{100., 200., 300., 400., 500.} << true
74 << DataContainer{100., 200., 300., 400., 500.} << true
75 << DataContainer{1., 2., 3., 4., 5.}
75 << DataContainer{1., 2., 3., 4., 5.}
76 << DataContainer{500., 400., 300., 200., 100.};
76 << DataContainer{500., 400., 300., 200., 100.};
77
77
78 QTest::newRow("unsortedData2")
78 QTest::newRow("unsortedData2")
79 << DataContainer{1., 4., 3., 5., 2.} << DataContainer{100., 200., 300., 400., 500.} << true
79 << DataContainer{1., 4., 3., 5., 2.} << DataContainer{100., 200., 300., 400., 500.} << true
80 << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 500., 300., 200., 400.};
80 << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 500., 300., 200., 400.};
81 }
81 }
82
82
83 void TestScalarSeries::testCtor()
83 void TestScalarSeries::testCtor()
84 {
84 {
85 // Creates series
85 // Creates series
86 QFETCH(DataContainer, xAxisData);
86 QFETCH(DataContainer, xAxisData);
87 QFETCH(DataContainer, valuesData);
87 QFETCH(DataContainer, valuesData);
88 QFETCH(bool, expectOK);
88 QFETCH(bool, expectOK);
89
89
90 if (expectOK) {
90 if (expectOK) {
91 auto series = std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData),
91 auto series = std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData),
92 Unit{}, Unit{});
92 Unit{}, Unit{});
93
93
94 // Validates results : we check that the data series is sorted on its x-axis data
94 // Validates results : we check that the data series is sorted on its x-axis data
95 QFETCH(DataContainer, expectedXAxisData);
95 QFETCH(DataContainer, expectedXAxisData);
96 QFETCH(DataContainer, expectedValuesData);
96 QFETCH(DataContainer, expectedValuesData);
97
97
98 validateRange(series->cbegin(), series->cend(), expectedXAxisData, expectedValuesData);
98 validateRange(series->cbegin(), series->cend(), expectedXAxisData, expectedValuesData);
99 }
99 }
100 else {
100 else {
101 QVERIFY_EXCEPTION_THROWN(std::make_shared<ScalarSeries>(
101 QVERIFY_EXCEPTION_THROWN(std::make_shared<ScalarSeries>(
102 std::move(xAxisData), std::move(valuesData), Unit{}, Unit{}),
102 std::move(xAxisData), std::move(valuesData), Unit{}, Unit{}),
103 std::invalid_argument);
103 std::invalid_argument);
104 }
104 }
105 }
105 }
106
106
107 void TestScalarSeries::testMerge_data()
107 void TestScalarSeries::testMerge_data()
108 {
108 {
109 testMerge_struct<ScalarSeries, DataContainer>();
109 testMerge_struct<ScalarSeries, DataContainer>();
110
110
111 QTest::newRow("sortedMerge") << ScalarBuilder{}
111 QTest::newRow("sortedMerge") << ScalarBuilder{}
112 .setX({1., 2., 3., 4., 5.})
112 .setX({1., 2., 3., 4., 5.})
113 .setValues({100., 200., 300., 400., 500.})
113 .setValues({100., 200., 300., 400., 500.})
114 .build()
114 .build()
115 << ScalarBuilder{}
115 << ScalarBuilder{}
116 .setX({6., 7., 8., 9., 10.})
116 .setX({6., 7., 8., 9., 10.})
117 .setValues({600., 700., 800., 900., 1000.})
117 .setValues({600., 700., 800., 900., 1000.})
118 .build()
118 .build()
119 << DataContainer{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
119 << DataContainer{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
120 << DataContainer{100., 200., 300., 400., 500.,
120 << DataContainer{100., 200., 300., 400., 500.,
121 600., 700., 800., 900., 1000.};
121 600., 700., 800., 900., 1000.};
122
122
123 QTest::newRow("unsortedMerge")
123 QTest::newRow("unsortedMerge")
124 << ScalarBuilder{}
124 << ScalarBuilder{}
125 .setX({6., 7., 8., 9., 10.})
125 .setX({6., 7., 8., 9., 10.})
126 .setValues({600., 700., 800., 900., 1000.})
126 .setValues({600., 700., 800., 900., 1000.})
127 .build()
127 .build()
128 << ScalarBuilder{}
128 << ScalarBuilder{}
129 .setX({1., 2., 3., 4., 5.})
129 .setX({1., 2., 3., 4., 5.})
130 .setValues({100., 200., 300., 400., 500.})
130 .setValues({100., 200., 300., 400., 500.})
131 .build()
131 .build()
132 << DataContainer{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
132 << DataContainer{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
133 << DataContainer{100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
133 << DataContainer{100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
134
134
135 QTest::newRow("unsortedMerge2 (merge not made because source is in the bounds of dest)")
135 QTest::newRow("unsortedMerge2 (merge not made because source is in the bounds of dest)")
136 << ScalarBuilder{}
136 << ScalarBuilder{}
137 .setX({1., 2., 8., 9., 10})
137 .setX({1., 2., 8., 9., 10})
138 .setValues({100., 200., 800., 900., 1000.})
138 .setValues({100., 200., 800., 900., 1000.})
139 .build()
139 .build()
140 << ScalarBuilder{}
140 << ScalarBuilder{}
141 .setX({3., 4., 5., 6., 7.})
141 .setX({3., 4., 5., 6., 7.})
142 .setValues({300., 400., 500., 600., 700.})
142 .setValues({300., 400., 500., 600., 700.})
143 .build()
143 .build()
144 << DataContainer{1., 2., 8., 9., 10.} << DataContainer{100., 200., 800., 900., 1000.};
144 << DataContainer{1., 2., 8., 9., 10.} << DataContainer{100., 200., 800., 900., 1000.};
145
145
146 QTest::newRow("unsortedMerge3")
146 QTest::newRow("unsortedMerge3")
147 << ScalarBuilder{}
147 << ScalarBuilder{}
148 .setX({3., 4., 5., 7., 8})
148 .setX({3., 4., 5., 7., 8})
149 .setValues({300., 400., 500., 700., 800.})
149 .setValues({300., 400., 500., 700., 800.})
150 .build()
150 .build()
151 << ScalarBuilder{}
151 << ScalarBuilder{}
152 .setX({1., 2., 3., 7., 10.})
152 .setX({1., 2., 3., 7., 10.})
153 .setValues({100., 200., 333., 777., 1000.})
153 .setValues({100., 200., 333., 777., 1000.})
154 .build()
154 .build()
155 << DataContainer{1., 2., 3., 4., 5., 7., 8., 10.}
155 << DataContainer{1., 2., 3., 4., 5., 7., 8., 10.}
156 << DataContainer{100., 200., 300., 400., 500., 700., 800., 1000.};
156 << DataContainer{100., 200., 300., 400., 500., 700., 800., 1000.};
157
157
158 QTest::newRow("emptySource") << ScalarBuilder{}
158 QTest::newRow("emptySource") << ScalarBuilder{}
159 .setX({3., 4., 5., 7., 8})
159 .setX({3., 4., 5., 7., 8})
160 .setValues({300., 400., 500., 700., 800.})
160 .setValues({300., 400., 500., 700., 800.})
161 .build()
161 .build()
162 << ScalarBuilder{}.setX({}).setValues({}).build()
162 << ScalarBuilder{}.setX({}).setValues({}).build()
163 << DataContainer{3., 4., 5., 7., 8.}
163 << DataContainer{3., 4., 5., 7., 8.}
164 << DataContainer{300., 400., 500., 700., 800.};
164 << DataContainer{300., 400., 500., 700., 800.};
165 }
165 }
166
166
167 void TestScalarSeries::testMerge()
167 void TestScalarSeries::testMerge()
168 {
168 {
169 testMerge_t<ScalarSeries, DataContainer>();
169 testMerge_t<ScalarSeries, DataContainer>();
170 }
170 }
171
171
172 void TestScalarSeries::testMergeWithVector_data()
172 void TestScalarSeries::testMergeWithVector_data()
173 {
173 {
174 testMergeDifferentTypes_struct<VectorSeries, ScalarSeries>();
174 testMergeDifferentTypes_struct<VectorSeries, ScalarSeries>();
175
175
176 QTest::newRow("mergeVectorInScalar")
176 QTest::newRow("mergeVectorInScalar") << ScalarBuilder{}
177 << ScalarBuilder{}
177 .setX({1., 2., 3., 4., 5.})
178 .setX({1., 2., 3., 4., 5.})
178 .setValues({100., 200., 300., 400., 500.})
179 .setValues({100., 200., 300., 400., 500.})
179 .build()
180 .build()
180 << VectorBuilder{}
181 << VectorBuilder{}
181 .setX({6., 7., 8., 9., 10.})
182 .setX({6., 7., 8., 9., 10.})
182 .setXValues({600., 700., 800., 900., 1000.})
183 .setXValues({600., 700., 800., 900., 1000.})
183 .setYValues({610., 710., 810., 910., 1010.})
184 .setYValues({610., 710., 810., 910., 1010.})
184 .setZValues({620., 720., 820., 920., 1020.})
185 .setZValues({620., 720., 820., 920., 1020.})
185 .build()
186 .build()
186 << DataContainer{1., 2., 3., 4., 5.}
187 << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 200., 300., 400., 500.};
187 << DataContainer{100., 200., 300., 400., 500.};
188 }
188 }
189
189
190 void TestScalarSeries::testMergeWithVector()
190 void TestScalarSeries::testMergeWithVector()
191 {
191 {
192 testMergeDifferentTypes_t<VectorSeries, ScalarSeries>();
192 testMergeDifferentTypes_t<VectorSeries, ScalarSeries>();
193 }
193 }
194
194
195 void TestScalarSeries::testMinXAxisData_data()
195 void TestScalarSeries::testMinXAxisData_data()
196 {
196 {
197 testMinXAxisData_struct<ScalarSeries>();
197 testMinXAxisData_struct<ScalarSeries>();
198
198
199 QTest::newRow("minData1") << ScalarBuilder{}
199 QTest::newRow("minData1") << ScalarBuilder{}
200 .setX({1., 2., 3., 4., 5.})
200 .setX({1., 2., 3., 4., 5.})
201 .setValues({100., 200., 300., 400., 500.})
201 .setValues({100., 200., 300., 400., 500.})
202 .build()
202 .build()
203 << 0. << true << 1.;
203 << 0. << true << 1.;
204 QTest::newRow("minData2") << ScalarBuilder{}
204 QTest::newRow("minData2") << ScalarBuilder{}
205 .setX({1., 2., 3., 4., 5.})
205 .setX({1., 2., 3., 4., 5.})
206 .setValues({100., 200., 300., 400., 500.})
206 .setValues({100., 200., 300., 400., 500.})
207 .build()
207 .build()
208 << 1. << true << 1.;
208 << 1. << true << 1.;
209 QTest::newRow("minData3") << ScalarBuilder{}
209 QTest::newRow("minData3") << ScalarBuilder{}
210 .setX({1., 2., 3., 4., 5.})
210 .setX({1., 2., 3., 4., 5.})
211 .setValues({100., 200., 300., 400., 500.})
211 .setValues({100., 200., 300., 400., 500.})
212 .build()
212 .build()
213 << 1.1 << true << 2.;
213 << 1.1 << true << 2.;
214 QTest::newRow("minData4") << ScalarBuilder{}
214 QTest::newRow("minData4") << ScalarBuilder{}
215 .setX({1., 2., 3., 4., 5.})
215 .setX({1., 2., 3., 4., 5.})
216 .setValues({100., 200., 300., 400., 500.})
216 .setValues({100., 200., 300., 400., 500.})
217 .build()
217 .build()
218 << 5. << true << 5.;
218 << 5. << true << 5.;
219 QTest::newRow("minData5") << ScalarBuilder{}
219 QTest::newRow("minData5") << ScalarBuilder{}
220 .setX({1., 2., 3., 4., 5.})
220 .setX({1., 2., 3., 4., 5.})
221 .setValues({100., 200., 300., 400., 500.})
221 .setValues({100., 200., 300., 400., 500.})
222 .build()
222 .build()
223 << 5.1 << false << std::numeric_limits<double>::quiet_NaN();
223 << 5.1 << false << std::numeric_limits<double>::quiet_NaN();
224 QTest::newRow("minData6") << ScalarBuilder{}.setX({}).setValues({}).build() << 1.1 << false
224 QTest::newRow("minData6") << ScalarBuilder{}.setX({}).setValues({}).build() << 1.1 << false
225 << std::numeric_limits<double>::quiet_NaN();
225 << std::numeric_limits<double>::quiet_NaN();
226 }
226 }
227
227
228 void TestScalarSeries::testMinXAxisData()
228 void TestScalarSeries::testMinXAxisData()
229 {
229 {
230 testMinXAxisData_t<ScalarSeries>();
230 testMinXAxisData_t<ScalarSeries>();
231 }
231 }
232
232
233 void TestScalarSeries::testMaxXAxisData_data()
233 void TestScalarSeries::testMaxXAxisData_data()
234 {
234 {
235 testMaxXAxisData_struct<ScalarSeries>();
235 testMaxXAxisData_struct<ScalarSeries>();
236
236
237 QTest::newRow("maxData1") << ScalarBuilder{}
237 QTest::newRow("maxData1") << ScalarBuilder{}
238 .setX({1., 2., 3., 4., 5.})
238 .setX({1., 2., 3., 4., 5.})
239 .setValues({100., 200., 300., 400., 500.})
239 .setValues({100., 200., 300., 400., 500.})
240 .build()
240 .build()
241 << 6. << true << 5.;
241 << 6. << true << 5.;
242 QTest::newRow("maxData2") << ScalarBuilder{}
242 QTest::newRow("maxData2") << ScalarBuilder{}
243 .setX({1., 2., 3., 4., 5.})
243 .setX({1., 2., 3., 4., 5.})
244 .setValues({100., 200., 300., 400., 500.})
244 .setValues({100., 200., 300., 400., 500.})
245 .build()
245 .build()
246 << 5. << true << 5.;
246 << 5. << true << 5.;
247 QTest::newRow("maxData3") << ScalarBuilder{}
247 QTest::newRow("maxData3") << ScalarBuilder{}
248 .setX({1., 2., 3., 4., 5.})
248 .setX({1., 2., 3., 4., 5.})
249 .setValues({100., 200., 300., 400., 500.})
249 .setValues({100., 200., 300., 400., 500.})
250 .build()
250 .build()
251 << 4.9 << true << 4.;
251 << 4.9 << true << 4.;
252 QTest::newRow("maxData4") << ScalarBuilder{}
252 QTest::newRow("maxData4") << ScalarBuilder{}
253 .setX({1., 2., 3., 4., 5.})
253 .setX({1., 2., 3., 4., 5.})
254 .setValues({100., 200., 300., 400., 500.})
254 .setValues({100., 200., 300., 400., 500.})
255 .build()
255 .build()
256 << 1.1 << true << 1.;
256 << 1.1 << true << 1.;
257 QTest::newRow("maxData5") << ScalarBuilder{}
257 QTest::newRow("maxData5") << ScalarBuilder{}
258 .setX({1., 2., 3., 4., 5.})
258 .setX({1., 2., 3., 4., 5.})
259 .setValues({100., 200., 300., 400., 500.})
259 .setValues({100., 200., 300., 400., 500.})
260 .build()
260 .build()
261 << 1. << true << 1.;
261 << 1. << true << 1.;
262 QTest::newRow("maxData6") << ScalarBuilder{}.setX({}).setValues({}).build() << 1.1 << false
262 QTest::newRow("maxData6") << ScalarBuilder{}.setX({}).setValues({}).build() << 1.1 << false
263 << std::numeric_limits<double>::quiet_NaN();
263 << std::numeric_limits<double>::quiet_NaN();
264 }
264 }
265
265
266 void TestScalarSeries::testMaxXAxisData()
266 void TestScalarSeries::testMaxXAxisData()
267 {
267 {
268 testMaxXAxisData_t<ScalarSeries>();
268 testMaxXAxisData_t<ScalarSeries>();
269 }
269 }
270
270
271 void TestScalarSeries::testPurge_data()
271 void TestScalarSeries::testPurge_data()
272 {
272 {
273 testPurge_struct<ScalarSeries>();
273 testPurge_struct<ScalarSeries>();
274
274
275 QTest::newRow("purgeScalar") << ScalarBuilder{}
275 QTest::newRow("purgeScalar") << ScalarBuilder{}
276 .setX({1., 2., 3., 4., 5.})
276 .setX({1., 2., 3., 4., 5.})
277 .setValues({100., 200., 300., 400., 500.})
277 .setValues({100., 200., 300., 400., 500.})
278 .build()
278 .build()
279 << 2. << 4. << DataContainer{2., 3., 4.}
279 << 2. << 4. << DataContainer{2., 3., 4.}
280 << std::vector<DataContainer>{{200., 300., 400.}};
280 << std::vector<DataContainer>{{200., 300., 400.}};
281 QTest::newRow("purgeScalar1 (min/max swap)")
281 QTest::newRow("purgeScalar1 (min/max swap)") << ScalarBuilder{}
282 << ScalarBuilder{}
282 .setX({1., 2., 3., 4., 5.})
283 .setX({1., 2., 3., 4., 5.})
283 .setValues({100., 200., 300., 400., 500.})
284 .setValues({100., 200., 300., 400., 500.})
284 .build()
285 .build()
285 << 4. << 2. << DataContainer{2., 3., 4.}
286 << 4. << 2. << DataContainer{2., 3., 4.} << std::vector<DataContainer>{{200., 300., 400.}};
286 << std::vector<DataContainer>{{200., 300., 400.}};
287 QTest::newRow("purgeScalar2") << ScalarBuilder{}
287 QTest::newRow("purgeScalar2") << ScalarBuilder{}
288 .setX({1., 2., 3., 4., 5.})
288 .setX({1., 2., 3., 4., 5.})
289 .setValues({100., 200., 300., 400., 500.})
289 .setValues({100., 200., 300., 400., 500.})
290 .build()
290 .build()
291 << 0. << 2.5 << DataContainer{1., 2.}
291 << 0. << 2.5 << DataContainer{1., 2.}
292 << std::vector<DataContainer>{{100., 200.}};
292 << std::vector<DataContainer>{{100., 200.}};
293 QTest::newRow("purgeScalar3") << ScalarBuilder{}
293 QTest::newRow("purgeScalar3") << ScalarBuilder{}
294 .setX({1., 2., 3., 4., 5.})
294 .setX({1., 2., 3., 4., 5.})
295 .setValues({100., 200., 300., 400., 500.})
295 .setValues({100., 200., 300., 400., 500.})
296 .build()
296 .build()
297 << 3.5 << 7. << DataContainer{4., 5.}
297 << 3.5 << 7. << DataContainer{4., 5.}
298 << std::vector<DataContainer>{{400., 500.}};
298 << std::vector<DataContainer>{{400., 500.}};
299 QTest::newRow("purgeScalar4") << ScalarBuilder{}
299 QTest::newRow("purgeScalar4") << ScalarBuilder{}
300 .setX({1., 2., 3., 4., 5.})
300 .setX({1., 2., 3., 4., 5.})
301 .setValues({100., 200., 300., 400., 500.})
301 .setValues({100., 200., 300., 400., 500.})
302 .build()
302 .build()
303 << 0. << 7. << DataContainer{1., 2., 3., 4., 5.}
303 << 0. << 7. << DataContainer{1., 2., 3., 4., 5.}
304 << std::vector<DataContainer>{{100., 200., 300., 400., 500.}};
304 << std::vector<DataContainer>{{100., 200., 300., 400., 500.}};
305 QTest::newRow("purgeScalar5") << ScalarBuilder{}
305 QTest::newRow("purgeScalar5") << ScalarBuilder{}
306 .setX({1., 2., 3., 4., 5.})
306 .setX({1., 2., 3., 4., 5.})
307 .setValues({100., 200., 300., 400., 500.})
307 .setValues({100., 200., 300., 400., 500.})
308 .build()
308 .build()
309 << 5.5 << 7. << DataContainer{} << std::vector<DataContainer>{{}};
309 << 5.5 << 7. << DataContainer{} << std::vector<DataContainer>{{}};
310 }
310 }
311
311
312 void TestScalarSeries::testPurge()
312 void TestScalarSeries::testPurge()
313 {
313 {
314 testPurge_t<ScalarSeries>();
314 testPurge_t<ScalarSeries>();
315 }
315 }
316
316
317 void TestScalarSeries::testXAxisRange_data()
317 void TestScalarSeries::testXAxisRange_data()
318 {
318 {
319 testXAxisRange_struct<ScalarSeries>();
319 testXAxisRange_struct<ScalarSeries>();
320
320
321 QTest::newRow("xAxisRange") << ScalarBuilder{}
321 QTest::newRow("xAxisRange") << ScalarBuilder{}
322 .setX({1., 2., 3., 4., 5.})
322 .setX({1., 2., 3., 4., 5.})
323 .setValues({100., 200., 300., 400., 500.})
323 .setValues({100., 200., 300., 400., 500.})
324 .build()
324 .build()
325 << -1. << 3.2 << DataContainer{1., 2., 3.}
325 << -1. << 3.2 << DataContainer{1., 2., 3.}
326 << DataContainer{100., 200., 300.};
326 << DataContainer{100., 200., 300.};
327 QTest::newRow("xAxisRange1 (min/max swap)")
327 QTest::newRow("xAxisRange1 (min/max swap)") << ScalarBuilder{}
328 << ScalarBuilder{}
328 .setX({1., 2., 3., 4., 5.})
329 .setX({1., 2., 3., 4., 5.})
329 .setValues({100., 200., 300., 400., 500.})
330 .setValues({100., 200., 300., 400., 500.})
330 .build()
331 .build()
331 << 3.2 << -1. << DataContainer{1., 2., 3.}
332 << 3.2 << -1. << DataContainer{1., 2., 3.} << DataContainer{100., 200., 300.};
332 << DataContainer{100., 200., 300.};
333 QTest::newRow("xAxisRange2") << ScalarBuilder{}
333 QTest::newRow("xAxisRange2") << ScalarBuilder{}
334 .setX({1., 2., 3., 4., 5.})
334 .setX({1., 2., 3., 4., 5.})
335 .setValues({100., 200., 300., 400., 500.})
335 .setValues({100., 200., 300., 400., 500.})
336 .build()
336 .build()
337 << 1. << 4. << DataContainer{1., 2., 3., 4.}
337 << 1. << 4. << DataContainer{1., 2., 3., 4.}
338 << DataContainer{100., 200., 300., 400.};
338 << DataContainer{100., 200., 300., 400.};
339 QTest::newRow("xAxisRange3") << ScalarBuilder{}
339 QTest::newRow("xAxisRange3") << ScalarBuilder{}
340 .setX({1., 2., 3., 4., 5.})
340 .setX({1., 2., 3., 4., 5.})
341 .setValues({100., 200., 300., 400., 500.})
341 .setValues({100., 200., 300., 400., 500.})
342 .build()
342 .build()
343 << 1. << 3.9 << DataContainer{1., 2., 3.}
343 << 1. << 3.9 << DataContainer{1., 2., 3.}
344 << DataContainer{100., 200., 300.};
344 << DataContainer{100., 200., 300.};
345 QTest::newRow("xAxisRange4") << ScalarBuilder{}
345 QTest::newRow("xAxisRange4") << ScalarBuilder{}
346 .setX({1., 2., 3., 4., 5.})
346 .setX({1., 2., 3., 4., 5.})
347 .setValues({100., 200., 300., 400., 500.})
347 .setValues({100., 200., 300., 400., 500.})
348 .build()
348 .build()
349 << 0. << 0.9 << DataContainer{} << DataContainer{};
349 << 0. << 0.9 << DataContainer{} << DataContainer{};
350 QTest::newRow("xAxisRange5") << ScalarBuilder{}
350 QTest::newRow("xAxisRange5") << ScalarBuilder{}
351 .setX({1., 2., 3., 4., 5.})
351 .setX({1., 2., 3., 4., 5.})
352 .setValues({100., 200., 300., 400., 500.})
352 .setValues({100., 200., 300., 400., 500.})
353 .build()
353 .build()
354 << 0. << 1. << DataContainer{1.} << DataContainer{100.};
354 << 0. << 1. << DataContainer{1.} << DataContainer{100.};
355 QTest::newRow("xAxisRange6") << ScalarBuilder{}
355 QTest::newRow("xAxisRange6") << ScalarBuilder{}
356 .setX({1., 2., 3., 4., 5.})
356 .setX({1., 2., 3., 4., 5.})
357 .setValues({100., 200., 300., 400., 500.})
357 .setValues({100., 200., 300., 400., 500.})
358 .build()
358 .build()
359 << 2.1 << 6. << DataContainer{3., 4., 5.}
359 << 2.1 << 6. << DataContainer{3., 4., 5.}
360 << DataContainer{300., 400., 500.};
360 << DataContainer{300., 400., 500.};
361 QTest::newRow("xAxisRange7") << ScalarBuilder{}
361 QTest::newRow("xAxisRange7") << ScalarBuilder{}
362 .setX({1., 2., 3., 4., 5.})
362 .setX({1., 2., 3., 4., 5.})
363 .setValues({100., 200., 300., 400., 500.})
363 .setValues({100., 200., 300., 400., 500.})
364 .build()
364 .build()
365 << 6. << 9. << DataContainer{} << DataContainer{};
365 << 6. << 9. << DataContainer{} << DataContainer{};
366 QTest::newRow("xAxisRange8") << ScalarBuilder{}
366 QTest::newRow("xAxisRange8") << ScalarBuilder{}
367 .setX({1., 2., 3., 4., 5.})
367 .setX({1., 2., 3., 4., 5.})
368 .setValues({100., 200., 300., 400., 500.})
368 .setValues({100., 200., 300., 400., 500.})
369 .build()
369 .build()
370 << 5. << 9. << DataContainer{5.} << DataContainer{500.};
370 << 5. << 9. << DataContainer{5.} << DataContainer{500.};
371 }
371 }
372
372
373 void TestScalarSeries::testXAxisRange()
373 void TestScalarSeries::testXAxisRange()
374 {
374 {
375 testXAxisRange_t<ScalarSeries>();
375 testXAxisRange_t<ScalarSeries>();
376 }
376 }
377
377
378 void TestScalarSeries::testValuesBounds_data()
378 void TestScalarSeries::testValuesBounds_data()
379 {
379 {
380 testValuesBounds_struct<ScalarSeries>();
380 testValuesBounds_struct<ScalarSeries>();
381
381
382 auto nan = std::numeric_limits<double>::quiet_NaN();
382 auto nan = std::numeric_limits<double>::quiet_NaN();
383
383
384 QTest::newRow("scalarBounds1") << ScalarBuilder{}
384 QTest::newRow("scalarBounds1") << ScalarBuilder{}
385 .setX({1., 2., 3., 4., 5.})
385 .setX({1., 2., 3., 4., 5.})
386 .setValues({100., 200., 300., 400., 500.})
386 .setValues({100., 200., 300., 400., 500.})
387 .build()
387 .build()
388 << 0. << 6. << true << 100. << 500.;
388 << 0. << 6. << true << 100. << 500.;
389 QTest::newRow("scalarBounds2") << ScalarBuilder{}
389 QTest::newRow("scalarBounds2") << ScalarBuilder{}
390 .setX({1., 2., 3., 4., 5.})
390 .setX({1., 2., 3., 4., 5.})
391 .setValues({100., 200., 300., 400., 500.})
391 .setValues({100., 200., 300., 400., 500.})
392 .build()
392 .build()
393 << 2. << 4. << true << 200. << 400.;
393 << 2. << 4. << true << 200. << 400.;
394 QTest::newRow("scalarBounds3") << ScalarBuilder{}
394 QTest::newRow("scalarBounds3") << ScalarBuilder{}
395 .setX({1., 2., 3., 4., 5.})
395 .setX({1., 2., 3., 4., 5.})
396 .setValues({100., 200., 300., 400., 500.})
396 .setValues({100., 200., 300., 400., 500.})
397 .build()
397 .build()
398 << 0. << 0.5 << false << nan << nan;
398 << 0. << 0.5 << false << nan << nan;
399 QTest::newRow("scalarBounds4") << ScalarBuilder{}
399 QTest::newRow("scalarBounds4") << ScalarBuilder{}
400 .setX({1., 2., 3., 4., 5.})
400 .setX({1., 2., 3., 4., 5.})
401 .setValues({100., 200., 300., 400., 500.})
401 .setValues({100., 200., 300., 400., 500.})
402 .build()
402 .build()
403 << 5.1 << 6. << false << nan << nan;
403 << 5.1 << 6. << false << nan << nan;
404 QTest::newRow("scalarBounds5")
404 QTest::newRow("scalarBounds5") << ScalarBuilder{}.setX({1.}).setValues({100.}).build() << 0.
405 << ScalarBuilder{}.setX({1.}).setValues({100.}).build() << 0. << 2. << true << 100. << 100.;
405 << 2. << true << 100. << 100.;
406 QTest::newRow("scalarBounds6")
406 QTest::newRow("scalarBounds6") << ScalarBuilder{}.setX({}).setValues({}).build() << 0. << 2.
407 << ScalarBuilder{}.setX({}).setValues({}).build() << 0. << 2. << false << nan << nan;
407 << false << nan << nan;
408
408
409 // Tests with NaN values: NaN values are not included in min/max search
409 // Tests with NaN values: NaN values are not included in min/max search
410 QTest::newRow("scalarBounds7") << ScalarBuilder{}
410 QTest::newRow("scalarBounds7") << ScalarBuilder{}
411 .setX({1., 2., 3., 4., 5.})
411 .setX({1., 2., 3., 4., 5.})
412 .setValues({nan, 200., 300., 400., nan})
412 .setValues({nan, 200., 300., 400., nan})
413 .build()
413 .build()
414 << 0. << 6. << true << 200. << 400.;
414 << 0. << 6. << true << 200. << 400.;
415 QTest::newRow("scalarBounds8")
415 QTest::newRow("scalarBounds8")
416 << ScalarBuilder{}.setX({1., 2., 3., 4., 5.}).setValues({nan, nan, nan, nan, nan}).build()
416 << ScalarBuilder{}.setX({1., 2., 3., 4., 5.}).setValues({nan, nan, nan, nan, nan}).build()
417 << 0. << 6. << true << nan << nan;
417 << 0. << 6. << true << nan << nan;
418 }
418 }
419
419
420 void TestScalarSeries::testValuesBounds()
420 void TestScalarSeries::testValuesBounds()
421 {
421 {
422 testValuesBounds_t<ScalarSeries>();
422 testValuesBounds_t<ScalarSeries>();
423 }
423 }
424
424
425 QTEST_MAIN(TestScalarSeries)
425 QTEST_MAIN(TestScalarSeries)
426 #include "TestScalarSeries.moc"
426 #include "TestScalarSeries.moc"
@@ -1,45 +1,47
1 #include "DataSource/DataSourceTreeWidget.h"
1 #include "DataSource/DataSourceTreeWidget.h"
2 #include "Common/MimeTypesDef.h"
2 #include "Common/MimeTypesDef.h"
3 #include "DataSource/DataSourceController.h"
3 #include "DataSource/DataSourceController.h"
4 #include "DataSource/DataSourceItem.h"
4 #include "DataSource/DataSourceItem.h"
5 #include "DataSource/DataSourceTreeWidgetItem.h"
5 #include "DataSource/DataSourceTreeWidgetItem.h"
6
6
7 #include "DragAndDrop/DragDropHelper.h"
7 #include "DragAndDrop/DragDropHelper.h"
8 #include "SqpApplication.h"
8 #include "SqpApplication.h"
9
9
10 #include <QMimeData>
10 #include <QMimeData>
11
11
12 DataSourceTreeWidget::DataSourceTreeWidget(QWidget *parent) : QTreeWidget(parent) {}
12 DataSourceTreeWidget::DataSourceTreeWidget(QWidget *parent) : QTreeWidget(parent)
13 {
14 }
13
15
14 QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
16 QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
15 {
17 {
16 auto mimeData = new QMimeData;
18 auto mimeData = new QMimeData;
17
19
18 // Basic check to ensure the item are correctly typed
20 // Basic check to ensure the item are correctly typed
19 Q_ASSERT(items.isEmpty() || dynamic_cast<DataSourceTreeWidgetItem *>(items.first()) != nullptr);
21 Q_ASSERT(items.isEmpty() || dynamic_cast<DataSourceTreeWidgetItem *>(items.first()) != nullptr);
20
22
21 QVariantList productData;
23 QVariantList productData;
22
24
23 for (auto item : items) {
25 for (auto item : items) {
24 auto dataSourceTreeItem = static_cast<DataSourceTreeWidgetItem *>(item);
26 auto dataSourceTreeItem = static_cast<DataSourceTreeWidgetItem *>(item);
25 auto dataSource = dataSourceTreeItem->data();
27 auto dataSource = dataSourceTreeItem->data();
26
28
27 if (dataSource->type() == DataSourceItemType::COMPONENT
29 if (dataSource->type() == DataSourceItemType::COMPONENT
28 || dataSource->type() == DataSourceItemType::PRODUCT) {
30 || dataSource->type() == DataSourceItemType::PRODUCT) {
29 auto metaData = dataSource->data();
31 auto metaData = dataSource->data();
30 productData << metaData;
32 productData << metaData;
31 }
33 }
32 }
34 }
33
35
34 auto encodedData = sqpApp->dataSourceController().mimeDataForProductsData(productData);
36 auto encodedData = sqpApp->dataSourceController().mimeDataForProductsData(productData);
35 mimeData->setData(MIME_TYPE_PRODUCT_LIST, encodedData);
37 mimeData->setData(MIME_TYPE_PRODUCT_LIST, encodedData);
36
38
37 return mimeData;
39 return mimeData;
38 }
40 }
39
41
40 void DataSourceTreeWidget::startDrag(Qt::DropActions supportedActions)
42 void DataSourceTreeWidget::startDrag(Qt::DropActions supportedActions)
41 {
43 {
42 // Resets the drag&drop operations before it's starting
44 // Resets the drag&drop operations before it's starting
43 sqpApp->dragDropHelper().resetDragAndDrop();
45 sqpApp->dragDropHelper().resetDragAndDrop();
44 QTreeWidget::startDrag(supportedActions);
46 QTreeWidget::startDrag(supportedActions);
45 }
47 }
@@ -1,292 +1,294
1 #include "DragAndDrop/DragDropHelper.h"
1 #include "DragAndDrop/DragDropHelper.h"
2 #include "DragAndDrop/DragDropScroller.h"
2 #include "DragAndDrop/DragDropScroller.h"
3 #include "DragAndDrop/DragDropTabSwitcher.h"
3 #include "DragAndDrop/DragDropTabSwitcher.h"
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5 #include "Visualization/VisualizationDragDropContainer.h"
5 #include "Visualization/VisualizationDragDropContainer.h"
6 #include "Visualization/VisualizationDragWidget.h"
6 #include "Visualization/VisualizationDragWidget.h"
7 #include "Visualization/VisualizationWidget.h"
7 #include "Visualization/VisualizationWidget.h"
8 #include "Visualization/operations/FindVariableOperation.h"
8 #include "Visualization/operations/FindVariableOperation.h"
9
9
10 #include "Variable/Variable.h"
10 #include "Variable/Variable.h"
11 #include "Variable/VariableController.h"
11 #include "Variable/VariableController.h"
12
12
13 #include "Common/MimeTypesDef.h"
13 #include "Common/MimeTypesDef.h"
14 #include "Common/VisualizationDef.h"
14 #include "Common/VisualizationDef.h"
15
15
16 #include <QDir>
16 #include <QDir>
17 #include <QLabel>
17 #include <QLabel>
18 #include <QUrl>
18 #include <QUrl>
19 #include <QVBoxLayout>
19 #include <QVBoxLayout>
20
20
21
21
22 Q_LOGGING_CATEGORY(LOG_DragDropHelper, "DragDropHelper")
22 Q_LOGGING_CATEGORY(LOG_DragDropHelper, "DragDropHelper")
23
23
24
24
25 struct DragDropHelper::DragDropHelperPrivate {
25 struct DragDropHelper::DragDropHelperPrivate {
26
26
27 VisualizationDragWidget *m_CurrentDragWidget = nullptr;
27 VisualizationDragWidget *m_CurrentDragWidget = nullptr;
28 std::unique_ptr<QWidget> m_PlaceHolder = nullptr;
28 std::unique_ptr<QWidget> m_PlaceHolder = nullptr;
29 QLabel *m_PlaceHolderLabel;
29 QLabel *m_PlaceHolderLabel;
30 QWidget *m_PlaceBackground;
30 QWidget *m_PlaceBackground;
31 std::unique_ptr<DragDropScroller> m_DragDropScroller = nullptr;
31 std::unique_ptr<DragDropScroller> m_DragDropScroller = nullptr;
32 std::unique_ptr<DragDropTabSwitcher> m_DragDropTabSwitcher = nullptr;
32 std::unique_ptr<DragDropTabSwitcher> m_DragDropTabSwitcher = nullptr;
33 QString m_ImageTempUrl; // Temporary file for image url generated by the drag & drop. Not using
33 QString m_ImageTempUrl; // Temporary file for image url generated by the drag & drop. Not using
34 // QTemporaryFile to have a name which is not generated.
34 // QTemporaryFile to have a name which is not generated.
35
35
36 VisualizationDragWidget *m_HighlightedDragWidget = nullptr;
36 VisualizationDragWidget *m_HighlightedDragWidget = nullptr;
37
37
38 QMetaObject::Connection m_DragWidgetDestroyedConnection;
38 QMetaObject::Connection m_DragWidgetDestroyedConnection;
39 QMetaObject::Connection m_HighlightedWidgetDestroyedConnection;
39 QMetaObject::Connection m_HighlightedWidgetDestroyedConnection;
40
40
41 QList<QWidget *> m_WidgetToClose;
41 QList<QWidget *> m_WidgetToClose;
42
42
43 explicit DragDropHelperPrivate()
43 explicit DragDropHelperPrivate()
44 : m_PlaceHolder{std::make_unique<QWidget>()},
44 : m_PlaceHolder{std::make_unique<QWidget>()},
45 m_DragDropScroller{std::make_unique<DragDropScroller>()},
45 m_DragDropScroller{std::make_unique<DragDropScroller>()},
46 m_DragDropTabSwitcher{std::make_unique<DragDropTabSwitcher>()}
46 m_DragDropTabSwitcher{std::make_unique<DragDropTabSwitcher>()}
47 {
47 {
48
48
49 auto layout = new QVBoxLayout{m_PlaceHolder.get()};
49 auto layout = new QVBoxLayout{m_PlaceHolder.get()};
50 layout->setSpacing(0);
50 layout->setSpacing(0);
51 layout->setContentsMargins(0, 0, 0, 0);
51 layout->setContentsMargins(0, 0, 0, 0);
52
52
53 m_PlaceHolderLabel = new QLabel{"", m_PlaceHolder.get()};
53 m_PlaceHolderLabel = new QLabel{"", m_PlaceHolder.get()};
54 m_PlaceHolderLabel->setMinimumHeight(25);
54 m_PlaceHolderLabel->setMinimumHeight(25);
55 layout->addWidget(m_PlaceHolderLabel);
55 layout->addWidget(m_PlaceHolderLabel);
56
56
57 m_PlaceBackground = new QWidget{m_PlaceHolder.get()};
57 m_PlaceBackground = new QWidget{m_PlaceHolder.get()};
58 m_PlaceBackground->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
58 m_PlaceBackground->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
59 layout->addWidget(m_PlaceBackground);
59 layout->addWidget(m_PlaceBackground);
60
60
61 sqpApp->installEventFilter(m_DragDropScroller.get());
61 sqpApp->installEventFilter(m_DragDropScroller.get());
62 sqpApp->installEventFilter(m_DragDropTabSwitcher.get());
62 sqpApp->installEventFilter(m_DragDropTabSwitcher.get());
63
63
64 m_ImageTempUrl = QDir::temp().absoluteFilePath("Sciqlop_graph.png");
64 m_ImageTempUrl = QDir::temp().absoluteFilePath("Sciqlop_graph.png");
65 }
65 }
66
66
67 void preparePlaceHolder(DragDropHelper::PlaceHolderType type, const QString &topLabelText) const
67 void preparePlaceHolder(DragDropHelper::PlaceHolderType type, const QString &topLabelText) const
68 {
68 {
69 if (m_CurrentDragWidget) {
69 if (m_CurrentDragWidget) {
70 m_PlaceHolder->setMinimumSize(m_CurrentDragWidget->size());
70 m_PlaceHolder->setMinimumSize(m_CurrentDragWidget->size());
71 m_PlaceHolder->setSizePolicy(m_CurrentDragWidget->sizePolicy());
71 m_PlaceHolder->setSizePolicy(m_CurrentDragWidget->sizePolicy());
72 }
72 }
73 else {
73 else {
74 // Configuration of the placeHolder when there is no dragWidget
74 // Configuration of the placeHolder when there is no dragWidget
75 // (for instance with a drag from a variable)
75 // (for instance with a drag from a variable)
76
76
77 m_PlaceHolder->setMinimumSize(0, GRAPH_MINIMUM_HEIGHT);
77 m_PlaceHolder->setMinimumSize(0, GRAPH_MINIMUM_HEIGHT);
78 m_PlaceHolder->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
78 m_PlaceHolder->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
79 }
79 }
80
80
81 switch (type) {
81 switch (type) {
82 case DragDropHelper::PlaceHolderType::Graph:
82 case DragDropHelper::PlaceHolderType::Graph:
83 m_PlaceBackground->setStyleSheet(
83 m_PlaceBackground->setStyleSheet(
84 "background-color: #BBD5EE; border: 1px solid #2A7FD4");
84 "background-color: #BBD5EE; border: 1px solid #2A7FD4");
85 break;
85 break;
86 case DragDropHelper::PlaceHolderType::Zone:
86 case DragDropHelper::PlaceHolderType::Zone:
87 case DragDropHelper::PlaceHolderType::Default:
87 case DragDropHelper::PlaceHolderType::Default:
88 m_PlaceBackground->setStyleSheet(
88 m_PlaceBackground->setStyleSheet(
89 "background-color: #BBD5EE; border: 2px solid #2A7FD4");
89 "background-color: #BBD5EE; border: 2px solid #2A7FD4");
90 m_PlaceHolderLabel->setStyleSheet("color: #2A7FD4");
90 m_PlaceHolderLabel->setStyleSheet("color: #2A7FD4");
91 break;
91 break;
92 }
92 }
93
93
94 m_PlaceHolderLabel->setText(topLabelText);
94 m_PlaceHolderLabel->setText(topLabelText);
95 m_PlaceHolderLabel->setVisible(!topLabelText.isEmpty());
95 m_PlaceHolderLabel->setVisible(!topLabelText.isEmpty());
96 }
96 }
97 };
97 };
98
98
99
99
100 DragDropHelper::DragDropHelper() : impl{spimpl::make_unique_impl<DragDropHelperPrivate>()} {}
100 DragDropHelper::DragDropHelper() : impl{spimpl::make_unique_impl<DragDropHelperPrivate>()}
101 {
102 }
101
103
102 DragDropHelper::~DragDropHelper()
104 DragDropHelper::~DragDropHelper()
103 {
105 {
104 QFile::remove(impl->m_ImageTempUrl);
106 QFile::remove(impl->m_ImageTempUrl);
105 }
107 }
106
108
107 void DragDropHelper::resetDragAndDrop()
109 void DragDropHelper::resetDragAndDrop()
108 {
110 {
109 setCurrentDragWidget(nullptr);
111 setCurrentDragWidget(nullptr);
110 impl->m_HighlightedDragWidget = nullptr;
112 impl->m_HighlightedDragWidget = nullptr;
111 }
113 }
112
114
113 void DragDropHelper::setCurrentDragWidget(VisualizationDragWidget *dragWidget)
115 void DragDropHelper::setCurrentDragWidget(VisualizationDragWidget *dragWidget)
114 {
116 {
115 if (impl->m_CurrentDragWidget) {
117 if (impl->m_CurrentDragWidget) {
116
118
117 QObject::disconnect(impl->m_DragWidgetDestroyedConnection);
119 QObject::disconnect(impl->m_DragWidgetDestroyedConnection);
118 }
120 }
119
121
120 if (dragWidget) {
122 if (dragWidget) {
121 // ensures the impl->m_CurrentDragWidget is reset when the widget is destroyed
123 // ensures the impl->m_CurrentDragWidget is reset when the widget is destroyed
122 impl->m_DragWidgetDestroyedConnection
124 impl->m_DragWidgetDestroyedConnection
123 = QObject::connect(dragWidget, &VisualizationDragWidget::destroyed,
125 = QObject::connect(dragWidget, &VisualizationDragWidget::destroyed,
124 [this]() { impl->m_CurrentDragWidget = nullptr; });
126 [this]() { impl->m_CurrentDragWidget = nullptr; });
125 }
127 }
126
128
127 impl->m_CurrentDragWidget = dragWidget;
129 impl->m_CurrentDragWidget = dragWidget;
128 }
130 }
129
131
130 VisualizationDragWidget *DragDropHelper::getCurrentDragWidget() const
132 VisualizationDragWidget *DragDropHelper::getCurrentDragWidget() const
131 {
133 {
132 return impl->m_CurrentDragWidget;
134 return impl->m_CurrentDragWidget;
133 }
135 }
134
136
135 QWidget &DragDropHelper::placeHolder() const
137 QWidget &DragDropHelper::placeHolder() const
136 {
138 {
137 return *impl->m_PlaceHolder;
139 return *impl->m_PlaceHolder;
138 }
140 }
139
141
140 void DragDropHelper::insertPlaceHolder(QVBoxLayout *layout, int index, PlaceHolderType type,
142 void DragDropHelper::insertPlaceHolder(QVBoxLayout *layout, int index, PlaceHolderType type,
141 const QString &topLabelText)
143 const QString &topLabelText)
142 {
144 {
143 removePlaceHolder();
145 removePlaceHolder();
144 impl->preparePlaceHolder(type, topLabelText);
146 impl->preparePlaceHolder(type, topLabelText);
145 layout->insertWidget(index, impl->m_PlaceHolder.get());
147 layout->insertWidget(index, impl->m_PlaceHolder.get());
146 impl->m_PlaceHolder->show();
148 impl->m_PlaceHolder->show();
147 }
149 }
148
150
149 void DragDropHelper::removePlaceHolder()
151 void DragDropHelper::removePlaceHolder()
150 {
152 {
151 auto parentWidget = impl->m_PlaceHolder->parentWidget();
153 auto parentWidget = impl->m_PlaceHolder->parentWidget();
152 if (parentWidget) {
154 if (parentWidget) {
153 parentWidget->layout()->removeWidget(impl->m_PlaceHolder.get());
155 parentWidget->layout()->removeWidget(impl->m_PlaceHolder.get());
154 impl->m_PlaceHolder->setParent(nullptr);
156 impl->m_PlaceHolder->setParent(nullptr);
155 impl->m_PlaceHolder->hide();
157 impl->m_PlaceHolder->hide();
156 }
158 }
157 }
159 }
158
160
159 bool DragDropHelper::isPlaceHolderSet() const
161 bool DragDropHelper::isPlaceHolderSet() const
160 {
162 {
161 return impl->m_PlaceHolder->parentWidget();
163 return impl->m_PlaceHolder->parentWidget();
162 }
164 }
163
165
164 void DragDropHelper::addDragDropScrollArea(QScrollArea *scrollArea)
166 void DragDropHelper::addDragDropScrollArea(QScrollArea *scrollArea)
165 {
167 {
166 impl->m_DragDropScroller->addScrollArea(scrollArea);
168 impl->m_DragDropScroller->addScrollArea(scrollArea);
167 }
169 }
168
170
169 void DragDropHelper::removeDragDropScrollArea(QScrollArea *scrollArea)
171 void DragDropHelper::removeDragDropScrollArea(QScrollArea *scrollArea)
170 {
172 {
171 impl->m_DragDropScroller->removeScrollArea(scrollArea);
173 impl->m_DragDropScroller->removeScrollArea(scrollArea);
172 }
174 }
173
175
174 void DragDropHelper::addDragDropTabBar(QTabBar *tabBar)
176 void DragDropHelper::addDragDropTabBar(QTabBar *tabBar)
175 {
177 {
176 impl->m_DragDropTabSwitcher->addTabBar(tabBar);
178 impl->m_DragDropTabSwitcher->addTabBar(tabBar);
177 }
179 }
178
180
179 void DragDropHelper::removeDragDropTabBar(QTabBar *tabBar)
181 void DragDropHelper::removeDragDropTabBar(QTabBar *tabBar)
180 {
182 {
181 impl->m_DragDropTabSwitcher->removeTabBar(tabBar);
183 impl->m_DragDropTabSwitcher->removeTabBar(tabBar);
182 }
184 }
183
185
184 QUrl DragDropHelper::imageTemporaryUrl(const QImage &image) const
186 QUrl DragDropHelper::imageTemporaryUrl(const QImage &image) const
185 {
187 {
186 image.save(impl->m_ImageTempUrl);
188 image.save(impl->m_ImageTempUrl);
187 return QUrl::fromLocalFile(impl->m_ImageTempUrl);
189 return QUrl::fromLocalFile(impl->m_ImageTempUrl);
188 }
190 }
189
191
190 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidget)
192 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidget)
191 {
193 {
192 if (impl->m_HighlightedDragWidget) {
194 if (impl->m_HighlightedDragWidget) {
193 impl->m_HighlightedDragWidget->highlightForMerge(false);
195 impl->m_HighlightedDragWidget->highlightForMerge(false);
194 QObject::disconnect(impl->m_HighlightedWidgetDestroyedConnection);
196 QObject::disconnect(impl->m_HighlightedWidgetDestroyedConnection);
195 }
197 }
196
198
197 if (dragWidget) {
199 if (dragWidget) {
198 dragWidget->highlightForMerge(true);
200 dragWidget->highlightForMerge(true);
199
201
200 // ensures the impl->m_HighlightedDragWidget is reset when the widget is destroyed
202 // ensures the impl->m_HighlightedDragWidget is reset when the widget is destroyed
201 impl->m_DragWidgetDestroyedConnection
203 impl->m_DragWidgetDestroyedConnection
202 = QObject::connect(dragWidget, &VisualizationDragWidget::destroyed,
204 = QObject::connect(dragWidget, &VisualizationDragWidget::destroyed,
203 [this]() { impl->m_HighlightedDragWidget = nullptr; });
205 [this]() { impl->m_HighlightedDragWidget = nullptr; });
204 }
206 }
205
207
206 impl->m_HighlightedDragWidget = dragWidget;
208 impl->m_HighlightedDragWidget = dragWidget;
207 }
209 }
208
210
209 VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const
211 VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const
210 {
212 {
211 return impl->m_HighlightedDragWidget;
213 return impl->m_HighlightedDragWidget;
212 }
214 }
213
215
214 void DragDropHelper::delayedCloseWidget(QWidget *widget)
216 void DragDropHelper::delayedCloseWidget(QWidget *widget)
215 {
217 {
216 widget->hide();
218 widget->hide();
217 impl->m_WidgetToClose << widget;
219 impl->m_WidgetToClose << widget;
218 }
220 }
219
221
220 void DragDropHelper::doCloseWidgets()
222 void DragDropHelper::doCloseWidgets()
221 {
223 {
222 for (auto widget : impl->m_WidgetToClose) {
224 for (auto widget : impl->m_WidgetToClose) {
223 widget->close();
225 widget->close();
224 }
226 }
225
227
226 impl->m_WidgetToClose.clear();
228 impl->m_WidgetToClose.clear();
227 }
229 }
228
230
229 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData,
231 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData,
230 VisualizationDragDropContainer *dropContainer)
232 VisualizationDragDropContainer *dropContainer)
231 {
233 {
232 if (!mimeData || !dropContainer) {
234 if (!mimeData || !dropContainer) {
233 qCWarning(LOG_DragDropHelper()) << QObject::tr(
235 qCWarning(LOG_DragDropHelper()) << QObject::tr(
234 "DragDropHelper::checkMimeDataForVisualization, invalid input parameters.");
236 "DragDropHelper::checkMimeDataForVisualization, invalid input parameters.");
235 Q_ASSERT(false);
237 Q_ASSERT(false);
236 return false;
238 return false;
237 }
239 }
238
240
239 auto result = false;
241 auto result = false;
240
242
241 if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) {
243 if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) {
242 auto variables = sqpApp->variableController().variablesForMimeData(
244 auto variables = sqpApp->variableController().variablesForMimeData(
243 mimeData->data(MIME_TYPE_VARIABLE_LIST));
245 mimeData->data(MIME_TYPE_VARIABLE_LIST));
244
246
245 if (variables.count() == 1) {
247 if (variables.count() == 1) {
246
248
247 auto variable = variables.first();
249 auto variable = variables.first();
248 if (variable->dataSeries() != nullptr) {
250 if (variable->dataSeries() != nullptr) {
249
251
250 // Check that the variable is not already in a graph
252 // Check that the variable is not already in a graph
251
253
252 auto parent = dropContainer->parentWidget();
254 auto parent = dropContainer->parentWidget();
253 while (parent && qobject_cast<VisualizationWidget *>(parent) == nullptr) {
255 while (parent && qobject_cast<VisualizationWidget *>(parent) == nullptr) {
254 parent = parent->parentWidget(); // Search for the top level VisualizationWidget
256 parent = parent->parentWidget(); // Search for the top level VisualizationWidget
255 }
257 }
256
258
257 if (parent) {
259 if (parent) {
258 auto visualizationWidget = static_cast<VisualizationWidget *>(parent);
260 auto visualizationWidget = static_cast<VisualizationWidget *>(parent);
259
261
260 FindVariableOperation findVariableOperation{variable};
262 FindVariableOperation findVariableOperation{variable};
261 visualizationWidget->accept(&findVariableOperation);
263 visualizationWidget->accept(&findVariableOperation);
262 auto variableContainers = findVariableOperation.result();
264 auto variableContainers = findVariableOperation.result();
263 if (variableContainers.empty()) {
265 if (variableContainers.empty()) {
264 result = true;
266 result = true;
265 }
267 }
266 else {
268 else {
267 // result = false: the variable already exist in the visualisation
269 // result = false: the variable already exist in the visualisation
268 }
270 }
269 }
271 }
270 else {
272 else {
271 qCWarning(LOG_DragDropHelper()) << QObject::tr(
273 qCWarning(LOG_DragDropHelper()) << QObject::tr(
272 "DragDropHelper::checkMimeDataForVisualization, the parent "
274 "DragDropHelper::checkMimeDataForVisualization, the parent "
273 "VisualizationWidget cannot be found. Cannot check if the variable is "
275 "VisualizationWidget cannot be found. Cannot check if the variable is "
274 "already used or not.");
276 "already used or not.");
275 }
277 }
276 }
278 }
277 else {
279 else {
278 // result = false: the variable is not fully loaded
280 // result = false: the variable is not fully loaded
279 }
281 }
280 }
282 }
281 else {
283 else {
282 // result = false: cannot drop multiple variables in the visualisation
284 // result = false: cannot drop multiple variables in the visualisation
283 }
285 }
284 }
286 }
285 else {
287 else {
286 // Other MIME data
288 // Other MIME data
287 // no special rules, accepted by default
289 // no special rules, accepted by default
288 result = true;
290 result = true;
289 }
291 }
290
292
291 return result;
293 return result;
292 }
294 }
@@ -1,13 +1,15
1 #include "Variable/VariableInspectorTableView.h"
1 #include "Variable/VariableInspectorTableView.h"
2
2
3 #include "DragAndDrop/DragDropHelper.h"
3 #include "DragAndDrop/DragDropHelper.h"
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent) {}
6 VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent)
7 {
8 }
7
9
8 void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions)
10 void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions)
9 {
11 {
10 // Resets the drag&drop operations before it's starting
12 // Resets the drag&drop operations before it's starting
11 sqpApp->dragDropHelper().resetDragAndDrop();
13 sqpApp->dragDropHelper().resetDragAndDrop();
12 QTableView::startDrag(supportedActions);
14 QTableView::startDrag(supportedActions);
13 }
15 }
General Comments 0
You need to be logged in to leave comments. Login now