File indexing completed on 2024-06-23 05:06:08
0001 /* 0002 * This file is part of the KDE Akonadi Search Project 0003 * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 * 0007 */ 0008 0009 #include "../contactcompleter.h" 0010 0011 #include <QCoreApplication> 0012 #include <QDebug> 0013 #include <QElapsedTimer> 0014 #include <QTimer> 0015 #include <iostream> 0016 0017 #include <Akonadi/ItemFetchJob> 0018 #include <Akonadi/ItemFetchScope> 0019 0020 using namespace Akonadi::Search::PIM; 0021 0022 class App : public QCoreApplication 0023 { 0024 Q_OBJECT 0025 public: 0026 App(int &argc, char **argv, int flags = ApplicationFlags); 0027 0028 QString m_query; 0029 0030 private Q_SLOTS: 0031 void main(); 0032 }; 0033 0034 int main(int argc, char **argv) 0035 { 0036 App app(argc, argv); 0037 0038 if (argc != 2) { 0039 qWarning() << "Proper args required"; 0040 exit(0); 0041 } 0042 app.m_query = QString::fromUtf8(argv[1]); 0043 0044 return app.exec(); 0045 } 0046 0047 App::App(int &argc, char **argv, int flags) 0048 : QCoreApplication(argc, argv, flags) 0049 { 0050 QTimer::singleShot(0, this, &App::main); 0051 } 0052 0053 void App::main() 0054 { 0055 ContactCompleter com(m_query, 100); 0056 0057 QElapsedTimer timer; 0058 timer.start(); 0059 0060 const QStringList emails = com.complete(); 0061 for (const QString &em : std::as_const(emails)) { 0062 std::cout << em.toUtf8().data() << std::endl; 0063 } 0064 0065 qDebug() << timer.elapsed(); 0066 quit(); 0067 } 0068 0069 #include "contactcompletiontest.moc"