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:
@@ -63,6 +63,7 @@ private slots:
|
||||
void updateFilterStatus();
|
||||
void startItemPreview( const QModelIndex & _idx );
|
||||
void stopItemPreview( const QModelIndex & _idx );
|
||||
void stopPreview();
|
||||
void triggerDefaultAction( const QModelIndex & _idx );
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ResourceTreeView.h - view for ResourceTreeModel
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -41,11 +41,20 @@ public slots:
|
||||
void setFilter( const QString & _s );
|
||||
void updateFilter( void );
|
||||
|
||||
|
||||
protected:
|
||||
virtual void startDrag( Qt::DropActions supportedActions );
|
||||
|
||||
|
||||
private:
|
||||
ResourceTreeModel * m_tm;
|
||||
|
||||
QString m_lastFilter;
|
||||
|
||||
|
||||
signals:
|
||||
void dragStarted();
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -72,4 +72,13 @@ void ResourceTreeView::updateFilter( void )
|
||||
|
||||
|
||||
|
||||
void ResourceTreeView::startDrag( Qt::DropActions supportedActions )
|
||||
{
|
||||
emit dragStarted();
|
||||
|
||||
QTreeView::startDrag( supportedActions );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_ResourceTreeView.cxx"
|
||||
|
||||
Reference in New Issue
Block a user