forked from len0rd/rockbox
rbutil: Fix TalkGenerator string correction.
- Fix regexp case insensitive option being inverted. - Pass more objects by reference. - Some const-ness. Change-Id: I1c77ad22ab1e505c8dce8c083d9c52e76a6860be
This commit is contained in:
parent
215ba4abf7
commit
948637c42c
2 changed files with 15 additions and 15 deletions
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
TalkGenerator::TalkGenerator(QObject* parent): QObject(parent)
|
TalkGenerator::TalkGenerator(QObject* parent): QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Creates Talkfiles.
|
//! \brief Creates Talkfiles.
|
||||||
|
@ -257,16 +256,17 @@ void TalkGenerator::abort()
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TalkGenerator::correctString(QString s)
|
QString TalkGenerator::correctString(const QString& s)
|
||||||
{
|
{
|
||||||
QString corrected = s;
|
QString corrected = s;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int max = m_corrections.size();
|
int max = m_corrections.size();
|
||||||
while(i < max) {
|
while(i < max) {
|
||||||
corrected = corrected.replace(QRegularExpression(m_corrections.at(i).search,
|
corrected = corrected.replace(QRegularExpression(m_corrections.at(i).search,
|
||||||
m_corrections.at(i).modifier.contains("i")
|
(m_corrections.at(i).modifier.contains("i")
|
||||||
? QRegularExpression::NoPatternOption
|
? QRegularExpression::CaseInsensitiveOption
|
||||||
: QRegularExpression::CaseInsensitiveOption),
|
: QRegularExpression::NoPatternOption)
|
||||||
|
| QRegularExpression::UseUnicodePropertiesOption),
|
||||||
m_corrections.at(i).replace);
|
m_corrections.at(i).replace);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ QString TalkGenerator::correctString(QString s)
|
||||||
return corrected;
|
return corrected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TalkGenerator::setLang(QString name)
|
void TalkGenerator::setLang(const QString& name)
|
||||||
{
|
{
|
||||||
m_lang = name;
|
m_lang = name;
|
||||||
|
|
||||||
|
@ -313,16 +313,16 @@ void TalkGenerator::setLang(QString name)
|
||||||
if(items.size() < 6)
|
if(items.size() < 6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QRegExp re_lang(items.at(0));
|
QRegularExpression re_lang(items.at(0));
|
||||||
QRegExp re_engine(items.at(1));
|
QRegularExpression re_engine(items.at(1));
|
||||||
QRegExp re_vendor(items.at(2));
|
QRegularExpression re_vendor(items.at(2));
|
||||||
if(!re_lang.exactMatch(m_lang)) {
|
if(!re_lang.match(m_lang).hasMatch()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!re_vendor.exactMatch(vendor)) {
|
if(!re_vendor.match(vendor).hasMatch()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!re_engine.exactMatch(engine)) {
|
if(!re_engine.match(engine).hasMatch()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
struct CorrectionItems co;
|
struct CorrectionItems co;
|
||||||
|
|
|
@ -53,11 +53,11 @@ public:
|
||||||
TalkGenerator(QObject* parent);
|
TalkGenerator(QObject* parent);
|
||||||
|
|
||||||
Status process(QList<TalkEntry>* list,int wavtrimth = -1);
|
Status process(QList<TalkEntry>* list,int wavtrimth = -1);
|
||||||
QString correctString(QString s);
|
QString correctString(const QString& s);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void abort();
|
void abort();
|
||||||
void setLang(QString name);
|
void setLang(const QString& name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void done(bool);
|
void done(bool);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue