25 const QVariant &value,
const QString &text, QUndoCommand *parent)
29 m_propertyMap.insert(property, value);
34 const QString &text, QUndoCommand *parent)
38 auto it = propertyMap.constBegin();
39 while (it != propertyMap.constEnd()) {
40 m_propertyMap.insert(it.key().toLatin1(), it.value().toVariant());
46void ModifyPropertyCommand::init()
48 if (text().isEmpty() && !m_propertyMap.isEmpty()) {
49 if (m_propertyMap.size() == 1) {
50 setText(tr(
"Modify property '%1'").arg(m_propertyMap.begin().value().toString()));
52 setText(tr(
"Modify multiple properties"));
62 qCDebug(KDSME_VIEW) <<
"Invalid object";
66 auto it = m_propertyMap.constBegin();
67 while (it != m_propertyMap.constEnd()) {
68 m_oldPropertyMap.insert(it.key(), m_object->property(it.key().constData()));
69 if (!m_object->setProperty(it.key().constData(), it.value())) {
70 qCDebug(KDSME_VIEW) <<
"Failed to set property" << it.key();
79 qCDebug(KDSME_VIEW) <<
"Invalid object";
83 auto it = m_oldPropertyMap.constBegin();
84 while (it != m_oldPropertyMap.constEnd()) {
85 if (!m_object->setProperty(it.key().constData(), it.value())) {
86 qCDebug(KDSME_VIEW) <<
"Failed to set property" << it.key();
90 m_oldPropertyMap.clear();
ModifyPropertyCommand(QObject *object, const char *property, const QVariant &value, const QString &text=QString(), QUndoCommand *parent=nullptr)