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

@@ -1,5 +1,11 @@
2008-05-04 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/effect_select_dialog.h:
* include/plugin.h:
* src/gui/effect_select_dialog.cpp:
fixed crash when adding an effect although none is selected and
improved overall usability
* plugins/organic/organic.cpp:
fixed knob-inheritance problems

View File

@@ -76,19 +76,14 @@ public:
signals:
void highlighted( const effectKey & _key );
void addPlugin( const effectKey & _key );
void doubleClicked( const effectKey & _key );
protected:
virtual void resizeEvent( QResizeEvent * );
protected slots:
void rowChanged( const QModelIndex &, const QModelIndex & );
void onAddButtonReleased( void );
void onDoubleClicked( const QModelIndex & );
void updateSelection( void );
private:
QVector<plugin::descriptor> m_pluginDescriptors;

View File

@@ -108,18 +108,28 @@ public:
user = l[1];
}
}
inline QString dumpBase64( void ) const
{
return( base64::encode(
QList<QVariant>()
<< name << user ) );
}
inline bool isValid( void ) const
{
return( desc != NULL &&
name != QString::null );
}
plugin::descriptor * desc;
QString name;
QVariant user;
};
typedef QList<key> keyList;
subPluginFeatures( plugin::PluginTypes _type ) :
m_type( _type )
{

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