##// END OF EJS Templates
Implements method to add a data source in the widget...
Alexandre Leroux -
r82:49b6273d9035
parent child
Show More
@@ -17,6 +17,14 class DataSourceWidget : public QWidget {
17 public:
17 public:
18 explicit DataSourceWidget(QWidget *parent = 0);
18 explicit DataSourceWidget(QWidget *parent = 0);
19
19
20 public slots:
21 /**
22 * Adds a data source. An item associated to the data source is created and then added to the
23 * representation tree
24 * @param dataSource the data source to add
25 */
26 void addDataSource(DataSourceItem &dataSource) noexcept;
27
20 private:
28 private:
21 class DataSourceWidgetPrivate;
29 class DataSourceWidgetPrivate;
22 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
30 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
@@ -13,6 +13,24 const auto TREE_NB_COLUMNS = 1;
13 /// Header labels for the tree
13 /// Header labels for the tree
14 const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
14 const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
15
15
16 /**
17 * Creates the item associated to a data source
18 * @param dataSource the data source for which to create the item
19 * @return the new item
20 */
21 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
22 {
23 // Creates item for the data source
24 auto item = new DataSourceTreeWidgetItem{dataSource};
25
26 // Generates items for the children of the data source
27 for (auto i = 0; i < dataSource->childCount(); ++i) {
28 item->addChild(createTreeWidgetItem(dataSource->child(i)));
29 }
30
31 return item;
32 }
33
16 } // namespace
34 } // namespace
17
35
18 class DataSourceWidget::DataSourceWidgetPrivate {
36 class DataSourceWidget::DataSourceWidgetPrivate {
@@ -34,3 +52,10 DataSourceWidget::DataSourceWidget(QWidget *parent)
34 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
52 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
35 {
53 {
36 }
54 }
55
56 void DataSourceWidget::addDataSource(DataSourceItem &dataSource) noexcept
57 {
58 // Creates the item associated to the source and adds it to the tree widget. The tree widget
59 // takes the ownership of the item
60 impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(&dataSource));
61 }
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