diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp index a2678f36..5bd9f5b7 100644 --- a/src/board/UBFeaturesController.cpp +++ b/src/board/UBFeaturesController.cpp @@ -429,8 +429,39 @@ UBFeature UBFeaturesController::addDownloadedFile( const QUrl &sourceUrl, const UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination ) { - UBFeature newElement = copyItemToFolder( url, destination ); + /*UBFeature newElement = copyItemToFolder( url, destination ); deleteItem( url ); + return newElement;*/ + QString sourcePath = url.toLocalFile(); + + Q_ASSERT( QFileInfo( sourcePath ).exists() ); + + UBFeature possibleDest = getDestinationForItem( url ); + + UBFeature dest = destination; + + if ( destination != trashElement && + !destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) ) + { + dest = possibleDest; + } + + QString name = QFileInfo( sourcePath ).fileName(); + QString destPath = dest.getFullPath().toLocalFile(); + QString destVirtualPath = dest.getFullVirtualPath(); + QString newFullPath = destPath + "/" + name; + if ( sourcePath.compare( newFullPath, Qt::CaseInsensitive ) ) + { + QFile( sourcePath ).copy( newFullPath ); + deleteItem( url ); + } + + QPixmap thumb = thumbnailForFile( newFullPath ); + + UBFeatureElementType type = FEATURE_ITEM; + if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") ) + type = FEATURE_INTERACTIVE; + UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type ); return newElement; } @@ -454,7 +485,8 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu QString destPath = dest.getFullPath().toLocalFile(); QString destVirtualPath = dest.getFullVirtualPath(); QString newFullPath = destPath + "/" + name; - QFile( sourcePath ).copy( newFullPath ); + if ( !sourcePath.compare( newFullPath, Qt::CaseInsensitive ) ) + QFile( sourcePath ).copy( newFullPath ); QPixmap thumb = thumbnailForFile( newFullPath ); diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index b5e70b2b..ea0fcaa7 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -831,7 +831,7 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act void UBFeaturesModel::addItem( const UBFeature &item ) { beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() ); - featuresList->push_back( item ); + featuresList->append( item ); endInsertRows(); }