Skip to content

Commit

Permalink
Part of work for goldendict#212: Make GD source to be ready for Qt5.
Browse files Browse the repository at this point in the history
Replaced deprecated to/fromAscii with to/fromLatin1
  • Loading branch information
Tvangeste committed Feb 3, 2013
1 parent 845f529 commit 9faf843
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion about.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions article_maker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ void ArticleRequest::bodyFinished()
+ "</div>";

head += "<span class=\"gdarticlebody gdlangfrom-";
head += LangCoder::intToCode2( activeDict->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() )
Expand Down
2 changes: 1 addition & 1 deletion article_netmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions articleview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion dsl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions forvo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion fsencoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ QString decode( const char *str )

char separator()
{
return QDir::separator().toAscii();
return QDir::separator().toLatin1();
}

string dirname( string const & str )
Expand Down
2 changes: 1 addition & 1 deletion groups_widgets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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( ")" );
Expand Down
2 changes: 1 addition & 1 deletion hunspell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions langcoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<quint32,quint32> LangCoder::findIdsForName( QString const & name )
Expand Down
2 changes: 1 addition & 1 deletion preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );
Expand Down
2 changes: 1 addition & 1 deletion website.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xdxf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 9faf843

Please sign in to comment.