Commit 7e58952c authored by Tobias Fella's avatar Tobias Fella
Browse files

Check availability of documents while counting them

Fixes the cases where documents are counted but not available.
This can happen if the events come from android's system calendar or if the document was deleted from another event's document list.
In both of these cases, the reference should probably be deleted instead, but this is a good safety measure nevertheless.

BUG: 456510
parent 27a559ac
Pipeline #202815 passed with stage
in 4 minutes and 44 seconds
......@@ -34,6 +34,7 @@ Kirigami.ScrollablePage {
reservationManager: ReservationManager
liveDataManager: LiveDataManager
transferManager: TransferManager
documentManager: DocumentManager
}
property alias arrival: _controller.arrival
property alias departure: _controller.departure
......
......@@ -38,6 +38,7 @@ Kirigami.AbstractCard {
reservationManager: ReservationManager
liveDataManager: LiveDataManager
transferManager: TransferManager
documentManager: DocumentManager
}
property alias arrival: _controller.arrival
property alias departure: _controller.departure
......
......@@ -15,6 +15,7 @@
#include "publictransport.h"
#include "transfer.h"
#include "transfermanager.h"
#include "documentmanager.h"
#include <KItinerary/BusTrip>
#include <KItinerary/CalendarHandler>
......@@ -131,6 +132,21 @@ void TimelineDelegateController::setTransferManager(QObject *transferMgr)
Q_EMIT setupChanged();
}
QObject* TimelineDelegateController::documentManager() const
{
return m_documentMgr;
}
void TimelineDelegateController::setDocumentManager(QObject *documentMgr)
{
if (m_documentMgr == documentMgr) {
return;
}
m_documentMgr = qobject_cast<DocumentManager*>(documentMgr);
Q_EMIT setupChanged();
}
QString TimelineDelegateController::batchId() const
{
return m_batchId;
......@@ -742,8 +758,9 @@ int TimelineDelegateController::documentCount() const
const auto res = m_resMgr->reservation(resId);
const auto docIds = DocumentUtil::documentIds(res);
for (const auto &docId : docIds) {
// TODO we could check if actually have the document first?
allDocIds.insert(docId.toString());
if (m_documentMgr->hasDocument(docId.toString())) {
allDocIds.insert(docId.toString());
}
}
}
return allDocIds.size();
......
......@@ -25,6 +25,7 @@ class QTimer;
class LiveDataManager;
class ReservationManager;
class TransferManager;
class DocumentManager;
/** C++ side logic for timeline delegates. */
class TimelineDelegateController : public QObject
......@@ -33,6 +34,7 @@ class TimelineDelegateController : public QObject
Q_PROPERTY(QObject* reservationManager READ reservationManager WRITE setReservationManager NOTIFY setupChanged)
Q_PROPERTY(QObject* liveDataManager READ liveDataManager WRITE setLiveDataManager NOTIFY setupChanged)
Q_PROPERTY(QObject* transferManager READ transferManager WRITE setTransferManager NOTIFY setupChanged)
Q_PROPERTY(QObject* documentManager READ documentManager WRITE setDocumentManager NOTIFY setupChanged)
Q_PROPERTY(QString batchId READ batchId WRITE setBatchId NOTIFY batchIdChanged)
Q_PROPERTY(bool isCurrent READ isCurrent NOTIFY currentChanged)
......@@ -87,6 +89,8 @@ public:
void setLiveDataManager(QObject *liveDataMgr);
QObject* transferManager() const;
void setTransferManager(QObject *transferMgr);
QObject* documentManager() const;
void setDocumentManager(QObject *documentMgr);
QString batchId() const;
void setBatchId(const QString &batchId);
......@@ -148,6 +152,7 @@ private:
ReservationManager *m_resMgr = nullptr; // ### should this be static?
LiveDataManager *m_liveDataMgr = nullptr;
TransferManager *m_transferMgr = nullptr;
DocumentManager *m_documentMgr = nullptr;
QString m_batchId;
bool m_isCurrent = false;
......
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