diff options
-rw-r--r-- | playerwidget.cpp | 14 | ||||
-rw-r--r-- | playerwidget.h | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp index 2c28d13..ad3d060 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -89,6 +89,7 @@ void PlayerWidget::setupGui(){ mPlayListView = new BeetView; mPlayListView->setModel(mPlayListModel); mPlayListView->setRootIsDecorated(false); + mPlayListView->setSelectionMode(QAbstractItemView::ExtendedSelection); QGroupBox *playListGB = new QGroupBox(tr("Playlist")); QVBoxLayout *playListL = new QVBoxLayout; playListL->addWidget(mPlayListView); @@ -118,12 +119,12 @@ void PlayerWidget::createActions(){ QAction *addToPlayListA = new QAction(QIcon(":/belly_right.png"), tr("Add to playlist"), this); connect(addToPlayListA, SIGNAL(triggered()), this, SLOT(addToPlayList())); QAction *removeFromPlayListA = new QAction(QIcon(":/belly_left.png"), tr("Remove from playlist"), this); + connect(removeFromPlayListA, SIGNAL(triggered()), this, SLOT(removeFromPlayList())); QAction *clearPlayListA = new QAction(QIcon(":/delete.png"), tr("Clear Playlist"), this); QAction *refreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh..."), this); connect(refreshA, SIGNAL(triggered()), this, SLOT(reindex())); QAction *configA = Globals::instance()->action(Globals::ConfigAction); mView->addAction(addToPlayListA); - mView->addAction(removeFromPlayListA); mPlayListView->addAction(removeFromPlayListA); mPlayListView->addAction(clearPlayListA); QWidget* spacer1 = new QWidget(); @@ -339,3 +340,14 @@ void PlayerWidget::addToPlayList(){ } } } + +void PlayerWidget::removeFromPlayList(){ + QModelIndexList sel = mPlayListView->selectionModel()->selectedRows(); + QList<QPersistentModelIndex> persistent; + foreach(QModelIndex i, sel){ + persistent << QPersistentModelIndex(i); + } + foreach(QPersistentModelIndex i, persistent){ + mPlayListModel->removeRow(i.row()); + } +} diff --git a/playerwidget.h b/playerwidget.h index a6b9373..c16878e 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -27,6 +27,7 @@ class PlayerWidget : public QWidget { void clearFilter(); void reindex(); void addToPlayList(); + void removeFromPlayList(); private: void setupGui(); |