@@ -6,6 +6,7 | |||||
6 | #include <QTreeWidgetItem> |
|
6 | #include <QTreeWidgetItem> | |
7 | #include <QWidget> |
|
7 | #include <QWidget> | |
8 |
|
8 | |||
|
9 | class CatalogueAbstractTreeItem; | |||
9 | class DBCatalogue; |
|
10 | class DBCatalogue; | |
10 |
|
11 | |||
11 | namespace Ui { |
|
12 | namespace Ui { | |
@@ -28,7 +29,8 public: | |||||
28 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
29 | explicit CatalogueSideBarWidget(QWidget *parent = 0); | |
29 | virtual ~CatalogueSideBarWidget(); |
|
30 | virtual ~CatalogueSideBarWidget(); | |
30 |
|
31 | |||
31 |
|
|
32 | CatalogueAbstractTreeItem *addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, | |
|
33 | const QString &repository); | |||
32 | void setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, bool hasChanges); |
|
34 | void setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, bool hasChanges); | |
33 |
|
35 | |||
34 | QVector<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const; |
|
36 | QVector<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const; |
@@ -30,8 +30,8 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { | |||||
30 | void configureTreeWidget(QTreeView *treeView); |
|
30 | void configureTreeWidget(QTreeView *treeView); | |
31 | QModelIndex addDatabaseItem(const QString &name); |
|
31 | QModelIndex addDatabaseItem(const QString &name); | |
32 | CatalogueAbstractTreeItem *getDatabaseItem(const QString &name); |
|
32 | CatalogueAbstractTreeItem *getDatabaseItem(const QString &name); | |
33 |
|
|
33 | CatalogueAbstractTreeItem *addCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue, | |
34 | const QModelIndex &databaseIndex); |
|
34 | const QModelIndex &databaseIndex); | |
35 |
|
35 | |||
36 | CatalogueTreeItem *getCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue) const; |
|
36 | CatalogueTreeItem *getCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue) const; | |
37 | void setHasChanges(bool value, const QModelIndex &index, CatalogueSideBarWidget *sideBarWidget); |
|
37 | void setHasChanges(bool value, const QModelIndex &index, CatalogueSideBarWidget *sideBarWidget); | |
@@ -115,26 +115,15 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) | |||||
115 | &CatalogueSideBarWidget::emitSelection); |
|
115 | &CatalogueSideBarWidget::emitSelection); | |
116 |
|
116 | |||
117 |
|
117 | |||
118 |
|
|
118 | connect(ui->btnAdd, &QToolButton::clicked, [this]() { | |
119 | // QVector<std::shared_ptr<DBCatalogue> > catalogues; |
|
119 | auto catalogue = std::make_shared<DBCatalogue>(); | |
120 | // impl->getSelectedItems(ui->treeView, events, eventProducts); |
|
120 | catalogue->setName(QString("Cat")); | |
|
121 | sqpApp->catalogueController().addCatalogue(catalogue); | |||
|
122 | auto item = this->addCatalogue(catalogue, REPOSITORY_DEFAULT); | |||
|
123 | this->setCatalogueChanges(catalogue, true); | |||
|
124 | ui->treeView->edit(impl->m_TreeModel->indexOf(item)); | |||
121 |
|
125 | |||
122 | // if (!events.isEmpty() && eventProducts.isEmpty()) { |
|
126 | }); | |
123 |
|
||||
124 | // if (QMessageBox::warning(this, tr("Remove Event(s)"), |
|
|||
125 | // tr("The selected event(s) will be completly removed " |
|
|||
126 | // "from the repository!\nAre you sure you want to |
|
|||
127 | // continue?"), |
|
|||
128 | // QMessageBox::Yes | QMessageBox::No, QMessageBox::No) |
|
|||
129 | // == QMessageBox::Yes) { |
|
|||
130 |
|
||||
131 | // for (auto event : events) { |
|
|||
132 | // sqpApp->catalogueController().removeEvent(event); |
|
|||
133 | // impl->removeEvent(event, ui->treeView); |
|
|||
134 | // } |
|
|||
135 | // } |
|
|||
136 | // } |
|
|||
137 | // }); |
|
|||
138 |
|
127 | |||
139 |
|
128 | |||
140 | connect(impl->m_TreeModel, &CatalogueTreeModel::itemDropped, [this](auto index) { |
|
129 | connect(impl->m_TreeModel, &CatalogueTreeModel::itemDropped, [this](auto index) { | |
@@ -193,11 +182,12 CatalogueSideBarWidget::~CatalogueSideBarWidget() | |||||
193 | delete ui; |
|
182 | delete ui; | |
194 | } |
|
183 | } | |
195 |
|
184 | |||
196 | void CatalogueSideBarWidget::addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, |
|
185 | CatalogueAbstractTreeItem * | |
197 | const QString &repository) |
|
186 | CatalogueSideBarWidget::addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, | |
|
187 | const QString &repository) | |||
198 | { |
|
188 | { | |
199 | auto repositoryItem = impl->getDatabaseItem(repository); |
|
189 | auto repositoryItem = impl->getDatabaseItem(repository); | |
200 | impl->addCatalogueItem(catalogue, impl->m_TreeModel->indexOf(repositoryItem)); |
|
190 | return impl->addCatalogueItem(catalogue, impl->m_TreeModel->indexOf(repositoryItem)); | |
201 | } |
|
191 | } | |
202 |
|
192 | |||
203 | void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, |
|
193 | void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, | |
@@ -336,12 +326,14 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getDatabaseItem(const QSt | |||||
336 | return nullptr; |
|
326 | return nullptr; | |
337 | } |
|
327 | } | |
338 |
|
328 | |||
339 |
|
|
329 | CatalogueAbstractTreeItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( | |
340 | const std::shared_ptr<DBCatalogue> &catalogue, const QModelIndex &databaseIndex) |
|
330 | const std::shared_ptr<DBCatalogue> &catalogue, const QModelIndex &databaseIndex) | |
341 | { |
|
331 | { | |
342 | auto catalogueItem |
|
332 | auto catalogueItem | |
343 | = new CatalogueTreeItem{catalogue, QIcon{":/icones/catalogue.png"}, CATALOGUE_ITEM_TYPE}; |
|
333 | = new CatalogueTreeItem{catalogue, QIcon{":/icones/catalogue.png"}, CATALOGUE_ITEM_TYPE}; | |
344 | m_TreeModel->addChildItem(catalogueItem, databaseIndex); |
|
334 | m_TreeModel->addChildItem(catalogueItem, databaseIndex); | |
|
335 | ||||
|
336 | return catalogueItem; | |||
345 | } |
|
337 | } | |
346 |
|
338 | |||
347 | CatalogueTreeItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getCatalogueItem( |
|
339 | CatalogueTreeItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getCatalogueItem( |
General Comments 0
You need to be logged in to leave comments.
Login now