From 90e991aec5fa6e6110ac4a973229a3892a72c00b 2017-10-25 14:31:39 From: Thibaud Rabillard Date: 2017-10-25 14:31:39 Subject: [PATCH] Format changes --- diff --git a/gui/include/DragDropHelper.h b/gui/include/DragDropHelper.h index d6b6284..95a9c45 100644 --- a/gui/include/DragDropHelper.h +++ b/gui/include/DragDropHelper.h @@ -1,5 +1,5 @@ -#ifndef DRAGDROPHELPER_H -#define DRAGDROPHELPER_H +#ifndef SCIQLOP_DRAGDROPHELPER_H +#define SCIQLOP_DRAGDROPHELPER_H #include #include @@ -13,15 +13,14 @@ class QMimeData; * @brief Event filter class which manage the scroll of QScrollArea during a drag&drop operation. * @note A QScrollArea inside an other QScrollArea is not fully supported. */ -class DragDropScroller : public QObject -{ +class DragDropScroller : public QObject { Q_OBJECT public: - DragDropScroller(QObject* parent = nullptr); + DragDropScroller(QObject *parent = nullptr); - void addScrollArea(QScrollArea* scrollArea); - void removeScrollArea(QScrollArea* scrollArea); + void addScrollArea(QScrollArea *scrollArea); + void removeScrollArea(QScrollArea *scrollArea); protected: bool eventFilter(QObject *obj, QEvent *event); @@ -37,31 +36,30 @@ private slots: /** * @brief Helper class for drag&drop operations. */ -class DragDropHelper -{ +class DragDropHelper { public: - DragDropHelper(); - ~DragDropHelper(); - static const QString MIME_TYPE_GRAPH; static const QString MIME_TYPE_ZONE; - void setCurrentDragWidget(VisualizationDragWidget* dragWidget); - VisualizationDragWidget* getCurrentDragWidget() const; + DragDropHelper(); + virtual ~DragDropHelper(); + + void setCurrentDragWidget(VisualizationDragWidget *dragWidget); + VisualizationDragWidget *getCurrentDragWidget() const; QWidget &placeHolder() const; - void insertPlaceHolder(QVBoxLayout* layout, int index); + void insertPlaceHolder(QVBoxLayout *layout, int index); void removePlaceHolder(); bool isPlaceHolderSet() const; - void addDragDropScrollArea(QScrollArea* scrollArea); - void removeDragDropScrollArea(QScrollArea* scrollArea); + void addDragDropScrollArea(QScrollArea *scrollArea); + void removeDragDropScrollArea(QScrollArea *scrollArea); - QUrl imageTemporaryUrl(const QImage& image) const; + QUrl imageTemporaryUrl(const QImage &image) const; private: class DragDropHelperPrivate; spimpl::unique_impl_ptr impl; }; -#endif // DRAGDROPHELPER_H +#endif // SCIQLOP_DRAGDROPHELPER_H diff --git a/gui/include/SqpApplication.h b/gui/include/SqpApplication.h index d7049ba..1027e29 100644 --- a/gui/include/SqpApplication.h +++ b/gui/include/SqpApplication.h @@ -45,7 +45,7 @@ public: VariableController &variableController() noexcept; VisualizationController &visualizationController() noexcept; - /// Accessors for the differents sciqlop helpers + /// Accessors for the differents sciqlop helpers DragDropHelper &dragDropHelper() noexcept; private: diff --git a/gui/include/Visualization/VisualizationDragDropContainer.h b/gui/include/Visualization/VisualizationDragDropContainer.h index 5f9e9bd..8520c0c 100644 --- a/gui/include/Visualization/VisualizationDragDropContainer.h +++ b/gui/include/Visualization/VisualizationDragDropContainer.h @@ -1,28 +1,27 @@ #ifndef VISUALIZATIONDRAGDROPCONTAINER_H #define VISUALIZATIONDRAGDROPCONTAINER_H -#include -#include -#include #include +#include +#include +#include class VisualizationDragWidget; -class VisualizationDragDropContainer : public QWidget -{ +class VisualizationDragDropContainer : public QWidget { Q_OBJECT signals: - void dropOccured(int dropIndex, const QMimeData* mimeData); + void dropOccured(int dropIndex, const QMimeData *mimeData); public: - VisualizationDragDropContainer(QWidget* parent = nullptr); + VisualizationDragDropContainer(QWidget *parent = nullptr); - void addDragWidget(VisualizationDragWidget* dragWidget); - void insertDragWidget(int index, VisualizationDragWidget* dragWidget); + void addDragWidget(VisualizationDragWidget *dragWidget); + void insertDragWidget(int index, VisualizationDragWidget *dragWidget); - void setAcceptedMimeTypes(const QStringList& mimeTypes); - void setMergeAllowedMimeTypes(const QStringList& mimeTypes); + void setAcceptedMimeTypes(const QStringList &mimeTypes); + void setMergeAllowedMimeTypes(const QStringList &mimeTypes); int countDragWidget() const; @@ -33,13 +32,11 @@ protected: void dropEvent(QDropEvent *event); private: - - class VisualizationDragDropContainerPrivate; spimpl::unique_impl_ptr impl; private slots: - void startDrag(VisualizationDragWidget* dragWidget, const QPoint& dragPosition); + void startDrag(VisualizationDragWidget *dragWidget, const QPoint &dragPosition); }; #endif // VISUALIZATIONDRAGDROPCONTAINER_H diff --git a/gui/include/Visualization/VisualizationDragWidget.h b/gui/include/Visualization/VisualizationDragWidget.h index 46e038f..b723cb0 100644 --- a/gui/include/Visualization/VisualizationDragWidget.h +++ b/gui/include/Visualization/VisualizationDragWidget.h @@ -1,18 +1,17 @@ #ifndef VISUALIZATIONDRAGWIDGET_H #define VISUALIZATIONDRAGWIDGET_H -#include -#include #include +#include +#include -class VisualizationDragWidget : public QWidget -{ +class VisualizationDragWidget : public QWidget { Q_OBJECT public: - VisualizationDragWidget(QWidget* parent = nullptr); + VisualizationDragWidget(QWidget *parent = nullptr); - virtual QMimeData* mimeData() const = 0; + virtual QMimeData *mimeData() const = 0; virtual bool isDragAllowed() const = 0; protected: @@ -24,7 +23,7 @@ private: spimpl::unique_impl_ptr impl; signals: - void dragDetected(VisualizationDragWidget* dragWidget, const QPoint& dragPosition); + void dragDetected(VisualizationDragWidget *dragWidget, const QPoint &dragPosition); }; #endif // VISUALIZATIONDRAGWIDGET_H diff --git a/gui/include/Visualization/VisualizationGraphWidget.h b/gui/include/Visualization/VisualizationGraphWidget.h index c8f0adc..b0e85c7 100644 --- a/gui/include/Visualization/VisualizationGraphWidget.h +++ b/gui/include/Visualization/VisualizationGraphWidget.h @@ -33,7 +33,7 @@ public: explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0); virtual ~VisualizationGraphWidget(); - VisualizationZoneWidget* parentZoneWidget() const noexcept; + VisualizationZoneWidget *parentZoneWidget() const noexcept; /// If acquisition isn't enable, requestDataLoading signal cannot be emit void enableAcquisition(bool enable); @@ -44,7 +44,7 @@ public: void removeVariable(std::shared_ptr variable) noexcept; /// Returns the list of all variables used in the graph - QList> variables() const; + QList > variables() const; void setYRange(const SqpRange &range); SqpRange graphRange() const noexcept; @@ -57,7 +57,7 @@ public: QString name() const override; // VisualisationDragWidget - QMimeData* mimeData() const override; + QMimeData *mimeData() const override; bool isDragAllowed() const override; signals: diff --git a/gui/include/Visualization/VisualizationTabWidget.h b/gui/include/Visualization/VisualizationTabWidget.h index 49a1769..4df7113 100644 --- a/gui/include/Visualization/VisualizationTabWidget.h +++ b/gui/include/Visualization/VisualizationTabWidget.h @@ -6,8 +6,8 @@ #include #include -#include #include +#include Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationTabWidget) @@ -39,13 +39,14 @@ public: VisualizationZoneWidget *createZone(std::shared_ptr variable); /** - * Creates a zone using a list of variables. The variables will be displayed in a new graph of the new - * zone. The zone is inserted at the specified index. + * Creates a zone using a list of variables. The variables will be displayed in a new graph of + * the new zone. The zone is inserted at the specified index. * @param variables the variables for which to create the zone * @param index The index where the zone should be inserted in the layout * @return the pointer to the created zone */ - VisualizationZoneWidget *createZone(const QList>& variables, int index); + VisualizationZoneWidget *createZone(const QList > &variables, + int index); /** * Creates a zone which is empty (no variables). The zone is inserted at the specified index. diff --git a/gui/include/Visualization/VisualizationZoneWidget.h b/gui/include/Visualization/VisualizationZoneWidget.h index a2dac14..3700489 100644 --- a/gui/include/Visualization/VisualizationZoneWidget.h +++ b/gui/include/Visualization/VisualizationZoneWidget.h @@ -15,7 +15,7 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationZoneWidget) namespace Ui { class VisualizationZoneWidget; -} // Ui +} // namespace Ui class Variable; class VisualizationGraphWidget; @@ -30,7 +30,7 @@ public: /// Adds a graph widget void addGraph(VisualizationGraphWidget *graphWidget); - /// Inserts a graph widget + /// Inserts a graph widget void insertGraph(int index, VisualizationGraphWidget *graphWidget); /** @@ -57,7 +57,8 @@ public: * @param index The index where the graph should be inserted in the layout * @return the pointer to the created graph */ - VisualizationGraphWidget *createGraph(const QList> variables, int index); + VisualizationGraphWidget *createGraph(const QList > variables, + int index); // IVisualizationWidget interface void accept(IVisualizationWidgetVisitor *visitor) override; @@ -66,7 +67,7 @@ public: QString name() const override; // VisualisationDragWidget - QMimeData* mimeData() const override; + QMimeData *mimeData() const override; bool isDragAllowed() const override; protected: @@ -83,7 +84,7 @@ private slots: /// Slot called when a variable is about to be removed from a graph contained in the zone void onVariableAboutToBeRemoved(std::shared_ptr variable); - void dropMimeData(int index, const QMimeData* mimeData); + void dropMimeData(int index, const QMimeData *mimeData); }; #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H diff --git a/gui/src/DragDropHelper.cpp b/gui/src/DragDropHelper.cpp index b327352..c0568d8 100644 --- a/gui/src/DragDropHelper.cpp +++ b/gui/src/DragDropHelper.cpp @@ -1,14 +1,14 @@ #include "DragDropHelper.h" -#include "Visualization/VisualizationDragWidget.h" #include "SqpApplication.h" +#include "Visualization/VisualizationDragWidget.h" -#include +#include #include -#include +#include #include -#include +#include #include -#include +#include const QString DragDropHelper::MIME_TYPE_GRAPH = "scqlop/graph"; const QString DragDropHelper::MIME_TYPE_ZONE = "scqlop/zone"; @@ -18,108 +18,97 @@ const int SCROLL_ZONE_SIZE = 50; struct DragDropScroller::DragDropScrollerPrivate { - QList m_scrollAreas; - QScrollArea* m_currentScrollArea = nullptr; - std::unique_ptr m_timer = nullptr; + QList m_ScrollAreas; + QScrollArea *m_CurrentScrollArea = nullptr; + std::unique_ptr m_Timer = nullptr; - enum class ScrollDirection {up, down, unknown}; - ScrollDirection m_direction = ScrollDirection::unknown; + enum class ScrollDirection { up, down, unknown }; + ScrollDirection m_Direction = ScrollDirection::unknown; - explicit DragDropScrollerPrivate() - : m_timer{std::make_unique()} + explicit DragDropScrollerPrivate() : m_Timer{std::make_unique()} { - m_timer->setInterval(0); + m_Timer->setInterval(0); } }; -DragDropScroller::DragDropScroller(QObject* parent) - : QObject{parent}, impl{spimpl::make_unique_impl()} +DragDropScroller::DragDropScroller(QObject *parent) + : QObject{parent}, impl{spimpl::make_unique_impl()} { - connect(impl->m_timer.get(), &QTimer::timeout, this, &DragDropScroller::onTimer); + connect(impl->m_Timer.get(), &QTimer::timeout, this, &DragDropScroller::onTimer); } -void DragDropScroller::addScrollArea(QScrollArea* scrollArea) +void DragDropScroller::addScrollArea(QScrollArea *scrollArea) { - impl->m_scrollAreas << scrollArea; + impl->m_ScrollAreas << scrollArea; scrollArea->viewport()->setAcceptDrops(true); } -void DragDropScroller::removeScrollArea(QScrollArea* scrollArea) +void DragDropScroller::removeScrollArea(QScrollArea *scrollArea) { - impl->m_scrollAreas.removeAll(scrollArea); + impl->m_ScrollAreas.removeAll(scrollArea); scrollArea->viewport()->setAcceptDrops(false); } bool DragDropScroller::eventFilter(QObject *obj, QEvent *event) { - if (event->type() == QEvent::DragMove) - { - auto w = static_cast(obj); + if (event->type() == QEvent::DragMove) { + auto w = static_cast(obj); - if (impl->m_currentScrollArea && impl->m_currentScrollArea->isAncestorOf(w)) - { - auto moveEvent = static_cast(event); + if (impl->m_CurrentScrollArea && impl->m_CurrentScrollArea->isAncestorOf(w)) { + auto moveEvent = static_cast(event); auto pos = moveEvent->pos(); - if (impl->m_currentScrollArea->viewport() != w) - { + if (impl->m_CurrentScrollArea->viewport() != w) { auto globalPos = w->mapToGlobal(moveEvent->pos()); - pos = impl->m_currentScrollArea->viewport()->mapFromGlobal(globalPos); + pos = impl->m_CurrentScrollArea->viewport()->mapFromGlobal(globalPos); } - auto isInTopZone = pos.y() > impl->m_currentScrollArea->viewport()->size().height() - SCROLL_ZONE_SIZE; + auto isInTopZone = pos.y() > impl->m_CurrentScrollArea->viewport()->size().height() + - SCROLL_ZONE_SIZE; auto isInBottomZone = pos.y() < SCROLL_ZONE_SIZE; - if (!isInTopZone && !isInBottomZone) - { - impl->m_direction = DragDropScrollerPrivate::ScrollDirection::unknown; - impl->m_timer->stop(); + if (!isInTopZone && !isInBottomZone) { + impl->m_Direction = DragDropScrollerPrivate::ScrollDirection::unknown; + impl->m_Timer->stop(); } - else if (!impl->m_timer->isActive()) - { - impl->m_direction = isInTopZone ? DragDropScrollerPrivate::ScrollDirection::up : DragDropScrollerPrivate::ScrollDirection::down; - impl->m_timer->start(); + else if (!impl->m_Timer->isActive()) { + impl->m_Direction = isInTopZone ? DragDropScrollerPrivate::ScrollDirection::up + : DragDropScrollerPrivate::ScrollDirection::down; + impl->m_Timer->start(); } } } - else if (event->type() == QEvent::DragEnter) - { - auto w = static_cast(obj); + else if (event->type() == QEvent::DragEnter) { + auto w = static_cast(obj); - for (auto scrollArea : impl-> m_scrollAreas) - { - if (impl->m_currentScrollArea != scrollArea && scrollArea->isAncestorOf(w)) - { - auto enterEvent = static_cast(event); + for (auto scrollArea : impl->m_ScrollAreas) { + if (impl->m_CurrentScrollArea != scrollArea && scrollArea->isAncestorOf(w)) { + auto enterEvent = static_cast(event); enterEvent->acceptProposedAction(); enterEvent->setDropAction(Qt::IgnoreAction); - impl->m_currentScrollArea = scrollArea; + impl->m_CurrentScrollArea = scrollArea; break; } } } - else if (event->type() == QEvent::DragLeave) - { - auto w = static_cast(obj); - if (impl->m_currentScrollArea) - { - if (!QRect(QPoint(), impl->m_currentScrollArea->size()).contains(impl->m_currentScrollArea->mapFromGlobal(QCursor::pos()))) - { - impl->m_currentScrollArea = nullptr; - impl->m_direction = DragDropScrollerPrivate::ScrollDirection::unknown; - impl->m_timer->stop(); + else if (event->type() == QEvent::DragLeave) { + auto w = static_cast(obj); + if (impl->m_CurrentScrollArea) { + if (!QRect(QPoint(), impl->m_CurrentScrollArea->size()) + .contains(impl->m_CurrentScrollArea->mapFromGlobal(QCursor::pos()))) { + impl->m_CurrentScrollArea = nullptr; + impl->m_Direction = DragDropScrollerPrivate::ScrollDirection::unknown; + impl->m_Timer->stop(); } } } - else if (event->type() == QEvent::Drop) - { - auto w = static_cast(obj); - if (impl->m_currentScrollArea) - { - impl->m_currentScrollArea = nullptr; - impl->m_direction = DragDropScrollerPrivate::ScrollDirection::unknown; - impl->m_timer->stop(); + else if (event->type() == QEvent::Drop) { + auto w = static_cast(obj); + if (impl->m_CurrentScrollArea) { + impl->m_CurrentScrollArea = nullptr; + impl->m_Direction = DragDropScrollerPrivate::ScrollDirection::unknown; + impl->m_Timer->stop(); } } @@ -128,121 +117,114 @@ bool DragDropScroller::eventFilter(QObject *obj, QEvent *event) void DragDropScroller::onTimer() { - if (impl->m_currentScrollArea) - { + if (impl->m_CurrentScrollArea) { auto mvt = 0; - switch (impl->m_direction) - { - case DragDropScrollerPrivate::ScrollDirection::up: - mvt = SCROLL_SPEED; - break; - case DragDropScrollerPrivate::ScrollDirection::down: - mvt = -SCROLL_SPEED; - break; - default: - break; + switch (impl->m_Direction) { + case DragDropScrollerPrivate::ScrollDirection::up: + mvt = SCROLL_SPEED; + break; + case DragDropScrollerPrivate::ScrollDirection::down: + mvt = -SCROLL_SPEED; + break; + default: + break; } - impl->m_currentScrollArea->verticalScrollBar()->setValue(impl->m_currentScrollArea->verticalScrollBar()->value() + mvt); + impl->m_CurrentScrollArea->verticalScrollBar()->setValue( + impl->m_CurrentScrollArea->verticalScrollBar()->value() + mvt); } } struct DragDropHelper::DragDropHelperPrivate { - VisualizationDragWidget* m_currentDragWidget = nullptr; - std::unique_ptr m_placeHolder = nullptr; - std::unique_ptr m_dragDropScroller = nullptr; - QString m_imageTempUrl; //Temporary file for image url generated by the drag & drop. Not using QTemporaryFile to have a name which is not generated. + VisualizationDragWidget *m_CurrentDragWidget = nullptr; + std::unique_ptr m_PlaceHolder = nullptr; + std::unique_ptr m_DragDropScroller = nullptr; + QString m_ImageTempUrl; // Temporary file for image url generated by the drag & drop. Not using + // QTemporaryFile to have a name which is not generated. explicit DragDropHelperPrivate() - : m_placeHolder{std::make_unique()}, - m_dragDropScroller{std::make_unique()} + : m_PlaceHolder{std::make_unique()}, + m_DragDropScroller{std::make_unique()} { - m_placeHolder->setStyleSheet("background-color: #BBD5EE; border:2px solid #2A7FD4"); - sqpApp->installEventFilter(m_dragDropScroller.get()); + m_PlaceHolder->setStyleSheet("background-color: #BBD5EE; border:2px solid #2A7FD4"); + sqpApp->installEventFilter(m_DragDropScroller.get()); - m_imageTempUrl = QDir::temp().absoluteFilePath("Scqlop_graph.png"); + m_ImageTempUrl = QDir::temp().absoluteFilePath("Scqlop_graph.png"); } void preparePlaceHolder() const { - if (m_currentDragWidget) - { - m_placeHolder->setMinimumSize(m_currentDragWidget->size()); - m_placeHolder->setSizePolicy(m_currentDragWidget->sizePolicy()); + if (m_CurrentDragWidget) { + m_PlaceHolder->setMinimumSize(m_CurrentDragWidget->size()); + m_PlaceHolder->setSizePolicy(m_CurrentDragWidget->sizePolicy()); } - else - { - m_placeHolder->setMinimumSize(200, 200); + else { + m_PlaceHolder->setMinimumSize(200, 200); } } }; -DragDropHelper::DragDropHelper() : - impl{spimpl::make_unique_impl()} -{ -} +DragDropHelper::DragDropHelper() : impl{spimpl::make_unique_impl()} {} DragDropHelper::~DragDropHelper() { - QFile::remove(impl->m_imageTempUrl); + QFile::remove(impl->m_ImageTempUrl); } void DragDropHelper::setCurrentDragWidget(VisualizationDragWidget *dragWidget) { - impl->m_currentDragWidget = dragWidget; + impl->m_CurrentDragWidget = dragWidget; } VisualizationDragWidget *DragDropHelper::getCurrentDragWidget() const { - return impl->m_currentDragWidget; + return impl->m_CurrentDragWidget; } -QWidget& DragDropHelper::placeHolder() const +QWidget &DragDropHelper::placeHolder() const { - return *impl->m_placeHolder; + return *impl->m_PlaceHolder; } void DragDropHelper::insertPlaceHolder(QVBoxLayout *layout, int index) { removePlaceHolder(); impl->preparePlaceHolder(); - layout->insertWidget(index, impl->m_placeHolder.get()); - impl->m_placeHolder->show(); + layout->insertWidget(index, impl->m_PlaceHolder.get()); + impl->m_PlaceHolder->show(); } void DragDropHelper::removePlaceHolder() { - auto parentWidget = impl->m_placeHolder->parentWidget(); - if (parentWidget) - { - parentWidget->layout()->removeWidget(impl->m_placeHolder.get()); - impl->m_placeHolder->setParent(nullptr); - impl->m_placeHolder->hide(); + auto parentWidget = impl->m_PlaceHolder->parentWidget(); + if (parentWidget) { + parentWidget->layout()->removeWidget(impl->m_PlaceHolder.get()); + impl->m_PlaceHolder->setParent(nullptr); + impl->m_PlaceHolder->hide(); } } bool DragDropHelper::isPlaceHolderSet() const { - return impl->m_placeHolder->parentWidget(); + return impl->m_PlaceHolder->parentWidget(); } void DragDropHelper::addDragDropScrollArea(QScrollArea *scrollArea) { - impl->m_dragDropScroller->addScrollArea(scrollArea); + impl->m_DragDropScroller->addScrollArea(scrollArea); } void DragDropHelper::removeDragDropScrollArea(QScrollArea *scrollArea) { - impl->m_dragDropScroller->removeScrollArea(scrollArea); + impl->m_DragDropScroller->removeScrollArea(scrollArea); } -QUrl DragDropHelper::imageTemporaryUrl(const QImage& image) const +QUrl DragDropHelper::imageTemporaryUrl(const QImage &image) const { - image.save(impl->m_imageTempUrl); - return QUrl::fromLocalFile(impl->m_imageTempUrl); + image.save(impl->m_ImageTempUrl); + return QUrl::fromLocalFile(impl->m_ImageTempUrl); } - diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index 1187cc9..7eaec69 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -2,13 +2,13 @@ #include #include +#include #include #include #include