comparison layer/TextLayer.cpp @ 99:453f7da3534e

* Fix serious failure to reload "imported" (i.e. all non-derived non-main) models from .sv file * Give a short playback duration to notes with formal duration of 0 or 1 * Show crosshairs on spectrogram even when there is another layer on top (if it isn't opaque) * Always paste to the same time in the layer as the cut/copy was from, rather than to the playback pointer -- less flexible, but more predictable and less annoying. We probably need a way to get the old behaviour if pasting from somewhere else in the future (e.g. from a text file), but we can't do that yet anyway * Use a compound operation for dragging and resizing selections, so as to ensure a single undo operation works * Use a note model as the target for feature extraction plugins that output variable samplerate data with more than one value per feature * Avoid possible crashes in cut/paste if a layer proves to have no model
author Chris Cannam
date Thu, 11 May 2006 11:35:46 +0000
parents 05c41701dc6c
children 0f36cdf407a6
comparison
equal deleted inserted replaced
98:2be85befe873 99:453f7da3534e
603 tr("Please enter a new label:"), 603 tr("Please enter a new label:"),
604 QLineEdit::Normal, label, &ok); 604 QLineEdit::Normal, label, &ok);
605 if (ok && label != points.begin()->label) { 605 if (ok && label != points.begin()->label) {
606 TextModel::RelabelCommand *command = 606 TextModel::RelabelCommand *command =
607 new TextModel::RelabelCommand(m_model, *points.begin(), label); 607 new TextModel::RelabelCommand(m_model, *points.begin(), label);
608 CommandHistory::getInstance()->addCommand(command, true); 608 CommandHistory::getInstance()->addCommand(command);
609 } 609 }
610 } 610 }
611 611
612 void 612 void
613 TextLayer::moveSelection(Selection s, size_t newStartFrame) 613 TextLayer::moveSelection(Selection s, size_t newStartFrame)
614 { 614 {
615 if (!m_model) return;
616
615 TextModel::EditCommand *command = 617 TextModel::EditCommand *command =
616 new TextModel::EditCommand(m_model, tr("Drag Selection")); 618 new TextModel::EditCommand(m_model, tr("Drag Selection"));
617 619
618 TextModel::PointList points = 620 TextModel::PointList points =
619 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 621 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
633 } 635 }
634 636
635 void 637 void
636 TextLayer::resizeSelection(Selection s, Selection newSize) 638 TextLayer::resizeSelection(Selection s, Selection newSize)
637 { 639 {
640 if (!m_model) return;
641
638 TextModel::EditCommand *command = 642 TextModel::EditCommand *command =
639 new TextModel::EditCommand(m_model, tr("Resize Selection")); 643 new TextModel::EditCommand(m_model, tr("Resize Selection"));
640 644
641 TextModel::PointList points = 645 TextModel::PointList points =
642 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 646 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
665 } 669 }
666 670
667 void 671 void
668 TextLayer::deleteSelection(Selection s) 672 TextLayer::deleteSelection(Selection s)
669 { 673 {
674 if (!m_model) return;
675
670 TextModel::EditCommand *command = 676 TextModel::EditCommand *command =
671 new TextModel::EditCommand(m_model, tr("Delete Selection")); 677 new TextModel::EditCommand(m_model, tr("Delete Selection"));
672 678
673 TextModel::PointList points = 679 TextModel::PointList points =
674 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 680 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
682 } 688 }
683 689
684 void 690 void
685 TextLayer::copy(Selection s, Clipboard &to) 691 TextLayer::copy(Selection s, Clipboard &to)
686 { 692 {
693 if (!m_model) return;
694
687 TextModel::PointList points = 695 TextModel::PointList points =
688 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 696 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
689 697
690 for (TextModel::PointList::iterator i = points.begin(); 698 for (TextModel::PointList::iterator i = points.begin();
691 i != points.end(); ++i) { 699 i != points.end(); ++i) {
697 } 705 }
698 706
699 void 707 void
700 TextLayer::paste(const Clipboard &from, int frameOffset) 708 TextLayer::paste(const Clipboard &from, int frameOffset)
701 { 709 {
710 if (!m_model) return;
711
702 const Clipboard::PointList &points = from.getPoints(); 712 const Clipboard::PointList &points = from.getPoints();
703 713
704 TextModel::EditCommand *command = 714 TextModel::EditCommand *command =
705 new TextModel::EditCommand(m_model, tr("Paste")); 715 new TextModel::EditCommand(m_model, tr("Paste"));
706 716