@@ -5,18 +5,22 | |||||
5 | #include <QAbstractItemModel> |
|
5 | #include <QAbstractItemModel> | |
6 |
|
6 | |||
7 | class DBEvent; |
|
7 | class DBEvent; | |
|
8 | class DBEventProduct; | |||
8 |
|
9 | |||
9 | class CatalogueEventsModel : public QAbstractItemModel { |
|
10 | class CatalogueEventsModel : public QAbstractItemModel { | |
10 | public: |
|
11 | public: | |
11 | CatalogueEventsModel(QObject *parent = nullptr); |
|
12 | CatalogueEventsModel(QObject *parent = nullptr); | |
12 |
|
13 | |||
13 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events); |
|
14 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events); | |
14 | std::shared_ptr<DBEvent> getEvent(int row) const; |
|
|||
15 |
|
||||
16 |
|
||||
17 | void addEvent(const std::shared_ptr<DBEvent> &event); |
|
15 | void addEvent(const std::shared_ptr<DBEvent> &event); | |
18 | void removeEvent(const std::shared_ptr<DBEvent> &event); |
|
16 | void removeEvent(const std::shared_ptr<DBEvent> &event); | |
19 |
|
17 | |||
|
18 | enum class ItemType { Root, Event, EventProduct }; | |||
|
19 | ItemType itemTypeOf(const QModelIndex &index) const; | |||
|
20 | std::shared_ptr<DBEvent> getEvent(const QModelIndex &index) const; | |||
|
21 | std::shared_ptr<DBEvent> getParentEvent(const QModelIndex &index) const; | |||
|
22 | std::shared_ptr<DBEventProduct> getEventProduct(const QModelIndex &index) const; | |||
|
23 | ||||
20 | void refreshEvent(const std::shared_ptr<DBEvent> &event); |
|
24 | void refreshEvent(const std::shared_ptr<DBEvent> &event); | |
21 |
|
25 | |||
22 | // Model |
|
26 | // Model | |
@@ -35,8 +39,8 public: | |||||
35 | QMimeData *mimeData(const QModelIndexList &indexes) const override; |
|
39 | QMimeData *mimeData(const QModelIndexList &indexes) const override; | |
36 |
|
40 | |||
37 | private: |
|
41 | private: | |
38 |
class CatalogueEvents |
|
42 | class CatalogueEventsModelPrivate; | |
39 |
spimpl::unique_impl_ptr<CatalogueEvents |
|
43 | spimpl::unique_impl_ptr<CatalogueEventsModelPrivate> impl; | |
40 | }; |
|
44 | }; | |
41 |
|
45 | |||
42 | #endif // SCIQLOP_CATALOGUEEVENTSMODEL_H |
|
46 | #endif // SCIQLOP_CATALOGUEEVENTSMODEL_H |
@@ -7,6 +7,7 | |||||
7 |
|
7 | |||
8 | class DBCatalogue; |
|
8 | class DBCatalogue; | |
9 | class DBEvent; |
|
9 | class DBEvent; | |
|
10 | class DBEventProduct; | |||
10 | class VisualizationWidget; |
|
11 | class VisualizationWidget; | |
11 |
|
12 | |||
12 | namespace Ui { |
|
13 | namespace Ui { | |
@@ -20,6 +21,10 class CatalogueEventsWidget : public QWidget { | |||||
20 |
|
21 | |||
21 | signals: |
|
22 | signals: | |
22 | void eventsSelected(const QVector<std::shared_ptr<DBEvent> > &event); |
|
23 | void eventsSelected(const QVector<std::shared_ptr<DBEvent> > &event); | |
|
24 | void eventProductsSelected( | |||
|
25 | const QVector<QPair<std::shared_ptr<DBEvent>, std::shared_ptr<DBEventProduct> > > | |||
|
26 | &eventproducts); | |||
|
27 | void selectionCleared(); | |||
23 |
|
28 | |||
24 | public: |
|
29 | public: | |
25 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
|
30 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
@@ -11,6 +11,7 class CatalogueInspectorWidget; | |||||
11 |
|
11 | |||
12 | class DBCatalogue; |
|
12 | class DBCatalogue; | |
13 | class DBEvent; |
|
13 | class DBEvent; | |
|
14 | class DBEventProduct; | |||
14 |
|
15 | |||
15 | class CatalogueInspectorWidget : public QWidget { |
|
16 | class CatalogueInspectorWidget : public QWidget { | |
16 | Q_OBJECT |
|
17 | Q_OBJECT | |
@@ -18,6 +19,8 class CatalogueInspectorWidget : public QWidget { | |||||
18 | signals: |
|
19 | signals: | |
19 | void catalogueUpdated(const std::shared_ptr<DBCatalogue> &catalogue); |
|
20 | void catalogueUpdated(const std::shared_ptr<DBCatalogue> &catalogue); | |
20 | void eventUpdated(const std::shared_ptr<DBEvent> &event); |
|
21 | void eventUpdated(const std::shared_ptr<DBEvent> &event); | |
|
22 | void eventProductUpdated(const std::shared_ptr<DBEvent> &event, | |||
|
23 | const std::shared_ptr<DBEventProduct> &eventProduct); | |||
21 |
|
24 | |||
22 | public: |
|
25 | public: | |
23 | explicit CatalogueInspectorWidget(QWidget *parent = 0); |
|
26 | explicit CatalogueInspectorWidget(QWidget *parent = 0); | |
@@ -29,6 +32,8 public: | |||||
29 | Page currentPage() const; |
|
32 | Page currentPage() const; | |
30 |
|
33 | |||
31 | void setEvent(const std::shared_ptr<DBEvent> &event); |
|
34 | void setEvent(const std::shared_ptr<DBEvent> &event); | |
|
35 | void setEventProduct(const std::shared_ptr<DBEvent> &event, | |||
|
36 | const std::shared_ptr<DBEventProduct> &eventProduct); | |||
32 | void setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue); |
|
37 | void setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue); | |
33 |
|
38 | |||
34 | public slots: |
|
39 | public slots: |
@@ -18,7 +18,7 | |||||
18 | const auto EVENT_ITEM_TYPE = 1; |
|
18 | const auto EVENT_ITEM_TYPE = 1; | |
19 | const auto EVENT_PRODUCT_ITEM_TYPE = 2; |
|
19 | const auto EVENT_PRODUCT_ITEM_TYPE = 2; | |
20 |
|
20 | |||
21 |
struct CatalogueEventsModel::CatalogueEvents |
|
21 | struct CatalogueEventsModel::CatalogueEventsModelPrivate { | |
22 | QVector<std::shared_ptr<DBEvent> > m_Events; |
|
22 | QVector<std::shared_ptr<DBEvent> > m_Events; | |
23 | std::unordered_map<DBEvent *, QVector<std::shared_ptr<DBEventProduct> > > m_EventProducts; |
|
23 | std::unordered_map<DBEvent *, QVector<std::shared_ptr<DBEventProduct> > > m_EventProducts; | |
24 |
|
24 | |||
@@ -92,32 +92,10 struct CatalogueEventsModel::CatalogueEventsTableModelPrivate { | |||||
92 | Q_ASSERT(false); |
|
92 | Q_ASSERT(false); | |
93 | return QStringLiteral("Unknown Data"); |
|
93 | return QStringLiteral("Unknown Data"); | |
94 | } |
|
94 | } | |
95 |
|
||||
96 | enum class ItemType { Root, Event, EventProduct }; |
|
|||
97 | ItemType indexItemType(const QModelIndex &index) const |
|
|||
98 | { |
|
|||
99 |
|
||||
100 | if (!index.isValid()) { |
|
|||
101 | return ItemType::Root; |
|
|||
102 | } |
|
|||
103 | else if (index.internalPointer() == nullptr) { |
|
|||
104 | return ItemType::Event; |
|
|||
105 | } |
|
|||
106 | else { |
|
|||
107 | return ItemType::EventProduct; |
|
|||
108 | } |
|
|||
109 | } |
|
|||
110 |
|
||||
111 | std::shared_ptr<DBEventProduct> getEventProduct(const QModelIndex &index) |
|
|||
112 | { |
|
|||
113 | auto event = static_cast<DBEvent *>(index.internalPointer()); |
|
|||
114 | return m_EventProducts.at(event).value(index.row()); |
|
|||
115 | } |
|
|||
116 | }; |
|
95 | }; | |
117 |
|
96 | |||
118 | CatalogueEventsModel::CatalogueEventsModel(QObject *parent) |
|
97 | CatalogueEventsModel::CatalogueEventsModel(QObject *parent) | |
119 | : QAbstractItemModel(parent), |
|
98 | : QAbstractItemModel(parent), impl{spimpl::make_unique_impl<CatalogueEventsModelPrivate>()} | |
120 | impl{spimpl::make_unique_impl<CatalogueEventsTableModelPrivate>()} |
|
|||
121 | { |
|
99 | { | |
122 | } |
|
100 | } | |
123 |
|
101 | |||
@@ -126,6 +104,7 void CatalogueEventsModel::setEvents(const QVector<std::shared_ptr<DBEvent> > &e | |||||
126 | beginResetModel(); |
|
104 | beginResetModel(); | |
127 |
|
105 | |||
128 | impl->m_Events = events; |
|
106 | impl->m_Events = events; | |
|
107 | impl->m_EventProducts.clear(); | |||
129 | for (auto event : events) { |
|
108 | for (auto event : events) { | |
130 | impl->parseEventProduct(event); |
|
109 | impl->parseEventProduct(event); | |
131 | } |
|
110 | } | |
@@ -133,9 +112,36 void CatalogueEventsModel::setEvents(const QVector<std::shared_ptr<DBEvent> > &e | |||||
133 | endResetModel(); |
|
112 | endResetModel(); | |
134 | } |
|
113 | } | |
135 |
|
114 | |||
136 |
std::shared_ptr<DBEvent> CatalogueEventsModel::getEvent( |
|
115 | std::shared_ptr<DBEvent> CatalogueEventsModel::getEvent(const QModelIndex &index) const | |
|
116 | { | |||
|
117 | if (itemTypeOf(index) == CatalogueEventsModel::ItemType::Event) { | |||
|
118 | return impl->m_Events.value(index.row()); | |||
|
119 | } | |||
|
120 | else { | |||
|
121 | return nullptr; | |||
|
122 | } | |||
|
123 | } | |||
|
124 | ||||
|
125 | std::shared_ptr<DBEvent> CatalogueEventsModel::getParentEvent(const QModelIndex &index) const | |||
137 | { |
|
126 | { | |
138 | return impl->m_Events.value(row); |
|
127 | if (itemTypeOf(index) == CatalogueEventsModel::ItemType::EventProduct) { | |
|
128 | return getEvent(index.parent()); | |||
|
129 | } | |||
|
130 | else { | |||
|
131 | return nullptr; | |||
|
132 | } | |||
|
133 | } | |||
|
134 | ||||
|
135 | std::shared_ptr<DBEventProduct> | |||
|
136 | CatalogueEventsModel::getEventProduct(const QModelIndex &index) const | |||
|
137 | { | |||
|
138 | if (itemTypeOf(index) == CatalogueEventsModel::ItemType::EventProduct) { | |||
|
139 | auto event = static_cast<DBEvent *>(index.internalPointer()); | |||
|
140 | return impl->m_EventProducts.at(event).value(index.row()); | |||
|
141 | } | |||
|
142 | else { | |||
|
143 | return nullptr; | |||
|
144 | } | |||
139 | } |
|
145 | } | |
140 |
|
146 | |||
141 | void CatalogueEventsModel::addEvent(const std::shared_ptr<DBEvent> &event) |
|
147 | void CatalogueEventsModel::addEvent(const std::shared_ptr<DBEvent> &event) | |
@@ -159,9 +165,14 void CatalogueEventsModel::removeEvent(const std::shared_ptr<DBEvent> &event) | |||||
159 |
|
165 | |||
160 | void CatalogueEventsModel::refreshEvent(const std::shared_ptr<DBEvent> &event) |
|
166 | void CatalogueEventsModel::refreshEvent(const std::shared_ptr<DBEvent> &event) | |
161 | { |
|
167 | { | |
162 |
auto |
|
168 | auto i = impl->m_Events.indexOf(event); | |
163 |
if ( |
|
169 | if (i >= 0) { | |
164 | emit dataChanged(index(eventIndex, 0), index(eventIndex, columnCount())); |
|
170 | auto eventIndex = index(i, 0); | |
|
171 | auto colCount = columnCount(); | |||
|
172 | emit dataChanged(eventIndex, index(i, colCount)); | |||
|
173 | ||||
|
174 | auto childCount = rowCount(eventIndex); | |||
|
175 | emit dataChanged(index(0, 0, eventIndex), index(childCount, colCount, eventIndex)); | |||
165 | } |
|
176 | } | |
166 | } |
|
177 | } | |
167 |
|
178 | |||
@@ -171,14 +182,14 QModelIndex CatalogueEventsModel::index(int row, int column, const QModelIndex & | |||||
171 | return QModelIndex(); |
|
182 | return QModelIndex(); | |
172 | } |
|
183 | } | |
173 |
|
184 | |||
174 |
switch (i |
|
185 | switch (itemTypeOf(parent)) { | |
175 |
case CatalogueEvents |
|
186 | case CatalogueEventsModel::ItemType::Root: | |
176 | return createIndex(row, column); |
|
187 | return createIndex(row, column); | |
177 |
case CatalogueEvents |
|
188 | case CatalogueEventsModel::ItemType::Event: { | |
178 |
auto event = getEvent(parent |
|
189 | auto event = getEvent(parent); | |
179 | return createIndex(row, column, event.get()); |
|
190 | return createIndex(row, column, event.get()); | |
180 | } |
|
191 | } | |
181 |
case CatalogueEvents |
|
192 | case CatalogueEventsModel::ItemType::EventProduct: | |
182 | break; |
|
193 | break; | |
183 | default: |
|
194 | default: | |
184 | break; |
|
195 | break; | |
@@ -189,8 +200,8 QModelIndex CatalogueEventsModel::index(int row, int column, const QModelIndex & | |||||
189 |
|
200 | |||
190 | QModelIndex CatalogueEventsModel::parent(const QModelIndex &index) const |
|
201 | QModelIndex CatalogueEventsModel::parent(const QModelIndex &index) const | |
191 | { |
|
202 | { | |
192 |
switch (i |
|
203 | switch (itemTypeOf(index)) { | |
193 |
case CatalogueEvents |
|
204 | case CatalogueEventsModel::ItemType::EventProduct: { | |
194 | auto parentEvent = static_cast<DBEvent *>(index.internalPointer()); |
|
205 | auto parentEvent = static_cast<DBEvent *>(index.internalPointer()); | |
195 | auto it |
|
206 | auto it | |
196 | = std::find_if(impl->m_Events.cbegin(), impl->m_Events.cend(), |
|
207 | = std::find_if(impl->m_Events.cbegin(), impl->m_Events.cend(), | |
@@ -203,9 +214,9 QModelIndex CatalogueEventsModel::parent(const QModelIndex &index) const | |||||
203 | return QModelIndex(); |
|
214 | return QModelIndex(); | |
204 | } |
|
215 | } | |
205 | } |
|
216 | } | |
206 |
case CatalogueEvents |
|
217 | case CatalogueEventsModel::ItemType::Root: | |
207 | break; |
|
218 | break; | |
208 |
case CatalogueEvents |
|
219 | case CatalogueEventsModel::ItemType::Event: | |
209 | break; |
|
220 | break; | |
210 | default: |
|
221 | default: | |
211 | break; |
|
222 | break; | |
@@ -220,14 +231,14 int CatalogueEventsModel::rowCount(const QModelIndex &parent) const | |||||
220 | return 0; |
|
231 | return 0; | |
221 | } |
|
232 | } | |
222 |
|
233 | |||
223 |
switch (i |
|
234 | switch (itemTypeOf(parent)) { | |
224 |
case CatalogueEvents |
|
235 | case CatalogueEventsModel::ItemType::Root: | |
225 | return impl->m_Events.count(); |
|
236 | return impl->m_Events.count(); | |
226 |
case CatalogueEvents |
|
237 | case CatalogueEventsModel::ItemType::Event: { | |
227 |
auto event = getEvent(parent |
|
238 | auto event = getEvent(parent); | |
228 | return impl->m_EventProducts[event.get()].count(); |
|
239 | return impl->m_EventProducts[event.get()].count(); | |
229 | } |
|
240 | } | |
230 |
case CatalogueEvents |
|
241 | case CatalogueEventsModel::ItemType::EventProduct: | |
231 | break; |
|
242 | break; | |
232 | default: |
|
243 | default: | |
233 | break; |
|
244 | break; | |
@@ -238,7 +249,7 int CatalogueEventsModel::rowCount(const QModelIndex &parent) const | |||||
238 |
|
249 | |||
239 | int CatalogueEventsModel::columnCount(const QModelIndex &parent) const |
|
250 | int CatalogueEventsModel::columnCount(const QModelIndex &parent) const | |
240 | { |
|
251 | { | |
241 |
return static_cast<int>(CatalogueEvents |
|
252 | return static_cast<int>(CatalogueEventsModelPrivate::Column::NbColumn); | |
242 | } |
|
253 | } | |
243 |
|
254 | |||
244 | Qt::ItemFlags CatalogueEventsModel::flags(const QModelIndex &index) const |
|
255 | Qt::ItemFlags CatalogueEventsModel::flags(const QModelIndex &index) const | |
@@ -250,17 +261,17 QVariant CatalogueEventsModel::data(const QModelIndex &index, int role) const | |||||
250 | { |
|
261 | { | |
251 | if (index.isValid()) { |
|
262 | if (index.isValid()) { | |
252 |
|
263 | |||
253 |
auto type = i |
|
264 | auto type = itemTypeOf(index); | |
254 |
if (type == CatalogueEvents |
|
265 | if (type == CatalogueEventsModel::ItemType::Event) { | |
255 |
auto event = getEvent(index |
|
266 | auto event = getEvent(index); | |
256 | switch (role) { |
|
267 | switch (role) { | |
257 | case Qt::DisplayRole: |
|
268 | case Qt::DisplayRole: | |
258 | return impl->eventData(index.column(), event); |
|
269 | return impl->eventData(index.column(), event); | |
259 | break; |
|
270 | break; | |
260 | } |
|
271 | } | |
261 | } |
|
272 | } | |
262 |
else if (type == CatalogueEvents |
|
273 | else if (type == CatalogueEventsModel::ItemType::EventProduct) { | |
263 |
auto product = |
|
274 | auto product = getEventProduct(index); | |
264 | switch (role) { |
|
275 | switch (role) { | |
265 | case Qt::DisplayRole: |
|
276 | case Qt::DisplayRole: | |
266 | return impl->eventProductData(index.column(), product); |
|
277 | return impl->eventProductData(index.column(), product); | |
@@ -315,7 +326,7 QMimeData *CatalogueEventsModel::mimeData(const QModelIndexList &indexes) const | |||||
315 | SqpRange firstTimeRange; |
|
326 | SqpRange firstTimeRange; | |
316 | for (const auto &index : indexes) { |
|
327 | for (const auto &index : indexes) { | |
317 | if (index.column() == 0) { // only the first column |
|
328 | if (index.column() == 0) { // only the first column | |
318 |
auto event = getEvent(index |
|
329 | auto event = getEvent(index); | |
319 | if (eventList.isEmpty()) { |
|
330 | if (eventList.isEmpty()) { | |
320 | // Gets the range of the first variable |
|
331 | // Gets the range of the first variable | |
321 | // firstTimeRange.m_TStart = event->getTStart(); |
|
332 | // firstTimeRange.m_TStart = event->getTStart(); | |
@@ -338,3 +349,16 QMimeData *CatalogueEventsModel::mimeData(const QModelIndexList &indexes) const | |||||
338 |
|
349 | |||
339 | return mimeData; |
|
350 | return mimeData; | |
340 | } |
|
351 | } | |
|
352 | ||||
|
353 | CatalogueEventsModel::ItemType CatalogueEventsModel::itemTypeOf(const QModelIndex &index) const | |||
|
354 | { | |||
|
355 | if (!index.isValid()) { | |||
|
356 | return ItemType::Root; | |||
|
357 | } | |||
|
358 | else if (index.internalPointer() == nullptr) { | |||
|
359 | return ItemType::Event; | |||
|
360 | } | |||
|
361 | else { | |||
|
362 | return ItemType::EventProduct; | |||
|
363 | } | |||
|
364 | } |
@@ -136,7 +136,7 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
136 | auto selectedRows = treeView->selectionModel()->selectedRows(); |
|
136 | auto selectedRows = treeView->selectionModel()->selectedRows(); | |
137 |
|
137 | |||
138 | if (selectedRows.count() == 1) { |
|
138 | if (selectedRows.count() == 1) { | |
139 |
auto event = m_Model->getEvent(selectedRows.first() |
|
139 | auto event = m_Model->getEvent(selectedRows.first()); | |
140 | if (m_VisualizationWidget) { |
|
140 | if (m_VisualizationWidget) { | |
141 | if (auto tab = m_VisualizationWidget->currentTabWidget()) { |
|
141 | if (auto tab = m_VisualizationWidget->currentTabWidget()) { | |
142 |
|
142 | |||
@@ -170,7 +170,7 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
170 | auto selectedRows = treeView->selectionModel()->selectedRows(); |
|
170 | auto selectedRows = treeView->selectionModel()->selectedRows(); | |
171 |
|
171 | |||
172 | if (selectedRows.count() == 1) { |
|
172 | if (selectedRows.count() == 1) { | |
173 |
auto event = m_Model->getEvent(selectedRows.first() |
|
173 | auto event = m_Model->getEvent(selectedRows.first()); | |
174 | if (m_VisualizationWidget) { |
|
174 | if (m_VisualizationWidget) { | |
175 | if (auto tab = m_VisualizationWidget->currentTabWidget()) { |
|
175 | if (auto tab = m_VisualizationWidget->currentTabWidget()) { | |
176 | if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) { |
|
176 | if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) { | |
@@ -233,11 +233,29 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |||||
233 |
|
233 | |||
234 | auto emitSelection = [this]() { |
|
234 | auto emitSelection = [this]() { | |
235 | QVector<std::shared_ptr<DBEvent> > events; |
|
235 | QVector<std::shared_ptr<DBEvent> > events; | |
|
236 | QVector<QPair<std::shared_ptr<DBEvent>, std::shared_ptr<DBEventProduct> > > eventProducts; | |||
|
237 | ||||
236 | for (auto rowIndex : ui->treeView->selectionModel()->selectedRows()) { |
|
238 | for (auto rowIndex : ui->treeView->selectionModel()->selectedRows()) { | |
237 | events << impl->m_Model->getEvent(rowIndex.row()); |
|
239 | ||
|
240 | auto itemType = impl->m_Model->itemTypeOf(rowIndex); | |||
|
241 | if (itemType == CatalogueEventsModel::ItemType::Event) { | |||
|
242 | events << impl->m_Model->getEvent(rowIndex); | |||
|
243 | } | |||
|
244 | else if (itemType == CatalogueEventsModel::ItemType::EventProduct) { | |||
|
245 | eventProducts << qMakePair(impl->m_Model->getParentEvent(rowIndex), | |||
|
246 | impl->m_Model->getEventProduct(rowIndex)); | |||
|
247 | } | |||
238 | } |
|
248 | } | |
239 |
|
249 | |||
240 | emit this->eventsSelected(events); |
|
250 | if (!events.isEmpty() && eventProducts.isEmpty()) { | |
|
251 | emit this->eventsSelected(events); | |||
|
252 | } | |||
|
253 | else if (events.isEmpty() && !eventProducts.isEmpty()) { | |||
|
254 | emit this->eventProductsSelected(eventProducts); | |||
|
255 | } | |||
|
256 | else { | |||
|
257 | emit this->selectionCleared(); | |||
|
258 | } | |||
241 | }; |
|
259 | }; | |
242 |
|
260 | |||
243 | connect(ui->treeView, &QTreeView::clicked, emitSelection); |
|
261 | connect(ui->treeView, &QTreeView::clicked, emitSelection); |
@@ -49,11 +49,27 CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |||||
49 | } |
|
49 | } | |
50 | }); |
|
50 | }); | |
51 |
|
51 | |||
|
52 | connect(ui->events, &CatalogueEventsWidget::eventProductsSelected, [this](auto eventProducts) { | |||
|
53 | if (eventProducts.count() == 1) { | |||
|
54 | ui->inspector->setEventProduct(eventProducts.first().first, | |||
|
55 | eventProducts.first().second); | |||
|
56 | } | |||
|
57 | else { | |||
|
58 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |||
|
59 | } | |||
|
60 | }); | |||
|
61 | ||||
|
62 | connect(ui->events, &CatalogueEventsWidget::selectionCleared, | |||
|
63 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
64 | ||||
52 | connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated, |
|
65 | connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated, | |
53 | [this](auto catalogue) { ui->catalogues->setCatalogueChanges(catalogue, true); }); |
|
66 | [this](auto catalogue) { ui->catalogues->setCatalogueChanges(catalogue, true); }); | |
54 |
|
67 | |||
55 | connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated, |
|
68 | connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated, | |
56 | [this](auto event) { ui->events->setEventChanges(event, true); }); |
|
69 | [this](auto event) { ui->events->setEventChanges(event, true); }); | |
|
70 | ||||
|
71 | connect(ui->inspector, &CatalogueInspectorWidget::eventProductUpdated, | |||
|
72 | [this](auto event, auto eventProduct) { ui->events->setEventChanges(event, true); }); | |||
57 | } |
|
73 | } | |
58 |
|
74 | |||
59 | CatalogueExplorer::~CatalogueExplorer() |
|
75 | CatalogueExplorer::~CatalogueExplorer() |
@@ -4,11 +4,13 | |||||
4 | #include <Common/DateUtils.h> |
|
4 | #include <Common/DateUtils.h> | |
5 | #include <DBCatalogue.h> |
|
5 | #include <DBCatalogue.h> | |
6 | #include <DBEvent.h> |
|
6 | #include <DBEvent.h> | |
|
7 | #include <DBEventProduct.h> | |||
7 | #include <DBTag.h> |
|
8 | #include <DBTag.h> | |
8 |
|
9 | |||
9 | struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate { |
|
10 | struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate { | |
10 | std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr; |
|
11 | std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr; | |
11 | std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr; |
|
12 | std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr; | |
|
13 | std::shared_ptr<DBEventProduct> m_DisplayedEventProduct = nullptr; | |||
12 |
|
14 | |||
13 | void connectCatalogueUpdateSignals(CatalogueInspectorWidget *inspector, |
|
15 | void connectCatalogueUpdateSignals(CatalogueInspectorWidget *inspector, | |
14 | Ui::CatalogueInspectorWidget *ui); |
|
16 | Ui::CatalogueInspectorWidget *ui); | |
@@ -61,18 +63,11 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpda | |||||
61 | } |
|
63 | } | |
62 | }); |
|
64 | }); | |
63 |
|
65 | |||
64 | connect(ui->leEventMission, &QLineEdit::editingFinished, [ui, inspector, this]() { |
|
|||
65 | // if (ui->leEventMission->text() != m_DisplayedEvent->getMission()) { |
|
|||
66 | // m_DisplayedEvent->setMission(ui->leEventMission->text()); |
|
|||
67 | // emit inspector->eventUpdated(m_DisplayedEvent); |
|
|||
68 | // } |
|
|||
69 | }); |
|
|||
70 |
|
||||
71 | connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() { |
|
66 | connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() { | |
72 |
|
|
67 | if (ui->leEventProduct->text() != m_DisplayedEventProduct->getProductId()) { | |
73 |
|
|
68 | m_DisplayedEventProduct->setProductId(ui->leEventProduct->text()); | |
74 |
|
|
69 | emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct); | |
75 |
|
|
70 | } | |
76 | }); |
|
71 | }); | |
77 |
|
72 | |||
78 | connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() { |
|
73 | connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() { | |
@@ -80,19 +75,19 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpda | |||||
80 | }); |
|
75 | }); | |
81 |
|
76 | |||
82 | connect(ui->dateTimeEventTStart, &QDateTimeEdit::editingFinished, [ui, inspector, this]() { |
|
77 | connect(ui->dateTimeEventTStart, &QDateTimeEdit::editingFinished, [ui, inspector, this]() { | |
83 |
|
|
78 | auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime()); | |
84 |
|
|
79 | if (time != m_DisplayedEventProduct->getTStart()) { | |
85 |
|
|
80 | m_DisplayedEventProduct->setTStart(time); | |
86 |
|
|
81 | emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct); | |
87 |
|
|
82 | } | |
88 | }); |
|
83 | }); | |
89 |
|
84 | |||
90 | connect(ui->dateTimeEventTEnd, &QDateTimeEdit::editingFinished, [ui, inspector, this]() { |
|
85 | connect(ui->dateTimeEventTEnd, &QDateTimeEdit::editingFinished, [ui, inspector, this]() { | |
91 |
|
|
86 | auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime()); | |
92 |
|
|
87 | if (time != m_DisplayedEventProduct->getTEnd()) { | |
93 |
|
|
88 | m_DisplayedEventProduct->setTEnd(time); | |
94 |
|
|
89 | emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct); | |
95 |
|
|
90 | } | |
96 | }); |
|
91 | }); | |
97 | } |
|
92 | } | |
98 |
|
93 | |||
@@ -113,9 +108,11 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event) | |||||
113 | blockSignals(true); |
|
108 | blockSignals(true); | |
114 |
|
109 | |||
115 | showPage(Page::EventProperties); |
|
110 | showPage(Page::EventProperties); | |
|
111 | ui->leEventName->setEnabled(true); | |||
116 | ui->leEventName->setText(event->getName()); |
|
112 | ui->leEventName->setText(event->getName()); | |
117 | // ui->leEventMission->setText(event->getMission()); |
|
113 | ui->leEventProduct->setEnabled(false); | |
118 |
|
|
114 | ui->leEventProduct->setText( | |
|
115 | QString::number(event->getEventProducts().size()).append(" product(s)")); | |||
119 |
|
116 | |||
120 | QString tagList; |
|
117 | QString tagList; | |
121 | auto tags = event->getTags(); |
|
118 | auto tags = event->getTags(); | |
@@ -124,14 +121,43 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event) | |||||
124 | tagList += ' '; |
|
121 | tagList += ' '; | |
125 | } |
|
122 | } | |
126 |
|
123 | |||
|
124 | ui->leEventTags->setEnabled(true); | |||
127 | ui->leEventTags->setText(tagList); |
|
125 | ui->leEventTags->setText(tagList); | |
128 |
|
126 | |||
|
127 | ui->dateTimeEventTStart->setEnabled(false); | |||
|
128 | ui->dateTimeEventTEnd->setEnabled(false); | |||
|
129 | ||||
129 | // ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart())); |
|
130 | // ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart())); | |
130 | // ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd())); |
|
131 | // ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd())); | |
131 |
|
132 | |||
132 | blockSignals(false); |
|
133 | blockSignals(false); | |
133 | } |
|
134 | } | |
134 |
|
135 | |||
|
136 | void CatalogueInspectorWidget::setEventProduct(const std::shared_ptr<DBEvent> &event, | |||
|
137 | const std::shared_ptr<DBEventProduct> &eventProduct) | |||
|
138 | { | |||
|
139 | impl->m_DisplayedEventProduct = eventProduct; | |||
|
140 | ||||
|
141 | blockSignals(true); | |||
|
142 | ||||
|
143 | showPage(Page::EventProperties); | |||
|
144 | ui->leEventName->setEnabled(false); | |||
|
145 | ui->leEventName->setText(event->getName()); | |||
|
146 | ui->leEventProduct->setEnabled(true); | |||
|
147 | ui->leEventProduct->setText(eventProduct->getProductId()); | |||
|
148 | ||||
|
149 | ui->leEventTags->setEnabled(false); | |||
|
150 | ui->leEventTags->clear(); | |||
|
151 | ||||
|
152 | ui->dateTimeEventTStart->setEnabled(true); | |||
|
153 | ui->dateTimeEventTEnd->setEnabled(true); | |||
|
154 | ||||
|
155 | ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(eventProduct->getTStart())); | |||
|
156 | ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(eventProduct->getTEnd())); | |||
|
157 | ||||
|
158 | blockSignals(false); | |||
|
159 | } | |||
|
160 | ||||
135 | void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue) |
|
161 | void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue) | |
136 | { |
|
162 | { | |
137 | impl->m_DisplayedCatalogue = catalogue; |
|
163 | impl->m_DisplayedCatalogue = catalogue; |
@@ -121,6 +121,9 | |||||
121 | <property name="dragDropMode"> |
|
121 | <property name="dragDropMode"> | |
122 | <enum>QAbstractItemView::DragDrop</enum> |
|
122 | <enum>QAbstractItemView::DragDrop</enum> | |
123 | </property> |
|
123 | </property> | |
|
124 | <property name="selectionMode"> | |||
|
125 | <enum>QAbstractItemView::ExtendedSelection</enum> | |||
|
126 | </property> | |||
124 | <property name="selectionBehavior"> |
|
127 | <property name="selectionBehavior"> | |
125 | <enum>QAbstractItemView::SelectRows</enum> |
|
128 | <enum>QAbstractItemView::SelectRows</enum> | |
126 | </property> |
|
129 | </property> |
@@ -53,7 +53,7 | |||||
53 | <item> |
|
53 | <item> | |
54 | <widget class="QStackedWidget" name="stackedWidget"> |
|
54 | <widget class="QStackedWidget" name="stackedWidget"> | |
55 | <property name="currentIndex"> |
|
55 | <property name="currentIndex"> | |
56 |
<number> |
|
56 | <number>2</number> | |
57 | </property> |
|
57 | </property> | |
58 | <widget class="QWidget" name="emptyPage"/> |
|
58 | <widget class="QWidget" name="emptyPage"/> | |
59 | <widget class="QWidget" name="catalogueInspectorPage"> |
|
59 | <widget class="QWidget" name="catalogueInspectorPage"> | |
@@ -113,98 +113,95 | |||||
113 | </widget> |
|
113 | </widget> | |
114 | <widget class="QWidget" name="eventInspectorPage"> |
|
114 | <widget class="QWidget" name="eventInspectorPage"> | |
115 | <layout class="QGridLayout" name="gridLayout"> |
|
115 | <layout class="QGridLayout" name="gridLayout"> | |
116 |
<item row=" |
|
116 | <item row="4" column="0"> | |
117 |
<widget class="Q |
|
117 | <widget class="QLabel" name="label_3"> | |
118 |
<property name="t |
|
118 | <property name="text"> | |
119 |
< |
|
119 | <string>Product</string> | |
120 | </property> |
|
120 | </property> | |
121 | </widget> |
|
121 | </widget> | |
122 | </item> |
|
122 | </item> | |
123 |
<item row=" |
|
123 | <item row="5" column="0"> | |
124 | <widget class="QLabel" name="label_4"> |
|
124 | <widget class="QLabel" name="label_4"> | |
125 | <property name="text"> |
|
125 | <property name="text"> | |
126 | <string>TStart</string> |
|
126 | <string>TStart</string> | |
127 | </property> |
|
127 | </property> | |
128 | </widget> |
|
128 | </widget> | |
129 | </item> |
|
129 | </item> | |
130 |
<item row=" |
|
130 | <item row="1" column="0"> | |
131 |
<widget class="QLabel" name="label |
|
131 | <widget class="QLabel" name="label"> | |
132 | <property name="text"> |
|
132 | <property name="text"> | |
133 |
<string> |
|
133 | <string>Name</string> | |
134 | </property> |
|
134 | </property> | |
135 | </widget> |
|
135 | </widget> | |
136 | </item> |
|
136 | </item> | |
137 |
<item row=" |
|
137 | <item row="0" column="0" colspan="2"> | |
138 |
<widget class="QLabel" name="label_ |
|
138 | <widget class="QLabel" name="label_10"> | |
|
139 | <property name="font"> | |||
|
140 | <font> | |||
|
141 | <pointsize>10</pointsize> | |||
|
142 | <weight>75</weight> | |||
|
143 | <bold>true</bold> | |||
|
144 | </font> | |||
|
145 | </property> | |||
139 | <property name="text"> |
|
146 | <property name="text"> | |
140 |
<string> |
|
147 | <string>Event Properties</string> | |
141 | </property> |
|
148 | </property> | |
142 | </widget> |
|
149 | </widget> | |
143 | </item> |
|
150 | </item> | |
144 |
<item row=" |
|
151 | <item row="8" column="1"> | |
145 | <widget class="QLineEdit" name="leEventProduct"/> |
|
152 | <spacer name="verticalSpacer"> | |
146 | </item> |
|
153 | <property name="orientation"> | |
147 | <item row="5" column="0"> |
|
154 | <enum>Qt::Vertical</enum> | |
148 | <widget class="QLabel" name="label_5"> |
|
|||
149 | <property name="text"> |
|
|||
150 | <string>Tend</string> |
|
|||
151 | </property> |
|
155 | </property> | |
152 | </widget> |
|
156 | <property name="sizeHint" stdset="0"> | |
|
157 | <size> | |||
|
158 | <width>20</width> | |||
|
159 | <height>40</height> | |||
|
160 | </size> | |||
|
161 | </property> | |||
|
162 | </spacer> | |||
153 | </item> |
|
163 | </item> | |
154 |
<item row=" |
|
164 | <item row="1" column="1"> | |
|
165 | <widget class="QLineEdit" name="leEventName"/> | |||
|
166 | </item> | |||
|
167 | <item row="5" column="1"> | |||
155 | <widget class="QDateTimeEdit" name="dateTimeEventTStart"> |
|
168 | <widget class="QDateTimeEdit" name="dateTimeEventTStart"> | |
156 | <property name="timeSpec"> |
|
169 | <property name="timeSpec"> | |
157 | <enum>Qt::UTC</enum> |
|
170 | <enum>Qt::UTC</enum> | |
158 | </property> |
|
171 | </property> | |
159 | </widget> |
|
172 | </widget> | |
160 | </item> |
|
173 | </item> | |
161 |
<item row=" |
|
174 | <item row="4" column="1"> | |
162 |
<widget class="QL |
|
175 | <widget class="QLineEdit" name="leEventProduct"/> | |
|
176 | </item> | |||
|
177 | <item row="6" column="0"> | |||
|
178 | <widget class="QLabel" name="label_5"> | |||
163 | <property name="text"> |
|
179 | <property name="text"> | |
164 |
<string> |
|
180 | <string>Tend</string> | |
165 | </property> |
|
181 | </property> | |
166 | </widget> |
|
182 | </widget> | |
167 | </item> |
|
183 | </item> | |
168 |
<item row=" |
|
184 | <item row="6" column="1"> | |
169 |
<widget class="Q |
|
185 | <widget class="QDateTimeEdit" name="dateTimeEventTEnd"> | |
170 | </item> |
|
186 | <property name="timeSpec"> | |
171 | <item row="1" column="0"> |
|
187 | <enum>Qt::UTC</enum> | |
172 | <widget class="QLabel" name="label"> |
|
|||
173 | <property name="text"> |
|
|||
174 | <string>Name</string> |
|
|||
175 | </property> |
|
188 | </property> | |
176 | </widget> |
|
189 | </widget> | |
177 | </item> |
|
190 | </item> | |
178 | <item row="2" column="1"> |
|
191 | <item row="2" column="1"> | |
179 | <widget class="QLineEdit" name="leEventMission"/> |
|
|||
180 | </item> |
|
|||
181 | <item row="6" column="1"> |
|
|||
182 | <widget class="QLineEdit" name="leEventTags"/> |
|
192 | <widget class="QLineEdit" name="leEventTags"/> | |
183 | </item> |
|
193 | </item> | |
184 |
<item row=" |
|
194 | <item row="2" column="0"> | |
185 | <spacer name="verticalSpacer"> |
|
195 | <widget class="QLabel" name="label_6"> | |
186 |
<property name=" |
|
196 | <property name="text"> | |
187 | <enum>Qt::Vertical</enum> |
|
197 | <string>Tags</string> | |
188 | </property> |
|
|||
189 | <property name="sizeHint" stdset="0"> |
|
|||
190 | <size> |
|
|||
191 | <width>20</width> |
|
|||
192 | <height>40</height> |
|
|||
193 | </size> |
|
|||
194 | </property> |
|
198 | </property> | |
195 |
</ |
|
199 | </widget> | |
196 | </item> |
|
200 | </item> | |
197 |
<item row=" |
|
201 | <item row="3" column="0" colspan="2"> | |
198 |
<widget class=" |
|
202 | <widget class="Line" name="line"> | |
199 |
<property name=" |
|
203 | <property name="orientation"> | |
200 |
< |
|
204 | <enum>Qt::Horizontal</enum> | |
201 | <pointsize>10</pointsize> |
|
|||
202 | <weight>75</weight> |
|
|||
203 | <bold>true</bold> |
|
|||
204 | </font> |
|
|||
205 | </property> |
|
|||
206 | <property name="text"> |
|
|||
207 | <string>Event Properties</string> |
|
|||
208 | </property> |
|
205 | </property> | |
209 | </widget> |
|
206 | </widget> | |
210 | </item> |
|
207 | </item> |
General Comments 0
You need to be logged in to leave comments.
Login now