mixer: add clearer pulseaudio control naming
[apps/mixer.git] / app / pacontrolmodel.h
index aa34a79..81eb70b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Konsulko Group
+ * Copyright (C) 2016,2017 Konsulko Group
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #include <pulse/pulseaudio.h>
 
-#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 <QAbstractListModel>
-#include <QStringList>
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QList>
 
 class PaControlModel;
 
 class PaControl
 {
        public:
-               PaControl(const quint32 &index, const QString &desc, const quint32 &type, const quint32 &channel, const QString &cdesc, const quint32 &volume);
+               PaControl(const quint32 &index, const QString &name, const QString &desc, const quint32 &type, const quint32 &channel, const QString &cdesc, const quint32 &volume);
 
                quint32 cindex() const;
+               QString name() const;
                QString desc() const;
                quint32 type() const;
                quint32 channel() const;
                QString cdesc() const;
                quint32 volume() const;
                void setCIndex(const QVariant&);
+               void setName(const QVariant&);
                void setDesc(const QVariant&);
                void setType(const QVariant&);
                void setChannel(const QVariant&);
                void setCDesc(const QVariant&);
-               void setVolume(pa_context *, const QVariant&);
+               void setVolume(PaControlModel *, const QVariant&);
 
        private:
                quint32 m_cindex;
+               QString m_name;
                QString m_desc;
                quint32 m_type;
                quint32 m_channel;
@@ -59,6 +57,7 @@ class PaControlModel : public QAbstractListModel
        public:
                enum PaControlRoles {
                        CIndexRole = Qt::UserRole + 1,
+                       NameRole,
                        DescRole,
                        TypeRole,
                        ChannelRole,
@@ -78,10 +77,16 @@ class PaControlModel : public QAbstractListModel
 
                Qt::ItemFlags flags(const QModelIndex &index) const;
 
+       public slots:
+               void addOneControl(int cindex, QString name, QString desc, int type, int channel, const char *cdesc, int volume);
+               void changeExternalVolume(uint32_t type, uint32_t cindex, uint32_t chan, uint32_t volume);
+
+       signals:
+               void volumeChanged(uint32_t type, uint32_t index, uint32_t channel, uint32_t volume);
+
        protected:
                QHash<int, QByteArray> roleNames() const;
        private:
                QList<PaControl> m_controls;
                pa_context *pa_ctx;
 };
-#endif // __cplusplus