diff --git a/ubuntu/backend/mpdbackend.cpp b/ubuntu/backend/mpdbackend.cpp index 83d66c237..a50c9df01 100644 --- a/ubuntu/backend/mpdbackend.cpp +++ b/ubuntu/backend/mpdbackend.cpp @@ -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) { diff --git a/ubuntu/backend/mpdbackend.h b/ubuntu/backend/mpdbackend.h index 2969b9001..0f9391726 100644 --- a/ubuntu/backend/mpdbackend.h +++ b/ubuntu/backend/mpdbackend.h @@ -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); diff --git a/ubuntu/qml/cantata/ListViewPage.qml b/ubuntu/qml/cantata/ListViewPage.qml index f8abba75c..e1dfafd51 100644 --- a/ubuntu/qml/cantata/ListViewPage.qml +++ b/ubuntu/qml/cantata/ListViewPage.qml @@ -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) diff --git a/ubuntu/qml/cantata/SubListViewPage.qml b/ubuntu/qml/cantata/SubListViewPage.qml index f16b542e2..8e369c751 100644 --- a/ubuntu/qml/cantata/SubListViewPage.qml +++ b/ubuntu/qml/cantata/SubListViewPage.qml @@ -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)