Mercurial > hg > svgui
comparison layer/TextLayer.cpp @ 360:d58701996fae
* Update remaining editable layers to support proper realignment on copy/paste
* Permit pasting when no suitable layer is current: create a new layer on paste
* Add preference for showing the splash screen or not
* Rename spectrogram smoothing prefs (partly following Craig's suggestions)
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 14:15:09 +0000 |
parents | 020c485aa7e0 |
children | e1a9e478b7f2 |
comparison
equal
deleted
inserted
replaced
359:020c485aa7e0 | 360:d58701996fae |
---|---|
25 | 25 |
26 #include <QPainter> | 26 #include <QPainter> |
27 #include <QMouseEvent> | 27 #include <QMouseEvent> |
28 #include <QInputDialog> | 28 #include <QInputDialog> |
29 #include <QTextStream> | 29 #include <QTextStream> |
30 #include <QMessageBox> | |
30 | 31 |
31 #include <iostream> | 32 #include <iostream> |
32 #include <cmath> | 33 #include <cmath> |
33 | 34 |
34 TextLayer::TextLayer() : | 35 TextLayer::TextLayer() : |
680 | 681 |
681 for (TextModel::PointList::iterator i = points.begin(); | 682 for (TextModel::PointList::iterator i = points.begin(); |
682 i != points.end(); ++i) { | 683 i != points.end(); ++i) { |
683 if (s.contains(i->frame)) { | 684 if (s.contains(i->frame)) { |
684 Clipboard::Point point(i->frame, i->height, i->label); | 685 Clipboard::Point point(i->frame, i->height, i->label); |
685 point.setReferenceFrame(m_model->alignToReference(i->frame)); | 686 point.setReferenceFrame(alignToReference(v, i->frame)); |
686 to.addPoint(point); | 687 to.addPoint(point); |
687 } | 688 } |
688 } | 689 } |
689 } | 690 } |
690 | 691 |
692 TextLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) | 693 TextLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) |
693 { | 694 { |
694 if (!m_model) return false; | 695 if (!m_model) return false; |
695 | 696 |
696 const Clipboard::PointList &points = from.getPoints(); | 697 const Clipboard::PointList &points = from.getPoints(); |
698 | |
699 bool realign = false; | |
700 | |
701 if (clipboardHasDifferentAlignment(v, from)) { | |
702 | |
703 QMessageBox::StandardButton button = | |
704 QMessageBox::question(v, tr("Re-align pasted items?"), | |
705 tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), | |
706 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, | |
707 QMessageBox::Yes); | |
708 | |
709 if (button == QMessageBox::Cancel) { | |
710 return false; | |
711 } | |
712 | |
713 if (button == QMessageBox::Yes) { | |
714 realign = true; | |
715 } | |
716 } | |
697 | 717 |
698 TextModel::EditCommand *command = | 718 TextModel::EditCommand *command = |
699 new TextModel::EditCommand(m_model, tr("Paste")); | 719 new TextModel::EditCommand(m_model, tr("Paste")); |
700 | 720 |
701 float valueMin = 0.0, valueMax = 1.0; | 721 float valueMin = 0.0, valueMax = 1.0; |
711 for (Clipboard::PointList::const_iterator i = points.begin(); | 731 for (Clipboard::PointList::const_iterator i = points.begin(); |
712 i != points.end(); ++i) { | 732 i != points.end(); ++i) { |
713 | 733 |
714 if (!i->haveFrame()) continue; | 734 if (!i->haveFrame()) continue; |
715 size_t frame = 0; | 735 size_t frame = 0; |
716 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | 736 |
717 frame = i->getFrame() + frameOffset; | 737 if (!realign) { |
738 | |
739 frame = i->getFrame(); | |
740 | |
741 } else { | |
742 | |
743 if (i->haveReferenceFrame()) { | |
744 frame = i->getReferenceFrame(); | |
745 frame = alignFromReference(v, frame); | |
746 } else { | |
747 frame = i->getFrame(); | |
748 } | |
718 } | 749 } |
750 | |
719 TextModel::Point newPoint(frame); | 751 TextModel::Point newPoint(frame); |
720 | 752 |
721 if (i->haveValue()) { | 753 if (i->haveValue()) { |
722 newPoint.height = (i->getValue() - valueMin) / (valueMax - valueMin); | 754 newPoint.height = (i->getValue() - valueMin) / (valueMax - valueMin); |
723 } else { | 755 } else { |