@@ -30,9 +30,7 void TestDataSourceController::testSetDataSourceItem() | |||
|
30 | 30 | |
|
31 | 31 | // Create a data source item |
|
32 | 32 | auto source1Name = QStringLiteral("Source1"); |
|
33 | auto source1Values = QVector<QVariant>{source1Name}; | |
|
34 | auto source1Item | |
|
35 | = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, std::move(source1Values)); | |
|
33 | auto source1Item = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, source1Name); | |
|
36 | 34 | |
|
37 | 35 | // Add data source item to the controller and check that a signal has been emitted after setting |
|
38 | 36 | // data source item in the controller |
@@ -10,6 +10,9 Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") | |||
|
10 | 10 | |
|
11 | 11 | namespace { |
|
12 | 12 | |
|
13 | // Column indexes | |
|
14 | const auto NAME_COLUMN = 0; | |
|
15 | ||
|
13 | 16 | QIcon itemIcon(const DataSourceItem *dataSource) |
|
14 | 17 | { |
|
15 | 18 | if (dataSource) { |
@@ -80,7 +83,23 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const Da | |||
|
80 | 83 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const |
|
81 | 84 | { |
|
82 | 85 | if (role == Qt::DisplayRole) { |
|
83 | return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{}; | |
|
86 | if (impl->m_Data) { | |
|
87 | switch (column) { | |
|
88 | case NAME_COLUMN: | |
|
89 | return impl->m_Data->name(); | |
|
90 | default: | |
|
91 | // No action | |
|
92 | break; | |
|
93 | } | |
|
94 | ||
|
95 | qCWarning(LOG_DataSourceTreeWidgetItem()) | |
|
96 | << QObject::tr("Can't get data (unknown column %1)").arg(column); | |
|
97 | } | |
|
98 | else { | |
|
99 | qCCritical(LOG_DataSourceTreeWidgetItem()) << QObject::tr("Can't get data (null item)"); | |
|
100 | } | |
|
101 | ||
|
102 | return QVariant{}; | |
|
84 | 103 | } |
|
85 | 104 | else { |
|
86 | 105 | return QTreeWidgetItem::data(column, role); |
@@ -23,8 +23,7 std::unique_ptr<IDataProvider> createDataProvider() noexcept | |||
|
23 | 23 | std::unique_ptr<DataSourceItem> createProductItem(const QString &productName, |
|
24 | 24 | const QUuid &dataSourceUid) |
|
25 | 25 | { |
|
26 | auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, | |
|
27 | QVector<QVariant>{productName}); | |
|
26 | auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, productName); | |
|
28 | 27 | |
|
29 | 28 | // Add action to load product from DataSourceController |
|
30 | 29 | result->addAction(std::make_unique<DataSourceItemAction>( |
@@ -42,18 +41,17 std::unique_ptr<DataSourceItem> createProductItem(const QString &productName, | |||
|
42 | 41 | std::unique_ptr<DataSourceItem> createDataSourceItem(const QUuid &dataSourceUid) noexcept |
|
43 | 42 | { |
|
44 | 43 | // Magnetic field products |
|
45 | auto magneticFieldFolder = std::make_unique<DataSourceItem>( | |
|
46 | DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")}); | |
|
44 | auto magneticFieldFolder = std::make_unique<DataSourceItem>(DataSourceItemType::NODE, | |
|
45 | QStringLiteral("Magnetic field")); | |
|
47 | 46 | magneticFieldFolder->appendChild(createProductItem(QStringLiteral("FGM"), dataSourceUid)); |
|
48 | 47 | magneticFieldFolder->appendChild(createProductItem(QStringLiteral("SC"), dataSourceUid)); |
|
49 | 48 | |
|
50 | 49 | // Electric field products |
|
51 | auto electricFieldFolder = std::make_unique<DataSourceItem>( | |
|
52 | DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")}); | |
|
50 | auto electricFieldFolder = std::make_unique<DataSourceItem>(DataSourceItemType::NODE, | |
|
51 | QStringLiteral("Electric field")); | |
|
53 | 52 | |
|
54 | 53 | // Root |
|
55 | auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE, | |
|
56 | QVector<QVariant>{DATA_SOURCE_NAME}); | |
|
54 | auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE, DATA_SOURCE_NAME); | |
|
57 | 55 | root->appendChild(std::move(magneticFieldFolder)); |
|
58 | 56 | root->appendChild(std::move(electricFieldFolder)); |
|
59 | 57 |
General Comments 0
You need to be logged in to leave comments.
Login now