1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Using QChar instead of 1-char QString everywhere

This commit is contained in:
nowrep 2012-07-01 18:50:18 +02:00
parent fbc44d2889
commit dd170f653f
19 changed files with 56 additions and 56 deletions

View File

@ -111,7 +111,7 @@ void AdBlockIcon::createMenu(QMenu* menu)
const QPair<AdBlockRule, QUrl> &pair = m_blockedPopups.at(i); const QPair<AdBlockRule, QUrl> &pair = m_blockedPopups.at(i);
QString address = pair.second.toString().right(55); QString address = pair.second.toString().right(55);
QString actionText = tr("%1 with (%2)").arg(address, pair.first.filter()).replace("&", "&&"); QString actionText = tr("%1 with (%2)").arg(address, pair.first.filter()).replace('&', "&&");
QAction* action = menu->addAction(actionText, manager, SLOT(showRule())); QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
action->setData(qVariantFromValue((void*)&pair.first)); action->setData(qVariantFromValue((void*)&pair.first));
@ -127,7 +127,7 @@ void AdBlockIcon::createMenu(QMenu* menu)
menu->addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false); menu->addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false);
foreach(const WebPage::AdBlockedEntry & entry, entries) { foreach(const WebPage::AdBlockedEntry & entry, entries) {
QString address = entry.url.toString().right(55); QString address = entry.url.toString().right(55);
QString actionText = tr("%1 with (%2)").arg(address, entry.rule->filter()).replace("&", "&&"); QString actionText = tr("%1 with (%2)").arg(address, entry.rule->filter()).replace('&', "&&");
QAction* action = menu->addAction(actionText, manager, SLOT(showRule())); QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
action->setData(qVariantFromValue((void*)entry.rule)); action->setData(qVariantFromValue((void*)entry.rule));

View File

@ -161,8 +161,8 @@ void CommandLineOptions::parseActions()
const QString &url = arguments.last(); const QString &url = arguments.last();
if (m_argc > 1 && !url.isEmpty() && !url.startsWith("-") && if (m_argc > 1 && !url.isEmpty() && !url.startsWith('-') &&
(url.contains(".") || url.contains("/") || url.contains("\\"))) { (url.contains('.') || url.contains('/') || url.contains('\\'))) {
ActionPair pair; ActionPair pair;
pair.action = Qz::CL_OpenUrl; pair.action = Qz::CL_OpenUrl;
pair.text = url; pair.text = url;

View File

@ -191,7 +191,7 @@ MainApplication::MainApplication(int &argc, char** argv)
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
if (startProfile.isEmpty()) { if (startProfile.isEmpty()) {
QSettings settings(PROFILEDIR + "profiles/profiles.ini", QSettings::IniFormat); QSettings settings(PROFILEDIR + "profiles/profiles.ini", QSettings::IniFormat);
if (settings.value("Profiles/startProfile", "default").toString().contains("/")) { if (settings.value("Profiles/startProfile", "default").toString().contains('/')) {
m_activeProfil = PROFILEDIR + "profiles/default/"; m_activeProfil = PROFILEDIR + "profiles/default/";
} }
else { else {
@ -744,7 +744,7 @@ void MainApplication::startPrivateBrowsing()
{ {
QStringList args; QStringList args;
foreach(const QString & arg, arguments()) { foreach(const QString & arg, arguments()) {
if (arg.startsWith("-")) { if (arg.startsWith('-')) {
args.append(arg); args.append(arg);
} }
} }
@ -763,7 +763,7 @@ QUrl MainApplication::userStyleSheet(const QString &filePath) const
QFile file(filePath); QFile file(filePath);
if (!filePath.isEmpty() && file.open(QFile::ReadOnly)) { if (!filePath.isEmpty() && file.open(QFile::ReadOnly)) {
userStyle = file.readAll(); userStyle = file.readAll();
userStyle.remove("\n"); userStyle.remove('\n');
file.close(); file.close();
} }

View File

@ -1461,7 +1461,7 @@ void QupZilla::savePage()
{ {
QNetworkRequest request(weView()->url()); QNetworkRequest request(weView()->url());
QString suggestedFileName = qz_getFileNameFromUrl(weView()->url()); QString suggestedFileName = qz_getFileNameFromUrl(weView()->url());
if (!suggestedFileName.contains(".")) { if (!suggestedFileName.contains('.')) {
suggestedFileName.append(".html"); suggestedFileName.append(".html");
} }

View File

@ -211,8 +211,8 @@ void AutoFillModel::completePage(WebPage* page)
for (int i = 0; i < arguments.count(); i++) { for (int i = 0; i < arguments.count(); i++) {
QString key = arguments.at(i).first; QString key = arguments.at(i).first;
QString value = arguments.at(i).second; QString value = arguments.at(i).second;
key.replace("+", " "); key.replace('+', ' ');
value.replace("+", " "); value.replace('+', ' ');
key = QUrl::fromEncoded(key.toUtf8()).toString(); key = QUrl::fromEncoded(key.toUtf8()).toString();
value = QUrl::fromEncoded(value.toUtf8()).toString(); value = QUrl::fromEncoded(value.toUtf8()).toString();
@ -362,13 +362,13 @@ QByteArray AutoFillModel::convertWebKitFormBoundaryIfNecessary(const QByteArray
QString string = rx.cap(1); QString string = rx.cap(1);
pos += rx.matchedLength(); pos += rx.matchedLength();
int endOfAttributeName = string.indexOf("\""); int endOfAttributeName = string.indexOf('"');
if (endOfAttributeName == -1) { if (endOfAttributeName == -1) {
continue; continue;
} }
QString attrName = string.left(endOfAttributeName); QString attrName = string.left(endOfAttributeName);
QString attrValue = string.mid(endOfAttributeName + 1).trimmed().remove("\n"); QString attrValue = string.mid(endOfAttributeName + 1).trimmed().remove('\n');
if (attrName.isEmpty() || attrValue.isEmpty()) { if (attrName.isEmpty() || attrValue.isEmpty()) {
continue; continue;

View File

@ -160,7 +160,7 @@ void CookieManager::slotRefreshTable()
QTreeWidgetItem* item; QTreeWidgetItem* item;
QString cookieDomain = cookie.domain(); QString cookieDomain = cookie.domain();
if (cookieDomain.startsWith(".")) { if (cookieDomain.startsWith('.')) {
cookieDomain = cookieDomain.mid(1); cookieDomain = cookieDomain.mid(1);
} }

View File

@ -238,7 +238,7 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply)
reg.indexIn(value); reg.indexIn(value);
path = reg.cap(1).trimmed(); path = reg.cap(1).trimmed();
if (path.startsWith("\"") && path.endsWith("\"")) { if (path.startsWith('"') && path.endsWith('"')) {
path = path.mid(1, path.length() - 2); path = path.mid(1, path.length() - 2);
} }
} }
@ -262,7 +262,7 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply)
QString name = baseName + endName; QString name = baseName + endName;
if (name.contains("\"")) { if (name.contains('"')) {
name.remove("\";"); name.remove("\";");
} }

View File

@ -104,7 +104,7 @@ QUrl LocationBar::createUrl()
QUrl urlToLoad; QUrl urlToLoad;
//Check for Search Engine shortcut //Check for Search Engine shortcut
int firstSpacePos = text().indexOf(" "); int firstSpacePos = text().indexOf(' ');
if (firstSpacePos != -1) { if (firstSpacePos != -1) {
QString shortcut = text().left(firstSpacePos); QString shortcut = text().left(firstSpacePos);
QString searchedString = QUrl::toPercentEncoding(text().mid(firstSpacePos).trimmed()); QString searchedString = QUrl::toPercentEncoding(text().mid(firstSpacePos).trimmed());

View File

@ -51,7 +51,7 @@
QString fileNameForCert(const QSslCertificate &cert) QString fileNameForCert(const QSslCertificate &cert)
{ {
QString certFileName = CertificateInfoWidget::certificateItemText(cert); QString certFileName = CertificateInfoWidget::certificateItemText(cert);
certFileName.remove(" "); certFileName.remove(' ');
certFileName.append(".crt"); certFileName.append(".crt");
certFileName = qz_filterCharsFromFilename(certFileName); certFileName = qz_filterCharsFromFilename(certFileName);
return certFileName; return certFileName;

View File

@ -58,7 +58,7 @@ Updater::Version Updater::parseVersionFromString(const QString &string)
bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two) bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two)
{ {
if (one.contains("rc") && two.contains("b")) { if (one.contains("rc") && two.contains('b')) {
return true; return true;
} }
@ -74,9 +74,9 @@ bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two)
return false; return false;
} }
if (one.contains("b")) { if (one.contains('b')) {
int o = one.remove("b").toInt(); int o = one.remove('b').toInt();
int t = two.remove("b").toInt(); int t = two.remove('b').toInt();
return o > t; return o > t;
} }

View File

@ -288,7 +288,7 @@ QString SpeedDial::getOpenFileName()
QString SpeedDial::urlFromUserInput(const QString &url) QString SpeedDial::urlFromUserInput(const QString &url)
{ {
return QUrl::fromUserInput(url).toString().remove("'"); return QUrl::fromUserInput(url).toString().remove('\'');
} }
void SpeedDial::setBackgroundImage(const QString &image) void SpeedDial::setBackgroundImage(const QString &image)

View File

@ -80,7 +80,7 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
foreach(const QString & code, langs) { foreach(const QString & code, langs) {
QString code_ = code; QString code_ = code;
QLocale loc = QLocale(code_.replace("-", "_")); QLocale loc = QLocale(code_.replace('-', '_'));
QString label; QString label;
if (loc.language() == QLocale::C) { if (loc.language() == QLocale::C) {
@ -202,8 +202,8 @@ void AcceptLanguage::accept()
QStringList langs; QStringList langs;
for (int i = 0; i < ui->listWidget->count(); i++) { for (int i = 0; i < ui->listWidget->count(); i++) {
QString t = ui->listWidget->item(i)->text(); QString t = ui->listWidget->item(i)->text();
QString code = t.mid(t.indexOf("[") + 1); QString code = t.mid(t.indexOf('[') + 1);
code.remove("]"); code.remove(']');
langs.append(code); langs.append(code);
} }

View File

@ -121,7 +121,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
m_actProfileName = mApp->currentProfilePath(); m_actProfileName = mApp->currentProfilePath();
m_actProfileName = m_actProfileName.left(m_actProfileName.length() - 1); m_actProfileName = m_actProfileName.left(m_actProfileName.length() - 1);
m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/")); m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/"));
m_actProfileName.remove("/"); m_actProfileName.remove('/');
ui->activeProfile->setText("<b>" + m_actProfileName + "</b>"); ui->activeProfile->setText("<b>" + m_actProfileName + "</b>");
@ -483,7 +483,7 @@ void Preferences::chooseDownPath()
return; return;
} }
#ifdef Q_WS_WIN //QFileDialog::getExistingDirectory returns path with \ instead of / (??) #ifdef Q_WS_WIN //QFileDialog::getExistingDirectory returns path with \ instead of / (??)
userFileName.replace("\\", "/"); userFileName.replace('\\', '/');
#endif #endif
userFileName += "/"; userFileName += "/";

View File

@ -39,7 +39,7 @@ QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
{ {
QString n = Qt::escape(string); QString n = Qt::escape(string);
if (!n.contains("\\")) { if (!n.contains('\\')) {
return n; return n;
} }

View File

@ -144,7 +144,7 @@ QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl)
else { else {
samePart = samePart.left(samePart.lastIndexOf("/") + 1); samePart = samePart.left(samePart.lastIndexOf("/") + 1);
int slashCount = samePart.count("/") + 1; int slashCount = samePart.count("/") + 1;
if (samePart.startsWith("/")) { if (samePart.startsWith('/')) {
slashCount--; slashCount--;
} }
if (samePart.endsWith("/")) { if (samePart.endsWith("/")) {
@ -164,14 +164,14 @@ QString qz_urlEncodeQueryString(const QUrl &url)
QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment); QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment);
if (url.hasQuery()) { if (url.hasQuery()) {
returnString += "?" + url.encodedQuery(); returnString += '?' + url.encodedQuery();
} }
if (url.hasFragment()) { if (url.hasFragment()) {
returnString += "#" + url.encodedFragment(); returnString += '#' + url.encodedFragment();
} }
returnString.replace(" ", "%20"); returnString.replace(' ', "%20");
return returnString; return returnString;
} }
@ -202,16 +202,16 @@ QString qz_ensureUniqueFilename(const QString &pathToFile)
QString qz_getFileNameFromUrl(const QUrl &url) QString qz_getFileNameFromUrl(const QUrl &url)
{ {
QString fileName = url.toString(QUrl::RemoveFragment | QUrl::RemoveQuery | QUrl::RemoveScheme | QUrl::RemovePort); QString fileName = url.toString(QUrl::RemoveFragment | QUrl::RemoveQuery | QUrl::RemoveScheme | QUrl::RemovePort);
if (fileName.indexOf("/") != -1) { if (fileName.indexOf('/') != -1) {
int pos = fileName.lastIndexOf("/"); int pos = fileName.lastIndexOf('/');
fileName = fileName.mid(pos); fileName = fileName.mid(pos);
fileName.remove("/"); fileName.remove('/');
} }
fileName = qz_filterCharsFromFilename(fileName); fileName = qz_filterCharsFromFilename(fileName);
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
fileName = qz_filterCharsFromFilename(url.host().replace(".", "-")); fileName = qz_filterCharsFromFilename(url.host().replace('.', '-'));
} }
return fileName; return fileName;
@ -221,15 +221,15 @@ QString qz_filterCharsFromFilename(const QString &name)
{ {
QString value = name; QString value = name;
value.replace("/", "-"); value.replace('/', '-');
value.remove("\\"); value.remove('\\');
value.remove(":"); value.remove(':');
value.remove("*"); value.remove('*');
value.remove("?"); value.remove('?');
value.remove("\""); value.remove('"');
value.remove("<"); value.remove('<');
value.remove(">"); value.remove('>');
value.remove("|"); value.remove('|');
return value; return value;
} }

View File

@ -109,13 +109,13 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
QString src = element.attribute("src"); QString src = element.attribute("src");
QString alt = element.attribute("alt"); QString alt = element.attribute("alt");
if (alt.isEmpty()) { if (alt.isEmpty()) {
if (src.indexOf("/") == -1) { if (src.indexOf('/') == -1) {
alt = src; alt = src;
} }
else { else {
int pos = src.lastIndexOf("/"); int pos = src.lastIndexOf("/");
alt = src.mid(pos); alt = src.mid(pos);
alt.remove("/"); alt.remove('/');
} }
} }
if (src.isEmpty() || alt.isEmpty()) { if (src.isEmpty() || alt.isEmpty()) {
@ -250,7 +250,7 @@ void SiteInfo::showImagePreview(QTreeWidgetItem* item)
if (imageUrl.scheme() == "data") { if (imageUrl.scheme() == "data") {
QByteArray encodedUrl = item->text(1).toUtf8(); QByteArray encodedUrl = item->text(1).toUtf8();
QByteArray imageData = encodedUrl.mid(encodedUrl.indexOf(",") + 1); QByteArray imageData = encodedUrl.mid(encodedUrl.indexOf(',') + 1);
m_activePixmap = qz_pixmapFromByteArray(imageData); m_activePixmap = qz_pixmapFromByteArray(imageData);
} }
else if (imageUrl.scheme() == "file") { else if (imageUrl.scheme() == "file") {

View File

@ -227,7 +227,7 @@ void TabWidget::aboutToShowTabsMenu()
} }
else { else {
QString title = tab->title(); QString title = tab->title();
title.replace("&", "&&"); title.replace('&', "&&");
if (title.length() > 40) { if (title.length() > 40) {
title.truncate(40); title.truncate(40);
title += ".."; title += "..";
@ -479,7 +479,7 @@ void TabWidget::setTabIcon(int index, const QIcon &icon)
void TabWidget::setTabText(int index, const QString &text) void TabWidget::setTabText(int index, const QString &text)
{ {
QString newtext = text; QString newtext = text;
newtext.replace("&", "&&"); // Avoid Alt+letter shortcuts newtext.replace('&', "&&"); // Avoid Alt+letter shortcuts
if (WebTab* webTab = weTab(index)) { if (WebTab* webTab = weTab(index)) {
if (webTab->isPinned()) { if (webTab->isPinned()) {

View File

@ -410,7 +410,7 @@ void WebPage::setSSLCertificate(const QSslCertificate &cert)
QSslCertificate WebPage::sslCertificate() QSslCertificate WebPage::sslCertificate()
{ {
if (url().scheme() == "https" && if (url().scheme() == "https" &&
m_SslCert.subjectInfo(QSslCertificate::CommonName).remove("*").contains(QRegExp(url().host()))) { m_SslCert.subjectInfo(QSslCertificate::CommonName).remove('*').contains(QRegExp(url().host()))) {
return m_SslCert; return m_SslCert;
} }
else { else {
@ -500,7 +500,7 @@ void WebPage::cleanBlockedObjects()
//May be relative url //May be relative url
QString relativeUrl = qz_makeRelativeUrl(mainFrameUrl, entry.url).toString(); QString relativeUrl = qz_makeRelativeUrl(mainFrameUrl, entry.url).toString();
findingStrings.append(relativeUrl); findingStrings.append(relativeUrl);
if (relativeUrl.startsWith("/")) { if (relativeUrl.startsWith('/')) {
findingStrings.append(relativeUrl.right(relativeUrl.size() - 1)); findingStrings.append(relativeUrl.right(relativeUrl.size() - 1));
} }
} }

View File

@ -397,7 +397,7 @@ void WebView::downloadPage()
{ {
QNetworkRequest request(url()); QNetworkRequest request(url());
QString suggestedFileName = qz_getFileNameFromUrl(url()); QString suggestedFileName = qz_getFileNameFromUrl(url());
if (!suggestedFileName.contains(".")) { if (!suggestedFileName.contains('.')) {
suggestedFileName.append(".html"); suggestedFileName.append(".html");
} }
@ -849,8 +849,8 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
menu->addAction(dictact); menu->addAction(dictact);
// #379: Remove newlines // #379: Remove newlines
QString selectedString = selectedText.trimmed().remove("\n"); QString selectedString = selectedText.trimmed().remove('\n');
if (!selectedString.contains(".")) { if (!selectedString.contains('.')) {
// Try to add .com // Try to add .com
selectedString.append(".com"); selectedString.append(".com");
} }
@ -868,7 +868,7 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
menu->addSeparator(); menu->addSeparator();
selectedText.truncate(20); selectedText.truncate(20);
// KDE is displaying new lines in menu actions ... weird -,- // KDE is displaying new lines in menu actions ... weird -,-
selectedText.replace("\n", " ").replace("\t", ""); selectedText.replace('\n', ' ').remove('\t');
SearchEngine engine = mApp->searchEnginesManager()->activeEngine(); SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
Action* act = new Action(engine.icon, tr("Search \"%1 ..\" with %2").arg(selectedText, engine.name)); Action* act = new Action(engine.icon, tr("Search \"%1 ..\" with %2").arg(selectedText, engine.name));