Mercurial > hg > svgui
comparison layer/Layer.cpp @ 127:89c625dda204
* Reorganising code base. This revision will not compile.
author | Chris Cannam |
---|---|
date | Mon, 31 Jul 2006 11:44:37 +0000 |
parents | |
children | 33929e0c3c6b |
comparison
equal
deleted
inserted
replaced
126:0e95c127bb53 | 127:89c625dda204 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "Layer.h" | |
17 #include "View.h" | |
18 #include "Model.h" | |
19 | |
20 #include <iostream> | |
21 | |
22 #include "layer/LayerFactory.h" //!!! shouldn't be including this here -- does that suggest we need to move this into layer/ ? | |
23 #include "PlayParameterRepository.h" | |
24 | |
25 Layer::Layer() | |
26 { | |
27 } | |
28 | |
29 Layer::~Layer() | |
30 { | |
31 // std::cerr << "Layer::~Layer(" << this << ")" << std::endl; | |
32 } | |
33 | |
34 QString | |
35 Layer::getPropertyContainerIconName() const | |
36 { | |
37 return LayerFactory::getInstance()->getLayerIconName | |
38 (LayerFactory::getInstance()->getLayerType(this)); | |
39 } | |
40 | |
41 QString | |
42 Layer::getLayerPresentationName() const | |
43 { | |
44 QString layerName = objectName(); | |
45 QString modelName; | |
46 if (getModel()) modelName = getModel()->objectName(); | |
47 | |
48 QString text; | |
49 if (modelName != "") { | |
50 text = QString("%1: %2").arg(modelName).arg(layerName); | |
51 } else { | |
52 text = layerName; | |
53 } | |
54 | |
55 return text; | |
56 } | |
57 | |
58 void | |
59 Layer::setObjectName(const QString &name) | |
60 { | |
61 QObject::setObjectName(name); | |
62 emit layerNameChanged(); | |
63 } | |
64 | |
65 QString | |
66 Layer::toXmlString(QString indent, QString extraAttributes) const | |
67 { | |
68 QString s; | |
69 | |
70 s += indent; | |
71 | |
72 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") | |
73 .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName | |
74 (LayerFactory::getInstance()->getLayerType(this)))) | |
75 .arg(getObjectExportId(this)) | |
76 .arg(encodeEntities(objectName())) | |
77 .arg(getObjectExportId(getModel())) | |
78 .arg(extraAttributes); | |
79 | |
80 return s; | |
81 } | |
82 | |
83 PlayParameters * | |
84 Layer::getPlayParameters() | |
85 { | |
86 // std::cerr << "Layer (" << this << ", " << objectName().toStdString() << ")::getPlayParameters: model is "<< getModel() << std::endl; | |
87 const Model *model = getModel(); | |
88 if (model) { | |
89 return PlayParameterRepository::getInstance()->getPlayParameters(model); | |
90 } | |
91 return 0; | |
92 } | |
93 | |
94 void | |
95 Layer::showLayer(View *view, bool show) | |
96 { | |
97 setLayerDormant(view, !show); | |
98 emit layerParametersChanged(); | |
99 } | |
100 | |
101 | |
102 #ifdef INCLUDE_MOCFILES | |
103 #include "Layer.moc.cpp" | |
104 #endif | |
105 |