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 "PropertyContainer.h" Chris@46: #include "CommandHistory.h" Chris@46: Chris@46: #include Chris@0: Chris@0: PropertyContainer::PropertyList Chris@0: PropertyContainer::getProperties() const Chris@0: { Chris@0: return PropertyList(); Chris@0: } Chris@0: Chris@94: //QString Chris@94: //PropertyContainer::getPropertyLabel(const PropertyName &) const Chris@94: //{ Chris@94: // return ""; Chris@94: //} Chris@94: Chris@0: PropertyContainer::PropertyType Chris@0: PropertyContainer::getPropertyType(const PropertyName &) const Chris@0: { Chris@0: return InvalidProperty; Chris@0: } Chris@0: Chris@0: QString Chris@0: PropertyContainer::getPropertyGroupName(const PropertyName &) const Chris@0: { Chris@0: return QString(); Chris@0: } Chris@0: Chris@0: int Chris@0: PropertyContainer::getPropertyRangeAndValue(const PropertyName &, int *min, int *max) const Chris@0: { Chris@0: if (min) *min = 0; Chris@0: if (max) *max = 0; Chris@0: return 0; Chris@0: } Chris@0: Chris@0: QString Chris@0: PropertyContainer::getPropertyValueLabel(const PropertyName &, int) const Chris@0: { Chris@0: return QString(); Chris@0: } Chris@0: Chris@0: void Chris@46: PropertyContainer::setProperty(const PropertyName &name, int) Chris@46: { Chris@46: std::cerr << "WARNING: PropertyContainer[" << getPropertyContainerName().toStdString() << "]::setProperty(" << name.toStdString() << "): no implementation in subclass!" << std::endl; Chris@46: } Chris@46: Chris@46: void Chris@46: PropertyContainer::setPropertyWithCommand(const PropertyName &name, int value) Chris@46: { Chris@46: int currentValue = getPropertyRangeAndValue(name, 0, 0); Chris@46: if (value == currentValue) return; Chris@46: Chris@46: CommandHistory::getInstance()->addCommand Chris@47: (new SetPropertyCommand(this, name, value), true, true); // bundled Chris@46: } Chris@46: Chris@46: PropertyContainer::SetPropertyCommand::SetPropertyCommand(PropertyContainer *pc, Chris@46: const PropertyName &pn, Chris@46: int value) : Chris@46: m_pc(pc), Chris@46: m_pn(pn), Chris@46: m_value(value), Chris@46: m_oldValue(0) Chris@0: { Chris@0: } Chris@0: Chris@46: void Chris@46: PropertyContainer::SetPropertyCommand::execute() Chris@46: { Chris@46: m_oldValue = m_pc->getPropertyRangeAndValue(m_pn, 0, 0); Chris@46: m_pc->setProperty(m_pn, m_value); Chris@46: } Chris@46: Chris@46: void Chris@46: PropertyContainer::SetPropertyCommand::unexecute() Chris@46: { Chris@46: m_pc->setProperty(m_pn, m_oldValue); Chris@46: } Chris@46: Chris@46: QString Chris@46: PropertyContainer::SetPropertyCommand::getName() const Chris@46: { Chris@46: return m_pc->tr("Set %1 Property").arg(m_pn); Chris@46: } Chris@46: