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

EffectsListView: Open a EffectWidget on double clicking on an effect.

parent 5c1af03d
#include "EffectsListView.h"
#include "EffectsEngine/EffectsEngine.h"
#include "EffectsEngine.h"
#include "EffectWidget.h"
#include <QApplication>
#include <QDialog>
#include <QMouseEvent>
#include <QStandardItem>
#include <QVBoxLayout>
#include <QtDebug>
......@@ -16,7 +19,8 @@ EffectsListView::EffectsListView(QWidget *parent) :
this,
SLOT( effectAdded(Effect*, const QString&, Effect::Type) ) );
setModel( m_model );
setEditTriggers( QListView::NoEditTriggers );
connect( this, SIGNAL( activated( QModelIndex ) ),
this, SLOT( effectActivated( QModelIndex ) ) );
}
void
......@@ -57,3 +61,19 @@ EffectsListView::mouseMoveEvent( QMouseEvent *event )
drag->setMimeData( mimeData );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
void
EffectsListView::effectActivated( const QModelIndex &index ) const
{
if ( index.isValid() == false )
return ;
Effect *effect = EffectsEngine::getInstance()->effect( m_model->data( index, Qt::DisplayRole ).toString() );
QDialog *dialog = new QDialog();
QVBoxLayout *layout = new QVBoxLayout( dialog );
EffectWidget *wid = new EffectWidget( dialog );
layout->addWidget( wid );
wid->setEffect( effect );
dialog->setWindowTitle( tr( "%1 informations" ).arg( effect->name() ) );
dialog->exec();
delete dialog;
}
......@@ -26,6 +26,8 @@ class EffectsListView : public QListView
public slots:
void effectAdded( Effect *effect, const QString& name,
Effect::Type type );
private slots:
void effectActivated( const QModelIndex& index ) const;
};
#endif // EFFECTLISTVIEW_H
......@@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="filterTab">
<attribute name="title">
......@@ -26,6 +26,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="EffectsListView" name="filterList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
......@@ -40,6 +43,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="EffectsListView" name="effectsList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
......
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