From 392effc544e3d94b82f806378d4ac1d11a185422 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Mon, 19 Dec 2016 13:55:11 -0500 Subject: AGL-style PulseAudio mixer app Change-Id: I566050a1a8f241f140523df236de81ab951c1394 Signed-off-by: Matt Porter --- app/pacontrolmodel.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 app/pacontrolmodel.h (limited to 'app/pacontrolmodel.h') diff --git a/app/pacontrolmodel.h b/app/pacontrolmodel.h new file mode 100644 index 0000000..aa34a79 --- /dev/null +++ b/app/pacontrolmodel.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2016 Konsulko Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef __cplusplus +extern void add_one_control(void *ctx, int, const char *, int, int, const char *, int); +#else +extern "C" void add_one_control(void *ctx, int, const char *, int, int, const char *, int); + +#include +#include + +class PaControlModel; + +class PaControl +{ + public: + PaControl(const quint32 &index, const QString &desc, const quint32 &type, const quint32 &channel, const QString &cdesc, const quint32 &volume); + + quint32 cindex() const; + QString desc() const; + quint32 type() const; + quint32 channel() const; + QString cdesc() const; + quint32 volume() const; + void setCIndex(const QVariant&); + void setDesc(const QVariant&); + void setType(const QVariant&); + void setChannel(const QVariant&); + void setCDesc(const QVariant&); + void setVolume(pa_context *, const QVariant&); + + private: + quint32 m_cindex; + QString m_desc; + quint32 m_type; + quint32 m_channel; + QString m_cdesc; + quint32 m_volume; +}; + +class PaControlModel : public QAbstractListModel +{ + Q_OBJECT + public: + enum PaControlRoles { + CIndexRole = Qt::UserRole + 1, + DescRole, + TypeRole, + ChannelRole, + CDescRole, + VolumeRole + }; + + PaControlModel(QObject *parent = 0); + + void addControl(const PaControl &control); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + + Qt::ItemFlags flags(const QModelIndex &index) const; + + protected: + QHash roleNames() const; + private: + QList m_controls; + pa_context *pa_ctx; +}; +#endif // __cplusplus -- cgit 1.2.3-korg