From 9faf843ab737d6daaaeb4ac6e04a7de66790708e Mon Sep 17 00:00:00 2001 From: Tvangeste Date: Sun, 3 Feb 2013 21:19:55 +0100 Subject: [PATCH] Part of work for #212: Make GD source to be ready for Qt5. Replaced deprecated to/fromAscii with to/fromLatin1 --- about.cc | 2 +- article_maker.cc | 4 ++-- article_netmgr.cc | 2 +- articleview.cc | 4 ++-- config.cc | 4 ++-- dsl.cc | 2 +- forvo.cc | 4 ++-- fsencoding.cc | 2 +- groups_widgets.cc | 2 +- hunspell.cc | 2 +- langcoder.cc | 4 ++-- preferences.cc | 2 +- website.cc | 2 +- xdxf.cc | 4 ++-- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/about.cc b/about.cc index 4e44840b..4ad79f43 100644 --- a/about.cc +++ b/about.cc @@ -15,7 +15,7 @@ About::About( QWidget * parent ): QDialog( parent ) if ( !versionFile.open( QFile::ReadOnly ) ) version = tr( "[Unknown]" ); else - version = QString::fromAscii( versionFile.readAll() ).trimmed(); + version = QString::fromLatin1( versionFile.readAll() ).trimmed(); ui.version->setText( version ); diff --git a/article_maker.cc b/article_maker.cc index 4938472e..b192d368 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -492,9 +492,9 @@ void ArticleRequest::bodyFinished() + ""; head += "getLangFrom() ).toAscii().data(); + head += LangCoder::intToCode2( activeDict->getLangFrom() ).toLatin1().data(); head += "\" lang=\""; - head += LangCoder::intToCode2( activeDict->getLangTo() ).toAscii().data(); + head += LangCoder::intToCode2( activeDict->getLangTo() ).toLatin1().data(); head += "\">"; if ( errorString.size() ) diff --git a/article_netmgr.cc b/article_netmgr.cc index e9c667c9..21532207 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -147,7 +147,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( if ( contextsEncoded.size() ) { - QByteArray ba = QByteArray::fromBase64( contextsEncoded.toAscii() ); + QByteArray ba = QByteArray::fromBase64( contextsEncoded.toLatin1() ); QBuffer buf( & ba ); diff --git a/articleview.cc b/articleview.cc index 18a235ed..f6b49c3d 100644 --- a/articleview.cc +++ b/articleview.cc @@ -235,7 +235,7 @@ void ArticleView::showDefinition( QString const & word, unsigned group, buf.close(); - req.addQueryItem( "contexts", QString::fromAscii( buf.buffer().toBase64() ) ); + req.addQueryItem( "contexts", QString::fromLatin1( buf.buffer().toBase64() ) ); } QString mutedDicts = getMutedForGroup( group ); @@ -497,7 +497,7 @@ void ArticleView::tryMangleWebsiteClickedUrl( QUrl & url, Contexts & contexts ) { // Looks this way - contexts[ ca.mid( 7 ) ] = QString::fromAscii( url.toEncoded() ); + contexts[ ca.mid( 7 ) ] = QString::fromLatin1( url.toEncoded() ); QUrl target; diff --git a/config.cc b/config.cc index 0b2b7442..7b9c8dc8 100644 --- a/config.cc +++ b/config.cc @@ -235,7 +235,7 @@ Group loadGroup( QDomElement grp, unsigned * nextId = 0 ) g.icon = grp.attribute( "icon" ); if ( !grp.attribute( "iconData" ).isEmpty() ) - g.iconData = QByteArray::fromBase64( grp.attribute( "iconData" ).toAscii() ); + g.iconData = QByteArray::fromBase64( grp.attribute( "iconData" ).toLatin1() ); if ( !grp.attribute( "shortcut" ).isEmpty() ) g.shortcut = QKeySequence::fromString( grp.attribute( "shortcut" ) ); @@ -819,7 +819,7 @@ void saveGroup( Group const & data, QDomElement & group ) { QDomAttr iconData = dd.createAttribute( "iconData" ); - iconData.setValue( QString::fromAscii( data.iconData.toBase64() ) ); + iconData.setValue( QString::fromLatin1( data.iconData.toBase64() ) ); group.setAttributeNode( iconData ); } diff --git a/dsl.cc b/dsl.cc index bf164440..d1d7c0e0 100644 --- a/dsl.cc +++ b/dsl.cc @@ -1009,7 +1009,7 @@ QString const& DslDictionary::getDescription() qint32 gdLang, annLang; QString langStr; - gdLang = LangCoder::code2toInt( QLocale::system().name().left( 2 ).toAscii().data() ); + gdLang = LangCoder::code2toInt( QLocale::system().name().left( 2 ).toLatin1().data() ); for(;;) { data.clear(); diff --git a/forvo.cc b/forvo.cc index 924498ca..332871c6 100644 --- a/forvo.cc +++ b/forvo.cc @@ -100,7 +100,7 @@ void ForvoDictionary::loadIcon() throw() #if 0 if ( languageCode.size() == 2 ) { - QString countryCode = Language::countryCodeForId( LangCoder::code2toInt( languageCode.toAscii().data() ) ); + QString countryCode = Language::countryCodeForId( LangCoder::code2toInt( languageCode.toLatin1().data() ) ); if ( countryCode.size() ) { @@ -175,7 +175,7 @@ void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr, QUrl reqUrl = QUrl::fromEncoded( QString( "http://apifree.forvo.com/key/" + key + "/format/xml/action/word-pronunciations/word/" + - QString::fromAscii( QUrl::toPercentEncoding( gd::toQString( str ) ) ) + "/language/" + languageCode + QString::fromLatin1( QUrl::toPercentEncoding( gd::toQString( str ) ) ) + "/language/" + languageCode ).toUtf8() ); // DPRINTF( "req: %s\n", reqUrl.toEncoded().data() ); diff --git a/fsencoding.cc b/fsencoding.cc index f19de3e4..64aef4ec 100644 --- a/fsencoding.cc +++ b/fsencoding.cc @@ -56,7 +56,7 @@ QString decode( const char *str ) char separator() { - return QDir::separator().toAscii(); + return QDir::separator().toLatin1(); } string dirname( string const & str ) diff --git a/groups_widgets.cc b/groups_widgets.cc index 6d701635..0548de06 100644 --- a/groups_widgets.cc +++ b/groups_widgets.cc @@ -81,7 +81,7 @@ void DictGroupWidget::groupIconActivated( int index ) QString formatList( " (" ); for( int x = 0; x < supImageFormats.size(); ++x ) - formatList += "*." + QString::fromAscii( supImageFormats[ x ] ) + " "; + formatList += "*." + QString::fromLatin1( supImageFormats[ x ] ) + " "; formatList.chop( 1 ); formatList.append( ")" ); diff --git a/hunspell.cc b/hunspell.cc index cdfd3930..149483ee 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -763,7 +763,7 @@ vector< DataFiles > findDataFiles( QString const & path ) QString localizedName; if ( dictBaseId.size() == 2 ) - localizedName = Language::localizedNameForId( LangCoder::code2toInt( dictBaseId.toAscii().data() ) ); + localizedName = Language::localizedNameForId( LangCoder::code2toInt( dictBaseId.toLatin1().data() ) ); QString dictName = dictId; diff --git a/langcoder.cc b/langcoder.cc index e1e30cba..ebc9e521 100644 --- a/langcoder.cc +++ b/langcoder.cc @@ -62,7 +62,7 @@ QString LangCoder::intToCode2( quint32 val ) code[ 0 ] = val & 0xFF; code[ 1 ] = ( val >> 8 ) & 0xFF; - return QString::fromAscii( code, 2 ); + return QString::fromLatin1( code, 2 ); } quint32 LangCoder::code3toInt(const std::string& code3) @@ -130,7 +130,7 @@ quint32 LangCoder::guessId( const QString & lang ) } // still not found - try to match by 2-symbol code - return code2toInt( lstr.left(2).toAscii().data() ); + return code2toInt( lstr.left(2).toLatin1().data() ); } QPair LangCoder::findIdsForName( QString const & name ) diff --git a/preferences.cc b/preferences.cc index 3a8d9822..78054bc5 100644 --- a/preferences.cc +++ b/preferences.cc @@ -59,7 +59,7 @@ Preferences::Preferences( QWidget * parent, Config::Preferences const & p ): continue; // We skip qt's own localizations sortedLocs.insertMulti( - Language::localizedNameForId( LangCoder::code2toInt( lang.toAscii().data() ) ), + Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ), QPair< QIcon, QString >( QIcon( QString( ":/flags/%1.png" ).arg( i->mid( 3, 2 ).toLower() ) ), i->mid( 0, i->size() - 3 ) ) ); diff --git a/website.cc b/website.cc index dd8e13a3..47ab31e0 100644 --- a/website.cc +++ b/website.cc @@ -97,7 +97,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str, for( int x = 1; x <= 16; ++x ) { urlString.replace( QString( "%25GDISO%1%25" ).arg( x ), - QTextCodec::codecForName( QString( "ISO 8859-%1" ).arg( x ).toAscii() )->fromUnicode( inputWord ).toPercentEncoding() ); + QTextCodec::codecForName( QString( "ISO 8859-%1" ).arg( x ).toLatin1() )->fromUnicode( inputWord ).toPercentEncoding() ); if ( x == 10 ) x = 12; // Skip encodings 11..12, they don't exist diff --git a/xdxf.cc b/xdxf.cc index 99386854..f92ec82f 100644 --- a/xdxf.cc +++ b/xdxf.cc @@ -1055,14 +1055,14 @@ vector< sptr< Dictionary::Class > > makeDictionaries( { // Read the xdxf - string str = stream.attributes().value( "lang_from" ).toString().toAscii().data(); + string str = stream.attributes().value( "lang_from" ).toString().toLatin1().data(); if ( str.size() > 3 ) str.resize( 3 ); idxHeader.langFrom = LangCoder::findIdForLanguageCode3( str.c_str() ); - str = stream.attributes().value( "lang_to" ).toString().toAscii().data(); + str = stream.attributes().value( "lang_to" ).toString().toLatin1().data(); if ( str.size() > 3 ) str.resize( 3 );