File indexing completed on 2022-09-27 16:24:28

0001 /***************************************************************************
0002  *   Copyright (C) 2009-2018 by Daniel Nicoletti                           *
0003  *   dantti12@gmail.com                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; see the file COPYING. If not, write to       *
0017  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0018  *   Boston, MA 02110-1301, USA.                                           *
0019  ***************************************************************************/
0020 #include "BackendDetails.h"
0021 #include "ui_BackendDetails.h"
0022 
0023 #include <QStringBuilder>
0024 #include <KLocalizedString>
0025 
0026 #include <Daemon>
0027 
0028 using namespace PackageKit;
0029 
0030 BackendDetails::BackendDetails(QWidget *parent) :
0031     QDialog(parent),
0032     ui(new Ui::BackendDetails)
0033 {
0034     ui->setupUi(this);
0035 
0036     setWindowTitle(i18n("Backend Details"));
0037     setWindowIcon(QIcon::fromTheme(QLatin1String("help-about")));
0038 
0039     // update information about PackageKit backend
0040     connect(Daemon::global(), &Daemon::changed, this, &BackendDetails::daemonChanged);
0041 
0042     if (Daemon::global()->isRunning()) {
0043         daemonChanged();
0044     }
0045 }
0046 
0047 BackendDetails::~BackendDetails()
0048 {
0049     delete ui;
0050 }
0051 
0052 void BackendDetails::daemonChanged()
0053 {
0054     // PackageKit
0055     QString versionMajor = QString::number(Daemon::global()->versionMajor());
0056     QString versionMinor = QString::number(Daemon::global()->versionMinor());
0057     QString versionMicro = QString::number(Daemon::global()->versionMicro());
0058     ui->pkVersionL->setText(versionMajor % QLatin1Char('.') % versionMinor % QLatin1Char('.') % versionMicro);
0059 
0060     // GENERAL - Setup backend name and author
0061     ui->nameL->setText(Daemon::global()->backendName());
0062     ui->descriptionL->setText(Daemon::global()->backendDescription());
0063     ui->authorL->setText(Daemon::global()->backendAuthor());
0064     ui->distroL->setText(Daemon::global()->distroID());
0065 
0066     // METHODS - Setup backend supported methods
0067     Transaction::Roles actions = Daemon::global()->roles();// TODO this is async now
0068     ui->getUpdatesCB->setChecked(actions & Transaction::RoleGetUpdates);
0069     ui->getDistroUpgradesCB->setChecked(actions & Transaction::RoleGetDistroUpgrades);
0070     ui->refreshCacheCB->setChecked(actions & Transaction::RoleRefreshCache);
0071     ui->searchNameCB->setChecked(actions & Transaction::RoleSearchName);
0072     ui->searchDetailsCB->setChecked(actions & Transaction::RoleSearchDetails);
0073     ui->searchGroupCB->setChecked(actions & Transaction::RoleSearchGroup);
0074     ui->searchFileCB->setChecked(actions & Transaction::RoleSearchFile);
0075     ui->cancelCB->setChecked(actions & Transaction::RoleCancel);
0076     ui->resolveCB->setChecked(actions & Transaction::RoleResolve);
0077 
0078     ui->updatePackageCB->setChecked(actions & Transaction::RoleUpdatePackages);
0079     ui->installPackageCB->setChecked(actions & Transaction::RoleInstallPackages);
0080     ui->removePackageCB->setChecked(actions & Transaction::RoleRemovePackages);
0081     ui->getDependsCB->setChecked(actions & Transaction::RoleDependsOn);
0082     ui->getRequiresCB->setChecked(actions & Transaction::RoleRequiredBy);
0083     ui->getUpdateDetailCB->setChecked(actions & Transaction::RoleGetUpdateDetail);
0084     ui->getDescriptionCB->setChecked(actions & Transaction::RoleGetDetails);
0085     ui->getFilesCB->setChecked(actions & Transaction::RoleRefreshCache);
0086     ui->installFileCB->setChecked(actions & Transaction::RoleInstallFiles);
0087 
0088     ui->getRepositoryListCB->setChecked(actions & Transaction::RoleGetRepoList);
0089     ui->repositoryEnableCB->setChecked(actions & Transaction::RoleRepoEnable);
0090     ui->repositorySetEnableCB->setChecked(actions & Transaction::RoleRepoSetData);
0091     ui->whatProvidesCB->setChecked(actions & Transaction::RoleWhatProvides);
0092     ui->getPackagesCB->setChecked(actions & Transaction::RoleGetPackages);
0093     ui->repairSystemCB->setChecked(actions & Transaction::RoleRepairSystem);
0094 
0095     // FILTERS - Setup filters
0096     Transaction::Filters filters = Daemon::global()->filters();
0097     ui->installedCB->setChecked(filters & Transaction::FilterInstalled);
0098     ui->guiCB->setChecked(filters & Transaction::FilterGui);
0099 
0100     ui->developmentCB->setChecked(filters & Transaction::FilterDevel);
0101     ui->freeCB->setChecked(filters & Transaction::FilterFree);
0102 
0103     ui->visibleCB->setChecked(filters & Transaction::FilterVisible);
0104     ui->supportedCB->setChecked(filters & Transaction::FilterSupported);
0105 
0106     ui->newestCB->setChecked(filters & Transaction::FilterNewest);
0107     ui->archCB->setChecked(filters & Transaction::FilterNotArch);
0108 }
0109 
0110 #include "moc_BackendDetails.cpp"