Detailed Description
The QPimModel class provides an abstract interface to the PIM model classes.
The QPimModel class defines a standard interface that is implemented by all of the PIM model classes. As it is an abstract interface, the QPimModel class should not be used directly. Instead use the classes that provide access for the specific PIM data types, QAppointmentModel, QContactModel or QTaskModel.
See also QAppointmentModel, QContactModel, QTaskModel, and Pim Library.
Member Function Documentation
QPimModel::QPimModel ( QObject * parent = 0 )
Constructs a PIM model with the given parent.
QPimModel::~QPimModel () [virtual]
Destroys the PIM model.
bool QPimModel::abortSyncTransaction ()
Aborts the current synchronization transaction.
Returns true if transaction successfully aborted.
See also startSyncTransaction() and commitSyncTransaction().
bool QPimModel::abortTransaction ()
Aborts the current transaction.
Returns true if transaction successfully aborted.
See also startTransaction() and commitTransaction().
QUniqueId QPimModel::addRecord ( const QByteArray & bytes, const QPimSource & source, const QString & format = QString() ) [pure virtual]
Adds the PIM record encoded in bytes to the model under the specified storage source. The format of the record in bytes is given by format. An empty format string will cause the record to be read using the data stream operators for the PIM data type of the model. Valid format strings are documented in QAppointmentModel, QContactModel and QTaskModel. If the specified source is null the function will add the record to the default storage source.
Returns a valid identifier for the record if the record was successfully added. Otherwise returns a null identifier.
Can only add PIM data that is represented by the model.
See also updateRecord() and removeRecord().
QList<QUniqueId> QPimModel::added ( const QDateTime & timestamp ) const
Returns the list of identifiers for records added to the current set of visible sources on or after the specified timestamp.
Timestamps are stored in UTC. Please use QTimeZone::toUtc() for times passed into this function.
See also removed() and modified().
QSet<QPimSource> QPimModel::availableSources () const
Returns the set of storage sources that can be shown.
See also setVisibleSources() and visibleSources().
QCategoryFilter QPimModel::categoryFilter () const
Returns the category filter that records are tested against in the current filter mode.
See also setCategoryFilter().
bool QPimModel::commitSyncTransaction ()
Commits the current synchronization transaction.
Returns true if transaction successfully committed.
Does not abort transaction if unsuccessfully committed.
See also startSyncTransaction() and abortSyncTransaction().
bool QPimModel::commitTransaction ()
Commits the current transaction.
Returns true if transaction successfully committed.
Does not abort transaction if unsuccessfully committed.
See also startTransaction() and abortTransaction().
bool QPimModel::contains ( const QModelIndex & index ) const
Returns true if the current filter mode of the model contains the given index.
See also exists().
bool QPimModel::contains ( const QUniqueId & identifier ) const
This is an overloaded member function, provided for convenience.
Returns true if the current filter mode of the model contains the record with given identifier.
See also exists().
QPimContext * QPimModel::context ( const QUniqueId & identifier ) const
Returns the context that could contain the record with specified identifier. This function does not check if the record currently exists in the corresponding context, but instead returns the context that this identifier belongs to. You can call QPimContext::exists() if you wish to be more certain, but be aware that other threads or processes may make the result out of date.
Returns 0 if this identifier does not belong to any context.
See also contexts().
QPimContext * QPimModel::context ( const QPimSource & source ) const
This is an overloaded member function, provided for convenience.
If the given source exists in the model returns the context that provides that source. Otherwise returns 0.
See also contexts() and availableSources().
const QList<QPimContext *> & QPimModel::contexts () const
Returns the contexts of record data that is shown by the record model.
int QPimModel::count () const
Return the number of records visible in the in the current filter mode.
QPimSource QPimModel::defaultSource () const
Returns the default storage sources relating to the device memory.
See also source(), availableSources(), and visibleSources().
bool QPimModel::editable ( const QModelIndex & index ) const
Returns true if the record for the given index can be updated or removed.
bool QPimModel::editable ( const QUniqueId & identifier ) const
This is an overloaded member function, provided for convenience.
Returns true if the record for the given identifier can be updated or removed.
bool QPimModel::exists ( const QUniqueId & identifier ) const
Returns true if a record with the given identifier is stored in the model.
The specified record does not need to be in the current filter mode.
See also contains().
bool QPimModel::flush ()
Ensures the data for the model is in a state suitable for syncing.
Returns true upon success.
See also startSyncTransaction().
Returns the identifier for the record at the specified index. If index is null or out of the range of the model, will return a null identifier.
QUniqueId QPimModel::id ( int row ) const
This is an overloaded member function, provided for convenience.
Returns the identifier for record at the specified row.
QModelIndex QPimModel::index ( const QUniqueId & identifier ) const
Returns the index of the record for the given identifier. If no record is found returns a null index.
See also contains() and exists().
QList<QUniqueId> QPimModel::modified ( const QDateTime & timestamp ) const
Returns the list of identifiers for records modified in the current set of visible sources on or after the specified timestamp.
Timestamps are stored in UTC. Please use QTimeZone::toUtc() for times passed into this function.
See also added() and removed().
QByteArray QPimModel::record ( const QUniqueId & identifier, const QString & format = QString() ) const [pure virtual]
Returns the record in the model with the specified identifier encoded in the format specified by the format string. An empty format string will cause the record to be written using the data stream operators for the PIM data type of the model.
bool QPimModel::refresh ()
Forces a refresh of the data for the model. The PIM data models update automatically and it should not be required that this function is called in normal use of the PIM data models.
Returns true upon success.
bool QPimModel::removeRecord ( const QUniqueId & identifier ) [pure virtual]
Removes the record from the model with the specified identifier.
Returns true if the record was successfully removed.
See also addRecord() and updateRecord().
QList<QUniqueId> QPimModel::removed ( const QDateTime & timestamp ) const
Returns the list of identifiers for records removed from the current set of visible sources on or after the specified timestamp.
Timestamps are stored in UTC. Please use QTimeZone::toUtc() for times passed into this function.
See also added() and modified().
void QPimModel::setCategoryFilter ( const QCategoryFilter & filter )
Sets the model to only contain records accepted by the specified category filter.
See also categoryFilter().
void QPimModel::setVisibleSources ( const QSet<QPimSource> & list )
Sets the model to show only records contained in the storage sources specified by list.
Also refreshes the model.
See also visibleSources() and availableSources().
QPimSource QPimModel::source ( const QUniqueId & identifier ) const
Returns the storage source that contains the record with the specified identifier. Returns a null source if the record does not exist.
See also availableSources().
bool QPimModel::sourceExists ( const QPimSource & source, const QUniqueId & identifier ) const
Returns true if the record for the given identifier is stored in the specified storage source.
See also exists() and availableSources().
bool QPimModel::startSyncTransaction ( const QDateTime & timestamp )
Prepares the currently visible sources for synchronization. All modifications between startSyncTransaction() and commitSyncTransaction() will be marked with the given timestamp for modification or creation as appropriate.
Returns true if transaction successfully initiated.
Does not abort the transaction if it is unsuccessful. The calling code must call abortSyncTransaction() to do that.
Timestamps are stored in UTC. Please use QTimeZone::toUtc() for times passed into this function.
See also commitSyncTransaction() and abortSyncTransaction().
bool QPimModel::startTransaction ()
Starts an SQL transaction on the database. Allows for calling multiple functions that may modify the database as an atomic operation.
Note that the database will be locked for the current model only. Do not modify any other PIM model instance until either committing or aborting the transaction.
Returns true if transaction successfully initiated.
See also commitTransaction() and abortTransaction().
bool QPimModel::updateRecord ( const QUniqueId & id, const QByteArray & bytes, const QString & format = QString() ) [pure virtual]
Updates the corresponding record in the model to equal the record encoded in bytes. The format of the record in bytes is given by the format string. An empty format string will cause the record to be read using the data stream operators for the PIM data type of the model. If id is not null will set the record identifier to id ready from the given bytes before attempting to update the record.
Returns true if the record was successfully updated.
See also addRecord() and removeRecord().
QSet<QPimSource> QPimModel::visibleSources () const
Returns the list of sources of record data that is currently shown by the record model.
See also setVisibleSources() and availableSources().