Implemented removing selected items from favorite

preferencesAboutTextFull
Anna Udovichenko 13 years ago
parent 0798539824
commit 4150279b9f
  1. 6
      src/gui/UBFeaturesActionBar.cpp
  2. 2
      src/gui/UBFeaturesActionBar.h
  3. 25
      src/gui/UBFeaturesWidget.cpp
  4. 3
      src/gui/UBFeaturesWidget.h

@ -77,6 +77,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder())); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));
connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite()));
// Build the default toolbar // Build the default toolbar
mLayout->addWidget(mpFavoriteBtn); mLayout->addWidget(mpFavoriteBtn);
@ -175,6 +176,11 @@ void UBFeaturesActionBar::onActionFavorite()
emit addElementsToFavorite(); emit addElementsToFavorite();
} }
void UBFeaturesActionBar::onActionRemoveFavorite()
{
emit removeElementsFromFavorite();
}
/* /*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{ {

@ -31,10 +31,12 @@ signals:
void addToFavorite( const QMimeData &data ); void addToFavorite( const QMimeData &data );
void removeFromFavorite( const QMimeData &data ); void removeFromFavorite( const QMimeData &data );
void addElementsToFavorite(); void addElementsToFavorite();
void removeElementsFromFavorite();
private slots: private slots:
void onSearchTextChanged(QString txt); void onSearchTextChanged(QString txt);
void onActionNewFolder(); void onActionNewFolder();
void onActionFavorite(); void onActionFavorite();
void onActionRemoveFavorite();
protected: protected:
//void dragMoveEvent(QDragMoveEvent *event); //void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent( QDragEnterEvent *event ); void dragEnterEvent( QDragEnterEvent *event );

@ -121,7 +121,8 @@ 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( 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 ) ) );
@ -348,6 +349,25 @@ void UBFeaturesWidget::addElementsToFavorite()
model->invalidate(); 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>();
items.append( feature.getFullPath() );
}
foreach ( QUrl url, items )
{
controller->removeFromFavorite( url );
featuresModel->deleteFavoriteItem( url.toString() );
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
stackedWidget->setCurrentIndex(ID_LISTVIEW); stackedWidget->setCurrentIndex(ID_LISTVIEW);
@ -854,7 +874,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() );
@ -889,6 +909,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);

@ -102,6 +102,7 @@ private slots:
void onDisplayMetadata( QMap<QString,QString> ); void onDisplayMetadata( QMap<QString,QString> );
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite(); void addElementsToFavorite();
void removeElementsFromFavorite();
protected: protected:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
}; };
@ -209,6 +210,8 @@ public:
bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent); bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent);
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
bool removeRow(int row, const QModelIndex &parent = QModelIndex()); bool removeRow(int row, const QModelIndex &parent = QModelIndex());
//bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
//bool insertRow(int row, const QModelIndex &parent = QModelIndex());
Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }

Loading…
Cancel
Save