|
|
@ -404,13 +404,19 @@ void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event ) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) |
|
|
|
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( event->mimeData()->hasUrls() ) |
|
|
|
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) |
|
|
|
|
|
|
|
event->acceptProposedAction(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) |
|
|
|
event->acceptProposedAction(); |
|
|
|
event->acceptProposedAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesListView::dropEvent( QDropEvent *event ) |
|
|
|
void UBFeaturesListView::dropEvent( QDropEvent *event ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( event->source() || dynamic_cast<UBFeaturesListView *>( event->source() ) ) |
|
|
|
if( event->source() && dynamic_cast<UBFeaturesListView *>( event->source() ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
event->setDropAction( Qt::MoveAction ); |
|
|
|
event->setDropAction( Qt::MoveAction ); |
|
|
|
} |
|
|
|
} |
|
|
@ -775,7 +781,7 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(row) |
|
|
|
Q_UNUSED(row) |
|
|
|
|
|
|
|
|
|
|
|
if ( !mimeData->hasUrls() ) |
|
|
|
if ( !mimeData->hasUrls() && !mimeData->hasImage() ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if ( action == Qt::IgnoreAction ) |
|
|
|
if ( action == Qt::IgnoreAction ) |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -794,6 +800,8 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( mimeData->hasUrls() ) |
|
|
|
|
|
|
|
{ |
|
|
|
QList<QUrl> urls = mimeData->urls(); |
|
|
|
QList<QUrl> urls = mimeData->urls(); |
|
|
|
|
|
|
|
|
|
|
|
foreach ( QUrl url, urls ) |
|
|
|
foreach ( QUrl url, urls ) |
|
|
@ -810,6 +818,13 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
} |
|
|
|
} |
|
|
|
addItem( element ); |
|
|
|
addItem( element ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if ( mimeData->hasImage() ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QImage image = qvariant_cast<QImage>( mimeData->imageData() ); |
|
|
|
|
|
|
|
UBFeature element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->importImage( image, parentFeature ); |
|
|
|
|
|
|
|
addItem( element ); |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -897,7 +912,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
QStringList UBFeaturesModel::mimeTypes() const |
|
|
|
QStringList UBFeaturesModel::mimeTypes() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList types; |
|
|
|
QStringList types; |
|
|
|
types << "text/uri-list"; |
|
|
|
types << "text/uri-list" << "image/png" << "image/tiff" << "image/gif" << "image/jpeg"; |
|
|
|
return types; |
|
|
|
return types; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|