QuickLoadDialog: implemented resource type filter

One can filter resource types now using the combobox. It's also possible
to pass a certain ResourceItem::Type to the QuickLoadDialog constructor
so the according type is preselected.
This commit is contained in:
Tobias Doerffel
2009-08-22 01:17:03 +02:00
parent 1c56bf4e55
commit 90e0cab629
3 changed files with 45 additions and 5 deletions

View File

@@ -27,15 +27,22 @@
#include <QtGui/QDialog>
#include "ResourceItem.h"
namespace Ui { class QuickLoadDialog; }
class ResourceListModel;
class QuickLoadDialog : public QDialog
{
Q_OBJECT
public:
QuickLoadDialog( QWidget * _parent );
~QuickLoadDialog();
QuickLoadDialog( QWidget * _parent, ResourceItem::Type _typeFilter =
ResourceItem::TypeUnknown );
virtual ~QuickLoadDialog();
private slots:
void setTypeFilter( int );
private:

View File

@@ -40,13 +40,18 @@
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<widget class="QComboBox" name="resourceTypeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>All types</string>
</property>
</item>
</widget>
</item>
</layout>
@@ -79,7 +84,7 @@
<tabstops>
<tabstop>filterEdit</tabstop>
<tabstop>resourceListView</tabstop>
<tabstop>comboBox</tabstop>
<tabstop>resourceTypeComboBox</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>

View File

@@ -30,13 +30,30 @@
QuickLoadDialog::QuickLoadDialog( QWidget * _parent ) :
QuickLoadDialog::QuickLoadDialog( QWidget * _parent,
ResourceItem::Type _typeFilter ) :
QDialog( _parent ),
ui( new Ui::QuickLoadDialog ),
m_listModel( new ResourceListModel( engine::mergedResourceDB(), this ) )
{
ui->setupUi( this );
// setup type combobox + type filtering
for( int i = ResourceItem::TypeUnknown+1; i < ResourceItem::NumTypes; ++i )
{
ui->resourceTypeComboBox->addItem(
ResourceItem::descriptiveTypeName(
static_cast<ResourceItem::Type>( i ) ) );
}
connect( ui->resourceTypeComboBox, SIGNAL( currentIndexChanged( int ) ),
this, SLOT( setTypeFilter( int ) ) );
if( _typeFilter != ResourceItem::TypeUnknown )
{
ui->resourceTypeComboBox->setCurrentIndex( _typeFilter );
}
// setup list view to display our model
ui->resourceListView->setModel( m_listModel );
ui->resourceListView->selectionModel()->select(
@@ -57,3 +74,14 @@ QuickLoadDialog::~QuickLoadDialog()
}
void QuickLoadDialog::setTypeFilter( int _type )
{
m_listModel->setTypeFilter( static_cast<ResourceItem::Type>( _type ) );
}
#include "moc_QuickLoadDialog.cxx"