From fd41ff4ab91d95c1ad505ca5b53697963fdf14b2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 6 Jan 2015 21:49:48 -0200 Subject: [PATCH] Start to make it possible to move columns around Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 21 +++++++++++++++++++++ qt-ui/divelogimportdialog.h | 1 + 2 files changed, 22 insertions(+) diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index d5fcd40a9..963c75710 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -211,6 +211,27 @@ void ColumnNameResult::setColumnValues(QList columns) endInsertRows(); } +void ColumnDropCSVView::mousePressEvent(QMouseEvent *press) +{ + QModelIndex atClick = indexAt(press->pos()); + if (!atClick.isValid() || atClick.row()) + return; + + QRect indexRect = visualRect(atClick); + QPixmap pix(indexRect.width(), indexRect.height()); + pix.fill(QColor(0,0,0,0)); + render(&pix, QPoint(0, 0),QRegion(indexRect)); + + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + mimeData->setData(subsurface_mimedata, atClick.data().toByteArray()); + drag->setPixmap(pix); + drag->setMimeData(mimeData); + if (drag->exec() != Qt::IgnoreAction){ + // Do stuff here. + } +} + DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDialog(parent), selector(true), ui(new Ui::DiveLogImportDialog) diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h index 8dc260a7d..0043f3ff2 100644 --- a/qt-ui/divelogimportdialog.h +++ b/qt-ui/divelogimportdialog.h @@ -58,6 +58,7 @@ class ColumnDropCSVView : public QTableView { public: ColumnDropCSVView(QWidget *parent); protected: + void mousePressEvent(QMouseEvent *press); void dragLeaveEvent(QDragLeaveEvent *leave); void dragEnterEvent(QDragEnterEvent *event); void dragMoveEvent(QDragMoveEvent *event);