Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Add-ons
Commits
82c096c4
Verified
Commit
82c096c4
authored
May 05, 2022
by
Fushan Wen
Browse files
dict: Do not use static array, move it to member variable
parent
8b45a93d
Changes
2
Hide whitespace changes
Inline
Side-by-side
dict/dictengine.cpp
View file @
82c096c4
...
...
@@ -20,6 +20,13 @@ DictEngine::DictEngine(QObject *parent)
,
m_dictName
(
QStringLiteral
(
"wn"
))
// In case we need to switch it later
,
m_serverName
(
QStringLiteral
(
"dict.org"
))
// Default, good dictionary
{
m_definitionResponses
=
{
QByteArrayLiteral
(
"250"
),
/**< ok (optional timing information here) */
QByteArrayLiteral
(
"552"
),
/**< No match */
QByteArrayLiteral
(
"550"
),
/**< Invalid database */
QByteArrayLiteral
(
"501"
),
/**< Syntax error, illegal parameters */
QByteArrayLiteral
(
"503"
),
/**< Command parameter not implemented */
};
}
DictEngine
::~
DictEngine
()
...
...
@@ -109,15 +116,7 @@ void DictEngine::getDefinition()
m_tcpSocket
->
write
(
command
);
m_tcpSocket
->
flush
();
static
const
std
::
array
<
QByteArray
,
5
>
responses
{
QByteArrayLiteral
(
"250"
),
/**< ok (optional timing information here) */
QByteArrayLiteral
(
"552"
),
/**< No match */
QByteArrayLiteral
(
"550"
),
/**< Invalid database */
QByteArrayLiteral
(
"501"
),
/**< Syntax error, illegal parameters */
QByteArrayLiteral
(
"503"
),
/**< Command parameter not implemented */
};
while
(
std
::
none_of
(
responses
.
cbegin
(),
responses
.
cend
(),
[
&
ret
](
const
QByteArray
&
code
)
{
while
(
std
::
none_of
(
m_definitionResponses
.
cbegin
(),
m_definitionResponses
.
cend
(),
[
&
ret
](
const
QByteArray
&
code
)
{
return
ret
.
contains
(
code
);
}))
{
m_tcpSocket
->
waitForReadyRead
();
...
...
dict/dictengine.h
View file @
82c096c4
...
...
@@ -47,4 +47,7 @@ private:
QString
m_dictName
;
QString
m_serverName
;
QMap
<
QString
,
QMap
<
QString
,
QString
>>
m_availableDictsCache
;
// https://datatracker.ietf.org/doc/html/rfc2229
std
::
array
<
QByteArray
,
5
>
m_definitionResponses
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment