##// END OF EJS Templates
Adaptation to the shared pointers of catalogue controller
trabillard -
r1143:20294bb49a24
parent child
Show More
@@ -41,8 +41,7 public:
41 std::list<std::shared_ptr<DBEvent> > retrieveEvents(const QString &repository) const;
41 std::list<std::shared_ptr<DBEvent> > retrieveEvents(const QString &repository) const;
42 std::list<std::shared_ptr<DBEvent> > retrieveAllEvents() const;
42 std::list<std::shared_ptr<DBEvent> > retrieveAllEvents() const;
43 std::list<std::shared_ptr<DBEvent> >
43 std::list<std::shared_ptr<DBEvent> >
44 retrieveEventsFromCatalogue(const QString &repository,
44 retrieveEventsFromCatalogue(std::shared_ptr<DBCatalogue> catalogue) const;
45 std::shared_ptr<DBCatalogue> catalogue) const;
46 // void updateEvent(std::shared_ptr<DBEvent> event);
45 // void updateEvent(std::shared_ptr<DBEvent> event);
47 // void trashEvent(std::shared_ptr<DBEvent> event);
46 // void trashEvent(std::shared_ptr<DBEvent> event);
48 // void removeEvent(std::shared_ptr<DBEvent> event);
47 // void removeEvent(std::shared_ptr<DBEvent> event);
@@ -103,8 +103,7 std::list<std::shared_ptr<DBEvent> > CatalogueController::retrieveAllEvents() co
103 }
103 }
104
104
105 std::list<std::shared_ptr<DBEvent> >
105 std::list<std::shared_ptr<DBEvent> >
106 CatalogueController::retrieveEventsFromCatalogue(const QString &repository,
106 CatalogueController::retrieveEventsFromCatalogue(std::shared_ptr<DBCatalogue> catalogue) const
107 std::shared_ptr<DBCatalogue> catalogue) const
108 {
107 {
109 auto eventsShared = std::list<std::shared_ptr<DBEvent> >{};
108 auto eventsShared = std::list<std::shared_ptr<DBEvent> >{};
110 auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue);
109 auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue);
@@ -4,17 +4,17
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QAbstractTableModel>
5 #include <QAbstractTableModel>
6
6
7 #include <DBEvent.h>
7 class DBEvent;
8
8
9 class CatalogueEventsTableModel : public QAbstractTableModel {
9 class CatalogueEventsTableModel : public QAbstractTableModel {
10 public:
10 public:
11 CatalogueEventsTableModel(QObject *parent = nullptr);
11 CatalogueEventsTableModel(QObject *parent = nullptr);
12
12
13 void setEvents(const QVector<DBEvent> &events);
13 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events);
14 DBEvent getEvent(int row) const;
14 std::shared_ptr<DBEvent> getEvent(int row) const;
15
15
16 void addEvent(const DBEvent &events);
16 void addEvent(const std::shared_ptr<DBEvent> &events);
17 void removeEvent(const DBEvent &events);
17 void removeEvent(const std::shared_ptr<DBEvent> &events);
18
18
19 // Model
19 // Model
20 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
20 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -19,7 +19,7 class CatalogueEventsWidget : public QWidget {
19 Q_OBJECT
19 Q_OBJECT
20
20
21 signals:
21 signals:
22 void eventsSelected(const QVector<DBEvent> &event);
22 void eventsSelected(const QVector<std::shared_ptr<DBEvent> > &event);
23
23
24 public:
24 public:
25 explicit CatalogueEventsWidget(QWidget *parent = 0);
25 explicit CatalogueEventsWidget(QWidget *parent = 0);
@@ -28,7 +28,7 public:
28 void setVisualizationWidget(VisualizationWidget *visualization);
28 void setVisualizationWidget(VisualizationWidget *visualization);
29
29
30 public slots:
30 public slots:
31 void populateWithCatalogues(const QVector<DBCatalogue> &catalogues);
31 void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
32
32
33 private:
33 private:
34 Ui::CatalogueEventsWidget *ui;
34 Ui::CatalogueEventsWidget *ui;
@@ -2,6 +2,7
2 #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H
2 #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5 #include <memory>
5
6
6 namespace Ui {
7 namespace Ui {
7 class CatalogueInspectorWidget;
8 class CatalogueInspectorWidget;
@@ -22,8 +23,8 public:
22
23
23 Page currentPage() const;
24 Page currentPage() const;
24
25
25 void setEvent(const DBEvent &event);
26 void setEvent(const std::shared_ptr<DBEvent> &event);
26 void setCatalogue(const DBCatalogue &catalogue);
27 void setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue);
27
28
28 public slots:
29 public slots:
29 void showPage(Page page);
30 void showPage(Page page);
@@ -5,7 +5,7
5 #include <QTreeWidgetItem>
5 #include <QTreeWidgetItem>
6 #include <QWidget>
6 #include <QWidget>
7
7
8 #include <DBCatalogue.h>
8 class DBCatalogue;
9
9
10 namespace Ui {
10 namespace Ui {
11 class CatalogueSideBarWidget;
11 class CatalogueSideBarWidget;
@@ -15,7 +15,7 class CatalogueSideBarWidget : public QWidget {
15 Q_OBJECT
15 Q_OBJECT
16
16
17 signals:
17 signals:
18 void catalogueSelected(const QVector<DBCatalogue> &catalogues);
18 void catalogueSelected(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
19 void databaseSelected(const QStringList &databases);
19 void databaseSelected(const QStringList &databases);
20 void allEventsSelected();
20 void allEventsSelected();
21 void trashSelected();
21 void trashSelected();
@@ -4,18 +4,19
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QTreeWidgetItem>
5 #include <QTreeWidgetItem>
6
6
7 #include <DBCatalogue.h>
7 class DBCatalogue;
8
8
9
9
10 class CatalogueTreeWidgetItem : public QTreeWidgetItem {
10 class CatalogueTreeWidgetItem : public QTreeWidgetItem {
11 public:
11 public:
12 CatalogueTreeWidgetItem(DBCatalogue catalogue, int type = QTreeWidgetItem::Type);
12 CatalogueTreeWidgetItem(std::shared_ptr<DBCatalogue> catalogue,
13 int type = QTreeWidgetItem::Type);
13
14
14 QVariant data(int column, int role) const override;
15 QVariant data(int column, int role) const override;
15 void setData(int column, int role, const QVariant &value) override;
16 void setData(int column, int role, const QVariant &value) override;
16
17
17 /// Returns the catalogue represented by the item
18 /// Returns the catalogue represented by the item
18 DBCatalogue catalogue() const;
19 std::shared_ptr<DBCatalogue> catalogue() const;
19
20
20 void setHasChanges(bool value);
21 void setHasChanges(bool value);
21
22
@@ -10,7 +10,7
10 #include <Time/TimeController.h>
10 #include <Time/TimeController.h>
11
11
12 struct CatalogueEventsTableModel::CatalogueEventsTableModelPrivate {
12 struct CatalogueEventsTableModel::CatalogueEventsTableModelPrivate {
13 QVector<DBEvent> m_Events;
13 QVector<std::shared_ptr<DBEvent> > m_Events;
14
14
15 enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn };
15 enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn };
16 QStringList columnNames()
16 QStringList columnNames()
@@ -18,20 +18,20 struct CatalogueEventsTableModel::CatalogueEventsTableModelPrivate {
18 return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), tr("Tags"), tr("Product")};
18 return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), tr("Tags"), tr("Product")};
19 }
19 }
20
20
21 QVariant eventData(int col, const DBEvent &event) const
21 QVariant eventData(int col, const std::shared_ptr<DBEvent> &event) const
22 {
22 {
23 switch (static_cast<Column>(col)) {
23 switch (static_cast<Column>(col)) {
24 case Column::Event:
24 case Column::Event:
25 return event.getName();
25 return event->getName();
26 case Column::TStart:
26 case Column::TStart:
27 return DateUtils::dateTime(event.getTStart());
27 return DateUtils::dateTime(event->getTStart());
28 case Column::TEnd:
28 case Column::TEnd:
29 return DateUtils::dateTime(event.getTEnd());
29 return DateUtils::dateTime(event->getTEnd());
30 case Column::Product:
30 case Column::Product:
31 return event.getProduct();
31 return event->getProduct();
32 case Column::Tags: {
32 case Column::Tags: {
33 QString tagList;
33 QString tagList;
34 auto tags = const_cast<DBEvent *>(&event)->getTags();
34 auto tags = event->getTags();
35 for (auto tag : tags) {
35 for (auto tag : tags) {
36 tagList += tag.getName();
36 tagList += tag.getName();
37 tagList += ' ';
37 tagList += ' ';
@@ -54,26 +54,26 CatalogueEventsTableModel::CatalogueEventsTableModel(QObject *parent)
54 {
54 {
55 }
55 }
56
56
57 void CatalogueEventsTableModel::setEvents(const QVector<DBEvent> &events)
57 void CatalogueEventsTableModel::setEvents(const QVector<std::shared_ptr<DBEvent> > &events)
58 {
58 {
59 beginResetModel();
59 beginResetModel();
60 impl->m_Events = events;
60 impl->m_Events = events;
61 endResetModel();
61 endResetModel();
62 }
62 }
63
63
64 DBEvent CatalogueEventsTableModel::getEvent(int row) const
64 std::shared_ptr<DBEvent> CatalogueEventsTableModel::getEvent(int row) const
65 {
65 {
66 return impl->m_Events.value(row);
66 return impl->m_Events.value(row);
67 }
67 }
68
68
69 void CatalogueEventsTableModel::addEvent(const DBEvent &events)
69 void CatalogueEventsTableModel::addEvent(const std::shared_ptr<DBEvent> &events)
70 {
70 {
71 beginInsertRows(QModelIndex(), impl->m_Events.count() - 1, impl->m_Events.count() - 1);
71 beginInsertRows(QModelIndex(), impl->m_Events.count() - 1, impl->m_Events.count() - 1);
72 // impl->m_Events.append(event); TODO
72 // impl->m_Events.append(event); TODO
73 endInsertRows();
73 endInsertRows();
74 }
74 }
75
75
76 void CatalogueEventsTableModel::removeEvent(const DBEvent &events)
76 void CatalogueEventsTableModel::removeEvent(const std::shared_ptr<DBEvent> &events)
77 {
77 {
78 // TODO
78 // TODO
79 auto index = -1; // impl->m_Events.indexOf(event);
79 auto index = -1; // impl->m_Events.indexOf(event);
@@ -155,7 +155,7 QMimeData *CatalogueEventsTableModel::mimeData(const QModelIndexList &indexes) c
155 {
155 {
156 auto mimeData = new QMimeData;
156 auto mimeData = new QMimeData;
157
157
158 QVector<DBEvent> eventList;
158 QVector<std::shared_ptr<DBEvent> > eventList;
159
159
160 SqpRange firstTimeRange;
160 SqpRange firstTimeRange;
161 for (const auto &index : indexes) {
161 for (const auto &index : indexes) {
@@ -163,8 +163,8 QMimeData *CatalogueEventsTableModel::mimeData(const QModelIndexList &indexes) c
163 auto event = getEvent(index.row());
163 auto event = getEvent(index.row());
164 if (eventList.isEmpty()) {
164 if (eventList.isEmpty()) {
165 // Gets the range of the first variable
165 // Gets the range of the first variable
166 firstTimeRange.m_TStart = event.getTStart();
166 firstTimeRange.m_TStart = event->getTStart();
167 firstTimeRange.m_TEnd = event.getTEnd();
167 firstTimeRange.m_TEnd = event->getTEnd();
168 }
168 }
169
169
170 eventList << event;
170 eventList << event;
@@ -27,21 +27,21 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
27
27
28 VisualizationWidget *m_VisualizationWidget = nullptr;
28 VisualizationWidget *m_VisualizationWidget = nullptr;
29
29
30 void setEvents(const QVector<DBEvent> &events, QTableView *tableView)
30 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events, QTableView *tableView)
31 {
31 {
32 tableView->setSortingEnabled(false);
32 tableView->setSortingEnabled(false);
33 m_Model->setEvents(events);
33 m_Model->setEvents(events);
34 tableView->setSortingEnabled(true);
34 tableView->setSortingEnabled(true);
35 }
35 }
36
36
37 void addEvent(const DBEvent &event, QTableView *tableView)
37 void addEvent(const std::shared_ptr<DBEvent> &event, QTableView *tableView)
38 {
38 {
39 tableView->setSortingEnabled(false);
39 tableView->setSortingEnabled(false);
40 m_Model->addEvent(event);
40 m_Model->addEvent(event);
41 tableView->setSortingEnabled(true);
41 tableView->setSortingEnabled(true);
42 }
42 }
43
43
44 void removeEvent(const DBEvent &event, QTableView *tableView)
44 void removeEvent(const std::shared_ptr<DBEvent> &event, QTableView *tableView)
45 {
45 {
46 tableView->setSortingEnabled(false);
46 tableView->setSortingEnabled(false);
47 m_Model->removeEvent(event);
47 m_Model->removeEvent(event);
@@ -143,8 +143,8 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
143 for (auto zoneName : m_ZonesForTimeMode) {
143 for (auto zoneName : m_ZonesForTimeMode) {
144 if (auto zone = tab->getZoneWithName(zoneName)) {
144 if (auto zone = tab->getZoneWithName(zoneName)) {
145 SqpRange eventRange;
145 SqpRange eventRange;
146 eventRange.m_TStart = event.getTStart();
146 eventRange.m_TStart = event->getTStart();
147 eventRange.m_TEnd = event.getTEnd();
147 eventRange.m_TEnd = event->getTEnd();
148 zone->setZoneRange(eventRange);
148 zone->setZoneRange(eventRange);
149 }
149 }
150 }
150 }
@@ -232,7 +232,7 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
232 });
232 });
233
233
234 auto emitSelection = [this]() {
234 auto emitSelection = [this]() {
235 QVector<DBEvent> events;
235 QVector<std::shared_ptr<DBEvent> > events;
236 for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) {
236 for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) {
237 events << impl->m_Model->getEvent(rowIndex.row());
237 events << impl->m_Model->getEvent(rowIndex.row());
238 }
238 }
@@ -271,19 +271,18 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualiz
271 impl->m_VisualizationWidget = visualization;
271 impl->m_VisualizationWidget = visualization;
272 }
272 }
273
273
274 void CatalogueEventsWidget::populateWithCatalogues(const QVector<DBCatalogue> &catalogues)
274 void CatalogueEventsWidget::populateWithCatalogues(
275 const QVector<std::shared_ptr<DBCatalogue> > &catalogues)
275 {
276 {
276 auto &dao = sqpApp->catalogueController().getDao();
277
278 QSet<QUuid> eventIds;
277 QSet<QUuid> eventIds;
279 QVector<DBEvent> events;
278 QVector<std::shared_ptr<DBEvent> > events;
280
279
281 for (auto catalogue : catalogues) {
280 for (auto catalogue : catalogues) {
282 auto catalogueEvents = dao.getCatalogueEvents(catalogue);
281 auto catalogueEvents = sqpApp->catalogueController().retrieveEventsFromCatalogue(catalogue);
283 for (auto event : catalogueEvents) {
282 for (auto event : catalogueEvents) {
284 if (!eventIds.contains(event.getUniqId())) {
283 if (!eventIds.contains(event->getUniqId())) {
285 events << event;
284 events << event;
286 eventIds.insert(event.getUniqId());
285 eventIds.insert(event->getUniqId());
287 }
286 }
288 }
287 }
289 }
288 }
@@ -28,15 +28,15 CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const
28 return static_cast<Page>(ui->stackedWidget->currentIndex());
28 return static_cast<Page>(ui->stackedWidget->currentIndex());
29 }
29 }
30
30
31 void CatalogueInspectorWidget::setEvent(const DBEvent &event)
31 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event)
32 {
32 {
33 showPage(Page::EventProperties);
33 showPage(Page::EventProperties);
34 ui->leEventName->setText(event.getName());
34 ui->leEventName->setText(event->getName());
35 ui->leEventMission->setText(event.getMission());
35 ui->leEventMission->setText(event->getMission());
36 ui->leEventProduct->setText(event.getProduct());
36 ui->leEventProduct->setText(event->getProduct());
37
37
38 QString tagList;
38 QString tagList;
39 auto tags = const_cast<DBEvent *>(&event)->getTags();
39 auto tags = event->getTags();
40 for (auto tag : tags) {
40 for (auto tag : tags) {
41 tagList += tag.getName();
41 tagList += tag.getName();
42 tagList += ' ';
42 tagList += ' ';
@@ -44,13 +44,13 void CatalogueInspectorWidget::setEvent(const DBEvent &event)
44
44
45 ui->leEventTags->setText(tagList);
45 ui->leEventTags->setText(tagList);
46
46
47 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event.getTStart()));
47 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart()));
48 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event.getTEnd()));
48 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd()));
49 }
49 }
50
50
51 void CatalogueInspectorWidget::setCatalogue(const DBCatalogue &catalogue)
51 void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue)
52 {
52 {
53 showPage(Page::CatalogueProperties);
53 showPage(Page::CatalogueProperties);
54 ui->leCatalogueName->setText(catalogue.getName());
54 ui->leCatalogueName->setText(catalogue->getName());
55 ui->leCatalogueAuthor->setText(catalogue.getAuthor());
55 ui->leCatalogueAuthor->setText(catalogue->getAuthor());
56 }
56 }
@@ -19,12 +19,11 constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3;
19
19
20 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
20 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
21
21
22 QHash<QTreeWidgetItem *, DBCatalogue> m_CatalogueMap;
23
24 void configureTreeWidget(QTreeWidget *treeWidget);
22 void configureTreeWidget(QTreeWidget *treeWidget);
25 QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget);
23 QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget);
26 QTreeWidgetItem *getDatabaseItem(const QString &name, QTreeWidget *treeWidget);
24 QTreeWidgetItem *getDatabaseItem(const QString &name, QTreeWidget *treeWidget);
27 void addCatalogueItem(const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem);
25 void addCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue,
26 QTreeWidgetItem *parentDatabaseItem);
28 };
27 };
29
28
30 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
29 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
@@ -47,7 +46,7 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
47 emit this->selectionCleared();
46 emit this->selectionCleared();
48 }
47 }
49 else {
48 else {
50 QVector<DBCatalogue> catalogues;
49 QVector<std::shared_ptr<DBCatalogue> > catalogues;
51 QStringList databases;
50 QStringList databases;
52 int selectionType = selectedItems.first()->type();
51 int selectionType = selectedItems.first()->type();
53
52
@@ -155,13 +154,9 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget(
155 treeWidget->addTopLevelItem(separatorItem);
154 treeWidget->addTopLevelItem(separatorItem);
156 treeWidget->setItemWidget(separatorItem, 0, separator);
155 treeWidget->setItemWidget(separatorItem, 0, separator);
157
156
158 auto &dao = sqpApp->catalogueController().getDao();
159 auto allPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, "-1",
160 ComparaisonOperation::DIFFERENT);
161
162 auto db = addDatabaseItem("Default", treeWidget);
157 auto db = addDatabaseItem("Default", treeWidget);
163
158
164 auto catalogues = dao.getCatalogues(allPredicate);
159 auto catalogues = sqpApp->catalogueController().getCatalogues("Default");
165 for (auto catalogue : catalogues) {
160 for (auto catalogue : catalogues) {
166 addCatalogueItem(catalogue, db);
161 addCatalogueItem(catalogue, db);
167 }
162 }
@@ -195,7 +190,7 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getDatabaseItem(const QSt
195 }
190 }
196
191
197 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem(
192 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem(
198 const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem)
193 const std::shared_ptr<DBCatalogue> &catalogue, QTreeWidgetItem *parentDatabaseItem)
199 {
194 {
200 auto catalogueItem = new CatalogueTreeWidgetItem{catalogue, CATALOGUE_ITEM_TYPE};
195 auto catalogueItem = new CatalogueTreeWidgetItem{catalogue, CATALOGUE_ITEM_TYPE};
201 catalogueItem->setIcon(0, QIcon{":/icones/catalogue.png"});
196 catalogueItem->setIcon(0, QIcon{":/icones/catalogue.png"});
@@ -2,6 +2,7
2
2
3 #include <memory>
3 #include <memory>
4
4
5 #include <DBCatalogue.h>
5 #include <QBoxLayout>
6 #include <QBoxLayout>
6 #include <QToolButton>
7 #include <QToolButton>
7
8
@@ -9,13 +10,15 const auto VALIDATION_BUTTON_ICON_SIZE = 12;
9
10
10 struct CatalogueTreeWidgetItem::CatalogueTreeWidgetItemPrivate {
11 struct CatalogueTreeWidgetItem::CatalogueTreeWidgetItemPrivate {
11
12
12 DBCatalogue m_Catalogue;
13 std::shared_ptr<DBCatalogue> m_Catalogue;
13
14
14 CatalogueTreeWidgetItemPrivate(DBCatalogue catalogue) : m_Catalogue(catalogue) {}
15 CatalogueTreeWidgetItemPrivate(std::shared_ptr<DBCatalogue> catalogue) : m_Catalogue(catalogue)
16 {
17 }
15 };
18 };
16
19
17
20
18 CatalogueTreeWidgetItem::CatalogueTreeWidgetItem(DBCatalogue catalogue, int type)
21 CatalogueTreeWidgetItem::CatalogueTreeWidgetItem(std::shared_ptr<DBCatalogue> catalogue, int type)
19 : QTreeWidgetItem(type),
22 : QTreeWidgetItem(type),
20 impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)}
23 impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)}
21 {
24 {
@@ -28,7 +31,7 QVariant CatalogueTreeWidgetItem::data(int column, int role) const
28 switch (role) {
31 switch (role) {
29 case Qt::EditRole: // fallthrough
32 case Qt::EditRole: // fallthrough
30 case Qt::DisplayRole:
33 case Qt::DisplayRole:
31 return impl->m_Catalogue.getName();
34 return impl->m_Catalogue->getName();
32 default:
35 default:
33 break;
36 break;
34 }
37 }
@@ -41,9 +44,9 void CatalogueTreeWidgetItem::setData(int column, int role, const QVariant &valu
41 {
44 {
42 if (role == Qt::EditRole && column == 0) {
45 if (role == Qt::EditRole && column == 0) {
43 auto newName = value.toString();
46 auto newName = value.toString();
44 if (newName != impl->m_Catalogue.getName()) {
47 if (newName != impl->m_Catalogue->getName()) {
45 setText(0, newName);
48 setText(0, newName);
46 impl->m_Catalogue.setName(newName);
49 impl->m_Catalogue->setName(newName);
47 setHasChanges(true);
50 setHasChanges(true);
48 }
51 }
49 }
52 }
@@ -52,7 +55,7 void CatalogueTreeWidgetItem::setData(int column, int role, const QVariant &valu
52 }
55 }
53 }
56 }
54
57
55 DBCatalogue CatalogueTreeWidgetItem::catalogue() const
58 std::shared_ptr<DBCatalogue> CatalogueTreeWidgetItem::catalogue() const
56 {
59 {
57 return impl->m_Catalogue;
60 return impl->m_Catalogue;
58 }
61 }
General Comments 0
You need to be logged in to leave comments. Login now