Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The QContent class represents a content carrying entity in the Qt Extended system, where content includes resources which an end-user may view or manage. More...
#include <QContent>
The QContent class represents a content carrying entity in the Qt Extended 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 meta-data 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 meta-data 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 using QContent to read, write and create documents see the Notes Application tutorial. For other examples using QContent, see the {Tutorial: Content Filtering}{Content Filtering} and Change Listener tutorials.
See also QContentSet and QContentFilter.
This enum specifies the type of change made to a QContent.
Constant | Value | Description |
---|---|---|
QContent::Added | 0 | the QContent has been added. |
QContent::Removed | 1 | the QContent has been deleted. |
QContent::Updated | 2 | the QContent has been modified. |
See also QContentSet::changed().
Identifies how an application is connected to the Qt Extended Document System.
Constant | Value | Description |
---|---|---|
QContent::DocumentSystemClient | 1 | The application performs document system operations by connecting to the Qt Extended Document Server. |
QContent::DocumentSystemDirect | 0 | The application connects directly to the backing store and performs all document system operations locally. |
This enum specifies the DRM State of this QContent object.
Constant | Value | Description |
---|---|---|
QContent::Unprotected | 0 | plain text "legacy" file, not subject to DRM |
QContent::Protected | 1 | file subject to DRM. |
Convenience enumeration that provides some of the more common content properties. All the properties have a key equal to their enumeration name in the default property group none.
Constant | Value | Description |
---|---|---|
QContent::Album | 0 | The name of the album which the content is part of. |
QContent::Artist | 1 | The name of the artist who produced the content. |
QContent::Author | 2 | The author of the content. |
QContent::Composer | 3 | The composer of the content. |
QContent::ContentUrl | 4 | A URL from which a copy of the content can be downloaded. Typically associated with OMA DRM content. |
QContent::Copyright | 5 | A copyright notice for the content. |
QContent::CopyrightUrl | 6 | A URL with copyright/legal information. |
QContent::Description | 7 | A description of the content. |
QContent::Genre | 8 | The genre the content belongs to. |
QContent::InformationUrl | 9 | A URL where additional information about the content can be obtained. Typically associated with OMA DRM content. |
QContent::PublisherUrl | 10 | The URL for the content publisher's website. |
QContent::RightsIssuerUrl | 11 | A URL where rights for DRM protected content may be obtained. Typically associated with OMA DRM content. |
QContent::Track | 12 | The content's position on an album. |
QContent::Version | 13 | The content's version number. |
QContent::Title | 14 | The title of the content. |
This enum specifies the type of document this QContent object appears to be.
Constant | Value | Description |
---|---|---|
QContent::UnknownUsage | 0 | unknown mode (default) |
QContent::Document | 1 | a user-visible document file suitable for "open" |
QContent::Data | 2 | a data or config file not suitable for "open" |
QContent::Application | 3 | an application (possibly Java, possibly DRM controlled) |
QContent::Folder | 4 | a category used to group applications. |
This typedef is deprecated.
UsageMode has been deprecated, use Role instead.
See also QContent::Role.
Constructs an empty invalid content object.
Creates a QContent object by fetching the meta-data 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.
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.
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.
Create a QContent by copying the other content object.
Destroys the content object.
Returns a list of category IDs for the categories a QContent has been assigned.
See also setCategories().
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.
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().
Writes the changes to the QContent object to the backing store. Returns true if successful
When a QContent is committed a notification is sent to all applications which can be listened for on the QtopiaApplication::contentChanged() signal.
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.
Copies the contents of from to this QContent.
Returns true is successful, otherwise false.
Copies the contents of the file and the meta-info from this QContent to newPath.
Returns true is successful, otherwise false.
See also moveTo().
Identifies whether the application connects to the Qt Extended Document Server or performs Document System operations locally.
See also setDocumentSystemConnection().
Returns a value of the DrmState enumeration indicating whether the content is DRM protected or not.
Returns true if this QContent object is in an error state. Call the errorString() method to return a text description of the error.
Returns the error string of this object. If error() is false then this method returns an empty string. Use error() instead of checking for an empty error string. The error string is not translated and therefore should not be used in a user interface.
Given an application binary name bin return the QContentId of the QContent record for that application. If bin is the fully qualified path of an ordinary file the QContentId of that file will be returned.
If bin does not refer to any application or file in the backing store then an InvalidId will be returned.
Note that binary names are unique across Qtopia.
Returns the name of the name of the application that will be launched if the QContent is executed.
If the QContent is an application this is the name of the binary, if it is a document it is the executable name of the application associated with the document MIME type.
If the content is not an application and there is no associated application associated with its MIME type then a null string will be returned.
See also setExecutableName() and execute().
Executes the application associated with this QContent.
See also executableName().
This is an overloaded member function, provided for convenience.
Executes the application associated with this QContent, with args as arguments.
See also executableName().
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 determine if there is a file associated with the QContent call fileKnown().
To get the file name with out potentially creating a new file use fileName() instead.
See also setFile(), executableName(), name(), fileName(), and fileKnown().
This function is deprecated.
Returns true if the QContent has been assigned a file name. Calling file() when fileKnown() is false will generate a new file and assign its file name to the QContent.
See also file().
Returns the file name of the file backing this content object.
See also setFile(), executableName(), name(), and file().
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().
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 grayed out (using the QIcon dynamic routines).
Returns the path to the icon for this file.
See also icon().
Returns the ID of this QContent. If this QContent is not present in the backing store its value will be QContent::InvalidId.
Takes a QFileInfo reference fi to a content object, and installs the meta-data for it in the backing store. The path must be an absolute path and the file must exist. If the file is a .desktop file linking to an application or a document then link target is installed in the database.
If MIME type 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().
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().
Returns true if this QContent object represents a document, or false if it represents an application. Convenience function.
See also usageMode().
Returns true if a QContent is uninitialized; returns false otherwise.
Queries the launcher configuration settings and returns true if an application QContent is in the systems PreloadApps list; otherwise returns false.
If the QContent is a document then the return value will indicate if the associated application is preloaded
Preloaded applications are applications that are launched in the background when Qt Extended is started.
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.
Returns the value of the last time underlying file was updated.
This function is deprecated.
Returns the path of the .desktop file the QContent was generated from or an empty string if the QContent was not generated from a .desktop file.
See also setLinkFile(), file(), and linkFileKnown().
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().
Read the unformatted contents of the file associated with a QContent into data.
If data is not empty the contents will be overridden.
Returns true if data could be read from the file and false otherwise.
Returns the root path of the media the content is stored on.
See also setMedia().
Returns an icon path for each MIME type an application QContent an open.
The icon list will contain one icon for each MIME type returned by mimeTypes().
See also mimeTypes().
Returns a DRM permission for each MIME type an application QContent can open. The launcher will ensure that a documents opened from the launcher menu have valid rights for their MIME type permission before launching the application.
The permission list will contain one permission for each MIME type returned by mimeTypes().
See also mimeTypes().
Returns a list of MIME types that an application QContent can view or edit. If the QContent is not an application this will return an empty list.
See also setMimeTypes().
Moves the contents of the file and the meta-info 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.
See also copyTo() and rename().
Returns the user-visible name for this content object
See also setName().
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.
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.
Returns all the DRM permissions the content currently has rights for. If force is true the rights will be re-queried. If force is false a cached value might be returned.
Returns the value of the key property within a property group.
Property groups provide a namespace for keys. Within a group a QContent may only have one value for a key, but a key may be repeated in another group with a different value. If no group is specified then the default group none is assumed.
See also setProperty().
This is an overloaded member function, provided for convenience.
Returns the value of the key property.
Returns the string key for a given property.
Uninstalls a QContent from the database and removes the associated file from the file-system.
This function is deprecated.
Uninstall the .desktop/link file for this object from the database, and remove it from the file-system.
Sets the name of the content to name and renames the associated file to match.
Returns true if the file could be renamed and false otherwise.
See also moveTo() and setName().
Returns a QDrmRights representation of any rights for this object for the given permission.
If 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.
Displaying the play permissions of a QContent:
void showPlayRights( const QContent &content, QWidget *parent ) { QDrmRights = content.rights( QDrmRights::Play ); QString title; switch( rights.status() ) { case QDrmRights::Invalid: title = tr( "Play permissions invalid." ); break; case QDrmRights::Valid: title = tr( "Play permissions valid." ); break; case QDrmRights::ValidInFuture: title = tr( "Play permissions pending." ); break; } QString message = title; foreach( QDrmRights::Constraint constraint, rights.constraints() ) { message += '\n' + constraint.name() + ":\t" + constraint.value(); for( int i = 0; i < constraint.attributeCount(); i++ ) message += "\n\t" constraint.attributeName( i ) + ":\t" ) + constraint.attributeValue( i ); } QMessageBox::information( parent, title, QString( "<qt>%1</qt>" ).arg( message ); }
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().
Saves data to the file associated with a QContent.
If the QContent is associated with an existing file its contents will be overwritten, otherwise a new file will be created. In order to create a new file the QContent must have valid values of name() and type().
Returns true if all the data is written to the file and false otherwise.
Saving data to a new file:
bool saveData( const QString &name, const QString &type, const QByteArray &data ) { QContent content; content.setName( name ); content.setType( type ); if( content.save( data ) ) { content.commit(); return true; } else { return false; } }
Sets the list of category IDs assigned to a QContent to categoryList.
This will overwrite the list of categories already assigned to a QContent, so new categories should be appended to the list returned by categories() to prevent existing categories being lost.
content.setCategories( content.categories() << newCategoryId );
The categories will not be written to the backing store until commit() is called.
See also categories() and commit().
Sets a string comment for this object.
See also comment().
Sets the type of connection the application has to the Qt Extended Document System. Returns true if the connection type is set, false otherwise.
Notes:
See also documentSystemConnection() and QTOPIA_SET_DOCUMENT_SYSTEM_CONNECTION().
This function is deprecated.
Sets the executable name property to exec. If the content is not an executable 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().
Sets the file that this content references to filename.
This does not move the contents of the file, to move a file use moveTo() instead.
Sets the icons associated with this content to iconpath.
The property will not be written to the backing store until commit() is called.
This function is deprecated.
Set the link/.desktop file that this content references to filename.
See also linkFile().
Sets the root path of the media the file is stored on. Once a QContent has been committed to the database the media cannot be changed. Returns true if successful; otherwise false.
See also media().
Sets the list of MIME types that the application can view or edit to mimeTypes.
The application's icon will be associated with the mime types in document lists and the application will be unable to open DRM protected content from the launcher.
MIME type associations are written to the database when commit() is called, if the QContent is not an application the associations will not be written to the database.
See also mimeTypes().
This is an overloaded member function, provided for convenience.
Sets the list of MIME types that the application can view or edit to mimeTypes.
The icon displayed each MIME type is obtained from the mimeTypeIcons list, and the DRM permission which is verified for documents opened from the launcher is obtained from the permissions list.
Each mime type is assigned the icon and DRM permission from the corresponding index in the mimeTypeIcons and permissions lists. If there is only one value in either list it is repeated for each MIME type. If a list has more then one item but fewer than mimeTypes then a null value is assigned for the remainder of the MIME types.
MIME type associations are written to the database when commit() is called, if the QContent is not an application the associations will not be written to the database.
See also mimeTypeIcons() and mimeTypePermissions().
Sets the Name property to name.
The property will not be written to the backing store until commit() is called.
This does not rename the underlying file, to rename a file use rename() instead.
Sets the key property of a QContent to value. A key is unique within a property group, but may be repeated in another group. If no group is specified then the key is assumed to belong to the default property group none.
The property value will not be written to the backing store until commit() is called.
See also property() and commit().
This is an overloaded member function, provided for convenience.
Sets the key property of a QContent to value.
The property will not be written to the backing store until commit() is called.
See also commit().
Sets the document status of the object to role as per the Role enum.
See also role().
Sets the Type property to type.
The property will not be written to the backing store until commit() is called.
Returns the plain-text size of the content in bytes
Returns a representive thumbnail of the content. If size is not null the thumbnail will be resized to fit those dimensions according to the given aspect ratio mode.
Returns the RFC2045 mime-type for the content.
See also setType().
Removes the Content with id from the backing store. This does not remove any files associated with the QContent, if the file is in a scanned location it will be reinstalled the next time that location is scanned.
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().
Returns an untranslated user visible name for this content object.
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().
Assignment operator. Assigns the data in other to this content object.
Equality operator. Returns true if this QContent object is the same as the other; otherwise returns false.
The values of the QContents are only tested if both are not null and both have invalid IDs, otherwise only the IDs are used to determine equality.
This variable holds a constant representing an invalid QContent identifier.
A QContentId is a globally unique identifier for a QContent record. Synonym for QPair<QtopiaDatabaseId, quint64>.
Synonym for QList<QContentId>.
A QtopiaDatabaseId is a globally unique identifier for a QContent backing store. Synonym for quint32.
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |