Component Class | Qt Installer Framework Manual

Qt Installer Framework Manual | Component

# Component Class

(QInstaller::Component)

The Component class represents the current component. More...

Header: | #include <Component>

- List of all members, including inherited members

## Public Types

class | SortingPriorityGreaterThan
class | SortingPriorityLessThan

## Properties

- archives : const QStringList
- autoCreateOperations : bool
- autoDependencies : const QStringList
- default : const bool
- dependencies : const QStringList
- displayName : const QString

- enabled : const bool
- fromOnlineRepository : const bool
- installed : const bool
- name : const QString
- repositoryUrl : const QUrl
- userInterfaces : const QStringList

## Public Functions

| Component(PackageManagerCore *core)
| ~Component()
void | addDependency(const QString &newDependency)
void | addDownloadableArchive(const QString &path)
void | addElevatedOperation(Operation *operation)
bool | addElevatedOperation(const QString &operation, const QString &parameter1 = QString(), const QString &parameter2 = QString(), const QString &parameter3 = QString(), const QString &parameter4 = QString(), const QString &parameter5 = QString(), const QString &parameter6 = QString(), const QString &parameter7 = QString(), const QString &parameter8 = QString(), const QString &parameter9 = QString(), const QString &parameter10 = QString())
bool | addElevatedOperation(const QString &operation, const QStringList &parameters)
void | addOperation(Operation *operation)
bool | addOperation(const QString &operation, const QString &parameter1 = QString(), const QString &parameter2 = QString(), const QString &parameter3 = QString(), const QString &parameter4 = QString(), const QString &parameter5 = QString(), const QString &parameter6 = QString(), const QString &parameter7 = QString(), const QString &parameter8 = QString(), const QString &parameter9 = QString(), const QString &parameter10 = QString())
bool | addOperation(const QString &operation, const QStringList &parameters)
void | addStopProcessForUpdateRequest(const QString &process)
void | appendComponent(Component *component)
QStringList | archives() const
bool | autoCreateOperations() const
QStringList | autoDependencies() const
virtual void | beginInstallation()
bool | componentChangeRequested()
virtual void | createOperations()
virtual void | createOperationsForArchive(const QString &archive)
virtual void | createOperationsForPath(const QString &path)
QStringList | dependencies() const
QList<Component *> | descendantComponents() const
QString | displayName() const
QStringList | downloadableArchives() const
bool | forcedInstallation() const
bool | installationRequested() const
bool | isAutoDependOn(const QSet<QString> &componentsToInstall) const
bool | isDefault() const
bool | isFromOnlineRepository() const
bool | isInstalled() const
bool | isSelected() const
bool | isSelectedForInstallation() const
bool | isUninstalled() const
bool | isVirtual() const
QHash<QString, QPair<QString, QString> > | licenses() const
void | loadComponentScript()
void | loadComponentScript(const QString &fileName)
void | loadDataFromPackage(const Package &package)
void | loadDataFromPackage(const LocalPackage &package)
void | loadLicenses(const QString &directory, const QHash<QString, QVariant> &licenseHash)
void | loadTranslations(const QDir &directory, const QStringList &qms)
void | loadUserInterfaces(const QDir &directory, const QStringList &uis)
QString | localTempPath() const
void | markAsPerformedInstallation()
QString | name() const
OperationList | operations() const
bool | operationsCreatedSuccessfully() const
PackageManagerCore * | packageManagerCore() const
Component * | parentComponent() const
QList<QPair<QString, bool> > | pathsForUninstallation() const
void | registerPathForUninstallation(const QString &path, bool wipe = false)
void | removeComponent(Component *component)
void | removeDownloadableArchive(const QString &path)
void | removeStopProcessForUpdateRequest(const QString &process)
QUrl | repositoryUrl() const
void | setInstalled()
void | setRepositoryUrl(const QUrl &url)
void | setStopProcessForUpdateRequest(const QString &process, bool requested)
void | setUninstalled()
void | setUpdateAvailable(bool isUpdateAvailable)
void | setValidatorCallbackName(const QString &name)
void | setValue(const QString &key, const QString &value)
QStringList | stopProcessForUpdateRequests() const
bool | uninstallationRequested() const
bool | updateRequested()
quint64 | updateUncompressedSize()
QWidget * | userInterface(const QString &name) const
QStringList | userInterfaces() const
bool | validatePage()
QString | value(const QString &key, const QString &defaultValue = QString()) const
QHash<QString, QString> | variables() const

## Public Slots

