Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit fa38fedf authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement job

parent ec904302
......@@ -34,4 +34,20 @@ void LanguagetoolResultJobTest::shouldHaveDefaultValue()
QVERIFY(!job.networkAccessManager());
QVERIFY(job.arguments().isEmpty());
QVERIFY(!job.canStart());
QVERIFY(job.text().isEmpty());
}
void LanguagetoolResultJobTest::shouldBeAbleToStart()
{
LanguagetoolResultJob job;
QVERIFY(!job.canStart());
job.setText(QStringLiteral("foo"));
QVERIFY(!job.canStart());
QNetworkAccessManager network;
job.setNetworkAccessManager(&network);
QVERIFY(job.canStart());
job.setText(QStringLiteral(" "));
QVERIFY(!job.canStart());
job.setText(QStringLiteral(" DDDD"));
QVERIFY(job.canStart());
}
......@@ -30,6 +30,7 @@ public:
~LanguagetoolResultJobTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldBeAbleToStart();
};
#endif // LANGUAGETOOLRESULTJOBTEST_H
......@@ -33,9 +33,21 @@ LanguagetoolResultJob::~LanguagetoolResultJob()
}
static bool hasNotEmptyText(const QString &text)
{
for (int i = 0; i < text.length(); ++i) {
if (!text.at(i).isSpace()) {
return true;
}
}
return false;
}
bool LanguagetoolResultJob::canStart() const
{
if (!mNetworkAccessManager) {
//
if (!mNetworkAccessManager || !hasNotEmptyText(mText)) {
return false;
}
return true;
......@@ -69,3 +81,13 @@ void LanguagetoolResultJob::setNetworkAccessManager(QNetworkAccessManager *netwo
{
mNetworkAccessManager = networkAccessManager;
}
QString LanguagetoolResultJob::text() const
{
return mText;
}
void LanguagetoolResultJob::setText(const QString &text)
{
mText = text;
}
......@@ -36,6 +36,10 @@ public:
QNetworkAccessManager *networkAccessManager() const;
void setNetworkAccessManager(QNetworkAccessManager *networkAccessManager);
Q_REQUIRED_RESULT QString text() const;
void setText(const QString &text);
Q_SIGNALS:
void finished(const QString &result);
void error();
......@@ -43,6 +47,7 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(LanguagetoolResultJob)
QStringList mArguments;
QString mText;
QNetworkAccessManager *mNetworkAccessManager = nullptr;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment