Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/layer/TextLayer.cpp Thu Apr 06 12:12:41 2006 +0000 +++ b/layer/TextLayer.cpp Fri Apr 07 17:50:33 2006 +0000 @@ -651,6 +651,65 @@ command->finish(); } +void +TextLayer::deleteSelection(Selection s) +{ + TextModel::EditCommand *command = + new TextModel::EditCommand(m_model, tr("Delete Selection")); + + TextModel::PointList points = + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + + for (TextModel::PointList::iterator i = points.begin(); + i != points.end(); ++i) { + if (s.contains(i->frame)) command->deletePoint(*i); + } + + command->finish(); +} + +void +TextLayer::copy(Selection s, Clipboard &to) +{ + TextModel::PointList points = + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + + for (TextModel::PointList::iterator i = points.begin(); + i != points.end(); ++i) { + if (s.contains(i->frame)) { + Clipboard::Point point(i->frame, i->height, i->label); + to.addPoint(point); + } + } +} + +void +TextLayer::paste(const Clipboard &from, int frameOffset) +{ + const Clipboard::PointList &points = from.getPoints(); + + TextModel::EditCommand *command = + new TextModel::EditCommand(m_model, tr("Paste")); + + for (Clipboard::PointList::const_iterator i = points.begin(); + i != points.end(); ++i) { + + if (!i->haveFrame()) continue; + size_t frame = 0; + if (frameOffset > 0 || -frameOffset < i->getFrame()) { + frame = i->getFrame() + frameOffset; + } + TextModel::Point newPoint(frame); + if (i->haveValue()) newPoint.height = i->haveValue(); + if (i->haveLabel()) newPoint.label = i->getLabel(); + else newPoint.label = tr("New Point"); + + command->addPoint(newPoint); + } + + command->finish(); +} + QString TextLayer::toXmlString(QString indent, QString extraAttributes) const {