File indexing completed on 2024-05-05 03:57:09

0001 /*
0002     KPeople - Duplicates
0003     SPDX-FileCopyrightText: 2013 Franck Arrecot <franck.arrecot@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef MERGEDIALOG_H
0009 #define MERGEDIALOG_H
0010 
0011 #include <kpeople/widgets/kpeoplewidgets_export.h>
0012 
0013 #include <QDialog>
0014 
0015 class QStandardItem;
0016 class KJob;
0017 class MergeDialogPrivate;
0018 
0019 namespace KPeople
0020 {
0021 class PersonsModel;
0022 class Match;
0023 
0024 /**
0025  * The merge dialog will be used to provide a GUI to attempt to
0026  * figure out what contacts should be merged.
0027  *
0028  * By properly mergeing contacts, the user will end up with having more
0029  * information on each person.
0030  *
0031  * @since 5.8
0032  */
0033 class KPEOPLEWIDGETS_EXPORT MergeDialog : public QDialog
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     enum Role {
0039         NameRole = Qt::DisplayRole,
0040         UriRole = Qt::UserRole + 1,
0041         PixmapRole,
0042         MergeReasonRole,
0043     };
0044 
0045     explicit MergeDialog(QWidget *parent = nullptr);
0046     ~MergeDialog() override;
0047 
0048     /**
0049      * Specifies which PersonsModel will be used to look for duplicates.
0050      */
0051     void setPersonsModel(PersonsModel *model);
0052 
0053 private Q_SLOTS:
0054     KPEOPLEWIDGETS_NO_EXPORT void searchForDuplicates();
0055     KPEOPLEWIDGETS_NO_EXPORT void searchForDuplicatesFinished(KJob *);
0056     KPEOPLEWIDGETS_NO_EXPORT void onMergeButtonClicked();
0057 
0058 private:
0059     KPEOPLEWIDGETS_NO_EXPORT QStandardItem *itemMergeContactFromMatch(bool parent, const KPeople::Match &match);
0060     KPEOPLEWIDGETS_NO_EXPORT void feedDuplicateModelFromMatches(const QList<Match> &matches);
0061 
0062     MergeDialogPrivate *const d_ptr;
0063     Q_DECLARE_PRIVATE(MergeDialog)
0064 };
0065 
0066 }
0067 
0068 #endif // MERGEDIALOG_H