comparison layer/TextLayer.cpp @ 675:3437e0fad7ae imaf_enc

IMAF load code from Jesus Corral Garcia
author Chris Cannam
date Mon, 04 Nov 2013 17:09:36 +0000
parents 4806715f7a19
children c02c51ae5238
comparison
equal deleted inserted replaced
643:77fa3fdbfc7e 675:3437e0fad7ae
125 for (TextModel::PointList::iterator i = points.begin(); 125 for (TextModel::PointList::iterator i = points.begin();
126 i != points.end(); ++i) { 126 i != points.end(); ++i) {
127 127
128 const TextModel::Point &p(*i); 128 const TextModel::Point &p(*i);
129 129
130 int px = v->getXForFrame(p.frame); 130 int px = v->getXForFrame(p.frame);
131 int py = getYForHeight(v, p.height); 131 int py = getYForHeight(v, p.height);
132 132
133 QString label = p.label; 133 QString label = p.label;
134 if (label == "") { 134 if (label == "") {
135 label = tr("<no text>"); 135 label = tr("<no text>");
136 } 136 }
137 137
138 QRect rect = metrics.boundingRect 138 QRect rect = metrics.boundingRect
139 (QRect(0, 0, 150, 200), 139 (QRect(0, 0, 150, 200),
140 Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label); 140 Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label);
141 141
203 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); 203 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate());
204 204
205 QString text; 205 QString text;
206 206
207 if (points.begin()->label == "") { 207 if (points.begin()->label == "") {
208 text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) 208 text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3"))
209 .arg(rt.toText(true).c_str()) 209 .arg(rt.toText(true).c_str())
210 .arg(points.begin()->height) 210 .arg(points.begin()->height)
211 .arg(points.begin()->label); 211 .arg(points.begin()->label);
212 } 212 }
213 213
368 paint.setPen(v->getBackground()); 368 paint.setPen(v->getBackground());
369 } 369 }
370 370
371 QString label = p.label; 371 QString label = p.label;
372 if (label == "") { 372 if (label == "") {
373 label = tr("<no text>"); 373 label = tr("<no text>");
374 } 374 }
375 375
376 QRect boxRect = paint.fontMetrics().boundingRect 376 QRect boxRect = paint.fontMetrics().boundingRect
377 (QRect(0, 0, boxMaxWidth, boxMaxHeight), 377 (QRect(0, 0, boxMaxWidth, boxMaxHeight),
378 Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label); 378 Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label);
451 451
452 m_editingCommand->deletePoint(m_editingPoint); 452 m_editingCommand->deletePoint(m_editingPoint);
453 m_editingPoint.frame = frame; 453 m_editingPoint.frame = frame;
454 m_editingPoint.height = height; 454 m_editingPoint.height = height;
455 m_editingCommand->addPoint(m_editingPoint); 455 m_editingCommand->addPoint(m_editingPoint);
456
457
456 } 458 }
457 459
458 void 460 void
459 TextLayer::drawEnd(View *v, QMouseEvent *) 461 TextLayer::drawEnd(View *v, QMouseEvent *)
460 { 462 {
461 // SVDEBUG << "TextLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; 463 // SVDEBUG << "TextLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl;
462 if (!m_model || !m_editing) return; 464 if (!m_model || !m_editing) return;
463 465
464 bool ok = false; 466 bool ok = false;
465 QString label = QInputDialog::getText(v, tr("Enter label"), 467 QString label = QInputDialog::getText(v, tr("Enter label"),
466 tr("Please enter a new label:"), 468 tr("Please enter a new label:"),
467 QLineEdit::Normal, "", &ok); 469 QLineEdit::Normal, "", &ok);
468 470
469 if (ok) { 471 if (ok) {
470 TextModel::RelabelCommand *command = 472 TextModel::RelabelCommand *command =
471 new TextModel::RelabelCommand(m_model, m_editingPoint, label); 473 new TextModel::RelabelCommand(m_model, m_editingPoint, label);