Sonnet

voikkoclient.cpp
1/*
2 * voikkoclient.cpp
3 *
4 * SPDX-FileCopyrightText: 2015 Jesse Jaara <jesse.jaara@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8
9#include "voikkoclient.h"
10#include "voikkodebug.h"
11#include "voikkodict.h"
12
13VoikkoClient::VoikkoClient(QObject *parent)
14 : Sonnet::Client(parent)
15{
16 qCDebug(SONNET_VOIKKO) << "Initializing Voikko spell checker plugin.";
17
18 char **dictionaries = voikkoListSupportedSpellingLanguages(nullptr);
19
20 if (!dictionaries) {
21 return;
22 }
23
24 for (int i = 0; dictionaries[i] != nullptr; ++i) {
25 QString language = QString::fromUtf8(dictionaries[i]);
26 m_supportedLanguages.append(language);
27 qCDebug(SONNET_VOIKKO) << "Found dictionary for language:" << language;
28 }
29
30 voikkoFreeCstrArray(dictionaries);
31}
32
33VoikkoClient::~VoikkoClient()
34{
35}
36
37int VoikkoClient::reliability() const
38{
39 return 50;
40}
41
42Sonnet::SpellerPlugin *VoikkoClient::createSpeller(const QString &language)
43{
44 VoikkoDict *speller = new VoikkoDict(language);
45 if (speller->initFailed()) {
46 delete speller;
47 return nullptr;
48 }
49
50 return speller;
51}
52
53QStringList VoikkoClient::languages() const
54{
55 return m_supportedLanguages;
56}
57
58QString VoikkoClient::name() const
59{
60 return QStringLiteral("Voikko");
61}
62
63#include "moc_voikkoclient.cpp"
The sonnet namespace.
QString fromUtf8(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.