Auto status change to "Under Review"
@@ -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 | 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 | 89 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html |
|
80 | 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 | 4 | #include <Common/spimpl.h> |
|
5 | 5 | #include <QWidget> |
|
6 | 6 | |
|
7 | class DBCatalogue; | |
|
8 | class DBEvent; | |
|
9 | ||
|
7 | 10 | namespace Ui { |
|
8 | 11 | class CatalogueEventsWidget; |
|
9 | 12 | } |
@@ -12,14 +15,14 class CatalogueEventsWidget : public QWidget { | |||
|
12 | 15 | Q_OBJECT |
|
13 | 16 | |
|
14 | 17 | signals: |
|
15 |
void eventSelected(const |
|
|
18 | void eventSelected(const DBEvent &event); | |
|
16 | 19 | |
|
17 | 20 | public: |
|
18 | 21 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
|
19 | 22 | virtual ~CatalogueEventsWidget(); |
|
20 | 23 | |
|
21 | 24 | public slots: |
|
22 |
void populateWithCatalogue(const |
|
|
25 | void populateWithCatalogue(const DBCatalogue &catalogue); | |
|
23 | 26 | |
|
24 | 27 | private: |
|
25 | 28 | Ui::CatalogueEventsWidget *ui; |
@@ -7,6 +7,9 namespace Ui { | |||
|
7 | 7 | class CatalogueInspectorWidget; |
|
8 | 8 | } |
|
9 | 9 | |
|
10 | class DBCatalogue; | |
|
11 | class DBEvent; | |
|
12 | ||
|
10 | 13 | class CatalogueInspectorWidget : public QWidget { |
|
11 | 14 | Q_OBJECT |
|
12 | 15 | |
@@ -19,8 +22,8 public: | |||
|
19 | 22 | |
|
20 | 23 | Page currentPage() const; |
|
21 | 24 | |
|
22 |
void setEvent(const |
|
|
23 |
void setCatalogue(const |
|
|
25 | void setEvent(const DBEvent &event); | |
|
26 | void setCatalogue(const DBCatalogue &catalogue); | |
|
24 | 27 | |
|
25 | 28 | public slots: |
|
26 | 29 | void showPage(Page page); |
@@ -5,6 +5,8 | |||
|
5 | 5 | #include <QTreeWidgetItem> |
|
6 | 6 | #include <QWidget> |
|
7 | 7 | |
|
8 | #include <DBCatalogue.h> | |
|
9 | ||
|
8 | 10 | namespace Ui { |
|
9 | 11 | class CatalogueSideBarWidget; |
|
10 | 12 | } |
@@ -13,7 +15,7 class CatalogueSideBarWidget : public QWidget { | |||
|
13 | 15 | Q_OBJECT |
|
14 | 16 | |
|
15 | 17 | signals: |
|
16 |
void catalogueSelected(const |
|
|
18 | void catalogueSelected(const DBCatalogue &catalogue); | |
|
17 | 19 | void allEventsSelected(); |
|
18 | 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 | 5 | gui_moc_headers = [ |
|
3 | 6 | 'include/DataSource/DataSourceWidget.h', |
|
4 | 7 | 'include/Settings/SqpSettingsDialog.h', |
@@ -103,7 +106,8 gui_sources = [ | |||
|
103 | 106 | 'src/Catalogue/CatalogueExplorer.cpp', |
|
104 | 107 | 'src/Catalogue/CatalogueEventsWidget.cpp', |
|
105 | 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 | 113 | gui_inc = include_directories(['include']) |
@@ -112,11 +116,11 sciqlop_gui_lib = library('sciqlopgui', | |||
|
112 | 116 | gui_sources, |
|
113 | 117 | gui_moc_files, |
|
114 | 118 | include_directories : [gui_inc], |
|
115 | dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core], | |
|
119 | dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep], | |
|
116 | 120 | install : true |
|
117 | 121 | ) |
|
118 | 122 | |
|
119 | 123 | sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib, |
|
120 | 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 | 1 | #include "Catalogue/CatalogueEventsWidget.h" |
|
2 | 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 | 13 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
7 | 14 | void addEventItem(const QStringList &data, QTableWidget *tableWidget); |
|
8 | 15 | |
|
9 | 16 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; |
|
10 | 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 | 42 | connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) { |
|
34 |
auto event = |
|
|
43 | auto event = impl->m_Events.value(row); | |
|
35 | 44 | emit this->eventSelected(event); |
|
36 | 45 | }); |
|
37 | 46 | |
|
38 | 47 | connect(ui->tableWidget, &QTableWidget::currentItemChanged, |
|
39 | 48 | [this](auto current, auto previous) { |
|
40 | 49 | if (current && current->row() >= 0) { |
|
41 |
auto event = |
|
|
50 | auto event = impl->m_Events.value(current->row()); | |
|
42 | 51 | emit this->eventSelected(event); |
|
43 | 52 | } |
|
44 | 53 | }); |
@@ -64,24 +73,30 CatalogueEventsWidget::~CatalogueEventsWidget() | |||
|
64 | 73 | delete ui; |
|
65 | 74 | } |
|
66 | 75 | |
|
67 |
void CatalogueEventsWidget::populateWithCatalogue(const |
|
|
76 | void CatalogueEventsWidget::populateWithCatalogue(const DBCatalogue &catalogue) | |
|
68 | 77 | { |
|
69 | 78 | ui->tableWidget->clearContents(); |
|
70 | 79 | ui->tableWidget->setRowCount(0); |
|
71 | 80 | |
|
72 | // TODO | |
|
73 | impl->addEventItem( | |
|
74 | {catalogue + " - Event 1", "12/12/2012 12:12", "12/12/2042 12:52", "cloud", "mfi/b_gse42"}, | |
|
75 | ui->tableWidget); | |
|
76 | impl->addEventItem( | |
|
77 | {catalogue + " - Event 2", "12/12/2012 12:10", "12/12/2042 12:42", "Acloud", "mfi/b_gse1"}, | |
|
78 | ui->tableWidget); | |
|
79 | impl->addEventItem( | |
|
80 | {catalogue + " - Event 3", "12/12/2012 12:22", "12/12/2042 12:12", "Gcloud", "mfi/b_gse2"}, | |
|
81 | ui->tableWidget); | |
|
82 | impl->addEventItem( | |
|
83 | {catalogue + " - Event 4", "12/12/2012 12:00", "12/12/2042 12:62", "Bcloud", "mfi/b_gse3"}, | |
|
84 | ui->tableWidget); | |
|
81 | auto &dao = sqpApp->catalogueController().getDao(); | |
|
82 | auto events = dao.getCatalogueEvents(catalogue); | |
|
83 | ||
|
84 | for (auto event : events) { | |
|
85 | impl->m_Events << event; | |
|
86 | ||
|
87 | auto tags = event.getTags(); | |
|
88 | QString tagList; | |
|
89 | for (auto tag : tags) { | |
|
90 | tagList += tag.getName(); | |
|
91 | tagList += ' '; | |
|
92 | } | |
|
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 | 102 | void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data, |
@@ -1,19 +1,22 | |||
|
1 | 1 | #include "Catalogue/CatalogueExplorer.h" |
|
2 | 2 | #include "ui_CatalogueExplorer.h" |
|
3 | 3 | |
|
4 | #include <DBCatalogue.h> | |
|
5 | #include <DBEvent.h> | |
|
6 | ||
|
4 | 7 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
5 | 8 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
6 | 9 | ui(new Ui::CatalogueExplorer) |
|
7 | 10 | { |
|
8 | 11 | ui->setupUi(this); |
|
9 | 12 | |
|
10 |
connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto |
|
|
11 |
ui->inspector->setCatalogue( |
|
|
12 |
ui->events->populateWithCatalogue( |
|
|
13 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogue) { | |
|
14 | ui->inspector->setCatalogue(catalogue); | |
|
15 | ui->events->populateWithCatalogue(catalogue); | |
|
13 | 16 | }); |
|
14 | 17 | |
|
15 | 18 | connect(ui->events, &CatalogueEventsWidget::eventSelected, |
|
16 |
[this](auto |
|
|
19 | [this](auto event) { ui->inspector->setEvent(event); }); | |
|
17 | 20 | } |
|
18 | 21 | |
|
19 | 22 | CatalogueExplorer::~CatalogueExplorer() |
@@ -1,6 +1,11 | |||
|
1 | 1 | #include "Catalogue/CatalogueInspectorWidget.h" |
|
2 | 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 | 9 | CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent) |
|
5 | 10 | : QWidget(parent), ui(new Ui::CatalogueInspectorWidget) |
|
6 | 11 | { |
@@ -23,14 +28,29 CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const | |||
|
23 | 28 | return static_cast<Page>(ui->stackedWidget->currentIndex()); |
|
24 | 29 | } |
|
25 | 30 | |
|
26 |
void CatalogueInspectorWidget::setEvent(const |
|
|
31 | void CatalogueInspectorWidget::setEvent(const DBEvent &event) | |
|
27 | 32 | { |
|
28 | 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 |
|
|
51 | void CatalogueInspectorWidget::setCatalogue(const DBCatalogue &catalogue) | |
|
33 | 52 | { |
|
34 | 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 | 1 | #include "Catalogue/CatalogueSideBarWidget.h" |
|
2 | 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 | 12 | constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; |
|
5 | 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 | 18 | struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { |
|
19 | ||
|
20 | QHash<QTreeWidgetItem *, DBCatalogue> m_CatalogueMap; | |
|
21 | ||
|
11 | 22 | void configureTreeWidget(QTreeWidget *treeWidget); |
|
12 | 23 | QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget); |
|
13 |
void addCatalogueItem(const |
|
|
24 | void addCatalogueItem(const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem); | |
|
14 | 25 | }; |
|
15 | 26 | |
|
16 | 27 | CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) |
@@ -24,7 +35,8 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) | |||
|
24 | 35 | auto emitSelection = [this](auto item) { |
|
25 | 36 | switch (item->type()) { |
|
26 | 37 | case CATALOGUE_ITEM_TYPE: |
|
27 |
emit this->catalogueSelected( |
|
|
38 | emit this->catalogueSelected( | |
|
39 | static_cast<CatalogueTreeWidgetItem *>(item)->catalogue()); | |
|
28 | 40 | break; |
|
29 | 41 | case ALL_EVENT_ITEM_TYPE: |
|
30 | 42 | emit this->allEventsSelected(); |
@@ -67,16 +79,16 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget( | |||
|
67 | 79 | treeWidget->setItemWidget(separatorItem, 0, separator); |
|
68 | 80 | |
|
69 | 81 | // Test |
|
70 | auto db = addDatabaseItem("Database 1", treeWidget); | |
|
71 | addCatalogueItem("Catalogue 1", db); | |
|
72 | addCatalogueItem("Catalogue 2", db); | |
|
73 | addCatalogueItem("Catalogue 3", db); | |
|
74 | addCatalogueItem("Catalogue 4", db); | |
|
82 | auto &dao = sqpApp->catalogueController().getDao(); | |
|
83 | auto allPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, "-1", | |
|
84 | ComparaisonOperation::DIFFERENT); | |
|
85 | ||
|
86 | auto db = addDatabaseItem("Default", treeWidget); | |
|
75 | 87 | |
|
76 | auto db2 = addDatabaseItem("Database 2", treeWidget); | |
|
77 | addCatalogueItem("Catalogue A", db2); | |
|
78 |
addCatalogueItem( |
|
|
79 | addCatalogueItem("Catalogue C", db2); | |
|
88 | auto catalogues = dao.getCatalogues(allPredicate); | |
|
89 | for (auto catalogue : catalogues) { | |
|
90 | addCatalogueItem(catalogue, db); | |
|
91 | } | |
|
80 | 92 | |
|
81 | 93 | treeWidget->expandAll(); |
|
82 | 94 | } |
@@ -93,9 +105,9 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QSt | |||
|
93 | 105 | } |
|
94 | 106 | |
|
95 | 107 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( |
|
96 |
const |
|
|
108 | const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem) | |
|
97 | 109 | { |
|
98 |
auto catalogueItem = new |
|
|
110 | auto catalogueItem = new CatalogueTreeWidgetItem(catalogue, CATALOGUE_ITEM_TYPE); | |
|
99 | 111 | catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png")); |
|
100 | 112 | parentDatabaseItem->addChild(catalogueItem); |
|
101 | 113 | } |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now