#include "songprivate.h"
#include "recordprivate.h"
#include "musiclibraryprivate.h"
#include "mldebug.h"

SongPrivate::SongPrivate(Song *pubPtr, RecordPrivate *r)
    : MusicObjectPrivate(pubPtr, r), record(r), num(0)
{
    LogAlloc();
    // Add to record's list of songs
    record->addSong(this);
}

SongPrivate::~SongPrivate()
{
    // Remove from record if it hasn't been cleared
    if (record) {
        record->removeSong(this);
    }
    LogDelete();
}

void SongPrivate::recordDeleted()
{
    // If record is deleted, clear pointer so destructor doesn't use it
    record = 0;
}

void SongPrivate::setNumber(int n)
{
    if (num != n) {
        num = n;
        library->notifyChanged(this);
    }
}

void SongPrivate::setMusicFile(const QString &mf)
{
    if (music != mf) {
        music = mf;
        library->notifyChanged(this);
    }
}
