UpdateOperation Class | Qt Installer Framework Manual

Qt Installer Framework Manual | UpdateOperation

# UpdateOperation Class

(KDUpdater::UpdateOperation)

The UpdateOperation class is an abstract base class for update operations. More...

Header: | #include <UpdateOperation>

- List of all members, including inherited members

## Public Types

enum | Error { NoError, InvalidArguments, UserDefinedError }

## Public Functions

QString | argumentKeyValue(const QString &key, const QString &defaultValue = QString()) const
QStringList | arguments() const
virtual void | backup() = 0
void | clear()
void | clearValue(const QString &name)
virtual UpdateOperation * | clone() const = 0
int | error() const
QString | errorString() const
QStringList | filesForDelayedDeletion() const
virtual bool | fromXml(const QDomDocument &doc)
virtual bool | fromXml(const QString &xml)
bool | hasValue(const QString &name) const
QString | name() const
QString | operationCommand() const
virtual bool | performOperation() = 0
void | setArguments(const QStringList &args)
void | setValue(const QString &name, const QVariant &value)
virtual bool | testOperation() = 0
virtual QDomDocument | toXml() const
virtual bool | undoOperation() = 0
QVariant | value(const QString &name) const

## Protected Functions

bool | deleteFileNowOrLater(const QString &file, QString *errorString = 0)
void | registerForDelayedDeletion(const QStringList &files)
void | setError(int error, const QString &errorString = QString())
void | setErrorString(const QString &str)
void | setName(const QString &name)

## Detailed Description

The UpdateOperation class is an abstract base class for update operations.

The KDUpdater::UpdateOperation is an abstract class that specifies an interface for update operations. Concrete implementations of this class must perform a single update operation, such as copy, move, or delete.

Note: Two separate threads cannot be using a single instance of KDUpdater::UpdateOperation at the same time.

## Member Type Documentation

### enum UpdateOperation::Error

This enum code specifies error codes related to operation arguments and operation runtime failures.

Constant | Value | Description
--- | --- | ---
`KDUpdater::UpdateOperation::NoError` | `0` | No error occurred.
`KDUpdater::UpdateOperation::InvalidArguments` | `1` | Number of arguments does not match or an invalid argument was set.
`KDUpdater::UpdateOperation::UserDefinedError` | `128` | An error occurred during operation run. Use UpdateOperation::errorString() to get the human-readable description of the error that occurred.

## Member Function Documentation

### QString UpdateOperation::argumentKeyValue(const QString &key, const QString &defaultValue = QString()) const

Searches the arguments for the key specified by key. If it can find the key, it returns the value set for it. Otherwise, it returns defaultValue. Arguments are specified in the following form: `key=value`.

### QStringList UpdateOperation::arguments() const

Returns the arguments of the update operation.

See also setArguments().

### `[pure virtual]` void UpdateOperation::backup()

Subclasses must implement this function to back up any data before performing the action.

### void UpdateOperation::clear()

Clears the previously set arguments.

### void UpdateOperation::clearValue(const QString &name)

Clears the value of name and removes it.

### `[pure virtual]` UpdateOperation *UpdateOperation::clone() const

Subclasses must implement this function to clone the current operation.

### `[protected]` bool UpdateOperation::deleteFileNowOrLater(const QString &file, QString *errorString = 0)

Tries to delete file. If file cannot be deleted, it is registered for delayed deletion.

If a backup copy of the file cannot be created, returns `false` and displays the error message specified by errorString.

### int UpdateOperation::error() const

Returns the error that was found during the processing of the operation. If no error was found, returns NoError. Subclasses can set more detailed error codes (optional).

Note: To check if an operation was successful, use the return value of performOperation(), undoOperation(), or testOperation().

See also setError().

### QString UpdateOperation::errorString() const

Returns a human-readable description of the last error that occurred.

See also setErrorString().

### QStringList UpdateOperation::filesForDelayedDeletion() const

Returns the list of files that are scheduled for later deletion.

### `[virtual]` bool UpdateOperation::fromXml(const QDomDocument &doc)

Restores operation arguments and values from the XML document doc. Returns `true` on success, otherwise `false`.

### `[virtual]` bool UpdateOperation::fromXml(const QString &xml)

This is an overloaded function.

Restores operation arguments and values from the XML file at path xml. Returns `true` on success, otherwise `false`.

### bool UpdateOperation::hasValue(const QString &name) const

Returns `true` if a value called name exists, otherwise returns `false`.

### QString UpdateOperation::name() const

Returns the update operation name.

See also setName().

### QString UpdateOperation::operationCommand() const

Returns a command line string that describes the update operation. The returned string will be of the form:

`<name> <arg1> <arg2> <arg3> ....`

### `[pure virtual]` bool UpdateOperation::performOperation()

Subclasses must implement this function to perform the update operation.

Returns `true` if the operation is successful.

### `[protected]` void UpdateOperation::registerForDelayedDeletion(const QStringList &files)

Registers a list of files to be deleted later once the application was restarted and the file or files are not used anymore.

### void UpdateOperation::setArguments(const QStringList &args)

Sets the arguments for the update operation to args.

See also arguments().

### `[protected]` void UpdateOperation::setError(int error, const QString &errorString = QString())

Sets the error condition to be error. The human-readable message is set to errorString.

See also UpdateOperation::error() and UpdateOperation::errorString().

### `[protected]` void UpdateOperation::setErrorString(const QString &str)

Sets the human-readable description of the last error that occurred to str.

See also errorString().

### `[protected]` void UpdateOperation::setName(const QString &name)

Sets the name of the operation to name. Subclasses will have to provide a unique name to describe the operation.

See also name().

### void UpdateOperation::setValue(const QString &name, const QVariant &value)

Sets the value of name to value.

See also value().

### `[pure virtual]` bool UpdateOperation::testOperation()

Subclasses must implement this function to perform the test operation.

Returns `true` if the operation is successful.

### `[virtual]` QDomDocument UpdateOperation::toXml() const

Saves operation arguments and values as an XML document and returns the document. You can override this method to store your own extra-data. Extra-data can be any data that you need to store to perform or undo the operation. The default implementation is taking care of arguments and values set via UpdateOperation::setValue().

### `[pure virtual]` bool UpdateOperation::undoOperation()

Subclasses must implement this function to perform the undo of the update operation.

Returns `true` if the operation is successful.

### QVariant UpdateOperation::value(const QString &name) const

Returns the value of name. If the value does not exist, returns an empty QVariant.

See also setValue().