bugfix: item drop in some area which not accept drop event and respond nothing to the drop event cause item missing

Change-Id: I96dcdb0e4dff297edcdd135650c7e4bc74d854da
This commit is contained in:
杨万青 2015-08-27 09:53:08 +08:00
parent a0e2337616
commit a1dbbe2876
Notes: Deepin Code Review 2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: <mr.asianwang@gmail.com>
Submitted-by: <mr.asianwang@gmail.com>
Submitted-at: Thu, 27 Aug 2015 13:35:56 +0800
Reviewed-on: https://cr.deepin.io/6615
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 22 additions and 0 deletions

View File

@ -5,6 +5,9 @@ DockLayout::DockLayout(QWidget *parent) :
QWidget(parent)
{
this->setAttribute(Qt::WA_TranslucentBackground);
this->installEventFilter(this);
this->setMouseTracking(true);
}
void DockLayout::addItem(AbstractDockItem *item)
@ -175,6 +178,24 @@ void DockLayout::relayout()
emit contentsWidthChange();
}
//for handle item drop in some area which not accept drop event and respond nothing to the drop event
bool DockLayout::eventFilter(QObject *obj, QEvent *event)
{
switch (event->type()) {
case QEvent::MouseMove:
case QEvent::Enter:
case QEvent::Leave:
if (m_dragItemMap.isEmpty())
break;
restoreTmpItem();
emit itemDropped();
break;
default:
break;
}
return QWidget::eventFilter(obj, event);
}
void DockLayout::dragEnterEvent(QDragEnterEvent *event)
{
event->setDropAction(Qt::MoveAction);

View File

@ -51,6 +51,7 @@ public slots:
void relayout();
protected:
bool eventFilter(QObject *obj, QEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);