mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-29 20:00:53 +00:00
Changed: #1302 Added signal 'reset text property' for returning to default value
This commit is contained in:
parent
6a87a9933c
commit
7badc3657b
6 changed files with 43 additions and 11 deletions
|
@ -704,7 +704,7 @@ void QtCheckBoxFactoryPrivate::slotReset()
|
|||
QtBoolPropertyManager *manager = q_ptr->propertyManager(property);
|
||||
if (!manager)
|
||||
return;
|
||||
manager->setResetProperty(property);
|
||||
manager->emitResetProperty(property);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2638,12 +2638,14 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void setValue(const QString &value);
|
||||
void setStateResetButton(bool enabled);
|
||||
|
||||
private Q_SLOTS:
|
||||
void buttonClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QString &value);
|
||||
void resetProperty();
|
||||
|
||||
private:
|
||||
QLineEdit *m_lineEdit;
|
||||
|
@ -2675,6 +2677,7 @@ QtTextEditWidget::QtTextEditWidget(QWidget *parent) :
|
|||
m_defaultButton->setMaximumWidth(16);
|
||||
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
||||
connect(m_defaultButton, SIGNAL(clicked()), this, SIGNAL(resetProperty()));
|
||||
lt->addWidget(m_button);
|
||||
lt->addWidget(m_defaultButton);
|
||||
m_defaultButton->setEnabled(false);
|
||||
|
@ -2686,6 +2689,11 @@ void QtTextEditWidget::setValue(const QString &value)
|
|||
m_lineEdit->setText(value);
|
||||
}
|
||||
|
||||
void QtTextEditWidget::setStateResetButton(bool enabled)
|
||||
{
|
||||
m_defaultButton->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void QtTextEditWidget::buttonClicked()
|
||||
{
|
||||
QGridLayout *gridLayout;
|
||||
|
@ -2761,6 +2769,7 @@ public:
|
|||
|
||||
void slotPropertyChanged(QtProperty *property, const QString &value);
|
||||
void slotSetValue(const QString &value);
|
||||
void slotResetProperty();
|
||||
};
|
||||
|
||||
void QtTextEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
|
||||
|
@ -2772,7 +2781,11 @@ void QtTextEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
|
|||
QListIterator<QtTextEditWidget *> itEditor(it.value());
|
||||
|
||||
while (itEditor.hasNext())
|
||||
itEditor.next()->setValue(value);
|
||||
{
|
||||
QtTextEditWidget *editor = itEditor.next();
|
||||
editor->setValue(value);
|
||||
editor->setStateResetButton(property->isModified());
|
||||
}
|
||||
}
|
||||
|
||||
void QtTextEditorFactoryPrivate::slotSetValue(const QString &value)
|
||||
|
@ -2789,6 +2802,22 @@ void QtTextEditorFactoryPrivate::slotSetValue(const QString &value)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QtTextEditorFactoryPrivate::slotResetProperty()
|
||||
{
|
||||
QObject *object = q_ptr->sender();
|
||||
const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd();
|
||||
for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
|
||||
if (itEditor.key() == object) {
|
||||
QtProperty *property = itEditor.value();
|
||||
QtTextPropertyManager *manager = q_ptr->propertyManager(property);
|
||||
if (!manager)
|
||||
return;
|
||||
manager->emitResetProperty(property);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QtTextEditFactory
|
||||
|
||||
|
@ -2841,8 +2870,10 @@ QWidget *QtTextEditorFactory::createEditor(QtTextPropertyManager *manager,
|
|||
QtTextEditWidget *editor = d_ptr->createEditor(property, parent);
|
||||
|
||||
editor->setValue(manager->value(property));
|
||||
|
||||
connect(editor, SIGNAL(valueChanged(QString)), this, SLOT(slotSetValue(QString)));
|
||||
editor->setStateResetButton(property->isModified());
|
||||
|
||||
connect(editor, SIGNAL(resetProperty()), this, SLOT(slotResetProperty()));
|
||||
connect(editor, SIGNAL(valueChanged(QString)), this, SLOT(slotSetValue(QString)));
|
||||
connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *)));
|
||||
return editor;
|
||||
}
|
||||
|
|
|
@ -462,6 +462,7 @@ private:
|
|||
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotResetProperty())
|
||||
};
|
||||
|
||||
#if QT_VERSION >= 0x040400
|
||||
|
|
|
@ -808,6 +808,11 @@ QtProperty *QtAbstractPropertyManager::addProperty(const QString &name)
|
|||
return property;
|
||||
}
|
||||
|
||||
void QtAbstractPropertyManager::emitResetProperty(QtProperty *property)
|
||||
{
|
||||
emit resetProperty(property);
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a property.
|
||||
|
||||
|
|
|
@ -170,6 +170,7 @@ public:
|
|||
void clear() const;
|
||||
|
||||
QtProperty *addProperty(const QString &name = QString());
|
||||
void emitResetProperty(QtProperty *property);
|
||||
Q_SIGNALS:
|
||||
|
||||
void propertyInserted(QtProperty *property,
|
||||
|
@ -177,6 +178,7 @@ Q_SIGNALS:
|
|||
void propertyChanged(QtProperty *property);
|
||||
void propertyRemoved(QtProperty *property, QtProperty *parent);
|
||||
void propertyDestroyed(QtProperty *property);
|
||||
void resetProperty(QtProperty *property);
|
||||
protected:
|
||||
virtual bool hasValue(const QtProperty *property) const;
|
||||
virtual QIcon valueIcon(const QtProperty *property) const;
|
||||
|
|
|
@ -1588,11 +1588,6 @@ void QtBoolPropertyManager::setValue(QtProperty *property, bool val)
|
|||
property, val);
|
||||
}
|
||||
|
||||
void QtBoolPropertyManager::setResetProperty(QtProperty *property)
|
||||
{
|
||||
emit resetProperty(property);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
|
|
|
@ -160,11 +160,9 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void setValue(QtProperty *property, bool val);
|
||||
void setResetProperty(QtProperty *property);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(QtProperty *property, bool val);
|
||||
void resetProperty(QtProperty *property);
|
||||
|
||||
protected:
|
||||
QString valueText(const QtProperty *property) const;
|
||||
|
|
Loading…
Reference in a new issue