From f40bf977c820147a78886c523455274227caa82d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 4 Nov 2016 17:34:15 +0200 Subject: [PATCH] Enable internal move in the list. Helps user quickly make reorder. --HG-- branch : feature --- src/app/valentina/main.cpp | 3 +++ src/libs/vpatterndb/vpiecenode.cpp | 21 +++++++++++++++++++ src/libs/vpatterndb/vpiecenode.h | 3 +++ .../dialogs/tools/dialogseamallowance.ui | 6 +++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 60348d25f..8016abe6b 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -29,6 +29,7 @@ #include "mainwindow.h" #include "core/vapplication.h" #include "../fervor/fvupdater.h" +#include "../vpatterndb/vpiecenode.h" #include // For QT_REQUIRE_VERSION #include @@ -53,6 +54,8 @@ int main(int argc, char *argv[]) qt_qhash_seed.store(0); // Lock producing random attribute order in XML + qRegisterMetaTypeStreamOperators("VPieceNode"); + #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support #endif diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index b2e5bbba3..f238e2f65 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -97,3 +97,24 @@ void VPieceNode::SetReverse(bool reverse) d->m_reverse = reverse; } } + +// Friend functions +//--------------------------------------------------------------------------------------------------------------------- +QDataStream& operator<<(QDataStream& out, const VPieceNode& p) +{ + out << p.d->m_id << static_cast(p.d->m_typeTool) << p.d->m_reverse; + return out; +} + +//--------------------------------------------------------------------------------------------------------------------- +QDataStream& operator>>(QDataStream& in, VPieceNode& p) +{ + in >> p.d->m_id; + + int type = 0; + in >> type; + p.d->m_typeTool = static_cast(type); + + in >> p.d->m_reverse; + return in; +} diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index 385d9bf6b..62e3ad3fd 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -46,6 +46,9 @@ public: VPieceNode &operator=(const VPieceNode &node); ~VPieceNode(); + friend QDataStream& operator<<(QDataStream& out, const VPieceNode& p); + friend QDataStream& operator>>(QDataStream& in, VPieceNode& p); + quint32 GetId() const; void SetId(quint32 id); diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui index 810e28537..78d9d7889 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui @@ -59,7 +59,11 @@ - + + + QAbstractItemView::InternalMove + +