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

QCategorySelector Class Reference
[QtBaseModule]

The QCategorySelector widget allows users to select categories for filtering or for applying to an item. More...

    #include <QCategorySelector>

Inherits QWidget.

Public Types

Public Functions

Public Slots

Signals

Additional Inherited Members


Detailed Description

The QCategorySelector widget allows users to select categories for filtering or for applying to an item.

QCategorySelector is a widget that shows categories the user can choose from. Its appearance and behavior are determined by flags given to the constructor. Control over the categories that are visible is achieved via the select...() functions.

QCategorySelector automatically updates when the system's categories are changed. It provides an interface for the user to add/edit/delete user categories.

QCategorySelector is typically used as a QCategorySelector::Filter or QCategorySelector::Editor;

Here's an example of using it as a filter.

    MyWidget::MyWidget()
    {
        QCategorySelector *sel = new QCategorySelector( "myappscope", QCategorySelector::Filter );
        connect( sel, SIGNAL(filterSelected(QCategoryFilter)),
                 this, SLOT(filterCategories(QCategoryFilter)) );
        QSettings settings("mycompany", "myapp");
        QCategoryFilter f;
        f.readConfig( settings, "filter" );
        sel->selectFilter( f );
    }

    void MyWidget::filterCategories( const QCategoryFilter &filter )
    {
        QSettings settings("mycompany", "myapp");
        filter.writeConfig( settings, "filter" );
        foreach ( item, itemList )
            item->setVisible( filter.accepted( item->categories() ) );
    }

Here's an example of using QCategorySelector an editor.

    MyWidget::MyWidget( MyRecord *item )
    {
        QCategorySelector *sel = new QCategorySelector( "myappscope", QCategorySelector::Editor );
        sel->selectCategories( item->categories() );
        connect( sel, SIGNAL(categoriesSelected(QList<QString>)),
                 item, SLOT(setCategories(QList<QString>)) );
    }

See also Categories.


Member Type Documentation

enum QCategorySelector::ContentFlag
flags QCategorySelector::ContentFlags

ConstantValueDescription
QCategorySelector::IncludeAll0x04Include the All categories option.
QCategorySelector::IncludeUnfiled0x08Include the Unfiled categories option.
QCategorySelector::SingleSelection0x80Allow selection of a single category. The default is to allow combinations of categories.
QCategorySelector::ListView0x10Display as a list view.
QCategorySelector::ComboView0x20Display as a combo box. Note that this will encourage exclusive selection of categories.
QCategorySelector::DialogView0x40Display as a button that opens a dialog containing a list view.
QCategorySelector::FilterIncludeAll | IncludeUnfiledAlias for IncludeAll|IncludeUnfiled.
QCategorySelector::EditorIncludeUnfiledAlias for IncludeUnfiled.
QCategorySelector::ViewMaskListView | ComboView | DialogViewMasks the view selection flags.

The list view looks like this.

[Missing image qcategoryselector-list.png]

The combo box looks like this.

[Missing image qcategoryselector-combo-down.png]

[Missing image qcategoryselector-combo-up.png]

The button looks like this.

[Missing image qcategoryselector-button.png]

The ContentFlags type is a typedef for QFlags<ContentFlag>. It stores an OR combination of ContentFlag values.


Member Function Documentation

QCategorySelector::QCategorySelector ( QWidget * parent = 0 )

Constructs a QCategorySelector as an editor widget with the given parent.

QCategorySelector::QCategorySelector ( const QString & scope, ContentFlags f = Editor, QWidget * parent = 0 )

Constructs a QCategorySelector with the given parent. Unless it is null, scope limits the categories that can be seen. The flags in f determine the apperance and behavior of the QCategorySelector.

QCategorySelector::~QCategorySelector ()   [virtual]

Destroys a QCategorySelector.

void QCategorySelector::categoriesSelected ( const QList<QString> & list )   [signal]

This signal is emitted when the selected categories changes. The selected categories are indicated by list.

Note that this function does not indicate if All or Unfiled is selected. Use filterSelected() to determine if these items are selected.

void QCategorySelector::filterSelected ( const QCategoryFilter & filter )   [signal]

This signal is emitted when the selected categories changes. The selected categories are indicated by filter.

See also QCategoryFilter::requiredCategories().

void QCategorySelector::selectAll ()   [slot]

Selects the All entry (all categories are selected).

void QCategorySelector::selectCategories ( const QString & categoryids )   [slot]

Selects the categories with identifiers in the comma-separated list categoryids.

void QCategorySelector::selectCategories ( const QStringList & categoryids )   [slot]

This is an overloaded member function, provided for convenience.

Selects the categories with identifiers in list categoryids.

void QCategorySelector::selectFilter ( const QCategoryFilter & filter )   [slot]

Selects the categories specified by filter.

void QCategorySelector::selectUnfiled ()   [slot]

Selects the Unfiled entry (no categories are selected).

QStringList QCategorySelector::selectedCategories () const

Returns the list of selected categories.

Note that this function does not indicate if All or Unfiled is selected. Use selectedFilter() to determine if these items are selected.

QCategoryFilter QCategorySelector::selectedFilter () const

Returns the QCategoryFilter that indicates the selected categories.

See also QCategoryFilter::requiredCategories().


Copyright © 2009 Nokia Trademarks
Qt Extended 4.4.3