/*  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 "mixertogglecontrol.h"
#include "mixertogglecontrol_p.h"

namespace Phonon
{
namespace Mixer
{

MixerToggleControlSharedData::MixerToggleControlSharedData(const MixerSharedData::Ptr &mixer, const AlsaElementId &id, MixerToggleControl::Category category)
    : MixerControlSharedData(mixer, id), m_category(category)
{
}

MixerToggleControl::MixerToggleControl(MixerToggleControlPrivate &dd)
    : MixerControl(dd)
{
}

MixerToggleControl::MixerToggleControl(const MixerToggleControl &rhs)
    : MixerControl(*new MixerToggleControlPrivate(const_cast<MixerToggleControlSharedData *>(rhs.d_func()->s_func())))
{
}

MixerToggleControl &MixerToggleControl::operator=(const MixerToggleControl &rhs)
{
    MixerControl::operator=(rhs);
    return *this;
}

bool MixerToggleControl::isChecked() const
{
    K_S(const MixerToggleControl);
    return s->isChecked();
}

void MixerToggleControl::setChecked(bool v)
{
    K_S(MixerToggleControl);
    s->setChecked(v);
}

template<> MixerToggleControl mixercontrol_cast<MixerToggleControl>(const MixerControl &mc)
{
    if (mc.type() == MixerControl::Toggle) {
        return static_cast<const MixerToggleControl &>(mc);
    }
    return MixerToggleControl(*new MixerToggleControlPrivate(0));
}

MixerToggleControl::Category MixerToggleControl::category() const
{
    K_S(const MixerToggleControl);
    return s->m_category;
}

} // namespace Mixer
} // namespace Phonon

template<> PHONON_MIXER_EXPORT Phonon::Mixer::MixerToggleControl qobject_cast<Phonon::Mixer::MixerToggleControl>(QObject *o)
{
    Phonon::Mixer::MixerToggleControlSharedData *s = qobject_cast<Phonon::Mixer::MixerToggleControlSharedData *>(o);
    return Phonon::Mixer::MixerToggleControl(*new Phonon::Mixer::MixerToggleControlPrivate(s));
}

// vim: sw=4 sts=4 et tw=100
