diff options
author | Katja Marttila <katja.marttila@qt.io> | 2024-01-04 16:29:40 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2024-02-23 10:58:34 +0200 |
commit | 3f5a21fe502a513f1cc3bdee1863688a85481fef (patch) | |
tree | a57db88ef6ae38a55c419759ab8418b5109d15f7 /src | |
parent | 46fbd3781595d9fa4818992c10b9511247cca95f (diff) |
Move non-ui related functionality to core
We need to access the core functionality despite of what user interface
is used.
Change-Id: I6c4c7e8526ff24a479128061aa40fba66e61660c
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/componentmodel.cpp | 18 | ||||
-rw-r--r-- | src/libs/installer/componentmodel.h | 3 | ||||
-rw-r--r-- | src/libs/installer/componentselectionpage_p.cpp | 50 | ||||
-rw-r--r-- | src/libs/installer/componentselectionpage_p.h | 5 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 147 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.h | 18 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 19 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.h | 5 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 86 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.h | 2 |
10 files changed, 209 insertions, 144 deletions
diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp index 7f9c3dcd4..1e8dd1ff7 100644 --- a/src/libs/installer/componentmodel.cpp +++ b/src/libs/installer/componentmodel.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -335,6 +335,22 @@ QSet<Component *> ComponentModel::uncheckable() const return m_uncheckable; } +bool ComponentModel::componentsSelected() const +{ + if (m_core->isInstaller() || m_core->isUpdater()) + return checked().count(); + + if (checkedState().testFlag(ComponentModel::DefaultChecked) == false) + return true; + + const QSet<Component *> uncheckables = uncheckable(); + for (auto &component : uncheckables) { + if (component->forcedInstallation() && !component->isInstalled()) + return true; // allow installation for new forced components + } + return false; +} + /*! Returns a pointer to the PackageManagerCore this model belongs to. */ diff --git a/src/libs/installer/componentmodel.h b/src/libs/installer/componentmodel.h index 1e8a2d297..c93dd60ae 100644 --- a/src/libs/installer/componentmodel.h +++ b/src/libs/installer/componentmodel.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -80,6 +80,7 @@ public: QSet<Component *> partially() const; QSet<Component *> unchecked() const; QSet<Component *> uncheckable() const; + bool componentsSelected() const; PackageManagerCore *core() const; ComponentModel::ModelState checkedState() const; diff --git a/src/libs/installer/componentselectionpage_p.cpp b/src/libs/installer/componentselectionpage_p.cpp index d9ed9a0ec..b68eebf06 100644 --- a/src/libs/installer/componentselectionpage_p.cpp +++ b/src/libs/installer/componentselectionpage_p.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2023 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -74,20 +74,17 @@ ComponentSelectionPagePrivate::ComponentSelectionPagePrivate(ComponentSelectionP , m_tabWidget(nullptr) , m_descriptionBaseWidget(nullptr) , m_categoryWidget(Q_NULLPTR) - , m_allowCompressedRepositoryInstall(false) , m_allowCreateOfflineInstaller(false) , m_categoryLayoutVisible(false) , m_allModel(m_core->defaultComponentModel()) , m_updaterModel(m_core->updaterComponentModel()) , m_currentModel(m_allModel) - , m_proxyModel(new ComponentSortFilterProxyModel(q)) + , m_proxyModel(m_core->componentSortFilterProxyModel()) , m_componentsResolved(false) , m_headerStretchLastSection(false) { m_treeView->setObjectName(QLatin1String("ComponentsTreeView")); m_treeView->setUniformRowHeights(true); - m_proxyModel->setRecursiveFilteringEnabled(true); - m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_descriptionBaseWidget = new QWidget(q); m_descriptionBaseWidget->setObjectName(QLatin1String("DescriptionBaseWidget")); @@ -237,10 +234,6 @@ ComponentSelectionPagePrivate::ComponentSelectionPagePrivate(ComponentSelectionP connect(m_core, SIGNAL(metaJobInfoMessage(QString)), this, SLOT(setMessage(QString))); connect(m_core, &PackageManagerCore::metaJobTotalProgress, this, &ComponentSelectionPagePrivate::setTotalProgress); - -#ifdef INSTALLCOMPRESSED - allowCompressedRepositoryInstall(); -#endif } ComponentSelectionPagePrivate::~ComponentSelectionPagePrivate() @@ -248,11 +241,6 @@ ComponentSelectionPagePrivate::~ComponentSelectionPagePrivate() } -void ComponentSelectionPagePrivate::allowCompressedRepositoryInstall() -{ - m_allowCompressedRepositoryInstall = true; -} - void ComponentSelectionPagePrivate::setAllowCreateOfflineInstaller(bool allow) { m_allowCreateOfflineInstaller = allow; @@ -260,7 +248,7 @@ void ComponentSelectionPagePrivate::setAllowCreateOfflineInstaller(bool allow) void ComponentSelectionPagePrivate::showCompressedRepositoryButton() { - if (m_allowCompressedRepositoryInstall) + if (m_core->allowCompressedRepositoryInstall()) m_qbspPushButton->setVisible(true); } @@ -498,27 +486,6 @@ void ComponentSelectionPagePrivate::deselectAll() m_currentModel->setCheckedState(ComponentModel::AllUnchecked); } -void ComponentSelectionPagePrivate::enableRepositoryCategory(const QString &repositoryName, bool enable) -{ - QMap<QString, RepositoryCategory> organizedRepositoryCategories = m_core->settings().organizedRepositoryCategories(); - - QMap<QString, RepositoryCategory>::iterator i = organizedRepositoryCategories.find(repositoryName); - RepositoryCategory repoCategory; - while (i != organizedRepositoryCategories.end() && i.key() == repositoryName) { - repoCategory = i.value(); - i++; - } - - RepositoryCategory replacement = repoCategory; - replacement.setEnabled(enable); - QSet<RepositoryCategory> tmpRepoCategories = m_core->settings().repositoryCategories(); - if (tmpRepoCategories.contains(repoCategory)) { - tmpRepoCategories.remove(repoCategory); - tmpRepoCategories.insert(replacement); - m_core->settings().addRepositoryCategories(tmpRepoCategories); - } -} - void ComponentSelectionPagePrivate::updateWidgetVisibility(bool show) { if (show) @@ -546,7 +513,7 @@ void ComponentSelectionPagePrivate::fetchRepositoryCategories() QList<QCheckBox*> checkboxes = m_categoryGroupBox->findChildren<QCheckBox *>(); for (int i = 0; i < checkboxes.count(); i++) { QCheckBox *checkbox = checkboxes.at(i); - enableRepositoryCategory(checkbox->objectName(), checkbox->isChecked()); + m_core->enableRepositoryCategory(checkbox->objectName(), checkbox->isChecked()); } if (!m_core->fetchRemotePackagesTree()) { @@ -571,15 +538,8 @@ void ComponentSelectionPagePrivate::qbspButtonClicked() ComponentSelectionPage::tr("Open File"),defaultDownloadDirectory, QLatin1String("QBSP or 7z Files (*.qbsp *.7z)")); - QSet<Repository> set; - foreach (QString fileName, fileNames) { - Repository repository = Repository::fromUserInput(fileName, true); - repository.setEnabled(true); - set.insert(repository); - } - if (set.count() > 0) { + if (m_core->addQBspRepositories(fileNames)) { updateWidgetVisibility(true); - m_core->settings().addTemporaryRepositories(set, false); if (!m_core->fetchCompressedPackagesTree()) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("FailToFetchPackages"), tr("Error"), m_core->error()); diff --git a/src/libs/installer/componentselectionpage_p.h b/src/libs/installer/componentselectionpage_p.h index ee00347a8..187fce61d 100644 --- a/src/libs/installer/componentselectionpage_p.h +++ b/src/libs/installer/componentselectionpage_p.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2023 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -66,7 +66,6 @@ public: explicit ComponentSelectionPagePrivate(ComponentSelectionPage *qq, PackageManagerCore *core); ~ComponentSelectionPagePrivate(); - void allowCompressedRepositoryInstall(); void setAllowCreateOfflineInstaller(bool allow); void showCompressedRepositoryButton(); void hideCompressedRepositoryButton(); @@ -83,7 +82,6 @@ public slots: void updateAllCheckStates(int which); void selectAll(); void deselectAll(); - void enableRepositoryCategory(const QString &repositoryName, bool enable); void updateWidgetVisibility(bool show); void fetchRepositoryCategories(); void createOfflineButtonClicked(); @@ -117,7 +115,6 @@ private: QProgressBar *m_progressBar; QGridLayout *m_mainGLayout; QVBoxLayout *m_rightSideVLayout; - bool m_allowCompressedRepositoryInstall; bool m_allowCreateOfflineInstaller; bool m_categoryLayoutVisible; ComponentModel *m_allModel; diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 0471be537..cdf27fb35 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2023 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -47,6 +47,7 @@ #include "installercalculator.h" #include "uninstallercalculator.h" #include "loggingutils.h" +#include "componentsortfilterproxymodel.h" #include <productkeycheck.h> @@ -1940,6 +1941,92 @@ void PackageManagerCore::setTemporaryRepositories(const QStringList &repositorie settings().setTemporaryRepositories(repositorySet, replace); } +bool PackageManagerCore::addQBspRepositories(const QStringList &repositories) +{ + QSet<Repository> set; + foreach (QString fileName, repositories) { + Repository repository = Repository::fromUserInput(fileName, true); + repository.setEnabled(true); + set.insert(repository); + } + if (set.count() > 0) { + settings().addTemporaryRepositories(set, false); + return true; + } + return false; +} + +bool PackageManagerCore::validRepositoriesAvailable() const +{ + foreach (const Repository &repo, settings().repositories()) { + if (repo.isEnabled() && repo.isValid()) { + return true; + } + } + return false; +} + +void PackageManagerCore::setAllowCompressedRepositoryInstall(bool allow) +{ + d->m_allowCompressedRepositoryInstall = allow; +} + +bool PackageManagerCore::allowCompressedRepositoryInstall() const +{ + return d->m_allowCompressedRepositoryInstall; +} + +bool PackageManagerCore::showRepositoryCategories() const +{ + bool showCagetories = settings().repositoryCategories().count() > 0 && !isOfflineOnly() && !isUpdater(); + if (showCagetories) + settings().setAllowUnstableComponents(true); + return showCagetories; +} + +QVariantMap PackageManagerCore::organizedRepositoryCategories() const +{ + QVariantMap map; + QSet<RepositoryCategory> categories = settings().repositoryCategories(); + foreach (const RepositoryCategory &category, categories) + map.insert(category.displayname(), QVariant::fromValue(category)); + return map; +} + +void PackageManagerCore::enableRepositoryCategory(const QString &repositoryName, bool enable) +{ + QMap<QString, RepositoryCategory> organizedRepositoryCategories = settings().organizedRepositoryCategories(); + + QMap<QString, RepositoryCategory>::iterator i = organizedRepositoryCategories.find(repositoryName); + RepositoryCategory repoCategory; + while (i != organizedRepositoryCategories.end() && i.key() == repositoryName) { + repoCategory = i.value(); + i++; + } + + RepositoryCategory replacement = repoCategory; + replacement.setEnabled(enable); + QSet<RepositoryCategory> tmpRepoCategories = settings().repositoryCategories(); + if (tmpRepoCategories.contains(repoCategory)) { + tmpRepoCategories.remove(repoCategory); + tmpRepoCategories.insert(replacement); + settings().addRepositoryCategories(tmpRepoCategories); + } +} + +void PackageManagerCore::runProgram() +{ + const QString program = replaceVariables(value(scRunProgram)); + + const QStringList args = replaceVariables(values(scRunProgramArguments)); + if (program.isEmpty()) + return; + + qCDebug(QInstaller::lcInstallerInstallLog) << "starting" << program << args; + QProcess::startDetached(program, args); +} + + /*! Returns the script engine that prepares and runs the component scripts. @@ -2517,6 +2604,20 @@ ComponentModel *PackageManagerCore::updaterComponentModel() const } /*! + Returns the proxy model +*/ + +ComponentSortFilterProxyModel *PackageManagerCore::componentSortFilterProxyModel() +{ + if (!d->m_componentSortFilterProxyModel) { + d->m_componentSortFilterProxyModel = new ComponentSortFilterProxyModel(this); + d->m_componentSortFilterProxyModel->setRecursiveFilteringEnabled(true); + d->m_componentSortFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + } + return d->m_componentSortFilterProxyModel; +} + +/*! Lists available packages filtered with \a regexp without GUI. Virtual components are not listed unless set visible. Optionally, a \a filters hash containing package information elements and regular expressions @@ -2898,6 +2999,20 @@ void PackageManagerCore::addLicenseItem(const QHash<QString, QVariantMap> &licen } } +bool PackageManagerCore::hasLicenses() const +{ + foreach (Component* component, orderedComponentsToInstall()) { + if (isMaintainer() && component->isInstalled()) + continue; // package manager or updater, hide as long as the component is installed + + // The component is about to be installed and provides a license, so the page needs to + // be shown. + if (!component->licenses().isEmpty()) + return true; + } + return false; +} + /*! * Adds \a component local \a dependencies to a hash table for quicker search for * uninstall dependency components. @@ -3127,12 +3242,22 @@ void PackageManagerCore::setCheckAvailableSpace(bool check) } /*! - Checks available disk space if the feature is not explicitly disabled. Informative - text about space status can be retrieved by passing \a message parameter. Returns + * Returns informative text about disk space status + */ +QString PackageManagerCore::availableSpaceMessage() const +{ + return m_availableSpaceMessage; +} + +/*! + Checks available disk space if the feature is not explicitly disabled. Returns \c true if there is sufficient free space on installation and temporary volumes. + + \sa availableSpaceMessage() */ -bool PackageManagerCore::checkAvailableSpace(QString &message) const +bool PackageManagerCore::checkAvailableSpace() { + m_availableSpaceMessage.clear(); const quint64 extraSpace = 256 * 1024 * 1024LL; quint64 required(requiredDiskSpace()); quint64 tempRequired(requiredTemporaryDiskSpace()); @@ -3188,21 +3313,21 @@ bool PackageManagerCore::checkAvailableSpace(QString &message) const } if (cacheOnSameVolume && (installVolumeAvailableSize <= (required + tempRequired))) { - message = tr("Not enough disk space to store temporary files and the " + m_availableSpaceMessage = tr("Not enough disk space to store temporary files and the " "installation. %1 are available, while the minimum required is %2.").arg( humanReadableSize(installVolumeAvailableSize), humanReadableSize(required + tempRequired)); return false; } if (installVolumeAvailableSize < required) { - message = tr("Not enough disk space to store all selected components! %1 are " + m_availableSpaceMessage = tr("Not enough disk space to store all selected components! %1 are " "available, while the minimum required is %2.").arg(humanReadableSize(installVolumeAvailableSize), humanReadableSize(required)); return false; } if (cacheVolumeAvailableSize < tempRequired) { - message = tr("Not enough disk space to store temporary files! %1 are available, " + m_availableSpaceMessage = tr("Not enough disk space to store temporary files! %1 are available, " "while the minimum required is %2. You may select another location for the " "temporary files by modifying the local cache path from the installer settings.") .arg(humanReadableSize(cacheVolumeAvailableSize), humanReadableSize(tempRequired)); @@ -3211,22 +3336,22 @@ bool PackageManagerCore::checkAvailableSpace(QString &message) const if (installVolumeAvailableSize - required < 0.01 * targetVolume.size()) { // warn for less than 1% of the volume's space being free - message = tr("The volume you selected for installation seems to have sufficient space for " + m_availableSpaceMessage = tr("The volume you selected for installation seems to have sufficient space for " "installation, but there will be less than 1% of the volume's space available afterwards."); } else if (installVolumeAvailableSize - required < 100 * 1024 * 1024LL) { // warn for less than 100MB being free - message = tr("The volume you selected for installation seems to have sufficient " + m_availableSpaceMessage = tr("The volume you selected for installation seems to have sufficient " "space for installation, but there will be less than 100 MB available afterwards."); } #ifdef Q_OS_WIN if (isOfflineGenerator() && (required > UINT_MAX)) { - message = tr("The estimated installer size %1 would exceed the supported executable " + m_availableSpaceMessage = tr("The estimated installer size %1 would exceed the supported executable " "size limit of %2. The application may not be able to run.") .arg(humanReadableSize(required), humanReadableSize(UINT_MAX)); } #endif } - message = QString::fromLatin1("%1 %2").arg(message, + m_availableSpaceMessage = QString::fromLatin1("%1 %2").arg(m_availableSpaceMessage, (isOfflineGenerator() ? tr("Created installer will use %1 of disk space.") : tr("Installation will use %1 of disk space.")) diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h index 713f77f00..009f956d9 100644 --- a/src/libs/installer/packagemanagercore.h +++ b/src/libs/installer/packagemanagercore.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2023 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -53,6 +53,7 @@ class ScriptEngine; class PackageManagerCorePrivate; class PackageManagerProxyFactory; class Settings; +class ComponentSortFilterProxyModel; // -- PackageManagerCore @@ -210,6 +211,15 @@ public: Q_INVOKABLE void addUserRepositories(const QStringList &repositories); Q_INVOKABLE void setTemporaryRepositories(const QStringList &repositories, bool replace = false, bool compressed = false); + bool addQBspRepositories(const QStringList &repositories); + bool validRepositoriesAvailable() const; + Q_INVOKABLE void setAllowCompressedRepositoryInstall(bool allow); + bool allowCompressedRepositoryInstall() const; + bool showRepositoryCategories() const; + QVariantMap organizedRepositoryCategories() const; + void enableRepositoryCategory(const QString &repositoryName, bool enable); + void runProgram(); + Q_INVOKABLE void autoAcceptMessageBoxes(); Q_INVOKABLE void autoRejectMessageBoxes(); Q_INVOKABLE void setMessageBoxAutomaticAnswer(const QString &identifier, int button); @@ -274,6 +284,7 @@ public: ComponentModel *defaultComponentModel() const; ComponentModel *updaterComponentModel() const; + ComponentSortFilterProxyModel *componentSortFilterProxyModel(); void listInstalledPackages(const QString ®exp = QString()); bool listAvailablePackages(const QString ®exp = QString(), @@ -326,7 +337,8 @@ public: Q_INVOKABLE bool hasAdminRights() const; void setCheckAvailableSpace(bool check); - bool checkAvailableSpace(QString &message) const; + bool checkAvailableSpace(); + QString availableSpaceMessage() const; Q_INVOKABLE quint64 requiredDiskSpace() const; Q_INVOKABLE quint64 requiredTemporaryDiskSpace() const; @@ -370,6 +382,7 @@ public: void clearLicenses(); QHash<QString, QMap<QString, QString>> sortedLicenses(); void addLicenseItem(const QHash<QString, QVariantMap> &licenses); + bool hasLicenses() const; void createLocalDependencyHash(const QString &component, const QString &dependencies) const; void createAutoDependencyHash(const QString &component, const QString &oldDependencies, const QString &newDependencies) const; @@ -472,6 +485,7 @@ private: friend class PackageManagerCorePrivate; QHash<QString, QString> m_fileDialogAutomaticAnswers; QHash<QString, QStringList> m_localVirtualWithDependants; + QString m_availableSpaceMessage; private: // remove once we deprecate isSelected, setSelected etc... diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 7ccfe2b1c..3985baa6b 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2023 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -188,9 +188,15 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core) , m_proxyFactory(nullptr) , m_defaultModel(nullptr) , m_updaterModel(nullptr) + , m_componentSortFilterProxyModel(nullptr) , m_guiObject(nullptr) , m_remoteFileEngineHandler(nullptr) , m_datFileName(QString()) +#ifdef INSTALLCOMPRESSED + , m_allowCompressedRepositoryInstall(true) +#else + , m_allowCompressedRepositoryInstall(false) +#endif { } @@ -228,9 +234,15 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core, q , m_proxyFactory(nullptr) , m_defaultModel(nullptr) , m_updaterModel(nullptr) + , m_componentSortFilterProxyModel(nullptr) , m_guiObject(nullptr) , m_remoteFileEngineHandler(new RemoteFileEngineHandler) , m_datFileName(datFileName) +#ifdef INSTALLCOMPRESSED + , m_allowCompressedRepositoryInstall(true) +#else + , m_allowCompressedRepositoryInstall(false) +#endif { foreach (const OperationBlob &operation, performedOperations) { std::unique_ptr<QInstaller::Operation> op(KDUpdater::UpdateOperationFactory::instance() @@ -3126,9 +3138,8 @@ bool PackageManagerCorePrivate::calculateComponentsAndRun() qCDebug(QInstaller::lcInstallerInstallLog).noquote() << htmlToString(m_core->componentResolveReasons()); - QString spaceInfo; - const bool spaceOk = m_core->checkAvailableSpace(spaceInfo); - qCDebug(QInstaller::lcInstallerInstallLog) << spaceInfo; + const bool spaceOk = m_core->checkAvailableSpace(); + qCDebug(QInstaller::lcInstallerInstallLog) << m_core->availableSpaceMessage(); if (!spaceOk || !(m_autoConfirmCommand || askUserConfirmCommand())) { qCDebug(QInstaller::lcInstallerInstallLog) << "Installation aborted."; diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h index 22b3ca9f3..c3e3e162c 100644 --- a/src/libs/installer/packagemanagercore_p.h +++ b/src/libs/installer/packagemanagercore_p.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2023 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -62,6 +62,7 @@ class ComponentAlias; class InstallerCalculator; class UninstallerCalculator; class RemoteFileEngineHandler; +class ComponentSortFilterProxyModel; class PackageManagerCorePrivate : public QObject { @@ -314,6 +315,7 @@ private: ComponentModel *m_defaultModel; ComponentModel *m_updaterModel; + ComponentSortFilterProxyModel *m_componentSortFilterProxyModel; QObject *m_guiObject; QScopedPointer<RemoteFileEngineHandler> m_remoteFileEngineHandler; @@ -331,6 +333,7 @@ private: QHash<QString, QStringList > m_componentReplaces; QString m_datFileName; + bool m_allowCompressedRepositoryInstall; }; } // namespace QInstaller diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 806e58823..2a843de01 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -1475,16 +1475,8 @@ int PackageManagerPage::nextId() const if (core->isUninstaller()) return nextNextId; // forcibly hide the license page if we run as uninstaller core->recalculateAllComponents(); - - foreach (Component* component, core->orderedComponentsToInstall()) { - if (core->isMaintainer() && component->isInstalled()) - continue; // package manager or updater, hide as long as the component is installed - - // The component is about to be installed and provides a license, so the page needs to - // be shown. - if (!component->licenses().isEmpty()) - return next; - } + if (core->hasLicenses()) + return next; return nextNextId; // no component with a license or all components with license installed } return next; // default, show the next page @@ -1627,7 +1619,7 @@ bool IntroductionPage::validatePage() bool isOfflineOnlyInstaller = core->isInstaller() && core->isOfflineOnly(); // If not offline only installer, at least one valid repository needs to be available - if (!isOfflineOnlyInstaller && !validRepositoriesAvailable()) { + if (!isOfflineOnlyInstaller && !core->validRepositoriesAvailable()) { setErrorMessage(QLatin1String("<font color=\"red\">") + tr("At least one valid and enabled " "repository required for this action to succeed.") + QLatin1String("</font>")); return isComplete(); @@ -1844,22 +1836,6 @@ void IntroductionPage::setErrorMessage(const QString &error) #endif } -/*! - Returns \c true if at least one valid and enabled repository is available. -*/ -bool IntroductionPage::validRepositoriesAvailable() const -{ - const PackageManagerCore *const core = packageManagerCore(); - bool valid = false; - - foreach (const Repository &repo, core->settings().repositories()) { - if (repo.isEnabled() && repo.isValid()) { - valid = true; - break; - } - } - return valid; -} // -- private slots @@ -1903,9 +1879,9 @@ void IntroductionPage::setPackageManager(bool value) */ void IntroductionPage::initializePage() { - const bool repositoriesAvailable = validRepositoriesAvailable(); - PackageManagerCore *core = packageManagerCore(); + const bool repositoriesAvailable = core->validRepositoriesAvailable(); + if (core->isPackageManager()) { m_packageManager->setChecked(true); } else if (core->isUpdater()) { @@ -1938,7 +1914,7 @@ void IntroductionPage::onCoreNetworkSettingsChanged() PackageManagerCore *core = packageManagerCore(); if (core->isUninstaller() || core->isMaintainer()) { - m_offlineMaintenanceTool = !validRepositoriesAvailable(); + m_offlineMaintenanceTool = !core->validRepositoriesAvailable(); setMaintainerToolsEnabled(!m_offlineMaintenanceTool); m_removeAllComponents->setChecked(m_offlineMaintenanceTool); @@ -2239,13 +2215,7 @@ void ComponentSelectionPage::entering() d->onModelStateChanged(d->m_currentModel->checkedState()); setModified(isComplete()); - if (core->settings().repositoryCategories().count() > 0 && !core->isOfflineOnly() - && !core->isUpdater()) { - d->showCategoryLayout(true); - core->settings().setAllowUnstableComponents(true); - } else { - d->showCategoryLayout(false); - } + d->showCategoryLayout(core->showRepositoryCategories()); d->showCompressedRepositoryButton(); d->showCreateOfflineInstallerButton(true); @@ -2345,16 +2315,6 @@ void ComponentSelectionPage::deselectComponent(const QString &id) } /*! - Adds the possibility to install a compressed repository on component selection - page. A new button which opens a file browser is added for compressed - repository selection. -*/ -void ComponentSelectionPage::allowCompressedRepositoryInstall() -{ - d->allowCompressedRepositoryInstall(); -} - -/*! Adds an additional virtual component with the \a name to be installed. Returns \c true if the virtual component is found and not installed. @@ -2392,18 +2352,7 @@ bool ComponentSelectionPage::isComplete() const if (!d->componentsResolved()) return false; - if (packageManagerCore()->isInstaller() || packageManagerCore()->isUpdater()) - return d->m_currentModel->checked().count(); - - if (d->m_currentModel->checkedState().testFlag(ComponentModel::DefaultChecked) == false) - return true; - - const QSet<Component *> uncheckable = d->m_currentModel->uncheckable(); - for (auto &component : uncheckable) { - if (component->forcedInstallation() && !component->isInstalled()) - return true; // allow installation for new forced components - } - return false; + return d->m_currentModel->componentsSelected(); } @@ -2761,11 +2710,10 @@ void ReadyForInstallationPage::entering() m_taskDetailsBrowser->setVisible(!componentsOk || LoggingHandler::instance().isVerbose()); setComplete(componentsOk); - QString spaceInfo; - if (packageManagerCore()->checkAvailableSpace(spaceInfo)) { - m_msgLabel->setText(QString::fromLatin1("%1 %2").arg(m_msgLabel->text(), spaceInfo)); + if (packageManagerCore()->checkAvailableSpace()) { + m_msgLabel->setText(QString::fromLatin1("%1 %2").arg(m_msgLabel->text(), packageManagerCore()->availableSpaceMessage())); } else { - m_msgLabel->setText(spaceInfo); + m_msgLabel->setText(packageManagerCore()->availableSpaceMessage()); setComplete(false); } } @@ -3172,16 +3120,8 @@ void FinishedPage::leaving() */ void FinishedPage::handleFinishClicked() { - const QString program = - packageManagerCore()->replaceVariables(packageManagerCore()->value(scRunProgram)); - - const QStringList args = packageManagerCore()->replaceVariables(packageManagerCore() - ->values(scRunProgramArguments)); - if (!m_runItCheckBox->isChecked() || program.isEmpty()) - return; - - qCDebug(QInstaller::lcInstallerInstallLog) << "starting" << program << args; - QProcess::startDetached(program, args); + if (m_runItCheckBox->isChecked()) + packageManagerCore()->runProgram(); } /*! diff --git a/src/libs/installer/packagemanagergui.h b/src/libs/installer/packagemanagergui.h index d1492f75d..d83643005 100644 --- a/src/libs/installer/packagemanagergui.h +++ b/src/libs/installer/packagemanagergui.h @@ -262,7 +262,6 @@ private: void leaving() override; void showWidgets(bool show); - bool validRepositoriesAvailable() const; private: bool m_updatesFetched; @@ -331,7 +330,6 @@ public: Q_INVOKABLE void selectDefault(); Q_INVOKABLE void selectComponent(const QString &id); Q_INVOKABLE void deselectComponent(const QString &id); - Q_INVOKABLE void allowCompressedRepositoryInstall(); Q_INVOKABLE bool addVirtualComponentToUninstall(const QString &name); void setAllowCreateOfflineInstaller(bool allow); |