diff options
author | kh1 <qt-info@nokia.com> | 2011-08-11 16:49:08 +0200 |
---|---|---|
committer | kh1 <qt-info@nokia.com> | 2011-08-12 11:03:10 +0200 |
commit | f69b248fb0a9f3dea4cd44edeb77d8dd936c6b29 (patch) | |
tree | e9702614b45a403a771c58b1b5c033c6cb5ce685 /installerbuilder | |
parent | 69d522b9d580f72e908b532736cf85d01fdf2680 (diff) |
Small cleanup.
Add a regular expression constant. Remove superfluous
check if the component is in the list, as in worst case
both methods need to iterate over the list to notice that
the component does not exist.
Review-By: Niels Weber
Diffstat (limited to 'installerbuilder')
-rw-r--r-- | installerbuilder/libinstaller/component.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/installerbuilder/libinstaller/component.cpp b/installerbuilder/libinstaller/component.cpp index 4034a3000..89739291e 100644 --- a/installerbuilder/libinstaller/component.cpp +++ b/installerbuilder/libinstaller/component.cpp @@ -65,6 +65,8 @@ static const QLatin1String scUninstalled("Uninstalled"); static const QLatin1String scCurrentState("CurrentState"); static const QLatin1String scForcedInstallation("ForcedInstallation"); +static QRegExp scCommaRegExp(QLatin1String("\\b(,|, )\\b")); + /*! \class QInstaller::Component Component describes a component within the installer. @@ -166,13 +168,13 @@ void Component::loadDataFromPackage(const Package &package) } setLocalTempPath(QInstaller::pathFromUrl(package.sourceInfo().url)); - const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString() - .split(QRegExp(QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts); + const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString().split(scCommaRegExp, + QString::SkipEmptyParts); if (!uis.isEmpty()) loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), uis); - const QStringList qms = package.data(QLatin1String("Translations")).toString() - .split(QRegExp(QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts); + const QStringList qms = package.data(QLatin1String("Translations")).toString().split(scCommaRegExp, + QString::SkipEmptyParts); if (!qms.isEmpty()) loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), qms); @@ -906,7 +908,7 @@ void Component::setSelected(bool selected) */ QStringList Component::dependencies() const { - return value(scDependencies).split(QRegExp(QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts); + return value(scDependencies).split(scCommaRegExp, QString::SkipEmptyParts); } /*! @@ -934,8 +936,7 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const // If there is no auto depend on value or the value is empty, we have nothing todo. The component does // not need to be installed as an auto dependency. - QStringList autoDependOnList = value(scAutoDependOn).split(QRegExp(QLatin1String("\\b(,|, )\\b")), - QString::SkipEmptyParts); + QStringList autoDependOnList = value(scAutoDependOn).split(scCommaRegExp, QString::SkipEmptyParts); if (autoDependOnList.isEmpty()) return false; @@ -946,13 +947,11 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const } foreach (const QString &component, components) { - if (autoDependOnList.contains(component)) { - autoDependOnList.removeAll(component); - if (autoDependOnList.isEmpty()) { - // If all components in the isAutoDependOn field are already installed or selected for - // installation, this component needs to be installed as well. - return true; - } + autoDependOnList.removeAll(component); + if (autoDependOnList.isEmpty()) { + // If all components in the isAutoDependOn field are already installed or selected for + // installation, this component needs to be installed as well. + return true; } } @@ -967,9 +966,8 @@ bool Component::isDefault() const // the script can override this method if (value(scDefault).compare(QLatin1String("script"), Qt::CaseInsensitive) == 0) { const QScriptValue valueFromScript = callScriptMethod(QLatin1String("isDefault")); - if (valueFromScript.isValid()) { + if (valueFromScript.isValid()) return valueFromScript.toBool(); - } verbose() << "value from script is not valid " << std::endl; return false; } |