diff options
Diffstat (limited to 'qtpropertybrowser/src/qteditorfactory.cpp')
-rw-r--r-- | qtpropertybrowser/src/qteditorfactory.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/qtpropertybrowser/src/qteditorfactory.cpp b/qtpropertybrowser/src/qteditorfactory.cpp index 2611461..5cb4a37 100644 --- a/qtpropertybrowser/src/qteditorfactory.cpp +++ b/qtpropertybrowser/src/qteditorfactory.cpp @@ -149,6 +149,7 @@ public: void slotPropertyChanged(QtProperty *property, int value); void slotRangeChanged(QtProperty *property, int min, int max); void slotSingleStepChanged(QtProperty *property, int step); + void slotReadOnlyChanged(QtProperty *property, bool readOnly); void slotSetValue(int value); }; @@ -199,6 +200,24 @@ void QtSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, int st } } +void QtSpinBoxFactoryPrivate::slotReadOnlyChanged( QtProperty *property, bool readOnly) +{ + if (!m_createdEditors.contains(property)) + return; + + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setReadOnly(readOnly); + editor->blockSignals(false); + } +} + void QtSpinBoxFactoryPrivate::slotSetValue(int value) { QObject *object = q_ptr->sender(); @@ -257,6 +276,8 @@ void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager) this, SLOT(slotRangeChanged(QtProperty *, int, int))); connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, SLOT(slotSingleStepChanged(QtProperty *, int))); + connect(manager, SIGNAL(readOnlyChanged(QtProperty *, bool)), + this, SLOT(slotReadOnlyChanged(QtProperty *, bool))); } /*! @@ -272,6 +293,7 @@ QWidget *QtSpinBoxFactory::createEditor(QtIntPropertyManager *manager, QtPropert editor->setRange(manager->minimum(property), manager->maximum(property)); editor->setValue(manager->value(property)); editor->setKeyboardTracking(false); + editor->setReadOnly(manager->isReadOnly(property)); connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); connect(editor, SIGNAL(destroyed(QObject *)), @@ -292,6 +314,8 @@ void QtSpinBoxFactory::disconnectPropertyManager(QtIntPropertyManager *manager) this, SLOT(slotRangeChanged(QtProperty *, int, int))); disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, SLOT(slotSingleStepChanged(QtProperty *, int))); + disconnect(manager, SIGNAL(readOnlyChanged(QtProperty *, bool)), + this, SLOT(slotReadOnlyChanged(QtProperty *, bool))); } // QtSliderFactory @@ -720,6 +744,7 @@ public: void slotRangeChanged(QtProperty *property, double min, double max); void slotSingleStepChanged(QtProperty *property, double step); void slotDecimalsChanged(QtProperty *property, int prec); + void slotReadOnlyChanged(QtProperty *property, bool readOnly); void slotSetValue(double value); }; @@ -777,6 +802,24 @@ void QtDoubleSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, } } +void QtDoubleSpinBoxFactoryPrivate::slotReadOnlyChanged( QtProperty *property, bool readOnly) +{ + if (!m_createdEditors.contains(property)) + return; + + QtDoublePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QDoubleSpinBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QDoubleSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setReadOnly(readOnly); + editor->blockSignals(false); + } +} + void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(QtProperty *property, int prec) { if (!m_createdEditors.contains(property)) @@ -856,6 +899,8 @@ void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager *man this, SLOT(slotSingleStepChanged(QtProperty *, double))); connect(manager, SIGNAL(decimalsChanged(QtProperty *, int)), this, SLOT(slotDecimalsChanged(QtProperty *, int))); + connect(manager, SIGNAL(readOnlyChanged(QtProperty *, bool)), + this, SLOT(slotReadOnlyChanged(QtProperty *, bool))); } /*! @@ -872,6 +917,7 @@ QWidget *QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager *manager, editor->setRange(manager->minimum(property), manager->maximum(property)); editor->setValue(manager->value(property)); editor->setKeyboardTracking(false); + editor->setReadOnly(manager->isReadOnly(property)); connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double))); connect(editor, SIGNAL(destroyed(QObject *)), @@ -894,6 +940,8 @@ void QtDoubleSpinBoxFactory::disconnectPropertyManager(QtDoublePropertyManager * this, SLOT(slotSingleStepChanged(QtProperty *, double))); disconnect(manager, SIGNAL(decimalsChanged(QtProperty *, int)), this, SLOT(slotDecimalsChanged(QtProperty *, int))); + disconnect(manager, SIGNAL(readOnlyChanged(QtProperty *, bool)), + this, SLOT(slotReadOnlyChanged(QtProperty *, bool))); } // QtLineEditFactory @@ -908,6 +956,7 @@ public: void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp); void slotSetValue(const QString &value); void slotEchoModeChanged(QtProperty *, int); + void slotReadOnlyChanged(QtProperty *, bool); }; void QtLineEditFactoryPrivate::slotPropertyChanged(QtProperty *property, @@ -966,8 +1015,24 @@ void QtLineEditFactoryPrivate::slotEchoModeChanged(QtProperty *property, int ech editor->setEchoMode((EchoMode)echoMode); editor->blockSignals(false); } +} + +void QtLineEditFactoryPrivate::slotReadOnlyChanged( QtProperty *property, bool readOnly) +{ + if (!m_createdEditors.contains(property)) + return; + QtStringPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + QListIterator<QLineEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QLineEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setReadOnly(readOnly); + editor->blockSignals(false); + } } void QtLineEditFactoryPrivate::slotSetValue(const QString &value) @@ -985,6 +1050,8 @@ void QtLineEditFactoryPrivate::slotSetValue(const QString &value) } } + + /*! \class QtLineEditFactory @@ -1027,6 +1094,8 @@ void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager) this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); connect(manager, SIGNAL(echoModeChanged(QtProperty*, int)), this, SLOT(slotEchoModeChanged(QtProperty *, int))); + connect(manager, SIGNAL(readOnlyChanged(QtProperty*, bool)), + this, SLOT(slotReadOnlyChanged(QtProperty *, bool))); } /*! @@ -1040,6 +1109,7 @@ QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager, QLineEdit *editor = d_ptr->createEditor(property, parent); editor->setEchoMode((EchoMode)manager->echoMode(property)); + editor->setReadOnly(manager->isReadOnly(property)); QRegExp regExp = manager->regExp(property); if (regExp.isValid()) { QValidator *validator = new QRegExpValidator(regExp, editor); @@ -1067,6 +1137,9 @@ void QtLineEditFactory::disconnectPropertyManager(QtStringPropertyManager *manag this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); disconnect(manager, SIGNAL(echoModeChanged(QtProperty*,int)), this, SLOT(slotEchoModeChanged(QtProperty *, int))); + disconnect(manager, SIGNAL(readOnlyChanged(QtProperty*, bool)), + this, SLOT(slotReadOnlyChanged(QtProperty *, bool))); + } // QtDateEditFactory |