Commit 3720833b authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Enable clazy qstring-allocations

parent 07a1f616
Pipeline #15457 passed with stage
in 10 minutes and 36 seconds
......@@ -48,7 +48,7 @@ build_clazy_clang_tidy:
script:
- srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && cat compile_commands.aux.json | jq '[.[] | select(.file | contains("/synctex/")| not)]' > compile_commands.json
- CLAZY_IGNORE_DIRS="settings_core.[cpp|h]|settings.[cpp.h]|pdfsettings.h|gssettings.h" CLAZY_CHECKS="level0,level1,level2,no-ctor-missing-parent-argument,no-qstring-allocations,isempty-vs-count,qhash-with-char-pointer-key,raw-environment-function,qproperty-type-mismatch" ninja
- CLAZY_IGNORE_DIRS="settings_core.[cpp|h]|settings.[cpp.h]|pdfsettings.h|gssettings.h" CLAZY_CHECKS="level0,level1,level2,no-ctor-missing-parent-argument,isempty-vs-count,qhash-with-char-pointer-key,raw-environment-function,qproperty-type-mismatch" ninja
# Fix the poppler header, remove when debian:unstable ships poppler 0.82 or later
- sed -i "N;N;N;N; s#class MediaRendition\;\nclass MovieAnnotation\;\nclass ScreenAnnotation;#class MediaRendition\;#g" /usr/include/poppler/qt5/poppler-link.h
- "run-clang-tidy -header-filter='.*/okular/.*' -checks='-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-loop-convert,modernize-use-nullptr,-bugprone-macro-parentheses,-bugprone-narrowing-conversions,-bugprone-branch-clone,-bugprone-incorrect-roundings' -config=\"{WarningsAsErrors: '*'}\""
......@@ -161,7 +161,7 @@ void AnnotationTest::testTypewriter()
m_document->addPageAnnotation( 0, annot );
QDomNode annotNode = annot->getAnnotationPropertiesDomNode();
QDomNodeList annotNodeList = annotNode.toElement().elementsByTagName("base");
QDomNodeList annotNodeList = annotNode.toElement().elementsByTagName(QStringLiteral("base"));
QDomElement annotEl = annotNodeList.item(0).toElement();
QCOMPARE( annotEl.attribute( QStringLiteral("color") ), QStringLiteral("#00ffffff") );
QCOMPARE( annotEl.attribute( QStringLiteral("flags") ), QStringLiteral("4") );
......
......@@ -92,7 +92,7 @@ void DocumentTest::testDocdataMigration()
// Check that the annotation from file1-docdata.xml was loaded
QCOMPARE( m_document->page( 0 )->annotations().size(), 1 );
QCOMPARE( m_document->page( 0 )->annotations().first()->uniqueName(), QString("testannot") );
QCOMPARE( m_document->page( 0 )->annotations().first()->uniqueName(), QStringLiteral("testannot") );
// Check that we detect that it must be migrated
QVERIFY( m_document->isDocdataMigrationNeeded() );
......@@ -102,7 +102,7 @@ void DocumentTest::testDocdataMigration()
// (because we have not migrated)
QCOMPARE( m_document->openDocument( testFilePath, testFileUrl, mime ), Okular::Document::OpenSuccess );
QCOMPARE( m_document->page( 0 )->annotations().size(), 1 );
QCOMPARE( m_document->page( 0 )->annotations().first()->uniqueName(), QString("testannot") );
QCOMPARE( m_document->page( 0 )->annotations().first()->uniqueName(), QStringLiteral("testannot") );
QVERIFY( m_document->isDocdataMigrationNeeded() );
// Do the migration
......
......@@ -144,7 +144,7 @@ void FormatTest::testSpecialFormat_data()
void FormatTest::testFocusAction()
{
QFETCH( QString, result );
Okular::FormFieldText *fft = reinterpret_cast< Okular::FormFieldText * >( m_fields[ "Validate/Focus" ] );
Okular::FormFieldText *fft = reinterpret_cast< Okular::FormFieldText * >( m_fields[ QStringLiteral("Validate/Focus") ] );
m_document->processFocusAction( fft->additionalAction( Okular::Annotation::FocusIn ), fft );
QCOMPARE( fft->text(), result );
......@@ -161,7 +161,7 @@ void FormatTest::testValidateAction()
{
QFETCH( QString, text );
QFETCH( QString, result );
Okular::FormFieldText *fft = reinterpret_cast< Okular::FormFieldText * >( m_fields[ "Validate/Focus" ] );
Okular::FormFieldText *fft = reinterpret_cast< Okular::FormFieldText * >( m_fields[ QStringLiteral("Validate/Focus") ] );
fft->setText( text );
bool ok = false;
......
......@@ -124,8 +124,8 @@ void KJSFunctionsTest::testNthFieldName()
Okular::ScriptAction *action = new Okular::ScriptAction( Okular::JavaScript, QStringLiteral( "var field = Doc.getField( Doc.getNthFieldName(%1) );\
field.display = display.visible;" ).arg( i ) );
m_document->processAction( action );
QVERIFY( m_fields[QString( "0.%1" ).arg(i)]->isVisible() );
m_fields[QString( "0.%1" ).arg(i)]->setVisible( false );
QVERIFY( m_fields[QStringLiteral( "0.%1" ).arg(i)]->isVisible() );
m_fields[QStringLiteral( "0.%1" ).arg(i)]->setVisible( false );
delete action;
}
}
......@@ -136,40 +136,40 @@ void KJSFunctionsTest::testDisplay()
QStringLiteral( "field = Doc.getField(\"0.0\");field.display=display.hidden;\
field = Doc.getField(\"0.10\");field.display=display.visible;" ) );
m_document->processAction( action );
QVERIFY( !m_fields["0.0"]->isVisible() );
QVERIFY( !m_fields["0.0"]->isPrintable() );
QVERIFY( m_fields["0.10"]->isVisible() );
QVERIFY( m_fields["0.10"]->isPrintable() );
QVERIFY( !m_fields[QStringLiteral("0.0")]->isVisible() );
QVERIFY( !m_fields[QStringLiteral("0.0")]->isPrintable() );
QVERIFY( m_fields[QStringLiteral("0.10")]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.10")]->isPrintable() );
delete action;
action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "field = Doc.getField(\"0.10\");field.display=display.noView;\
field = Doc.getField(\"0.15\");field.display=display.noPrint;" ) );
m_document->processAction( action );
QVERIFY( !m_fields["0.10"]->isVisible() );
QVERIFY( m_fields["0.10"]->isPrintable() );
QVERIFY( m_fields["0.15"]->isVisible() );
QVERIFY( !m_fields["0.15"]->isPrintable() );
QVERIFY( !m_fields[QStringLiteral("0.10")]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.10")]->isPrintable() );
QVERIFY( m_fields[QStringLiteral("0.15")]->isVisible() );
QVERIFY( !m_fields[QStringLiteral("0.15")]->isPrintable() );
delete action;
action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "field = Doc.getField(\"0.15\");field.display=display.hidden;\
field = Doc.getField(\"0.20\");field.display=display.visible;" ) );
m_document->processAction( action );
QVERIFY( !m_fields["0.15"]->isVisible() );
QVERIFY( !m_fields["0.15"]->isPrintable() );
QVERIFY( m_fields["0.20"]->isVisible() );
QVERIFY( m_fields["0.20"]->isPrintable() );
QVERIFY( !m_fields[QStringLiteral("0.15")]->isVisible() );
QVERIFY( !m_fields[QStringLiteral("0.15")]->isPrintable() );
QVERIFY( m_fields[QStringLiteral("0.20")]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.20")]->isPrintable() );
delete action;
action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "field = Doc.getField(\"0.20\");field.display=display.hidden;\
field = Doc.getField(\"0.0\");field.display=display.visible;" ) );
m_document->processAction( action );
QVERIFY( !m_fields["0.20"]->isVisible() );
QVERIFY( !m_fields["0.20"]->isPrintable() );
QVERIFY( m_fields["0.0"]->isVisible() );
QVERIFY( m_fields["0.0"]->isPrintable() );
QVERIFY( !m_fields[QStringLiteral("0.20")]->isVisible() );
QVERIFY( !m_fields[QStringLiteral("0.20")]->isPrintable() );
QVERIFY( m_fields[QStringLiteral("0.0")]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.0")]->isPrintable() );
delete action;
}
......@@ -189,15 +189,15 @@ void KJSFunctionsTest::testSetClearInterval()
obj.idx = obj.idx + 1;};\
intv = app.setInterval('obj.inc()', 450);obj.idx;" ) );
m_document->processAction( action );
QVERIFY( m_fields["0.0"]->isVisible() );
QVERIFY( !m_fields["0.3"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.0")]->isVisible() );
QVERIFY( !m_fields[QStringLiteral("0.3")]->isVisible() );
delete action;
delay();
action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "app.clearInterval(intv);obj.idx;" ) );
m_document->processAction( action );
QVERIFY( m_fields["0.3"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.3")]->isVisible() );
delete action;
}
......@@ -206,25 +206,25 @@ void KJSFunctionsTest::testSetClearTimeOut()
Okular::ScriptAction *action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "intv = app.setTimeOut('obj.inc()', 1);obj.idx;" ) );
m_document->processAction( action );
QVERIFY( m_fields["0.3"]->isVisible() );
QVERIFY( !m_fields["0.4"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.3")]->isVisible() );
QVERIFY( !m_fields[QStringLiteral("0.4")]->isVisible() );
delay();
delete action;
QVERIFY( m_fields["0.4"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.4")]->isVisible() );
action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "intv = app.setTimeOut('obj.inc()', 2000);obj.idx;" ) );
m_document->processAction( action );
QVERIFY( m_fields["0.4"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.4")]->isVisible() );
delete action;
action = new Okular::ScriptAction( Okular::JavaScript,
QStringLiteral( "app.clearTimeOut(intv);obj.idx;" ) );
m_document->processAction( action );
QVERIFY( m_fields["0.4"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.4")]->isVisible() );
delay();
QVERIFY( m_fields["0.4"]->isVisible() );
QVERIFY( m_fields[QStringLiteral("0.4")]->isVisible() );
delete action;
}
......@@ -375,7 +375,7 @@ void KJSFunctionsTest::testPrintD()
QFETCH(QString, script);
QFETCH(QString, result);
QVERIFY( script.contains( "printd" ) );
QVERIFY( script.contains( QLatin1String("printd") ) );
PrintDHelper test( m_document, script, result );
}
......
......@@ -7,6 +7,8 @@
* (at your option) any later version. *
***************************************************************************/
// clazy:excludeall=qstring-allocations
#include <QtTest>
#include <qprintdialog.h>
......
......@@ -10,6 +10,8 @@
* (at your option) any later version. *
***************************************************************************/
// clazy:excludeall=qstring-allocations
#include <QtTest>
#include "../core/annotations.h"
......
......@@ -7,6 +7,8 @@
* (at your option) any later version. *
***************************************************************************/
// clazy:excludeall=qstring-allocations
#include <QtTest>
#include "../core/document.h"
......
......@@ -698,9 +698,9 @@ void DocumentPrivate::loadViewsInfo( View *view, const QDomElement &e )
view->setCapability( View::ZoomModality, newmode );
}
}
else if ( viewElement.tagName() == "viewMode" )
else if ( viewElement.tagName() == QLatin1String("viewMode") )
{
const QString modeString = viewElement.attribute( "mode" );
const QString modeString = viewElement.attribute( QStringLiteral("mode") );
bool newmode_ok = true;
const int newmode = !modeString.isEmpty() ? modeString.toInt( &newmode_ok ) : 2;
if ( newmode_ok
......@@ -711,9 +711,9 @@ void DocumentPrivate::loadViewsInfo( View *view, const QDomElement &e )
view->setCapability( View::ViewModeModality, newmode );
}
}
else if ( viewElement.tagName() == "continuous" )
else if ( viewElement.tagName() == QLatin1String("continuous") )
{
const QString modeString = viewElement.attribute( "mode" );
const QString modeString = viewElement.attribute( QStringLiteral("mode") );
bool newmode_ok = true;
const int newmode = !modeString.isEmpty() ? modeString.toInt( &newmode_ok ) : 2;
if ( newmode_ok
......@@ -724,9 +724,9 @@ void DocumentPrivate::loadViewsInfo( View *view, const QDomElement &e )
view->setCapability( View::Continuous, newmode );
}
}
else if ( viewElement.tagName() == "trimMargins" )
else if ( viewElement.tagName() == QLatin1String("trimMargins") )
{
const QString valueString = viewElement.attribute( "value" );
const QString valueString = viewElement.attribute( QStringLiteral("value") );
bool newmode_ok = true;
const int newmode = !valueString.isEmpty() ? valueString.toInt( &newmode_ok ) : 2;
if ( newmode_ok
......@@ -767,32 +767,32 @@ void DocumentPrivate::saveViewsInfo( View *view, QDomElement &e ) const
&& ( view->capabilityFlags( View::Continuous )
& ( View::CapabilityRead | View::CapabilitySerializable ) ) )
{
QDomElement contEl = e.ownerDocument().createElement( "continuous" );
QDomElement contEl = e.ownerDocument().createElement( QStringLiteral("continuous") );
e.appendChild( contEl );
const bool mode = view->capability( View::Continuous ).toBool();
contEl.setAttribute( "mode", mode );
contEl.setAttribute( QStringLiteral("mode"), mode );
}
if ( view->supportsCapability( View::ViewModeModality )
&& ( view->capabilityFlags( View::ViewModeModality )
& ( View::CapabilityRead | View::CapabilitySerializable ) ) )
{
QDomElement viewEl = e.ownerDocument().createElement( "viewMode" );
QDomElement viewEl = e.ownerDocument().createElement( QStringLiteral("viewMode") );
e.appendChild( viewEl );
bool ok = true;
const int mode = view->capability( View::ViewModeModality ).toInt( &ok );
if ( ok )
{
viewEl.setAttribute( "mode", mode );
viewEl.setAttribute( QStringLiteral("mode"), mode );
}
}
if ( view->supportsCapability( View::TrimMargins )
&& ( view->capabilityFlags( View::TrimMargins )
& ( View::CapabilityRead | View::CapabilitySerializable ) ) )
{
QDomElement contEl = e.ownerDocument().createElement( "trimMargins" );
QDomElement contEl = e.ownerDocument().createElement( QStringLiteral("trimMargins") );
e.appendChild( contEl );
const bool value = view->capability( View::TrimMargins ).toBool();
contEl.setAttribute( "value", value );
contEl.setAttribute( QStringLiteral("value"), value );
}
}
......
......@@ -174,7 +174,7 @@ static KJSObject appAlert( KJSContext *context, void *,
QString cMsg = arguments.at( 0 ).toString( context );
int nIcon = 0;
int nType = 0;
QString cTitle = "Okular";
QString cTitle = QStringLiteral("Okular");
if( arguments.count() >= 2 )
nIcon = arguments.at( 1 ).toInt32( context );
......@@ -223,14 +223,14 @@ static KJSObject appAlert( KJSContext *context, void *,
if( arguments.count() >= 6 )
{
oCheckbox = arguments.at( 5 );
KJSObject oMsg = oCheckbox.property( context, "cMsg" );
KJSObject oMsg = oCheckbox.property( context, QStringLiteral("cMsg") );
QString msg = i18n( "Do not show this message again" );
if( oMsg.isString() )
msg = oMsg.toString( context );
bool bInitialValue = false;
KJSObject value = oCheckbox.property( context, "bInitialValue" );
KJSObject value = oCheckbox.property( context, QStringLiteral("bInitialValue") );
if( value.isBoolean() )
bInitialValue = value.toBoolean( context );
checkBox = new QCheckBox( msg );
......
......@@ -92,7 +92,7 @@ static KJSObject printd( KJSContext *context, void *,
}
else
{
format = arguments.at( 0 ).toString( context ).replace( "tt", "ap" );
format = arguments.at( 0 ).toString( context ).replace( QLatin1String("tt"), QLatin1String("ap") );
format.replace( 't', 'a' );
for( QChar &formatChar : format )
{
......@@ -103,8 +103,8 @@ static KJSObject printd( KJSContext *context, void *,
}
}
QLocale locale( "en_US" );
const QStringList str = arguments.at( 1 ).toString( context ).split( QRegularExpression( "\\W") );
QLocale locale( QStringLiteral("en_US") );
const QStringList str = arguments.at( 1 ).toString( context ).split( QRegularExpression( QStringLiteral("\\W") ) );
QString myStr = QStringLiteral( "%1/%2/%3 %4:%5:%6" ).arg( str[1], str[2], str[3], str[4], str[5], str[6] );
QDateTime date = locale.toDateTime( myStr, QStringLiteral( "MMM/d/yyyy H:m:s" ) );
......
......@@ -51,7 +51,7 @@ void ChmGeneratorTest::testDocumentStructure()
{
unsigned int expectedPageNr = 6;
QCOMPARE( m_document->pages(), expectedPageNr);
QCOMPARE( m_document->metaData(QLatin1String("DocumentTitle")).toString(), QStringLiteral("okular test chm") );
QCOMPARE( m_document->metaData(QStringLiteral("DocumentTitle")).toString(), QStringLiteral("okular test chm") );
const Okular::DocumentSynopsis *docSyn = m_document->documentSynopsis();
QDomElement heading1 = docSyn->documentElement();
......
......@@ -49,7 +49,7 @@ EBook_CHM::EBook_CHM()
m_textCodec = nullptr;
m_textCodecForSpecialFiles = nullptr;
m_detectedLCID = 0;
m_currentEncoding = "UTF-8";
m_currentEncoding = QStringLiteral("UTF-8");
m_htmlEntityDecoder = nullptr;
}
......@@ -75,7 +75,7 @@ void EBook_CHM::close()
m_textCodec = nullptr;
m_textCodecForSpecialFiles = nullptr;
m_detectedLCID = 0;
m_currentEncoding = "UTF-8";
m_currentEncoding = QStringLiteral("UTF-8");
}
QString EBook_CHM::title() const
......@@ -251,7 +251,7 @@ bool EBook_CHM::load(const QString &archiveName)
QString filename;
// If the file has a file:// prefix, remove it
if ( archiveName.startsWith( "file://" ) )
if ( archiveName.startsWith( QLatin1String("file://") ) )
filename = archiveName.mid( 7 ); // strip it
else
filename = archiveName;
......@@ -279,7 +279,7 @@ bool EBook_CHM::load(const QString &archiveName)
// Reset encoding
m_textCodec = nullptr;
m_textCodecForSpecialFiles = nullptr;
m_currentEncoding = "UTF-8";
m_currentEncoding = QStringLiteral("UTF-8");
// Get information from /#WINDOWS and /#SYSTEM files (encoding, title, context file and so)
// and guess the encoding
......@@ -288,10 +288,10 @@ bool EBook_CHM::load(const QString &archiveName)
guessTextEncoding();
// Check whether the search tables are present
if ( ResolveObject("/#TOPICS", &m_chmTOPICS)
&& ResolveObject("/#STRINGS", &m_chmSTRINGS)
&& ResolveObject("/#URLTBL", &m_chmURLTBL)
&& ResolveObject("/#URLSTR", &m_chmURLSTR) )
if ( ResolveObject(QStringLiteral("/#TOPICS"), &m_chmTOPICS)
&& ResolveObject(QStringLiteral("/#STRINGS"), &m_chmSTRINGS)
&& ResolveObject(QStringLiteral("/#URLTBL"), &m_chmURLTBL)
&& ResolveObject(QStringLiteral("/#URLSTR"), &m_chmURLSTR) )
{
m_lookupTablesValid = true;
fillTopicsUrlMap();
......@@ -301,18 +301,18 @@ bool EBook_CHM::load(const QString &archiveName)
// Some CHM files have toc and index files, but do not set the name properly.
// Some heuristics here.
if ( m_topicsFile.isEmpty() && hasFile( "/toc.hhc" ) )
if ( m_topicsFile.isEmpty() && hasFile( QStringLiteral("/toc.hhc") ) )
m_topicsFile = "/toc.hhc";
if ( m_indexFile.isEmpty() && hasFile( "/index.hhk" ) )
if ( m_indexFile.isEmpty() && hasFile( QStringLiteral("/index.hhk") ) )
m_indexFile = "/index.hhk";
if ( !m_topicsFile.isEmpty() || ( m_lookupTablesValid && hasFile( "/#TOCIDX" ) ) )
if ( !m_topicsFile.isEmpty() || ( m_lookupTablesValid && hasFile( QStringLiteral("/#TOCIDX") ) ) )
m_tocAvailable = true;
else
m_tocAvailable = false;
if ( !m_indexFile.isEmpty() || ( m_lookupTablesValid && hasFile( "/$WWKeywordLinks/BTree" ) ) )
if ( !m_indexFile.isEmpty() || ( m_lookupTablesValid && hasFile( QStringLiteral("/$WWKeywordLinks/BTree") ) ) )
m_indexAvailable = true;
else
m_indexAvailable = false;
......@@ -440,9 +440,9 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
//DEBUGPARSER(("tag: '%s', tagword: '%s'\n", qPrintable( tag ), qPrintable( tagword ) ));
// <OBJECT type="text/sitemap"> - a topic entry
if ( tagword == "object" && tag.indexOf ("text/sitemap", 0, Qt::CaseInsensitive ) != -1 )
if ( tagword == QLatin1String("object") && tag.indexOf (QLatin1String("text/sitemap"), 0, Qt::CaseInsensitive ) != -1 )
in_object = true;
else if ( tagword == "/object" && in_object )
else if ( tagword == QLatin1String("/object") && in_object )
{
// a topic entry closed. Add a tree item
if ( entry.name.isEmpty() && entry.urls.isEmpty() )
......@@ -479,11 +479,11 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
entry.seealso.clear();
in_object = false;
}
else if ( tagword == "param" && in_object )
else if ( tagword == QLatin1String("param") && in_object )
{
// <param name="Name" value="First Page">
int offset; // strlen("param ")
QString name_pattern = "name=", value_pattern = "value=";
const QString name_pattern = QStringLiteral("name="), value_pattern = QStringLiteral("value=");
QString pname, pvalue;
if ( (offset = tag.indexOf (name_pattern, 0, Qt::CaseInsensitive )) == -1 )
......@@ -501,13 +501,13 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
//DEBUGPARSER(("<param>: name '%s', value '%s'", qPrintable( pname ), qPrintable( pvalue )));
if ( pname == "name" || pname == "keyword" )
if ( pname == QLatin1String("name") || pname == QLatin1String("keyword") )
{
// Some help files contain duplicate names, where the second name is empty. Work it around by keeping the first one
if ( !pvalue.isEmpty() )
entry.name = pvalue;
}
else if ( pname == "merge" )
else if ( pname == QLatin1String("merge") )
{
// MERGE implementation is experimental
QUrl mergeurl = pathToUrl( pvalue );
......@@ -526,7 +526,7 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
else
qWarning( "MERGE is used in index but file %s was not found in CHM archive", qPrintable(pvalue) );
}
else if ( pname == "local" )
else if ( pname == QLatin1String("local") )
{
// Check for URL duplication
QUrl url = pathToUrl( pvalue );
......@@ -534,12 +534,12 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
if ( !entry.urls.contains( url ) )
entry.urls.push_back( url );
}
else if ( pname == "see also" && asIndex && entry.name != pvalue )
else if ( pname == QLatin1String("see also") && asIndex && entry.name != pvalue )
{
entry.urls.push_back( QUrl("seealso") );
entry.urls.push_back( QUrl(QStringLiteral("seealso")) );
entry.seealso = pvalue;
}
else if ( pname == "imagenumber" )
else if ( pname == QLatin1String("imagenumber") )
{
bool bok;
int imgnum = pvalue.toInt (&bok);
......@@ -548,7 +548,7 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
entry.iconid = (EBookTocEntry::Icon) imgnum;
}
}
else if ( tagword == "ul" ) // increase indent level
else if ( tagword == QLatin1String("ul") ) // increase indent level
{
// Fix for buggy help files
if ( ++indent >= MAX_NEST_DEPTH )
......@@ -556,7 +556,7 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
DEBUGPARSER(("<ul>: new intent is %d\n", indent - root_indent_offset));
}
else if ( tagword == "/ul" ) // decrease indent level
else if ( tagword == QLatin1String("/ul") ) // decrease indent level
{
if ( --indent < root_indent_offset )
indent = root_indent_offset;
......@@ -607,7 +607,7 @@ bool EBook_CHM::getInfoFromWindows()
chmUnitInfo ui;
long size = 0;
if ( ResolveObject("/#WINDOWS", &ui) )
if ( ResolveObject(QStringLiteral("/#WINDOWS"), &ui) )
{
if ( !RetrieveObject(&ui, buffer, 0, WIN_HEADER_LEN) )
return false;
......@@ -621,7 +621,7 @@ bool EBook_CHM::getInfoFromWindows()
if ( !RetrieveObject (&ui, raw, 8, entries * entry_size) )
return false;
if( !ResolveObject ("/#STRINGS", &ui) )
if( !ResolveObject (QStringLiteral("/#STRINGS"), &ui) )
return false;
for ( unsigned int i = 0; i < entries; ++i )
......@@ -686,7 +686,7 @@ bool EBook_CHM::getInfoFromSystem()
// Run the first loop to detect the encoding. We need this, because title could be
// already encoded in user encoding. Same for file names
if ( !ResolveObject ("/#SYSTEM", &ui) )
if ( !ResolveObject (QStringLiteral("/#SYSTEM"), &ui) )
return false;
// Can we pull BUFF_SIZE bytes of the #SYSTEM file?
......@@ -749,10 +749,10 @@ bool EBook_CHM::getInfoFromSystem()
if ( m_topicsFile.isEmpty() )
{
QString topicAttempt = "/", tmp;
QString topicAttempt = QStringLiteral("/");
topicAttempt += QString ((const char*) buffer +index +2);
tmp = topicAttempt + ".hhc";
QString tmp = topicAttempt + ".hhc";
if ( ResolveObject( tmp, &ui) )
m_topicsFile = qPrintable( tmp );
......@@ -910,7 +910,7 @@ void EBook_CHM::fillTopicsUrlMap()
if ( off_title < (unsigned int)strings.size() )
m_url2topics[url] = encodeWithCurrentCodec ( (const char*) strings.data() + off_title );
else
m_url2topics[url] = "Untitled";
m_url2topics[url] = QStringLiteral("Untitled");
}
}
......@@ -923,11 +923,11 @@ bool EBook_CHM::parseBinaryTOC( QList< EBookTocEntry >& toc ) const
QByteArray tocidx, topics, urltbl, urlstr, strings;
// Read the index tables
if ( !getBinaryContent( tocidx, "/#TOCIDX" )
|| !getBinaryContent( topics, "/#TOPICS" )
|| !getBinaryContent( urltbl, "/#URLTBL" )
|| !getBinaryContent( urlstr, "/#URLSTR" )
|| !getBinaryContent( strings, "/#STRINGS" ) )
if ( !getBinaryContent( tocidx, QStringLiteral("/#TOCIDX") )
|| !getBinaryContent( topics, QStringLiteral("/#TOPICS") )
|| !getBinaryContent( urltbl, QStringLiteral("/#URLTBL") )
|| !getBinaryContent( urlstr, QStringLiteral("/#URLSTR") )
|| !getBinaryContent( strings, QStringLiteral("/#STRINGS") ) )
return false;
// Shamelessly stolen from xchm
......@@ -1066,7 +1066,7 @@ bool EBook_CHM::hasOption(const QString & name) const
QUrl EBook_CHM::pathToUrl(const QString &link) const
{
if ( link.startsWith( "http://" ) || link.startsWith( "https://" ) )
if ( link.startsWith( QLatin1String("http://") ) || link.startsWith( QLatin1String("https://") ) )
return QUrl( link );
QUrl url;
......@@ -1096,13 +1096,13 @@ QString EBook_CHM::urlToPath(const QUrl &link) const
{
if ( link.scheme() == URL_SCHEME_CHM )
{
if ( link.path() == "/" || link.path().isEmpty() )
if ( link.path() == QLatin1String("/") || link.path().isEmpty() )
return m_home;
return link.path();
}
return "";
return QLatin1String("");
}
......
......@@ -302,5 +302,5 @@ QString Ebook_CHM_Encoding::guessByLCID(unsigned short lcid)
return t->qtcodec;
}