@@ -24,6 +24,9 public: | |||||
24 | virtual QVariant data(int column, int role) const override; |
|
24 | virtual QVariant data(int column, int role) const override; | |
25 | virtual void setData(int column, int role, const QVariant &value) override; |
|
25 | virtual void setData(int column, int role, const QVariant &value) override; | |
26 |
|
26 | |||
|
27 | /// @return the actions associated to the item | |||
|
28 | QList<QAction *> actions() const noexcept; | |||
|
29 | ||||
27 | private: |
|
30 | private: | |
28 | class DataSourceTreeWidgetItemPrivate; |
|
31 | class DataSourceTreeWidgetItemPrivate; | |
29 | spimpl::unique_impl_ptr<DataSourceTreeWidgetItemPrivate> impl; |
|
32 | spimpl::unique_impl_ptr<DataSourceTreeWidgetItemPrivate> impl; |
@@ -3,6 +3,8 | |||||
3 |
|
3 | |||
4 | #include <SqpApplication.h> |
|
4 | #include <SqpApplication.h> | |
5 |
|
5 | |||
|
6 | #include <QAction> | |||
|
7 | ||||
6 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") |
|
8 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") | |
7 |
|
9 | |||
8 | namespace { |
|
10 | namespace { | |
@@ -40,6 +42,9 struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate { | |||||
40 |
|
42 | |||
41 | /// Model used to retrieve data source information |
|
43 | /// Model used to retrieve data source information | |
42 | const DataSourceItem *m_Data; |
|
44 | const DataSourceItem *m_Data; | |
|
45 | /// Actions associated to the item. The parent of the item (QTreeWidget) takes the ownership of | |||
|
46 | /// the actions | |||
|
47 | QList<QAction *> m_Actions; | |||
43 | }; |
|
48 | }; | |
44 |
|
49 | |||
45 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) |
|
50 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) | |
@@ -54,6 +59,8 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const Da | |||||
54 | { |
|
59 | { | |
55 | // Sets the icon depending on the data source |
|
60 | // Sets the icon depending on the data source | |
56 | setIcon(0, itemIcon(impl->m_Data)); |
|
61 | setIcon(0, itemIcon(impl->m_Data)); | |
|
62 | ||||
|
63 | /// @todo ALX : generate actions based on the DataSourceItem (model) | |||
57 | } |
|
64 | } | |
58 |
|
65 | |||
59 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const |
|
66 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const | |
@@ -73,3 +80,8 void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &val | |||||
73 | QTreeWidgetItem::setData(column, role, value); |
|
80 | QTreeWidgetItem::setData(column, role, value); | |
74 | } |
|
81 | } | |
75 | } |
|
82 | } | |
|
83 | ||||
|
84 | QList<QAction *> DataSourceTreeWidgetItem::actions() const noexcept | |||
|
85 | { | |||
|
86 | return impl->m_Actions; | |||
|
87 | } |
General Comments 0
You need to be logged in to leave comments.
Login now