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
14e326ef
Commit
14e326ef
authored
Apr 18, 2012
by
Anna Udovichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some bugs fixed and more DnD functionality implemented
parent
2e049770
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
24 deletions
+84
-24
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+34
-3
UBFeaturesController.h
src/board/UBFeaturesController.h
+3
-2
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+33
-17
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+14
-2
No files found.
src/board/UBFeaturesController.cpp
View file @
14e326ef
...
@@ -27,7 +27,7 @@ UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &nam
...
@@ -27,7 +27,7 @@ UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &nam
UBFeature
::
UBFeature
(
const
UBFeature
&
f
)
UBFeature
::
UBFeature
(
const
UBFeature
&
f
)
{
{
virtualPath
=
f
.
getUrl
();
virtualPath
=
f
.
getUrl
();
mPath
=
f
.
getPath
();
mPath
=
f
.
get
Full
Path
();
mThumbnail
=
f
.
getThumbnail
();
mThumbnail
=
f
.
getThumbnail
();
mName
=
f
.
getName
();
mName
=
f
.
getName
();
elementType
=
f
.
getType
();
elementType
=
f
.
getType
();
...
@@ -110,7 +110,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
...
@@ -110,7 +110,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
}
}
QString
itemName
=
(
fileType
!=
FEATURE_ITEM
)
?
fileName
:
fileInfo
->
completeBaseName
();
QString
itemName
=
(
fileType
!=
FEATURE_ITEM
)
?
fileName
:
fileInfo
->
completeBaseName
();
QPixmap
icon
=
QPixmap
(
":images/libpalette/soundIcon.svg"
);
QPixmap
icon
=
QPixmap
(
":images/libpalette/soundIcon.svg"
);
QString
fullFileName
=
currentPath
+
"/"
+
fileName
;
QString
fullFileName
=
fileInfo
->
filePath
()
;
if
(
fileType
==
FEATURE_FOLDER
)
if
(
fileType
==
FEATURE_FOLDER
)
{
{
...
@@ -131,7 +131,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
...
@@ -131,7 +131,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
icon = QPixmap( thumbnailPath );
icon = QPixmap( thumbnailPath );
else icon = createThumbnail( fullFileName );*/
else icon = createThumbnail( fullFileName );*/
}
}
featuresList
->
push_back
(
UBFeature
(
currVirtualPath
,
icon
,
fileName
,
currentPath
,
fileType
)
);
featuresList
->
push_back
(
UBFeature
(
currVirtualPath
,
icon
,
fileName
,
fullFileName
,
fileType
)
);
if
(
fileType
==
FEATURE_FOLDER
)
if
(
fileType
==
FEATURE_FOLDER
)
{
{
...
@@ -194,7 +194,16 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
...
@@ -194,7 +194,16 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
UBFeature
UBFeaturesController
::
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
UBFeature
UBFeaturesController
::
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
{
{
UBFeature
newElement
=
copyItemToFolder
(
url
,
destination
);
QString
sourcePath
=
url
.
toLocalFile
();
QString
sourcePath
=
url
.
toLocalFile
();
QFile
::
remove
(
sourcePath
);
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
sourcePath
);
if
(
thumbnailPath
.
length
()
&&
QFileInfo
(
thumbnailPath
).
exists
())
{
QFile
::
remove
(
thumbnailPath
);
}
return
newElement
;
/*QString sourcePath = url.toLocalFile();
Q_ASSERT( QFileInfo( sourcePath ).exists() );
Q_ASSERT( QFileInfo( sourcePath ).exists() );
...
@@ -217,8 +226,30 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
...
@@ -217,8 +226,30 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = UBFeatureElementType::FEATURE_INTERACTIVE;
type = UBFeatureElementType::FEATURE_INTERACTIVE;
UBFeature newElement( destVirtualPath, thumb, name, destPath, type );
UBFeature newElement( destVirtualPath, thumb, name, destPath, type );
return newElement;*/
}
UBFeature
UBFeaturesController
::
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
{
QString
sourcePath
=
url
.
toLocalFile
();
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
QString
name
=
QFileInfo
(
sourcePath
).
fileName
();
QString
destPath
=
destination
.
getFullPath
();
QString
destVirtualPath
=
destination
.
getUrl
()
+
"/"
+
destination
.
getName
();
QString
newFullPath
=
destPath
+
"/"
+
name
;
QFile
(
sourcePath
).
copy
(
newFullPath
);
QPixmap
thumb
=
thumbnailForFile
(
newFullPath
);
UBFeatureElementType
type
=
UBFeatureElementType
::
FEATURE_ITEM
;
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
newFullPath
).
contains
(
"application"
)
)
type
=
UBFeatureElementType
::
FEATURE_INTERACTIVE
;
UBFeature
newElement
(
destVirtualPath
,
thumb
,
name
,
newFullPath
,
type
);
return
newElement
;
return
newElement
;
}
}
/*
/*
void UBFeaturesController::addImageToCurrentPage( const QString &path )
void UBFeaturesController::addImageToCurrentPage( const QString &path )
{
{
...
...
src/board/UBFeaturesController.h
View file @
14e326ef
...
@@ -31,8 +31,8 @@ public:
...
@@ -31,8 +31,8 @@ public:
return
mThumbnail
;
return
mThumbnail
;
};
};
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
+
"/"
+
mName
;
};
QString
getFullPath
()
const
{
return
mPath
;
};
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
;
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
;
private
:
private
:
QString
virtualPath
;
QString
virtualPath
;
...
@@ -58,6 +58,7 @@ public:
...
@@ -58,6 +58,7 @@ public:
void
addItemToPage
(
const
UBFeature
&
item
);
void
addItemToPage
(
const
UBFeature
&
item
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
static
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
static
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
private
:
private
:
void
initDirectoryTree
();
void
initDirectoryTree
();
void
fileSystemScan
(
const
QString
&
currPath
,
const
QString
&
currVirtualPath
);
void
fileSystemScan
(
const
QString
&
currPath
,
const
QString
&
currVirtualPath
);
...
...
src/gui/UBFeaturesWidget.cpp
View file @
14e326ef
...
@@ -28,8 +28,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
...
@@ -28,8 +28,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
featuresModel
=
new
UBFeaturesModel
(
this
);
featuresModel
=
new
UBFeaturesModel
(
this
);
featuresModel
->
setFeaturesList
(
controller
->
getFeatures
()
);
featuresModel
->
setFeaturesList
(
controller
->
getFeatures
()
);
featuresModel
->
setSupportedDragActions
(
Qt
::
CopyAction
|
Qt
::
MoveAction
);
featuresModel
->
setSupportedDragActions
(
Qt
::
CopyAction
|
Qt
::
MoveAction
);
featuresListView
=
new
Q
ListView
(
this
);
featuresListView
=
new
UBFeatures
ListView
(
this
);
pathListView
=
new
Q
ListView
(
this
);
pathListView
=
new
UBFeatures
ListView
(
this
);
featuresProxyModel
=
new
UBFeaturesProxyModel
(
this
);
featuresProxyModel
=
new
UBFeaturesProxyModel
(
this
);
...
@@ -69,7 +69,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
...
@@ -69,7 +69,7 @@ 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
->
setMovement
(
QListView
::
Static
);
//
pathListView->setMovement( QListView::Static );
pathListView
->
setDragDropMode
(
QAbstractItemView
::
DragDrop
);
pathListView
->
setDragDropMode
(
QAbstractItemView
::
DragDrop
);
pathScene
=
new
QGraphicsScene
(
this
);
pathScene
=
new
QGraphicsScene
(
this
);
...
@@ -192,6 +192,21 @@ UBFeaturesWidget::~UBFeaturesWidget()
...
@@ -192,6 +192,21 @@ UBFeaturesWidget::~UBFeaturesWidget()
{
{
}
}
UBFeaturesListView
::
UBFeaturesListView
(
QWidget
*
parent
,
const
char
*
name
)
:
QListView
(
parent
)
{
setObjectName
(
name
);
}
void
UBFeaturesListView
::
dropEvent
(
QDropEvent
*
event
)
{
if
(
event
->
source
()
||
dynamic_cast
<
UBFeaturesListView
*>
(
event
->
source
()
)
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
}
QListView
::
dropEvent
(
event
);
}
UBFeatureProperties
::
UBFeatureProperties
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
UBFeatureProperties
::
UBFeatureProperties
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpLayout
(
NULL
)
,
mpLayout
(
NULL
)
,
mpButtonLayout
(
NULL
)
,
mpButtonLayout
(
NULL
)
...
@@ -432,18 +447,6 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
...
@@ -432,18 +447,6 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
}
}
}
}
mimeData
->
setUrls
(
urlList
);
mimeData
->
setUrls
(
urlList
);
/*QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
foreach (QModelIndex index, indexes) {
if (index.isValid()) {
QString str = qVariantValue<QString>(data(index));
stream << str;
}
}
mimeData->setData("text/uri-list", encodedData);*/
return
mimeData
;
return
mimeData
;
}
}
...
@@ -476,7 +479,16 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
...
@@ -476,7 +479,16 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
foreach
(
QUrl
url
,
urls
)
foreach
(
QUrl
url
,
urls
)
{
{
UBFeature
element
=
UBFeaturesController
::
moveItemToFolder
(
url
,
parentFeature
);
UBFeature
element
;
if
(
action
==
Qt
::
MoveAction
)
{
element
=
UBFeaturesController
::
moveItemToFolder
(
url
,
parentFeature
);
}
else
{
element
=
UBFeaturesController
::
copyItemToFolder
(
url
,
parentFeature
);
}
beginInsertRows
(
QModelIndex
(),
featuresList
->
size
(),
featuresList
->
size
()
);
beginInsertRows
(
QModelIndex
(),
featuresList
->
size
(),
featuresList
->
size
()
);
featuresList
->
push_back
(
element
);
featuresList
->
push_back
(
element
);
endInsertRows
();
endInsertRows
();
...
@@ -517,6 +529,10 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
...
@@ -517,6 +529,10 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
if
(
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_INTERACTIVE
||
if
(
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_INTERACTIVE
||
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_ITEM
)
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_ITEM
)
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
if
(
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_FOLDER
||
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_CATEGORY
&&
item
.
getFullPath
()
!=
""
)
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
else
return
defaultFlags
;
}
}
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
}
}
...
@@ -605,7 +621,7 @@ void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionVie
...
@@ -605,7 +621,7 @@ void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionVie
{
{
UBFeature
feature
=
index
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
feature
=
index
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
QRect
rect
=
option
.
rect
;
QRect
rect
=
option
.
rect
;
if
(
!
feature
.
getPath
().
isEmpty
()
)
if
(
!
feature
.
get
Full
Path
().
isEmpty
()
)
{
{
painter
->
drawPixmap
(
rect
.
left
()
-
10
,
rect
.
center
().
y
()
-
5
,
*
arrowPixmap
);
painter
->
drawPixmap
(
rect
.
left
()
-
10
,
rect
.
center
().
y
()
-
5
,
*
arrowPixmap
);
}
}
...
...
src/gui/UBFeaturesWidget.h
View file @
14e326ef
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <QLocale>
#include <QLocale>
#include <QGraphicsLinearLayout>
#include <QGraphicsLinearLayout>
#include <QStackedWidget>
#include <QStackedWidget>
#include <QDropEvent>
#include "UBDockPaletteWidget.h"
#include "UBDockPaletteWidget.h"
#include "UBLibActionBar.h"
#include "UBLibActionBar.h"
...
@@ -34,6 +35,7 @@ class UBFeaturesPathProxyModel;
...
@@ -34,6 +35,7 @@ class UBFeaturesPathProxyModel;
class
UBFeaturesPathViewer
;
class
UBFeaturesPathViewer
;
class
UBFeatureProperties
;
class
UBFeatureProperties
;
class
UBFeatureItemButton
;
class
UBFeatureItemButton
;
class
UBFeaturesListView
;
class
UBFeaturesWidget
:
public
UBDockPaletteWidget
class
UBFeaturesWidget
:
public
UBDockPaletteWidget
{
{
...
@@ -62,8 +64,8 @@ private:
...
@@ -62,8 +64,8 @@ private:
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
Q
ListView
*
featuresListView
;
UBFeatures
ListView
*
featuresListView
;
Q
ListView
*
pathListView
;
UBFeatures
ListView
*
pathListView
;
QVBoxLayout
*
layout
;
QVBoxLayout
*
layout
;
UBFeaturesPathViewer
*
pathViewer
;
UBFeaturesPathViewer
*
pathViewer
;
QGraphicsScene
*
pathScene
;
QGraphicsScene
*
pathScene
;
...
@@ -79,6 +81,16 @@ private slots:
...
@@ -79,6 +81,16 @@ private slots:
void
searchStarted
(
QString
);
void
searchStarted
(
QString
);
};
};
class
UBFeaturesListView
:
public
QListView
{
Q_OBJECT
public
:
UBFeaturesListView
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBFeaturesListView"
);
virtual
~
UBFeaturesListView
()
{};
protected
:
virtual
void
dropEvent
(
QDropEvent
*
event
);
};
class
UBFeaturesPathViewer
:
public
QGraphicsView
class
UBFeaturesPathViewer
:
public
QGraphicsView
{
{
Q_OBJECT
Q_OBJECT
...
...
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