@@ -0,0 +1,14 | |||||
|
1 | #ifndef SCIQLOP_DATASOURCETREEWIDGET_H | |||
|
2 | #define SCIQLOP_DATASOURCETREEWIDGET_H | |||
|
3 | ||||
|
4 | #include <QTreeWidget> | |||
|
5 | ||||
|
6 | class DataSourceTreeWidget : public QTreeWidget { | |||
|
7 | public: | |||
|
8 | DataSourceTreeWidget(QWidget *parent); | |||
|
9 | ||||
|
10 | protected: | |||
|
11 | QMimeData *mimeData(const QList<QTreeWidgetItem *> items) const override; | |||
|
12 | }; | |||
|
13 | ||||
|
14 | #endif // SCIQLOP_DATASOURCETREEWIDGET_H |
@@ -0,0 +1,38 | |||||
|
1 | #include "DataSource/DataSourceTreeWidget.h" | |||
|
2 | #include "Common/MimeTypesDef.h" | |||
|
3 | #include "DataSource/DataSourceItem.h" | |||
|
4 | #include "DataSource/DataSourceTreeWidgetItem.h" | |||
|
5 | ||||
|
6 | #include <QMimeData> | |||
|
7 | ||||
|
8 | DataSourceTreeWidget::DataSourceTreeWidget(QWidget *parent) : QTreeWidget(parent) {} | |||
|
9 | ||||
|
10 | QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const | |||
|
11 | { | |||
|
12 | auto mimeData = new QMimeData; | |||
|
13 | ||||
|
14 | // Basic check to ensure the item are correctly typed | |||
|
15 | Q_ASSERT(items.isEmpty() || dynamic_cast<DataSourceTreeWidgetItem *>(items.first()) != nullptr); | |||
|
16 | ||||
|
17 | QVariantList productData; | |||
|
18 | ||||
|
19 | for (auto item : items) { | |||
|
20 | auto dataSourceTreeItem = static_cast<DataSourceTreeWidgetItem *>(item); | |||
|
21 | auto dataSource = dataSourceTreeItem->data(); | |||
|
22 | ||||
|
23 | if (dataSource->type() == DataSourceItemType::COMPONENT | |||
|
24 | || dataSource->type() == DataSourceItemType::PRODUCT) { | |||
|
25 | auto metaData = dataSource->data(); | |||
|
26 | productData << metaData; | |||
|
27 | } | |||
|
28 | } | |||
|
29 | ||||
|
30 | QByteArray encodedData; | |||
|
31 | QDataStream stream(&encodedData, QIODevice::WriteOnly); | |||
|
32 | ||||
|
33 | stream << productData; | |||
|
34 | ||||
|
35 | mimeData->setData(MIME_TYPE_PRODUCT_LIST, encodedData); | |||
|
36 | ||||
|
37 | return mimeData; | |||
|
38 | } |
@@ -1,18 +1,19 | |||||
1 | #ifndef SCIQLOP_MIMETYPESDEF_H |
|
1 | #ifndef SCIQLOP_MIMETYPESDEF_H | |
2 | #define SCIQLOP_MIMETYPESDEF_H |
|
2 | #define SCIQLOP_MIMETYPESDEF_H | |
3 |
|
3 | |||
4 | #include "CoreGlobal.h" |
|
4 | #include "CoreGlobal.h" | |
5 |
|
5 | |||
6 | #include <QString> |
|
6 | #include <QString> | |
7 |
|
7 | |||
8 | // ////////////////// // |
|
8 | // ////////////////// // | |
9 | // SciQlop Mime Types // |
|
9 | // SciQlop Mime Types // | |
10 | // ////////////////// // |
|
10 | // ////////////////// // | |
11 |
|
11 | |||
12 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_GRAPH; |
|
12 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_GRAPH; | |
13 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_ZONE; |
|
13 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_ZONE; | |
14 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_VARIABLE_LIST; |
|
14 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_VARIABLE_LIST; | |
|
15 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_PRODUCT_LIST; | |||
15 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_TIME_RANGE; |
|
16 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_TIME_RANGE; | |
16 |
|
17 | |||
17 |
|
18 | |||
18 | #endif // SCIQLOP_MIMETYPESDEF_H |
|
19 | #endif // SCIQLOP_MIMETYPESDEF_H |
@@ -1,63 +1,65 | |||||
1 |
|
1 | |||
2 | core_moc_headers = [ |
|
2 | core_moc_headers = [ | |
3 | 'include/Data/IDataProvider.h', |
|
3 | 'include/Data/IDataProvider.h', | |
4 | 'include/DataSource/DataSourceController.h', |
|
4 | 'include/DataSource/DataSourceController.h', | |
5 | 'include/DataSource/DataSourceItemAction.h', |
|
5 | 'include/DataSource/DataSourceItemAction.h', | |
|
6 | 'include/DataSource/DataSourceWidget.h', | |||
6 | 'include/Network/NetworkController.h', |
|
7 | 'include/Network/NetworkController.h', | |
7 | 'include/Time/TimeController.h', |
|
8 | 'include/Time/TimeController.h', | |
8 | 'include/Variable/Variable.h', |
|
9 | 'include/Variable/Variable.h', | |
9 | 'include/Variable/VariableCacheController.h', |
|
10 | 'include/Variable/VariableCacheController.h', | |
10 | 'include/Variable/VariableController.h', |
|
11 | 'include/Variable/VariableController.h', | |
11 | 'include/Variable/VariableAcquisitionWorker.h', |
|
12 | 'include/Variable/VariableAcquisitionWorker.h', | |
12 | 'include/Variable/VariableCacheStrategy.h', |
|
13 | 'include/Variable/VariableCacheStrategy.h', | |
13 | 'include/Variable/VariableSynchronizationGroup.h', |
|
14 | 'include/Variable/VariableSynchronizationGroup.h', | |
14 | 'include/Variable/VariableModel.h', |
|
15 | 'include/Variable/VariableModel.h', | |
15 | 'include/Visualization/VisualizationController.h' |
|
16 | 'include/Visualization/VisualizationController.h' | |
16 | ] |
|
17 | ] | |
17 |
|
18 | |||
18 |
|
19 | |||
19 | core_moc_files = qt5.preprocess(moc_headers : core_moc_headers) |
|
20 | core_moc_files = qt5.preprocess(moc_headers : core_moc_headers) | |
20 |
|
21 | |||
21 | core_sources = [ |
|
22 | core_sources = [ | |
22 | 'src/Common/DateUtils.cpp', |
|
23 | 'src/Common/DateUtils.cpp', | |
23 | 'src/Common/StringUtils.cpp', |
|
24 | 'src/Common/StringUtils.cpp', | |
24 | 'src/Common/MimeTypesDef.cpp', |
|
25 | 'src/Common/MimeTypesDef.cpp', | |
25 | 'src/Data/ScalarSeries.cpp', |
|
26 | 'src/Data/ScalarSeries.cpp', | |
26 | 'src/Data/DataSeriesIterator.cpp', |
|
27 | 'src/Data/DataSeriesIterator.cpp', | |
27 | 'src/Data/ArrayDataIterator.cpp', |
|
28 | 'src/Data/ArrayDataIterator.cpp', | |
28 | 'src/Data/VectorSeries.cpp', |
|
29 | 'src/Data/VectorSeries.cpp', | |
29 | 'src/DataSource/DataSourceController.cpp', |
|
30 | 'src/DataSource/DataSourceController.cpp', | |
30 | 'src/DataSource/DataSourceItem.cpp', |
|
31 | 'src/DataSource/DataSourceItem.cpp', | |
31 | 'src/DataSource/DataSourceItemAction.cpp', |
|
32 | 'src/DataSource/DataSourceItemAction.cpp', | |
|
33 | 'src/DataSource/DataSourceWidget.cpp', | |||
32 | 'src/Network/NetworkController.cpp', |
|
34 | 'src/Network/NetworkController.cpp', | |
33 | 'src/Plugin/PluginManager.cpp', |
|
35 | 'src/Plugin/PluginManager.cpp', | |
34 | 'src/Settings/SqpSettingsDefs.cpp', |
|
36 | 'src/Settings/SqpSettingsDefs.cpp', | |
35 | 'src/Time/TimeController.cpp', |
|
37 | 'src/Time/TimeController.cpp', | |
36 | 'src/Variable/Variable.cpp', |
|
38 | 'src/Variable/Variable.cpp', | |
37 | 'src/Variable/VariableCacheController.cpp', |
|
39 | 'src/Variable/VariableCacheController.cpp', | |
38 | 'src/Variable/VariableController.cpp', |
|
40 | 'src/Variable/VariableController.cpp', | |
39 | 'src/Variable/VariableAcquisitionWorker.cpp', |
|
41 | 'src/Variable/VariableAcquisitionWorker.cpp', | |
40 | 'src/Variable/VariableSynchronizationGroup.cpp', |
|
42 | 'src/Variable/VariableSynchronizationGroup.cpp', | |
41 | 'src/Variable/VariableModel.cpp', |
|
43 | 'src/Variable/VariableModel.cpp', | |
42 | 'src/Visualization/VisualizationController.cpp' |
|
44 | 'src/Visualization/VisualizationController.cpp' | |
43 | ] |
|
45 | ] | |
44 |
|
46 | |||
45 | core_inc = include_directories(['include', '../plugin/include']) |
|
47 | core_inc = include_directories(['include', '../plugin/include']) | |
46 |
|
48 | |||
47 | sciqlop_core_lib = library('sciqlopcore', |
|
49 | sciqlop_core_lib = library('sciqlopcore', | |
48 | core_sources, |
|
50 | core_sources, | |
49 | core_moc_files, |
|
51 | core_moc_files, | |
50 | cpp_args : '-DCORE_LIB', |
|
52 | cpp_args : '-DCORE_LIB', | |
51 | include_directories : core_inc, |
|
53 | include_directories : core_inc, | |
52 | dependencies : [qt5core, qt5network], |
|
54 | dependencies : [qt5core, qt5network], | |
53 | install : true |
|
55 | install : true | |
54 | ) |
|
56 | ) | |
55 |
|
57 | |||
56 |
|
58 | |||
57 | sciqlop_core = declare_dependency(link_with : sciqlop_core_lib, |
|
59 | sciqlop_core = declare_dependency(link_with : sciqlop_core_lib, | |
58 | include_directories : core_inc, |
|
60 | include_directories : core_inc, | |
59 | dependencies : [qt5core, qt5network]) |
|
61 | dependencies : [qt5core, qt5network]) | |
60 |
|
62 | |||
61 |
|
63 | |||
62 | subdir('tests') |
|
64 | subdir('tests') | |
63 |
|
65 |
@@ -1,6 +1,7 | |||||
1 | #include "Common/MimeTypesDef.h" |
|
1 | #include "Common/MimeTypesDef.h" | |
2 |
|
2 | |||
3 | const QString MIME_TYPE_GRAPH = QStringLiteral("scqlop/graph"); |
|
3 | const QString MIME_TYPE_GRAPH = QStringLiteral("scqlop/graph"); | |
4 | const QString MIME_TYPE_ZONE = QStringLiteral("scqlop/zone"); |
|
4 | const QString MIME_TYPE_ZONE = QStringLiteral("scqlop/zone"); | |
5 | const QString MIME_TYPE_VARIABLE_LIST = QStringLiteral("scqlop/var-list"); |
|
5 | const QString MIME_TYPE_VARIABLE_LIST = QStringLiteral("scqlop/var-list"); | |
|
6 | const QString MIME_TYPE_PRODUCT_LIST = QStringLiteral("scqlop/product-list"); | |||
6 | const QString MIME_TYPE_TIME_RANGE = QStringLiteral("scqlop/time-range"); |
|
7 | const QString MIME_TYPE_TIME_RANGE = QStringLiteral("scqlop/time-range"); |
@@ -1,176 +1,185 | |||||
1 | #include <DataSource/DataSourceItem.h> |
|
1 | #include <DataSource/DataSourceItem.h> | |
2 | #include <DataSource/DataSourceItemAction.h> |
|
2 | #include <DataSource/DataSourceItemAction.h> | |
3 | #include <DataSource/DataSourceTreeWidgetItem.h> |
|
3 | #include <DataSource/DataSourceTreeWidgetItem.h> | |
4 |
|
4 | |||
5 | #include <QAction> |
|
5 | #include <QAction> | |
6 |
|
6 | |||
7 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") |
|
7 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") | |
8 |
|
8 | |||
9 | namespace { |
|
9 | namespace { | |
10 |
|
10 | |||
11 | // Column indexes |
|
11 | // Column indexes | |
12 | const auto NAME_COLUMN = 0; |
|
12 | const auto NAME_COLUMN = 0; | |
13 |
|
13 | |||
14 | QIcon itemIcon(const DataSourceItem *dataSource) |
|
14 | QIcon itemIcon(const DataSourceItem *dataSource) | |
15 | { |
|
15 | { | |
16 | if (dataSource) { |
|
16 | if (dataSource) { | |
17 | auto dataSourceType = dataSource->type(); |
|
17 | auto dataSourceType = dataSource->type(); | |
18 | switch (dataSourceType) { |
|
18 | switch (dataSourceType) { | |
19 | case DataSourceItemType::NODE: { |
|
19 | case DataSourceItemType::NODE: { | |
20 | return dataSource->isRoot() ? QIcon{":/icones/dataSourceRoot.png"} |
|
20 | return dataSource->isRoot() ? QIcon{":/icones/dataSourceRoot.png"} | |
21 | : QIcon{":/icones/dataSourceNode.png"}; |
|
21 | : QIcon{":/icones/dataSourceNode.png"}; | |
22 | } |
|
22 | } | |
23 | case DataSourceItemType::PRODUCT: |
|
23 | case DataSourceItemType::PRODUCT: | |
24 | return QIcon{":/icones/dataSourceProduct.png"}; |
|
24 | return QIcon{":/icones/dataSourceProduct.png"}; | |
25 | case DataSourceItemType::COMPONENT: |
|
25 | case DataSourceItemType::COMPONENT: | |
26 | return QIcon{":/icones/dataSourceComponent.png"}; |
|
26 | return QIcon{":/icones/dataSourceComponent.png"}; | |
27 | default: |
|
27 | default: | |
28 | // No action |
|
28 | // No action | |
29 | break; |
|
29 | break; | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | qCWarning(LOG_DataSourceTreeWidgetItem()) |
|
32 | qCWarning(LOG_DataSourceTreeWidgetItem()) | |
33 | << QObject::tr("Can't set data source icon : unknown data source type"); |
|
33 | << QObject::tr("Can't set data source icon : unknown data source type"); | |
34 | } |
|
34 | } | |
35 | else { |
|
35 | else { | |
36 | qCCritical(LOG_DataSourceTreeWidgetItem()) |
|
36 | qCCritical(LOG_DataSourceTreeWidgetItem()) | |
37 | << QObject::tr("Can't set data source icon : the data source is null"); |
|
37 | << QObject::tr("Can't set data source icon : the data source is null"); | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | // Default cases |
|
40 | // Default cases | |
41 | return QIcon{}; |
|
41 | return QIcon{}; | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | /// @return the tooltip text for a variant. The text depends on whether the data is a simple variant |
|
44 | /// @return the tooltip text for a variant. The text depends on whether the data is a simple variant | |
45 | /// or a list of variants |
|
45 | /// or a list of variants | |
46 | QString tooltipValue(const QVariant &variant) noexcept |
|
46 | QString tooltipValue(const QVariant &variant) noexcept | |
47 | { |
|
47 | { | |
48 | // If the variant is a list of variants, the text of the tooltip is of the form: {val1, val2, |
|
48 | // If the variant is a list of variants, the text of the tooltip is of the form: {val1, val2, | |
49 | // ...} |
|
49 | // ...} | |
50 | if (variant.canConvert<QVariantList>()) { |
|
50 | if (variant.canConvert<QVariantList>()) { | |
51 | auto valueString = QStringLiteral("{"); |
|
51 | auto valueString = QStringLiteral("{"); | |
52 |
|
52 | |||
53 | auto variantList = variant.value<QVariantList>(); |
|
53 | auto variantList = variant.value<QVariantList>(); | |
54 | for (auto it = variantList.cbegin(), end = variantList.cend(); it != end; ++it) { |
|
54 | for (auto it = variantList.cbegin(), end = variantList.cend(); it != end; ++it) { | |
55 | valueString.append(it->toString()); |
|
55 | valueString.append(it->toString()); | |
56 |
|
56 | |||
57 | if (std::distance(it, end) != 1) { |
|
57 | if (std::distance(it, end) != 1) { | |
58 | valueString.append(", "); |
|
58 | valueString.append(", "); | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | valueString.append(QStringLiteral("}")); |
|
62 | valueString.append(QStringLiteral("}")); | |
63 |
|
63 | |||
64 | return valueString; |
|
64 | return valueString; | |
65 | } |
|
65 | } | |
66 | else { |
|
66 | else { | |
67 | return variant.toString(); |
|
67 | return variant.toString(); | |
68 | } |
|
68 | } | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | QString itemTooltip(const DataSourceItem *dataSource) noexcept |
|
71 | QString itemTooltip(const DataSourceItem *dataSource) noexcept | |
72 | { |
|
72 | { | |
73 | // The tooltip displays all item's data |
|
73 | // The tooltip displays all item's data | |
74 | if (dataSource) { |
|
74 | if (dataSource) { | |
75 | auto result = QString{}; |
|
75 | auto result = QString{}; | |
76 |
|
76 | |||
77 | const auto &data = dataSource->data(); |
|
77 | const auto &data = dataSource->data(); | |
78 | for (auto it = data.cbegin(), end = data.cend(); it != end; ++it) { |
|
78 | for (auto it = data.cbegin(), end = data.cend(); it != end; ++it) { | |
79 | result.append(QString{"<b>%1:</b> %2<br/>"}.arg(it.key(), tooltipValue(it.value()))); |
|
79 | result.append(QString{"<b>%1:</b> %2<br/>"}.arg(it.key(), tooltipValue(it.value()))); | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | return result; |
|
82 | return result; | |
83 | } |
|
83 | } | |
84 | else { |
|
84 | else { | |
85 | qCCritical(LOG_DataSourceTreeWidgetItem()) |
|
85 | qCCritical(LOG_DataSourceTreeWidgetItem()) | |
86 | << QObject::tr("Can't set data source tooltip : the data source is null"); |
|
86 | << QObject::tr("Can't set data source tooltip : the data source is null"); | |
87 |
|
87 | |||
88 | return QString{}; |
|
88 | return QString{}; | |
89 | } |
|
89 | } | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | } // namespace |
|
92 | } // namespace | |
93 |
|
93 | |||
94 | struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate { |
|
94 | struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate { | |
95 | explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {} |
|
95 | explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {} | |
96 |
|
96 | |||
97 | /// Model used to retrieve data source information |
|
97 | /// Model used to retrieve data source information | |
98 | const DataSourceItem *m_Data; |
|
98 | const DataSourceItem *m_Data; | |
99 | /// Actions associated to the item. The parent of the item (QTreeWidget) takes the ownership of |
|
99 | /// Actions associated to the item. The parent of the item (QTreeWidget) takes the ownership of | |
100 | /// the actions |
|
100 | /// the actions | |
101 | QList<QAction *> m_Actions; |
|
101 | QList<QAction *> m_Actions; | |
102 | }; |
|
102 | }; | |
103 |
|
103 | |||
104 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) |
|
104 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) | |
105 | : DataSourceTreeWidgetItem{nullptr, data, type} |
|
105 | : DataSourceTreeWidgetItem{nullptr, data, type} | |
106 | { |
|
106 | { | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data, |
|
109 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data, | |
110 | int type) |
|
110 | int type) | |
111 | : QTreeWidgetItem{parent, type}, |
|
111 | : QTreeWidgetItem{parent, type}, | |
112 | impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)} |
|
112 | impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)} | |
113 | { |
|
113 | { | |
114 | // Sets the icon and the tooltip depending on the data source |
|
114 | // Sets the icon and the tooltip depending on the data source | |
115 | setIcon(0, itemIcon(impl->m_Data)); |
|
115 | setIcon(0, itemIcon(impl->m_Data)); | |
116 | setToolTip(0, itemTooltip(impl->m_Data)); |
|
116 | setToolTip(0, itemTooltip(impl->m_Data)); | |
117 |
|
117 | |||
118 | // Generates tree actions based on the item actions |
|
118 | // Generates tree actions based on the item actions | |
119 | auto createTreeAction = [this, &parent](const auto &itemAction) { |
|
119 | auto createTreeAction = [this, &parent](const auto &itemAction) { | |
120 | auto treeAction = new QAction{itemAction->name(), parent}; |
|
120 | auto treeAction = new QAction{itemAction->name(), parent}; | |
121 |
|
121 | |||
122 | // Executes item action when tree action is triggered |
|
122 | // Executes item action when tree action is triggered | |
123 | QObject::connect(treeAction, &QAction::triggered, itemAction, |
|
123 | QObject::connect(treeAction, &QAction::triggered, itemAction, | |
124 | &DataSourceItemAction::execute); |
|
124 | &DataSourceItemAction::execute); | |
125 |
|
125 | |||
126 | return treeAction; |
|
126 | return treeAction; | |
127 | }; |
|
127 | }; | |
128 |
|
128 | |||
129 | auto itemActions = impl->m_Data->actions(); |
|
129 | auto itemActions = impl->m_Data->actions(); | |
130 | std::transform(std::cbegin(itemActions), std::cend(itemActions), |
|
130 | std::transform(std::cbegin(itemActions), std::cend(itemActions), | |
131 | std::back_inserter(impl->m_Actions), createTreeAction); |
|
131 | std::back_inserter(impl->m_Actions), createTreeAction); | |
|
132 | ||||
|
133 | // Sets the flags of the items | |||
|
134 | auto flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; | |||
|
135 | if (data->type() == DataSourceItemType::COMPONENT | |||
|
136 | || data->type() == DataSourceItemType::PRODUCT) { | |||
|
137 | flags |= Qt::ItemIsDragEnabled; | |||
|
138 | } | |||
|
139 | ||||
|
140 | setFlags(flags); | |||
132 | } |
|
141 | } | |
133 |
|
142 | |||
134 | const DataSourceItem *DataSourceTreeWidgetItem::data() const |
|
143 | const DataSourceItem *DataSourceTreeWidgetItem::data() const | |
135 | { |
|
144 | { | |
136 | return impl->m_Data; |
|
145 | return impl->m_Data; | |
137 | } |
|
146 | } | |
138 |
|
147 | |||
139 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const |
|
148 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const | |
140 | { |
|
149 | { | |
141 | if (role == Qt::DisplayRole) { |
|
150 | if (role == Qt::DisplayRole) { | |
142 | if (impl->m_Data) { |
|
151 | if (impl->m_Data) { | |
143 | switch (column) { |
|
152 | switch (column) { | |
144 | case NAME_COLUMN: |
|
153 | case NAME_COLUMN: | |
145 | return impl->m_Data->name(); |
|
154 | return impl->m_Data->name(); | |
146 | default: |
|
155 | default: | |
147 | // No action |
|
156 | // No action | |
148 | break; |
|
157 | break; | |
149 | } |
|
158 | } | |
150 |
|
159 | |||
151 | qCWarning(LOG_DataSourceTreeWidgetItem()) |
|
160 | qCWarning(LOG_DataSourceTreeWidgetItem()) | |
152 | << QObject::tr("Can't get data (unknown column %1)").arg(column); |
|
161 | << QObject::tr("Can't get data (unknown column %1)").arg(column); | |
153 | } |
|
162 | } | |
154 | else { |
|
163 | else { | |
155 | qCCritical(LOG_DataSourceTreeWidgetItem()) << QObject::tr("Can't get data (null item)"); |
|
164 | qCCritical(LOG_DataSourceTreeWidgetItem()) << QObject::tr("Can't get data (null item)"); | |
156 | } |
|
165 | } | |
157 |
|
166 | |||
158 | return QVariant{}; |
|
167 | return QVariant{}; | |
159 | } |
|
168 | } | |
160 | else { |
|
169 | else { | |
161 | return QTreeWidgetItem::data(column, role); |
|
170 | return QTreeWidgetItem::data(column, role); | |
162 | } |
|
171 | } | |
163 | } |
|
172 | } | |
164 |
|
173 | |||
165 | void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value) |
|
174 | void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value) | |
166 | { |
|
175 | { | |
167 | // Data can't be changed by edition |
|
176 | // Data can't be changed by edition | |
168 | if (role != Qt::EditRole) { |
|
177 | if (role != Qt::EditRole) { | |
169 | QTreeWidgetItem::setData(column, role, value); |
|
178 | QTreeWidgetItem::setData(column, role, value); | |
170 | } |
|
179 | } | |
171 | } |
|
180 | } | |
172 |
|
181 | |||
173 | QList<QAction *> DataSourceTreeWidgetItem::actions() const noexcept |
|
182 | QList<QAction *> DataSourceTreeWidgetItem::actions() const noexcept | |
174 | { |
|
183 | { | |
175 | return impl->m_Actions; |
|
184 | return impl->m_Actions; | |
176 | } |
|
185 | } |
@@ -1,33 +1,46 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>DataSourceWidget</class> |
|
3 | <class>DataSourceWidget</class> | |
4 | <widget class="QWidget" name="DataSourceWidget"> |
|
4 | <widget class="QWidget" name="DataSourceWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>400</width> |
|
9 | <width>400</width> | |
10 | <height>300</height> |
|
10 | <height>300</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Data sources</string> |
|
14 | <string>Data sources</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QGridLayout" name="gridLayout"> |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
17 | <item row="0" column="0"> |
|
17 | <item row="0" column="0"> | |
18 | <widget class="QLineEdit" name="filterLineEdit"/> |
|
18 | <widget class="QLineEdit" name="filterLineEdit"/> | |
19 | </item> |
|
19 | </item> | |
20 | <item row="1" column="0"> |
|
20 | <item row="1" column="0"> | |
21 |
<widget class=" |
|
21 | <widget class="DataSourceTreeWidget" name="treeWidget"> | |
|
22 | <property name="dragEnabled"> | |||
|
23 | <bool>true</bool> | |||
|
24 | </property> | |||
|
25 | <property name="dragDropMode"> | |||
|
26 | <enum>QAbstractItemView::DragOnly</enum> | |||
|
27 | </property> | |||
22 | <column> |
|
28 | <column> | |
23 | <property name="text"> |
|
29 | <property name="text"> | |
24 | <string notr="true">1</string> |
|
30 | <string notr="true">1</string> | |
25 | </property> |
|
31 | </property> | |
26 | </column> |
|
32 | </column> | |
27 | </widget> |
|
33 | </widget> | |
28 | </item> |
|
34 | </item> | |
29 | </layout> |
|
35 | </layout> | |
30 | </widget> |
|
36 | </widget> | |
|
37 | <customwidgets> | |||
|
38 | <customwidget> | |||
|
39 | <class>DataSourceTreeWidget</class> | |||
|
40 | <extends>QTreeWidget</extends> | |||
|
41 | <header>DataSource/DataSourceTreeWidget.h</header> | |||
|
42 | </customwidget> | |||
|
43 | </customwidgets> | |||
31 | <resources/> |
|
44 | <resources/> | |
32 | <connections/> |
|
45 | <connections/> | |
33 | </ui> |
|
46 | </ui> |
@@ -1,37 +1,40 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>VariableInspectorWidget</class> |
|
3 | <class>VariableInspectorWidget</class> | |
4 | <widget class="QWidget" name="VariableInspectorWidget"> |
|
4 | <widget class="QWidget" name="VariableInspectorWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>400</width> |
|
9 | <width>400</width> | |
10 | <height>300</height> |
|
10 | <height>300</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Variables</string> |
|
14 | <string>Variables</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QGridLayout" name="gridLayout"> |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
17 | <item row="0" column="0"> |
|
17 | <item row="0" column="0"> | |
18 | <widget class="QTableView" name="tableView"> |
|
18 | <widget class="QTableView" name="tableView"> | |
|
19 | <property name="acceptDrops"> | |||
|
20 | <bool>true</bool> | |||
|
21 | </property> | |||
19 | <property name="dragEnabled"> |
|
22 | <property name="dragEnabled"> | |
20 | <bool>true</bool> |
|
23 | <bool>true</bool> | |
21 | </property> |
|
24 | </property> | |
22 | <property name="dragDropMode"> |
|
25 | <property name="dragDropMode"> | |
23 | <enum>QAbstractItemView::DragDrop</enum> |
|
26 | <enum>QAbstractItemView::DragDrop</enum> | |
24 | </property> |
|
27 | </property> | |
25 | <property name="sortingEnabled"> |
|
28 | <property name="sortingEnabled"> | |
26 | <bool>true</bool> |
|
29 | <bool>true</bool> | |
27 | </property> |
|
30 | </property> | |
28 | <attribute name="horizontalHeaderStretchLastSection"> |
|
31 | <attribute name="horizontalHeaderStretchLastSection"> | |
29 | <bool>true</bool> |
|
32 | <bool>true</bool> | |
30 | </attribute> |
|
33 | </attribute> | |
31 | </widget> |
|
34 | </widget> | |
32 | </item> |
|
35 | </item> | |
33 | </layout> |
|
36 | </layout> | |
34 | </widget> |
|
37 | </widget> | |
35 | <resources/> |
|
38 | <resources/> | |
36 | <connections/> |
|
39 | <connections/> | |
37 | </ui> |
|
40 | </ui> |
General Comments 0
You need to be logged in to leave comments.
Login now