Enable internal move in the list. Helps user quickly make reorder.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-04 17:34:15 +02:00
parent eb84ae7526
commit f40bf977c8
4 changed files with 32 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "core/vapplication.h" #include "core/vapplication.h"
#include "../fervor/fvupdater.h" #include "../fervor/fvupdater.h"
#include "../vpatterndb/vpiecenode.h"
#include <QMessageBox> // For QT_REQUIRE_VERSION #include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer> #include <QTimer>
@ -53,6 +54,8 @@ int main(int argc, char *argv[])
qt_qhash_seed.store(0); // Lock producing random attribute order in XML qt_qhash_seed.store(0); // Lock producing random attribute order in XML
qRegisterMetaTypeStreamOperators<VPieceNode>("VPieceNode");
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
#endif #endif

View File

@ -97,3 +97,24 @@ void VPieceNode::SetReverse(bool reverse)
d->m_reverse = reverse; d->m_reverse = reverse;
} }
} }
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
QDataStream& operator<<(QDataStream& out, const VPieceNode& p)
{
out << p.d->m_id << static_cast<int>(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<Tool>(type);
in >> p.d->m_reverse;
return in;
}

View File

@ -46,6 +46,9 @@ public:
VPieceNode &operator=(const VPieceNode &node); VPieceNode &operator=(const VPieceNode &node);
~VPieceNode(); ~VPieceNode();
friend QDataStream& operator<<(QDataStream& out, const VPieceNode& p);
friend QDataStream& operator>>(QDataStream& in, VPieceNode& p);
quint32 GetId() const; quint32 GetId() const;
void SetId(quint32 id); void SetId(quint32 id);

View File

@ -59,7 +59,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QListWidget" name="listWidget"/> <widget class="QListWidget" name="listWidget">
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="helpLabel"> <widget class="QLabel" name="helpLabel">