unity.scopes.qt.QSearchMetadata

Metadata passed with search requests. More...

#include <unity/scopes/qt/QSearchMetadata.h>

Public Member Functions

 QSearchMetadata (QString const &locale, QString const &form_factor)
 Create SearchMetadata with the given locale and form factor. More...
 
 QSearchMetadata (int cardinality, QString const &locale, QString const &form_factor)
 Create SearchMetadata with the given cardinality, locale, and form factor. More...
 
void set_cardinality (int cardinality)
 Set cardinality. More...
 
int cardinality () const
 Get cardinality. More...
 
void set_location (Location const &location)
 Set location. More...
 
Location location () const
 Get location. More...
 
bool has_location () const
 Does the SearchMetadata have a location. More...
 
void remove_location ()
 Remove location data entirely. More...
 
void set_hint (QString const &key, QVariant const &value)
 Sets a hint. More...
 
QVariantMap hints () const
 Get all hints. More...
 
bool contains_hint (QString const &key) const
 Check if this SearchMetadata has a hint. More...
 
QVariant & operator[] (QString const &key)
 Returns a reference to a hint. More...
 
QVariant const & operator[] (QString const &key) const
 Returns a const reference to a hint. More...
 
Copy and assignment

Copy and assignment operators (move and non-move versions) have the usual value semantics.

 QSearchMetadata (QSearchMetadata const &other)
 
 QSearchMetadata (QSearchMetadata &&)
 
QSearchMetadataoperator= (QSearchMetadata const &other)
 
QSearchMetadataoperator= (QSearchMetadata &&)
 

Detailed Description

Metadata passed with search requests.

Constructor & Destructor Documentation

unity::scopes::qt::QSearchMetadata::QSearchMetadata ( QString const &  locale,
QString const &  form_factor 
)

Create SearchMetadata with the given locale and form factor.

Parameters
localelocale string, eg. en_EN
form_factorform factor name, e.g. phone, desktop, phone-version etc.
unity::scopes::qt::QSearchMetadata::QSearchMetadata ( int  cardinality,
QString const &  locale,
QString const &  form_factor 
)

Create SearchMetadata with the given cardinality, locale, and form factor.

Parameters
cardinalitymaximum number of search results
localelocale string, eg. en_EN
form_factorform factor name, e.g. phone, desktop, phone-version etc.

Member Function Documentation

int unity::scopes::qt::QSearchMetadata::cardinality ( ) const

Get cardinality.

Returns
The maxmium number of search results, or 0 for no limit.
bool unity::scopes::qt::QSearchMetadata::contains_hint ( QString const &  key) const

Check if this SearchMetadata has a hint.

Parameters
keyThe hint name.
Returns
True if the hint is set.
bool unity::scopes::qt::QSearchMetadata::has_location ( ) const

Does the SearchMetadata have a location.

Returns
True if there is a location property.
QVariantMap unity::scopes::qt::QSearchMetadata::hints ( ) const

Get all hints.

Returns
Hints dictionary.
Exceptions
unity::NotFoundExceptionif no hints are available.
Location unity::scopes::qt::QSearchMetadata::location ( ) const

Get location.

Returns
Location data representing the current location, including attributes such as city and country.
Exceptions
unity::NotFoundExceptionif no location data is available.
QVariant& unity::scopes::qt::QSearchMetadata::operator[] ( QString const &  key)

Returns a reference to a hint.

This method can be used to read or set hints. Setting a value of an existing hint overwrites its previous value. Referencing a non-existing hint automatically creates it with a default value of Variant::Type::Null.

Parameters
keyThe name of the hint.
Returns
A reference to the hint.
QVariant const& unity::scopes::qt::QSearchMetadata::operator[] ( QString const &  key) const

Returns a const reference to a hint.

This method can be used for read-only access to hints. Referencing a non-existing hint throws unity::InvalidArgumentException.

Parameters
keyThe name of the hint.
Returns
A const reference to the hint.
Exceptions
unity::NotFoundExceptionif no hint with the given name exists.
void unity::scopes::qt::QSearchMetadata::remove_location ( )

Remove location data entirely.

This method does nothing if no location data is present.

void unity::scopes::qt::QSearchMetadata::set_cardinality ( int  cardinality)

Set cardinality.

Parameters
cardinalityThe maximum number of search results.
void unity::scopes::qt::QSearchMetadata::set_hint ( QString const &  key,
QVariant const &  value 
)

Sets a hint.

Parameters
keyThe name of the hint.
valueHint value
void unity::scopes::qt::QSearchMetadata::set_location ( Location const &  location)

Set location.

Parameters
locationLocation data.

  翻译: