comparison widgets/Pane.cpp @ 51:d2eac322d71b

* Tidying and bug fixes in document stuff and file load/save * Add list of layer names (and source model names where appropriate) to pane
author Chris Cannam
date Fri, 10 Mar 2006 17:37:45 +0000
parents 75cfbc6e709b
children 128ebfeeebee
comparison
equal deleted inserted replaced
50:75cfbc6e709b 51:d2eac322d71b
131 if (e) { 131 if (e) {
132 paint.setClipRect(r); 132 paint.setClipRect(r);
133 } 133 }
134 134
135 const Model *waveformModel = 0; // just for reporting purposes 135 const Model *waveformModel = 0; // just for reporting purposes
136 int verticalScaleWidth = 0;
136 137
137 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { 138 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
138 --vi; 139 --vi;
139 140
140 if (dynamic_cast<WaveformLayer *>(*vi)) { 141 if (dynamic_cast<WaveformLayer *>(*vi)) {
141 waveformModel = (*vi)->getModel(); 142 waveformModel = (*vi)->getModel();
142 } 143 }
143 144
144 int sw = (*vi)->getVerticalScaleWidth(this, paint); 145 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
145 146
146 if (sw > 0 && r.left() < sw) { 147 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
147 148
148 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); 149 // Profiler profiler("Pane::paintEvent - painting vertical scale", true);
149 150
150 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl; 151 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl;
151 paint.save(); 152 paint.save();
152 153
153 paint.setPen(Qt::black); 154 paint.setPen(Qt::black);
154 paint.setBrush(Qt::white); 155 paint.setBrush(Qt::white);
155 paint.drawRect(0, 0, sw, height()); 156 paint.drawRect(0, 0, verticalScaleWidth, height());
156 157
157 paint.setBrush(Qt::NoBrush); 158 paint.setBrush(Qt::NoBrush);
158 (*vi)->paintVerticalScale(this, paint, QRect(0, 0, sw, height())); 159 (*vi)->paintVerticalScale
160 (this, paint, QRect(0, 0, verticalScaleWidth, height()));
159 161
160 paint.restore(); 162 paint.restore();
161 } 163 }
162 164
163 if (m_identifyFeatures) { 165 if (m_identifyFeatures) {
311 // from that of the main model. 313 // from that of the main model.
312 314
313 if (sampleRate == mainModelRate) { 315 if (sampleRate == mainModelRate) {
314 if (sampleRate != playbackRate) srNote = " " + tr("(R)"); 316 if (sampleRate != playbackRate) srNote = " " + tr("(R)");
315 } else { 317 } else {
318 std::cerr << "Sample rate = " << sampleRate << ", main model rate = " << mainModelRate << std::endl;
316 srNote = " " + tr("(X)"); 319 srNote = " " + tr("(X)");
317 } 320 }
318 321
319 QString desc = tr("%1 / %2Hz%3") 322 QString desc = tr("%1 / %2Hz%3")
320 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(), 323 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(),
321 sampleRate) 324 sampleRate)
322 .toText(false).c_str()) 325 .toText(false).c_str())
323 .arg(sampleRate) 326 .arg(sampleRate)
324 .arg(srNote); 327 .arg(srNote);
325 328
326 paint.drawText(width() - paint.fontMetrics().width(desc) - 5, 329 paint.drawText(verticalScaleWidth + 5,
330 //width() - paint.fontMetrics().width(desc) - 5,
327 height() - paint.fontMetrics().height() + 331 height() - paint.fontMetrics().height() +
328 paint.fontMetrics().ascent() - 6, 332 paint.fontMetrics().ascent() - 6,
329 desc); 333 desc);
334 }
335
336 std::vector<QString> texts;
337 int maxTextWidth = 0;
338
339 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
340
341 QString layerName = (*i)->objectName();
342 QString modelName;
343 if ((*i)->getModel()) modelName = (*i)->getModel()->objectName();
344
345 QString text;
346 if (modelName != "") {
347 text = QString("%1: %2").arg(modelName).arg(layerName);
348 } else {
349 text = layerName;
350 }
351
352 texts.push_back(text);
353 int tw = paint.fontMetrics().width(text);
354 if (tw > maxTextWidth) maxTextWidth = tw;
355 }
356
357 int lly = height() - 6;
358
359 for (int i = 0; i < texts.size(); ++i) {
360
361 if (i == texts.size() - 1) {
362 if (m_lightBackground) {
363 paint.setPen(Qt::black);
364 } else {
365 paint.setPen(Qt::white);
366 }
367 }
368
369 paint.drawText(width() - maxTextWidth - 5,
370 lly - paint.fontMetrics().height() +
371 paint.fontMetrics().ascent(),
372 texts[i]);
373
374 lly -= paint.fontMetrics().height();
330 } 375 }
331 } 376 }
332 377
333 if (m_clickedInRange && m_shiftPressed) { 378 if (m_clickedInRange && m_shiftPressed) {
334 if (m_manager && (m_manager->getToolMode() == ViewManager::NavigateMode)) { 379 if (m_manager && (m_manager->getToolMode() == ViewManager::NavigateMode)) {