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