summaryrefslogtreecommitdiff
path: root/src/dic-options/PackFieldsView.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/dic-options/PackFieldsView.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'src/dic-options/PackFieldsView.cpp')
-rw-r--r--src/dic-options/PackFieldsView.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/dic-options/PackFieldsView.cpp b/src/dic-options/PackFieldsView.cpp
new file mode 100644
index 0000000..6925984
--- /dev/null
+++ b/src/dic-options/PackFieldsView.cpp
@@ -0,0 +1,36 @@
+#include "PackFieldsView.h"
+
+PackFieldsView::PackFieldsView(QWidget *parent):
+ QListView( parent )
+ {
+ setDragEnabled(true);
+ setAcceptDrops(true);
+ setDropIndicatorShown(true);
+ setDragDropOverwriteMode( false );
+ }
+
+void PackFieldsView::setModel( QAbstractItemModel* aModel )
+ {
+ QListView::setModel( aModel );
+ qRegisterMetaType< QList<QPersistentModelIndex> >();
+ connect( aModel, SIGNAL(indexesDropped(QList<QPersistentModelIndex>)),
+ this, SLOT(selectIndexes(QList<QPersistentModelIndex>)), Qt::QueuedConnection );
+ }
+
+void PackFieldsView::selectIndexes( QList<QPersistentModelIndex> aIndexes )
+ {
+ selectionModel()->clearSelection();
+ foreach( QPersistentModelIndex pIndex, aIndexes )
+ {
+ QModelIndex index = model()->index( pIndex.row(), 0, pIndex.parent() );
+ selectionModel()->select( index, QItemSelectionModel::Select );
+ }
+ selectionModel()->setCurrentIndex( aIndexes[0], QItemSelectionModel::NoUpdate );
+ }
+
+void PackFieldsView::updateCurrent()
+ {
+ QItemSelection selection = selectionModel()->selection();
+ reset();
+ selectionModel()->select( selection, QItemSelectionModel::Select );
+ }