|
|
|
@ -18,15 +18,24 @@ |
|
|
|
|
#include "domain/UBGraphicsVideoItem.h" |
|
|
|
|
#include "domain/UBGraphicsWidgetItem.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 QUrl &realPath, UBFeatureElementType type) |
|
|
|
|
: virtualPath(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString UBFeature::getUrl() const |
|
|
|
|
{ |
|
|
|
|
if ( elementType == FEATURE_INTERNAL ) |
|
|
|
|
return getFullPath().toString(); |
|
|
|
|
/*if ( UBApplication::isFromWeb( getFullPath() ) )
|
|
|
|
|
return QUrl( getFullPath() );*/ |
|
|
|
|
return getFullPath().toLocalFile(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool UBFeature::operator ==( const UBFeature &f )const |
|
|
|
|
{ |
|
|
|
|
return virtualPath == f.getUrl() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType(); |
|
|
|
|
return virtualPath == f.getVirtualPath() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool UBFeature::operator !=( const UBFeature &f )const |
|
|
|
@ -55,24 +64,24 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) : |
|
|
|
|
|
|
|
|
|
void UBFeaturesController::initDirectoryTree() |
|
|
|
|
{ |
|
|
|
|
mUserAudioDirectoryPath = UBSettings::settings()->userAudioDirectory(); |
|
|
|
|
mUserVideoDirectoryPath = UBSettings::settings()->userVideoDirectory(); |
|
|
|
|
mUserPicturesDirectoryPath = UBSettings::settings()->userImageDirectory(); |
|
|
|
|
mUserInteractiveDirectoryPath = UBSettings::settings()->userInteractiveDirectory(); |
|
|
|
|
mUserAnimationDirectoryPath = UBSettings::settings()->userAnimationDirectory(); |
|
|
|
|
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 = UBSettings::settings()->applicationImageLibraryDirectory(); |
|
|
|
|
mLibInteractiveDirectoryPath = UBSettings::settings()->applicationInteractivesDirectory(); |
|
|
|
|
mLibApplicationsDirectoryPath = UBSettings::settings()->applicationApplicationsLibraryDirectory(); |
|
|
|
|
mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; |
|
|
|
|
mLibSearchDirectoryPath = UBSettings::settings()->userSearchDirectory(); |
|
|
|
|
trashDirectoryPath = UBSettings::userTrashDirPath(); |
|
|
|
|
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() ); |
|
|
|
|
|
|
|
|
|
featuresList = new QList <UBFeature>(); |
|
|
|
|
|
|
|
|
|
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", QUrl() ) ); |
|
|
|
|
currentElement = featuresList->at(0); |
|
|
|
|
|
|
|
|
|
appPath = rootPath + "/Applications"; |
|
|
|
@ -99,7 +108,7 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
|
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", "favorites", FEATURE_FAVORITE ); |
|
|
|
|
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 ); |
|
|
|
@ -107,10 +116,10 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
|
|
|
|
|
|
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, QUrl( tool.id ), FEATURE_INTERNAL ) ); |
|
|
|
|
if ( favoriteSet->find( QUrl( tool.id ) ) != favoriteSet->end() ) |
|
|
|
|
{ |
|
|
|
|
featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); |
|
|
|
|
featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, QUrl( tool.id ), FEATURE_INTERNAL ) ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
fileSystemScan( mUserInteractiveDirectoryPath, appPath ); |
|
|
|
@ -129,9 +138,9 @@ void UBFeaturesController::initDirectoryTree() |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesController::fileSystemScan(const QString & currentPath, const QString & currVirtualPath) |
|
|
|
|
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath) |
|
|
|
|
{ |
|
|
|
|
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath); |
|
|
|
|
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); |
|
|
|
|
|
|
|
|
|
QFileInfoList::iterator fileInfo; |
|
|
|
|
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) |
|
|
|
@ -152,6 +161,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt |
|
|
|
|
QPixmap icon = QPixmap(":images/libpalette/soundIcon.svg"); |
|
|
|
|
QString fullFileName = fileInfo->filePath(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( fileType == FEATURE_FOLDER )
|
|
|
|
|
{ |
|
|
|
|
icon = QPixmap(":images/libpalette/folder.svg"); |
|
|
|
@ -171,15 +181,15 @@ 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, QUrl::fromLocalFile( fullFileName ), fileType ) ); |
|
|
|
|
if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) |
|
|
|
|
{ |
|
|
|
|
featuresList->append( UBFeature( favoritePath, icon, fileName, fullFileName, fileType ) ); |
|
|
|
|
featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( fileType == FEATURE_FOLDER ) |
|
|
|
|
{ |
|
|
|
|
fileSystemScan( fullFileName, currVirtualPath + "/" + fileName ); |
|
|
|
|
fileSystemScan( QUrl::fromLocalFile( fullFileName ), currVirtualPath + "/" + fileName ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -187,7 +197,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt |
|
|
|
|
|
|
|
|
|
void UBFeaturesController::loadFavoriteList() |
|
|
|
|
{ |
|
|
|
|
favoriteSet = new QSet<QString>(); |
|
|
|
|
favoriteSet = new QSet<QUrl>(); |
|
|
|
|
QFile file( UBSettings::userDataDirectory() + "/favorites.dat" ); |
|
|
|
|
if ( file.exists() ) |
|
|
|
|
{ |
|
|
|
@ -197,7 +207,7 @@ void UBFeaturesController::loadFavoriteList() |
|
|
|
|
in >> elementsNumber; |
|
|
|
|
for ( int i = 0; i < elementsNumber; ++i) |
|
|
|
|
{ |
|
|
|
|
QString path; |
|
|
|
|
QUrl path; |
|
|
|
|
in >> path; |
|
|
|
|
/*QFileInfo fileInfo( path );
|
|
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
@ -216,7 +226,7 @@ void UBFeaturesController::saveFavoriteList() |
|
|
|
|
file.open(QIODevice::WriteOnly); |
|
|
|
|
QDataStream out(&file); |
|
|
|
|
out << favoriteSet->size(); |
|
|
|
|
for ( QSet<QString>::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it ) |
|
|
|
|
for ( QSet<QUrl>::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it ) |
|
|
|
|
{ |
|
|
|
|
out << (*it); |
|
|
|
|
} |
|
|
|
@ -226,12 +236,12 @@ void UBFeaturesController::saveFavoriteList() |
|
|
|
|
UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) |
|
|
|
|
{ |
|
|
|
|
QString filePath = fileNameFromUrl( path ); |
|
|
|
|
if ( favoriteSet->find( filePath ) == favoriteSet->end() ) |
|
|
|
|
if ( favoriteSet->find( path ) == favoriteSet->end() ) |
|
|
|
|
{ |
|
|
|
|
QFileInfo fileInfo( filePath ); |
|
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, filePath, fileTypeFromUrl(filePath) ); |
|
|
|
|
favoriteSet->insert( filePath ); |
|
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, path, fileTypeFromUrl(filePath) ); |
|
|
|
|
favoriteSet->insert( path ); |
|
|
|
|
saveFavoriteList(); |
|
|
|
|
return elem; |
|
|
|
|
} |
|
|
|
@ -241,9 +251,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( path ) != favoriteSet->end() ) |
|
|
|
|
{ |
|
|
|
|
favoriteSet->erase( favoriteSet->find( filePath ) ); |
|
|
|
|
favoriteSet->erase( favoriteSet->find( path ) ); |
|
|
|
|
saveFavoriteList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -256,6 +266,7 @@ QString UBFeaturesController::fileNameFromUrl( const QUrl &url ) |
|
|
|
|
return url.toLocalFile(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path ) |
|
|
|
|
{ |
|
|
|
|
QFileInfo fileInfo( path ); |
|
|
|
@ -336,24 +347,26 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path) |
|
|
|
|
|
|
|
|
|
UBFeature UBFeaturesController::newFolder( const QString &name ) |
|
|
|
|
{ |
|
|
|
|
QString path = currentElement.getFullPath() + "/" + name; |
|
|
|
|
QString path = currentElement.getFullPath().toLocalFile() + "/" + name; |
|
|
|
|
if(!QFileInfo(path).exists()) |
|
|
|
|
{ |
|
|
|
|
QDir().mkpath(path); |
|
|
|
|
} |
|
|
|
|
return UBFeature( currentElement.getUrl() + "/" + currentElement.getName(), QPixmap(":images/libpalette/folder.svg"), name, path, FEATURE_FOLDER ); |
|
|
|
|
return UBFeature( currentElement.getFullVirtualPath(), QPixmap(":images/libpalette/folder.svg"),
|
|
|
|
|
name, QUrl::fromLocalFile( path ), FEATURE_FOLDER ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesController::addItemToPage(const UBFeature &item) |
|
|
|
|
{ |
|
|
|
|
if ( item.getType() == FEATURE_INTERNAL ) |
|
|
|
|
UBApplication::boardController->downloadURL( item.getFullPath() ); |
|
|
|
|
/*if ( item.getType() == FEATURE_INTERNAL )
|
|
|
|
|
{ |
|
|
|
|
UBApplication::boardController->downloadURL( QUrl( item.getFullPath() ) ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
UBApplication::boardController->downloadURL( QUrl::fromLocalFile( item.getFullPath() ) ); |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url ) |
|
|
|
@ -394,14 +407,14 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
|
UBFeature dest = destination; |
|
|
|
|
|
|
|
|
|
if ( destination != trashElement &&
|
|
|
|
|
!destination.getVirtualPath().startsWith( possibleDest.getVirtualPath(), Qt::CaseInsensitive ) ) |
|
|
|
|
!destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) ) |
|
|
|
|
{ |
|
|
|
|
dest = possibleDest; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString name = QFileInfo( sourcePath ).fileName(); |
|
|
|
|
QString destPath = dest.getFullPath(); |
|
|
|
|
QString destVirtualPath = dest.getVirtualPath(); |
|
|
|
|
QString destPath = dest.getFullPath().toLocalFile(); |
|
|
|
|
QString destVirtualPath = dest.getFullVirtualPath(); |
|
|
|
|
QString newFullPath = destPath + "/" + name; |
|
|
|
|
QFile( sourcePath ).copy( newFullPath ); |
|
|
|
|
|
|
|
|
@ -410,7 +423,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
|
UBFeatureElementType type = FEATURE_ITEM; |
|
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
|
|
|
|
|
type = FEATURE_INTERACTIVE; |
|
|
|
|
UBFeature newElement( destVirtualPath, thumb, name, newFullPath, type ); |
|
|
|
|
UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type ); |
|
|
|
|
return newElement; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -429,7 +442,7 @@ void UBFeaturesController::deleteItem( const QUrl &url ) |
|
|
|
|
|
|
|
|
|
bool UBFeaturesController::isTrash( const QUrl &url ) |
|
|
|
|
{ |
|
|
|
|
return url.toLocalFile().startsWith( trashDirectoryPath ); |
|
|
|
|
return url.toLocalFile().startsWith( trashDirectoryPath.toLocalFile() ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBFeaturesController::~UBFeaturesController() |
|
|
|
|