Commit fd026a12 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

EffectStack: Allow effect removal.

parent 2c41eef6
......@@ -61,6 +61,19 @@ EffectInstanceListModel::data( const QModelIndex &index, int role ) const
}
}
bool
EffectInstanceListModel::removeRows( int row, int count, const QModelIndex& index /*= QModelIndex()*/ )
{
if ( count != 1 )
return false;
if ( row < 0 || row >= m_list->size() )
return false;
beginRemoveRows( index, row, row );
m_list->removeAt( row );
endRemoveRows();
return true;
}
void
EffectInstanceListModel::moveUp( const QModelIndex &index )
{
......
......@@ -33,6 +33,7 @@ class EffectInstanceListModel : public QAbstractListModel
EffectInstanceListModel( EffectsEngine::EffectList *list );
virtual qint32 rowCount( const QModelIndex &parent ) const;
virtual QVariant data( const QModelIndex &index, int role ) const;
virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
void moveUp( const QModelIndex &index );
void moveDown( const QModelIndex &index );
......
......@@ -38,6 +38,7 @@ EffectStack::EffectStack( EffectsEngine::EffectList *list, QWidget *parent ):
this, SLOT( selectedChanged( QModelIndex ) ) );
connect( m_ui->upButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
connect( m_ui->downButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
connect( m_ui->removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) );
}
EffectStack::~EffectStack()
......@@ -67,3 +68,9 @@ EffectStack::moveDown()
if ( m_ui->list->currentIndex().row() < m_model->rowCount( QModelIndex() ) - 1 )
m_ui->list->setCurrentIndex( m_ui->list->currentIndex().sibling( m_ui->list->currentIndex().row() + 1, 0 ) );
}
void
EffectStack::remove()
{
m_model->removeRow( m_ui->list->currentIndex().row() );
}
......@@ -48,6 +48,7 @@ class EffectStack : public QDialog
void selectedChanged( const QModelIndex &index );
void moveUp();
void moveDown();
void remove();
private:
Ui::EffectStack *m_ui;
......
......@@ -49,6 +49,17 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../resources.qrc">
<normaloff>:/images/remove</normaloff>:/images/remove</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment