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
2033c14f
Commit
2033c14f
authored
Jul 30, 2012
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Features widget featuring and refactoring
parent
40142401
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
998 additions
and
666 deletions
+998
-666
style.qss
resources/style.qss
+7
-6
UBBoardPaletteManager.cpp
src/board/UBBoardPaletteManager.cpp
+6
-6
UBBoardPaletteManager.h
src/board/UBBoardPaletteManager.h
+3
-3
UBBoardView.h
src/board/UBBoardView.h
+1
-1
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+281
-109
UBFeaturesController.h
src/board/UBFeaturesController.h
+83
-24
UBSetting.cpp
src/core/UBSetting.cpp
+4
-0
UBSetting.h
src/core/UBSetting.h
+1
-0
UBSettings.cpp
src/core/UBSettings.cpp
+2
-0
UBSettings.h
src/core/UBSettings.h
+2
-0
UBFileSystemUtils.cpp
src/frameworks/UBFileSystemUtils.cpp
+11
-2
UBFileSystemUtils.h
src/frameworks/UBFileSystemUtils.h
+4
-2
UBFeaturesActionBar.cpp
src/gui/UBFeaturesActionBar.cpp
+51
-29
UBFeaturesActionBar.h
src/gui/UBFeaturesActionBar.h
+15
-9
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+422
-416
UBFeaturesWidget.h
src/gui/UBFeaturesWidget.h
+104
-58
UBRubberBand.cpp
src/gui/UBRubberBand.cpp
+1
-1
No files found.
resources/style.qss
View file @
2033c14f
...
@@ -5,7 +5,9 @@ QWidget#UBLibNavigatorWidget,
...
@@ -5,7 +5,9 @@ QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget,
QWidget#UBDownloadWidget,
QWidget#UBTeacherGuideWidget,
QWidget#UBTeacherGuideWidget,
QWidget#UBFeatureProperties
QWidget#UBFeatureProperties,
QWidget#UBFeaturesNavigatorWidget,
QWidget#PathList
{
{
background: #EEEEEE;
background: #EEEEEE;
border-radius: 10px;
border-radius: 10px;
...
@@ -26,14 +28,13 @@ QWidget#UBLibWebView
...
@@ -26,14 +28,13 @@ QWidget#UBLibWebView
border: 2px solid #999999;
border: 2px solid #999999;
}
}
Q
Widget#UBFeaturesWeb
View
Q
List
View
{
{
background: #EEEEEE;
border: 0px;
border-radius : 10px;
border: 2px solid #999999;
}
}
QListView
QWidget#UBFeaturesWebView
{
{
background: #EEEEEE;
background: #EEEEEE;
border-radius : 10px;
border-radius : 10px;
...
...
src/board/UBBoardPaletteManager.cpp
View file @
2033c14f
...
@@ -83,9 +83,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
...
@@ -83,9 +83,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
,
mPendingPanButtonPressed
(
false
)
,
mPendingPanButtonPressed
(
false
)
,
mPendingEraseButtonPressed
(
false
)
,
mPendingEraseButtonPressed
(
false
)
,
mpPageNavigWidget
(
NULL
)
,
mpPageNavigWidget
(
NULL
)
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
,
mpLibWidget
(
NULL
)
,
mpLibWidget
(
NULL
)
#endif
//
#endif
,
mpCachePropWidget
(
NULL
)
,
mpCachePropWidget
(
NULL
)
,
mpDownloadWidget
(
NULL
)
,
mpDownloadWidget
(
NULL
)
,
mpDesktopLibWidget
(
NULL
)
,
mpDesktopLibWidget
(
NULL
)
...
@@ -136,9 +136,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
...
@@ -136,9 +136,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpPageNavigWidget
=
new
UBPageNavigationWidget
();
mpPageNavigWidget
=
new
UBPageNavigationWidget
();
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
mpLibWidget
=
new
UBLibWidget
();
mpLibWidget
=
new
UBLibWidget
();
#endif
//
#endif
mpCachePropWidget
=
new
UBCachePropertiesWidget
();
mpCachePropWidget
=
new
UBCachePropertiesWidget
();
...
@@ -170,10 +170,10 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
...
@@ -170,10 +170,10 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//Do not show deprecated lib widget to prevent collisions. Uncomment to return lib widget
//Do not show deprecated lib widget to prevent collisions. Uncomment to return lib widget
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
mRightPalette
->
registerWidget
(
mpLibWidget
);
mRightPalette
->
registerWidget
(
mpLibWidget
);
mRightPalette
->
addTab
(
mpLibWidget
);
mRightPalette
->
addTab
(
mpLibWidget
);
#endif
//
#endif
// The cache widget will be visible only if a cache is put on the page
// The cache widget will be visible only if a cache is put on the page
...
...
src/board/UBBoardPaletteManager.h
View file @
2033c14f
...
@@ -45,7 +45,7 @@ class UBApplicationController;
...
@@ -45,7 +45,7 @@ class UBApplicationController;
class
UBDockTeacherGuideWidget
;
class
UBDockTeacherGuideWidget
;
// Uncomment this to use old-styles lib paletter
// Uncomment this to use old-styles lib paletter
#define USE_WEB_WIDGET
//
#define USE_WEB_WIDGET
class
UBBoardPaletteManager
:
public
QObject
class
UBBoardPaletteManager
:
public
QObject
...
@@ -134,10 +134,10 @@ class UBBoardPaletteManager : public QObject
...
@@ -134,10 +134,10 @@ class UBBoardPaletteManager : public QObject
/** The page navigator widget */
/** The page navigator widget */
UBPageNavigationWidget
*
mpPageNavigWidget
;
UBPageNavigationWidget
*
mpPageNavigWidget
;
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
/** The library widget */
/** The library widget */
UBLibWidget
*
mpLibWidget
;
UBLibWidget
*
mpLibWidget
;
#endif
//
#endif
/** The cache properties widget */
/** The cache properties widget */
UBCachePropertiesWidget
*
mpCachePropWidget
;
UBCachePropertiesWidget
*
mpCachePropWidget
;
...
...
src/board/UBBoardView.h
View file @
2033c14f
...
@@ -28,7 +28,7 @@ class UBRubberBand;
...
@@ -28,7 +28,7 @@ class UBRubberBand;
class
UBBoardView
:
public
QGraphicsView
class
UBBoardView
:
public
QGraphicsView
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
...
...
src/board/UBFeaturesController.cpp
View file @
2033c14f
...
@@ -18,12 +18,27 @@
...
@@ -18,12 +18,27 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "gui/UBFeaturesWidget.h"
const
QString
UBFeaturesController
::
virtualRootName
=
"root"
;
UBFeature
::
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QUrl
&
realPath
,
UBFeatureElementType
type
)
UBFeature
::
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QUrl
&
realPath
,
UBFeatureElementType
type
)
:
virtual
Path
(
url
),
mThumbnail
(
icon
),
mName
(
name
),
mPath
(
realPath
),
elementType
(
type
)
:
virtual
Dir
(
url
),
mThumbnail
(
icon
),
mName
(
name
),
mPath
(
realPath
),
elementType
(
type
)
{
{
}
}
UBFeature
::~
UBFeature
()
{
for
(
int
i
=
0
;
i
<
mChildren
.
count
();
i
++
)
{
delete
mChildren
[
i
];
}
for
(
int
i
=
0
;
i
<
mParents
.
count
();
i
++
)
{
mParents
[
i
]
->
mChildren
.
removeAll
(
this
);
}
}
QString
UBFeature
::
getUrl
()
const
QString
UBFeature
::
getUrl
()
const
{
{
if
(
elementType
==
FEATURE_INTERNAL
)
if
(
elementType
==
FEATURE_INTERNAL
)
...
@@ -35,7 +50,7 @@ QString UBFeature::getUrl() const
...
@@ -35,7 +50,7 @@ QString UBFeature::getUrl() const
bool
UBFeature
::
operator
==
(
const
UBFeature
&
f
)
const
bool
UBFeature
::
operator
==
(
const
UBFeature
&
f
)
const
{
{
return
virtualPath
==
f
.
getVirtualPath
()
&&
mName
==
f
.
getName
()
&&
mPath
==
f
.
getFullPath
()
&&
elementType
==
f
.
getType
();
return
virtualDir
==
f
.
getVirtualPath
()
&&
mName
==
f
.
getName
()
&&
mPath
==
f
.
getFullPath
()
&&
elementType
==
f
.
getType
();
}
}
bool
UBFeature
::
operator
!=
(
const
UBFeature
&
f
)
const
bool
UBFeature
::
operator
!=
(
const
UBFeature
&
f
)
const
...
@@ -51,70 +66,105 @@ bool UBFeature::isFolder() const
...
@@ -51,70 +66,105 @@ bool UBFeature::isFolder() const
bool
UBFeature
::
isDeletable
()
const
bool
UBFeature
::
isDeletable
()
const
{
{
return
elementType
==
FEATURE_ITEM
;
return
elementType
==
FEATURE_ITEM
||
elementType
==
FEATURE_FOLDER
;
}
bool
UBFeature
::
inTrash
()
const
{
return
getFullPath
().
toLocalFile
().
startsWith
(
QUrl
::
fromLocalFile
(
UBSettings
::
userTrashDirPath
()).
toLocalFile
()
);
}
}
UBFeaturesController
::
UBFeaturesController
(
QWidget
*
pParentWidget
)
:
UBFeaturesController
::
UBFeaturesController
(
QWidget
*
pParentWidget
)
:
QObject
(
pParentWidget
),
QObject
(
pParentWidget
)
mLastItemOffsetIndex
(
0
)
,
featuresList
(
0
)
,
mLastItemOffsetIndex
(
0
)
{
{
rootPath
=
"/root"
;
//Initializing virtual structure of the list
initDirectoryTree
();
rootPath
=
"/"
+
virtualRootName
;
appPath
=
rootPath
+
"/Applications"
;
audiosPath
=
rootPath
+
"/Audios"
;
moviesPath
=
rootPath
+
"/Movies"
;
picturesPath
=
rootPath
+
"/Pictures"
;
flashPath
=
rootPath
+
"/Animations"
;
interactPath
=
rootPath
+
"/Interactivities"
;
shapesPath
=
rootPath
+
"/Shapes"
;
trashPath
=
rootPath
+
"/Trash"
;
favoritePath
=
rootPath
+
"/Favorites"
;
//Initializing physical directories from UBSettings
mUserAudioDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userAudioDirectory
());
mUserVideoDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userVideoDirectory
());
mUserPicturesDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userImageDirectory
());
mUserInteractiveDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userInteractiveDirectory
());
mUserAnimationDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userAnimationDirectory
());
mLibPicturesDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationImageLibraryDirectory
());
mLibInteractiveDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationInteractivesDirectory
());
mLibApplicationsDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationApplicationsLibraryDirectory
());
mLibShapesDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationShapeLibraryDirectory
());
mLibSearchDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userSearchDirectory
());
trashDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
userTrashDirPath
());
rootElement
=
UBFeature
(
QString
(),
QPixmap
(
":images/libpalette/home.png"
),
"root"
,
QUrl
());
audiosElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/AudiosCategory.svg"
),
"Audios"
,
mUserAudioDirectoryPath
,
FEATURE_CATEGORY
);
moviesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/MoviesCategory.svg"
),
"Movies"
,
mUserVideoDirectoryPath
,
FEATURE_CATEGORY
);
picturesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/PicturesCategory.svg"
),
"Pictures"
,
mUserPicturesDirectoryPath
,
FEATURE_CATEGORY
);
flashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FlashCategory.svg"
),
"Animations"
,
mUserAnimationDirectoryPath
,
FEATURE_CATEGORY
);
interactElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/InteractivesCategory.svg"
),
"Interactivities"
,
mLibInteractiveDirectoryPath
,
FEATURE_CATEGORY
);
applicationsElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ApplicationsCategory.svg"
),
"Applications"
,
mUserInteractiveDirectoryPath
,
FEATURE_CATEGORY
);
shapesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ShapesCategory.svg"
),
"Shapes"
,
mLibShapesDirectoryPath
,
FEATURE_CATEGORY
);
favoriteElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FavoritesCategory.svg"
),
"Favorites"
,
QUrl
(
"favorites"
),
FEATURE_FAVORITE
);
webSearchElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/WebSearchCategory.svg"
),
"Web search"
,
mLibSearchDirectoryPath
,
FEATURE_SEARCH
);
trashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/TrashCategory.svg"
),
"Trash"
,
trashDirectoryPath
,
FEATURE_TRASH
);
featuresList
=
new
QList
<
UBFeature
>
();
scanFS
();
featuresModel
=
new
UBFeaturesModel
(
featuresList
,
this
);
featuresModel
->
setSupportedDragActions
(
Qt
::
CopyAction
|
Qt
::
MoveAction
);
featuresProxyModel
=
new
UBFeaturesProxyModel
(
this
);
featuresProxyModel
->
setFilterFixedString
(
rootPath
);
featuresProxyModel
->
setSourceModel
(
featuresModel
);
featuresProxyModel
->
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
featuresSearchModel
=
new
UBFeaturesSearchProxyModel
(
this
);
featuresSearchModel
->
setSourceModel
(
featuresModel
);
featuresSearchModel
->
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
featuresPathModel
=
new
UBFeaturesPathProxyModel
(
this
);
featuresPathModel
->
setPath
(
rootPath
);
featuresPathModel
->
setSourceModel
(
featuresModel
);
connect
(
featuresModel
,
SIGNAL
(
dataRestructured
()),
featuresProxyModel
,
SLOT
(
invalidate
()));
}
}
void
UBFeaturesController
::
initDirectoryTree
()
void
UBFeaturesController
::
scanFS
()
{
{
mUserAudioDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userAudioDirectory
()
);
featuresList
->
clear
();
mUserVideoDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userVideoDirectory
()
);
featuresList
->
append
(
rootElement
);
mUserPicturesDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userImageDirectory
()
);
mUserInteractiveDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userInteractiveDirectory
()
);
mUserAnimationDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userAnimationDirectory
()
);
mLibPicturesDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationImageLibraryDirectory
()
);
*
featuresList
<<
audiosElement
mLibInteractiveDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationInteractivesDirectory
()
);
<<
moviesElement
mLibApplicationsDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationApplicationsLibraryDirectory
()
);
<<
picturesElement
mLibShapesDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
applicationShapeLibraryDirectory
()
);
<<
flashElement
mLibSearchDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
settings
()
->
userSearchDirectory
()
);
<<
interactElement
trashDirectoryPath
=
QUrl
::
fromLocalFile
(
UBSettings
::
userTrashDirPath
()
);
<<
applicationsElement
<<
shapesElement
<<
favoriteElement
<<
webSearchElement
<<
trashElement
;
featuresList
=
new
QList
<
UBFeature
>
();
loadFavoriteList
();
QList
<
UBToolsManager
::
UBToolDescriptor
>
tools
=
UBToolsManager
::
manager
()
->
allTools
();
QList
<
UBToolsManager
::
UBToolDescriptor
>
tools
=
UBToolsManager
::
manager
()
->
allTools
();
featuresList
->
append
(
UBFeature
(
QString
(),
QPixmap
(
":images/libpalette/home.png"
),
"root"
,
QUrl
()
)
);
foreach
(
UBToolsManager
::
UBToolDescriptor
tool
,
tools
)
currentElement
=
featuresList
->
at
(
0
);
appPath
=
rootPath
+
"/Applications"
;
audiosPath
=
rootPath
+
"/Audios"
;
moviesPath
=
rootPath
+
"/Movies"
;
picturesPath
=
rootPath
+
"/Pictures"
;
flashPath
=
rootPath
+
"/Animations"
;
interactPath
=
rootPath
+
"/Interactivities"
;
shapesPath
=
rootPath
+
"/Shapes"
;
trashPath
=
rootPath
+
"/Trash"
;
favoritePath
=
rootPath
+
"/Favorites"
;
audiosElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/AudiosCategory.svg"
),
"Audios"
,
mUserAudioDirectoryPath
);
featuresList
->
append
(
audiosElement
);
moviesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/MoviesCategory.svg"
),
"Movies"
,
mUserVideoDirectoryPath
);
featuresList
->
append
(
moviesElement
);
picturesElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/PicturesCategory.svg"
),
"Pictures"
,
mUserPicturesDirectoryPath
);
featuresList
->
append
(
picturesElement
);
featuresList
->
append
(
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/ApplicationsCategory.svg"
),
"Applications"
,
mUserInteractiveDirectoryPath
)
);
flashElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/FlashCategory.svg"
),
"Animations"
,
mUserAnimationDirectoryPath
);
featuresList
->
append
(
flashElement
);
interactElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/InteractivesCategory.svg"
),
"Interactivities"
,
mLibInteractiveDirectoryPath
);
featuresList
->
append
(
interactElement
);
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"
,
QUrl
(
"favorites"
),
FEATURE_FAVORITE
);
featuresList
->
append
(
favoriteElement
);
webSearchElement
=
UBFeature
(
rootPath
,
QPixmap
(
":images/libpalette/WebSearchCategory.svg"
),
"Web search"
,
mLibSearchDirectoryPath
);
featuresList
->
append
(
webSearchElement
);
loadFavoriteList
();
foreach
(
UBToolsManager
::
UBToolDescriptor
tool
,
tools
)
{
{
featuresList
->
append
(
UBFeature
(
appPath
,
tool
.
icon
,
tool
.
label
,
QUrl
(
tool
.
id
),
FEATURE_INTERNAL
)
);
featuresList
->
append
(
UBFeature
(
appPath
,
tool
.
icon
,
tool
.
label
,
QUrl
(
tool
.
id
),
FEATURE_INTERNAL
)
);
if
(
favoriteSet
->
find
(
QUrl
(
tool
.
id
)
)
!=
favoriteSet
->
end
()
)
if
(
favoriteSet
->
find
(
QUrl
(
tool
.
id
)
)
!=
favoriteSet
->
end
()
)
...
@@ -122,19 +172,19 @@ void UBFeaturesController::initDirectoryTree()
...
@@ -122,19 +172,19 @@ void UBFeaturesController::initDirectoryTree()
featuresList
->
append
(
UBFeature
(
favoritePath
,
tool
.
icon
,
tool
.
label
,
QUrl
(
tool
.
id
),
FEATURE_INTERNAL
)
);
featuresList
->
append
(
UBFeature
(
favoritePath
,
tool
.
icon
,
tool
.
label
,
QUrl
(
tool
.
id
),
FEATURE_INTERNAL
)
);
}
}
}
}
fileSystemScan
(
mUserInteractiveDirectoryPath
,
appPath
);
fileSystemScan
(
mUserAudioDirectoryPath
,
audiosPath
);
fileSystemScan
(
mUserInteractiveDirectoryPath
,
appPath
);
fileSystemScan
(
mUserPicturesDirectoryPath
,
picturesPath
);
fileSystemScan
(
mUserAudioDirectoryPath
,
audiosPath
);
fileSystemScan
(
mUserVideoDirectoryPath
,
moviesPath
);
fileSystemScan
(
mUserPicturesDirectoryPath
,
picturesPath
);
fileSystemScan
(
mUserAnimationDirectoryPath
,
flashPath
);
fileSystemScan
(
mUserVideoDirectoryPath
,
moviesPath
);
fileSystemScan
(
mUserAnimationDirectoryPath
,
flashPath
);
fileSystemScan
(
mLibApplicationsDirectoryPath
,
appPath
);
fileSystemScan
(
mLibPicturesDirectoryPath
,
picturesPath
);
fileSystemScan
(
mLibApplicationsDirectoryPath
,
appPath
);
fileSystemScan
(
mLibShapesDirectoryPath
,
shapesPath
);
fileSystemScan
(
mLibPicturesDirectoryPath
,
picturesPath
);
fileSystemScan
(
mLibInteractiveDirectoryPath
,
interactPath
);
fileSystemScan
(
mLibShapesDirectoryPath
,
shapesPath
);
fileSystemScan
(
trashDirectoryPath
,
trashPath
);
fileSystemScan
(
mLibInteractiveDirectoryPath
,
interactPath
);
fileSystemScan
(
mLibSearchDirectoryPath
,
rootPath
+
"/"
+
"Web search"
);
fileSystemScan
(
trashDirectoryPath
,
trashPath
);
fileSystemScan
(
mLibSearchDirectoryPath
,
rootPath
+
"/"
+
"Web search"
);
}
}
...
@@ -181,7 +231,14 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
...
@@ -181,7 +231,14 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
icon = QPixmap( thumbnailPath );
icon = QPixmap( thumbnailPath );
else icon = createThumbnail( fullFileName );*/
else icon = createThumbnail( fullFileName );*/
}
}
featuresList
->
append
(
UBFeature
(
currVirtualPath
,
icon
,
fileName
,
QUrl
::
fromLocalFile
(
fullFileName
),
fileType
)
);
UBFeature
testFeature
(
currVirtualPath
,
icon
,
fileName
,
QUrl
::
fromLocalFile
(
fullFileName
),
fileType
);
if
(
featuresList
->
contains
(
testFeature
))
{
qDebug
()
<<
"the same feature found"
;
}
featuresList
->
append
(
testFeature
);
if
(
favoriteSet
->
find
(
QUrl
::
fromLocalFile
(
fullFileName
)
)
!=
favoriteSet
->
end
()
)
if
(
favoriteSet
->
find
(
QUrl
::
fromLocalFile
(
fullFileName
)
)
!=
favoriteSet
->
end
()
)
{
{
featuresList
->
append
(
UBFeature
(
favoritePath
,
icon
,
fileName
,
QUrl
::
fromLocalFile
(
fullFileName
),
fileType
)
);
featuresList
->
append
(
UBFeature
(
favoritePath
,
icon
,
fileName
,
QUrl
::
fromLocalFile
(
fullFileName
),
fileType
)
);
...
@@ -189,7 +246,7 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
...
@@ -189,7 +246,7 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
if
(
fileType
==
FEATURE_FOLDER
)
if
(
fileType
==
FEATURE_FOLDER
)
{
{
fileSystemScan
(
QUrl
::
fromLocalFile
(
fullFileName
),
currVirtualPath
+
"/"
+
fileName
);
fileSystemScan
(
QUrl
::
fromLocalFile
(
fullFileName
),
currVirtualPath
+
"/"
+
fileName
);
}
}
}
}
...
@@ -233,7 +290,7 @@ void UBFeaturesController::saveFavoriteList()
...
@@ -233,7 +290,7 @@ void UBFeaturesController::saveFavoriteList()
file
.
close
();
file
.
close
();
}
}
UBFeature
UBFeaturesController
::
addToFavorite
(
const
QUrl
&
path
)
void
UBFeaturesController
::
addToFavorite
(
const
QUrl
&
path
)
{
{
QString
filePath
=
fileNameFromUrl
(
path
);
QString
filePath
=
fileNameFromUrl
(
path
);
if
(
favoriteSet
->
find
(
path
)
==
favoriteSet
->
end
()
)
if
(
favoriteSet
->
find
(
path
)
==
favoriteSet
->
end
()
)
...
@@ -243,19 +300,24 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
...
@@ -243,19 +300,24 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
UBFeature
elem
(
favoritePath
,
thumbnailForFile
(
filePath
),
fileName
,
path
,
fileTypeFromUrl
(
filePath
)
);
UBFeature
elem
(
favoritePath
,
thumbnailForFile
(
filePath
),
fileName
,
path
,
fileTypeFromUrl
(
filePath
)
);
favoriteSet
->
insert
(
path
);
favoriteSet
->
insert
(
path
);
saveFavoriteList
();
saveFavoriteList
();
return
elem
;
if
(
!
elem
.
getVirtualPath
().
isEmpty
()
&&
!
elem
.
getVirtualPath
().
isNull
())
featuresModel
->
addItem
(
elem
);
}
}
return
UBFeature
();
}
}
void
UBFeaturesController
::
removeFromFavorite
(
const
QUrl
&
path
)
void
UBFeaturesController
::
removeFromFavorite
(
const
QUrl
&
path
,
bool
deleteManualy
)
{
{
QString
filePath
=
fileNameFromUrl
(
path
);
//
QString filePath = fileNameFromUrl( path );
if
(
favoriteSet
->
find
(
path
)
!=
favoriteSet
->
end
()
)
if
(
favoriteSet
->
find
(
path
)
!=
favoriteSet
->
end
()
)
{
{
favoriteSet
->
erase
(
favoriteSet
->
find
(
path
)
);
favoriteSet
->
erase
(
favoriteSet
->
find
(
path
)
);
saveFavoriteList
();
saveFavoriteList
();
}
}
if
(
deleteManualy
)
{
featuresModel
->
deleteFavoriteItem
(
path
.
toString
());
}
}
}
QString
UBFeaturesController
::
fileNameFromUrl
(
const
QUrl
&
url
)
QString
UBFeaturesController
::
fileNameFromUrl
(
const
QUrl
&
url
)
...
@@ -366,15 +428,18 @@ UBFeature UBFeaturesController::importImage( const QImage &image, const UBFeatur
...
@@ -366,15 +428,18 @@ UBFeature UBFeaturesController::importImage( const QImage &image, const UBFeatur
}
}
UBFeature
UBFeaturesController
::
newFolder
(
const
QString
&
name
)
void
UBFeaturesController
::
addNewFolder
(
const
QString
&
name
)
{
{
QString
path
=
currentElement
.
getFullPath
().
toLocalFile
()
+
"/"
+
name
;
QString
path
=
currentElement
.
getFullPath
().
toLocalFile
()
+
"/"
+
name
;
if
(
!
QFileInfo
(
path
).
exists
())
{
if
(
!
QFileInfo
(
path
).
exists
())
{
QDir
().
mkpath
(
path
);
QDir
().
mkpath
(
path
);
}
}
return
UBFeature
(
currentElement
.
getFullVirtualPath
(),
QPixmap
(
":images/libpalette/folder.svg"
),
UBFeature
newFeatureFolder
=
UBFeature
(
currentElement
.
getFullVirtualPath
(),
QPixmap
(
":images/libpalette/folder.svg"
),
name
,
QUrl
::
fromLocalFile
(
path
),
FEATURE_FOLDER
);
name
,
QUrl
::
fromLocalFile
(
path
),
FEATURE_FOLDER
);
featuresModel
->
addItem
(
newFeatureFolder
);
featuresProxyModel
->
invalidate
();
}
}
void
UBFeaturesController
::
addItemToPage
(
const
UBFeature
&
item
)
void
UBFeaturesController
::
addItemToPage
(
const
UBFeature
&
item
)
...
@@ -387,8 +452,7 @@ void UBFeaturesController::addItemAsBackground(const UBFeature &item)
...
@@ -387,8 +452,7 @@ void UBFeaturesController::addItemAsBackground(const UBFeature &item)
UBApplication
::
boardController
->
downloadURL
(
item
.
getFullPath
(),
QPointF
(),
QSize
(),
true
);
UBApplication
::
boardController
->
downloadURL
(
item
.
getFullPath
(),
QPointF
(),
QSize
(),
true
);
}
}
UBFeature
UBFeaturesController
::
getParentFeatureForUrl
(
const
QUrl
&
url
)
UBFeature
UBFeaturesController
::
getDestinationForItem
(
const
QUrl
&
url
)
{
{
QString
mimetype
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
.
toString
()
);
QString
mimetype
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
.
toString
()
);
...
@@ -410,7 +474,7 @@ UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url )
...
@@ -410,7 +474,7 @@ UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url )
UBFeature
UBFeaturesController
::
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
)
UBFeature
UBFeaturesController
::
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
)
{
{
UBFeature
dest
=
get
DestinationForItem
(
sourceUrl
);
UBFeature
dest
=
get
ParentFeatureForUrl
(
sourceUrl
);
if
(
dest
==
UBFeature
()
)
if
(
dest
==
UBFeature
()
)
return
UBFeature
();
return
UBFeature
();
QString
fileName
=
QFileInfo
(
sourceUrl
.
toString
()
).
fileName
();
QString
fileName
=
QFileInfo
(
sourceUrl
.
toString
()
).
fileName
();
...
@@ -436,7 +500,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
...
@@ -436,7 +500,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
UBFeature
possibleDest
=
getDestinationForItem
(
url
);
UBFeature
possibleDest
=
getParentFeatureForUrl
(
url
);
UBFeature
dest
=
destination
;
UBFeature
dest
=
destination
;
...
@@ -462,59 +526,167 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
...
@@ -462,59 +526,167 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
newFullPath
).
contains
(
"application"
)
)
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
newFullPath
).
contains
(
"application"
)
)
type
=
FEATURE_INTERACTIVE
;
type
=
FEATURE_INTERACTIVE
;
UBFeature
newElement
(
destVirtualPath
,
thumb
,
name
,
QUrl
::
fromLocalFile
(
newFullPath
),
type
);
UBFeature
newElement
(
destVirtualPath
,
thumb
,
name
,
QUrl
::
fromLocalFile
(
newFullPath
),
type
);
return
newElement
;
return
newElement
;
}
void
UBFeaturesController
::
rescanModel
()
{
featuresModel
->
removeRows
(
0
,
featuresList
->
count
()
-
1
);
//Could implement infolder scanning for better perfomance
scanFS
();
refreshModels
();
}
void
UBFeaturesController
::
siftElements
(
const
QString
&
pSiftValue
)
{
featuresProxyModel
->
setFilterFixedString
(
pSiftValue
);
featuresProxyModel
->
invalidate
();
featuresPathModel
->
setPath
(
pSiftValue
);
featuresPathModel
->
invalidate
();
}
UBFeature
UBFeaturesController
::
getFeature
(
const
QModelIndex
&
index
,
QListView
*
pOnView
)
{
return
qobject_cast
<
QSortFilterProxyModel
*>
(
pOnView
->
model
())
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
}
void
UBFeaturesController
::
searchStarted
(
const
QString
&
pattern
,
QListView
*
pOnView
)
{
if
(
pattern
.
isEmpty
())
{
pOnView
->
setModel
(
featuresProxyModel
);
featuresProxyModel
->
invalidate
();
}
else
if
(
pattern
.
size
()
>
2
)
{
featuresSearchModel
->
setFilterWildcard
(
"*"
+
pattern
+
"*"
);
pOnView
->
setModel
(
featuresSearchModel
);
featuresSearchModel
->
invalidate
();
}
}
void
UBFeaturesController
::
refreshModels
()
{
featuresProxyModel
->
invalidate
();
featuresSearchModel
->
invalidate
();
featuresPathModel
->
invalidate
();
}
}
UBFeature
UBFeaturesController
::
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
UBFeature
UBFeaturesController
::
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
)
{
{
QString
sourcePath
=
url
.
toLocalFile
();
QString
sourcePath
=
url
.
toLocalFile
();
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
UBFeature
possibleDest
=
getDestinationForItem
(
url
);
UBFeature
possibleDest
=
getParentFeatureForUrl
(
url
);
UBFeature
dest
=
destination
;
UBFeature
dest
=
destination
;
if
(
destination
!=
trashElement
&&
if
(
destination
!=
trashElement
&&
!
destination
.
getFullVirtualPath
().
startsWith
(
possibleDest
.
getFullVirtualPath
(),
Qt
::
CaseInsensitive
)
)
!
destination
.
getFullVirtualPath
().
startsWith
(
possibleDest
.
getFullVirtualPath
(),
Qt
::
CaseInsensitive
)
)
{
{
dest
=
possibleDest
;
dest
=
possibleDest
;
}
}
QString
name
=
QFileInfo
(
sourcePath
).
fileName
();
QString
name
=
QFileInfo
(
sourcePath
).
fileName
();
QString
destPath
=
dest
.
getFullPath
().
toLocalFile
();
QString
destPath
=
dest
.
getFullPath
().
toLocalFile
();
QString
destVirtualPath
=
dest
.
getFullVirtualPath
();
QString
destVirtualPath
=
dest
.
getFullVirtualPath
();
QString
newFullPath
=
destPath
+
"/"
+
name
;
QString
newFullPath
=
destPath
+
"/"
+
name
;
if
(
!
sourcePath
.
compare
(
newFullPath
,
Qt
::
CaseInsensitive
)
)
if
(
!
sourcePath
.
compare
(
newFullPath
,
Qt
::
CaseInsensitive
)
)
QFile
(
sourcePath
).
copy
(
newFullPath
);
QFile
(
sourcePath
).
copy
(
newFullPath
);
QPixmap
thumb
=
thumbnailForFile
(
newFullPath
);
QPixmap
thumb
=
thumbnailForFile
(
newFullPath
);
UBFeatureElementType
type
=
FEATURE_ITEM
;
UBFeatureElementType
type
=
FEATURE_ITEM
;
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
newFullPath
).
contains
(
"application"
)
)
if
(
UBFileSystemUtils
::
mimeTypeFromFileName
(
newFullPath
).
contains
(
"application"
)
)
type
=
FEATURE_INTERACTIVE
;
type
=
FEATURE_INTERACTIVE
;
UBFeature
newElement
(
destVirtualPath
,
thumb
,
name
,
QUrl
::
fromLocalFile
(
newFullPath
),
type
);
UBFeature
newElement
(
destVirtualPath
,
thumb
,
name
,
QUrl
::
fromLocalFile
(
newFullPath
),
type
);
return
newElement
;
return
newElement
;
}
}
void
UBFeaturesController
::
deleteItem
(
const
QUrl
&
url
)
void
UBFeaturesController
::
deleteItem
(
const
QUrl
&
url
)
{
{
QString
path
=
url
.
toLocalFile
();
QString
path
=
url
.
toLocalFile
();
Q_ASSERT
(
QFileInfo
(
path
).
exists
()
);
Q_ASSERT
(
QFileInfo
(
path
).
exists
()
);
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
path
);
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
path
);
if
(
thumbnailPath
.
length
()
&&
QFileInfo
(
thumbnailPath
).
exists
()
)
if
(
thumbnailPath
.
length
()
&&
QFileInfo
(
thumbnailPath
).
exists
())
{
{
if
(
QFileInfo
(
thumbnailPath
).
isFile
())
{
QFile
::
remove
(
thumbnailPath
);
QFile
::
remove
(
thumbnailPath
);
}
else
if
(
QFileInfo
(
thumbnailPath
).
isDir
()){
if
(
!
UBFileSystemUtils
::
deleteDir
(
thumbnailPath
))
{
qDebug
()
<<
"Not able to delete directory"
;
}
}
}
if
(
QFileInfo
(
path
).
isFile
())
{
QFile
::
remove
(
path
);
}
else
if
(
QFileInfo
(
path
).
isDir
())
{
UBFileSystemUtils
::
deleteDir
(
path
);
}
}
QFile
::
remove
(
path
);
}
void
UBFeaturesController
::
deleteItem
(
const
UBFeature
&
pFeature
)
{
QUrl
sourceUrl
=
pFeature
.
getFullPath
();
featuresModel
->
deleteItem
(
pFeature
);
deleteItem
(
sourceUrl
);
}
}
bool
UBFeaturesController
::
isTrash
(
const
QUrl
&
url
)
bool
UBFeaturesController
::
isTrash
(
const
QUrl
&
url
)
{
{
return
url
.
toLocalFile
().
startsWith
(
trashDirectoryPath
.
toLocalFile
()
);
return
url
.
toLocalFile
().
startsWith
(
trashDirectoryPath
.
toLocalFile
()
);
}
}
void
UBFeaturesController
::
moveToTrash
(
UBFeature
feature
,
bool
deleteManualy
)
{
featuresModel
->
moveData
(
feature
,
trashElement
,
Qt
::
MoveAction
,
deleteManualy
);
removeFromFavorite
(
feature
.
getFullPath
());
featuresModel
->
deleteFavoriteItem
(
UBFeaturesController
::
fileNameFromUrl
(
feature
.
getFullPath
()));
}
UBFeaturesController
::~
UBFeaturesController
()
UBFeaturesController
::~
UBFeaturesController
()
{
{
if
(
featuresList
)
{
delete
featuresList
;
}
}
void
UBFeaturesController
::
assignFeaturesListVeiw
(
UBFeaturesListView
*
pList
)
{
pList
->
setDragDropMode
(
QAbstractItemView
::
DragDrop
);
pList
->
setSelectionMode
(
QAbstractItemView
::
ContiguousSelection
);
pList
->
setResizeMode
(
QListView
::
Adjust
);
pList
->
setViewMode
(
QListView
::
IconMode
);
pList
->
setIconSize
(
QSize
(
UBFeaturesWidget
::
defaultThumbnailSize
,
UBFeaturesWidget
::
defaultThumbnailSize
));
pList
->
setGridSize
(
QSize
(
UBFeaturesWidget
::
defaultThumbnailSize
+
20
,
UBFeaturesWidget
::
defaultThumbnailSize
+
20
));
itemDelegate
=
new
UBFeaturesItemDelegate
(
this
,
pList
);
pList
->
setItemDelegate
(
itemDelegate
);
pList
->
setModel
(
featuresProxyModel
);
}
}
void
UBFeaturesController
::
assignPathListView
(
UBFeaturesListView
*
pList
)
{
pList
->
setViewMode
(
QListView
::
IconMode
);
pList
->
setIconSize
(
QSize
(
UBFeaturesWidget
::
defaultThumbnailSize
-
10
,
UBFeaturesWidget
::
defaultThumbnailSize
-
10
));
pList
->
setGridSize
(
QSize
(
UBFeaturesWidget
::
defaultThumbnailSize
+
10
,
UBFeaturesWidget
::
defaultThumbnailSize
-
10
));
pList
->
setFixedHeight
(
60
);
pList
->
setSelectionMode
(
QAbstractItemView
::
NoSelection
);
pList
->
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
pList
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOn
);
pList
->
setFlow
(
QListView
::
LeftToRight
);
pList
->
setWrapping
(
false
);
pList
->
setDragDropMode
(
QAbstractItemView
::
DropOnly
);
pList
->
setModel
(
featuresPathModel
);
pathItemDelegate
=
new
UBFeaturesPathItemDelegate
(
this
);
pList
->
setItemDelegate
(
pathItemDelegate
);
}
src/board/UBFeaturesController.h
View file @
2033c14f
...
@@ -11,6 +11,15 @@
...
@@ -11,6 +11,15 @@
#include <QMap>
#include <QMap>
#include <QUrl>
#include <QUrl>
#include <QByteArray>
#include <QByteArray>
#include <QtGui>
class
UBFeaturesModel
;
class
UBFeaturesItemDelegate
;
class
UBFeaturesPathItemDelegate
;
class
UBFeaturesProxyModel
;
class
UBFeaturesSearchProxyModel
;
class
UBFeaturesPathProxyModel
;
class
UBFeaturesListView
;
//#include "UBDockPaletteWidget.h"
//#include "UBDockPaletteWidget.h"
...
@@ -33,77 +42,122 @@ public:
...
@@ -33,77 +42,122 @@ public:
UBFeature
()
{;}
UBFeature
()
{;}
//UBFeature(const UBFeature &f);
//UBFeature(const UBFeature &f);
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QUrl
&
realPath
,
UBFeatureElementType
type
=
FEATURE_CATEGORY
);
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QUrl
&
realPath
,
UBFeatureElementType
type
=
FEATURE_CATEGORY
);
virtual
~
UBFeature
()
{;}
// UBFeature();
virtual
~
UBFeature
();
QString
getName
()
const
{
return
mName
;
}
QString
getName
()
const
{
return
mName
;
}
QPixmap
getThumbnail
()
const
{
return
mThumbnail
;}
QPixmap
getThumbnail
()
const
{
return
mThumbnail
;}
QString
getVirtualPath
()
const
{
return
virtual
Path
;
}
QString
getVirtualPath
()
const
{
return
virtual
Dir
;
}
//QString getPath() const { return mPath; };
//QString getPath() const { return mPath; };
QUrl
getFullPath
()
const
{
return
mPath
;
}
QUrl
getFullPath
()
const
{
return
mPath
;
}
QString
getFullVirtualPath
()
const
{
return
virtualPath
+
"/"
+
mName
;
}
QString
getFullVirtualPath
()
const
{
return
virtualDir
+
"/"
+
mName
;
}
QString
getUrl
()
const
;
QString
getUrl
()
const
;
void
setFullPath
(
const
QUrl
&
newPath
)
{
mPath
=
newPath
;}
void
setFullVirtualPath
(
const
QString
&
newVirtualPath
)
{
virtualDir
=
newVirtualPath
;}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
bool
isFolder
()
const
;
bool
isFolder
()
const
;
bool
isDeletable
()
const
;
bool
isDeletable
()
const
;
bool
inTrash
()
const
;
bool
operator
==
(
const
UBFeature
&
f
)
const
;
bool
operator
==
(
const
UBFeature
&
f
)
const
;
bool
operator
!=
(
const
UBFeature
&
f
)
const
;
bool
operator
!=
(
const
UBFeature
&
f
)
const
;
const
QMap
<
QString
,
QString
>
&
getMetadata
()
const
{
return
metadata
;
}
const
QMap
<
QString
,
QString
>
&
getMetadata
()
const
{
return
metadata
;
}
void
setMetadata
(
const
QMap
<
QString
,
QString
>
&
data
)
{
metadata
=
data
;
}
void
setMetadata
(
const
QMap
<
QString
,
QString
>
&
data
)
{
metadata
=
data
;
}
bool
hasChildren
()
const
{
return
mChildren
.
count
();}
bool
hasParents
()
const
{
return
mParents
.
count
();}
bool
hasRelationships
()
const
{
return
mChildren
.
count
()
&&
mParents
.
count
();}
private
:
private
:
QString
virtualPath
;
QString
virtualDir
;
QPixmap
mThumbnail
;
QPixmap
mThumbnail
;
QString
mName
;
QString
mName
;
QUrl
mPath
;
QUrl
mPath
;
UBFeatureElementType
elementType
;
UBFeatureElementType
elementType
;
QMap
<
QString
,
QString
>
metadata
;
QMap
<
QString
,
QString
>
metadata
;
QList
<
UBFeature
*>
mChildren
;
QList
<
UBFeature
*>
mParents
;
};
};
Q_DECLARE_METATYPE
(
UBFeature
)
Q_DECLARE_METATYPE
(
UBFeature
)
class
UBFeaturesController
:
public
QObject
class
UBFeaturesController
:
public
QObject
{
{
friend
class
UBFeaturesWidget
;
Q_OBJECT
Q_OBJECT
public
:
public
:
UBFeaturesController
(
QWidget
*
parentWidget
);
UBFeaturesController
(
QWidget
*
parentWidget
);
virtual
~
UBFeaturesController
();
virtual
~
UBFeaturesController
();
QList
<
UBFeature
>*
getFeatures
()
const
{
return
featuresList
;
}
QList
<
UBFeature
>*
getFeatures
()
const
{
return
featuresList
;
}
const
QString
&
getRootPath
()
const
{
return
rootPath
;
}
const
QString
&
getRootPath
()
const
{
return
rootPath
;}
void
scanFS
();
void
addItemToPage
(
const
UBFeature
&
item
);
void
addItemToPage
(
const
UBFeature
&
item
);
void
addItemAsBackground
(
const
UBFeature
&
item
);
void
addItemAsBackground
(
const
UBFeature
&
item
);
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
UBFeature
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
);
UBFeature
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
);
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
void
rescanModel
();
void
siftElements
(
const
QString
&
pSiftValue
);
//TODO make less complicated for betteer maintainence
UBFeature
getFeature
(
const
QModelIndex
&
index
,
QListView
*
pOnView
);
void
searchStarted
(
const
QString
&
pattern
,
QListView
*
pOnView
);
void
refreshModels
();
void
deleteItem
(
const
QUrl
&
url
);
void
deleteItem
(
const
QUrl
&
url
);
void
deleteItem
(
const
UBFeature
&
pFeature
);
bool
isTrash
(
const
QUrl
&
url
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
void
moveToTrash
(
UBFeature
feature
,
bool
deleteManualy
=
false
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
void
addNewFolder
(
const
QString
&
name
);
void
removeFromFavorite
(
const
QUrl
&
path
);
void
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
,
bool
deleteManualy
=
false
);
UBFeature
importImage
(
const
QImage
&
image
,
const
UBFeature
&
destination
);
UBFeature
importImage
(
const
QImage
&
image
,
const
UBFeature
&
destination
);
void
fileSystemScan
(
const
QUrl
&
currPath
,
const
QString
&
currVirtualPath
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
bool
isDeletable
(
const
QUrl
&
url
);
static
bool
isDeletable
(
const
QUrl
&
url
);
static
char
featureTypeSplitter
()
{
return
':'
;}
static
const
QString
virtualRootName
;
void
assignFeaturesListVeiw
(
UBFeaturesListView
*
pList
);
void
assignPathListView
(
UBFeaturesListView
*
pList
);
private
:
private
:
void
initDirectoryTree
();
void
fileSystemScan
(
const
QUrl
&
currPath
,
const
QString
&
currVirtualPath
);
UBFeaturesItemDelegate
*
itemDelegate
;
static
QPixmap
createThumbnail
(
const
QString
&
path
);
UBFeaturesPathItemDelegate
*
pathItemDelegate
;
UBFeaturesModel
*
featuresModel
;
UBFeaturesProxyModel
*
featuresProxyModel
;
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
private
:
static
QPixmap
createThumbnail
(
const
QString
&
path
);
//void addImageToCurrentPage( const QString &path );
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
loadFavoriteList
();
void
saveFavoriteList
();
void
saveFavoriteList
();
UBFeature
getDestinationForItem
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
QList
<
UBFeature
>
*
featuresList
;
QList
<
UBFeature
>
*
featuresList
;
UBFeature
*
rootElement
;
QUrl
mUserAudioDirectoryPath
;
QUrl
mUserAudioDirectoryPath
;
QUrl
mUserVideoDirectoryPath
;
QUrl
mUserVideoDirectoryPath
;
...
@@ -135,19 +189,24 @@ private:
...
@@ -135,19 +189,24 @@ private:
int
mLastItemOffsetIndex
;
int
mLastItemOffsetIndex
;
UBFeature
currentElement
;
UBFeature
currentElement
;
UBFeature
trashElement
;
UBFeature
favoriteElement
;
UBFeature
rootElement
;
UBFeature
favoriteElement
;
UBFeature
audiosElement
;
UBFeature
audiosElement
;
UBFeature
moviesElement
;
UBFeature
moviesElement
;
UBFeature
picturesElement
;
UBFeature
picturesElement
;
UBFeature
interactElement
;
UBFeature
interactElement
;
UBFeature
applicationsElement
;
UBFeature
flashElement
;
UBFeature
flashElement
;
UBFeature
shapesElement
;
UBFeature
shapesElement
;
UBFeature
webSearchElement
;
UBFeature
webSearchElement
;
QSet
<
QUrl
>
*
favoriteSet
;
QSet
<
QUrl
>
*
favoriteSet
;
};
public
:
UBFeature
trashElement
;
UBFeature
getParentFeatureForUrl
(
const
QUrl
&
url
);
};
#endif
#endif
src/core/UBSetting.cpp
View file @
2033c14f
...
@@ -74,6 +74,10 @@ void UBSetting::setString(const QString& pValue)
...
@@ -74,6 +74,10 @@ void UBSetting::setString(const QString& pValue)
{
{
set
(
pValue
);
set
(
pValue
);
}
}
void
UBSetting
::
setInt
(
int
pValue
)
{
set
(
pValue
);
}
UBColorListSetting
::
UBColorListSetting
(
UBSettings
*
parent
)
UBColorListSetting
::
UBColorListSetting
(
UBSettings
*
parent
)
...
...
src/core/UBSetting.h
View file @
2033c14f
...
@@ -54,6 +54,7 @@ class UBSetting : public QObject
...
@@ -54,6 +54,7 @@ class UBSetting : public QObject
void
setBool
(
bool
pValue
);
void
setBool
(
bool
pValue
);
void
setString
(
const
QString
&
pValue
);
void
setString
(
const
QString
&
pValue
);
void
setInt
(
int
pValue
);
signals
:
signals
:
...
...
src/core/UBSettings.cpp
View file @
2033c14f
...
@@ -217,6 +217,8 @@ void UBSettings::init()
...
@@ -217,6 +217,8 @@ void UBSettings::init()
appStartMode
=
new
UBSetting
(
this
,
"App"
,
"StartMode"
,
""
);
appStartMode
=
new
UBSetting
(
this
,
"App"
,
"StartMode"
,
""
);
featureSliderPosition
=
new
UBSetting
(
this
,
"Board"
,
"FeatureSliderPosition"
,
40
);
boardPenFineWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenFineWidth"
,
1.5
);
boardPenFineWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenFineWidth"
,
1.5
);
boardPenMediumWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenMediumWidth"
,
3.0
);
boardPenMediumWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenMediumWidth"
,
3.0
);
boardPenStrongWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenStrongWidth"
,
8.0
);
boardPenStrongWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenStrongWidth"
,
8.0
);
...
...
src/core/UBSettings.h
View file @
2033c14f
...
@@ -239,6 +239,8 @@ class UBSettings : public QObject
...
@@ -239,6 +239,8 @@ class UBSettings : public QObject
UBSetting
*
appStartMode
;
UBSetting
*
appStartMode
;
UBSetting
*
featureSliderPosition
;
UBColorListSetting
*
boardPenLightBackgroundColors
;
UBColorListSetting
*
boardPenLightBackgroundColors
;
UBColorListSetting
*
boardPenLightBackgroundSelectedColors
;
UBColorListSetting
*
boardPenLightBackgroundSelectedColors
;
...
...
src/frameworks/UBFileSystemUtils.cpp
View file @
2033c14f
...
@@ -61,14 +61,14 @@ bool UBFileSystemUtils::isAZipFile(QString &filePath)
...
@@ -61,14 +61,14 @@ bool UBFileSystemUtils::isAZipFile(QString &filePath)
return
result
;
return
result
;
}
}
bool
UBFileSystemUtils
::
copyFile
(
const
QString
&
source
,
const
QString
&
D
estination
,
bool
overwrite
)
bool
UBFileSystemUtils
::
copyFile
(
const
QString
&
source
,
const
QString
&
d
estination
,
bool
overwrite
)
{
{
if
(
!
QFile
::
exists
(
source
))
{
if
(
!
QFile
::
exists
(
source
))
{
qDebug
()
<<
"file"
<<
source
<<
"does not present in fs"
;
qDebug
()
<<
"file"
<<
source
<<
"does not present in fs"
;
return
false
;
return
false
;
}
}
QString
normalizedDestination
=
D
estination
;
QString
normalizedDestination
=
d
estination
;
if
(
QFile
::
exists
(
normalizedDestination
))
{
if
(
QFile
::
exists
(
normalizedDestination
))
{
if
(
QFileInfo
(
normalizedDestination
).
isFile
()
&&
overwrite
)
{
if
(
QFileInfo
(
normalizedDestination
).
isFile
()
&&
overwrite
)
{
QFile
::
remove
(
normalizedDestination
);
QFile
::
remove
(
normalizedDestination
);
...
@@ -86,6 +86,15 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destinati
...
@@ -86,6 +86,15 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destinati
return
QFile
::
copy
(
source
,
normalizedDestination
);
return
QFile
::
copy
(
source
,
normalizedDestination
);
}
}
bool
UBFileSystemUtils
::
copy
(
const
QString
&
source
,
const
QString
&
destination
,
bool
overwrite
)
{
if
(
QFileInfo
(
source
).
isDir
())
{
return
copyDir
(
source
,
destination
);
}
else
{
return
copyFile
(
source
,
destination
,
overwrite
);
}
}
bool
UBFileSystemUtils
::
deleteFile
(
const
QString
&
path
)
bool
UBFileSystemUtils
::
deleteFile
(
const
QString
&
path
)
{
{
QFile
f
(
path
);
QFile
f
(
path
);
...
...
src/frameworks/UBFileSystemUtils.h
View file @
2033c14f
...
@@ -45,6 +45,10 @@ class UBFileSystemUtils
...
@@ -45,6 +45,10 @@ class UBFileSystemUtils
static
bool
moveDir
(
const
QString
&
pSourceDirPath
,
const
QString
&
pTargetDirPath
);
static
bool
moveDir
(
const
QString
&
pSourceDirPath
,
const
QString
&
pTargetDirPath
);
static
bool
copyFile
(
const
QString
&
source
,
const
QString
&
destination
,
bool
overwrite
=
false
);
static
bool
copy
(
const
QString
&
source
,
const
QString
&
Destination
,
bool
overwrite
=
false
);
static
QString
cleanName
(
const
QString
&
name
);
static
QString
cleanName
(
const
QString
&
name
);
static
QString
digitFileFormat
(
const
QString
&
s
,
int
digit
);
static
QString
digitFileFormat
(
const
QString
&
s
,
int
digit
);
...
@@ -65,8 +69,6 @@ class UBFileSystemUtils
...
@@ -65,8 +69,6 @@ class UBFileSystemUtils
static
bool
isAZipFile
(
QString
&
filePath
);
static
bool
isAZipFile
(
QString
&
filePath
);
static
bool
copyFile
(
const
QString
&
source
,
const
QString
&
Destination
,
bool
overwrite
=
false
);
static
bool
deleteFile
(
const
QString
&
path
);
static
bool
deleteFile
(
const
QString
&
path
);
/**
/**
* Compress a source directory in a zip file.
* Compress a source directory in a zip file.
...
...
src/gui/UBFeaturesActionBar.cpp
View file @
2033c14f
#include "UBFeaturesActionBar.h"
#include "UBFeaturesActionBar.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
#include "gui/UBFeaturesWidget.h"
UBFeaturesActionBar
::
UBFeaturesActionBar
(
UBFeaturesController
*
controller
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
UBFeaturesActionBar
::
UBFeaturesActionBar
(
UBFeaturesController
*
controller
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
featuresController
(
controller
)
,
featuresController
(
controller
)
...
@@ -8,6 +9,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
...
@@ -8,6 +9,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
,
mLayout
(
NULL
)
,
mLayout
(
NULL
)
,
mpFavoriteAction
(
NULL
)
,
mpFavoriteAction
(
NULL
)
,
mpSocialAction
(
NULL
)
,
mpSocialAction
(
NULL
)
,
mpRescanModelAction
(
NULL
)
,
mpDeleteAction
(
NULL
)
,
mpDeleteAction
(
NULL
)
,
mpSearchAction
(
NULL
)
,
mpSearchAction
(
NULL
)
,
mpCloseAction
(
NULL
)
,
mpCloseAction
(
NULL
)
...
@@ -15,6 +17,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
...
@@ -15,6 +17,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
,
mpNewFolderAction
(
NULL
)
,
mpNewFolderAction
(
NULL
)
,
mpFavoriteBtn
(
NULL
)
,
mpFavoriteBtn
(
NULL
)
,
mpSocialBtn
(
NULL
)
,
mpSocialBtn
(
NULL
)
,
mpRescanModelBtn
(
NULL
)
,
mpDeleteBtn
(
NULL
)
,
mpDeleteBtn
(
NULL
)
,
mpCloseBtn
(
NULL
)
,
mpCloseBtn
(
NULL
)
,
mpRemoveFavoriteBtn
(
NULL
)
,
mpRemoveFavoriteBtn
(
NULL
)
...
@@ -39,6 +42,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
...
@@ -39,6 +42,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mpFavoriteAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniFavorite.png"
),
tr
(
"Add to favorites"
),
this
);
mpFavoriteAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniFavorite.png"
),
tr
(
"Add to favorites"
),
this
);
mpSocialAction
=
new
QAction
(
QIcon
(
":/images/libpalette/social.png"
),
tr
(
"Share"
),
this
);
mpSocialAction
=
new
QAction
(
QIcon
(
":/images/libpalette/social.png"
),
tr
(
"Share"
),
this
);
mpSearchAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniSearch.png"
),
tr
(
"Search"
),
this
);
mpSearchAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniSearch.png"
),
tr
(
"Search"
),
this
);
mpRescanModelAction
=
new
QAction
(
QIcon
(
":/images/cursors/rotate.png"
),
tr
(
"Rescan file system"
),
this
);
mpDeleteAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniTrash.png"
),
tr
(
"Delete"
),
this
);
mpDeleteAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniTrash.png"
),
tr
(
"Delete"
),
this
);
mpCloseAction
=
new
QAction
(
QIcon
(
":/images/close.svg"
),
tr
(
"Back to folder"
),
this
);
mpCloseAction
=
new
QAction
(
QIcon
(
":/images/close.svg"
),
tr
(
"Back to folder"
),
this
);
mpRemoveFavorite
=
new
QAction
(
QIcon
(
":/images/libpalette/trash_favorite.svg"
),
tr
(
"Remove from favorites"
),
this
);
mpRemoveFavorite
=
new
QAction
(
QIcon
(
":/images/libpalette/trash_favorite.svg"
),
tr
(
"Remove from favorites"
),
this
);
...
@@ -48,6 +52,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
...
@@ -48,6 +52,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mpFavoriteBtn
=
new
UBActionButton
(
this
,
mpFavoriteAction
);
mpFavoriteBtn
=
new
UBActionButton
(
this
,
mpFavoriteAction
);
mpSocialBtn
=
new
UBActionButton
(
this
,
mpSocialAction
);
mpSocialBtn
=
new
UBActionButton
(
this
,
mpSocialAction
);
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpRescanModelBtn
=
new
UBActionButton
(
this
,
mpRescanModelAction
);
mpDeleteBtn
=
new
UBActionButton
(
this
,
mpDeleteAction
);
mpDeleteBtn
=
new
UBActionButton
(
this
,
mpDeleteAction
);
mpCloseBtn
=
new
UBActionButton
(
this
,
mpCloseAction
);
mpCloseBtn
=
new
UBActionButton
(
this
,
mpCloseAction
);
mpRemoveFavoriteBtn
=
new
UBActionButton
(
this
,
mpRemoveFavorite
);
mpRemoveFavoriteBtn
=
new
UBActionButton
(
this
,
mpRemoveFavorite
);
...
@@ -79,14 +84,17 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
...
@@ -79,14 +84,17 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
connect
(
mSearchBar
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
onSearchTextChanged
(
QString
)));
connect
(
mSearchBar
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
onSearchTextChanged
(
QString
)));
connect
(
mpNewFolderAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionNewFolder
()));
connect
(
mpNewFolderAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionNewFolder
()));
connect
(
mpRemoveFavorite
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionRemoveFavorite
()));
connect
(
mpRemoveFavorite
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionRemoveFavorite
()));
connect
(
mpRescanModelAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionRescanModel
()));
connect
(
mpDeleteAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionTrash
()));
connect
(
mpDeleteAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionTrash
()));
// Build the default toolbar
// Build the default toolbar
mLayout
->
addWidget
(
mpFavoriteBtn
);
mLayout
->
addWidget
(
mpFavoriteBtn
);
mLayout
->
addWidget
(
mpSocialBtn
);
mLayout
->
addWidget
(
mpSocialBtn
);
mLayout
->
addWidget
(
mpNewFolderBtn
);
mLayout
->
addWidget
(
mpNewFolderBtn
);
mLayout
->
addWidget
(
mSearchBar
);
mLayout
->
addWidget
(
mSearchBar
);
//mLayout->addWidget(mpSearchBtn);
//mLayout->addWidget(mpSearchBtn);
mLayout
->
addWidget
(
mpRescanModelBtn
);
mLayout
->
addWidget
(
mpDeleteBtn
);
mLayout
->
addWidget
(
mpDeleteBtn
);
mLayout
->
addWidget
(
mpCloseBtn
);
mLayout
->
addWidget
(
mpCloseBtn
);
mLayout
->
addWidget
(
mpRemoveFavoriteBtn
);
mLayout
->
addWidget
(
mpRemoveFavoriteBtn
);
...
@@ -115,6 +123,7 @@ void UBFeaturesActionBar::setButtons()
...
@@ -115,6 +123,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
setEnabled
(
true
);
mpNewFolderBtn
->
setEnabled
(
true
);
mpDeleteBtn
->
setEnabled
(
true
);
mpDeleteBtn
->
setEnabled
(
true
);
mpRescanModelBtn
->
show
();
break
;
break
;
case
IN_ROOT
:
case
IN_ROOT
:
mpFavoriteBtn
->
show
();
mpFavoriteBtn
->
show
();
...
@@ -126,6 +135,7 @@ void UBFeaturesActionBar::setButtons()
...
@@ -126,6 +135,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
setEnabled
(
false
);
mpNewFolderBtn
->
setEnabled
(
false
);
mpDeleteBtn
->
setEnabled
(
false
);
mpDeleteBtn
->
setEnabled
(
false
);
mpRescanModelBtn
->
show
();
break
;
break
;
case
IN_PROPERTIES
:
case
IN_PROPERTIES
:
mpFavoriteBtn
->
show
();
mpFavoriteBtn
->
show
();
...
@@ -136,6 +146,7 @@ void UBFeaturesActionBar::setButtons()
...
@@ -136,6 +146,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
mpCloseBtn
->
hide
();
mpRemoveFavoriteBtn
->
hide
();
mpRemoveFavoriteBtn
->
hide
();
mpNewFolderBtn
->
hide
();
mpNewFolderBtn
->
hide
();
mpRescanModelBtn
->
hide
();
break
;
break
;
case
IN_FAVORITE
:
case
IN_FAVORITE
:
mpFavoriteBtn
->
hide
();
mpFavoriteBtn
->
hide
();
...
@@ -146,6 +157,7 @@ void UBFeaturesActionBar::setButtons()
...
@@ -146,6 +157,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
mpCloseBtn
->
hide
();
mpRemoveFavoriteBtn
->
show
();
mpRemoveFavoriteBtn
->
show
();
mpNewFolderBtn
->
hide
();
mpNewFolderBtn
->
hide
();
mpRescanModelBtn
->
hide
();
break
;
break
;
case
IN_TRASH
:
case
IN_TRASH
:
mpFavoriteBtn
->
hide
();
mpFavoriteBtn
->
hide
();
...
@@ -158,6 +170,7 @@ void UBFeaturesActionBar::setButtons()
...
@@ -158,6 +170,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
mpCloseBtn
->
hide
();
//mpRemoveFavoriteBtn->show();
//mpRemoveFavoriteBtn->show();
mpNewFolderBtn
->
hide
();
mpNewFolderBtn
->
hide
();
mpRescanModelBtn
->
hide
();
break
;
break
;
default
:
default
:
break
;
break
;
...
@@ -189,48 +202,57 @@ void UBFeaturesActionBar::onActionTrash()
...
@@ -189,48 +202,57 @@ void UBFeaturesActionBar::onActionTrash()
{
{
emit
deleteSelectedElements
();
emit
deleteSelectedElements
();
}
}
void
UBFeaturesActionBar
::
onActionRescanModel
()
/*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{
{
e
vent->acceptProposedAction
();
e
mit
rescanModel
();
}
}
*/
void
UBFeaturesActionBar
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
void
UBFeaturesActionBar
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
{
if
(
event
->
mimeData
()
->
hasFormat
(
"text/uri-list"
))
const
UBFeaturesMimeData
*
fMimeData
=
qobject_cast
<
const
UBFeaturesMimeData
*>
(
event
->
mimeData
());
{
if
(
fMimeData
)
{
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
}
else
{
event
->
ignore
();
}
}
}
void
UBFeaturesActionBar
::
dropEvent
(
QDropEvent
*
event
)
void
UBFeaturesActionBar
::
dropEvent
(
QDropEvent
*
event
)
{
{
QWidget
*
dest
=
childAt
(
event
->
pos
()
);
const
UBFeaturesMimeData
*
fMimeData
=
qobject_cast
<
const
UBFeaturesMimeData
*>
(
event
->
mimeData
());
if
(
dest
==
mpDeleteBtn
)
{
if
(
!
fMimeData
)
{
QList
<
QUrl
>
urls
=
event
->
mimeData
()
->
urls
();
qWarning
()
<<
"data came from not supported widget"
;
foreach
(
QUrl
url
,
urls
)
event
->
ignore
();
{
return
;
if
(
!
UBFeaturesController
::
isDeletable
(
url
)
)
}
return
;
}
QWidget
*
dest
=
childAt
(
event
->
pos
());
event
->
setDropAction
(
Qt
::
MoveAction
);
if
(
dest
==
mpDeleteBtn
)
{
QList
<
UBFeature
>
featuresList
=
fMimeData
->
features
();
foreach
(
UBFeature
curFeature
,
featuresList
)
{
if
(
!
curFeature
.
isDeletable
())
{
qWarning
()
<<
"Undeletable feature found, stopping deleting process"
;
event
->
ignore
();
return
;
}
}
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
event
->
accept
();
emit
deleteElements
(
*
event
->
mimeData
()
);
}
emit
deleteElements
(
fMimeData
);
else
if
(
dest
==
mpFavoriteBtn
)
{
}
else
if
(
dest
==
mpFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
CopyAction
);
event
->
setDropAction
(
Qt
::
CopyAction
);
event
->
accept
();
event
->
accept
();
emit
addToFavorite
(
*
event
->
mimeData
()
);
}
emit
addToFavorite
(
fMimeData
);
else
if
(
dest
==
mpRemoveFavoriteBtn
)
{
}
else
if
(
dest
==
mpRemoveFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
event
->
accept
();
emit
removeFromFavorite
(
*
event
->
mimeData
()
);
emit
removeFromFavorite
(
fMimeData
);
}
}
}
}
...
...
src/gui/UBFeaturesActionBar.h
View file @
2033c14f
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
#include "UBLibActionBar.h"
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
#include "board/UBFeaturesController.h"
class
UBFeaturesMimeData
;
enum
UBFeaturesActionBarState
enum
UBFeaturesActionBarState
{
{
IN_ROOT
,
IN_ROOT
,
...
@@ -24,25 +26,30 @@ public:
...
@@ -24,25 +26,30 @@ public:
~
UBFeaturesActionBar
();
~
UBFeaturesActionBar
();
void
setCurrentState
(
UBFeaturesActionBarState
state
);
void
setCurrentState
(
UBFeaturesActionBarState
state
);
signals
:
signals
:
void
searchElement
(
const
QString
&
text
);
void
searchElement
(
const
QString
&
text
);
void
newFolderToCreate
();
void
newFolderToCreate
();
void
deleteElements
(
const
QMimeData
&
data
);
void
deleteElements
(
const
UBFeaturesMimeData
*
data
);
void
addToFavorite
(
const
QMimeData
&
data
);
void
addToFavorite
(
const
UBFeaturesMimeData
*
data
);
void
removeFromFavorite
(
const
QMimeData
&
data
);
void
removeFromFavorite
(
const
UBFeaturesMimeData
*
data
);
void
addElementsToFavorite
();
void
addElementsToFavorite
();
void
removeElementsFromFavorite
();
void
removeElementsFromFavorite
();
void
deleteSelectedElements
();
void
deleteSelectedElements
();
void
rescanModel
();
private
slots
:
private
slots
:
void
onSearchTextChanged
(
QString
txt
);
void
onSearchTextChanged
(
QString
txt
);
void
onActionNewFolder
();
void
onActionNewFolder
();
void
onActionFavorite
();
void
onActionFavorite
();
void
onActionRemoveFavorite
();
void
onActionRemoveFavorite
();
void
onActionTrash
();
void
onActionTrash
();
void
onActionRescanModel
();
protected
:
protected
:
//void dragMoveEvent(QDragMoveEvent *event);
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
void
dropEvent
(
QDropEvent
*
event
);
void
dropEvent
(
QDropEvent
*
event
);
private
:
private
:
void
setButtons
();
void
setButtons
();
UBFeaturesController
*
featuresController
;
UBFeaturesController
*
featuresController
;
...
@@ -56,6 +63,7 @@ private:
...
@@ -56,6 +63,7 @@ private:
QHBoxLayout
*
mLayout
;
QHBoxLayout
*
mLayout
;
QAction
*
mpFavoriteAction
;
QAction
*
mpFavoriteAction
;
QAction
*
mpSocialAction
;
QAction
*
mpSocialAction
;
QAction
*
mpRescanModelAction
;
QAction
*
mpDeleteAction
;
QAction
*
mpDeleteAction
;
QAction
*
mpSearchAction
;
QAction
*
mpSearchAction
;
QAction
*
mpCloseAction
;
QAction
*
mpCloseAction
;
...
@@ -63,13 +71,11 @@ private:
...
@@ -63,13 +71,11 @@ private:
QAction
*
mpNewFolderAction
;
QAction
*
mpNewFolderAction
;
UBActionButton
*
mpFavoriteBtn
;
UBActionButton
*
mpFavoriteBtn
;
UBActionButton
*
mpSocialBtn
;
UBActionButton
*
mpSocialBtn
;
UBActionButton
*
mpRescanModelBtn
;
UBActionButton
*
mpDeleteBtn
;
UBActionButton
*
mpDeleteBtn
;
//UBActionButton* mpSearchBtn;
UBActionButton
*
mpCloseBtn
;
UBActionButton
*
mpCloseBtn
;
UBActionButton
*
mpRemoveFavoriteBtn
;
UBActionButton
*
mpRemoveFavoriteBtn
;
UBActionButton
*
mpNewFolderBtn
;
UBActionButton
*
mpNewFolderBtn
;
};
};
#endif
#endif
\ No newline at end of file
src/gui/UBFeaturesWidget.cpp
View file @
2033c14f
...
@@ -10,345 +10,222 @@
...
@@ -10,345 +10,222 @@
#include "globals/UBGlobals.h"
#include "globals/UBGlobals.h"
#include "board/UBBoardController.h"
#include "board/UBBoardController.h"
const
char
*
objNamePathList
=
"PathList"
;
const
char
*
objNameFeatureList
=
"FeatureList"
;
const
QMargins
FeatureListMargins
(
0
,
0
,
0
,
30
);
const
int
FeatureListBorderOffset
=
10
;
const
char
featureTypeSplitter
=
':'
;
static
const
QString
mimeSankoreFeatureTypes
=
"Sankore/featureTypes"
;
UBFeaturesWidget
::
UBFeaturesWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
UBDockPaletteWidget
(
parent
)
UBFeaturesWidget
::
UBFeaturesWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
UBDockPaletteWidget
(
parent
)
{
{
setObjectName
(
name
);
setObjectName
(
name
);
mName
=
"FeaturesWidget"
;
mName
=
"FeaturesWidget"
;
mVisibleState
=
true
;
mVisibleState
=
true
;
SET_STYLE_SHEET
();
SET_STYLE_SHEET
();
//setAttribute(Qt::WA_StyledBackground, true);
//setStyleSheet(UBApplication::globalStyleSheet());
mIconToLeft
=
QPixmap
(
":images/library_open.png"
);
mIconToLeft
=
QPixmap
(
":images/library_open.png"
);
mIconToRight
=
QPixmap
(
":images/library_close.png"
);
mIconToRight
=
QPixmap
(
":images/library_close.png"
);
setAcceptDrops
(
true
);
setAcceptDrops
(
true
);
stackedWidget
=
new
QStackedWidget
(
this
);
//Main UBFeature functionality
layout
=
new
QVBoxLayout
(
this
);
controller
=
new
UBFeaturesController
(
this
);
controller
=
new
UBFeaturesController
(
this
);
//Main layout including all the widgets in palette
layout
=
new
QVBoxLayout
(
this
);
featuresModel
=
new
UBFeaturesModel
(
this
);
featuresModel
->
setFeaturesList
(
controller
->
getFeatures
()
);
//Path icon view on the top of the palette
featuresModel
->
setSupportedDragActions
(
Qt
::
CopyAction
|
Qt
::
MoveAction
);
pathListView
=
new
UBFeaturesListView
(
this
,
objNamePathList
);
featuresListView
=
new
UBFeaturesListView
(
this
);
controller
->
assignPathListView
(
pathListView
);
pathListView
=
new
UBFeaturesListView
(
this
);
//Maintains the view of the main part of the palette. Consists of
//mNavigator
featuresProxyModel
=
new
UBFeaturesProxyModel
(
this
);
//featureProperties
featuresProxyModel
->
setFilterFixedString
(
controller
->
getRootPath
()
);
//webVeiw
featuresProxyModel
->
setSourceModel
(
featuresModel
);
stackedWidget
=
new
QStackedWidget
(
this
);
featuresProxyModel
->
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
//Main features icon view with QSlider on the bottom
featuresSearchModel
=
new
UBFeaturesSearchProxyModel
(
this
);
mNavigator
=
new
UBFeaturesNavigatorWidget
(
this
);
featuresSearchModel
->
setSourceModel
(
featuresModel
);
controller
->
assignFeaturesListVeiw
(
mNavigator
->
listView
());
featuresSearchModel
->
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
mNavigator
->
setSliderPosition
(
UBSettings
::
settings
()
->
featureSliderPosition
->
get
().
toInt
());
featuresPathModel
=
new
UBFeaturesPathProxyModel
(
this
);
//Specifies the properties of a standalone element
featuresPathModel
->
setPath
(
controller
->
getRootPath
()
);
featureProperties
=
new
UBFeatureProperties
(
this
);
featuresPathModel
->
setSourceModel
(
featuresModel
);
//Used to show search bar on the search widget
webView
=
new
UBFeaturesWebView
(
this
);
//featuresListView->setStyleSheet( QString("background: #EEEEEE;border-radius: 10px;border: 2px solid #999999;") );
featuresListView
->
setDragDropMode
(
QAbstractItemView
::
DragDrop
);
//filling stackwidget
featuresListView
->
setSelectionMode
(
QAbstractItemView
::
ContiguousSelection
);
stackedWidget
->
addWidget
(
mNavigator
);
featuresListView
->
setModel
(
featuresProxyModel
);
stackedWidget
->
addWidget
(
featureProperties
);
stackedWidget
->
addWidget
(
webView
);
featuresListView
->
setResizeMode
(
QListView
::
Adjust
);
stackedWidget
->
setCurrentIndex
(
ID_LISTVIEW
);
featuresListView
->
setViewMode
(
QListView
::
IconMode
);
currentStackedWidget
=
ID_LISTVIEW
;
itemDelegate
=
new
UBFeaturesItemDelegate
(
this
,
featuresListView
);
featuresListView
->
setItemDelegate
(
itemDelegate
);
//Bottom actionbar for DnD, quick search etc
//featuresListView->setSelectionRectVisible(false);
mActionBar
=
new
UBFeaturesActionBar
(
controller
,
this
);
featuresListView
->
setIconSize
(
QSize
(
defaultThumbnailSize
,
defaultThumbnailSize
)
);
//Filling main layout
featuresListView
->
setGridSize
(
QSize
(
defaultThumbnailSize
*
1.75
,
defaultThumbnailSize
*
1.75
)
);
layout
->
addWidget
(
pathListView
);
//pathListView->setStyleSheet( QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;") );
pathListView
->
setModel
(
featuresPathModel
);
pathListView
->
setViewMode
(
QListView
::
IconMode
);
pathListView
->
setIconSize
(
QSize
(
defaultThumbnailSize
-
10
,
defaultThumbnailSize
-
10
)
);
pathListView
->
setGridSize
(
QSize
(
defaultThumbnailSize
+
10
,
defaultThumbnailSize
-
10
)
);
pathListView
->
setFixedHeight
(
60
);
pathItemDelegate
=
new
UBFeaturesPathItemDelegate
(
this
);
pathListView
->
setItemDelegate
(
pathItemDelegate
);
pathListView
->
setSelectionMode
(
QAbstractItemView
::
NoSelection
);
pathListView
->
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
pathListView
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOn
);
pathListView
->
setFlow
(
QListView
::
LeftToRight
);
pathListView
->
setWrapping
(
false
);
//pathListView->setResizeMode( QListView::Adjust );
//pathListView->setMovement( QListView::Static );
pathListView
->
setDragDropMode
(
QAbstractItemView
::
DropOnly
);
//pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this );
featureProperties
=
new
UBFeatureProperties
(
this
);
webView
=
new
UBFeaturesWebView
(
this
);
//layout->addWidget( pathViewer );
//pathViewer->show();
//layout->addWidget( featuresListView );
layout
->
addWidget
(
pathListView
);
layout
->
addWidget
(
stackedWidget
);
layout
->
addWidget
(
stackedWidget
);
layout
->
addWidget
(
mActionBar
);
stackedWidget
->
addWidget
(
featuresListView
);
stackedWidget
->
addWidget
(
featureProperties
);
connect
(
mNavigator
->
listView
(),
SIGNAL
(
clicked
(
const
QModelIndex
&
)),
this
,
SLOT
(
currentSelected
(
const
QModelIndex
&
)));
stackedWidget
->
addWidget
(
webView
);
connect
(
mActionBar
,
SIGNAL
(
searchElement
(
const
QString
&
)),
this
,
SLOT
(
searchStarted
(
const
QString
&
)));
stackedWidget
->
setCurrentIndex
(
ID_LISTVIEW
);
connect
(
mActionBar
,
SIGNAL
(
newFolderToCreate
()),
this
,
SLOT
(
createNewFolder
()));
currentStackedWidget
=
ID_LISTVIEW
;
connect
(
mActionBar
,
SIGNAL
(
deleteElements
(
const
UBFeaturesMimeData
*
)),
this
,
SLOT
(
deleteElements
(
const
UBFeaturesMimeData
*
)));
connect
(
mActionBar
,
SIGNAL
(
deleteSelectedElements
()),
this
,
SLOT
(
deleteSelectedElements
()));
mActionBar
=
new
UBFeaturesActionBar
(
controller
,
this
);
connect
(
mActionBar
,
SIGNAL
(
addToFavorite
(
const
UBFeaturesMimeData
*
)),
this
,
SLOT
(
addToFavorite
(
const
UBFeaturesMimeData
*
)));
thumbSlider
=
new
QSlider
(
Qt
::
Horizontal
,
featuresListView
);
connect
(
mActionBar
,
SIGNAL
(
removeFromFavorite
(
const
UBFeaturesMimeData
*
)),
this
,
SLOT
(
removeFromFavorite
(
const
UBFeaturesMimeData
*
)));
thumbSlider
->
setMinimum
(
minThumbnailSize
);
connect
(
mActionBar
,
SIGNAL
(
addElementsToFavorite
()
),
this
,
SLOT
(
addElementsToFavorite
())
);
thumbSlider
->
setMaximum
(
maxThumbnailSize
);
connect
(
mActionBar
,
SIGNAL
(
removeElementsFromFavorite
()),
this
,
SLOT
(
removeElementsFromFavorite
()));
thumbSlider
->
setValue
(
defaultThumbnailSize
);
//qDebug() << "init" << featuresListView->height();
connect
(
mActionBar
,
SIGNAL
(
rescanModel
()),
this
,
SLOT
(
rescanModel
()));
thumbSlider
->
move
(
0
,
featuresListView
->
height
()
);
connect
(
pathListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)),
this
,
SLOT
(
currentSelected
(
const
QModelIndex
&
)));
thumbSlider
->
resize
(
thumbSlider
->
width
(),
thumbSlider
->
height
()
+
4
);
connect
(
UBApplication
::
boardController
,
SIGNAL
(
displayMetadata
(
QMap
<
QString
,
QString
>
)),
this
,
SLOT
(
onDisplayMetadata
(
QMap
<
QString
,
QString
>
)));
thumbSlider
->
show
();
connect
(
UBDownloadManager
::
downloadManager
(),
SIGNAL
(
addDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)),
this
,
SLOT
(
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)));
featuresListView
->
installEventFilter
(
this
);
//layout->addWidget( thumbSlider );
layout
->
addWidget
(
mActionBar
);
/*connect(featuresListView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex &, const QModelIndex & )),
this, SLOT(currentSelected(const QModelIndex &)));*/
connect
(
featuresListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)
),
this
,
SLOT
(
currentSelected
(
const
QModelIndex
&
)
)
);
connect
(
mActionBar
,
SIGNAL
(
searchElement
(
const
QString
&
)
),
this
,
SLOT
(
searchStarted
(
const
QString
&
)
)
);
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
(
mActionBar
,
SIGNAL
(
addElementsToFavorite
()
),
this
,
SLOT
(
addElementsToFavorite
()
)
);
connect
(
mActionBar
,
SIGNAL
(
removeElementsFromFavorite
()
),
this
,
SLOT
(
removeElementsFromFavorite
()
)
);
connect
(
mActionBar
,
SIGNAL
(
deleteSelectedElements
()
),
this
,
SLOT
(
deleteSelectedElements
()
)
);
connect
(
pathListView
,
SIGNAL
(
clicked
(
const
QModelIndex
&
)
),
this
,
SLOT
(
currentPathChanged
(
const
QModelIndex
&
)
)
);
connect
(
thumbSlider
,
SIGNAL
(
sliderMoved
(
int
)
),
this
,
SLOT
(
thumbnailSizeChanged
(
int
)
)
);
connect
(
UBApplication
::
boardController
,
SIGNAL
(
displayMetadata
(
QMap
<
QString
,
QString
>
)
),
this
,
SLOT
(
onDisplayMetadata
(
QMap
<
QString
,
QString
>
)
)
);
connect
(
UBDownloadManager
::
downloadManager
(),
SIGNAL
(
addDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)
),
this
,
SLOT
(
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
)
)
);
}
}
UBFeaturesWidget
::~
UBFeaturesWidget
()
UBFeaturesWidget
::~
UBFeaturesWidget
()
{
{
if
(
thumbSlider
!=
NULL
)
{
delete
thumbSlider
;
thumbSlider
=
NULL
;
}
}
bool
UBFeaturesWidget
::
eventFilter
(
QObject
*
target
,
QEvent
*
event
)
{
if
(
target
==
featuresListView
&&
event
->
type
()
==
QEvent
::
Resize
)
{
thumbSlider
->
move
(
10
,
featuresListView
->
height
()
-
thumbSlider
->
height
()
-
10
);
thumbSlider
->
resize
(
featuresListView
->
width
()
-
20
,
thumbSlider
->
height
()
);
//qDebug() << featuresListView->height();
//return true;
}
return
UBDockPaletteWidget
::
eventFilter
(
target
,
event
);
}
}
void
UBFeaturesWidget
::
searchStarted
(
const
QString
&
pattern
)
void
UBFeaturesWidget
::
searchStarted
(
const
QString
&
pattern
)
{
{
if
(
pattern
.
isEmpty
()
)
controller
->
searchStarted
(
pattern
,
mNavigator
->
listView
());
{
featuresListView
->
setModel
(
featuresProxyModel
);
featuresProxyModel
->
invalidate
();
}
else
if
(
pattern
.
size
()
>
2
)
{
featuresSearchModel
->
setFilterWildcard
(
"*"
+
pattern
+
"*"
);
featuresListView
->
setModel
(
featuresSearchModel
);
featuresSearchModel
->
invalidate
();
}
}
}
void
UBFeaturesWidget
::
currentSelected
(
const
QModelIndex
&
current
)
void
UBFeaturesWidget
::
currentSelected
(
const
QModelIndex
&
current
)
{
{
if
(
current
.
isValid
())
if
(
!
current
.
isValid
())
{
{
qWarning
()
<<
"SLOT:currentSelected, invalid index catched"
;
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
return
;
/*QString name = model->data(current).toString();
}
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
.
isFolder
()
)
QString
objName
=
sender
()
->
objectName
();
{
QString
newPath
=
feature
.
getFullVirtualPath
();
//pathViewer->addPathElement( feature.getThumbnail(), newPath );
controller
->
setCurrentElement
(
feature
);
model
->
setFilterFixedString
(
newPath
);
if
(
objName
.
isEmpty
())
{
model
->
invalidate
()
;
qWarning
()
<<
"incorrrect sender"
;
switchToListView
();
}
featuresPathModel
->
setPath
(
newPath
);
QListView
*
calledList
=
0
;
featuresPathModel
->
invalidate
();
if
(
objName
==
objNamePathList
)
{
if
(
feature
.
getType
()
==
FEATURE_FAVORITE
)
calledList
=
pathListView
;
{
}
else
if
(
objName
==
objNameFeatureList
)
{
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
calledList
=
mNavigator
->
listView
();
}
}
else
if
(
feature
.
getType
()
==
FEATURE_TRASH
)
{
mActionBar
->
setCurrentState
(
IN_TRASH
);
}
else
{
mActionBar
->
setCurrentState
(
IN_FOLDER
);
}
}
else
if
(
feature
.
getType
()
==
FEATURE_SEARCH
)
{
webView
->
showElement
(
feature
);
switchToWebView
();
}
else
{
featureProperties
->
showElement
(
feature
);
switchToProperties
();
mActionBar
->
setCurrentState
(
IN_PROPERTIES
);
}
}
}
void
UBFeaturesWidget
::
currentPathChanged
(
const
QModelIndex
&
index
)
UBFeature
feature
=
controller
->
getFeature
(
current
,
calledList
);
{
// QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( mNavigator->listView()->model() );
if
(
index
.
isValid
()
)
// UBFeature feature = model->data(current, Qt::UserRole + 1).value<UBFeature>();
{
UBFeature
feature
=
featuresPathModel
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
if
(
feature
.
isFolder
()
)
{
QString
newPath
=
feature
.
getFullVirtualPath
();
QString
newPath
=
feature
.
getFullVirtualPath
();
featuresPathModel
->
setPath
(
newPath
);
controller
->
setCurrentElement
(
feature
);
featuresPathModel
->
invalidate
();
controller
->
siftElements
(
newPath
);
featuresListView
->
setModel
(
featuresProxyModel
);
switchToListView
();
featuresProxyModel
->
setFilterFixedString
(
newPath
);
featuresProxyModel
->
invalidate
();
if
(
feature
.
getType
()
==
FEATURE_FAVORITE
)
{
switchToListView
();
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
controller
->
setCurrentElement
(
feature
);
if
(
feature
.
getType
()
==
FEATURE_CATEGORY
&&
feature
.
getName
()
==
"root"
)
}
else
if
(
feature
.
getType
()
==
FEATURE_CATEGORY
&&
feature
.
getName
()
==
"root"
)
{
{
mActionBar
->
setCurrentState
(
IN_ROOT
);
mActionBar
->
setCurrentState
(
IN_ROOT
);
}
}
else
if
(
feature
.
getType
()
==
FEATURE_TRASH
)
{
else
if
(
feature
.
getType
()
==
FEATURE_FAVORITE
)
mActionBar
->
setCurrentState
(
IN_TRASH
);
{
mActionBar
->
setCurrentState
(
IN_FAVORITE
);
}
else
{
}
mActionBar
->
setCurrentState
(
IN_FOLDER
);
else
if
(
feature
.
getType
()
==
FEATURE_TRASH
)
}
{
mActionBar
->
setCurrentState
(
IN_TRASH
);
}
else
if
(
feature
.
getType
()
==
FEATURE_SEARCH
)
{
}
webView
->
showElement
(
feature
);
else
switchToWebView
();
{
mActionBar
->
setCurrentState
(
IN_FOLDER
);
}
else
{
}
featureProperties
->
showElement
(
feature
);
}
switchToProperties
();
mActionBar
->
setCurrentState
(
IN_PROPERTIES
);
}
}
}
void
UBFeaturesWidget
::
createNewFolder
()
void
UBFeaturesWidget
::
createNewFolder
()
{
{
UBNewFolderDlg
dlg
;
UBNewFolderDlg
dlg
;
if
(
QDialog
::
Accepted
==
dlg
.
exec
())
if
(
QDialog
::
Accepted
==
dlg
.
exec
())
{
{
controller
->
addNewFolder
(
dlg
.
folderName
());
UBFeature
newFolder
=
controller
->
newFolder
(
dlg
.
folderName
()
);
featuresModel
->
addItem
(
newFolder
);
featuresProxyModel
->
invalidate
();
}
}
}
}
void
UBFeaturesWidget
::
deleteElements
(
const
QMimeData
&
mimeData
)
void
UBFeaturesWidget
::
deleteElements
(
const
UBFeaturesMimeData
*
mimeData
)
{
{
if
(
!
mimeData
.
hasUrls
()
)
if
(
!
mimeData
->
features
().
count
()
)
return
;
return
;
QList
<
QUrl
>
urls
=
mimeData
.
urls
();
QList
<
UBFeature
>
featuresList
=
mimeData
->
features
();
foreach
(
QUrl
url
,
urls
)
foreach
(
UBFeature
curFeature
,
featuresList
)
{
{
if
(
curFeature
.
inTrash
())
{
if
(
controller
->
isTrash
(
url
)
)
controller
->
deleteItem
(
curFeature
.
getFullPath
());
{
controller
->
deleteItem
(
url
);
}
else
{
}
controller
->
moveToTrash
(
curFeature
);
else
}
{
}
UBFeature
elem
=
controller
->
moveItemToFolder
(
url
,
controller
->
getTrashElement
()
);
controller
->
removeFromFavorite
(
url
);
controller
->
refreshModels
();
featuresModel
->
addItem
(
elem
);
featuresModel
->
deleteFavoriteItem
(
UBFeaturesController
::
fileNameFromUrl
(
url
)
);
}
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
}
}
void
UBFeaturesWidget
::
deleteSelectedElements
()
void
UBFeaturesWidget
::
deleteSelectedElements
()
{
{
QModelIndexList
selected
=
featuresListView
->
selectionModel
()
->
selectedIndexes
();
QModelIndexList
selected
=
mNavigator
->
listView
()
->
selectionModel
()
->
selectedIndexes
();
QList
<
QUrl
>
urls
;
foreach
(
QModelIndex
sel
,
selected
)
{
UBFeature
feature
=
sel
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
if
(
feature
.
isDeletable
()
)
urls
.
append
(
feature
.
getFullPath
()
);
}
foreach
(
QUrl
url
,
urls
)
foreach
(
QModelIndex
sel
,
selected
)
{
{
if
(
controller
->
isTrash
(
url
)
)
UBFeature
feature
=
sel
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
{
if
(
feature
.
isDeletable
())
{
controller
->
deleteItem
(
url
);
if
(
feature
.
inTrash
())
{
}
controller
->
deleteItem
(
feature
);
else
}
else
{
{
controller
->
moveToTrash
(
feature
,
true
);
UBFeature
elem
=
controller
->
moveItemToFolder
(
url
,
controller
->
getTrashElement
()
);
}
controller
->
removeFromFavorite
(
url
);
}
featuresModel
->
addItem
(
elem
);
featuresModel
->
deleteFavoriteItem
(
url
.
toString
()
);
}
featuresModel
->
deleteItem
(
url
.
toString
()
);
}
}
controller
->
refreshModels
();
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
}
}
void
UBFeaturesWidget
::
addToFavorite
(
const
QMimeData
&
mimeData
)
void
UBFeaturesWidget
::
rescanModel
(
)
{
{
if
(
!
mimeData
.
hasUrls
()
)
controller
->
rescanModel
();
return
;
QList
<
QUrl
>
urls
=
mimeData
.
urls
();
foreach
(
QUrl
url
,
urls
)
{
UBFeature
elem
=
controller
->
addToFavorite
(
url
);
if
(
!
elem
.
getVirtualPath
().
isEmpty
()
&&
!
elem
.
getVirtualPath
().
isNull
()
)
featuresModel
->
addItem
(
elem
);
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
}
}
void
UBFeaturesWidget
::
removeFromFavorite
(
const
QMimeData
&
mimeData
)
void
UBFeaturesWidget
::
addToFavorite
(
const
UBFeaturesMimeData
*
mimeData
)
{
{
if
(
!
mimeData
.
hasUrls
()
)
if
(
!
mimeData
->
hasUrls
()
)
return
;
return
;
QList
<
QUrl
>
urls
=
mimeData
.
urls
();
foreach
(
QUrl
url
,
urls
)
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
{
foreach
(
QUrl
url
,
urls
)
{
controller
->
removeFromFavorite
(
url
);
controller
->
addToFavorite
(
url
);
}
}
controller
->
refreshModels
();
}
}
void
UBFeaturesWidget
::
thumbnailSizeChanged
(
int
value
)
void
UBFeaturesWidget
::
removeFromFavorite
(
const
UBFeaturesMimeData
*
mimeData
)
{
{
featuresListView
->
setIconSize
(
QSize
(
value
,
value
)
);
if
(
!
mimeData
->
hasUrls
()
)
featuresListView
->
setGridSize
(
QSize
(
value
*
1.75
,
value
*
1.75
)
);
return
;
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
foreach
(
QUrl
url
,
urls
)
{
controller
->
removeFromFavorite
(
url
);
}
}
}
void
UBFeaturesWidget
::
onDisplayMetadata
(
QMap
<
QString
,
QString
>
metadata
)
void
UBFeaturesWidget
::
onDisplayMetadata
(
QMap
<
QString
,
QString
>
metadata
)
...
@@ -363,61 +240,53 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
...
@@ -363,61 +240,53 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
void
UBFeaturesWidget
::
onAddDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentHeader
,
QByteArray
pData
)
void
UBFeaturesWidget
::
onAddDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentHeader
,
QByteArray
pData
)
{
{
Q_UNUSED
(
pContentHeader
)
if
(
pSuccess
)
if
(
pSuccess
)
{
{
UBFeature
newFeature
=
controller
->
addDownloadedFile
(
sourceUrl
,
pData
);
UBFeature
newFeature
=
controller
->
addDownloadedFile
(
sourceUrl
,
pData
);
if
(
newFeature
!=
UBFeature
()
)
if
(
newFeature
!=
UBFeature
()
)
{
{
featuresModel
->
addItem
(
newFeature
);
featuresModel
->
addItem
(
newFeature
);
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
mNavigator
->
listView
()
->
model
()
);
model
->
invalidate
();
model
->
invalidate
();
}
}
}
}
}
}
void
UBFeaturesWidget
::
addElementsToFavorite
()
void
UBFeaturesWidget
::
addElementsToFavorite
()
{
{
if
(
currentStackedWidget
==
ID_PROPERTIES
)
if
(
currentStackedWidget
==
ID_PROPERTIES
)
{
{
UBFeature
feature
=
featureProperties
->
getCurrentElement
();
UBFeature
feature
=
featureProperties
->
getCurrentElement
();
if
(
feature
!=
UBFeature
()
&&
!
UBApplication
::
isFromWeb
(
feature
.
getFullPath
().
toString
()
)
)
if
(
feature
!=
UBFeature
()
&&
!
UBApplication
::
isFromWeb
(
feature
.
getFullPath
().
toString
()))
{
{
controller
->
addToFavorite
(
feature
.
getFullPath
()
);
UBFeature
elem
=
controller
->
addToFavorite
(
feature
.
getFullPath
()
);
featuresModel
->
addItem
(
elem
);
}
}
}
else
if
(
currentStackedWidget
==
ID_LISTVIEW
)
}
else
if
(
currentStackedWidget
==
ID_LISTVIEW
)
{
{
QModelIndexList
selected
=
mNavigator
->
listView
()
->
selectionModel
()
->
selectedIndexes
();
QModelIndexList
selected
=
featuresListView
->
selectionModel
()
->
selectedIndexes
();
for
(
int
i
=
0
;
i
<
selected
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
selected
.
size
();
++
i
)
{
UBFeature
feature
=
selected
.
at
(
i
).
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
feature
=
selected
.
at
(
i
).
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
elem
=
controller
->
addToFavorite
(
feature
.
getFullPath
()
);
controller
->
addToFavorite
(
feature
.
getFullPath
());
if
(
!
elem
.
getVirtualPath
().
isEmpty
()
&&
!
elem
.
getVirtualPath
().
isNull
()
)
}
featuresModel
->
addItem
(
elem
);
}
}
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
controller
->
refreshModels
();
}
}
void
UBFeaturesWidget
::
removeElementsFromFavorite
()
void
UBFeaturesWidget
::
removeElementsFromFavorite
()
{
{
QModelIndexList
selected
=
featuresListView
->
selectionModel
()
->
selectedIndexes
();
QModelIndexList
selected
=
mNavigator
->
listView
()
->
selectionModel
()
->
selectedIndexes
();
//qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
QList
<
QUrl
>
items
;
QList
<
QUrl
>
items
;
for
(
int
i
=
0
;
i
<
selected
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
selected
.
size
();
++
i
)
{
{
UBFeature
feature
=
selected
.
at
(
i
).
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
feature
=
selected
.
at
(
i
).
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
items
.
append
(
feature
.
getFullPath
()
);
items
.
append
(
feature
.
getFullPath
()
);
}
}
foreach
(
QUrl
url
,
items
)
{
foreach
(
QUrl
url
,
items
)
{
controller
->
removeFromFavorite
(
url
);
controller
->
removeFromFavorite
(
url
,
true
);
featuresModel
->
deleteFavoriteItem
(
url
.
toString
()
);
}
}
QSortFilterProxyModel
*
model
=
dynamic_cast
<
QSortFilterProxyModel
*>
(
featuresListView
->
model
()
);
model
->
invalidate
();
controller
->
refreshModels
();
}
}
void
UBFeaturesWidget
::
switchToListView
()
void
UBFeaturesWidget
::
switchToListView
()
...
@@ -438,6 +307,21 @@ void UBFeaturesWidget::switchToWebView()
...
@@ -438,6 +307,21 @@ void UBFeaturesWidget::switchToWebView()
currentStackedWidget
=
ID_WEBVIEW
;
currentStackedWidget
=
ID_WEBVIEW
;
}
}
void
UBFeaturesWidget
::
updateSliderPosition
()
{
// //Calculating the topleft position of the slider
// int scrollBarVOffset = featuresListView->horizontalScrollBar()->isVisible() ? featuresListView->horizontalScrollBar()->height() : 0;
// int xSlider = scrollbarHorisontalPadding();
// int ySlider = featuresListView->height() - (thumbSlider->height() + scrollbarVerticalIndent() + scrollBarVOffset);
// thumbSlider->move( xSlider, ySlider);
// //Calculating new slider's size
// int scrollBarHOffset = featuresListView->verticalScrollBar()->isVisible() ? featuresListView->verticalScrollBar()->width() : 0;
// int wSlider = featuresListView->width() - 2 * scrollbarHorisontalPadding() - scrollBarHOffset;
// int hSlider = thumbSlider->height();
// thumbSlider->resize(wSlider, hSlider);
}
/*
/*
void UBFeaturesWidget::currentPathChanged(const QString &path)
void UBFeaturesWidget::currentPathChanged(const QString &path)
...
@@ -451,14 +335,16 @@ void UBFeaturesWidget::currentPathChanged(const QString &path)
...
@@ -451,14 +335,16 @@ void UBFeaturesWidget::currentPathChanged(const QString &path)
}
}
*/
*/
QStringList
UBFeaturesMimeData
::
formats
()
const
{
return
QMimeData
::
formats
();
}
UBFeaturesListView
::
UBFeaturesListView
(
QWidget
*
parent
,
const
char
*
name
)
UBFeaturesListView
::
UBFeaturesListView
(
QWidget
*
parent
,
const
char
*
name
)
:
QListView
(
parent
)
:
QListView
(
parent
)
{
{
setObjectName
(
name
);
setObjectName
(
name
);
//rubberBand = new UBRubberBand( QRubberBand::Rectangle, this );
}
}
/*
/*
...
@@ -495,19 +381,75 @@ void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
...
@@ -495,19 +381,75 @@ void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
void
UBFeaturesListView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
void
UBFeaturesListView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
{
if
(
event
->
mimeData
()
->
hasUrls
()
||
event
->
mimeData
()
->
hasImage
()
)
const
UBFeaturesMimeData
*
fMimeData
=
qobject_cast
<
const
UBFeaturesMimeData
*>
(
event
->
mimeData
());
QModelIndex
index
=
indexAt
(
event
->
pos
());
UBFeature
onFeature
=
model
()
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
if
(
fMimeData
)
{
if
(
!
index
.
isValid
()
||
!
onFeature
.
isFolder
())
{
event
->
ignore
();
return
;
}
}
if
(
event
->
mimeData
()
->
hasUrls
()
||
event
->
mimeData
()
->
hasImage
()
)
{
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
else
{
event
->
ignore
();
}
}
}
void
UBFeaturesListView
::
dropEvent
(
QDropEvent
*
event
)
void
UBFeaturesListView
::
dropEvent
(
QDropEvent
*
event
)
{
{
if
(
event
->
source
()
&&
dynamic_cast
<
UBFeaturesListView
*>
(
event
->
source
()
)
)
QWidget
*
eventSource
=
event
->
source
();
{
if
(
eventSource
&&
eventSource
->
objectName
()
==
objNameFeatureList
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
setDropAction
(
Qt
::
MoveAction
);
}
}
QListView
::
dropEvent
(
event
);
QListView
::
dropEvent
(
event
);
}
void
UBFeaturesListView
::
thumbnailSizeChanged
(
int
value
)
{
setIconSize
(
QSize
(
value
,
value
));
setGridSize
(
QSize
(
value
+
20
,
value
+
20
));
UBSettings
::
settings
()
->
featureSliderPosition
->
set
(
value
);
}
}
UBFeaturesNavigatorWidget
::
UBFeaturesNavigatorWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
),
mListView
(
0
),
mListSlder
(
0
)
{
// if ('\0' == name) {
name
=
"UBFeaturesNavigatorWidget"
;
// }
setObjectName
(
name
);
SET_STYLE_SHEET
()
mListView
=
new
UBFeaturesListView
(
this
,
objNameFeatureList
);
mListSlder
=
new
QSlider
(
Qt
::
Horizontal
,
this
);
mListSlder
->
setMinimum
(
UBFeaturesWidget
::
minThumbnailSize
);
mListSlder
->
setMaximum
(
UBFeaturesWidget
::
maxThumbnailSize
);
mListSlder
->
setValue
(
UBFeaturesWidget
::
minThumbnailSize
);
mListSlder
->
setMinimumHeight
(
20
);
mListView
->
setParent
(
this
);
QVBoxLayout
*
mainLayer
=
new
QVBoxLayout
(
this
);
mainLayer
->
addWidget
(
mListView
,
1
);
mainLayer
->
addWidget
(
mListSlder
,
0
);
connect
(
mListSlder
,
SIGNAL
(
valueChanged
(
int
)),
mListView
,
SLOT
(
thumbnailSizeChanged
(
int
)));
}
void
UBFeaturesNavigatorWidget
::
setSliderPosition
(
int
pValue
)
{
mListSlder
->
setValue
(
pValue
);
}
UBFeaturesWebView
::
UBFeaturesWebView
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
UBFeaturesWebView
::
UBFeaturesWebView
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpView
(
NULL
)
,
mpView
(
NULL
)
...
@@ -609,10 +551,10 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
...
@@ -609,10 +551,10 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
,
mpAddToLibButton
(
NULL
)
,
mpAddToLibButton
(
NULL
)
,
mpSetAsBackgroundButton
(
NULL
)
,
mpSetAsBackgroundButton
(
NULL
)
,
mpObjInfoLabel
(
NULL
)
,
mpObjInfoLabel
(
NULL
)
,
mpObjInfos
(
NULL
)
,
mpThumbnail
(
NULL
)
,
mpThumbnail
(
NULL
)
,
mpOrigPixmap
(
NULL
)
,
mpOrigPixmap
(
NULL
)
,
mpElement
(
NULL
)
,
mpElement
(
NULL
)
,
mpObjInfos
(
NULL
)
{
{
setObjectName
(
name
);
setObjectName
(
name
);
...
@@ -735,6 +677,7 @@ UBFeature UBFeatureProperties::getCurrentElement() const
...
@@ -735,6 +677,7 @@ UBFeature UBFeatureProperties::getCurrentElement() const
{
{
if
(
mpElement
)
if
(
mpElement
)
return
*
mpElement
;
return
*
mpElement
;
return
UBFeature
();
return
UBFeature
();
}
}
...
@@ -863,18 +806,17 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
...
@@ -863,18 +806,17 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
if
(
!
index
.
isValid
())
if
(
!
index
.
isValid
())
return
QVariant
();
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
if
(
role
==
Qt
::
DisplayRole
)
{
return
featuresList
->
at
(
index
.
row
()).
getName
();
return
featuresList
->
at
(
index
.
row
()).
getName
();
else
if
(
role
==
Qt
::
DecorationRole
)
}
{
else
if
(
role
==
Qt
::
DecorationRole
)
{
return
QIcon
(
featuresList
->
at
(
index
.
row
()).
getThumbnail
()
);
return
QIcon
(
featuresList
->
at
(
index
.
row
()).
getThumbnail
()
);
}
else
if
(
role
==
Qt
::
UserRole
)
}
else
if
(
role
==
Qt
::
UserRole
)
{
{
return
featuresList
->
at
(
index
.
row
()).
getVirtualPath
();
return
featuresList
->
at
(
index
.
row
()).
getVirtualPath
();
}
else
if
(
role
==
Qt
::
UserRole
+
1
)
}
else
if
(
role
==
Qt
::
UserRole
+
1
)
{
{
//return featuresList->at(index.row()).getType();
//return featuresList->at(index.row()).getType();
UBFeature
f
=
featuresList
->
at
(
index
.
row
());
UBFeature
f
=
featuresList
->
at
(
index
.
row
());
return
QVariant
::
fromValue
(
f
);
return
QVariant
::
fromValue
(
f
);
...
@@ -885,26 +827,29 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
...
@@ -885,26 +827,29 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
QMimeData
*
UBFeaturesModel
::
mimeData
(
const
QModelIndexList
&
indexes
)
const
QMimeData
*
UBFeaturesModel
::
mimeData
(
const
QModelIndexList
&
indexes
)
const
{
{
QMimeData
*
mimeData
=
new
Q
MimeData
();
UBFeaturesMimeData
*
mimeData
=
new
UBFeatures
MimeData
();
QList
<
QUrl
>
urlList
;
QList
<
QUrl
>
urlList
;
QList
<
UBFeature
>
featuresList
;
QByteArray
typeData
;
foreach
(
QModelIndex
index
,
indexes
)
foreach
(
QModelIndex
index
,
indexes
)
{
{
if
(
index
.
isValid
()
)
if
(
index
.
isValid
())
{
{
UBFeature
element
=
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
element
=
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
urlList
.
push_back
(
element
.
getFullPath
()
);
urlList
.
push_back
(
element
.
getFullPath
()
);
/*if ( element.getType() == FEATURE_INTERNAL )
QString
curPath
=
element
.
getFullPath
().
toLocalFile
();
{
featuresList
.
append
(
element
);
urlList.push_back( QUrl( element.getFullPath() ) );
}
if
(
!
typeData
.
isNull
())
{
else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM )
typeData
+=
UBFeaturesController
::
featureTypeSplitter
();
{
}
urlList.push_back( element.getFullPath() );
typeData
+=
QString
::
number
(
element
.
getType
()).
toAscii
();
}*/
}
}
}
}
mimeData
->
setUrls
(
urlList
);
mimeData
->
setUrls
(
urlList
);
mimeData
->
setFeatures
(
featuresList
);
mimeData
->
setData
(
mimeSankoreFeatureTypes
,
typeData
);
return
mimeData
;
return
mimeData
;
}
}
...
@@ -913,50 +858,41 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
...
@@ -913,50 +858,41 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
{
{
Q_UNUSED
(
row
)
Q_UNUSED
(
row
)
if
(
!
mimeData
->
hasUrls
()
&&
!
mimeData
->
hasImage
()
)
const
UBFeaturesMimeData
*
fMimeData
=
qobject_cast
<
const
UBFeaturesMimeData
*>
(
mimeData
);
bool
dataFromSameModel
=
false
;
if
(
fMimeData
)
dataFromSameModel
=
true
;
if
((
!
mimeData
->
hasUrls
()
&&
!
mimeData
->
hasImage
())
)
return
false
;
return
false
;
if
(
action
==
Qt
::
IgnoreAction
)
if
(
action
==
Qt
::
IgnoreAction
)
return
true
;
return
true
;
if
(
column
>
0
)
if
(
column
>
0
)
return
false
;
return
false
;
int
endRow
=
0
;
UBFeature
parentFeature
;
if
(
!
parent
.
isValid
())
{
UBFeature
parentFeature
;
if
(
!
parent
.
isValid
()
)
{
parentFeature
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
getCurrentElement
();
parentFeature
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
getCurrentElement
();
}
}
else
{
else
parentFeature
=
parent
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
{
parentFeature
=
parent
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
}
if
(
mimeData
->
hasUrls
()
)
{
QList
<
QUrl
>
urls
=
mimeData
->
urls
();
foreach
(
QUrl
url
,
urls
)
{
UBFeature
element
;
if
(
action
==
Qt
::
MoveAction
)
{
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
moveItemToFolder
(
url
,
parentFeature
);
}
else
{
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
copyItemToFolder
(
url
,
parentFeature
);
}
addItem
(
element
);
}
}
}
else
if
(
mimeData
->
hasImage
()
)
{
if
(
mimeData
->
hasUrls
())
{
QList
<
UBFeature
>
featList
=
fMimeData
->
features
();
for
(
int
i
=
0
;
i
<
featList
.
count
();
i
++
)
{
UBFeature
sourceElement
;
if
(
dataFromSameModel
)
{
sourceElement
=
featList
.
at
(
i
);
moveData
(
sourceElement
,
parentFeature
,
Qt
::
MoveAction
);
}
}
}
else
if
(
mimeData
->
hasImage
()
)
{
QImage
image
=
qvariant_cast
<
QImage
>
(
mimeData
->
imageData
()
);
QImage
image
=
qvariant_cast
<
QImage
>
(
mimeData
->
imageData
()
);
UBFeature
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
importImage
(
image
,
parentFeature
);
UBFeature
element
=
dynamic_cast
<
UBFeaturesWidget
*>
(
QObject
::
parent
())
->
getFeaturesController
()
->
importImage
(
image
,
parentFeature
);
addItem
(
element
);
addItem
(
element
);
}
}
return
true
;
return
true
;
}
}
...
@@ -992,6 +928,16 @@ void UBFeaturesModel::deleteItem( const QString &path )
...
@@ -992,6 +928,16 @@ void UBFeaturesModel::deleteItem( const QString &path )
}
}
}
}
void
UBFeaturesModel
::
deleteItem
(
const
UBFeature
&
feature
)
{
int
i
=
featuresList
->
indexOf
(
feature
);
if
(
i
==
-
1
)
{
qDebug
()
<<
"no matches in deleting item from UBFEaturesModel"
;
return
;
}
removeRow
(
i
,
QModelIndex
());
}
bool
UBFeaturesModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
bool
UBFeaturesModel
::
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
)
{
{
if
(
row
<
0
)
if
(
row
<
0
)
...
@@ -1018,39 +964,100 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent )
...
@@ -1018,39 +964,100 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent )
return
true
;
return
true
;
}
}
void
UBFeaturesModel
::
moveData
(
const
UBFeature
&
source
,
const
UBFeature
&
destination
,
Qt
::
DropAction
action
=
Qt
::
CopyAction
,
bool
deleteManualy
)
{
UBFeaturesController
*
curController
=
qobject_cast
<
UBFeaturesController
*>
(
QObject
::
parent
());
if
(
!
curController
)
return
;
QString
sourcePath
=
source
.
getFullPath
().
toLocalFile
();
QString
sourceVirtualPath
=
source
.
getVirtualPath
();
UBFeatureElementType
sourceType
=
source
.
getType
();
QPixmap
sourceIcon
=
source
.
getThumbnail
();
Q_ASSERT
(
QFileInfo
(
sourcePath
).
exists
()
);
QString
name
=
QFileInfo
(
sourcePath
).
fileName
();
QString
destPath
=
destination
.
getFullPath
().
toLocalFile
();
QString
destVirtualPath
=
destination
.
getFullVirtualPath
();
QString
destFullPath
=
destPath
+
"/"
+
name
;
if
(
sourcePath
.
compare
(
destFullPath
,
Qt
::
CaseInsensitive
)
||
destination
.
getType
()
!=
FEATURE_TRASH
)
{
UBFileSystemUtils
::
copy
(
sourcePath
,
destFullPath
);
if
(
action
==
Qt
::
MoveAction
)
{
curController
->
deleteItem
(
source
.
getFullPath
()
);
}
}
//Passing all the source container ubdating dependancy pathes
if
(
sourceType
==
FEATURE_FOLDER
)
{
for
(
int
i
=
0
;
i
<
featuresList
->
count
();
i
++
)
{
UBFeature
&
curFeature
=
(
*
featuresList
)[
i
];
QString
curFeatureFullPath
=
curFeature
.
getFullPath
().
toLocalFile
();
QString
curFeatureVirtualPath
=
curFeature
.
getVirtualPath
();
if
(
curFeatureFullPath
.
contains
(
sourcePath
)
&&
curFeatureFullPath
!=
sourcePath
)
{
UBFeature
copyFeature
=
curFeature
;
QUrl
newPath
=
QUrl
::
fromLocalFile
(
curFeatureFullPath
.
replace
(
sourcePath
,
destFullPath
));
QString
newVirtualPath
=
curFeatureVirtualPath
.
replace
(
sourceVirtualPath
,
destVirtualPath
);
//when copying to trash don't change the real path
if
(
destination
.
getType
()
!=
FEATURE_TRASH
)
{
// processing copy or move action for real FS
if
(
action
==
Qt
::
CopyAction
)
{
copyFeature
.
setFullPath
(
newPath
);
}
else
{
curFeature
.
setFullPath
(
newPath
);
}
}
// processing copy or move action for real FS
if
(
action
==
Qt
::
CopyAction
)
{
copyFeature
.
setFullVirtualPath
(
newVirtualPath
);
}
else
{
curFeature
.
setFullVirtualPath
(
newVirtualPath
);
}
if
(
action
==
Qt
::
CopyAction
)
{
addItem
(
copyFeature
);
}
}
}
}
UBFeature
newElement
(
destVirtualPath
,
sourceIcon
,
name
,
QUrl
::
fromLocalFile
(
destFullPath
),
sourceType
);
addItem
(
newElement
);
if
(
deleteManualy
)
{
deleteItem
(
source
);
}
emit
dataRestructured
();
}
Qt
::
ItemFlags
UBFeaturesModel
::
flags
(
const
QModelIndex
&
index
)
const
Qt
::
ItemFlags
UBFeaturesModel
::
flags
(
const
QModelIndex
&
index
)
const
{
{
Qt
::
ItemFlags
defa
ultFlags
=
QAbstractItemModel
::
flags
(
index
);
Qt
::
ItemFlags
res
ultFlags
=
QAbstractItemModel
::
flags
(
index
);
if
(
index
.
isValid
()
)
if
(
index
.
isValid
()
)
{
{
UBFeature
item
=
index
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
item
=
index
.
data
(
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
if
(
item
.
getType
()
==
FEATURE_INTERACTIVE
||
if
(
item
.
getType
()
==
FEATURE_INTERACTIVE
item
.
getType
()
==
FEATURE_ITEM
||
||
item
.
getType
()
==
FEATURE_ITEM
item
.
getType
()
==
FEATURE_INTERNAL
)
||
item
.
getType
()
==
FEATURE_INTERNAL
return
Qt
::
ItemIsDragEnabled
|
defaultFlags
;
||
item
.
getType
()
==
FEATURE_FOLDER
)
if
(
item
.
isFolder
()
&&
!
item
.
getVirtualPath
().
isNull
()
)
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
resultFlags
|=
Qt
::
ItemIsDragEnabled
;
else
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
}
if
(
item
.
isFolder
()
&&
!
item
.
getVirtualPath
().
isNull
()
)
/*if ( index.isValid() )
resultFlags
|=
Qt
::
ItemIsDropEnabled
;
{
}
UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>();
switch( item.getType() )
return
resultFlags
;
{
case FEATURE_CATEGORY:
case FEATURE_FOLDER:
case FEATURE_FAVORITE:
case FEATURE_TRASH:
return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
case FEATURE_INTERACTIVE:
case FEATURE_INTERNAL:
case FEATURE_ITEM:
return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
default:;
}
}*/
return
defaultFlags
|
Qt
::
ItemIsDropEnabled
;
}
}
...
@@ -1063,13 +1070,12 @@ QStringList UBFeaturesModel::mimeTypes() const
...
@@ -1063,13 +1070,12 @@ QStringList UBFeaturesModel::mimeTypes() const
int
UBFeaturesModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
int
UBFeaturesModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
{
if
(
parent
.
isValid
()
)
if
(
parent
.
isValid
()
||
!
featuresList
)
return
0
;
return
0
;
else
else
return
featuresList
->
size
();
return
featuresList
->
size
();
}
}
bool
UBFeaturesProxyModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
bool
UBFeaturesProxyModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
{
{
QModelIndex
index
=
sourceModel
()
->
index
(
sourceRow
,
0
,
sourceParent
);
QModelIndex
index
=
sourceModel
()
->
index
(
sourceRow
,
0
,
sourceParent
);
...
@@ -1085,10 +1091,10 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn
...
@@ -1085,10 +1091,10 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature
feature
=
sourceModel
()
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
UBFeature
feature
=
sourceModel
()
->
data
(
index
,
Qt
::
UserRole
+
1
).
value
<
UBFeature
>
();
bool
isFile
=
feature
.
getType
()
==
FEATURE_INTERACTIVE
||
bool
isFile
=
feature
.
getType
()
==
FEATURE_INTERACTIVE
feature
.
getType
()
==
FEATURE_INTERNAL
||
||
feature
.
getType
()
==
FEATURE_INTERNAL
feature
.
getType
()
==
FEATURE_ITEM
;
||
feature
.
getType
()
==
FEATURE_ITEM
;
return
isFile
&&
filterRegExp
().
exactMatch
(
feature
.
getName
()
);
return
isFile
&&
filterRegExp
().
exactMatch
(
feature
.
getName
()
);
}
}
...
@@ -1111,13 +1117,13 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc
...
@@ -1111,13 +1117,13 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc
if
(
listView
)
if
(
listView
)
{
{
const
QFontMetrics
fm
=
listView
->
fontMetrics
();
const
QFontMetrics
fm
=
listView
->
fontMetrics
();
const
QSize
iSize
=
listView
->
icon
Size
();
const
QSize
iSize
=
listView
->
grid
Size
();
return
elidedText
(
fm
,
iSize
.
width
(),
Qt
::
ElideRight
,
text
);
return
elidedText
(
fm
,
iSize
.
width
(),
Qt
::
ElideRight
,
text
);
}
}
return
text
;
return
text
;
}
}
UBFeaturesPathItemDelegate
::
UBFeaturesPathItemDelegate
(
Q
Widge
t
*
parent
)
:
QStyledItemDelegate
(
parent
)
UBFeaturesPathItemDelegate
::
UBFeaturesPathItemDelegate
(
Q
Objec
t
*
parent
)
:
QStyledItemDelegate
(
parent
)
{
{
arrowPixmap
=
new
QPixmap
(
":images/navig_arrow.png"
);
arrowPixmap
=
new
QPixmap
(
":images/navig_arrow.png"
);
}
}
...
...
src/gui/UBFeaturesWidget.h
View file @
2033c14f
...
@@ -16,13 +16,12 @@
...
@@ -16,13 +16,12 @@
#include <QDropEvent>
#include <QDropEvent>
#include "UBDockPaletteWidget.h"
#include "UBDockPaletteWidget.h"
//#include "UBLibActionBar
.h"
#include "core/UBSettings
.h"
#include "board/UBFeaturesController.h"
#include "board/UBFeaturesController.h"
#include "api/UBWidgetUniboardAPI.h"
#include "api/UBWidgetUniboardAPI.h"
#include "UBFeaturesActionBar.h"
#include "UBFeaturesActionBar.h"
#include "UBRubberBand.h"
#include "UBRubberBand.h"
#define THUMBNAIL_WIDTH 400
#define THUMBNAIL_WIDTH 400
#define ID_LISTVIEW 0
#define ID_LISTVIEW 0
#define ID_PROPERTIES 1
#define ID_PROPERTIES 1
...
@@ -41,6 +40,8 @@ class UBFeatureProperties;
...
@@ -41,6 +40,8 @@ class UBFeatureProperties;
class
UBFeatureItemButton
;
class
UBFeatureItemButton
;
class
UBFeaturesListView
;
class
UBFeaturesListView
;
class
UBFeaturesWebView
;
class
UBFeaturesWebView
;
class
UBFeaturesNavigatorWidget
;
class
UBFeaturesMimeData
;
class
UBFeaturesWidget
:
public
UBDockPaletteWidget
class
UBFeaturesWidget
:
public
UBDockPaletteWidget
{
{
...
@@ -54,77 +55,119 @@ public:
...
@@ -54,77 +55,119 @@ public:
return
mode
==
eUBDockPaletteWidget_BOARD
return
mode
==
eUBDockPaletteWidget_BOARD
||
mode
==
eUBDockPaletteWidget_DESKTOP
;
||
mode
==
eUBDockPaletteWidget_DESKTOP
;
}
}
UBFeaturesController
*
getFeaturesController
()
const
{
return
controller
;
};
UBFeaturesController
*
getFeaturesController
()
const
{
return
controller
;
}
static
const
int
minThumbnailSize
=
20
;
static
const
int
minThumbnailSize
=
20
;
static
const
int
maxThumbnailSize
=
100
;
static
const
int
maxThumbnailSize
=
100
;
static
const
int
defaultThumbnailSize
=
40
;
static
const
int
defaultThumbnailSize
=
40
;
private
:
void
switchToListView
();
public
:
void
switchToProperties
();
int
scrollbarHorisontalPadding
()
const
{
return
10
;}
void
switchToWebView
();
int
scrollbarVerticalIndent
()
const
{
return
0
;}
UBFeaturesController
*
controller
;
UBFeaturesItemDelegate
*
itemDelegate
;
UBFeaturesPathItemDelegate
*
pathItemDelegate
;
UBFeaturesModel
*
featuresModel
;
UBFeaturesProxyModel
*
featuresProxyModel
;
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
UBFeaturesListView
*
featuresListView
;
UBFeaturesListView
*
pathListView
;
QSlider
*
thumbSlider
;
QVBoxLayout
*
layout
;
//UBFeaturesPathViewer *pathViewer;
//QGraphicsScene *pathScene;
UBFeaturesActionBar
*
mActionBar
;
UBFeatureProperties
*
featureProperties
;
UBFeaturesWebView
*
webView
;
QStackedWidget
*
stackedWidget
;
int
currentStackedWidget
;
private
slots
:
private
slots
:
void
currentSelected
(
const
QModelIndex
&
);
void
currentSelected
(
const
QModelIndex
&
);
//void currentPathChanged(const QString &);
void
searchStarted
(
const
QString
&
);
void
currentPathChanged
(
const
QModelIndex
&
);
void
createNewFolder
();
void
searchStarted
(
const
QString
&
);
void
deleteElements
(
const
UBFeaturesMimeData
*
);
void
createNewFolder
();
void
addToFavorite
(
const
UBFeaturesMimeData
*
);
void
deleteElements
(
const
QMimeData
&
);
void
removeFromFavorite
(
const
UBFeaturesMimeData
*
);
void
addToFavorite
(
const
QMimeData
&
);
void
onDisplayMetadata
(
QMap
<
QString
,
QString
>
);
void
removeFromFavorite
(
const
QMimeData
&
);
void
thumbnailSizeChanged
(
int
);
void
onDisplayMetadata
(
QMap
<
QString
,
QString
>
);
void
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
);
void
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
);
void
addElementsToFavorite
();
void
addElementsToFavorite
();
void
removeElementsFromFavorite
();
void
removeElementsFromFavorite
();
void
deleteSelectedElements
();
void
deleteSelectedElements
();
protected
:
void
rescanModel
();
bool
eventFilter
(
QObject
*
target
,
QEvent
*
event
);
private
:
void
switchToListView
();
void
switchToProperties
();
void
switchToWebView
();
void
updateSliderPosition
();
private
:
UBFeaturesController
*
controller
;
UBFeaturesItemDelegate
*
itemDelegate
;
UBFeaturesPathItemDelegate
*
pathItemDelegate
;
UBFeaturesModel
*
featuresModel
;
UBFeaturesProxyModel
*
featuresProxyModel
;
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
UBFeaturesNavigatorWidget
*
mNavigator
;
UBFeaturesListView
*
pathListView
;
QVBoxLayout
*
layout
;
UBFeaturesActionBar
*
mActionBar
;
UBFeatureProperties
*
featureProperties
;
UBFeaturesWebView
*
webView
;
QStackedWidget
*
stackedWidget
;
int
currentStackedWidget
;
};
class
UBFeaturesMimeData
:
public
QMimeData
{
Q_OBJECT
public
:
virtual
QStringList
formats
()
const
;
QList
<
UBFeature
>
features
()
const
{
return
mFeatures
;}
void
setFeatures
(
const
QList
<
UBFeature
>
&
fList
)
{
mFeatures
=
fList
;}
private
:
QList
<
UBFeature
>
mFeatures
;
};
};
class
UBFeaturesListView
:
public
QListView
class
UBFeaturesListView
:
public
QListView
{
{
Q_OBJECT
Q_OBJECT
public
:
public
:
UBFeaturesListView
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBFeaturesListView"
);
UBFeaturesListView
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBFeaturesListView"
);
virtual
~
UBFeaturesListView
()
{;}
virtual
~
UBFeaturesListView
()
{;}
protected
:
protected
:
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
/*virtual void mousePressEvent( QMouseEvent *event );
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
virtual void mouseReleaseEvent( QMouseEvent *event );*/
private
slots
:
void
thumbnailSizeChanged
(
int
);
private
:
private
:
//UBRubberBand *rubberBand;
//UBRubberBand *rubberBand;
//QPoint rubberOrigin;
//QPoint rubberOrigin;
};
};
// class created to have the same style for slider and QListView itself
class
UBFeaturesNavigatorWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBFeaturesNavigatorWidget
(
QWidget
*
parent
,
const
char
*
name
=
""
);
UBFeaturesListView
*
listView
()
{
return
mListView
;}
void
setSliderPosition
(
int
pValue
);
private
:
UBFeaturesListView
*
mListView
;
QSlider
*
mListSlder
;
};
class
UBFeaturesWebView
:
public
QWidget
class
UBFeaturesWebView
:
public
QWidget
{
{
Q_OBJECT
Q_OBJECT
...
@@ -169,9 +212,9 @@ private:
...
@@ -169,9 +212,9 @@ private:
QVBoxLayout
*
mpLayout
;
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpButtonLayout
;
QHBoxLayout
*
mpButtonLayout
;
UBFeatureItemButton
*
mpAddPageButton
;
UBFeatureItemButton
*
mpAddPageButton
;
UBFeatureItemButton
*
mpAddToLibButton
;
UBFeatureItemButton
*
mpAddToLibButton
;
UBFeatureItemButton
*
mpSetAsBackgroundButton
;
UBFeatureItemButton
*
mpSetAsBackgroundButton
;
QLabel
*
mpObjInfoLabel
;
QLabel
*
mpObjInfoLabel
;
QTreeWidget
*
mpObjInfos
;
QTreeWidget
*
mpObjInfos
;
QLabel
*
mpThumbnail
;
QLabel
*
mpThumbnail
;
...
@@ -181,9 +224,6 @@ private:
...
@@ -181,9 +224,6 @@ private:
QTreeWidgetItem
*
mpItem
;
QTreeWidgetItem
*
mpItem
;
};
};
class
UBFeatureItemButton
:
public
QPushButton
class
UBFeatureItemButton
:
public
QPushButton
{
{
public
:
public
:
...
@@ -194,13 +234,18 @@ public:
...
@@ -194,13 +234,18 @@ public:
class
UBFeaturesModel
:
public
QAbstractListModel
class
UBFeaturesModel
:
public
QAbstractListModel
{
{
Q_OBJECT
Q_OBJECT
signals
:
void
dataRestructured
();
public
:
public
:
UBFeaturesModel
(
QObject
*
parent
=
0
)
:
QAbstractListModel
(
paren
t
)
{;}
UBFeaturesModel
(
QList
<
UBFeature
>
*
pFeaturesList
,
QObject
*
parent
=
0
)
:
QAbstractListModel
(
parent
),
featuresList
(
pFeaturesLis
t
)
{;}
virtual
~
UBFeaturesModel
(){;}
virtual
~
UBFeaturesModel
(){;}
void
addItem
(
const
UBFeature
&
item
);
void
addItem
(
const
UBFeature
&
item
);
void
deleteFavoriteItem
(
const
QString
&
path
);
void
deleteFavoriteItem
(
const
QString
&
path
);
void
deleteItem
(
const
QString
&
path
);
void
deleteItem
(
const
QString
&
path
);
void
deleteItem
(
const
UBFeature
&
feature
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
QMimeData
*
mimeData
(
const
QModelIndexList
&
indexes
)
const
;
QMimeData
*
mimeData
(
const
QModelIndexList
&
indexes
)
const
;
...
@@ -212,10 +257,11 @@ public:
...
@@ -212,10 +257,11 @@ public:
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
//bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
//bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
//bool insertRow(int row, const QModelIndex &parent = QModelIndex());
//bool insertRow(int row, const QModelIndex &parent = QModelIndex());
void
moveData
(
const
UBFeature
&
source
,
const
UBFeature
&
destination
,
Qt
::
DropAction
action
,
bool
deleteManualy
=
false
);
Qt
::
DropActions
supportedDropActions
()
const
{
return
Qt
::
MoveAction
|
Qt
::
CopyAction
;
}
Qt
::
DropActions
supportedDropActions
()
const
{
return
Qt
::
MoveAction
|
Qt
::
CopyAction
;
}
// void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
void
setFeaturesList
(
QList
<
UBFeature
>
*
flist
)
{
featuresList
=
flist
;
}
private
:
private
:
QList
<
UBFeature
>
*
featuresList
;
QList
<
UBFeature
>
*
featuresList
;
};
};
...
@@ -257,7 +303,7 @@ class UBFeaturesItemDelegate : public QStyledItemDelegate
...
@@ -257,7 +303,7 @@ class UBFeaturesItemDelegate : public QStyledItemDelegate
{
{
Q_OBJECT
Q_OBJECT
public
:
public
:
UBFeaturesItemDelegate
(
Q
Widge
t
*
parent
=
0
,
const
QListView
*
lw
=
0
)
:
QStyledItemDelegate
(
parent
)
{
listView
=
lw
;
}
UBFeaturesItemDelegate
(
Q
Objec
t
*
parent
=
0
,
const
QListView
*
lw
=
0
)
:
QStyledItemDelegate
(
parent
)
{
listView
=
lw
;
}
~
UBFeaturesItemDelegate
()
{}
~
UBFeaturesItemDelegate
()
{}
//UBFeaturesItemDelegate(const QListView *lw = 0) { listView = lw; };
//UBFeaturesItemDelegate(const QListView *lw = 0) { listView = lw; };
//void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
//void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
...
@@ -271,7 +317,7 @@ class UBFeaturesPathItemDelegate : public QStyledItemDelegate
...
@@ -271,7 +317,7 @@ class UBFeaturesPathItemDelegate : public QStyledItemDelegate
{
{
Q_OBJECT
Q_OBJECT
public
:
public
:
UBFeaturesPathItemDelegate
(
QWidge
t
*
parent
=
0
);
UBFeaturesPathItemDelegate
(
QObjec
t
*
parent
=
0
);
~
UBFeaturesPathItemDelegate
();
~
UBFeaturesPathItemDelegate
();
virtual
QString
displayText
(
const
QVariant
&
value
,
const
QLocale
&
locale
)
const
;
virtual
QString
displayText
(
const
QVariant
&
value
,
const
QLocale
&
locale
)
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
...
...
src/gui/UBRubberBand.cpp
View file @
2033c14f
...
@@ -35,7 +35,7 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
...
@@ -35,7 +35,7 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
#elif defined(Q_WS_MAC)
#elif defined(Q_WS_MAC)
customStyle
=
new
QMacStyle
();
customStyle
=
new
QMacStyle
();
#elif defined(Q_WS_X11)
#elif defined(Q_WS_X11)
//
customStyle = QStyleFactory::create("oxygen");
customStyle
=
QStyleFactory
::
create
(
"oxygen"
);
#endif
#endif
if
(
customStyle
)
if
(
customStyle
)
...
...
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