/*  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.

*/

#ifndef MIXERELEMENT_P_H
#define MIXERELEMENT_P_H

#include "mixerelement.h"
#include "mixer_p.h"
#include <QtCore/QExplicitlySharedDataPointer>
#include <QtGui/QIcon>
#include <QtCore/QObject>
#include <QtCore/QSharedData>
#include <QtCore/QString>

namespace Phonon
{
namespace Mixer
{

class MixerElementSharedData : public QObject, public QSharedData
{
    Q_OBJECT
    public:
        typedef QExplicitlySharedDataPointer<MixerElementSharedData> Ptr;
        MixerElementSharedData(MixerSharedData::Ptr m)
            : m_mixer(m) {}
        MixerElementSharedData(MixerSharedData::Ptr m, const QString &name, const QIcon &icon)
            : m_mixer(m), m_name(name), m_icon(icon) {}

    Q_SIGNALS:
        void controlAdded(const MixerControl &);
        void controlRemoved(const MixerControl &);

    private:
        bool operator<(const MixerElementSharedData &rhs) const;

        bool isValid() const { return m_mixer && m_mixer->isValid(); }
        QString name() const;
        QIcon icon() const;

        MixerSharedData::Ptr m_mixer;
        QString m_name;
        QIcon m_icon;
};

class MixerElementPrivate
{
    Q_DECLARE_PUBLIC(MixerElement)
    protected:
        MixerElement *q_ptr;
        MixerElementSharedData::Ptr s_ptr;

    public:
        MixerElementPrivate(const MixerElementSharedData::Ptr &);
        void invalidate();
};

} // namespace Mixer
} // namespace Phonon
#endif // MIXERELEMENT_P_H
