comparison layer/NoteLayer.cpp @ 125:999ae0f7d10c

* Change preferences dialog to ok/apply/cancel model * Make preferences persist in a config file * Change instance() to getInstance() for all singleton types * Make pasting to time-value layer with no values in clipboard ask you how to generate the values * Fix bad behaviour caused by importing "data"-type (i.e. 3d dense) model from annotation file without a fixed window size available
author Chris Cannam
date Thu, 27 Jul 2006 16:06:32 +0000
parents bd6e85b3d88b
children 33929e0c3c6b
comparison
equal deleted inserted replaced
124:bd6e85b3d88b 125:999ae0f7d10c
922 to.addPoint(point); 922 to.addPoint(point);
923 } 923 }
924 } 924 }
925 } 925 }
926 926
927 void 927 bool
928 NoteLayer::paste(const Clipboard &from, int frameOffset) 928 NoteLayer::paste(const Clipboard &from, int frameOffset, bool interactive)
929 { 929 {
930 if (!m_model) return; 930 if (!m_model) return false;
931 931
932 const Clipboard::PointList &points = from.getPoints(); 932 const Clipboard::PointList &points = from.getPoints();
933 933
934 NoteModel::EditCommand *command = 934 NoteModel::EditCommand *command =
935 new NoteModel::EditCommand(m_model, tr("Paste")); 935 new NoteModel::EditCommand(m_model, tr("Paste"));
947 if (i->haveLabel()) newPoint.label = i->getLabel(); 947 if (i->haveLabel()) newPoint.label = i->getLabel();
948 if (i->haveValue()) newPoint.value = i->getValue(); 948 if (i->haveValue()) newPoint.value = i->getValue();
949 else newPoint.value = (m_model->getValueMinimum() + 949 else newPoint.value = (m_model->getValueMinimum() +
950 m_model->getValueMaximum()) / 2; 950 m_model->getValueMaximum()) / 2;
951 if (i->haveDuration()) newPoint.duration = i->getDuration(); 951 if (i->haveDuration()) newPoint.duration = i->getDuration();
952 else newPoint.duration = m_model->getResolution(); //!!! 952 else {
953 size_t nextFrame = frame;
954 Clipboard::PointList::const_iterator j = i;
955 for (; j != points.end(); ++j) {
956 if (!j->haveFrame()) continue;
957 if (j != i) break;
958 }
959 if (j != points.end()) {
960 nextFrame = j->getFrame();
961 }
962 if (nextFrame == frame) {
963 newPoint.duration = m_model->getResolution();
964 } else {
965 newPoint.duration = nextFrame - frame;
966 }
967 }
953 968
954 command->addPoint(newPoint); 969 command->addPoint(newPoint);
955 } 970 }
956 971
957 command->finish(); 972 command->finish();
973 return true;
958 } 974 }
959 975
960 QString 976 QString
961 NoteLayer::toXmlString(QString indent, QString extraAttributes) const 977 NoteLayer::toXmlString(QString indent, QString extraAttributes) const
962 { 978 {