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

QContentSortCriteria Class Reference
[QtBaseModule]

The QContentSortCriteria class defines the attributes and order a QContentSet should be sorted by. More...

    #include <QContentSortCriteria>

Public Types

Public Functions


Detailed Description

The QContentSortCriteria class defines the attributes and order a QContentSet should be sorted by.

The sorting criteria is an ordered list of QContent attributes and sort orders which can be used to compare two QContents. When a comparison is made between QContents each attribute in the sorting criteria is compared in order until one that is not equal is found and the result of that comparison is returned. If all comparisons are equal the sorting criteria will fall back to the user visible name, and then the content id in ascending order to make a comparison. A comparison with a null QContent will always return the null QContent as the lesser one.

When sorting by a property it is also necessary to provide an attribute scope to specify the group and key of the property that are sorted on. The scope should be a string of the form [group]/[key]. Alternatively if the property belongs to the QContent::Property enumeration that may be used instead of an attribute.

Using the sort criteria a content set containing music sorted by artist, album, and track number could be created as below:

    QContentSet music;

    music.setCriteria( QContentFilter::mimeType( "audio/mpeg" ) );

    QContentSortCriteria sort;

    sort.addSort( QContentSortCriteria::Property, "none/Artist" );
    sort.addSort( QContentSortCriteria::Property, "none/Album" );
    sort.addSort( QContentSortCriteria::Property, "none/Track" );

    music.setSortCriteria( sort );

Member Type Documentation

enum QContentSortCriteria::Attribute

The Attribute enumeration defines an attribute of a QContent that a comparison should be made on.

ConstantValueDescription
QContentSortCriteria::Name0The user visible name of the content.
QContentSortCriteria::MimeType1The type of the content.
QContentSortCriteria::Property2A property of the content. The group and key for the property must be supplied as an scope of the sort as a string of the form [group]/[key]
QContentSortCriteria::FileName3The file name of the content.
QContentSortCriteria::LastUpdated4The time and date the content record was last updated.


Member Function Documentation

QContentSortCriteria::QContentSortCriteria ()

Constructs a null sort criteria.

QContentSortCriteria::QContentSortCriteria ( Attribute attribute, Qt::SortOrder order = Qt::AscendingOrder )

Constructs a sort criteria that sorts a set by an attribute in the given sort order.

QContentSortCriteria::QContentSortCriteria ( Attribute attribute, const QString & scope, Qt::SortOrder order = Qt::AscendingOrder )

Constructs a sort criteria that sorts a set by an attribute with a scope in the given sort order.

QContentSortCriteria::QContentSortCriteria ( QContent::Property property, Qt::SortOrder order = Qt::AscendingOrder )

Constructs a sort criteria that sorts a set by property in the given sort order.

QContentSortCriteria::QContentSortCriteria ( const QContentSortCriteria & other )

Constructs a copy of the sort criteria other.

QContentSortCriteria::~QContentSortCriteria ()

Destroys a sort criteria.

void QContentSortCriteria::addSort ( Attribute attribute, Qt::SortOrder order = Qt::AscendingOrder )

Adds an attribute to sort by in the given order to the end of the sort criteria.

void QContentSortCriteria::addSort ( Attribute attribute, const QString & scope, Qt::SortOrder order = Qt::AscendingOrder )

This is an overloaded member function, provided for convenience.

Adds an attribute with a scope to sort by in the given order to the end of the sort criteria.

void QContentSortCriteria::addSort ( QContent::Property property, Qt::SortOrder order = Qt::AscendingOrder )

This is an overloaded member function, provided for convenience.

Adds a property to sort by in the given order to the end of the sort criteria.

Attribute QContentSortCriteria::attribute ( int index ) const

Returns the attribute sorted by at the given index.

void QContentSortCriteria::clear ()

Removes all sorts from the sorting criteria.

int QContentSortCriteria::compare ( const QContent & left, const QContent & right ) const

Compares the left and right contents using the sorting criteria and returns a negative integer if the left is less than the right, a positive integer if the left is greater than the right, and zero if they are equivalent.

bool QContentSortCriteria::greaterThan ( const QContent & left, const QContent & right ) const

Compares the left and right contents using the sorting criteria and returns true if the left is greater than the right and false otherwise.

bool QContentSortCriteria::lessThan ( const QContent & left, const QContent & right ) const

Compares the left and right contents using the sorting criteria and returns true if the left is less than the right and false otherwise.

Qt::SortOrder QContentSortCriteria::order ( int index ) const

Returns the order the attribute at the given index is sorted by.

QString QContentSortCriteria::scope ( int index ) const

Returns the scope of the attribute sorted by at the given index.

int QContentSortCriteria::sortCount () const

Returns the number of attributes the sorting criteria sorts on.

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

Compares other to a sort criteria. Returns true if it is not equal; false otherwise.

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

Assigns the value of other to a sort criteria.

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

Compares other to a sort criteria. Returns true if it is equal; false otherwise.


Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3