Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
Rekonq
Commits
8681257e
Commit
8681257e
authored
Mar 30, 2011
by
Andrea Diamantini
Browse files
Implement/fix drag and drop handling of text & url in the webview
BUG:254102
parent
af59cbe2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/webview.cpp
View file @
8681257e
...
...
@@ -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
);
}
src/webview.h
View file @
8681257e
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment