comparison 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
comparison
equal deleted inserted replaced
332:13e5870040e6 333:1afaf98dbf11
54 } 54 }
55 55
56 m_sourceModel = model; 56 m_sourceModel = model;
57 57
58 if (m_sourceModel) { 58 if (m_sourceModel) {
59 connect(m_sourceModel, SIGNAL(alignmentCompletionChanged()),
60 this, SIGNAL(alignmentCompletionChanged()));
59 connect(m_sourceModel, SIGNAL(aboutToBeDeleted()), 61 connect(m_sourceModel, SIGNAL(aboutToBeDeleted()),
60 this, SLOT(sourceModelAboutToBeDeleted())); 62 this, SLOT(sourceModelAboutToBeDeleted()));
61 } 63 }
62 } 64 }
63 65
94 } 96 }
95 97
96 const Model * 98 const Model *
97 Model::getAlignmentReference() const 99 Model::getAlignmentReference() const
98 { 100 {
99 if (!m_alignment) return this; 101 if (!m_alignment) {
102 if (m_sourceModel) return m_sourceModel->getAlignmentReference();
103 return this;
104 }
100 return m_alignment->getReferenceModel(); 105 return m_alignment->getReferenceModel();
101 } 106 }
102 107
103 size_t 108 size_t
104 Model::alignToReference(size_t frame) const 109 Model::alignToReference(size_t frame) const
105 { 110 {
106 if (!m_alignment) return frame; 111 if (!m_alignment) {
107 return m_alignment->toReference(frame); 112 if (m_sourceModel) return m_sourceModel->alignToReference(frame);
113 else return frame;
114 }
115 size_t refFrame = m_alignment->toReference(frame);
116 //!!! this should be totally wrong, but because alignToReference and
117 // alignFromReference are the wrong way around, it's right... *sigh*
118 if (refFrame > getEndFrame()) refFrame = getEndFrame();
119 return refFrame;
108 } 120 }
109 121
110 size_t 122 size_t
111 Model::alignFromReference(size_t refFrame) const 123 Model::alignFromReference(size_t refFrame) const
112 { 124 {
113 if (!m_alignment) return refFrame; 125 if (!m_alignment) {
114 return m_alignment->fromReference(refFrame); 126 if (m_sourceModel) return m_sourceModel->alignFromReference(refFrame);
127 else return refFrame;
128 }
129 size_t frame = m_alignment->fromReference(refFrame);
130 return frame;
115 } 131 }
116 132
117 int 133 int
118 Model::getAlignmentCompletion() const 134 Model::getAlignmentCompletion() const
119 { 135 {
120 // std::cerr << "Model::getAlignmentCompletion" << std::endl; 136 // std::cerr << "Model::getAlignmentCompletion" << std::endl;
121 if (!m_alignment) return 100; 137 if (!m_alignment) {
138 if (m_sourceModel) return m_sourceModel->getAlignmentCompletion();
139 else return 100;
140 }
122 int completion = 0; 141 int completion = 0;
123 (void)m_alignment->isReady(&completion); 142 (void)m_alignment->isReady(&completion);
124 // std::cerr << " -> " << completion << std::endl; 143 // std::cerr << " -> " << completion << std::endl;
125 return completion; 144 return completion;
145 }
146
147 QString
148 Model::getTitle() const
149 {
150 if (m_sourceModel) return m_sourceModel->getTitle();
151 }
152
153 QString
154 Model::getMaker() const
155 {
156 if (m_sourceModel) return m_sourceModel->getMaker();
126 } 157 }
127 158
128 void 159 void
129 Model::toXml(QTextStream &stream, QString indent, 160 Model::toXml(QTextStream &stream, QString indent,
130 QString extraAttributes) const 161 QString extraAttributes) const