Commit 8781e21c authored by Volker Krause's avatar Volker Krause

Update document model if the corresponding reservation batch changes

parent 0b02d6a3
......@@ -106,6 +106,22 @@ void DocumentsModel::setDocumentManager(DocumentManager *mgr)
emit setupChanged();
}
void DocumentsModel::setReservationManager(ReservationManager* mgr)
{
if (m_resMgr == mgr) {
return;
}
m_resMgr = mgr;
connect(mgr, &ReservationManager::batchContentChanged, this, [this](const QString &batchId) {
if (batchId == m_batchId) {
reload();
}
});
emit setupChanged();
}
void DocumentsModel::reload()
{
if (!m_docMgr || !m_resMgr || m_batchId.isEmpty()) {
......
......@@ -33,7 +33,7 @@ class DocumentsModel : public QAbstractListModel
Q_OBJECT
Q_PROPERTY(QString batchId MEMBER m_batchId NOTIFY setupChanged)
Q_PROPERTY(DocumentManager* documentManager MEMBER m_docMgr WRITE setDocumentManager NOTIFY setupChanged)
Q_PROPERTY(ReservationManager* reservationManager MEMBER m_resMgr NOTIFY setupChanged)
Q_PROPERTY(ReservationManager* reservationManager MEMBER m_resMgr WRITE setReservationManager NOTIFY setupChanged)
Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
public:
......@@ -51,6 +51,7 @@ public:
QHash<int, QByteArray> roleNames() const override;
void setDocumentManager(DocumentManager *mgr);
void setReservationManager(ReservationManager *mgr);
Q_SIGNALS:
void setupChanged();
......
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