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
b5fd37a9
Commit
b5fd37a9
authored
May 07, 2012
by
Anna Udovichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added importing images from board to library
parent
17dd8564
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
20 deletions
+58
-20
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+21
-0
UBFeaturesController.h
src/board/UBFeaturesController.h
+1
-0
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+35
-20
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+1
-0
No files found.
src/board/UBFeaturesController.cpp
View file @
b5fd37a9
...
...
@@ -345,6 +345,27 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
return
QPixmap
(
thumbnailPath
);
}
UBFeature
UBFeaturesController
::
importImage
(
const
QImage
&
image
,
const
UBFeature
&
destination
)
{
QDateTime
now
=
QDateTime
::
currentDateTime
();
QString
fileName
=
tr
(
"ImportedImage"
)
+
"-"
+
now
.
toString
(
"dd-MM-yyyy hh-mm-ss"
)
+
".png"
;
UBFeature
dest
=
destination
;
if
(
!
destination
.
getFullVirtualPath
().
startsWith
(
picturesElement
.
getFullVirtualPath
(),
Qt
::
CaseInsensitive
)
)
{
dest
=
picturesElement
;
}
QString
filePath
=
dest
.
getFullPath
().
toLocalFile
()
+
"/"
+
fileName
;
image
.
save
(
filePath
);
QPixmap
thumb
=
createThumbnail
(
filePath
);
return
UBFeature
(
dest
.
getFullVirtualPath
(),
thumb
,
fileName
,
QUrl
::
fromLocalFile
(
filePath
),
FEATURE_ITEM
);
}
UBFeature
UBFeaturesController
::
newFolder
(
const
QString
&
name
)
{
QString
path
=
currentElement
.
getFullPath
().
toLocalFile
()
+
"/"
+
name
;
...
...
src/board/UBFeaturesController.h
View file @
b5fd37a9
...
...
@@ -86,6 +86,7 @@ public:
UBFeature
newFolder
(
const
QString
&
name
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
);
UBFeature
importImage
(
const
QImage
&
image
,
const
UBFeature
&
destination
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
...
...
src/gui/UBFeaturesWidget.cpp
View file @
b5fd37a9
...
...
@@ -404,13 +404,19 @@ void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event )
*/
void
UBFeaturesListView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
if
(
event
->
mimeData
()
->
hasUrls
()
)
if
(
event
->
mimeData
()
->
hasUrls
()
||
event
->
mimeData
()
->
hasImage
()
)
event
->
acceptProposedAction
();
}
void
UBFeaturesListView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
if
(
event
->
mimeData
()
->
hasUrls
()
||
event
->
mimeData
()
->
hasImage
()
)
event
->
acceptProposedAction
();
}
void
UBFeaturesListView
::
dropEvent
(
QDropEvent
*
event
)
{
if
(
event
->
source
()
||
dynamic_cast
<
UBFeaturesListView
*>
(
event
->
source
()
)
)
if
(
event
->
source
()
&&
dynamic_cast
<
UBFeaturesListView
*>
(
event
->
source
()
)
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
}
...
...
@@ -775,7 +781,7 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
{
Q_UNUSED
(
row
)
if
(
!
mimeData
->
hasUrls
()
)
if
(
!
mimeData
->
hasUrls
()
&&
!
mimeData
->
hasImage
()
)
return
false
;
if
(
action
==
Qt
::
IgnoreAction
)
return
true
;
...
...
@@ -794,22 +800,31 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
parentFeature
=
parent
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
}
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
foreach
(
QUrl
url
,
urls
)
{
UBFeature
element
;
if
(
action
==
Qt
::
MoveAction
)
{
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
moveItemToFolder
(
url
,
parentFeature
);
}
else
{
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
copyItemToFolder
(
url
,
parentFeature
);
}
addItem
(
element
);
}
if
(
mimeData
->
hasUrls
()
)
{
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
foreach
(
QUrl
url
,
urls
)
{
UBFeature
element
;
if
(
action
==
Qt
::
MoveAction
)
{
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
moveItemToFolder
(
url
,
parentFeature
);
}
else
{
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
copyItemToFolder
(
url
,
parentFeature
);
}
addItem
(
element
);
}
}
else
if
(
mimeData
->
hasImage
()
)
{
QImage
image
=
qvariant_cast
<
QImage
>
(
mimeData
->
imageData
()
);
UBFeature
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
importImage
(
image
,
parentFeature
);
addItem
(
element
);
}
return
true
;
}
...
...
@@ -897,7 +912,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
QStringList
UBFeaturesModel
::
mimeTypes
()
const
{
QStringList
types
;
types
<<
"text/uri-list"
;
types
<<
"text/uri-list"
<<
"image/png"
<<
"image/tiff"
<<
"image/gif"
<<
"image/jpeg"
;
return
types
;
}
...
...
src/gui/UBFeaturesWidget.h
View file @
b5fd37a9
...
...
@@ -114,6 +114,7 @@ public:
protected
:
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
...
...
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