From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/dic-options/PackFieldsView.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/dic-options/PackFieldsView.cpp (limited to 'src/dic-options/PackFieldsView.cpp') 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 >(); + connect( aModel, SIGNAL(indexesDropped(QList)), + this, SLOT(selectIndexes(QList)), Qt::QueuedConnection ); + } + +void PackFieldsView::selectIndexes( QList 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 ); + } -- cgit