From ae4b64b198a143240aa5dd1e202e5016abfdae71 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 8 Dec 2016 13:18:19 +0100 Subject: Wrap references in a Reerence type. This allows us to make sure that references are not taken out of context (the resource). Because we need to use the type-specific accessors more we also ran into a problem that we cannot "downcast" a reference with the change recording still working, for that we have the cast() operator now. --- examples/maildirresource/maildirresource.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/maildirresource') diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 1eee786..a05afc6 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp @@ -129,16 +129,16 @@ public: void newEntity(Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE { - const ApplicationDomain::Mail mail{newEntity}; + auto mail = newEntity.cast(); const auto mimeMessage = mail.getMimeMessagePath(); if (!mimeMessage.isNull()) { - ApplicationDomain::Mail{newEntity}.setMimeMessagePath(moveMessage(mimeMessage, mail.getFolder())); + mail.setMimeMessagePath(moveMessage(mimeMessage, mail.getFolder())); } } void modifiedEntity(const Sink::ApplicationDomain::ApplicationDomainType &oldEntity, Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE { - ApplicationDomain::Mail newMail{newEntity}; + auto newMail = newEntity.cast(); const ApplicationDomain::Mail oldMail{oldEntity}; const auto mimeMessage = newMail.getMimeMessagePath(); const auto newFolder = newMail.getFolder(); @@ -190,7 +190,7 @@ public: void newEntity(Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE { - auto folderName = newEntity.getProperty("name").toString(); + auto folderName = Sink::ApplicationDomain::Folder{newEntity}.getName(); const auto path = mMaildirPath + "/" + folderName; KPIM::Maildir maildir(path, false); maildir.create(); -- cgit v1.2.3