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
e130379b
Commit
e130379b
authored
May 02, 2012
by
Anna Udovichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some DnD bugs fixed
parent
f2c60833
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
28 deletions
+128
-28
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+50
-7
UBFeaturesController.h
src/board/UBFeaturesController.h
+10
-0
UBFeaturesActionBar.cpp
src/gui/UBFeaturesActionBar.cpp
+10
-0
UBFeaturesActionBar.h
src/gui/UBFeaturesActionBar.h
+2
-1
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+49
-20
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+7
-0
No files found.
src/board/UBFeaturesController.cpp
View file @
e130379b
...
@@ -24,7 +24,15 @@ UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &nam
...
@@ -24,7 +24,15 @@ UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &nam
}
}
bool
UBFeature
::
operator
==
(
const
UBFeature
&
f
)
const
{
return
virtualPath
==
f
.
getUrl
()
&&
mName
==
f
.
getName
()
&&
mPath
==
f
.
getFullPath
()
&&
elementType
==
f
.
getType
();
}
bool
UBFeature
::
operator
!=
(
const
UBFeature
&
f
)
const
{
return
!
(
*
this
==
f
);
}
bool
UBFeature
::
isFolder
()
const
bool
UBFeature
::
isFolder
()
const
{
{
...
@@ -72,12 +80,17 @@ void UBFeaturesController::initDirectoryTree()
...
@@ -72,12 +80,17 @@ void UBFeaturesController::initDirectoryTree()
trashPath
=
rootPath
+
"/Trash"
;
trashPath
=
rootPath
+
"/Trash"
;
favoritePath
=
rootPath
+
"/Favorites"
;
favoritePath
=
rootPath
+
"/Favorites"
;
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/AudiosCategory.svg"
),
"Audios"
,
mUserAudioDirectoryPath
)
);
audiosElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/AudiosCategory.svg"
),
"Audios"
,
mUserAudioDirectoryPath
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/MoviesCategory.svg"
),
"Movies"
,
mUserVideoDirectoryPath
)
);
featuresList
->
append
(
audiosElement
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/PicturesCategory.svg"
),
"Pictures"
,
mUserPicturesDirectoryPath
)
);
moviesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/MoviesCategory.svg"
),
"Movies"
,
mUserVideoDirectoryPath
);
featuresList
->
append
(
moviesElement
);
picturesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/PicturesCategory.svg"
),
"Pictures"
,
mUserPicturesDirectoryPath
);
featuresList
->
append
(
picturesElement
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ApplicationsCategory.svg"
),
"Applications"
,
mUserInteractiveDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ApplicationsCategory.svg"
),
"Applications"
,
mUserInteractiveDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FlashCategory.svg"
),
"Animations"
,
mUserAnimationDirectoryPath
)
);
flashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FlashCategory.svg"
),
"Animations"
,
mUserAnimationDirectoryPath
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/InteractivesCategory.svg"
),
"Interactivities"
,
mLibInteractiveDirectoryPath
)
);
featuresList
->
append
(
flashElement
);
interactElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/InteractivesCategory.svg"
),
"Interactivities"
,
mLibInteractiveDirectoryPath
);
featuresList
->
append
(
interactElement
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ShapesCategory.svg"
),
"Shapes"
,
mLibShapesDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ShapesCategory.svg"
),
"Shapes"
,
mLibShapesDirectoryPath
)
);
trashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/TrashCategory.svg"
),
"Trash"
,
trashDirectoryPath
,
FEATURE_TRASH
);
trashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/TrashCategory.svg"
),
"Trash"
,
trashDirectoryPath
,
FEATURE_TRASH
);
featuresList
->
append
(
trashElement
);
featuresList
->
append
(
trashElement
);
...
@@ -325,6 +338,26 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
...
@@ -325,6 +338,26 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
}
}
}
}
UBFeature
UBFeaturesController
::
getDestinationForItem
(
const
QUrl
&
url
)
{
QString
mimetype
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
fileNameFromUrl
(
url
)
);
if
(
mimetype
.
contains
(
"audio"
)
)
return
audiosElement
;
if
(
mimetype
.
contains
(
"video"
)
)
return
moviesElement
;
else
if
(
mimetype
.
contains
(
"image"
)
)
return
picturesElement
;
else
if
(
mimetype
.
contains
(
"application"
)
)
{
if
(
mimetype
.
contains
(
"x-shockwave-flash"
)
)
return
flashElement
;
else
return
interactElement
;
}
return
UBFeature
();
}
UBFeature
UBFeaturesController
::
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
UBFeature
UBFeaturesController
::
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
{
{
UBFeature
newElement
=
copyItemToFolder
(
url
,
destination
);
UBFeature
newElement
=
copyItemToFolder
(
url
,
destination
);
...
@@ -338,9 +371,19 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
...
@@ -338,9 +371,19 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
UBFeature
possibleDest
=
getDestinationForItem
(
url
);
UBFeature
dest
=
destination
;
if
(
destination
!=
trashElement
&&
!
destination
.
getVirtualPath
().
startsWith
(
possibleDest
.
getVirtualPath
(),
Qt
::
CaseInsensitive
)
)
{
dest
=
possibleDest
;
}
QString
name
=
QFileInfo
(
sourcePath
).
fileName
();
QString
name
=
QFileInfo
(
sourcePath
).
fileName
();
QString
destPath
=
dest
ination
.
getFullPath
();
QString
destPath
=
dest
.
getFullPath
();
QString
destVirtualPath
=
dest
ination
.
getUrl
()
+
"/"
+
destination
.
getName
();
QString
destVirtualPath
=
dest
.
getVirtualPath
();
QString
newFullPath
=
destPath
+
"/"
+
name
;
QString
newFullPath
=
destPath
+
"/"
+
name
;
QFile
(
sourcePath
).
copy
(
newFullPath
);
QFile
(
sourcePath
).
copy
(
newFullPath
);
...
...
src/board/UBFeaturesController.h
View file @
e130379b
...
@@ -34,8 +34,11 @@ public:
...
@@ -34,8 +34,11 @@ public:
QString
getUrl
()
const
{
return
virtualPath
;
}
QString
getUrl
()
const
{
return
virtualPath
;
}
//QString getPath() const { return mPath; };
//QString getPath() const { return mPath; };
QString
getFullPath
()
const
{
return
mPath
;
}
QString
getFullPath
()
const
{
return
mPath
;
}
QString
getVirtualPath
()
const
{
return
virtualPath
+
"/"
+
mName
;
}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
bool
isFolder
()
const
;
bool
isFolder
()
const
;
bool
operator
==
(
const
UBFeature
&
f
)
const
;
bool
operator
!=
(
const
UBFeature
&
f
)
const
;
private
:
private
:
QString
virtualPath
;
QString
virtualPath
;
QPixmap
mThumbnail
;
QPixmap
mThumbnail
;
...
@@ -78,6 +81,7 @@ private:
...
@@ -78,6 +81,7 @@ private:
//void addImageToCurrentPage( const QString &path );
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
loadFavoriteList
();
void
saveFavoriteList
();
void
saveFavoriteList
();
UBFeature
getDestinationForItem
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
...
@@ -115,6 +119,12 @@ private:
...
@@ -115,6 +119,12 @@ private:
UBFeature
currentElement
;
UBFeature
currentElement
;
UBFeature
trashElement
;
UBFeature
trashElement
;
UBFeature
favoriteElement
;
UBFeature
favoriteElement
;
UBFeature
audiosElement
;
UBFeature
moviesElement
;
UBFeature
picturesElement
;
UBFeature
interactElement
;
UBFeature
flashElement
;
UBFeature
shapesElement
;
QSet
<
QString
>
*
favoriteSet
;
QSet
<
QString
>
*
favoriteSet
;
};
};
...
...
src/gui/UBFeaturesActionBar.cpp
View file @
e130379b
...
@@ -143,6 +143,16 @@ void UBFeaturesActionBar::setButtons()
...
@@ -143,6 +143,16 @@ void UBFeaturesActionBar::setButtons()
mpRemoveFavoriteBtn
->
show
();
mpRemoveFavoriteBtn
->
show
();
mpNewFolderBtn
->
hide
();
mpNewFolderBtn
->
hide
();
break
;
break
;
case
IN_TRASH
:
mpFavoriteBtn
->
hide
();
mpSocialBtn
->
hide
();
mSearchBar
->
show
();
//mpSearchBtn->show();
//mpDeleteBtn->hide();
mpCloseBtn
->
hide
();
//mpRemoveFavoriteBtn->show();
mpNewFolderBtn
->
hide
();
break
;
default
:
default
:
break
;
break
;
}
}
...
...
src/gui/UBFeaturesActionBar.h
View file @
e130379b
...
@@ -12,7 +12,8 @@ enum UBFeaturesActionBarState
...
@@ -12,7 +12,8 @@ enum UBFeaturesActionBarState
IN_ROOT
,
IN_ROOT
,
IN_FOLDER
,
IN_FOLDER
,
IN_PROPERTIES
,
IN_PROPERTIES
,
IN_FAVORITE
IN_FAVORITE
,
IN_TRASH
};
};
class
UBFeaturesActionBar
:
public
QWidget
class
UBFeaturesActionBar
:
public
QWidget
...
...
src/gui/UBFeaturesWidget.cpp
View file @
e130379b
...
@@ -56,6 +56,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
...
@@ -56,6 +56,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
featuresListView
->
setViewMode
(
QListView
::
IconMode
);
featuresListView
->
setViewMode
(
QListView
::
IconMode
);
itemDelegate
=
new
UBFeaturesItemDelegate
(
this
,
featuresListView
);
itemDelegate
=
new
UBFeaturesItemDelegate
(
this
,
featuresListView
);
featuresListView
->
setItemDelegate
(
itemDelegate
);
featuresListView
->
setItemDelegate
(
itemDelegate
);
//featuresListView->setSelectionRectVisible(false);
featuresListView
->
setIconSize
(
QSize
(
defaultThumbnailSize
,
defaultThumbnailSize
)
);
featuresListView
->
setIconSize
(
QSize
(
defaultThumbnailSize
,
defaultThumbnailSize
)
);
featuresListView
->
setGridSize
(
QSize
(
defaultThumbnailSize
*
1.75
,
defaultThumbnailSize
*
1.75
)
);
featuresListView
->
setGridSize
(
QSize
(
defaultThumbnailSize
*
1.75
,
defaultThumbnailSize
*
1.75
)
);
...
@@ -71,6 +72,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
...
@@ -71,6 +72,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
pathListView
->
setSelectionMode
(
QAbstractItemView
::
NoSelection
);
pathListView
->
setSelectionMode
(
QAbstractItemView
::
NoSelection
);
pathListView
->
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
pathListView
->
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
pathListView
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOn
);
pathListView
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOn
);
pathListView
->
setFlow
(
QListView
::
LeftToRight
);
pathListView
->
setWrapping
(
false
);
//pathListView->setResizeMode( QListView::Adjust );
//pathListView->setResizeMode( QListView::Adjust );
//pathListView->setMovement( QListView::Static );
//pathListView->setMovement( QListView::Static );
pathListView
->
setDragDropMode
(
QAbstractItemView
::
DropOnly
);
pathListView
->
setDragDropMode
(
QAbstractItemView
::
DropOnly
);
...
@@ -170,6 +174,10 @@ void UBFeaturesWidget::currentSelected(const QModelIndex ¤t)
...
@@ -170,6 +174,10 @@ void UBFeaturesWidget::currentSelected(const QModelIndex ¤t)
{
{
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
}
}
else
if
(
feature
.
getType
()
==
FEATURE_TRASH
)
{
mActionBar
->
setCurrentState
(
IN_TRASH
);
}
else
else
{
{
mActionBar
->
setCurrentState
(
IN_FOLDER
);
mActionBar
->
setCurrentState
(
IN_FOLDER
);
...
@@ -208,6 +216,10 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
...
@@ -208,6 +216,10 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
{
{
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
}
}
else
if
(
feature
.
getType
()
==
FEATURE_TRASH
)
{
mActionBar
->
setCurrentState
(
IN_TRASH
);
}
else
else
{
{
mActionBar
->
setCurrentState
(
IN_FOLDER
);
mActionBar
->
setCurrentState
(
IN_FOLDER
);
...
@@ -224,7 +236,6 @@ void UBFeaturesWidget::createNewFolder()
...
@@ -224,7 +236,6 @@ void UBFeaturesWidget::createNewFolder()
featuresModel
->
addItem
(
newFolder
);
featuresModel
->
addItem
(
newFolder
);
featuresProxyModel
->
invalidate
();
featuresProxyModel
->
invalidate
();
}
}
}
}
void
UBFeaturesWidget
::
deleteElements
(
const
QMimeData
&
mimeData
)
void
UBFeaturesWidget
::
deleteElements
(
const
QMimeData
&
mimeData
)
...
@@ -315,11 +326,39 @@ UBFeaturesWidget::~UBFeaturesWidget()
...
@@ -315,11 +326,39 @@ UBFeaturesWidget::~UBFeaturesWidget()
{
{
}
}
UBFeaturesListView
::
UBFeaturesListView
(
QWidget
*
parent
,
const
char
*
name
)
:
QListView
(
parent
)
UBFeaturesListView
::
UBFeaturesListView
(
QWidget
*
parent
,
const
char
*
name
)
:
QListView
(
parent
)
{
{
setObjectName
(
name
);
setObjectName
(
name
);
//rubberBand = new UBRubberBand( QRubberBand::Rectangle, this );
}
/*
void UBFeaturesListView::mousePressEvent( QMouseEvent *event )
{
rubberOrigin = event->pos();
rubberBand->setGeometry( QRect( rubberOrigin, QSize() ) );
//qDebug() << rubberOrigin.x() << rubberOrigin.y();
rubberBand->show();
QListView::mousePressEvent(event);
}
void UBFeaturesListView::mouseMoveEvent( QMouseEvent *event )
{
QPoint current = event->pos();
rubberBand->setGeometry( QRect( rubberOrigin, current ).normalized() );
//setSelection( rubberBand->rect(), QItemSelectionModel::Select );
QListView::mouseMoveEvent(event);
}
}
void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event )
{
rubberBand->hide();
QListView::mouseReleaseEvent(event);
}
*/
void
UBFeaturesListView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
void
UBFeaturesListView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
{
if
(
event
->
mimeData
()
->
hasUrls
()
)
if
(
event
->
mimeData
()
->
hasUrls
()
)
...
@@ -537,19 +576,15 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
...
@@ -537,19 +576,15 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
int
endRow
=
0
;
int
endRow
=
0
;
UBFeature
parentFeature
;
if
(
!
parent
.
isValid
()
)
if
(
!
parent
.
isValid
()
)
{
{
return
false
;
parentFeature
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
getCurrentElement
();
/*if (row < 0)
endRow = featuresList->size();
else
endRow = qMin( row, featuresList->size() );*/
}
}
else
else
endRow
=
parent
.
row
();
{
Q_UNUSED
(
endRow
)
//why do we need this variable?
parentFeature
=
parent
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
}
UBFeature
parentFeature
=
parent
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
...
@@ -628,7 +663,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
...
@@ -628,7 +663,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
if
(
item
.
isFolder
()
&&
!
item
.
getFullPath
().
isNull
()
)
if
(
item
.
isFolder
()
&&
!
item
.
getFullPath
().
isNull
()
)
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
else
return
defaultFlags
;
else
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
}
}
/*if ( index.isValid() )
/*if ( index.isValid() )
{
{
...
@@ -647,7 +682,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
...
@@ -647,7 +682,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
default:;
default:;
}
}
}*/
}*/
return
defaultFlags
;
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
}
}
...
@@ -710,13 +745,7 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc
...
@@ -710,13 +745,7 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc
{
{
const
QFontMetrics
fm
=
listView
->
fontMetrics
();
const
QFontMetrics
fm
=
listView
->
fontMetrics
();
const
QSize
iSize
=
listView
->
iconSize
();
const
QSize
iSize
=
listView
->
iconSize
();
return
elidedText
(
fm
,
iSize
.
width
(),
Qt
::
ElideRight
,
text
);
if
(
iSize
.
width
()
>
0
&&
fm
.
width
(
text
)
>
iSize
.
width
()
)
{
while
(
fm
.
width
(
text
)
>
iSize
.
width
())
text
.
resize
(
text
.
size
()
-
1
);
text
+=
"..."
;
}
}
}
return
text
;
return
text
;
}
}
...
...
src/gui/UBFeaturesWidget.h
View file @
e130379b
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
//#include "UBLibActionBar.h"
//#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
#include "board/UBFeaturesController.h"
#include "UBFeaturesActionBar.h"
#include "UBFeaturesActionBar.h"
#include "UBRubberBand.h"
#define THUMBNAIL_WIDTH 400
#define THUMBNAIL_WIDTH 400
...
@@ -105,6 +106,12 @@ public:
...
@@ -105,6 +106,12 @@ public:
protected
:
protected
:
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
private
:
//UBRubberBand *rubberBand;
//QPoint rubberOrigin;
};
};
...
...
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