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