summaryrefslogtreecommitdiffstats
path: root/src/imports/audioengine/qdeclarative_audiocategory_p.cpp
diff options
context:
space:
mode:
authorSiteshwar Vashisht <siteshwar@gmail.com>2015-03-25 19:43:19 +0530
committerKonstantin Ritt <ritt.ks@gmail.com>2015-04-23 11:56:18 +0000
commit176d52bb28b425f697ad8df001ba2c7c52fda766 (patch)
treeffc4740404f9537bcef939acddb25c2cce4f7203 /src/imports/audioengine/qdeclarative_audiocategory_p.cpp
parent227c8aa723d9e82c2826a1d2823cd73236f18bbb (diff)
Refactored code for audio engine to allow dynamic object creation
QDeclarativeSound, QDeclarativeAudioSample, QDeclarativeAudioCategory and QDeclarativeAttenuationModel can now be dynamically added to AudioEngine instance or declared inside AudioEngine object definition. QDeclarativePlayVariation can now be dynamically added to Sound instance or declared inside Sound object definition. Change-Id: If4c2e16895a71eb71ded1998c107360698f8ac7f Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/imports/audioengine/qdeclarative_audiocategory_p.cpp')
-rw-r--r--src/imports/audioengine/qdeclarative_audiocategory_p.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/imports/audioengine/qdeclarative_audiocategory_p.cpp b/src/imports/audioengine/qdeclarative_audiocategory_p.cpp
index df1a3cec9..847941ca9 100644
--- a/src/imports/audioengine/qdeclarative_audiocategory_p.cpp
+++ b/src/imports/audioengine/qdeclarative_audiocategory_p.cpp
@@ -51,7 +51,9 @@ QT_USE_NAMESPACE
This type is part of the \b{QtAudioEngine 1.0} module.
An instance of AudioCategory can be accessed through \l {QtAudioEngine::AudioEngine::categories}
- {AudioEngine.categories} with its unique name and must be defined inside AudioEngine.
+ {AudioEngine.categories} with its unique name and must be defined inside AudioEngine or be added
+ to it using \l{QtAudioEngine::AudioEngine::addAudioCategory()}{AudioEngine.addAudioCategory()} if
+ AudioCategory is created dynamically.
\qml
import QtQuick 2.0
@@ -103,8 +105,8 @@ QT_USE_NAMESPACE
*/
QDeclarativeAudioCategory::QDeclarativeAudioCategory(QObject *parent)
: QObject(parent)
- , m_complete(false)
, m_volume(1)
+ , m_engine(0)
{
}
@@ -112,21 +114,9 @@ QDeclarativeAudioCategory::~QDeclarativeAudioCategory()
{
}
-void QDeclarativeAudioCategory::classBegin()
+void QDeclarativeAudioCategory::setEngine(QDeclarativeAudioEngine *engine)
{
- if (!parent() || !parent()->inherits("QDeclarativeAudioEngine")) {
- qWarning("AudioCategory must be defined inside AudioEngine!");
- return;
- }
-}
-
-void QDeclarativeAudioCategory::componentComplete()
-{
- if (m_name.isEmpty()) {
- qWarning("AudioCategory must have a name!");
- return;
- }
- m_complete = true;
+ m_engine = engine;
}
/*!
@@ -159,7 +149,7 @@ void QDeclarativeAudioCategory::setVolume(qreal volume)
*/
void QDeclarativeAudioCategory::setName(const QString& name)
{
- if (m_complete) {
+ if (m_engine) {
qWarning("AudioCategory: you can not change name after initialization.");
return;
}