33#include <NDEVR/QTDesignObject.h>
34#include <NDEVR/QCustomCombobox.h>
35#include <NDEVR/QCustomValidator.h>
36#include <NDEVR/ManagedDesignCommand.h>
37#include <NDEVR/JSONNode.h>
38#include <NDEVR/RegexFunctions.h>
52 connect(
this, &QCustomComboBox::edited,
this, &DesignObjectComboWidget::sendCommand);
61 setDesignProperty(property);
65 if (m_target ==
object)
67 if (!m_target.isNull())
69 disconnect(&m_target.get(), &QTDesignObject::updatedSignal,
this, &DesignObjectComboWidget::onObjectUpdatedSlot);
70 disconnect(&m_target.get(), &QTDesignObject::deletedSignal,
this, &DesignObjectComboWidget::onObjectDeletedSlot);
73 if (!m_target.isNull())
75 connect(&m_target.get(), &QTDesignObject::updatedSignal,
this, &DesignObjectComboWidget::onObjectUpdatedSlot);
76 connect(&m_target.get(), &QTDesignObject::deletedSignal,
this, &DesignObjectComboWidget::onObjectDeletedSlot);
78 setEnabled(!m_target.isNull());
79 onObjectUpdatedSlot();
83 m_property = property;
84 if (m_title.isEmpty())
86 if (property == DesignObject::DesignProperty::e_meta_data)
87 setWindowTitle(
String(m_meta_data_title).formatAsTitleString().getAs<QString>());
89 setWindowTitle(
String(property).formatAsTitleString().getAs<QString>());
92 onObjectUpdatedSlot();
95 case DesignObject::DesignProperty::e_file:
96 validator.
setRegex(RegexFunctions::FileRegex());
102 setCustomValidator(validator);
106 m_meta_data_title = metadata;
107 setDesignProperty(DesignObject::DesignProperty::e_meta_data);
112 if (m_title.translation().size() == 0)
114 if (m_property == DesignObject::DesignProperty::e_meta_data)
115 setWindowTitle(
String(m_meta_data_title).formatAsTitleString().getAs<QString>());
117 setWindowTitle(
String(m_property).formatAsTitleString().getAs<QString>());
121 setWindowTitle(m_title.translation().getAs<QString>());
131 if (m_target.isNull())
133 String name = getAs<String>();
134 if (m_property == DesignObject::DesignProperty::e_meta_data)
136 m_target->postCommand(ManagedDesignCommand::SetMetadata(m_meta_data_title, name));
141 m_target->postCommand(ManagedDesignCommand::SetProperty(m_property, name));
146 if (!m_target.isNull() && m_property != DesignObject::e_design_property_size)
149 if (m_property == DesignObject::e_meta_data)
151 if (m_target->get().hasMetaData(m_meta_data_title))
152 object_name = m_target->
get().metaData(m_meta_data_title).getAs<
String>();
156 object_name = m_target->getProperty<
String>(m_property);
158 if (object_name.
size() != 0)
160 setValue(object_name);
constexpr t_index_type size() const
Definition Buffer.hpp:823
decltype(auto) get(t_index_type index)
Definition Buffer.hpp:541
A low-level database object that can be used to access general stored properties within the NDEVR Mod...
Definition DesignObject.h:67
t_type getProperty(DesignProperty property) const
Definition DesignObject.h:256
DesignProperty
Values stored in the property database.
Definition DesignObject.h:93
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
A compact way to present a list of options to the user.
Definition QCustomCombobox.h:53
Responsible on most user input fields for correcting the input when possible or allerting the user th...
Definition QCustomValidator.h:47
void setRegex(const String ®ex)
The core String class for the NDEVR API.
Definition String.h:69
t_type getAs() const
Converts a string into an object. To use this function an object must have overwritten StringStream<t...
Definition String.h:143
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13