changeset 1480:232262e38051 by-id

Update for changes to PlayParameters
author Chris Cannam
date Thu, 04 Jul 2019 18:04:44 +0100
parents 9bf8aa2916e9
children e540aa5d89cd
files layer/Layer.cpp layer/Layer.h widgets/LayerTree.cpp widgets/PropertyBox.cpp
diffstat 4 files changed, 22 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Layer.cpp	Wed Jul 03 14:20:42 2019 +0100
+++ b/layer/Layer.cpp	Thu Jul 04 18:04:44 2019 +0100
@@ -107,13 +107,11 @@
     emit layerNameChanged();
 }
 
-PlayParameters *
+std::shared_ptr<PlayParameters>
 Layer::getPlayParameters() 
 {
-//    cerr << "Layer (" << this << ", " << objectName() << ")::getPlayParameters: model is "<< getModel() << endl;
     return PlayParameterRepository::getInstance()->getPlayParameters
         (getModel().untyped);
-    return nullptr;
 }
 
 void
--- a/layer/Layer.h	Wed Jul 03 14:20:42 2019 +0100
+++ b/layer/Layer.h	Thu Jul 04 18:04:44 2019 +0100
@@ -411,7 +411,12 @@
      */
     virtual bool isLayerDormant(const LayerGeometryProvider *v) const;
 
-    PlayParameters *getPlayParameters() override;
+    /**
+     * Return the play parameters for this layer, if any. The return
+     * value is a shared_ptr that can be passed to (e.g.)
+     * PlayParameterRepository::EditCommand to change the parameters.
+     */
+    std::shared_ptr<PlayParameters> getPlayParameters() override;
 
     /**
      * True if this layer will need to place text labels when it is
--- a/widgets/LayerTree.cpp	Wed Jul 03 14:20:42 2019 +0100
+++ b/widgets/LayerTree.cpp	Thu Jul 04 18:04:44 2019 +0100
@@ -296,9 +296,9 @@
         for (int j = 0; j < pane->getLayerCount(); ++j) {
             Layer *layer = pane->getLayer(j);
             if (!layer) continue;
-            PlayParameters *params = layer->getPlayParameters();
+            auto params = layer->getPlayParameters();
             if (!params) continue;
-            connect(params, SIGNAL(playAudibleChanged(bool)),
+            connect(params.get(), SIGNAL(playAudibleChanged(bool)),
                     this, SLOT(playParametersAudibilityChanged(bool)));
         }
     }
@@ -378,7 +378,7 @@
         for (int j = 0; j < pane->getLayerCount(); ++j) {
             Layer *layer = pane->getLayer(j);
             if (!layer) continue;
-            if (layer->getPlayParameters() == params) {
+            if (layer->getPlayParameters().get() == params) { // ugh
                 SVDEBUG << "LayerTreeModel::playParametersAudibilityChanged("
                           << params << "," << a << "): row " << pane->getLayerCount() - j - 1 << ", col " << 2 << endl;
 
@@ -434,7 +434,7 @@
                 }
             } else if (col == m_layerPlayedColumn) {
                 if (role == Qt::CheckStateRole) {
-                    PlayParameters *params = layer->getPlayParameters();
+                    auto params = layer->getPlayParameters();
                     if (params) return QVariant(params->isPlayMuted() ?
                                                 Qt::Unchecked : Qt::Checked);
                     else return QVariant();
@@ -475,7 +475,7 @@
         }
     } else if (col == m_layerPlayedColumn) {
         if (role == Qt::CheckStateRole) {
-            PlayParameters *params = layer->getPlayParameters();
+            auto params = layer->getPlayParameters();
             if (params) {
                 params->setPlayMuted(value.toInt() == Qt::Unchecked);
                 emit dataChanged(index, index);
--- a/widgets/PropertyBox.cpp	Wed Jul 03 14:20:42 2019 +0100
+++ b/widgets/PropertyBox.cpp	Thu Jul 04 18:04:44 2019 +0100
@@ -142,7 +142,7 @@
                 this, SLOT(populateViewPlayFrame()));
     }
 
-    PlayParameters *params = m_container->getPlayParameters();
+    auto params = m_container->getPlayParameters();
     if (!params && !layer) return;
 
     m_viewPlayFrame = new QFrame;
@@ -175,7 +175,7 @@
                 this, SLOT(mouseEnteredWidget()));
         connect(m_playButton, SIGNAL(mouseLeft()),
                 this, SLOT(mouseLeftWidget()));
-        connect(params, SIGNAL(playAudibleChanged(bool)),
+        connect(params.get(), SIGNAL(playAudibleChanged(bool)),
                 this, SLOT(playAudibleChanged(bool)));
 
         LevelPanToolButton *levelPan = new LevelPanToolButton;
@@ -186,9 +186,9 @@
                 this, SLOT(playGainControlChanged(float)));
         connect(levelPan, SIGNAL(panChanged(float)),
                 this, SLOT(playPanControlChanged(float)));
-        connect(params, SIGNAL(playGainChanged(float)),
+        connect(params.get(), SIGNAL(playGainChanged(float)),
                 levelPan, SLOT(setLevel(float)));
-        connect(params, SIGNAL(playPanChanged(float)),
+        connect(params.get(), SIGNAL(playPanChanged(float)),
                 levelPan, SLOT(setPan(float)));
         connect(levelPan, SIGNAL(mouseEntered()),
                 this, SLOT(mouseEnteredWidget()));
@@ -674,7 +674,7 @@
 void
 PropertyBox::playAudibleButtonChanged(bool audible)
 {
-    PlayParameters *params = m_container->getPlayParameters();
+    auto params = m_container->getPlayParameters();
     if (!params) return;
 
     if (params->isPlayAudible() != audible) {
@@ -690,7 +690,7 @@
 {
     QObject *obj = sender();
 
-    PlayParameters *params = m_container->getPlayParameters();
+    auto params = m_container->getPlayParameters();
     if (!params) return;
 
     if (params->getPlayGain() != gain) {
@@ -708,7 +708,7 @@
 {
     QObject *obj = sender();
 
-    PlayParameters *params = m_container->getPlayParameters();
+    auto params = m_container->getPlayParameters();
     if (!params) return;
 
     if (params->getPlayPan() != pan) {
@@ -724,7 +724,7 @@
 void
 PropertyBox::editPlayParameters()
 {
-    PlayParameters *params = m_container->getPlayParameters();
+    auto params = m_container->getPlayParameters();
     if (!params) return;
 
     QString clip = params->getPlayClipId();
@@ -774,7 +774,7 @@
 void
 PropertyBox::playClipChanged(QString id)
 {
-    PlayParameters *params = m_container->getPlayParameters();
+    auto params = m_container->getPlayParameters();
     if (!params) return;
 
     params->setPlayClipId(id);
@@ -823,7 +823,7 @@
 
     } else if (wname == "playParamButton") {
  
-        PlayParameters *params = m_container->getPlayParameters();
+        auto params = m_container->getPlayParameters();
         if (params) {
             help = tr("Change sound used for playback (currently \"%1\")")
                 .arg(params->getPlayClipId());