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
Expand all
Show 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,
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget,
QWidget#UBTeacherGuideWidget,
QWidget#UBFeatureProperties
QWidget#UBFeatureProperties,
QWidget#UBFeaturesNavigatorWidget,
QWidget#PathList
{
background: #EEEEEE;
border-radius: 10px;
...
...
@@ -26,14 +28,13 @@ QWidget#UBLibWebView
border: 2px solid #999999;
}
Q
Widget#UBFeaturesWeb
View
Q
List
View
{
background: #EEEEEE;
border-radius : 10px;
border: 2px solid #999999;
border: 0px;
}
QListView
QWidget#UBFeaturesWebView
{
background: #EEEEEE;
border-radius : 10px;
...
...
src/board/UBBoardPaletteManager.cpp
View file @
2033c14f
...
...
@@ -83,9 +83,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
,
mPendingPanButtonPressed
(
false
)
,
mPendingEraseButtonPressed
(
false
)
,
mpPageNavigWidget
(
NULL
)
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
,
mpLibWidget
(
NULL
)
#endif
//
#endif
,
mpCachePropWidget
(
NULL
)
,
mpDownloadWidget
(
NULL
)
,
mpDesktopLibWidget
(
NULL
)
...
...
@@ -136,9 +136,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpPageNavigWidget
=
new
UBPageNavigationWidget
();
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
mpLibWidget
=
new
UBLibWidget
();
#endif
//
#endif
mpCachePropWidget
=
new
UBCachePropertiesWidget
();
...
...
@@ -170,10 +170,10 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//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
->
addTab
(
mpLibWidget
);
#endif
//
#endif
// 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;
class
UBDockTeacherGuideWidget
;
// Uncomment this to use old-styles lib paletter
#define USE_WEB_WIDGET
//
#define USE_WEB_WIDGET
class
UBBoardPaletteManager
:
public
QObject
...
...
@@ -134,10 +134,10 @@ class UBBoardPaletteManager : public QObject
/** The page navigator widget */
UBPageNavigationWidget
*
mpPageNavigWidget
;
#ifdef USE_WEB_WIDGET
//
#ifdef USE_WEB_WIDGET
/** The library widget */
UBLibWidget
*
mpLibWidget
;
#endif
//
#endif
/** The cache properties widget */
UBCachePropertiesWidget
*
mpCachePropWidget
;
...
...
src/board/UBBoardView.h
View file @
2033c14f
...
...
@@ -28,7 +28,7 @@ class UBRubberBand;
class
UBBoardView
:
public
QGraphicsView
{
Q_OBJECT
;
Q_OBJECT
public
:
...
...
src/board/UBFeaturesController.cpp
View file @
2033c14f
This diff is collapsed.
Click to expand it.
src/board/UBFeaturesController.h
View file @
2033c14f
...
...
@@ -11,6 +11,15 @@
#include <QMap>
#include <QUrl>
#include <QByteArray>
#include <QtGui>
class
UBFeaturesModel
;
class
UBFeaturesItemDelegate
;
class
UBFeaturesPathItemDelegate
;
class
UBFeaturesProxyModel
;
class
UBFeaturesSearchProxyModel
;
class
UBFeaturesPathProxyModel
;
class
UBFeaturesListView
;
//#include "UBDockPaletteWidget.h"
...
...
@@ -33,77 +42,122 @@ public:
UBFeature
()
{;}
//UBFeature(const UBFeature &f);
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
;
}
QPixmap
getThumbnail
()
const
{
return
mThumbnail
;}
QString
getVirtualPath
()
const
{
return
virtual
Path
;
}
QString
getVirtualPath
()
const
{
return
virtual
Dir
;
}
//QString getPath() const { return mPath; };
QUrl
getFullPath
()
const
{
return
mPath
;
}
QString
getFullVirtualPath
()
const
{
return
virtualPath
+
"/"
+
mName
;
}
QString
getFullVirtualPath
()
const
{
return
virtualDir
+
"/"
+
mName
;
}
QString
getUrl
()
const
;
void
setFullPath
(
const
QUrl
&
newPath
)
{
mPath
=
newPath
;}
void
setFullVirtualPath
(
const
QString
&
newVirtualPath
)
{
virtualDir
=
newVirtualPath
;}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
bool
isFolder
()
const
;
bool
isDeletable
()
const
;
bool
inTrash
()
const
;
bool
operator
==
(
const
UBFeature
&
f
)
const
;
bool
operator
!=
(
const
UBFeature
&
f
)
const
;
const
QMap
<
QString
,
QString
>
&
getMetadata
()
const
{
return
metadata
;
}
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
:
QString
virtualPath
;
QString
virtualDir
;
QPixmap
mThumbnail
;
QString
mName
;
QUrl
mPath
;
UBFeatureElementType
elementType
;
QMap
<
QString
,
QString
>
metadata
;
QList
<
UBFeature
*>
mChildren
;
QList
<
UBFeature
*>
mParents
;
};
Q_DECLARE_METATYPE
(
UBFeature
)
class
UBFeaturesController
:
public
QObject
{
friend
class
UBFeaturesWidget
;
Q_OBJECT
public
:
UBFeaturesController
(
QWidget
*
parentWidget
);
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
addItemAsBackground
(
const
UBFeature
&
item
);
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
void
addItemToPage
(
const
UBFeature
&
item
);
void
addItemAsBackground
(
const
UBFeature
&
item
);
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
UBFeature
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
);
UBFeature
moveItemToFolder
(
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
UBFeature
&
pFeature
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
);
void
moveToTrash
(
UBFeature
feature
,
bool
deleteManualy
=
false
);
void
addNewFolder
(
const
QString
&
name
);
void
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
,
bool
deleteManualy
=
false
);
UBFeature
importImage
(
const
QImage
&
image
,
const
UBFeature
&
destination
);
void
fileSystemScan
(
const
QUrl
&
currPath
,
const
QString
&
currVirtualPath
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
bool
isDeletable
(
const
QUrl
&
url
);
static
char
featureTypeSplitter
()
{
return
':'
;}
static
const
QString
virtualRootName
;
void
assignFeaturesListVeiw
(
UBFeaturesListView
*
pList
);
void
assignPathListView
(
UBFeaturesListView
*
pList
);
private
:
void
initDirectoryTree
();
void
fileSystemScan
(
const
QUrl
&
currPath
,
const
QString
&
currVirtualPath
);
UBFeaturesItemDelegate
*
itemDelegate
;
UBFeaturesPathItemDelegate
*
pathItemDelegate
;
UBFeaturesModel
*
featuresModel
;
UBFeaturesProxyModel
*
featuresProxyModel
;
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
private
:
static
QPixmap
createThumbnail
(
const
QString
&
path
);
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
saveFavoriteList
();
UBFeature
getDestinationForItem
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
QList
<
UBFeature
>
*
featuresList
;
UBFeature
*
rootElement
;
QUrl
mUserAudioDirectoryPath
;
QUrl
mUserVideoDirectoryPath
;
...
...
@@ -135,19 +189,24 @@ private:
int
mLastItemOffsetIndex
;
UBFeature
currentElement
;
UBFeature
trashElement
;
UBFeature
rootElement
;
UBFeature
favoriteElement
;
UBFeature
audiosElement
;
UBFeature
moviesElement
;
UBFeature
picturesElement
;
UBFeature
interactElement
;
UBFeature
applicationsElement
;
UBFeature
flashElement
;
UBFeature
shapesElement
;
UBFeature
webSearchElement
;
QSet
<
QUrl
>
*
favoriteSet
;
};
public
:
UBFeature
trashElement
;
UBFeature
getParentFeatureForUrl
(
const
QUrl
&
url
);
};
#endif
src/core/UBSetting.cpp
View file @
2033c14f
...
...
@@ -74,6 +74,10 @@ void UBSetting::setString(const QString& pValue)
{
set
(
pValue
);
}
void
UBSetting
::
setInt
(
int
pValue
)
{
set
(
pValue
);
}
UBColorListSetting
::
UBColorListSetting
(
UBSettings
*
parent
)
...
...
src/core/UBSetting.h
View file @
2033c14f
...
...
@@ -54,6 +54,7 @@ class UBSetting : public QObject
void
setBool
(
bool
pValue
);
void
setString
(
const
QString
&
pValue
);
void
setInt
(
int
pValue
);
signals
:
...
...
src/core/UBSettings.cpp
View file @
2033c14f
...
...
@@ -217,6 +217,8 @@ void UBSettings::init()
appStartMode
=
new
UBSetting
(
this
,
"App"
,
"StartMode"
,
""
);
featureSliderPosition
=
new
UBSetting
(
this
,
"Board"
,
"FeatureSliderPosition"
,
40
);
boardPenFineWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenFineWidth"
,
1.5
);
boardPenMediumWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenMediumWidth"
,
3.0
);
boardPenStrongWidth
=
new
UBSetting
(
this
,
"Board"
,
"PenStrongWidth"
,
8.0
);
...
...
src/core/UBSettings.h
View file @
2033c14f
...
...
@@ -239,6 +239,8 @@ class UBSettings : public QObject
UBSetting
*
appStartMode
;
UBSetting
*
featureSliderPosition
;
UBColorListSetting
*
boardPenLightBackgroundColors
;
UBColorListSetting
*
boardPenLightBackgroundSelectedColors
;
...
...
src/frameworks/UBFileSystemUtils.cpp
View file @
2033c14f
...
...
@@ -61,14 +61,14 @@ bool UBFileSystemUtils::isAZipFile(QString &filePath)
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
))
{
qDebug
()
<<
"file"
<<
source
<<
"does not present in fs"
;
return
false
;
}
QString
normalizedDestination
=
D
estination
;
QString
normalizedDestination
=
d
estination
;
if
(
QFile
::
exists
(
normalizedDestination
))
{
if
(
QFileInfo
(
normalizedDestination
).
isFile
()
&&
overwrite
)
{
QFile
::
remove
(
normalizedDestination
);
...
...
@@ -86,6 +86,15 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destinati
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
)
{
QFile
f
(
path
);
...
...
src/frameworks/UBFileSystemUtils.h
View file @
2033c14f
...
...
@@ -45,6 +45,10 @@ class UBFileSystemUtils
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
digitFileFormat
(
const
QString
&
s
,
int
digit
);
...
...
@@ -65,8 +69,6 @@ class UBFileSystemUtils
static
bool
isAZipFile
(
QString
&
filePath
);
static
bool
copyFile
(
const
QString
&
source
,
const
QString
&
Destination
,
bool
overwrite
=
false
);
static
bool
deleteFile
(
const
QString
&
path
);
/**
* Compress a source directory in a zip file.
...
...
src/gui/UBFeaturesActionBar.cpp
View file @
2033c14f
#include "UBFeaturesActionBar.h"
#include "core/memcheck.h"
#include "gui/UBFeaturesWidget.h"
UBFeaturesActionBar
::
UBFeaturesActionBar
(
UBFeaturesController
*
controller
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
featuresController
(
controller
)
...
...
@@ -8,6 +9,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
,
mLayout
(
NULL
)
,
mpFavoriteAction
(
NULL
)
,
mpSocialAction
(
NULL
)
,
mpRescanModelAction
(
NULL
)
,
mpDeleteAction
(
NULL
)
,
mpSearchAction
(
NULL
)
,
mpCloseAction
(
NULL
)
...
...
@@ -15,6 +17,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
,
mpNewFolderAction
(
NULL
)
,
mpFavoriteBtn
(
NULL
)
,
mpSocialBtn
(
NULL
)
,
mpRescanModelBtn
(
NULL
)
,
mpDeleteBtn
(
NULL
)
,
mpCloseBtn
(
NULL
)
,
mpRemoveFavoriteBtn
(
NULL
)
...
...
@@ -39,6 +42,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mpFavoriteAction
=
new
QAction
(
QIcon
(
":/images/libpalette/miniFavorite.png"
),
tr
(
"Add to favorites"
),
this
);
mpSocialAction
=
new
QAction
(
QIcon
(
":/images/libpalette/social.png"
),
tr
(
"Share"
),
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
);
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
);
...
...
@@ -48,6 +52,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mpFavoriteBtn
=
new
UBActionButton
(
this
,
mpFavoriteAction
);
mpSocialBtn
=
new
UBActionButton
(
this
,
mpSocialAction
);
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpRescanModelBtn
=
new
UBActionButton
(
this
,
mpRescanModelAction
);
mpDeleteBtn
=
new
UBActionButton
(
this
,
mpDeleteAction
);
mpCloseBtn
=
new
UBActionButton
(
this
,
mpCloseAction
);
mpRemoveFavoriteBtn
=
new
UBActionButton
(
this
,
mpRemoveFavorite
);
...
...
@@ -79,14 +84,17 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
connect
(
mSearchBar
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
onSearchTextChanged
(
QString
)));
connect
(
mpNewFolderAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionNewFolder
()));
connect
(
mpRemoveFavorite
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionRemoveFavorite
()));
connect
(
mpRescanModelAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionRescanModel
()));
connect
(
mpDeleteAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onActionTrash
()));
// Build the default toolbar
mLayout
->
addWidget
(
mpFavoriteBtn
);
mLayout
->
addWidget
(
mpSocialBtn
);
mLayout
->
addWidget
(
mpNewFolderBtn
);
mLayout
->
addWidget
(
mSearchBar
);
//mLayout->addWidget(mpSearchBtn);
mLayout
->
addWidget
(
mpRescanModelBtn
);
mLayout
->
addWidget
(
mpDeleteBtn
);
mLayout
->
addWidget
(
mpCloseBtn
);
mLayout
->
addWidget
(
mpRemoveFavoriteBtn
);
...
...
@@ -115,6 +123,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
setEnabled
(
true
);
mpDeleteBtn
->
setEnabled
(
true
);
mpRescanModelBtn
->
show
();
break
;
case
IN_ROOT
:
mpFavoriteBtn
->
show
();
...
...
@@ -126,6 +135,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn
->
show
();
mpNewFolderBtn
->
setEnabled
(
false
);
mpDeleteBtn
->
setEnabled
(
false
);
mpRescanModelBtn
->
show
();
break
;
case
IN_PROPERTIES
:
mpFavoriteBtn
->
show
();
...
...
@@ -136,6 +146,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
mpRemoveFavoriteBtn
->
hide
();
mpNewFolderBtn
->
hide
();
mpRescanModelBtn
->
hide
();
break
;
case
IN_FAVORITE
:
mpFavoriteBtn
->
hide
();
...
...
@@ -146,6 +157,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
mpRemoveFavoriteBtn
->
show
();
mpNewFolderBtn
->
hide
();
mpRescanModelBtn
->
hide
();
break
;
case
IN_TRASH
:
mpFavoriteBtn
->
hide
();
...
...
@@ -158,6 +170,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn
->
hide
();
//mpRemoveFavoriteBtn->show();
mpNewFolderBtn
->
hide
();
mpRescanModelBtn
->
hide
();
break
;
default
:
break
;
...
...
@@ -189,48 +202,57 @@ void UBFeaturesActionBar::onActionTrash()
{
emit
deleteSelectedElements
();
}
/*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
void
UBFeaturesActionBar
::
onActionRescanModel
()
{
e
vent->acceptProposedAction
();
e
mit
rescanModel
();
}
*/
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
();
}
else
{
event
->
ignore
();
}
}
void
UBFeaturesActionBar
::
dropEvent
(
QDropEvent
*
event
)
void
UBFeaturesActionBar
::
dropEvent
(
QDropEvent
*
event
)
{
QWidget
*
dest
=
childAt
(
event
->
pos
()
);
if
(
dest
==
mpDeleteBtn
)
{
QList
<
QUrl
>
urls
=
event
->
mimeData
()
->
urls
();
foreach
(
QUrl
url
,
urls
)
{
if
(
!
UBFeaturesController
::
isDeletable
(
url
)
)
const
UBFeaturesMimeData
*
fMimeData
=
qobject_cast
<
const
UBFeaturesMimeData
*>
(
event
->
mimeData
());
if
(
!
fMimeData
)
{
qWarning
()
<<
"data came from not supported widget"
;
event
->
ignore
();
return
;
}
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
emit
deleteElements
(
*
event
->
mimeData
()
);
QWidget
*
dest
=
childAt
(
event
->
pos
());
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
;
}
else
if
(
dest
==
mpFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
CopyAction
);
event
->
accept
();
emit
addToFavorite
(
*
event
->
mimeData
()
);
}
else
if
(
dest
==
mpRemoveFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
emit
deleteElements
(
fMimeData
);
}
else
if
(
dest
==
mpFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
CopyAction
);
event
->
accept
();
emit
addToFavorite
(
fMimeData
);
}
else
if
(
dest
==
mpRemoveFavoriteBtn
)
{
event
->
setDropAction
(
Qt
::
MoveAction
);
event
->
accept
();
emit
removeFromFavorite
(
*
event
->
mimeData
()
);
emit
removeFromFavorite
(
fMimeData
);
}
}
...
...
src/gui/UBFeaturesActionBar.h
View file @
2033c14f
...
...
@@ -7,6 +7,8 @@
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
class
UBFeaturesMimeData
;
enum
UBFeaturesActionBarState
{
IN_ROOT
,
...
...
@@ -24,25 +26,30 @@ public:
~
UBFeaturesActionBar
();
void
setCurrentState
(
UBFeaturesActionBarState
state
);
signals
:
void
searchElement
(
const
QString
&
text
);
void
newFolderToCreate
();
void
deleteElements
(
const
QMimeData
&
data
);
void
addToFavorite
(
const
QMimeData
&
data
);
void
removeFromFavorite
(
const
QMimeData
&
data
);
void
deleteElements
(
const
UBFeaturesMimeData
*
data
);
void
addToFavorite
(
const
UBFeaturesMimeData
*
data
);
void
removeFromFavorite
(
const
UBFeaturesMimeData
*
data
);
void
addElementsToFavorite
();
void
removeElementsFromFavorite
();
void
deleteSelectedElements
();
void
rescanModel
();
private
slots
:
void
onSearchTextChanged
(
QString
txt
);
void
onActionNewFolder
();
void
onActionFavorite
();
void
onActionRemoveFavorite
();
void
onActionTrash
();
void
onActionRescanModel
();
protected
:
//void dragMoveEvent(QDragMoveEvent *event);
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
void
dropEvent
(
QDropEvent
*
event
);
private
:
void
setButtons
();
UBFeaturesController
*
featuresController
;
...
...
@@ -56,6 +63,7 @@ private:
QHBoxLayout
*
mLayout
;
QAction
*
mpFavoriteAction
;
QAction
*
mpSocialAction
;
QAction
*
mpRescanModelAction
;
QAction
*
mpDeleteAction
;
QAction
*
mpSearchAction
;
QAction
*
mpCloseAction
;
...
...
@@ -63,13 +71,11 @@ private:
QAction
*
mpNewFolderAction
;
UBActionButton
*
mpFavoriteBtn
;
UBActionButton
*
mpSocialBtn
;
UBActionButton
*
mpRescanModelBtn
;
UBActionButton
*
mpDeleteBtn
;
//UBActionButton* mpSearchBtn;
UBActionButton
*
mpCloseBtn
;
UBActionButton
*
mpRemoveFavoriteBtn
;
UBActionButton
*
mpNewFolderBtn
;
};
#endif
src/gui/UBFeaturesWidget.cpp
View file @
2033c14f
This diff is collapsed.
Click to expand it.
src/gui/UBFeaturesWidget.h
View file @
2033c14f
...
...
@@ -16,13 +16,12 @@
#include <QDropEvent>
#include "UBDockPaletteWidget.h"
//#include "UBLibActionBar
.h"
#include "core/UBSettings
.h"
#include "board/UBFeaturesController.h"
#include "api/UBWidgetUniboardAPI.h"
#include "UBFeaturesActionBar.h"
#include "UBRubberBand.h"
#define THUMBNAIL_WIDTH 400
#define ID_LISTVIEW 0
#define ID_PROPERTIES 1
...
...
@@ -41,6 +40,8 @@ class UBFeatureProperties;
class
UBFeatureItemButton
;
class
UBFeaturesListView
;
class
UBFeaturesWebView
;
class
UBFeaturesNavigatorWidget
;
class
UBFeaturesMimeData
;
class
UBFeaturesWidget
:
public
UBDockPaletteWidget
{
...
...
@@ -54,16 +55,39 @@ public:
return
mode
==
eUBDockPaletteWidget_BOARD
||
mode
==
eUBDockPaletteWidget_DESKTOP
;
}
UBFeaturesController
*
getFeaturesController
()
const
{
return
controller
;
};
UBFeaturesController
*
getFeaturesController
()
const
{
return
controller
;
}
static
const
int
minThumbnailSize
=
20
;
static
const
int
maxThumbnailSize
=
100
;
static
const
int
defaultThumbnailSize
=
40
;
public
:
int
scrollbarHorisontalPadding
()
const
{
return
10
;}
int
scrollbarVerticalIndent
()
const
{
return
0
;}
private
slots
:
void
currentSelected
(
const
QModelIndex
&
);
void
searchStarted
(
const
QString
&
);
void
createNewFolder
();
void
deleteElements
(
const
UBFeaturesMimeData
*
);
void
addToFavorite
(
const
UBFeaturesMimeData
*
);
void
removeFromFavorite
(
const
UBFeaturesMimeData
*
);
void
onDisplayMetadata
(
QMap
<
QString
,
QString
>
);
void
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
);
void
addElementsToFavorite
();
void
removeElementsFromFavorite
();
void
deleteSelectedElements
();
void
rescanModel
();
private
:
void
switchToListView
();
void
switchToProperties
();
void
switchToWebView
();
void
updateSliderPosition
();
private
:
UBFeaturesController
*
controller
;
UBFeaturesItemDelegate
*
itemDelegate
;
...
...
@@ -74,45 +98,42 @@ private:
UBFeaturesSearchProxyModel
*
featuresSearchModel
;
UBFeaturesPathProxyModel
*
featuresPathModel
;
UBFeaturesListView
*
featuresListView
;
UBFeaturesNavigatorWidget
*
mNavigator
;
UBFeaturesListView
*
pathListView
;
QSlider
*
thumbSlider
;
QVBoxLayout
*
layout
;
//UBFeaturesPathViewer *pathViewer;
//QGraphicsScene *pathScene;
UBFeaturesActionBar
*
mActionBar
;
UBFeatureProperties
*
featureProperties
;
UBFeaturesWebView
*
webView
;
QStackedWidget
*
stackedWidget
;
int
currentStackedWidget
;
private
slots
:
void
currentSelected
(
const
QModelIndex
&
);
//void currentPathChanged(const QString &);
void
currentPathChanged
(
const
QModelIndex
&
);
void
searchStarted
(
const
QString
&
);
void
createNewFolder
();
void
deleteElements
(
const
QMimeData
&
);
void
addToFavorite
(
const
QMimeData
&
);
void
removeFromFavorite
(
const
QMimeData
&
);
void
thumbnailSizeChanged
(
int
);
void
onDisplayMetadata
(
QMap
<
QString
,
QString
>
);
void
onAddDownloadedFileToLibrary
(
bool
,
QUrl
,
QString
,
QByteArray
);
void
addElementsToFavorite
();
void
removeElementsFromFavorite
();
void
deleteSelectedElements
();
protected
:
bool
eventFilter
(
QObject
*
target
,
QEvent
*
event
);
};
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
{
Q_OBJECT
public
:
UBFeaturesListView
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBFeaturesListView"
);
virtual
~
UBFeaturesListView
()
{;}
protected
:
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
...
...
@@ -120,11 +141,33 @@ protected:
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
private
slots
:
void
thumbnailSizeChanged
(
int
);
private
:
//UBRubberBand *rubberBand;
//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
{
Q_OBJECT
...
...
@@ -169,9 +212,9 @@ private:
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpButtonLayout
;
UBFeatureItemButton
*
mpAddPageButton
;
UBFeatureItemButton
*
mpAddToLibButton
;
UBFeatureItemButton
*
mpSetAsBackgroundButton
;
UBFeatureItemButton
*
mpAddPageButton
;
UBFeatureItemButton
*
mpAddToLibButton
;
UBFeatureItemButton
*
mpSetAsBackgroundButton
;
QLabel
*
mpObjInfoLabel
;
QTreeWidget
*
mpObjInfos
;
QLabel
*
mpThumbnail
;
...
...
@@ -181,9 +224,6 @@ private:
QTreeWidgetItem
*
mpItem
;
};
class
UBFeatureItemButton
:
public
QPushButton
{
public
:
...
...
@@ -194,13 +234,18 @@ public:
class
UBFeaturesModel
:
public
QAbstractListModel
{
Q_OBJECT
signals
:
void
dataRestructured
();
public
:
UBFeaturesModel
(
QObject
*
parent
=
0
)
:
QAbstractListModel
(
paren
t
)
{;}
UBFeaturesModel
(
QList
<
UBFeature
>
*
pFeaturesList
,
QObject
*
parent
=
0
)
:
QAbstractListModel
(
parent
),
featuresList
(
pFeaturesLis
t
)
{;}
virtual
~
UBFeaturesModel
(){;}
void
addItem
(
const
UBFeature
&
item
);
void
deleteFavoriteItem
(
const
QString
&
path
);
void
deleteItem
(
const
QString
&
path
);
void
deleteItem
(
const
UBFeature
&
feature
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
QMimeData
*
mimeData
(
const
QModelIndexList
&
indexes
)
const
;
...
...
@@ -213,9 +258,10 @@ public:
//bool insertRows(int row, int count, 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
;
}
// void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
void
setFeaturesList
(
QList
<
UBFeature
>
*
flist
)
{
featuresList
=
flist
;
}
private
:
QList
<
UBFeature
>
*
featuresList
;
};
...
...
@@ -257,7 +303,7 @@ class UBFeaturesItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
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(const QListView *lw = 0) { listView = lw; };
//void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
...
...
@@ -271,7 +317,7 @@ class UBFeaturesPathItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public
:
UBFeaturesPathItemDelegate
(
QWidge
t
*
parent
=
0
);
UBFeaturesPathItemDelegate
(
QObjec
t
*
parent
=
0
);
~
UBFeaturesPathItemDelegate
();
virtual
QString
displayText
(
const
QVariant
&
value
,
const
QLocale
&
locale
)
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)
#elif defined(Q_WS_MAC)
customStyle
=
new
QMacStyle
();
#elif defined(Q_WS_X11)
//
customStyle = QStyleFactory::create("oxygen");
customStyle
=
QStyleFactory
::
create
(
"oxygen"
);
#endif
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