filterdemo.cpp Example File
content/filtering/filterdemo.cpp
#include "filterdemo.h"
#include <QSoftMenuBar>
#include <QKeyEvent>
FilterDemo::FilterDemo( QWidget *parent, Qt::WindowFlags flags )
: QListView( parent )
, index( 0 )
{
setWindowFlags( flags );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setModel( new QContentSetModel( &contentSet, this ) );
QSoftMenuBar::menuFor( this );
QSoftMenuBar::setLabel( this, Qt::Key_Select, QSoftMenuBar::NoLabel );
QSoftMenuBar::setLabel( this, Qt::Key_Back, QSoftMenuBar::Next );
nextFilter();
}
void FilterDemo::keyPressEvent( QKeyEvent *event )
{
if ( event->key() == Qt::Key_Back && nextFilter() ) {
event->accept();
} else {
QListView::keyPressEvent( event );
}
}
bool FilterDemo::nextFilter()
{
switch( index++ )
{
case 0:
contentSet.setCriteria( QContentFilter( QContent::Application ) );
return true;
case 1:
contentSet.addCriteria( QContentFilter::Category, "Games", QContentFilter::And );
return true;
case 2:
contentSet.setCriteria( QContentFilter::MimeType, "image/jpeg" );
contentSet.addCriteria( QContentFilter::mimeType( "image/png" ), QContentFilter::Or );
contentSet.addCriteria( QContentFilter( QContent::Document ), QContentFilter::And );
return true;
case 3:
contentSet.addCriteria( QContentFilter( QContent::Application )
& QContentFilter::category( "Games" )
, QContentFilter::Or );
QSoftMenuBar::setLabel( this, Qt::Key_Back, QSoftMenuBar::Back );
return true;
default:
return false;
}
}
Copyright © 2009 Trolltech |
Trademarks |
Qt Extended 4.4.3 |