Home · All Classes · Grouped Classes · Annotated · Functions

QContent Class Reference

The QContent class represents a content carrying entity in the Qtopia system, where content includes resources which an end-user may view or manage. More...

    #include <QContent>

Public Types

Public Functions

Static Public Members

Protected Functions

Related Non-Members


Detailed Description

The QContent class represents a content carrying entity in the Qtopia system, where content includes resources which an end-user may view or manage.

By creating content with a Role of Data using the setRole() method, resources not intended to be directly consumed by the end-user may also be managed.

An instance of a QContent may, for example, represent any one of the following types of content:

The QContent class is responsible for providing access to metadata about the content contained in a file or stream.

As a system-wide invariant, the backing store is authoritative for information about content available on the device. For example content stored in a DRM file or a stream may not have a logical file on the file-system.

In general applications should use the QContent and QContentSet interface to manage, and search for resources, instead of calling through to the file-system.

The backing store is typically an SQL database, although it could be some other kind of persistent storage.

The static methods install() and uninstall() are used to update records of metadata in the backing store in response to hardware and software events such as:

To be notified of these events, create a QContentSet object and connect to its QContentSet::changed() signal.

See also QContentSet and QContentFilter.


Member Type Documentation

enum QContent::ChangeType

This enum specifies the type of change made to a QContent.

ConstantValueDescription
QContent::Added0the QContent has been added.
QContent::Removed1the QContent has been deleted.
QContent::Updated2the QContent has been modified.

See also QContentSet::changed().

enum QContent::DrmState

This enum specifies the DRM State of this QContent object.

ConstantValueDescription
QContent::Unprotected0plain text "legacy" file, not subject to drm
QContent::Protected1file subject to drm.

enum QContent::Property

Convenience enum provides some of the more common content properties.

ConstantValueDescription
QContent::Album0The name of the album which the content is part of.
QContent::Artist1The name of the artist who produced the content.
QContent::Author2The author of the content.
QContent::Composer3The composer of the content.
QContent::ContentUrl4A URL from which a copy of the content can be downloaded. Typically associated with OMA DRM content.
QContent::Copyright5A copyright notice for the content.
QContent::CopyrightUrl6A URL with copyright/legal information.
QContent::Description7A description of the content.
QContent::Genre8The genre the content belongs to.
QContent::InformationUrl9A URL where additional information about the content can be obtained. Typically associated with OMA DRM content.
QContent::PublisherUrl10The URL for the content publisher's website.
QContent::RightsIssuerUrl11A URL where rights for DRM protected content may be obtained. Typically associated with OMA DRM content.
QContent::Track12The content's position on an album.
QContent::Version13The content's version number.

enum QContent::Role

This enum specifies the type of document this QContent object appears to be.

ConstantValueDescription
QContent::UnknownUsage0unknown mode (default)
QContent::Document1a user-visible document file suitable for "open"
QContent::Data2a data or config file not suitable for "open"
QContent::Application3an application (possibly Java, possibly DRM controlled)

typedef QContent::UsageMode

This typedef is deprecated.

UsageMode has been deprecated, use Role instead.

See also QContent::Role.


Member Function Documentation

QContent::QContent ()

Constructs an empty invalid content object.

QContent::QContent ( QContentId id )

Create a QContent object by fetching the metadata from the backing store specified by id. This method will be fast if the object has already been referenced by QContent and QContentSet classes loaded in the current process, since internally the results of calls to the backing store are cached.

QContent::QContent ( const QString & fileName, bool store = true )

Create a QContent based on the content contained in the file represented by fileName.

Passing store specifies whether this content object is stored into the backing store database, or only used as a local object.

QContent::QContent ( const QFileInfo & fi, bool store = true )

Create a QContent based on the content contained in the file represented by fi.

Passing store specifies whether this content object is stored into the backing store, or only used as a local object.

QContent::QContent ( const QContent & other )

Create a QContent by copying the other content object.

QContent::~QContent ()   [virtual]

Destroys the content object.

QStringList QContent::categories () const

Return a list of strings representing the categories on this object. Usually it will make more sense to create a QContentSet and set category filters on it.

See also setCategories().

void QContent::clearErrors ()   [static]

Clear all error flags and errors strings on all QContent objects. Note: this method clears the global error cache for all QContent objects in this process.

QString QContent::comment () const

Return the comment for this object, typically used on ToolTips For DRM controlled objects this will include a summary of the rights and DRM status

See also setComment().

bool QContent::commit ()

Writes the changes to the QContent object to the backing store. Returns true if successfull

bool QContent::commit ( ChangeType & change )   [protected]

This is an overloaded member function, provided for convenience.

Writes the changes to the QContent to the backing store. Returns true if successfull and sets change to the type of change committed.

bool QContent::copyContent ( const QContent & from )

Copy the contents of from to this QContent.

Returns true is successful, otherwise false.

bool QContent::copyTo ( const QString & newPath )

Copy the contents of the file and the metainfo from this QContent to newPath.

Returns true is successful, otherwise false.

DrmState QContent::drmState () const

Return the DRM status of this object, as per the DRMState enum. This value is a cache of the real value available from the DRM agent. When an object expires an event should be fired to update the database but be aware that stale information may be displayed.

bool QContent::error () const

Return true if this QContent object is in an error state. Call the errorString() method to return a text description of the error.

QContentId QContent::execToContent ( const QString & bin )   [static]

Given an application binary name bin, return QContentId pointing to the QContent item representing an application with that binary.

A path name may be supplied for bin (eg bin may contain "/" characters).

Note that binary names are unique across qtopia.

QString QContent::executableName () const

Returns the executable name property. This is the name of the executable program associated with the QContent target.

See also setExecutableName() and execute().

void QContent::execute ( const QStringList & args ) const

Executes the application associated with this QContent, with args as arguments.

See also executableName() and setExecutableName().

void QContent::execute () const

This is an overloaded member function, provided for convenience.

Executes the application associated with this QContent.

See also executableName() and setExecutableName().

QString QContent::file () const

Returns the file associated with the QContent.

See also setFile(), executableName(), and name().

bool QContent::fileKnown () const

Return true if the file associated with this QContent object is already known. If false, calling file() will generate a file name.

QIcon QContent::icon () const

Return the icon for this object. If the object is an application, then it will be the application icon, otherwise it will be a generic icon for the mime-type of the object.

If the object is a DRM controlled, a key emblem is super-imposed on the icon. If the content does not have current rights for the default application the icon is shown greyed out (using the QIcon dynamic routines).

See also setIcon().

QIcon QContent::icon ( QDrmRights::Permission permission ) const

This is an overloaded member function, provided for convenience.

Return the icon for this object. If the object is an application, then it will be the application icon, otherwise it will be a generic icon for the mime-type of the object.

If the object is a DRM controlled, a key emblem is super-imposed on the icon. If the content does not have current rights for permission the icon is shown greyed out (using the QIcon dynamic routines).

QString QContent::iconName () const

Return the path to the icon for this file.

See also icon().

QContentId QContent::id () const

Returns the Id of this QContent. If this QContent is not present in the backing store its value will be QContent::InvalidId.

QContentId QContent::install ( const QFileInfo & fi )   [static]

Takes a QFileInfo reference fi to a content object, and installs the metadata for it in the backing store/database. The path must be an absolute path and the file must exist. If the file is a .desktop file referring to an application or a document a QContent record is created.

If mimetype data is not available, it is determined by file extension, or failing that, the magic number.

If the object is a DRM-controlled file (is a .dcf file, or is otherwise shown as drm controlled) the DRM subsystem is queried for the DRM status.

See also QContentSet::scan().

void QContent::installBatch ( const QList<QFileInfo> & batch )   [static]

Installs a set of files in a batch, committing to the database only once. This achieves a significant performance boost over multiple calls to install.

See also install().

bool QContent::isDocument () const

Convenience function to test if this QContent is a Document or an Application. Returns true if this QContent is a Document or an Application; otherwise returns false.

See also usageMode().

bool QContent::isPreloaded () const

Queries the launcher configuration settings and returns true if this object is in the systems PreloadApps list; otherwise returns false.

bool QContent::isValid ( bool force = false ) const

Content is invalid if the backing file is unavailable, either due to removal of media or deletion of the file. If force is true, the content will be revalidated even if this value has been previously cached. Returns true if content is valid; otherwise returns false.

Note: this method can be expensive.

QDateTime QContent::lastUpdated () const

Return the value of the last time underlying file was updated.

QString QContent::linkFile () const

Deprecated functionality: Return the path of the .desktop link file this metainfo ContentLink was generated from if available.

See also setLinkFile().

bool QContent::linkFileKnown () const

Return true if the file associated with this QContent object is already known. If false, calling file() will generate a file name.

See also QContent::fileKnown(), QContent::linkFile(), and QContent::file().

bool QContent::load ( QByteArray & data ) const

Loads the content into data.

Returns true if successful; otherwise false.

QString QContent::media () const

Returns the root path of the media the content is stored on.

See also setMedia().

QStringList QContent::mimeTypeIcons () const

Returns the MimeTypeIcons property of the QContent.

QList<QDrmRights::Permission> QContent::mimeTypePermissions () const

Returns MimeTypePermissions property of the QContent.

QStringList QContent::mimeTypes () const

Returns the MimeTypes property. This is the list of MIME types that the application can view or edit.

See also setMimeTypes().

bool QContent::moveTo ( const QString & newPath )

Move the contents of the file and the metainfo from this QContent to newPath.

Returns true if the contents is successfully moved, otherwise false.

Note: The id() of the original file will be invalid and should not be used.

QString QContent::name () const

Return the user-visible name for this content object

See also setName().

QIODevice * QContent::open ( QIODevice::OpenMode mode )

Opens a QIODevice using mode mode.

Returns the QIODevice if successful, otherwise returns 0. It is the caller's responsibility to delete the return value.

QIODevice * QContent::open () const

This is an overloaded member function, provided for convenience.

Opens a read only QIODevice.

Returns the QIODevice if successful, otherwise returns 0. It is the caller's responsibility to delete the return value.

