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
fe0c8ab2
Commit
fe0c8ab2
authored
Apr 26, 2012
by
Anna Udovichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Favorite functionality partially implemented
parent
512fd415
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
42 deletions
+154
-42
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+102
-0
UBFeaturesController.h
src/board/UBFeaturesController.h
+9
-0
UBFeaturesActionBar.cpp
src/gui/UBFeaturesActionBar.cpp
+6
-0
UBFeaturesActionBar.h
src/gui/UBFeaturesActionBar.h
+1
-0
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+32
-2
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+4
-40
No files found.
src/board/UBFeaturesController.cpp
View file @
fe0c8ab2
...
...
@@ -72,6 +72,7 @@ void UBFeaturesController::initDirectoryTree()
interactPath
=
rootPath
+
"/Interactivities"
;
shapesPath
=
rootPath
+
"/Shapes"
;
trashPath
=
rootPath
+
"/Trash"
;
favoritePath
=
rootPath
+
"/Favorites"
;
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/AudiosCategory.svg"
),
"Audios"
,
mUserAudioDirectoryPath
)
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/MoviesCategory.svg"
),
"Movies"
,
mUserVideoDirectoryPath
)
);
...
...
@@ -82,10 +83,18 @@ 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"
);
featuresList
->
append
(
favoriteElement
);
loadFavoriteList
();
foreach
(
UBToolsManager
::
UBToolDescriptor
tool
,
tools
)
{
featuresList
->
append
(
UBFeature
(
appPath
,
tool
.
icon
,
tool
.
label
,
tool
.
id
,
FEATURE_INTERNAL
)
);
if
(
favoriteSet
->
find
(
tool
.
id
)
!=
favoriteSet
->
end
()
)
{
featuresList
->
append
(
UBFeature
(
favoritePath
,
tool
.
icon
,
tool
.
label
,
tool
.
id
,
FEATURE_INTERNAL
)
);
}
}
fileSystemScan
(
mUserInteractiveDirectoryPath
,
appPath
);
fileSystemScan
(
mUserAudioDirectoryPath
,
audiosPath
);
...
...
@@ -99,6 +108,8 @@ void UBFeaturesController::initDirectoryTree()
fileSystemScan
(
mLibInteractiveDirectoryPath
,
interactPath
);
fileSystemScan
(
trashDirectoryPath
,
trashPath
);
}
void
UBFeaturesController
::
fileSystemScan
(
const
QString
&
currentPath
,
const
QString
&
currVirtualPath
)
...
...
@@ -138,6 +149,10 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
else icon = createThumbnail( fullFileName );*/
}
featuresList
->
append
(
UBFeature
(
currVirtualPath
,
icon
,
fileName
,
fullFileName
,
fileType
)
);
if
(
favoriteSet
->
find
(
fullFileName
)
!=
favoriteSet
->
end
()
)
{
featuresList
->
append
(
UBFeature
(
favoritePath
,
icon
,
fileName
,
fullFileName
,
fileType
)
);
}
if
(
fileType
==
FEATURE_FOLDER
)
{
...
...
@@ -147,8 +162,95 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
}
}
void
UBFeaturesController
::
loadFavoriteList
()
{
favoriteSet
=
new
QSet
<
QString
>
();
QFile
file
(
UBSettings
::
userDataDirectory
()
+
"/favorites.dat"
);
if
(
file
.
exists
()
)
{
file
.
open
(
QIODevice
::
ReadOnly
);
QDataStream
in
(
&
file
);
int
elementsNumber
;
in
>>
elementsNumber
;
for
(
int
i
=
0
;
i
<
elementsNumber
;
++
i
)
{
QString
path
;
in
>>
path
;
/*QFileInfo fileInfo( path );
QString fileName = fileInfo.fileName();
UBFeature elem( favoritePath, thumbnailForFile( path ), fileName, path, fileTypeFromUrl(path) );
featuresList->append( elem );*/
favoriteSet
->
insert
(
path
);
}
}
}
void
UBFeaturesController
::
saveFavoriteList
()
{
QFile
file
(
UBSettings
::
userDataDirectory
()
+
"/favorites.dat"
);
file
.
resize
(
0
);
file
.
open
(
QIODevice
::
WriteOnly
);
QDataStream
out
(
&
file
);
out
<<
favoriteSet
->
size
();
for
(
QSet
<
QString
>::
iterator
it
=
favoriteSet
->
begin
();
it
!=
favoriteSet
->
end
();
++
it
)
{
out
<<
(
*
it
);
}
file
.
close
();
}
UBFeature
UBFeaturesController
::
addToFavorite
(
const
QUrl
&
path
)
{
QString
filePath
=
fileNameFromUrl
(
path
);
if
(
favoriteSet
->
find
(
filePath
)
==
favoriteSet
->
end
()
)
{
QFileInfo
fileInfo
(
filePath
);
QString
fileName
=
fileInfo
.
fileName
();
UBFeature
elem
(
favoritePath
,
thumbnailForFile
(
filePath
),
fileName
,
filePath
,
fileTypeFromUrl
(
filePath
)
);
favoriteSet
->
insert
(
filePath
);
saveFavoriteList
();
return
elem
;
}
return
UBFeature
();
}
QString
UBFeaturesController
::
fileNameFromUrl
(
const
QUrl
&
url
)
{
QString
fileName
=
url
.
toString
();
if
(
fileName
.
contains
(
"uniboardTool://"
)
)
return
fileName
;
return
url
.
toLocalFile
();
}
UBFeatureElementType
UBFeaturesController
::
fileTypeFromUrl
(
const
QString
&
path
)
{
QFileInfo
fileInfo
(
path
);
QString
fileName
=
fileInfo
.
fileName
();
UBFeatureElementType
fileType
=
fileInfo
.
isDir
()
?
FEATURE_FOLDER
:
FEATURE_ITEM
;
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
fileName
).
contains
(
"application"
)
)
{
fileType
=
FEATURE_INTERACTIVE
;
}
else
if
(
path
.
contains
(
"uniboardTool://"
)
)
{
fileType
=
FEATURE_INTERNAL
;
}
return
fileType
;
}
QPixmap
UBFeaturesController
::
thumbnailForFile
(
const
QString
&
path
)
{
if
(
path
.
contains
(
"uniboardTool://"
)
)
{
return
QPixmap
(
UBToolsManager
::
manager
()
->
iconFromToolId
(
path
)
);
}
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
path
).
contains
(
"application"
)
)
{
return
QPixmap
(
UBAbstractWidget
::
iconFilePath
(
QUrl
::
fromLocalFile
(
path
)
)
);
}
QPixmap
thumb
;
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
path
);
...
...
src/board/UBFeaturesController.h
View file @
fe0c8ab2
...
...
@@ -66,11 +66,16 @@ public:
static
void
deleteItem
(
const
QUrl
&
url
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
private
:
void
initDirectoryTree
();
void
fileSystemScan
(
const
QString
&
currPath
,
const
QString
&
currVirtualPath
);
static
QPixmap
createThumbnail
(
const
QString
&
path
);
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
saveFavoriteList
();
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
QVector
<
UBFeature
>
*
featuresList
;
UBFeature
*
rootElement
;
...
...
@@ -100,10 +105,14 @@ private:
QString
shapesPath
;
QString
interactPath
;
QString
trashPath
;
QString
favoritePath
;
int
mLastItemOffsetIndex
;
UBFeature
currentElement
;
UBFeature
trashElement
;
UBFeature
favoriteElement
;
QSet
<
QString
>
*
favoriteSet
;
};
...
...
src/gui/UBFeaturesActionBar.cpp
View file @
fe0c8ab2
...
...
@@ -180,6 +180,12 @@ void UBFeaturesActionBar::dropEvent( QDropEvent *event )
event
->
accept
();
emit
deleteElements
(
*
event
->
mimeData
()
);
}
if
(
dest
==
mpFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
CopyAction
);
event
->
accept
();
emit
addToFavorite
(
*
event
->
mimeData
()
);
}
}
...
...
src/gui/UBFeaturesActionBar.h
View file @
fe0c8ab2
...
...
@@ -27,6 +27,7 @@ signals:
void
searchElement
(
const
QString
&
text
);
void
newFolderToCreate
();
void
deleteElements
(
const
QMimeData
&
data
);
void
addToFavorite
(
const
QMimeData
&
data
);
private
slots
:
void
onSearchTextChanged
(
QString
txt
);
void
onActionNewFolder
();
...
...
src/gui/UBFeaturesWidget.cpp
View file @
fe0c8ab2
...
...
@@ -97,7 +97,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
this
,
SLOT
(
currentSelected
(
const
QModelIndex
&
)
)
);
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
(
mActionBar
,
SIGNAL
(
deleteElements
(
const
QMimeData
&
)
),
this
,
SLOT
(
deleteElements
(
const
QMimeData
&
)
)
);
connect
(
mActionBar
,
SIGNAL
(
addToFavorite
(
const
QMimeData
&
)
),
this
,
SLOT
(
addToFavorite
(
const
QMimeData
&
)
)
);
connect
(
pathListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)
),
this
,
SLOT
(
currentPathChanged
(
const
QModelIndex
&
)
)
);
}
...
...
@@ -211,6 +212,22 @@ void UBFeaturesWidget::deleteElements( const QMimeData & mimeData )
model
->
invalidate
();
}
void
UBFeaturesWidget
::
addToFavorite
(
const
QMimeData
&
mimeData
)
{
if
(
!
mimeData
.
hasUrls
()
)
return
;
QList
<
QUrl
>
urls
=
mimeData
.
urls
();
foreach
(
QUrl
url
,
urls
)
{
UBFeature
elem
=
controller
->
addToFavorite
(
url
);
if
(
!
elem
.
getUrl
().
isEmpty
()
&&
!
elem
.
getUrl
().
isNull
()
)
featuresModel
->
addItem
(
elem
);
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
}
void
UBFeaturesWidget
::
switchToListView
()
{
stackedWidget
->
setCurrentIndex
(
ID_LISTVIEW
);
...
...
@@ -500,6 +517,19 @@ void UBFeaturesModel::addItem( const UBFeature &item )
endInsertRows
();
}
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
)
)
{
removeRow
(
i
,
QModelIndex
()
);
return
;
}
}
}
bool
UBFeaturesModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
{
if
(
row
<
0
)
...
...
@@ -590,7 +620,7 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde
UBFeature
feature
=
sourceModel
()
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
bool
isFolder
=
feature
.
getType
()
==
FEATURE_CATEGORY
||
feature
.
getType
()
==
FEATURE_FOLDER
;
feature
.
getType
()
==
FEATURE_FOLDER
||
feature
.
getType
()
==
FEATURE_TRASH
;
QString
virtualFullPath
=
feature
.
getUrl
()
+
"/"
+
feature
.
getName
();
return
isFolder
&&
path
.
startsWith
(
virtualFullPath
);
...
...
src/gui/UBFeaturesWidget.h
View file @
fe0c8ab2
...
...
@@ -83,6 +83,7 @@ private slots:
void
searchStarted
(
const
QString
&
);
void
createNewFolder
();
void
deleteElements
(
const
QMimeData
&
);
void
addToFavorite
(
const
QMimeData
&
);
};
class
UBFeaturesListView
:
public
QListView
...
...
@@ -96,46 +97,6 @@ protected:
virtual
void
dropEvent
(
QDropEvent
*
event
);
};
/*
class UBFeaturesPathViewer : public QGraphicsView
{
Q_OBJECT
public:
UBFeaturesPathViewer(const QPixmap &root, const QString &rootPath, QGraphicsScene *sc, QWidget* parent=0, const char* name="UBFeaturesPathViewer");
virtual ~UBFeaturesPathViewer() {;}
void addPathElement(const QPixmap &p, const QString &s);
void truncatePath(int number);
private:
QGraphicsLinearLayout *layout;
QGraphicsWidget *container;
QPixmap *arrowPixmap;
};
class UBFolderWidget : public QLabel
{
Q_OBJECT
public:
UBFolderWidget( QWidget * parent = 0, Qt::WindowFlags f = 0 ) : QLabel( parent, f ) {;}
virtual ~UBFolderWidget() {;}
virtual QString getPath()const { return path;}
virtual void setPath( const QString &p ) { path = p;}
signals:
void clicked(const QString &);
protected:
virtual void mouseReleaseEvent ( QMouseEvent * ev )
{
Q_UNUSED(ev)
emit clicked(path);
}
virtual void mousePressEvent ( QMouseEvent * ev )
{
ev->accept();
}
private:
QString path;
};
*/
class
UBFeatureProperties
:
public
QWidget
{
...
...
@@ -190,6 +151,8 @@ public:
virtual
~
UBFeaturesModel
(){;}
void
addItem
(
const
UBFeature
&
item
);
void
deleteFavoriteItem
(
const
QString
&
path
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
QMimeData
*
mimeData
(
const
QModelIndexList
&
indexes
)
const
;
QStringList
mimeTypes
()
const
;
...
...
@@ -198,6 +161,7 @@ public:
bool
dropMimeData
(
const
QMimeData
*
mimeData
,
Qt
::
DropAction
action
,
int
row
,
int
column
,
const
QModelIndex
&
parent
);
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
Qt
::
DropActions
supportedDropActions
()
const
{
return
Qt
::
MoveAction
|
Qt
::
CopyAction
;
}
void
setFeaturesList
(
QVector
<
UBFeature
>
*
flist
)
{
featuresList
=
flist
;
}
...
...
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