Skip to content

Commit

Permalink
Add songs to model only after retrieving their url
Browse files Browse the repository at this point in the history
  • Loading branch information
Iktwo committed Sep 24, 2014
1 parent fbf1200 commit 7520966
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/musicstreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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<Song *>(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;
Expand Down
1 change: 1 addition & 0 deletions src/musicstreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MusicStreamer : public QAbstractListModel
private:
Downloader *mDownloader;
QObjectList mSongs;
QObjectList mTempSongs;
bool mSearching;
bool mServerError;
QString mLastSearchHasMoreResults;
Expand Down

0 comments on commit 7520966

Please sign in to comment.