kdeaccountsresource.h 2.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
    Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>

    This library is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published by
    the Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    This library is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
    License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to the
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
*/

#ifndef KDEACCOUNTSRESOURCE_H
#define KDEACCOUNTSRESOURCE_H

#include "singlefileresource.h"
#include "settings.h"

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
26
#include <kcontacts/addressee.h>
27 28 29

class KDEAccountsResource : public Akonadi::SingleFileResource<Settings>
{
Laurent Montel's avatar
Laurent Montel committed
30
    Q_OBJECT
31

Laurent Montel's avatar
Laurent Montel committed
32 33
public:
    KDEAccountsResource(const QString &id);
34 35
    ~KDEAccountsResource();

Laurent Montel's avatar
Laurent Montel committed
36
protected Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
37 38
    bool retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &parts) Q_DECL_OVERRIDE;
    void retrieveItems(const Akonadi::Collection &collection) Q_DECL_OVERRIDE;
39

Laurent Montel's avatar
Laurent Montel committed
40
protected:
41 42 43
    /**
     * Customize the configuration dialog before it is displayed.
     */
Laurent Montel's avatar
Laurent Montel committed
44
    void customizeConfigDialog(Akonadi::SingleFileResourceConfigDialog<Settings> *dlg) Q_DECL_OVERRIDE;
45 46 47 48 49

    /*
     * Do stuff when the configuration dialog has been accepted, before
     * reloadFile() is called.
     */
Laurent Montel's avatar
Laurent Montel committed
50
    void configDialogAcceptedActions(Akonadi::SingleFileResourceConfigDialog<Settings> *dlg) Q_DECL_OVERRIDE;
51

Laurent Montel's avatar
Laurent Montel committed
52 53
    bool readFromFile(const QString &fileName) Q_DECL_OVERRIDE;
    bool writeToFile(const QString &fileName) Q_DECL_OVERRIDE;
54

Laurent Montel's avatar
Laurent Montel committed
55 56 57
    void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) Q_DECL_OVERRIDE;
    void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) Q_DECL_OVERRIDE;
    void itemRemoved(const Akonadi::Item &item) Q_DECL_OVERRIDE;
58

Laurent Montel's avatar
Laurent Montel committed
59
private:
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
60
    typedef QMap<QString, KContacts::Addressee> ContactsMap;
61
    ContactsMap mContacts;
62 63 64
};

#endif