blob: 6925984d0ea4419bb9808c13984821eb8c63ce0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 );
}
|