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
a9eb37ce
Commit
a9eb37ce
authored
Feb 10, 2012
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dnd finished Sankore 354
parent
b8060d03
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
110 deletions
+36
-110
UBWidgetUniboardAPI.cpp
src/api/UBWidgetUniboardAPI.cpp
+22
-34
UBWidgetUniboardAPI.h
src/api/UBWidgetUniboardAPI.h
+2
-2
UBBoardView.cpp
src/board/UBBoardView.cpp
+6
-60
UBBoardView.h
src/board/UBBoardView.h
+1
-6
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+4
-8
UBGraphicsWidgetItem.h
src/domain/UBGraphicsWidgetItem.h
+1
-0
No files found.
src/api/UBWidgetUniboardAPI.cpp
View file @
a9eb37ce
...
@@ -470,36 +470,6 @@ void UBWidgetUniboardAPI::enableDropOnWidget()
...
@@ -470,36 +470,6 @@ void UBWidgetUniboardAPI::enableDropOnWidget()
mGraphicsWidget
->
setAcceptDrops
(
true
);
mGraphicsWidget
->
setAcceptDrops
(
true
);
}
}
QString
UBWidgetUniboardAPI
::
downloadUrl
(
const
QString
&
objectUrl
,
const
QString
&
extention
)
{
QString
result
;
QUrl
widgetUrl
=
mGraphicsWidget
->
getOwnFolder
();
QString
destFileName
=
widgetUrl
.
toLocalFile
()
+
"/objects/"
+
QUuid
::
createUuid
().
toString
()
+
extention
;
if
(
UBFileSystemUtils
::
copyFile
(
objectUrl
,
destFileName
))
{
result
=
destFileName
.
remove
(
widgetUrl
.
toLocalFile
());
}
else
{
qDebug
()
<<
"can't copy from "
<<
widgetUrl
<<
"to"
<<
destFileName
;
result
=
QString
();
}
return
result
;
}
QString
UBWidgetUniboardAPI
::
downloadWeb
(
const
QString
&
objectUrl
)
{
// When we fall there, it means that we are dropping something from the web to the board
sDownloadFileDesc
desc
;
desc
.
dest
=
sDownloadFileDesc
::
graphicsWidget
;
desc
.
modal
=
true
;
desc
.
url
=
objectUrl
;
desc
.
currentSize
=
0
;
desc
.
name
=
QFileInfo
(
objectUrl
).
fileName
();
desc
.
totalSize
=
0
;
// The total size will be retrieved during the download
registerIDWidget
(
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
));
return
QString
();
}
void
UBWidgetUniboardAPI
::
ProcessDropEvent
(
QDropEvent
*
event
)
void
UBWidgetUniboardAPI
::
ProcessDropEvent
(
QDropEvent
*
event
)
{
{
const
QMimeData
*
pMimeData
=
event
->
mimeData
();
const
QMimeData
*
pMimeData
=
event
->
mimeData
();
...
@@ -541,7 +511,6 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
...
@@ -541,7 +511,6 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
registerIDWidget
(
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
));
registerIDWidget
(
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
));
// return;
}
}
}
else
if
(
pMimeData
->
hasUrls
())
{
//Local file processing
}
else
if
(
pMimeData
->
hasUrls
())
{
//Local file processing
...
@@ -554,7 +523,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
...
@@ -554,7 +523,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
contentType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
fileName
);
contentType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
fileName
);
if
(
supportedTypeHeader
(
contentType
))
{
if
(
supportedTypeHeader
(
contentType
))
{
destFileName
=
getObjDir
()
+
QUuid
::
createUuid
().
toString
()
+
extention
;
destFileName
=
getObjDir
()
+
QUuid
::
createUuid
().
toString
()
+
"."
+
extention
;
if
(
!
UBFileSystemUtils
::
copyFile
(
fileName
,
destFileName
))
{
if
(
!
UBFileSystemUtils
::
copyFile
(
fileName
,
destFileName
))
{
qDebug
()
<<
"can't copy from"
<<
fileName
<<
"to"
<<
destFileName
;
qDebug
()
<<
"can't copy from"
<<
fileName
<<
"to"
<<
destFileName
;
...
@@ -625,8 +594,8 @@ void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc de
...
@@ -625,8 +594,8 @@ void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc de
destFile
.
close
();
destFile
.
close
();
//To make js interpreter accept drop event we need to generate move event first.
//To make js interpreter accept drop event we need to generate move event first.
QDragMoveEvent
readm
ove
(
dropPoint
,
desc
.
dropActions
,
&
dropMimeData
,
desc
.
dropMouseButtons
,
desc
.
dropModifiers
);
QDragMoveEvent
pseudoM
ove
(
dropPoint
,
desc
.
dropActions
,
&
dropMimeData
,
desc
.
dropMouseButtons
,
desc
.
dropModifiers
);
QApplication
::
sendEvent
(
mGraphicsWidget
->
widgetWebView
(),
&
readm
ove
);
QApplication
::
sendEvent
(
mGraphicsWidget
->
widgetWebView
(),
&
pseudoM
ove
);
QDropEvent
readyEvent
(
dropPoint
,
desc
.
dropActions
,
&
dropMimeData
,
desc
.
dropMouseButtons
,
desc
.
dropModifiers
);
QDropEvent
readyEvent
(
dropPoint
,
desc
.
dropActions
,
&
dropMimeData
,
desc
.
dropMouseButtons
,
desc
.
dropModifiers
);
//sending event to destination either it had been downloaded or not
//sending event to destination either it had been downloaded or not
...
@@ -680,6 +649,25 @@ bool UBWidgetUniboardAPI::takeIDWidget(int id)
...
@@ -680,6 +649,25 @@ bool UBWidgetUniboardAPI::takeIDWidget(int id)
return
false
;
return
false
;
}
}
bool
UBWidgetUniboardAPI
::
isDropableData
(
const
QMimeData
*
pMimeData
)
const
{
QString
fileName
=
QString
();
if
(
pMimeData
->
hasHtml
())
{
fileName
=
UBApplication
::
urlFromHtml
(
pMimeData
->
html
());
if
(
fileName
.
isEmpty
())
return
false
;
}
else
if
(
pMimeData
->
hasUrls
())
{
fileName
=
pMimeData
->
urls
().
at
(
0
).
toLocalFile
();
if
(
fileName
.
isEmpty
())
return
false
;
}
if
(
supportedTypeHeader
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
fileName
)))
return
true
;
return
false
;
}
UBDocumentDatastoreAPI
::
UBDocumentDatastoreAPI
(
UBGraphicsW3CWidgetItem
*
graphicsWidget
)
UBDocumentDatastoreAPI
::
UBDocumentDatastoreAPI
(
UBGraphicsW3CWidgetItem
*
graphicsWidget
)
:
UBW3CWebStorage
(
graphicsWidget
)
:
UBW3CWebStorage
(
graphicsWidget
)
...
...
src/api/UBWidgetUniboardAPI.h
View file @
a9eb37ce
...
@@ -246,9 +246,8 @@ class UBWidgetUniboardAPI : public QObject
...
@@ -246,9 +246,8 @@ 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
*/
*/
QString
downloadUrl
(
const
QString
&
objectUrl
,
const
QString
&
extention
=
""
);
QString
downloadWeb
(
const
QString
&
objectUrl
);
void
ProcessDropEvent
(
QDropEvent
*
);
void
ProcessDropEvent
(
QDropEvent
*
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
private
slots
:
private
slots
:
void
onDownloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
);
void
onDownloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
);
...
@@ -257,6 +256,7 @@ private:
...
@@ -257,6 +256,7 @@ private:
inline
void
registerIDWidget
(
int
id
){
webDownloadIds
.
append
(
id
);}
inline
void
registerIDWidget
(
int
id
){
webDownloadIds
.
append
(
id
);}
inline
bool
takeIDWidget
(
int
id
);
inline
bool
takeIDWidget
(
int
id
);
private
:
private
:
QString
uuid
();
QString
uuid
();
...
...
src/board/UBBoardView.cpp
View file @
a9eb37ce
...
@@ -52,18 +52,6 @@
...
@@ -52,18 +52,6 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
//Known extentions for files, add if you know more supported
const
QString
audioExtentions
=
".mp3.wma.ogg"
;
const
QString
videoExtentions
=
".avi.flv"
;
const
QString
imageExtentions
=
".png.jpg.tif.bmp.tga"
;
const
QString
htmlExtentions
=
".htm.html.xhtml"
;
//Allways use aliases instead of const char* itself
const
QString
imageAlias
=
"image"
;
const
QString
videoAlias
=
"video"
;
const
QString
audioAlias
=
"audio"
;
const
QString
htmlAlias
=
"html"
;
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
QWidget
*
pParent
)
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
QWidget
*
pParent
)
:
QGraphicsView
(
pParent
)
:
QGraphicsView
(
pParent
)
,
mController
(
pController
)
,
mController
(
pController
)
...
@@ -724,11 +712,11 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
...
@@ -724,11 +712,11 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
}
}
}
}
void
UBBoardView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
//
void UBBoardView::dragEnterEvent (QDragEnterEvent *event)
{
//
{
// TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
//
// TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
event
->
acceptProposedAction
();
//
event->acceptProposedAction ();
}
//
}
void
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
void
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
{
...
@@ -738,7 +726,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
...
@@ -738,7 +726,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
if
(
graphicsWidget
)
{
if
(
graphicsWidget
)
{
if
(
graphicsWidget
->
acceptDrops
())
{
if
(
graphicsWidget
->
acceptDrops
())
{
if
(
!
mOkOnWidget
)
{
if
(
!
mOkOnWidget
)
{
if
(
!
isDropableData
(
event
->
mimeData
()))
{
if
(
!
graphicsWidget
->
isDropableData
(
event
->
mimeData
()))
{
mOkOnWidget
=
false
;
mOkOnWidget
=
false
;
event
->
ignore
();
event
->
ignore
();
return
;
return
;
...
@@ -759,48 +747,6 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
...
@@ -759,48 +747,6 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
}
}
}
}
QString
UBBoardView
::
fileExtention
(
const
QString
&
filename
)
const
{
int
pos
=
filename
.
lastIndexOf
(
"."
);
if
(
pos
!=
-
1
)
return
filename
.
right
(
filename
.
size
()
-
pos
);
else
return
QString
();
}
QString
UBBoardView
::
typeForExtention
(
const
QString
&
extention
)
const
{
if
(
extention
.
isEmpty
())
return
QString
();
QString
result
=
QString
();
if
(
audioExtentions
.
contains
(
extention
))
{
result
=
audioAlias
;
}
else
if
(
videoExtentions
.
contains
(
extention
))
{
result
=
videoAlias
;
}
else
if
(
imageExtentions
.
contains
(
extention
))
{
result
=
imageAlias
;
// } else if (htmlExtentions.contains(extention)) {
// result = htmlAlias;
}
return
result
;
}
bool
UBBoardView
::
isDropableData
(
const
QMimeData
*
pMimeData
)
const
{
if
(
pMimeData
->
hasHtml
())
{
return
true
;
}
if
(
pMimeData
->
hasUrls
())
{
if
(
!
typeForExtention
(
fileExtention
(
pMimeData
->
urls
().
at
(
0
).
toLocalFile
())).
isNull
())
{
return
true
;
}
}
return
false
;
}
void
UBBoardView
::
dropEvent
(
QDropEvent
*
event
)
void
UBBoardView
::
dropEvent
(
QDropEvent
*
event
)
{
{
mOkOnWidget
=
false
;
mOkOnWidget
=
false
;
...
...
src/board/UBBoardView.h
View file @
a9eb37ce
...
@@ -65,7 +65,7 @@ class UBBoardView : public QGraphicsView
...
@@ -65,7 +65,7 @@ class UBBoardView : public QGraphicsView
QGraphicsItem
*
items
[],
QGraphicsItem
*
items
[],
const
QStyleOptionGraphicsItem
options
[]);
const
QStyleOptionGraphicsItem
options
[]);
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
//
virtual void dragEnterEvent(QDragEnterEvent * event);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
...
@@ -88,8 +88,6 @@ class UBBoardView : public QGraphicsView
...
@@ -88,8 +88,6 @@ class UBBoardView : public QGraphicsView
}
}
QList
<
QUrl
>
processMimeData
(
const
QMimeData
*
pMimeData
);
QList
<
QUrl
>
processMimeData
(
const
QMimeData
*
pMimeData
);
QString
processMimeData
(
const
QMimeData
*
pMimeData
,
UBGraphicsWidgetItem
*
widget
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
UBBoardController
*
mController
;
UBBoardController
*
mController
;
...
@@ -118,9 +116,6 @@ class UBBoardView : public QGraphicsView
...
@@ -118,9 +116,6 @@ class UBBoardView : public QGraphicsView
bool
mVirtualKeyboardActive
;
bool
mVirtualKeyboardActive
;
bool
mOkOnWidget
;
bool
mOkOnWidget
;
QString
typeForExtention
(
const
QString
&
extention
)
const
;
QString
fileExtention
(
const
QString
&
filename
)
const
;
private
slots
:
private
slots
:
void
settingChanged
(
QVariant
newValue
);
void
settingChanged
(
QVariant
newValue
);
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
a9eb37ce
...
@@ -278,18 +278,14 @@ void UBGraphicsWidgetItem::clearSource()
...
@@ -278,18 +278,14 @@ void UBGraphicsWidgetItem::clearSource()
UBFileSystemUtils
::
deleteFile
(
getSnapshotPath
().
toLocalFile
());
UBFileSystemUtils
::
deleteFile
(
getSnapshotPath
().
toLocalFile
());
}
}
QString
UBGraphicsWidgetItem
::
downloadUrl
(
const
QString
&
fileUrl
,
const
QString
&
extention
)
{
return
mUniboardAPI
->
downloadUrl
(
fileUrl
,
extention
);
}
QString
UBGraphicsWidgetItem
::
downloadWeb
(
const
QString
&
fileUrl
)
{
return
mUniboardAPI
->
downloadWeb
(
fileUrl
);
}
void
UBGraphicsWidgetItem
::
processDropEvent
(
QDropEvent
*
event
)
void
UBGraphicsWidgetItem
::
processDropEvent
(
QDropEvent
*
event
)
{
{
return
mUniboardAPI
->
ProcessDropEvent
(
event
);
return
mUniboardAPI
->
ProcessDropEvent
(
event
);
}
}
bool
UBGraphicsWidgetItem
::
isDropableData
(
const
QMimeData
*
data
)
const
{
return
mUniboardAPI
->
isDropableData
(
data
);
}
UBGraphicsAppleWidgetItem
::
UBGraphicsAppleWidgetItem
(
const
QUrl
&
pWidgetUrl
,
QGraphicsItem
*
parent
)
UBGraphicsAppleWidgetItem
::
UBGraphicsAppleWidgetItem
(
const
QUrl
&
pWidgetUrl
,
QGraphicsItem
*
parent
)
:
UBGraphicsWidgetItem
(
parent
)
:
UBGraphicsWidgetItem
(
parent
)
...
...
src/domain/UBGraphicsWidgetItem.h
View file @
a9eb37ce
...
@@ -70,6 +70,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
...
@@ -70,6 +70,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
QString
downloadUrl
(
const
QString
&
fileUrl
,
const
QString
&
extention
);
QString
downloadUrl
(
const
QString
&
fileUrl
,
const
QString
&
extention
);
QString
downloadWeb
(
const
QString
&
fileUrl
);
QString
downloadWeb
(
const
QString
&
fileUrl
);
void
processDropEvent
(
QDropEvent
*
event
);
void
processDropEvent
(
QDropEvent
*
event
);
bool
isDropableData
(
const
QMimeData
*
data
)
const
;
virtual
void
setOwnFolder
(
const
QUrl
&
newFolder
)
{
ownFolder
=
newFolder
;}
virtual
void
setOwnFolder
(
const
QUrl
&
newFolder
)
{
ownFolder
=
newFolder
;}
virtual
QUrl
getOwnFolder
()
const
{
return
ownFolder
;}
virtual
QUrl
getOwnFolder
()
const
{
return
ownFolder
;}
...
...
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