Commit 636fa0eb authored by Volker Krause's avatar Volker Krause
Browse files

Sort health certificates by longest relevant first

That is a good approximation of a sensible order, as eg. outdated test
certificates will end up further down now.
parent 1dd32d24
......@@ -76,8 +76,10 @@ void HealthCertificateManager::importCertificate(const QByteArray &rawData)
beginInsertRows({}, m_certificates.size(), m_certificates.size());
const auto it = std::lower_bound(m_certificates.begin(), m_certificates.end(), certData, certLessThan);
const auto row = std::distance(m_certificates.begin(), it);
beginInsertRows({}, row, row);
m_certificates.insert(it, std::move(certData));
......@@ -170,6 +172,7 @@ void HealthCertificateManager::loadCertificates()
std::sort(m_certificates.begin(), m_certificates.end(), certLessThan);
......@@ -188,3 +191,13 @@ QByteArray HealthCertificateManager::certificateRawData(const CertData &certData
return {};
bool HealthCertificateManager::certLessThan(const CertData &lhs, const CertData &rhs)
const auto lhsDt = KHealthCertificate::relevantUntil(lhs.cert);
const auto rhsDt = KHealthCertificate::relevantUntil(rhs.cert);
if (lhsDt == rhsDt) {
return <;
return lhsDt > rhsDt;
......@@ -44,6 +44,7 @@ private:
QString name;
QVariant cert;
static bool certLessThan(const CertData &lhs, const CertData &rhs);
void loadCertificates();
QByteArray certificateRawData(const CertData &certData) const;
Markdown is supported
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