QDrmRights::Permissions QContent::permissions ( bool force = true ) const

Returns all the DRM permissions the content currently has rights for. A true value of force will cause the rights to be requeried otherwise a cached value may be returned.

QString QContent::property ( const QString & key, const QString & group = QString() ) const

Return a property associated with this content with key key and group group. If group is not specifed the default group will be used.

See also setProperty().

QString QContent::property ( Property key ) const

This is an overloaded member function, provided for convenience.

Return a property associated with this content with key key.

See also setProperty().

QString QContent::propertyKey ( Property property )   [static]

Returns the string key for a given property.

void QContent::removeFiles ()

Uninstall this object from the database, and remove it from the filesystem.

void QContent::removeLinkFile ()

This function is deprecated.

Uninstall the .desktop/link file for this object from the database, and remove it from the filesystem.

QDrmRights QContent::rights ( QDrmRights::Permission permission ) const

Return a QDrmRights representation of any rights for this object for the given permission. If the drmStatus() returns Unprotected, then this method returns a QDrmRights object with valid rights for all permissions. Use drmStatus() != Unprotected to test for unprotected content and permissions() & [permission] to test for a specific permission.

Role QContent::role () const

Return the document status of the object as per the Role enum. This value does not usually change. The status is used to determine what to display to the user. Data objects make no sense to display to the user, as they cannot be launched or categorized. These files are only of use to the applications which operate on them.

See also setRole().

bool QContent::save ( const QByteArray & data )

Saves the data data.

Returns true is successful; otherwise false.

void QContent::setCategories ( const QStringList & categoryList )

Set the categories associated with this content to categoryList. The categores will not be written to the backing store until commit() is called.

See also categories() and commit().

void QContent::setComment ( const QString & comment )

Sets a string comment for this object.

See also comment().

void QContent::setExecutableName ( const QString & exec )

Sets the executable name property to exec. The property will not be written to the backing store until commit() is called.

See also executableName() and execute().

void QContent::setFile ( const QString & filename )

Set the file that this content references to filename

See also file().

void QContent::setIcon ( const QString & iconpath )

Sets the icons associated with this content to iconpath. The property will not be written to the backing store until commit() is called.

See also icon() and commit().

void QContent::setLinkFile ( const QString & filename )

This function is deprecated.

Set the link/.desktop file that this content references to filename.

See also linkFile().

bool QContent::setMedia ( const QString & media )

Sets the root path of the media the file is stored on. Once a QContent has been commited to the database the media cannot be changed. Returns true if successful; otherwise false.

See also media().

void QContent::setMimeTypes ( const QStringList & mimeTypes )

Sets the MimeTypes property tp mimeTypes. This is the list of MIME types that the application can view or edit.

See also mimeTypes().

void QContent::setName ( const QString & docname )

Sets the Name property to docname. The property will not be written to the backing store until commit() is called.

See also name().

void QContent::setProperty ( const QString & key, const QString & value, const QString & group = QString() )

Set a property associated with the content with key key and value value. If group is specified then the property will be stored in the specified group, otherwise it will be stored in the default group. The property will not be written to the backing store until commit() is called.

See also property() and commit().

void QContent::setProperty ( Property key, const QString & value )

This is an overloaded member function, provided for convenience.

Set a property associated with the content with key key and value value. The property will not be written to the backing store until commit() is called.

See also property() and commit().

void QContent::setRole ( Role role )

Set the document status of the object to role as per the Role enum.

See also role().

void QContent::setType ( const QString & doctype )

Sets the Type property to doctype. The property will not be written to the backing store until commit() is called.

See also type() and name().

qint64 QContent::size () const

Return the plaintext size of the content in bytes

QString QContent::type () const

Return the RFC2045 mime-type for the content

See also setType().

void QContent::uninstall ( QContentId id )   [static]

Remove the Content with id from the backing store

void QContent::uninstallBatch ( const QList<QContentId> & batch )   [static]

Uninstalls a set of files in a batch, committing to the database only once. This achieves a significant performance boost over multiple calls to uninstall().

See also uninstall().

UsageMode QContent::usageMode () const

This function is deprecated.

Return the document status of the object as per the UsageMode enum. This value does not usually change. The status is used to determine what to display to the user. Data objects make no sense to display to the user, as they cannot be launched or categorized. These files are only of use to the applications which operate on them.

See also role().

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

Assignment operator. Sets data on this to be what is set on other.

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

Equality operator. Return true if this Content object is the same as the other; otherwise returns false. Is true if both have the same Id number, or if both are empty.


Member Variable Documentation

const QContentId QContent::InvalidId

This variable holds a constant representing an invalid QContent identifier.


Related Non-Members

typedef QContentId

A QContentId is a globally unique identifier for a QContent record. Synonym for QPair<QtopiaDatabaseId, quint64>.

typedef QContentIdList

Synonym for QList<QContentId>.

typedef QtopiaDatabaseId

A QtopiaDatabaseId is a globally unique identifier for a QContent backing store. Synonym for quint32.


Copyright © 2007 Trolltech Trademarks
Qtopia 4.2.5