|
|
|
@ -121,6 +121,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale |
|
|
|
|
connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) );
|
|
|
|
|
connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) ); |
|
|
|
|
connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); |
|
|
|
|
connect ( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) );
|
|
|
|
|
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), |
|
|
|
|
this, SLOT( currentPathChanged( const QModelIndex & ) ) ); |
|
|
|
|
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); |
|
|
|
@ -333,6 +334,20 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesWidget::addElementsToFavorite() |
|
|
|
|
{ |
|
|
|
|
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); |
|
|
|
|
for ( int i = 0; i < selected.size(); ++i ) |
|
|
|
|
{ |
|
|
|
|
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>(); |
|
|
|
|
UBFeature elem = controller->addToFavorite( feature.getFullPath() ); |
|
|
|
|
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() ) |
|
|
|
|
featuresModel->addItem( elem ); |
|
|
|
|
} |
|
|
|
|
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); |
|
|
|
|
model->invalidate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesWidget::switchToListView() |
|
|
|
|
{ |
|
|
|
|
stackedWidget->setCurrentIndex(ID_LISTVIEW); |
|
|
|
@ -404,13 +419,19 @@ void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 ); |
|
|
|
|
} |
|
|
|
@ -775,7 +796,7 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
|
{ |
|
|
|
|
Q_UNUSED(row) |
|
|
|
|
|
|
|
|
|
if ( !mimeData->hasUrls() ) |
|
|
|
|
if ( !mimeData->hasUrls() && !mimeData->hasImage() ) |
|
|
|
|
return false; |
|
|
|
|
if ( action == Qt::IgnoreAction ) |
|
|
|
|
return true; |
|
|
|
@ -794,6 +815,8 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
|
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( mimeData->hasUrls() ) |
|
|
|
|
{ |
|
|
|
|
QList<QUrl> urls = mimeData->urls(); |
|
|
|
|
|
|
|
|
|
foreach ( QUrl url, urls ) |
|
|
|
@ -810,13 +833,20 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::addItem( const UBFeature &item ) |
|
|
|
|
{ |
|
|
|
|
beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() ); |
|
|
|
|
featuresList->push_back( item ); |
|
|
|
|
featuresList->append( item ); |
|
|
|
|
endInsertRows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -897,7 +927,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
|
QStringList UBFeaturesModel::mimeTypes() const |
|
|
|
|
{ |
|
|
|
|
QStringList types; |
|
|
|
|
types << "text/uri-list"; |
|
|
|
|
types << "text/uri-list" << "image/png" << "image/tiff" << "image/gif" << "image/jpeg"; |
|
|
|
|
return types; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|