Refactoring. Hide compatibility layer behind a function.

toVector().

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2020-01-16 19:20:55 +02:00
parent 7e3c7e0f88
commit 658eafc3d3
7 changed files with 31 additions and 15 deletions

View File

@ -49,6 +49,7 @@
#include "vlayoutpaper_p.h" #include "vlayoutpaper_p.h"
#include "vposition.h" #include "vposition.h"
#include "../ifc/exception/vexceptionterminatedposition.h" #include "../ifc/exception/vexceptionterminatedposition.h"
#include "../vmisc/compatibility.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPaper::VLayoutPaper() VLayoutPaper::VLayoutPaper()
@ -411,7 +412,7 @@ QVector<VLayoutPiece> VLayoutPaper::GetDetails() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetDetails(const QList<VLayoutPiece> &details) void VLayoutPaper::SetDetails(const QList<VLayoutPiece> &details)
{ {
d->details = details.toVector(); d->details = ConvertToVector(details);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -519,7 +519,7 @@ QVector<T> VLayoutPiece::Map(QVector<T> points) const
{ {
SwapItemsAt(list, k, s-(1+k)); SwapItemsAt(list, k, s-(1+k));
} }
points = list.toVector(); points = ConvertToVector(list);
} }
return points; return points;
} }

View File

@ -102,6 +102,17 @@ inline QSet<T> ConvertToSet(const C &container)
#endif #endif
} }
//---------------------------------------------------------------------------------------------------------------------
template <typename T, template <typename> class C>
inline QVector<T> ConvertToVector(const C<T> &container)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return QVector<T>(container.begin(), container.end());
#else
return container.toVector();
#endif
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
inline void SwapItemsAt(T &container, int i, int j) inline void SwapItemsAt(T &container, int i, int j)

View File

@ -52,6 +52,7 @@
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "../vmisc/compatibility.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
@ -143,7 +144,7 @@ void DialogFlippingByAxis::SetSuffix(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByAxis::GetObjects() const QVector<quint32> DialogFlippingByAxis::GetObjects() const
{ {
return objects.toVector(); return ConvertToVector(objects);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -164,7 +165,7 @@ void DialogFlippingByAxis::ShowDialog(bool click)
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis); VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->VisualMode(); operation->VisualMode();
scene->ToggleArcSelection(false); scene->ToggleArcSelection(false);
@ -290,7 +291,7 @@ void DialogFlippingByAxis::SaveData()
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis); VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->SetOriginPointId(GetOriginPointId()); operation->SetOriginPointId(GetOriginPointId());
operation->SetAxisType(GetAxisType()); operation->SetAxisType(GetAxisType());
operation->RefreshGeometry(); operation->RefreshGeometry();

View File

@ -52,6 +52,7 @@
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "../vmisc/compatibility.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
@ -138,7 +139,7 @@ void DialogFlippingByLine::SetSuffix(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByLine::GetObjects() const QVector<quint32> DialogFlippingByLine::GetObjects() const
{ {
return objects.toVector(); return ConvertToVector(objects);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -159,7 +160,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis); VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->VisualMode(); operation->VisualMode();
scene->ToggleArcSelection(false); scene->ToggleArcSelection(false);
@ -314,7 +315,7 @@ void DialogFlippingByLine::SaveData()
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis); VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->SetFirstLinePointId(GetFirstLinePointId()); operation->SetFirstLinePointId(GetFirstLinePointId());
operation->SetSecondLinePointId(GetSecondLinePointId()); operation->SetSecondLinePointId(GetSecondLinePointId());
operation->RefreshGeometry(); operation->RefreshGeometry();

View File

@ -56,6 +56,7 @@
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "../vmisc/compatibility.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
@ -253,7 +254,7 @@ void DialogMove::SetRotationOrigPointId(const quint32 &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogMove::GetObjects() const QVector<quint32> DialogMove::GetObjects() const
{ {
return objects.toVector(); return ConvertToVector(objects);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -275,7 +276,7 @@ void DialogMove::ShowDialog(bool click)
VisToolMove *operation = qobject_cast<VisToolMove *>(vis); VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->VisualMode(); operation->VisualMode();
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow()); VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
@ -497,7 +498,7 @@ void DialogMove::SaveData()
VisToolMove *operation = qobject_cast<VisToolMove *>(vis); VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->SetAngle(formulaAngle); operation->SetAngle(formulaAngle);
operation->SetLength(formulaLength); operation->SetLength(formulaLength);
operation->SetRotationAngle(formulaRotationAngle); operation->SetRotationAngle(formulaRotationAngle);

View File

@ -56,6 +56,7 @@
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "../vmisc/compatibility.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
@ -166,7 +167,7 @@ void DialogRotation::SetSuffix(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogRotation::GetObjects() const QVector<quint32> DialogRotation::GetObjects() const
{ {
return objects.toVector(); return ConvertToVector(objects);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -187,7 +188,7 @@ void DialogRotation::ShowDialog(bool click)
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis); VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->VisualMode(); operation->VisualMode();
scene->ToggleArcSelection(false); scene->ToggleArcSelection(false);
@ -261,7 +262,7 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
// It's not really logical for a user that a center of rotation no need to select. // It's not really logical for a user that a center of rotation no need to select.
// To fix this issue we just silently remove it from the list. // To fix this issue we just silently remove it from the list.
objects.removeOne(id); objects.removeOne(id);
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
} }
else else
{ {
@ -380,7 +381,7 @@ void DialogRotation::SaveData()
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis); VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
operation->SetObjects(objects.toVector()); operation->SetObjects(ConvertToVector(objects));
operation->SetOriginPointId(GetOrigPointId()); operation->SetOriginPointId(GetOrigPointId());
operation->SetAngle(formulaAngle); operation->SetAngle(formulaAngle);
operation->RefreshGeometry(); operation->RefreshGeometry();