void | setAutoCreateOperations(bool autoCreateOperations)

## Signals

void | loaded()
void | valueChanged(const QString &key, const QString &value)
void | virtualStateChanged()

## Detailed Description

The Component class represents the current component.

## Property Documentation

### archives : const QStringList

This property holds the list of archive URLs registered for the component.

The URLs are prefixed with `installer://`.

Access functions:

QStringList | archives() const

See also addDownloadableArchive() and removeDownloadableArchive().

### autoCreateOperations : bool

This property holds whether some standard operations for the component should be automatically created when the installation starts.

The default is `true`.

Access functions:

bool | autoCreateOperations() const
void | setAutoCreateOperations(bool autoCreateOperations)

### autoDependencies : const QStringList

This property holds the value of the element in the package information file.

Access functions:

QStringList | autoDependencies() const

### default : const bool

This property holds whether the component is a default one. This is a read-only property.

Note: Always `false` for virtual components.

Access functions:

bool | isDefault() const

### dependencies : const QStringList

This property holds the components this component depends on. This is a read-only property.

Access functions:

QStringList | dependencies() const

### displayName : const QString

This property holds the name of the component as shown in the user interface.

Access functions:

QString | displayName() const

### enabled : const bool

This property holds whether the component is currently enabled. The property is both readable and writable.

### fromOnlineRepository : const bool

This property holds whether this component has been loaded from an online repository.

Access functions:

bool | isFromOnlineRepository() const

### installed : const bool

This property holds whether the component is installed. This is a read-only property.

Access functions:

bool | isInstalled() const

### name : const QString

This property holds the name of the component as set in the tag of the package information file.

Access functions:

QString | name() const

### repositoryUrl : const QUrl

This property holds the repository URL the component is downloaded from.

If this component is not downloaded from an online repository, returns an empty QUrl.

Access functions:

QUrl | repositoryUrl() const

### userInterfaces : const QStringList

This property holds a list of all user interface class names known to this component.

Access functions:

QStringList | userInterfaces() const

## Member Function Documentation

### Component::Component(PackageManagerCore *core)

Creates a new component in the package manager specified by core.

### Component::~Component()

Destroys the component.

### void Component::addDependency(const QString &newDependency)

Adds the component specified by newDependency to the list of dependencies.

See also component.addDependency and dependencies.

### void Component::addDownloadableArchive(const QString &path)

Adds the archive path to this component. This can only be called if this component was downloaded from an online repository. When adding path, it will be downloaded from the repository when the installation starts.

See also component.addDownloadableArchive, removeDownloadableArchive(), fromOnlineRepository, and archives.

### void Component::addElevatedOperation(Operation *operation)

Adds operation to the list of operations needed to install this component. operation is executed with elevated rights.

### bool Component::addElevatedOperation(const QString &operation, const QString &parameter1 = QString(), const QString &parameter2 = QString(), const QString &parameter3 = QString(), const QString &parameter4 = QString(), const QString &parameter5 = QString(), const QString &parameter6 = QString(), const QString &parameter7 = QString(), const QString &parameter8 = QString(), const QString &parameter9 = QString(), const QString &parameter10 = QString())

Convenience method for calling the elevated operation operation with up to ten parameters: parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, and parameter10.

See also component.addElevatedOperation.

### bool Component::addElevatedOperation(const QString &operation, const QStringList &parameters)

Creates and adds the installation operation operation. Add any number of parameters. The variables that the parameters contain, such as `@TargetDir@`, are replaced with their values. The operation is executed with elevated rights.

### void Component::addOperation(Operation *operation)

Adds operation to the list of operations needed to install this component.

### bool Component::addOperation(const QString &operation, const QString &parameter1 = QString(), const QString &parameter2 = QString(), const QString &parameter3 = QString(), const QString &parameter4 = QString(), const QString &parameter5 = QString(), const QString &parameter6 = QString(), const QString &parameter7 = QString(), const QString &parameter8 = QString(), const QString &parameter9 = QString(), const QString &parameter10 = QString())

Convenience method for calling the operation operation with up to ten parameters: parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, and parameter10.

See also component.addOperation.

### bool Component::addOperation(const QString &operation, const QStringList &parameters)

Creates and adds an installation operation for operation. Add any number of parameters. The variables that the parameters contain, such as `@TargetDir@`, are replaced with their values.

### void Component::addStopProcessForUpdateRequest(const QString &process)

Adds a request for quitting the process process before installing, updating, or uninstalling the component.

See also component.addStopProcessForUpdateRequest.

