/*  This file is part of the KDE project
    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2 as published by the Free Software Foundation.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

*/

#include "mixercontrol.h"
#include "mixercontrol_p.h"
#include <QtCore/QStringList>
#include "defs_p.h"

namespace Phonon
{
namespace Mixer
{

MixerControl::~MixerControl()
{
    delete d_ptr;
}

MixerControl::MixerControl(const MixerControl &rhs)
    : d_ptr(new MixerControlPrivate(rhs.d_ptr->s_ptr))
{
    d_ptr->q_ptr = this;
    Q_ASSERT(d_ptr->s_ptr);
}

MixerControl &MixerControl::operator=(const MixerControl &rhs)
{
    d_ptr->s_ptr = rhs.d_ptr->s_ptr;
    Q_ASSERT(d_ptr->s_ptr);
    return *this;
}

bool MixerControl::operator==(const MixerControl &rhs) const
{
    return (d_ptr->s_ptr == rhs.d_ptr->s_ptr);
}

MixerControl::MixerControl(MixerControlPrivate &dd)
    : d_ptr(&dd)
{
    d_ptr->q_ptr = this;
    //Q_ASSERT(d_ptr->s_ptr);
}

MixerControlPrivate::MixerControlPrivate(const MixerControlSharedData::Ptr &_sharedData)
    : q_ptr(0),
    s_ptr(_sharedData)
{
}

const QObject *MixerControl::notifier() const
{
    K_S(const MixerControl);
    return s;
}

bool MixerControl::isValid() const
{
    K_S(const MixerControl);
    if (s) {
        return s->isValid();
    }
    return false;
}

void MixerControlPrivate::invalidate()
{
    s_ptr->m_mixer = 0;
}

int MixerControl::id() const
{
    K_S(const MixerControl);
    return s->id();
}

int MixerControlSharedData::id() const
{
    return m_id.numid();
}

MixerControlSet MixerControl::parentSet() const
{
    K_S(const MixerControl);
    return s->m_controlSet;
}

QString MixerControl::extraInfo() const
{
    K_S(const MixerControl);
    return s->m_extraInfo;
}

} // namespace Mixer
} // namespace Phonon
