Implemented removing selected items

preferencesAboutTextFull
Anna Udovichenko 13 years ago
parent 59221084e8
commit b484dae47f
  1. 12
      src/gui/UBFeaturesActionBar.cpp
  2. 2
      src/gui/UBFeaturesActionBar.h
  3. 43
      src/gui/UBFeaturesWidget.cpp
  4. 2
      src/gui/UBFeaturesWidget.h

@ -66,8 +66,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mButtonGroup->addButton(mpRemoveFavoriteBtn);
mButtonGroup->addButton(mpNewFolderBtn);
// Connect signals & slots
connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
/*connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
/*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose()));
@ -78,6 +78,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));
connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
// Build the default toolbar
mLayout->addWidget(mpFavoriteBtn);
@ -149,6 +150,8 @@ void UBFeaturesActionBar::setButtons()
mpFavoriteBtn->hide();
mpSocialBtn->hide();
mSearchBar->show();
mpDeleteBtn->show();
mpDeleteBtn->setEnabled(true);
//mpSearchBtn->show();
//mpDeleteBtn->hide();
mpCloseBtn->hide();
@ -181,6 +184,11 @@ void UBFeaturesActionBar::onActionRemoveFavorite()
emit removeElementsFromFavorite();
}
void UBFeaturesActionBar::onActionTrash()
{
emit deleteSelectedElements();
}
/*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{

@ -32,11 +32,13 @@ signals:
void removeFromFavorite( const QMimeData &data );
void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
private slots:
void onSearchTextChanged(QString txt);
void onActionNewFolder();
void onActionFavorite();
void onActionRemoveFavorite();
void onActionTrash();
protected:
//void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent( QDragEnterEvent *event );

@ -123,6 +123,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) );
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 ) ) );
@ -278,6 +279,36 @@ 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>();
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() )
@ -902,6 +933,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 )

@ -103,6 +103,7 @@ private slots:
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
protected:
bool eventFilter(QObject *target, QEvent *event);
};
@ -200,6 +201,7 @@ public:
void addItem( const UBFeature &item );
void deleteFavoriteItem( const QString &path );
void deleteItem( const QString &path );
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
QMimeData *mimeData( const QModelIndexList &indexes ) const;

Loading…
Cancel
Save