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:
parent
fbc44d2889
commit
dd170f653f
@ -111,7 +111,7 @@ void AdBlockIcon::createMenu(QMenu* menu)
|
||||
const QPair<AdBlockRule, QUrl> &pair = m_blockedPopups.at(i);
|
||||
|
||||
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()));
|
||||
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);
|
||||
foreach(const WebPage::AdBlockedEntry & entry, entries) {
|
||||
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()));
|
||||
action->setData(qVariantFromValue((void*)entry.rule));
|
||||
|
@ -161,8 +161,8 @@ void CommandLineOptions::parseActions()
|
||||
|
||||
const QString &url = arguments.last();
|
||||
|
||||
if (m_argc > 1 && !url.isEmpty() && !url.startsWith("-") &&
|
||||
(url.contains(".") || url.contains("/") || url.contains("\\"))) {
|
||||
if (m_argc > 1 && !url.isEmpty() && !url.startsWith('-') &&
|
||||
(url.contains('.') || url.contains('/') || url.contains('\\'))) {
|
||||
ActionPair pair;
|
||||
pair.action = Qz::CL_OpenUrl;
|
||||
pair.text = url;
|
||||
|
@ -191,7 +191,7 @@ MainApplication::MainApplication(int &argc, char** argv)
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
if (startProfile.isEmpty()) {
|
||||
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/";
|
||||
}
|
||||
else {
|
||||
@ -744,7 +744,7 @@ void MainApplication::startPrivateBrowsing()
|
||||
{
|
||||
QStringList args;
|
||||
foreach(const QString & arg, arguments()) {
|
||||
if (arg.startsWith("-")) {
|
||||
if (arg.startsWith('-')) {
|
||||
args.append(arg);
|
||||
}
|
||||
}
|
||||
@ -763,7 +763,7 @@ QUrl MainApplication::userStyleSheet(const QString &filePath) const
|
||||
QFile file(filePath);
|
||||
if (!filePath.isEmpty() && file.open(QFile::ReadOnly)) {
|
||||
userStyle = file.readAll();
|
||||
userStyle.remove("\n");
|
||||
userStyle.remove('\n');
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ void QupZilla::savePage()
|
||||
{
|
||||
QNetworkRequest request(weView()->url());
|
||||
QString suggestedFileName = qz_getFileNameFromUrl(weView()->url());
|
||||
if (!suggestedFileName.contains(".")) {
|
||||
if (!suggestedFileName.contains('.')) {
|
||||
suggestedFileName.append(".html");
|
||||
}
|
||||
|
||||
|
@ -211,8 +211,8 @@ void AutoFillModel::completePage(WebPage* page)
|
||||
for (int i = 0; i < arguments.count(); i++) {
|
||||
QString key = arguments.at(i).first;
|
||||
QString value = arguments.at(i).second;
|
||||
key.replace("+", " ");
|
||||
value.replace("+", " ");
|
||||
key.replace('+', ' ');
|
||||
value.replace('+', ' ');
|
||||
|
||||
key = QUrl::fromEncoded(key.toUtf8()).toString();
|
||||
value = QUrl::fromEncoded(value.toUtf8()).toString();
|
||||
@ -362,13 +362,13 @@ QByteArray AutoFillModel::convertWebKitFormBoundaryIfNecessary(const QByteArray
|
||||
QString string = rx.cap(1);
|
||||
pos += rx.matchedLength();
|
||||
|
||||
int endOfAttributeName = string.indexOf("\"");
|
||||
int endOfAttributeName = string.indexOf('"');
|
||||
if (endOfAttributeName == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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()) {
|
||||
continue;
|
||||
|
@ -160,7 +160,7 @@ void CookieManager::slotRefreshTable()
|
||||
QTreeWidgetItem* item;
|
||||
|
||||
QString cookieDomain = cookie.domain();
|
||||
if (cookieDomain.startsWith(".")) {
|
||||
if (cookieDomain.startsWith('.')) {
|
||||
cookieDomain = cookieDomain.mid(1);
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply)
|
||||
reg.indexIn(value);
|
||||
path = reg.cap(1).trimmed();
|
||||
|
||||
if (path.startsWith("\"") && path.endsWith("\"")) {
|
||||
if (path.startsWith('"') && path.endsWith('"')) {
|
||||
path = path.mid(1, path.length() - 2);
|
||||
}
|
||||
}
|
||||
@ -262,7 +262,7 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply)
|
||||
|
||||
QString name = baseName + endName;
|
||||
|
||||
if (name.contains("\"")) {
|
||||
if (name.contains('"')) {
|
||||
name.remove("\";");
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ QUrl LocationBar::createUrl()
|
||||
QUrl urlToLoad;
|
||||
|
||||
//Check for Search Engine shortcut
|
||||
int firstSpacePos = text().indexOf(" ");
|
||||
int firstSpacePos = text().indexOf(' ');
|
||||
if (firstSpacePos != -1) {
|
||||
QString shortcut = text().left(firstSpacePos);
|
||||
QString searchedString = QUrl::toPercentEncoding(text().mid(firstSpacePos).trimmed());
|
||||
|
@ -51,7 +51,7 @@
|
||||
QString fileNameForCert(const QSslCertificate &cert)
|
||||
{
|
||||
QString certFileName = CertificateInfoWidget::certificateItemText(cert);
|
||||
certFileName.remove(" ");
|
||||
certFileName.remove(' ');
|
||||
certFileName.append(".crt");
|
||||
certFileName = qz_filterCharsFromFilename(certFileName);
|
||||
return certFileName;
|
||||
|
@ -58,7 +58,7 @@ Updater::Version Updater::parseVersionFromString(const QString &string)
|
||||
|
||||
bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two)
|
||||
{
|
||||
if (one.contains("rc") && two.contains("b")) {
|
||||
if (one.contains("rc") && two.contains('b')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,9 +74,9 @@ bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (one.contains("b")) {
|
||||
int o = one.remove("b").toInt();
|
||||
int t = two.remove("b").toInt();
|
||||
if (one.contains('b')) {
|
||||
int o = one.remove('b').toInt();
|
||||
int t = two.remove('b').toInt();
|
||||
|
||||
return o > t;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ QString SpeedDial::getOpenFileName()
|
||||
|
||||
QString SpeedDial::urlFromUserInput(const QString &url)
|
||||
{
|
||||
return QUrl::fromUserInput(url).toString().remove("'");
|
||||
return QUrl::fromUserInput(url).toString().remove('\'');
|
||||
}
|
||||
|
||||
void SpeedDial::setBackgroundImage(const QString &image)
|
||||
|
@ -80,7 +80,7 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
|
||||
|
||||
foreach(const QString & code, langs) {
|
||||
QString code_ = code;
|
||||
QLocale loc = QLocale(code_.replace("-", "_"));
|
||||
QLocale loc = QLocale(code_.replace('-', '_'));
|
||||
QString label;
|
||||
|
||||
if (loc.language() == QLocale::C) {
|
||||
@ -202,8 +202,8 @@ void AcceptLanguage::accept()
|
||||
QStringList langs;
|
||||
for (int i = 0; i < ui->listWidget->count(); i++) {
|
||||
QString t = ui->listWidget->item(i)->text();
|
||||
QString code = t.mid(t.indexOf("[") + 1);
|
||||
code.remove("]");
|
||||
QString code = t.mid(t.indexOf('[') + 1);
|
||||
code.remove(']');
|
||||
langs.append(code);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
||||
m_actProfileName = mApp->currentProfilePath();
|
||||
m_actProfileName = m_actProfileName.left(m_actProfileName.length() - 1);
|
||||
m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/"));
|
||||
m_actProfileName.remove("/");
|
||||
m_actProfileName.remove('/');
|
||||
|
||||
ui->activeProfile->setText("<b>" + m_actProfileName + "</b>");
|
||||
|
||||
@ -483,7 +483,7 @@ void Preferences::chooseDownPath()
|
||||
return;
|
||||
}
|
||||
#ifdef Q_WS_WIN //QFileDialog::getExistingDirectory returns path with \ instead of / (??)
|
||||
userFileName.replace("\\", "/");
|
||||
userFileName.replace('\\', '/');
|
||||
#endif
|
||||
userFileName += "/";
|
||||
|
||||
|
@ -39,7 +39,7 @@ QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
|
||||
{
|
||||
QString n = Qt::escape(string);
|
||||
|
||||
if (!n.contains("\\")) {
|
||||
if (!n.contains('\\')) {
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl)
|
||||
else {
|
||||
samePart = samePart.left(samePart.lastIndexOf("/") + 1);
|
||||
int slashCount = samePart.count("/") + 1;
|
||||
if (samePart.startsWith("/")) {
|
||||
if (samePart.startsWith('/')) {
|
||||
slashCount--;
|
||||
}
|
||||
if (samePart.endsWith("/")) {
|
||||
@ -164,14 +164,14 @@ QString qz_urlEncodeQueryString(const QUrl &url)
|
||||
QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment);
|
||||
|
||||
if (url.hasQuery()) {
|
||||
returnString += "?" + url.encodedQuery();
|
||||
returnString += '?' + url.encodedQuery();
|
||||
}
|
||||
|
||||
if (url.hasFragment()) {
|
||||
returnString += "#" + url.encodedFragment();
|
||||
returnString += '#' + url.encodedFragment();
|
||||
}
|
||||
|
||||
returnString.replace(" ", "%20");
|
||||
returnString.replace(' ', "%20");
|
||||
|
||||
return returnString;
|
||||
}
|
||||
@ -202,16 +202,16 @@ QString qz_ensureUniqueFilename(const QString &pathToFile)
|
||||
QString qz_getFileNameFromUrl(const QUrl &url)
|
||||
{
|
||||
QString fileName = url.toString(QUrl::RemoveFragment | QUrl::RemoveQuery | QUrl::RemoveScheme | QUrl::RemovePort);
|
||||
if (fileName.indexOf("/") != -1) {
|
||||
int pos = fileName.lastIndexOf("/");
|
||||
if (fileName.indexOf('/') != -1) {
|
||||
int pos = fileName.lastIndexOf('/');
|
||||
fileName = fileName.mid(pos);
|
||||
fileName.remove("/");
|
||||
fileName.remove('/');
|
||||
}
|
||||
|
||||
fileName = qz_filterCharsFromFilename(fileName);
|
||||
|
||||
if (fileName.isEmpty()) {
|
||||
fileName = qz_filterCharsFromFilename(url.host().replace(".", "-"));
|
||||
fileName = qz_filterCharsFromFilename(url.host().replace('.', '-'));
|
||||
}
|
||||
|
||||
return fileName;
|
||||
@ -221,15 +221,15 @@ QString qz_filterCharsFromFilename(const QString &name)
|
||||
{
|
||||
QString value = name;
|
||||
|
||||
value.replace("/", "-");
|
||||
value.remove("\\");
|
||||
value.remove(":");
|
||||
value.remove("*");
|
||||
value.remove("?");
|
||||
value.remove("\"");
|
||||
value.remove("<");
|
||||
value.remove(">");
|
||||
value.remove("|");
|
||||
value.replace('/', '-');
|
||||
value.remove('\\');
|
||||
value.remove(':');
|
||||
value.remove('*');
|
||||
value.remove('?');
|
||||
value.remove('"');
|
||||
value.remove('<');
|
||||
value.remove('>');
|
||||
value.remove('|');
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -109,13 +109,13 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
|
||||
QString src = element.attribute("src");
|
||||
QString alt = element.attribute("alt");
|
||||
if (alt.isEmpty()) {
|
||||
if (src.indexOf("/") == -1) {
|
||||
if (src.indexOf('/') == -1) {
|
||||
alt = src;
|
||||
}
|
||||
else {
|
||||
int pos = src.lastIndexOf("/");
|
||||
alt = src.mid(pos);
|
||||
alt.remove("/");
|
||||
alt.remove('/');
|
||||
}
|
||||
}
|
||||
if (src.isEmpty() || alt.isEmpty()) {
|
||||
@ -250,7 +250,7 @@ void SiteInfo::showImagePreview(QTreeWidgetItem* item)
|
||||
|
||||
if (imageUrl.scheme() == "data") {
|
||||
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);
|
||||
}
|
||||
else if (imageUrl.scheme() == "file") {
|
||||
|
@ -227,7 +227,7 @@ void TabWidget::aboutToShowTabsMenu()
|
||||
}
|
||||
else {
|
||||
QString title = tab->title();
|
||||
title.replace("&", "&&");
|
||||
title.replace('&', "&&");
|
||||
if (title.length() > 40) {
|
||||
title.truncate(40);
|
||||
title += "..";
|
||||
@ -479,7 +479,7 @@ void TabWidget::setTabIcon(int index, const QIcon &icon)
|
||||
void TabWidget::setTabText(int index, const QString &text)
|
||||
{
|
||||
QString newtext = text;
|
||||
newtext.replace("&", "&&"); // Avoid Alt+letter shortcuts
|
||||
newtext.replace('&', "&&"); // Avoid Alt+letter shortcuts
|
||||
|
||||
if (WebTab* webTab = weTab(index)) {
|
||||
if (webTab->isPinned()) {
|
||||
|
@ -410,7 +410,7 @@ void WebPage::setSSLCertificate(const QSslCertificate &cert)
|
||||
QSslCertificate WebPage::sslCertificate()
|
||||
{
|
||||
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;
|
||||
}
|
||||
else {
|
||||
@ -500,7 +500,7 @@ void WebPage::cleanBlockedObjects()
|
||||
//May be relative url
|
||||
QString relativeUrl = qz_makeRelativeUrl(mainFrameUrl, entry.url).toString();
|
||||
findingStrings.append(relativeUrl);
|
||||
if (relativeUrl.startsWith("/")) {
|
||||
if (relativeUrl.startsWith('/')) {
|
||||
findingStrings.append(relativeUrl.right(relativeUrl.size() - 1));
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ void WebView::downloadPage()
|
||||
{
|
||||
QNetworkRequest request(url());
|
||||
QString suggestedFileName = qz_getFileNameFromUrl(url());
|
||||
if (!suggestedFileName.contains(".")) {
|
||||
if (!suggestedFileName.contains('.')) {
|
||||
suggestedFileName.append(".html");
|
||||
}
|
||||
|
||||
@ -849,8 +849,8 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
|
||||
menu->addAction(dictact);
|
||||
|
||||
// #379: Remove newlines
|
||||
QString selectedString = selectedText.trimmed().remove("\n");
|
||||
if (!selectedString.contains(".")) {
|
||||
QString selectedString = selectedText.trimmed().remove('\n');
|
||||
if (!selectedString.contains('.')) {
|
||||
// Try to add .com
|
||||
selectedString.append(".com");
|
||||
}
|
||||
@ -868,7 +868,7 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
|
||||
menu->addSeparator();
|
||||
selectedText.truncate(20);
|
||||
// KDE is displaying new lines in menu actions ... weird -,-
|
||||
selectedText.replace("\n", " ").replace("\t", "");
|
||||
selectedText.replace('\n', ' ').remove('\t');
|
||||
|
||||
SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
|
||||
Action* act = new Action(engine.icon, tr("Search \"%1 ..\" with %2").arg(selectedText, engine.name));
|
||||
|
Loading…
Reference in New Issue
Block a user