File indexing completed on 2025-01-05 04:58:20

0001 /*
0002   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "blacklistbalooemailsearchjob.h"
0009 
0010 #include <PIM/contactcompleter.h>
0011 using namespace PimCommon;
0012 
0013 BlackListBalooEmailSearchJob::BlackListBalooEmailSearchJob(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 BlackListBalooEmailSearchJob::~BlackListBalooEmailSearchJob() = default;
0019 
0020 bool BlackListBalooEmailSearchJob::start()
0021 {
0022     const QString trimmedString = mSearchEmail.trimmed();
0023     if (trimmedString.isEmpty()) {
0024         deleteLater();
0025         return false;
0026     }
0027 
0028     Akonadi::Search::PIM::ContactCompleter com(trimmedString, mLimit);
0029     Q_EMIT emailsFound(com.complete());
0030     deleteLater();
0031     return true;
0032 }
0033 
0034 void BlackListBalooEmailSearchJob::setSearchEmail(const QString &searchEmail)
0035 {
0036     mSearchEmail = searchEmail;
0037 }
0038 
0039 void BlackListBalooEmailSearchJob::setLimit(int limit)
0040 {
0041     mLimit = qMax(10, limit);
0042 }
0043 
0044 #include "moc_blacklistbalooemailsearchjob.cpp"