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
ff0abb53
Commit
ff0abb53
authored
Nov 07, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the download manager for the modal files
parent
b422398d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
18 deletions
+69
-18
UBBoardController.cpp
src/board/UBBoardController.cpp
+6
-6
UBLibraryController.cpp
src/board/UBLibraryController.cpp
+5
-5
UBDownloadManager.cpp
src/core/UBDownloadManager.cpp
+47
-3
UBDownloadManager.h
src/core/UBDownloadManager.h
+4
-0
UBDownloadWidget.cpp
src/gui/UBDownloadWidget.cpp
+3
-1
UBHttpGet.cpp
src/network/UBHttpGet.cpp
+3
-2
UBHttpGet.h
src/network/UBHttpGet.h
+1
-1
No files found.
src/board/UBBoardController.cpp
View file @
ff0abb53
...
...
@@ -767,13 +767,13 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
desc
.
isBackground
=
isBackground
;
// INFO: DO NOT UNCOMMENT THE NEXT LINE! DEVELOPMENT IN PROGRESS
//
UBDownloadManager::downloadManager()->addFileToDownload(desc);
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
);
UBHttpGet
*
http
=
new
UBHttpGet
(
mActiveScene
);
showMessage
(
tr
(
"Downloading content from %1"
).
arg
(
url
.
toString
()),
true
);
connect
(
http
,
SIGNAL
(
downloadFinished
(
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)),
this
,
SLOT
(
downloadFinished
(
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)));
http
->
get
(
url
,
pPos
,
pSize
,
isBackground
);
//
UBHttpGet *http = new UBHttpGet(mActiveScene);
//
showMessage(tr("Downloading content from %1").arg(url.toString()), true);
//
connect(http, SIGNAL(downloadFinished(bool, QUrl, QString, QByteArray, QPointF, QSize, bool)),
//
this, SLOT(downloadFinished(bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
//
http->get(url, pPos, pSize, isBackground);
}
}
...
...
src/board/UBLibraryController.cpp
View file @
ff0abb53
...
...
@@ -239,11 +239,11 @@ QList<UBLibElement*> UBLibraryController::rootCategoriesList()
categories
<<
element
;
// Note : FEATURE IN DEVELOPMENT, DO NOT ERASE (or you will get problems) !!!!
//
mSearchCategoryPath = QUrl::fromLocalFile(UBSettings::settings()->uniboardSearchDirectory());
//
element = new UBLibElement(eUBLibElementType_Folder, mSearchCategoryPath, tr("Web Search", "Web search category element"));
//
element->setThumbnail(QImage(":images/libpalette/WebSearchCategory.svg"));
//
element->setMoveable(false);
//
categories << element;
mSearchCategoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
uniboardSearchDirectory
());
element
=
new
UBLibElement
(
eUBLibElementType_Folder
,
mSearchCategoryPath
,
tr
(
"Web Search"
,
"Web search category element"
));
element
->
setThumbnail
(
QImage
(
":images/libpalette/WebSearchCategory.svg"
));
element
->
setMoveable
(
false
);
categories
<<
element
;
element
=
new
UBLibElement
(
eUBLibElementType_Folder
,
mAnimationUserDirectoryPath
,
tr
(
"Animations"
,
"Animations category element"
));
element
->
setThumbnail
(
QImage
(
":images/libpalette/FlashCategory.svg"
));
...
...
src/core/UBDownloadManager.cpp
View file @
ff0abb53
...
...
@@ -84,7 +84,9 @@ void UBDownloadManager::init()
{
mCrntDL
.
clear
();
mPendingDL
.
clear
();
mReplies
.
clear
();
mLastID
=
1
;
mDLAvailability
.
clear
();
for
(
int
i
=
0
;
i
<
SIMULTANEOUS_DOWNLOAD
;
i
++
)
{
mDLAvailability
.
append
(
-
1
);
...
...
@@ -228,6 +230,9 @@ void UBDownloadManager::updateFileCurrentSize(int id, qint64 received, qint64 to
// Remove the finished file from the current download list
mCrntDL
.
remove
(
i
);
// Here we don't forget to remove the reply related to the finished download
mReplies
.
remove
(
id
);
// Free the download slot used by the finished file
for
(
int
j
=
0
;
j
<
mDLAvailability
.
size
();
j
++
)
{
...
...
@@ -265,7 +270,9 @@ void UBDownloadManager::startFileDownload(sDownloadFileDesc desc)
UBDownloadHttpFile
*
http
=
new
UBDownloadHttpFile
(
desc
.
id
,
this
);
connect
(
http
,
SIGNAL
(
downloadProgress
(
int
,
qint64
,
qint64
)),
this
,
SLOT
(
onDownloadProgress
(
int
,
qint64
,
qint64
)));
connect
(
http
,
SIGNAL
(
downloadFinished
(
int
,
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)),
this
,
SLOT
(
onDownloadFinished
(
int
,
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)));
http
->
get
(
QUrl
(
desc
.
url
));
// We send here the request and store its reply in order to be able to cancel it if needed
mReplies
[
desc
.
id
]
=
http
->
get
(
QUrl
(
desc
.
url
));
}
/**
...
...
@@ -295,7 +302,7 @@ void UBDownloadManager::checkIfModalRemains()
}
}
if
(
bModal
)
if
(
bModal
||
(
mCrntDL
.
empty
()
&&
mPendingDL
.
empty
())
)
{
// Close the modal window
UBApplication
::
mainWindow
->
hideDownloadWidget
();
...
...
@@ -311,12 +318,40 @@ void UBDownloadManager::checkIfModalRemains()
void
UBDownloadManager
::
cancelDownloads
()
{
// Stop the current downloads
QMap
<
int
,
QNetworkReply
*>::
iterator
it
=
mReplies
.
begin
();
for
(;
it
!=
mReplies
.
end
();
it
++
)
{
dynamic_cast
<
QNetworkReply
*>
(
it
.
value
())
->
abort
();
}
// Clear all the lists
init
();
checkIfModalRemains
();
// Notify everyone that the downloads have been canceled.
emit
cancelAllDownloads
();
}
void
UBDownloadManager
::
onDownloadError
(
int
id
)
{
QNetworkReply
*
pReply
=
mReplies
.
value
(
id
);
if
(
NULL
!=
pReply
)
{
// Check which error occured:
switch
(
pReply
->
error
())
{
case
QNetworkReply
:
:
OperationCanceledError
:
// For futur developments: do something in case of download aborting (message? remove the download?)
break
;
default
:
// Check the documentation of QNetworkReply in Qt Assistant for the different error cases
break
;
}
}
}
// ------------------------------------------------------------------------------
/**
* \brief Constructor
...
...
@@ -361,6 +396,15 @@ void UBDownloadHttpFile::onDownloadProgress(qint64 bytesReceived, qint64 bytesTo
*/
void
UBDownloadHttpFile
::
onDownloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
{
emit
downloadFinished
(
mId
,
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
,
pPos
,
pSize
,
isBackground
);
if
(
pSuccess
)
{
// Notify the end of the download
emit
downloadFinished
(
mId
,
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
,
pPos
,
pSize
,
isBackground
);
}
else
{
// Notify the fact that and error occured during the download
emit
downloadError
(
mId
);
}
}
src/core/UBDownloadManager.h
View file @
ff0abb53
...
...
@@ -49,6 +49,7 @@ public:
signals
:
void
downloadProgress
(
int
id
,
qint64
current
,
qint64
total
);
void
downloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
downloadError
(
int
id
);
private
slots
:
void
onDownloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
...
...
@@ -83,6 +84,7 @@ private slots:
void
onUpdateDownloadLists
();
void
onDownloadProgress
(
int
id
,
qint64
received
,
qint64
total
);
void
onDownloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
onDownloadError
(
int
id
);
private
:
void
init
();
...
...
@@ -101,6 +103,8 @@ private:
int
mLastID
;
/** The current download availability (-1 = free, otherwise the file ID is recorded)*/
QVector
<
int
>
mDLAvailability
;
/** A map containing the replies of the GET operations */
QMap
<
int
,
QNetworkReply
*>
mReplies
;
};
#endif // UBDOWNLOADMANAGER_H
src/gui/UBDownloadWidget.cpp
View file @
ff0abb53
...
...
@@ -109,6 +109,7 @@ void UBDownloadWidget::onFileAddedToDownload()
void
UBDownloadWidget
::
addCurrentDownloads
()
{
QVector
<
sDownloadFileDesc
>
actualDL
=
UBDownloadManager
::
downloadManager
()
->
currentDownloads
();
qDebug
()
<<
"Actual downloads size: "
<<
actualDL
.
size
();
for
(
int
i
=
0
;
i
<
actualDL
.
size
();
i
++
)
{
mpItem
=
new
QTreeWidgetItem
(
mpTree
);
...
...
@@ -130,6 +131,7 @@ void UBDownloadWidget::addCurrentDownloads()
void
UBDownloadWidget
::
addPendingDownloads
()
{
QVector
<
sDownloadFileDesc
>
pendingDL
=
UBDownloadManager
::
downloadManager
()
->
pendingDownloads
();
qDebug
()
<<
"Pending downloads size: "
<<
pendingDL
.
size
();
for
(
int
i
=
0
;
i
<
pendingDL
.
size
();
i
++
)
{
mpItem
=
new
QTreeWidgetItem
(
mpTree
);
...
...
@@ -182,7 +184,7 @@ void UBDownloadWidget::onDownloadFinished(int id)
*/
void
UBDownloadWidget
::
onCancelClicked
()
{
UBDownloadManager
::
downloadManager
()
->
cancelDownloads
();
}
// ---------------------------------------------------------------------------------------------
...
...
src/network/UBHttpGet.cpp
View file @
ff0abb53
...
...
@@ -43,7 +43,7 @@ UBHttpGet::~UBHttpGet()
}
void
UBHttpGet
::
get
(
QUrl
pUrl
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
QNetworkReply
*
UBHttpGet
::
get
(
QUrl
pUrl
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
{
mPos
=
pPos
;
mSize
=
pSize
;
...
...
@@ -61,6 +61,7 @@ void UBHttpGet::get(QUrl pUrl, QPointF pPos, QSize pSize, bool isBackground)
connect
(
mReply
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readyRead
()));
connect
(
mReply
,
SIGNAL
(
downloadProgress
(
qint64
,
qint64
)),
this
,
SLOT
(
downloadProgressed
(
qint64
,
qint64
)));
return
mReply
;
}
...
...
@@ -111,7 +112,7 @@ void UBHttpGet::requestFinished()
void
UBHttpGet
::
downloadProgressed
(
qint64
bytesReceived
,
qint64
bytesTotal
)
{
qDebug
()
<<
"received: "
<<
bytesReceived
<<
", / "
<<
bytesTotal
<<
" bytes"
;
//
qDebug() << "received: " << bytesReceived << ", / " << bytesTotal << " bytes";
if
(
-
1
!=
bytesTotal
)
{
emit
downloadProgress
(
bytesReceived
,
bytesTotal
);
...
...
src/network/UBHttpGet.h
View file @
ff0abb53
...
...
@@ -29,7 +29,7 @@ class UBHttpGet : public QObject
UBHttpGet
(
QObject
*
parent
=
0
);
virtual
~
UBHttpGet
();
void
get
(
QUrl
pUrl
,
QPointF
pPoint
=
QPointF
(
0
,
0
),
QSize
pSize
=
QSize
(
0
,
0
),
bool
isBackground
=
false
);
QNetworkReply
*
get
(
QUrl
pUrl
,
QPointF
pPoint
=
QPointF
(
0
,
0
),
QSize
pSize
=
QSize
(
0
,
0
),
bool
isBackground
=
false
);
signals
:
...
...
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