summaryrefslogtreecommitdiffstats
path: root/accounts/maildir/maildirsettings.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 22:30:07 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 22:30:07 +0100
commitfd31aa9b05ea215e8071cf76fe21ec746204f3a3 (patch)
treefd656cf389060e6a5c7ef3253d3337e0a48864c8 /accounts/maildir/maildirsettings.cpp
parent54c3e5912b0d64bad5a1c66bc96f0552ac5e21f5 (diff)
downloadkube-fd31aa9b05ea215e8071cf76fe21ec746204f3a3.tar.gz
kube-fd31aa9b05ea215e8071cf76fe21ec746204f3a3.zip
Added a maildir configuration controller that can edit the config in
sink. The property binding only works when using actual QObject::property'ies. It doesn't work at all with Q_PROPERTY, even with a NOTIFY signal.
Diffstat (limited to 'accounts/maildir/maildirsettings.cpp')
-rw-r--r--accounts/maildir/maildirsettings.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/accounts/maildir/maildirsettings.cpp b/accounts/maildir/maildirsettings.cpp
new file mode 100644
index 00000000..4a3b1a00
--- /dev/null
+++ b/accounts/maildir/maildirsettings.cpp
@@ -0,0 +1,55 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#include "maildirsettings.h"
20
21#include <sink/store.h>
22#include <QDebug>
23
24MaildirSettings::MaildirSettings(QObject *parent)
25 : QObject(parent)
26{
27}
28
29void MaildirSettings::setIdentifier(const QByteArray &id)
30{
31 mIdentifier = id;
32 Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::IdentityFilter(mIdentifier) + Sink::Query::RequestedProperties(QList<QByteArray>() << "path"))
33 .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) {
34 setProperty("path", resource.getProperty("path"));
35 }).exec();
36}
37
38QByteArray MaildirSettings::identifier() const
39{
40 return mIdentifier;
41}
42
43void MaildirSettings::save()
44{
45 if (!mIdentifier.isEmpty()) {
46 Sink::ApplicationDomain::SinkResource resource(mIdentifier);
47 resource.setProperty("path", property("path"));
48 Sink::Store::modify(resource).exec();
49 } else {
50 Sink::ApplicationDomain::SinkResource resource;
51 resource.setProperty("path", property("path"));
52 Sink::Store::create(resource).exec();
53 }
54}
55