summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/installer/commandlineparser.cpp3
-rw-r--r--src/libs/installer/component.cpp9
-rw-r--r--src/libs/installer/component.h2
-rw-r--r--src/libs/installer/constants.h1
-rw-r--r--src/libs/installer/packagemanagercore.cpp21
-rw-r--r--src/libs/installer/packagemanagercore.h3
-rw-r--r--src/sdk/sdkapp.h2
-rw-r--r--tests/auto/installer/componentmodel/tst_componentmodel.cpp56
8 files changed, 92 insertions, 5 deletions
diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp
index bf40c9bc0..60b02c3ae 100644
--- a/src/libs/installer/commandlineparser.cpp
+++ b/src/libs/installer/commandlineparser.cpp
@@ -130,6 +130,9 @@ CommandLineParser::CommandLineParser()
<< CommandLineOptions::scNoForceInstallationShort << CommandLineOptions::scNoForceInstallationLong,
QLatin1String("Allow deselecting components that are marked as forced.")));
m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scNoDefaultInstallationLong,
+ QLatin1String("Deselects components that are marked as default.")));
+ m_parser.addOption(QCommandLineOption(QStringList()
<< CommandLineOptions::scNoSizeCheckingShort << CommandLineOptions::scNoSizeCheckingLong,
QLatin1String("Disable checking of free space for installation target.")));
m_parser.addOption(QCommandLineOption(QStringList()
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 60ec9ae9f..389580e7c 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -305,7 +305,12 @@ void Component::loadDataFromPackage(const Package &package)
setValue(scName, package.data(scName).toString());
setValue(scDisplayName, package.data(scDisplayName).toString());
setValue(scDescription, package.data(scDescription).toString());
- setValue(scDefault, package.data(scDefault).toString());
+
+ QString isDefault = package.data(scDefault, scFalse).toString().toLower();
+ if (PackageManagerCore::noDefaultInstallation())
+ isDefault = scFalse;
+ setValue(scDefault, isDefault);
+
setValue(scAutoDependOn, package.data(scAutoDependOn).toString());
setValue(scCompressedSize, package.data(scCompressedSize).toString());
setValue(scUncompressedSize, package.data(scUncompressedSize).toString());
diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h
index 6dafd61b2..3cb259bd1 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 58660482c..fecba0e6c 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -174,6 +174,7 @@ static const QLatin1String scInstallCompressedRepositoryShort("i");
static const QLatin1String scInstallCompressedRepositoryLong("install-compressed-repository");
static const QLatin1String scCreateLocalRepositoryShort("c");
static const QLatin1String scCreateLocalRepositoryLong("create-local-repository");
+static const QLatin1String scNoDefaultInstallationLong("no-default-installations");
// Developer options
static const QLatin1String scScriptShort("s");
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index d1a9c6351..2287e5a73 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -412,6 +412,7 @@ static QFont *sVirtualComponentsFont = nullptr;
Q_GLOBAL_STATIC(QMutex, globalVirtualComponentsFontMutex);
static bool sNoForceInstallation = false;
+static bool sNoDefaultInstallation = false;
static bool sVirtualComponentsVisible = false;
static bool sCreateLocalRepositoryFromBinary = false;
@@ -1248,6 +1249,26 @@ void PackageManagerCore::setNoForceInstallation(bool value)
/* static */
/*!
+ Returns \c true if components are not selected by default although
+ \c <Default> element is set in the package information file.
+*/
+bool PackageManagerCore::noDefaultInstallation()
+{
+ return sNoDefaultInstallation;
+}
+
+/* static */
+/*!
+ Overwrites the value specified for the component in the \c <Default>
+ element in the package information file with \a value. Setting \a value
+ to \c true unselects the components.
+*/
+void PackageManagerCore::setNoDefaultInstallation(bool value)
+{
+ sNoDefaultInstallation = value;
+}
+/* static */
+/*!
Returns \c true if a local repository should be created from binary content.
*/
bool PackageManagerCore::createLocalRepositoryFromBinary()
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index 9e24b5c0a..67e7d6365 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -110,6 +110,9 @@ public:
static bool noForceInstallation();
static void setNoForceInstallation(bool value);
+ static bool noDefaultInstallation();
+ static void setNoDefaultInstallation(bool value);
+
static bool createLocalRepositoryFromBinary();
static void setCreateLocalRepositoryFromBinary(bool create);
diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h
index dc4641f24..ecaee3758 100644
--- a/src/sdk/sdkapp.h
+++ b/src/sdk/sdkapp.h
@@ -265,6 +265,8 @@ public:
QInstaller::PackageManagerCore::setNoForceInstallation(m_parser
.isSet(CommandLineOptions::scNoForceInstallationLong));
+ QInstaller::PackageManagerCore::setNoDefaultInstallation(m_parser
+ .isSet(CommandLineOptions::scNoDefaultInstallationLong));
QInstaller::PackageManagerCore::setCreateLocalRepositoryFromBinary(m_parser
.isSet(CommandLineOptions::scCreateLocalRepositoryLong)
|| m_core->settings().createLocalRepository());
diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp
index d5cae916c..220aa73e3 100644
--- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp
+++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp
@@ -1,3 +1,31 @@
+/**************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
#include "component.h"
#include "componentmodel.h"
#include "updatesinfo_p.h"
@@ -38,7 +66,8 @@ public:
enum Option {
NoFlags = 0x00,
VirtualsVisible = 0x01,
- NoForcedInstallation = 0x02
+ NoForcedInstallation = 0x02,
+ NoDefaultInstallation = 0x04
};
Q_DECLARE_FLAGS(Options, Option);
@@ -358,11 +387,30 @@ private slots:
}
}
+ void testNoDefaultInstallation()
+ {
+ setPackageManagerOptions(NoDefaultInstallation);
+
+ QList<Component*> rootComponents = loadComponents();
+ testComponentsLoaded(rootComponents);
+
+ // setup the model with 1 column
+ ComponentModel model(1, &m_core);
+ model.setRootComponents(rootComponents);
+ testDefaultInheritedModelBehavior(&model, 1);
+
+ model.setCheckedState(ComponentModel::DefaultChecked);
+ QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked);
+ testModelState(&model, QStringList() << vendorProduct, QStringList(), m_defaultUnchecked
+ + m_uncheckable + m_defaultPartially + QStringList() << vendorSecondProductSub);
+ }
+
private:
void setPackageManagerOptions(Options flags) const
{
m_core.setNoForceInstallation(flags.testFlag(NoForcedInstallation));
m_core.setVirtualComponentsVisible(flags.testFlag(VirtualsVisible));
+ m_core.setNoDefaultInstallation(flags.testFlag(NoDefaultInstallation));
}
void testComponentsLoaded(const QList<Component *> &rootComponents) const
@@ -472,7 +520,10 @@ private:
// we need at least these to be able to test the model
component->setValue("Name", info.data.value("Name").toString());
- component->setValue("Default", info.data.value("Default").toString());
+ QString isDefault = info.data.value("Default").toString();
+ if (m_core.noDefaultInstallation())
+ isDefault = scFalse;
+ component->setValue("Default", isDefault);
component->setValue("Virtual", info.data.value("Virtual").toString());
component->setValue("DisplayName", info.data.value("DisplayName").toString());
component->setValue("Checkable", info.data.value("Checkable").toString());
@@ -516,6 +567,7 @@ private:
QStringList m_defaultPartially;
QStringList m_defaultUnchecked;
QStringList m_uncheckable;
+ QStringList m_defaultNoChecked;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(tst_ComponentModel::Options)