mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
opt: Sorting through the use of strings
there are many string conversion in the system .some of them can be avoided .
This commit is contained in:
parent
cb67c465a3
commit
c2f856c074
|
@ -514,7 +514,7 @@ void ArticleRequest::altSearchFinished()
|
|||
#ifdef QT_DEBUG
|
||||
for( unsigned x = 0; x < altsVector.size(); ++x )
|
||||
{
|
||||
qDebug() << "Alt:" << gd::toQString( altsVector[ x ] );
|
||||
qDebug() << "Alt:" << QString::fromStdU32String( altsVector[ x ] );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1012,7 +1012,7 @@ QString ArticleRequest::makeSplittedWordCompound()
|
|||
|
||||
Folding::normalizeWhitespace( ws );
|
||||
|
||||
result.append( gd::toQString( ws ) );
|
||||
result.append( QString::fromStdU32String( ws ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ void BtreeWordSearchRequest::findMatches()
|
|||
|
||||
if( useWildcards )
|
||||
{
|
||||
regexp.setPattern( wildcardsToRegexp( gd::toQString( Folding::applyDiacriticsOnly( Folding::applySimpleCaseOnly( str ) ) ) ) );
|
||||
regexp.setPattern( wildcardsToRegexp( QString::fromStdU32String( Folding::applyDiacriticsOnly( Folding::applySimpleCaseOnly( str ) ) ) ) );
|
||||
if( !regexp.isValid() )
|
||||
regexp.setPattern( QRegularExpression::escape( regexp.pattern() ) );
|
||||
regexp.setPatternOptions( QRegularExpression::CaseInsensitiveOption );
|
||||
|
@ -337,7 +337,7 @@ void BtreeWordSearchRequest::findMatches()
|
|||
wstring result = Folding::applyDiacriticsOnly( word );
|
||||
if( result.size() >= (wstring::size_type)minMatchLength )
|
||||
{
|
||||
QRegularExpressionMatch match = regexp.match( gd::toQString( result ) );
|
||||
QRegularExpressionMatch match = regexp.match( QString::fromStdU32String( result ) );
|
||||
if( match.hasMatch() && match.capturedStart() == 0 )
|
||||
{
|
||||
addMatch( word );
|
||||
|
|
|
@ -133,7 +133,7 @@ std::string Iconv::toUtf8( char const * fromEncoding, void const * fromData,
|
|||
|
||||
Iconv ic( Utf8, fromEncoding );
|
||||
|
||||
QString outStr = ic.convert(fromData, dataSize);
|
||||
return gd::toStdString(outStr);
|
||||
const QString outStr = ic.convert(fromData, dataSize);
|
||||
return outStr.toStdString();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
namespace gd
|
||||
{
|
||||
QString toQString( wstring const & in )
|
||||
{
|
||||
return QString::fromStdU32String( in );
|
||||
}
|
||||
|
||||
//This is not only about non-BMP characters.even without non-BMP. this wrapper has removed the tailing \0
|
||||
//so even https://bugreports.qt-project.org/browse/QTBUG-25536 has been fixed . It can not directly be replaced by
|
||||
// QString::toStd32String();
|
||||
wstring toWString( QString const & in )
|
||||
{
|
||||
QVector< unsigned int > v = in.toUcs4();
|
||||
|
@ -25,12 +24,9 @@ namespace gd
|
|||
|
||||
wstring normalize( const wstring & str )
|
||||
{
|
||||
return gd::toWString( gd::toQString( str ).normalized( QString::NormalizationForm_C ) );
|
||||
return gd::toWString( QString::fromStdU32String( str ).normalized( QString::NormalizationForm_C ) );
|
||||
}
|
||||
|
||||
std::string toStdString(const QString& str)
|
||||
{
|
||||
return str.toStdString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,8 @@
|
|||
|
||||
namespace gd
|
||||
{
|
||||
QString toQString( wstring const & );
|
||||
wstring toWString( QString const & );
|
||||
wstring normalize( wstring const & );
|
||||
std::string toStdString(const QString& );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -206,7 +206,7 @@ InputPhrase Preferences::sanitizeInputPhrase( QString const & inputPhrase ) cons
|
|||
}
|
||||
|
||||
const QString withPunct = _phase.simplified().remove( QChar( 0xAD ) ); // Simplify whitespaces and remove soft hyphens;
|
||||
result.phrase = gd::toQString( Folding::trimWhitespaceOrPunct( gd::toWString( withPunct ) ) );
|
||||
result.phrase = QString::fromStdU32String( Folding::trimWhitespaceOrPunct( gd::toWString( withPunct ) ) );
|
||||
if ( !result.isValid() )
|
||||
return result; // The suffix of an invalid input phrase must be empty.
|
||||
|
||||
|
|
|
@ -451,7 +451,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
text = Html::unescape( gd::toQString( wstr ) );
|
||||
text = Html::unescape( QString::fromStdU32String( wstr ) );
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
{
|
||||
|
|
|
@ -763,10 +763,9 @@ void Babylon::convertToUtf8( std::string &s, unsigned int type )
|
|||
|
||||
size_t inbufbytes = s.size();
|
||||
|
||||
char *inbuf;
|
||||
inbuf = (char *)s.data();
|
||||
char* inbuf = (char*)s.data();
|
||||
const void* test = inbuf;
|
||||
|
||||
QString convStr = conv_.convert(test,inbufbytes);
|
||||
s = gd::toStdString(convStr);
|
||||
const QString convStr = conv_.convert(test,inbufbytes);
|
||||
s = convStr.toStdString();
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ void DictServerWordSearchRequest::run()
|
|||
QString matchReq = QString( "MATCH " )
|
||||
+ dict.databases.at( i )
|
||||
+ " " + dict.strategies.at( ns )
|
||||
+ " \"" + gd::toQString( word )
|
||||
+ " \"" + QString::fromStdU32String( word )
|
||||
+ "\"\r\n";
|
||||
socket->write( matchReq.toUtf8() );
|
||||
socket->waitForBytesWritten( 1000 );
|
||||
|
@ -644,7 +644,7 @@ void DictServerArticleRequest::run()
|
|||
{
|
||||
QString defineReq = QString( "DEFINE " )
|
||||
+ dict.databases.at( i )
|
||||
+ " \"" + gd::toQString( word ) + "\"\r\n";
|
||||
+ " \"" + QString::fromStdU32String( word ) + "\"\r\n";
|
||||
socket->write( defineReq.toUtf8() );
|
||||
socket->waitForBytesWritten( 1000 );
|
||||
|
||||
|
|
|
@ -1063,7 +1063,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
{
|
||||
// Find ISO 639-1 code
|
||||
string langcode;
|
||||
QString attr = gd::toQString( node.tagAttrs );
|
||||
QString attr = QString::fromStdU32String( node.tagAttrs );
|
||||
int n = attr.indexOf( "id=" );
|
||||
if( n >= 0 )
|
||||
{
|
||||
|
@ -1097,10 +1097,10 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
url.setHost( "localhost" );
|
||||
wstring nodeStr = node.renderAsText();
|
||||
normalizeHeadword( nodeStr );
|
||||
url.setPath( Utils::Url::ensureLeadingSlash( gd::toQString( nodeStr ) ) );
|
||||
url.setPath( Utils::Url::ensureLeadingSlash( QString::fromStdU32String( nodeStr ) ) );
|
||||
if( !node.tagAttrs.empty() )
|
||||
{
|
||||
QString attr = gd::toQString( node.tagAttrs ).remove( '\"' );
|
||||
QString attr = QString::fromStdU32String( node.tagAttrs ).remove( '\"' );
|
||||
int n = attr.indexOf( '=' );
|
||||
if( n > 0 )
|
||||
{
|
||||
|
@ -1123,7 +1123,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
url.setHost( "localhost" );
|
||||
wstring nodeStr = node.renderAsText();
|
||||
normalizeHeadword( nodeStr );
|
||||
url.setPath( Utils::Url::ensureLeadingSlash( gd::toQString( nodeStr ) ) );
|
||||
url.setPath( Utils::Url::ensureLeadingSlash( QString::fromStdU32String( nodeStr ) ) );
|
||||
|
||||
result += string( R"(<a class="dsl_ref" href=")" ) + url.toEncoded().data() +"\">"
|
||||
+ processNodeChildren( node ) + "</a>";
|
||||
|
@ -1147,12 +1147,12 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
else
|
||||
{
|
||||
gdWarning( R"(DSL: Unknown tag "%s" with attributes "%s" found in "%s", article "%s".)",
|
||||
gd::toQString( node.tagName ).toUtf8().data(), gd::toQString( node.tagAttrs ).toUtf8().data(),
|
||||
getName().c_str(), gd::toQString( currentHeadword ).toUtf8().data() );
|
||||
QString::fromStdU32String( node.tagName ).toUtf8().data(), QString::fromStdU32String( node.tagAttrs ).toUtf8().data(),
|
||||
getName().c_str(), QString::fromStdU32String( currentHeadword ).toUtf8().data() );
|
||||
|
||||
result += "<span class=\"dsl_unknown\">[" + string( gd::toQString( node.tagName ).toUtf8().data() );
|
||||
result += "<span class=\"dsl_unknown\">[" + string( QString::fromStdU32String( node.tagName ).toUtf8().data() );
|
||||
if( !node.tagAttrs.empty() )
|
||||
result += " " + string( gd::toQString( node.tagAttrs ).toUtf8().data() );
|
||||
result += " " + string( QString::fromStdU32String( node.tagAttrs ).toUtf8().data() );
|
||||
result += "]" + processNodeChildren( node ) + "</span>";
|
||||
}
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
{
|
||||
unescapeDsl( articleHeadword );
|
||||
normalizeHeadword( articleHeadword );
|
||||
headword = gd::toQString( articleHeadword );
|
||||
headword = QString::fromStdU32String( articleHeadword );
|
||||
}
|
||||
|
||||
wstring articleText;
|
||||
|
@ -1433,7 +1433,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
|
||||
if( !articleText.empty() )
|
||||
{
|
||||
text = gd::toQString( articleText ).normalized( QString::NormalizationForm_C );
|
||||
text = QString::fromStdU32String( articleText ).normalized( QString::NormalizationForm_C );
|
||||
|
||||
articleText.clear();
|
||||
|
||||
|
@ -1524,7 +1524,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
{
|
||||
// Use base DSL parser for articles with insided cards
|
||||
ArticleDom dom( gd::toWString( text ), getName(), articleHeadword );
|
||||
text = gd::toQString( dom.root.renderAsText( true ) );
|
||||
text = QString::fromStdU32String( dom.root.renderAsText( true ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1946,7 +1946,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
|
||||
gdDebug( "Dsl: Building the index for dictionary: %s\n",
|
||||
gd::toQString( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
QString::fromStdU32String( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
|
||||
File::Class idx( indexFile, "wb" );
|
||||
|
||||
|
@ -2136,7 +2136,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
break; // No more headwords
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Alt headword" << gd::toQString( curString );
|
||||
qDebug() << "Alt headword" << QString::fromStdU32String( curString );
|
||||
#endif
|
||||
|
||||
processUnsortedParts( curString, true );
|
||||
|
|
|
@ -146,7 +146,7 @@ bool isAtSignFirst( wstring const & str )
|
|||
{
|
||||
// Test if '@' is first in string except spaces and dsl tags
|
||||
QRegularExpression reg( R"([ \t]*(?:\[[^\]]+\][ \t]*)*@)", QRegularExpression::PatternOption::CaseInsensitiveOption);
|
||||
return gd::toQString( str ).indexOf (reg) == 0;
|
||||
return QString::fromStdU32String( str ).indexOf (reg) == 0;
|
||||
}
|
||||
|
||||
/////////////// ArticleDom
|
||||
|
@ -357,11 +357,11 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
{
|
||||
if( !dictionaryName.empty() )
|
||||
gdWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found in "%s", article "%s".)",
|
||||
gd::toQString( name ).toUtf8().data(), gd::toQString( attrs ).toUtf8().data(),
|
||||
dictionaryName.c_str(), gd::toQString( headword ).toUtf8().data() );
|
||||
QString::fromStdU32String( name ).toUtf8().data(), QString::fromStdU32String( attrs ).toUtf8().data(),
|
||||
dictionaryName.c_str(), QString::fromStdU32String( headword ).toUtf8().data() );
|
||||
else
|
||||
gdWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found)",
|
||||
gd::toQString( name ).toUtf8().data(), gd::toQString( attrs ).toUtf8().data() );
|
||||
QString::fromStdU32String( name ).toUtf8().data(), QString::fromStdU32String( attrs ).toUtf8().data() );
|
||||
|
||||
throw eot();
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
list< Node * >::iterator it = std::find_if( stack.begin(), stack.end(), MustTagBeClosed() );
|
||||
if( it == stack.end() )
|
||||
return; // no unclosed tags that must be closed => nothing to warn about
|
||||
QByteArray const firstTagName = gd::toQString( ( *it )->tagName ).toUtf8();
|
||||
QByteArray const firstTagName = QString::fromStdU32String( ( *it )->tagName ).toUtf8();
|
||||
++it;
|
||||
unsigned const unclosedTagCount = 1 + std::count_if( it, stack.end(), MustTagBeClosed() );
|
||||
|
||||
|
@ -671,7 +671,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
else
|
||||
{
|
||||
gdWarning( "Warning: %u tag(s) were unclosed in \"%s\", article \"%s\", first tag name \"%s\".\n",
|
||||
unclosedTagCount, dictName.c_str(), gd::toQString( headword ).toUtf8().constData(),
|
||||
unclosedTagCount, dictName.c_str(), QString::fromStdU32String( headword ).toUtf8().constData(),
|
||||
firstTagName.constData() );
|
||||
}
|
||||
}
|
||||
|
@ -815,11 +815,11 @@ void ArticleDom::closeTag( wstring const & name,
|
|||
{
|
||||
if( !dictionaryName.empty() )
|
||||
gdWarning( R"(No corresponding opening tag for closing tag "%s" found in "%s", article "%s".)",
|
||||
gd::toQString( name ).toUtf8().data(), dictionaryName.c_str(),
|
||||
gd::toQString( headword ).toUtf8().data() );
|
||||
QString::fromStdU32String( name ).toUtf8().data(), dictionaryName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().data() );
|
||||
else
|
||||
gdWarning( "No corresponding opening tag for closing tag \"%s\" found.",
|
||||
gd::toQString( name ).toUtf8().data() );
|
||||
QString::fromStdU32String( name ).toUtf8().data() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ void EpwingHeadwordsRequest::run()
|
|||
return;
|
||||
}
|
||||
|
||||
QRegularExpressionMatch m = RX::Epwing::refWord.match( gd::toQString( str ) );
|
||||
QRegularExpressionMatch m = RX::Epwing::refWord.match( QString::fromStdU32String( str ) );
|
||||
if ( !m.hasMatch() ) {
|
||||
finish();
|
||||
return;
|
||||
|
@ -728,7 +728,7 @@ void EpwingArticleRequest::run()
|
|||
articlesIncluded.insert( x.articleOffset );
|
||||
}
|
||||
|
||||
QRegularExpressionMatch m = RX::Epwing::refWord.match( gd::toQString( word ) );
|
||||
QRegularExpressionMatch m = RX::Epwing::refWord.match( QString::fromStdU32String( word ) );
|
||||
bool ref = m.hasMatch();
|
||||
|
||||
// Also try to find word in the built-in dictionary index
|
||||
|
@ -806,7 +806,7 @@ void EpwingArticleRequest::getBuiltInArticle( wstring const & word_,
|
|||
QVector< int > pg, off;
|
||||
{
|
||||
Mutex::Lock _( dict.eBook.getLibMutex() );
|
||||
dict.eBook.getArticlePos( gd::toQString( word_ ), pg, off );
|
||||
dict.eBook.getArticlePos( QString::fromStdU32String( word_ ), pg, off );
|
||||
}
|
||||
|
||||
for( int i = 0; i < pg.size(); i++ )
|
||||
|
@ -843,7 +843,7 @@ void EpwingDictionary::getHeadwordPos( wstring const & word_, QVector< int > & p
|
|||
{
|
||||
try {
|
||||
Mutex::Lock _( eBook.getLibMutex() );
|
||||
eBook.getArticlePos( gd::toQString( word_ ), pg, off );
|
||||
eBook.getArticlePos( QString::fromStdU32String( word_ ), pg, off );
|
||||
}
|
||||
catch ( ... ) {
|
||||
//ignore
|
||||
|
@ -1079,7 +1079,7 @@ void EpwingWordSearchRequest::findMatches()
|
|||
if( Utils::AtomicInt::loadAcquire( isCancelled ) )
|
||||
break;
|
||||
|
||||
if( !edict.eBook.getMatches( gd::toQString( str ), headwords ) )
|
||||
if( !edict.eBook.getMatches( QString::fromStdU32String( str ), headwords ) )
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1122,7 +1122,7 @@ void EpwingBook::fixHeadword( QString & headword )
|
|||
//}
|
||||
|
||||
gd::wstring folded = Folding::applyPunctOnly( gd::toWString( fixed ) );
|
||||
//fixed = gd::toQString( folded );
|
||||
//fixed = QString::fromStdU32String( folded );
|
||||
|
||||
//if( isHeadwordCorrect( fixed ) )
|
||||
//{
|
||||
|
@ -1131,7 +1131,7 @@ void EpwingBook::fixHeadword( QString & headword )
|
|||
//}
|
||||
|
||||
folded = Folding::applyDiacriticsOnly( folded );
|
||||
fixed = gd::toQString( folded );
|
||||
fixed = QString::fromStdU32String( folded );
|
||||
|
||||
//if( isHeadwordCorrect( fixed ) )
|
||||
//{
|
||||
|
@ -1140,7 +1140,7 @@ void EpwingBook::fixHeadword( QString & headword )
|
|||
//}
|
||||
|
||||
//folded = Folding::applyWhitespaceOnly( folded );
|
||||
//fixed = gd::toQString( folded );
|
||||
//fixed = QString::fromStdU32String( folded );
|
||||
|
||||
//if( isHeadwordCorrect( fixed ) )
|
||||
// headword = fixed;
|
||||
|
|
|
@ -122,7 +122,7 @@ ForvoArticleRequest::ForvoArticleRequest( wstring const & str,
|
|||
void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
||||
wstring const & str )
|
||||
{
|
||||
gdDebug( "Forvo: requesting article %s\n", gd::toQString( str ).toUtf8().data() );
|
||||
gdDebug( "Forvo: requesting article %s\n", QString::fromStdU32String( str ).toUtf8().data() );
|
||||
|
||||
QString key = apiKey;
|
||||
|
||||
|
@ -131,7 +131,7 @@ void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
|||
"/key/" + key +
|
||||
"/action/word-pronunciations"
|
||||
"/format/xml"
|
||||
"/word/" + QLatin1String( QUrl::toPercentEncoding( gd::toQString( str ) ) ) +
|
||||
"/word/" + QLatin1String( QUrl::toPercentEncoding( QString::fromStdU32String( str ) ) ) +
|
||||
"/language/" + languageCode +
|
||||
"/order/rate-desc"
|
||||
).toUtf8() );
|
||||
|
|
|
@ -852,7 +852,7 @@ void GlsDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
|
||||
wstring wstr = Utf8::decode( articleStr );
|
||||
|
||||
text = Html::unescape( gd::toQString( wstr ) );
|
||||
text = Html::unescape( QString::fromStdU32String( wstr ) );
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
{
|
||||
|
@ -1414,7 +1414,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
|
||||
gdDebug( "Gls: Building the index for dictionary: %s\n",
|
||||
gd::toQString( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
QString::fromStdU32String( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
|
||||
File::Class idx( indexFile, "wb" );
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
|
||||
for( vector< string >::size_type x = 0; x < suggestions.size(); ++x )
|
||||
{
|
||||
QString suggestion = gd::toQString( decodeFromHunspell( hunspell, suggestions[ x ].c_str() ) );
|
||||
QString suggestion = QString::fromStdU32String( decodeFromHunspell( hunspell, suggestions[ x ].c_str() ) );
|
||||
|
||||
// Strip comments
|
||||
int n = suggestion.indexOf( '#' );
|
||||
|
@ -492,7 +492,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
if ( Folding::applySimpleCaseOnly( alt ) != lowercasedWord ) // No point in providing same word
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << ">>>>>Alt:" << gd::toQString( alt );
|
||||
qDebug() << ">>>>>Alt:" << QString::fromStdU32String( alt );
|
||||
#endif
|
||||
result.append( alt );
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,
|
|||
|
||||
GlobalBroadcaster::instance()->addWhitelist( reqUrl.host() );
|
||||
|
||||
Utils::Url::addQueryItem( reqUrl, "apfrom", gd::toQString( str ).replace( '+', "%2B" ) );
|
||||
Utils::Url::addQueryItem( reqUrl, "apfrom", QString::fromStdU32String( str ).replace( '+', "%2B" ) );
|
||||
|
||||
netReply = std::shared_ptr<QNetworkReply>(mgr.get( QNetworkRequest( reqUrl ) ));
|
||||
|
||||
|
@ -418,11 +418,11 @@ MediaWikiArticleRequest::MediaWikiArticleRequest( wstring const & str,
|
|||
void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
||||
wstring const & str )
|
||||
{
|
||||
gdDebug( "MediaWiki: requesting article %s\n", gd::toQString( str ).toUtf8().data() );
|
||||
gdDebug( "MediaWiki: requesting article %s\n", QString::fromStdU32String( str ).toUtf8().data() );
|
||||
|
||||
QUrl reqUrl( url + "/api.php?action=parse&prop=text|revid|sections&format=xml&redirects" );
|
||||
|
||||
Utils::Url::addQueryItem( reqUrl, "page", gd::toQString( str ).replace( '+', "%2B" ) );
|
||||
Utils::Url::addQueryItem( reqUrl, "page", QString::fromStdU32String( str ).replace( '+', "%2B" ) );
|
||||
QNetworkRequest req( reqUrl ) ;
|
||||
//millseconds.
|
||||
req.setTransferTimeout(3000);
|
||||
|
|
|
@ -62,7 +62,7 @@ sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word,
|
|||
|
||||
{
|
||||
if ( prg.type == Config::Program::PrefixMatch )
|
||||
return std::make_shared<ProgramWordSearchRequest>( gd::toQString( word ), prg );
|
||||
return std::make_shared<ProgramWordSearchRequest>( QString::fromStdU32String( word ), prg );
|
||||
else
|
||||
{
|
||||
sptr< WordSearchRequestInstant > sr = std::make_shared<WordSearchRequestInstant>();
|
||||
|
@ -112,7 +112,7 @@ sptr< Dictionary::DataRequest > ProgramsDictionary::getArticle(
|
|||
|
||||
case Config::Program::Html:
|
||||
case Config::Program::PlainText:
|
||||
return std::make_shared<ProgramDataRequest>( gd::toQString( word ), prg );
|
||||
return std::make_shared<ProgramDataRequest>( QString::fromStdU32String( word ), prg );
|
||||
|
||||
default:
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
|
|
|
@ -455,7 +455,7 @@ void SdictDictionary::getArticleText( uint32_t articleAddress, QString & headwor
|
|||
try
|
||||
{
|
||||
wstring wstr = Utf8::decode( articleStr );
|
||||
text = Html::unescape( gd::toQString( wstr ) );
|
||||
text = Html::unescape( QString::fromStdU32String( wstr ) );
|
||||
}
|
||||
catch( std::exception & )
|
||||
{
|
||||
|
|
|
@ -1199,7 +1199,7 @@ void StardictDictionary::getArticleText( uint32_t articleAddress, QString & head
|
|||
|
||||
wstring wstr = Utf8::decode( articleStr );
|
||||
|
||||
text = Html::unescape( gd::toQString( wstr ) );
|
||||
text = Html::unescape( QString::fromStdU32String( wstr ) );
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
{
|
||||
|
|
|
@ -331,7 +331,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
|
|||
{
|
||||
urlString = urlTemplate;
|
||||
|
||||
QString inputWord = gd::toQString( str );
|
||||
QString inputWord = QString::fromStdU32String( str );
|
||||
|
||||
urlString.replace( "%25GDWORD%25", inputWord.toUtf8().toPercentEncoding() );
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ void XdxfDictionary::getArticleText( uint32_t articleAddress, QString & headword
|
|||
|
||||
wstring wstr = Utf8::decode( articleStr );
|
||||
|
||||
text = Html::unescape( gd::toQString( wstr ) );
|
||||
text = Html::unescape( QString::fromStdU32String( wstr ) );
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
{
|
||||
|
|
|
@ -463,7 +463,7 @@ string convert( string const & in, DICT_TYPE type, map < string, string > const
|
|||
}
|
||||
else
|
||||
title = i->second;
|
||||
el.setAttribute( "title", gd::toQString( Utf8::decode( title ) ) );
|
||||
el.setAttribute( "title", QString::fromStdU32String( Utf8::decode( title ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -683,7 +683,7 @@ void FTSResultsRequest::checkSingleArticle( uint32_t offset,
|
|||
articleText = articleText.normalized( QString::NormalizationForm_C );
|
||||
|
||||
if( ignoreDiacritics )
|
||||
articleText = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( articleText ) ) );
|
||||
articleText = QString::fromStdU32String( Folding::applyDiacriticsOnly( gd::toWString( articleText ) ) );
|
||||
|
||||
if( articleText.contains( searchRegularExpression ) )
|
||||
{
|
||||
|
@ -726,7 +726,7 @@ void FTSResultsRequest::checkSingleArticle( uint32_t offset,
|
|||
articleText = articleText.normalized( QString::NormalizationForm_C );
|
||||
|
||||
if( ignoreDiacritics )
|
||||
articleText = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( articleText ) ) );
|
||||
articleText = QString::fromStdU32String( Folding::applyDiacriticsOnly( gd::toWString( articleText ) ) );
|
||||
|
||||
if( ignoreWordsOrder )
|
||||
{
|
||||
|
@ -1106,7 +1106,7 @@ void FTSResultsRequest::fullIndexSearch( BtreeIndexing::BtreeIndex & ftsIndex,
|
|||
QString word = QString::fromUtf8( links[ x ].word.data(), links[ x ].word.size() );
|
||||
|
||||
if( ignoreDiacritics )
|
||||
word = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( word ) ) );
|
||||
word = QString::fromStdU32String( Folding::applyDiacriticsOnly( gd::toWString( word ) ) );
|
||||
|
||||
for( int i = 0; i < indexWords.size(); i++ )
|
||||
{
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
wordsInIndex( 0 )
|
||||
{
|
||||
if( ignoreDiacritics_ )
|
||||
searchString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( searchString_ ) ) );
|
||||
searchString = QString::fromStdU32String( Folding::applyDiacriticsOnly( gd::toWString( searchString_ ) ) );
|
||||
|
||||
foundHeadwords = new QList< FTS::FtsHeadword >;
|
||||
results = 0;
|
||||
|
|
|
@ -88,7 +88,7 @@ void HeadwordListModel::requestFinished()
|
|||
{
|
||||
auto allmatches = ( *i )->getAllMatches();
|
||||
for( auto & match : allmatches )
|
||||
filterWords.append( gd::toQString( match.word ) );
|
||||
filterWords.append( QString::fromStdU32String( match.word ) );
|
||||
}
|
||||
queuedRequests.erase( i++ );
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ BabylonLang getBabylonLangByIndex( int index )
|
|||
|
||||
quint32 findBlgLangIDByEnglishName( gd::wstring const & lang )
|
||||
{
|
||||
const QString enName = gd::toQString( lang );
|
||||
QString enName = QString::fromStdU32String( lang );
|
||||
for ( const auto & idx : BabylonDb ) {
|
||||
if ( QString::compare( idx.englishName, enName, Qt::CaseInsensitive ) == 0 )
|
||||
return idx.id;
|
||||
|
|
|
@ -169,7 +169,7 @@ public:
|
|||
nextChar += consumed;
|
||||
left -= consumed;
|
||||
}
|
||||
normalizedString = gd::toQString( normText );
|
||||
normalizedString = QString::fromStdU32String( normText );
|
||||
}
|
||||
};
|
||||
/// End of DiacriticsHandler class
|
||||
|
@ -2450,7 +2450,7 @@ void ArticleView::highlightFTSResults()
|
|||
bool ignoreDiacritics = Utils::Url::hasQueryItem( url, "ignore_diacritics" );
|
||||
|
||||
if( ignoreDiacritics )
|
||||
regString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) );
|
||||
regString = QString::fromStdU32String( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) );
|
||||
else
|
||||
regString = regString.remove( AccentMarkHandler::accentMark() );
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@ void WordFinder::updateResults()
|
|||
//GD_DPRINTF( "%d: %ls\n", i->second, i->first.c_str() );
|
||||
|
||||
if ( searchResults.size() < maxSearchResults )
|
||||
searchResults.push_back( std::pair< QString, bool >( gd::toQString( i->word ), i->wasSuggested ) );
|
||||
searchResults.push_back( std::pair< QString, bool >( QString::fromStdU32String( i->word ), i->wasSuggested ) );
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue