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
13 years ago
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()
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
)
{
const
QMimeData
*
pMimeData
=
event
->
mimeData
();
...
...
@@ -541,7 +511,6 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
registerIDWidget
(
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
));
// return;
}
}
else
if
(
pMimeData
->
hasUrls
())
{
//Local file processing
...
...
@@ -554,7 +523,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
contentType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
fileName
);
if
(
supportedTypeHeader
(
contentType
))
{
destFileName
=
getObjDir
()
+
QUuid
::
createUuid
().
toString
()
+
extention
;
destFileName
=
getObjDir
()
+
QUuid
::
createUuid
().
toString
()
+
"."
+
extention
;
if
(
!
UBFileSystemUtils
::
copyFile
(
fileName
,
destFileName
))
{
qDebug
()
<<
"can't copy from"
<<
fileName
<<
"to"
<<
destFileName
;
...
...
@@ -625,8 +594,8 @@ void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc de
destFile
.
close
();
//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
);
QApplication
::
sendEvent
(
mGraphicsWidget
->
widgetWebView
(),
&
readm
ove
);
QDragMoveEvent
pseudoM
ove
(
dropPoint
,
desc
.
dropActions
,
&
dropMimeData
,
desc
.
dropMouseButtons
,
desc
.
dropModifiers
);
QApplication
::
sendEvent
(
mGraphicsWidget
->
widgetWebView
(),
&
pseudoM
ove
);
QDropEvent
readyEvent
(
dropPoint
,
desc
.
dropActions
,
&
dropMimeData
,
desc
.
dropMouseButtons
,
desc
.
dropModifiers
);
//sending event to destination either it had been downloaded or not
...
...
@@ -680,6 +649,25 @@ bool UBWidgetUniboardAPI::takeIDWidget(int id)
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
)
:
UBW3CWebStorage
(
graphicsWidget
)
...
...
This diff is collapsed.
Click to expand it.
src/api/UBWidgetUniboardAPI.h
View file @
a9eb37ce
...
...
@@ -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.
* 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
*
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
private
slots
:
void
onDownloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
);
...
...
@@ -257,6 +256,7 @@ private:
inline
void
registerIDWidget
(
int
id
){
webDownloadIds
.
append
(
id
);}
inline
bool
takeIDWidget
(
int
id
);
private
:
QString
uuid
();
...
...
This diff is collapsed.
Click to expand it.
src/board/UBBoardView.cpp
View file @
a9eb37ce
...
...
@@ -52,18 +52,6 @@
#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
)
:
QGraphicsView
(
pParent
)
,
mController
(
pController
)
...
...
@@ -724,11 +712,11 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
}
}
void
UBBoardView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
// TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
event
->
acceptProposedAction
();
}
//
void UBBoardView::dragEnterEvent (QDragEnterEvent *event)
//
{
//
// TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
//
event->acceptProposedAction ();
//
}
void
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
...
...
@@ -738,7 +726,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
if
(
graphicsWidget
)
{
if
(
graphicsWidget
->
acceptDrops
())
{
if
(
!
mOkOnWidget
)
{
if
(
!
isDropableData
(
event
->
mimeData
()))
{
if
(
!
graphicsWidget
->
isDropableData
(
event
->
mimeData
()))
{
mOkOnWidget
=
false
;
event
->
ignore
();
return
;
...
...
@@ -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
)
{
mOkOnWidget
=
false
;
...
...
This diff is collapsed.
Click to expand it.
src/board/UBBoardView.h
View file @
a9eb37ce
...
...
@@ -65,7 +65,7 @@ class UBBoardView : public QGraphicsView
QGraphicsItem
*
items
[],
const
QStyleOptionGraphicsItem
options
[]);
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
//
virtual void dragEnterEvent(QDragEnterEvent * event);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
...
...
@@ -88,8 +88,6 @@ class UBBoardView : public QGraphicsView
}
QList
<
QUrl
>
processMimeData
(
const
QMimeData
*
pMimeData
);
QString
processMimeData
(
const
QMimeData
*
pMimeData
,
UBGraphicsWidgetItem
*
widget
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
UBBoardController
*
mController
;
...
...
@@ -118,9 +116,6 @@ class UBBoardView : public QGraphicsView
bool
mVirtualKeyboardActive
;
bool
mOkOnWidget
;
QString
typeForExtention
(
const
QString
&
extention
)
const
;
QString
fileExtention
(
const
QString
&
filename
)
const
;
private
slots
:
void
settingChanged
(
QVariant
newValue
);
...
...
This diff is collapsed.
Click to expand it.
src/domain/UBGraphicsWidgetItem.cpp
View file @
a9eb37ce
...
...
@@ -278,18 +278,14 @@ void UBGraphicsWidgetItem::clearSource()
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
)
{
return
mUniboardAPI
->
ProcessDropEvent
(
event
);
}
bool
UBGraphicsWidgetItem
::
isDropableData
(
const
QMimeData
*
data
)
const
{
return
mUniboardAPI
->
isDropableData
(
data
);
}
UBGraphicsAppleWidgetItem
::
UBGraphicsAppleWidgetItem
(
const
QUrl
&
pWidgetUrl
,
QGraphicsItem
*
parent
)
:
UBGraphicsWidgetItem
(
parent
)
...
...
This diff is collapsed.
Click to expand it.
src/domain/UBGraphicsWidgetItem.h
View file @
a9eb37ce
...
...
@@ -70,6 +70,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
QString
downloadUrl
(
const
QString
&
fileUrl
,
const
QString
&
extention
);
QString
downloadWeb
(
const
QString
&
fileUrl
);
void
processDropEvent
(
QDropEvent
*
event
);
bool
isDropableData
(
const
QMimeData
*
data
)
const
;
virtual
void
setOwnFolder
(
const
QUrl
&
newFolder
)
{
ownFolder
=
newFolder
;}
virtual
QUrl
getOwnFolder
()
const
{
return
ownFolder
;}
...
...
This diff is collapsed.
Click to expand it.
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