#include <QLayout>
#include <QListView>
#include <QPushButton>
+#include <QSortFilterProxyModel>
HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent )
QHBoxLayout* aListLayout = new QHBoxLayout();
myList = new QListView( this );
- myList->setModel( new HYDROGUI_ZLevelsModel );
+
+ HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel();
+ QSortFilterProxyModel* aFilteredModel = new QSortFilterProxyModel();
+ aFilteredModel->setSourceModel( aModel );
+ aFilteredModel->setFilterKeyColumn( 0 );
+ aFilteredModel->setFilterRole( HYDROGUI_VisibleRole );
+
+ myList->setModel( aFilteredModel );
myTop = new QPushButton( tr("TOP") );
myUp = new QPushButton( tr("UP") );
aDlgButtonsLayout->addWidget( myClose );
aDlgButtonsLayout->addStretch();
aMainLayout->addLayout( aDlgButtonsLayout );
+
+ connect( myAllObjects, SIGNAL( stateChanged( int ) ), this, SLOT( OnStateChanged() ) );
+
+ OnStateChanged();
}
HYDROGUI_ZLevelsDlg::~HYDROGUI_ZLevelsDlg()
void HYDROGUI_ZLevelsDlg::setObjects( const QList<QString>& theObjects )
{
- HYDROGUI_ZLevelsModel* aModel = dynamic_cast<HYDROGUI_ZLevelsModel*>( myList->model() );
- aModel->setObjects( theObjects );
-}
\ No newline at end of file
+ QSortFilterProxyModel* aFilterModel = dynamic_cast<QSortFilterProxyModel*>( myList->model() );
+ if( aFilterModel )
+ {
+ HYDROGUI_ZLevelsModel* aModel = dynamic_cast<HYDROGUI_ZLevelsModel*>( aFilterModel->sourceModel() );
+ if( aModel )
+ aModel->setObjects( theObjects );
+ }
+}
+
+void HYDROGUI_ZLevelsDlg::OnStateChanged()
+{
+ QSortFilterProxyModel* aFilterModel = dynamic_cast<QSortFilterProxyModel*>( myList->model() );
+ bool isAll = myAllObjects->isChecked();
+ QString anExpr = isAll ? "true|false" : "true";
+ aFilterModel->setFilterRegExp( anExpr );
+}
#include <QAbstractListModel>
#include <QPixmap>
+const int HYDROGUI_VisibleRole = Qt::UserRole + 1;
+
/**
* \class HYDROGUI_ZLevelsModel
* \brief The class representing custom list model for the Z levels
public:
HYDROGUI_ZLevelsModel( QObject* theParent = 0 );
- ~HYDROGUI_ZLevelsModel();
+ virtual ~HYDROGUI_ZLevelsModel();
virtual QVariant data( const QModelIndex &theIndex, int theRole = Qt::DisplayRole ) const;