Auto status change to "Under Review"
@@ -12,6 +12,8 public: | |||||
12 | CatalogueTreeWidgetItem(DBCatalogue catalogue, int type = QTreeWidgetItem::Type); |
|
12 | CatalogueTreeWidgetItem(DBCatalogue catalogue, int type = QTreeWidgetItem::Type); | |
13 |
|
13 | |||
14 | QVariant data(int column, int role) const override; |
|
14 | QVariant data(int column, int role) const override; | |
|
15 | void setData(int column, int role, const QVariant &value) override; | |||
|
16 | ||||
15 | DBCatalogue catalogue() const; |
|
17 | DBCatalogue catalogue() const; | |
16 |
|
18 | |||
17 | private: |
|
19 | private: |
@@ -12,11 +12,13 CatalogueTreeWidgetItem::CatalogueTreeWidgetItem(DBCatalogue catalogue, int type | |||||
12 | : QTreeWidgetItem(type), |
|
12 | : QTreeWidgetItem(type), | |
13 | impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)} |
|
13 | impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)} | |
14 | { |
|
14 | { | |
|
15 | setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable); | |||
15 | } |
|
16 | } | |
16 |
|
17 | |||
17 | QVariant CatalogueTreeWidgetItem::data(int column, int role) const |
|
18 | QVariant CatalogueTreeWidgetItem::data(int column, int role) const | |
18 | { |
|
19 | { | |
19 | switch (role) { |
|
20 | switch (role) { | |
|
21 | case Qt::EditRole: // fallthrough | |||
20 | case Qt::DisplayRole: |
|
22 | case Qt::DisplayRole: | |
21 | return impl->m_Catalogue.getName(); |
|
23 | return impl->m_Catalogue.getName(); | |
22 | default: |
|
24 | default: | |
@@ -26,6 +28,18 QVariant CatalogueTreeWidgetItem::data(int column, int role) const | |||||
26 | return QTreeWidgetItem::data(column, role); |
|
28 | return QTreeWidgetItem::data(column, role); | |
27 | } |
|
29 | } | |
28 |
|
30 | |||
|
31 | void CatalogueTreeWidgetItem::setData(int column, int role, const QVariant &value) | |||
|
32 | { | |||
|
33 | if (role == Qt::EditRole && column == 0) { | |||
|
34 | auto newName = value.toString(); | |||
|
35 | setText(0, newName); | |||
|
36 | impl->m_Catalogue.setName(newName); | |||
|
37 | } | |||
|
38 | else { | |||
|
39 | QTreeWidgetItem::setData(column, role, value); | |||
|
40 | } | |||
|
41 | } | |||
|
42 | ||||
29 | DBCatalogue CatalogueTreeWidgetItem::catalogue() const |
|
43 | DBCatalogue CatalogueTreeWidgetItem::catalogue() const | |
30 | { |
|
44 | { | |
31 | return impl->m_Catalogue; |
|
45 | return impl->m_Catalogue; |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now