summaryrefslogtreecommitdiff
path: root/src/dic-options/FieldsView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dic-options/FieldsView.cpp')
-rw-r--r--src/dic-options/FieldsView.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/dic-options/FieldsView.cpp b/src/dic-options/FieldsView.cpp
new file mode 100644
index 0000000..65801c7
--- /dev/null
+++ b/src/dic-options/FieldsView.cpp
@@ -0,0 +1,41 @@
+#include "FieldsView.h"
+#include "FieldStyleDelegate.h"
+
+#include <QHeaderView>
+
+FieldsView::FieldsView(QWidget *parent):
+ QTableView( parent )
+ {
+ setDragEnabled(true);
+ setAcceptDrops(true);
+ setDropIndicatorShown(true);
+ setDragDropOverwriteMode( false );
+ FieldStyleDelegate* delegate = new FieldStyleDelegate(this);
+ setItemDelegateForColumn( 1, delegate );
+
+ setShowGrid(false);
+ verticalHeader()->hide();
+ setSelectionBehavior( QAbstractItemView::SelectRows );
+ }
+
+void FieldsView::startDrag(Qt::DropActions supportedActions)
+ {
+ selectionModel()->select( selectionModel()->selection(),
+ QItemSelectionModel::Select | QItemSelectionModel::Rows );
+ QAbstractItemView::startDrag( supportedActions );
+ }
+
+void FieldsView::setModel( FieldsListModel* aModel )
+ {
+ QTableView::setModel( aModel );
+ qRegisterMetaType< QList<QPersistentModelIndex> >();
+ connect( aModel, SIGNAL(indexesDropped(QList<QPersistentModelIndex>)),
+ this, SLOT(selectIndexes(QList<QPersistentModelIndex>)), Qt::QueuedConnection );
+ }
+
+void FieldsView::selectIndexes( QList<QPersistentModelIndex> aIndexes )
+ {
+ selectionModel()->clearSelection();
+ foreach( QPersistentModelIndex pIndex, aIndexes )
+ selectionModel()->select( pIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows );
+ }