@@ -1,25 +1,31 | |||
|
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 | namespace Ui { |
|
8 | 8 | class CatalogueEventsWidget; |
|
9 | 9 | } |
|
10 | 10 | |
|
11 | 11 | class CatalogueEventsWidget : public QWidget { |
|
12 | 12 | Q_OBJECT |
|
13 | 13 | |
|
14 | signals: | |
|
15 | void eventSelected(); | |
|
16 | ||
|
14 | 17 | public: |
|
15 | 18 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
|
16 | 19 | virtual ~CatalogueEventsWidget(); |
|
17 | 20 | |
|
21 | public slots: | |
|
22 | void populateWithCatalogue(const QString &catalogue); | |
|
23 | ||
|
18 | 24 | private: |
|
19 | 25 | Ui::CatalogueEventsWidget *ui; |
|
20 | 26 | |
|
21 | 27 | class CatalogueEventsWidgetPrivate; |
|
22 | 28 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; |
|
23 | 29 | }; |
|
24 | 30 | |
|
25 | 31 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
@@ -1,25 +1,31 | |||
|
1 | 1 | #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
2 | 2 | #define SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
3 | 3 | |
|
4 | 4 | #include <Common/spimpl.h> |
|
5 | #include <QTreeWidgetItem> | |
|
5 | 6 | #include <QWidget> |
|
6 | 7 | |
|
7 | 8 | namespace Ui { |
|
8 | 9 | class CatalogueSideBarWidget; |
|
9 | 10 | } |
|
10 | 11 | |
|
11 | 12 | class CatalogueSideBarWidget : public QWidget { |
|
12 | 13 | Q_OBJECT |
|
13 | 14 | |
|
15 | signals: | |
|
16 | void catalogueSelected(const QString &catalogue); | |
|
17 | void allEventsSelected(); | |
|
18 | void trashSelected(); | |
|
19 | ||
|
14 | 20 | public: |
|
15 | 21 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
16 | 22 | virtual ~CatalogueSideBarWidget(); |
|
17 | 23 | |
|
18 | 24 | private: |
|
19 | 25 | Ui::CatalogueSideBarWidget *ui; |
|
20 | 26 | |
|
21 | 27 | class CatalogueSideBarWidgetPrivate; |
|
22 | 28 | spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl; |
|
23 | 29 | }; |
|
24 | 30 | |
|
25 | 31 | #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H |
@@ -1,66 +1,78 | |||
|
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 | connect(ui->tableWidget, &QTableWidget::cellClicked, | |
|
32 | [this](auto row, auto column) { emit this->eventSelected(); }); | |
|
33 | ||
|
31 | 34 | Q_ASSERT(impl->columnNames().count() == (int)CatalogueEventsWidgetPrivate::Column::NbColumn); |
|
32 | 35 | ui->tableWidget->setColumnCount((int)CatalogueEventsWidgetPrivate::Column::NbColumn); |
|
33 | 36 | ui->tableWidget->setHorizontalHeaderLabels(impl->columnNames()); |
|
34 | 37 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
|
35 | 38 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
|
36 | 39 | ui->tableWidget->horizontalHeader()->setSortIndicatorShown(true); |
|
37 | ||
|
38 | ||
|
39 | // test | |
|
40 | impl->addEventItem({"Event 1", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
41 | ui->tableWidget); | |
|
42 | impl->addEventItem({"Event 2", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
43 | ui->tableWidget); | |
|
44 | impl->addEventItem({"Event 3", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
45 | ui->tableWidget); | |
|
46 | impl->addEventItem({"Event 4", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
47 | ui->tableWidget); | |
|
48 | 40 | } |
|
49 | 41 | |
|
50 | 42 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
51 | 43 | { |
|
52 | 44 | delete ui; |
|
53 | 45 | } |
|
54 | 46 | |
|
47 | void CatalogueEventsWidget::populateWithCatalogue(const QString &catalogue) | |
|
48 | { | |
|
49 | ui->tableWidget->clearContents(); | |
|
50 | ui->tableWidget->setRowCount(0); | |
|
51 | ||
|
52 | // TODO | |
|
53 | impl->addEventItem( | |
|
54 | {catalogue + " - Event 1", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
55 | ui->tableWidget); | |
|
56 | impl->addEventItem( | |
|
57 | {catalogue + " - Event 2", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
58 | ui->tableWidget); | |
|
59 | impl->addEventItem( | |
|
60 | {catalogue + " - Event 3", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
61 | ui->tableWidget); | |
|
62 | impl->addEventItem( | |
|
63 | {catalogue + " - Event 4", "12/12/2012 12:12", "12/12/2042 12:42", "cloud", "mfi/b_gse"}, | |
|
64 | ui->tableWidget); | |
|
65 | } | |
|
66 | ||
|
55 | 67 | void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data, |
|
56 | 68 | QTableWidget *tableWidget) |
|
57 | 69 | { |
|
58 | 70 | auto row = tableWidget->rowCount(); |
|
59 | 71 | tableWidget->setRowCount(row + 1); |
|
60 | 72 | |
|
61 | 73 | for (auto i = 0; i < (int)Column::NbColumn; ++i) { |
|
62 | 74 | auto item = new QTableWidgetItem(data.value(i)); |
|
63 | 75 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
64 | 76 | tableWidget->setItem(row, i, item); |
|
65 | 77 | } |
|
66 | 78 | } |
@@ -1,14 +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 | ||
|
10 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto name) { | |
|
11 | ui->inspector->showPage(CatalogueInspectorWidget::Page::CatalogueProperties); | |
|
12 | ui->events->populateWithCatalogue(name); | |
|
13 | }); | |
|
14 | ||
|
15 | connect(ui->events, &CatalogueEventsWidget::eventSelected, | |
|
16 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::EventProperties); }); | |
|
9 | 17 | } |
|
10 | 18 | |
|
11 | 19 | CatalogueExplorer::~CatalogueExplorer() |
|
12 | 20 | { |
|
13 | 21 | delete ui; |
|
14 | 22 | } |
@@ -1,81 +1,98 | |||
|
1 | 1 | #include "Catalogue/CatalogueSideBarWidget.h" |
|
2 | 2 | #include "ui_CatalogueSideBarWidget.h" |
|
3 | 3 | |
|
4 | auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; | |
|
5 | auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1; | |
|
6 | auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2; | |
|
7 | auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3; | |
|
4 | constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; | |
|
5 | constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1; | |
|
6 | constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2; | |
|
7 | constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3; | |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { |
|
11 | 11 | void configureTreeWidget(QTreeWidget *treeWidget); |
|
12 | 12 | QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget); |
|
13 | 13 | void addCatalogueItem(const QString &name, QTreeWidgetItem *parentDatabaseItem); |
|
14 | 14 | }; |
|
15 | 15 | |
|
16 | 16 | CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) |
|
17 | 17 | : QWidget(parent), |
|
18 | 18 | ui(new Ui::CatalogueSideBarWidget), |
|
19 | 19 | impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()} |
|
20 | 20 | { |
|
21 | 21 | ui->setupUi(this); |
|
22 | 22 | impl->configureTreeWidget(ui->treeWidget); |
|
23 | ||
|
24 | connect(ui->treeWidget, &QTreeWidget::itemClicked, [this](auto item) { | |
|
25 | switch (item->type()) { | |
|
26 | case CATALOGUE_ITEM_TYPE: | |
|
27 | emit this->catalogueSelected(item->text(0)); | |
|
28 | break; | |
|
29 | case ALL_EVENT_ITEM_TYPE: | |
|
30 | emit this->allEventsSelected(); | |
|
31 | break; | |
|
32 | case TRASH_ITEM_TYPE: | |
|
33 | emit this->trashSelected(); | |
|
34 | break; | |
|
35 | case DATABASE_ITEM_TYPE: | |
|
36 | default: | |
|
37 | break; | |
|
38 | } | |
|
39 | }); | |
|
23 | 40 | } |
|
24 | 41 | |
|
25 | 42 | CatalogueSideBarWidget::~CatalogueSideBarWidget() |
|
26 | 43 | { |
|
27 | 44 | delete ui; |
|
28 | 45 | } |
|
29 | 46 | |
|
30 | 47 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget( |
|
31 | 48 | QTreeWidget *treeWidget) |
|
32 | 49 | { |
|
33 | 50 | auto allEventsItem = new QTreeWidgetItem({"All Events"}, ALL_EVENT_ITEM_TYPE); |
|
34 | 51 | allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png")); |
|
35 | 52 | treeWidget->addTopLevelItem(allEventsItem); |
|
36 | 53 | |
|
37 | 54 | auto trashItem = new QTreeWidgetItem({"Trash"}, TRASH_ITEM_TYPE); |
|
38 | 55 | trashItem->setIcon(0, QIcon(":/icones/trash.png")); |
|
39 | 56 | treeWidget->addTopLevelItem(trashItem); |
|
40 | 57 | |
|
41 | 58 | auto separator = new QFrame(treeWidget); |
|
42 | 59 | separator->setFrameShape(QFrame::HLine); |
|
43 | 60 | |
|
44 | 61 | auto separatorItem = new QTreeWidgetItem(); |
|
45 | 62 | separatorItem->setFlags(Qt::NoItemFlags); |
|
46 | 63 | treeWidget->addTopLevelItem(separatorItem); |
|
47 | 64 | treeWidget->setItemWidget(separatorItem, 0, separator); |
|
48 | 65 | |
|
49 | 66 | // Test |
|
50 | 67 | auto db = addDatabaseItem("Database 1", treeWidget); |
|
51 | 68 | addCatalogueItem("Catalogue 1", db); |
|
52 | 69 | addCatalogueItem("Catalogue 2", db); |
|
53 | 70 | addCatalogueItem("Catalogue 3", db); |
|
54 | 71 | addCatalogueItem("Catalogue 4", db); |
|
55 | 72 | |
|
56 | 73 | auto db2 = addDatabaseItem("Database 2", treeWidget); |
|
57 | 74 | addCatalogueItem("Catalogue A", db2); |
|
58 | 75 | addCatalogueItem("Catalogue B", db2); |
|
59 | 76 | addCatalogueItem("Catalogue C", db2); |
|
60 | 77 | |
|
61 | 78 | treeWidget->expandAll(); |
|
62 | 79 | } |
|
63 | 80 | |
|
64 | 81 | QTreeWidgetItem * |
|
65 | 82 | CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name, |
|
66 | 83 | QTreeWidget *treeWidget) |
|
67 | 84 | { |
|
68 | 85 | auto databaseItem = new QTreeWidgetItem({name}, DATABASE_ITEM_TYPE); |
|
69 | 86 | databaseItem->setIcon(0, QIcon(":/icones/database.png")); |
|
70 | 87 | treeWidget->addTopLevelItem(databaseItem); |
|
71 | 88 | |
|
72 | 89 | return databaseItem; |
|
73 | 90 | } |
|
74 | 91 | |
|
75 | 92 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( |
|
76 | 93 | const QString &name, QTreeWidgetItem *parentDatabaseItem) |
|
77 | 94 | { |
|
78 | 95 | auto catalogueItem = new QTreeWidgetItem({name}, CATALOGUE_ITEM_TYPE); |
|
79 | 96 | catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png")); |
|
80 | 97 | parentDatabaseItem->addChild(catalogueItem); |
|
81 | 98 | } |
General Comments 0
You need to be logged in to leave comments.
Login now