annotate base/Layer.cpp @ 16:cc98d496d52b

* Add command history class, and basic undo/redo menus. No actual commands to undo/redo yet. Selecting the placeholders sometimes seems to cause a crash, so this looks a little uncertain so far. * Add Rename Layer * Remove models from playback when their layers are removed (and ref counts hit zero) * Don't hang around waiting so much when there's work to be done in the audio buffer fill thread * Put more sensible names on layers generated from transforms * Add basic editing to time-value layer like existing editing in time-instants layer, and make both of them snap to the appropriate resolution during drag
author Chris Cannam
date Mon, 30 Jan 2006 17:51:56 +0000
parents 47500c27ac26
children 4b16526b011b
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 A waveform viewer and audio annotation editor.
Chris@2 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@0 6
Chris@0 7 This is experimental software. Not for distribution.
Chris@0 8 */
Chris@0 9
Chris@0 10 #include "Layer.h"
Chris@0 11 #include "View.h"
Chris@0 12
Chris@0 13 #include <iostream>
Chris@0 14
Chris@3 15 #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ?
Chris@3 16
Chris@0 17 Layer::Layer(View *w)
Chris@0 18 {
Chris@0 19 m_view = w;
Chris@0 20
Chris@0 21 // Subclass must call this:
Chris@0 22 // w->addLayer(this);
Chris@0 23 }
Chris@0 24
Chris@0 25 Layer::~Layer()
Chris@0 26 {
Chris@0 27 m_view->removeLayer(this);
Chris@0 28 }
Chris@0 29
Chris@12 30 QString
Chris@12 31 Layer::getPropertyContainerIconName() const
Chris@12 32 {
Chris@12 33 return LayerFactory::instance()->getLayerIconName
Chris@12 34 (LayerFactory::instance()->getLayerType(this));
Chris@12 35 }
Chris@12 36
Chris@0 37 void
Chris@0 38 Layer::setObjectName(const QString &name)
Chris@0 39 {
Chris@0 40 QObject::setObjectName(name);
Chris@0 41 emit layerNameChanged();
Chris@0 42 }
Chris@0 43
Chris@15 44 int
Chris@15 45 Layer::getXForFrame(long frame) const
Chris@15 46 {
Chris@15 47 if (m_view) return m_view->getXForFrame(frame);
Chris@15 48 else return 0;
Chris@15 49 }
Chris@15 50
Chris@15 51 long
Chris@15 52 Layer::getFrameForX(int x) const
Chris@15 53 {
Chris@15 54 if (m_view) return m_view->getFrameForX(x);
Chris@15 55 else return 0;
Chris@15 56 }
Chris@15 57
Chris@3 58 QString
Chris@3 59 Layer::toXmlString(QString indent, QString extraAttributes) const
Chris@3 60 {
Chris@3 61 QString s;
Chris@3 62
Chris@3 63 s += indent;
Chris@3 64
Chris@6 65 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n")
Chris@3 66 .arg(LayerFactory::instance()->getLayerTypeName
Chris@3 67 (LayerFactory::instance()->getLayerType(this)))
Chris@4 68 .arg(getObjectExportId(this))
Chris@3 69 .arg(objectName())
Chris@4 70 .arg(getObjectExportId(getModel()))
Chris@3 71 .arg(extraAttributes);
Chris@3 72
Chris@3 73 return s;
Chris@3 74 }
Chris@0 75
Chris@0 76 #ifdef INCLUDE_MOCFILES
Chris@0 77 #include "Layer.moc.cpp"
Chris@0 78 #endif
Chris@0 79