generators: Fix build without implicit cast to/from ascii

See previous commit for details.
parent b512e668
......@@ -35,7 +35,7 @@ static void imagesInArchive( const QString &prefix, const KArchiveDirectory* dir
Q_FOREACH ( const QString &entry, dir->entries() ) {
const KArchiveEntry *e = dir->entry( entry );
if ( e->isDirectory() ) {
imagesInArchive( prefix + entry + '/', static_cast<const KArchiveDirectory*>( e ), entries );
imagesInArchive( prefix + entry + QLatin1Char('/'), static_cast<const KArchiveDirectory*>( e ), entries );
} else if ( e->isFile() ) {
entries->append( prefix + entry );
}
......
......@@ -110,7 +110,7 @@ static int natural_order_compare( const QString &leftStr, const QString &rightSt
/* process run of digits */
if ( ca.isDigit() && cb.isDigit() ) {
fractional = (ca == '0' || cb == '0');
fractional = (ca == QLatin1Char('0') || cb == QLatin1Char('0'));
if ( fractional ) {
if ( (result = compare_left( leftStr, ai, rightStr, bi )) != 0 )
......
......@@ -46,7 +46,7 @@ static UnrarFlavour* detectUnrar( const QString &unrarPath, const QString &versi
proc.start( unrarPath, QStringList() << versionCommand );
bool ok = proc.waitForFinished( -1 );
Q_UNUSED( ok )
const QStringList lines = QString::fromLocal8Bit( proc.readAllStandardOutput() ).split( '\n', QString::SkipEmptyParts );
const QStringList lines = QString::fromLocal8Bit( proc.readAllStandardOutput() ).split( QLatin1Char('\n'), QString::SkipEmptyParts );
if ( !lines.isEmpty() )
{
if ( lines.first().startsWith( QLatin1String("UNRAR ") ) )
......@@ -118,7 +118,7 @@ bool Unrar::open( const QString &fileName )
mStdOutData.clear();
mStdErrData.clear();
int ret = startSyncProcess( QStringList() << QStringLiteral("e") << mFileName << mTempDir->path() + '/' );
int ret = startSyncProcess( QStringList() << QStringLiteral("e") << mFileName << mTempDir->path() + QLatin1Char('/') );
bool ok = ret == 0;
return ok;
......@@ -134,13 +134,13 @@ QStringList Unrar::list()
startSyncProcess( QStringList() << QStringLiteral("lb") << mFileName );
const QStringList listFiles = helper->kind->processListing( QString::fromLocal8Bit( mStdOutData ).split( '\n', QString::SkipEmptyParts ) );
const QStringList listFiles = helper->kind->processListing( QString::fromLocal8Bit( mStdOutData ).split( QLatin1Char('\n'), QString::SkipEmptyParts ) );
QStringList newList;
Q_FOREACH ( const QString &f, listFiles ) {
// Extract all the files to mTempDir regardless of their path inside the archive
// This will break if ever an arvhice with two files with the same name in different subfolders
QFileInfo fi( f );
if ( QFile::exists( mTempDir->path() + '/' + fi.fileName() ) ) {
if ( QFile::exists( mTempDir->path() + QLatin1Char('/') + fi.fileName() ) ) {
newList.append( fi.fileName() );
}
}
......@@ -152,7 +152,7 @@ QByteArray Unrar::contentOf( const QString &fileName ) const
if ( !isSuitableVersionAvailable() )
return QByteArray();
QFile file( mTempDir->path() + '/' + fileName );
QFile file( mTempDir->path() + QLatin1Char('/') + fileName );
if ( !file.open( QIODevice::ReadOnly ) )
return QByteArray();
......@@ -164,7 +164,7 @@ QIODevice* Unrar::createDevice( const QString &fileName ) const
if ( !isSuitableVersionAvailable() )
return 0;
std::unique_ptr< QFile> file( new QFile( mTempDir->path() + '/' + fileName ) );
std::unique_ptr< QFile> file( new QFile( mTempDir->path() + QLatin1Char('/') + fileName ) );
if ( !file->open( QIODevice::ReadOnly ) )
return 0;
......
......@@ -1059,7 +1059,7 @@ bool KDjVu::exportAsPostScript( QFile* file, const QList<int>& pageList ) const
pl += QLatin1String( "," );
pl += QString::number( p );
}
pl.prepend( "-page=" );
pl.prepend( QStringLiteral ( "-page=" ) );
// setting the options
static const int optc = 1;
......
......@@ -85,17 +85,17 @@ void Converter::_handle_anchors(const QTextBlock &start, const QString &name) {
// remove ./ or ../
// making it easier to compare, with links
while(!hrefString.isNull() && ( hrefString.at(0) == '.' || hrefString.at(0) == '/') ){
while(!hrefString.isNull() && ( hrefString.at(0) == QLatin1Char('.') || hrefString.at(0) == QLatin1Char('/')) ){
hrefString.remove(0,1);
}
QUrl href(hrefString);
if (href.isValid() && !href.isEmpty()) {
if (href.isRelative()) { // Inside document link
if(!hrefString.indexOf('#'))
if(!hrefString.indexOf(QLatin1Char('#')))
hrefString = name + hrefString;
else if(QFileInfo(hrefString).path() == QLatin1String(".") && curDir != QLatin1String("."))
hrefString = curDir + '/' + hrefString;
hrefString = curDir + QLatin1Char('/') + hrefString;
// QTextCharFormat sometimes splits a link in two
// if there's no white space between words & the first one is an anchor
......@@ -122,7 +122,7 @@ void Converter::_handle_anchors(const QTextBlock &start, const QString &name) {
if (!names.empty()) {
for (QStringList::const_iterator lit = names.constBegin();
lit != names.constEnd(); ++lit) {
mSectionMap.insert(name + '#' + *lit, bit);
mSectionMap.insert(name + QLatin1Char('#') + *lit, bit);
}
}
......
......@@ -20,7 +20,7 @@ namespace {
QString resourceUrl(const QUrl &baseUrl, const QString &u)
{
QUrl newUrl(baseUrl.adjusted(QUrl::RemoveFilename).path() + '/' + u);
QUrl newUrl(baseUrl.adjusted(QUrl::RemoveFilename).path() + QLatin1Char('/') + u);
QString newDir = newUrl.toLocalFile();
newDir.remove(0, 1);
return newDir;
......@@ -56,7 +56,7 @@ struct epub *EpubDocument::getEpub()
void EpubDocument::setCurrentSubDocument(const QString &doc)
{
mCurrentSubDocument = QUrl::fromLocalFile("/" + doc);
mCurrentSubDocument = QUrl::fromLocalFile(QLatin1Char('/') + doc);
}
int EpubDocument::maxContentHeight() const
......
......@@ -283,7 +283,7 @@ bool Converter::convertTitleInfo( const QDomElement &element )
if ( !convertTextNode( child, keywords ) )
return false;
mTitleInfo->mKeywords = keywords.split( ' ', QString::SkipEmptyParts );
mTitleInfo->mKeywords = keywords.split( QLatin1Char(' '), QString::SkipEmptyParts );
} else if ( child.tagName() == QLatin1String( "date" ) ) {
if ( !convertDate( child, mTitleInfo->mDate ) )
return false;
......@@ -606,7 +606,7 @@ bool Converter::convertImage( const QDomElement &element )
{
QString href = element.attributeNS( QStringLiteral("http://www.w3.org/1999/xlink"), QStringLiteral("href") );
if ( href.startsWith( '#' ) )
if ( href.startsWith( QLatin1Char('#') ) )
href = href.mid( 1 );
const QImage img = qVariantValue<QImage>( mTextDocument->resource( QTextDocument::ImageResource, QUrl( href ) ) );
......@@ -758,7 +758,7 @@ bool Converter::convertLink( const QDomElement &element )
if ( type == QLatin1String("note") )
mCursor->insertText( QStringLiteral("]") );
if ( href.startsWith( '#' ) ) { // local link
if ( href.startsWith( QLatin1Char('#') ) ) { // local link
mLocalLinks.insert( href.mid( 1 ), QPair<int, int>( startPosition, endPosition ) );
} else {
// external link
......
......@@ -37,12 +37,12 @@ class KIMGIOTest
void KIMGIOTest::initTestCase()
{
// Make sure we find the okularGenerator_kimgio that we build just now and not the system one
QFileInfo lib( GENERATOR_PATH );
QFileInfo lib( QStringLiteral(GENERATOR_PATH) );
QVERIFY2( lib.exists(), GENERATOR_PATH );
QStringList libPaths = QCoreApplication::libraryPaths();
libPaths.prepend( lib.absolutePath() );
QCoreApplication::setLibraryPaths( libPaths );
QVERIFY( !KPluginLoader::findPlugin( "okularGenerator_kimgio" ).isEmpty() );
QVERIFY( !KPluginLoader::findPlugin( QStringLiteral("okularGenerator_kimgio") ).isEmpty() );
// make sure we didn't break the search path for image formats:
auto availableFormats = QImageReader::supportedImageFormats();
QVERIFY2(availableFormats.contains( "jpeg" ), availableFormats.join( ", " ).data() );
......@@ -80,7 +80,7 @@ void KIMGIOTest::testExifOrientation()
QFETCH( QString, imgPath );
QMimeDatabase db;
Okular::SettingsCore::instance( "kimgiotest" );
Okular::SettingsCore::instance( QStringLiteral("kimgiotest") );
Okular::Document *m_document = new Okular::Document( 0 );
const QMimeType mime = db.mimeTypeForFile( imgPath );
......
......@@ -82,7 +82,7 @@ QTextDocument* Converter::convert( const QString &fileName )
if (!format.anchorNames().isEmpty()) {
// link targets
Q_FOREACH(const QString& name, format.anchorNames())
targets['#'+name]=it;
targets[QLatin1Char('#')+name]=it;
}
}
......
......@@ -17,7 +17,7 @@
OKULAR_EXPORT_PLUGIN(MobiGenerator, "libokularGenerator_mobi.json")
MobiGenerator::MobiGenerator( QObject *parent, const QVariantList &args )
: Okular::TextDocumentGenerator( new Mobi::Converter, "okular_mobi_generator_settings", parent, args )
: Okular::TextDocumentGenerator( new Mobi::Converter, QStringLiteral("okular_mobi_generator_settings"), parent, args )
{
}
......@@ -25,7 +25,7 @@ void MobiGenerator::addPages( KConfigDialog* dlg )
{
Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget();
dlg->addPage( widget, generalSettings(), i18n("Mobipocket"), "application-x-mobipocket-ebook", i18n("Mobipocket Backend Configuration") );
dlg->addPage( widget, generalSettings(), i18n("Mobipocket"), QStringLiteral("application-x-mobipocket-ebook"), i18n("Mobipocket Backend Configuration") );
}
#include "generator_mobi.moc"
......@@ -25,7 +25,7 @@ MobiDocument::MobiDocument(const QString &fileName) : QTextDocument()
if (doc->isValid()) {
QString text=doc->text();
QString header=text.left(1024);
if (header.contains("<html>") || header.contains("<HTML>")) {
if (header.contains(QStringLiteral("<html>")) || header.contains(QStringLiteral("<HTML>"))) {
// HACK BEGIN Get the links without CSS to be blue
// Remove if Qt ever gets fixed and the code in textdocumentgenerator.cpp works
const QPalette orig = qApp->palette();
......@@ -53,7 +53,7 @@ MobiDocument::~MobiDocument()
QVariant MobiDocument::loadResource(int type, const QUrl &name)
{
if (type!=QTextDocument::ImageResource || name.scheme()!=QString("pdbrec")) return QVariant();
if (type!=QTextDocument::ImageResource || name.scheme()!=QString(QStringLiteral("pdbrec"))) return QVariant();
bool ok;
quint16 recnum=name.path().mid(1).toUShort(&ok);
if (!ok || recnum>=doc->imageCount()) return QVariant();
......@@ -69,8 +69,8 @@ QVariant MobiDocument::loadResource(int type, const QUrl &name)
int outsideTag(const QString& data, int pos)
{
for (int i=pos-1;i>=0;i--) {
if (data[i]=='>') return pos;
if (data[i]=='<') return i;
if (data[i]==QLatin1Char('>')) return pos;
if (data[i]==QLatin1Char('<')) return i;
}
return pos;
}
......@@ -79,7 +79,7 @@ QString MobiDocument::fixMobiMarkup(const QString& data)
{
QString ret=data;
QMap<int,QString> anchorPositions;
static QRegExp anchors("<a(?: href=\"[^\"]*\"){0,1}[\\s]+filepos=['\"]{0,1}([\\d]+)[\"']{0,1}", Qt::CaseInsensitive);
static QRegExp anchors(QStringLiteral("<a(?: href=\"[^\"]*\"){0,1}[\\s]+filepos=['\"]{0,1}([\\d]+)[\"']{0,1}"), Qt::CaseInsensitive);
int pos=0;
// find all link destinations
......@@ -97,20 +97,20 @@ QString MobiDocument::fixMobiMarkup(const QString& data)
// link pointing outside the document, ignore
if ( (it.key()+offset) >= ret.size()) continue;
int fixedpos=outsideTag(ret, it.key()+offset);
ret.insert(fixedpos,QString("<a name=\"")+it.value()+QString("\">&nbsp;</a>"));
ret.insert(fixedpos,QStringLiteral("<a name=\"")+it.value()+QStringLiteral("\">&nbsp;</a>"));
// inserting anchor shifts all offsets after the anchor
offset+=21+it.value().size();
}
// replace links referencing filepos with normal internal links
ret.replace(anchors,"<a href=\"#\\1\"");
ret.replace(anchors, QStringLiteral("<a href=\"#\\1\""));
// Mobipocket uses strange variang of IMG tags: <img recindex="3232"> where recindex is number of
// record containing image
static QRegExp imgs("<img.*recindex=\"([\\d]*)\".*>", Qt::CaseInsensitive);
static QRegExp imgs(QStringLiteral("<img.*recindex=\"([\\d]*)\".*>"), Qt::CaseInsensitive);
imgs.setMinimal(true);
ret.replace(imgs,"<img src=\"pdbrec:/\\1\">");
ret.replace("<mbp:pagebreak/>","<p style=\"page-break-after:always\"></p>");
ret.replace(imgs, QStringLiteral("<img src=\"pdbrec:/\\1\">"));
ret.replace(QStringLiteral("<mbp:pagebreak/>"), QStringLiteral("<p style=\"page-break-after:always\"></p>"));
return ret;
}
......@@ -253,7 +253,7 @@ bool Converter::convertHeader( QTextCursor *cursor, const QDomElement &element )
child = child.nextSibling();
}
emit addTitle( element.attribute( QStringLiteral("outline-level"), 0 ).toInt(), element.text(), cursor->block() );
emit addTitle( element.attribute( QStringLiteral("outline-level"), QStringLiteral("0") ).toInt(), element.text(), cursor->block() );
return true;
}
......@@ -284,7 +284,7 @@ bool Converter::convertParagraph( QTextCursor *cursor, const QDomElement &elemen
mCursor->insertText( QStringLiteral(" ") );
} else if ( childElement.tagName() == QLatin1String( "s" ) ) {
QString spaces;
spaces.fill( ' ', childElement.attribute( QStringLiteral("c") ).toInt() );
spaces.fill( QLatin1Char(' '), childElement.attribute( QStringLiteral("c") ).toInt() );
mCursor->insertText( spaces );
} else if ( childElement.tagName() == QLatin1String( "frame" ) ) {
if ( !convertFrame( childElement ) )
......
......@@ -32,7 +32,7 @@ void KOOOGenerator::addPages( KConfigDialog* dlg )
void KOOOGenerator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const
{
*walletKey = fileName + "/opendocument";
*walletKey = fileName + QStringLiteral("/opendocument");
*walletName = KWallet::Wallet::LocalWallet();
*walletFolder = KWallet::Wallet::PasswordFolder();
}
......
......@@ -132,9 +132,9 @@ bool QUnpluck::open( const QString &fileName )
bool status = true;
mInfo.insert( QStringLiteral("name"), plkr_GetName( mDocument ) );
mInfo.insert( QStringLiteral("title"), plkr_GetTitle( mDocument ) );
mInfo.insert( QStringLiteral("author"), plkr_GetAuthor( mDocument ) );
mInfo.insert( QStringLiteral("name"), QString::fromLocal8Bit(plkr_GetName( mDocument ) ));
mInfo.insert( QStringLiteral("title"), QString::fromLocal8Bit(plkr_GetTitle( mDocument ) ));
mInfo.insert( QStringLiteral("author"), QString::fromLocal8Bit(plkr_GetAuthor( mDocument ) ));
mInfo.insert( QStringLiteral("time"), QDateTime::fromTime_t( plkr_GetPublicationTime( mDocument ) ).toString() );
AddRecord( plkr_GetHomeRecordID( mDocument ) );
......@@ -380,7 +380,7 @@ void QUnpluck::ParseText
end = ptr + text_len;
while (ptr < end) {
if (ptr[0]) {
context->cursor->insertText( QString( (char*)ptr ) );
context->cursor->insertText( QString::fromLocal8Bit( (char*)ptr ) );
ptr += strlen ((char*)ptr);
}
else {
......@@ -974,7 +974,7 @@ bool QUnpluck::TranscribeTextRecord
QTextBlockFormat oldBlockFormat = context->cursor->blockFormat();
QTextBlockFormat blockFormat;
blockFormat.setProperty( QTextFormat::BlockTrailingHorizontalRulerWidth, "100%");
blockFormat.setProperty( QTextFormat::BlockTrailingHorizontalRulerWidth, QStringLiteral("100%"));
context->cursor->insertBlock( blockFormat );
context->cursor->insertBlock( oldBlockFormat );
context->cursor->setCharFormat( charFormat );
......
......@@ -1263,7 +1263,7 @@ bool PDFGenerator::setDocumentRenderHints()
const Poppler::Document::RenderHints oldhints = pdfdoc->renderHints();
#define SET_HINT(hintname, hintdefvalue, hintflag) \
{ \
bool newhint = documentMetaData(hintname, hintdefvalue).toBool(); \
bool newhint = documentMetaData(QStringLiteral(hintname), hintdefvalue).toBool(); \
if (newhint != oldhints.testFlag(hintflag)) \
{ \
pdfdoc->setRenderHint(hintflag, newhint); \
......@@ -1379,7 +1379,7 @@ Okular::TextPage * PDFGenerator::abstractTextPage(const QList<Poppler::TextBox*>
if (addChar)
{
QRectF charBBox = word->charBoundingBox(textBoxChar);
append(ktp, (j==qstringCharCount-1 && !next) ? (s + "\n") : s,
append(ktp, (j==qstringCharCount-1 && !next) ? (s + QLatin1Char('\n')) : s,
charBBox.left()/width,
charBBox.bottom()/height,
charBBox.right()/width,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment