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