Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@52: Sonic Visualiser Chris@52: An audio file viewer and annotation editor. Chris@52: Centre for Digital Music, Queen Mary, University of London. Chris@52: This file copyright 2006 Chris Cannam. Chris@0: Chris@52: This program is free software; you can redistribute it and/or Chris@52: modify it under the terms of the GNU General Public License as Chris@52: published by the Free Software Foundation; either version 2 of the Chris@52: License, or (at your option) any later version. See the file Chris@52: COPYING included with this distribution for more information. Chris@0: */ Chris@0: Chris@0: #include "Layer.h" Chris@0: #include "View.h" Chris@47: #include "Model.h" Chris@0: Chris@0: #include Chris@0: Chris@3: #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ? Chris@28: #include "PlayParameterRepository.h" Chris@3: Chris@39: Layer::Layer() Chris@0: { Chris@0: } Chris@0: Chris@0: Layer::~Layer() Chris@0: { Chris@117: // std::cerr << "Layer::~Layer(" << this << ")" << std::endl; Chris@0: } Chris@0: Chris@12: QString Chris@12: Layer::getPropertyContainerIconName() const Chris@12: { Chris@12: return LayerFactory::instance()->getLayerIconName Chris@12: (LayerFactory::instance()->getLayerType(this)); Chris@12: } Chris@12: Chris@47: QString Chris@47: Layer::getLayerPresentationName() const Chris@47: { Chris@47: QString layerName = objectName(); Chris@47: QString modelName; Chris@47: if (getModel()) modelName = getModel()->objectName(); Chris@47: Chris@47: QString text; Chris@47: if (modelName != "") { Chris@47: text = QString("%1: %2").arg(modelName).arg(layerName); Chris@47: } else { Chris@47: text = layerName; Chris@47: } Chris@47: Chris@47: return text; Chris@47: } Chris@47: Chris@0: void Chris@0: Layer::setObjectName(const QString &name) Chris@0: { Chris@0: QObject::setObjectName(name); Chris@0: emit layerNameChanged(); Chris@0: } Chris@15: Chris@3: QString Chris@3: Layer::toXmlString(QString indent, QString extraAttributes) const Chris@3: { Chris@3: QString s; Chris@3: Chris@3: s += indent; Chris@3: Chris@6: s += QString("\n") Chris@77: .arg(encodeEntities(LayerFactory::instance()->getLayerTypeName Chris@77: (LayerFactory::instance()->getLayerType(this)))) Chris@4: .arg(getObjectExportId(this)) Chris@77: .arg(encodeEntities(objectName())) Chris@4: .arg(getObjectExportId(getModel())) Chris@3: .arg(extraAttributes); Chris@3: Chris@3: return s; Chris@3: } Chris@0: Chris@28: PlayParameters * Chris@29: Layer::getPlayParameters() Chris@28: { Chris@32: // std::cerr << "Layer (" << this << ", " << objectName().toStdString() << ")::getPlayParameters: model is "<< getModel() << std::endl; Chris@28: const Model *model = getModel(); Chris@28: if (model) { Chris@28: return PlayParameterRepository::instance()->getPlayParameters(model); Chris@28: } Chris@28: return 0; Chris@28: } Chris@28: Chris@29: void Chris@36: Layer::showLayer(View *view, bool show) Chris@29: { Chris@36: setLayerDormant(view, !show); Chris@29: emit layerParametersChanged(); Chris@29: } Chris@28: Chris@28: Chris@0: #ifdef INCLUDE_MOCFILES Chris@0: #include "Layer.moc.cpp" Chris@0: #endif Chris@0: