From f05d42eac36a34e60487fbe207d64d0d9d771708 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Mon, 11 Jul 2016 22:07:57 +0200 Subject: [PATCH] core: Fix build without implicit cast to/from ascii See previous commits for details. --- core/bookmarkmanager.cpp | 4 +-- core/document.cpp | 52 ++++++++++++++++++------------------ core/fileprinter.cpp | 4 +-- core/form.cpp | 2 +- core/generator.cpp | 4 +-- core/page.cpp | 2 +- core/script/kjs_document.cpp | 4 +-- core/script/kjs_util.cpp | 2 +- core/textpage.cpp | 6 ++--- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/core/bookmarkmanager.cpp b/core/bookmarkmanager.cpp index 72cae5536..f05083d0a 100644 --- a/core/bookmarkmanager.cpp +++ b/core/bookmarkmanager.cpp @@ -41,7 +41,7 @@ class OkularBookmarkAction : public KBookmarkAction : KBookmarkAction( bk, owner, parent ) { if ( vp.isValid() ) - setText( QString::number( vp.pageNumber + 1 ) + " - " + text() ); + setText( QString::number( vp.pageNumber + 1 ) + QStringLiteral(" - ") + text() ); setProperty("pageNumber", vp.pageNumber + 1); setProperty("htmlRef", bk.url().fragment(QUrl::FullyDecoded)); } @@ -140,7 +140,7 @@ BookmarkManager::BookmarkManager( DocumentPrivate * document ) d->document = document; - d->file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "okular/bookmarks.xml" ; + d->file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/okular/bookmarks.xml"); d->manager = KBookmarkManager::managerForFile( d->file, QStringLiteral("okular") ); d->manager->setEditorOptions( QGuiApplication::applicationDisplayName(), false ); diff --git a/core/document.cpp b/core/document.cpp index 0c785f2fe..af842e124 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -484,7 +484,7 @@ qulonglong DocumentPrivate::getTotalMemory() QString entry = readStream.readLine(); if ( entry.isNull() ) break; if ( entry.startsWith( QLatin1String("MemTotal:") ) ) - return (cachedValue = (Q_UINT64_C(1024) * entry.section( ' ', -2, -2 ).toULongLong())); + return (cachedValue = (Q_UINT64_C(1024) * entry.section( QLatin1Char ( ' ' ), -2, -2 ).toULongLong())); } #elif defined(Q_OS_FREEBSD) qulonglong physmem; @@ -543,7 +543,7 @@ qulonglong DocumentPrivate::getFreeMemory( qulonglong *freeSwap ) { if ( entry.startsWith( names[i] ) ) { - values[i] = entry.section( ' ', -2, -2 ).toULongLong( &foundValues[i] ); + values[i] = entry.section( QLatin1Char ( ' ' ), -2, -2 ).toULongLong( &foundValues[i] ); } } } @@ -1271,7 +1271,7 @@ void DocumentPrivate::saveDocumentInfo() const ++endIt; while ( backIterator != endIt ) { - QString name = (backIterator == m_viewportIterator) ? "current" : "oldPage"; + QString name = (backIterator == m_viewportIterator) ? QStringLiteral ("current") : QStringLiteral ("oldPage"); QDomElement historyEntry = doc.createElement( name ); historyEntry.setAttribute( QStringLiteral("viewport"), (*backIterator).toString() ); historyNode.appendChild( historyEntry ); @@ -2220,7 +2220,7 @@ QString DocumentPrivate::docDataFileName(const QUrl &url, qint64 document_size) { QString fn = url.fileName(); - fn = QString::number( document_size ) + '.' + fn + ".xml"; + fn = QString::number( document_size ) + QLatin1Char('.') + fn + QStringLiteral(".xml"); QString docdataDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/okular/docdata"); // make sure that the okular/docdata/ directory exists (probably this used to be handled by KStandardDirs) @@ -2255,7 +2255,7 @@ QVector DocumentPrivate::availableGenerators() static QVector result; if (result.isEmpty()) { - result = KPluginLoader::findPlugins("okular/generators"); + result = KPluginLoader::findPlugins( QLatin1String ( "okular/generators" ) ); } return result; } @@ -2489,7 +2489,7 @@ Document::OpenResult Document::openDocument(const QString & docFile, const QUrl AudioPlayer::instance()->d->m_currentDocument = isstdin ? QUrl() : d->m_url; d->m_docSize = document_size; - const QStringList docScripts = d->m_generator->metaData( QStringLiteral("DocumentScripts"), "JavaScript" ).toStringList(); + const QStringList docScripts = d->m_generator->metaData( QStringLiteral("DocumentScripts"), QStringLiteral ( "JavaScript" ) ).toStringList(); if ( !docScripts.isEmpty() ) { d->m_scripter = new Scripter( d ); @@ -3631,7 +3631,7 @@ void Document::searchText( int searchID, const QString & text, bool fromStart, Q else if ( type == GoogleAll || type == GoogleAny ) { QMap< Page *, QVector< QPair > > *pageMatches = new QMap< Page *, QVector > >; - const QStringList words = text.split( ' ', QString::SkipEmptyParts ); + const QStringList words = text.split( QLatin1Char ( ' ' ), QString::SkipEmptyParts ); // search and highlight every word in 'text' on all pages QMetaObject::invokeMethod(this, "doContinueGooglesDocumentSearch", Qt::QueuedConnection, Q_ARG(void *, pagesToNotify), Q_ARG(void *, pageMatches), Q_ARG(int, 0), Q_ARG(int, searchID), Q_ARG(QStringList, words)); @@ -3817,7 +3817,7 @@ QString Document::bookmarkedPageRange() const else if ( startId >= 0 && endId >= 0 ) { if ( !range.isEmpty() ) - range += ','; + range += QLatin1Char ( ',' ); if ( endId - startId > 0 ) range += QStringLiteral( "%1-%2" ).arg( startId + 1 ).arg( endId + 1 ); @@ -3830,7 +3830,7 @@ QString Document::bookmarkedPageRange() const if ( startId >= 0 && endId >= 0 ) { if ( !range.isEmpty() ) - range += ','; + range += QLatin1Char ( ',' ); if ( endId - startId > 0 ) range += QStringLiteral( "%1-%2" ).arg( startId + 1 ).arg( endId + 1 ); @@ -4089,9 +4089,9 @@ void Document::processSourceReference( const SourceReference * ref ) // replacing the placeholders QHash< QChar, QString > map; - map.insert( 'f', absFileName ); - map.insert( 'c', QString::number( ref->column() ) ); - map.insert( 'l', QString::number( ref->row() ) ); + map.insert( QLatin1Char ( 'f' ), absFileName ); + map.insert( QLatin1Char ( 'c' ), QString::number( ref->column() ) ); + map.insert( QLatin1Char ( 'l' ), QString::number( ref->row() ) ); const QString cmd = KMacroExpander::expandMacrosShellQuote( p, map ); if ( cmd.isEmpty() ) return; @@ -4435,7 +4435,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con return OpenError; std::unique_ptr< ArchiveData > archiveData( new ArchiveData() ); - const int dotPos = documentFileName.indexOf( '.' ); + const int dotPos = documentFileName.indexOf( QLatin1Char('.') ); if ( dotPos != -1 ) archiveData->document.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX") + documentFileName.mid(dotPos)); if ( !archiveData->document.open() ) @@ -4834,7 +4834,7 @@ DocumentViewport::DocumentViewport( const QString & xmlDesc ) // decode the string bool ok; int field = 0; - QString token = xmlDesc.section( ';', field, field ); + QString token = xmlDesc.section( QLatin1Char(';'), field, field ); while ( !token.isEmpty() ) { // decode the current token @@ -4847,27 +4847,27 @@ DocumentViewport::DocumentViewport( const QString & xmlDesc ) else if ( token.startsWith( QLatin1String("C1") ) ) { rePos.enabled = true; - rePos.normalizedX = token.section( ':', 1, 1 ).toDouble(); - rePos.normalizedY = token.section( ':', 2, 2 ).toDouble(); + rePos.normalizedX = token.section( QLatin1Char(':'), 1, 1 ).toDouble(); + rePos.normalizedY = token.section( QLatin1Char(':'), 2, 2 ).toDouble(); rePos.pos = Center; } else if ( token.startsWith( QLatin1String("C2") ) ) { rePos.enabled = true; - rePos.normalizedX = token.section( ':', 1, 1 ).toDouble(); - rePos.normalizedY = token.section( ':', 2, 2 ).toDouble(); - if (token.section( ':', 3, 3 ).toInt() == 1) rePos.pos = Center; + rePos.normalizedX = token.section( QLatin1Char(':'), 1, 1 ).toDouble(); + rePos.normalizedY = token.section( QLatin1Char(':'), 2, 2 ).toDouble(); + if (token.section( QLatin1Char(':'), 3, 3 ).toInt() == 1) rePos.pos = Center; else rePos.pos = TopLeft; } else if ( token.startsWith( QLatin1String("AF1") ) ) { autoFit.enabled = true; - autoFit.width = token.section( ':', 1, 1 ) == QLatin1String("T"); - autoFit.height = token.section( ':', 2, 2 ) == QLatin1String("T"); + autoFit.width = token.section( QLatin1Char(':'), 1, 1 ) == QLatin1String("T"); + autoFit.height = token.section( QLatin1Char(':'), 2, 2 ) == QLatin1String("T"); } // proceed tokenizing string field++; - token = xmlDesc.section( ';', field, field ); + token = xmlDesc.section( QLatin1Char(';'), field, field ); } } @@ -4878,12 +4878,12 @@ QString DocumentViewport::toString() const // if has center coordinates, save them on string if ( rePos.enabled ) s += QStringLiteral( ";C2:" ) + QString::number( rePos.normalizedX ) + - ':' + QString::number( rePos.normalizedY ) + - ':' + QString::number( rePos.pos ); + QLatin1Char(':') + QString::number( rePos.normalizedY ) + + QLatin1Char(':') + QString::number( rePos.pos ); // if has autofit enabled, save its state on string if ( autoFit.enabled ) - s += QStringLiteral( ";AF1:" ) + (autoFit.width ? "T" : "F") + - ':' + (autoFit.height ? "T" : "F"); + s += QStringLiteral( ";AF1:" ) + (autoFit.width ? QLatin1Char('T') : QLatin1Char('F')) + + QLatin1Char(':') + (autoFit.height ? QLatin1Char('T') : QLatin1Char('F')); return s; } diff --git a/core/fileprinter.cpp b/core/fileprinter.cpp index 92872930c..04b52893f 100644 --- a/core/fileprinter.cpp +++ b/core/fileprinter.cpp @@ -203,7 +203,7 @@ QString FilePrinter::pageListToPageRange( const QList &pageList ) seqEnd = i; if ( !pageRange.isEmpty() ) { - pageRange.append(","); + pageRange.append(QLatin1Char(',')); } if ( seqStart == seqEnd ) { @@ -666,7 +666,7 @@ QStringList FilePrinter::optionCupsProperties( QPrinter &printer ) if ( dialogOptions[i+1].isEmpty() ) { cupsOptions << QStringLiteral("-o") << dialogOptions[i]; } else { - cupsOptions << QStringLiteral("-o") << dialogOptions[i] + '=' + dialogOptions[i+1]; + cupsOptions << QStringLiteral("-o") << dialogOptions[i] + QLatin1Char('=') + dialogOptions[i+1]; } } diff --git a/core/form.cpp b/core/form.cpp index 498550431..2566ef830 100644 --- a/core/form.cpp +++ b/core/form.cpp @@ -188,7 +188,7 @@ class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate void setValue( const QString& v ) { Q_Q( FormFieldChoice ); - QStringList choices = v.split( ';', QString::SkipEmptyParts ); + QStringList choices = v.split( QLatin1Char (';'), QString::SkipEmptyParts ); QList newchoices; foreach ( const QString& str, choices ) { diff --git a/core/generator.cpp b/core/generator.cpp index 7f630a148..2900871d6 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -360,7 +360,7 @@ bool Generator::exportTo( const QString&, const ExportFormat& ) void Generator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const { - *walletKey = fileName.section('/', -1, -1); + *walletKey = fileName.section( QLatin1Char('/'), -1, -1); *walletName = KWallet::Wallet::NetworkWallet(); *walletFolder = QStringLiteral("KPdf"); } @@ -657,7 +657,7 @@ bool ExportFormat::operator!=( const ExportFormat &other ) const QDebug operator<<( QDebug str, const Okular::PixmapRequest &req ) { QString s = QStringLiteral( "PixmapRequest(#%2, %1, %3x%4, page %6, prio %5)" ) - .arg( QString( req.asynchronous() ? "async" : "sync" ) ) + .arg( QString( req.asynchronous() ? QStringLiteral ( "async" ) : QStringLiteral ( "sync" ) ) ) .arg( (qulonglong)req.observer() ) .arg( req.width() ) .arg( req.height() ) diff --git a/core/page.cpp b/core/page.cpp index 6ce247e59..a1d8f0fa5 100644 --- a/core/page.cpp +++ b/core/page.cpp @@ -633,7 +633,7 @@ void Page::addAnnotation( Annotation * annotation ) // Generate uniqueName: okular-{UUID} if(annotation->uniqueName().isEmpty()) { - QString uniqueName = "okular-" + QUuid::createUuid().toString(); + QString uniqueName = QStringLiteral("okular-") + QUuid::createUuid().toString(); annotation->setUniqueName( uniqueName ); } annotation->d_ptr->m_page = d; diff --git a/core/script/kjs_document.cpp b/core/script/kjs_document.cpp index b16bd12fc..097268ebe 100644 --- a/core/script/kjs_document.cpp +++ b/core/script/kjs_document.cpp @@ -149,8 +149,8 @@ do { \ if ( !data.isEmpty() ) \ { \ const KJSString newval( data ); \ - obj.setProperty( ctx, property, newval ); \ - obj.setProperty( ctx, QString( property ).toLower(), newval ); \ + obj.setProperty( ctx, QStringLiteral(property), newval ); \ + obj.setProperty( ctx, QStringLiteral( property ).toLower(), newval ); \ } \ } while ( 0 ); KEY_GET( DocumentInfo::Title, "Title" ); diff --git a/core/script/kjs_util.cpp b/core/script/kjs_util.cpp index 937f4f510..9ea93ec38 100644 --- a/core/script/kjs_util.cpp +++ b/core/script/kjs_util.cpp @@ -37,7 +37,7 @@ static KJSObject crackURL( KJSContext *context, void *, || url.scheme() != QLatin1String( "http" ) || url.scheme() != QLatin1String( "https" ) ) { - return context->throwException( "Protocol not valid: '" + url.scheme() + '\'' ); + return context->throwException( QStringLiteral("Protocol not valid: '") + url.scheme() + QLatin1Char('\'') ); } KJSObject obj; diff --git a/core/textpage.cpp b/core/textpage.cpp index 07843409d..44dfa14d9 100644 --- a/core/textpage.cpp +++ b/core/textpage.cpp @@ -784,14 +784,14 @@ static int stringLengthAdaptedWithHyphen(const QString &str, const TextList::Con // we have a '-' just followed by a '\n' character // check if the string contains a '-' character // if the '-' is the last entry - if ( str.endsWith( '-' ) ) + if ( str.endsWith( QLatin1Char('-') ) ) { // validity chek of it + 1 if ( ( it + 1 ) != textListEnd ) { // 1. if the next character is '\n' const QString &lookahedStr = (*(it+1))->text(); - if (lookahedStr.startsWith('\n')) + if (lookahedStr.startsWith(QLatin1Char('\n'))) { len -= 1; } @@ -1138,7 +1138,7 @@ void TextPagePrivate::setWordList(const TextList &list) static void removeSpace(TextList *words) { TextList::Iterator it = words->begin(); - const QString str(' '); + const QString str(QLatin1Char(' ')); while ( it != words->end() ) {