The QVersitWriter class writes Versit documents such as vCards to a device. More...
#include <QVersitWriter>
Inherits: QObject.
enum | Error { NoError, UnspecifiedError, IOError, OutOfMemoryError, NotReadyError } |
enum | State { InactiveState, ActiveState, CanceledState, FinishedState } |
QVersitWriter () | |
QVersitWriter ( QIODevice * outputDevice ) | |
QVersitWriter ( QByteArray * outputBytes ) | |
~QVersitWriter () | |
QTextCodec * | defaultCodec () const |
QIODevice * | device () const |
Error | error () const |
void | setDefaultCodec ( QTextCodec * codec ) |
void | setDevice ( QIODevice * device ) |
State | state () const |
bool | waitForFinished ( int msec = -1 ) |
void | cancel () |
bool | startWriting ( const QList<QVersitDocument> & input ) |
bool | startWriting ( const QList<QVersitDocument> & input, QVersitDocument::VersitType type ) |
bool | startWriting ( const QVersitDocument & input ) |
bool | startWriting ( const QVersitDocument & input, QVersitDocument::VersitType type ) |
void | stateChanged ( QVersitWriter::State state ) |
The QVersitWriter class writes Versit documents such as vCards to a device.
QVersitWriter converts a QVersitDocument into its textual representation. QVersitWriter supports writing to an abstract I/O device which can be for example a file or a memory buffer. The writing can be done asynchronously and the waitForFinished() function can be used to implement a blocking write.
The serialization of the document is done in accordance with the type of the QVersitDocument being written. The value of each QVersitProperty is encoded according to the type of object:
See also QVersitDocument and QVersitProperty.
This enum specifies an error that occurred during the most recent operation:
Constant | Value | Description |
---|---|---|
QVersitWriter::NoError | 0 | The most recent operation was successful |
QVersitWriter::UnspecifiedError | 1 | The most recent operation failed for an undocumented reason |
QVersitWriter::IOError | 2 | The most recent operation failed because of a problem with the device |
QVersitWriter::OutOfMemoryError | 3 | The most recent operation failed due to running out of memory |
QVersitWriter::NotReadyError | 4 | The most recent operation failed because there is an operation in progress |
Enumerates the various states that a reader may be in at any given time
Constant | Value | Description |
---|---|---|
QVersitWriter::InactiveState | 0 | Write operation not yet started |
QVersitWriter::ActiveState | 1 | Write operation started, not yet finished |
QVersitWriter::CanceledState | 2 | Write operation is finished due to cancelation |
QVersitWriter::FinishedState | 3 | Write operation successfully completed |
Constructs a new writer.
Constructs a new writer that writes to outputDevice.
Constructs a new writer that appends to outputBytes.
Frees the memory used by the writer. Waits until a pending asynchronous writing has been completed.
Attempts to asynchronously cancel the write request.
Returns the document's codec.
See also setDefaultCodec().
Returns the device used for writing, or 0 if no device has been set.
See also setDevice().
Returns the error encountered by the last operation.
Sets the default codec for the writer to use for writing the entire output.
If codec is NULL, the writer uses the codec according to the specification prescribed default. (for vCard 2.1, ASCII; for vCard 3.0, UTF-8).
See also defaultCodec().
Sets the device used for writing to device. Does not take ownership of the device.
See also device().
Starts writing input to device() asynchronously. The serialization format is determined based on the contents of the input documents.
Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.
The device must be already open. The client is responsible for closing it when finished.
Starts writing input to device() asynchronously using the serialization format specified by type. If type is QVersitDocument::InvalidType, the format will be determined based on the contents of the input documents.
Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.
The device must be already open. The client is responsible for closing it when finished.
Starts writing input to device() asynchronously. The serialization format is determined based on the contents of the input documents.
Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.
The device must be already open. The client is responsible for closing it when finished.
Starts writing input to device() asynchronously using the serialization format specified by type. If type is QVersitDocument::InvalidType, the format will be determined based on the contents of the input documents.
Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.
The device must be already open. The client is responsible for closing it when finished.
Returns the state of the writer.
The signal is emitted by the writer when its state has changed (eg. when it has finished writing to the device). state is the new state of the writer.
If the state is ActiveState, blocks until the writer has finished writing or msec milliseconds has elapsed, returning true if it successfully finishes or is cancelled by the user. If msec is negative or zero, the function blocks until the writer has finished, regardless of how long it takes. If the state is FinishedState, returns true immediately. Otherwise, returns false immediately.