changeset 1479:9bf8aa2916e9 by-id

Further ModelId updates
author Chris Cannam
date Wed, 03 Jul 2019 14:20:42 +0100
parents d39db4673676
children 232262e38051
files view/View.cpp view/ViewManager.cpp view/ViewManager.h widgets/ModelDataTableDialog.cpp widgets/ModelDataTableDialog.h
diffstat 5 files changed, 25 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/view/View.cpp	Wed Jul 03 08:55:02 2019 +0100
+++ b/view/View.cpp	Wed Jul 03 14:20:42 2019 +0100
@@ -1378,7 +1378,7 @@
 {
     if (!m_manager ||
         !m_manager->getAlignMode() ||
-        !m_manager->getPlaybackModel()) {
+        m_manager->getPlaybackModel().isNone()) {
         return {};
     }
 
--- a/view/ViewManager.cpp	Wed Jul 03 08:55:02 2019 +0100
+++ b/view/ViewManager.cpp	Wed Jul 03 14:20:42 2019 +0100
@@ -35,7 +35,6 @@
     m_globalCentreFrame(0),
     m_globalZoom(ZoomLevel::FramesPerPixel, 1024),
     m_playbackFrame(0),
-    m_playbackModel(nullptr),
     m_mainModelSampleRate(0),
     m_lastLeft(0), 
     m_lastRight(0),
@@ -194,14 +193,14 @@
     }
 }
 
-Model *
+ModelId
 ViewManager::getPlaybackModel() const
 {
     return m_playbackModel;
 }
 
 void
-ViewManager::setPlaybackModel(Model *model)
+ViewManager::setPlaybackModel(ModelId model)
 {
     m_playbackModel = model;
 }
@@ -212,10 +211,14 @@
 #ifdef DEBUG_VIEW_MANAGER
     cerr << "ViewManager::alignPlaybackFrameToReference(" << frame << "): playback model is " << m_playbackModel << endl;
 #endif
-    if (!m_playbackModel || !m_alignMode) {
+    if (m_playbackModel.isNone() || !m_alignMode) {
         return frame;
     } else {
-        sv_frame_t f = m_playbackModel->alignToReference(frame);
+        auto playbackModel = ModelById::get(m_playbackModel);
+        if (!playbackModel) {
+            return frame;
+        } 
+        sv_frame_t f = playbackModel->alignToReference(frame);
 #ifdef DEBUG_VIEW_MANAGER
         cerr << "aligned frame = " << f << endl;
 #endif
@@ -229,10 +232,14 @@
 #ifdef DEBUG_VIEW_MANAGER
     cerr << "ViewManager::alignReferenceToPlaybackFrame(" << frame << "): playback model is " << m_playbackModel << endl;
 #endif
-    if (!m_playbackModel || !m_alignMode) {
+    if (m_playbackModel.isNone() || !m_alignMode) {
         return frame;
     } else {
-        sv_frame_t f = m_playbackModel->alignFromReference(frame);
+        auto playbackModel = ModelById::get(m_playbackModel);
+        if (!playbackModel) {
+            return frame;
+        } 
+        sv_frame_t f = playbackModel->alignFromReference(frame);
 #ifdef DEBUG_VIEW_MANAGER
         cerr << "aligned frame = " << f << endl;
 #endif
--- a/view/ViewManager.h	Wed Jul 03 08:55:02 2019 +0100
+++ b/view/ViewManager.h	Wed Jul 03 14:20:42 2019 +0100
@@ -29,6 +29,8 @@
 #include "base/BaseTypes.h"
 #include "base/ZoomLevel.h"
 
+#include "data/model/Model.h"
+
 class AudioPlaySource;
 class AudioRecordTarget;
 class Model;
@@ -93,8 +95,8 @@
     sv_frame_t getPlaybackFrame() const; // the set method is a slot
 
     // Only meaningful in solo mode, and used for optional alignment feature
-    Model *getPlaybackModel() const;
-    void setPlaybackModel(Model *);
+    ModelId getPlaybackModel() const;
+    void setPlaybackModel(ModelId);
 
     sv_frame_t alignPlaybackFrameToReference(sv_frame_t) const override;
     sv_frame_t alignReferenceToPlaybackFrame(sv_frame_t) const override;
@@ -347,7 +349,7 @@
     sv_frame_t m_globalCentreFrame;
     ZoomLevel m_globalZoom;
     mutable sv_frame_t m_playbackFrame;
-    Model *m_playbackModel; //!!!
+    ModelId m_playbackModel;
     sv_samplerate_t m_mainModelSampleRate;
 
     float m_lastLeft;
--- a/widgets/ModelDataTableDialog.cpp	Wed Jul 03 08:55:02 2019 +0100
+++ b/widgets/ModelDataTableDialog.cpp	Wed Jul 03 14:20:42 2019 +0100
@@ -36,7 +36,7 @@
 
 #include <iostream>
 
-ModelDataTableDialog::ModelDataTableDialog(TabularModel *model,
+ModelDataTableDialog::ModelDataTableDialog(ModelId tabularModelId,
                                            QString title, QWidget *parent) :
     QMainWindow(parent),
     m_currentRow(0),
@@ -119,7 +119,7 @@
     m_tableView->setSortingEnabled(true);
     m_tableView->sortByColumn(0, Qt::AscendingOrder);
 
-    m_table = new ModelDataTableModel(model);
+    m_table = new ModelDataTableModel(tabularModelId);
     m_tableView->setModel(m_table);
 
     m_tableView->horizontalHeader()->setStretchLastSection(true);
--- a/widgets/ModelDataTableDialog.h	Wed Jul 03 08:55:02 2019 +0100
+++ b/widgets/ModelDataTableDialog.h	Wed Jul 03 14:20:42 2019 +0100
@@ -20,7 +20,8 @@
 
 #include "base/BaseTypes.h"
 
-class TabularModel;
+#include "data/model/Model.h"
+
 class ModelDataTableModel;
 class QTableView;
 class QModelIndex;
@@ -33,7 +34,7 @@
     Q_OBJECT
     
 public:
-    ModelDataTableDialog(TabularModel *model,
+    ModelDataTableDialog(ModelId tabularModelId,
                          QString title, QWidget *parent =0);
     ~ModelDataTableDialog();