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