diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-02-02 03:36:05 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-02-02 03:36:05 +0100 |
commit | 821a246b101038937f8070152a9c14ead1c4169b (patch) | |
tree | b0ba8d37aa87abc2650ae7255b80f991276623bb /src/urlbar | |
parent | Merge commit 'refs/merge-requests/83' of git://gitorious.org/rekonq/mainline ... (diff) | |
download | rekonq-821a246b101038937f8070152a9c14ead1c4169b.tar.xz |
This should fix last wrong encoded urls
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/urlbar.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index be19dae4..adeba6ae 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -140,13 +140,15 @@ void UrlBar::setUrl(const QUrl& url) if(url.scheme() == "about") { m_currentUrl = KUrl(); + updateUrl(); // updateUrl before setFocus setFocus(); } else { m_currentUrl = KUrl(url); + updateUrl(); } - updateUrl(); + } @@ -302,36 +304,43 @@ bool UrlBar::isLoading() return true; } + void UrlBar::keyPressEvent(QKeyEvent *event) { QString currentText = m_lineEdit->text().trimmed(); - if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) - && !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive)) + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { - QString append; - if (event->modifiers() == Qt::ControlModifier) + if( !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive) ) { - append = QLatin1String(".com"); + QString append; + if (event->modifiers() == Qt::ControlModifier) + { + append = QLatin1String(".com"); + } + else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) + { + append = QLatin1String(".org"); + } + else if (event->modifiers() == Qt::ShiftModifier) + { + append = QLatin1String(".net"); + } + + QUrl url(QLatin1String("http://www.") + currentText); + QString host = url.host(); + if (!host.endsWith(append, Qt::CaseInsensitive)) + { + host += append; + url.setHost(host); + m_lineEdit->setText(url.toString()); + } } - else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) - { - append = QLatin1String(".org"); - } - else if (event->modifiers() == Qt::ShiftModifier) - { - append = QLatin1String(".net"); - } - - QUrl url(QLatin1String("http://www.") + currentText); - QString host = url.host(); - if (!host.endsWith(append, Qt::CaseInsensitive)) + else { - host += append; - url.setHost(host); - m_lineEdit->setText(url.toString()); + // fill lineEdit with its stripped contents to remove trailing spaces + m_lineEdit->setText(currentText); } } KHistoryComboBox::keyPressEvent(event); } - |