Fixed some DnD bugs

preferencesAboutTextFull
Anna Udovichenko 13 years ago
parent b5fd37a9dd
commit 604ea2faea
  1. 34
      src/board/UBFeaturesController.cpp
  2. 2
      src/gui/UBFeaturesWidget.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,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();
}

Loading…
Cancel
Save