Auto status change to "Under Review"
@@ -1,34 +1,34 | |||||
1 | #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
1 | #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H | |
2 | #define SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
2 | #define SCIQLOP_CATALOGUEEVENTSWIDGET_H | |
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 | #include <QWidget> |
|
5 | #include <QWidget> | |
6 |
|
6 | |||
7 | class DBCatalogue; |
|
7 | class DBCatalogue; | |
8 | class DBEvent; |
|
8 | class DBEvent; | |
9 |
|
9 | |||
10 | namespace Ui { |
|
10 | namespace Ui { | |
11 | class CatalogueEventsWidget; |
|
11 | class CatalogueEventsWidget; | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | class CatalogueEventsWidget : public QWidget { |
|
14 | class CatalogueEventsWidget : public QWidget { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 |
|
16 | |||
17 | signals: |
|
17 | signals: | |
18 | void eventsSelected(const QVector<DBEvent> &event); |
|
18 | void eventsSelected(const QVector<DBEvent> &event); | |
19 |
|
19 | |||
20 | public: |
|
20 | public: | |
21 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
|
21 | explicit CatalogueEventsWidget(QWidget *parent = 0); | |
22 | virtual ~CatalogueEventsWidget(); |
|
22 | virtual ~CatalogueEventsWidget(); | |
23 |
|
23 | |||
24 | public slots: |
|
24 | public slots: | |
25 | void populateWithCatalogue(const DBCatalogue &catalogue); |
|
25 | void populateWithCatalogues(const QVector<DBCatalogue> &catalogues); | |
26 |
|
26 | |||
27 | private: |
|
27 | private: | |
28 | Ui::CatalogueEventsWidget *ui; |
|
28 | Ui::CatalogueEventsWidget *ui; | |
29 |
|
29 | |||
30 | class CatalogueEventsWidgetPrivate; |
|
30 | class CatalogueEventsWidgetPrivate; | |
31 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; |
|
31 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; | |
32 | }; |
|
32 | }; | |
33 |
|
33 | |||
34 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
34 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
@@ -1,33 +1,35 | |||||
1 | #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
1 | #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H | |
2 | #define SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
2 | #define SCIQLOP_CATALOGUESIDEBARWIDGET_H | |
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 | #include <QTreeWidgetItem> |
|
5 | #include <QTreeWidgetItem> | |
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
8 | #include <DBCatalogue.h> |
|
8 | #include <DBCatalogue.h> | |
9 |
|
9 | |||
10 | namespace Ui { |
|
10 | namespace Ui { | |
11 | class CatalogueSideBarWidget; |
|
11 | class CatalogueSideBarWidget; | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | class CatalogueSideBarWidget : public QWidget { |
|
14 | class CatalogueSideBarWidget : public QWidget { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 |
|
16 | |||
17 | signals: |
|
17 | signals: | |
18 | void catalogueSelected(const DBCatalogue &catalogue); |
|
18 | void catalogueSelected(const QVector<DBCatalogue> &catalogues); | |
|
19 | void databaseSelected(const QStringList &databases); | |||
19 | void allEventsSelected(); |
|
20 | void allEventsSelected(); | |
20 | void trashSelected(); |
|
21 | void trashSelected(); | |
|
22 | void selectionCleared(); | |||
21 |
|
23 | |||
22 | public: |
|
24 | public: | |
23 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
25 | explicit CatalogueSideBarWidget(QWidget *parent = 0); | |
24 | virtual ~CatalogueSideBarWidget(); |
|
26 | virtual ~CatalogueSideBarWidget(); | |
25 |
|
27 | |||
26 | private: |
|
28 | private: | |
27 | Ui::CatalogueSideBarWidget *ui; |
|
29 | Ui::CatalogueSideBarWidget *ui; | |
28 |
|
30 | |||
29 | class CatalogueSideBarWidgetPrivate; |
|
31 | class CatalogueSideBarWidgetPrivate; | |
30 | spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl; |
|
32 | spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl; | |
31 | }; |
|
33 | }; | |
32 |
|
34 | |||
33 | #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
35 | #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H |
@@ -1,91 +1,92 | |||||
1 | #include "Catalogue/CatalogueEventsWidget.h" |
|
1 | #include "Catalogue/CatalogueEventsWidget.h" | |
2 | #include "ui_CatalogueEventsWidget.h" |
|
2 | #include "ui_CatalogueEventsWidget.h" | |
3 |
|
3 | |||
4 | #include <Catalogue/CatalogueController.h> |
|
4 | #include <Catalogue/CatalogueController.h> | |
5 | #include <Catalogue/CatalogueEventsTableModel.h> |
|
5 | #include <Catalogue/CatalogueEventsTableModel.h> | |
6 | #include <CatalogueDao.h> |
|
6 | #include <CatalogueDao.h> | |
7 | #include <DBCatalogue.h> |
|
7 | #include <DBCatalogue.h> | |
8 | #include <SqpApplication.h> |
|
8 | #include <SqpApplication.h> | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | /// Format of the dates appearing in the label of a cursor |
|
11 | /// Format of the dates appearing in the label of a cursor | |
12 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); |
|
12 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); | |
13 |
|
13 | |||
14 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
14 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |
15 |
|
15 | |||
16 | CatalogueEventsTableModel *m_Model = nullptr; |
|
16 | CatalogueEventsTableModel *m_Model = nullptr; | |
17 | }; |
|
17 | }; | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) |
|
20 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |
21 | : QWidget(parent), |
|
21 | : QWidget(parent), | |
22 | ui(new Ui::CatalogueEventsWidget), |
|
22 | ui(new Ui::CatalogueEventsWidget), | |
23 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} |
|
23 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} | |
24 | { |
|
24 | { | |
25 | ui->setupUi(this); |
|
25 | ui->setupUi(this); | |
26 |
|
26 | |||
27 | impl->m_Model = new CatalogueEventsTableModel(this); |
|
27 | impl->m_Model = new CatalogueEventsTableModel(this); | |
28 | ui->tableView->setModel(impl->m_Model); |
|
28 | ui->tableView->setModel(impl->m_Model); | |
29 |
|
29 | |||
30 | ui->tableView->setSortingEnabled(true); |
|
30 | ui->tableView->setSortingEnabled(true); | |
31 |
|
31 | |||
32 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { |
|
32 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { | |
33 | if (checked) { |
|
33 | if (checked) { | |
34 | ui->btnChart->setChecked(false); |
|
34 | ui->btnChart->setChecked(false); | |
35 | } |
|
35 | } | |
36 | }); |
|
36 | }); | |
37 |
|
37 | |||
38 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { |
|
38 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { | |
39 | if (checked) { |
|
39 | if (checked) { | |
40 | ui->btnTime->setChecked(false); |
|
40 | ui->btnTime->setChecked(false); | |
41 | } |
|
41 | } | |
42 | }); |
|
42 | }); | |
43 |
|
43 | |||
44 | connect(ui->tableView, &QTableView::clicked, [this](auto index) { |
|
44 | auto emitSelection = [this]() { | |
45 | QVector<DBEvent> events; |
|
45 | QVector<DBEvent> events; | |
46 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { |
|
46 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { | |
47 | events << impl->m_Model->getEvent(rowIndex.row()); |
|
47 | events << impl->m_Model->getEvent(rowIndex.row()); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | emit this->eventsSelected(events); |
|
50 | emit this->eventsSelected(events); | |
51 |
} |
|
51 | }; | |
52 |
|
||||
53 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { |
|
|||
54 | QVector<DBEvent> events; |
|
|||
55 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { |
|
|||
56 | events << impl->m_Model->getEvent(rowIndex.row()); |
|
|||
57 | } |
|
|||
58 |
|
52 | |||
59 | emit this->eventsSelected(events); |
|
53 | connect(ui->tableView, &QTableView::clicked, emitSelection); | |
60 | }); |
|
54 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection); | |
61 |
|
55 | |||
62 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { |
|
56 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { | |
63 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; |
|
57 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; | |
64 | ui->btnChart->setEnabled(isNotMultiSelection); |
|
58 | ui->btnChart->setEnabled(isNotMultiSelection); | |
65 | ui->btnTime->setEnabled(isNotMultiSelection); |
|
59 | ui->btnTime->setEnabled(isNotMultiSelection); | |
66 | }); |
|
60 | }); | |
67 |
|
61 | |||
68 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
|
62 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
69 | ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
|
63 | ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); | |
70 | ui->tableView->horizontalHeader()->setSortIndicatorShown(true); |
|
64 | ui->tableView->horizontalHeader()->setSortIndicatorShown(true); | |
71 | } |
|
65 | } | |
72 |
|
66 | |||
73 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
67 | CatalogueEventsWidget::~CatalogueEventsWidget() | |
74 | { |
|
68 | { | |
75 | delete ui; |
|
69 | delete ui; | |
76 | } |
|
70 | } | |
77 |
|
71 | |||
78 | void CatalogueEventsWidget::populateWithCatalogue(const DBCatalogue &catalogue) |
|
72 | void CatalogueEventsWidget::populateWithCatalogues(const QVector<DBCatalogue> &catalogues) | |
79 | { |
|
73 | { | |
80 | auto &dao = sqpApp->catalogueController().getDao(); |
|
74 | auto &dao = sqpApp->catalogueController().getDao(); | |
81 | auto events = dao.getCatalogueEvents(catalogue); |
|
|||
82 |
|
75 | |||
83 | QVector<DBEvent> eventVector; |
|
76 | QSet<QUuid> eventIds; | |
84 | for (auto event : events) { |
|
77 | QVector<DBEvent> events; | |
85 | eventVector << event; |
|
78 | ||
|
79 | for (auto catalogue : catalogues) { | |||
|
80 | auto catalogueEvents = dao.getCatalogueEvents(catalogue); | |||
|
81 | for (auto event : catalogueEvents) { | |||
|
82 | if (!eventIds.contains(event.getUniqId())) { | |||
|
83 | events << event; | |||
|
84 | eventIds.insert(event.getUniqId()); | |||
|
85 | } | |||
|
86 | } | |||
86 | } |
|
87 | } | |
87 |
|
88 | |||
88 | ui->tableView->setSortingEnabled(false); |
|
89 | ui->tableView->setSortingEnabled(false); | |
89 |
impl->m_Model->setEvents(event |
|
90 | impl->m_Model->setEvents(events); | |
90 | ui->tableView->setSortingEnabled(true); |
|
91 | ui->tableView->setSortingEnabled(true); | |
91 | } |
|
92 | } |
@@ -1,31 +1,50 | |||||
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> |
|
4 | #include <DBCatalogue.h> | |
5 | #include <DBEvent.h> |
|
5 | #include <DBEvent.h> | |
6 |
|
6 | |||
7 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
7 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |
8 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
8 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), | |
9 | ui(new Ui::CatalogueExplorer) |
|
9 | ui(new Ui::CatalogueExplorer) | |
10 | { |
|
10 | { | |
11 | ui->setupUi(this); |
|
11 | ui->setupUi(this); | |
12 |
|
12 | |||
13 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogue) { |
|
13 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) { | |
14 | ui->inspector->setCatalogue(catalogue); |
|
14 | if (catalogues.count() == 1) { | |
15 |
ui-> |
|
15 | ui->inspector->setCatalogue(catalogues.first()); | |
|
16 | } | |||
|
17 | else { | |||
|
18 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |||
|
19 | } | |||
|
20 | ||||
|
21 | ui->events->populateWithCatalogues(catalogues); | |||
16 | }); |
|
22 | }); | |
17 |
|
23 | |||
|
24 | connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) { | |||
|
25 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |||
|
26 | }); | |||
|
27 | ||||
|
28 | connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected, | |||
|
29 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
30 | ||||
|
31 | connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, | |||
|
32 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
33 | ||||
|
34 | connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared, | |||
|
35 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
36 | ||||
18 | connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { |
|
37 | connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { | |
19 | if (events.count() == 1) { |
|
38 | if (events.count() == 1) { | |
20 | ui->inspector->setEvent(events.first()); |
|
39 | ui->inspector->setEvent(events.first()); | |
21 | } |
|
40 | } | |
22 | else { |
|
41 | else { | |
23 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); |
|
42 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |
24 | } |
|
43 | } | |
25 | }); |
|
44 | }); | |
26 | } |
|
45 | } | |
27 |
|
46 | |||
28 | CatalogueExplorer::~CatalogueExplorer() |
|
47 | CatalogueExplorer::~CatalogueExplorer() | |
29 | { |
|
48 | { | |
30 | delete ui; |
|
49 | delete ui; | |
31 | } |
|
50 | } |
@@ -1,113 +1,151 | |||||
1 | #include "Catalogue/CatalogueSideBarWidget.h" |
|
1 | #include "Catalogue/CatalogueSideBarWidget.h" | |
2 | #include "ui_CatalogueSideBarWidget.h" |
|
2 | #include "ui_CatalogueSideBarWidget.h" | |
3 | #include <SqpApplication.h> |
|
3 | #include <SqpApplication.h> | |
4 |
|
4 | |||
5 | #include <Catalogue/CatalogueController.h> |
|
5 | #include <Catalogue/CatalogueController.h> | |
6 | #include <Catalogue/CatalogueTreeWidgetItem.h> |
|
6 | #include <Catalogue/CatalogueTreeWidgetItem.h> | |
7 | #include <CatalogueDao.h> |
|
7 | #include <CatalogueDao.h> | |
8 | #include <ComparaisonPredicate.h> |
|
8 | #include <ComparaisonPredicate.h> | |
9 | #include <DBCatalogue.h> |
|
9 | #include <DBCatalogue.h> | |
10 |
|
10 | |||
11 |
|
11 | |||
12 | constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; |
|
12 | constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; | |
13 | constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1; |
|
13 | constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1; | |
14 | constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2; |
|
14 | constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2; | |
15 | constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3; |
|
15 | constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3; | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { |
|
18 | struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { | |
19 |
|
19 | |||
20 | QHash<QTreeWidgetItem *, DBCatalogue> m_CatalogueMap; |
|
20 | QHash<QTreeWidgetItem *, DBCatalogue> m_CatalogueMap; | |
21 |
|
21 | |||
22 | void configureTreeWidget(QTreeWidget *treeWidget); |
|
22 | void configureTreeWidget(QTreeWidget *treeWidget); | |
23 | QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget); |
|
23 | QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget); | |
24 | void addCatalogueItem(const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem); |
|
24 | void addCatalogueItem(const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem); | |
25 | }; |
|
25 | }; | |
26 |
|
26 | |||
27 | CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) |
|
27 | CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) | |
28 | : QWidget(parent), |
|
28 | : QWidget(parent), | |
29 | ui(new Ui::CatalogueSideBarWidget), |
|
29 | ui(new Ui::CatalogueSideBarWidget), | |
30 | impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()} |
|
30 | impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()} | |
31 | { |
|
31 | { | |
32 | ui->setupUi(this); |
|
32 | ui->setupUi(this); | |
33 | impl->configureTreeWidget(ui->treeWidget); |
|
33 | impl->configureTreeWidget(ui->treeWidget); | |
34 |
|
34 | |||
35 |
auto emitSelection = [this]( |
|
35 | auto emitSelection = [this]() { | |
36 | switch (item->type()) { |
|
36 | ||
|
37 | auto selectedItems = ui->treeWidget->selectedItems(); | |||
|
38 | if (selectedItems.isEmpty()) { | |||
|
39 | emit this->selectionCleared(); | |||
|
40 | } | |||
|
41 | else { | |||
|
42 | QVector<DBCatalogue> catalogues; | |||
|
43 | QStringList databases; | |||
|
44 | int selectionType = selectedItems.first()->type(); | |||
|
45 | ||||
|
46 | for (auto item : ui->treeWidget->selectedItems()) { | |||
|
47 | if (item->type() == selectionType) { | |||
|
48 | switch (selectionType) { | |||
37 | case CATALOGUE_ITEM_TYPE: |
|
49 | case CATALOGUE_ITEM_TYPE: | |
38 |
|
|
50 | catalogues.append( | |
39 | static_cast<CatalogueTreeWidgetItem *>(item)->catalogue()); |
|
51 | static_cast<CatalogueTreeWidgetItem *>(item)->catalogue()); | |
40 | break; |
|
52 | break; | |
|
53 | case DATABASE_ITEM_TYPE: | |||
|
54 | selectionType = DATABASE_ITEM_TYPE; | |||
|
55 | databases.append(item->text(0)); | |||
|
56 | case ALL_EVENT_ITEM_TYPE: // fallthrough | |||
|
57 | case TRASH_ITEM_TYPE: // fallthrough | |||
|
58 | default: | |||
|
59 | break; | |||
|
60 | } | |||
|
61 | } | |||
|
62 | else { | |||
|
63 | // Incoherent multi selection | |||
|
64 | selectionType = -1; | |||
|
65 | break; | |||
|
66 | } | |||
|
67 | } | |||
|
68 | ||||
|
69 | switch (selectionType) { | |||
|
70 | case CATALOGUE_ITEM_TYPE: | |||
|
71 | emit this->catalogueSelected(catalogues); | |||
|
72 | break; | |||
|
73 | case DATABASE_ITEM_TYPE: | |||
|
74 | emit this->databaseSelected(databases); | |||
|
75 | break; | |||
41 | case ALL_EVENT_ITEM_TYPE: |
|
76 | case ALL_EVENT_ITEM_TYPE: | |
42 | emit this->allEventsSelected(); |
|
77 | emit this->allEventsSelected(); | |
43 | break; |
|
78 | break; | |
44 | case TRASH_ITEM_TYPE: |
|
79 | case TRASH_ITEM_TYPE: | |
45 | emit this->trashSelected(); |
|
80 | emit this->trashSelected(); | |
46 | break; |
|
81 | break; | |
47 | case DATABASE_ITEM_TYPE: |
|
|||
48 | default: |
|
82 | default: | |
|
83 | emit this->selectionCleared(); | |||
49 | break; |
|
84 | break; | |
50 | } |
|
85 | } | |
|
86 | } | |||
|
87 | ||||
|
88 | ||||
51 | }; |
|
89 | }; | |
52 |
|
90 | |||
53 | connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection); |
|
91 | connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection); | |
54 | connect(ui->treeWidget, &QTreeWidget::currentItemChanged, emitSelection); |
|
92 | connect(ui->treeWidget, &QTreeWidget::currentItemChanged, emitSelection); | |
55 | } |
|
93 | } | |
56 |
|
94 | |||
57 | CatalogueSideBarWidget::~CatalogueSideBarWidget() |
|
95 | CatalogueSideBarWidget::~CatalogueSideBarWidget() | |
58 | { |
|
96 | { | |
59 | delete ui; |
|
97 | delete ui; | |
60 | } |
|
98 | } | |
61 |
|
99 | |||
62 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget( |
|
100 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget( | |
63 | QTreeWidget *treeWidget) |
|
101 | QTreeWidget *treeWidget) | |
64 | { |
|
102 | { | |
65 | auto allEventsItem = new QTreeWidgetItem({"All Events"}, ALL_EVENT_ITEM_TYPE); |
|
103 | auto allEventsItem = new QTreeWidgetItem({"All Events"}, ALL_EVENT_ITEM_TYPE); | |
66 | allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png")); |
|
104 | allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png")); | |
67 | treeWidget->addTopLevelItem(allEventsItem); |
|
105 | treeWidget->addTopLevelItem(allEventsItem); | |
68 |
|
106 | |||
69 | auto trashItem = new QTreeWidgetItem({"Trash"}, TRASH_ITEM_TYPE); |
|
107 | auto trashItem = new QTreeWidgetItem({"Trash"}, TRASH_ITEM_TYPE); | |
70 | trashItem->setIcon(0, QIcon(":/icones/trash.png")); |
|
108 | trashItem->setIcon(0, QIcon(":/icones/trash.png")); | |
71 | treeWidget->addTopLevelItem(trashItem); |
|
109 | treeWidget->addTopLevelItem(trashItem); | |
72 |
|
110 | |||
73 | auto separator = new QFrame(treeWidget); |
|
111 | auto separator = new QFrame(treeWidget); | |
74 | separator->setFrameShape(QFrame::HLine); |
|
112 | separator->setFrameShape(QFrame::HLine); | |
75 |
|
113 | |||
76 | auto separatorItem = new QTreeWidgetItem(); |
|
114 | auto separatorItem = new QTreeWidgetItem(); | |
77 | separatorItem->setFlags(Qt::NoItemFlags); |
|
115 | separatorItem->setFlags(Qt::NoItemFlags); | |
78 | treeWidget->addTopLevelItem(separatorItem); |
|
116 | treeWidget->addTopLevelItem(separatorItem); | |
79 | treeWidget->setItemWidget(separatorItem, 0, separator); |
|
117 | treeWidget->setItemWidget(separatorItem, 0, separator); | |
80 |
|
118 | |||
81 | // Test |
|
119 | // Test | |
82 | auto &dao = sqpApp->catalogueController().getDao(); |
|
120 | auto &dao = sqpApp->catalogueController().getDao(); | |
83 | auto allPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, "-1", |
|
121 | auto allPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, "-1", | |
84 | ComparaisonOperation::DIFFERENT); |
|
122 | ComparaisonOperation::DIFFERENT); | |
85 |
|
123 | |||
86 | auto db = addDatabaseItem("Default", treeWidget); |
|
124 | auto db = addDatabaseItem("Default", treeWidget); | |
87 |
|
125 | |||
88 | auto catalogues = dao.getCatalogues(allPredicate); |
|
126 | auto catalogues = dao.getCatalogues(allPredicate); | |
89 | for (auto catalogue : catalogues) { |
|
127 | for (auto catalogue : catalogues) { | |
90 | addCatalogueItem(catalogue, db); |
|
128 | addCatalogueItem(catalogue, db); | |
91 | } |
|
129 | } | |
92 |
|
130 | |||
93 | treeWidget->expandAll(); |
|
131 | treeWidget->expandAll(); | |
94 | } |
|
132 | } | |
95 |
|
133 | |||
96 | QTreeWidgetItem * |
|
134 | QTreeWidgetItem * | |
97 | CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name, |
|
135 | CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name, | |
98 | QTreeWidget *treeWidget) |
|
136 | QTreeWidget *treeWidget) | |
99 | { |
|
137 | { | |
100 | auto databaseItem = new QTreeWidgetItem({name}, DATABASE_ITEM_TYPE); |
|
138 | auto databaseItem = new QTreeWidgetItem({name}, DATABASE_ITEM_TYPE); | |
101 | databaseItem->setIcon(0, QIcon(":/icones/database.png")); |
|
139 | databaseItem->setIcon(0, QIcon(":/icones/database.png")); | |
102 | treeWidget->addTopLevelItem(databaseItem); |
|
140 | treeWidget->addTopLevelItem(databaseItem); | |
103 |
|
141 | |||
104 | return databaseItem; |
|
142 | return databaseItem; | |
105 | } |
|
143 | } | |
106 |
|
144 | |||
107 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( |
|
145 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( | |
108 | const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem) |
|
146 | const DBCatalogue &catalogue, QTreeWidgetItem *parentDatabaseItem) | |
109 | { |
|
147 | { | |
110 | auto catalogueItem = new CatalogueTreeWidgetItem(catalogue, CATALOGUE_ITEM_TYPE); |
|
148 | auto catalogueItem = new CatalogueTreeWidgetItem(catalogue, CATALOGUE_ITEM_TYPE); | |
111 | catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png")); |
|
149 | catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png")); | |
112 | parentDatabaseItem->addChild(catalogueItem); |
|
150 | parentDatabaseItem->addChild(catalogueItem); | |
113 | } |
|
151 | } |
@@ -1,90 +1,96 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>CatalogueSideBarWidget</class> |
|
3 | <class>CatalogueSideBarWidget</class> | |
4 | <widget class="QWidget" name="CatalogueSideBarWidget"> |
|
4 | <widget class="QWidget" name="CatalogueSideBarWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>330</width> |
|
9 | <width>330</width> | |
10 | <height>523</height> |
|
10 | <height>523</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <property name="leftMargin"> |
|
17 | <property name="leftMargin"> | |
18 | <number>0</number> |
|
18 | <number>0</number> | |
19 | </property> |
|
19 | </property> | |
20 | <property name="topMargin"> |
|
20 | <property name="topMargin"> | |
21 | <number>0</number> |
|
21 | <number>0</number> | |
22 | </property> |
|
22 | </property> | |
23 | <property name="rightMargin"> |
|
23 | <property name="rightMargin"> | |
24 | <number>0</number> |
|
24 | <number>0</number> | |
25 | </property> |
|
25 | </property> | |
26 | <property name="bottomMargin"> |
|
26 | <property name="bottomMargin"> | |
27 | <number>0</number> |
|
27 | <number>0</number> | |
28 | </property> |
|
28 | </property> | |
29 | <item> |
|
29 | <item> | |
30 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
30 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
31 | <item> |
|
31 | <item> | |
32 | <widget class="QToolButton" name="btnAdd"> |
|
32 | <widget class="QToolButton" name="btnAdd"> | |
33 | <property name="text"> |
|
33 | <property name="text"> | |
34 | <string>+</string> |
|
34 | <string>+</string> | |
35 | </property> |
|
35 | </property> | |
36 | <property name="icon"> |
|
36 | <property name="icon"> | |
37 | <iconset> |
|
37 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> |
|
38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> | |
39 | </property> |
|
39 | </property> | |
40 | <property name="autoRaise"> |
|
40 | <property name="autoRaise"> | |
41 | <bool>true</bool> |
|
41 | <bool>true</bool> | |
42 | </property> |
|
42 | </property> | |
43 | </widget> |
|
43 | </widget> | |
44 | </item> |
|
44 | </item> | |
45 | <item> |
|
45 | <item> | |
46 | <widget class="QToolButton" name="btnRemove"> |
|
46 | <widget class="QToolButton" name="btnRemove"> | |
47 | <property name="text"> |
|
47 | <property name="text"> | |
48 | <string> - </string> |
|
48 | <string> - </string> | |
49 | </property> |
|
49 | </property> | |
50 | <property name="icon"> |
|
50 | <property name="icon"> | |
51 | <iconset> |
|
51 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> |
|
52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> | |
53 | </property> |
|
53 | </property> | |
54 | <property name="autoRaise"> |
|
54 | <property name="autoRaise"> | |
55 | <bool>true</bool> |
|
55 | <bool>true</bool> | |
56 | </property> |
|
56 | </property> | |
57 | </widget> |
|
57 | </widget> | |
58 | </item> |
|
58 | </item> | |
59 | <item> |
|
59 | <item> | |
60 | <spacer name="horizontalSpacer"> |
|
60 | <spacer name="horizontalSpacer"> | |
61 | <property name="orientation"> |
|
61 | <property name="orientation"> | |
62 | <enum>Qt::Horizontal</enum> |
|
62 | <enum>Qt::Horizontal</enum> | |
63 | </property> |
|
63 | </property> | |
64 | <property name="sizeHint" stdset="0"> |
|
64 | <property name="sizeHint" stdset="0"> | |
65 | <size> |
|
65 | <size> | |
66 | <width>40</width> |
|
66 | <width>40</width> | |
67 | <height>20</height> |
|
67 | <height>20</height> | |
68 | </size> |
|
68 | </size> | |
69 | </property> |
|
69 | </property> | |
70 | </spacer> |
|
70 | </spacer> | |
71 | </item> |
|
71 | </item> | |
72 | </layout> |
|
72 | </layout> | |
73 | </item> |
|
73 | </item> | |
74 | <item> |
|
74 | <item> | |
75 | <widget class="QTreeWidget" name="treeWidget"> |
|
75 | <widget class="QTreeWidget" name="treeWidget"> | |
|
76 | <property name="selectionMode"> | |||
|
77 | <enum>QAbstractItemView::ExtendedSelection</enum> | |||
|
78 | </property> | |||
76 | <attribute name="headerVisible"> |
|
79 | <attribute name="headerVisible"> | |
77 | <bool>false</bool> |
|
80 | <bool>false</bool> | |
78 | </attribute> |
|
81 | </attribute> | |
79 | <column> |
|
82 | <column> | |
80 | <property name="text"> |
|
83 | <property name="text"> | |
81 | <string notr="true">1</string> |
|
84 | <string notr="true">1</string> | |
82 | </property> |
|
85 | </property> | |
83 | </column> |
|
86 | </column> | |
84 | </widget> |
|
87 | </widget> | |
85 | </item> |
|
88 | </item> | |
86 | </layout> |
|
89 | </layout> | |
87 | </widget> |
|
90 | </widget> | |
88 |
<resources |
|
91 | <resources> | |
|
92 | <include location="../../resources/sqpguiresources.qrc"/> | |||
|
93 | <include location="../../resources/sqpguiresources.qrc"/> | |||
|
94 | </resources> | |||
89 | <connections/> |
|
95 | <connections/> | |
90 | </ui> |
|
96 | </ui> |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now