core: Fix build without implicit cast to/from ascii

See previous commits for details.
frameworks
Martin T. H. Sandsmark 10 years ago
parent ba4b9eb1a6
commit f05d42eac3
  1. 4
      core/bookmarkmanager.cpp
  2. 52
      core/document.cpp
  3. 4
      core/fileprinter.cpp
  4. 2
      core/form.cpp
  5. 4
      core/generator.cpp
  6. 2
      core/page.cpp
  7. 4
      core/script/kjs_document.cpp
  8. 2
      core/script/kjs_util.cpp
  9. 6
      core/textpage.cpp

@ -41,7 +41,7 @@ class OkularBookmarkAction : public KBookmarkAction
: KBookmarkAction( bk, owner, parent ) : KBookmarkAction( bk, owner, parent )
{ {
if ( vp.isValid() ) if ( vp.isValid() )
setText( QString::number( vp.pageNumber + 1 ) + " - " + text() ); setText( QString::number( vp.pageNumber + 1 ) + QStringLiteral(" - ") + text() );
setProperty("pageNumber", vp.pageNumber + 1); setProperty("pageNumber", vp.pageNumber + 1);
setProperty("htmlRef", bk.url().fragment(QUrl::FullyDecoded)); setProperty("htmlRef", bk.url().fragment(QUrl::FullyDecoded));
} }
@ -140,7 +140,7 @@ BookmarkManager::BookmarkManager( DocumentPrivate * document )
d->document = 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 = KBookmarkManager::managerForFile( d->file, QStringLiteral("okular") );
d->manager->setEditorOptions( QGuiApplication::applicationDisplayName(), false ); d->manager->setEditorOptions( QGuiApplication::applicationDisplayName(), false );

