Commit 604ea2fa authored by Anna Udovichenko's avatar Anna Udovichenko

Fixed some DnD bugs

parent b5fd37a9
......@@ -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,6 +485,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
QString destPath = dest.getFullPath().toLocalFile();
QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name;
if ( !sourcePath.compare( newFullPath, Qt::CaseInsensitive ) )
QFile( sourcePath ).copy( newFullPath );
QPixmap thumb = thumbnailForFile( newFullPath );
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment