summaryrefslogtreecommitdiff
path: root/src/dic-options/PackFieldsView.cpp
diff options
context:
space:
mode:
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 );
+ }