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
6fa9930b
Commit
6fa9930b
authored
Nov 10, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Supported drag and drop in the library from Firefox and Chrome
parent
0898bc53
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
71 additions
and
11 deletions
+71
-11
UBLibraryController.cpp
src/board/UBLibraryController.cpp
+20
-2
UBLibraryController.h
src/board/UBLibraryController.h
+1
-1
UBApplication.cpp
src/core/UBApplication.cpp
+2
-3
UBDownloadManager.cpp
src/core/UBDownloadManager.cpp
+10
-0
UBDownloadManager.h
src/core/UBDownloadManager.h
+1
-0
UBLibraryWidget.cpp
src/gui/UBLibraryWidget.cpp
+32
-1
UBLibraryWidget.h
src/gui/UBLibraryWidget.h
+2
-0
UBNetworkAccessManager.cpp
src/network/UBNetworkAccessManager.cpp
+3
-4
No files found.
src/board/UBLibraryController.cpp
View file @
6fa9930b
...
...
@@ -23,6 +23,7 @@
#include "core/UBSettings.h"
#include "core/UBSetting.h"
#include "core/UBApplicationController.h"
#include "core/UBDownloadManager.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsScene.h"
...
...
@@ -110,7 +111,6 @@ void UBLibraryController::createDirectory(QUrl& pDirPath)
void
UBLibraryController
::
routeItem
(
QString
&
pItem
,
QString
pMiddleDirectory
)
{
qDebug
()
<<
"routeItem: "
<<
pItem
;
QFileInfo
itemToRoute
(
pItem
);
QString
mimetype
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
itemToRoute
.
fileName
());
QString
destination
(
""
);
...
...
@@ -138,6 +138,7 @@ void UBLibraryController::routeItem(QString& pItem, QString pMiddleDirectory)
createDirectory
(
url
);
}
destination
=
UBFileSystemUtils
::
normalizeFilePath
(
destination
+
"/"
+
itemToRoute
.
fileName
());
QFile
::
copy
(
pItem
,
destination
);
}
}
...
...
@@ -187,7 +188,24 @@ void UBLibraryController::importItemOnLibrary(QString& pItemString)
}
}
else
{
routeItem
(
pItemString
);
if
(
pItemString
.
startsWith
(
"uniboardTool://"
)
||
pItemString
.
startsWith
(
"file://"
)
||
pItemString
.
startsWith
(
"/"
))
{
// The user dropped a local file
routeItem
(
pItemString
);
}
else
{
// The user dropped a file from the web. We must download it.
sDownloadFileDesc
desc
;
desc
.
currentSize
=
0
;
desc
.
id
=
0
;
desc
.
isBackground
=
false
;
desc
.
modal
=
false
;
desc
.
name
=
QFileInfo
(
pItemString
).
fileName
();
desc
.
totalSize
=
0
;
desc
.
url
=
pItemString
;
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
);
}
}
}
...
...
src/board/UBLibraryController.h
View file @
6fa9930b
...
...
@@ -120,6 +120,7 @@ class UBLibraryController : public QObject
void
createNewFolder
(
QString
name
,
UBLibElement
*
parentElem
);
bool
canItemsOnElementBeDeleted
(
UBLibElement
*
pElement
);
void
routeItem
(
QString
&
pItem
,
QString
pMiddleDirectory
=
QString
());
signals
:
void
dialogClosed
(
int
state
);
...
...
@@ -153,7 +154,6 @@ class UBLibraryController : public QObject
QList
<
UBLibElement
*>
addVirtualElementsForItemPath
(
const
QString
&
pPath
);
void
createInternalWidgetItems
();
void
routeItem
(
QString
&
pItem
,
QString
pMiddleDirectory
=
QString
());
void
createDirectory
(
QUrl
&
pDirPath
);
QUrl
mAudioStandardDirectoryPath
;
...
...
src/core/UBApplication.cpp
View file @
6fa9930b
...
...
@@ -633,15 +633,14 @@ QString UBApplication::globalStyleSheet()
QString
UBApplication
::
urlFromHtml
(
QString
html
)
{
qDebug
()
<<
"HTML: "
<<
html
.
remove
(
QRegExp
(
"[
\\
0]"
));
QString
url
;
QDomDocument
domDoc
;
domDoc
.
setContent
(
html
);
domDoc
.
setContent
(
html
.
remove
(
QRegExp
(
"[
\\
0]"
))
);
QDomElement
rootElem
=
domDoc
.
documentElement
();
url
=
rootElem
.
attribute
(
"src"
);
qDebug
()
<<
url
;
return
url
;
}
src/core/UBDownloadManager.cpp
View file @
6fa9930b
...
...
@@ -15,6 +15,8 @@
#include "UBDownloadManager.h"
#include "core/UBApplication.h"
#include "gui/UBMainWindow.h"
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
/** The unique instance of the download manager */
static
UBDownloadManager
*
pInstance
=
NULL
;
...
...
@@ -73,6 +75,10 @@ void UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
updateDownloadOrder
();
UBApplication
::
mainWindow
->
showDownloadWidget
();
}
else
{
UBApplication
::
boardController
->
paletteManager
()
->
startDownloads
();
}
emit
fileAddedToDownload
();
}
...
...
@@ -190,6 +196,10 @@ void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl
// 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
;
}
}
...
...
src/core/UBDownloadManager.h
View file @
6fa9930b
...
...
@@ -78,6 +78,7 @@ signals:
void
downloadFinished
(
int
id
);
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
);
void
cancelAllDownloads
();
void
allDownloadsFinished
();
...
...
src/gui/UBLibraryWidget.cpp
View file @
6fa9930b
...
...
@@ -14,6 +14,7 @@
*/
#include <QList>
#include <QFileInfo>
#include <QDir>
#include "UBLibraryWidget.h"
#include "core/UBSettings.h"
...
...
@@ -24,6 +25,7 @@
#include "board/UBLibraryController.h"
#include "core/memcheck.h"
#include "core/UBDownloadManager.h"
#include "frameworks/UBFileSystemUtils.h"
...
...
@@ -87,6 +89,7 @@ void UBLibraryWidget::init()
connect
(
this
,
SIGNAL
(
mouseClick
(
QGraphicsItem
*
,
int
)),
this
,
SLOT
(
onItemClicked
(
QGraphicsItem
*
,
int
)));
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
onSelectionChanged
()));
connect
(
UBDownloadManager
::
downloadManager
(),
SIGNAL
(
addDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)),
this
,
SLOT
(
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)));
}
/**
...
...
@@ -362,7 +365,14 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
}
else
if
(
pMimeData
->
hasHtml
())
{
qDebug
()
<<
"hasHtml Unsupported yet"
;
qDebug
()
<<
"hasHtml"
;
QString
html
=
pMimeData
->
html
();
QString
url
=
UBApplication
::
urlFromHtml
(
html
);
if
(
""
!=
url
)
{
mLibraryController
->
importItemOnLibrary
(
url
);
bDropAccepted
=
true
;
}
}
else
if
(
pMimeData
->
hasText
())
{
...
...
@@ -666,3 +676,24 @@ void UBNewFolderDlg::text_Edited(const QString &newText)
QToolTip
::
showText
(
mpLineEdit
->
mapToGlobal
(
QPoint
()),
"A file name can`t contain any of the following characters:
\r\n
"
+
illegalCharList
);
}
}
void
UBLibraryWidget
::
onAddDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentHeader
,
QByteArray
pData
)
{
Q_UNUSED
(
pContentHeader
);
if
(
pSuccess
)
{
QDir
dir
;
dir
.
mkdir
(
"tmp"
);
QString
qsFileName
=
QFileInfo
(
sourceUrl
.
toString
()).
fileName
();
QString
qsFilePath
=
UBFileSystemUtils
::
normalizeFilePath
(
QString
(
"tmp/%0"
).
arg
(
qsFileName
));
QFile
f
(
qsFilePath
);
if
(
f
.
open
(
QIODevice
::
WriteOnly
))
{
f
.
write
(
pData
);
f
.
close
();
}
mLibraryController
->
routeItem
(
qsFilePath
);
dir
.
remove
(
qsFileName
);
dir
.
rmdir
(
"tmp"
);
// Due to Qt, the directoy will be removed only if it's empty :)
}
}
src/gui/UBLibraryWidget.h
View file @
6fa9930b
...
...
@@ -55,6 +55,8 @@ public slots:
void
onSearchElement
(
QString
elem
);
void
onNewFolderToCreate
();
void
onDropMe
(
const
QMimeData
*
_data
);
void
onAddDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentHeader
,
QByteArray
pData
);
signals
:
void
navigBarUpdate
(
UBLibElement
*
pElem
);
void
itemsSelected
(
QList
<
UBLibElement
*>
elemList
,
bool
inTrash
);
...
...
src/network/UBNetworkAccessManager.cpp
View file @
6fa9930b
...
...
@@ -84,11 +84,10 @@ QNetworkReply* UBNetworkAccessManager::createRequest(Operation op, const QNetwor
QNetworkReply
*
UBNetworkAccessManager
::
get
(
const
QNetworkRequest
&
request
)
{
qDebug
()
<<
"request url: "
<<
request
.
url
();
QTime
loadStartTime
;
QTime
loadStartTime
;
loadStartTime
.
start
();
QNetworkReply
*
networkReply
=
QNetworkAccessManager
::
get
(
request
);
return
networkReply
;
QNetworkReply
*
networkReply
=
QNetworkAccessManager
::
get
(
request
);
return
networkReply
;
}
void
UBNetworkAccessManager
::
authenticationRequired
(
QNetworkReply
*
reply
,
QAuthenticator
*
auth
)
...
...
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