• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk

  • Nepomuk
  • Utils
  • FacetModel
Public Types | Public Slots | Signals | Public Member Functions | List of all members
Nepomuk::Utils::FacetModel Class Reference
The Facet API

#include <Nepomuk/Utils/FacetModel>

Inheritance diagram for Nepomuk::Utils::FacetModel:
Inheritance graph
[legend]

Public Types

enum  CustomRoles { FacetRole = 235265643 }
 

Public Slots

void addFacet (Nepomuk::Utils::Facet *facet)
 
void clear ()
 
void clearSelection ()
 
Nepomuk::Query::Query extractFacetsFromQuery (const Nepomuk::Query::Query &query)
 
void setClientQuery (const Nepomuk::Query::Query &query)
 
void setFacets (const QList< Nepomuk::Utils::Facet * > &facets)
 

Signals

void queryTermChanged (const Nepomuk::Query::Term &term)
 

Public Member Functions

 FacetModel (QObject *parent=0)
 
 ~FacetModel ()
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
QList< Facet * > facets () const
 
Qt::ItemFlags flags (const QModelIndex &index) const
 
bool hasChildren (const QModelIndex &parent) const
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
QModelIndex parent (const QModelIndex &index) const
 
Query::Term queryTerm () const
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 
bool setData (const QModelIndex &index, const QVariant &value, int role)
 
- Public Member Functions inherited from QAbstractItemModel
 QAbstractItemModel (QObject *parent)
 
virtual  ~QAbstractItemModel ()
 
virtual QModelIndex buddy (const QModelIndex &index) const
 
virtual bool canFetchMore (const QModelIndex &parent) const
 
virtual int columnCount (const QModelIndex &parent) const =0
 
void columnsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void columnsInserted (const QModelIndex &parent, int start, int end)
 
void columnsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsRemoved (const QModelIndex &parent, int start, int end)
 
virtual QVariant data (const QModelIndex &index, int role) const =0
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 
virtual void fetchMore (const QModelIndex &parent)
 
bool hasIndex (int row, int column, const QModelIndex &parent) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const =0
 
bool insertColumn (int column, const QModelIndex &parent)
 
virtual bool insertColumns (int column, int count, const QModelIndex &parent)
 
bool insertRow (int row, const QModelIndex &parent)
 
virtual bool insertRows (int row, int count, const QModelIndex &parent)
 
virtual QMap< int, QVariant > itemData (const QModelIndex &index) const
 
void layoutAboutToBeChanged ()
 
void layoutChanged ()
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const
 
virtual QMimeData * mimeData (const QModelIndexList &indexes) const
 
virtual QStringList mimeTypes () const
 
void modelAboutToBeReset ()
 
void modelReset ()
 
virtual QModelIndex parent (const QModelIndex &index) const =0
 
bool removeColumn (int column, const QModelIndex &parent)
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent)
 
bool removeRow (int row, const QModelIndex &parent)
 
virtual bool removeRows (int row, int count, const QModelIndex &parent)
 
virtual void revert ()
 
const QHash< int, QByteArray > & roleNames () const
 
virtual int rowCount (const QModelIndex &parent) const =0
 
void rowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void rowsInserted (const QModelIndex &parent, int start, int end)
 
void rowsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsRemoved (const QModelIndex &parent, int start, int end)
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role)
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 
void setSupportedDragActions (QFlags< Qt::DropAction > actions)
 
QModelIndex sibling (int row, int column, const QModelIndex &index) const
 
virtual void sort (int column, Qt::SortOrder order)
 
virtual QSize span (const QModelIndex &index) const
 
virtual bool submit ()
 
Qt::DropActions supportedDragActions () const
 
virtual Qt::DropActions supportedDropActions () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QAbstractItemModel
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 
void beginResetModel ()
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 
QModelIndex createIndex (int row, int column, void *ptr) const
 
QModelIndex createIndex (int row, int column, int id) const
 
QModelIndex createIndex (int row, int column, quint32 id) const
 
void endInsertColumns ()
 
void endInsertRows ()
 
void endMoveColumns ()
 
void endMoveRows ()
 
void endRemoveColumns ()
 
void endRemoveRows ()
 
void endResetModel ()
 
QModelIndexList persistentIndexList () const
 
void reset ()
 
void resetInternalData ()
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A FacetModel contains a list of facets that are provided in a tree structure.

The FacetModel manages a list of Facet instances that are layed out in a tree structure in which the leafs are checkable. This allows to easily configure the facets by clicking the tree.

Facets are added via setFacets() and addFacet().

The FacetModel can be used to create and augment queries using the queryTerm() method and connecting to the queryTermChanged() signal. In addition FacetModel provides the extractFacetsFromTerm() method which converts a query into facet selections. This is very convinient if the query comes from another source like a query bookmark or another application.

