Auto status change to "Under Review"
@@ -0,0 +1,13 | |||||
|
1 | #ifndef SCIQLOP_CATALOGUEEXPLORERHELPER_H | |||
|
2 | #define SCIQLOP_CATALOGUEEXPLORERHELPER_H | |||
|
3 | ||||
|
4 | #include <QWidget> | |||
|
5 | ||||
|
6 | #include <functional> | |||
|
7 | ||||
|
8 | struct CatalogueExplorerHelper { | |||
|
9 | static QWidget *buildValidationWidget(QWidget *parent, std::function<void()> save, | |||
|
10 | std::function<void()> discard); | |||
|
11 | }; | |||
|
12 | ||||
|
13 | #endif // SCIQLOP_CATALOGUEEXPLORERHELPER_H |
@@ -0,0 +1,32 | |||||
|
1 | #include "Catalogue/CatalogueExplorerHelper.h" | |||
|
2 | ||||
|
3 | #include <QBoxLayout> | |||
|
4 | #include <QToolButton> | |||
|
5 | ||||
|
6 | const auto VALIDATION_BUTTON_ICON_SIZE = 12; | |||
|
7 | ||||
|
8 | QWidget *CatalogueExplorerHelper::buildValidationWidget(QWidget *parent, std::function<void()> save, | |||
|
9 | std::function<void()> discard) | |||
|
10 | { | |||
|
11 | auto widget = new QWidget{parent}; | |||
|
12 | ||||
|
13 | auto layout = new QHBoxLayout{widget}; | |||
|
14 | layout->setContentsMargins(0, 0, 0, 0); | |||
|
15 | layout->setSpacing(0); | |||
|
16 | ||||
|
17 | auto btnValid = new QToolButton{widget}; | |||
|
18 | btnValid->setIcon(QIcon{":/icones/save"}); | |||
|
19 | btnValid->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE}); | |||
|
20 | btnValid->setAutoRaise(true); | |||
|
21 | QObject::connect(btnValid, &QToolButton::clicked, save); | |||
|
22 | layout->addWidget(btnValid); | |||
|
23 | ||||
|
24 | auto btnDiscard = new QToolButton{widget}; | |||
|
25 | btnDiscard->setIcon(QIcon{":/icones/discard"}); | |||
|
26 | btnDiscard->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE}); | |||
|
27 | btnDiscard->setAutoRaise(true); | |||
|
28 | QObject::connect(btnDiscard, &QToolButton::clicked, discard); | |||
|
29 | layout->addWidget(btnDiscard); | |||
|
30 | ||||
|
31 | return widget; | |||
|
32 | } |
@@ -3,17 +3,29 | |||||
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 | #include <QAbstractItemModel> |
|
5 | #include <QAbstractItemModel> | |
|
6 | #include <QLoggingCategory> | |||
|
7 | #include <unordered_set> | |||
6 |
|
8 | |||
7 | class DBEvent; |
|
9 | class DBEvent; | |
8 | class DBEventProduct; |
|
10 | class DBEventProduct; | |
9 |
|
11 | |||
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueEventsModel) | |||
|
13 | ||||
10 | class CatalogueEventsModel : public QAbstractItemModel { |
|
14 | class CatalogueEventsModel : public QAbstractItemModel { | |
|
15 | Q_OBJECT | |||
|
16 | ||||
|
17 | signals: | |||
|
18 | void modelSorted(); | |||
|
19 | ||||
11 | public: |
|
20 | public: | |
12 | CatalogueEventsModel(QObject *parent = nullptr); |
|
21 | CatalogueEventsModel(QObject *parent = nullptr); | |
13 |
|
22 | |||
|
23 | enum class Column { Name, TStart, TEnd, Tags, Product, Validation, NbColumn }; | |||
|
24 | ||||
14 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events); |
|
25 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events); | |
15 | void addEvent(const std::shared_ptr<DBEvent> &event); |
|
26 | void addEvent(const std::shared_ptr<DBEvent> &event); | |
16 | void removeEvent(const std::shared_ptr<DBEvent> &event); |
|
27 | void removeEvent(const std::shared_ptr<DBEvent> &event); | |
|
28 | QVector<std::shared_ptr<DBEvent> > events() const; | |||
17 |
|
29 | |||
18 | enum class ItemType { Root, Event, EventProduct }; |
|
30 | enum class ItemType { Root, Event, EventProduct }; | |
19 | ItemType itemTypeOf(const QModelIndex &index) const; |
|
31 | ItemType itemTypeOf(const QModelIndex &index) const; | |
@@ -21,8 +33,18 public: | |||||
21 | std::shared_ptr<DBEvent> getParentEvent(const QModelIndex &index) const; |
|
33 | std::shared_ptr<DBEvent> getParentEvent(const QModelIndex &index) const; | |
22 | std::shared_ptr<DBEventProduct> getEventProduct(const QModelIndex &index) const; |
|
34 | std::shared_ptr<DBEventProduct> getEventProduct(const QModelIndex &index) const; | |
23 |
|
35 | |||
|
36 | /// Refresh the data for the specified event | |||
24 | void refreshEvent(const std::shared_ptr<DBEvent> &event); |
|
37 | void refreshEvent(const std::shared_ptr<DBEvent> &event); | |
25 |
|
38 | |||
|
39 | /// Returns a QModelIndex which represent the specified event | |||
|
40 | QModelIndex indexOf(const std::shared_ptr<DBEvent> &event) const; | |||
|
41 | ||||
|
42 | /// Marks a change flag on the specified event to allow sorting on the validation column | |||
|
43 | void setEventHasChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges); | |||
|
44 | ||||
|
45 | /// Returns true if the specified event has unsaved changes | |||
|
46 | bool eventsHasChanges(const std::shared_ptr<DBEvent> &event) const; | |||
|
47 | ||||
26 | // Model |
|
48 | // Model | |
27 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
|
49 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; | |
28 | QModelIndex parent(const QModelIndex &index) const; |
|
50 | QModelIndex parent(const QModelIndex &index) const; |
@@ -22,6 +22,9 public: | |||||
22 | /// changes |
|
22 | /// changes | |
23 | void setHasChanges(bool value); |
|
23 | void setHasChanges(bool value); | |
24 |
|
24 | |||
|
25 | /// Returns true if the widget indicating the event has unsaved changes is displayed | |||
|
26 | bool hasChanges(); | |||
|
27 | ||||
25 | /// Refreshes the data displayed by the item from the catalogue |
|
28 | /// Refreshes the data displayed by the item from the catalogue | |
26 | void refresh(); |
|
29 | void refresh(); | |
27 |
|
30 |
@@ -25,7 +25,8 gui_moc_headers = [ | |||||
25 | 'include/Catalogue/CatalogueExplorer.h', |
|
25 | 'include/Catalogue/CatalogueExplorer.h', | |
26 | 'include/Catalogue/CatalogueEventsWidget.h', |
|
26 | 'include/Catalogue/CatalogueEventsWidget.h', | |
27 | 'include/Catalogue/CatalogueSideBarWidget.h', |
|
27 | 'include/Catalogue/CatalogueSideBarWidget.h', | |
28 | 'include/Catalogue/CatalogueInspectorWidget.h' |
|
28 | 'include/Catalogue/CatalogueInspectorWidget.h', | |
|
29 | 'include/Catalogue/CatalogueEventsModel.h' | |||
29 | ] |
|
30 | ] | |
30 |
|
31 | |||
31 | gui_ui_files = [ |
|
32 | gui_ui_files = [ | |
@@ -116,7 +117,8 gui_sources = [ | |||||
116 | 'src/Catalogue/CatalogueSideBarWidget.cpp', |
|
117 | 'src/Catalogue/CatalogueSideBarWidget.cpp', | |
117 | 'src/Catalogue/CatalogueInspectorWidget.cpp', |
|
118 | 'src/Catalogue/CatalogueInspectorWidget.cpp', | |
118 | 'src/Catalogue/CatalogueTreeWidgetItem.cpp', |
|
119 | 'src/Catalogue/CatalogueTreeWidgetItem.cpp', | |
119 | 'src/Catalogue/CatalogueEventsModel.cpp' |
|
120 | 'src/Catalogue/CatalogueEventsModel.cpp', | |
|
121 | 'src/Catalogue/CatalogueExplorerHelper.cpp' | |||
120 | ] |
|
122 | ] | |
121 |
|
123 | |||
122 | gui_inc = include_directories(['include']) |
|
124 | gui_inc = include_directories(['include']) |
@@ -15,33 +15,46 | |||||
15 | #include <QHash> |
|
15 | #include <QHash> | |
16 | #include <QMimeData> |
|
16 | #include <QMimeData> | |
17 |
|
17 | |||
|
18 | Q_LOGGING_CATEGORY(LOG_CatalogueEventsModel, "CatalogueEventsModel") | |||
|
19 | ||||
18 | const auto EVENT_ITEM_TYPE = 1; |
|
20 | const auto EVENT_ITEM_TYPE = 1; | |
19 | const auto EVENT_PRODUCT_ITEM_TYPE = 2; |
|
21 | const auto EVENT_PRODUCT_ITEM_TYPE = 2; | |
20 |
|
22 | |||
21 | struct CatalogueEventsModel::CatalogueEventsModelPrivate { |
|
23 | struct CatalogueEventsModel::CatalogueEventsModelPrivate { | |
22 | QVector<std::shared_ptr<DBEvent> > m_Events; |
|
24 | QVector<std::shared_ptr<DBEvent> > m_Events; | |
23 | std::unordered_map<DBEvent *, QVector<std::shared_ptr<DBEventProduct> > > m_EventProducts; |
|
25 | std::unordered_map<DBEvent *, QVector<std::shared_ptr<DBEventProduct> > > m_EventProducts; | |
|
26 | std::unordered_set<std::shared_ptr<DBEvent> > m_EventsWithChanges; | |||
24 |
|
27 | |||
25 | enum class Column { Name, TStart, TEnd, Tags, Product, NbColumn }; |
|
|||
26 | QStringList columnNames() |
|
28 | QStringList columnNames() | |
27 | { |
|
29 | { | |
28 |
return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), |
|
30 | return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), | |
|
31 | tr("Tags"), tr("Product"), tr("")}; | |||
|
32 | } | |||
|
33 | ||||
|
34 | QVariant sortData(int col, const std::shared_ptr<DBEvent> &event) const | |||
|
35 | { | |||
|
36 | if (col == (int)CatalogueEventsModel::Column::Validation) { | |||
|
37 | return m_EventsWithChanges.find(event) != m_EventsWithChanges.cend() ? true | |||
|
38 | : QVariant(); | |||
|
39 | } | |||
|
40 | ||||
|
41 | return eventData(col, event); | |||
29 | } |
|
42 | } | |
30 |
|
43 | |||
31 | QVariant eventData(int col, const std::shared_ptr<DBEvent> &event) const |
|
44 | QVariant eventData(int col, const std::shared_ptr<DBEvent> &event) const | |
32 | { |
|
45 | { | |
33 | switch (static_cast<Column>(col)) { |
|
46 | switch (static_cast<Column>(col)) { | |
34 | case Column::Name: |
|
47 | case CatalogueEventsModel::Column::Name: | |
35 | return event->getName(); |
|
48 | return event->getName(); | |
36 | case Column::TStart: |
|
49 | case CatalogueEventsModel::Column::TStart: | |
37 | return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTStart()) |
|
50 | return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTStart()) | |
38 | : QVariant{}; |
|
51 | : QVariant{}; | |
39 | case Column::TEnd: |
|
52 | case CatalogueEventsModel::Column::TEnd: | |
40 | return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTEnd()) |
|
53 | return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTEnd()) | |
41 | : QVariant{}; |
|
54 | : QVariant{}; | |
42 | case Column::Product: |
|
55 | case CatalogueEventsModel::Column::Product: | |
43 | return QString::number(nbEventProducts(event)) + " product(s)"; |
|
56 | return QString::number(nbEventProducts(event)) + " product(s)"; | |
44 | case Column::Tags: { |
|
57 | case CatalogueEventsModel::Column::Tags: { | |
45 | QString tagList; |
|
58 | QString tagList; | |
46 | auto tags = event->getTags(); |
|
59 | auto tags = event->getTags(); | |
47 | for (auto tag : tags) { |
|
60 | for (auto tag : tags) { | |
@@ -51,6 +64,8 struct CatalogueEventsModel::CatalogueEventsModelPrivate { | |||||
51 |
|
64 | |||
52 | return tagList; |
|
65 | return tagList; | |
53 | } |
|
66 | } | |
|
67 | case CatalogueEventsModel::Column::Validation: | |||
|
68 | return QVariant(); | |||
54 | default: |
|
69 | default: | |
55 | break; |
|
70 | break; | |
56 | } |
|
71 | } | |
@@ -80,17 +95,18 struct CatalogueEventsModel::CatalogueEventsModelPrivate { | |||||
80 | QVariant eventProductData(int col, const std::shared_ptr<DBEventProduct> &eventProduct) const |
|
95 | QVariant eventProductData(int col, const std::shared_ptr<DBEventProduct> &eventProduct) const | |
81 | { |
|
96 | { | |
82 | switch (static_cast<Column>(col)) { |
|
97 | switch (static_cast<Column>(col)) { | |
83 | case Column::Name: |
|
98 | case CatalogueEventsModel::Column::Name: | |
84 | return eventProduct->getProductId(); |
|
99 | return eventProduct->getProductId(); | |
85 | case Column::TStart: |
|
100 | case CatalogueEventsModel::Column::TStart: | |
86 | return DateUtils::dateTime(eventProduct->getTStart()); |
|
101 | return DateUtils::dateTime(eventProduct->getTStart()); | |
87 | case Column::TEnd: |
|
102 | case CatalogueEventsModel::Column::TEnd: | |
88 | return DateUtils::dateTime(eventProduct->getTEnd()); |
|
103 | return DateUtils::dateTime(eventProduct->getTEnd()); | |
89 | case Column::Product: |
|
104 | case CatalogueEventsModel::Column::Product: | |
90 | return eventProduct->getProductId(); |
|
105 | return eventProduct->getProductId(); | |
91 |
case Column::Tags: |
|
106 | case CatalogueEventsModel::Column::Tags: | |
92 | return QString(); |
|
107 | return QString(); | |
93 | } |
|
108 | case CatalogueEventsModel::Column::Validation: | |
|
109 | return QVariant(); | |||
94 | default: |
|
110 | default: | |
95 | break; |
|
111 | break; | |
96 | } |
|
112 | } | |
@@ -111,6 +127,7 void CatalogueEventsModel::setEvents(const QVector<std::shared_ptr<DBEvent> > &e | |||||
111 |
|
127 | |||
112 | impl->m_Events = events; |
|
128 | impl->m_Events = events; | |
113 | impl->m_EventProducts.clear(); |
|
129 | impl->m_EventProducts.clear(); | |
|
130 | impl->m_EventsWithChanges.clear(); | |||
114 | for (auto event : events) { |
|
131 | for (auto event : events) { | |
115 | impl->parseEventProduct(event); |
|
132 | impl->parseEventProduct(event); | |
116 | } |
|
133 | } | |
@@ -165,21 +182,58 void CatalogueEventsModel::removeEvent(const std::shared_ptr<DBEvent> &event) | |||||
165 | beginRemoveRows(QModelIndex(), index, index); |
|
182 | beginRemoveRows(QModelIndex(), index, index); | |
166 | impl->m_Events.removeAt(index); |
|
183 | impl->m_Events.removeAt(index); | |
167 | impl->m_EventProducts.erase(event.get()); |
|
184 | impl->m_EventProducts.erase(event.get()); | |
|
185 | impl->m_EventsWithChanges.erase(event); | |||
168 | endRemoveRows(); |
|
186 | endRemoveRows(); | |
169 | } |
|
187 | } | |
170 | } |
|
188 | } | |
171 |
|
189 | |||
|
190 | QVector<std::shared_ptr<DBEvent> > CatalogueEventsModel::events() const | |||
|
191 | { | |||
|
192 | return impl->m_Events; | |||
|
193 | } | |||
|
194 | ||||
172 | void CatalogueEventsModel::refreshEvent(const std::shared_ptr<DBEvent> &event) |
|
195 | void CatalogueEventsModel::refreshEvent(const std::shared_ptr<DBEvent> &event) | |
173 | { |
|
196 | { | |
174 |
auto |
|
197 | auto eventIndex = indexOf(event); | |
175 | if (i >= 0) { |
|
198 | if (eventIndex.isValid()) { | |
176 | auto eventIndex = index(i, 0); |
|
199 | ||
|
200 | // Refreshes the event line | |||
177 | auto colCount = columnCount(); |
|
201 | auto colCount = columnCount(); | |
178 |
emit dataChanged(eventIndex, index( |
|
202 | emit dataChanged(eventIndex, index(eventIndex.row(), colCount)); | |
179 |
|
203 | |||
|
204 | // Also refreshes its children event products | |||
180 | auto childCount = rowCount(eventIndex); |
|
205 | auto childCount = rowCount(eventIndex); | |
181 | emit dataChanged(index(0, 0, eventIndex), index(childCount, colCount, eventIndex)); |
|
206 | emit dataChanged(index(0, 0, eventIndex), index(childCount, colCount, eventIndex)); | |
182 | } |
|
207 | } | |
|
208 | else { | |||
|
209 | qCWarning(LOG_CatalogueEventsModel()) << "refreshEvent: event not found."; | |||
|
210 | } | |||
|
211 | } | |||
|
212 | ||||
|
213 | QModelIndex CatalogueEventsModel::indexOf(const std::shared_ptr<DBEvent> &event) const | |||
|
214 | { | |||
|
215 | auto row = impl->m_Events.indexOf(event); | |||
|
216 | if (row >= 0) { | |||
|
217 | return index(row, 0); | |||
|
218 | } | |||
|
219 | ||||
|
220 | return QModelIndex(); | |||
|
221 | } | |||
|
222 | ||||
|
223 | void CatalogueEventsModel::setEventHasChanges(const std::shared_ptr<DBEvent> &event, | |||
|
224 | bool hasChanges) | |||
|
225 | { | |||
|
226 | if (hasChanges) { | |||
|
227 | impl->m_EventsWithChanges.insert(event); | |||
|
228 | } | |||
|
229 | else { | |||
|
230 | impl->m_EventsWithChanges.erase(event); | |||
|
231 | } | |||
|
232 | } | |||
|
233 | ||||
|
234 | bool CatalogueEventsModel::eventsHasChanges(const std::shared_ptr<DBEvent> &event) const | |||
|
235 | { | |||
|
236 | return impl->m_EventsWithChanges.find(event) != impl->m_EventsWithChanges.cend(); | |||
183 | } |
|
237 | } | |
184 |
|
238 | |||
185 | QModelIndex CatalogueEventsModel::index(int row, int column, const QModelIndex &parent) const |
|
239 | QModelIndex CatalogueEventsModel::index(int row, int column, const QModelIndex &parent) const | |
@@ -255,7 +309,7 int CatalogueEventsModel::rowCount(const QModelIndex &parent) const | |||||
255 |
|
309 | |||
256 | int CatalogueEventsModel::columnCount(const QModelIndex &parent) const |
|
310 | int CatalogueEventsModel::columnCount(const QModelIndex &parent) const | |
257 | { |
|
311 | { | |
258 |
return static_cast<int>(CatalogueEventsModel |
|
312 | return static_cast<int>(CatalogueEventsModel::Column::NbColumn); | |
259 | } |
|
313 | } | |
260 |
|
314 | |||
261 | Qt::ItemFlags CatalogueEventsModel::flags(const QModelIndex &index) const |
|
315 | Qt::ItemFlags CatalogueEventsModel::flags(const QModelIndex &index) const | |
@@ -302,8 +356,8 void CatalogueEventsModel::sort(int column, Qt::SortOrder order) | |||||
302 | { |
|
356 | { | |
303 | std::sort(impl->m_Events.begin(), impl->m_Events.end(), |
|
357 | std::sort(impl->m_Events.begin(), impl->m_Events.end(), | |
304 | [this, column, order](auto e1, auto e2) { |
|
358 | [this, column, order](auto e1, auto e2) { | |
305 |
auto data1 = impl-> |
|
359 | auto data1 = impl->sortData(column, e1); | |
306 |
auto data2 = impl-> |
|
360 | auto data2 = impl->sortData(column, e2); | |
307 |
|
361 | |||
308 | auto result = data1.toString() < data2.toString(); |
|
362 | auto result = data1.toString() < data2.toString(); | |
309 |
|
363 | |||
@@ -311,6 +365,7 void CatalogueEventsModel::sort(int column, Qt::SortOrder order) | |||||
311 | }); |
|
365 | }); | |
312 |
|
366 | |||
313 | emit dataChanged(QModelIndex(), QModelIndex()); |
|
367 | emit dataChanged(QModelIndex(), QModelIndex()); | |
|
368 | emit modelSorted(); | |||
314 | } |
|
369 | } | |
315 |
|
370 | |||
316 | Qt::DropActions CatalogueEventsModel::supportedDragActions() const |
|
371 | Qt::DropActions CatalogueEventsModel::supportedDragActions() const |
@@ -3,6 +3,7 | |||||
3 |
|
3 | |||
4 | #include <Catalogue/CatalogueController.h> |
|
4 | #include <Catalogue/CatalogueController.h> | |
5 | #include <Catalogue/CatalogueEventsModel.h> |
|
5 | #include <Catalogue/CatalogueEventsModel.h> | |
|
6 | #include <Catalogue/CatalogueExplorerHelper.h> | |||
6 | #include <CatalogueDao.h> |
|
7 | #include <CatalogueDao.h> | |
7 | #include <DBCatalogue.h> |
|
8 | #include <DBCatalogue.h> | |
8 | #include <SqpApplication.h> |
|
9 | #include <SqpApplication.h> | |
@@ -16,8 +17,8 | |||||
16 |
|
17 | |||
17 | Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget") |
|
18 | Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget") | |
18 |
|
19 | |||
19 | /// Format of the dates appearing in the label of a cursor |
|
20 | /// Fixed size of the validation column | |
20 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); |
|
21 | const auto VALIDATION_COLUMN_SIZE = 35; | |
21 |
|
22 | |||
22 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
23 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |
23 |
|
24 | |||
@@ -277,8 +278,20 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |||||
277 | }); |
|
278 | }); | |
278 |
|
279 | |||
279 | ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); |
|
280 | ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
280 |
ui->treeView->header()->setSectionResizeMode( |
|
281 | ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Name, | |
|
282 | QHeaderView::Stretch); | |||
|
283 | ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Validation, | |||
|
284 | QHeaderView::Fixed); | |||
|
285 | ui->treeView->header()->resizeSection((int)CatalogueEventsModel::Column::Validation, | |||
|
286 | VALIDATION_COLUMN_SIZE); | |||
281 | ui->treeView->header()->setSortIndicatorShown(true); |
|
287 | ui->treeView->header()->setSortIndicatorShown(true); | |
|
288 | ||||
|
289 | connect(impl->m_Model, &CatalogueEventsModel::modelSorted, [this]() { | |||
|
290 | auto allEvents = impl->m_Model->events(); | |||
|
291 | for (auto event : allEvents) { | |||
|
292 | setEventChanges(event, impl->m_Model->eventsHasChanges(event)); | |||
|
293 | } | |||
|
294 | }); | |||
282 | } |
|
295 | } | |
283 |
|
296 | |||
284 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
297 | CatalogueEventsWidget::~CatalogueEventsWidget() | |
@@ -294,6 +307,25 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualiz | |||||
294 | void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges) |
|
307 | void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges) | |
295 | { |
|
308 | { | |
296 | impl->m_Model->refreshEvent(event); |
|
309 | impl->m_Model->refreshEvent(event); | |
|
310 | ||||
|
311 | auto eventIndex = impl->m_Model->indexOf(event); | |||
|
312 | auto validationIndex | |||
|
313 | = eventIndex.sibling(eventIndex.row(), (int)CatalogueEventsModel::Column::Validation); | |||
|
314 | ||||
|
315 | if (hasChanges) { | |||
|
316 | if (ui->treeView->indexWidget(validationIndex) == nullptr) { | |||
|
317 | auto widget = CatalogueExplorerHelper::buildValidationWidget( | |||
|
318 | ui->treeView, [this, event]() { setEventChanges(event, false); }, | |||
|
319 | [this, event]() { setEventChanges(event, false); }); | |||
|
320 | ui->treeView->setIndexWidget(validationIndex, widget); | |||
|
321 | } | |||
|
322 | } | |||
|
323 | else { | |||
|
324 | // Note: the widget is destroyed | |||
|
325 | ui->treeView->setIndexWidget(validationIndex, nullptr); | |||
|
326 | } | |||
|
327 | ||||
|
328 | impl->m_Model->setEventHasChanges(event, hasChanges); | |||
297 | } |
|
329 | } | |
298 |
|
330 | |||
299 | void CatalogueEventsWidget::populateWithCatalogues( |
|
331 | void CatalogueEventsWidget::populateWithCatalogues( |
@@ -1,12 +1,9 | |||||
1 | #include "Catalogue/CatalogueTreeWidgetItem.h" |
|
1 | #include "Catalogue/CatalogueTreeWidgetItem.h" | |
|
2 | #include <Catalogue/CatalogueExplorerHelper.h> | |||
2 |
|
3 | |||
3 | #include <memory> |
|
4 | #include <memory> | |
4 |
|
5 | |||
5 | #include <DBCatalogue.h> |
|
6 | #include <DBCatalogue.h> | |
6 | #include <QBoxLayout> |
|
|||
7 | #include <QToolButton> |
|
|||
8 |
|
||||
9 | const auto VALIDATION_BUTTON_ICON_SIZE = 12; |
|
|||
10 |
|
7 | |||
11 | /// Column in the tree widget where the apply and cancel buttons must appear |
|
8 | /// Column in the tree widget where the apply and cancel buttons must appear | |
12 | const auto APPLY_CANCEL_BUTTONS_COLUMN = 1; |
|
9 | const auto APPLY_CANCEL_BUTTONS_COLUMN = 1; | |
@@ -66,29 +63,11 std::shared_ptr<DBCatalogue> CatalogueTreeWidgetItem::catalogue() const | |||||
66 | void CatalogueTreeWidgetItem::setHasChanges(bool value) |
|
63 | void CatalogueTreeWidgetItem::setHasChanges(bool value) | |
67 | { |
|
64 | { | |
68 | if (value) { |
|
65 | if (value) { | |
69 | if (treeWidget()->itemWidget(this, APPLY_CANCEL_BUTTONS_COLUMN) == nullptr) { |
|
66 | if (!hasChanges()) { | |
70 | auto widet = new QWidget{treeWidget()}; |
|
67 | auto widget = CatalogueExplorerHelper::buildValidationWidget( | |
71 |
|
68 | treeWidget(), [this]() { setHasChanges(false); }, | ||
72 | auto layout = new QHBoxLayout{widet}; |
|
69 | [this]() { setHasChanges(false); }); | |
73 | layout->setContentsMargins(0, 0, 0, 0); |
|
70 | treeWidget()->setItemWidget(this, APPLY_CANCEL_BUTTONS_COLUMN, widget); | |
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 | } |
|
71 | } | |
93 | } |
|
72 | } | |
94 | else { |
|
73 | else { | |
@@ -97,6 +76,11 void CatalogueTreeWidgetItem::setHasChanges(bool value) | |||||
97 | } |
|
76 | } | |
98 | } |
|
77 | } | |
99 |
|
78 | |||
|
79 | bool CatalogueTreeWidgetItem::hasChanges() | |||
|
80 | { | |||
|
81 | return treeWidget()->itemWidget(this, APPLY_CANCEL_BUTTONS_COLUMN) != nullptr; | |||
|
82 | } | |||
|
83 | ||||
100 | void CatalogueTreeWidgetItem::refresh() |
|
84 | void CatalogueTreeWidgetItem::refresh() | |
101 | { |
|
85 | { | |
102 | emitDataChanged(); |
|
86 | emitDataChanged(); |
General Comments 4
Pull request updated. Auto status change to "Under Review"
Changed commits: * 1 added * 0 removed Changed files: * M app/src/Main.cpp * M core/include/Catalogue/CatalogueController.h * M core/src/Catalogue/CatalogueController.cpp * M core/src/Plugin/PluginManager.cpp * M core/tests/Data/TestDataSeriesUtils.cpp * M gui/include/Catalogue/CatalogueEventsModel.h * M gui/include/Catalogue/CatalogueEventsWidget.h * M gui/include/Catalogue/CatalogueTreeWidgetItem.h * M gui/meson.build * M gui/src/Catalogue/CatalogueEventsModel.cpp * M gui/src/Catalogue/CatalogueEventsWidget.cpp * M gui/src/Catalogue/CatalogueExplorer.cpp * M gui/src/Catalogue/CatalogueSideBarWidget.cpp * M gui/src/Catalogue/CatalogueTreeWidgetItem.cpp * M gui/src/Visualization/VisualizationActionManager.cpp * M gui/src/Visualization/VisualizationGraphWidget.cpp * M gui/src/Visualization/VisualizationSelectionZoneItem.cpp * M plugins/amda/tests/TestAmdaResultParser.cpp * R cmake/FindCatalogueAPI.cmake * R core/include/Common/MimeTypesDef.h * R core/include/Data/DataSeriesUtils.h * R core/include/Data/OptionalAxis.h * R core/include/Data/SpectrogramSeries.h * R core/include/Data/Unit.h * R core/include/DataSource/DataSourceItemMergeHelper.h * R core/include/Variable/VariableCacheStrategyFactory.h * R core/include/Variable/VariableSingleThresholdCacheStrategy.h * R core/src/Common/MimeTypesDef.cpp * R core/src/Data/DataSeriesUtils.cpp * R core/src/Data/OptionalAxis.cpp * R core/src/Data/SpectrogramSeries.cpp * R core/src/DataSource/DataSourceItemMergeHelper.cpp * R core/tests-resources/TestDataSeriesUtils/TestThresholds.txt * R core/tests/Data/DataSeriesBuilders.cpp * R core/tests/Data/DataSeriesBuilders.h * R core/tests/Data/DataSeriesTestsUtils.cpp * R core/tests/Data/DataSeriesTestsUtils.h * R core/tests/Data/TestOptionalAxis.cpp * R core/tests/Data/TestScalarSeries.cpp * R core/tests/Data/TestSpectrogramSeries.cpp * R core/tests/Data/TestVectorSeries.cpp * R core/tests/DataSource/DataSourceItemBuilder.cpp * R core/tests/DataSource/DataSourceItemBuilder.h * R core/tests/DataSource/TestDataSourceItem.cpp * R core/tests/Variable/TestVariableSync.cpp * R extern/CatalogueAPI.cmake * R gui/include/Actions/ActionsGuiController.h * R gui/include/Actions/SelectionZoneAction.h * R gui/include/Catalogue/CatalogueExplorer.h * R gui/include/Catalogue/CatalogueInspectorWidget.h * R gui/include/Catalogue/CatalogueSideBarWidget.h * R gui/include/Common/VisualizationDef.h * R gui/include/DataSource/DataSourceTreeWidget.h * R gui/include/DragAndDrop/DragDropGuiController.h * R gui/include/DragAndDrop/DragDropScroller.h * R gui/include/DragAndDrop/DragDropTabSwitcher.h * R gui/include/Variable/VariableInspectorTableView.h * R gui/include/Visualization/AxisRenderingUtils.h * R gui/include/Visualization/ColorScaleEditor.h * R gui/include/Visualization/MacScrollBarStyle.h * R gui/include/Visualization/PlottablesRenderingUtils.h * R gui/include/Visualization/QCPColorMapIterator.h * R gui/include/Visualization/SqpColorScale.h * R gui/include/Visualization/VisualizationActionManager.h * R gui/include/Visualization/VisualizationCursorItem.h * R gui/include/Visualization/VisualizationDragDropContainer.h * R gui/include/Visualization/VisualizationDragWidget.h * R gui/include/Visualization/VisualizationMultiZoneSelectionDialog.h * R gui/include/Visualization/VisualizationSelectionZoneItem.h * R gui/include/Visualization/VisualizationSelectionZoneManager.h * R gui/resources/icones/add.png * R gui/resources/icones/allEvents.png * R gui/resources/icones/catalogue.png * R gui/resources/icones/chart.png * R gui/resources/icones/cursor.png * R gui/resources/icones/database.png * R gui/resources/icones/discard.png * R gui/resources/icones/drag.png * R gui/resources/icones/pointer.png * R gui/resources/icones/rectangle.png * R gui/resources/icones/remove.png * R gui/resources/icones/save.png * R gui/resources/icones/time.png * R gui/resources/icones/trash.png * R gui/resources/icones/zoom.png * R gui/src/Actions/ActionsGuiController.cpp * R gui/src/Actions/SelectionZoneAction.cpp * R gui/src/Catalogue/CatalogueInspectorWidget.cpp * R gui/src/Common/VisualizationDef.cpp * R gui/src/DataSource/DataSourceTreeWidget.cpp * R gui/src/DragAndDrop/DragDropGuiController.cpp * R gui/src/DragAndDrop/DragDropScroller.cpp * R gui/src/DragAndDrop/DragDropTabSwitcher.cpp * R gui/src/Variable/VariableInspectorTableView.cpp * R gui/src/Visualization/AxisRenderingUtils.cpp * R gui/src/Visualization/ColorScaleEditor.cpp * R gui/src/Visualization/MacScrollBarStyle.cpp * R gui/src/Visualization/PlottablesRenderingUtils.cpp * R gui/src/Visualization/QCPColorMapIterator.cpp * R gui/src/Visualization/SqpColorScale.cpp * R gui/src/Visualization/VisualizationCursorItem.cpp * R gui/src/Visualization/VisualizationDragDropContainer.cpp * R gui/src/Visualization/VisualizationDragWidget.cpp * R gui/src/Visualization/VisualizationMultiZoneSelectionDialog.cpp * R gui/src/Visualization/VisualizationSelectionZoneManager.cpp * R gui/ui/Catalogue/CatalogueEventsWidget.ui * R gui/ui/Catalogue/CatalogueExplorer.ui * R gui/ui/Catalogue/CatalogueInspectorWidget.ui * R gui/ui/Catalogue/CatalogueSideBarWidget.ui * R gui/ui/Visualization/ColorScaleEditor.ui * R gui/ui/Visualization/VisualizationMultiZoneSelectionDialog.ui * R plugins/amda/include/AmdaResultParserDefs.h * R plugins/amda/include/AmdaResultParserHelper.h * R plugins/amda/include/AmdaServer.h * R plugins/amda/resources/samples/AmdaSampleV3.json * R plugins/amda/src/AmdaResultParserDefs.cpp * R plugins/amda/src/AmdaResultParserHelper.cpp * R plugins/amda/src/AmdaServer.cpp * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/FileNotFound.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/NaNValue.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/NaNX.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/NoUnit.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/TooManyValues.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/ValidScalar1.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/ValidVector1.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/WrongDate.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/WrongUnit.txt * R plugins/amda/tests-resources/TestAmdaResultParser/amdaV2/WrongValue.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/InvalidSpectrogramWrongBands.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogram1.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogram2.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogram3.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogramDataHoles.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogramDataHoles2.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogramFillValues.txt * R plugins/amda/tests-resources/TestAmdaResultParser/spectro/ValidSpectrogramNaNValues.txt * R plugins/amda/vera-exclusions/exclusions.txt * R plugins/mockplugin/include/MockDefs.h * R plugins/mockplugin/src/MockDefs.cpp * R subprojects/CatalogueAPI.wrap * R subprojects/QxOrm.wrap * R .gitignore * R CMakeLists.txt * R app/src/MainWindow.cpp * R app/ui/MainWindow.ui * R cmake/sciqlop_applications.cmake * R cmake/sciqlop_package_qt.cmake * R core/CMakeLists.txt * R core/cmake/Findsciqlop-core.cmake * R core/include/Common/SortUtils.h * R core/include/Data/ArrayData.h * R core/include/Data/DataSeries.h * R core/include/Data/DataSeriesIterator.h * R core/include/Data/IDataSeries.h * R core/include/Data/VariableRequest.h * R core/include/DataSource/DataSourceController.h * R core/include/DataSource/DataSourceItem.h * R core/include/DataSource/DataSourceItemAction.h * R core/include/Plugin/PluginManager.h * R core/include/Time/TimeController.h * R core/include/Variable/Variable.h * R core/include/Variable/VariableCacheStrategy.h * R core/include/Variable/VariableController.h * R core/include/Variable/VariableModel.h * R core/meson.build * R core/src/Data/DataSeriesIterator.cpp * R core/src/Data/VectorSeries.cpp * R core/src/DataSource/DataSourceController.cpp * R core/src/DataSource/DataSourceItem.cpp * R core/src/DataSource/DataSourceItemAction.cpp * R core/src/Time/TimeController.cpp * R core/src/Variable/Variable.cpp * R core/src/Variable/VariableAcquisitionWorker.cpp * R core/src/Variable/VariableController.cpp * R core/src/Variable/VariableModel.cpp * R core/tests/Data/TestTwoDimArrayData.cpp * R core/tests/Variable/TestVariable.cpp * R core/tests/meson.build * R gui/CMakeLists.txt * R gui/cmake/Findsciqlop-gui.cmake * R gui/include/DataSource/DataSourceWidget.h * R gui/include/SqpApplication.h * R gui/include/TimeWidget/TimeWidget.h * R gui/include/Visualization/VisualizationGraphHelper.h * R gui/include/Visualization/VisualizationGraphRenderingDelegate.h * R gui/include/Visualization/VisualizationGraphWidget.h * R gui/include/Visualization/VisualizationTabWidget.h * R gui/include/Visualization/VisualizationWidget.h * R gui/include/Visualization/VisualizationZoneWidget.h * R gui/resources/sqpguiresources.qrc * R gui/src/DataSource/DataSourceTreeWidgetItem.cpp * R gui/src/DataSource/DataSourceWidget.cpp * R gui/src/SqpApplication.cpp * R gui/src/TimeWidget/TimeWidget.cpp * R gui/src/Variable/VariableInspectorWidget.cpp * R gui/src/Visualization/VisualizationGraphHelper.cpp * R gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp * R gui/src/Visualization/VisualizationTabWidget.cpp * R gui/src/Visualization/VisualizationWidget.cpp * R gui/src/Visualization/VisualizationZoneWidget.cpp * R gui/src/Visualization/operations/GenerateVariableMenuOperation.cpp * R gui/src/Visualization/operations/RescaleAxeOperation.cpp * R gui/ui/DataSource/DataSourceWidget.ui * R gui/ui/TimeWidget/TimeWidget.ui * R gui/ui/Variable/VariableInspectorWidget.ui * R gui/ui/Visualization/VisualizationTabWidget.ui * R gui/ui/Visualization/VisualizationZoneWidget.ui * R gui/vera-exclusions/exclusions.txt * R meson.build * R plugins/amda/CMakeLists.txt * R plugins/amda/cmake/Findsciqlop-amda.cmake * R plugins/amda/include/AmdaDefs.h * R plugins/amda/include/AmdaPlugin.h * R plugins/amda/include/AmdaProvider.h * R plugins/amda/include/AmdaResultParser.h * R plugins/amda/meson.build * R plugins/amda/resources/amdaresources.qrc * R plugins/amda/src/AmdaDefs.cpp * R plugins/amda/src/AmdaPlugin.cpp * R plugins/amda/src/AmdaProvider.cpp * R plugins/amda/src/AmdaResultParser.cpp * R plugins/amda/tests/TestAmdaAcquisition.cpp * R plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake * R plugins/mockplugin/include/CosinusProvider.h * R plugins/mockplugin/meson.build * R plugins/mockplugin/src/CosinusProvider.cpp * R plugins/mockplugin/src/MockPlugin.cpp * R plugins/mockplugin/tests/TestCosinusAcquisition.cpp * R core/src/Variable/VariableCacheStrategy.cpp * R core/tests/Data/TestDataSeries.cpp
Status change > Approved
You need to be logged in to leave comments.
Login now