Sonnet

voikkoclient.cpp
1 /*
2  * voikkoclient.cpp
3  *
4  * SPDX-FileCopyrightText: 2015 Jesse Jaara <[email protected]>
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 
13 VoikkoClient::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 
33 VoikkoClient::~VoikkoClient()
34 {
35 }
36 
37 int VoikkoClient::reliability() const
38 {
39  return 50;
40 }
41 
42 Sonnet::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 
53 QStringList VoikkoClient::languages() const
54 {
55  return m_supportedLanguages;
56 }
57 
58 QString VoikkoClient::name() const
59 {
60  return QStringLiteral("Voikko");
61 }
QString fromUtf8(const char *str, int size)
The sonnet namespace.
QString language() const
Definition: speller.cpp:145
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:14:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.