QPlaceContent Class

The QPlaceContent class serves as the base class for rich content types. 更多...

头: #include <QPlaceContent>
qmake: QT += location
Since: Qt 5.6
继承者:

QPlaceEditorial , QPlaceImage ,和 QPlaceReview

该类在 Qt 5.6 引入。

公共类型

typedef Collection
enum Type { NoType, ImageType, ReviewType, EditorialType, CustomType }

公共函数

QPlaceContent (const QPlaceContent & other )
QPlaceContent ()
QPlaceContent & operator= (const QPlaceContent & other )
virtual ~QPlaceContent ()
QString attribution () const
void setAttribution (const QString & attribution )
void setSupplier (const QPlaceSupplier & supplier )
void setUser (const QPlaceUser & user )
QPlaceSupplier supplier () const
QPlaceContent::Type type () const
QPlaceUser user () const
bool operator!= (const QPlaceContent & other ) const
bool operator== (const QPlaceContent & other ) const

详细描述

Rich content such as images , reviews and editorials inherit from the QPlaceContent class which contains common properties such as an attribution string and content contributor, which may take the form of a user and/or supplier . It is possible that a user from a supplier is contributing content, hence both fields could be filled in simultaneously.

注意: Some providers may require that the attribution string be displayed to the user whenever a piece of content is viewed.

Conversion between QPlaceContent and it's subclasses can be easily performed without casting. Due to the way it has been implemented, object slicing is not an issue, the following code is valid:

QPlaceImage image;
image.setUrl(QUrl("www.example.com"));
QPlaceContent content = image;
QPlaceImage image2;
image2 = content;
qDebug() << image2.url(); //image2.url() == "www.example.com"
					

The rich content of a place is typically made available as paginated items. The ability to convert between QPlaceContent and it's subclasses means that code which handles the mechanics of paging can be easily shared for each of the sub types.

At present the QPlaceContent class is not extensible by 3rd parties.

Note: The Places API considers content objects to be 'retrieve-only' objects. Submission of content to a provider is not a supported use case.

另请参阅 QPlaceImage , QPlaceReview ,和 QPlaceEditorial .

成员类型文档编制

typedef QPlaceContent:: Collection

同义词 QMap <int, QPlaceContent >. The key of the map is an int representing the index of the content. The value is the content object itself.

The Collection is intended to be a container where content items, that have been retrieved as pages, can be stored. This enables a developer to skip pages, for example indexes 0-9 may be stored in the collection, if the user skips to indexes 80-99, these can be stored in the collection as well.

enum QPlaceContent:: Type

Defines the type of content.

常量 描述
QPlaceContent::NoType 0 The content object is default constructed, any other content type may be assigned to this content object
QPlaceContent::ImageType 1 The content object is an image
QPlaceContent::ReviewType 2 The content object is a review
QPlaceContent::EditorialType 3 The content object is an editorial
QPlaceContent::CustomType 0x0100 The content object is of a custom type

成员函数文档编制

QPlaceContent:: QPlaceContent (const QPlaceContent & other )

Constructs a new copy of other .

QPlaceContent:: QPlaceContent ()

Constructs an default content object which has no type.

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

赋值 other content object to this and returns a reference to this content object.

[虚拟] QPlaceContent:: ~QPlaceContent ()

Destroys the content object.

QString QPlaceContent:: attribution () const

Returns a rich text attribution string.

注意 : Some providers may require that the attribution of a particular content item always be displayed when the content item is shown.

另请参阅 setAttribution ().

void QPlaceContent:: setAttribution (const QString & attribution )

Sets a rich text attribution string for this content item.

另请参阅 attribution ().

void QPlaceContent:: setSupplier (const QPlaceSupplier & supplier )

设置 supplier of the content.

另请参阅 supplier ().

void QPlaceContent:: setUser (const QPlaceUser & user )

设置 user who contributed this content.

另请参阅 user ().

QPlaceSupplier QPlaceContent:: supplier () const

Returns the supplier who contributed this content.

另请参阅 setSupplier ().

QPlaceContent::Type QPlaceContent:: type () const

Returns the content type.

QPlaceUser QPlaceContent:: user () const

Returns the user who contributed this content.

另请参阅 setUser ().

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

Returns true if this content object is not equivalent to other ,否则返回 false。

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

Returns true if this content object is equivalent to other ,否则返回 false。