Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@52
|
4 Sonic Visualiser
|
Chris@52
|
5 An audio file viewer and annotation editor.
|
Chris@52
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@52
|
7 This file copyright 2006 Chris Cannam.
|
Chris@0
|
8
|
Chris@52
|
9 This program is free software; you can redistribute it and/or
|
Chris@52
|
10 modify it under the terms of the GNU General Public License as
|
Chris@52
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@52
|
12 License, or (at your option) any later version. See the file
|
Chris@52
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #include "PropertyContainer.h"
|
Chris@46
|
17 #include "CommandHistory.h"
|
Chris@46
|
18
|
Chris@46
|
19 #include <iostream>
|
Chris@0
|
20
|
Chris@0
|
21 PropertyContainer::PropertyList
|
Chris@0
|
22 PropertyContainer::getProperties() const
|
Chris@0
|
23 {
|
Chris@0
|
24 return PropertyList();
|
Chris@0
|
25 }
|
Chris@0
|
26
|
Chris@94
|
27 //QString
|
Chris@94
|
28 //PropertyContainer::getPropertyLabel(const PropertyName &) const
|
Chris@94
|
29 //{
|
Chris@94
|
30 // return "";
|
Chris@94
|
31 //}
|
Chris@94
|
32
|
Chris@0
|
33 PropertyContainer::PropertyType
|
Chris@0
|
34 PropertyContainer::getPropertyType(const PropertyName &) const
|
Chris@0
|
35 {
|
Chris@0
|
36 return InvalidProperty;
|
Chris@0
|
37 }
|
Chris@0
|
38
|
Chris@0
|
39 QString
|
Chris@0
|
40 PropertyContainer::getPropertyGroupName(const PropertyName &) const
|
Chris@0
|
41 {
|
Chris@0
|
42 return QString();
|
Chris@0
|
43 }
|
Chris@0
|
44
|
Chris@0
|
45 int
|
Chris@0
|
46 PropertyContainer::getPropertyRangeAndValue(const PropertyName &, int *min, int *max) const
|
Chris@0
|
47 {
|
Chris@0
|
48 if (min) *min = 0;
|
Chris@0
|
49 if (max) *max = 0;
|
Chris@0
|
50 return 0;
|
Chris@0
|
51 }
|
Chris@0
|
52
|
Chris@0
|
53 QString
|
Chris@0
|
54 PropertyContainer::getPropertyValueLabel(const PropertyName &, int) const
|
Chris@0
|
55 {
|
Chris@0
|
56 return QString();
|
Chris@0
|
57 }
|
Chris@0
|
58
|
Chris@190
|
59 RangeMapper *
|
Chris@190
|
60 PropertyContainer::getNewPropertyRangeMapper(const PropertyName &) const
|
Chris@190
|
61 {
|
Chris@190
|
62 return 0;
|
Chris@190
|
63 }
|
Chris@190
|
64
|
Chris@0
|
65 void
|
Chris@46
|
66 PropertyContainer::setProperty(const PropertyName &name, int)
|
Chris@46
|
67 {
|
Chris@46
|
68 std::cerr << "WARNING: PropertyContainer[" << getPropertyContainerName().toStdString() << "]::setProperty(" << name.toStdString() << "): no implementation in subclass!" << std::endl;
|
Chris@46
|
69 }
|
Chris@46
|
70
|
Chris@46
|
71 void
|
Chris@46
|
72 PropertyContainer::setPropertyWithCommand(const PropertyName &name, int value)
|
Chris@46
|
73 {
|
Chris@46
|
74 int currentValue = getPropertyRangeAndValue(name, 0, 0);
|
Chris@46
|
75 if (value == currentValue) return;
|
Chris@46
|
76
|
Chris@46
|
77 CommandHistory::getInstance()->addCommand
|
Chris@47
|
78 (new SetPropertyCommand(this, name, value), true, true); // bundled
|
Chris@46
|
79 }
|
Chris@46
|
80
|
Chris@46
|
81 PropertyContainer::SetPropertyCommand::SetPropertyCommand(PropertyContainer *pc,
|
Chris@46
|
82 const PropertyName &pn,
|
Chris@46
|
83 int value) :
|
Chris@46
|
84 m_pc(pc),
|
Chris@46
|
85 m_pn(pn),
|
Chris@46
|
86 m_value(value),
|
Chris@46
|
87 m_oldValue(0)
|
Chris@0
|
88 {
|
Chris@0
|
89 }
|
Chris@0
|
90
|
Chris@46
|
91 void
|
Chris@46
|
92 PropertyContainer::SetPropertyCommand::execute()
|
Chris@46
|
93 {
|
Chris@46
|
94 m_oldValue = m_pc->getPropertyRangeAndValue(m_pn, 0, 0);
|
Chris@46
|
95 m_pc->setProperty(m_pn, m_value);
|
Chris@46
|
96 }
|
Chris@46
|
97
|
Chris@46
|
98 void
|
Chris@46
|
99 PropertyContainer::SetPropertyCommand::unexecute()
|
Chris@46
|
100 {
|
Chris@46
|
101 m_pc->setProperty(m_pn, m_oldValue);
|
Chris@46
|
102 }
|
Chris@46
|
103
|
Chris@46
|
104 QString
|
Chris@46
|
105 PropertyContainer::SetPropertyCommand::getName() const
|
Chris@46
|
106 {
|
Chris@46
|
107 return m_pc->tr("Set %1 Property").arg(m_pn);
|
Chris@46
|
108 }
|
Chris@46
|
109
|