summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/findbar.cpp36
-rw-r--r--src/findbar.h8
-rw-r--r--src/mainwindow.cpp19
-rw-r--r--src/tests/link_test.html7
-rw-r--r--src/webpage.cpp26
-rw-r--r--src/webpage.h1
6 files changed, 35 insertions, 62 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp
index 6b92f130..43b23035 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -43,7 +43,6 @@
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
#include <QtGui/QColor>
-#include <QtGui/QKeyEvent>
#include <QtCore/QString>
#include <QtCore/QTimer>
@@ -64,7 +63,6 @@ FindBar::FindBar(KMainWindow *mainwindow)
hideButton->setAutoRaise(true);
hideButton->setIcon(KIcon("dialog-close"));
connect(hideButton, SIGNAL(clicked()), this, SLOT(hide()));
- connect(hideButton, SIGNAL(clicked()), mainwindow, SLOT(findNext()));
layout->addWidget(hideButton);
layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop);
@@ -122,41 +120,21 @@ bool FindBar::matchCase() const
}
-void FindBar::clear()
-{
- m_lineEdit->setText(QString());
-}
-
-
void FindBar::show()
{
- // set focus to findbar if user select showFindBar shortcut
- m_lineEdit->setFocus();
- m_lineEdit->selectAll();
-
// show findbar if not visible
if (isVisible())
return;
-
+
QWidget::show();
m_hideTimer->start(60000);
// emit a new find signal with the current text
- QString temp = m_lineEdit->text();
- m_lineEdit->setText("");
- m_lineEdit->setText(temp);
-}
-
-
-void FindBar::keyPressEvent(QKeyEvent* event)
-{
- if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty())
- {
- emit searchString(m_lineEdit->text());
- return;
- }
-
- QWidget::keyPressEvent(event);
+ emit(searchString(m_lineEdit->text()));
+
+ // set focus to findbar if user select showFindBar shortcut
+ m_lineEdit->setFocus();
+ m_lineEdit->selectAll();
}
@@ -184,9 +162,9 @@ void FindBar::notifyMatch(bool match)
}
-
void FindBar::hide()
{
m_hideTimer->stop();
QWidget::hide();
+ emit(searchString(m_lineEdit->text()));
}
diff --git a/src/findbar.h b/src/findbar.h
index d56b8d25..8f220c92 100644
--- a/src/findbar.h
+++ b/src/findbar.h
@@ -35,11 +35,9 @@
// Qt Includes
#include <QtGui/QWidget>
#include <QtGui/QCheckBox>
-#include <QtGui/QKeyEvent>
// Forward Declarations
class KMainWindow;
-class QKeyEvent;
class QString;
@@ -52,15 +50,11 @@ public:
~FindBar();
KLineEdit *lineEdit() const;
bool matchCase() const;
+ void notifyMatch(bool match);
public slots:
- void clear();
void show();
void hide();
- void notifyMatch(bool match);
-
-protected Q_SLOTS:
- void keyPressEvent(QKeyEvent* event);
signals:
void searchString(const QString &);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index ef74adab..39dd9a40 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -777,22 +777,17 @@ void MainWindow::find(const QString & search)
findNext();
}
+
void MainWindow::matchCaseUpdate()
{
if (!currentTab())
return;
- QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
-
- if (m_findBar->matchCase())
- options |= QWebPage::FindCaseSensitively;
-
currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument);
- bool found = currentTab()->view()->findText(m_lastSearch, options);
- m_findBar->notifyMatch(found);
- if(!found)
- currentTab()->view()->page()->focusNextPrevChild(true);
+ findNext();
}
+
+
void MainWindow::findNext()
{
if (!currentTab())
@@ -819,12 +814,6 @@ void MainWindow::findPrevious()
{
if (!currentTab())
return;
-
- if(m_findBar->isHidden())
- {
- currentTab()->view()->page()->focusNextPrevChild(true);
- return;
- }
QWebPage::FindFlags options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument;
if (m_findBar->matchCase())
diff --git a/src/tests/link_test.html b/src/tests/link_test.html
index 7dd1470d..5ca3cd41 100644
--- a/src/tests/link_test.html
+++ b/src/tests/link_test.html
@@ -135,6 +135,13 @@
<td><a href="http://ads.cnn.com/" target="_blank">link</a></td>
</tr>
+
+<tr>
+<td>http://ja.wikipedia.org/wiki/特別:最近の更新</td>
+<td>KGet import links with particular encoding</td>
+<td><a href="http://ja.wikipedia.org/wiki/特別:最近の更新">link</a></td>
+</tr>
+
<tr>
<td></td>
<td></td>
diff --git a/src/webpage.cpp b/src/webpage.cpp
index ce2d5e40..b5318874 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -72,7 +72,7 @@
WebPage::WebPage(QObject *parent)
- : KWebPage(parent, KWalletIntegration)
+ : KWebPage(parent, KWalletIntegration)
{
setForwardUnsupportedContent(true);
@@ -87,9 +87,10 @@ WebPage::WebPage(QObject *parent)
// Web Plugin Factory
setPluginFactory(new WebPluginFactory(this));
-
- connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ // managing errors
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ // handling load & content
connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
@@ -121,8 +122,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
return false;
}
- m_requestedUrl = request.url();
-
return KWebPage::acceptNavigationRequest(frame, request, type);
}
@@ -218,7 +217,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
if( reply->error() == QNetworkReply::ContentAccessDenied )
return;
- if( reply->url() != m_requestedUrl ) // prevent favicon loading
+ // don't bother on elements loading errors: we'll manage just
+ // main url page ones
+ WebView *v = qobject_cast<WebView *>(view());
+ if( reply->url() != v->url() )
return;
if( reply->error() == QNetworkReply::ContentNotFoundError )
@@ -334,18 +336,22 @@ void WebPage::downloadRequest(const QNetworkRequest &request)
void WebPage::downloadAllContentsWithKGet()
{
- QList<QString> contentList;
+ QSet<QString> contents;
+ KUrl baseUrl( currentFrame()->url() );
+ KUrl relativeUrl;
QWebElementCollection images = mainFrame()->documentElement().findAll("img");
foreach(QWebElement img, images)
{
- contentList.append(img.attribute("src"));
+ relativeUrl.setEncodedUrl(img.attribute("src").toUtf8(),KUrl::TolerantMode);
+ contents << baseUrl.resolved(relativeUrl).toString();
}
QWebElementCollection links = mainFrame()->documentElement().findAll("a");
foreach(QWebElement link, links)
{
- contentList.append(link.attribute("href"));
+ relativeUrl.setEncodedUrl(link.attribute("href").toUtf8(),KUrl::TolerantMode);
+ contents << baseUrl.resolved(relativeUrl).toString();
}
if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
@@ -353,5 +359,5 @@ void WebPage::downloadAllContentsWithKGet()
KToolInvocation::kdeinitExecWait("kget");
}
QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
- kget.call("importLinks", QVariant(contentList));
+ kget.call("importLinks", QVariant(contents.toList()));
}
diff --git a/src/webpage.h b/src/webpage.h
index bbaa0f63..f76fd334 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -77,7 +77,6 @@ private slots:
private:
QString errorPage(QNetworkReply *);
- QUrl m_requestedUrl;
ProtocolHandler m_protHandler;
};