From 8539a975891cfb7f0b02cad905b82c4e95d9220a 2019-09-11 11:43:15 From: Alexis Jeandet Date: 2019-09-11 11:43:15 Subject: [PATCH] Switched to cpp_utils package Signed-off-by: Alexis Jeandet --- diff --git a/core b/core index 63c6ae3..29637e9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 63c6ae3895dda76aabbc560a636a1f3d8d4d95bf +Subproject commit 29637e951955d1747d325407e2d833646c98f1c2 diff --git a/gui/src/Catalogue2/eventeditor.cpp b/gui/src/Catalogue2/eventeditor.cpp index 24dae56..44b1102 100644 --- a/gui/src/Catalogue2/eventeditor.cpp +++ b/gui/src/Catalogue2/eventeditor.cpp @@ -1,7 +1,7 @@ #include "Catalogue2/eventeditor.h" #include "ui_eventeditor.h" #include -#include +#include EventEditor::EventEditor(QWidget* parent) : QWidget(parent), ui(new Ui::EventEditor) { @@ -38,15 +38,15 @@ void EventEditor::_setEventName(const CatalogueController::Event_ptr& event, mod void EventEditor::_setTags(const CatalogueController::Event_ptr& event, mode is_editable) { - this->ui->Tags->setText(StringUtils::join(event->tags, ", ")); + this->ui->Tags->setText(QString::fromStdString(cpp_utils::containers::join(event->tags, ','))); this->ui->Tags->setEnabled(bool(is_editable)); } void EventEditor::_setProducts(const CatalogueController::Event_ptr& event, mode is_editable) { QStringList products; - this->ui->Products->setText(StringUtils::join(event->products, ", ", - [](const auto& product) { return QString::fromStdString(product.name); })); + std::transform(std::cbegin(event->products),std::cend(event->products),std::begin(products),[](const auto& product) { return QString::fromStdString(product.name); }); + this->ui->Products->setText(cpp_utils::containers::join(products, QString(", "))); this->ui->Products->setEnabled(bool(is_editable)); } diff --git a/gui/src/Catalogue2/eventsmodel.cpp b/gui/src/Catalogue2/eventsmodel.cpp index 968a7cd..2fb3d15 100644 --- a/gui/src/Catalogue2/eventsmodel.cpp +++ b/gui/src/Catalogue2/eventsmodel.cpp @@ -15,8 +15,9 @@ along with SciQLop. If not, see . */ #include "Catalogue2/eventsmodel.h" -#include #include +#include + EventsModel::EventsModel(QObject* parent) : QAbstractItemModel(parent) {} @@ -63,7 +64,7 @@ QModelIndex EventsModel::parent(const QModelIndex& index) const auto item = to_item(index); if (item->type == ItemType::Product) { - auto repoIndex = SciQLop::containers::index_of(_items, item->parent); + auto repoIndex = cpp_utils::containers::index_of(_items, item->parent); return createIndex(repoIndex, 0, item->parent); } return QModelIndex(); diff --git a/gui/src/Catalogue2/repositoriesmodel.cpp b/gui/src/Catalogue2/repositoriesmodel.cpp index ef6bed5..cdbad06 100644 --- a/gui/src/Catalogue2/repositoriesmodel.cpp +++ b/gui/src/Catalogue2/repositoriesmodel.cpp @@ -15,7 +15,7 @@ along with SciQLop. If not, see . */ #include -#include +#include #include @@ -83,7 +83,7 @@ QModelIndex RepositoriesModel::parent(const QModelIndex& index) const auto item = to_item(index); if (item->type == ItemType::Catalogue) { - auto repoIndex = SciQLop::containers::index_of(_items, item->parent); + auto repoIndex = cpp_utils::containers::index_of(_items, item->parent); return createIndex(repoIndex, 0, item->parent); } return QModelIndex(); diff --git a/gui/src/Visualization/VisualizationGraphHelper.cpp b/gui/src/Visualization/VisualizationGraphHelper.cpp index 55dd14a..fecf076 100644 --- a/gui/src/Visualization/VisualizationGraphHelper.cpp +++ b/gui/src/Visualization/VisualizationGraphHelper.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index fc081a5..05ef611 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -1002,7 +1003,7 @@ void VisualizationGraphWidget::mousePressEvent(QMouseEvent* event) auto alreadySelectedZones = parentVisualizationWidget()->selectionZoneManager().selectedItems(); selectedZone->setAssociatedEditedZones(alreadySelectedZones); - if (SciQLop::containers::contains(alreadySelectedZones, selectedZone)) + if (cpp_utils::containers::contains(alreadySelectedZones, selectedZone)) { alreadySelectedZones.removeOne(selectedZone); } diff --git a/gui/tests/GUITestUtils/GUITestUtils.h b/gui/tests/GUITestUtils/GUITestUtils.h index e26018d..581e616 100644 --- a/gui/tests/GUITestUtils/GUITestUtils.h +++ b/gui/tests/GUITestUtils/GUITestUtils.h @@ -1,7 +1,7 @@ #ifndef GUITESTUTILS_H #define GUITESTUTILS_H -#include +#include #include #include #include @@ -19,7 +19,7 @@ QPoint center(T* widget) return QPoint { widget->width() / 2, widget->height() / 2 }; } -HAS_METHOD(viewport) +HAS_METHOD(has_viewport, viewport) template static inline constexpr bool is_QWidgetOrDerived = std::is_base_of::value; @@ -27,14 +27,14 @@ static inline constexpr bool is_QWidgetOrDerived = std::is_base_of:: template using viewport_type = decltype(std::declval().viewport()); -HAS_METHOD(topLevelItem) +HAS_METHOD(has_topLevelItem, topLevelItem) template void mouseMove(T* widget, QPoint pos, Qt::MouseButton mouseModifier) { QCursor::setPos(widget->mapToGlobal(pos)); QMouseEvent event(QEvent::MouseMove, pos, Qt::NoButton, mouseModifier, Qt::NoModifier); - if constexpr (has_viewport) + if constexpr (has_viewport_v) { if constexpr (is_QWidgetOrDerived>) { @@ -56,7 +56,7 @@ void mouseMove(T* widget, QPoint pos, Qt::MouseButton mouseModifier) template void setMouseTracking(T* widget) { - if constexpr (has_viewport) + if constexpr (has_viewport_v) { if constexpr (is_QWidgetOrDerived>) { @@ -76,7 +76,7 @@ void setMouseTracking(T* widget) template auto getItem(T* widget, T2 itemIndex) { - if constexpr (has_topLevelItem) + if constexpr (has_topLevelItem_v) { return widget->topLevelItem(itemIndex); } @@ -105,7 +105,7 @@ template void dragnDropItem(T1* sourceWidget, T2* destWidget, T3* item, T4* destItem = Q_NULLPTR) { auto itemCenterPos = sourceWidget->visualItemRect(item).center(); - if constexpr (has_viewport) + if constexpr (has_viewport_v) { QTest::mousePress(sourceWidget->viewport(), Qt::LeftButton, Qt::NoModifier, itemCenterPos); } @@ -123,7 +123,7 @@ void dragnDropItem(T1* sourceWidget, T2* destWidget, T3* item, T4* destItem = Q_ auto destItemCenterPos = destWidget->visualItemRect(destItem).center(); QTest::mouseRelease(destWidget, Qt::LeftButton, Qt::NoModifier, destItemCenterPos); } - else if constexpr (has_viewport) + else if constexpr (has_viewport_v) { QTest::mouseRelease(destWidget->viewport(), Qt::LeftButton); } diff --git a/gui/tests/catalogue/browser/main.cpp b/gui/tests/catalogue/browser/main.cpp index c4dd139..af8ccd6 100644 --- a/gui/tests/catalogue/browser/main.cpp +++ b/gui/tests/catalogue/browser/main.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include diff --git a/subprojects/cpp_utils.wrap b/subprojects/cpp_utils.wrap new file mode 100644 index 0000000..e1ca5c1 --- /dev/null +++ b/subprojects/cpp_utils.wrap @@ -0,0 +1,5 @@ +[wrap-git] +directory = cpp_utils +url = https://github.com/jeandet/cpp_utils.git +revision = master +