Commit f2f85876 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

pk: Make sure that we give precedence to the first pkgid we receive

This is something Fedora seems to do and we were not honoring.


(cherry picked from commit 9572f935)
parent 330af80e
......@@ -54,16 +54,16 @@ QString PackageKitResource::availablePackageId() const
if (!pkgid.isEmpty())
return pkgid;
QMap<PackageKit::Transaction::Info, QStringList>::const_iterator it = m_packages.constFind(PackageKit::Transaction::InfoAvailable);
const auto it = m_packages.constFind(PackageKit::Transaction::InfoAvailable);
if (it != m_packages.constEnd())
return it->last();
return it->first();
return installedPackageId();
}
QString PackageKitResource::installedPackageId() const
{
const auto installed = m_packages[PackageKit::Transaction::InfoInstalled];
return installed.isEmpty() ? QString() : installed.last();
return installed.isEmpty() ? QString() : installed.first();
}
QString PackageKitResource::comment()
......@@ -147,9 +147,9 @@ void PackageKitResource::addPackageId(PackageKit::Transaction::Info info, const
{
auto oldState = state();
if (arch)
m_packages[info].append(packageId);
m_packages[info].archPkgIds.append(packageId);
else
m_packages[info].prepend(packageId);
m_packages[info].nonarchPkgIds.append(packageId);
if (oldState != state())
emit stateChanged();
......
......@@ -94,7 +94,19 @@ class PackageKitResource : public AbstractResource
/** fetches details individually, it's better if done in batch, like for updates */
virtual void fetchDetails();
QMap<PackageKit::Transaction::Info, QStringList> m_packages;
struct Ids {
QVector<QString> archPkgIds;
QVector<QString> nonarchPkgIds;
QString first() const {
return !archPkgIds.isEmpty() ? archPkgIds.first() : nonarchPkgIds.first();
}
bool isEmpty() const {
return archPkgIds.isEmpty() && nonarchPkgIds.isEmpty();
}
};
QMap<PackageKit::Transaction::Info, Ids> m_packages;
const QString m_summary;
const QString m_name;
int m_dependenciesCount = -1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment