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
Show 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
UBFeature
::
UBFeature
(
const
UBFeature
&
f
)
{
virtualPath
=
f
.
getUrl
();
mPath
=
f
.
getPath
();
mPath
=
f
.
get
Full
Path
();
mThumbnail
=
f
.
getThumbnail
();
mName
=
f
.
getName
();
elementType
=
f
.
getType
();
...
...
@@ -110,7 +110,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
}
QString
itemName
=
(
fileType
!=
FEATURE_ITEM
)
?
fileName
:
fileInfo
->
completeBaseName
();
QPixmap
icon
=
QPixmap
(
":images/libpalette/soundIcon.svg"
);
QString
fullFileName
=
currentPath
+
"/"
+
fileName
;
QString
fullFileName
=
fileInfo
->
filePath
()
;
if
(
fileType
==
FEATURE_FOLDER
)
{
...
...
@@ -131,7 +131,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
icon = QPixmap( thumbnailPath );
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
)
{
...
...
@@ -194,7 +194,16 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
UBFeature
UBFeaturesController
::
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
{
UBFeature
newElement
=
copyItemToFolder
(
url
,
destination
);
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() );
...
...
@@ -217,8 +226,30 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = UBFeatureElementType::FEATURE_INTERACTIVE;
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
;
}
/*
void UBFeaturesController::addImageToCurrentPage( const QString &path )
{
...
...
src/board/UBFeaturesController.h
View file @
14e326ef
...
...
@@ -31,8 +31,8 @@ public:
return
mThumbnail
;
};
QString
getUrl
()
const
{
return
virtualPath
;
};
QString
getPath
()
const
{
return
mPath
;
};
QString
getFullPath
()
const
{
return
mPath
+
"/"
+
mName
;
};
//
QString getPath() const { return mPath; };
QString
getFullPath
()
const
{
return
mPath
;
};
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
;
private
:
QString
virtualPath
;
...
...
@@ -58,6 +58,7 @@ public:
void
addItemToPage
(
const
UBFeature
&
item
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
static
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
private
:
void
initDirectoryTree
();
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
featuresModel
=
new
UBFeaturesModel
(
this
);
featuresModel
->
setFeaturesList
(
controller
->
getFeatures
()
);
featuresModel
->
setSupportedDragActions
(
Qt
::
CopyAction
|
Qt
::
MoveAction
);
featuresListView
=
new
Q
ListView
(
this
);
pathListView
=
new
Q
ListView
(
this
);
featuresListView
=
new
UBFeatures
ListView
(
this
);
pathListView
=
new
UBFeatures
ListView
(
this
);
featuresProxyModel
=
new
UBFeaturesProxyModel
(
this
);
...
...
@@ -69,7 +69,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
pathListView
->
setSelectionMode
(
QAbstractItemView
::
NoSelection
);
pathListView
->
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
pathListView
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOn
);
pathListView
->
setMovement
(
QListView
::
Static
);
//
pathListView->setMovement( QListView::Static );
pathListView
->
setDragDropMode
(
QAbstractItemView
::
DragDrop
);
pathScene
=
new
QGraphicsScene
(
this
);
...
...
@@ -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
)
,
mpLayout
(
NULL
)
,
mpButtonLayout
(
NULL
)
...
...
@@ -432,18 +447,6 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
}
}
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
;
}
...
...
@@ -476,7 +479,16 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
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
()
);
featuresList
->
push_back
(
element
);
endInsertRows
();
...
...
@@ -517,6 +529,10 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
if
(
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_INTERACTIVE
||
item
.
getType
()
==
UBFeatureElementType
::
FEATURE_ITEM
)
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
;
}
...
...
@@ -605,7 +621,7 @@ void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionVie
{
UBFeature
feature
=
index
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
QRect
rect
=
option
.
rect
;
if
(
!
feature
.
getPath
().
isEmpty
()
)
if
(
!
feature
.
get
Full
Path
().
isEmpty
()
)
{
painter
->
drawPixmap
(
rect
.
left
()
-
10
,
rect
.
center
().
y
()
-
5
,
*
arrowPixmap
);
}
...
...
src/gui/UBFeaturesWidget.h
View file @
14e326ef
...
...
@@ -13,6 +13,7 @@
#include <QLocale>
#include <QGraphicsLinearLayout>
#include <QStackedWidget>
#include <QDropEvent>
#include "UBDockPaletteWidget.h"
#include "UBLibActionBar.h"
...
...
@@ -34,6 +35,7 @@ class UBFeaturesPathProxyModel;
class
UBFeaturesPathViewer
;
class
UBFeatureProperties
;
class
UBFeatureItemButton
;
class
UBFeaturesListView
;
class
UBFeaturesWidget
:
public
UBDockPaletteWidget
{
...
...
@@ -62,8 +64,8 @@ private:
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
Q
ListView
*
featuresListView
;
Q
ListView
*
pathListView
;
UBFeatures
ListView
*
featuresListView
;
UBFeatures
ListView
*
pathListView
;
QVBoxLayout
*
layout
;
UBFeaturesPathViewer
*
pathViewer
;
QGraphicsScene
*
pathScene
;
...
...
@@ -79,6 +81,16 @@ private slots:
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
{
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