##// END OF EJS Templates
Merge branch 'feature/CatalogueGuiPart2' into develop
trabillard -
r1188:17cb73ee00c8 merge
parent child
Show More
@@ -0,0 +1,381
1 #include "Catalogue/CatalogueEventsModel.h"
2
3 #include <Common/DateUtils.h>
4 #include <Common/MimeTypesDef.h>
5 #include <DBEvent.h>
6 #include <DBEventProduct.h>
7 #include <DBTag.h>
8 #include <Data/SqpRange.h>
9 #include <SqpApplication.h>
10 #include <Time/TimeController.h>
11
12 #include <list>
13 #include <unordered_map>
14
15 #include <QHash>
16 #include <QMimeData>
17
18 const auto EVENT_ITEM_TYPE = 1;
19 const auto EVENT_PRODUCT_ITEM_TYPE = 2;
20
21 struct CatalogueEventsModel::CatalogueEventsModelPrivate {
22 QVector<std::shared_ptr<DBEvent> > m_Events;
23 std::unordered_map<DBEvent *, QVector<std::shared_ptr<DBEventProduct> > > m_EventProducts;
24
25 enum class Column { Name, TStart, TEnd, Tags, Product, NbColumn };
26 QStringList columnNames()
27 {
28 return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), tr("Tags"), tr("Product")};
29 }
30
31 QVariant eventData(int col, const std::shared_ptr<DBEvent> &event) const
32 {
33 switch (static_cast<Column>(col)) {
34 case Column::Name:
35 return event->getName();
36 case Column::TStart:
37 return DateUtils::dateTime(event->getTStart());
38 case Column::TEnd:
39 return DateUtils::dateTime(event->getTEnd());
40 case Column::Product: {
41 auto eventProductsIt = m_EventProducts.find(event.get());
42 if (eventProductsIt != m_EventProducts.cend()) {
43 return QString::number(m_EventProducts.at(event.get()).count()) + " product(s)";
44 }
45 else {
46 return "0 product";
47 }
48 }
49 case Column::Tags: {
50 QString tagList;
51 auto tags = event->getTags();
52 for (auto tag : tags) {
53 tagList += tag.getName();
54 tagList += ' ';
55 }
56
57 return tagList;
58 }
59 default:
60 break;
61 }
62
63 Q_ASSERT(false);
64 return QStringLiteral("Unknown Data");
65 }
66
67 void parseEventProduct(const std::shared_ptr<DBEvent> &event)
68 {
69 for (auto product : event->getEventProducts()) {
70 m_EventProducts[event.get()].append(std::make_shared<DBEventProduct>(product));
71 }
72 }
73
74 QVariant eventProductData(int col, const std::shared_ptr<DBEventProduct> &eventProduct) const
75 {
76 switch (static_cast<Column>(col)) {
77 case Column::Name:
78 return eventProduct->getProductId();
79 case Column::TStart:
80 return DateUtils::dateTime(eventProduct->getTStart());
81 case Column::TEnd:
82 return DateUtils::dateTime(eventProduct->getTEnd());
83 case Column::Product:
84 return eventProduct->getProductId();
85 case Column::Tags: {
86 return QString();
87 }
88 default:
89 break;
90 }
91
92 Q_ASSERT(false);
93 return QStringLiteral("Unknown Data");
94 }
95 };
96
97 CatalogueEventsModel::CatalogueEventsModel(QObject *parent)
98 : QAbstractItemModel(parent), impl{spimpl::make_unique_impl<CatalogueEventsModelPrivate>()}
99 {
100 }
101
102 void CatalogueEventsModel::setEvents(const QVector<std::shared_ptr<DBEvent> > &events)
103 {
104 beginResetModel();
105
106 impl->m_Events = events;
107 impl->m_EventProducts.clear();
108 for (auto event : events) {
109 impl->parseEventProduct(event);
110 }
111
112 endResetModel();
113 }
114
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
126 {
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 }
145 }
146
147 void CatalogueEventsModel::addEvent(const std::shared_ptr<DBEvent> &event)
148 {
149 beginInsertRows(QModelIndex(), impl->m_Events.count() - 1, impl->m_Events.count() - 1);
150 impl->m_Events.append(event);
151 impl->parseEventProduct(event);
152 endInsertRows();
153 }
154
155 void CatalogueEventsModel::removeEvent(const std::shared_ptr<DBEvent> &event)
156 {
157 auto index = impl->m_Events.indexOf(event);
158 if (index >= 0) {
159 beginRemoveRows(QModelIndex(), index, index);
160 impl->m_Events.removeAt(index);
161 impl->m_EventProducts.erase(event.get());
162 endRemoveRows();
163 }
164 }
165
166 void CatalogueEventsModel::refreshEvent(const std::shared_ptr<DBEvent> &event)
167 {
168 auto i = impl->m_Events.indexOf(event);
169 if (i >= 0) {
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));
176 }
177 }
178
179 QModelIndex CatalogueEventsModel::index(int row, int column, const QModelIndex &parent) const
180 {
181 if (!hasIndex(row, column, parent)) {
182 return QModelIndex();
183 }
184
185 switch (itemTypeOf(parent)) {
186 case CatalogueEventsModel::ItemType::Root:
187 return createIndex(row, column);
188 case CatalogueEventsModel::ItemType::Event: {
189 auto event = getEvent(parent);
190 return createIndex(row, column, event.get());
191 }
192 case CatalogueEventsModel::ItemType::EventProduct:
193 break;
194 default:
195 break;
196 }
197
198 return QModelIndex();
199 }
200
201 QModelIndex CatalogueEventsModel::parent(const QModelIndex &index) const
202 {
203 switch (itemTypeOf(index)) {
204 case CatalogueEventsModel::ItemType::EventProduct: {
205 auto parentEvent = static_cast<DBEvent *>(index.internalPointer());
206 auto it
207 = std::find_if(impl->m_Events.cbegin(), impl->m_Events.cend(),
208 [parentEvent](auto event) { return event.get() == parentEvent; });
209
210 if (it != impl->m_Events.cend()) {
211 return createIndex(it - impl->m_Events.cbegin(), 0);
212 }
213 else {
214 return QModelIndex();
215 }
216 }
217 case CatalogueEventsModel::ItemType::Root:
218 break;
219 case CatalogueEventsModel::ItemType::Event:
220 break;
221 default:
222 break;
223 }
224
225 return QModelIndex();
226 }
227
228 int CatalogueEventsModel::rowCount(const QModelIndex &parent) const
229 {
230 if (parent.column() > 0) {
231 return 0;
232 }
233
234 switch (itemTypeOf(parent)) {
235 case CatalogueEventsModel::ItemType::Root:
236 return impl->m_Events.count();
237 case CatalogueEventsModel::ItemType::Event: {
238 auto event = getEvent(parent);
239 return impl->m_EventProducts[event.get()].count();
240 }
241 case CatalogueEventsModel::ItemType::EventProduct:
242 break;
243 default:
244 break;
245 }
246
247 return 0;
248 }
249
250 int CatalogueEventsModel::columnCount(const QModelIndex &parent) const
251 {
252 return static_cast<int>(CatalogueEventsModelPrivate::Column::NbColumn);
253 }
254
255 Qt::ItemFlags CatalogueEventsModel::flags(const QModelIndex &index) const
256 {
257 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
258 }
259
260 QVariant CatalogueEventsModel::data(const QModelIndex &index, int role) const
261 {
262 if (index.isValid()) {
263
264 auto type = itemTypeOf(index);
265 if (type == CatalogueEventsModel::ItemType::Event) {
266 auto event = getEvent(index);
267 switch (role) {
268 case Qt::DisplayRole:
269 return impl->eventData(index.column(), event);
270 break;
271 }
272 }
273 else if (type == CatalogueEventsModel::ItemType::EventProduct) {
274 auto product = getEventProduct(index);
275 switch (role) {
276 case Qt::DisplayRole:
277 return impl->eventProductData(index.column(), product);
278 break;
279 }
280 }
281 }
282
283 return QVariant{};
284 }
285
286 QVariant CatalogueEventsModel::headerData(int section, Qt::Orientation orientation, int role) const
287 {
288 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
289 return impl->columnNames().value(section);
290 }
291
292 return QVariant();
293 }
294
295 void CatalogueEventsModel::sort(int column, Qt::SortOrder order)
296 {
297 std::sort(impl->m_Events.begin(), impl->m_Events.end(),
298 [this, column, order](auto e1, auto e2) {
299 auto data1 = impl->eventData(column, e1);
300 auto data2 = impl->eventData(column, e2);
301
302 auto result = data1.toString() < data2.toString();
303
304 return order == Qt::AscendingOrder ? result : !result;
305 });
306
307 emit dataChanged(QModelIndex(), QModelIndex());
308 }
309
310 Qt::DropActions CatalogueEventsModel::supportedDragActions() const
311 {
312 return Qt::CopyAction | Qt::MoveAction;
313 }
314
315 QStringList CatalogueEventsModel::mimeTypes() const
316 {
317 return {MIME_TYPE_EVENT_LIST, MIME_TYPE_TIME_RANGE};
318 }
319
320 QMimeData *CatalogueEventsModel::mimeData(const QModelIndexList &indexes) const
321 {
322 auto mimeData = new QMimeData;
323
324 bool isFirst = true;
325
326 QVector<std::shared_ptr<DBEvent> > eventList;
327 QVector<std::shared_ptr<DBEventProduct> > eventProductList;
328
329 SqpRange firstTimeRange;
330 for (const auto &index : indexes) {
331 if (index.column() == 0) { // only the first column
332
333 auto type = itemTypeOf(index);
334 if (type == ItemType::Event) {
335 auto event = getEvent(index);
336 eventList << event;
337
338 if (isFirst) {
339 isFirst = false;
340 firstTimeRange.m_TStart = event->getTStart();
341 firstTimeRange.m_TEnd = event->getTEnd();
342 }
343 }
344 else if (type == ItemType::EventProduct) {
345 auto product = getEventProduct(index);
346 eventProductList << product;
347
348 if (isFirst) {
349 isFirst = false;
350 firstTimeRange.m_TStart = product->getTStart();
351 firstTimeRange.m_TEnd = product->getTEnd();
352 }
353 }
354 }
355 }
356
357 auto eventsEncodedData
358 = QByteArray{}; // sqpApp->catalogueController().->mimeDataForEvents(eventList); //TODO
359 mimeData->setData(MIME_TYPE_EVENT_LIST, eventsEncodedData);
360
361 if (eventList.count() + eventProductList.count() == 1) {
362 // No time range MIME data if multiple events are dragged
363 auto timeEncodedData = TimeController::mimeDataForTimeRange(firstTimeRange);
364 mimeData->setData(MIME_TYPE_TIME_RANGE, timeEncodedData);
365 }
366
367 return mimeData;
368 }
369
370 CatalogueEventsModel::ItemType CatalogueEventsModel::itemTypeOf(const QModelIndex &index) const
371 {
372 if (!index.isValid()) {
373 return ItemType::Root;
374 }
375 else if (index.internalPointer() == nullptr) {
376 return ItemType::Event;
377 }
378 else {
379 return ItemType::EventProduct;
380 }
381 }
@@ -1,38 +1,46
1 #ifndef SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H
2 #define SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H
1 #ifndef SCIQLOP_CATALOGUEEVENTSMODEL_H
2 #define SCIQLOP_CATALOGUEEVENTSMODEL_H
3 3
4 4 #include <Common/spimpl.h>
5 #include <QAbstractTableModel>
5 #include <QAbstractItemModel>
6 6
7 7 class DBEvent;
8 class DBEventProduct;
8 9
9 class CatalogueEventsTableModel : public QAbstractTableModel {
10 class CatalogueEventsModel : public QAbstractItemModel {
10 11 public:
11 CatalogueEventsTableModel(QObject *parent = nullptr);
12 CatalogueEventsModel(QObject *parent = nullptr);
12 13
13 14 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events);
14 std::shared_ptr<DBEvent> getEvent(int row) const;
15 void addEvent(const std::shared_ptr<DBEvent> &event);
16 void removeEvent(const std::shared_ptr<DBEvent> &event);
15 17
16 void addEvent(const std::shared_ptr<DBEvent> &events);
17 void removeEvent(const std::shared_ptr<DBEvent> &events);
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
24 void refreshEvent(const std::shared_ptr<DBEvent> &event);
18 25
19 26 // Model
27 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
28 QModelIndex parent(const QModelIndex &index) const;
20 29 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
21 30 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
22 31 Qt::ItemFlags flags(const QModelIndex &index) const override;
23 32 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
24 33 QVariant headerData(int section, Qt::Orientation orientation,
25 34 int role = Qt::DisplayRole) const override;
26 35 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
27 36
28 37 Qt::DropActions supportedDragActions() const override;
29 38 QStringList mimeTypes() const override;
30 39 QMimeData *mimeData(const QModelIndexList &indexes) const override;
31 40
32
33 41 private:
34 class CatalogueEventsTableModelPrivate;
35 spimpl::unique_impl_ptr<CatalogueEventsTableModelPrivate> impl;
42 class CatalogueEventsModelPrivate;
43 spimpl::unique_impl_ptr<CatalogueEventsModelPrivate> impl;
36 44 };
37 45
38 #endif // SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H
46 #endif // SCIQLOP_CATALOGUEEVENTSMODEL_H
@@ -1,40 +1,47
1 1 #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H
2 2 #define SCIQLOP_CATALOGUEEVENTSWIDGET_H
3 3
4 4 #include <Common/spimpl.h>
5 5 #include <QLoggingCategory>
6 6 #include <QWidget>
7 7
8 8 class DBCatalogue;
9 9 class DBEvent;
10 class DBEventProduct;
10 11 class VisualizationWidget;
11 12
12 13 namespace Ui {
13 14 class CatalogueEventsWidget;
14 15 }
15 16
16 17 Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueEventsWidget)
17 18
18 19 class CatalogueEventsWidget : public QWidget {
19 20 Q_OBJECT
20 21
21 22 signals:
22 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 29 public:
25 30 explicit CatalogueEventsWidget(QWidget *parent = 0);
26 31 virtual ~CatalogueEventsWidget();
27 32
28 33 void setVisualizationWidget(VisualizationWidget *visualization);
29 34
35 void setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges);
36
30 37 public slots:
31 38 void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
32 39
33 40 private:
34 41 Ui::CatalogueEventsWidget *ui;
35 42
36 43 class CatalogueEventsWidgetPrivate;
37 44 spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl;
38 45 };
39 46
40 47 #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H
@@ -1,36 +1,49
1 1 #ifndef SCIQLOP_CATALOGUEINSPECTORWIDGET_H
2 2 #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H
3 3
4 #include <Common/spimpl.h>
4 5 #include <QWidget>
5 6 #include <memory>
6 7
7 8 namespace Ui {
8 9 class CatalogueInspectorWidget;
9 10 }
10 11
11 12 class DBCatalogue;
12 13 class DBEvent;
14 class DBEventProduct;
13 15
14 16 class CatalogueInspectorWidget : public QWidget {
15 17 Q_OBJECT
16 18
19 signals:
20 void catalogueUpdated(const std::shared_ptr<DBCatalogue> &catalogue);
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);
24
17 25 public:
18 26 explicit CatalogueInspectorWidget(QWidget *parent = 0);
19 27 virtual ~CatalogueInspectorWidget();
20 28
21 29 /// Enum matching the pages inside the stacked widget
22 30 enum class Page { Empty, CatalogueProperties, EventProperties };
23 31
24 32 Page currentPage() const;
25 33
26 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);
27 37 void setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue);
28 38
29 39 public slots:
30 40 void showPage(Page page);
31 41
32 42 private:
33 43 Ui::CatalogueInspectorWidget *ui;
44
45 class CatalogueInspectorWidgetPrivate;
46 spimpl::unique_impl_ptr<CatalogueInspectorWidgetPrivate> impl;
34 47 };
35 48
36 49 #endif // SCIQLOP_CATALOGUEINSPECTORWIDGET_H
@@ -1,38 +1,43
1 1 #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H
2 2 #define SCIQLOP_CATALOGUESIDEBARWIDGET_H
3 3
4 4 #include <Common/spimpl.h>
5 #include <QLoggingCategory>
5 6 #include <QTreeWidgetItem>
6 7 #include <QWidget>
7 8
8 9 class DBCatalogue;
9 10
10 11 namespace Ui {
11 12 class CatalogueSideBarWidget;
12 13 }
13 14
15 Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueSideBarWidget)
16
14 17 class CatalogueSideBarWidget : public QWidget {
15 18 Q_OBJECT
16 19
17 20 signals:
18 21 void catalogueSelected(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
19 22 void databaseSelected(const QStringList &databases);
20 23 void allEventsSelected();
21 24 void trashSelected();
22 25 void selectionCleared();
23 26
24 27 public:
25 28 explicit CatalogueSideBarWidget(QWidget *parent = 0);
26 29 virtual ~CatalogueSideBarWidget();
27 30
31 void setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, bool hasChanges);
32
28 33 private:
29 34 Ui::CatalogueSideBarWidget *ui;
30 35
31 36 class CatalogueSideBarWidgetPrivate;
32 37 spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl;
33 38
34 39 private slots:
35 40 void onContextMenuRequested(const QPoint &pos);
36 41 };
37 42
38 43 #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H
@@ -1,28 +1,33
1 1 #ifndef SCIQLOP_CATALOGUETREEWIDGETITEM_H
2 2 #define SCIQLOP_CATALOGUETREEWIDGETITEM_H
3 3
4 4 #include <Common/spimpl.h>
5 5 #include <QTreeWidgetItem>
6 6
7 7 class DBCatalogue;
8 8
9 9
10 10 class CatalogueTreeWidgetItem : public QTreeWidgetItem {
11 11 public:
12 12 CatalogueTreeWidgetItem(std::shared_ptr<DBCatalogue> catalogue,
13 13 int type = QTreeWidgetItem::Type);
14 14
15 15 QVariant data(int column, int role) const override;
16 16 void setData(int column, int role, const QVariant &value) override;
17 17
18 18 /// Returns the catalogue represented by the item
19 19 std::shared_ptr<DBCatalogue> catalogue() const;
20 20
21 /// Displays or hides the save and cancel buttons indicating that the catalogue has unsaved
22 /// changes
21 23 void setHasChanges(bool value);
22 24
25 /// Refreshes the data displayed by the item from the catalogue
26 void refresh();
27
23 28 private:
24 29 class CatalogueTreeWidgetItemPrivate;
25 30 spimpl::unique_impl_ptr<CatalogueTreeWidgetItemPrivate> impl;
26 31 };
27 32
28 33 #endif // SCIQLOP_CATALOGUETREEWIDGETITEM_H
@@ -1,30 +1,30
1 1 #ifndef SCIQLOP_VISUALIZATIONMULTIZONESELECTIONDIALOG_H
2 2 #define SCIQLOP_VISUALIZATIONMULTIZONESELECTIONDIALOG_H
3 3
4 4 #include <Common/spimpl.h>
5 5 #include <QDialog>
6 6
7 7 namespace Ui {
8 8 class VisualizationMultiZoneSelectionDialog;
9 9 }
10 10
11 11 class VisualizationSelectionZoneItem;
12 12
13 13 class VisualizationMultiZoneSelectionDialog : public QDialog {
14 14 Q_OBJECT
15 15
16 16 public:
17 17 explicit VisualizationMultiZoneSelectionDialog(QWidget *parent = 0);
18 ~VisualizationMultiZoneSelectionDialog();
18 virtual ~VisualizationMultiZoneSelectionDialog();
19 19
20 20 void setZones(const QVector<VisualizationSelectionZoneItem *> &zones);
21 21 QMap<VisualizationSelectionZoneItem *, bool> selectedZones() const;
22 22
23 23 private:
24 24 Ui::VisualizationMultiZoneSelectionDialog *ui;
25 25
26 26 class VisualizationMultiZoneSelectionDialogPrivate;
27 27 spimpl::unique_impl_ptr<VisualizationMultiZoneSelectionDialogPrivate> impl;
28 28 };
29 29
30 30 #endif // SCIQLOP_VISUALIZATIONMULTIZONESELECTIONDIALOG_H
@@ -1,127 +1,127
1 1
2 2 qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep'])
3 3 catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep'])
4 4
5 5 gui_moc_headers = [
6 6 'include/DataSource/DataSourceWidget.h',
7 7 'include/Settings/SqpSettingsDialog.h',
8 8 'include/Settings/SqpSettingsGeneralWidget.h',
9 9 'include/SidePane/SqpSidePane.h',
10 10 'include/SqpApplication.h',
11 11 'include/DragAndDrop/DragDropScroller.h',
12 12 'include/DragAndDrop/DragDropTabSwitcher.h',
13 13 'include/TimeWidget/TimeWidget.h',
14 14 'include/Variable/VariableInspectorWidget.h',
15 15 'include/Variable/RenameVariableDialog.h',
16 16 'include/Visualization/qcustomplot.h',
17 17 'include/Visualization/VisualizationGraphWidget.h',
18 18 'include/Visualization/VisualizationTabWidget.h',
19 19 'include/Visualization/VisualizationWidget.h',
20 20 'include/Visualization/VisualizationZoneWidget.h',
21 21 'include/Visualization/VisualizationDragDropContainer.h',
22 22 'include/Visualization/VisualizationDragWidget.h',
23 23 'include/Visualization/ColorScaleEditor.h',
24 24 'include/Actions/SelectionZoneAction.h',
25 25 'include/Visualization/VisualizationMultiZoneSelectionDialog.h',
26 26 'include/Catalogue/CatalogueExplorer.h',
27 27 'include/Catalogue/CatalogueEventsWidget.h',
28 28 'include/Catalogue/CatalogueSideBarWidget.h',
29 29 'include/Catalogue/CatalogueInspectorWidget.h'
30 30 ]
31 31
32 32 gui_ui_files = [
33 33 'ui/DataSource/DataSourceWidget.ui',
34 34 'ui/Settings/SqpSettingsDialog.ui',
35 35 'ui/Settings/SqpSettingsGeneralWidget.ui',
36 36 'ui/SidePane/SqpSidePane.ui',
37 37 'ui/TimeWidget/TimeWidget.ui',
38 38 'ui/Variable/VariableInspectorWidget.ui',
39 39 'ui/Variable/RenameVariableDialog.ui',
40 40 'ui/Variable/VariableMenuHeaderWidget.ui',
41 41 'ui/Visualization/VisualizationGraphWidget.ui',
42 42 'ui/Visualization/VisualizationTabWidget.ui',
43 43 'ui/Visualization/VisualizationWidget.ui',
44 44 'ui/Visualization/VisualizationZoneWidget.ui',
45 45 'ui/Visualization/ColorScaleEditor.ui',
46 46 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui',
47 47 'ui/Catalogue/CatalogueExplorer.ui',
48 48 'ui/Catalogue/CatalogueEventsWidget.ui',
49 49 'ui/Catalogue/CatalogueSideBarWidget.ui',
50 50 'ui/Catalogue/CatalogueInspectorWidget.ui'
51 51 ]
52 52
53 53 gui_qresources = ['resources/sqpguiresources.qrc']
54 54
55 55 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
56 56 ui_files : gui_ui_files,
57 57 qresources : gui_qresources)
58 58
59 59 gui_sources = [
60 60 'src/SqpApplication.cpp',
61 61 'src/DragAndDrop/DragDropGuiController.cpp',
62 62 'src/DragAndDrop/DragDropScroller.cpp',
63 63 'src/DragAndDrop/DragDropTabSwitcher.cpp',
64 64 'src/Common/ColorUtils.cpp',
65 65 'src/Common/VisualizationDef.cpp',
66 66 'src/DataSource/DataSourceTreeWidgetItem.cpp',
67 67 'src/DataSource/DataSourceTreeWidgetHelper.cpp',
68 68 'src/DataSource/DataSourceWidget.cpp',
69 69 'src/DataSource/DataSourceTreeWidget.cpp',
70 70 'src/Settings/SqpSettingsDialog.cpp',
71 71 'src/Settings/SqpSettingsGeneralWidget.cpp',
72 72 'src/SidePane/SqpSidePane.cpp',
73 73 'src/TimeWidget/TimeWidget.cpp',
74 74 'src/Variable/VariableInspectorWidget.cpp',
75 75 'src/Variable/VariableInspectorTableView.cpp',
76 76 'src/Variable/VariableMenuHeaderWidget.cpp',
77 77 'src/Variable/RenameVariableDialog.cpp',
78 78 'src/Visualization/VisualizationGraphHelper.cpp',
79 79 'src/Visualization/VisualizationGraphRenderingDelegate.cpp',
80 80 'src/Visualization/VisualizationGraphWidget.cpp',
81 81 'src/Visualization/VisualizationTabWidget.cpp',
82 82 'src/Visualization/VisualizationWidget.cpp',
83 83 'src/Visualization/VisualizationZoneWidget.cpp',
84 84 'src/Visualization/qcustomplot.cpp',
85 85 'src/Visualization/QCustomPlotSynchronizer.cpp',
86 86 'src/Visualization/operations/FindVariableOperation.cpp',
87 87 'src/Visualization/operations/GenerateVariableMenuOperation.cpp',
88 88 'src/Visualization/operations/MenuBuilder.cpp',
89 89 'src/Visualization/operations/RemoveVariableOperation.cpp',
90 90 'src/Visualization/operations/RescaleAxeOperation.cpp',
91 91 'src/Visualization/VisualizationDragDropContainer.cpp',
92 92 'src/Visualization/VisualizationDragWidget.cpp',
93 93 'src/Visualization/AxisRenderingUtils.cpp',
94 94 'src/Visualization/PlottablesRenderingUtils.cpp',
95 95 'src/Visualization/MacScrollBarStyle.cpp',
96 96 'src/Visualization/VisualizationCursorItem.cpp',
97 97 'src/Visualization/ColorScaleEditor.cpp',
98 98 'src/Visualization/SqpColorScale.cpp',
99 99 'src/Visualization/QCPColorMapIterator.cpp',
100 100 'src/Visualization/VisualizationSelectionZoneItem.cpp',
101 101 'src/Visualization/VisualizationSelectionZoneManager.cpp',
102 102 'src/Actions/SelectionZoneAction.cpp',
103 103 'src/Actions/ActionsGuiController.cpp',
104 104 'src/Visualization/VisualizationActionManager.cpp',
105 105 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp',
106 106 'src/Catalogue/CatalogueExplorer.cpp',
107 107 'src/Catalogue/CatalogueEventsWidget.cpp',
108 108 'src/Catalogue/CatalogueSideBarWidget.cpp',
109 109 'src/Catalogue/CatalogueInspectorWidget.cpp',
110 110 'src/Catalogue/CatalogueTreeWidgetItem.cpp',
111 'src/Catalogue/CatalogueEventsTableModel.cpp'
111 'src/Catalogue/CatalogueEventsModel.cpp'
112 112 ]
113 113
114 114 gui_inc = include_directories(['include'])
115 115
116 116 sciqlop_gui_lib = library('sciqlopgui',
117 117 gui_sources,
118 118 gui_moc_files,
119 119 include_directories : [gui_inc],
120 120 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep],
121 121 install : true
122 122 )
123 123
124 124 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
125 125 include_directories : gui_inc,
126 126 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep])
127 127
@@ -1,291 +1,316
1 1 #include "Catalogue/CatalogueEventsWidget.h"
2 2 #include "ui_CatalogueEventsWidget.h"
3 3
4 4 #include <Catalogue/CatalogueController.h>
5 #include <Catalogue/CatalogueEventsTableModel.h>
5 #include <Catalogue/CatalogueEventsModel.h>
6 6 #include <CatalogueDao.h>
7 7 #include <DBCatalogue.h>
8 8 #include <SqpApplication.h>
9 9 #include <Visualization/VisualizationTabWidget.h>
10 10 #include <Visualization/VisualizationWidget.h>
11 11 #include <Visualization/VisualizationZoneWidget.h>
12 12
13 13 #include <QDialog>
14 14 #include <QDialogButtonBox>
15 15 #include <QListWidget>
16 16
17 17 Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget")
18 18
19 19 /// Format of the dates appearing in the label of a cursor
20 20 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
21 21
22 22 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
23 23
24 CatalogueEventsTableModel *m_Model = nullptr;
24 CatalogueEventsModel *m_Model = nullptr;
25 25 QStringList m_ZonesForTimeMode;
26 26 QString m_ZoneForGraphMode;
27 27
28 28 VisualizationWidget *m_VisualizationWidget = nullptr;
29 29
30 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events, QTableView *tableView)
30 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events, QTreeView *treeView)
31 31 {
32 tableView->setSortingEnabled(false);
32 treeView->setSortingEnabled(false);
33 33 m_Model->setEvents(events);
34 tableView->setSortingEnabled(true);
34 treeView->setSortingEnabled(true);
35 35 }
36 36
37 void addEvent(const std::shared_ptr<DBEvent> &event, QTableView *tableView)
37 void addEvent(const std::shared_ptr<DBEvent> &event, QTreeView *treeView)
38 38 {
39 tableView->setSortingEnabled(false);
39 treeView->setSortingEnabled(false);
40 40 m_Model->addEvent(event);
41 tableView->setSortingEnabled(true);
41 treeView->setSortingEnabled(true);
42 42 }
43 43
44 void removeEvent(const std::shared_ptr<DBEvent> &event, QTableView *tableView)
44 void removeEvent(const std::shared_ptr<DBEvent> &event, QTreeView *treeView)
45 45 {
46 tableView->setSortingEnabled(false);
46 treeView->setSortingEnabled(false);
47 47 m_Model->removeEvent(event);
48 tableView->setSortingEnabled(true);
48 treeView->setSortingEnabled(true);
49 49 }
50 50
51 51 QStringList getAvailableVisualizationZoneList() const
52 52 {
53 53 if (m_VisualizationWidget) {
54 54 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
55 55 return tab->availableZoneWidgets();
56 56 }
57 57 }
58 58
59 59 return QStringList{};
60 60 }
61 61
62 62 QStringList selectZone(QWidget *parent, const QStringList &selectedZones,
63 63 bool allowMultiSelection, const QPoint &location)
64 64 {
65 65 auto availableZones = getAvailableVisualizationZoneList();
66 66 if (availableZones.isEmpty()) {
67 67 return QStringList{};
68 68 }
69 69
70 70 QDialog d(parent, Qt::Tool);
71 71 d.setWindowTitle("Choose a zone");
72 72 auto layout = new QVBoxLayout{&d};
73 73 layout->setContentsMargins(0, 0, 0, 0);
74 74 auto listWidget = new QListWidget{&d};
75 75 layout->addWidget(listWidget);
76 76
77 77 QSet<QListWidgetItem *> checkedItems;
78 78 for (auto zone : availableZones) {
79 79 auto item = new QListWidgetItem{zone};
80 80 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
81 81 if (selectedZones.contains(zone)) {
82 82 item->setCheckState(Qt::Checked);
83 83 checkedItems << item;
84 84 }
85 85 else {
86 86 item->setCheckState(Qt::Unchecked);
87 87 }
88 88
89 89 listWidget->addItem(item);
90 90 }
91 91
92 92 auto buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok, &d};
93 93 layout->addWidget(buttonBox);
94 94
95 95 QObject::connect(buttonBox, &QDialogButtonBox::accepted, &d, &QDialog::accept);
96 96 QObject::connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject);
97 97
98 98 QObject::connect(listWidget, &QListWidget::itemChanged,
99 99 [&checkedItems, allowMultiSelection, listWidget](auto item) {
100 100 if (item->checkState() == Qt::Checked) {
101 101 if (!allowMultiSelection) {
102 102 for (auto checkedItem : checkedItems) {
103 103 listWidget->blockSignals(true);
104 104 checkedItem->setCheckState(Qt::Unchecked);
105 105 listWidget->blockSignals(false);
106 106 }
107 107
108 108 checkedItems.clear();
109 109 }
110 110 checkedItems << item;
111 111 }
112 112 else {
113 113 checkedItems.remove(item);
114 114 }
115 115 });
116 116
117 117 QStringList result;
118 118
119 119 d.setMinimumWidth(120);
120 120 d.resize(d.minimumSizeHint());
121 121 d.move(location);
122 122 if (d.exec() == QDialog::Accepted) {
123 123 for (auto item : checkedItems) {
124 124 result += item->text();
125 125 }
126 126 }
127 127 else {
128 128 result = selectedZones;
129 129 }
130 130
131 131 return result;
132 132 }
133 133
134 void updateForTimeMode(QTableView *tableView)
134 void updateForTimeMode(QTreeView *treeView)
135 135 {
136 auto selectedRows = tableView->selectionModel()->selectedRows();
136 auto selectedRows = treeView->selectionModel()->selectedRows();
137 137
138 138 if (selectedRows.count() == 1) {
139 auto event = m_Model->getEvent(selectedRows.first().row());
140 if (m_VisualizationWidget) {
141 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
142
143 for (auto zoneName : m_ZonesForTimeMode) {
144 if (auto zone = tab->getZoneWithName(zoneName)) {
145 SqpRange eventRange;
146 eventRange.m_TStart = event->getTStart();
147 eventRange.m_TEnd = event->getTEnd();
148 zone->setZoneRange(eventRange);
139 auto event = m_Model->getEvent(selectedRows.first());
140 if (event) {
141 if (m_VisualizationWidget) {
142 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
143
144 for (auto zoneName : m_ZonesForTimeMode) {
145 if (auto zone = tab->getZoneWithName(zoneName)) {
146 SqpRange eventRange;
147 eventRange.m_TStart = event->getTStart();
148 eventRange.m_TEnd = event->getTEnd();
149 zone->setZoneRange(eventRange);
150 }
149 151 }
150 152 }
153 else {
154 qCWarning(LOG_CatalogueEventsWidget())
155 << "updateTimeZone: no tab found in the visualization";
156 }
151 157 }
152 158 else {
153 159 qCWarning(LOG_CatalogueEventsWidget())
154 << "updateTimeZone: no tab found in the visualization";
160 << "updateTimeZone: visualization widget not found";
155 161 }
156 162 }
157 else {
158 qCWarning(LOG_CatalogueEventsWidget())
159 << "updateTimeZone: visualization widget not found";
160 }
161 163 }
162 164 else {
163 165 qCWarning(LOG_CatalogueEventsWidget())
164 166 << "updateTimeZone: not compatible with multiple events selected";
165 167 }
166 168 }
167 169
168 void updateForGraphMode(QTableView *tableView)
170 void updateForGraphMode(QTreeView *treeView)
169 171 {
170 auto selectedRows = tableView->selectionModel()->selectedRows();
172 auto selectedRows = treeView->selectionModel()->selectedRows();
171 173
172 174 if (selectedRows.count() == 1) {
173 auto event = m_Model->getEvent(selectedRows.first().row());
175 auto event = m_Model->getEvent(selectedRows.first());
174 176 if (m_VisualizationWidget) {
175 177 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
176 178 if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) {
177 179 // TODO
178 180 }
179 181 }
180 182 else {
181 183 qCWarning(LOG_CatalogueEventsWidget())
182 184 << "updateGraphMode: no tab found in the visualization";
183 185 }
184 186 }
185 187 else {
186 188 qCWarning(LOG_CatalogueEventsWidget())
187 189 << "updateGraphMode: visualization widget not found";
188 190 }
189 191 }
190 192 else {
191 193 qCWarning(LOG_CatalogueEventsWidget())
192 194 << "updateGraphMode: not compatible with multiple events selected";
193 195 }
194 196 }
195 197 };
196 198
197 199 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
198 200 : QWidget(parent),
199 201 ui(new Ui::CatalogueEventsWidget),
200 202 impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()}
201 203 {
202 204 ui->setupUi(this);
203 205
204 impl->m_Model = new CatalogueEventsTableModel{this};
205 ui->tableView->setModel(impl->m_Model);
206 impl->m_Model = new CatalogueEventsModel{this};
207 ui->treeView->setModel(impl->m_Model);
206 208
207 ui->tableView->setSortingEnabled(true);
208 ui->tableView->setDragDropMode(QAbstractItemView::DragDrop);
209 ui->tableView->setDragEnabled(true);
209 ui->treeView->setSortingEnabled(true);
210 ui->treeView->setDragDropMode(QAbstractItemView::DragDrop);
211 ui->treeView->setDragEnabled(true);
210 212
211 213 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
212 214 if (checked) {
213 215 ui->btnChart->setChecked(false);
214 216 impl->m_ZonesForTimeMode
215 217 = impl->selectZone(this, impl->m_ZonesForTimeMode, true,
216 218 this->mapToGlobal(ui->btnTime->frameGeometry().center()));
217 219
218 impl->updateForTimeMode(ui->tableView);
220 impl->updateForTimeMode(ui->treeView);
219 221 }
220 222 });
221 223
222 224 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
223 225 if (checked) {
224 226 ui->btnTime->setChecked(false);
225 227 impl->m_ZoneForGraphMode
226 228 = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false,
227 229 this->mapToGlobal(ui->btnChart->frameGeometry().center()))
228 230 .value(0);
229 231
230 impl->updateForGraphMode(ui->tableView);
232 impl->updateForGraphMode(ui->treeView);
231 233 }
232 234 });
233 235
234 236 auto emitSelection = [this]() {
235 237 QVector<std::shared_ptr<DBEvent> > events;
236 for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) {
237 events << impl->m_Model->getEvent(rowIndex.row());
238 QVector<QPair<std::shared_ptr<DBEvent>, std::shared_ptr<DBEventProduct> > > eventProducts;
239
240 for (auto rowIndex : ui->treeView->selectionModel()->selectedRows()) {
241
242 auto itemType = impl->m_Model->itemTypeOf(rowIndex);
243 if (itemType == CatalogueEventsModel::ItemType::Event) {
244 events << impl->m_Model->getEvent(rowIndex);
245 }
246 else if (itemType == CatalogueEventsModel::ItemType::EventProduct) {
247 eventProducts << qMakePair(impl->m_Model->getParentEvent(rowIndex),
248 impl->m_Model->getEventProduct(rowIndex));
249 }
238 250 }
239 251
240 emit this->eventsSelected(events);
252 if (!events.isEmpty() && eventProducts.isEmpty()) {
253 emit this->eventsSelected(events);
254 }
255 else if (events.isEmpty() && !eventProducts.isEmpty()) {
256 emit this->eventProductsSelected(eventProducts);
257 }
258 else {
259 emit this->selectionCleared();
260 }
241 261 };
242 262
243 connect(ui->tableView, &QTableView::clicked, emitSelection);
244 connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection);
263 connect(ui->treeView, &QTreeView::clicked, emitSelection);
264 connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection);
245 265
246 connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() {
247 auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1;
266 connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() {
267 auto isNotMultiSelection = ui->treeView->selectionModel()->selectedRows().count() <= 1;
248 268 ui->btnChart->setEnabled(isNotMultiSelection);
249 269 ui->btnTime->setEnabled(isNotMultiSelection);
250 270
251 271 if (isNotMultiSelection && ui->btnTime->isChecked()) {
252 impl->updateForTimeMode(ui->tableView);
272 impl->updateForTimeMode(ui->treeView);
253 273 }
254 274 else if (isNotMultiSelection && ui->btnChart->isChecked()) {
255 impl->updateForGraphMode(ui->tableView);
275 impl->updateForGraphMode(ui->treeView);
256 276 }
257 277 });
258 278
259 ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
260 ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
261 ui->tableView->horizontalHeader()->setSortIndicatorShown(true);
279 ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
280 ui->treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
281 ui->treeView->header()->setSortIndicatorShown(true);
262 282 }
263 283
264 284 CatalogueEventsWidget::~CatalogueEventsWidget()
265 285 {
266 286 delete ui;
267 287 }
268 288
269 289 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualization)
270 290 {
271 291 impl->m_VisualizationWidget = visualization;
272 292 }
273 293
294 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges)
295 {
296 impl->m_Model->refreshEvent(event);
297 }
298
274 299 void CatalogueEventsWidget::populateWithCatalogues(
275 300 const QVector<std::shared_ptr<DBCatalogue> > &catalogues)
276 301 {
277 302 QSet<QUuid> eventIds;
278 303 QVector<std::shared_ptr<DBEvent> > events;
279 304
280 305 for (auto catalogue : catalogues) {
281 306 auto catalogueEvents = sqpApp->catalogueController().retrieveEventsFromCatalogue(catalogue);
282 307 for (auto event : catalogueEvents) {
283 308 if (!eventIds.contains(event->getUniqId())) {
284 309 events << event;
285 310 eventIds.insert(event->getUniqId());
286 311 }
287 312 }
288 313 }
289 314
290 impl->setEvents(events, ui->tableView);
315 impl->setEvents(events, ui->treeView);
291 316 }
@@ -1,61 +1,83
1 1 #include "Catalogue/CatalogueExplorer.h"
2 2 #include "ui_CatalogueExplorer.h"
3 3
4 4 #include <Visualization/VisualizationWidget.h>
5 5
6 6 #include <DBCatalogue.h>
7 7 #include <DBEvent.h>
8 8
9 9 struct CatalogueExplorer::CatalogueExplorerPrivate {
10 10 };
11 11
12 12 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
13 13 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
14 14 ui(new Ui::CatalogueExplorer),
15 15 impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>()}
16 16 {
17 17 ui->setupUi(this);
18 18
19 19 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) {
20 20 if (catalogues.count() == 1) {
21 21 ui->inspector->setCatalogue(catalogues.first());
22 22 }
23 23 else {
24 24 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
25 25 }
26 26
27 27 ui->events->populateWithCatalogues(catalogues);
28 28 });
29 29
30 30 connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) {
31 31 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
32 32 });
33 33
34 34 connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected,
35 35 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
36 36
37 37 connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected,
38 38 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
39 39
40 40 connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared,
41 41 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
42 42
43 43 connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) {
44 44 if (events.count() == 1) {
45 45 ui->inspector->setEvent(events.first());
46 46 }
47 47 else {
48 48 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
49 49 }
50 50 });
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
65 connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated,
66 [this](auto catalogue) { ui->catalogues->setCatalogueChanges(catalogue, true); });
67
68 connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated,
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); });
51 73 }
52 74
53 75 CatalogueExplorer::~CatalogueExplorer()
54 76 {
55 77 delete ui;
56 78 }
57 79
58 80 void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization)
59 81 {
60 82 ui->events->setVisualizationWidget(visualization);
61 83 }
@@ -1,56 +1,181
1 1 #include "Catalogue/CatalogueInspectorWidget.h"
2 2 #include "ui_CatalogueInspectorWidget.h"
3 3
4 4 #include <Common/DateUtils.h>
5 5 #include <DBCatalogue.h>
6 6 #include <DBEvent.h>
7 #include <DBEventProduct.h>
7 8 #include <DBTag.h>
8 9
10 struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate {
11 std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr;
12 std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr;
13 std::shared_ptr<DBEventProduct> m_DisplayedEventProduct = nullptr;
14
15 void connectCatalogueUpdateSignals(CatalogueInspectorWidget *inspector,
16 Ui::CatalogueInspectorWidget *ui);
17 void connectEventUpdateSignals(CatalogueInspectorWidget *inspector,
18 Ui::CatalogueInspectorWidget *ui);
19 };
20
9 21 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
10 : QWidget(parent), ui(new Ui::CatalogueInspectorWidget)
22 : QWidget(parent),
23 ui(new Ui::CatalogueInspectorWidget),
24 impl{spimpl::make_unique_impl<CatalogueInspectorWidgetPrivate>()}
11 25 {
12 26 ui->setupUi(this);
13 27 showPage(Page::Empty);
28
29 impl->connectCatalogueUpdateSignals(this, ui);
30 impl->connectEventUpdateSignals(this, ui);
14 31 }
15 32
16 33 CatalogueInspectorWidget::~CatalogueInspectorWidget()
17 34 {
18 35 delete ui;
19 36 }
20 37
38 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectCatalogueUpdateSignals(
39 CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
40 {
41 connect(ui->leCatalogueName, &QLineEdit::editingFinished, [ui, inspector, this]() {
42 if (ui->leCatalogueName->text() != m_DisplayedCatalogue->getName()) {
43 m_DisplayedCatalogue->setName(ui->leCatalogueName->text());
44 emit inspector->catalogueUpdated(m_DisplayedCatalogue);
45 }
46 });
47
48 connect(ui->leCatalogueAuthor, &QLineEdit::editingFinished, [ui, inspector, this]() {
49 if (ui->leCatalogueAuthor->text() != m_DisplayedCatalogue->getAuthor()) {
50 m_DisplayedCatalogue->setAuthor(ui->leCatalogueAuthor->text());
51 emit inspector->catalogueUpdated(m_DisplayedCatalogue);
52 }
53 });
54 }
55
56 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpdateSignals(
57 CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
58 {
59 connect(ui->leEventName, &QLineEdit::editingFinished, [ui, inspector, this]() {
60 if (ui->leEventName->text() != m_DisplayedEvent->getName()) {
61 m_DisplayedEvent->setName(ui->leEventName->text());
62 emit inspector->eventUpdated(m_DisplayedEvent);
63 }
64 });
65
66 connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() {
67 auto tags = ui->leEventTags->text().split(QRegExp("\\s+"));
68 std::list<QString> tagNames;
69 for (auto tag : tags) {
70 tagNames.push_back(tag);
71 }
72
73 if (m_DisplayedEvent->getTagsNames() != tagNames) {
74 m_DisplayedEvent->setTagsNames(tagNames);
75 emit inspector->eventUpdated(m_DisplayedEvent);
76 }
77 });
78
79 connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() {
80 if (ui->leEventProduct->text() != m_DisplayedEventProduct->getProductId()) {
81 m_DisplayedEventProduct->setProductId(ui->leEventProduct->text());
82 emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct);
83 }
84 });
85
86 connect(ui->dateTimeEventTStart, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
87 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime());
88 if (time != m_DisplayedEventProduct->getTStart()) {
89 m_DisplayedEventProduct->setTStart(time);
90 emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct);
91 }
92 });
93
94 connect(ui->dateTimeEventTEnd, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
95 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime());
96 if (time != m_DisplayedEventProduct->getTEnd()) {
97 m_DisplayedEventProduct->setTEnd(time);
98 emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct);
99 }
100 });
101 }
102
21 103 void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page)
22 104 {
23 105 ui->stackedWidget->setCurrentIndex(static_cast<int>(page));
24 106 }
25 107
26 108 CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const
27 109 {
28 110 return static_cast<Page>(ui->stackedWidget->currentIndex());
29 111 }
30 112
31 113 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event)
32 114 {
115 impl->m_DisplayedEvent = event;
116
117 blockSignals(true);
118
33 119 showPage(Page::EventProperties);
120 ui->leEventName->setEnabled(true);
34 121 ui->leEventName->setText(event->getName());
35 ui->leEventMission->setText(event->getMission());
36 ui->leEventProduct->setText(event->getProduct());
122 ui->leEventProduct->setEnabled(false);
123 ui->leEventProduct->setText(
124 QString::number(event->getEventProducts().size()).append(" product(s)"));
37 125
38 126 QString tagList;
39 auto tags = event->getTags();
127 auto tags = event->getTagsNames();
40 128 for (auto tag : tags) {
41 tagList += tag.getName();
129 tagList += tag;
42 130 tagList += ' ';
43 131 }
44 132
133 ui->leEventTags->setEnabled(true);
45 134 ui->leEventTags->setText(tagList);
46 135
136 ui->dateTimeEventTStart->setEnabled(false);
137 ui->dateTimeEventTEnd->setEnabled(false);
138
47 139 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart()));
48 140 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd()));
141
142 blockSignals(false);
143 }
144
145 void CatalogueInspectorWidget::setEventProduct(const std::shared_ptr<DBEvent> &event,
146 const std::shared_ptr<DBEventProduct> &eventProduct)
147 {
148 impl->m_DisplayedEventProduct = eventProduct;
149
150 blockSignals(true);
151
152 showPage(Page::EventProperties);
153 ui->leEventName->setEnabled(false);
154 ui->leEventName->setText(event->getName());
155 ui->leEventProduct->setEnabled(true);
156 ui->leEventProduct->setText(eventProduct->getProductId());
157
158 ui->leEventTags->setEnabled(false);
159 ui->leEventTags->clear();
160
161 ui->dateTimeEventTStart->setEnabled(true);
162 ui->dateTimeEventTEnd->setEnabled(true);
163
164 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(eventProduct->getTStart()));
165 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(eventProduct->getTEnd()));
166
167 blockSignals(false);
49 168 }
50 169
51 170 void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue)
52 171 {
172 impl->m_DisplayedCatalogue = catalogue;
173
174 blockSignals(true);
175
53 176 showPage(Page::CatalogueProperties);
54 177 ui->leCatalogueName->setText(catalogue->getName());
55 178 ui->leCatalogueAuthor->setText(catalogue->getAuthor());
179
180 blockSignals(false);
56 181 }
@@ -1,198 +1,247
1 1 #include "Catalogue/CatalogueSideBarWidget.h"
2 2 #include "ui_CatalogueSideBarWidget.h"
3 3 #include <SqpApplication.h>
4 4
5 5 #include <Catalogue/CatalogueController.h>
6 6 #include <Catalogue/CatalogueTreeWidgetItem.h>
7 7 #include <CatalogueDao.h>
8 8 #include <ComparaisonPredicate.h>
9 9 #include <DBCatalogue.h>
10 10
11 11 #include <QMenu>
12 12
13 Q_LOGGING_CATEGORY(LOG_CatalogueSideBarWidget, "CatalogueSideBarWidget")
14
13 15
14 16 constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType;
15 17 constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1;
16 18 constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2;
17 19 constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3;
18 20
19 21
20 22 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
21 23
22 24 void configureTreeWidget(QTreeWidget *treeWidget);
23 25 QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget);
24 26 QTreeWidgetItem *getDatabaseItem(const QString &name, QTreeWidget *treeWidget);
25 27 void addCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue,
26 28 QTreeWidgetItem *parentDatabaseItem);
29
30 CatalogueTreeWidgetItem *getCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue,
31 QTreeWidget *treeWidget) const;
27 32 };
28 33
29 34 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
30 35 : QWidget(parent),
31 36 ui(new Ui::CatalogueSideBarWidget),
32 37 impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()}
33 38 {
34 39 ui->setupUi(this);
35 40 impl->configureTreeWidget(ui->treeWidget);
36 41
37 42 ui->treeWidget->setColumnCount(2);
38 43 ui->treeWidget->header()->setStretchLastSection(false);
39 44 ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
40 45 ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
41 46
42 47 auto emitSelection = [this]() {
43 48
44 49 auto selectedItems = ui->treeWidget->selectedItems();
45 50 if (selectedItems.isEmpty()) {
46 51 emit this->selectionCleared();
47 52 }
48 53 else {
49 54 QVector<std::shared_ptr<DBCatalogue> > catalogues;
50 55 QStringList databases;
51 56 int selectionType = selectedItems.first()->type();
52 57
53 58 for (auto item : ui->treeWidget->selectedItems()) {
54 59 if (item->type() == selectionType) {
55 60 switch (selectionType) {
56 61 case CATALOGUE_ITEM_TYPE:
57 62 catalogues.append(
58 63 static_cast<CatalogueTreeWidgetItem *>(item)->catalogue());
59 64 break;
60 65 case DATABASE_ITEM_TYPE:
61 66 selectionType = DATABASE_ITEM_TYPE;
62 67 databases.append(item->text(0));
63 68 case ALL_EVENT_ITEM_TYPE: // fallthrough
64 69 case TRASH_ITEM_TYPE: // fallthrough
65 70 default:
66 71 break;
67 72 }
68 73 }
69 74 else {
70 75 // Incoherent multi selection
71 76 selectionType = -1;
72 77 break;
73 78 }
74 79 }
75 80
76 81 switch (selectionType) {
77 82 case CATALOGUE_ITEM_TYPE:
78 83 emit this->catalogueSelected(catalogues);
79 84 break;
80 85 case DATABASE_ITEM_TYPE:
81 86 emit this->databaseSelected(databases);
82 87 break;
83 88 case ALL_EVENT_ITEM_TYPE:
84 89 emit this->allEventsSelected();
85 90 break;
86 91 case TRASH_ITEM_TYPE:
87 92 emit this->trashSelected();
88 93 break;
89 94 default:
90 95 emit this->selectionCleared();
91 96 break;
92 97 }
93 98 }
94 99
95 100
96 101 };
97 102
98 103 connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection);
99 104 connect(ui->treeWidget, &QTreeWidget::currentItemChanged, emitSelection);
105 connect(ui->treeWidget, &QTreeWidget::itemChanged,
106 [emitSelection, this](auto item, auto column) {
107 auto selectedItems = ui->treeWidget->selectedItems();
108 qDebug() << "ITEM CHANGED" << column;
109 if (selectedItems.contains(item) && column == 0) {
110 emitSelection();
111 }
112 });
100 113
101 114 ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
102 115 connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this,
103 116 &CatalogueSideBarWidget::onContextMenuRequested);
104 117 }
105 118
106 119 CatalogueSideBarWidget::~CatalogueSideBarWidget()
107 120 {
108 121 delete ui;
109 122 }
110 123
124 void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue,
125 bool hasChanges)
126 {
127 if (auto catalogueItem = impl->getCatalogueItem(catalogue, ui->treeWidget)) {
128 catalogueItem->setHasChanges(hasChanges);
129 catalogueItem->refresh();
130 }
131 }
132
111 133 void CatalogueSideBarWidget::onContextMenuRequested(const QPoint &pos)
112 134 {
113 135 QMenu menu{this};
114 136
115 137 auto currentItem = ui->treeWidget->currentItem();
116 138 switch (currentItem->type()) {
117 139 case CATALOGUE_ITEM_TYPE:
118 140 menu.addAction("Rename",
119 141 [this, currentItem]() { ui->treeWidget->editItem(currentItem); });
120 142 break;
121 143 case DATABASE_ITEM_TYPE:
122 144 break;
123 145 case ALL_EVENT_ITEM_TYPE:
124 146 break;
125 147 case TRASH_ITEM_TYPE:
126 148 menu.addAction("Empty Trash", []() {
127 149 // TODO
128 150 });
129 151 break;
130 152 default:
131 153 break;
132 154 }
133 155
134 156 if (!menu.isEmpty()) {
135 157 menu.exec(ui->treeWidget->mapToGlobal(pos));
136 158 }
137 159 }
138 160
139 161 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget(
140 162 QTreeWidget *treeWidget)
141 163 {
142 164 auto allEventsItem = new QTreeWidgetItem{{"All Events"}, ALL_EVENT_ITEM_TYPE};
143 165 allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png"));
144 166 treeWidget->addTopLevelItem(allEventsItem);
145 167
146 168 auto trashItem = new QTreeWidgetItem{{"Trash"}, TRASH_ITEM_TYPE};
147 169 trashItem->setIcon(0, QIcon(":/icones/trash.png"));
148 170 treeWidget->addTopLevelItem(trashItem);
149 171
150 172 auto separator = new QFrame{treeWidget};
151 173 separator->setFrameShape(QFrame::HLine);
152 174 auto separatorItem = new QTreeWidgetItem{};
153 175 separatorItem->setFlags(Qt::NoItemFlags);
154 176 treeWidget->addTopLevelItem(separatorItem);
155 177 treeWidget->setItemWidget(separatorItem, 0, separator);
156 178
157 179 auto db = addDatabaseItem("Default", treeWidget);
158 180
159 181 auto catalogues = sqpApp->catalogueController().getCatalogues("Default");
160 182 for (auto catalogue : catalogues) {
161 183 addCatalogueItem(catalogue, db);
162 184 }
163 185
164 186 treeWidget->expandAll();
165 187 }
166 188
167 189 QTreeWidgetItem *
168 190 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name,
169 191 QTreeWidget *treeWidget)
170 192 {
171 193 auto databaseItem = new QTreeWidgetItem{{name}, DATABASE_ITEM_TYPE};
172 194 databaseItem->setIcon(0, QIcon{":/icones/database.png"});
173 195 treeWidget->addTopLevelItem(databaseItem);
174 196
175 197 return databaseItem;
176 198 }
177 199
178 200 QTreeWidgetItem *
179 201 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getDatabaseItem(const QString &name,
180 202 QTreeWidget *treeWidget)
181 203 {
182 204 for (auto i = 0; i < treeWidget->topLevelItemCount(); ++i) {
183 205 auto item = treeWidget->topLevelItem(i);
184 206 if (item->type() == DATABASE_ITEM_TYPE && item->text(0) == name) {
185 207 return item;
186 208 }
187 209 }
188 210
189 211 return nullptr;
190 212 }
191 213
192 214 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem(
193 215 const std::shared_ptr<DBCatalogue> &catalogue, QTreeWidgetItem *parentDatabaseItem)
194 216 {
195 217 auto catalogueItem = new CatalogueTreeWidgetItem{catalogue, CATALOGUE_ITEM_TYPE};
196 218 catalogueItem->setIcon(0, QIcon{":/icones/catalogue.png"});
197 219 parentDatabaseItem->addChild(catalogueItem);
198 220 }
221
222 CatalogueTreeWidgetItem *CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getCatalogueItem(
223 const std::shared_ptr<DBCatalogue> &catalogue, QTreeWidget *treeWidget) const
224 {
225 for (auto i = 0; i < treeWidget->topLevelItemCount(); ++i) {
226 auto item = treeWidget->topLevelItem(i);
227 if (item->type() == DATABASE_ITEM_TYPE) {
228 for (auto j = 0; j < item->childCount(); ++j) {
229 auto childItem = item->child(j);
230 if (childItem->type() == CATALOGUE_ITEM_TYPE) {
231 auto catalogueItem = static_cast<CatalogueTreeWidgetItem *>(childItem);
232 if (catalogueItem->catalogue() == catalogue) {
233 return catalogueItem;
234 }
235 }
236 else {
237 qCWarning(LOG_CatalogueSideBarWidget()) << "getCatalogueItem: Invalid tree "
238 "structure. A database item should "
239 "only contain catalogues.";
240 Q_ASSERT(false);
241 }
242 }
243 }
244 }
245
246 return nullptr;
247 }
@@ -1,93 +1,103
1 1 #include "Catalogue/CatalogueTreeWidgetItem.h"
2 2
3 3 #include <memory>
4 4
5 5 #include <DBCatalogue.h>
6 6 #include <QBoxLayout>
7 7 #include <QToolButton>
8 8
9 9 const auto VALIDATION_BUTTON_ICON_SIZE = 12;
10 10
11 /// Column in the tree widget where the apply and cancel buttons must appear
12 const auto APPLY_CANCEL_BUTTONS_COLUMN = 1;
13
11 14 struct CatalogueTreeWidgetItem::CatalogueTreeWidgetItemPrivate {
12 15
13 16 std::shared_ptr<DBCatalogue> m_Catalogue;
14 17
15 18 CatalogueTreeWidgetItemPrivate(std::shared_ptr<DBCatalogue> catalogue) : m_Catalogue(catalogue)
16 19 {
17 20 }
18 21 };
19 22
20 23
21 24 CatalogueTreeWidgetItem::CatalogueTreeWidgetItem(std::shared_ptr<DBCatalogue> catalogue, int type)
22 25 : QTreeWidgetItem(type),
23 26 impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)}
24 27 {
25 28 setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
26 29 }
27 30
28 31 QVariant CatalogueTreeWidgetItem::data(int column, int role) const
29 32 {
30 33 if (column == 0) {
31 34 switch (role) {
32 35 case Qt::EditRole: // fallthrough
33 36 case Qt::DisplayRole:
34 37 return impl->m_Catalogue->getName();
35 38 default:
36 39 break;
37 40 }
38 41 }
39 42
40 43 return QTreeWidgetItem::data(column, role);
41 44 }
42 45
43 46 void CatalogueTreeWidgetItem::setData(int column, int role, const QVariant &value)
44 47 {
45 48 if (role == Qt::EditRole && column == 0) {
46 49 auto newName = value.toString();
47 50 if (newName != impl->m_Catalogue->getName()) {
48 51 setText(0, newName);
49 52 impl->m_Catalogue->setName(newName);
50 53 setHasChanges(true);
51 54 }
52 55 }
53 56 else {
54 57 QTreeWidgetItem::setData(column, role, value);
55 58 }
56 59 }
57 60
58 61 std::shared_ptr<DBCatalogue> CatalogueTreeWidgetItem::catalogue() const
59 62 {
60 63 return impl->m_Catalogue;
61 64 }
62 65
63 66 void CatalogueTreeWidgetItem::setHasChanges(bool value)
64 67 {
65 68 if (value) {
66 auto widet = new QWidget{treeWidget()};
67
68 auto layout = new QHBoxLayout{widet};
69 layout->setContentsMargins(0, 0, 0, 0);
70 layout->setSpacing(0);
71
72 auto btnValid = new QToolButton{widet};
73 btnValid->setIcon(QIcon{":/icones/save"});
74 btnValid->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE});
75 btnValid->setAutoRaise(true);
76 QObject::connect(btnValid, &QToolButton::clicked, [this]() { setHasChanges(false); });
77 layout->addWidget(btnValid);
78
79 auto btnDiscard = new QToolButton{widet};
80 btnDiscard->setIcon(QIcon{":/icones/discard"});
81 btnDiscard->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE});
82 btnDiscard->setAutoRaise(true);
83 QObject::connect(btnDiscard, &QToolButton::clicked, [this]() { setHasChanges(false); });
84 layout->addWidget(btnDiscard);
85
86 treeWidget()->setItemWidget(this, 1, {widet});
87 treeWidget()->resizeColumnToContents(1);
69 if (treeWidget()->itemWidget(this, APPLY_CANCEL_BUTTONS_COLUMN) == nullptr) {
70 auto widet = new QWidget{treeWidget()};
71
72 auto layout = new QHBoxLayout{widet};
73 layout->setContentsMargins(0, 0, 0, 0);
74 layout->setSpacing(0);
75
76 auto btnValid = new QToolButton{widet};
77 btnValid->setIcon(QIcon{":/icones/save"});
78 btnValid->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE});
79 btnValid->setAutoRaise(true);
80 QObject::connect(btnValid, &QToolButton::clicked, [this]() { setHasChanges(false); });
81 layout->addWidget(btnValid);
82
83 auto btnDiscard = new QToolButton{widet};
84 btnDiscard->setIcon(QIcon{":/icones/discard"});
85 btnDiscard->setIconSize(
86 QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE});
87 btnDiscard->setAutoRaise(true);
88 QObject::connect(btnDiscard, &QToolButton::clicked, [this]() { setHasChanges(false); });
89 layout->addWidget(btnDiscard);
90
91 treeWidget()->setItemWidget(this, APPLY_CANCEL_BUTTONS_COLUMN, {widet});
92 }
88 93 }
89 94 else {
90 95 // Note: the widget is destroyed
91 treeWidget()->setItemWidget(this, 1, nullptr);
96 treeWidget()->setItemWidget(this, APPLY_CANCEL_BUTTONS_COLUMN, nullptr);
92 97 }
93 98 }
99
100 void CatalogueTreeWidgetItem::refresh()
101 {
102 emitDataChanged();
103 }
@@ -1,154 +1,142
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>CatalogueEventsWidget</class>
4 4 <widget class="QWidget" name="CatalogueEventsWidget">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 9 <width>566</width>
10 10 <height>258</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 15 </property>
16 16 <layout class="QVBoxLayout" name="verticalLayout">
17 17 <property name="leftMargin">
18 18 <number>0</number>
19 19 </property>
20 20 <property name="topMargin">
21 21 <number>0</number>
22 22 </property>
23 23 <property name="rightMargin">
24 24 <number>0</number>
25 25 </property>
26 26 <property name="bottomMargin">
27 27 <number>0</number>
28 28 </property>
29 29 <item>
30 30 <layout class="QHBoxLayout" name="horizontalLayout">
31 31 <item>
32 32 <widget class="QToolButton" name="btnAdd">
33 33 <property name="text">
34 34 <string>+</string>
35 35 </property>
36 36 <property name="icon">
37 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">
41 41 <bool>true</bool>
42 42 </property>
43 43 </widget>
44 44 </item>
45 45 <item>
46 46 <widget class="QToolButton" name="btnRemove">
47 47 <property name="text">
48 48 <string> - </string>
49 49 </property>
50 50 <property name="icon">
51 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">
55 55 <bool>true</bool>
56 56 </property>
57 57 </widget>
58 58 </item>
59 59 <item>
60 60 <widget class="Line" name="line">
61 61 <property name="orientation">
62 62 <enum>Qt::Vertical</enum>
63 63 </property>
64 64 </widget>
65 65 </item>
66 66 <item>
67 67 <widget class="QToolButton" name="btnTime">
68 68 <property name="text">
69 69 <string>T</string>
70 70 </property>
71 71 <property name="icon">
72 72 <iconset resource="../../resources/sqpguiresources.qrc">
73 73 <normaloff>:/icones/time.png</normaloff>:/icones/time.png</iconset>
74 74 </property>
75 75 <property name="checkable">
76 76 <bool>true</bool>
77 77 </property>
78 78 <property name="autoRaise">
79 79 <bool>true</bool>
80 80 </property>
81 81 </widget>
82 82 </item>
83 83 <item>
84 84 <widget class="QToolButton" name="btnChart">
85 85 <property name="text">
86 86 <string>G</string>
87 87 </property>
88 88 <property name="icon">
89 89 <iconset resource="../../resources/sqpguiresources.qrc">
90 90 <normaloff>:/icones/chart.png</normaloff>:/icones/chart.png</iconset>
91 91 </property>
92 92 <property name="checkable">
93 93 <bool>true</bool>
94 94 </property>
95 95 <property name="autoRaise">
96 96 <bool>true</bool>
97 97 </property>
98 98 </widget>
99 99 </item>
100 100 <item>
101 101 <widget class="Line" name="line_2">
102 102 <property name="orientation">
103 103 <enum>Qt::Vertical</enum>
104 104 </property>
105 105 </widget>
106 106 </item>
107 107 <item>
108 108 <widget class="QLineEdit" name="lineEdit">
109 109 <property name="enabled">
110 110 <bool>false</bool>
111 111 </property>
112 112 </widget>
113 113 </item>
114 114 </layout>
115 115 </item>
116 116 <item>
117 <widget class="QTableView" name="tableView">
117 <widget class="QTreeView" name="treeView">
118 118 <property name="dragEnabled">
119 119 <bool>true</bool>
120 120 </property>
121 121 <property name="dragDropMode">
122 122 <enum>QAbstractItemView::DragDrop</enum>
123 123 </property>
124 <property name="selectionMode">
125 <enum>QAbstractItemView::ExtendedSelection</enum>
126 </property>
124 127 <property name="selectionBehavior">
125 128 <enum>QAbstractItemView::SelectRows</enum>
126 129 </property>
127 <attribute name="horizontalHeaderVisible">
128 <bool>true</bool>
129 </attribute>
130 <attribute name="horizontalHeaderHighlightSections">
131 <bool>false</bool>
132 </attribute>
133 <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
134 <bool>true</bool>
135 </attribute>
136 <attribute name="verticalHeaderVisible">
137 <bool>false</bool>
138 </attribute>
139 <attribute name="verticalHeaderDefaultSectionSize">
140 <number>25</number>
141 </attribute>
142 <attribute name="verticalHeaderHighlightSections">
130 <attribute name="headerStretchLastSection">
143 131 <bool>false</bool>
144 132 </attribute>
145 133 </widget>
146 134 </item>
147 135 </layout>
148 136 </widget>
149 137 <resources>
150 138 <include location="../../resources/sqpguiresources.qrc"/>
151 139 <include location="../../resources/sqpguiresources.qrc"/>
152 140 </resources>
153 141 <connections/>
154 142 </ui>
@@ -1,214 +1,219
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>CatalogueInspectorWidget</class>
4 4 <widget class="QWidget" name="CatalogueInspectorWidget">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 9 <width>400</width>
10 10 <height>300</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 15 </property>
16 16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 17 <property name="leftMargin">
18 18 <number>0</number>
19 19 </property>
20 20 <property name="topMargin">
21 21 <number>0</number>
22 22 </property>
23 23 <property name="rightMargin">
24 24 <number>0</number>
25 25 </property>
26 26 <property name="bottomMargin">
27 27 <number>0</number>
28 28 </property>
29 29 <item>
30 30 <widget class="QFrame" name="frame">
31 31 <property name="frameShape">
32 32 <enum>QFrame::Box</enum>
33 33 </property>
34 34 <property name="frameShadow">
35 35 <enum>QFrame::Sunken</enum>
36 36 </property>
37 37 <property name="lineWidth">
38 38 <number>1</number>
39 39 </property>
40 40 <layout class="QVBoxLayout" name="verticalLayout">
41 41 <property name="leftMargin">
42 42 <number>0</number>
43 43 </property>
44 44 <property name="topMargin">
45 45 <number>0</number>
46 46 </property>
47 47 <property name="rightMargin">
48 48 <number>0</number>
49 49 </property>
50 50 <property name="bottomMargin">
51 51 <number>0</number>
52 52 </property>
53 53 <item>
54 54 <widget class="QStackedWidget" name="stackedWidget">
55 55 <property name="currentIndex">
56 <number>1</number>
56 <number>2</number>
57 57 </property>
58 58 <widget class="QWidget" name="emptyPage"/>
59 59 <widget class="QWidget" name="catalogueInspectorPage">
60 60 <layout class="QGridLayout" name="gridLayout_2">
61 61 <item row="1" column="0">
62 62 <widget class="QLabel" name="label_7">
63 63 <property name="text">
64 64 <string>Name</string>
65 65 </property>
66 66 </widget>
67 67 </item>
68 68 <item row="1" column="1">
69 69 <widget class="QLineEdit" name="leCatalogueName"/>
70 70 </item>
71 71 <item row="2" column="0">
72 72 <widget class="QLabel" name="label_8">
73 73 <property name="text">
74 74 <string>Author</string>
75 75 </property>
76 76 </widget>
77 77 </item>
78 78 <item row="2" column="1">
79 79 <widget class="QLineEdit" name="leCatalogueAuthor">
80 80 <property name="text">
81 81 <string/>
82 82 </property>
83 83 </widget>
84 84 </item>
85 85 <item row="3" column="1">
86 86 <spacer name="verticalSpacer_2">
87 87 <property name="orientation">
88 88 <enum>Qt::Vertical</enum>
89 89 </property>
90 90 <property name="sizeHint" stdset="0">
91 91 <size>
92 92 <width>20</width>
93 93 <height>40</height>
94 94 </size>
95 95 </property>
96 96 </spacer>
97 97 </item>
98 98 <item row="0" column="0" colspan="2">
99 99 <widget class="QLabel" name="label_9">
100 100 <property name="font">
101 101 <font>
102 102 <pointsize>10</pointsize>
103 103 <weight>75</weight>
104 104 <bold>true</bold>
105 105 </font>
106 106 </property>
107 107 <property name="text">
108 108 <string>Catalogue Properties</string>
109 109 </property>
110 110 </widget>
111 111 </item>
112 112 </layout>
113 113 </widget>
114 114 <widget class="QWidget" name="eventInspectorPage">
115 115 <layout class="QGridLayout" name="gridLayout">
116 <item row="5" column="1">
117 <widget class="QDateTimeEdit" name="dateTimeEventTEnd"/>
118 </item>
119 116 <item row="4" column="0">
120 <widget class="QLabel" name="label_4">
121 <property name="text">
122 <string>TStart</string>
123 </property>
124 </widget>
125 </item>
126 <item row="6" column="0">
127 <widget class="QLabel" name="label_6">
128 <property name="text">
129 <string>Tags</string>
130 </property>
131 </widget>
132 </item>
133 <item row="3" column="0">
134 117 <widget class="QLabel" name="label_3">
135 118 <property name="text">
136 119 <string>Product</string>
137 120 </property>
138 121 </widget>
139 122 </item>
140 <item row="3" column="1">
141 <widget class="QLineEdit" name="leEventProduct"/>
142 </item>
143 123 <item row="5" column="0">
144 <widget class="QLabel" name="label_5">
145 <property name="text">
146 <string>Tend</string>
147 </property>
148 </widget>
149 </item>
150 <item row="4" column="1">
151 <widget class="QDateTimeEdit" name="dateTimeEventTStart"/>
152 </item>
153 <item row="2" column="0">
154 <widget class="QLabel" name="label_2">
124 <widget class="QLabel" name="label_4">
155 125 <property name="text">
156 <string>Mission</string>
126 <string>TStart</string>
157 127 </property>
158 128 </widget>
159 129 </item>
160 <item row="1" column="1">
161 <widget class="QLineEdit" name="leEventName"/>
162 </item>
163 130 <item row="1" column="0">
164 131 <widget class="QLabel" name="label">
165 132 <property name="text">
166 133 <string>Name</string>
167 134 </property>
168 135 </widget>
169 136 </item>
170 <item row="2" column="1">
171 <widget class="QLineEdit" name="leEventMission"/>
172 </item>
173 <item row="6" column="1">
174 <widget class="QLineEdit" name="leEventTags"/>
137 <item row="0" column="0" colspan="2">
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>
146 <property name="text">
147 <string>Event Properties</string>
148 </property>
149 </widget>
175 150 </item>
176 <item row="7" column="1">
151 <item row="8" column="1">
177 152 <spacer name="verticalSpacer">
178 153 <property name="orientation">
179 154 <enum>Qt::Vertical</enum>
180 155 </property>
181 156 <property name="sizeHint" stdset="0">
182 157 <size>
183 158 <width>20</width>
184 159 <height>40</height>
185 160 </size>
186 161 </property>
187 162 </spacer>
188 163 </item>
189 <item row="0" column="0" colspan="2">
190 <widget class="QLabel" name="label_10">
191 <property name="font">
192 <font>
193 <pointsize>10</pointsize>
194 <weight>75</weight>
195 <bold>true</bold>
196 </font>
164 <item row="1" column="1">
165 <widget class="QLineEdit" name="leEventName"/>
166 </item>
167 <item row="5" column="1">
168 <widget class="QDateTimeEdit" name="dateTimeEventTStart">
169 <property name="timeSpec">
170 <enum>Qt::UTC</enum>
171 </property>
172 </widget>
173 </item>
174 <item row="4" column="1">
175 <widget class="QLineEdit" name="leEventProduct"/>
176 </item>
177 <item row="6" column="0">
178 <widget class="QLabel" name="label_5">
179 <property name="text">
180 <string>Tend</string>
197 181 </property>
182 </widget>
183 </item>
184 <item row="6" column="1">
185 <widget class="QDateTimeEdit" name="dateTimeEventTEnd">
186 <property name="timeSpec">
187 <enum>Qt::UTC</enum>
188 </property>
189 </widget>
190 </item>
191 <item row="2" column="1">
192 <widget class="QLineEdit" name="leEventTags"/>
193 </item>
194 <item row="2" column="0">
195 <widget class="QLabel" name="label_6">
198 196 <property name="text">
199 <string>Event Properties</string>
197 <string>Tags</string>
198 </property>
199 </widget>
200 </item>
201 <item row="3" column="0" colspan="2">
202 <widget class="Line" name="line">
203 <property name="orientation">
204 <enum>Qt::Horizontal</enum>
200 205 </property>
201 206 </widget>
202 207 </item>
203 208 </layout>
204 209 </widget>
205 210 </widget>
206 211 </item>
207 212 </layout>
208 213 </widget>
209 214 </item>
210 215 </layout>
211 216 </widget>
212 217 <resources/>
213 218 <connections/>
214 219 </ui>
1 NO CONTENT: file was removed
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

You need to be logged in to leave comments. Login now