@ -484,7 +484,7 @@ qulonglong DocumentPrivate::getTotalMemory()
QString entry = readStream.readLine(); QString entry = readStream.readLine();
if ( entry.isNull() ) break; if ( entry.isNull() ) break;
if ( entry.startsWith( QLatin1String("MemTotal:") ) ) 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) #elif defined(Q_OS_FREEBSD)
qulonglong physmem; qulonglong physmem;
@ -543,7 +543,7 @@ qulonglong DocumentPrivate::getFreeMemory( qulonglong *freeSwap )
{ {
if ( entry.startsWith( names[i] ) ) 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; ++endIt;
while ( backIterator != 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 ); QDomElement historyEntry = doc.createElement( name );
historyEntry.setAttribute( QStringLiteral("viewport"), (*backIterator).toString() ); historyEntry.setAttribute( QStringLiteral("viewport"), (*backIterator).toString() );
historyNode.appendChild( historyEntry ); historyNode.appendChild( historyEntry );
@ -2220,7 +2220,7 @@ QString DocumentPrivate::docDataFileName(const QUrl &url, qint64 document_size)
{ {
QString fn = url.fileName(); 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) QString docdataDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QStringLiteral("/okular/docdata"); + QStringLiteral("/okular/docdata");
// make sure that the okular/docdata/ directory exists (probably this used to be handled by KStandardDirs) // make sure that the okular/docdata/ directory exists (probably this used to be handled by KStandardDirs)
@ -2255,7 +2255,7 @@ QVector<KPluginMetaData> DocumentPrivate::availableGenerators()
static QVector<KPluginMetaData> result; static QVector<KPluginMetaData> result;
if (result.isEmpty()) if (result.isEmpty())
{ {
result = KPluginLoader::findPlugins("okular/generators"); result = KPluginLoader::findPlugins( QLatin1String ( "okular/generators" ) );
} }
return result; 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; AudioPlayer::instance()->d->m_currentDocument = isstdin ? QUrl() : d->m_url;
d->m_docSize = document_size; 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() ) if ( !docScripts.isEmpty() )
{ {
d->m_scripter = new Scripter( d ); 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 ) else if ( type == GoogleAll || type == GoogleAny )
{ {
QMap< Page *, QVector< QPair<RegularAreaRect *, QColor> > > *pageMatches = new QMap< Page *, QVector<QPair<RegularAreaRect *, QColor> > >; QMap< Page *, QVector< QPair<RegularAreaRect *, QColor> > > *pageMatches = new QMap< Page *, QVector<QPair<RegularAreaRect *, QColor> > >;
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 // 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)); 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 ) else if ( startId >= 0 && endId >= 0 )
{ {
if ( !range.isEmpty() ) if ( !range.isEmpty() )
range += ','; range += QLatin1Char ( ',' );
if ( endId - startId > 0 ) if ( endId - startId > 0 )
range += QStringLiteral( "%1-%2" ).arg( startId + 1 ).arg( endId + 1 ); range += QStringLiteral( "%1-%2" ).arg( startId + 1 ).arg( endId + 1 );
@ -3830,7 +3830,7 @@ QString Document::bookmarkedPageRange() const
if ( startId >= 0 && endId >= 0 ) if ( startId >= 0 && endId >= 0 )
{ {
if ( !range.isEmpty() ) if ( !range.isEmpty() )
range += ','; range += QLatin1Char ( ',' );
if ( endId - startId > 0 ) if ( endId - startId > 0 )
range += QStringLiteral( "%1-%2" ).arg( startId + 1 ).arg( endId + 1 ); range += QStringLiteral( "%1-%2" ).arg( startId + 1 ).arg( endId + 1 );
@ -4089,9 +4089,9 @@ void Document::processSourceReference( const SourceReference * ref )
// replacing the placeholders // replacing the placeholders
QHash< QChar, QString > map; QHash< QChar, QString > map;
map.insert( 'f', absFileName ); map.insert( QLatin1Char ( 'f' ), absFileName );
map.insert( 'c', QString::number( ref->column() ) ); map.insert( QLatin1Char ( 'c' ), QString::number( ref->column() ) );
map.insert( 'l', QString::number( ref->row() ) ); map.insert( QLatin1Char ( 'l' ), QString::number( ref->row() ) );
const QString cmd = KMacroExpander::expandMacrosShellQuote( p, map ); const QString cmd = KMacroExpander::expandMacrosShellQuote( p, map );
if ( cmd.isEmpty() ) if ( cmd.isEmpty() )
return; return;
@ -4435,7 +4435,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con
return OpenError; return OpenError;
std::unique_ptr< ArchiveData > archiveData( new ArchiveData() ); std::unique_ptr< ArchiveData > archiveData( new ArchiveData() );
const int dotPos = documentFileName.indexOf( '.' ); const int dotPos = documentFileName.indexOf( QLatin1Char('.') );
if ( dotPos != -1 ) if ( dotPos != -1 )
archiveData->document.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX") + documentFileName.mid(dotPos)); archiveData->document.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX") + documentFileName.mid(dotPos));
if ( !archiveData->document.open() ) if ( !archiveData->document.open() )
@ -4834,7 +4834,7 @@ DocumentViewport::DocumentViewport( const QString & xmlDesc )
// decode the string // decode the string
bool ok; bool ok;
int field = 0; int field = 0;
QString token = xmlDesc.section( ';', field, field ); QString token = xmlDesc.section( QLatin1Char(';'), field, field );
while ( !token.isEmpty() ) while ( !token.isEmpty() )
{ {
// decode the current token // decode the current token
@ -4847,27 +4847,27 @@ DocumentViewport::DocumentViewport( const QString & xmlDesc )
else if ( token.startsWith( QLatin1String("C1") ) ) else if ( token.startsWith( QLatin1String("C1") ) )
{ {
rePos.enabled = true; rePos.enabled = true;
rePos.normalizedX = token.section( ':', 1, 1 ).toDouble(); rePos.normalizedX = token.section( QLatin1Char(':'), 1, 1 ).toDouble();
rePos.normalizedY = token.section( ':', 2, 2 ).toDouble(); rePos.normalizedY = token.section( QLatin1Char(':'), 2, 2 ).toDouble();
rePos.pos = Center; rePos.pos = Center;
} }
else if ( token.startsWith( QLatin1String("C2") ) ) else if ( token.startsWith( QLatin1String("C2") ) )
{ {
rePos.enabled = true; rePos.enabled = true;
rePos.normalizedX = token.section( ':', 1, 1 ).toDouble(); rePos.normalizedX = token.section( QLatin1Char(':'), 1, 1 ).toDouble();
rePos.normalizedY = token.section( ':', 2, 2 ).toDouble(); rePos.normalizedY = token.section( QLatin1Char(':'), 2, 2 ).toDouble();
if (token.section( ':', 3, 3 ).toInt() == 1) rePos.pos = Center; if (token.section( QLatin1Char(':'), 3, 3 ).toInt() == 1) rePos.pos = Center;
else rePos.pos = TopLeft; else rePos.pos = TopLeft;
} }
else if ( token.startsWith( QLatin1String("AF1") ) ) else if ( token.startsWith( QLatin1String("AF1") ) )
{ {
autoFit.enabled = true; autoFit.enabled = true;
autoFit.width = token.section( ':', 1, 1 ) == QLatin1String("T"); autoFit.width = token.section( QLatin1Char(':'), 1, 1 ) == QLatin1String("T");
autoFit.height = token.section( ':', 2, 2 ) == QLatin1String("T"); autoFit.height = token.section( QLatin1Char(':'), 2, 2 ) == QLatin1String("T");
} }
// proceed tokenizing string // proceed tokenizing string
field++; 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 has center coordinates, save them on string
if ( rePos.enabled ) if ( rePos.enabled )
s += QStringLiteral( ";C2:" ) + QString::number( rePos.normalizedX ) + s += QStringLiteral( ";C2:" ) + QString::number( rePos.normalizedX ) +
':' + QString::number( rePos.normalizedY ) + QLatin1Char(':') + QString::number( rePos.normalizedY ) +
':' + QString::number( rePos.pos ); QLatin1Char(':') + QString::number( rePos.pos );
// if has autofit enabled, save its state on string // if has autofit enabled, save its state on string
if ( autoFit.enabled ) if ( autoFit.enabled )
s += QStringLiteral( ";AF1:" ) + (autoFit.width ? "T" : "F") + s += QStringLiteral( ";AF1:" ) + (autoFit.width ? QLatin1Char('T') : QLatin1Char('F')) +
':' + (autoFit.height ? "T" : "F"); QLatin1Char(':') + (autoFit.height ? QLatin1Char('T') : QLatin1Char('F'));
return s; return s;
} }

@ -203,7 +203,7 @@ QString FilePrinter::pageListToPageRange( const QList<int> &pageList )
seqEnd = i; seqEnd = i;
if ( !pageRange.isEmpty() ) { if ( !pageRange.isEmpty() ) {
pageRange.append(","); pageRange.append(QLatin1Char(','));
} }
if ( seqStart == seqEnd ) { if ( seqStart == seqEnd ) {
@ -666,7 +666,7 @@ QStringList FilePrinter::optionCupsProperties( QPrinter &printer )
if ( dialogOptions[i+1].isEmpty() ) { if ( dialogOptions[i+1].isEmpty() ) {
cupsOptions << QStringLiteral("-o") << dialogOptions[i]; cupsOptions << QStringLiteral("-o") << dialogOptions[i];
} else { } else {
cupsOptions << QStringLiteral("-o") << dialogOptions[i] + '=' + dialogOptions[i+1]; cupsOptions << QStringLiteral("-o") << dialogOptions[i] + QLatin1Char('=') + dialogOptions[i+1];
} }
} }

@ -188,7 +188,7 @@ class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate
void setValue( const QString& v ) void setValue( const QString& v )
{ {
Q_Q( FormFieldChoice ); Q_Q( FormFieldChoice );
QStringList choices = v.split( ';', QString::SkipEmptyParts ); QStringList choices = v.split( QLatin1Char (';'), QString::SkipEmptyParts );
QList<int> newchoices; QList<int> newchoices;
foreach ( const QString& str, choices ) foreach ( const QString& str, choices )
{ {

@ -360,7 +360,7 @@ bool Generator::exportTo( const QString&, const ExportFormat& )
void Generator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const 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(); *walletName = KWallet::Wallet::NetworkWallet();
*walletFolder = QStringLiteral("KPdf"); *walletFolder = QStringLiteral("KPdf");
} }
@ -657,7 +657,7 @@ bool ExportFormat::operator!=( const ExportFormat &other ) const
QDebug operator<<( QDebug str, const Okular::PixmapRequest &req ) QDebug operator<<( QDebug str, const Okular::PixmapRequest &req )
{ {
QString s = QStringLiteral( "PixmapRequest(#%2, %1, %3x%4, page %6, prio %5)" ) 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( (qulonglong)req.observer() )
.arg( req.width() ) .arg( req.width() )
.arg( req.height() ) .arg( req.height() )

@ -633,7 +633,7 @@ void Page::addAnnotation( Annotation * annotation )
// Generate uniqueName: okular-{UUID} // Generate uniqueName: okular-{UUID}
if(annotation->uniqueName().isEmpty()) if(annotation->uniqueName().isEmpty())
{ {
QString uniqueName = "okular-" + QUuid::createUuid().toString(); QString uniqueName = QStringLiteral("okular-") + QUuid::createUuid().toString();
annotation->setUniqueName( uniqueName ); annotation->setUniqueName( uniqueName );
} }
annotation->d_ptr->m_page = d; annotation->d_ptr->m_page = d;

@ -149,8 +149,8 @@ do { \
if ( !data.isEmpty() ) \ if ( !data.isEmpty() ) \
{ \ { \
const KJSString newval( data ); \ const KJSString newval( data ); \
obj.setProperty( ctx, property, newval ); \ obj.setProperty( ctx, QStringLiteral(property), newval ); \
obj.setProperty( ctx, QString( property ).toLower(), newval ); \ obj.setProperty( ctx, QStringLiteral( property ).toLower(), newval ); \
} \ } \
} while ( 0 ); } while ( 0 );
KEY_GET( DocumentInfo::Title, "Title" ); KEY_GET( DocumentInfo::Title, "Title" );

@ -37,7 +37,7 @@ static KJSObject crackURL( KJSContext *context, void *,
|| url.scheme() != QLatin1String( "http" ) || url.scheme() != QLatin1String( "http" )
|| url.scheme() != QLatin1String( "https" ) ) || url.scheme() != QLatin1String( "https" ) )
{ {
return context->throwException( "Protocol not valid: '" + url.scheme() + '\'' ); return context->throwException( QStringLiteral("Protocol not valid: '") + url.scheme() + QLatin1Char('\'') );
} }
KJSObject obj; KJSObject obj;

@ -784,14 +784,14 @@ static int stringLengthAdaptedWithHyphen(const QString &str, const TextList::Con
// we have a '-' just followed by a '\n' character // we have a '-' just followed by a '\n' character
// check if the string contains a '-' character // check if the string contains a '-' character
// if the '-' is the last entry // if the '-' is the last entry
if ( str.endsWith( '-' ) ) if ( str.endsWith( QLatin1Char('-') ) )
{ {
// validity chek of it + 1 // validity chek of it + 1
if ( ( it + 1 ) != textListEnd ) if ( ( it + 1 ) != textListEnd )
{ {
// 1. if the next character is '\n' // 1. if the next character is '\n'
const QString &lookahedStr = (*(it+1))->text(); const QString &lookahedStr = (*(it+1))->text();
if (lookahedStr.startsWith('\n')) if (lookahedStr.startsWith(QLatin1Char('\n')))
{ {
len -= 1; len -= 1;
} }
@ -1138,7 +1138,7 @@ void TextPagePrivate::setWordList(const TextList &list)
static void removeSpace(TextList *words) static void removeSpace(TextList *words)
{ {
TextList::Iterator it = words->begin(); TextList::Iterator it = words->begin();
const QString str(' '); const QString str(QLatin1Char(' '));
while ( it != words->end() ) while ( it != words->end() )
{ {

Loading…
Cancel
Save