[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-mediacenter/sinny-playlist] /: Let the user clear the playlist.
From: Shantanu Tushar <shaan7in () gmail ! com>
Date: 2012-05-15 7:00:12
Message-ID: 20120515070012.15085A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit dba177240ec97d74c92bff54a71b628283a78021 by Shantanu Tushar.
Committed on 15/05/2012 at 08:59.
Pushed by shantanu into branch 'sinny-playlist'.
Let the user clear the playlist.
Patch by Prashansha Bharti <prashansa007@gmail.com>
M +16 -1 components/playlist/Playlist.qml
M +10 -0 libs/mediacenter/playlistmodel.cpp
M +1 -0 libs/mediacenter/playlistmodel.h
http://commits.kde.org/plasma-mediacenter/dba177240ec97d74c92bff54a71b628283a78021
diff --git a/components/playlist/Playlist.qml b/components/playlist/Playlist.qml
index bcd2d22..6cd23ed 100644
--- a/components/playlist/Playlist.qml
+++ b/components/playlist/Playlist.qml
@@ -18,6 +18,7 @@
***************************************************************************/
import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
Rectangle {
id: playlistItem
@@ -26,9 +27,23 @@ import QtQuick 1.1
height: parent.height
width: parent.width / 3
color: "black"
+
+ PlasmaComponents.ToolButton {
+ id: clearPlaylist
+ width: 40
+ height: width
+ anchors.top: parent.top
+ iconSource: "edit-clear-list"
+ onClicked: {
+ playlistModel.clearPlaylist();
+ }
+ }
ListView {
- anchors.fill:parent
+ anchors.top: clearPlaylist.bottom
+ anchors.bottom: parent.bottom
model: playlistModel
+ width: parent.width
+ height: parent.height - clearPlaylist.height
spacing: 3
delegate:
diff --git a/libs/mediacenter/playlistmodel.cpp b/libs/mediacenter/playlistmodel.cpp
index 08363b8..5cda032 100644
--- a/libs/mediacenter/playlistmodel.cpp
+++ b/libs/mediacenter/playlistmodel.cpp
@@ -76,6 +76,16 @@ QString PlaylistModel::getPreviousUrl()
return m_musicList.at(m_currentIndex).mediaUrl();
}
+void PlaylistModel::clearPlaylist()
+{
+ beginResetModel();
+
+ m_musicList.clear();
+ m_currentIndex = -1;
+
+ endResetModel();
+}
+
int PlaylistModel::currentIndex()
{
return m_currentIndex;
diff --git a/libs/mediacenter/playlistmodel.h b/libs/mediacenter/playlistmodel.h
index 10f5e58..720d88b 100644
--- a/libs/mediacenter/playlistmodel.h
+++ b/libs/mediacenter/playlistmodel.h
@@ -51,6 +51,7 @@ public:
Q_INVOKABLE void addToPlaylist(const QString &url, const QString &name);
Q_INVOKABLE QString getNextUrl();
Q_INVOKABLE QString getPreviousUrl();
+ Q_INVOKABLE void clearPlaylist();
int currentIndex();
void setCurrentIndex(int index);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic