ResourceBrowser: stop preview when drag operation starts

Make sure preview is stopped as soon as a drag operation starts. This
is done by overloading QAbstractItemView::startDrag() and emit a signal
from there which is connected to an according slot in ResourceBrowser.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-06-23 00:13:40 +02:00
parent 65b044c5c1
commit 75a45cca5f
4 changed files with 34 additions and 2 deletions

View File

@@ -110,6 +110,11 @@ ResourceBrowser::ResourceBrowser( QWidget * _parent ) :
connect( m_treeView,
SIGNAL( clicked( const QModelIndex & ) ),
this, SLOT( stopItemPreview( const QModelIndex & ) ) );
// setup a direct connection so preview is instantly stopped when
// drag operation begins
connect( m_treeView,
SIGNAL( dragStarted() ),
this, SLOT( stopPreview() ), Qt::DirectConnection );
connect( m_treeView,
SIGNAL( doubleClicked( const QModelIndex & ) ),
this,
@@ -240,7 +245,15 @@ void ResourceBrowser::startItemPreview( const QModelIndex & _idx )
void ResourceBrowser::stopItemPreview( const QModelIndex & _idx )
void ResourceBrowser::stopItemPreview( const QModelIndex & )
{
stopPreview();
}
void ResourceBrowser::stopPreview()
{
m_previewer.stopPreview();
}

View File

@@ -72,4 +72,13 @@ void ResourceTreeView::updateFilter( void )
void ResourceTreeView::startDrag( Qt::DropActions supportedActions )
{
emit dragStarted();
QTreeView::startDrag( supportedActions );
}
#include "moc_ResourceTreeView.cxx"