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