|
|
@ -18,6 +18,8 @@ |
|
|
|
#include "domain/UBGraphicsVideoItem.h" |
|
|
|
#include "domain/UBGraphicsVideoItem.h" |
|
|
|
#include "domain/UBGraphicsWidgetItem.h" |
|
|
|
#include "domain/UBGraphicsWidgetItem.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
|
|
|
UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type) |
|
|
|
UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type) |
|
|
|
: virtualPath(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type) |
|
|
|
: virtualPath(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -67,12 +69,10 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; |
|
|
|
mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; |
|
|
|
trashDirectoryPath = UBSettings::userTrashDirPath(); |
|
|
|
trashDirectoryPath = UBSettings::userTrashDirPath(); |
|
|
|
|
|
|
|
|
|
|
|
featuresList = new QList <UBFeature>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); |
|
|
|
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); |
|
|
|
|
|
|
|
|
|
|
|
featuresList->append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) ); |
|
|
|
featuresList.append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) ); |
|
|
|
currentElement = featuresList->at(0); |
|
|
|
currentElement = featuresList.at(0); |
|
|
|
|
|
|
|
|
|
|
|
appPath = rootPath + "/Applications"; |
|
|
|
appPath = rootPath + "/Applications"; |
|
|
|
audiosPath = rootPath + "/Audios"; |
|
|
|
audiosPath = rootPath + "/Audios"; |
|
|
@ -85,30 +85,30 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
favoritePath = rootPath + "/Favorites"; |
|
|
|
favoritePath = rootPath + "/Favorites"; |
|
|
|
|
|
|
|
|
|
|
|
audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath ); |
|
|
|
audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath ); |
|
|
|
featuresList->append( audiosElement ); |
|
|
|
featuresList.append( audiosElement ); |
|
|
|
moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath ); |
|
|
|
moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath ); |
|
|
|
featuresList->append( moviesElement ); |
|
|
|
featuresList.append( moviesElement ); |
|
|
|
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath ); |
|
|
|
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath ); |
|
|
|
featuresList->append( picturesElement ); |
|
|
|
featuresList.append( picturesElement ); |
|
|
|
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) ); |
|
|
|
featuresList.append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) ); |
|
|
|
flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath ); |
|
|
|
flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath ); |
|
|
|
featuresList->append( flashElement ); |
|
|
|
featuresList.append( flashElement ); |
|
|
|
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath ); |
|
|
|
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath ); |
|
|
|
featuresList->append( interactElement ); |
|
|
|
featuresList.append( interactElement ); |
|
|
|
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) ); |
|
|
|
featuresList.append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) ); |
|
|
|
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH ); |
|
|
|
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH ); |
|
|
|
featuresList->append( trashElement ); |
|
|
|
featuresList.append( trashElement ); |
|
|
|
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", "favorites", FEATURE_FAVORITE ); |
|
|
|
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", "favorites", FEATURE_FAVORITE ); |
|
|
|
featuresList->append( favoriteElement ); |
|
|
|
featuresList.append( favoriteElement ); |
|
|
|
|
|
|
|
|
|
|
|
loadFavoriteList(); |
|
|
|
loadFavoriteList(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (UBToolsManager::UBToolDescriptor tool, tools) |
|
|
|
foreach (UBToolsManager::UBToolDescriptor tool, tools) |
|
|
|
{ |
|
|
|
{ |
|
|
|
featuresList->append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); |
|
|
|
featuresList.append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); |
|
|
|
if ( favoriteSet->find( tool.id ) != favoriteSet->end() ) |
|
|
|
if ( favoriteSet.find( tool.id ) != favoriteSet.end() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); |
|
|
|
featuresList.append( UBFeature( favoritePath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
fileSystemScan( mUserInteractiveDirectoryPath, appPath ); |
|
|
|
fileSystemScan( mUserInteractiveDirectoryPath, appPath ); |
|
|
@ -163,10 +163,10 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt |
|
|
|
icon = QPixmap( thumbnailPath ); |
|
|
|
icon = QPixmap( thumbnailPath ); |
|
|
|
else icon = createThumbnail( fullFileName );*/ |
|
|
|
else icon = createThumbnail( fullFileName );*/ |
|
|
|
} |
|
|
|
} |
|
|
|
featuresList->append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) ); |
|
|
|
featuresList.append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) ); |
|
|
|
if ( favoriteSet->find( fullFileName ) != favoriteSet->end() ) |
|
|
|
if ( favoriteSet.find( fullFileName ) != favoriteSet.end() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
featuresList->append( UBFeature( favoritePath, icon, fileName, fullFileName, fileType ) ); |
|
|
|
featuresList.append( UBFeature( favoritePath, icon, fileName, fullFileName, fileType ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( fileType == FEATURE_FOLDER ) |
|
|
|
if ( fileType == FEATURE_FOLDER ) |
|
|
@ -179,7 +179,6 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::loadFavoriteList() |
|
|
|
void UBFeaturesController::loadFavoriteList() |
|
|
|
{ |
|
|
|
{ |
|
|
|
favoriteSet = new QSet<QString>(); |
|
|
|
|
|
|
|
QFile file( UBSettings::userDataDirectory() + "/favorites.dat" ); |
|
|
|
QFile file( UBSettings::userDataDirectory() + "/favorites.dat" ); |
|
|
|
if ( file.exists() ) |
|
|
|
if ( file.exists() ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -196,7 +195,7 @@ void UBFeaturesController::loadFavoriteList() |
|
|
|
|
|
|
|
|
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( path ), fileName, path, fileTypeFromUrl(path) ); |
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( path ), fileName, path, fileTypeFromUrl(path) ); |
|
|
|
featuresList->append( elem );*/ |
|
|
|
featuresList->append( elem );*/ |
|
|
|
favoriteSet->insert( path ); |
|
|
|
favoriteSet.insert( path ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -207,8 +206,8 @@ void UBFeaturesController::saveFavoriteList() |
|
|
|
file.resize(0); |
|
|
|
file.resize(0); |
|
|
|
file.open(QIODevice::WriteOnly); |
|
|
|
file.open(QIODevice::WriteOnly); |
|
|
|
QDataStream out(&file); |
|
|
|
QDataStream out(&file); |
|
|
|
out << favoriteSet->size(); |
|
|
|
out << favoriteSet.size(); |
|
|
|
for ( QSet<QString>::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it ) |
|
|
|
for ( QSet<QString>::iterator it = favoriteSet.begin(); it != favoriteSet.end(); ++it ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
out << (*it); |
|
|
|
out << (*it); |
|
|
|
} |
|
|
|
} |
|
|
@ -218,12 +217,12 @@ void UBFeaturesController::saveFavoriteList() |
|
|
|
UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) |
|
|
|
UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString filePath = fileNameFromUrl( path ); |
|
|
|
QString filePath = fileNameFromUrl( path ); |
|
|
|
if ( favoriteSet->find( filePath ) == favoriteSet->end() ) |
|
|
|
if ( favoriteSet.find( filePath ) == favoriteSet.end() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFileInfo fileInfo( filePath ); |
|
|
|
QFileInfo fileInfo( filePath ); |
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, filePath, fileTypeFromUrl(filePath) ); |
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, filePath, fileTypeFromUrl(filePath) ); |
|
|
|
favoriteSet->insert( filePath ); |
|
|
|
favoriteSet.insert( filePath ); |
|
|
|
saveFavoriteList(); |
|
|
|
saveFavoriteList(); |
|
|
|
return elem; |
|
|
|
return elem; |
|
|
|
} |
|
|
|
} |
|
|
@ -233,9 +232,9 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) |
|
|
|
void UBFeaturesController::removeFromFavorite( const QUrl &path ) |
|
|
|
void UBFeaturesController::removeFromFavorite( const QUrl &path ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString filePath = fileNameFromUrl( path ); |
|
|
|
QString filePath = fileNameFromUrl( path ); |
|
|
|
if ( favoriteSet->find( filePath ) != favoriteSet->end() ) |
|
|
|
if ( favoriteSet.find( filePath ) != favoriteSet.end() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
favoriteSet->erase( favoriteSet->find( filePath ) ); |
|
|
|
favoriteSet.erase( favoriteSet.find( filePath ) ); |
|
|
|
saveFavoriteList(); |
|
|
|
saveFavoriteList(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|