|
|
@ -99,6 +99,9 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) : |
|
|
|
mUserAnimationDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAnimationDirectory()); |
|
|
|
mUserAnimationDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAnimationDirectory()); |
|
|
|
|
|
|
|
|
|
|
|
mLibPicturesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationImageLibraryDirectory()); |
|
|
|
mLibPicturesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationImageLibraryDirectory()); |
|
|
|
|
|
|
|
mLibAudiosDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationAudiosLibraryDirectory()); |
|
|
|
|
|
|
|
mLibVideosDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationVideosLibraryDirectory()); |
|
|
|
|
|
|
|
mLibAnimationsDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationAnimationsLibraryDirectory()); |
|
|
|
mLibInteractiveDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationInteractivesDirectory()); |
|
|
|
mLibInteractiveDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationInteractivesDirectory()); |
|
|
|
mLibApplicationsDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationApplicationsLibraryDirectory()); |
|
|
|
mLibApplicationsDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationApplicationsLibraryDirectory()); |
|
|
|
mLibShapesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationShapeLibraryDirectory()); |
|
|
|
mLibShapesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationShapeLibraryDirectory()); |
|
|
@ -162,15 +165,12 @@ void UBFeaturesController::scanFS() |
|
|
|
|
|
|
|
|
|
|
|
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); |
|
|
|
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (UBToolsManager::UBToolDescriptor tool, tools) |
|
|
|
foreach (UBToolsManager::UBToolDescriptor tool, tools) { |
|
|
|
{ |
|
|
|
|
|
|
|
featuresList->append(UBFeature(appPath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL)); |
|
|
|
featuresList->append(UBFeature(appPath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL)); |
|
|
|
if ( favoriteSet->find( QUrl( tool.id ) ) != favoriteSet->end() ) |
|
|
|
if (favoriteSet->find(QUrl(tool.id)) != favoriteSet->end()) { |
|
|
|
{ |
|
|
|
|
|
|
|
featuresList->append(UBFeature(favoritePath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL)); |
|
|
|
featuresList->append(UBFeature(favoritePath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Claudio:
|
|
|
|
//Claudio:
|
|
|
|
// don't change the order of the scans
|
|
|
|
// don't change the order of the scans
|
|
|
|
fileSystemScan( mLibAudiosDirectoryPath, audiosPath); |
|
|
|
fileSystemScan( mLibAudiosDirectoryPath, audiosPath); |
|
|
@ -189,7 +189,6 @@ void UBFeaturesController::scanFS() |
|
|
|
fileSystemScan( mLibInteractiveDirectoryPath, interactPath ); |
|
|
|
fileSystemScan( mLibInteractiveDirectoryPath, interactPath ); |
|
|
|
fileSystemScan( trashDirectoryPath, trashPath ); |
|
|
|
fileSystemScan( trashDirectoryPath, trashPath ); |
|
|
|
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" ); |
|
|
|
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" ); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath) |
|
|
|
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath) |
|
|
@ -197,62 +196,27 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin |
|
|
|
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); |
|
|
|
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); |
|
|
|
|
|
|
|
|
|
|
|
QFileInfoList::iterator fileInfo; |
|
|
|
QFileInfoList::iterator fileInfo; |
|
|
|
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) |
|
|
|
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) { |
|
|
|
{ |
|
|
|
QString fullFileName = fileInfo->absoluteFilePath(); |
|
|
|
UBFeatureElementType fileType = fileInfo->isDir() ? FEATURE_FOLDER : FEATURE_ITEM; |
|
|
|
UBFeatureElementType featureType = fileTypeFromUrl(fullFileName); |
|
|
|
|
|
|
|
|
|
|
|
QString fileName = fileInfo->fileName(); |
|
|
|
QString fileName = fileInfo->fileName(); |
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application") )
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application/search") ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fileType = FEATURE_SEARCH; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
fileType = FEATURE_INTERACTIVE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
QString itemName = (fileType != FEATURE_ITEM) ? fileName : fileInfo->completeBaseName(); |
|
|
|
|
|
|
|
QPixmap icon = QPixmap(":images/libpalette/soundIcon.svg"); |
|
|
|
|
|
|
|
QString fullFileName = fileInfo->filePath(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap icon(getIcon(fullFileName, featureType)); |
|
|
|
|
|
|
|
|
|
|
|
if ( fileType == FEATURE_FOLDER )
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
icon = QPixmap(":images/libpalette/folder.svg"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if ( fileType == FEATURE_INTERACTIVE ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
icon = QPixmap( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(fullFileName) ) ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( fullFileName.contains(".thumbnail.")) |
|
|
|
if ( fullFileName.contains(".thumbnail.")) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
icon = thumbnailForFile( fullFileName ); |
|
|
|
|
|
|
|
/*QString thumbnailPath = UBFileSystemUtils::thumbnailPath( fullFileName );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (QFileInfo( thumbnailPath).exists() ) |
|
|
|
|
|
|
|
icon = QPixmap( thumbnailPath ); |
|
|
|
|
|
|
|
else icon = createThumbnail( fullFileName );*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), fileType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (featuresList->contains(testFeature)) { |
|
|
|
UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType); |
|
|
|
qDebug() << "the same feature found"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
featuresList->append(testFeature); |
|
|
|
featuresList->append(testFeature); |
|
|
|
if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) |
|
|
|
|
|
|
|
{ |
|
|
|
if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) { |
|
|
|
featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) ); |
|
|
|
featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), featureType ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( fileType == FEATURE_FOLDER ) |
|
|
|
if (featureType == FEATURE_FOLDER) { |
|
|
|
{ |
|
|
|
|
|
|
|
fileSystemScan(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName); |
|
|
|
fileSystemScan(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -296,7 +260,7 @@ void UBFeaturesController::addToFavorite( const QUrl &path ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFileInfo fileInfo( filePath ); |
|
|
|
QFileInfo fileInfo( filePath ); |
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, path, fileTypeFromUrl(filePath) ); |
|
|
|
UBFeature elem( favoritePath, getIcon( filePath, FEATURE_CATEGORY ), fileName, path, fileTypeFromUrl(filePath) ); |
|
|
|
favoriteSet->insert( path ); |
|
|
|
favoriteSet->insert( path ); |
|
|
|
saveFavoriteList(); |
|
|
|
saveFavoriteList(); |
|
|
|
|
|
|
|
|
|
|
@ -331,22 +295,41 @@ QString UBFeaturesController::fileNameFromUrl( const QUrl &url ) |
|
|
|
UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path ) |
|
|
|
UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFileInfo fileInfo(path); |
|
|
|
QFileInfo fileInfo(path); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fileInfo.exists()) { |
|
|
|
|
|
|
|
return FEATURE_INVALID; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
QString fileName = fileInfo.fileName(); |
|
|
|
|
|
|
|
QString mimeString = UBFileSystemUtils::mimeTypeFromFileName(fileName); |
|
|
|
|
|
|
|
|
|
|
|
UBFeatureElementType fileType = fileInfo.isDir() ? FEATURE_FOLDER : FEATURE_ITEM; |
|
|
|
UBFeatureElementType fileType = fileInfo.isDir() ? FEATURE_FOLDER : FEATURE_ITEM; |
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application") )
|
|
|
|
|
|
|
|
{ |
|
|
|
if ( mimeString.contains("application")) { |
|
|
|
|
|
|
|
if (mimeString.contains("application/search")) { |
|
|
|
|
|
|
|
fileType = FEATURE_SEARCH; |
|
|
|
|
|
|
|
} else { |
|
|
|
fileType = FEATURE_INTERACTIVE; |
|
|
|
fileType = FEATURE_INTERACTIVE; |
|
|
|
} |
|
|
|
} |
|
|
|
else if ( path.contains("uniboardTool://") ) |
|
|
|
} else if ( path.contains("uniboardTool://")) { |
|
|
|
{ |
|
|
|
|
|
|
|
fileType = FEATURE_INTERNAL; |
|
|
|
fileType = FEATURE_INTERNAL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return fileType; |
|
|
|
return fileType; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QPixmap UBFeaturesController::thumbnailForFile(const QString &path) |
|
|
|
QPixmap UBFeaturesController::getIcon(const QString &path, UBFeatureElementType pFType = FEATURE_INVALID) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( pFType == FEATURE_FOLDER ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
return QPixmap(":images/libpalette/folder.svg"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if ( pFType == FEATURE_INTERACTIVE ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return QPixmap( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( path.contains("uniboardTool://") ) |
|
|
|
if ( path.contains("uniboardTool://") ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return QPixmap( UBToolsManager::manager()->iconFromToolId(path) ); |
|
|
|
return QPixmap( UBToolsManager::manager()->iconFromToolId(path) ); |
|
|
@ -406,10 +389,18 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path) |
|
|
|
return QPixmap(thumbnailPath); |
|
|
|
return QPixmap(thumbnailPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeature UBFeaturesController::importImage( const QImage &image, const UBFeature &destination ) |
|
|
|
void UBFeaturesController::importImage(const QImage &image, const QString &fileName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
importImage(image, currentElement, fileName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::importImage( const QImage &image, const UBFeature &destination, const QString &fileName ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QString mFileName = fileName; |
|
|
|
|
|
|
|
if (mFileName.isNull()) { |
|
|
|
QDateTime now = QDateTime::currentDateTime(); |
|
|
|
QDateTime now = QDateTime::currentDateTime(); |
|
|
|
QString fileName = tr("ImportedImage") + "-" + now.toString("dd-MM-yyyy hh-mm-ss") + ".png"; |
|
|
|
mFileName = tr("ImportedImage") + "-" + now.toString("dd-MM-yyyy hh-mm-ss") + ".png"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeature dest = destination; |
|
|
|
UBFeature dest = destination; |
|
|
|
|
|
|
|
|
|
|
@ -418,19 +409,26 @@ UBFeature UBFeaturesController::importImage( const QImage &image, const UBFeatur |
|
|
|
dest = picturesElement; |
|
|
|
dest = picturesElement; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString filePath = dest.getFullPath().toLocalFile() + "/" + fileName; |
|
|
|
QString filePath = dest.getFullPath().toLocalFile() + "/" + mFileName; |
|
|
|
image.save(filePath); |
|
|
|
image.save(filePath); |
|
|
|
|
|
|
|
|
|
|
|
QPixmap thumb = createThumbnail( filePath ); |
|
|
|
QPixmap thumb = createThumbnail( filePath ); |
|
|
|
return UBFeature( dest.getFullVirtualPath(), thumb, fileName,
|
|
|
|
UBFeature resultItem = UBFeature( dest.getFullVirtualPath(), thumb, mFileName, |
|
|
|
QUrl::fromLocalFile( filePath ), FEATURE_ITEM ); |
|
|
|
QUrl::fromLocalFile( filePath ), FEATURE_ITEM ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
featuresModel->addItem(resultItem); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::addNewFolder(const QString &name) |
|
|
|
void UBFeaturesController::addNewFolder(const QString &name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString path = currentElement.getFullPath().toLocalFile() + "/" + name; |
|
|
|
QString path = currentElement.getFullPath().toLocalFile() + "/" + name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("/root" == currentElement.getFullVirtualPath()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!QFileInfo(path).exists()) { |
|
|
|
if(!QFileInfo(path).exists()) { |
|
|
|
QDir().mkpath(path); |
|
|
|
QDir().mkpath(path); |
|
|
|
} |
|
|
|
} |
|
|
@ -451,7 +449,7 @@ void UBFeaturesController::addItemAsBackground(const UBFeature &item) |
|
|
|
UBApplication::boardController->downloadURL( item.getFullPath(), QPointF(), QSize(), true ); |
|
|
|
UBApplication::boardController->downloadURL( item.getFullPath(), QPointF(), QSize(), true ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeature UBFeaturesController::getParentFeatureForUrl( const QUrl &url ) |
|
|
|
UBFeature UBFeaturesController::getDestinationFeatureForUrl( const QUrl &url ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName( url.toString() ); |
|
|
|
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName( url.toString() ); |
|
|
|
|
|
|
|
|
|
|
@ -473,7 +471,7 @@ UBFeature UBFeaturesController::getParentFeatureForUrl( const QUrl &url ) |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteArray &pData) |
|
|
|
void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteArray &pData) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBFeature dest = getParentFeatureForUrl( sourceUrl ); |
|
|
|
UBFeature dest = getDestinationFeatureForUrl( sourceUrl ); |
|
|
|
|
|
|
|
|
|
|
|
if ( dest == UBFeature() ) |
|
|
|
if ( dest == UBFeature() ) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -487,7 +485,7 @@ void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteA |
|
|
|
file.write(pData); |
|
|
|
file.write(pData); |
|
|
|
file.close(); |
|
|
|
file.close(); |
|
|
|
|
|
|
|
|
|
|
|
UBFeature downloadedFeature = UBFeature( dest.getFullVirtualPath(), thumbnailForFile( filePath ), |
|
|
|
UBFeature downloadedFeature = UBFeature( dest.getFullVirtualPath(), getIcon( filePath ), |
|
|
|
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM); |
|
|
|
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM); |
|
|
|
if (downloadedFeature != UBFeature()) { |
|
|
|
if (downloadedFeature != UBFeature()) { |
|
|
|
featuresModel->addItem(downloadedFeature); |
|
|
|
featuresModel->addItem(downloadedFeature); |
|
|
@ -505,7 +503,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
|
|
|
|
|
|
|
|
Q_ASSERT( QFileInfo( sourcePath ).exists() ); |
|
|
|
Q_ASSERT( QFileInfo( sourcePath ).exists() ); |
|
|
|
|
|
|
|
|
|
|
|
UBFeature possibleDest = getParentFeatureForUrl( url ); |
|
|
|
UBFeature possibleDest = getDestinationFeatureForUrl( url ); |
|
|
|
|
|
|
|
|
|
|
|
UBFeature dest = destination; |
|
|
|
UBFeature dest = destination; |
|
|
|
|
|
|
|
|
|
|
@ -525,7 +523,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
deleteItem( url ); |
|
|
|
deleteItem( url ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QPixmap thumb = thumbnailForFile( newFullPath ); |
|
|
|
QPixmap thumb = getIcon( newFullPath ); |
|
|
|
|
|
|
|
|
|
|
|
UBFeatureElementType type = FEATURE_ITEM; |
|
|
|
UBFeatureElementType type = FEATURE_ITEM; |
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
|
|
|
|
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
|
|
|
@ -584,7 +582,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
|
|
|
|
|
|
|
|
Q_ASSERT( QFileInfo( sourcePath ).exists() ); |
|
|
|
Q_ASSERT( QFileInfo( sourcePath ).exists() ); |
|
|
|
|
|
|
|
|
|
|
|
UBFeature possibleDest = getParentFeatureForUrl( url ); |
|
|
|
UBFeature possibleDest = getDestinationFeatureForUrl( url ); |
|
|
|
|
|
|
|
|
|
|
|
UBFeature dest = destination; |
|
|
|
UBFeature dest = destination; |
|
|
|
|
|
|
|
|
|
|
@ -601,7 +599,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
if (!sourcePath.compare(newFullPath, Qt::CaseInsensitive)) |
|
|
|
if (!sourcePath.compare(newFullPath, Qt::CaseInsensitive)) |
|
|
|
QFile(sourcePath).copy(newFullPath); |
|
|
|
QFile(sourcePath).copy(newFullPath); |
|
|
|
|
|
|
|
|
|
|
|
QPixmap thumb = thumbnailForFile( newFullPath ); |
|
|
|
QPixmap thumb = getIcon(newFullPath); |
|
|
|
|
|
|
|
|
|
|
|
UBFeatureElementType type = FEATURE_ITEM; |
|
|
|
UBFeatureElementType type = FEATURE_ITEM; |
|
|
|
if (UBFileSystemUtils::mimeTypeFromFileName(newFullPath).contains("application")) |
|
|
|
if (UBFileSystemUtils::mimeTypeFromFileName(newFullPath).contains("application")) |
|
|
@ -610,6 +608,45 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu |
|
|
|
return newElement; |
|
|
|
return newElement; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::moveExternalData(const QUrl &url, const UBFeature &destination) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString sourcePath = url.toLocalFile(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_ASSERT( QFileInfo( sourcePath ).exists() ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeature possibleDest = getDestinationFeatureForUrl(url); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeature dest = destination; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( destination != trashElement && |
|
|
|
|
|
|
|
!destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dest = possibleDest; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeatureElementType type = fileTypeFromUrl(sourcePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == FEATURE_FOLDER) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString name = QFileInfo(sourcePath).fileName(); |
|
|
|
|
|
|
|
QString destPath = dest.getFullPath().toLocalFile(); |
|
|
|
|
|
|
|
QString destVirtualPath = dest.getFullVirtualPath(); |
|
|
|
|
|
|
|
QString newFullPath = destPath + "/" + name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sourcePath.compare(newFullPath, Qt::CaseInsensitive) || !UBFileSystemUtils::copy(sourcePath, newFullPath)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(QFileInfo(newFullPath).exists()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap thumb = getIcon(newFullPath, type); |
|
|
|
|
|
|
|
UBFeature newElement(destVirtualPath, thumb, name, QUrl::fromLocalFile(newFullPath), type); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
featuresModel->addItem(newElement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesController::deleteItem(const QUrl &url) |
|
|
|
void UBFeaturesController::deleteItem(const QUrl &url) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString path = url.toLocalFile(); |
|
|
|
QString path = url.toLocalFile(); |
|
|
|