kaddressbookimportexportplugininterface.h 2.06 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
2
   SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

4
   SPDX-License-Identifier: GPL-2.0-or-later
Laurent Montel's avatar
Laurent Montel committed
5 6 7 8 9 10
*/

#ifndef KADDRESSBOOKIMPORTEXPORTPLUGININTERFACE_H
#define KADDRESSBOOKIMPORTEXPORTPLUGININTERFACE_H

#include "kaddressbook_importexport_export.h"
Laurent Montel's avatar
Laurent Montel committed
11
#include <PimCommon/AbstractGenericPluginInterface>
12
#include <QList>
Laurent Montel's avatar
Laurent Montel committed
13
#include <AkonadiCore/Collection>
14
class QItemSelectionModel;
Laurent Montel's avatar
Laurent Montel committed
15
namespace KAddressBookImportExport {
16 17

/** Import/export plugin interface. */
Laurent Montel's avatar
Laurent Montel committed
18 19 20 21
class KADDRESSBOOK_IMPORTEXPORT_EXPORT KAddressBookImportExportPluginInterface : public PimCommon::AbstractGenericPluginInterface
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
22
    explicit KAddressBookImportExportPluginInterface(QObject *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
23
    ~KAddressBookImportExportPluginInterface();
24

Laurent Montel's avatar
Laurent Montel committed
25 26 27 28 29
    enum ImportExportAction {
        Import = 0,
        Export = 1
    };

Laurent Montel's avatar
Laurent Montel committed
30
    Q_REQUIRED_RESULT QList<QAction *> importActions() const;
31 32
    void setImportActions(const QList<QAction *> &importAction);

Laurent Montel's avatar
Laurent Montel committed
33
    Q_REQUIRED_RESULT QList<QAction *> exportActions() const;
34 35
    void setExportActions(const QList<QAction *> &exportAction);

Laurent Montel's avatar
Laurent Montel committed
36
    Q_REQUIRED_RESULT ImportExportAction importExportAction() const;
Laurent Montel's avatar
Laurent Montel committed
37
    void setImportExportAction(ImportExportAction importExportAction);
Laurent Montel's avatar
Laurent Montel committed
38

Laurent Montel's avatar
Laurent Montel committed
39
    Q_REQUIRED_RESULT Akonadi::Collection defaultCollection() const;
Laurent Montel's avatar
Laurent Montel committed
40 41
    void setDefaultCollection(const Akonadi::Collection &defaultCollection);

42 43
    void setSelectionModel(QItemSelectionModel *model);

Laurent Montel's avatar
Laurent Montel committed
44
    Q_REQUIRED_RESULT QItemSelectionModel *itemSelectionModel() const;
45 46
    void setItemSelectionModel(QItemSelectionModel *itemSelectionModel);

Laurent Montel's avatar
Laurent Montel committed
47
    Q_REQUIRED_RESULT virtual bool canImportFileType(const QUrl &url);
Laurent Montel's avatar
Laurent Montel committed
48
    virtual void importFile(const QUrl &url);
Laurent Montel's avatar
Laurent Montel committed
49

Laurent Montel's avatar
Laurent Montel committed
50
    Q_REQUIRED_RESULT virtual bool canImportData() const;
Laurent Montel's avatar
Laurent Montel committed
51 52
    virtual void importData(const QByteArray &data);

53 54 55
protected:
    QList<QAction *> mImportActions;
    QList<QAction *> mExportActions;
Laurent Montel's avatar
Laurent Montel committed
56
    ImportExportAction mImportExportAction = Import;
Laurent Montel's avatar
Laurent Montel committed
57
    Akonadi::Collection mDefaultCollection;
Laurent Montel's avatar
Laurent Montel committed
58
    QItemSelectionModel *mItemSelectionModel = nullptr;
Laurent Montel's avatar
Laurent Montel committed
59 60 61
};
}
#endif // KADDRESSBOOKIMPORTEXPORTPLUGININTERFACE_H