changed list-widget to be a list-view and added a line-edit for filtering the list

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@892 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-04-06 17:24:36 +00:00
parent 1ffbe12e80
commit 0429fe86e3
2 changed files with 59 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
/*
* effect_select_dialog.h - dialog to choose effect plugin
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -27,11 +27,15 @@
#define _EFFECT_SELECT_DIALOG_H
#include <QtGui/QDialog>
#include <QtGui/QListWidget>
#include <QtGui/QSortFilterProxyModel>
#include <QtGui/QStandardItemModel>
#include "effect_chain.h"
#include "effect.h"
class QLineEdit;
class QListView;
class QScrollArea;
@@ -81,17 +85,20 @@ protected:
protected slots:
void rowChanged( int _plugin );
void onAddButtonReleased();
void onDoubleClicked( QListWidgetItem * _item );
void rowChanged( const QModelIndex &, const QModelIndex & );
void onAddButtonReleased( void );
void onDoubleClicked( const QModelIndex & );
private:
QVector<plugin::descriptor> m_pluginDescriptors;
effectKeyList m_effectKeys;
effectKey m_currentSelection;
QListWidget * m_pluginList;
QLineEdit * m_filterEdit;
QListView * m_pluginList;
QStandardItemModel m_sourceModel;
QSortFilterProxyModel m_model;
QScrollArea * m_scrollArea;
QWidget * m_descriptionWidget;

View File

@@ -27,6 +27,8 @@
#include <QtGui/QGroupBox>
#include <QtGui/QLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QListView>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
@@ -48,7 +50,7 @@ effectSelectDialog::effectSelectDialog( QWidget * _parent ) :
vlayout->setMargin( 10 );
effectListWidget * elist = new effectListWidget( this );
elist->setMinimumSize( 500, 400 );
elist->setMinimumSize( 540, 400 );
connect( elist, SIGNAL( doubleClicked( const effectKey & ) ),
this, SLOT( selectPlugin() ) );
connect( elist, SIGNAL( highlighted( const effectKey & ) ),
@@ -64,7 +66,7 @@ effectSelectDialog::effectSelectDialog( QWidget * _parent ) :
QPushButton * select_btn = new QPushButton(
embed::getIconPixmap( "add" ),
tr( "Add" ), buttons );
connect( select_btn, SIGNAL( clicked() ),
connect( select_btn, SIGNAL( activated() ),
this, SLOT( selectPlugin() ) );
/* QPushButton * ports_btn = new QPushButton(
@@ -151,6 +153,8 @@ void effectSelectDialog::selectPlugin( void )
effectListWidget::effectListWidget( QWidget * _parent ) :
QWidget( _parent ),
m_sourceModel(),
m_model(),
m_descriptionWidget( NULL )
{
plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors );
@@ -192,12 +196,35 @@ effectListWidget::effectListWidget( QWidget * _parent ) :
"" );
}
m_pluginList = new QListWidget( this );
m_pluginList->insertItems( 0, plugin_names );
connect( m_pluginList, SIGNAL( currentRowChanged( int ) ),
SLOT( rowChanged( int ) ) );
connect( m_pluginList, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ),
SLOT( onDoubleClicked( QListWidgetItem * ) ) );
int row = 0;
for( QStringList::iterator it = plugin_names.begin();
it != plugin_names.end(); ++it )
{
m_sourceModel.setItem( row, 0, new QStandardItem( *it ) );
++row;
}
m_model.setSourceModel( &m_sourceModel );
m_model.setFilterCaseSensitivity( Qt::CaseInsensitive );
m_filterEdit = new QLineEdit( this );
connect( m_filterEdit, SIGNAL( textChanged( const QString & ) ),
&m_model, SLOT( setFilterRegExp( const QString & ) ) );
m_pluginList = new QListView( this );
m_pluginList->setModel( &m_model );
QItemSelectionModel * sm = new QItemSelectionModel( &m_model );
m_pluginList->setSelectionModel( sm );
m_pluginList->setSelectionBehavior( QAbstractItemView::SelectRows );
m_pluginList->setSelectionMode( QAbstractItemView::SingleSelection );
m_pluginList->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
connect( sm, SIGNAL( currentRowChanged( const QModelIndex &,
const QModelIndex & ) ),
SLOT( rowChanged( const QModelIndex &,
const QModelIndex & ) ) );
connect( m_pluginList, SIGNAL( doubleClicked( const QModelIndex & ) ),
SLOT( onDoubleClicked( const QModelIndex & ) ) );
QGroupBox * groupbox = new QGroupBox( tr( "Description" ), this );
groupbox->setFixedHeight( 200 );
@@ -214,13 +241,14 @@ effectListWidget::effectListWidget( QWidget * _parent ) :
QVBoxLayout * vboxl = new QVBoxLayout( this );
vboxl->setMargin( 0 );
vboxl->setSpacing( 10 );
vboxl->addWidget( m_filterEdit );
vboxl->addWidget( m_pluginList );
vboxl->addWidget( groupbox );
if( m_pluginList->count() > 0 )
if( m_sourceModel.rowCount() > 0 )
{
m_pluginList->setCurrentRow( 0 );
rowChanged( 0 );
// m_pluginList->setCurrentRow( 0 );
//rowChanged( 0 );
}
}
@@ -234,12 +262,13 @@ effectListWidget::~effectListWidget()
void effectListWidget::rowChanged( int _pluginIndex )
void effectListWidget::rowChanged( const QModelIndex & _idx,
const QModelIndex & )
{
delete m_descriptionWidget;
m_descriptionWidget = NULL;
m_currentSelection = m_effectKeys[_pluginIndex];
m_currentSelection = m_effectKeys[_idx.row()];
if( m_currentSelection.desc &&
m_currentSelection.desc->sub_plugin_features )
{
@@ -253,7 +282,8 @@ void effectListWidget::rowChanged( int _pluginIndex )
m_currentSelection.desc->sub_plugin_features->
fillDescriptionWidget( m_descriptionWidget,
&m_currentSelection );
foreach( QWidget * w, m_descriptionWidget->findChildren<QWidget *>() )
foreach( QWidget * w,
m_descriptionWidget->findChildren<QWidget *>() )
{
if( w->parent() == m_descriptionWidget )
{
@@ -268,8 +298,7 @@ void effectListWidget::rowChanged( int _pluginIndex )
void effectListWidget::onDoubleClicked( QListWidgetItem * _item )
void effectListWidget::onDoubleClicked( const QModelIndex & )
{
emit( doubleClicked( m_currentSelection ) );
}