summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-03-30 00:44:19 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-03-30 00:44:19 +0200
commit8681257ee91ac1bde53ff3a65cea2f2c2fd12792 (patch)
treee7a7c51a0a4bec43504a2f75a0e8fe13f155066e
parentAllow drag from urlbar (diff)
downloadrekonq-8681257ee91ac1bde53ff3a65cea2f2c2fd12792.tar.xz
Implement/fix drag and drop handling of text & url in the webview
BUG:254102
-rw-r--r--src/webview.cpp33
-rw-r--r--src/webview.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index 16c9c2e5..91910970 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -472,6 +472,7 @@ void WebView::enterEvent(QEvent *event)
void WebView::dropEvent(QDropEvent *event)
{
+ bool isEditable = page()->frameAt(event->pos())->hitTestContent(event->pos()).isContentEditable();
if (event->mimeData()->hasFormat("application/rekonq-bookmark"))
{
QByteArray addresses = event->mimeData()->data("application/rekonq-bookmark");
@@ -485,6 +486,20 @@ void WebView::dropEvent(QDropEvent *event)
emit loadUrl(bookmark.url(), Rekonq::CurrentTab);
}
}
+ else if (event->mimeData()->hasUrls() && event->source() != this && !isEditable) //dropped links
+ {
+ Q_FOREACH (const QUrl &url, event->mimeData()->urls())
+ {
+ emit loadUrl(url, Rekonq::NewFocusedTab);
+ }
+ }
+ else if (event->mimeData()->hasFormat("text/plain") && event->source() != this && !isEditable) //dropped plain text with url format
+ {
+ QUrl url = QUrl::fromUserInput(event->mimeData()->data("text/plain"));
+
+ if (url.isValid())
+ emit loadUrl(url, Rekonq::NewFocusedTab);
+ }
else
{
KWebView::dropEvent(event);
@@ -800,3 +815,21 @@ void WebView::stopScrolling()
m_dy = 0;
m_smoothScrolling = false;
}
+
+
+void WebView::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasUrls() || event->mimeData()->hasText())
+ event->acceptProposedAction();
+ else
+ KWebView::dragEnterEvent(event);
+}
+
+
+void WebView::dragMoveEvent(QDragMoveEvent *event)
+{
+ if (event->mimeData()->hasUrls() || event->mimeData()->hasText())
+ event->acceptProposedAction();
+ else
+ KWebView::dragMoveEvent(event);
+}
diff --git a/src/webview.h b/src/webview.h
index b954c17e..1fec1ae4 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -65,6 +65,8 @@ protected:
void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
void dropEvent(QDropEvent *event);
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dragMoveEvent(QDragMoveEvent * event);
private Q_SLOTS:
void search();