diff --git a/src/musicstreamer.cpp b/src/musicstreamer.cpp index 7fabf4f..0d5854b 100644 --- a/src/musicstreamer.cpp +++ b/src/musicstreamer.cpp @@ -58,11 +58,7 @@ void MusicStreamer::songFound(const QString &title, const QString &artist, const const QString &comment, int kbps, const QString &code, const QString &picture, long long hits) { - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - mSongs.append(new Song(title, artist, length, comment, kbps, code, picture, hits, this)); - endInsertRows(); - - emit songsChanged(); + mTempSongs.append(new Song(title, artist, length, comment, kbps, code, picture, hits, this)); } QObjectList MusicStreamer::songs() @@ -74,12 +70,15 @@ void MusicStreamer::decodedUrl(const QString &code, const QString &url) { // qDebug() << Q_FUNC_INFO << " URL: " << url; int i = 0; - foreach (QObject *item, mSongs) { + foreach (QObject *item, mTempSongs) { Song *song = qobject_cast(item); if (song->code() == code) { song->setUrl(url); - QModelIndex index = createIndex(i, 0); - dataChanged(index, index); + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + mSongs.append(song); + endInsertRows(); + emit songsChanged(); + mTempSongs.removeAt(i); break; } ++i; diff --git a/src/musicstreamer.h b/src/musicstreamer.h index 8978db6..aeacea0 100644 --- a/src/musicstreamer.h +++ b/src/musicstreamer.h @@ -68,6 +68,7 @@ class MusicStreamer : public QAbstractListModel private: Downloader *mDownloader; QObjectList mSongs; + QObjectList mTempSongs; bool mSearching; bool mServerError; QString mLastSearchHasMoreResults;