Make it possible to move from top to bottom

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-01-06 22:24:46 -02:00 committed by Dirk Hohndel
parent 59fc5cecb7
commit 1ba08e2fec
2 changed files with 35 additions and 0 deletions

View file

@ -103,6 +103,37 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
}
}
void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
{
Q_UNUSED(leave);
}
void ColumnNameView::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
}
void ColumnNameView::dragMoveEvent(QDragMoveEvent *event)
{
QModelIndex curr = indexAt(event->pos());
if (!curr.isValid() || curr.row() != 0)
return;
event->acceptProposedAction();
}
void ColumnNameView::dropEvent(QDropEvent *event)
{
const QMimeData *mimeData = event->mimeData();
if (mimeData->data(subsurface_mimedata).count()) {
if (event->source() != this) {
event->acceptProposedAction();
QVariant value = QString(mimeData->data(subsurface_mimedata));
model()->insertRow(model()->rowCount());
model()->setData(model()->index(model()->rowCount()-1, 0), value);
}
}
}
ColumnDropCSVView::ColumnDropCSVView(QWidget *parent)
{
setAcceptDrops(true);

View file

@ -50,6 +50,10 @@ public:
ColumnNameView(QWidget *parent);
protected:
void mousePressEvent(QMouseEvent *press);
void dragLeaveEvent(QDragLeaveEvent *leave);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private:
int currentDraggedIndex;
};