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