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