Sonnet

aspellclient.cpp
1/*
2 * kspell_aspellclient.cpp
3 *
4 * SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org>
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
17using namespace Sonnet;
18
19ASpellClient::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
29ASpellClient::~ASpellClient()
30{
31 delete_aspell_config(m_config);
32}
33
34SpellerPlugin *ASpellClient::createSpeller(const QString &language)
35{
36 ASpellDict *ad = new ASpellDict(language);
37 return ad;
38}
39
40QStringList 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}
55
56#include "moc_aspellclient.cpp"
The sonnet namespace.
QString applicationDirPath()
void append(QList< T > &&value)
QString fromLatin1(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.