@@ -6,6 +6,7 | |||
|
6 | 6 | #include <QTreeWidgetItem> |
|
7 | 7 | #include <QWidget> |
|
8 | 8 | |
|
9 | class CatalogueAbstractTreeItem; | |
|
9 | 10 | class DBCatalogue; |
|
10 | 11 | |
|
11 | 12 | namespace Ui { |
@@ -28,7 +29,8 public: | |||
|
28 | 29 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
29 | 30 | virtual ~CatalogueSideBarWidget(); |
|
30 | 31 | |
|
31 |
|
|
|
32 | CatalogueAbstractTreeItem *addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, | |
|
33 | const QString &repository); | |
|
32 | 34 | void setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, bool hasChanges); |
|
33 | 35 | |
|
34 | 36 | QVector<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const; |
@@ -30,8 +30,8 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { | |||
|
30 | 30 | void configureTreeWidget(QTreeView *treeView); |
|
31 | 31 | QModelIndex addDatabaseItem(const QString &name); |
|
32 | 32 | CatalogueAbstractTreeItem *getDatabaseItem(const QString &name); |
|
33 |
|
|
|
34 | const QModelIndex &databaseIndex); | |
|
33 | CatalogueAbstractTreeItem *addCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue, | |
|
34 | const QModelIndex &databaseIndex); | |
|
35 | 35 | |
|
36 | 36 | CatalogueTreeItem *getCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue) const; |
|
37 | 37 | void setHasChanges(bool value, const QModelIndex &index, CatalogueSideBarWidget *sideBarWidget); |
@@ -115,26 +115,15 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) | |||
|
115 | 115 | &CatalogueSideBarWidget::emitSelection); |
|
116 | 116 | |
|
117 | 117 | |
|
118 |
|
|
|
119 | // QVector<std::shared_ptr<DBCatalogue> > catalogues; | |
|
120 | // impl->getSelectedItems(ui->treeView, events, eventProducts); | |
|
118 | connect(ui->btnAdd, &QToolButton::clicked, [this]() { | |
|
119 | auto catalogue = std::make_shared<DBCatalogue>(); | |
|
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()) { | |
|
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 | // }); | |
|
126 | }); | |
|
138 | 127 | |
|
139 | 128 | |
|
140 | 129 | connect(impl->m_TreeModel, &CatalogueTreeModel::itemDropped, [this](auto index) { |
@@ -193,11 +182,12 CatalogueSideBarWidget::~CatalogueSideBarWidget() | |||
|
193 | 182 | delete ui; |
|
194 | 183 | } |
|
195 | 184 | |
|
196 | void CatalogueSideBarWidget::addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, | |
|
197 | const QString &repository) | |
|
185 | CatalogueAbstractTreeItem * | |
|
186 | CatalogueSideBarWidget::addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, | |
|
187 | const QString &repository) | |
|
198 | 188 | { |
|
199 | 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 | 193 | void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, |
@@ -336,12 +326,14 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getDatabaseItem(const QSt | |||
|
336 | 326 | return nullptr; |
|
337 | 327 | } |
|
338 | 328 | |
|
339 |
|
|
|
329 | CatalogueAbstractTreeItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( | |
|
340 | 330 | const std::shared_ptr<DBCatalogue> &catalogue, const QModelIndex &databaseIndex) |
|
341 | 331 | { |
|
342 | 332 | auto catalogueItem |
|
343 | 333 | = new CatalogueTreeItem{catalogue, QIcon{":/icones/catalogue.png"}, CATALOGUE_ITEM_TYPE}; |
|
344 | 334 | m_TreeModel->addChildItem(catalogueItem, databaseIndex); |
|
335 | ||
|
336 | return catalogueItem; | |
|
345 | 337 | } |
|
346 | 338 | |
|
347 | 339 | CatalogueTreeItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getCatalogueItem( |
General Comments 0
You need to be logged in to leave comments.
Login now