Auto status change to "Under Review"
@@ -22,7 +22,7 public: | |||
|
22 | 22 | virtual ~CatalogueEventsWidget(); |
|
23 | 23 | |
|
24 | 24 | public slots: |
|
25 | void populateWithCatalogue(const DBCatalogue &catalogue); | |
|
25 | void populateWithCatalogues(const QVector<DBCatalogue> &catalogues); | |
|
26 | 26 | |
|
27 | 27 | private: |
|
28 | 28 | Ui::CatalogueEventsWidget *ui; |
@@ -15,9 +15,11 class CatalogueSideBarWidget : public QWidget { | |||
|
15 | 15 | Q_OBJECT |
|
16 | 16 | |
|
17 | 17 | signals: |
|
18 | void catalogueSelected(const DBCatalogue &catalogue); | |
|
18 | void catalogueSelected(const QVector<DBCatalogue> &catalogues); | |
|
19 | void databaseSelected(const QStringList &databases); | |
|
19 | 20 | void allEventsSelected(); |
|
20 | 21 | void trashSelected(); |
|
22 | void selectionCleared(); | |
|
21 | 23 | |
|
22 | 24 | public: |
|
23 | 25 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
@@ -41,23 +41,17 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |||
|
41 | 41 | } |
|
42 | 42 | }); |
|
43 | 43 | |
|
44 | connect(ui->tableView, &QTableView::clicked, [this](auto index) { | |
|
44 | auto emitSelection = [this]() { | |
|
45 | 45 | QVector<DBEvent> events; |
|
46 | 46 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { |
|
47 | 47 | events << impl->m_Model->getEvent(rowIndex.row()); |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | emit this->eventsSelected(events); |
|
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 | } | |
|
51 | }; | |
|
58 | 52 | |
|
59 | emit this->eventsSelected(events); | |
|
60 | }); | |
|
53 | connect(ui->tableView, &QTableView::clicked, emitSelection); | |
|
54 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection); | |
|
61 | 55 | |
|
62 | 56 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { |
|
63 | 57 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; |
@@ -75,17 +69,24 CatalogueEventsWidget::~CatalogueEventsWidget() | |||
|
75 | 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 | 74 | auto &dao = sqpApp->catalogueController().getDao(); |
|
81 | auto events = dao.getCatalogueEvents(catalogue); | |
|
82 | 75 | |
|
83 | QVector<DBEvent> eventVector; | |
|
84 | for (auto event : events) { | |
|
85 | eventVector << event; | |
|
76 | QSet<QUuid> eventIds; | |
|
77 | QVector<DBEvent> events; | |
|
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 | 89 | ui->tableView->setSortingEnabled(false); |
|
89 |
impl->m_Model->setEvents(event |
|
|
90 | impl->m_Model->setEvents(events); | |
|
90 | 91 | ui->tableView->setSortingEnabled(true); |
|
91 | 92 | } |
@@ -10,11 +10,30 CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |||
|
10 | 10 | { |
|
11 | 11 | ui->setupUi(this); |
|
12 | 12 | |
|
13 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogue) { | |
|
14 | ui->inspector->setCatalogue(catalogue); | |
|
15 |
ui-> |
|
|
13 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) { | |
|
14 | if (catalogues.count() == 1) { | |
|
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 | 37 | connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { |
|
19 | 38 | if (events.count() == 1) { |
|
20 | 39 | ui->inspector->setEvent(events.first()); |
@@ -32,22 +32,60 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) | |||
|
32 | 32 | ui->setupUi(this); |
|
33 | 33 | impl->configureTreeWidget(ui->treeWidget); |
|
34 | 34 | |
|
35 |
auto emitSelection = [this]( |
|
|
36 | switch (item->type()) { | |
|
35 | auto emitSelection = [this]() { | |
|
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 | 49 | case CATALOGUE_ITEM_TYPE: |
|
38 |
|
|
|
50 | catalogues.append( | |
|
39 | 51 | static_cast<CatalogueTreeWidgetItem *>(item)->catalogue()); |
|
40 | 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 | 76 | case ALL_EVENT_ITEM_TYPE: |
|
42 | 77 | emit this->allEventsSelected(); |
|
43 | 78 | break; |
|
44 | 79 | case TRASH_ITEM_TYPE: |
|
45 | 80 | emit this->trashSelected(); |
|
46 | 81 | break; |
|
47 | case DATABASE_ITEM_TYPE: | |
|
48 | 82 | default: |
|
83 | emit this->selectionCleared(); | |
|
49 | 84 | break; |
|
50 | 85 | } |
|
86 | } | |
|
87 | ||
|
88 | ||
|
51 | 89 | }; |
|
52 | 90 | |
|
53 | 91 | connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection); |
@@ -34,7 +34,7 | |||
|
34 | 34 | <string>+</string> |
|
35 | 35 | </property> |
|
36 | 36 | <property name="icon"> |
|
37 | <iconset> | |
|
37 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
|
38 | 38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> |
|
39 | 39 | </property> |
|
40 | 40 | <property name="autoRaise"> |
@@ -48,7 +48,7 | |||
|
48 | 48 | <string> - </string> |
|
49 | 49 | </property> |
|
50 | 50 | <property name="icon"> |
|
51 | <iconset> | |
|
51 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
|
52 | 52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> |
|
53 | 53 | </property> |
|
54 | 54 | <property name="autoRaise"> |
@@ -73,6 +73,9 | |||
|
73 | 73 | </item> |
|
74 | 74 | <item> |
|
75 | 75 | <widget class="QTreeWidget" name="treeWidget"> |
|
76 | <property name="selectionMode"> | |
|
77 | <enum>QAbstractItemView::ExtendedSelection</enum> | |
|
78 | </property> | |
|
76 | 79 | <attribute name="headerVisible"> |
|
77 | 80 | <bool>false</bool> |
|
78 | 81 | </attribute> |
@@ -85,6 +88,9 | |||
|
85 | 88 | </item> |
|
86 | 89 | </layout> |
|
87 | 90 | </widget> |
|
88 |
<resources |
|
|
91 | <resources> | |
|
92 | <include location="../../resources/sqpguiresources.qrc"/> | |
|
93 | <include location="../../resources/sqpguiresources.qrc"/> | |
|
94 | </resources> | |
|
89 | 95 | <connections/> |
|
90 | 96 | </ui> |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now