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:
@@ -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:
|
||||
|
||||
@@ -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/>
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user