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