##// END OF EJS Templates
Display catalogues and events with CatalogueAPI
trabillard -
r1129:9abcd350a712
parent child
Show More
@@ -0,0 +1,22
1 #ifndef SCIQLOP_CATALOGUETREEWIDGETITEM_H
2 #define SCIQLOP_CATALOGUETREEWIDGETITEM_H
3
4 #include <Common/spimpl.h>
5 #include <QTreeWidgetItem>
6
7 #include <DBCatalogue.h>
8
9
10 class CatalogueTreeWidgetItem : public QTreeWidgetItem {
11 public:
12 CatalogueTreeWidgetItem(DBCatalogue catalogue, int type = QTreeWidgetItem::Type);
13
14 QVariant data(int column, int role) const override;
15 DBCatalogue catalogue() const;
16
17 private:
18 class CatalogueTreeWidgetItemPrivate;
19 spimpl::unique_impl_ptr<CatalogueTreeWidgetItemPrivate> impl;
20 };
21
22 #endif // SCIQLOP_CATALOGUETREEWIDGETITEM_H
@@ -0,0 +1,32
1 #include "Catalogue/CatalogueTreeWidgetItem.h"
2
3 struct CatalogueTreeWidgetItem::CatalogueTreeWidgetItemPrivate {
4
5 DBCatalogue m_Catalogue;
6
7 CatalogueTreeWidgetItemPrivate(DBCatalogue catalogue) : m_Catalogue(catalogue) {}
8 };
9
10
11 CatalogueTreeWidgetItem::CatalogueTreeWidgetItem(DBCatalogue catalogue, int type)
12 : QTreeWidgetItem(type),
13 impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)}
14 {
15 }
16
17 QVariant CatalogueTreeWidgetItem::data(int column, int role) const
18 {
19 switch (role) {
20 case Qt::DisplayRole:
21 return impl->m_Catalogue.getName();
22 default:
23 break;
24 }
25
26 return QTreeWidgetItem::data(column, role);
27 }
28
29 DBCatalogue CatalogueTreeWidgetItem::catalogue() const
30 {
31 return impl->m_Catalogue;
32 }
@@ -75,6 +75,16 INSTALL(TARGETS ${SQPGUI_LIBRARY_NAME}
75 )
75 )
76 add_dependencies(${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
76 add_dependencies(${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
77
77
78 # Find CATALOGUE_API
79 include_directories("${CATALOGUEAPI_INCLUDE}")
80 TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES})
81 INSTALL(TARGETS ${SQPGUI_LIBRARY_NAME}
82 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
83 LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
84 ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR}
85 )
86
87 add_dependencies(${SQPGUI_LIBRARY_NAME} CatalogueAPI)
78
88
79 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
89 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
80 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
90 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
@@ -4,6 +4,9
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QWidget>
5 #include <QWidget>
6
6
7 class DBCatalogue;
8 class DBEvent;
9
7 namespace Ui {
10 namespace Ui {
8 class CatalogueEventsWidget;
11 class CatalogueEventsWidget;
9 }
12 }
@@ -12,14 +15,14 class CatalogueEventsWidget : public QWidget {
12 Q_OBJECT
15 Q_OBJECT
13
16
14 signals:
17 signals:
15 void eventSelected(const QString &event);
18 void eventSelected(const DBEvent &event);
16
19
17 public:
20 public:
18 explicit CatalogueEventsWidget(QWidget *parent = 0);
21 explicit CatalogueEventsWidget(QWidget *parent = 0);
19 virtual ~CatalogueEventsWidget();
22 virtual ~CatalogueEventsWidget();
20
23
21 public slots:
24 public slots:
22 void populateWithCatalogue(const QString &catalogue);
25 void populateWithCatalogue(const DBCatalogue &catalogue);
23
26
24 private:
27 private:
25 Ui::CatalogueEventsWidget *ui;
28 Ui::CatalogueEventsWidget *ui;
@@ -7,6 +7,9 namespace Ui {
7 class CatalogueInspectorWidget;
7 class CatalogueInspectorWidget;
8 }
8 }
9
9
10 class DBCatalogue;
11 class DBEvent;
12
10 class CatalogueInspectorWidget : public QWidget {
13 class CatalogueInspectorWidget : public QWidget {
11 Q_OBJECT
14 Q_OBJECT
12
15
@@ -19,8 +22,8 public:
19
22
20 Page currentPage() const;
23 Page currentPage() const;
21
24
22 void setEvent(const QString &event);
25 void setEvent(const DBEvent &event);
23 void setCatalogue(const QString &catalogue);
26 void setCatalogue(const DBCatalogue &catalogue);
24
27
25 public slots:
28 public slots:
26 void showPage(Page page);
29 void showPage(Page page);
@@ -5,6 +5,8
5 #include <QTreeWidgetItem>
5 #include <QTreeWidgetItem>
6 #include <QWidget>
6 #include <QWidget>
7
7
8 #include <DBCatalogue.h>
9
8 namespace Ui {
10 namespace Ui {
9 class CatalogueSideBarWidget;
11 class CatalogueSideBarWidget;
10 }
12 }
@@ -13,7 +15,7 class CatalogueSideBarWidget : public QWidget {
13 Q_OBJECT
15 Q_OBJECT
14
16
15 signals:
17 signals:
16 void catalogueSelected(const QString &catalogue);
18 void catalogueSelected(const DBCatalogue &catalogue);
17 void allEventsSelected();
19 void allEventsSelected();
18 void trashSelected();
20 void trashSelected();
19
21
@@ -1,4 +1,7
1
1
2 qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep'])
3 catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep'])
4
2 gui_moc_headers = [
5 gui_moc_headers = [
3 'include/DataSource/DataSourceWidget.h',
6 'include/DataSource/DataSourceWidget.h',
4 'include/Settings/SqpSettingsDialog.h',
7 'include/Settings/SqpSettingsDialog.h',
@@ -103,7 +106,8 gui_sources = [
103 'src/Catalogue/CatalogueExplorer.cpp',
106 'src/Catalogue/CatalogueExplorer.cpp',
104 'src/Catalogue/CatalogueEventsWidget.cpp',
107 'src/Catalogue/CatalogueEventsWidget.cpp',
105 'src/Catalogue/CatalogueSideBarWidget.cpp',
108 'src/Catalogue/CatalogueSideBarWidget.cpp',
106 'src/Catalogue/CatalogueInspectorWidget.cpp'
109 'src/Catalogue/CatalogueInspectorWidget.cpp',
110 'src/Catalogue/CatalogueTreeWidgetItem.cpp'
107 ]
111 ]
108
112
109 gui_inc = include_directories(['include'])
113 gui_inc = include_directories(['include'])
@@ -112,11 +116,11 sciqlop_gui_lib = library('sciqlopgui',
112 gui_sources,
116 gui_sources,
113 gui_moc_files,
117 gui_moc_files,
114 include_directories : [gui_inc],
118 include_directories : [gui_inc],
115 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core],
119 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep],
116 install : true
120 install : true
117 )
121 )
118
122
119 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
123 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
120 include_directories : gui_inc,
124 include_directories : gui_inc,
121 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core])
125 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep])
122
126
@@ -1,13 +1,22
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 <Catalogue/CatalogueController.h>
5 #include <CatalogueDao.h>
6 #include <DBCatalogue.h>
7 #include <SqpApplication.h>
8
9
10 /// Format of the dates appearing in the label of a cursor
11 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
5
12
6 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
13 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
7 void addEventItem(const QStringList &data, QTableWidget *tableWidget);
14 void addEventItem(const QStringList &data, QTableWidget *tableWidget);
8
15
9 enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn };
16 enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn };
10 QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; }
17 QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; }
18
19 QVector<DBEvent> m_Events;
11 };
20 };
12
21
13
22
@@ -31,14 +40,14 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
31 });
40 });
32
41
33 connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) {
42 connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) {
34 auto event = ui->tableWidget->item(row, 0)->text();
43 auto event = impl->m_Events.value(row);
35 emit this->eventSelected(event);
44 emit this->eventSelected(event);
36 });
45 });
37
46
38 connect(ui->tableWidget, &QTableWidget::currentItemChanged,
47 connect(ui->tableWidget, &QTableWidget::currentItemChanged,
39 [this](auto current, auto previous) {
48 [this](auto current, auto previous) {
40 if (current && current->row() >= 0) {
49 if (current && current->row() >= 0) {
41 auto event = ui->tableWidget->item(current->row(), 0)->text();
50 auto event = impl->m_Events.value(current->row());
42 emit this->eventSelected(event);
51 emit this->eventSelected(event);
43 }
52 }
44 });
53 });
@@ -64,24 +73,30 CatalogueEventsWidget::~CatalogueEventsWidget()
64 delete ui;
73 delete ui;
65 }
74 }
66
75
67 void CatalogueEventsWidget::populateWithCatalogue(const QString &catalogue)
76 void CatalogueEventsWidget::populateWithCatalogue(const DBCatalogue &catalogue)
68 {
77 {
69 ui->tableWidget->clearContents();
78 ui->tableWidget->clearContents();
70 ui->tableWidget->setRowCount(0);
79 ui->tableWidget->setRowCount(0);
71
80
72 // TODO
81 auto &dao = sqpApp->catalogueController().getDao();
73 impl->addEventItem(
82 auto events = dao.getCatalogueEvents(catalogue);
74 {catalogue + " - Event 1", "12/12/2012 12:12", "12/12/2042 12:52", "cloud", "mfi/b_gse42"},
83
75 ui->tableWidget);
84 for (auto event : events) {
76 impl->addEventItem(
85 impl->m_Events << event;
77 {catalogue + " - Event 2", "12/12/2012 12:10", "12/12/2042 12:42", "Acloud", "mfi/b_gse1"},
86
78 ui->tableWidget);
87 auto tags = event.getTags();
79 impl->addEventItem(
88 QString tagList;
80 {catalogue + " - Event 3", "12/12/2012 12:22", "12/12/2042 12:12", "Gcloud", "mfi/b_gse2"},
89 for (auto tag : tags) {
81 ui->tableWidget);
90 tagList += tag.getName();
82 impl->addEventItem(
91 tagList += ' ';
83 {catalogue + " - Event 4", "12/12/2012 12:00", "12/12/2042 12:62", "Bcloud", "mfi/b_gse3"},
92 }
84 ui->tableWidget);
93
94 impl->addEventItem({event.getName(),
95 DateUtils::dateTime(event.getTStart()).toString(DATETIME_FORMAT),
96 DateUtils::dateTime(event.getTEnd()).toString(DATETIME_FORMAT), tagList,
97 event.getProduct()},
98 ui->tableWidget);
99 }
85 }
100 }
86
101
87 void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data,
102 void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data,
@@ -1,19 +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 #include <DBCatalogue.h>
5 #include <DBEvent.h>
6
4 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
5 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
8 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
6 ui(new Ui::CatalogueExplorer)
9 ui(new Ui::CatalogueExplorer)
7 {
10 {
8 ui->setupUi(this);
11 ui->setupUi(this);
9
12
10 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto name) {
13 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogue) {
11 ui->inspector->setCatalogue(name);
14 ui->inspector->setCatalogue(catalogue);
12 ui->events->populateWithCatalogue(name);
15 ui->events->populateWithCatalogue(catalogue);
13 });
16 });
14
17
15 connect(ui->events, &CatalogueEventsWidget::eventSelected,
18 connect(ui->events, &CatalogueEventsWidget::eventSelected,
16 [this](auto name) { ui->inspector->setEvent(name); });
19 [this](auto event) { ui->inspector->setEvent(event); });
17 }
20 }
18
21
19 CatalogueExplorer::~CatalogueExplorer()
22 CatalogueExplorer::~CatalogueExplorer()
@@ -1,6 +1,11
1 #include "Catalogue/CatalogueInspectorWidget.h"
1 #include "Catalogue/CatalogueInspectorWidget.h"
2 #include "ui_CatalogueInspectorWidget.h"
2 #include "ui_CatalogueInspectorWidget.h"
3
3
4 #include <Common/DateUtils.h>
5 #include <DBCatalogue.h>
6 #include <DBEvent.h>
7 #include <DBTag.h>
8
4 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
9 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
5 : QWidget(parent), ui(new Ui::CatalogueInspectorWidget)
10 : QWidget(parent), ui(new Ui::CatalogueInspectorWidget)
6 {
11 {
@@ -23,14 +28,29 CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const
23 return static_cast<Page>(ui->stackedWidget->currentIndex());
28 return static_cast<Page>(ui->stackedWidget->currentIndex());
24 }
29 }
25
30
26 void CatalogueInspectorWidget::setEvent(const QString &event)
31 void CatalogueInspectorWidget::setEvent(const DBEvent &event)
27 {
32 {
28 showPage(Page::EventProperties);
33 showPage(Page::EventProperties);
29 ui->leEventName->setText(event);
34 ui->leEventName->setText(event.getName());
35 ui->leEventMission->setText(event.getMission());
36 ui->leEventProduct->setText(event.getProduct());
37
38 QString tagList;
39 auto tags = const_cast<DBEvent *>(&event)->getTags();
40 for (auto tag : tags) {
41 tagList += tag.getName();
42 tagList += ' ';
43 }
44
45 ui->leEventTags->setText(tagList);
46
47 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event.getTStart()));
48 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event.getTEnd()));
30 }
49 }
31
50
32 void CatalogueInspectorWidget::setCatalogue(const QString &catalogue)
51 void CatalogueInspectorWidget::setCatalogue(const DBCatalogue &catalogue)
33 {
52 {
34 showPage(Page::CatalogueProperties);
53 showPage(Page::CatalogueProperties);
35 ui->leCatalogueName->setText(catalogue);
54 ui->leCatalogueName->setText(catalogue.getName());
55 ui->leCatalogueAuthor->setText(catalogue.getAuthor());
36 }
56 }
@@ -1,5 +1,13
1 #include "Catalogue/CatalogueSideBarWidget.h"
1 #include "Catalogue/CatalogueSideBarWidget.h"
2 #include "ui_CatalogueSideBarWidget.h"
2 #include "ui_CatalogueSideBarWidget.h"
3 #include <SqpApplication.h>
4
5 #include <Catalogue/CatalogueController.h>
6 #include <Catalogue/CatalogueTreeWidgetItem.h>
7 #include <CatalogueDao.h>
8 #include <ComparaisonPredicate.h>
9 #include <DBCatalogue.h>
10
3
11
4 constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType;
12 constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType;
5 constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1;
13 constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1;
@@ -8,9 +16,12 constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3;
8
16
9
17
10 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
18 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
19
20 QHash<QTreeWidgetItem *, DBCatalogue> m_CatalogueMap;
21
11 void configureTreeWidget(QTreeWidget *treeWidget);
22 void configureTreeWidget(QTreeWidget *treeWidget);
12 QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget);
23 QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget);
13 void addCatalogueItem(const QString &name, QTreeWidgetItem *parentDatabaseItem);
24 void addCatalogueItem(const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem);
14 };
25 };
15
26
16 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
27 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
@@ -24,7 +35,8 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
24 auto emitSelection = [this](auto item) {
35 auto emitSelection = [this](auto item) {
25 switch (item->type()) {
36 switch (item->type()) {
26 case CATALOGUE_ITEM_TYPE:
37 case CATALOGUE_ITEM_TYPE:
27 emit this->catalogueSelected(item->text(0));
38 emit this->catalogueSelected(
39 static_cast<CatalogueTreeWidgetItem *>(item)->catalogue());
28 break;
40 break;
29 case ALL_EVENT_ITEM_TYPE:
41 case ALL_EVENT_ITEM_TYPE:
30 emit this->allEventsSelected();
42 emit this->allEventsSelected();
@@ -67,16 +79,16 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget(
67 treeWidget->setItemWidget(separatorItem, 0, separator);
79 treeWidget->setItemWidget(separatorItem, 0, separator);
68
80
69 // Test
81 // Test
70 auto db = addDatabaseItem("Database 1", treeWidget);
82 auto &dao = sqpApp->catalogueController().getDao();
71 addCatalogueItem("Catalogue 1", db);
83 auto allPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, "-1",
72 addCatalogueItem("Catalogue 2", db);
84 ComparaisonOperation::DIFFERENT);
73 addCatalogueItem("Catalogue 3", db);
85
74 addCatalogueItem("Catalogue 4", db);
86 auto db = addDatabaseItem("Default", treeWidget);
75
87
76 auto db2 = addDatabaseItem("Database 2", treeWidget);
88 auto catalogues = dao.getCatalogues(allPredicate);
77 addCatalogueItem("Catalogue A", db2);
89 for (auto catalogue : catalogues) {
78 addCatalogueItem("Catalogue B", db2);
90 addCatalogueItem(catalogue, db);
79 addCatalogueItem("Catalogue C", db2);
91 }
80
92
81 treeWidget->expandAll();
93 treeWidget->expandAll();
82 }
94 }
@@ -93,9 +105,9 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QSt
93 }
105 }
94
106
95 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem(
107 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem(
96 const QString &name, QTreeWidgetItem *parentDatabaseItem)
108 const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem)
97 {
109 {
98 auto catalogueItem = new QTreeWidgetItem({name}, CATALOGUE_ITEM_TYPE);
110 auto catalogueItem = new CatalogueTreeWidgetItem(catalogue, CATALOGUE_ITEM_TYPE);
99 catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png"));
111 catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png"));
100 parentDatabaseItem->addChild(catalogueItem);
112 parentDatabaseItem->addChild(catalogueItem);
101 }
113 }
General Comments 0
You need to be logged in to leave comments. Login now