diff --git a/src/lib/adblock/adblockmanager.cpp b/src/lib/adblock/adblockmanager.cpp index a98bee19b..5a7242902 100644 --- a/src/lib/adblock/adblockmanager.cpp +++ b/src/lib/adblock/adblockmanager.cpp @@ -287,7 +287,9 @@ bool AdBlockManager::isEnabled() bool AdBlockManager::canRunOnScheme(const QString &scheme) const { - return !(scheme == "file" || scheme == "qrc" || scheme == "qupzilla" || scheme == "data" || scheme == "abp"); + return !(scheme == QLatin1String("file") || scheme == QLatin1String("qrc") + || scheme == QLatin1String("qupzilla") || scheme == QLatin1String("data") + || scheme == QLatin1String("abp")); } bool AdBlockManager::canBeBlocked(const QUrl &url) const diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index 0b6ff0f29..6ba67a9e9 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -237,5 +237,6 @@ void GM_Manager::load() bool GM_Manager::canRunOnScheme(const QString &scheme) { - return (scheme == "http" || scheme == "https" || scheme == "data" || scheme == "ftp"); + return (scheme == QLatin1String("http") || scheme == QLatin1String("https") + || scheme == QLatin1String("data") || scheme == QLatin1String("ftp")); } diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index 81c59cd33..0fac6e305 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -38,7 +38,7 @@ PluginSpec GM_Plugin::pluginSpec() spec.name = "GreaseMonkey"; spec.info = "Userscripts for QupZilla"; spec.description = "Provides support for userscripts (www.userscripts.org)"; - spec.version = "0.2.1"; + spec.version = "0.2.2"; spec.author = "David Rosca "; spec.icon = QPixmap(":gm/data/icon.png"); spec.hasSettings = true; @@ -62,7 +62,7 @@ void GM_Plugin::unload() bool GM_Plugin::testPlugin() { - return (QupZilla::VERSION == "1.3.1"); + return (QupZilla::VERSION == QLatin1String("1.3.1")); } QTranslator* GM_Plugin::getTranslator(const QString &locale) diff --git a/src/plugins/GreaseMonkey/gm_script.cpp b/src/plugins/GreaseMonkey/gm_script.cpp index 18507c6f4..56425b4d9 100644 --- a/src/plugins/GreaseMonkey/gm_script.cpp +++ b/src/plugins/GreaseMonkey/gm_script.cpp @@ -162,12 +162,12 @@ void GM_Script::parseScript(const QString &filePath) const QStringList &lines = metadataBlock.split('\n'); foreach(QString line, lines) { - if (!line.startsWith("// @")) { + if (!line.startsWith(QLatin1String("// @"))) { continue; } - line = line.mid(3).replace('\t', ' '); - int index = line.indexOf(' '); + line = line.mid(3).replace(QLatin1Char('\t'), QLatin1Char(' ')); + int index = line.indexOf(QLatin1Char(' ')); if (index < 0) { continue; @@ -184,39 +184,39 @@ void GM_Script::parseScript(const QString &filePath) continue; } - if (key == "@name") { + if (key == QLatin1String("@name")) { m_name = value; } - else if (key == "@namespace") { + else if (key == QLatin1String("@namespace")) { m_namespace = value; } - else if (key == "@description") { + else if (key == QLatin1String("@description")) { m_description = value; } - else if (key == "@version") { + else if (key == QLatin1String("@version")) { m_version = value; } - else if (key == "@updateURL") { + else if (key == QLatin1String("@updateURL")) { m_downloadUrl = QUrl(value); } - else if (key == "@include" || key == "@match") { + else if (key == QLatin1String("@include") || key == QLatin1String("@match")) { m_include.append(GM_UrlMatcher(value)); } - else if (key == "@exclude" || key == "@exclude_match") { + else if (key == QLatin1String("@exclude") || key == QLatin1String("@exclude_match")) { m_exclude.append(GM_UrlMatcher(value)); } - else if (key == "@require") { + else if (key == QLatin1String("@require")) { requireList.append(value); } - else if (key == "@run-at") { - if (value == "document-end") { + else if (key == QLatin1String("@run-at")) { + if (value == QLatin1String("document-end")) { m_startAt = DocumentEnd; } - else if (value == "document-start") { + else if (value == QLatin1String("document-start")) { m_startAt = DocumentStart; } } - else if (key == "@downloadURL" && m_downloadUrl.isEmpty()) { + else if (key == QLatin1String("@downloadURL") && m_downloadUrl.isEmpty()) { m_downloadUrl = QUrl(value); } } @@ -225,7 +225,7 @@ void GM_Script::parseScript(const QString &filePath) m_include.append(GM_UrlMatcher("*")); } - int index = fileData.indexOf("// ==/UserScript==") + 18; + int index = fileData.indexOf(QLatin1String("// ==/UserScript==")) + 18; QString script = fileData.mid(index).trimmed(); script.prepend(m_manager->requireScripts(requireList)); diff --git a/src/plugins/GreaseMonkey/gm_urlmatcher.cpp b/src/plugins/GreaseMonkey/gm_urlmatcher.cpp index c5f24502f..baa0c1cca 100644 --- a/src/plugins/GreaseMonkey/gm_urlmatcher.cpp +++ b/src/plugins/GreaseMonkey/gm_urlmatcher.cpp @@ -25,10 +25,10 @@ bool wildcardMatch(const QString &string, const QString &pattern) int stringSize = string.size(); int patternSize = pattern.size(); - bool startsWithWildcard = pattern[0] == '*'; - bool endsWithWildcard = pattern[patternSize - 1] == '*'; + bool startsWithWildcard = pattern[0] == QLatin1Char('*'); + bool endsWithWildcard = pattern[patternSize - 1] == QLatin1Char('*'); - const QStringList &parts = pattern.split('*'); + const QStringList &parts = pattern.split(QLatin1Char('*')); int pos = 0; if (startsWithWildcard) { @@ -76,7 +76,7 @@ bool GM_UrlMatcher::match(const QString &urlString) const void GM_UrlMatcher::parsePattern(QString pattern) { - if (pattern.startsWith('/') && pattern.endsWith('/')) { + if (pattern.startsWith(QLatin1Char('/')) && pattern.endsWith(QLatin1Char('/'))) { pattern = pattern.mid(1); pattern = pattern.left(pattern.size() - 1); @@ -85,14 +85,14 @@ void GM_UrlMatcher::parsePattern(QString pattern) return; } - if (pattern.contains(".tld")) { + if (pattern.contains(QLatin1String(".tld"))) { - pattern.replace(QRegExp("(\\W)"), "\\\\1") - .replace(QRegExp("\\*+"), "*") - .replace(QRegExp("^\\\\\\|"), "^") - .replace(QRegExp("\\\\\\|$"), "$") - .replace(QRegExp("\\\\\\*"), ".*") - .replace("\\.tld", "\\.[a-z.]{2,6}"); + pattern.replace(QRegExp("(\\W)"), QLatin1String("\\\\1")) + .replace(QRegExp("\\*+"), QLatin1String("*")) + .replace(QRegExp("^\\\\\\|"), QLatin1String("^")) + .replace(QRegExp("\\\\\\|$"), QLatin1String("$")) + .replace(QRegExp("\\\\\\*"), QLatin1String(".*")) + .replace("\\.tld", QLatin1String("\\.[a-z.]{2,6}")); m_useRegExp = true; m_regExp = QRegExp(pattern, Qt::CaseInsensitive);