Implement removing of items in the Playlist

This commit is contained in:
Thomas Frauendorfer 2007-10-17 14:11:45 +02:00
parent eef3e53bd9
commit 0cf6c18de4
5 changed files with 44 additions and 3 deletions

View file

@ -359,12 +359,16 @@ PlaylistWidget::addButtons (void)
Skin::PLS_MSC_BTN_1);
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_ALL_0,
Skin::PLS_DEL_ALL_1);
connect (b, SIGNAL(activated ()),
connect (b, SIGNAL (activated ()),
&XMMSHandler::getInstance(), SLOT (playlistClear ()));
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_CRP_0,
Skin::PLS_DEL_CRP_1);
connect (b, SIGNAL (activated ()),
m_view, SLOT (cropSelected ()));
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_FIL_0,
Skin::PLS_DEL_FIL_1);
connect (b, SIGNAL (activated ()),
m_view, SLOT (removeSelected ()));
// connect (b, SIGNAL(activated ()), m_list, SLOT (deleteFiles ()));
/* Selection menu */

View file

@ -1,4 +1,4 @@
// TODO might not need those
// TODO might not need those two
#include <xmmsclient/xmmsclient++.h>
#include "XMMSHandler.h"
@ -119,6 +119,18 @@ PlaylistView::invertSelection () {
QItemSelectionModel::NoUpdate);
}
void
PlaylistView::cropSelected () {
invertSelection ();
removeSelected ();
selectAll ();
}
void
PlaylistView::removeSelected () {
qobject_cast<PlaylistModel *> (model ())->removeRows (selectedIndexes ());
}
void
PlaylistView::setModel (QAbstractItemModel *model) {
QListView::setModel (model);
@ -144,6 +156,7 @@ PlaylistView::contextMenuEvent (QContextMenuEvent *e)
qm.addAction (a);
a = new QAction (tr ("Remove selected"), this);
connect (a, SIGNAL (triggered ()), this, SLOT (removeSelected ()));
qm.addAction (a);
qm.addSeparator ();
@ -222,7 +235,6 @@ PlaylistView::mouseDoubleClickEvent (QMouseEvent *event)
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
xmmsh.requestTrackChange (index.row());
// TODO check for status first.
if (m_status == XMMS_PLAYBACK_STATUS_STOP ||
m_status == XMMS_PLAYBACK_STATUS_PAUSE) {
xmmsh.play ();

View file

@ -38,6 +38,8 @@ class PlaylistView : public QListView {
void handleStatus (const Xmms::Playback::Status st);
void invertSelection (void);
void cropSelected (void);
void removeSelected (void);
void settingsSaved (void);
void setPixmaps (Skin *skin);