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

Auto status change to "Under Review"

Approved

Status change > Approved

You need to be logged in to leave comments. Login now