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
512fd415
Commit
512fd415
authored
Apr 23, 2012
by
Anna Udovichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented deleting items
parent
addc1fe1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
127 deletions
+114
-127
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+19
-51
UBFeaturesController.h
src/board/UBFeaturesController.h
+10
-3
UBFeaturesActionBar.cpp
src/gui/UBFeaturesActionBar.cpp
+38
-0
UBFeaturesActionBar.h
src/gui/UBFeaturesActionBar.h
+7
-1
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+36
-71
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+4
-1
No files found.
src/board/UBFeaturesController.cpp
View file @
512fd415
...
...
@@ -55,6 +55,7 @@ void UBFeaturesController::initDirectoryTree()
mLibInteractiveDirectoryPath
=
UBSettings
::
settings
()
->
applicationInteractivesDirectory
();
mLibApplicationsDirectoryPath
=
UBSettings
::
settings
()
->
applicationApplicationsLibraryDirectory
();
mLibShapesDirectoryPath
=
UBSettings
::
settings
()
->
applicationShapeLibraryDirectory
()
;
trashDirectoryPath
=
UBSettings
::
userTrashDirPath
();
featuresList
=
new
QVector
<
UBFeature
>
();
...
...
@@ -70,6 +71,7 @@ void UBFeaturesController::initDirectoryTree()
flashPath
=
rootPath
+
"/Animations"
;
interactPath
=
rootPath
+
"/Interactivities"
;
shapesPath
=
rootPath
+
"/Shapes"
;
trashPath
=
rootPath
+
"/Trash"
;
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/AudiosCategory.svg"
),
"Audios"
,
mUserAudioDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/MoviesCategory.svg"
),
"Movies"
,
mUserVideoDirectoryPath
)
);
...
...
@@ -78,6 +80,8 @@ void UBFeaturesController::initDirectoryTree()
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FlashCategory.svg"
),
"Animations"
,
mUserAnimationDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/InteractivesCategory.svg"
),
"Interactivities"
,
mLibInteractiveDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ShapesCategory.svg"
),
"Shapes"
,
mLibShapesDirectoryPath
)
);
trashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/TrashCategory.svg"
),
"Trash"
,
trashDirectoryPath
,
FEATURE_TRASH
);
featuresList
->
append
(
trashElement
);
foreach
(
UBToolsManager
::
UBToolDescriptor
tool
,
tools
)
{
...
...
@@ -93,6 +97,7 @@ void UBFeaturesController::initDirectoryTree()
fileSystemScan
(
mLibPicturesDirectoryPath
,
picturesPath
);
fileSystemScan
(
mLibShapesDirectoryPath
,
shapesPath
);
fileSystemScan
(
mLibInteractiveDirectoryPath
,
interactPath
);
fileSystemScan
(
trashDirectoryPath
,
trashPath
);
}
...
...
@@ -206,38 +211,15 @@ 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
;
deleteItem
(
url
);
/*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 );
QFile::remove( sourcePath );
QString thumbnailPath = UBFileSystemUtils::thumbnailPath( sourcePath );
if (thumbnailPath.length() && QFileInfo( thumbnailPath ).exists())
{
QFile::remove(thumbnailPath);
}
QPixmap thumb = thumbnailForFile( newFullPath );
UBFeatureElementType type = UBFeatureElementType::FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = UBFeatureElementType::FEATURE_INTERACTIVE;
UBFeature newElement( destVirtualPath, thumb, name, destPath, type );
return newElement;*/
}*/
return
newElement
;
}
UBFeature
UBFeaturesController
::
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
...
...
@@ -261,37 +243,23 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
return
newElement
;
}
/*
void UBFeaturesController::addImageToCurrentPage( const QString &path )
void
UBFeaturesController
::
deleteItem
(
const
QUrl
&
url
)
{
QPointF pos = UBApplication::boardController->activeScene()->normalizedSceneRect().center();
mLastItemOffsetIndex = qMin(mLastItemOffsetIndex, 5);
QGraphicsItem* itemInScene = 0;
QString
path
=
url
.
toLocalFile
();
Q_ASSERT
(
QFileInfo
(
path
).
exists
()
);
if ( UBApplication::boardController->activeScene() )
{
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName( path );
pos = QPointF( pos.x() + 50 * mLastItemOffsetIndex, pos.y() + 50 * mLastItemOffsetIndex );
mLastItemOffsetIndex++;
//TODO UB 4.x move this logic to the scene ..
if (mimeType == "image/svg+xml")
{
itemInScene = UBApplication::boardController->activeScene()->addSvg( QUrl::fromLocalFile(path), pos );
}
else
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
path
);
if
(
thumbnailPath
.
length
()
&&
QFileInfo
(
thumbnailPath
).
exists
())
{
itemInScene = UBApplication::boardController->activeScene()->addPixmap( QPixmap(path), pos );
}
QFile
::
remove
(
thumbnailPath
);
}
QFile
::
remove
(
path
);
}
if (itemInScene)
{
itemInScene = UBApplication::boardController->activeScene()->scaleToFitDocumentSize(itemInScene, false, UBSettings::objectInControlViewMargin);
}
bool
UBFeaturesController
::
isTrash
(
const
QUrl
&
url
)
{
return
url
.
toLocalFile
().
startsWith
(
trashDirectoryPath
);
}
*/
UBFeaturesController
::~
UBFeaturesController
()
{
...
...
src/board/UBFeaturesController.h
View file @
512fd415
...
...
@@ -17,7 +17,8 @@ enum UBFeatureElementType
FEATURE_FOLDER
,
FEATURE_INTERACTIVE
,
FEATURE_INTERNAL
,
FEATURE_ITEM
FEATURE_ITEM
,
FEATURE_TRASH
};
class
UBFeature
...
...
@@ -52,15 +53,18 @@ public:
QVector
<
UBFeature
>*
getFeatures
()
const
{
return
featuresList
;
}
QString
getRootPath
()
const
{
return
rootPath
;
}
const
QString
&
getRootPath
()
const
{
return
rootPath
;
}
void
addItemToPage
(
const
UBFeature
&
item
);
UBFeature
getCurrentElement
()
const
{
return
currentElement
;
}
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
static
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
static
void
deleteItem
(
const
QUrl
&
url
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
private
:
void
initDirectoryTree
();
...
...
@@ -85,6 +89,7 @@ private:
QString
mLibAnimationDirectoryPath
;
QString
mLibApplicationsDirectoryPath
;
QString
mLibShapesDirectoryPath
;
QString
trashDirectoryPath
;
QString
rootPath
;
QString
audiosPath
;
...
...
@@ -94,9 +99,11 @@ private:
QString
flashPath
;
QString
shapesPath
;
QString
interactPath
;
QString
trashPath
;
int
mLastItemOffsetIndex
;
UBFeature
currentElement
;
UBFeature
trashElement
;
};
...
...
src/gui/UBFeaturesActionBar.cpp
View file @
512fd415
...
...
@@ -87,6 +87,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mLayout
->
addWidget
(
mpCloseBtn
);
mLayout
->
addWidget
(
mpRemoveFavoriteBtn
);
setCurrentState
(
IN_ROOT
);
mpDeleteBtn
->
setAcceptDrops
(
true
);
setAcceptDrops
(
true
);
}
void
UBFeaturesActionBar
::
setCurrentState
(
UBFeaturesActionBarState
state
)
...
...
@@ -100,7 +102,16 @@ void UBFeaturesActionBar::setButtons()
switch
(
currentState
)
{
case
IN_FOLDER
:
mpFavoriteBtn
->
show
();
mpSocialBtn
->
hide
();
mSearchBar
->
show
();
mpDeleteBtn
->
show
();
mpCloseBtn
->
hide
();
mpRemoveFavoriteBtn
->
hide
();
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
setEnabled
(
true
);
mpDeleteBtn
->
setEnabled
(
true
);
break
;
case
IN_ROOT
:
mpFavoriteBtn
->
show
();
mpSocialBtn
->
hide
();
...
...
@@ -109,6 +120,8 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
mpRemoveFavoriteBtn
->
hide
();
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
setEnabled
(
false
);
mpDeleteBtn
->
setEnabled
(
false
);
break
;
case
IN_PROPERTIES
:
mpFavoriteBtn
->
show
();
...
...
@@ -145,6 +158,31 @@ void UBFeaturesActionBar::onActionNewFolder()
emit
newFolderToCreate
();
}
/*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}
*/
void
UBFeaturesActionBar
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
if
(
event
->
mimeData
()
->
hasFormat
(
"text/uri-list"
))
event
->
acceptProposedAction
();
}
void
UBFeaturesActionBar
::
dropEvent
(
QDropEvent
*
event
)
{
QWidget
*
dest
=
childAt
(
event
->
pos
()
);
if
(
dest
==
mpDeleteBtn
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
emit
deleteElements
(
*
event
->
mimeData
()
);
}
}
UBFeaturesActionBar
::~
UBFeaturesActionBar
()
{
}
\ No newline at end of file
src/gui/UBFeaturesActionBar.h
View file @
512fd415
...
...
@@ -3,6 +3,7 @@
#include <QWidget>
#include <QToolButton>
#include <QDropEvent>
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
...
...
@@ -23,11 +24,16 @@ public:
void
setCurrentState
(
UBFeaturesActionBarState
state
);
signals
:
void
searchElement
(
QString
text
);
void
searchElement
(
const
QString
&
text
);
void
newFolderToCreate
();
void
deleteElements
(
const
QMimeData
&
data
);
private
slots
:
void
onSearchTextChanged
(
QString
txt
);
void
onActionNewFolder
();
protected
:
//void dragMoveEvent(QDragMoveEvent *event);
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
void
dropEvent
(
QDropEvent
*
event
);
private
:
void
setButtons
();
UBFeaturesController
*
featuresController
;
...
...
src/gui/UBFeaturesWidget.cpp
View file @
512fd415
...
...
@@ -48,7 +48,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
//featuresListView->setStyleSheet( QString("background: #EEEEEE;border-radius: 10px;border: 2px solid #999999;") );
featuresListView
->
setDragDropMode
(
QAbstractItemView
::
InternalMove
);
featuresListView
->
setDragDropMode
(
QAbstractItemView
::
DragDrop
);
featuresListView
->
setModel
(
featuresProxyModel
);
featuresListView
->
setResizeMode
(
QListView
::
Adjust
);
...
...
@@ -95,13 +95,14 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
this, SLOT(currentSelected(const QModelIndex &)));*/
connect
(
featuresListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)
),
this
,
SLOT
(
currentSelected
(
const
QModelIndex
&
)
)
);
connect
(
mActionBar
,
SIGNAL
(
searchElement
(
QString
)
),
this
,
SLOT
(
searchStarted
(
QString
)
)
);
connect
(
mActionBar
,
SIGNAL
(
searchElement
(
const
QString
&
)
),
this
,
SLOT
(
const
searchStarted
(
QString
&
)
)
);
connect
(
mActionBar
,
SIGNAL
(
newFolderToCreate
()
),
this
,
SLOT
(
createNewFolder
()
)
);
connect
(
mActionBar
,
SIGNAL
(
deleteElements
(
const
QMimeData
&
)),
this
,
SLOT
(
deleteElements
(
const
QMimeData
&
)
)
);
connect
(
pathListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)
),
this
,
SLOT
(
currentPathChanged
(
const
QModelIndex
&
)
)
);
}
void
UBFeaturesWidget
::
searchStarted
(
QString
pattern
)
void
UBFeaturesWidget
::
searchStarted
(
const
QString
&
pattern
)
{
if
(
pattern
.
isEmpty
()
)
{
...
...
@@ -125,7 +126,8 @@ void UBFeaturesWidget::currentSelected(const QModelIndex ¤t)
QString path = model->data(current, Qt::UserRole).toString();
eUBLibElementType type = (eUBLibElementType)model->data(current, Qt::UserRole + 1).toInt();*/
UBFeature
feature
=
model
->
data
(
current
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
if
(
feature
.
getType
()
==
FEATURE_FOLDER
||
feature
.
getType
()
==
FEATURE_CATEGORY
)
if
(
feature
.
getType
()
==
FEATURE_FOLDER
||
feature
.
getType
()
==
FEATURE_CATEGORY
||
feature
.
getType
()
==
FEATURE_TRASH
)
{
QString
newPath
=
feature
.
getUrl
()
+
"/"
+
feature
.
getName
();
//pathViewer->addPathElement( feature.getThumbnail(), newPath );
...
...
@@ -187,6 +189,28 @@ void UBFeaturesWidget::createNewFolder()
}
void
UBFeaturesWidget
::
deleteElements
(
const
QMimeData
&
mimeData
)
{
if
(
!
mimeData
.
hasUrls
()
)
return
;
QList
<
QUrl
>
urls
=
mimeData
.
urls
();
foreach
(
QUrl
url
,
urls
)
{
if
(
controller
->
isTrash
(
url
)
)
{
UBFeaturesController
::
deleteItem
(
url
);
}
else
{
UBFeature
elem
=
UBFeaturesController
::
moveItemToFolder
(
url
,
controller
->
getTrashElement
()
);
featuresModel
->
addItem
(
elem
);
}
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
}
void
UBFeaturesWidget
::
switchToListView
()
{
stackedWidget
->
setCurrentIndex
(
ID_LISTVIEW
);
...
...
@@ -223,6 +247,12 @@ UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) : QL
setObjectName
(
name
);
}
void
UBFeaturesListView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
if
(
event
->
mimeData
()
->
hasUrls
()
)
event
->
acceptProposedAction
();
}
void
UBFeaturesListView
::
dropEvent
(
QDropEvent
*
event
)
{
if
(
event
->
source
()
||
dynamic_cast
<
UBFeaturesListView
*>
(
event
->
source
()
)
)
...
...
@@ -356,73 +386,7 @@ void UBFeatureProperties::onAddToPage()
UBFeatureProperties
::~
UBFeatureProperties
()
{
}
/*
UBFeaturesPathViewer::UBFeaturesPathViewer(const QPixmap &root, const QString &rootPath, QGraphicsScene *sc, QWidget* parent, const char* name) : QGraphicsView(sc, parent)
{
setObjectName(name);
//setAttribute(Qt::WA_StyledBackground, true);
//setStyleSheet(UBApplication::globalStyleSheet());
layout = new QGraphicsLinearLayout();
container = new QGraphicsWidget();
container->setMaximumWidth( width() - 20 );
container->setLayout( layout );
scene()->addItem( container );
UBFolderWidget* pIconLabel = new UBFolderWidget();
pIconLabel->setStyleSheet(QString("background-color: transparent;"));
pIconLabel->setPixmap( root );
pIconLabel->setPath(rootPath);
connect( pIconLabel, SIGNAL( clicked(const QString &) ), parent, SLOT( currentPathChanged(const QString &) ) );
QGraphicsProxyWidget *iconWidget = scene()->addWidget( pIconLabel ) ;;
layout->addItem( iconWidget );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
setAlignment( Qt::AlignLeft );
setFixedHeight( 70 );
arrowPixmap = new QPixmap(":images/navig_arrow.png");
}
void UBFeaturesPathViewer::addPathElement(const QPixmap &p, const QString &s)
{
UBFolderWidget* pIconLabel = new UBFolderWidget();
pIconLabel->setStyleSheet(QString("background-color: transparent;"));
pIconLabel->setPixmap( *arrowPixmap );
QGraphicsProxyWidget *iconWidget = scene()->addWidget( pIconLabel );
layout->addItem( iconWidget );
pIconLabel = new UBFolderWidget();
pIconLabel->setStyleSheet(QString("background-color: transparent;"));
pIconLabel->setPixmap( p.scaledToHeight( height() - 30, Qt::SmoothTransformation) );
pIconLabel->setPath(s);
connect( pIconLabel, SIGNAL( clicked(const QString &) ), parent(), SLOT( currentPathChanged(const QString &) ) );
iconWidget = scene()->addWidget( pIconLabel );
layout->addItem( iconWidget );
scene()->invalidate();
}
void UBFeaturesPathViewer::truncatePath(int number)
{
QList <QGraphicsItem*> items = scene()->items();
int itemsToDel = items.size() - number * 2;
for ( QList <QGraphicsItem*>::iterator it = items.begin() ; it != items.begin() + itemsToDel; ++it )
{
scene()->removeItem( (*it) );
QGraphicsLayoutItem *layoutItem = dynamic_cast<QGraphicsLayoutItem *>(*it);
Q_ASSERT(layout);
layout->removeItem(layoutItem);
delete layoutItem;
}
scene()->invalidate();
}
*/
UBFeatureItemButton
::
UBFeatureItemButton
(
QWidget
*
parent
,
const
char
*
name
)
:
QPushButton
(
parent
)
{
setObjectName
(
name
);
...
...
@@ -540,7 +504,7 @@ bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent
{
if
(
row
<
0
)
return
false
;
if
(
row
+
count
>
=
featuresList
->
size
()
)
if
(
row
+
count
>
featuresList
->
size
()
)
return
false
;
beginRemoveRows
(
parent
,
row
,
row
+
count
-
1
);
featuresList
->
remove
(
row
,
count
);
...
...
@@ -571,6 +535,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
item
.
getType
()
==
FEATURE_INTERNAL
)
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
if
(
item
.
getType
()
==
FEATURE_FOLDER
||
item
.
getType
()
==
FEATURE_TRASH
||
(
item
.
getType
()
==
FEATURE_CATEGORY
&&
!
item
.
getFullPath
().
isNull
()))
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
else
return
defaultFlags
;
...
...
src/gui/UBFeaturesWidget.h
View file @
512fd415
...
...
@@ -75,12 +75,14 @@ private:
QStackedWidget
*
stackedWidget
;
int
currentStackedWidget
;
QModelIndex
trashIndex
;
private
slots
:
void
currentSelected
(
const
QModelIndex
&
);
//void currentPathChanged(const QString &);
void
currentPathChanged
(
const
QModelIndex
&
);
void
searchStarted
(
QString
);
void
searchStarted
(
const
QString
&
);
void
createNewFolder
();
void
deleteElements
(
const
QMimeData
&
);
};
class
UBFeaturesListView
:
public
QListView
...
...
@@ -90,6 +92,7 @@ public:
UBFeaturesListView
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBFeaturesListView"
);
virtual
~
UBFeaturesListView
()
{;}
protected
:
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
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