KTextAddons

languagetoolresultjob.h
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "textgrammarcheckprivate_export.h"
10#include <QObject>
11class QNetworkRequest;
12class QNetworkReply;
14namespace TextGrammarCheck
15{
16class TEXTGRAMMARCHECK_TESTS_EXPORT LanguageToolResultJob : public QObject
17{
18 Q_OBJECT
19public:
20 explicit LanguageToolResultJob(QObject *parent = nullptr);
21 ~LanguageToolResultJob() override;
22 [[nodiscard]] bool canStart() const;
23 void start();
24 [[nodiscard]] QStringList arguments() const;
25 void setArguments(const QStringList &arguments);
26
27 QNetworkAccessManager *networkAccessManager() const;
28 void setNetworkAccessManager(QNetworkAccessManager *networkAccessManager);
29
30 [[nodiscard]] QString text() const;
31 void setText(const QString &text);
32
33 [[nodiscard]] QString url() const;
34 void setUrl(const QString &url);
35
36 [[nodiscard]] QString language() const;
37 void setLanguage(const QString &language);
38
39Q_SIGNALS:
40 void finished(const QString &result);
41 void error(const QString &errorStr);
42
43private:
44 Q_DISABLE_COPY(LanguageToolResultJob)
45 enum class JobError : uint8_t {
46 NotError,
47 EmptyText,
48 UrlNotDefined,
49 NetworkManagerNotDefined,
50 LanguageNotDefined,
51 };
52
53 [[nodiscard]] LanguageToolResultJob::JobError canStartError() const;
54 void slotCheckGrammarFinished();
55 void addRequestAttribute(QNetworkRequest &request) const;
56 void slotFinish(QNetworkReply *reply);
57 QStringList mArguments;
58 QString mText;
59 QString mUrl;
60 QString mLanguage;
61 QNetworkAccessManager *mNetworkAccessManager = nullptr;
62};
63}
Q_SCRIPTABLE Q_NOREPLY void start()
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.