File indexing completed on 2024-04-21 04:58:02
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2009 Fredy Yanardi <fyanardi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "SuggestionEngine.h" 0008 0009 #include <kservice.h> 0010 0011 #include "searchbar_debug.h" 0012 0013 SuggestionEngine::SuggestionEngine(const QString &engineName, QObject *parent) 0014 : QObject(parent), 0015 m_engineName(engineName) 0016 { 0017 // First get the suggestion request URL for this engine 0018 KService::Ptr service = KService::serviceByDesktopPath(QStringLiteral("searchproviders/%1.desktop").arg(m_engineName)); 0019 0020 if (service) { 0021 #if QT_VERSION_MAJOR < 6 0022 const QString suggestionURL = service->property(QStringLiteral("Suggest")).toString(); 0023 #else 0024 const QString suggestionURL = service->property<QString>(QStringLiteral("Suggest")); 0025 #endif 0026 if (!suggestionURL.isNull() && !suggestionURL.isEmpty()) { 0027 m_requestURL = suggestionURL; 0028 } else { 0029 qCWarning(SEARCHBAR_LOG) << "Missing property [Suggest] for suggestion engine: " + m_engineName; 0030 } 0031 } 0032 } 0033 0034 QString SuggestionEngine::requestURL() const 0035 { 0036 return m_requestURL; 0037 } 0038 0039 QString SuggestionEngine::engineName() const 0040 { 0041 return m_engineName; 0042 } 0043