Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

QCategoryFilter Class Reference
[QtBaseModule]

The QCategoryFilter class allows consistent filtering of records or objects that have a set of categories assigned. More...

    #include <QCategoryFilter>

Public Types

Public Functions


Detailed Description

The QCategoryFilter class allows consistent filtering of records or objects that have a set of categories assigned.

QCategoryFilter is used to represent selected categories. Unlike a list of category ids, QCategoryFilter handles the All and Unfiled cases so it allows unambiguous behaviour when new categories are added to the system. It is most useful when filtering items by category to create a QCategoryFilter and use the accepted() function.

See also Categories.


Member Type Documentation

enum QCategoryFilter::FilterType

ConstantValueDescription
QCategoryFilter::List0Only accepts category sets that contain all of the required categories.
QCategoryFilter::Unfiled1Only accepts empty category sets.
QCategoryFilter::All2Accepts all category sets.


Member Function Documentation

QCategoryFilter::QCategoryFilter ()

Constructs a QCategoryFilter object. By default this object will accept all category sets.

QCategoryFilter::QCategoryFilter ( FilterType t )

Constructs a QCategoryFilter object of type t.

See also FilterType.

QCategoryFilter::QCategoryFilter ( const QList<QString> & set )

Constructs a QCategoryFilter object that only accepts category sets containing all of the category ids listed in set. The type is set to QCategoryFilter::List.

QCategoryFilter::QCategoryFilter ( const QString & c )

Constructs a QCategoryFilter object that only accepts category sets containing category id c. The type is set to QCategoryFilter::List.

QCategoryFilter::QCategoryFilter ( const QCategoryFilter & other )

Constructs a QCategoryFilter object as a copy of other.

QCategoryFilter::~QCategoryFilter ()

Destroys a QCategoryFilter object.

bool QCategoryFilter::acceptAll () const

Returns true if the QCategoryFilterObject accepts all category sets. Otherwise returns false.

See also QCategoryFilter::requiredCategories().

bool QCategoryFilter::acceptUnfiledOnly () const

Returns true if the QCategoryFilterObject only accepts empty category sets. Otherwise returns false.

bool QCategoryFilter::accepted ( const QList<QString> & list ) const

Returns true if the set of categories described by list is accepted by the QCategoryFilter object. Otherwise returns false.

QString QCategoryFilter::label ( const QString & scope = QString() ) const

Returns a translated string that briefly describes the QCategoryFilter object. If specified, scope specifies the scope in which to search for the label.

This is useful when displaying a string describing the categories the QCategoryFilter allows.

    currentCategoryLabel->setText( catetoryFilter->label() );

void QCategoryFilter::readConfig ( const QSettings & c, const QString & key )

Reads the QCategoryFilter from field key in c.

    QSettings settings("mycompany", "myapp");
    QCategoryFilter filter;
    filter.readConfig(settings,"filter");

See also writeConfig().

QList<QString> QCategoryFilter::requiredCategories () const

Returns the list of categories that must be in a set for the set to be accepted. Note that this only returns a list of the QCategoryFilter object is of type QCategoryFilter::List. To get the list of categories corresponding to QCategoryFilter::All you must create a QCategoryManager.

    QStringList categories;
    if ( filter.acceptAll() )
        categories = QCategoryManager(scope).categoryIds();
    else
        categories = filter.requiredCategories(); // returns empty list for Unfiled

void QCategoryFilter::writeConfig ( QSettings & c, const QString & key ) const

Writes the QCategoryFilter to field key in c.

    QCategoryFilter filter("mycategory");
    QSettings settings("mycompany", "myapp");
    filter.writeConfig(settings,"filter");

See also readConfig().

bool QCategoryFilter::operator!= ( const QCategoryFilter & other ) const

Returns true if the QCategoryFilter object is not equivilent to other. Otherwise returns false.

QCategoryFilter & QCategoryFilter::operator= ( const QCategoryFilter & other )

Assigns the QCategoryFilter object to be a copy of other.

bool QCategoryFilter::operator== ( const QCategoryFilter & other ) const

Returns true if the QCategoryFilter object is equivilent to other. Otherwise returns false.


Copyright © 2009 Nokia Trademarks
Qt Extended 4.4.3