#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 ); }