Show number of tracks and total duration in playqueue

This commit is contained in:
craig.p.drummond
2014-04-13 19:25:57 +00:00
committed by craig.p.drummond
parent 04fb7ae3b8
commit 67bc1a7ed6
5 changed files with 31 additions and 3 deletions

View File

@@ -160,6 +160,7 @@ PlayQueueModel::PlayQueueModel(QObject *parent)
: QAbstractItemModel(parent)
, currentSongId(-1)
, currentSongRowNum(-1)
, time(0)
, mpdState(MPDState_Inactive)
#ifndef ENABLE_UBUNTU
, dropAdjust(0)
@@ -811,6 +812,7 @@ void PlayQueueModel::clear()
currentSongId=-1;
currentSongRowNum=0;
stopAfterTrackId=-1;
time=0;
endResetModel();
}
@@ -864,7 +866,7 @@ void PlayQueueModel::update(const QList<Song> &songList)
stopAfterTrackId=-1;
}
} else {
quint32 time = 0;
time = 0;
QSet<qint32> removed=ids-newIds;
foreach (qint32 id, removed) {
@@ -1229,8 +1231,7 @@ void PlayQueueModel::playSong(const QString &file)
void PlayQueueModel::stats()
{
quint32 time = 0;
time = 0;
//Loop over all songs
foreach(const Song &song, songs) {
time += song.time;

View File

@@ -128,6 +128,7 @@ public:
Action * redoAct() { return redoAction; }
void enableUndo(bool e);
bool lastCommandWasUnodOrRedo() const { return Cmd_Other!=lastCommand; }
qint32 totalTime() const { return time; }
private:
void saveHistory(const QList<Song> &prevList);
@@ -175,6 +176,7 @@ private:
QSet<qint32> ids;
qint32 currentSongId;
mutable qint32 currentSongRowNum;
quint32 time;
StreamFetcher *fetcher;
MPDState mpdState;
#ifndef ENABLE_UBUNTU

View File

@@ -26,6 +26,7 @@
#include "currentcover.h"
#include "covers.h"
#include "localize.h"
#include "plurals.h"
#include <QString>
#include <QModelIndex>
@@ -447,6 +448,14 @@ void MPDBackend::updatePlayQueue(const QList<Song> &songs)
//Touch specific:
if (0==songs.count()) {
playQueueStatus=QString();
} else if (0==playQueueModel.totalTime()) {
playQueueStatus=Plurals::tracks(songs.count());
} else {
playQueueStatus=Plurals::tracksWithDuration(songs.count(), Utils::formatDuration(playQueueModel.totalTime()));
}
emit onPlayQueueChanged();
}

View File

@@ -54,6 +54,7 @@ class MPDBackend : public QObject
Q_PROPERTY(quint8 mpdVolume READ getMpdVolume WRITE setMpdVolume NOTIFY onMpdVolumeChanged)
Q_PROPERTY(bool playQueueEmpty READ isPlayQueueEmpty NOTIFY onPlayQueueChanged)
Q_PROPERTY(QString playQueueStatus READ getPlayQueueStatus NOTIFY onPlayQueueChanged)
Q_PROPERTY(bool artistsFound READ getArtistsFound NOTIFY onArtistsModelChanged)
Q_PROPERTY(bool albumsFound READ getAlbumsFound NOTIFY onAlbumsModelChanged)
Q_PROPERTY(bool playlistsFound READ getPlaylistsFound NOTIFY onPlaylistsModelChanged)
@@ -79,6 +80,7 @@ public:
Q_INVOKABLE QString getCurrentSongSubText() { return subText; }
Q_INVOKABLE quint32 getCurrentSongPlayqueuePosition() { return playQueueModel.currentSongRow(); }
Q_INVOKABLE quint8 getMpdVolume() { return MPDStatus::self()->volume(); }
Q_INVOKABLE QString getPlayQueueStatus() { return playQueueStatus; }
Q_INVOKABLE void setMpdVolume(quint8 volume);
Q_INVOKABLE bool isPlayQueueEmpty() { return playQueueModel.rowCount() == 0; }
Q_INVOKABLE bool getArtistsFound() { return MusicLibraryModel::self()->rowCount()>0; }
@@ -141,6 +143,7 @@ private:
Song current;
QString mainText;
QString subText;
QString playQueueStatus;
QTimer *statusTimer;
PlayQueueModel playQueueModel;
PlayQueueProxyModel playQueueProxyModel;

View File

@@ -305,6 +305,19 @@ Page {
}
}
Label {
id: playQueueStatusLabel
text: backend.playQueueStatus
anchors {
top: isPhone?(buttonsRow2.visible?buttonsRow2.bottom:parent.top):controlsRow.bottom
right: parent.right
topMargin: (isPhone)?units.gu(1):units.gu(2)
leftMargin: units.gu(1)
rightMargin: units.gu(1)
}
visible: !backend.playQueueEmpty && backend.isConnected;
}
ListView {
id: playqueueListView
clip: true