Sonnet

aspellclient.cpp
1 /*
2  * kspell_aspellclient.cpp
3  *
4  * SPDX-FileCopyrightText: 2003 Zack Rusin <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-or-later
7  */
8 
9 #include "aspellclient.h"
10 #include "aspelldict.h"
11 
12 #include "aspell_debug.h"
13 #ifdef Q_OS_WIN
14 #include <QCoreApplication>
15 #endif
16 
17 using namespace Sonnet;
18 
19 ASpellClient::ASpellClient(QObject *parent)
20  : Client(parent)
21  , m_config(new_aspell_config())
22 {
23 #ifdef Q_OS_WIN
24  aspell_config_replace(m_config, "data-dir", QString::fromLatin1("%1/data/aspell").arg(QCoreApplication::applicationDirPath()).toLatin1().constData());
25  aspell_config_replace(m_config, "dict-dir", QString::fromLatin1("%1/data/aspell").arg(QCoreApplication::applicationDirPath()).toLatin1().constData());
26 #endif
27 }
28 
29 ASpellClient::~ASpellClient()
30 {
31  delete_aspell_config(m_config);
32 }
33 
34 SpellerPlugin *ASpellClient::createSpeller(const QString &language)
35 {
36  ASpellDict *ad = new ASpellDict(language);
37  return ad;
38 }
39 
40 QStringList ASpellClient::languages() const
41 {
42  AspellDictInfoList *l = get_aspell_dict_info_list(m_config);
43  AspellDictInfoEnumeration *el = aspell_dict_info_list_elements(l);
44 
45  QStringList langs;
46  const AspellDictInfo *di = nullptr;
47  while ((di = aspell_dict_info_enumeration_next(el))) {
48  langs.append(QString::fromLatin1(di->name));
49  }
50 
51  delete_aspell_dict_info_enumeration(el);
52 
53  return langs;
54 }
void append(const T &value)
QString applicationDirPath()
The sonnet namespace.
QString fromLatin1(const char *str, int size)
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.