### void Component::appendComponent(Component *component)

Appends component as a child of this component. If component already has a parent, it is removed from the previous parent. If the component contains several children and has the SortingPriorityGreaterThan() sorting priority set, the child list is sorted so that the child component with the highest priority is placed on top.

### QStringList Component::archives() const

Contains the names of all archives known to this component. Even downloaded archives are mapped to the `installer://` URL through the used QFileEngineHandler during the download process.

Note: Getter function for property archives.

### bool Component::autoCreateOperations() const

Specifies whether operations should be automatically created when the installation starts. This would be done by calling createOperations(). If you set this to `false`, it is completely up to the component's script to create all operations.

Note: Getter function for property autoCreateOperations.

See also setAutoCreateOperations() and component.autoCreateOperations.

### `[virtual]` void Component::beginInstallation()

See also component.beginInstallation.

### bool Component::componentChangeRequested()

Returns `true` if that component will be changed (update, installation, or uninstallation).

See also component.componentChangeRequested.

### `[virtual]` void Component::createOperations()

See also component.createOperations and createOperationsForArchive().

### `[virtual]` void Component::createOperationsForArchive(const QString &archive)

Creates all operations needed to install this component's archive. This method gets called from createOperations. You can override this method by providing a method with the same name in the component script.

Note: If you call this method from a script, it will not call the script's method with the same name.

The default implementation calls createOperationsForPath for everything contained in the archive. If archive is a compressed archive known to the installer system, an Extract operation is created, instead.

See also component.createOperationsForArchive.

### `[virtual]` void Component::createOperationsForPath(const QString &path)

Creates all operations needed to install this component's path. path is a fully qualified filename including the component's name. This method gets called from createOperationsForArchive. You can override it by providing a method with the same name in the component script.

Note: RSA signature files are omitted by this method.

Note: If you call this method from a script, it will not call the script's method with the same name.

The default implementation is recursively creating Copy and Mkdir operations for all files and folders within path.

See also component.createOperationsForPath.

### QList<Component *> Component::descendantComponents() const

Returns a list of child components, including all descendants of the component's children.

Note: The returned list does include all children; non-virtual components as well as virtual components.

### QString Component::displayName() const

Contains this component's display name as visible to the user.

Note: Getter function for property displayName.

### QStringList Component::downloadableArchives() const

Returns the archives to be downloaded from the online repository before installation.

### bool Component::forcedInstallation() const

Returns whether this component should always be installed.

### bool Component::installationRequested() const

Returns whether the user wants to install the component.

See also component.installationRequested.

### bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const

Determines whether the component comes as an auto dependency. Returns `true` if all components in componentsToInstall are already installed or selected for installation and this component thus needs to be installed as well.

See also component.isAutoDependOn.

### bool Component::isFromOnlineRepository() const

Returns whether this component has been loaded from an online repository.

Note: Getter function for property fromOnlineRepository.

See also component.isFromOnlineRepository, addDownloadableArchive(), and fromOnlineRepository.

### bool Component::isSelected() const

Returns whether the component is selected.

### bool Component::isSelectedForInstallation() const

Returns whether the component is selected for installation.

### bool Component::isUninstalled() const

Returns whether the component is uninstalled.

See also component.isUninstalled.

### bool Component::isVirtual() const

Returns whether this component is virtual.

### QHash<QString, QPair<QString, QString> > Component::licenses() const

Returns a hash that contains the file names and text of license files for the component.

### void Component::loadComponentScript()

Loads the component script into the script engine.

### void Component::loadComponentScript(const QString &fileName)

Loads the script at fileName into the script engine. The installer and all its components as well as other useful things are being exported into the script. For more information, see Component Scripting.

Throws an error when either the script at fileName could not be opened, or QScriptEngine could not evaluate the script.

### void Component::loadDataFromPackage(const Package &package)

Sets variables according to the values set in the package.xml file of package. Also loads UI files, licenses and translations if they are referenced in the package.xml.

### void Component::loadDataFromPackage(const LocalPackage &package)

Sets variables according to the values set in the package.xml file of a local package.

### void Component::loadLicenses(const QString &directory, const QHash<QString, QVariant> &licenseHash)

Loads the text of the licenses contained in licenseHash from directory. This is saved into a new hash containing the filename and the text of that file.

### void Component::loadTranslations(const QDir &directory, const QStringList &qms)

Loads the translations matching the name filters qms inside directory. Only translations with a base name matching the current locale's name are loaded. For more information, see Translating Pages.

### void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis)

