mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Editing of keywords
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@255 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+14
-7
@@ -109,18 +109,25 @@ IMPLEMENT_REFLECTION_NAMELESS(TextValue) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : FakeTextValue
|
||||
|
||||
FakeTextValue::FakeTextValue(const TextFieldP& field, String* underlying, bool untagged)
|
||||
FakeTextValue::FakeTextValue(const TextFieldP& field, String* underlying, bool editable, bool untagged)
|
||||
: TextValue(field), underlying(underlying)
|
||||
, untagged(untagged)
|
||||
{
|
||||
if (underlying) {
|
||||
value.assign(untagged ? escape(*underlying) : *underlying);
|
||||
, editable(editable), untagged(untagged)
|
||||
{}
|
||||
|
||||
void FakeTextValue::store() {
|
||||
if (editable) {
|
||||
*underlying = untagged ? untag(value) : value;
|
||||
} else {
|
||||
retrieve();
|
||||
}
|
||||
}
|
||||
void FakeTextValue::retrieve() {
|
||||
value.assign(untagged ? escape(*underlying) : *underlying);
|
||||
}
|
||||
|
||||
void FakeTextValue::onAction(Action& a, bool undone) {
|
||||
if (underlying) {
|
||||
*underlying = untagged ? untag(value) : value;
|
||||
store();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +137,6 @@ bool FakeTextValue::equals(const Value* that) {
|
||||
const FakeTextValue* thatT = dynamic_cast<const FakeTextValue*>(that);
|
||||
if (!thatT || underlying != thatT->underlying) return false;
|
||||
// update the value
|
||||
value.assign(untagged ? escape(*underlying) : *underlying);
|
||||
retrieve();
|
||||
return true;
|
||||
}
|
||||
|
||||
+10
-2
@@ -107,10 +107,18 @@ class FakeTextValue : public TextValue {
|
||||
public:
|
||||
/// Initialize the fake text value
|
||||
/** underlying can be nullptr, in that case there is no underlying value */
|
||||
FakeTextValue(const TextFieldP& field, String* underlying, bool untagged);
|
||||
FakeTextValue(const TextFieldP& field, String* underlying, bool editable, bool untagged);
|
||||
|
||||
String* const underlying; ///< The underlying actual value, can be null
|
||||
bool const untagged; ///< The underlying value is untagged
|
||||
bool const editable; ///< The underlying value can be edited
|
||||
bool const untagged; ///< The underlying value is untagged
|
||||
|
||||
/// Store the value in the underlying value.
|
||||
/** May be overloaded to do some transformation */
|
||||
virtual void store();
|
||||
/// Retrieve the value from the underlying value.
|
||||
/** May be overloaded to do some transformation */
|
||||
virtual void retrieve();
|
||||
|
||||
/// Update underlying data
|
||||
virtual void onAction(Action& a, bool undone);
|
||||
|
||||
Reference in New Issue
Block a user