Commit c2cf81f2 authored by David Faure's avatar David Faure

Dict Engine: improve error handling.

Summary:
Instead of returning "<dl>\n<dt><b></b></dt>\n<dd></dl>"
when the word doesn't exist, return a proper readable string so users
know that the lookup is done and nothing was found.

Test Plan: I'm porting the dict applet to QtQuick, review request coming soon.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: broulik, plasma-devel, #plasma

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8419
parent 983a4a46
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_engine_dict\")
set(dict_engine_SRCS
dictengine.cpp
)
......@@ -7,6 +9,7 @@ add_library(plasma_engine_dict MODULE ${dict_engine_SRCS})
target_link_libraries (plasma_engine_dict
KF5::Plasma
KF5::Service
KF5::I18n
Qt5::Network
)
......
......@@ -21,6 +21,7 @@
#include <QDebug>
#include <QTcpSocket>
#include <KLocalizedString>
#include <Plasma/DataContainer>
......@@ -49,7 +50,6 @@ void DictEngine::setServer(const QString &server)
static QString wnToHtml(const QString &word, QByteArray &text)
{
Q_UNUSED(word)
QList<QByteArray> splitText = text.split('\n');
QString def;
def += QLatin1String("<dl>\n");
......@@ -73,10 +73,13 @@ static QString wnToHtml(const QString &word, QByteArray &text)
continue;
}
if (currentLine.startsWith("552")) {
return i18n("No match found for %1", word);
}
if (!(currentLine.startsWith(QLatin1String("150"))
|| currentLine.startsWith(QLatin1String("151"))
|| currentLine.startsWith(QLatin1String("250"))
|| currentLine.startsWith(QLatin1String("552")))) {
|| currentLine.startsWith(QLatin1String("250")))) {
currentLine.replace(linkRx,QLatin1String("<a href=\"\\1\">\\1</a>"));
if (isFirst) {
......
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