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
0cf7b075
Commit
0cf7b075
authored
Apr 26, 2012
by
Anna Udovichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented deleting from favorite folder
parent
fe0c8ab2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
33 deletions
+73
-33
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+16
-8
UBFeaturesController.h
src/board/UBFeaturesController.h
+12
-8
UBFeaturesActionBar.cpp
src/gui/UBFeaturesActionBar.cpp
+7
-2
UBFeaturesActionBar.h
src/gui/UBFeaturesActionBar.h
+1
-0
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+36
-15
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+1
-0
No files found.
src/board/UBFeaturesController.cpp
View file @
0cf7b075
...
...
@@ -24,17 +24,15 @@ UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &nam
}
UBFeature
::
UBFeature
(
const
UBFeature
&
f
)
bool
UBFeature
::
isFolder
()
const
{
virtualPath
=
f
.
getUrl
();
mPath
=
f
.
getFullPath
();
mThumbnail
=
f
.
getThumbnail
();
mName
=
f
.
getName
();
elementType
=
f
.
getType
();
return
elementType
==
FEATURE_CATEGORY
||
elementType
==
FEATURE_TRASH
||
elementType
==
FEATURE_FAVORITE
||
elementType
==
FEATURE_FOLDER
;
}
UBFeaturesController
::
UBFeaturesController
(
QWidget
*
pParentWidget
)
:
QObject
(
pParentWidget
),
mLastItemOffsetIndex
(
0
)
...
...
@@ -83,7 +81,7 @@ void UBFeaturesController::initDirectoryTree()
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
);
favoriteElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FavoritesCategory.svg"
),
"Favorites"
,
"favorites"
);
favoriteElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FavoritesCategory.svg"
),
"Favorites"
,
"favorites"
,
FEATURE_FAVORITE
);
featuresList
->
append
(
favoriteElement
);
loadFavoriteList
();
...
...
@@ -215,6 +213,16 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
return
UBFeature
();
}
void
UBFeaturesController
::
removeFromFavorite
(
const
QUrl
&
path
)
{
QString
filePath
=
fileNameFromUrl
(
path
);
if
(
favoriteSet
->
find
(
filePath
)
!=
favoriteSet
->
end
()
)
{
favoriteSet
->
erase
(
favoriteSet
->
find
(
filePath
)
);
saveFavoriteList
();
}
}
QString
UBFeaturesController
::
fileNameFromUrl
(
const
QUrl
&
url
)
{
QString
fileName
=
url
.
toString
();
...
...
src/board/UBFeaturesController.h
View file @
0cf7b075
...
...
@@ -18,14 +18,15 @@ enum UBFeatureElementType
FEATURE_INTERACTIVE
,
FEATURE_INTERNAL
,
FEATURE_ITEM
,
FEATURE_TRASH
FEATURE_TRASH
,
FEATURE_FAVORITE
};
class
UBFeature
{
public
:
UBFeature
()
{;}
UBFeature
(
const
UBFeature
&
f
);
//
UBFeature(const UBFeature &f);
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QString
&
realPath
,
UBFeatureElementType
type
=
FEATURE_CATEGORY
);
virtual
~
UBFeature
()
{;}
QString
getName
()
const
{
return
mName
;
}
...
...
@@ -34,6 +35,7 @@ public:
//QString getPath() const { return mPath; };
QString
getFullPath
()
const
{
return
mPath
;
}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
bool
isFolder
()
const
;
private
:
QString
virtualPath
;
QPixmap
mThumbnail
;
...
...
@@ -59,14 +61,16 @@ public:
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
);
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
void
deleteItem
(
const
QUrl
&
url
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
private
:
void
initDirectoryTree
();
void
fileSystemScan
(
const
QString
&
currPath
,
const
QString
&
currVirtualPath
);
...
...
@@ -74,7 +78,7 @@ private:
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
saveFavoriteList
();
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
QVector
<
UBFeature
>
*
featuresList
;
...
...
src/gui/UBFeaturesActionBar.cpp
View file @
0cf7b075
...
...
@@ -180,13 +180,18 @@ void UBFeaturesActionBar::dropEvent( QDropEvent *event )
event
->
accept
();
emit
deleteElements
(
*
event
->
mimeData
()
);
}
if
(
dest
==
mpFavoriteBtn
)
else
if
(
dest
==
mpFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
CopyAction
);
event
->
accept
();
emit
addToFavorite
(
*
event
->
mimeData
()
);
}
else
if
(
dest
==
mpRemoveFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
emit
removeFromFavorite
(
*
event
->
mimeData
()
);
}
}
UBFeaturesActionBar
::~
UBFeaturesActionBar
()
...
...
src/gui/UBFeaturesActionBar.h
View file @
0cf7b075
...
...
@@ -28,6 +28,7 @@ signals:
void
newFolderToCreate
();
void
deleteElements
(
const
QMimeData
&
data
);
void
addToFavorite
(
const
QMimeData
&
data
);
void
removeFromFavorite
(
const
QMimeData
&
data
);
private
slots
:
void
onSearchTextChanged
(
QString
txt
);
void
onActionNewFolder
();
...
...
src/gui/UBFeaturesWidget.cpp
View file @
0cf7b075
...
...
@@ -99,6 +99,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect
(
mActionBar
,
SIGNAL
(
newFolderToCreate
()
),
this
,
SLOT
(
createNewFolder
()
)
);
connect
(
mActionBar
,
SIGNAL
(
deleteElements
(
const
QMimeData
&
)
),
this
,
SLOT
(
deleteElements
(
const
QMimeData
&
)
)
);
connect
(
mActionBar
,
SIGNAL
(
addToFavorite
(
const
QMimeData
&
)
),
this
,
SLOT
(
addToFavorite
(
const
QMimeData
&
)
)
);
connect
(
mActionBar
,
SIGNAL
(
removeFromFavorite
(
const
QMimeData
&
)
),
this
,
SLOT
(
removeFromFavorite
(
const
QMimeData
&
)
)
);
connect
(
pathListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)
),
this
,
SLOT
(
currentPathChanged
(
const
QModelIndex
&
)
)
);
}
...
...
@@ -127,8 +128,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
||
feature
.
getType
()
==
FEATURE_TRASH
)
if
(
feature
.
isFolder
()
)
{
QString
newPath
=
feature
.
getUrl
()
+
"/"
+
feature
.
getName
();
//pathViewer->addPathElement( feature.getThumbnail(), newPath );
...
...
@@ -140,7 +141,14 @@ void UBFeaturesWidget::currentSelected(const QModelIndex ¤t)
featuresPathModel
->
setPath
(
newPath
);
featuresPathModel
->
invalidate
();
mActionBar
->
setCurrentState
(
IN_FOLDER
);
if
(
feature
.
getType
()
==
FEATURE_FAVORITE
)
{
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
}
else
{
mActionBar
->
setCurrentState
(
IN_FOLDER
);
}
}
else
{
...
...
@@ -171,6 +179,10 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
{
mActionBar
->
setCurrentState
(
IN_ROOT
);
}
else
if
(
feature
.
getType
()
==
FEATURE_FAVORITE
)
{
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
}
else
{
mActionBar
->
setCurrentState
(
IN_FOLDER
);
...
...
@@ -198,14 +210,16 @@ void UBFeaturesWidget::deleteElements( const QMimeData & mimeData )
foreach
(
QUrl
url
,
urls
)
{
if
(
controller
->
isTrash
(
url
)
)
if
(
controller
->
isTrash
(
url
)
)
{
UBFeaturesController
::
deleteItem
(
url
);
controller
->
deleteItem
(
url
);
}
else
{
UBFeature
elem
=
UBFeaturesController
::
moveItemToFolder
(
url
,
controller
->
getTrashElement
()
);
UBFeature
elem
=
controller
->
moveItemToFolder
(
url
,
controller
->
getTrashElement
()
);
controller
->
removeFromFavorite
(
url
);
featuresModel
->
addItem
(
elem
);
featuresModel
->
deleteFavoriteItem
(
UBFeaturesController
::
fileNameFromUrl
(
url
)
);
}
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
...
...
@@ -228,6 +242,17 @@ void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData )
model
->
invalidate
();
}
void
UBFeaturesWidget
::
removeFromFavorite
(
const
QMimeData
&
mimeData
)
{
if
(
!
mimeData
.
hasUrls
()
)
return
;
QList
<
QUrl
>
urls
=
mimeData
.
urls
();
foreach
(
QUrl
url
,
urls
)
{
controller
->
removeFromFavorite
(
url
);
}
}
void
UBFeaturesWidget
::
switchToListView
()
{
stackedWidget
->
setCurrentIndex
(
ID_LISTVIEW
);
...
...
@@ -499,11 +524,11 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
if
(
action
==
Qt
::
MoveAction
)
{
element
=
UBFeaturesController
::
moveItemToFolder
(
url
,
parentFeature
);
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
moveItemToFolder
(
url
,
parentFeature
);
}
else
{
element
=
UBFeaturesController
::
copyItemToFolder
(
url
,
parentFeature
);
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
copyItemToFolder
(
url
,
parentFeature
);
}
addItem
(
element
);
}
...
...
@@ -522,7 +547,7 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path )
for
(
int
i
=
0
;
i
<
featuresList
->
size
();
++
i
)
{
if
(
!
QString
::
compare
(
featuresList
->
at
(
i
).
getFullPath
(),
path
,
Qt
::
CaseInsensitive
)
&&
!
QString
::
compare
(
featuresList
->
at
(
i
).
getUrl
(),
"
root/favorite
"
,
Qt
::
CaseInsensitive
)
)
!
QString
::
compare
(
featuresList
->
at
(
i
).
getUrl
(),
"
/root/favorites
"
,
Qt
::
CaseInsensitive
)
)
{
removeRow
(
i
,
QModelIndex
()
);
return
;
...
...
@@ -564,9 +589,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
item
.
getType
()
==
FEATURE_ITEM
||
item
.
getType
()
==
FEATURE_INTERNAL
)
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
if
(
item
.
getType
()
==
FEATURE_FOLDER
||
item
.
getType
()
==
FEATURE_TRASH
||
(
item
.
getType
()
==
FEATURE_CATEGORY
&&
!
item
.
getFullPath
().
isNull
()))
if
(
item
.
isFolder
()
&&
!
item
.
getFullPath
().
isNull
()
)
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
else
return
defaultFlags
;
}
...
...
@@ -619,11 +642,9 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature
feature
=
sourceModel
()
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
bool
isFolder
=
feature
.
getType
()
==
FEATURE_CATEGORY
||
feature
.
getType
()
==
FEATURE_FOLDER
||
feature
.
getType
()
==
FEATURE_TRASH
;
QString
virtualFullPath
=
feature
.
getUrl
()
+
"/"
+
feature
.
getName
();
return
isFolder
&&
path
.
startsWith
(
virtualFullPath
);
return
feature
.
isFolder
()
&&
path
.
startsWith
(
virtualFullPath
);
}
QString
UBFeaturesItemDelegate
::
displayText
(
const
QVariant
&
value
,
const
QLocale
&
locale
)
const
...
...
src/gui/UBFeaturesWidget.h
View file @
0cf7b075
...
...
@@ -84,6 +84,7 @@ private slots:
void
createNewFolder
();
void
deleteElements
(
const
QMimeData
&
);
void
addToFavorite
(
const
QMimeData
&
);
void
removeFromFavorite
(
const
QMimeData
&
);
};
class
UBFeaturesListView
:
public
QListView
...
...
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