##// END OF EJS Templates
(Minor) Extracts ui of DataSourceWidget
Alexandre Leroux -
r109:9e9399294f6e
parent child
Show More
@@ -1,10 +1,12
1 #ifndef SCIQLOP_DATASOURCEWIDGET_H
1 #ifndef SCIQLOP_DATASOURCEWIDGET_H
2 #define SCIQLOP_DATASOURCEWIDGET_H
2 #define SCIQLOP_DATASOURCEWIDGET_H
3
3
4 #include <Common/spimpl.h>
5
6 #include <QWidget>
4 #include <QWidget>
7
5
6 namespace Ui {
7 class DataSourceWidget;
8 } // Ui
9
8 class DataSourceItem;
10 class DataSourceItem;
9
11
10 /**
12 /**
@@ -26,8 +28,7 public slots:
26 void addDataSource(DataSourceItem *dataSource) noexcept;
28 void addDataSource(DataSourceItem *dataSource) noexcept;
27
29
28 private:
30 private:
29 class DataSourceWidgetPrivate;
31 Ui::DataSourceWidget *ui;
30 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
31 };
32 };
32
33
33 #endif // SCIQLOP_DATASOURCEWIDGET_H
34 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -33,24 +33,13 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
33
33
34 } // namespace
34 } // namespace
35
35
36 class DataSourceWidget::DataSourceWidgetPrivate {
36 DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget}
37 public:
38 explicit DataSourceWidgetPrivate(DataSourceWidget &widget)
39 : m_Ui{std::make_unique<Ui::DataSourceWidget>()}
40 {
41 m_Ui->setupUi(&widget);
42
43 // Set tree properties
44 m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
45 m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
46 }
47
48 std::unique_ptr<Ui::DataSourceWidget> m_Ui;
49 };
50
51 DataSourceWidget::DataSourceWidget(QWidget *parent)
52 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
53 {
37 {
38 ui->setupUi(this);
39
40 // Set tree properties
41 ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
42 ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
54 }
43 }
55
44
56 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
45 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
@@ -58,6 +47,6 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
58 // Creates the item associated to the source and adds it to the tree widget. The tree widget
47 // Creates the item associated to the source and adds it to the tree widget. The tree widget
59 // takes the ownership of the item
48 // takes the ownership of the item
60 if (dataSource) {
49 if (dataSource) {
61 impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
50 ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
62 }
51 }
63 }
52 }
General Comments 0
You need to be logged in to leave comments. Login now