Mercurial > hg > svgui
comparison layer/NoteLayer.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 | bf306158803d |
children | 19bf27e4fb29 |
comparison
equal
deleted
inserted
replaced
75:dfdbf336bb37 | 76:45ba0b381c5d |
---|---|
725 } | 725 } |
726 | 726 |
727 command->finish(); | 727 command->finish(); |
728 } | 728 } |
729 | 729 |
730 void | |
731 NoteLayer::deleteSelection(Selection s) | |
732 { | |
733 NoteModel::EditCommand *command = | |
734 new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); | |
735 | |
736 NoteModel::PointList points = | |
737 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
738 | |
739 for (NoteModel::PointList::iterator i = points.begin(); | |
740 i != points.end(); ++i) { | |
741 | |
742 if (s.contains(i->frame)) { | |
743 command->deletePoint(*i); | |
744 } | |
745 } | |
746 | |
747 command->finish(); | |
748 } | |
749 | |
750 void | |
751 NoteLayer::copy(Selection s, Clipboard &to) | |
752 { | |
753 NoteModel::PointList points = | |
754 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
755 | |
756 for (NoteModel::PointList::iterator i = points.begin(); | |
757 i != points.end(); ++i) { | |
758 if (s.contains(i->frame)) { | |
759 Clipboard::Point point(i->frame, i->label); | |
760 to.addPoint(point); | |
761 } | |
762 } | |
763 } | |
764 | |
765 void | |
766 NoteLayer::paste(const Clipboard &from, int frameOffset) | |
767 { | |
768 const Clipboard::PointList &points = from.getPoints(); | |
769 | |
770 NoteModel::EditCommand *command = | |
771 new NoteModel::EditCommand(m_model, tr("Paste")); | |
772 | |
773 for (Clipboard::PointList::const_iterator i = points.begin(); | |
774 i != points.end(); ++i) { | |
775 | |
776 if (!i->haveFrame()) continue; | |
777 size_t frame = 0; | |
778 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | |
779 frame = i->getFrame() + frameOffset; | |
780 } | |
781 NoteModel::Point newPoint(frame); | |
782 | |
783 if (i->haveLabel()) newPoint.label = i->getLabel(); | |
784 if (i->haveValue()) newPoint.value = i->getValue(); | |
785 else newPoint.value = (m_model->getValueMinimum() + | |
786 m_model->getValueMaximum()) / 2; | |
787 if (i->haveDuration()) newPoint.duration = i->getDuration(); | |
788 else newPoint.duration = m_model->getResolution(); //!!! | |
789 | |
790 command->addPoint(newPoint); | |
791 } | |
792 | |
793 command->finish(); | |
794 } | |
795 | |
730 QString | 796 QString |
731 NoteLayer::toXmlString(QString indent, QString extraAttributes) const | 797 NoteLayer::toXmlString(QString indent, QString extraAttributes) const |
732 { | 798 { |
733 return Layer::toXmlString(indent, extraAttributes + | 799 return Layer::toXmlString(indent, extraAttributes + |
734 QString(" colour=\"%1\" verticalScale=\"%2\"") | 800 QString(" colour=\"%1\" verticalScale=\"%2\"") |