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