LocalPackageHub Class | Qt Installer Framework Manual

- Qt Installer Framework Manual
- LocalPackageHub

# LocalPackageHub Class

class KDUpdater::LocalPackageHub

The LocalPackageHub class provides access to information about packages installed on the application side. More...

Header: | #include <LocalPackageHub>

- List of all members, including inherited members

## Public Types

enum | Error { NoError, NotYetReadError, CouldNotReadPackageFileError, InvalidXmlError, InvalidContentError }

## Public Functions

| LocalPackageHub()
| ~LocalPackageHub()
void | addPackage(const QString &name, const QString &version, const QString &title, const QPair<QString, bool> &treeName, const QString &description, const int sortingPriority, const QStringList &dependencies, const QStringList &autoDependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, bool checkable, bool expandedByDefault, const QString &contentSha1)
QString | applicationName() const
QString | applicationVersion() const
void | clearPackageInfos()
KDUpdater::LocalPackageHub::Error | error() const
QString | errorString() const
QString | fileName() const
bool | isValid() const
QMap<QString, KDUpdater::LocalPackage> | localPackages() const
KDUpdater::LocalPackage | packageInfo(const QString &pkgName) const
int | packageInfoCount() const
QList<KDUpdater::LocalPackage> | packageInfos() const
QStringList | packageNames() const
void | refresh()
bool | removePackage(const QString &name)
void | setApplicationName(const QString &name)
void | setApplicationVersion(const QString &version)
void | setFileName(const QString &fileName)
void | writeToDisk()

## Detailed Description

This class parses the installation information XML file specified via the setFileName() method and provides access to the information defined within the file through an API. You can:

- Get the application name via the applicationName() method.
- Get the application version via the applicationVersion() method.
- Get information about the number of packages installed and their meta-data via the packageInfoCount() and packageInfo() methods.

## Member Type Documentation

### enum LocalPackageHub::Error

Error codes related to retrieving information about installed packages:

Constant | Value | Description
--- | --- | ---
`KDUpdater::LocalPackageHub::NoError` | `0` | No error occurred.
`KDUpdater::LocalPackageHub::NotYetReadError` | `1` | The installation information was not parsed yet from the XML file.
`KDUpdater::LocalPackageHub::CouldNotReadPackageFileError` | `2` | The specified installation information file could not be read (does not exist or is not readable).
`KDUpdater::LocalPackageHub::InvalidXmlError` | `3` | The installation information file contains invalid XML.
`KDUpdater::LocalPackageHub::InvalidContentError` | `4` | The installation information file contains valid XML, but does not match the expected format for package descriptions.

## Member Function Documentation

### LocalPackageHub::LocalPackageHub()

Constructs a local package hub. To fully setup the class you have to call setFileName().

See also setFileName.

### `[noexcept]` LocalPackageHub::~LocalPackageHub()

Destructor

### void LocalPackageHub::addPackage(const QString &name, const QString &version, const QString &title, const QPair<QString, bool> &treeName, const QString &description, const int sortingPriority, const QStringList &dependencies, const QStringList &autoDependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, bool checkable, bool expandedByDefault, const QString &contentSha1)

Marks the package specified by name as installed. Sets the values of version, title, treeName, description, sortingPriority, dependencies, autoDependencies, forcedInstallation, virtualComp, uncompressedSize, inheritVersionFrom, checkable, expandedByDefault, and contentSha1 for the package.

### QString LocalPackageHub::applicationName() const

Returns the application name.

See also setApplicationName().

### QString LocalPackageHub::applicationVersion() const

Returns the application version.

See also setApplicationVersion().

### void LocalPackageHub::clearPackageInfos()

Clears the installed package list.

### KDUpdater::LocalPackageHub::Error LocalPackageHub::error() const

Returns the error that was found during the processing of the installation information XML file. If no error was found, returns NoError.

### QString LocalPackageHub::errorString() const

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

### QString LocalPackageHub::fileName() const

Returns the name of the installation information XML file that this class refers to.

See also setFileName().

### bool LocalPackageHub::isValid() const

Returns `true` if LocalPackageHub is valid; otherwise returns `false`. You can use the errorString() method to receive a descriptive error message.

### QMap<QString, KDUpdater::LocalPackage> LocalPackageHub::localPackages() const

Returns a map of all local installed packages. Map key is the package name.

### KDUpdater::LocalPackage LocalPackageHub::packageInfo(const QString &pkgName) const

Returns the package info structure whose name is pkgName. If no such package was found, this function returns a default-constructed value.

### int LocalPackageHub::packageInfoCount() const

Returns the number of KDUpdater::LocalPackage objects contained in this class.

### QList<KDUpdater::LocalPackage> LocalPackageHub::packageInfos() const

Returns all package info structures.

### QStringList LocalPackageHub::packageNames() const

Returns a list of all local installed packages.

### void LocalPackageHub::refresh()

Re-reads the installation information XML file and updates itself. Changes to applicationName() and applicationVersion() are lost after this function returns. The function emits a reset() signal after completion.

### bool LocalPackageHub::removePackage(const QString &name)

Removes the package specified by name. Returns `false` if the package is not found.

### void LocalPackageHub::setApplicationName(const QString &name)

Sets the application name to name. By default, this is the name specified in the `<ApplicationName>` element of the installation information XML file.

See also applicationName().

### void LocalPackageHub::setApplicationVersion(const QString &version)

Sets the application version to version. By default, this is the version specified in the `<ApplicationVersion>` element of the installation information XML file.

See also applicationVersion().

### void LocalPackageHub::setFileName(const QString &fileName)

Sets the complete file name of the installation information XML file to fileName. The function also issues a call to refresh() to reload installation information from the XML file.

See also fileName().

### void LocalPackageHub::writeToDisk()

Writes the installation information file to disk.