1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QDECLARATIVERADIODATA_P_H 41 #define QDECLARATIVERADIODATA_P_H 42 43 // 44 // W A R N I N G 45 // ------------- 46 // 47 // This file is not part of the Qt API. It exists for the convenience 48 // of other Qt classes. This header file may change from version to 49 // version without notice, or even be removed. 50 // 51 // We mean it. 52 // 53 54 #include <qradiodata.h> 55 #include <qradiotuner.h> 56 #include <QtQml/qqml.h> 57 58 QT_BEGIN_NAMESPACE 59 60 class QDeclarativeRadioData : public QObject 61 { 62 Q_OBJECT 63 Q_PROPERTY(QString stationId READ stationId NOTIFY stationIdChanged) 64 Q_PROPERTY(QDeclarativeRadioData::ProgramType programType READ programType NOTIFY programTypeChanged) 65 Q_PROPERTY(QString programTypeName READ programTypeName NOTIFY programTypeNameChanged) 66 Q_PROPERTY(QString stationName READ stationName NOTIFY stationNameChanged) 67 Q_PROPERTY(QString radioText READ radioText NOTIFY radioTextChanged) 68 Q_PROPERTY(bool alternativeFrequenciesEnabled READ alternativeFrequenciesEnabled 69 WRITE setAlternativeFrequenciesEnabled NOTIFY alternativeFrequenciesEnabledChanged) 70 Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged) 71 Q_ENUMS(Error) 72 Q_ENUMS(ProgramType) 73 Q_ENUMS(Availability) 74 75 public: 76 77 enum Error { 78 NoError = QRadioData::NoError, 79 ResourceError = QRadioData::ResourceError, 80 OpenError = QRadioData::OpenError, 81 OutOfRangeError = QRadioData::OutOfRangeError 82 }; 83 84 enum ProgramType { 85 Undefined = QRadioData::Undefined, 86 News = QRadioData::News, 87 CurrentAffairs = QRadioData::CurrentAffairs, 88 Information = QRadioData::Information, 89 Sport = QRadioData::Sport, 90 Education = QRadioData::Education, 91 Drama = QRadioData::Drama, 92 Culture = QRadioData::Culture, 93 Science = QRadioData::Science, 94 Varied = QRadioData::Varied, 95 PopMusic = QRadioData::PopMusic, 96 RockMusic = QRadioData::RockMusic, 97 EasyListening = QRadioData::EasyListening, 98 LightClassical = QRadioData::LightClassical, 99 SeriousClassical = QRadioData::SeriousClassical, 100 OtherMusic = QRadioData::OtherMusic, 101 Weather = QRadioData::Weather, 102 Finance = QRadioData::Finance, 103 ChildrensProgrammes = QRadioData::ChildrensProgrammes, 104 SocialAffairs = QRadioData::SocialAffairs, 105 Religion = QRadioData::Religion, 106 PhoneIn = QRadioData::PhoneIn, 107 Travel = QRadioData::Travel, 108 Leisure = QRadioData::Leisure, 109 JazzMusic = QRadioData::JazzMusic, 110 CountryMusic = QRadioData::CountryMusic, 111 NationalMusic = QRadioData::NationalMusic, 112 OldiesMusic = QRadioData::OldiesMusic, 113 FolkMusic = QRadioData::FolkMusic, 114 Documentary = QRadioData::Documentary, 115 AlarmTest = QRadioData::AlarmTest, 116 Alarm = QRadioData::Alarm, 117 Talk = QRadioData::Talk, 118 ClassicRock = QRadioData::ClassicRock, 119 AdultHits = QRadioData::AdultHits, 120 SoftRock = QRadioData::SoftRock, 121 Top40 = QRadioData::Top40, 122 Soft = QRadioData::Soft, 123 Nostalgia = QRadioData::Nostalgia, 124 Classical = QRadioData::Classical, 125 RhythmAndBlues = QRadioData::RhythmAndBlues, 126 SoftRhythmAndBlues = QRadioData::SoftRhythmAndBlues, 127 Language = QRadioData::Language, 128 ReligiousMusic = QRadioData::ReligiousMusic, 129 ReligiousTalk = QRadioData::ReligiousTalk, 130 Personality = QRadioData::Personality, 131 Public = QRadioData::Public, 132 College = QRadioData::College 133 }; 134 135 enum Availability { 136 Available = QMultimedia::Available, 137 Busy = QMultimedia::Busy, 138 Unavailable = QMultimedia::ServiceMissing, 139 ResourceMissing = QMultimedia::ResourceError 140 }; 141 142 QDeclarativeRadioData(QObject *parent = 0); 143 QDeclarativeRadioData(QRadioTuner *tuner, QObject *parent = 0); 144 ~QDeclarativeRadioData(); 145 146 QString stationId() const; 147 QDeclarativeRadioData::ProgramType programType() const; 148 QString programTypeName() const; 149 QString stationName() const; 150 QString radioText() const; 151 bool alternativeFrequenciesEnabled() const; 152 isAvailable()153 Q_INVOKABLE bool isAvailable() const {return availability() == Available;} 154 Availability availability() const; 155 156 public Q_SLOTS: 157 void setAlternativeFrequenciesEnabled(bool enabled); 158 159 Q_SIGNALS: 160 void stationIdChanged(QString stationId); 161 void programTypeChanged(QDeclarativeRadioData::ProgramType programType); 162 void programTypeNameChanged(QString programTypeName); 163 void stationNameChanged(QString stationName); 164 void radioTextChanged(QString radioText); 165 void alternativeFrequenciesEnabledChanged(bool enabled); 166 167 void availabilityChanged(Availability availability); 168 169 void errorChanged(); 170 void error(QDeclarativeRadioData::Error errorCode); 171 172 private Q_SLOTS: 173 void _q_programTypeChanged(QRadioData::ProgramType programType); 174 void _q_error(QRadioData::Error errorCode); 175 void _q_availabilityChanged(QMultimedia::AvailabilityStatus); 176 177 private: 178 void connectSignals(); 179 180 Q_DISABLE_COPY(QDeclarativeRadioData) 181 182 QRadioData *m_radioData; 183 QRadioTuner *m_radioTuner; 184 }; 185 186 QT_END_NAMESPACE 187 188 QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadioData)) 189 190 #endif // QDECLARATIVERADIODATA_P_H 191