File indexing completed on 2024-04-28 15:29:27

0001 /*
0002     SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef MATCHESSOLVER_H
0008 #define MATCHESSOLVER_H
0009 
0010 #include <KJob>
0011 
0012 #include "match_p.h"
0013 #include <kpeople/kpeople_export.h>
0014 
0015 class QUrl;
0016 class QModelIndex;
0017 
0018 namespace KPeople
0019 {
0020 class PersonsModel;
0021 
0022 /**
0023  * @brief This class is responsible for merging different persons into one
0024  *
0025  * One of the important tasks of KPeople is putting together different contacts into
0026  * the same person representation.
0027  *
0028  * This class gets a list of matches, usually from @a DuplicatesFinder and makes
0029  * the needed changes to the database so that everything looks as it should.
0030  */
0031 
0032 class KPEOPLE_EXPORT MatchesSolver : public KJob
0033 {
0034     Q_OBJECT
0035 public:
0036     /**
0037      * Constructs a solver given the @p matches against a @p model.
0038      *
0039      * Note: Obviously, the @p model should be the same @p matches refers to.
0040      */
0041     explicit MatchesSolver(const QList<Match> &matches, PersonsModel *model, QObject *parent = nullptr);
0042 
0043     /**
0044      * Start doing some crazy matching!
0045      *
0046      * @see KJob::finished()
0047      */
0048     void start() override;
0049 
0050 private Q_SLOTS:
0051     void startMatching();
0052 
0053 private:
0054     const QList<Match> m_matches;
0055     PersonsModel *const m_model;
0056 };
0057 }
0058 
0059 #endif // MATCHESSOLVER_H