##// END OF EJS Templates
Add catalogue handling
perrinel -
r1330:4af886ed9de4
parent child
Show More
@@ -62,6 +62,7 public:
62 62 void updateCatalogue(std::shared_ptr<DBCatalogue> catalogue);
63 63 void removeCatalogue(std::shared_ptr<DBCatalogue> catalogue);
64 64 void saveCatalogue(std::shared_ptr<DBCatalogue> catalogue);
65 void discardCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool &removed);
65 66
66 67 void saveAll();
67 68 bool hasChanges() const;
@@ -30,7 +30,7 static QString REPOSITORY_TRASH_SUFFIX = QString{"_trash"};
30 30 /**
31 31 * Possible types of an repository
32 32 */
33 enum class DBType { SYNC, WORK, TRASH};
33 enum class DBType { SYNC, WORK, TRASH };
34 34 class CatalogueController::CatalogueControllerPrivate {
35 35
36 36 public:
@@ -41,9 +41,10 public:
41 41 QStringList m_RepositoryList;
42 42 CatalogueController *m_Q;
43 43
44 QSet<QString> m_EventKeysWithChanges;
44 QSet<QString> m_KeysWithChanges;
45 45
46 46 QString eventUniqueKey(const std::shared_ptr<DBEvent> &event) const;
47 QString catalogueUniqueKey(const std::shared_ptr<DBCatalogue> &catalogue) const;
47 48
48 49 void copyDBtoDB(const QString &dbFrom, const QString &dbTo);
49 50 QString toWorkRepository(QString repository);
@@ -53,7 +54,8 public:
53 54 void saveEvent(std::shared_ptr<DBEvent> event, bool persist = true);
54 55 void saveCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool persist = true);
55 56
56 std::shared_ptr<IRequestPredicate> createFinder(const QUuid& uniqId, const QString & repository, DBType type);
57 std::shared_ptr<IRequestPredicate> createFinder(const QUuid &uniqId, const QString &repository,
58 DBType type);
57 59 };
58 60
59 61 CatalogueController::CatalogueController(QObject *parent)
@@ -148,7 +150,7 void CatalogueController::updateEvent(std::shared_ptr<DBEvent> event)
148 150 event->setRepository(impl->toWorkRepository(event->getRepository()));
149 151
150 152 auto uniqueId = impl->eventUniqueKey(event);
151 impl->m_EventKeysWithChanges.insert(uniqueId);
153 impl->m_KeysWithChanges.insert(uniqueId);
152 154
153 155 impl->m_CatalogueDao.updateEvent(*event);
154 156 }
@@ -197,13 +199,13 void CatalogueController::addEvent(std::shared_ptr<DBEvent> event)
197 199
198 200
199 201 auto uniqueId = impl->eventUniqueKey(event);
200 impl->m_EventKeysWithChanges.insert(uniqueId);
202 impl->m_KeysWithChanges.insert(uniqueId);
201 203 }
202 204
203 205 void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
204 206 {
205 207 impl->saveEvent(event, true);
206 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
208 impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
207 209 }
208 210
209 211 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool &removed)
@@ -219,7 +221,7 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool &rem
219 221
220 222 auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
221 223 *event = workEvent;
222 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
224 impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
223 225 }
224 226 else {
225 227 removed = true;
@@ -231,7 +233,7 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool &rem
231 233
232 234 bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event) const
233 235 {
234 return impl->m_EventKeysWithChanges.contains(impl->eventUniqueKey(event));
236 return impl->m_KeysWithChanges.contains(impl->eventUniqueKey(event));
235 237 }
236 238
237 239 std::list<std::shared_ptr<DBCatalogue> >
@@ -254,21 +256,22 void CatalogueController::addCatalogue(std::shared_ptr<DBCatalogue> catalogue)
254 256 auto catalogueTemp = *catalogue;
255 257 impl->m_CatalogueDao.addCatalogue(catalogueTemp);
256 258
257 auto workPred = impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::WORK);
259 auto workPred
260 = impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::WORK);
258 261
259 262 auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
260 263 *catalogue = workCatalogue;
261 264
262 // auto uniqueId = impl->eventUniqueKey(catalogue);
263 // impl->m_EventKeysWithChanges.insert(uniqueId);
265 auto uniqueId = impl->catalogueUniqueKey(catalogue);
266 impl->m_KeysWithChanges.insert(uniqueId);
264 267 }
265 268
266 269 void CatalogueController::updateCatalogue(std::shared_ptr<DBCatalogue> catalogue)
267 270 {
268 271 catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
269 272
270 // auto uniqueId = impl->eventUniqueKey(event);
271 // impl->m_EventKeysWithChanges.insert(uniqueId);
273 auto uniqueId = impl->catalogueUniqueKey(catalogue);
274 impl->m_KeysWithChanges.insert(uniqueId);
272 275
273 276 impl->m_CatalogueDao.updateCatalogue(*catalogue);
274 277 }
@@ -286,7 +289,32 void CatalogueController::removeCatalogue(std::shared_ptr<DBCatalogue> catalogue
286 289 void CatalogueController::saveCatalogue(std::shared_ptr<DBCatalogue> catalogue)
287 290 {
288 291 impl->saveCatalogue(catalogue, true);
289 // impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
292 impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
293 }
294
295 void CatalogueController::discardCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool &removed)
296 {
297 auto syncPred
298 = impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::SYNC);
299 auto workPred
300 = impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::WORK);
301
302 auto syncCatalogue = impl->m_CatalogueDao.getCatalogue(syncPred);
303 if (!syncCatalogue.getUniqId().isNull()) {
304 removed = false;
305 impl->m_CatalogueDao.copyCatalogue(
306 syncCatalogue, impl->toWorkRepository(catalogue->getRepository()), true);
307
308 auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
309 *catalogue = workCatalogue;
310 impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
311 }
312 else {
313 removed = true;
314 // Since the element wasn't in sync repository. Discard it means remove it
315 catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
316 impl->m_CatalogueDao.removeCatalogue(*catalogue);
317 }
290 318 }
291 319
292 320 void CatalogueController::saveAll()
@@ -306,12 +334,12 void CatalogueController::saveAll()
306 334 }
307 335
308 336 impl->savAllDB();
309 impl->m_EventKeysWithChanges.clear();
337 impl->m_KeysWithChanges.clear();
310 338 }
311 339
312 340 bool CatalogueController::hasChanges() const
313 341 {
314 return !impl->m_EventKeysWithChanges.isEmpty(); // TODO: catalogues
342 return !impl->m_KeysWithChanges.isEmpty();
315 343 }
316 344
317 345 QByteArray
@@ -400,6 +428,12 QString CatalogueController::CatalogueControllerPrivate::eventUniqueKey(
400 428 return event->getUniqId().toString().append(event->getRepository());
401 429 }
402 430
431 QString CatalogueController::CatalogueControllerPrivate::catalogueUniqueKey(
432 const std::shared_ptr<DBCatalogue> &catalogue) const
433 {
434 return catalogue->getUniqId().toString().append(catalogue->getRepository());
435 }
436
403 437 void CatalogueController::CatalogueControllerPrivate::copyDBtoDB(const QString &dbFrom,
404 438 const QString &dbTo)
405 439 {
@@ -461,28 +495,28 void CatalogueController::CatalogueControllerPrivate::saveCatalogue(
461 495 }
462 496 }
463 497
464 std::shared_ptr<IRequestPredicate> CatalogueController::CatalogueControllerPrivate::createFinder(const QUuid &uniqId, const QString &repository, DBType type)
498 std::shared_ptr<IRequestPredicate> CatalogueController::CatalogueControllerPrivate::createFinder(
499 const QUuid &uniqId, const QString &repository, DBType type)
465 500 {
466 501 // update catalogue parameter
467 auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(
468 QString{"uniqId"}, uniqId, ComparaisonOperation::EQUALEQUAL);
502 auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, uniqId,
503 ComparaisonOperation::EQUALEQUAL);
469 504
470 505 auto repositoryType = repository;
471 506 switch (type) {
472 case DBType::SYNC:
473 repositoryType = toSyncRepository(repositoryType);
474 break;
475 case DBType::WORK:
476 repositoryType =toWorkRepository(repositoryType);
477 break;
478 case DBType::TRASH:
479 default:
480 break;
507 case DBType::SYNC:
508 repositoryType = toSyncRepository(repositoryType);
509 break;
510 case DBType::WORK:
511 repositoryType = toWorkRepository(repositoryType);
512 break;
513 case DBType::TRASH:
514 default:
515 break;
481 516 }
482 517
483 518 auto repositoryPredicate = std::make_shared<ComparaisonPredicate>(
484 QString{"repository"}, repositoryType,
485 ComparaisonOperation::EQUALEQUAL);
519 QString{"repository"}, repositoryType, ComparaisonOperation::EQUALEQUAL);
486 520
487 521 auto finderPred = std::make_shared<CompoundPredicate>(CompoundOperation::AND);
488 522 finderPred->AddRequestPredicate(uniqIdPredicate);
@@ -33,6 +33,9 public:
33 33
34 34 QVector<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const;
35 35
36 private slots:
37 void emitSelection();
38
36 39 private:
37 40 Ui::CatalogueSideBarWidget *ui;
38 41
@@ -15,6 +15,7 public:
15 15 virtual ~CatalogueAbstractTreeItem();
16 16
17 17 void addChild(CatalogueAbstractTreeItem *child);
18 void removeChild(CatalogueAbstractTreeItem *child);
18 19 QVector<CatalogueAbstractTreeItem *> children() const;
19 20 CatalogueAbstractTreeItem *parent() const;
20 21
@@ -27,6 +27,9 public:
27 27 QVector<CatalogueAbstractTreeItem *> topLevelItems() const;
28 28
29 29 void addChildItem(CatalogueAbstractTreeItem *child, const QModelIndex &parentIndex);
30 void removeChildItem(CatalogueAbstractTreeItem *child, const QModelIndex &parentIndex);
31 /// Refresh the data for the specified index
32 void refresh(const QModelIndex &index);
30 33
31 34 CatalogueAbstractTreeItem *item(const QModelIndex &index) const;
32 35 QModelIndex indexOf(CatalogueAbstractTreeItem *item, int column = 0) const;
@@ -65,8 +65,8 struct CatalogueActionManager::CatalogueActionManagerPrivate {
65 65
66 66
67 67 if (catalogue) {
68 // TODO
69 // catalogue->addEvent(event);
68 catalogue->addEvent(event->getUniqId());
69 sqpApp->catalogueController().updateCatalogue(catalogue);
70 70 m_CatalogueExplorer->sideBarWidget().setCatalogueChanges(catalogue, true);
71 71 if (m_CatalogueExplorer->eventsWidget().displayedCatalogues().contains(catalogue)) {
72 72 m_CatalogueExplorer->eventsWidget().addEvent(event);
@@ -131,7 +131,7 void CatalogueActionManager::installSelectionZoneActions()
131 131 if (!selectedCatalogue) {
132 132 selectedCatalogue = std::make_shared<DBCatalogue>();
133 133 selectedCatalogue->setName(dialog.catalogueName());
134 // sqpApp->catalogueController().addCatalogue(selectedCatalogue); TODO
134 sqpApp->catalogueController().addCatalogue(selectedCatalogue);
135 135 impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(selectedCatalogue,
136 136 REPOSITORY_DEFAULT);
137 137 }
@@ -12,6 +12,7
12 12 #include <DBCatalogue.h>
13 13
14 14 #include <QMenu>
15 #include <QMessageBox>
15 16
16 17 Q_LOGGING_CATEGORY(LOG_CatalogueSideBarWidget, "CatalogueSideBarWidget")
17 18
@@ -33,7 +34,7 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
33 34 const QModelIndex &databaseIndex);
34 35
35 36 CatalogueTreeItem *getCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue) const;
36 void setHasChanges(bool value, const QModelIndex &index, QTreeView *treeView);
37 void setHasChanges(bool value, const QModelIndex &index, CatalogueSideBarWidget *sideBarWidget);
37 38 bool hasChanges(const QModelIndex &index, QTreeView *treeView);
38 39
39 40 int selectionType(QTreeView *treeView) const
@@ -109,39 +110,77 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
109 110 ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
110 111 ui->treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
111 112
112 auto emitSelection = [this]() {
113
114 auto selectionType = impl->selectionType(ui->treeView);
115
116 switch (selectionType) {
117 case CATALOGUE_ITEM_TYPE:
118 emit this->catalogueSelected(impl->selectedCatalogues(ui->treeView));
119 break;
120 case DATABASE_ITEM_TYPE:
121 emit this->databaseSelected(impl->selectedRepositories(ui->treeView));
122 break;
123 case ALL_EVENT_ITEM_TYPE:
124 emit this->allEventsSelected();
125 break;
126 case TRASH_ITEM_TYPE:
127 emit this->trashSelected();
128 break;
129 default:
130 emit this->selectionCleared();
131 break;
113 connect(ui->treeView, &QTreeView::clicked, this, &CatalogueSideBarWidget::emitSelection);
114 connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, this,
115 &CatalogueSideBarWidget::emitSelection);
116
117
118 // connect(ui->btnAdd, &QToolButton::clicked, [this]() {
119 // QVector<std::shared_ptr<DBCatalogue> > catalogues;
120 // impl->getSelectedItems(ui->treeView, events, eventProducts);
121
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 // });
138
139
140 connect(impl->m_TreeModel, &CatalogueTreeModel::itemDropped, [this](auto index) {
141 auto item = impl->m_TreeModel->item(index);
142 if (item && item->type() == CATALOGUE_ITEM_TYPE) {
143 auto catalogue = static_cast<CatalogueTreeItem *>(item)->catalogue();
144 this->setCatalogueChanges(catalogue, true);
132 145 }
133 };
146 });
147 connect(ui->btnRemove, &QToolButton::clicked, [this]() {
148 QVector<QPair<std::shared_ptr<DBCatalogue>, CatalogueAbstractTreeItem *> >
149 cataloguesToItems;
150 auto selectedIndexes = ui->treeView->selectionModel()->selectedRows();
151
152 for (auto index : selectedIndexes) {
153 auto item = impl->m_TreeModel->item(index);
154 if (item && item->type() == CATALOGUE_ITEM_TYPE) {
155 auto catalogue = static_cast<CatalogueTreeItem *>(item)->catalogue();
156 cataloguesToItems << qMakePair(catalogue, item);
157 }
158 }
159
160 if (!cataloguesToItems.isEmpty()) {
161
162 if (QMessageBox::warning(this, tr("Remove Catalogue(s)"),
163 tr("The selected catalogues(s) will be completly removed "
164 "from the repository!\nAre you sure you want to continue?"),
165 QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
166 == QMessageBox::Yes) {
167
168 for (auto catalogueToItem : cataloguesToItems) {
169 sqpApp->catalogueController().removeCatalogue(catalogueToItem.first);
170 impl->m_TreeModel->removeChildItem(
171 catalogueToItem.second,
172 impl->m_TreeModel->indexOf(catalogueToItem.second->parent()));
173 }
174 }
175 }
176 });
134 177
135 connect(ui->treeView, &QTreeView::clicked, emitSelection);
136 connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, emitSelection);
137 connect(impl->m_TreeModel, &CatalogueTreeModel::itemRenamed, [emitSelection, this](auto index) {
178 connect(impl->m_TreeModel, &CatalogueTreeModel::itemRenamed, [this](auto index) {
138 179 auto selectedIndexes = ui->treeView->selectionModel()->selectedRows();
139 180 if (selectedIndexes.contains(index)) {
140 emitSelection();
181 this->emitSelection();
141 182 }
142
143 auto item = impl->m_TreeModel->item(index);
144 impl->setHasChanges(true, index, ui->treeView);
183 impl->setHasChanges(true, index, this);
145 184 });
146 185
147 186 ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -166,7 +205,7 void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalog
166 205 {
167 206 if (auto catalogueItem = impl->getCatalogueItem(catalogue)) {
168 207 auto index = impl->m_TreeModel->indexOf(catalogueItem);
169 impl->setHasChanges(hasChanges, index, ui->treeView);
208 impl->setHasChanges(hasChanges, index, this);
170 209 // catalogueItem->refresh();
171 210 }
172 211 }
@@ -189,6 +228,29 CatalogueSideBarWidget::getCatalogues(const QString &repository) const
189 228 return result;
190 229 }
191 230
231 void CatalogueSideBarWidget::emitSelection()
232 {
233 auto selectionType = impl->selectionType(ui->treeView);
234
235 switch (selectionType) {
236 case CATALOGUE_ITEM_TYPE:
237 emit this->catalogueSelected(impl->selectedCatalogues(ui->treeView));
238 break;
239 case DATABASE_ITEM_TYPE:
240 emit this->databaseSelected(impl->selectedRepositories(ui->treeView));
241 break;
242 case ALL_EVENT_ITEM_TYPE:
243 emit this->allEventsSelected();
244 break;
245 case TRASH_ITEM_TYPE:
246 emit this->trashSelected();
247 break;
248 default:
249 emit this->selectionCleared();
250 break;
251 }
252 }
253
192 254 void CatalogueSideBarWidget::onContextMenuRequested(const QPoint &pos)
193 255 {
194 256 QMenu menu{this};
@@ -307,25 +369,48 CatalogueTreeItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getCat
307 369 return nullptr;
308 370 }
309 371
310 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::setHasChanges(bool value,
311 const QModelIndex &index,
312 QTreeView *treeView)
372 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::setHasChanges(
373 bool value, const QModelIndex &index, CatalogueSideBarWidget *sideBarWidget)
313 374 {
375 std::shared_ptr<DBCatalogue> catalogue = nullptr;
376 auto item = m_TreeModel->item(index);
377 if (item && item->type() == CATALOGUE_ITEM_TYPE) {
378 catalogue = static_cast<CatalogueTreeItem *>(item)->catalogue();
379 }
380
314 381 auto validationIndex = index.sibling(index.row(), (int)CatalogueTreeModel::Column::Validation);
315 382 if (value) {
316 if (!hasChanges(validationIndex, treeView)) {
383 if (!hasChanges(validationIndex, sideBarWidget->ui->treeView)) {
317 384 auto widget = CatalogueExplorerHelper::buildValidationWidget(
318 treeView, [this, validationIndex,
319 treeView]() { setHasChanges(false, validationIndex, treeView); },
320 [this, validationIndex, treeView]() {
321 setHasChanges(false, validationIndex, treeView);
385 sideBarWidget->ui->treeView,
386 [this, validationIndex, sideBarWidget, catalogue]() {
387 if (catalogue) {
388 sqpApp->catalogueController().saveCatalogue(catalogue);
389 }
390 setHasChanges(false, validationIndex, sideBarWidget);
391 },
392 [this, validationIndex, sideBarWidget, catalogue, item]() {
393 if (catalogue) {
394 bool removed;
395 sqpApp->catalogueController().discardCatalogue(catalogue, removed);
396
397 if (removed) {
398 m_TreeModel->removeChildItem(item,
399 m_TreeModel->indexOf(item->parent()));
400 }
401 else {
402 m_TreeModel->refresh(m_TreeModel->indexOf(item));
403 setHasChanges(false, validationIndex, sideBarWidget);
404 }
405 sideBarWidget->emitSelection();
406 }
322 407 });
323 treeView->setIndexWidget(validationIndex, widget);
408 sideBarWidget->ui->treeView->setIndexWidget(validationIndex, widget);
324 409 }
325 410 }
326 411 else {
327 412 // Note: the widget is destroyed
328 treeView->setIndexWidget(validationIndex, nullptr);
413 sideBarWidget->ui->treeView->setIndexWidget(validationIndex, nullptr);
329 414 }
330 415 }
331 416
@@ -24,6 +24,12 void CatalogueAbstractTreeItem::addChild(CatalogueAbstractTreeItem *child)
24 24 child->impl->m_Parent = this;
25 25 }
26 26
27 void CatalogueAbstractTreeItem::removeChild(CatalogueAbstractTreeItem *child)
28 {
29 impl->m_Children.removeAll(child);
30 delete child;
31 }
32
27 33 QVector<CatalogueAbstractTreeItem *> CatalogueAbstractTreeItem::children() const
28 34 {
29 35 return impl->m_Children;
@@ -76,17 +76,27 Qt::ItemFlags CatalogueTreeItem::flags(int column) const
76 76
77 77 bool CatalogueTreeItem::canDropMimeData(const QMimeData *data, Qt::DropAction action)
78 78 {
79 return data->hasFormat(MIME_TYPE_EVENT_LIST);
79 auto events = sqpApp->catalogueController().eventsForMimeData(data->data(MIME_TYPE_EVENT_LIST));
80 auto canDrop = data->hasFormat(MIME_TYPE_EVENT_LIST);
81
82 for (auto event : events) {
83 canDrop &= (event->getRepository() == impl->m_Catalogue->getRepository());
84 }
85 return canDrop;
80 86 }
81 87
82 88 bool CatalogueTreeItem::dropMimeData(const QMimeData *data, Qt::DropAction action)
83 89 {
84 90 Q_ASSERT(canDropMimeData(data, action));
85
86 auto events = sqpApp->catalogueController().eventsForMimeData(data->data(MIME_TYPE_EVENT_LIST));
87 // impl->m_Catalogue->addEvents(events); TODO: move events in the new catalogue
88 91 // Warning: Check that the events aren't already in the catalogue
89 92 // Also check for the repository !!!
93
94 auto events = sqpApp->catalogueController().eventsForMimeData(data->data(MIME_TYPE_EVENT_LIST));
95
96 for (auto event : events) {
97 impl->m_Catalogue->addEvent(event->getUniqId());
98 sqpApp->catalogueController().updateCatalogue(impl->m_Catalogue);
99 }
90 100 }
91 101
92 102 std::shared_ptr<DBCatalogue> CatalogueTreeItem::catalogue() const
@@ -46,6 +46,23 void CatalogueTreeModel::addChildItem(CatalogueAbstractTreeItem *child,
46 46 emit dataChanged(parentIndex, parentIndex);
47 47 }
48 48
49 void CatalogueTreeModel::removeChildItem(CatalogueAbstractTreeItem *child,
50 const QModelIndex &parentIndex)
51 {
52 auto parentItem = item(parentIndex);
53 int i = parentItem->children().indexOf(child);
54 beginRemoveRows(parentIndex, i, i);
55 parentItem->removeChild(child);
56 endRemoveRows();
57
58 emit dataChanged(parentIndex, parentIndex);
59 }
60
61 void CatalogueTreeModel::refresh(const QModelIndex &index)
62 {
63 emit dataChanged(index, index);
64 }
65
49 66 CatalogueAbstractTreeItem *CatalogueTreeModel::item(const QModelIndex &index) const
50 67 {
51 68 return static_cast<CatalogueAbstractTreeItem *>(index.internalPointer());
@@ -31,7 +31,7
31 31 <item>
32 32 <widget class="QToolButton" name="btnAdd">
33 33 <property name="enabled">
34 <bool>false</bool>
34 <bool>true</bool>
35 35 </property>
36 36 <property name="text">
37 37 <string>+</string>
@@ -48,7 +48,7
48 48 <item>
49 49 <widget class="QToolButton" name="btnRemove">
50 50 <property name="enabled">
51 <bool>false</bool>
51 <bool>true</bool>
52 52 </property>
53 53 <property name="text">
54 54 <string> - </string>
@@ -100,7 +100,6
100 100 </widget>
101 101 <resources>
102 102 <include location="../../resources/sqpguiresources.qrc"/>
103 <include location="../../resources/sqpguiresources.qrc"/>
104 103 </resources>
105 104 <connections/>
106 105 </ui>
General Comments 0
You need to be logged in to leave comments. Login now