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
65dfcec7
Commit
65dfcec7
authored
Oct 11, 2012
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Names of downloaded content
parent
9efb2695
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
44 deletions
+117
-44
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+105
-34
UBFeaturesController.h
src/board/UBFeaturesController.h
+4
-1
UBDownloadManager.cpp
src/core/UBDownloadManager.cpp
+1
-1
UBDownloadManager.h
src/core/UBDownloadManager.h
+1
-1
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+5
-6
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+1
-1
No files found.
src/board/UBFeaturesController.cpp
View file @
65dfcec7
...
...
@@ -485,6 +485,71 @@ void UBFeaturesController::saveFavoriteList()
file
.
close
();
}
QString
UBFeaturesController
::
uniqNameForFeature
(
const
UBFeature
&
feature
,
const
QString
&
pName
,
const
QString
&
pExtention
)
const
{
Q_ASSERT
(
featuresList
);
QStringList
resultList
;
QString
parentVirtualPath
=
feature
.
getFullVirtualPath
();
QString
resultName
;
qDebug
()
<<
"start"
;
foreach
(
UBFeature
curFeature
,
*
featuresList
)
{
if
(
curFeature
.
getFullVirtualPath
().
startsWith
(
feature
.
getFullVirtualPath
()))
{
QString
curResultName
=
curFeature
.
getFullVirtualPath
();
if
(
!
parentVirtualPath
.
endsWith
(
"/"
))
{
parentVirtualPath
.
append
(
"/"
);
}
//Cut virtual path prevfix
int
i
=
curResultName
.
indexOf
(
feature
.
getFullVirtualPath
());
if
(
i
!=
-
1
)
{
curResultName
=
curResultName
.
right
(
curFeature
.
getFullVirtualPath
().
count
()
-
i
-
parentVirtualPath
.
count
());
}
//if directory has children, emptying the name;
i
=
curResultName
.
indexOf
(
"/"
);
if
(
i
!=
-
1
)
{
curResultName
=
""
;
}
if
(
!
curResultName
.
isEmpty
())
{
resultList
.
append
(
curResultName
);
}
qDebug
()
<<
curResultName
;
}
}
if
(
!
resultList
.
contains
(
pName
+
pExtention
,
Qt
::
CaseInsensitive
))
{
resultName
=
pName
+
pExtention
;
}
else
{
for
(
int
i
=
0
;
i
<
16777215
;
i
++
)
{
QString
probeName
=
pName
+
"_"
+
QString
::
number
(
i
)
+
pExtention
;
if
(
!
resultList
.
contains
(
probeName
,
Qt
::
CaseInsensitive
))
{
resultName
=
probeName
;
break
;
}
}
}
qDebug
()
<<
"result name is "
<<
resultName
;
return
resultName
;
}
QString
UBFeaturesController
::
adjustName
(
const
QString
&
str
)
{
if
(
str
.
isNull
())
{
return
QString
();
}
QString
resultStr
=
str
;
QRegExp
invalidSymbols
(
"[
\\
/
\\
s
\\
:
\\
?
\\
*
\\
|
\\
<
\\
>
\\\"
]+"
);
return
resultStr
.
replace
(
invalidSymbols
,
"_"
);
}
void
UBFeaturesController
::
addToFavorite
(
const
QUrl
&
path
)
{
QString
filePath
=
fileNameFromUrl
(
path
);
...
...
@@ -660,7 +725,6 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
}
if
(
!
destination
.
getFullVirtualPath
().
startsWith
(
picturesElement
.
getFullVirtualPath
(),
Qt
::
CaseInsensitive
)
)
{
dest
=
picturesElement
;
...
...
@@ -730,16 +794,20 @@ void UBFeaturesController::addItemAsBackground(const UBFeature &item)
UBFeature
UBFeaturesController
::
getDestinationFeatureForUrl
(
const
QUrl
&
url
)
{
QString
mimetype
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
.
toString
()
);
return
getDestinationFeatureForMimeType
(
mimetype
);
}
if
(
mimetype
.
contains
(
"audio"
)
)
UBFeature
UBFeaturesController
::
getDestinationFeatureForMimeType
(
const
QString
&
pMmimeType
)
{
if
(
pMmimeType
.
contains
(
"audio"
)
)
return
audiosElement
;
if
(
mimet
ype
.
contains
(
"video"
)
)
if
(
pMmimeT
ype
.
contains
(
"video"
)
)
return
moviesElement
;
else
if
(
mimetype
.
contains
(
"image"
)
||
mimet
ype
.
isEmpty
())
else
if
(
pMmimeType
.
contains
(
"image"
)
||
pMmimeT
ype
.
isEmpty
())
return
picturesElement
;
else
if
(
mimet
ype
.
contains
(
"application"
)
)
{
if
(
mimet
ype
.
contains
(
"x-shockwave-flash"
)
)
else
if
(
pMmimeT
ype
.
contains
(
"application"
)
)
{
if
(
pMmimeT
ype
.
contains
(
"x-shockwave-flash"
)
)
return
flashElement
;
else
return
interactElement
;
...
...
@@ -747,48 +815,51 @@ UBFeature UBFeaturesController::getDestinationFeatureForUrl( const QUrl &url )
return
UBFeature
();
}
void
UBFeaturesController
::
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
)
void
UBFeaturesController
::
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
,
const
QString
pContentSource
,
const
QString
pTitle
)
{
UBFeature
dest
=
getDestinationFeatureFor
Url
(
sourceUrl
);
UBFeature
dest
=
getDestinationFeatureFor
MimeType
(
pContentSource
);
//TODO:claudio check this
if
(
dest
==
UBFeature
())
return
;
QString
fileName
(
""
)
;
QString
filePath
(
""
)
;
QString
fileName
;
QString
filePath
;
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
sourceUrl
.
toString
()
).
isEmpty
()){
fileName
=
tr
(
"ImportedImage"
)
+
"-"
+
QDateTime
::
currentDateTime
().
toString
(
"dd-MM-yyyy hh-mm-ss"
)
+
".jpg"
;
filePath
=
dest
.
getFullPath
().
toLocalFile
()
+
"/"
+
fileName
;
QImage
::
fromData
(
pData
).
save
(
filePath
);
//Audio item
if
(
dest
==
picturesElement
)
{
UBFeature
downloadedFeature
=
UBFeature
(
dest
.
getFullVirtualPath
()
+
"/"
+
fileName
,
getIcon
(
filePath
,
fileTypeFromUrl
(
filePath
)),
fileName
,
QUrl
::
fromLocalFile
(
filePath
),
FEATURE_ITEM
);
if
(
downloadedFeature
!=
UBFeature
())
{
featuresModel
->
addItem
(
downloadedFeature
);
}
}
else
{
fileName
=
QFileInfo
(
sourceUrl
.
toString
()
).
fileName
();
filePath
=
dest
.
getFullPath
().
toLocalFile
()
+
"/"
+
fileName
;
QString
UniqName
=
uniqNameForFeature
(
dest
,
adjustName
(
pTitle
),
".jpg"
);
fileName
=
!
UniqName
.
isNull
()
?
UniqName
:
tr
(
"ImportedImage"
)
+
"-"
+
QDateTime
::
currentDateTime
().
toString
(
"dd-MM-yyyy hh-mm-ss"
)
+
".jpg"
;
QFile
file
(
filePath
);
if
(
file
.
open
(
QIODevice
::
WriteOnly
))
{
file
.
write
(
pData
);
file
.
close
();
filePath
=
dest
.
getFullPath
().
toLocalFile
()
+
"/"
+
fileName
;
QImage
::
fromData
(
pData
).
save
(
filePath
);
UBFeature
downloadedFeature
=
UBFeature
(
dest
.
getFullVirtualPath
()
+
"/"
+
fileName
,
getIcon
(
filePath
,
fileTypeFromUrl
(
filePath
)),
fileName
,
QUrl
::
fromLocalFile
(
filePath
),
FEATURE_ITEM
);
if
(
downloadedFeature
!=
UBFeature
())
{
featuresModel
->
addItem
(
downloadedFeature
);
}
}
else
{
fileName
=
QFileInfo
(
sourceUrl
.
toString
()
).
fileName
();
filePath
=
dest
.
getFullPath
().
toLocalFile
()
+
"/"
+
fileName
;
QFile
file
(
filePath
);
if
(
file
.
open
(
QIODevice
::
WriteOnly
))
{
file
.
write
(
pData
);
file
.
close
();
UBFeature
downloadedFeature
=
UBFeature
(
dest
.
getFullVirtualPath
()
+
"/"
+
fileName
,
getIcon
(
filePath
,
fileTypeFromUrl
(
filePath
)),
fileName
,
QUrl
::
fromLocalFile
(
filePath
),
FEATURE_ITEM
);
if
(
downloadedFeature
!=
UBFeature
())
{
featuresModel
->
addItem
(
downloadedFeature
);
}
}
}
}
}
...
...
src/board/UBFeaturesController.h
View file @
65dfcec7
...
...
@@ -151,7 +151,7 @@ public:
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
void
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
);
void
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
,
const
QString
pContentSource
,
const
QString
pTitle
);
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
...
...
@@ -234,6 +234,8 @@ private:
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
saveFavoriteList
();
QString
uniqNameForFeature
(
const
UBFeature
&
feature
,
const
QString
&
pName
=
"Imported"
,
const
QString
&
pExtention
=
""
)
const
;
QString
adjustName
(
const
QString
&
str
);
QList
<
UBFeature
>
*
featuresList
;
...
...
@@ -276,6 +278,7 @@ private:
public
:
UBFeature
trashElement
;
UBFeature
getDestinationFeatureForUrl
(
const
QUrl
&
url
);
UBFeature
getDestinationFeatureForMimeType
(
const
QString
&
pMmimeType
);
};
...
...
src/core/UBDownloadManager.cpp
View file @
65dfcec7
...
...
@@ -283,7 +283,7 @@ void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl
}
else
{
emit
addDownloadedFileToLibrary
(
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
);
emit
addDownloadedFileToLibrary
(
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
,
desc
.
name
);
}
break
;
...
...
src/core/UBDownloadManager.h
View file @
65dfcec7
...
...
@@ -132,7 +132,7 @@ signals:
void
downloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
);
void
downloadModalFinished
();
void
addDownloadedFileToBoard
(
bool
pSuccess
,
QUrl
sourceUrl
,
QUrl
contentUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
addDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
void
addDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QString
pTitle
);
void
cancelAllDownloads
();
void
allDownloadsFinished
();
...
...
src/gui/UBFeaturesWidget.cpp
View file @
65dfcec7
...
...
@@ -67,8 +67,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
connect
(
mActionBar
,
SIGNAL
(
rescanModel
()),
this
,
SLOT
(
rescanModel
()));
connect
(
pathListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)),
this
,
SLOT
(
currentSelected
(
const
QModelIndex
&
)));
connect
(
UBApplication
::
boardController
,
SIGNAL
(
displayMetadata
(
QMap
<
QString
,
QString
>
)),
this
,
SLOT
(
onDisplayMetadata
(
QMap
<
QString
,
QString
>
)));
connect
(
UBDownloadManager
::
downloadManager
(),
SIGNAL
(
addDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
))
,
this
,
SLOT
(
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)));
connect
(
UBDownloadManager
::
downloadManager
(),
SIGNAL
(
addDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
,
QString
))
,
this
,
SLOT
(
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
,
QString
)));
connect
(
centralWidget
,
SIGNAL
(
lockMainWidget
(
bool
)),
this
,
SLOT
(
lockIt
(
bool
)));
connect
(
centralWidget
,
SIGNAL
(
createNewFolderSignal
(
QString
)),
controller
,
SLOT
(
addNewFolder
(
QString
)));
connect
(
controller
,
SIGNAL
(
scanStarted
()),
centralWidget
,
SLOT
(
scanStarted
()));
...
...
@@ -299,12 +299,11 @@ void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QU
centralWidget
->
setPropertiesThumbnail
(
pix
);
}
void
UBFeaturesWidget
::
onAddDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentHeader
,
QByteArray
pData
)
void
UBFeaturesWidget
::
onAddDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentHeader
,
QByteArray
pData
,
QString
pTitle
)
{
Q_UNUSED
(
pContentHeader
)
if
(
pSuccess
)
{
qDebug
()
<<
pData
.
length
();
controller
->
addDownloadedFile
(
sourceUrl
,
pData
);
controller
->
addDownloadedFile
(
sourceUrl
,
pData
,
pContentHeader
,
pTitle
);
controller
->
refreshModels
();
}
}
...
...
@@ -1065,7 +1064,7 @@ void UBFeatureProperties::onAddToLib()
desc
.
isBackground
=
false
;
desc
.
modal
=
false
;
desc
.
dest
=
sDownloadFileDesc
::
library
;
desc
.
name
=
QFileInfo
(
mpElement
->
getFullPath
().
toString
()).
fileName
(
);
desc
.
name
=
mpElement
->
getMetadata
().
value
(
"Title"
,
QString
()
);
qDebug
()
<<
desc
.
name
;
desc
.
srcUrl
=
mpElement
->
getFullPath
().
toString
();
qDebug
()
<<
desc
.
srcUrl
;
...
...
src/gui/UBFeaturesWidget.h
View file @
65dfcec7
...
...
@@ -87,7 +87,7 @@ private slots:
void
addToFavorite
(
const
UBFeaturesMimeData
*
);
void
removeFromFavorite
(
const
UBFeaturesMimeData
*
);
void
onDisplayMetadata
(
QMap
<
QString
,
QString
>
);
void
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
);
void
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
,
QString
pTitle
);
void
addElementsToFavorite
();
void
removeElementsFromFavorite
();
void
deleteSelectedElements
();
...
...
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