fixed crash when adding an effect although none is selected and improved overall usability

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@954 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-05-04 22:33:27 +00:00
parent 43638ae14f
commit 23e1a368bd
4 changed files with 43 additions and 28 deletions

View File

@@ -125,7 +125,10 @@ void effectSelectDialog::setSelection( const effectKey & _selection )
void effectSelectDialog::selectPlugin( void )
{
accept();
if( m_currentSelection.isValid() )
{
accept();
}
}
@@ -194,6 +197,8 @@ effectListWidget::effectListWidget( QWidget * _parent ) :
m_filterEdit = new QLineEdit( this );
connect( m_filterEdit, SIGNAL( textChanged( const QString & ) ),
&m_model, SLOT( setFilterRegExp( const QString & ) ) );
connect( m_filterEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( updateSelection() ) );
m_pluginList = new QListView( this );
m_pluginList->setModel( &m_model );
@@ -228,11 +233,7 @@ effectListWidget::effectListWidget( QWidget * _parent ) :
vboxl->addWidget( m_pluginList );
vboxl->addWidget( groupbox );
if( m_sourceModel.rowCount() > 0 )
{
// m_pluginList->setCurrentRow( 0 );
//rowChanged( 0 );
}
updateSelection();
}
@@ -253,10 +254,15 @@ void effectListWidget::rowChanged( const QModelIndex & _idx,
if( m_model.mapToSource( _idx ).row() < 0 )
{
return;
// invalidate current selection
m_currentSelection =
plugin::descriptor::subPluginFeatures::key();
}
else
{
m_currentSelection =
m_effectKeys[m_model.mapToSource( _idx ).row()];
}
m_currentSelection = m_effectKeys[m_model.mapToSource( _idx ).row()];
if( m_currentSelection.desc &&
m_currentSelection.desc->sub_plugin_features )
{
@@ -286,6 +292,7 @@ void effectListWidget::rowChanged( const QModelIndex & _idx,
void effectListWidget::onDoubleClicked( const QModelIndex & )
{
emit( doubleClicked( m_currentSelection ) );
@@ -294,22 +301,19 @@ void effectListWidget::onDoubleClicked( const QModelIndex & )
void effectListWidget::onAddButtonReleased()
void effectListWidget::updateSelection( void )
{
emit( addPlugin( m_currentSelection ) );
// no valid selection anymore due to changed filter?
if( m_pluginList->selectionModel()->selection().size() <= 0 )
{
// then select our first item
m_pluginList->selectionModel()->select( m_model.index( 0, 0 ),
QItemSelectionModel::ClearAndSelect );
rowChanged( m_model.index( 0, 0 ), QModelIndex() );
}
}
void effectListWidget::resizeEvent( QResizeEvent * )
{
//m_descriptionWidget->setFixedWidth( width() - 40 );
}
#include "effect_select_dialog.moc"
#endif