@@ -0,0 +1,5 | |||
|
1 | [wrap-git] | |
|
2 | directory = cpp_utils | |
|
3 | url = https://github.com/jeandet/cpp_utils.git | |
|
4 | revision = master | |
|
5 |
@@ -1,1 +1,1 | |||
|
1 | Subproject commit 63c6ae3895dda76aabbc560a636a1f3d8d4d95bf | |
|
1 | Subproject commit 29637e951955d1747d325407e2d833646c98f1c2 |
@@ -1,7 +1,7 | |||
|
1 | 1 | #include "Catalogue2/eventeditor.h" |
|
2 | 2 | #include "ui_eventeditor.h" |
|
3 | 3 | #include <Common/DateUtils.h> |
|
4 | #include <Common/StringUtils.h> | |
|
4 | #include <containers/algorithms.hpp> | |
|
5 | 5 | |
|
6 | 6 | EventEditor::EventEditor(QWidget* parent) : QWidget(parent), ui(new Ui::EventEditor) |
|
7 | 7 | { |
@@ -38,15 +38,15 void EventEditor::_setEventName(const CatalogueController::Event_ptr& event, mod | |||
|
38 | 38 | |
|
39 | 39 | void EventEditor::_setTags(const CatalogueController::Event_ptr& event, mode is_editable) |
|
40 | 40 | { |
|
41 |
this->ui->Tags->setText(String |
|
|
41 | this->ui->Tags->setText(QString::fromStdString(cpp_utils::containers::join(event->tags, ','))); | |
|
42 | 42 | this->ui->Tags->setEnabled(bool(is_editable)); |
|
43 | 43 | } |
|
44 | 44 | |
|
45 | 45 | void EventEditor::_setProducts(const CatalogueController::Event_ptr& event, mode is_editable) |
|
46 | 46 | { |
|
47 | 47 | QStringList products; |
|
48 | this->ui->Products->setText(StringUtils::join(event->products, ", ", | |
|
49 | [](const auto& product) { return QString::fromStdString(product.name); })); | |
|
48 | std::transform(std::cbegin(event->products),std::cend(event->products),std::begin(products),[](const auto& product) { return QString::fromStdString(product.name); }); | |
|
49 | this->ui->Products->setText(cpp_utils::containers::join(products, QString(", "))); | |
|
50 | 50 | this->ui->Products->setEnabled(bool(is_editable)); |
|
51 | 51 | } |
|
52 | 52 |
@@ -15,8 +15,9 | |||
|
15 | 15 | along with SciQLop. If not, see <https://www.gnu.org/licenses/>. |
|
16 | 16 | */ |
|
17 | 17 | #include "Catalogue2/eventsmodel.h" |
|
18 | #include <Common/containers.h> | |
|
19 | 18 | #include <SqpApplication.h> |
|
19 | #include <containers/algorithms.hpp> | |
|
20 | ||
|
20 | 21 | |
|
21 | 22 | EventsModel::EventsModel(QObject* parent) : QAbstractItemModel(parent) {} |
|
22 | 23 | |
@@ -63,7 +64,7 QModelIndex EventsModel::parent(const QModelIndex& index) const | |||
|
63 | 64 | auto item = to_item(index); |
|
64 | 65 | if (item->type == ItemType::Product) |
|
65 | 66 | { |
|
66 |
auto repoIndex = |
|
|
67 | auto repoIndex = cpp_utils::containers::index_of(_items, item->parent); | |
|
67 | 68 | return createIndex(repoIndex, 0, item->parent); |
|
68 | 69 | } |
|
69 | 70 | return QModelIndex(); |
@@ -15,7 +15,7 | |||
|
15 | 15 | along with SciQLop. If not, see <https://www.gnu.org/licenses/>. |
|
16 | 16 | */ |
|
17 | 17 | #include <Catalogue2/repositoriesmodel.h> |
|
18 |
#include < |
|
|
18 | #include <containers/algorithms.hpp> | |
|
19 | 19 | #include <SqpApplication.h> |
|
20 | 20 | |
|
21 | 21 | |
@@ -83,7 +83,7 QModelIndex RepositoriesModel::parent(const QModelIndex& index) const | |||
|
83 | 83 | auto item = to_item(index); |
|
84 | 84 | if (item->type == ItemType::Catalogue) |
|
85 | 85 | { |
|
86 |
auto repoIndex = |
|
|
86 | auto repoIndex = cpp_utils::containers::index_of(_items, item->parent); | |
|
87 | 87 | return createIndex(repoIndex, 0, item->parent); |
|
88 | 88 | } |
|
89 | 89 | return QModelIndex(); |
@@ -6,7 +6,7 | |||
|
6 | 6 | #include <Data/TimeSeriesUtils.h> |
|
7 | 7 | #include <Data/VectorTimeSerie.h> |
|
8 | 8 | |
|
9 |
#include < |
|
|
9 | #include <cpp_utils.hpp> | |
|
10 | 10 | #include <Variable/Variable2.h> |
|
11 | 11 | #include <algorithm> |
|
12 | 12 | #include <cmath> |
@@ -14,7 +14,8 | |||
|
14 | 14 | #include <Actions/ActionsGuiController.h> |
|
15 | 15 | #include <Actions/FilteringAction.h> |
|
16 | 16 | #include <Common/MimeTypesDef.h> |
|
17 | #include <Common/containers.h> | |
|
17 | #include <cpp_utils_qt/cpp_utils_qt.hpp> | |
|
18 | #include <containers/algorithms.hpp> | |
|
18 | 19 | #include <Data/DateTimeRangeHelper.h> |
|
19 | 20 | #include <DragAndDrop/DragDropGuiController.h> |
|
20 | 21 | #include <Settings/SqpSettingsDefs.h> |
@@ -1002,7 +1003,7 void VisualizationGraphWidget::mousePressEvent(QMouseEvent* event) | |||
|
1002 | 1003 | auto alreadySelectedZones |
|
1003 | 1004 | = parentVisualizationWidget()->selectionZoneManager().selectedItems(); |
|
1004 | 1005 | selectedZone->setAssociatedEditedZones(alreadySelectedZones); |
|
1005 |
if ( |
|
|
1006 | if (cpp_utils::containers::contains(alreadySelectedZones, selectedZone)) | |
|
1006 | 1007 | { |
|
1007 | 1008 | alreadySelectedZones.removeOne(selectedZone); |
|
1008 | 1009 | } |
@@ -1,7 +1,7 | |||
|
1 | 1 | #ifndef GUITESTUTILS_H |
|
2 | 2 | #define GUITESTUTILS_H |
|
3 | 3 | |
|
4 | #include <Common/cpp_utils.h> | |
|
4 | #include <types/detectors.hpp> | |
|
5 | 5 | #include <QCoreApplication> |
|
6 | 6 | #include <QCursor> |
|
7 | 7 | #include <QDesktopWidget> |
@@ -19,7 +19,7 QPoint center(T* widget) | |||
|
19 | 19 | return QPoint { widget->width() / 2, widget->height() / 2 }; |
|
20 | 20 | } |
|
21 | 21 | |
|
22 | HAS_METHOD(viewport) | |
|
22 | HAS_METHOD(has_viewport, viewport) | |
|
23 | 23 | |
|
24 | 24 | template <typename T> |
|
25 | 25 | static inline constexpr bool is_QWidgetOrDerived = std::is_base_of<QWidget, T>::value; |
@@ -27,14 +27,14 static inline constexpr bool is_QWidgetOrDerived = std::is_base_of<QWidget, T>:: | |||
|
27 | 27 | template <typename T> |
|
28 | 28 | using viewport_type = decltype(std::declval<T>().viewport()); |
|
29 | 29 | |
|
30 | HAS_METHOD(topLevelItem) | |
|
30 | HAS_METHOD(has_topLevelItem, topLevelItem) | |
|
31 | 31 | |
|
32 | 32 | template <typename T> |
|
33 | 33 | void mouseMove(T* widget, QPoint pos, Qt::MouseButton mouseModifier) |
|
34 | 34 | { |
|
35 | 35 | QCursor::setPos(widget->mapToGlobal(pos)); |
|
36 | 36 | QMouseEvent event(QEvent::MouseMove, pos, Qt::NoButton, mouseModifier, Qt::NoModifier); |
|
37 | if constexpr (has_viewport<T>) | |
|
37 | if constexpr (has_viewport_v<T>) | |
|
38 | 38 | { |
|
39 | 39 | if constexpr (is_QWidgetOrDerived<viewport_type<T>>) |
|
40 | 40 | { |
@@ -56,7 +56,7 void mouseMove(T* widget, QPoint pos, Qt::MouseButton mouseModifier) | |||
|
56 | 56 | template <typename T> |
|
57 | 57 | void setMouseTracking(T* widget) |
|
58 | 58 | { |
|
59 | if constexpr (has_viewport<T>) | |
|
59 | if constexpr (has_viewport_v<T>) | |
|
60 | 60 | { |
|
61 | 61 | if constexpr (is_QWidgetOrDerived<viewport_type<T>>) |
|
62 | 62 | { |
@@ -76,7 +76,7 void setMouseTracking(T* widget) | |||
|
76 | 76 | template <typename T, typename T2> |
|
77 | 77 | auto getItem(T* widget, T2 itemIndex) |
|
78 | 78 | { |
|
79 | if constexpr (has_topLevelItem<T>) | |
|
79 | if constexpr (has_topLevelItem_v<T>) | |
|
80 | 80 | { |
|
81 | 81 | return widget->topLevelItem(itemIndex); |
|
82 | 82 | } |
@@ -105,7 +105,7 template <typename T1, typename T2, typename T3, typename T4 = void> | |||
|
105 | 105 | void dragnDropItem(T1* sourceWidget, T2* destWidget, T3* item, T4* destItem = Q_NULLPTR) |
|
106 | 106 | { |
|
107 | 107 | auto itemCenterPos = sourceWidget->visualItemRect(item).center(); |
|
108 | if constexpr (has_viewport<T1>) | |
|
108 | if constexpr (has_viewport_v<T1>) | |
|
109 | 109 | { |
|
110 | 110 | QTest::mousePress(sourceWidget->viewport(), Qt::LeftButton, Qt::NoModifier, itemCenterPos); |
|
111 | 111 | } |
@@ -123,7 +123,7 void dragnDropItem(T1* sourceWidget, T2* destWidget, T3* item, T4* destItem = Q_ | |||
|
123 | 123 | auto destItemCenterPos = destWidget->visualItemRect(destItem).center(); |
|
124 | 124 | QTest::mouseRelease(destWidget, Qt::LeftButton, Qt::NoModifier, destItemCenterPos); |
|
125 | 125 | } |
|
126 | else if constexpr (has_viewport<T2>) | |
|
126 | else if constexpr (has_viewport_v<T2>) | |
|
127 | 127 | { |
|
128 | 128 | QTest::mouseRelease(destWidget->viewport(), Qt::LeftButton); |
|
129 | 129 | } |
General Comments 0
You need to be logged in to leave comments.
Login now