##// END OF EJS Templates
Adds type for a data source item...
Alexandre Leroux -
r78:0afc39d45cc4
parent child
Show More
@@ -7,6 +7,11
7 #include <QVector>
7 #include <QVector>
8
8
9 /**
9 /**
10 * Possible types of an item
11 */
12 enum class DataSourceItemType { NODE, PRODUCT };
13
14 /**
10 * @brief The DataSourceItem class aims to represent a structure element of a data source.
15 * @brief The DataSourceItem class aims to represent a structure element of a data source.
11 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
16 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
12 * containing other DataSourceItem objects (children).
17 * containing other DataSourceItem objects (children).
@@ -14,7 +19,7
14 */
19 */
15 class DataSourceItem {
20 class DataSourceItem {
16 public:
21 public:
17 explicit DataSourceItem(QVector<QVariant> data = {});
22 explicit DataSourceItem(DataSourceItemType type, QVector<QVariant> data = {});
18
23
19 /**
24 /**
20 * Adds a child to the item. The item takes ownership of the child.
25 * Adds a child to the item. The item takes ownership of the child.
@@ -44,6 +49,8 public:
44 */
49 */
45 DataSourceItem *parentItem() const noexcept;
50 DataSourceItem *parentItem() const noexcept;
46
51
52 DataSourceItemType type() const noexcept;
53
47 private:
54 private:
48 class DataSourceItemPrivate;
55 class DataSourceItemPrivate;
49 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
56 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
@@ -3,18 +3,19
3 #include <QVector>
3 #include <QVector>
4
4
5 struct DataSourceItem::DataSourceItemPrivate {
5 struct DataSourceItem::DataSourceItemPrivate {
6 explicit DataSourceItemPrivate(QVector<QVariant> data)
6 explicit DataSourceItemPrivate(DataSourceItemType type, QVector<QVariant> data)
7 : m_Parent{nullptr}, m_Children{}, m_Data{std::move(data)}
7 : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)}
8 {
8 {
9 }
9 }
10
10
11 DataSourceItem *m_Parent;
11 DataSourceItem *m_Parent;
12 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
12 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
13 DataSourceItemType m_Type;
13 QVector<QVariant> m_Data;
14 QVector<QVariant> m_Data;
14 };
15 };
15
16
16 DataSourceItem::DataSourceItem(QVector<QVariant> data)
17 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data)
17 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(data)}
18 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))}
18 {
19 {
19 }
20 }
20
21
@@ -48,3 +49,8 DataSourceItem *DataSourceItem::parentItem() const noexcept
48 {
49 {
49 return impl->m_Parent;
50 return impl->m_Parent;
50 }
51 }
52
53 DataSourceItemType DataSourceItem::type() const noexcept
54 {
55 return impl->m_Type;
56 }
@@ -31,7 +31,8 void TestDataSourceController::testSetDataSourceItem()
31 // Create a data source item
31 // Create a data source item
32 auto source1Name = QStringLiteral("Source1");
32 auto source1Name = QStringLiteral("Source1");
33 auto source1Values = QVector<QVariant>{source1Name};
33 auto source1Values = QVector<QVariant>{source1Name};
34 auto source1Item = std::make_unique<DataSourceItem>(std::move(source1Values));
34 auto source1Item
35 = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, std::move(source1Values));
35
36
36 // Add data source item to the controller and check that a signal has been emitted after setting
37 // Add data source item to the controller and check that a signal has been emitted after setting
37 // data source item in the controller
38 // data source item in the controller
@@ -41,7 +42,8 void TestDataSourceController::testSetDataSourceItem()
41
42
42 // Try to a data source item with an unregistered uid and check that no signal has been emitted
43 // Try to a data source item with an unregistered uid and check that no signal has been emitted
43 auto unregisteredUid = QUuid::createUuid();
44 auto unregisteredUid = QUuid::createUuid();
44 dataSourceController.setDataSourceItem(unregisteredUid, std::make_unique<DataSourceItem>());
45 dataSourceController.setDataSourceItem(
46 unregisteredUid, std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT));
45 QCOMPARE(signalSpy.count(), 1);
47 QCOMPARE(signalSpy.count(), 1);
46 }
48 }
47
49
General Comments 3
Under Review
author

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

Changed commits:
  * 6 added
  * 3 removed

Changed files:
  * A gui/src/Visualization/VisualizationWidget.cpp
  * A gui/include/SidePane/SqpSidePane.h
  * A gui/include/Visualization/VisualizationGraphWidget.h
  * A gui/include/Visualization/VisualizationTabWidget.h
  * A gui/include/Visualization/VisualizationWidget.h
  * A gui/include/Visualization/VisualizationZoneWidget.h
  * A gui/include/Visualization/qcustomplot.h
  * A gui/src/SidePane/SqpSidePane.cpp
  * A gui/src/Visualization/VisualizationGraphWidget.cpp
  * A gui/src/Visualization/VisualizationTabWidget.cpp
  * A gui/src/Visualization/VisualizationZoneWidget.cpp
  * A gui/src/Visualization/qcustomplot.cpp
  * M gui/include/DataSource/DataSourceWidget.h
  * M gui/src/DataSource/DataSourceTreeWidgetItem.cpp
  * M gui/src/DataSource/DataSourceWidget.cpp
  * M app/src/Main.cpp
  * M app/src/MainWindow.cpp
  * M app/ui/MainWindow.ui
  * M core/include/DataSource/DataSourceController.h
  * M core/src/DataSource/DataSourceController.cpp
  * M core/tests/DataSource/TestDataSourceController.cpp
  * M gui/ui/visualization/VisualizationWidget.ui
  * M gui/vera-exclusions/exclusions.txt
  * M gui/src/visualization/VisualizationWidget.cpp
  * R cmake/sciqlop_package_qt.cmake
  * R core/include/Plugin/PluginManager.h
  * R core/include/Visualization/VisualizationController.h
  * R core/src/Plugin/PluginManager.cpp
  * R core/src/Visualization/VisualizationController.cpp
  * R gui/include/sidepane/SqpSidePane.h
  * R gui/include/visualization/VisualizationGraphWidget.h
  * R gui/include/visualization/VisualizationTabWidget.h
  * R gui/include/visualization/VisualizationWidget.h
  * R gui/include/visualization/VisualizationZoneWidget.h
  * R gui/include/visualization/qcustomplot.h
  * R gui/src/sidepane/SqpSidePane.cpp
  * R gui/src/visualization/VisualizationGraphWidget.cpp
  * R gui/src/visualization/VisualizationTabWidget.cpp
  * R gui/src/visualization/VisualizationZoneWidget.cpp
  * R gui/src/visualization/qcustomplot.cpp
  * R gui/ui/sidepane/SqpSidePane.ui
  * R gui/ui/visualization/VisualizationGraphWidget.ui
  * R gui/ui/visualization/VisualizationTabWidget.ui
  * R gui/ui/visualization/VisualizationZoneWidget.ui
  * R plugin/CMakeLists.txt
  * R plugin/cmake/Findsciqlop-plugin.cmake
  * R plugin/include/Plugin/IPlugin.h
  * R app/CMakeLists.txt
  * R app/include/MainWindow.h
  * R app/vera-exclusions/exclusions.txt
  * R cmake/sciqlop_applications.cmake
  * R core/CMakeLists.txt
  * R core/include/Common/spimpl.h
  * R gui/CMakeLists.txt
  * R gui/include/SqpApplication.h
  * R gui/src/SqpApplication.cpp
  * R app/src/mainwindow.ui
Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now