|
|
|
@ -121,7 +121,9 @@ 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( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); |
|
|
|
|
connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) ); |
|
|
|
|
connect( mActionBar, SIGNAL( deleteSelectedElements() ), this, SLOT( deleteSelectedElements() ) ); |
|
|
|
|
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), |
|
|
|
|
this, SLOT( currentPathChanged( const QModelIndex & ) ) ); |
|
|
|
|
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); |
|
|
|
@ -277,6 +279,37 @@ void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) |
|
|
|
|
model->invalidate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesWidget::deleteSelectedElements() |
|
|
|
|
{ |
|
|
|
|
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); |
|
|
|
|
QList <QUrl> urls; |
|
|
|
|
foreach ( QModelIndex sel, selected ) |
|
|
|
|
{ |
|
|
|
|
UBFeature feature = sel.data( Qt::UserRole + 1 ).value<UBFeature>(); |
|
|
|
|
if ( feature.isDeletable() ) |
|
|
|
|
urls.append( feature.getFullPath() ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach (QUrl url, urls) |
|
|
|
|
{ |
|
|
|
|
if ( controller->isTrash( url ) ) |
|
|
|
|
{ |
|
|
|
|
controller->deleteItem( url ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() ); |
|
|
|
|
controller->removeFromFavorite( url ); |
|
|
|
|
featuresModel->addItem( elem ); |
|
|
|
|
featuresModel->deleteFavoriteItem( url.toString() ); |
|
|
|
|
} |
|
|
|
|
featuresModel->deleteItem( url.toString() ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); |
|
|
|
|
model->invalidate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData ) |
|
|
|
|
{ |
|
|
|
|
if ( !mimeData.hasUrls() ) |
|
|
|
@ -335,14 +368,45 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesWidget::addElementsToFavorite() |
|
|
|
|
{ |
|
|
|
|
if ( currentStackedWidget == ID_PROPERTIES ) |
|
|
|
|
{ |
|
|
|
|
UBFeature feature = featureProperties->getCurrentElement(); |
|
|
|
|
if ( feature != UBFeature() && !UBApplication::isFromWeb( feature.getFullPath().toString() ) ) |
|
|
|
|
{ |
|
|
|
|
UBFeature elem = controller->addToFavorite( feature.getFullPath() ); |
|
|
|
|
featuresModel->addItem( elem ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if ( currentStackedWidget == ID_LISTVIEW ) |
|
|
|
|
{ |
|
|
|
|
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::removeElementsFromFavorite() |
|
|
|
|
{ |
|
|
|
|
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); |
|
|
|
|
//qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
|
|
|
|
|
QList <QUrl> items; |
|
|
|
|
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 ); |
|
|
|
|
items.append( feature.getFullPath() ); |
|
|
|
|
} |
|
|
|
|
foreach ( QUrl url, items ) |
|
|
|
|
{ |
|
|
|
|
controller->removeFromFavorite( url ); |
|
|
|
|
featuresModel->deleteFavoriteItem( url.toString() ); |
|
|
|
|
} |
|
|
|
|
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); |
|
|
|
|
model->invalidate(); |
|
|
|
@ -609,6 +673,13 @@ void UBFeatureProperties::showEvent (QShowEvent *event ) |
|
|
|
|
adaptSize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBFeature UBFeatureProperties::getCurrentElement() const |
|
|
|
|
{ |
|
|
|
|
if ( mpElement ) |
|
|
|
|
return *mpElement; |
|
|
|
|
return UBFeature(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeatureProperties::adaptSize() |
|
|
|
|
{ |
|
|
|
|
if( NULL != mpOrigPixmap ) |
|
|
|
@ -854,7 +925,7 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) |
|
|
|
|
{ |
|
|
|
|
for ( int i = 0; i < featuresList->size(); ++i ) |
|
|
|
|
{ |
|
|
|
|
if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) && |
|
|
|
|
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) && |
|
|
|
|
!QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) ) |
|
|
|
|
{ |
|
|
|
|
removeRow( i, QModelIndex() ); |
|
|
|
@ -863,6 +934,18 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::deleteItem( const QString &path ) |
|
|
|
|
{ |
|
|
|
|
for ( int i = 0; i < featuresList->size(); ++i ) |
|
|
|
|
{ |
|
|
|
|
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) ) |
|
|
|
|
{ |
|
|
|
|
removeRow( i, QModelIndex() ); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent ) |
|
|
|
|
{ |
|
|
|
|
if ( row < 0 ) |
|
|
|
@ -889,6 +972,7 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent ) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
|
{ |
|
|
|
|
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); |
|
|
|
|