Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
7c14893b
Commit
7c14893b
authored
Aug 20, 2012
by
Yimgo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed drag and drop in widget items.
parent
58746c87
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
88 deletions
+53
-88
UBWidgetUniboardAPI.cpp
src/api/UBWidgetUniboardAPI.cpp
+10
-12
UBWidgetUniboardAPI.h
src/api/UBWidgetUniboardAPI.h
+2
-2
UBBoardView.cpp
src/board/UBBoardView.cpp
+8
-42
UBGraphicsWebView.cpp
src/domain/UBGraphicsWebView.cpp
+2
-2
UBGraphicsWebView.h
src/domain/UBGraphicsWebView.h
+1
-1
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+27
-27
UBGraphicsWidgetItem.h
src/domain/UBGraphicsWidgetItem.h
+3
-2
No files found.
src/api/UBWidgetUniboardAPI.cpp
View file @
7c14893b
...
@@ -476,7 +476,7 @@ void UBWidgetUniboardAPI::enableDropOnWidget(bool enable)
...
@@ -476,7 +476,7 @@ void UBWidgetUniboardAPI::enableDropOnWidget(bool enable)
}
}
}
}
void
UBWidgetUniboardAPI
::
ProcessDropEvent
(
QDropEvent
*
event
)
void
UBWidgetUniboardAPI
::
ProcessDropEvent
(
Q
GraphicsSceneDrag
DropEvent
*
event
)
{
{
const
QMimeData
*
pMimeData
=
event
->
mimeData
();
const
QMimeData
*
pMimeData
=
event
->
mimeData
();
...
@@ -485,11 +485,12 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
...
@@ -485,11 +485,12 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
bool
downloaded
=
false
;
bool
downloaded
=
false
;
QGraphicsView
*
tmpView
=
mGraphicsWidget
->
scene
()
->
views
().
at
(
0
);
QGraphicsView
*
tmpView
=
mGraphicsWidget
->
scene
()
->
views
().
at
(
0
);
QPoint
dropPoint
(
mGraphicsWidget
->
mapFromScene
(
tmpView
->
mapToScene
(
event
->
pos
())).
toPoint
());
QPoint
dropPoint
(
mGraphicsWidget
->
mapFromScene
(
tmpView
->
mapToScene
(
event
->
pos
().
toPoint
())).
toPoint
());
Qt
::
DropActions
dropActions
=
event
->
dropAction
();
Qt
::
DropActions
dropActions
=
event
->
possibleActions
();
Qt
::
MouseButtons
dropMouseButtons
=
event
->
mouseButtons
();
Qt
::
MouseButtons
dropMouseButtons
=
event
->
buttons
();
Qt
::
KeyboardModifiers
dropModifiers
=
event
->
keyboardModifiers
();
Qt
::
KeyboardModifiers
dropModifiers
=
event
->
modifiers
();
QMimeData
dropMimeData
;
QMimeData
*
dropMimeData
=
new
QMimeData
;
qDebug
()
<<
event
->
possibleActions
();
if
(
pMimeData
->
hasHtml
())
{
//Dropping element from web browser
if
(
pMimeData
->
hasHtml
())
{
//Dropping element from web browser
...
@@ -510,7 +511,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
...
@@ -510,7 +511,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
desc
.
name
=
QFileInfo
(
url
).
fileName
();
desc
.
name
=
QFileInfo
(
url
).
fileName
();
desc
.
totalSize
=
0
;
// The total size will be retrieved during the download
desc
.
totalSize
=
0
;
// The total size will be retrieved during the download
desc
.
dropPoint
=
event
->
pos
();
//Passing pure event point. No modifications
desc
.
dropPoint
=
event
->
pos
()
.
toPoint
()
;
//Passing pure event point. No modifications
desc
.
dropActions
=
dropActions
;
desc
.
dropActions
=
dropActions
;
desc
.
dropMouseButtons
=
dropMouseButtons
;
desc
.
dropMouseButtons
=
dropMouseButtons
;
desc
.
dropModifiers
=
dropModifiers
;
desc
.
dropModifiers
=
dropModifiers
;
...
@@ -542,12 +543,9 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
...
@@ -542,12 +543,9 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
}
}
qDebug
()
<<
destFileName
;
qDebug
()
<<
destFileName
;
QString
mimeText
=
createMimeText
(
downloaded
,
contentType
,
destFileName
);
QString
mimeText
=
createMimeText
(
downloaded
,
contentType
,
destFileName
);
dropMimeData
.
setData
(
tMimeText
,
mimeText
.
toAscii
());
dropMimeData
->
setData
(
tMimeText
,
mimeText
.
toAscii
());
QDropEvent
readyEvent
(
dropPoint
,
dropActions
,
&
dropMimeData
,
dropMouseButtons
,
dropModifiers
);
event
->
setMimeData
(
dropMimeData
);
//sending event to destination either it had been downloaded or not
QApplication
::
sendEvent
(
mGraphicsWidget
,
&
readyEvent
);
readyEvent
.
acceptProposedAction
();
}
}
void
UBWidgetUniboardAPI
::
onDownloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
)
void
UBWidgetUniboardAPI
::
onDownloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
)
...
...
src/api/UBWidgetUniboardAPI.h
View file @
7c14893b
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#define UBWIDGETAPI_H
#define UBWIDGETAPI_H
#include <QtCore>
#include <QtCore>
#include <QDropEvent>
#include <Q
GraphicsSceneDrag
DropEvent>
#include "UBW3CWidgetAPI.h"
#include "UBW3CWidgetAPI.h"
#include "core/UBDownloadManager.h"
#include "core/UBDownloadManager.h"
...
@@ -246,7 +246,7 @@ class UBWidgetUniboardAPI : public QObject
...
@@ -246,7 +246,7 @@ class UBWidgetUniboardAPI : public QObject
* When an object is dropped on a widget, this one send us the informations to download it locally.
* When an object is dropped on a widget, this one send us the informations to download it locally.
* this method download the object on the widget directory and return the path of the downloaded object
* this method download the object on the widget directory and return the path of the downloaded object
*/
*/
void
ProcessDropEvent
(
QDropEvent
*
);
void
ProcessDropEvent
(
Q
GraphicsSceneDrag
DropEvent
*
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
private
slots
:
private
slots
:
...
...
src/board/UBBoardView.cpp
View file @
7c14893b
...
@@ -1202,56 +1202,22 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
...
@@ -1202,56 +1202,22 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
}
}
void
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
void
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
{
QGraphicsItem
*
graphicsItemAtPos
=
itemAt
(
event
->
pos
().
x
(),
event
->
pos
().
y
());
QGraphicsView
::
dragMoveEvent
(
event
);
UBGraphicsWidgetItem
*
graphicsWidget
=
dynamic_cast
<
UBGraphicsWidgetItem
*>
(
graphicsItemAtPos
);
if
(
graphicsWidget
)
{
if
(
graphicsWidget
->
acceptDrops
())
{
if
(
!
mOkOnWidget
)
{
if
(
!
graphicsWidget
->
isDropableData
(
event
->
mimeData
()))
{
mOkOnWidget
=
false
;
event
->
ignore
();
return
;
}
else
{
mOkOnWidget
=
true
;
}
}
QPoint
newPoint
(
graphicsWidget
->
mapFromScene
(
mapToScene
(
event
->
pos
())).
toPoint
());
QDragMoveEvent
newEvent
(
newPoint
,
event
->
dropAction
(),
event
->
mimeData
(),
event
->
mouseButtons
(),
event
->
keyboardModifiers
());
QApplication
::
sendEvent
(
graphicsWidget
,
&
newEvent
);
}
else
{
mOkOnWidget
=
false
;
event
->
ignore
();
}
}
else
{
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
mOkOnWidget
=
false
;
}
}
}
void
UBBoardView
::
dropEvent
(
QDropEvent
*
event
)
void
UBBoardView
::
dropEvent
(
QDropEvent
*
event
)
{
{
mOkOnWidget
=
false
;
if
(
!
itemAt
(
event
->
pos
().
x
(),
event
->
pos
().
y
()))
{
QGraphicsItem
*
graphicsItemAtPos
=
itemAt
(
event
->
pos
().
x
(),
event
->
pos
().
y
());
if
(
!
event
->
source
()
||
dynamic_cast
<
UBThumbnailWidget
*>
(
event
->
source
())
||
dynamic_cast
<
QWebView
*>
(
event
->
source
())
||
dynamic_cast
<
UBTGMediaWidget
*>
(
event
->
source
())
||
dynamic_cast
<
QListView
*>
(
event
->
source
())
||
dynamic_cast
<
UBTGDraggableTreeItem
*>
(
event
->
source
()))
{
UBGraphicsWidgetItem
*
graphicsWidget
=
dynamic_cast
<
UBGraphicsWidgetItem
*>
(
graphicsItemAtPos
);
if
(
graphicsWidget
&&
graphicsWidget
->
acceptDrops
())
{
graphicsWidget
->
processDropEvent
(
event
);
event
->
acceptProposedAction
();
}
else
if
(
!
event
->
source
()
||
dynamic_cast
<
UBThumbnailWidget
*>
(
event
->
source
())
||
dynamic_cast
<
QWebView
*>
(
event
->
source
())
||
dynamic_cast
<
UBTGMediaWidget
*>
(
event
->
source
())
||
dynamic_cast
<
QListView
*>
(
event
->
source
())
||
dynamic_cast
<
UBTGDraggableTreeItem
*>
(
event
->
source
()))
{
mController
->
processMimeData
(
event
->
mimeData
(),
mapToScene
(
event
->
pos
()));
mController
->
processMimeData
(
event
->
mimeData
(),
mapToScene
(
event
->
pos
()));
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
}
}
else
QGraphicsView
::
dropEvent
(
event
);
}
}
void
void
...
...
src/domain/UBGraphicsWebView.cpp
View file @
7c14893b
...
@@ -151,10 +151,10 @@ void UBGraphicsWebView::remove()
...
@@ -151,10 +151,10 @@ void UBGraphicsWebView::remove()
mDelegate
->
remove
(
true
);
mDelegate
->
remove
(
true
);
}
}
bool
UBGraphicsWebView
::
event
(
QEvent
*
event
)
/*
bool UBGraphicsWebView::event(QEvent *event)
{
{
if (event->type() == QEvent::ShortcutOverride)
if (event->type() == QEvent::ShortcutOverride)
event->accept();
event->accept();
return QGraphicsWebView::event(event);
return QGraphicsWebView::event(event);
}
}
*/
src/domain/UBGraphicsWebView.h
View file @
7c14893b
...
@@ -54,7 +54,7 @@ class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResiza
...
@@ -54,7 +54,7 @@ class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResiza
virtual
void
wheelEvent
(
QGraphicsSceneWheelEvent
*
event
);
virtual
void
wheelEvent
(
QGraphicsSceneWheelEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
bool
event
(
QEvent
*
event
);
//
virtual bool event(QEvent *event);
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
};
};
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
7c14893b
...
@@ -97,7 +97,6 @@ UBGraphicsWidgetItem::~UBGraphicsWidgetItem()
...
@@ -97,7 +97,6 @@ UBGraphicsWidgetItem::~UBGraphicsWidgetItem()
void
UBGraphicsWidgetItem
::
initialize
()
void
UBGraphicsWidgetItem
::
initialize
()
{
{
installEventFilter
(
this
);
UBGraphicsWebView
::
setMinimumSize
(
nominalSize
());
UBGraphicsWebView
::
setMinimumSize
(
nominalSize
());
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
// Necessary to set if we want z value to be assigned correctly
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
// Necessary to set if we want z value to be assigned correctly
...
@@ -277,9 +276,9 @@ void UBGraphicsWidgetItem::removeScript()
...
@@ -277,9 +276,9 @@ void UBGraphicsWidgetItem::removeScript()
page
()
->
mainFrame
()
->
evaluateJavaScript
(
"if(widget && widget.onremove) { widget.onremove();}"
);
page
()
->
mainFrame
()
->
evaluateJavaScript
(
"if(widget && widget.onremove) { widget.onremove();}"
);
}
}
void
UBGraphicsWidgetItem
::
processDropEvent
(
QDropEvent
*
event
)
void
UBGraphicsWidgetItem
::
processDropEvent
(
Q
GraphicsSceneDrag
DropEvent
*
event
)
{
{
return
mUniboardAPI
->
ProcessDropEvent
(
event
);
mUniboardAPI
->
ProcessDropEvent
(
event
);
}
}
bool
UBGraphicsWidgetItem
::
isDropableData
(
const
QMimeData
*
data
)
const
bool
UBGraphicsWidgetItem
::
isDropableData
(
const
QMimeData
*
data
)
const
{
{
...
@@ -486,6 +485,31 @@ void UBGraphicsWidgetItem::unFreeze()
...
@@ -486,6 +485,31 @@ void UBGraphicsWidgetItem::unFreeze()
mIsFrozen
=
false
;
mIsFrozen
=
false
;
}
}
bool
UBGraphicsWidgetItem
::
event
(
QEvent
*
event
)
{
if
(
mShouldMoveWidget
&&
event
->
type
()
==
QEvent
::
MouseMove
)
{
QMouseEvent
*
mouseMoveEvent
=
static_cast
<
QMouseEvent
*>
(
event
);
if
(
mouseMoveEvent
->
buttons
()
&
Qt
::
LeftButton
)
{
QPointF
scenePos
=
mapToScene
(
mouseMoveEvent
->
pos
());
QPointF
newPos
=
pos
()
+
scenePos
-
mLastMousePos
;
setPos
(
newPos
);
mLastMousePos
=
scenePos
;
event
->
accept
();
return
true
;
}
}
else
if
(
event
->
type
()
==
QEvent
::
ShortcutOverride
)
event
->
accept
();
return
UBGraphicsWebView
::
event
(
event
);
}
void
UBGraphicsWidgetItem
::
dropEvent
(
QGraphicsSceneDragDropEvent
*
event
)
{
processDropEvent
(
event
);
QGraphicsWebView
::
dropEvent
(
event
);
}
void
UBGraphicsWidgetItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsWidgetItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
UBGraphicsWebView
::
mousePressEvent
(
event
);
UBGraphicsWebView
::
mousePressEvent
(
event
);
...
@@ -522,30 +546,6 @@ void UBGraphicsWidgetItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
...
@@ -522,30 +546,6 @@ void UBGraphicsWidgetItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
UBGraphicsWebView
::
hoverMoveEvent
(
event
);
UBGraphicsWebView
::
hoverMoveEvent
(
event
);
}
}
bool
UBGraphicsWidgetItem
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
if
(
mShouldMoveWidget
&&
obj
==
this
&&
event
->
type
()
==
QEvent
::
MouseMove
)
{
QMouseEvent
*
mouseMoveEvent
=
static_cast
<
QMouseEvent
*>
(
event
);
if
(
mouseMoveEvent
->
buttons
()
&
Qt
::
LeftButton
)
{
QPointF
scenePos
=
mapToScene
(
mouseMoveEvent
->
pos
());
QPointF
newPos
=
pos
()
+
scenePos
-
mLastMousePos
;
setPos
(
newPos
);
mLastMousePos
=
scenePos
;
event
->
accept
();
return
true
;
}
}
/* standard event processing */
return
QObject
::
eventFilter
(
obj
,
event
);
}
void
UBGraphicsWidgetItem
::
sendJSEnterEvent
()
void
UBGraphicsWidgetItem
::
sendJSEnterEvent
()
{
{
if
(
page
()
&&
page
()
->
mainFrame
())
if
(
page
()
&&
page
()
->
mainFrame
())
...
...
src/domain/UBGraphicsWidgetItem.h
View file @
7c14893b
...
@@ -76,7 +76,7 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
...
@@ -76,7 +76,7 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
virtual
void
remove
();
virtual
void
remove
();
void
removeScript
();
void
removeScript
();
void
processDropEvent
(
QDropEvent
*
event
);
void
processDropEvent
(
Q
GraphicsSceneDrag
DropEvent
*
event
);
bool
isDropableData
(
const
QMimeData
*
data
)
const
;
bool
isDropableData
(
const
QMimeData
*
data
)
const
;
virtual
QUrl
getOwnFolder
()
const
;
virtual
QUrl
getOwnFolder
()
const
;
...
@@ -136,12 +136,13 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
...
@@ -136,12 +136,13 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
QMap
<
QString
,
QString
>
mDatastore
;
QMap
<
QString
,
QString
>
mDatastore
;
QMap
<
QString
,
QString
>
mPreferences
;
QMap
<
QString
,
QString
>
mPreferences
;
virtual
bool
event
(
QEvent
*
event
);
virtual
void
dropEvent
(
QGraphicsSceneDragDropEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
virtual
void
sendJSEnterEvent
();
virtual
void
sendJSEnterEvent
();
virtual
void
sendJSLeaveEvent
();
virtual
void
sendJSLeaveEvent
();
virtual
void
injectInlineJavaScript
();
virtual
void
injectInlineJavaScript
();
...
...
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