@@ -1,4 +1,5 | |||||
1 | #include <DataSource/DataSourceItem.h> |
|
1 | #include <DataSource/DataSourceItem.h> | |
|
2 | #include <DataSource/DataSourceItemAction.h> | |||
2 | #include <DataSource/DataSourceTreeWidgetItem.h> |
|
3 | #include <DataSource/DataSourceTreeWidgetItem.h> | |
3 |
|
4 | |||
4 | #include <SqpApplication.h> |
|
5 | #include <SqpApplication.h> | |
@@ -60,7 +61,20 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const Da | |||||
60 | // Sets the icon depending on the data source |
|
61 | // Sets the icon depending on the data source | |
61 | setIcon(0, itemIcon(impl->m_Data)); |
|
62 | setIcon(0, itemIcon(impl->m_Data)); | |
62 |
|
63 | |||
63 |
// |
|
64 | // Generates tree actions based on the item actions | |
|
65 | auto createTreeAction = [this, &parent](const auto &itemAction) { | |||
|
66 | auto treeAction = new QAction{itemAction->name(), parent}; | |||
|
67 | ||||
|
68 | // Executes item action when tree action is triggered | |||
|
69 | QObject::connect(treeAction, &QAction::triggered, itemAction, | |||
|
70 | &DataSourceItemAction::execute); | |||
|
71 | ||||
|
72 | return treeAction; | |||
|
73 | }; | |||
|
74 | ||||
|
75 | auto itemActions = impl->m_Data->actions(); | |||
|
76 | std::transform(std::cbegin(itemActions), std::cend(itemActions), | |||
|
77 | std::back_inserter(impl->m_Actions), createTreeAction); | |||
64 | } |
|
78 | } | |
65 |
|
79 | |||
66 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const |
|
80 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const |
General Comments 0
You need to be logged in to leave comments.
Login now