##// END OF EJS Templates
Manage inspector with multiple events selected
trabillard -
r1131:af544061861d
parent child
Show More
@@ -1,34 +1,34
1 #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H
1 #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H
2 #define SCIQLOP_CATALOGUEEVENTSWIDGET_H
2 #define SCIQLOP_CATALOGUEEVENTSWIDGET_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QWidget>
5 #include <QWidget>
6
6
7 class DBCatalogue;
7 class DBCatalogue;
8 class DBEvent;
8 class DBEvent;
9
9
10 namespace Ui {
10 namespace Ui {
11 class CatalogueEventsWidget;
11 class CatalogueEventsWidget;
12 }
12 }
13
13
14 class CatalogueEventsWidget : public QWidget {
14 class CatalogueEventsWidget : public QWidget {
15 Q_OBJECT
15 Q_OBJECT
16
16
17 signals:
17 signals:
18 void eventSelected(const DBEvent &event);
18 void eventsSelected(const QVector<DBEvent> &event);
19
19
20 public:
20 public:
21 explicit CatalogueEventsWidget(QWidget *parent = 0);
21 explicit CatalogueEventsWidget(QWidget *parent = 0);
22 virtual ~CatalogueEventsWidget();
22 virtual ~CatalogueEventsWidget();
23
23
24 public slots:
24 public slots:
25 void populateWithCatalogue(const DBCatalogue &catalogue);
25 void populateWithCatalogue(const DBCatalogue &catalogue);
26
26
27 private:
27 private:
28 Ui::CatalogueEventsWidget *ui;
28 Ui::CatalogueEventsWidget *ui;
29
29
30 class CatalogueEventsWidgetPrivate;
30 class CatalogueEventsWidgetPrivate;
31 spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl;
31 spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl;
32 };
32 };
33
33
34 #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H
34 #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H
@@ -1,86 +1,91
1 #include "Catalogue/CatalogueEventsWidget.h"
1 #include "Catalogue/CatalogueEventsWidget.h"
2 #include "ui_CatalogueEventsWidget.h"
2 #include "ui_CatalogueEventsWidget.h"
3
3
4 #include <Catalogue/CatalogueController.h>
4 #include <Catalogue/CatalogueController.h>
5 #include <Catalogue/CatalogueEventsTableModel.h>
5 #include <Catalogue/CatalogueEventsTableModel.h>
6 #include <CatalogueDao.h>
6 #include <CatalogueDao.h>
7 #include <DBCatalogue.h>
7 #include <DBCatalogue.h>
8 #include <SqpApplication.h>
8 #include <SqpApplication.h>
9
9
10
10
11 /// Format of the dates appearing in the label of a cursor
11 /// Format of the dates appearing in the label of a cursor
12 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
12 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
13
13
14 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
14 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
15
15
16 CatalogueEventsTableModel *m_Model = nullptr;
16 CatalogueEventsTableModel *m_Model = nullptr;
17 };
17 };
18
18
19
19
20 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
20 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
21 : QWidget(parent),
21 : QWidget(parent),
22 ui(new Ui::CatalogueEventsWidget),
22 ui(new Ui::CatalogueEventsWidget),
23 impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()}
23 impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()}
24 {
24 {
25 ui->setupUi(this);
25 ui->setupUi(this);
26
26
27 impl->m_Model = new CatalogueEventsTableModel(this);
27 impl->m_Model = new CatalogueEventsTableModel(this);
28 ui->tableView->setModel(impl->m_Model);
28 ui->tableView->setModel(impl->m_Model);
29
29
30 ui->tableView->setSortingEnabled(true);
30 ui->tableView->setSortingEnabled(true);
31
31
32 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
32 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
33 if (checked) {
33 if (checked) {
34 ui->btnChart->setChecked(false);
34 ui->btnChart->setChecked(false);
35 }
35 }
36 });
36 });
37
37
38 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
38 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
39 if (checked) {
39 if (checked) {
40 ui->btnTime->setChecked(false);
40 ui->btnTime->setChecked(false);
41 }
41 }
42 });
42 });
43
43
44 connect(ui->tableView, &QTableView::clicked, [this](auto index) {
44 connect(ui->tableView, &QTableView::clicked, [this](auto index) {
45 auto event = impl->m_Model->getEvent(index.row());
45 QVector<DBEvent> events;
46 emit this->eventSelected(event);
46 for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) {
47 events << impl->m_Model->getEvent(rowIndex.row());
48 }
49
50 emit this->eventsSelected(events);
47 });
51 });
48
52
49 connect(ui->tableView->selectionModel(), &QItemSelectionModel::currentChanged,
53 connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() {
50 [this](auto current, auto previous) {
54 QVector<DBEvent> events;
51 if (current.isValid() && current.row() >= 0) {
55 for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) {
52 auto event = impl->m_Model->getEvent(current.row());
56 events << impl->m_Model->getEvent(rowIndex.row());
53 emit this->eventSelected(event);
57 }
54 }
58
55 });
59 emit this->eventsSelected(events);
60 });
56
61
57 connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() {
62 connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() {
58 auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1;
63 auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1;
59 ui->btnChart->setEnabled(isNotMultiSelection);
64 ui->btnChart->setEnabled(isNotMultiSelection);
60 ui->btnTime->setEnabled(isNotMultiSelection);
65 ui->btnTime->setEnabled(isNotMultiSelection);
61 });
66 });
62
67
63 ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
68 ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
64 ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
69 ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
65 ui->tableView->horizontalHeader()->setSortIndicatorShown(true);
70 ui->tableView->horizontalHeader()->setSortIndicatorShown(true);
66 }
71 }
67
72
68 CatalogueEventsWidget::~CatalogueEventsWidget()
73 CatalogueEventsWidget::~CatalogueEventsWidget()
69 {
74 {
70 delete ui;
75 delete ui;
71 }
76 }
72
77
73 void CatalogueEventsWidget::populateWithCatalogue(const DBCatalogue &catalogue)
78 void CatalogueEventsWidget::populateWithCatalogue(const DBCatalogue &catalogue)
74 {
79 {
75 auto &dao = sqpApp->catalogueController().getDao();
80 auto &dao = sqpApp->catalogueController().getDao();
76 auto events = dao.getCatalogueEvents(catalogue);
81 auto events = dao.getCatalogueEvents(catalogue);
77
82
78 QVector<DBEvent> eventVector;
83 QVector<DBEvent> eventVector;
79 for (auto event : events) {
84 for (auto event : events) {
80 eventVector << event;
85 eventVector << event;
81 }
86 }
82
87
83 ui->tableView->setSortingEnabled(false);
88 ui->tableView->setSortingEnabled(false);
84 impl->m_Model->setEvents(eventVector);
89 impl->m_Model->setEvents(eventVector);
85 ui->tableView->setSortingEnabled(true);
90 ui->tableView->setSortingEnabled(true);
86 }
91 }
@@ -1,25 +1,31
1 #include "Catalogue/CatalogueExplorer.h"
1 #include "Catalogue/CatalogueExplorer.h"
2 #include "ui_CatalogueExplorer.h"
2 #include "ui_CatalogueExplorer.h"
3
3
4 #include <DBCatalogue.h>
4 #include <DBCatalogue.h>
5 #include <DBEvent.h>
5 #include <DBEvent.h>
6
6
7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
8 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
8 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
9 ui(new Ui::CatalogueExplorer)
9 ui(new Ui::CatalogueExplorer)
10 {
10 {
11 ui->setupUi(this);
11 ui->setupUi(this);
12
12
13 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogue) {
13 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogue) {
14 ui->inspector->setCatalogue(catalogue);
14 ui->inspector->setCatalogue(catalogue);
15 ui->events->populateWithCatalogue(catalogue);
15 ui->events->populateWithCatalogue(catalogue);
16 });
16 });
17
17
18 connect(ui->events, &CatalogueEventsWidget::eventSelected,
18 connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) {
19 [this](auto event) { ui->inspector->setEvent(event); });
19 if (events.count() == 1) {
20 ui->inspector->setEvent(events.first());
21 }
22 else {
23 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
24 }
25 });
20 }
26 }
21
27
22 CatalogueExplorer::~CatalogueExplorer()
28 CatalogueExplorer::~CatalogueExplorer()
23 {
29 {
24 delete ui;
30 delete ui;
25 }
31 }
General Comments 0
You need to be logged in to leave comments. Login now