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
3fed7dc8
Commit
3fed7dc8
authored
Jan 31, 2012
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some changes for sDownloadFileDesc
parent
4a051f2a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
122 additions
and
33 deletions
+122
-33
UBWidgetUniboardAPI.cpp
src/api/UBWidgetUniboardAPI.cpp
+19
-0
UBWidgetUniboardAPI.h
src/api/UBWidgetUniboardAPI.h
+15
-1
UBBoardView.cpp
src/board/UBBoardView.cpp
+27
-4
UBBoardView.h
src/board/UBBoardView.h
+3
-3
UBDownloadManager.cpp
src/core/UBDownloadManager.cpp
+26
-18
UBDownloadManager.h
src/core/UBDownloadManager.h
+24
-3
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+4
-0
UBGraphicsWidgetItem.h
src/domain/UBGraphicsWidgetItem.h
+2
-1
UBHttpGet.cpp
src/network/UBHttpGet.cpp
+2
-2
pdfMerger.pri
src/pdf-merger/pdfMerger.pri
+0
-1
No files found.
src/api/UBWidgetUniboardAPI.cpp
View file @
3fed7dc8
...
...
@@ -55,6 +55,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
mMessagesAPI
=
new
UBWidgetMessageAPI
(
w3CGraphicsWidget
->
w3cWidget
());
mDatastoreAPI
=
new
UBDatastoreAPI
(
w3CGraphicsWidget
);
}
connect
(
UBDownloadManager
::
downloadManager
(),
SIGNAL
(
downloadFinished
(
bool
,
int
,
QUrl
,
QString
,
QByteArray
)),
this
,
SLOT
(
onDownloadFinished
(
bool
,
int
,
QUrl
,
QString
,
QByteArray
)));
}
...
...
@@ -451,7 +452,25 @@ QString UBWidgetUniboardAPI::downloadUrl(const QString &objectUrl, const 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
.
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
::
onDownloadFinished
(
bool
pSuccess
,
int
id
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
)
{
Q_UNUSED
(
pData
)
qDebug
()
<<
"got an ID"
<<
id
<<
pSuccess
<<
sourceUrl
<<
pContentTypeHeader
;
}
UBDocumentDatastoreAPI
::
UBDocumentDatastoreAPI
(
UBGraphicsW3CWidgetItem
*
graphicsWidget
)
:
UBW3CWebStorage
(
graphicsWidget
)
...
...
src/api/UBWidgetUniboardAPI.h
View file @
3fed7dc8
...
...
@@ -245,6 +245,20 @@ class UBWidgetUniboardAPI : public QObject
* 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
);
private
slots
:
void
onDownloadFinished
(
bool
pSuccess
,
int
id
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
private
:
inline
void
registerIDWidget
(
int
id
){
webDownloadIds
.
append
(
id
);}
inline
bool
expectedID
(
int
id
)
const
{
return
webDownloadIds
.
contains
(
id
);}
inline
bool
removeID
(
int
id
)
{
return
webDownloadIds
.
removeAll
(
id
);}
// void unregister
private
:
...
...
@@ -265,7 +279,7 @@ class UBWidgetUniboardAPI : public QObject
UBWidgetMessageAPI
*
mMessagesAPI
;
UBDatastoreAPI
*
mDatastoreAPI
;
QList
<
int
>
webDownloadIds
;
};
...
...
src/board/UBBoardView.cpp
View file @
3fed7dc8
...
...
@@ -66,6 +66,7 @@ const QString htmlAlias = "html";
const
QString
tMainSection
=
"mimedata"
;
const
QString
tType
=
"type"
;
const
QString
tPath
=
"path"
;
const
QString
tMessage
=
"message"
;
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
QWidget
*
pParent
)
:
QGraphicsView
(
pParent
)
...
...
@@ -771,6 +772,24 @@ QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidge
writer
.
writeStartDocument
();
writer
.
writeStartElement
(
tMainSection
);
if
(
pMimeData
->
hasHtml
())
{
QList
<
QUrl
>
urls
=
pMimeData
->
urls
();
int
index
=
0
;
foreach
(
const
QUrl
url
,
urls
)
{
// QPointF pos(pPos + QPointF(index * 15, index * 15));
// downloadURL(url, pos);
widget
->
downloadWeb
(
url
.
toString
());
index
++
;
}
writer
.
writeTextElement
(
tMessage
,
"Downloading content process..."
);
writer
.
writeEndElement
();
writer
.
writeEndDocument
();
return
mimeXml
;
}
if
(
pMimeData
->
hasUrls
())
{
QList
<
QUrl
>
urls
=
pMimeData
->
urls
();
...
...
@@ -806,7 +825,7 @@ QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidge
return
mimeXml
;
}
QString
UBBoardView
::
fileExtention
(
const
QString
&
filename
)
QString
UBBoardView
::
fileExtention
(
const
QString
&
filename
)
const
{
int
pos
=
filename
.
lastIndexOf
(
"."
);
if
(
pos
!=
-
1
)
...
...
@@ -814,7 +833,7 @@ QString UBBoardView::fileExtention(const QString &filename)
else
return
QString
();
}
QString
UBBoardView
::
typeForExtention
(
const
QString
&
extention
)
QString
UBBoardView
::
typeForExtention
(
const
QString
&
extention
)
const
{
if
(
extention
.
isEmpty
())
return
QString
();
...
...
@@ -833,8 +852,12 @@ QString UBBoardView::typeForExtention(const QString &extention)
return
result
;
}
bool
UBBoardView
::
isDropableData
(
const
QMimeData
*
pMimeData
)
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
;
...
...
@@ -850,7 +873,7 @@ void UBBoardView::dropEvent (QDropEvent *event)
QGraphicsItem
*
graphicsItemAtPos
=
itemAt
(
event
->
pos
().
x
(),
event
->
pos
().
y
());
UBGraphicsWidgetItem
*
graphicsWidget
=
dynamic_cast
<
UBGraphicsWidgetItem
*>
(
graphicsItemAtPos
);
if
(
graphicsWidget
&&
graphicsWidget
->
acceptDrops
()){
if
(
graphicsWidget
&&
graphicsWidget
->
acceptDrops
())
{
// A new event is build to avoid problem related to different way to pass the mime type
// A parsing is done to try to provide a mimeType with only urls.
QMimeData
mimeData
;
...
...
src/board/UBBoardView.h
View file @
3fed7dc8
...
...
@@ -89,7 +89,7 @@ class UBBoardView : public QGraphicsView
QList
<
QUrl
>
processMimeData
(
const
QMimeData
*
pMimeData
);
QString
processMimeData
(
const
QMimeData
*
pMimeData
,
UBGraphicsWidgetItem
*
widget
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
);
bool
isDropableData
(
const
QMimeData
*
pMimeData
)
const
;
UBBoardController
*
mController
;
...
...
@@ -118,8 +118,8 @@ class UBBoardView : public QGraphicsView
bool
mVirtualKeyboardActive
;
bool
mOkOnWidget
;
QString
typeForExtention
(
const
QString
&
extention
);
QString
fileExtention
(
const
QString
&
filename
);
QString
typeForExtention
(
const
QString
&
extention
)
const
;
QString
fileExtention
(
const
QString
&
filename
)
const
;
private
slots
:
...
...
src/core/UBDownloadManager.cpp
View file @
3fed7dc8
...
...
@@ -70,7 +70,7 @@ void UBDownloadManager::destroy()
* \brief Add a file to the download list
* @param desc as the given file description
*/
void
UBDownloadManager
::
addFileToDownload
(
sDownloadFileDesc
desc
)
int
UBDownloadManager
::
addFileToDownload
(
sDownloadFileDesc
desc
)
{
// Set the ID for this download
desc
.
id
=
mLastID
;
...
...
@@ -89,6 +89,8 @@ void UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
UBApplication
::
boardController
->
paletteManager
()
->
startDownloads
();
emit
fileAddedToDownload
();
return
desc
.
id
;
}
/**
...
...
@@ -194,23 +196,29 @@ void UBDownloadManager::onDownloadProgress(int id, qint64 received, qint64 total
*/
void
UBDownloadManager
::
onDownloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
{
for
(
int
i
=
0
;
i
<
mCrntDL
.
size
();
i
++
)
{
sDownloadFileDesc
desc
=
mCrntDL
.
at
(
i
);
if
(
id
==
desc
.
id
)
{
if
(
desc
.
modal
)
{
// The downloaded file is modal so we must put it on the board
emit
addDownloadedFileToBoard
(
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
,
pPos
,
pSize
,
isBackground
);
}
else
{
emit
addDownloadedFileToLibrary
(
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
);
}
break
;
}
}
// Temporary data for dnd do not delete it please
Q_UNUSED
(
pPos
)
Q_UNUSED
(
pSize
)
Q_UNUSED
(
isBackground
)
emit
downloadFinished
(
pSuccess
,
id
,
sourceUrl
,
pContentTypeHeader
,
pData
);
// for(int i=0; i<mCrntDL.size(); i++)
// {
// sDownloadFileDesc desc = mCrntDL.at(i);
// if(id == desc.id)
// {
// if(desc.modal)
// {
// // The downloaded file is modal so we must put it on the board
// emit addDownloadedFileToBoard(pSuccess, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
// }
// else
// {
// emit addDownloadedFileToLibrary(pSuccess, sourceUrl, pContentTypeHeader, pData);
// }
// break;
// }
// }
// Then do this
updateFileCurrentSize
(
id
);
...
...
src/core/UBDownloadManager.h
View file @
3fed7dc8
...
...
@@ -19,6 +19,7 @@
#include <QString>
#include <QVector>
#include <QMutex>
#include <QDropEvent>
#include "UBDownloadThread.h"
...
...
@@ -26,8 +27,26 @@
#define SIMULTANEOUS_DOWNLOAD 2 // Maximum 5 because of QNetworkAccessManager limitation!!!
typedef
struct
enum
eDestinations
{
board
//default for sDownloadFileDesc
,
library
,
graphicsWidget
};
struct
sDownloadFileDesc
{
//creating constructor to make sure to have default values
sDownloadFileDesc
()
:
dest
(
board
)
,
id
(
0
)
,
totalSize
(
0
)
,
currentSize
(
0
)
,
modal
(
false
)
,
isBackground
(
false
)
,
widgetDrop
(
0
)
{;}
eDestinations
dest
;
QString
name
;
int
id
;
int
totalSize
;
...
...
@@ -37,7 +56,8 @@ typedef struct
QPointF
pos
;
// For board drop only
QSize
size
;
// For board drop only
bool
isBackground
;
// For board drop only
}
sDownloadFileDesc
;
QDropEvent
*
widgetDrop
;
//For widget's drops
};
class
UBDownloadHttpFile
:
public
UBHttpGet
{
...
...
@@ -66,7 +86,7 @@ public:
UBDownloadManager
(
QObject
*
parent
=
0
,
const
char
*
name
=
"UBDownloadManager"
);
~
UBDownloadManager
();
static
UBDownloadManager
*
downloadManager
();
void
addFileToDownload
(
sDownloadFileDesc
desc
);
int
addFileToDownload
(
sDownloadFileDesc
desc
);
QVector
<
sDownloadFileDesc
>
currentDownloads
();
QVector
<
sDownloadFileDesc
>
pendingDownloads
();
void
cancelDownloads
();
...
...
@@ -78,6 +98,7 @@ signals:
void
fileAddedToDownload
();
void
downloadUpdated
(
int
id
,
qint64
crnt
,
qint64
total
);
void
downloadFinished
(
int
id
);
void
downloadFinished
(
bool
pSuccess
,
int
id
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
void
downloadModalFinished
();
void
addDownloadedFileToBoard
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
addDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
3fed7dc8
...
...
@@ -258,6 +258,10 @@ QString UBGraphicsWidgetItem::downloadUrl(const QString &fileUrl, const QString
{
return
mUniboardAPI
->
downloadUrl
(
fileUrl
,
extention
);
}
QString
UBGraphicsWidgetItem
::
downloadWeb
(
const
QString
&
fileUrl
)
{
return
mUniboardAPI
->
downloadWeb
(
fileUrl
);
}
UBGraphicsAppleWidgetItem
::
UBGraphicsAppleWidgetItem
(
const
QUrl
&
pWidgetUrl
,
QGraphicsItem
*
parent
)
:
UBGraphicsWidgetItem
(
parent
)
...
...
src/domain/UBGraphicsWidgetItem.h
View file @
3fed7dc8
...
...
@@ -62,11 +62,12 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
QMap
<
QString
,
QString
>
datastoreEntries
()
const
;
void
removeDatastoreEntry
(
const
QString
&
key
);
void
removeAllDatastoreEntries
();
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;
}
virtual
void
remove
();
void
removeScript
();
QString
downloadUrl
(
const
QString
&
fileUrl
,
const
QString
&
extention
);
QString
downloadWeb
(
const
QString
&
fileUrl
);
virtual
void
setOwnFolder
(
const
QUrl
&
newFolder
)
{
ownFolder
=
newFolder
;}
virtual
QUrl
getOwnFolder
()
const
{
return
ownFolder
;}
...
...
src/network/UBHttpGet.cpp
View file @
3fed7dc8
...
...
@@ -49,8 +49,8 @@ QNetworkReply* UBHttpGet::get(QUrl pUrl, QPointF pPos, QSize pSize, bool isBackg
mSize
=
pSize
;
mIsBackground
=
isBackground
;
if
(
mReply
)
delete
mReply
;
if
(
mReply
)
delete
mReply
;
UBNetworkAccessManager
*
nam
=
UBNetworkAccessManager
::
defaultAccessManager
();
mReply
=
nam
->
get
(
QNetworkRequest
(
pUrl
));
//mReply deleted by this destructor
...
...
src/pdf-merger/pdfMerger.pri
View file @
3fed7dc8
...
...
@@ -58,7 +58,6 @@ SOURCES += \
macx {
LIBS += -lz
}
...
...
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