diff data/model/Model.cpp @ 333:1afaf98dbf11

* Factor out uses of "Sonic Visualiser" in "common" code to applicationName() * Add ability to show work title + artist in top-left of pane (thinking of Vect but may be useful in SV in future) * A few other generalisations useful for Vect
author Chris Cannam
date Fri, 09 Nov 2007 17:46:58 +0000
parents a71dec01c4d3
children 516819f2b97b 6f6ab834449d
line wrap: on
line diff
--- a/data/model/Model.cpp	Wed Nov 07 14:53:12 2007 +0000
+++ b/data/model/Model.cpp	Fri Nov 09 17:46:58 2007 +0000
@@ -56,6 +56,8 @@
     m_sourceModel = model;
 
     if (m_sourceModel) {
+        connect(m_sourceModel, SIGNAL(alignmentCompletionChanged()),
+                this, SIGNAL(alignmentCompletionChanged()));
         connect(m_sourceModel, SIGNAL(aboutToBeDeleted()),
                 this, SLOT(sourceModelAboutToBeDeleted()));
     }
@@ -96,35 +98,64 @@
 const Model *
 Model::getAlignmentReference() const
 {
-    if (!m_alignment) return this;
+    if (!m_alignment) {
+        if (m_sourceModel) return m_sourceModel->getAlignmentReference();
+        return this;
+    }
     return m_alignment->getReferenceModel();
 }
 
 size_t
 Model::alignToReference(size_t frame) const
 {
-    if (!m_alignment) return frame;
-    return m_alignment->toReference(frame);
+    if (!m_alignment) {
+        if (m_sourceModel) return m_sourceModel->alignToReference(frame);
+        else return frame;
+    }
+    size_t refFrame = m_alignment->toReference(frame);
+    //!!! this should be totally wrong, but because alignToReference and
+    // alignFromReference are the wrong way around, it's right... *sigh*
+    if (refFrame > getEndFrame()) refFrame = getEndFrame();
+    return refFrame;
 }
 
 size_t
 Model::alignFromReference(size_t refFrame) const
 {
-    if (!m_alignment) return refFrame;
-    return m_alignment->fromReference(refFrame);
+    if (!m_alignment) {
+        if (m_sourceModel) return m_sourceModel->alignFromReference(refFrame);
+        else return refFrame;
+    }
+    size_t frame = m_alignment->fromReference(refFrame);
+    return frame;
 }
 
 int
 Model::getAlignmentCompletion() const
 {
 //    std::cerr << "Model::getAlignmentCompletion" << std::endl;
-    if (!m_alignment) return 100;
+    if (!m_alignment) {
+        if (m_sourceModel) return m_sourceModel->getAlignmentCompletion();
+        else return 100;
+    }
     int completion = 0;
     (void)m_alignment->isReady(&completion);
 //    std::cerr << " -> " << completion << std::endl;
     return completion;
 }
 
+QString
+Model::getTitle() const
+{
+    if (m_sourceModel) return m_sourceModel->getTitle();
+}
+
+QString
+Model::getMaker() const
+{
+    if (m_sourceModel) return m_sourceModel->getMaker();
+}
+
 void
 Model::toXml(QTextStream &stream, QString indent,
              QString extraAttributes) const