Mercurial > hg > svgui
comparison layer/TextLayer.cpp @ 76:45ba0b381c5d
* Fix long-standing off-by-1 bug in WaveFileModel that was getting us the wrong
values for almost all audio data when merging channels (channel == -1)
* Implement cut, copy and paste
* Make draw mode work properly in time value layer
* Minor fixes to CSV import
author | Chris Cannam |
---|---|
date | Fri, 07 Apr 2006 17:50:33 +0000 |
parents | 705f05ab42e3 |
children | 19bf27e4fb29 |
comparison
equal
deleted
inserted
replaced
75:dfdbf336bb37 | 76:45ba0b381c5d |
---|---|
649 } | 649 } |
650 | 650 |
651 command->finish(); | 651 command->finish(); |
652 } | 652 } |
653 | 653 |
654 void | |
655 TextLayer::deleteSelection(Selection s) | |
656 { | |
657 TextModel::EditCommand *command = | |
658 new TextModel::EditCommand(m_model, tr("Delete Selection")); | |
659 | |
660 TextModel::PointList points = | |
661 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
662 | |
663 for (TextModel::PointList::iterator i = points.begin(); | |
664 i != points.end(); ++i) { | |
665 if (s.contains(i->frame)) command->deletePoint(*i); | |
666 } | |
667 | |
668 command->finish(); | |
669 } | |
670 | |
671 void | |
672 TextLayer::copy(Selection s, Clipboard &to) | |
673 { | |
674 TextModel::PointList points = | |
675 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
676 | |
677 for (TextModel::PointList::iterator i = points.begin(); | |
678 i != points.end(); ++i) { | |
679 if (s.contains(i->frame)) { | |
680 Clipboard::Point point(i->frame, i->height, i->label); | |
681 to.addPoint(point); | |
682 } | |
683 } | |
684 } | |
685 | |
686 void | |
687 TextLayer::paste(const Clipboard &from, int frameOffset) | |
688 { | |
689 const Clipboard::PointList &points = from.getPoints(); | |
690 | |
691 TextModel::EditCommand *command = | |
692 new TextModel::EditCommand(m_model, tr("Paste")); | |
693 | |
694 for (Clipboard::PointList::const_iterator i = points.begin(); | |
695 i != points.end(); ++i) { | |
696 | |
697 if (!i->haveFrame()) continue; | |
698 size_t frame = 0; | |
699 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | |
700 frame = i->getFrame() + frameOffset; | |
701 } | |
702 TextModel::Point newPoint(frame); | |
703 if (i->haveValue()) newPoint.height = i->haveValue(); | |
704 if (i->haveLabel()) newPoint.label = i->getLabel(); | |
705 else newPoint.label = tr("New Point"); | |
706 | |
707 command->addPoint(newPoint); | |
708 } | |
709 | |
710 command->finish(); | |
711 } | |
712 | |
654 QString | 713 QString |
655 TextLayer::toXmlString(QString indent, QString extraAttributes) const | 714 TextLayer::toXmlString(QString indent, QString extraAttributes) const |
656 { | 715 { |
657 return Layer::toXmlString(indent, extraAttributes + | 716 return Layer::toXmlString(indent, extraAttributes + |
658 QString(" colour=\"%1\"") | 717 QString(" colour=\"%1\"") |