File indexing completed on 2024-11-24 04:43:04

0001 /*
0002     SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include <QObject>
0009 
0010 #include <Akonadi/Collection>
0011 #include <Akonadi/Item>
0012 #include <KContacts/Addressee>
0013 namespace KABMergeContacts
0014 {
0015 class MergeContactsJob : public QObject
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit MergeContactsJob(QObject *parent = nullptr);
0020     ~MergeContactsJob() override;
0021 
0022     void start();
0023 
0024     void setListItem(const Akonadi::Item::List &lstItem);
0025 
0026     void setDestination(const Akonadi::Collection &collection);
0027 
0028     [[nodiscard]] bool canStart() const;
0029 
0030     void setNewContact(const KContacts::Addressee &addr);
0031 
0032 Q_SIGNALS:
0033     void finished(const Akonadi::Item &item);
0034 
0035 private:
0036     void slotCreateMergedContactFinished(KJob *job);
0037     void slotDeleteContactsFinished(KJob *job);
0038     void generateMergedContact();
0039     void createMergedContact(const KContacts::Addressee &addressee);
0040 
0041     Akonadi::Collection mCollection;
0042     Akonadi::Item::List mListItem;
0043     Akonadi::Item mCreatedContact;
0044     KContacts::Addressee mNewContact;
0045 };
0046 }