|
|
@ -18,8 +18,6 @@ |
|
|
|
#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 +65,15 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
mLibInteractiveDirectoryPath = UBSettings::settings()->applicationInteractivesDirectory(); |
|
|
|
mLibInteractiveDirectoryPath = UBSettings::settings()->applicationInteractivesDirectory(); |
|
|
|
mLibApplicationsDirectoryPath = UBSettings::settings()->applicationApplicationsLibraryDirectory(); |
|
|
|
mLibApplicationsDirectoryPath = UBSettings::settings()->applicationApplicationsLibraryDirectory(); |
|
|
|
mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; |
|
|
|
mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; |
|
|
|
|
|
|
|
mLibSearchDirectoryPath = UBSettings::settings()->userSearchDirectory(); |
|
|
|
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 +86,31 @@ 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 ); |
|
|
|
|
|
|
|
searchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath ); |
|
|
|
|
|
|
|
featuresList->append( searchElement ); |
|
|
|
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 ); |
|
|
@ -122,7 +124,7 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
fileSystemScan( mLibShapesDirectoryPath, shapesPath ); |
|
|
|
fileSystemScan( mLibShapesDirectoryPath, shapesPath ); |
|
|
|
fileSystemScan( mLibInteractiveDirectoryPath, interactPath ); |
|
|
|
fileSystemScan( mLibInteractiveDirectoryPath, interactPath ); |
|
|
|
fileSystemScan( trashDirectoryPath, trashPath ); |
|
|
|
fileSystemScan( trashDirectoryPath, trashPath ); |
|
|
|
|
|
|
|
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -137,7 +139,13 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt |
|
|
|
UBFeatureElementType fileType = fileInfo->isDir() ? FEATURE_FOLDER : FEATURE_ITEM; |
|
|
|
UBFeatureElementType fileType = fileInfo->isDir() ? FEATURE_FOLDER : FEATURE_ITEM; |
|
|
|
|
|
|
|
|
|
|
|
QString fileName = fileInfo->fileName(); |
|
|
|
QString fileName = fileInfo->fileName(); |
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application") ) { |
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application") )
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application/search") ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fileType = FEATURE_SEARCH; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
fileType = FEATURE_INTERACTIVE; |
|
|
|
fileType = FEATURE_INTERACTIVE; |
|
|
|
} |
|
|
|
} |
|
|
|
QString itemName = (fileType != FEATURE_ITEM) ? fileName : fileInfo->completeBaseName(); |
|
|
|
QString itemName = (fileType != FEATURE_ITEM) ? fileName : fileInfo->completeBaseName(); |
|
|
@ -163,10 +171,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,6 +187,7 @@ 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() ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -195,7 +204,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 ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -206,8 +215,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); |
|
|
|
} |
|
|
|
} |
|
|
@ -217,12 +226,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; |
|
|
|
} |
|
|
|
} |
|
|
@ -232,9 +241,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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|