Fixed notifications for adding stuff to the play queue
This commit is contained in:
committed by
nikwen.developer@gmail.com
parent
168337c943
commit
fd094be97e
@@ -274,36 +274,26 @@ void MPDBackend::playlistsUpdated() {
|
||||
emit onPlaylistsModelChanged();
|
||||
}
|
||||
|
||||
QString MPDBackend::add(const QString &modelName, const QVariant &rows, bool replace) { //TODO: SubListViewPage!!!
|
||||
void MPDBackend::add(const QString &modelName, const QVariant &rows, bool replace) { //TODO: SubListViewPage!!!
|
||||
if (QVariant::Int==rows.type() && "playlists"==modelName) {
|
||||
loadPlaylist(rows.toInt(), replace);
|
||||
return QString(); //no replace for playlists
|
||||
return; //no replace for playlists
|
||||
}
|
||||
|
||||
QString returnText;
|
||||
ProxyModel *proxy=0;
|
||||
ActionModel *model=0;
|
||||
if ("artists"==modelName) {
|
||||
proxy=&artistsProxyModel;
|
||||
model=MusicLibraryModel::self();
|
||||
if (!replace) {
|
||||
returnText = i18n("Added artist");
|
||||
}
|
||||
} else if ("albums"==modelName) {
|
||||
proxy=&albumsProxyModel;
|
||||
model=AlbumsModel::self();
|
||||
if (!replace) {
|
||||
returnText = i18n("Added album");
|
||||
}
|
||||
} else if ("playlists"==modelName) {
|
||||
proxy=&playlistsProxyModel;
|
||||
model=PlaylistsModel::self(); //no replace for playlists
|
||||
model=PlaylistsModel::self();
|
||||
} else if ("folders"==modelName) {
|
||||
proxy=&foldersProxyModel;
|
||||
model=DirViewModel::self();
|
||||
if (!replace) {
|
||||
returnText = i18n("Added folder");
|
||||
}
|
||||
}
|
||||
|
||||
if (model) {
|
||||
@@ -320,7 +310,7 @@ QString MPDBackend::add(const QString &modelName, const QVariant &rows, bool rep
|
||||
foreach (int r, rowList) {
|
||||
idx=proxy->index(r, 0, idx);
|
||||
if (!idx.isValid()) {
|
||||
return QString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
QStringList fileNames = model->filenames(QModelIndexList() << proxy->mapToSource(idx), false);
|
||||
@@ -329,8 +319,6 @@ QString MPDBackend::add(const QString &modelName, const QVariant &rows, bool rep
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnText;
|
||||
}
|
||||
|
||||
void MPDBackend::remove(const QString &modelName, const QVariant &rows) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
Q_INVOKABLE void previousSong();
|
||||
Q_INVOKABLE void clearPlayQueue() { emit clear(); }
|
||||
Q_INVOKABLE bool getIsConnected() { return MPDConnection::self()->isConnected(); }
|
||||
Q_INVOKABLE QString add(const QString &modelName, const QVariant &rows, bool replace);
|
||||
Q_INVOKABLE void add(const QString &modelName, const QVariant &rows, bool replace);
|
||||
Q_INVOKABLE void remove(const QString &modelName, const QVariant &rows);
|
||||
Q_INVOKABLE void loadPlaylist(int index, bool replace);
|
||||
Q_INVOKABLE void removeFromPlayQueue(int index);
|
||||
|
||||
@@ -42,12 +42,12 @@ Page {
|
||||
property alias emptyViewVisible: emptyLabel.visible
|
||||
property alias emptyViewText: emptyLabel.text
|
||||
|
||||
function add(index, replace) {
|
||||
var notifyText = backend.add(modelName, index, replace)
|
||||
function add(index, replace, mainText) {
|
||||
backend.add(modelName, index, replace)
|
||||
if (replace) {
|
||||
pageStack.push(currentlyPlayingPage)
|
||||
} else if (notifyText !== undefined && notifyText !== "") {
|
||||
notification.show(notifyText)
|
||||
} else if (mainText !== undefined && mainText !== "") {
|
||||
notification.show(qsTr(i18n.tr("Added \"%1\"")).arg(mainText))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ Page {
|
||||
firstButtonImageSource: "../../icons/toolbar/media-playback-start-light.svg"
|
||||
secondButtonImageSource: "../../icons/toolbar/add.svg"
|
||||
|
||||
onFirstImageButtonClicked: listViewPage.add(index, true)
|
||||
onSecondImageButtonClicked: listViewPage.add(index, false)
|
||||
onFirstImageButtonClicked: listViewPage.add(index, true, model.mainText)
|
||||
onSecondImageButtonClicked: listViewPage.add(index, false, model.mainText)
|
||||
|
||||
onClicked: model.hasChildren ? listViewPage.onDelegateClicked(index, model.titleText) : "";
|
||||
onItemRemoved: listViewPage.remove(index)
|
||||
|
||||
@@ -50,13 +50,13 @@ Page {
|
||||
newRows[rows.length] = index
|
||||
return newRows
|
||||
}
|
||||
|
||||
function add(index, replace) {
|
||||
var notifyText = backend.add(modelName, hierarchy(index), replace)
|
||||
|
||||
function add(index, replace, mainText) {
|
||||
backend.add(modelName, index, replace)
|
||||
if (replace) {
|
||||
pageStack.push(currentlyPlayingPage)
|
||||
} else if (notifyText !== undefined && notifyText !== "") {
|
||||
notification.show(notifyText)
|
||||
} else if (mainText !== undefined && mainText !== "") {
|
||||
notification.show(qsTr(i18n.tr("Added \"%1\"")).arg(mainText))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ Page {
|
||||
progression: model.hasChildren
|
||||
forceProgressionSpacing: subListView.hasProgression
|
||||
|
||||
onFirstImageButtonClicked: subListViewPage.add(index, true)
|
||||
onSecondImageButtonClicked: subListViewPage.add(index, false)
|
||||
onFirstImageButtonClicked: subListViewPage.add(index, true, model.mainText)
|
||||
onSecondImageButtonClicked: subListViewPage.add(index, false, model.mainText)
|
||||
|
||||
onClicked: model.hasChildren ? subListViewPage.onDelegateClicked(index, model.titleText) : "";
|
||||
onItemRemoved: subListViewPage.remove(index)
|
||||
|
||||
Reference in New Issue
Block a user