Auto status change to "Under Review"
@@ -1,99 +1,100 | |||||
1 | #include "Catalogue/CatalogueEventsWidget.h" |
|
1 | #include "Catalogue/CatalogueEventsWidget.h" | |
2 | #include "ui_CatalogueEventsWidget.h" |
|
2 | #include "ui_CatalogueEventsWidget.h" | |
3 |
|
3 | |||
4 | #include <QtDebug> |
|
4 | #include <QtDebug> | |
5 |
|
5 | |||
6 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
6 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |
7 | void addEventItem(const QStringList &data, QTableWidget *tableWidget); |
|
7 | void addEventItem(const QStringList &data, QTableWidget *tableWidget); | |
8 |
|
8 | |||
9 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; |
|
9 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; | |
10 | QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; } |
|
10 | QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; } | |
11 | }; |
|
11 | }; | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) |
|
14 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |
15 | : QWidget(parent), |
|
15 | : QWidget(parent), | |
16 | ui(new Ui::CatalogueEventsWidget), |
|
16 | ui(new Ui::CatalogueEventsWidget), | |
17 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} |
|
17 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} | |
18 | { |
|
18 | { | |
19 | ui->setupUi(this); |
|
19 | ui->setupUi(this); | |
20 |
|
20 | |||
21 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { |
|
21 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { | |
22 | if (checked) { |
|
22 | if (checked) { | |
23 | ui->btnChart->setChecked(false); |
|
23 | ui->btnChart->setChecked(false); | |
24 | } |
|
24 | } | |
25 | }); |
|
25 | }); | |
26 |
|
26 | |||
27 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { |
|
27 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { | |
28 | if (checked) { |
|
28 | if (checked) { | |
29 | ui->btnTime->setChecked(false); |
|
29 | ui->btnTime->setChecked(false); | |
30 | } |
|
30 | } | |
31 | }); |
|
31 | }); | |
32 |
|
32 | |||
33 | connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) { |
|
33 | connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) { | |
34 | auto event = ui->tableWidget->item(row, 0)->text(); |
|
34 | auto event = ui->tableWidget->item(row, 0)->text(); | |
35 | emit this->eventSelected(event); |
|
35 | emit this->eventSelected(event); | |
36 | }); |
|
36 | }); | |
37 |
|
37 | |||
38 | connect(ui->tableWidget, &QTableWidget::currentItemChanged, |
|
38 | connect(ui->tableWidget, &QTableWidget::currentItemChanged, | |
39 | [this](auto current, auto previous) { |
|
39 | [this](auto current, auto previous) { | |
40 | if (current && current->row() >= 0) { |
|
40 | if (current && current->row() >= 0) { | |
41 | auto event = ui->tableWidget->item(current->row(), 0)->text(); |
|
41 | auto event = ui->tableWidget->item(current->row(), 0)->text(); | |
42 | emit this->eventSelected(event); |
|
42 | emit this->eventSelected(event); | |
43 | } |
|
43 | } | |
44 | }); |
|
44 | }); | |
45 |
|
45 | |||
46 | connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, [this]() { |
|
46 | connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, [this]() { | |
47 | auto selection = ui->tableWidget->selectedRanges(); |
|
47 | auto selection = ui->tableWidget->selectedRanges(); | |
48 | auto isSingleSelection = selection.count() == 1 && selection.first().rowCount() == 1; |
|
48 | auto isNotMultiSelection | |
49 | ui->btnChart->setEnabled(isSingleSelection); |
|
49 | = selection.isEmpty() || (selection.count() == 1 && selection.first().rowCount() == 1); | |
50 |
ui->btn |
|
50 | ui->btnChart->setEnabled(isNotMultiSelection); | |
|
51 | ui->btnTime->setEnabled(isNotMultiSelection); | |||
51 | }); |
|
52 | }); | |
52 |
|
53 | |||
53 | Q_ASSERT(impl->columnNames().count() == (int)CatalogueEventsWidgetPrivate::Column::NbColumn); |
|
54 | Q_ASSERT(impl->columnNames().count() == (int)CatalogueEventsWidgetPrivate::Column::NbColumn); | |
54 | ui->tableWidget->setColumnCount((int)CatalogueEventsWidgetPrivate::Column::NbColumn); |
|
55 | ui->tableWidget->setColumnCount((int)CatalogueEventsWidgetPrivate::Column::NbColumn); | |
55 | ui->tableWidget->setHorizontalHeaderLabels(impl->columnNames()); |
|
56 | ui->tableWidget->setHorizontalHeaderLabels(impl->columnNames()); | |
56 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
|
57 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
57 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
|
58 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); | |
58 | ui->tableWidget->horizontalHeader()->setSortIndicatorShown(true); |
|
59 | ui->tableWidget->horizontalHeader()->setSortIndicatorShown(true); | |
59 | } |
|
60 | } | |
60 |
|
61 | |||
61 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
62 | CatalogueEventsWidget::~CatalogueEventsWidget() | |
62 | { |
|
63 | { | |
63 | delete ui; |
|
64 | delete ui; | |
64 | } |
|
65 | } | |
65 |
|
66 | |||
66 | void CatalogueEventsWidget::populateWithCatalogue(const QString &catalogue) |
|
67 | void CatalogueEventsWidget::populateWithCatalogue(const QString &catalogue) | |
67 | { |
|
68 | { | |
68 | ui->tableWidget->clearContents(); |
|
69 | ui->tableWidget->clearContents(); | |
69 | ui->tableWidget->setRowCount(0); |
|
70 | ui->tableWidget->setRowCount(0); | |
70 |
|
71 | |||
71 | // TODO |
|
72 | // TODO | |
72 | impl->addEventItem( |
|
73 | impl->addEventItem( | |
73 | {catalogue + " - Event 1", "12/12/2012 12:12", "12/12/2042 12:52", "cloud", "mfi/b_gse42"}, |
|
74 | {catalogue + " - Event 1", "12/12/2012 12:12", "12/12/2042 12:52", "cloud", "mfi/b_gse42"}, | |
74 | ui->tableWidget); |
|
75 | ui->tableWidget); | |
75 | impl->addEventItem( |
|
76 | impl->addEventItem( | |
76 | {catalogue + " - Event 2", "12/12/2012 12:10", "12/12/2042 12:42", "Acloud", "mfi/b_gse1"}, |
|
77 | {catalogue + " - Event 2", "12/12/2012 12:10", "12/12/2042 12:42", "Acloud", "mfi/b_gse1"}, | |
77 | ui->tableWidget); |
|
78 | ui->tableWidget); | |
78 | impl->addEventItem( |
|
79 | impl->addEventItem( | |
79 | {catalogue + " - Event 3", "12/12/2012 12:22", "12/12/2042 12:12", "Gcloud", "mfi/b_gse2"}, |
|
80 | {catalogue + " - Event 3", "12/12/2012 12:22", "12/12/2042 12:12", "Gcloud", "mfi/b_gse2"}, | |
80 | ui->tableWidget); |
|
81 | ui->tableWidget); | |
81 | impl->addEventItem( |
|
82 | impl->addEventItem( | |
82 | {catalogue + " - Event 4", "12/12/2012 12:00", "12/12/2042 12:62", "Bcloud", "mfi/b_gse3"}, |
|
83 | {catalogue + " - Event 4", "12/12/2012 12:00", "12/12/2042 12:62", "Bcloud", "mfi/b_gse3"}, | |
83 | ui->tableWidget); |
|
84 | ui->tableWidget); | |
84 | } |
|
85 | } | |
85 |
|
86 | |||
86 | void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data, |
|
87 | void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data, | |
87 | QTableWidget *tableWidget) |
|
88 | QTableWidget *tableWidget) | |
88 | { |
|
89 | { | |
89 | tableWidget->setSortingEnabled(false); |
|
90 | tableWidget->setSortingEnabled(false); | |
90 | auto row = tableWidget->rowCount(); |
|
91 | auto row = tableWidget->rowCount(); | |
91 | tableWidget->setRowCount(row + 1); |
|
92 | tableWidget->setRowCount(row + 1); | |
92 |
|
93 | |||
93 | for (auto i = 0; i < (int)Column::NbColumn; ++i) { |
|
94 | for (auto i = 0; i < (int)Column::NbColumn; ++i) { | |
94 | auto item = new QTableWidgetItem(data.value(i)); |
|
95 | auto item = new QTableWidgetItem(data.value(i)); | |
95 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
96 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); | |
96 | tableWidget->setItem(row, i, item); |
|
97 | tableWidget->setItem(row, i, item); | |
97 | } |
|
98 | } | |
98 | tableWidget->setSortingEnabled(true); |
|
99 | tableWidget->setSortingEnabled(true); | |
99 | } |
|
100 | } |
@@ -1,22 +1,22 | |||||
1 | #include "Catalogue/CatalogueExplorer.h" |
|
1 | #include "Catalogue/CatalogueExplorer.h" | |
2 | #include "ui_CatalogueExplorer.h" |
|
2 | #include "ui_CatalogueExplorer.h" | |
3 |
|
3 | |||
4 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
4 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |
5 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
5 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), | |
6 | ui(new Ui::CatalogueExplorer) |
|
6 | ui(new Ui::CatalogueExplorer) | |
7 | { |
|
7 | { | |
8 | ui->setupUi(this); |
|
8 | ui->setupUi(this); | |
9 |
|
9 | |||
10 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto name) { |
|
10 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto name) { | |
11 |
ui->inspector->set |
|
11 | ui->inspector->setCatalogue(name); | |
12 | ui->events->populateWithCatalogue(name); |
|
12 | ui->events->populateWithCatalogue(name); | |
13 | }); |
|
13 | }); | |
14 |
|
14 | |||
15 | connect(ui->events, &CatalogueEventsWidget::eventSelected, |
|
15 | connect(ui->events, &CatalogueEventsWidget::eventSelected, | |
16 |
[this](auto name) { ui->inspector->set |
|
16 | [this](auto name) { ui->inspector->setEvent(name); }); | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | CatalogueExplorer::~CatalogueExplorer() |
|
19 | CatalogueExplorer::~CatalogueExplorer() | |
20 | { |
|
20 | { | |
21 | delete ui; |
|
21 | delete ui; | |
22 | } |
|
22 | } |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now