File indexing completed on 2025-02-02 04:11:05

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #include "property.hpp"
0008 #include "model/object.hpp"
0009 #include "command/property_commands.hpp"
0010 
0011 glaxnimate::model::BaseProperty::BaseProperty(Object* object, const KLazyLocalizedString& name, PropertyTraits traits)
0012     : object_(object), name_(name), traits_(traits)
0013 {
0014     if ( object )
0015         object_->add_property(this);
0016 }
0017 
0018 void glaxnimate::model::BaseProperty::value_changed()
0019 {
0020     object_->property_value_changed(this, value());
0021 }
0022 
0023 bool glaxnimate::model::BaseProperty::set_undoable ( const QVariant& val, bool commit )
0024 {
0025     if ( !valid_value(val) )
0026         return false;
0027 
0028     object_->push_command(new command::SetPropertyValue(this, value(), val, commit));
0029     return true;
0030 }