An improved user experience can be created by setting the final query used to list the results via setClientQuery(). This allows the FacetModel to filter the available choices, hiding those that do not make sense with the current result set or even showing facets that did not make sense before (compare the ProxyFacet example in Facet Examples).

Typically one would use FacetWidget instead of creating ones own FacetModel.

Author
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org
Since
4.6

Definition at line 67 of file facetmodel.h.

Member Enumeration Documentation

enum Nepomuk::Utils::FacetModel::CustomRoles

Special roles FacetModel provides through data() in addition to the standard Qt roles.

See also
Qt::ItemDataRole
Enumerator
FacetRole 

Provides a pointer to the Facet instance itself.

Used internally.

Definition at line 88 of file facetmodel.h.

Constructor & Destructor Documentation

Nepomuk::Utils::FacetModel::FacetModel ( QObject *  parent = 0)

Creates an empty facet model.

Nepomuk::Utils::FacetModel::~FacetModel ( )

Destructor.

Member Function Documentation

void Nepomuk::Utils::FacetModel::addFacet ( Nepomuk::Utils::Facet *  facet)
slot

Add facet to the model.

Used to populate the model with facets. Ownership of facet is transferred to the model.

void Nepomuk::Utils::FacetModel::clear ( )
slot

Remove all facets from the model.

void Nepomuk::Utils::FacetModel::clearSelection ( )
slot

Convenience method that clears the selection on all facets.

See also
Facet::clearSelection()
int Nepomuk::Utils::FacetModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Reimplemented to provide facet data to Qt's model/view framework.

QVariant Nepomuk::Utils::FacetModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

Reimplemented to provide facet data to Qt's model/view framework.

Nepomuk::Query::Query Nepomuk::Utils::FacetModel::extractFacetsFromQuery ( const Nepomuk::Query::Query &  query)
slot

Extract as many facets from a query as possible.

This method is not able to handle all kinds of queries but works well on queries created via queryTerm().

Facets supported by this model will be extracted from query and configured accordingly in the model.

Be aware that this method is not related to setClientQuery(). It is intended to split up a query in order to represent it graphically. It will, however change the client query in order to achieve the best possible term extraction. Thus, one would typically call setClientQuery after calling this method if query does not already contain the full client query.

Typically a client would call this method and then try to handle the returned rest query in another way like converting it into a desktop user query string that can be shown in a search line edit. Another idea would be to use custom filters or a simple warning for the user that additional conditions are in place that could not be "translated" into facets.

Returns
The rest query after facets have been extracted.
QList<Facet*> Nepomuk::Utils::FacetModel::facets ( ) const
Returns
All Facet instances added via addFacet() and setFacets().
Qt::ItemFlags Nepomuk::Utils::FacetModel::flags ( const QModelIndex &  index) const
virtual

Reimplemented to provide facet data to Qt's model/view framework.

Reimplemented from QAbstractItemModel.

bool Nepomuk::Utils::FacetModel::hasChildren ( const QModelIndex &  parent) const
virtual

Reimplemented to provide facet data to Qt's model/view framework.

Reimplemented from QAbstractItemModel.

QModelIndex Nepomuk::Utils::FacetModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const

Reimplemented to provide facet data to Qt's model/view framework.

QModelIndex Nepomuk::Utils::FacetModel::parent ( const QModelIndex &  index) const

Reimplemented to provide facet data to Qt's model/view framework.

Query::Term Nepomuk::Utils::FacetModel::queryTerm ( ) const

Construct a query term from the selected facets in this model.

Returns
A new query which combines the facets in this model.
void Nepomuk::Utils::FacetModel::queryTermChanged ( const Nepomuk::Query::Term &  term)
signal

Emitted whenever the facets change, i.e.

when the user changes the selection or it is changed programmatically via extractFacetsFromQuery()

int Nepomuk::Utils::FacetModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Reimplemented to provide facet data to Qt's model/view framework.

void Nepomuk::Utils::FacetModel::setClientQuery ( const Nepomuk::Query::Query &  query)
slot

Can be used to set the full query the client is using (this includes facets created through this model).

It allows the facet system to disable certain choices that would not change the result set or do not make sense otherwise.

Be aware that this method is not related to extractFacetsFromTerm(). It is merely intended to improve the overall user experienceby filtering the facet choices depending on the current query.

Typically a client would call both extractFacetsFromTerm() and setClientQuery() seperately. However, they will often be called with the same query/term.

See also
Facet::setClientQuery()
bool Nepomuk::Utils::FacetModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
virtual

Reimplemented to provide facet data to Qt's model/view framework.

Reimplemented from QAbstractItemModel.

void Nepomuk::Utils::FacetModel::setFacets ( const QList< Nepomuk::Utils::Facet * > &  facets)
slot

Set facets as the list of facets used in this model.

Used to populate the model with facets. Ownership of the facets is transferred to the model.


The documentation for this class was generated from the following file:
  • facetmodel.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk

Skip menu "Nepomuk"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal