Made QRadioData bind to QRadioTuner to avoid using multiple services
QRadioData has been updated to be a QMediaBindableInterface, and it will bind to a QRadioTuner instance, i.e. a QMediaObject that provides a service which implements the QRadioDataControl. This change is reflected in the declarative implementations of radio tuner and data. There is a new `radioData` property in the Radio element which will give access to the declarative RadioData element for the tuner. If a RadioData element is created in QML, it will have an anonymous tuner which communicates with the underlying media service (which is pretty much the same how the QRadioTuner and QRadioData classes work previously). Updated radio tuner and data test cases to use availability control and extended the mock media service to allow providing a number of controls rather than just one (needed for testing availability of all classes extending from or using QMediaObject). Change-Id: Id41dde66eee529decd828fd2dcdfe4a54c0e81f4 Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
@@ -87,7 +87,9 @@ QT_BEGIN_NAMESPACE
|
||||
You can also use the Radio element to get information about tuning, for instance the
|
||||
frequency steps supported for tuning.
|
||||
|
||||
The corresponding \l RadioData element gives RDS information about the current radio station.
|
||||
The corresponding \l RadioData element gives RDS information about the
|
||||
current radio station. The best way to access the RadioData element for
|
||||
the current Radio is to use the \c radioData property.
|
||||
|
||||
\sa {Radio Overview}
|
||||
|
||||
@@ -95,10 +97,10 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
QDeclarativeRadio::QDeclarativeRadio(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_radioTuner(0)
|
||||
QObject(parent)
|
||||
{
|
||||
m_radioTuner = new QRadioTuner(this);
|
||||
m_radioData = new QDeclarativeRadioData(m_radioTuner, this);
|
||||
|
||||
connect(m_radioTuner, SIGNAL(stateChanged(QRadioTuner::State)), this, SLOT(_q_stateChanged(QRadioTuner::State)));
|
||||
connect(m_radioTuner, SIGNAL(bandChanged(QRadioTuner::Band)), this, SLOT(_q_bandChanged(QRadioTuner::Band)));
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <qradiotuner.h>
|
||||
#include "qdeclarativeradiodata_p.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@@ -77,6 +78,7 @@ class QDeclarativeRadio : public QObject
|
||||
Q_PROPERTY(int maximumFrequency READ maximumFrequency NOTIFY bandChanged)
|
||||
Q_PROPERTY(bool antennaConnected READ isAntennaConnected NOTIFY antennaConnectedChanged)
|
||||
Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged)
|
||||
Q_PROPERTY(QDeclarativeRadioData* radioData READ radioData CONSTANT)
|
||||
Q_ENUMS(State)
|
||||
Q_ENUMS(Band)
|
||||
Q_ENUMS(Error)
|
||||
@@ -146,6 +148,8 @@ public:
|
||||
Q_INVOKABLE bool isAvailable() const {return availability() == Available;}
|
||||
Availability availability() const;
|
||||
|
||||
QDeclarativeRadioData *radioData() { return m_radioData; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void setBand(QDeclarativeRadio::Band band);
|
||||
void setFrequency(int frequency);
|
||||
@@ -190,6 +194,7 @@ private:
|
||||
Q_DISABLE_COPY(QDeclarativeRadio)
|
||||
|
||||
QRadioTuner *m_radioTuner;
|
||||
QDeclarativeRadioData *m_radioData;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -70,52 +70,47 @@ QT_BEGIN_NAMESPACE
|
||||
band: Radio.FM
|
||||
}
|
||||
|
||||
RadioData {
|
||||
id: radioData
|
||||
}
|
||||
|
||||
Column {
|
||||
Text {
|
||||
text: radioData.stationName
|
||||
text: radio.radioData.stationName
|
||||
}
|
||||
|
||||
Text {
|
||||
text: radioData.programTypeName
|
||||
text: radio.radioData.programTypeName
|
||||
}
|
||||
|
||||
Text {
|
||||
text: radioData.radioText
|
||||
text: radio.radioData.radioText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\endqml
|
||||
|
||||
You use \c RadioData together with the \l Radio element. The properties of the RadioData element will reflect the
|
||||
information broadcast by the radio station the Radio element is currently tuned to.
|
||||
You use \c RadioData together with the \l Radio element, either by
|
||||
accessing the \c radioData property of the Radio element, or
|
||||
creating a separate RadioData element. The properties of the
|
||||
RadioData element will reflect the information broadcast by the
|
||||
radio station the Radio element is currently tuned to.
|
||||
|
||||
\sa {Radio Overview}
|
||||
*/
|
||||
QDeclarativeRadioData::QDeclarativeRadioData(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_radioData(0)
|
||||
QObject(parent)
|
||||
{
|
||||
m_radioData = new QRadioData(this);
|
||||
m_radioTuner = new QRadioTuner(this);
|
||||
m_radioData = m_radioTuner->radioData();
|
||||
|
||||
connect(m_radioData, SIGNAL(programTypeChanged(QRadioData::ProgramType)), this,
|
||||
SLOT(_q_programTypeChanged(QRadioData::ProgramType)));
|
||||
connectSignals();
|
||||
}
|
||||
|
||||
connect(m_radioData, SIGNAL(stationIdChanged(QString)), this, SIGNAL(stationIdChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(programTypeNameChanged(QString)), this, SIGNAL(programTypeNameChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(stationNameChanged(QString)), this, SIGNAL(stationNameChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(radioTextChanged(QString)), this, SIGNAL(radioTextChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), this,
|
||||
SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
|
||||
QDeclarativeRadioData::QDeclarativeRadioData(QRadioTuner *tuner, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
m_radioTuner = tuner;
|
||||
m_radioData = m_radioTuner->radioData();
|
||||
|
||||
// Note we map availabilityError->availability
|
||||
connect(m_radioData, SIGNAL(availabilityErrorChanged(QtMultimedia::AvailabilityError)), this, SLOT(_q_availabilityChanged(QtMultimedia::AvailabilityError)));
|
||||
|
||||
connect(m_radioData, SIGNAL(error(QRadioData::Error)), this, SLOT(_q_error(QRadioData::Error)));
|
||||
connectSignals();
|
||||
}
|
||||
|
||||
QDeclarativeRadioData::~QDeclarativeRadioData()
|
||||
@@ -290,4 +285,23 @@ void QDeclarativeRadioData::_q_availabilityChanged(QtMultimedia::AvailabilityErr
|
||||
emit availabilityChanged(Availability(error));
|
||||
}
|
||||
|
||||
void QDeclarativeRadioData::connectSignals()
|
||||
{
|
||||
connect(m_radioData, SIGNAL(programTypeChanged(QRadioData::ProgramType)), this,
|
||||
SLOT(_q_programTypeChanged(QRadioData::ProgramType)));
|
||||
|
||||
connect(m_radioData, SIGNAL(stationIdChanged(QString)), this, SIGNAL(stationIdChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(programTypeNameChanged(QString)), this, SIGNAL(programTypeNameChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(stationNameChanged(QString)), this, SIGNAL(stationNameChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(radioTextChanged(QString)), this, SIGNAL(radioTextChanged(QString)));
|
||||
connect(m_radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), this,
|
||||
SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
|
||||
|
||||
// Note we map availabilityError->availability
|
||||
// Since the radio data element depends on the service for the tuner, the availability is also dictated from the tuner
|
||||
connect(m_radioTuner, SIGNAL(availabilityErrorChanged(QtMultimedia::AvailabilityError)), this, SLOT(_q_availabilityChanged(QtMultimedia::AvailabilityError)));
|
||||
|
||||
connect(m_radioData, SIGNAL(error(QRadioData::Error)), this, SLOT(_q_error(QRadioData::Error)));
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <qradiodata.h>
|
||||
#include <qradiotuner.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@@ -143,6 +144,7 @@ public:
|
||||
};
|
||||
|
||||
QDeclarativeRadioData(QObject *parent = 0);
|
||||
QDeclarativeRadioData(QRadioTuner *tuner, QObject *parent = 0);
|
||||
~QDeclarativeRadioData();
|
||||
|
||||
QString stationId() const;
|
||||
@@ -177,9 +179,12 @@ private Q_SLOTS:
|
||||
void _q_availabilityChanged(QtMultimedia::AvailabilityError);
|
||||
|
||||
private:
|
||||
void connectSignals();
|
||||
|
||||
Q_DISABLE_COPY(QDeclarativeRadioData)
|
||||
|
||||
QRadioData *m_radioData;
|
||||
QRadioTuner *m_radioTuner;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user