// SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: LGPL-2.1-or-later

#pragma once

#include "merkuro_contact_export.h"
#include <KContacts/Addressee>
#include <QAbstractListModel>

class MERKURO_CONTACT_EXPORT ImppModel : public QAbstractListModel
{
    Q_OBJECT

public:
    enum ExtraRole {
        UrlRole = Qt::UserRole,
        TypeRole,
        TypeLabelRole,
        TypeIconRole,
        UsernameRole,
    };

    explicit ImppModel(QObject *parent = nullptr);

    int rowCount(const QModelIndex &parent = {}) const override;
    QVariant data(const QModelIndex &idx, int role) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    QHash<int, QByteArray> roleNames() const override;

    void loadContact(const KContacts::Addressee &contact);
    void storeContact(KContacts::Addressee &contact) const;

    Q_INVOKABLE void addImpp(const QUrl &address);
    Q_INVOKABLE void deleteImpp(const int row);

    /**
     * Copies the IMPP at `index` to the system clipboard
     */
    Q_INVOKABLE void copyToClipboard(int index) const;

Q_SIGNALS:
    void changed(const KContacts::Impp::List &impps);

private:
    KContacts::Impp::List m_impps;
};