Loads the user interface files matching the name filters uis inside directory. The loaded interface can be accessed via userInterfaces() by using the class name set in the UI file.

### `[signal]` void Component::loaded()

See also component.loaded.

### QString Component::localTempPath() const

Returns the path to the local directory where the component is temporarily stored.

### void Component::markAsPerformedInstallation()

Marks the component as installed.

### QString Component::name() const

Contains the unique identifier of this component.

Note: Getter function for property name.

### OperationList Component::operations() const

Returns the operations needed to install this component. If autoCreateOperations() is `true`, createOperations() is called if no operations have been automatically created yet.

### bool Component::operationsCreatedSuccessfully() const

Returns whether the operations needed to install this component were created successfully.

### PackageManagerCore *Component::packageManagerCore() const

Returns the installer this component belongs to.

### Component *Component::parentComponent() const

Returns the parent of this component. For example, the parent of a component called `org.qt-project.sdk.qt` is `org.qt-project.sdk` if it exists.

### QList<QPair<QString, bool> > Component::pathsForUninstallation() const

Returns the list of paths previously registered for uninstallation with registerPathForUninstallation().

### void Component::registerPathForUninstallation(const QString &path, bool wipe = false)

Registers the file or directory at path for being removed when this component gets uninstalled. In case of a directory, this will be recursive. If wipe is set to `true`, the directory will also be deleted if it contains changes made by the user after installation.

See also component.registerPathForUninstallation.

### void Component::removeComponent(Component *component)

Removes component if it is a child of this component. The component object still exists after the function returns. It is up to the caller to delete the passed component.

### void Component::removeDownloadableArchive(const QString &path)

Removes the archive path previously added via addDownloadableArchive() from this component. This can only be called if this component was downloaded from an online repository.

See also component.removeDownloadableArchive, addDownloadableArchive(), fromOnlineRepository, and archives.

### void Component::removeStopProcessForUpdateRequest(const QString &process)

Removes the request for quitting the process process again.

See also component.removeStopProcessForUpdateRequest.

### QUrl Component::repositoryUrl() const

Contains the repository URL this component is downloaded from. If this component is not downloaded from an online repository, returns an empty QUrl.

Note: Getter function for property repositoryUrl.

See also setRepositoryUrl().

### void Component::setInstalled()

See also isInstalled() and component.setInstalled.

### void Component::setRepositoryUrl(const QUrl &url)

Sets this component's repository URL as url.

See also repositoryUrl().

### void Component::setStopProcessForUpdateRequest(const QString &process, bool requested)

A convenience function for adding or removing the request for stopping process depending on whether requested is `true` (add) or `false` (remove).

See also component.addStopProcessForUpdateReques.

### void Component::setUninstalled()

See also isUninstalled() and component.setUninstalled.

### void Component::setUpdateAvailable(bool isUpdateAvailable)

Sets the isUpdateAvailable flag to `true` to indicate that the core found an update.

See also component.setUpdateAvailable.

### void Component::setValidatorCallbackName(const QString &name)

Sets the validator callback name to name.

### void Component::setValue(const QString &key, const QString &value)

Sets the value of the variable with key to value.

See also value() and component.setValue.

### QStringList Component::stopProcessForUpdateRequests() const

The list of processes that need to be closed before installing, updating, or uninstalling this component.

### bool Component::uninstallationRequested() const

Returns whether the user wants to uninstall the component.

See also component.uninstallationRequested.

### bool Component::updateRequested()

Returns whether the user wants to install the update for this component.

See also component.updateRequested.

### quint64 Component::updateUncompressedSize()

Returns the size of a compressed archive.

### QWidget *Component::userInterface(const QString &name) const

Returns the QWidget created for name or `0` if the widget has been deleted or cannot be found.

See also component.userInterface.

### bool Component::validatePage()

Calls the script method with the validator callback name. Returns `true` if the method returns `true`. Always returns `true` if the validator callback name is empty.

### QString Component::value(const QString &key, const QString &defaultValue = QString()) const

Returns the value of variable name key. If key is not known yet, defaultValue is returned.

Note: If a component is virtual and you ask for the component value with the key `Default`, it will always return `false`.

See also setValue().

### `[signal]` void Component::valueChanged(const QString &key, const QString &value)

Emitted when the value of the variable with the name key changes to value.

See also component.valueChanged and setValue().

### QHash<QString, QString> Component::variables() const

Returns a key and value based hash of all variables set for this component.

### `[signal]` void Component::virtualStateChanged()

See also component.virtualStateChanged.