File indexing completed on 2024-11-24 04:39:33

0001 /*
0002   SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadi-contact-widgets_export.h"
0010 
0011 #include <KJob>
0012 
0013 #include <memory>
0014 
0015 namespace KContacts
0016 {
0017 class Addressee;
0018 }
0019 
0020 namespace Akonadi
0021 {
0022 class Collection;
0023 }
0024 namespace Akonadi
0025 {
0026 class AddContactJobPrivate;
0027 
0028 /**
0029  * @short A job to add a new contact to Akonadi.
0030  *
0031  * The job will check whether a contact with the given email address already
0032  * exists in Akonadi and adds it if it does not exist yet.
0033  */
0034 class AKONADI_CONTACT_WIDGETS_EXPORT AddContactJob : public KJob
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     /**
0040      * Creates a new add contact job.
0041      *
0042      * If the contact is not found, the user will be presented a dialog to
0043      * choose the address book where the new contact shall be stored.
0044      *
0045      * @param contact The contact to add.
0046      * @param parentWidget The widget that will be used as parent for dialog.
0047      * @param parent The parent object.
0048      */
0049     AddContactJob(const KContacts::Addressee &contact, QWidget *parentWidget, QObject *parent = nullptr);
0050 
0051     /**
0052      * Creates a new add contact job.
0053      *
0054      * @param contact The contact to add.
0055      * @param collection The address book collection where the contact shall be stored in.
0056      * @param parent The parent object.
0057      */
0058     AddContactJob(const KContacts::Addressee &contact, const Akonadi::Collection &collection, QObject *parent = nullptr);
0059 
0060     /**
0061      * Destroys the add email address job.
0062      */
0063     ~AddContactJob() override;
0064 
0065     /**
0066      * Starts the job.
0067      */
0068     void start() override;
0069 
0070     void showMessageBox(bool b);
0071 
0072 private:
0073     //@cond PRIVATE
0074     friend class AddContactJobPrivate;
0075     std::unique_ptr<AddContactJobPrivate> const d;
0076     //@endcond
0077 };
0078 }