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.

A QContent object can be either an executable application or a document. Documents include text documents, pictures, pieces of music, and video clips.

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.

For an example of how to gain access to a content object that already exists in the database and how to add a completely new content object to the backing store (persistent storage), see Document Database Access. For other examples involving QContent objects, see Using QDocumentSelector to Write a Notes Application and Listening for Changes in the Documents Database

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::DocumentSystemConnection

Identifies how an application is connected to the Qtopia Document System.

ConstantValueDescription
QContent::DocumentSystemClient1The application performs document system operations by connecting to the Qtopia Document Server.
QContent::DocumentSystemDirect0The application connects directly to the content databases and performs all document system operations locally.

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)
QContent::Folder4a category used to group applications.

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 )

Creates 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

Returns 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

Returns 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 successful

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 successful and sets change to the type of change committed.

bool QContent::copyContent ( const QContent & from )

Copies the contents of from to this QContent.

Returns true is successful, otherwise false.

bool QContent::copyTo ( const QString & newPath )

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

Returns true is successful, otherwise false.

void QContent::deserialize ( Stream & stream )

Reads the contents of a QContent from stream.

DocumentSystemConnection QContent::documentSystemConnection ()   [static]

Identifies whether the application connects to the Qtopia Document Server or performs Document System operations locally.

See also setDocumentSystemConnection().

DrmState QContent::drmState () const

Returns 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

Returns 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

This function is deprecated.

Returns the file name of the file associated with the QContent. If no file is currently associated with the content this will reserve a new file name and so should be called with caution. To get the file name with out potentially creating a new file use fileName() instead.

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

bool QContent::fileKnown () const

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

QString QContent::fileName () const

Returns the file name of the file backing this content object.

QIcon QContent::icon () const

Returns 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.

See also setIcon().

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

This is an overloaded member function, provided for convenience.

Returns 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

Returns 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 (i.e. it 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

Returns true if this QContent object represents a document, or false if it represents an application. Convenience function.

See also usageMode().

bool QContent::isNull () const

Returns true if a QContent is unitialized; returns false otherwise.

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

Returns false if the Content link is invalid or if the backing file is unavailable, either. due to removal of media or deletion of the file.

Note: the parameter force is retained for compatibility, but is ignored.

QDateTime QContent::lastUpdated () const

Returns 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

Returns 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 )

Moves 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

Returns 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. If force is true the rights will be requeried. If force is false a cached value might be returned.

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

Returns 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.

Returns 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 ()

Uninstalls 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

Returns 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

Returns 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::serialize ( Stream & stream ) const

Writes the contents of a QContent to a stream.

void QContent::setCategories ( const QStringList & categoryList )

Sets 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().

bool QContent::setDocumentSystemConnection ( DocumentSystemConnection connection )   [static]

Sets the type of connection the application has to the Qtopia Document System. Returns true if the connection type is set, false otherwise.

Notes:

See also documentSystemConnection() and QTOPIA_SET_DOCUMENT_SYSTEM_CONNECTION().

void QContent::setExecutableName ( const QString & exec )

This function is deprecated.

Sets the executable name property to exec. If the content is not an execuatable this will change the file name. The property will not be written to the backing store until commit() is called.

Use setFile() instead.

See also executableName() and setFile().

void QContent::setFile ( const QString & filename )

Sets 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 to mimeTypes. This is the list of MIME types that the application can view or edit.

See also mimeTypes().

void QContent::setMimeTypes ( const QStringList & mimeTypes, const QStringList & mimeTypeIcons, const QList<QDrmRights::Permission> & permissions )

This is an overloaded member function, provided for convenience.

Sets the MimeTypes property to mimeTypes and associates icons from mimeTypeIcons and permissions to these mimetypes. This is the list of MIME types that the application can view or edit.

void QContent::setName ( const QString & name )

Sets the Name property to name. 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() )

Sets 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.

Sets 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 )

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

See also role().

void QContent::setType ( const QString & type )

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

See also type() and name().

qint64 QContent::size () const

Returns the plaintext size of the content in bytes

QString QContent::type () const

Returns the RFC2045 mime-type for the content if this content object represents a document.

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().

QString QContent::untranslatedName () const

Returns an untranslated user visible name for this content object.

UsageMode QContent::usageMode () const

This function is deprecated.

Returns 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. Assigns the data in other to this content object.

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

Equality operator. Returns 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.3.0