From af544061861d47f194992333b19110dcdb50c24f 2017-12-13 11:16:03 From: Thibaud Rabillard Date: 2017-12-13 11:16:03 Subject: [PATCH] Manage inspector with multiple events selected --- diff --git a/gui/include/Catalogue/CatalogueEventsWidget.h b/gui/include/Catalogue/CatalogueEventsWidget.h index 456a176..1886a81 100644 --- a/gui/include/Catalogue/CatalogueEventsWidget.h +++ b/gui/include/Catalogue/CatalogueEventsWidget.h @@ -15,7 +15,7 @@ class CatalogueEventsWidget : public QWidget { Q_OBJECT signals: - void eventSelected(const DBEvent &event); + void eventsSelected(const QVector &event); public: explicit CatalogueEventsWidget(QWidget *parent = 0); diff --git a/gui/src/Catalogue/CatalogueEventsWidget.cpp b/gui/src/Catalogue/CatalogueEventsWidget.cpp index 64c2109..887a1dc 100644 --- a/gui/src/Catalogue/CatalogueEventsWidget.cpp +++ b/gui/src/Catalogue/CatalogueEventsWidget.cpp @@ -42,17 +42,22 @@ CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) }); connect(ui->tableView, &QTableView::clicked, [this](auto index) { - auto event = impl->m_Model->getEvent(index.row()); - emit this->eventSelected(event); + QVector events; + for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { + events << impl->m_Model->getEvent(rowIndex.row()); + } + + emit this->eventsSelected(events); }); - connect(ui->tableView->selectionModel(), &QItemSelectionModel::currentChanged, - [this](auto current, auto previous) { - if (current.isValid() && current.row() >= 0) { - auto event = impl->m_Model->getEvent(current.row()); - emit this->eventSelected(event); - } - }); + connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { + QVector events; + for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { + events << impl->m_Model->getEvent(rowIndex.row()); + } + + emit this->eventsSelected(events); + }); connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; diff --git a/gui/src/Catalogue/CatalogueExplorer.cpp b/gui/src/Catalogue/CatalogueExplorer.cpp index e755148..fbaeb00 100644 --- a/gui/src/Catalogue/CatalogueExplorer.cpp +++ b/gui/src/Catalogue/CatalogueExplorer.cpp @@ -15,8 +15,14 @@ CatalogueExplorer::CatalogueExplorer(QWidget *parent) ui->events->populateWithCatalogue(catalogue); }); - connect(ui->events, &CatalogueEventsWidget::eventSelected, - [this](auto event) { ui->inspector->setEvent(event); }); + connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { + if (events.count() == 1) { + ui->inspector->setEvent(events.first()); + } + else { + ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); + } + }); } CatalogueExplorer::~CatalogueExplorer()