Added RDS functionality to the QRadioTuner/QDeclarativeRadio
Change-Id: I865e3caba82977002cf1f01f1d64ee0a42de77c6 Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
cbb21e30d5
commit
6aea1a22ee
@@ -49,6 +49,7 @@
|
||||
#include "qdeclarativeaudio_p.h"
|
||||
#include "qdeclarativevideooutput_p.h"
|
||||
#include "qdeclarativeradio_p.h"
|
||||
#include "qdeclarativeradiodata_p.h"
|
||||
#include "qdeclarativebackgroundaudio_p.h"
|
||||
#include "qdeclarativecamera_p.h"
|
||||
#include "qdeclarativecamerapreviewprovider_p.h"
|
||||
@@ -76,6 +77,7 @@ public:
|
||||
qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "MediaPlayer");
|
||||
qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
|
||||
qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
|
||||
qmlRegisterType<QDeclarativeRadioData>(uri, 4, 0, "RadioData");
|
||||
qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio");
|
||||
qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera");
|
||||
qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture",
|
||||
|
||||
@@ -17,6 +17,7 @@ HEADERS += \
|
||||
qsgvideonode_i420.h \
|
||||
qsgvideonode_rgb.h \
|
||||
qdeclarativeradio_p.h \
|
||||
qdeclarativeradiodata_p.h \
|
||||
qdeclarativebackgroundaudio_p.h \
|
||||
qdeclarativecamera_p.h \
|
||||
qdeclarativecameracapture_p.h \
|
||||
@@ -36,6 +37,7 @@ SOURCES += \
|
||||
qsgvideonode_i420.cpp \
|
||||
qsgvideonode_rgb.cpp \
|
||||
qdeclarativeradio.cpp \
|
||||
qdeclarativeradiodata.cpp \
|
||||
qdeclarativebackgroundaudio.cpp \
|
||||
qdeclarativecamera.cpp \
|
||||
qdeclarativecameracapture.cpp \
|
||||
|
||||
@@ -58,6 +58,7 @@ QDeclarativeRadio::QDeclarativeRadio(QObject *parent) :
|
||||
connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int)));
|
||||
connect(m_radioTuner, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
|
||||
connect(m_radioTuner, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
|
||||
connect(m_radioTuner, SIGNAL(stationFound(int, QString)), this, SIGNAL(stationFound(int, QString)));
|
||||
|
||||
connect(m_radioTuner, SIGNAL(error(QRadioTuner::Error)), this, SLOT(_q_error(QRadioTuner::Error)));
|
||||
}
|
||||
@@ -171,6 +172,11 @@ void QDeclarativeRadio::scanUp()
|
||||
m_radioTuner->searchForward();
|
||||
}
|
||||
|
||||
void QDeclarativeRadio::searchAllStations(QDeclarativeRadio::SearchMode searchMode)
|
||||
{
|
||||
m_radioTuner->searchAllStations(static_cast<QRadioTuner::SearchMode>(searchMode));
|
||||
}
|
||||
|
||||
void QDeclarativeRadio::tuneDown()
|
||||
{
|
||||
int f = frequency();
|
||||
|
||||
@@ -79,6 +79,7 @@ class QDeclarativeRadio : public QObject
|
||||
Q_ENUMS(Band)
|
||||
Q_ENUMS(Error)
|
||||
Q_ENUMS(StereoMode)
|
||||
Q_ENUMS(SearchMode)
|
||||
|
||||
public:
|
||||
enum State {
|
||||
@@ -107,6 +108,11 @@ public:
|
||||
Auto = QRadioTuner::Auto
|
||||
};
|
||||
|
||||
enum SearchMode {
|
||||
SearchFast = QRadioTuner::SearchFast,
|
||||
SearchGetStationId = QRadioTuner::SearchGetStationId
|
||||
};
|
||||
|
||||
QDeclarativeRadio(QObject *parent = 0);
|
||||
~QDeclarativeRadio();
|
||||
|
||||
@@ -139,6 +145,8 @@ public Q_SLOTS:
|
||||
void scanUp();
|
||||
void tuneUp();
|
||||
void tuneDown();
|
||||
void searchAllStations(QDeclarativeRadio::SearchMode searchMode = QDeclarativeRadio::SearchFast );
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
@@ -151,6 +159,7 @@ Q_SIGNALS:
|
||||
void signalStrengthChanged(int signalStrength);
|
||||
void volumeChanged(int volume);
|
||||
void mutedChanged(bool muted);
|
||||
void stationFound(int frequency, QString stationId);
|
||||
|
||||
void errorChanged();
|
||||
void error(QDeclarativeRadio::Error errorCode);
|
||||
|
||||
118
src/imports/multimedia/qdeclarativeradiodata.cpp
Normal file
118
src/imports/multimedia/qdeclarativeradiodata.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativeradiodata_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDeclarativeRadioData::QDeclarativeRadioData(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_radioData(0)
|
||||
{
|
||||
m_radioData = new QRadioData(this);
|
||||
|
||||
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)));
|
||||
|
||||
connect(m_radioData, SIGNAL(error(QRadioData::Error)), this, SLOT(_q_error(QRadioData::Error)));
|
||||
}
|
||||
|
||||
QDeclarativeRadioData::~QDeclarativeRadioData()
|
||||
{
|
||||
}
|
||||
|
||||
bool QDeclarativeRadioData::isAvailable() const
|
||||
{
|
||||
return m_radioData->isAvailable();
|
||||
}
|
||||
|
||||
QString QDeclarativeRadioData::stationId() const
|
||||
{
|
||||
return m_radioData->stationId();
|
||||
}
|
||||
|
||||
QDeclarativeRadioData::ProgramType QDeclarativeRadioData::programType() const
|
||||
{
|
||||
return static_cast<QDeclarativeRadioData::ProgramType>(m_radioData->programType());
|
||||
}
|
||||
|
||||
QString QDeclarativeRadioData::programTypeName() const
|
||||
{
|
||||
return m_radioData->programTypeName();
|
||||
}
|
||||
|
||||
QString QDeclarativeRadioData::stationName() const
|
||||
{
|
||||
return m_radioData->stationName();
|
||||
}
|
||||
|
||||
QString QDeclarativeRadioData::radioText() const
|
||||
{
|
||||
return m_radioData->radioText();
|
||||
}
|
||||
|
||||
bool QDeclarativeRadioData::alternativeFrequenciesEnabled() const
|
||||
{
|
||||
return m_radioData->isAlternativeFrequenciesEnabled();
|
||||
}
|
||||
|
||||
void QDeclarativeRadioData::setAlternativeFrequenciesEnabled(bool enabled)
|
||||
{
|
||||
m_radioData->setAlternativeFrequenciesEnabled(enabled);
|
||||
}
|
||||
|
||||
void QDeclarativeRadioData::_q_programTypeChanged(QRadioData::ProgramType programType)
|
||||
{
|
||||
emit programTypeChanged(static_cast<QDeclarativeRadioData::ProgramType>(programType));
|
||||
}
|
||||
|
||||
void QDeclarativeRadioData::_q_error(QRadioData::Error errorCode)
|
||||
{
|
||||
emit error(static_cast<QDeclarativeRadioData::Error>(errorCode));
|
||||
emit errorChanged();
|
||||
}
|
||||
178
src/imports/multimedia/qdeclarativeradiodata_p.h
Normal file
178
src/imports/multimedia/qdeclarativeradiodata_p.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVERADIODATA_P_H
|
||||
#define QDECLARATIVERADIODATA_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <qradiodata.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeRadioData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString stationId READ stationId NOTIFY stationIdChanged)
|
||||
Q_PROPERTY(QDeclarativeRadioData::ProgramType programType READ programType NOTIFY programTypeChanged)
|
||||
Q_PROPERTY(QString programTypeName READ programTypeName NOTIFY programTypeNameChanged)
|
||||
Q_PROPERTY(QString stationName READ stationName NOTIFY stationNameChanged)
|
||||
Q_PROPERTY(QString radioText READ radioText NOTIFY radioTextChanged)
|
||||
Q_PROPERTY(bool alternativeFrequenciesEnabled READ alternativeFrequenciesEnabled
|
||||
WRITE setAlternativeFrequenciesEnabled NOTIFY alternativeFrequenciesEnabledChanged)
|
||||
Q_ENUMS(Error)
|
||||
Q_ENUMS(ProgramType)
|
||||
|
||||
public:
|
||||
|
||||
enum Error {
|
||||
NoError = QRadioData::NoError,
|
||||
ResourceError = QRadioData::ResourceError,
|
||||
OpenError = QRadioData::OpenError,
|
||||
OutOfRangeError = QRadioData::OutOfRangeError
|
||||
};
|
||||
|
||||
enum ProgramType {
|
||||
Undefined = QRadioData::Undefined,
|
||||
News = QRadioData::News,
|
||||
CurrentAffairs = QRadioData::CurrentAffairs,
|
||||
Information = QRadioData::Information,
|
||||
Sport = QRadioData::Sport,
|
||||
Education = QRadioData::Education,
|
||||
Drama = QRadioData::Drama,
|
||||
Culture = QRadioData::Culture,
|
||||
Science = QRadioData::Science,
|
||||
Varied = QRadioData::Varied,
|
||||
PopMusic = QRadioData::PopMusic,
|
||||
RockMusic = QRadioData::RockMusic,
|
||||
EasyListening = QRadioData::EasyListening,
|
||||
LightClassical = QRadioData::LightClassical,
|
||||
SeriousClassical = QRadioData::SeriousClassical,
|
||||
OtherMusic = QRadioData::OtherMusic,
|
||||
Weather = QRadioData::Weather,
|
||||
Finance = QRadioData::Finance,
|
||||
ChildrensProgrammes = QRadioData::ChildrensProgrammes,
|
||||
SocialAffairs = QRadioData::SocialAffairs,
|
||||
Religion = QRadioData::Religion,
|
||||
PhoneIn = QRadioData::PhoneIn,
|
||||
Travel = QRadioData::Travel,
|
||||
Leisure = QRadioData::Leisure,
|
||||
JazzMusic = QRadioData::JazzMusic,
|
||||
CountryMusic = QRadioData::CountryMusic,
|
||||
NationalMusic = QRadioData::NationalMusic,
|
||||
OldiesMusic = QRadioData::OldiesMusic,
|
||||
FolkMusic = QRadioData::FolkMusic,
|
||||
Documentary = QRadioData::Documentary,
|
||||
AlarmTest = QRadioData::AlarmTest,
|
||||
Alarm = QRadioData::Alarm,
|
||||
Talk = QRadioData::Talk,
|
||||
ClassicRock = QRadioData::ClassicRock,
|
||||
AdultHits = QRadioData::AdultHits,
|
||||
SoftRock = QRadioData::SoftRock,
|
||||
Top40 = QRadioData::Top40,
|
||||
Soft = QRadioData::Soft,
|
||||
Nostalgia = QRadioData::Nostalgia,
|
||||
Classical = QRadioData::Classical,
|
||||
RhythmAndBlues = QRadioData::RhythmAndBlues,
|
||||
SoftRhythmAndBlues = QRadioData::SoftRhythmAndBlues,
|
||||
Language = QRadioData::Language,
|
||||
ReligiousMusic = QRadioData::ReligiousMusic,
|
||||
ReligiousTalk = QRadioData::ReligiousTalk,
|
||||
Personality = QRadioData::Personality,
|
||||
Public = QRadioData::Public,
|
||||
College = QRadioData::College,
|
||||
};
|
||||
|
||||
QDeclarativeRadioData(QObject *parent = 0);
|
||||
~QDeclarativeRadioData();
|
||||
|
||||
Q_INVOKABLE bool isAvailable() const;
|
||||
|
||||
QString stationId() const;
|
||||
QDeclarativeRadioData::ProgramType programType() const;
|
||||
QString programTypeName() const;
|
||||
QString stationName() const;
|
||||
QString radioText() const;
|
||||
bool alternativeFrequenciesEnabled() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setAlternativeFrequenciesEnabled(bool enabled);
|
||||
|
||||
Q_SIGNALS:
|
||||
void stationIdChanged(QString stationId);
|
||||
void programTypeChanged(QDeclarativeRadioData::ProgramType programType);
|
||||
void programTypeNameChanged(QString programTypeName);
|
||||
void stationNameChanged(QString stationName);
|
||||
void radioTextChanged(QString radioText);
|
||||
void alternativeFrequenciesEnabledChanged(bool enabled);
|
||||
|
||||
void errorChanged();
|
||||
void error(QDeclarativeRadioData::Error errorCode);
|
||||
|
||||
private Q_SLOTS:
|
||||
void _q_programTypeChanged(QRadioData::ProgramType programType);
|
||||
void _q_error(QRadioData::Error errorCode);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QDeclarativeRadioData)
|
||||
|
||||
QRadioData *m_radioData;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadioData))
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECLARATIVERADIODATA_P_H
|
||||
Reference in New Issue
Block a user