ResourceBrowser: trigger default action on double click
Connect to QTreeView::doubleClicked() signal in order to trigger a default action. For example projects now can be loaded via simple double click. 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 triggerDefaultAction( const QModelIndex & _idx );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -110,6 +110,10 @@ ResourceBrowser::ResourceBrowser( QWidget * _parent ) :
|
||||
connect( m_treeView,
|
||||
SIGNAL( clicked( const QModelIndex & ) ),
|
||||
this, SLOT( stopItemPreview( const QModelIndex & ) ) );
|
||||
connect( m_treeView,
|
||||
SIGNAL( doubleClicked( const QModelIndex & ) ),
|
||||
this,
|
||||
SLOT( triggerDefaultAction( const QModelIndex & ) ) );
|
||||
|
||||
PianoView * pianoView = new PianoView( contentParent() );
|
||||
pianoView->setModel( m_previewer.pianoModel() );
|
||||
@@ -244,6 +248,40 @@ void ResourceBrowser::stopItemPreview( const QModelIndex & _idx )
|
||||
|
||||
|
||||
|
||||
void ResourceBrowser::triggerDefaultAction( const QModelIndex & _idx )
|
||||
{
|
||||
ResourceItem * item = m_treeModel.item( _idx );
|
||||
Actions action = NumActions;
|
||||
switch( item->type() )
|
||||
{
|
||||
case ResourceItem::TypeSample:
|
||||
action = LoadInNewTrackBBEditor;
|
||||
break;
|
||||
case ResourceItem::TypePreset:
|
||||
case ResourceItem::TypePluginSpecificPreset:
|
||||
case ResourceItem::TypePlugin:
|
||||
case ResourceItem::TypeSoundFont:
|
||||
action = LoadInNewTrackSongEditor;
|
||||
break;
|
||||
case ResourceItem::TypeProject:
|
||||
action = LoadProject;
|
||||
break;
|
||||
case ResourceItem::TypeForeignProject:
|
||||
case ResourceItem::TypeMidiFile:
|
||||
action = ImportFile;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( action != NumActions )
|
||||
{
|
||||
triggerAction( action, item );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ResourceBrowser::updateFilterStatus()
|
||||
{
|
||||
m_filterStatusLabel->setText( QString( "%1/%2" ).
|
||||
|
||||
Reference in New Issue
Block a user