Commit 505e7697 authored by Volker Krause's avatar Volker Krause

Add access to pkpass modification time

Needed for proper update poll time computation.
parent 08fd1eef
......@@ -43,6 +43,7 @@ private Q_SLOTS:
PkPassManager mgr;
const auto now = QDateTime::currentDateTime();
QSignalSpy addSpy(&mgr, &PkPassManager::passAdded);
......@@ -54,12 +55,14 @@ private Q_SLOTS:
const auto passId = QStringLiteral("");
QCOMPARE(mgr.pass(passId), nullptr);
mgr.importPass(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v1.pkpass")));
QCOMPARE(addSpy.size(), 1);
QCOMPARE(, passId);
QVERIFY(mgr.updateTime(passId) >= now);
auto passes = mgr.passes();
QCOMPARE(passes.size(), 1);
......@@ -78,6 +78,10 @@ private:
void updateArrivalData(const KPublicTransport::Departure &arr, const QString &resId);
void updateDepartureData(const KPublicTransport::Departure &dep, const QString &resId);
/** Best known departure time. */
QDateTime departureTime(const QString &resId, const QVariant &res) const;
/** Best known arrival time. */
QDateTime arrivalTime(const QString &resId, const QVariant &res) const;
/** Check if the trip @p res has departed, based on the best knowledge we have. */
bool hasDeparted(const QString &resId, const QVariant &res) const;
/** Check if the trip @p res has arrived, based on the best knowledge we have. */
......@@ -231,6 +231,13 @@ void PkPassManager::updatePass(const QString& passId)
QDateTime PkPassManager::updateTime(const QString &passId) const
const QString passPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/passes/") + passId + QLatin1String(".pkpass");
QFileInfo fi(passPath);
return fi.lastModified();
QDateTime PkPassManager::relevantDate(KPkPass::Pass *pass)
const auto dt = pass->relevantDate();
......@@ -48,6 +48,8 @@ public:
Q_INVOKABLE void removePass(const QString &passId);
void updatePass(const QString &passId);
/** Time the pass was last updated (ie. file system mtime). */
QDateTime updateTime(const QString &passId) const;
static QDateTime relevantDate(KPkPass::Pass *pass);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment