File indexing completed on 2024-05-12 04:35:09
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2016 The Qt Company Ltd. 0004 ** Contact: https://www.qt.io/licensing/ 0005 ** 0006 ** This file is part of the tools applications of the Qt Toolkit. 0007 ** 0008 ** $QT_BEGIN_LICENSE:LGPL$ 0009 ** Commercial License Usage 0010 ** Licensees holding valid commercial Qt licenses may use this file in 0011 ** accordance with the commercial license agreement provided with the 0012 ** Software or, alternatively, in accordance with the terms contained in 0013 ** a written agreement between you and The Qt Company. For licensing terms 0014 ** and conditions see https://www.qt.io/terms-conditions. For further 0015 ** information use the contact form at https://www.qt.io/contact-us. 0016 ** 0017 ** GNU Lesser General Public License Usage 0018 ** Alternatively, this file may be used under the terms of the GNU Lesser 0019 ** General Public License version 3 as published by the Free Software 0020 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 0021 ** packaging of this file. Please review the following information to 0022 ** ensure the GNU Lesser General Public License version 3 requirements 0023 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 0024 ** 0025 ** GNU General Public License Usage 0026 ** Alternatively, this file may be used under the terms of the GNU 0027 ** General Public License version 2.0 or (at your option) the GNU General 0028 ** Public license version 3 or any later version approved by the KDE Free 0029 ** Qt Foundation. The licenses are as published by the Free Software 0030 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 0031 ** included in the packaging of this file. Please review the following 0032 ** information to ensure the GNU General Public License requirements will 0033 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 0034 ** https://www.gnu.org/licenses/gpl-3.0.html. 0035 ** 0036 ** $QT_END_LICENSE$ 0037 ** 0038 ****************************************************************************/ 0039 0040 #include "qteditorfactory.h" 0041 #include "qtpropertybrowserutils_p.h" 0042 #include <QtWidgets/QSpinBox> 0043 #include <QtWidgets/QScrollBar> 0044 #include <QtWidgets/QComboBox> 0045 #include <QtWidgets/QAbstractItemView> 0046 #include <QtWidgets/QLineEdit> 0047 #include <QtWidgets/QDateTimeEdit> 0048 #include <QtWidgets/QHBoxLayout> 0049 #include <QtWidgets/QMenu> 0050 #include <QtGui/QKeyEvent> 0051 #include <QtWidgets/QApplication> 0052 #include <QtWidgets/QLabel> 0053 #include <QtWidgets/QToolButton> 0054 #include <QtWidgets/QColorDialog> 0055 #include <QtWidgets/QFontDialog> 0056 #include <QtWidgets/QSpacerItem> 0057 #include <QtWidgets/QKeySequenceEdit> 0058 #include <QtCore/QMap> 0059 0060 #if defined(Q_CC_MSVC) 0061 # pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ 0062 #endif 0063 0064 QT_BEGIN_NAMESPACE 0065 0066 // Set a hard coded left margin to account for the indentation 0067 // of the tree view icon when switching to an editor 0068 0069 static inline void setupTreeViewEditorMargin(QLayout *lt) 0070 { 0071 enum { DecorationMargin = 4 }; 0072 if (QApplication::layoutDirection() == Qt::LeftToRight) 0073 lt->setContentsMargins(DecorationMargin, 0, 0, 0); 0074 else 0075 lt->setContentsMargins(0, 0, DecorationMargin, 0); 0076 } 0077 0078 // ---------- EditorFactoryPrivate : 0079 // Base class for editor factory private classes. Manages mapping of properties to editors and vice versa. 0080 0081 template <class Editor> 0082 class EditorFactoryPrivate 0083 { 0084 public: 0085 0086 typedef QList<Editor *> EditorList; 0087 typedef QMap<QtProperty *, EditorList> PropertyToEditorListMap; 0088 typedef QMap<Editor *, QtProperty *> EditorToPropertyMap; 0089 0090 Editor *createEditor(QtProperty *property, QWidget *parent); 0091 void initializeEditor(QtProperty *property, Editor *e); 0092 void slotEditorDestroyed(QObject *object); 0093 0094 PropertyToEditorListMap m_createdEditors; 0095 EditorToPropertyMap m_editorToProperty; 0096 }; 0097 0098 template <class Editor> 0099 Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget *parent) 0100 { 0101 Editor *editor = new Editor(parent); 0102 initializeEditor(property, editor); 0103 return editor; 0104 } 0105 0106 template <class Editor> 0107 void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor *editor) 0108 { 0109 typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property); 0110 if (it == m_createdEditors.end()) 0111 it = m_createdEditors.insert(property, EditorList()); 0112 it.value().append(editor); 0113 m_editorToProperty.insert(editor, property); 0114 } 0115 0116 template <class Editor> 0117 void EditorFactoryPrivate<Editor>::slotEditorDestroyed(QObject *object) 0118 { 0119 const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end(); 0120 for (typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) { 0121 if (itEditor.key() == object) { 0122 Editor *editor = itEditor.key(); 0123 QtProperty *property = itEditor.value(); 0124 const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property); 0125 if (pit != m_createdEditors.end()) { 0126 pit.value().removeAll(editor); 0127 if (pit.value().empty()) 0128 m_createdEditors.erase(pit); 0129 } 0130 m_editorToProperty.erase(itEditor); 0131 return; 0132 } 0133 } 0134 } 0135 0136 // ------------ QtSpinBoxFactory 0137 0138 class QtSpinBoxFactoryPrivate : public EditorFactoryPrivate<QSpinBox> 0139 { 0140 QtSpinBoxFactory *q_ptr; 0141 Q_DECLARE_PUBLIC(QtSpinBoxFactory) 0142 public: 0143 0144 void slotPropertyChanged(QtProperty *property, int value); 0145 void slotRangeChanged(QtProperty *property, int min, int max); 0146 void slotSingleStepChanged(QtProperty *property, int step); 0147 void slotSetValue(int value); 0148 }; 0149 0150 void QtSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) 0151 { 0152 const auto it = m_createdEditors.constFind(property); 0153 if (it == m_createdEditors.cend()) 0154 return; 0155 for (QSpinBox *editor : it.value()) { 0156 if (editor->value() != value) { 0157 editor->blockSignals(true); 0158 editor->setValue(value); 0159 editor->blockSignals(false); 0160 } 0161 } 0162 } 0163 0164 void QtSpinBoxFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max) 0165 { 0166 const auto it = m_createdEditors.constFind(property); 0167 if (it == m_createdEditors.cend()) 0168 return; 0169 0170 QtIntPropertyManager *manager = q_ptr->propertyManager(property); 0171 if (!manager) 0172 return; 0173 0174 for (QSpinBox *editor : it.value()) { 0175 editor->blockSignals(true); 0176 editor->setRange(min, max); 0177 editor->setValue(manager->value(property)); 0178 editor->blockSignals(false); 0179 } 0180 } 0181 0182 void QtSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, int step) 0183 { 0184 const auto it = m_createdEditors.constFind(property); 0185 if (it == m_createdEditors.cend()) 0186 return; 0187 for (QSpinBox *editor : it.value()) { 0188 editor->blockSignals(true); 0189 editor->setSingleStep(step); 0190 editor->blockSignals(false); 0191 } 0192 } 0193 0194 void QtSpinBoxFactoryPrivate::slotSetValue(int value) 0195 { 0196 QObject *object = q_ptr->sender(); 0197 const QMap<QSpinBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 0198 for (QMap<QSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) { 0199 if (itEditor.key() == object) { 0200 QtProperty *property = itEditor.value(); 0201 QtIntPropertyManager *manager = q_ptr->propertyManager(property); 0202 if (!manager) 0203 return; 0204 manager->setValue(property, value); 0205 return; 0206 } 0207 } 0208 } 0209 0210 /*! 0211 \class QtSpinBoxFactory 0212 \internal 0213 \inmodule QtDesigner 0214 \since 4.4 0215 0216 \brief The QtSpinBoxFactory class provides QSpinBox widgets for 0217 properties created by QtIntPropertyManager objects. 0218 0219 \sa QtAbstractEditorFactory, QtIntPropertyManager 0220 */ 0221 0222 /*! 0223 Creates a factory with the given \a parent. 0224 */ 0225 QtSpinBoxFactory::QtSpinBoxFactory(QObject *parent) 0226 : QtAbstractEditorFactory<QtIntPropertyManager>(parent), d_ptr(new QtSpinBoxFactoryPrivate()) 0227 { 0228 d_ptr->q_ptr = this; 0229 0230 } 0231 0232 /*! 0233 Destroys this factory, and all the widgets it has created. 0234 */ 0235 QtSpinBoxFactory::~QtSpinBoxFactory() 0236 { 0237 qDeleteAll(d_ptr->m_editorToProperty.keys()); 0238 } 0239 0240 /*! 0241 \internal 0242 0243 Reimplemented from the QtAbstractEditorFactory class. 0244 */ 0245 void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager) 0246 { 0247 connect(manager, SIGNAL(valueChanged(QtProperty*,int)), 0248 this, SLOT(slotPropertyChanged(QtProperty*,int))); 0249 connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), 0250 this, SLOT(slotRangeChanged(QtProperty*,int,int))); 0251 connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), 0252 this, SLOT(slotSingleStepChanged(QtProperty*,int))); 0253 } 0254 0255 /*! 0256 \internal 0257 0258 Reimplemented from the QtAbstractEditorFactory class. 0259 */ 0260 QWidget *QtSpinBoxFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property, 0261 QWidget *parent) 0262 { 0263 QSpinBox *editor = d_ptr->createEditor(property, parent); 0264 editor->setSingleStep(manager->singleStep(property)); 0265 editor->setRange(manager->minimum(property), manager->maximum(property)); 0266 editor->setValue(manager->value(property)); 0267 editor->setKeyboardTracking(false); 0268 0269 connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); 0270 connect(editor, SIGNAL(destroyed(QObject*)), 0271 this, SLOT(slotEditorDestroyed(QObject*))); 0272 return editor; 0273 } 0274 0275 /*! 0276 \internal 0277 0278 Reimplemented from the QtAbstractEditorFactory class. 0279 */ 0280 void QtSpinBoxFactory::disconnectPropertyManager(QtIntPropertyManager *manager) 0281 { 0282 disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), 0283 this, SLOT(slotPropertyChanged(QtProperty*,int))); 0284 disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), 0285 this, SLOT(slotRangeChanged(QtProperty*,int,int))); 0286 disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), 0287 this, SLOT(slotSingleStepChanged(QtProperty*,int))); 0288 } 0289 0290 // QtSliderFactory 0291 0292 class QtSliderFactoryPrivate : public EditorFactoryPrivate<QSlider> 0293 { 0294 QtSliderFactory *q_ptr; 0295 Q_DECLARE_PUBLIC(QtSliderFactory) 0296 public: 0297 void slotPropertyChanged(QtProperty *property, int value); 0298 void slotRangeChanged(QtProperty *property, int min, int max); 0299 void slotSingleStepChanged(QtProperty *property, int step); 0300 void slotSetValue(int value); 0301 }; 0302 0303 void QtSliderFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) 0304 { 0305 const auto it = m_createdEditors.constFind(property); 0306 if (it == m_createdEditors.cend()) 0307 return; 0308 for (QSlider *editor : it.value()) { 0309 editor->blockSignals(true); 0310 editor->setValue(value); 0311 editor->blockSignals(false); 0312 } 0313 } 0314 0315 void QtSliderFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max) 0316 { 0317 const auto it = m_createdEditors.constFind(property); 0318 if (it == m_createdEditors.cend()) 0319 return; 0320 0321 QtIntPropertyManager *manager = q_ptr->propertyManager(property); 0322 if (!manager) 0323 return; 0324 0325 for (QSlider *editor : it.value()) { 0326 editor->blockSignals(true); 0327 editor->setRange(min, max); 0328 editor->setValue(manager->value(property)); 0329 editor->blockSignals(false); 0330 } 0331 } 0332 0333 void QtSliderFactoryPrivate::slotSingleStepChanged(QtProperty *property, int step) 0334 { 0335 const auto it = m_createdEditors.constFind(property); 0336 if (it == m_createdEditors.cend()) 0337 return; 0338 for (QSlider *editor : it.value()) { 0339 editor->blockSignals(true); 0340 editor->setSingleStep(step); 0341 editor->blockSignals(false); 0342 } 0343 } 0344 0345 void QtSliderFactoryPrivate::slotSetValue(int value) 0346 { 0347 QObject *object = q_ptr->sender(); 0348 const QMap<QSlider *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 0349 for (QMap<QSlider *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor ) { 0350 if (itEditor.key() == object) { 0351 QtProperty *property = itEditor.value(); 0352 QtIntPropertyManager *manager = q_ptr->propertyManager(property); 0353 if (!manager) 0354 return; 0355 manager->setValue(property, value); 0356 return; 0357 } 0358 } 0359 } 0360 0361 /*! 0362 \class QtSliderFactory 0363 \internal 0364 \inmodule QtDesigner 0365 \since 4.4 0366 0367 \brief The QtSliderFactory class provides QSlider widgets for 0368 properties created by QtIntPropertyManager objects. 0369 0370 \sa QtAbstractEditorFactory, QtIntPropertyManager 0371 */ 0372 0373 /*! 0374 Creates a factory with the given \a parent. 0375 */ 0376 QtSliderFactory::QtSliderFactory(QObject *parent) 0377 : QtAbstractEditorFactory<QtIntPropertyManager>(parent), d_ptr(new QtSliderFactoryPrivate()) 0378 { 0379 d_ptr->q_ptr = this; 0380 0381 } 0382 0383 /*! 0384 Destroys this factory, and all the widgets it has created. 0385 */ 0386 QtSliderFactory::~QtSliderFactory() 0387 { 0388 qDeleteAll(d_ptr->m_editorToProperty.keys()); 0389 } 0390 0391 /*! 0392 \internal 0393 0394 Reimplemented from the QtAbstractEditorFactory class. 0395 */ 0396 void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager) 0397 { 0398 connect(manager, SIGNAL(valueChanged(QtProperty*,int)), 0399 this, SLOT(slotPropertyChanged(QtProperty*,int))); 0400 connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), 0401 this, SLOT(slotRangeChanged(QtProperty*,int,int))); 0402 connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), 0403 this, SLOT(slotSingleStepChanged(QtProperty*,int))); 0404 } 0405 0406 /*! 0407 \internal 0408 0409 Reimplemented from the QtAbstractEditorFactory class. 0410 */ 0411 QWidget *QtSliderFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property, 0412 QWidget *parent) 0413 { 0414 QSlider *editor = new QSlider(Qt::Horizontal, parent); 0415 d_ptr->initializeEditor(property, editor); 0416 editor->setSingleStep(manager->singleStep(property)); 0417 editor->setRange(manager->minimum(property), manager->maximum(property)); 0418 editor->setValue(manager->value(property)); 0419 0420 connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); 0421 connect(editor, SIGNAL(destroyed(QObject*)), 0422 this, SLOT(slotEditorDestroyed(QObject*))); 0423 return editor; 0424 } 0425 0426 /*! 0427 \internal 0428 0429 Reimplemented from the QtAbstractEditorFactory class. 0430 */ 0431 void QtSliderFactory::disconnectPropertyManager(QtIntPropertyManager *manager) 0432 { 0433 disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), 0434 this, SLOT(slotPropertyChanged(QtProperty*,int))); 0435 disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), 0436 this, SLOT(slotRangeChanged(QtProperty*,int,int))); 0437 disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), 0438 this, SLOT(slotSingleStepChanged(QtProperty*,int))); 0439 } 0440 0441 // QtSliderFactory 0442 0443 class QtScrollBarFactoryPrivate : public EditorFactoryPrivate<QScrollBar> 0444 { 0445 QtScrollBarFactory *q_ptr; 0446 Q_DECLARE_PUBLIC(QtScrollBarFactory) 0447 public: 0448 void slotPropertyChanged(QtProperty *property, int value); 0449 void slotRangeChanged(QtProperty *property, int min, int max); 0450 void slotSingleStepChanged(QtProperty *property, int step); 0451 void slotSetValue(int value); 0452 }; 0453 0454 void QtScrollBarFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) 0455 { 0456 const auto it = m_createdEditors.constFind(property); 0457 if (it == m_createdEditors.cend()) 0458 return; 0459 0460 for (QScrollBar *editor : it.value()) { 0461 editor->blockSignals(true); 0462 editor->setValue(value); 0463 editor->blockSignals(false); 0464 } 0465 } 0466 0467 void QtScrollBarFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max) 0468 { 0469 const auto it = m_createdEditors.constFind(property); 0470 if (it == m_createdEditors.cend()) 0471 return; 0472 0473 QtIntPropertyManager *manager = q_ptr->propertyManager(property); 0474 if (!manager) 0475 return; 0476 0477 for (QScrollBar *editor : it.value()) { 0478 editor->blockSignals(true); 0479 editor->setRange(min, max); 0480 editor->setValue(manager->value(property)); 0481 editor->blockSignals(false); 0482 } 0483 } 0484 0485 void QtScrollBarFactoryPrivate::slotSingleStepChanged(QtProperty *property, int step) 0486 { 0487 const auto it = m_createdEditors.constFind(property); 0488 if (it == m_createdEditors.cend()) 0489 return; 0490 for (QScrollBar *editor : it.value()) { 0491 editor->blockSignals(true); 0492 editor->setSingleStep(step); 0493 editor->blockSignals(false); 0494 } 0495 } 0496 0497 void QtScrollBarFactoryPrivate::slotSetValue(int value) 0498 { 0499 QObject *object = q_ptr->sender(); 0500 const QMap<QScrollBar *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 0501 for (QMap<QScrollBar *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 0502 if (itEditor.key() == object) { 0503 QtProperty *property = itEditor.value(); 0504 QtIntPropertyManager *manager = q_ptr->propertyManager(property); 0505 if (!manager) 0506 return; 0507 manager->setValue(property, value); 0508 return; 0509 } 0510 } 0511 0512 /*! 0513 \class QtScrollBarFactory 0514 \internal 0515 \inmodule QtDesigner 0516 \since 4.4 0517 0518 \brief The QtScrollBarFactory class provides QScrollBar widgets for 0519 properties created by QtIntPropertyManager objects. 0520 0521 \sa QtAbstractEditorFactory, QtIntPropertyManager 0522 */ 0523 0524 /*! 0525 Creates a factory with the given \a parent. 0526 */ 0527 QtScrollBarFactory::QtScrollBarFactory(QObject *parent) 0528 : QtAbstractEditorFactory<QtIntPropertyManager>(parent), d_ptr(new QtScrollBarFactoryPrivate()) 0529 { 0530 d_ptr->q_ptr = this; 0531 0532 } 0533 0534 /*! 0535 Destroys this factory, and all the widgets it has created. 0536 */ 0537 QtScrollBarFactory::~QtScrollBarFactory() 0538 { 0539 qDeleteAll(d_ptr->m_editorToProperty.keys()); 0540 } 0541 0542 /*! 0543 \internal 0544 0545 Reimplemented from the QtAbstractEditorFactory class. 0546 */ 0547 void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager) 0548 { 0549 connect(manager, SIGNAL(valueChanged(QtProperty*,int)), 0550 this, SLOT(slotPropertyChanged(QtProperty*,int))); 0551 connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), 0552 this, SLOT(slotRangeChanged(QtProperty*,int,int))); 0553 connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), 0554 this, SLOT(slotSingleStepChanged(QtProperty*,int))); 0555 } 0556 0557 /*! 0558 \internal 0559 0560 Reimplemented from the QtAbstractEditorFactory class. 0561 */ 0562 QWidget *QtScrollBarFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property, 0563 QWidget *parent) 0564 { 0565 QScrollBar *editor = new QScrollBar(Qt::Horizontal, parent); 0566 d_ptr->initializeEditor(property, editor); 0567 editor->setSingleStep(manager->singleStep(property)); 0568 editor->setRange(manager->minimum(property), manager->maximum(property)); 0569 editor->setValue(manager->value(property)); 0570 connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); 0571 connect(editor, SIGNAL(destroyed(QObject*)), 0572 this, SLOT(slotEditorDestroyed(QObject*))); 0573 return editor; 0574 } 0575 0576 /*! 0577 \internal 0578 0579 Reimplemented from the QtAbstractEditorFactory class. 0580 */ 0581 void QtScrollBarFactory::disconnectPropertyManager(QtIntPropertyManager *manager) 0582 { 0583 disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), 0584 this, SLOT(slotPropertyChanged(QtProperty*,int))); 0585 disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), 0586 this, SLOT(slotRangeChanged(QtProperty*,int,int))); 0587 disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), 0588 this, SLOT(slotSingleStepChanged(QtProperty*,int))); 0589 } 0590 0591 // QtCheckBoxFactory 0592 0593 class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate<QtBoolEdit> 0594 { 0595 QtCheckBoxFactory *q_ptr; 0596 Q_DECLARE_PUBLIC(QtCheckBoxFactory) 0597 public: 0598 void slotPropertyChanged(QtProperty *property, bool value); 0599 void slotSetValue(bool value); 0600 }; 0601 0602 void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value) 0603 { 0604 const auto it = m_createdEditors.constFind(property); 0605 if (it == m_createdEditors.cend()) 0606 return; 0607 0608 for (QtBoolEdit *editor : it.value()) { 0609 editor->blockCheckBoxSignals(true); 0610 editor->setChecked(value); 0611 editor->blockCheckBoxSignals(false); 0612 } 0613 } 0614 0615 void QtCheckBoxFactoryPrivate::slotSetValue(bool value) 0616 { 0617 QObject *object = q_ptr->sender(); 0618 0619 const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 0620 for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 0621 if (itEditor.key() == object) { 0622 QtProperty *property = itEditor.value(); 0623 QtBoolPropertyManager *manager = q_ptr->propertyManager(property); 0624 if (!manager) 0625 return; 0626 manager->setValue(property, value); 0627 return; 0628 } 0629 } 0630 0631 /*! 0632 \class QtCheckBoxFactory 0633 \internal 0634 \inmodule QtDesigner 0635 \since 4.4 0636 0637 \brief The QtCheckBoxFactory class provides QCheckBox widgets for 0638 properties created by QtBoolPropertyManager objects. 0639 0640 \sa QtAbstractEditorFactory, QtBoolPropertyManager 0641 */ 0642 0643 /*! 0644 Creates a factory with the given \a parent. 0645 */ 0646 QtCheckBoxFactory::QtCheckBoxFactory(QObject *parent) 0647 : QtAbstractEditorFactory<QtBoolPropertyManager>(parent), d_ptr(new QtCheckBoxFactoryPrivate()) 0648 { 0649 d_ptr->q_ptr = this; 0650 0651 } 0652 0653 /*! 0654 Destroys this factory, and all the widgets it has created. 0655 */ 0656 QtCheckBoxFactory::~QtCheckBoxFactory() 0657 { 0658 qDeleteAll(d_ptr->m_editorToProperty.keys()); 0659 } 0660 0661 /*! 0662 \internal 0663 0664 Reimplemented from the QtAbstractEditorFactory class. 0665 */ 0666 void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager) 0667 { 0668 connect(manager, SIGNAL(valueChanged(QtProperty*,bool)), 0669 this, SLOT(slotPropertyChanged(QtProperty*,bool))); 0670 } 0671 0672 /*! 0673 \internal 0674 0675 Reimplemented from the QtAbstractEditorFactory class. 0676 */ 0677 QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtProperty *property, 0678 QWidget *parent) 0679 { 0680 QtBoolEdit *editor = d_ptr->createEditor(property, parent); 0681 editor->setChecked(manager->value(property)); 0682 0683 connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); 0684 connect(editor, SIGNAL(destroyed(QObject*)), 0685 this, SLOT(slotEditorDestroyed(QObject*))); 0686 return editor; 0687 } 0688 0689 /*! 0690 \internal 0691 0692 Reimplemented from the QtAbstractEditorFactory class. 0693 */ 0694 void QtCheckBoxFactory::disconnectPropertyManager(QtBoolPropertyManager *manager) 0695 { 0696 disconnect(manager, SIGNAL(valueChanged(QtProperty*,bool)), 0697 this, SLOT(slotPropertyChanged(QtProperty*,bool))); 0698 } 0699 0700 // QtDoubleSpinBoxFactory 0701 0702 class QtDoubleSpinBoxFactoryPrivate : public EditorFactoryPrivate<QDoubleSpinBox> 0703 { 0704 QtDoubleSpinBoxFactory *q_ptr; 0705 Q_DECLARE_PUBLIC(QtDoubleSpinBoxFactory) 0706 public: 0707 0708 void slotPropertyChanged(QtProperty *property, double value); 0709 void slotRangeChanged(QtProperty *property, double min, double max); 0710 void slotSingleStepChanged(QtProperty *property, double step); 0711 void slotDecimalsChanged(QtProperty *property, int prec); 0712 void slotSetValue(double value); 0713 }; 0714 0715 void QtDoubleSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, double value) 0716 { 0717 const auto it = m_createdEditors.constFind(property); 0718 if (it == m_createdEditors.cend()) 0719 return; 0720 for (QDoubleSpinBox *editor : it.value()) { 0721 if (editor->value() != value) { 0722 editor->blockSignals(true); 0723 editor->setValue(value); 0724 editor->blockSignals(false); 0725 } 0726 } 0727 } 0728 0729 void QtDoubleSpinBoxFactoryPrivate::slotRangeChanged(QtProperty *property, 0730 double min, double max) 0731 { 0732 const auto it = m_createdEditors.constFind(property); 0733 if (it == m_createdEditors.cend()) 0734 return; 0735 0736 QtDoublePropertyManager *manager = q_ptr->propertyManager(property); 0737 if (!manager) 0738 return; 0739 0740 for (QDoubleSpinBox *editor : it.value()) { 0741 editor->blockSignals(true); 0742 editor->setRange(min, max); 0743 editor->setValue(manager->value(property)); 0744 editor->blockSignals(false); 0745 } 0746 } 0747 0748 void QtDoubleSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, double step) 0749 { 0750 const auto it = m_createdEditors.constFind(property); 0751 if (it == m_createdEditors.cend()) 0752 return; 0753 0754 QtDoublePropertyManager *manager = q_ptr->propertyManager(property); 0755 if (!manager) 0756 return; 0757 0758 for (QDoubleSpinBox *editor : it.value()) { 0759 editor->blockSignals(true); 0760 editor->setSingleStep(step); 0761 editor->blockSignals(false); 0762 } 0763 } 0764 0765 void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(QtProperty *property, int prec) 0766 { 0767 const auto it = m_createdEditors.constFind(property); 0768 if (it == m_createdEditors.constEnd()) 0769 return; 0770 0771 QtDoublePropertyManager *manager = q_ptr->propertyManager(property); 0772 if (!manager) 0773 return; 0774 0775 for (QDoubleSpinBox *editor : it.value()) { 0776 editor->blockSignals(true); 0777 editor->setDecimals(prec); 0778 editor->setValue(manager->value(property)); 0779 editor->blockSignals(false); 0780 } 0781 } 0782 0783 void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value) 0784 { 0785 QObject *object = q_ptr->sender(); 0786 const QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itcend = m_editorToProperty.constEnd(); 0787 for (QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor) { 0788 if (itEditor.key() == object) { 0789 QtProperty *property = itEditor.value(); 0790 QtDoublePropertyManager *manager = q_ptr->propertyManager(property); 0791 if (!manager) 0792 return; 0793 manager->setValue(property, value); 0794 return; 0795 } 0796 } 0797 } 0798 0799 /*! \class QtDoubleSpinBoxFactory 0800 \internal 0801 \inmodule QtDesigner 0802 \since 4.4 0803 0804 \brief The QtDoubleSpinBoxFactory class provides QDoubleSpinBox 0805 widgets for properties created by QtDoublePropertyManager objects. 0806 0807 \sa QtAbstractEditorFactory, QtDoublePropertyManager 0808 */ 0809 0810 /*! 0811 Creates a factory with the given \a parent. 0812 */ 0813 QtDoubleSpinBoxFactory::QtDoubleSpinBoxFactory(QObject *parent) 0814 : QtAbstractEditorFactory<QtDoublePropertyManager>(parent), d_ptr(new QtDoubleSpinBoxFactoryPrivate()) 0815 { 0816 d_ptr->q_ptr = this; 0817 0818 } 0819 0820 /*! 0821 Destroys this factory, and all the widgets it has created. 0822 */ 0823 QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory() 0824 { 0825 qDeleteAll(d_ptr->m_editorToProperty.keys()); 0826 } 0827 0828 /*! 0829 \internal 0830 0831 Reimplemented from the QtAbstractEditorFactory class. 0832 */ 0833 void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager *manager) 0834 { 0835 connect(manager, SIGNAL(valueChanged(QtProperty*,double)), 0836 this, SLOT(slotPropertyChanged(QtProperty*,double))); 0837 connect(manager, SIGNAL(rangeChanged(QtProperty*,double,double)), 0838 this, SLOT(slotRangeChanged(QtProperty*,double,double))); 0839 connect(manager, SIGNAL(singleStepChanged(QtProperty*,double)), 0840 this, SLOT(slotSingleStepChanged(QtProperty*,double))); 0841 connect(manager, SIGNAL(decimalsChanged(QtProperty*,int)), 0842 this, SLOT(slotDecimalsChanged(QtProperty*,int))); 0843 } 0844 0845 /*! 0846 \internal 0847 0848 Reimplemented from the QtAbstractEditorFactory class. 0849 */ 0850 QWidget *QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager *manager, 0851 QtProperty *property, QWidget *parent) 0852 { 0853 QDoubleSpinBox *editor = d_ptr->createEditor(property, parent); 0854 editor->setSingleStep(manager->singleStep(property)); 0855 editor->setDecimals(manager->decimals(property)); 0856 editor->setRange(manager->minimum(property), manager->maximum(property)); 0857 editor->setValue(manager->value(property)); 0858 editor->setKeyboardTracking(false); 0859 0860 connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double))); 0861 connect(editor, SIGNAL(destroyed(QObject*)), 0862 this, SLOT(slotEditorDestroyed(QObject*))); 0863 return editor; 0864 } 0865 0866 /*! 0867 \internal 0868 0869 Reimplemented from the QtAbstractEditorFactory class. 0870 */ 0871 void QtDoubleSpinBoxFactory::disconnectPropertyManager(QtDoublePropertyManager *manager) 0872 { 0873 disconnect(manager, SIGNAL(valueChanged(QtProperty*,double)), 0874 this, SLOT(slotPropertyChanged(QtProperty*,double))); 0875 disconnect(manager, SIGNAL(rangeChanged(QtProperty*,double,double)), 0876 this, SLOT(slotRangeChanged(QtProperty*,double,double))); 0877 disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,double)), 0878 this, SLOT(slotSingleStepChanged(QtProperty*,double))); 0879 disconnect(manager, SIGNAL(decimalsChanged(QtProperty*,int)), 0880 this, SLOT(slotDecimalsChanged(QtProperty*,int))); 0881 } 0882 0883 // QtLineEditFactory 0884 0885 class QtLineEditFactoryPrivate : public EditorFactoryPrivate<QLineEdit> 0886 { 0887 QtLineEditFactory *q_ptr; 0888 Q_DECLARE_PUBLIC(QtLineEditFactory) 0889 public: 0890 0891 void slotPropertyChanged(QtProperty *property, const QString &value); 0892 void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp); 0893 void slotSetValue(const QString &value); 0894 }; 0895 0896 void QtLineEditFactoryPrivate::slotPropertyChanged(QtProperty *property, 0897 const QString &value) 0898 { 0899 const auto it = m_createdEditors.constFind(property); 0900 if (it == m_createdEditors.constEnd()) 0901 return; 0902 0903 for (QLineEdit *editor : it.value()) { 0904 if (editor->text() != value) 0905 editor->setText(value); 0906 } 0907 } 0908 0909 void QtLineEditFactoryPrivate::slotRegExpChanged(QtProperty *property, 0910 const QRegExp ®Exp) 0911 { 0912 const auto it = m_createdEditors.constFind(property); 0913 if (it == m_createdEditors.constEnd()) 0914 return; 0915 0916 QtStringPropertyManager *manager = q_ptr->propertyManager(property); 0917 if (!manager) 0918 return; 0919 0920 for (QLineEdit *editor : it.value()) { 0921 editor->blockSignals(true); 0922 const QValidator *oldValidator = editor->validator(); 0923 QValidator *newValidator = 0; 0924 if (regExp.isValid()) { 0925 newValidator = new QRegExpValidator(regExp, editor); 0926 } 0927 editor->setValidator(newValidator); 0928 if (oldValidator) 0929 delete oldValidator; 0930 editor->blockSignals(false); 0931 } 0932 } 0933 0934 void QtLineEditFactoryPrivate::slotSetValue(const QString &value) 0935 { 0936 QObject *object = q_ptr->sender(); 0937 const QMap<QLineEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 0938 for (QMap<QLineEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 0939 if (itEditor.key() == object) { 0940 QtProperty *property = itEditor.value(); 0941 QtStringPropertyManager *manager = q_ptr->propertyManager(property); 0942 if (!manager) 0943 return; 0944 manager->setValue(property, value); 0945 return; 0946 } 0947 } 0948 0949 /*! 0950 \class QtLineEditFactory 0951 \internal 0952 \inmodule QtDesigner 0953 \since 4.4 0954 0955 \brief The QtLineEditFactory class provides QLineEdit widgets for 0956 properties created by QtStringPropertyManager objects. 0957 0958 \sa QtAbstractEditorFactory, QtStringPropertyManager 0959 */ 0960 0961 /*! 0962 Creates a factory with the given \a parent. 0963 */ 0964 QtLineEditFactory::QtLineEditFactory(QObject *parent) 0965 : QtAbstractEditorFactory<QtStringPropertyManager>(parent), d_ptr(new QtLineEditFactoryPrivate()) 0966 { 0967 d_ptr->q_ptr = this; 0968 0969 } 0970 0971 /*! 0972 Destroys this factory, and all the widgets it has created. 0973 */ 0974 QtLineEditFactory::~QtLineEditFactory() 0975 { 0976 qDeleteAll(d_ptr->m_editorToProperty.keys()); 0977 } 0978 0979 /*! 0980 \internal 0981 0982 Reimplemented from the QtAbstractEditorFactory class. 0983 */ 0984 void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager) 0985 { 0986 connect(manager, SIGNAL(valueChanged(QtProperty*,QString)), 0987 this, SLOT(slotPropertyChanged(QtProperty*,QString))); 0988 connect(manager, SIGNAL(regExpChanged(QtProperty*,QRegExp)), 0989 this, SLOT(slotRegExpChanged(QtProperty*,QRegExp))); 0990 } 0991 0992 /*! 0993 \internal 0994 0995 Reimplemented from the QtAbstractEditorFactory class. 0996 */ 0997 QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager, 0998 QtProperty *property, QWidget *parent) 0999 { 1000 1001 QLineEdit *editor = d_ptr->createEditor(property, parent); 1002 QRegExp regExp = manager->regExp(property); 1003 if (regExp.isValid()) { 1004 QValidator *validator = new QRegExpValidator(regExp, editor); 1005 editor->setValidator(validator); 1006 } 1007 editor->setText(manager->value(property)); 1008 1009 connect(editor, SIGNAL(textEdited(QString)), 1010 this, SLOT(slotSetValue(QString))); 1011 connect(editor, SIGNAL(destroyed(QObject*)), 1012 this, SLOT(slotEditorDestroyed(QObject*))); 1013 return editor; 1014 } 1015 1016 /*! 1017 \internal 1018 1019 Reimplemented from the QtAbstractEditorFactory class. 1020 */ 1021 void QtLineEditFactory::disconnectPropertyManager(QtStringPropertyManager *manager) 1022 { 1023 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QString)), 1024 this, SLOT(slotPropertyChanged(QtProperty*,QString))); 1025 disconnect(manager, SIGNAL(regExpChanged(QtProperty*,QRegExp)), 1026 this, SLOT(slotRegExpChanged(QtProperty*,QRegExp))); 1027 } 1028 1029 // QtDateEditFactory 1030 1031 class QtDateEditFactoryPrivate : public EditorFactoryPrivate<QDateEdit> 1032 { 1033 QtDateEditFactory *q_ptr; 1034 Q_DECLARE_PUBLIC(QtDateEditFactory) 1035 public: 1036 1037 void slotPropertyChanged(QtProperty *property, const QDate &value); 1038 void slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max); 1039 void slotSetValue(const QDate &value); 1040 }; 1041 1042 void QtDateEditFactoryPrivate::slotPropertyChanged(QtProperty *property, const QDate &value) 1043 { 1044 const auto it = m_createdEditors.constFind(property); 1045 if (it == m_createdEditors.constEnd()) 1046 return; 1047 for (QDateEdit *editor : it.value()) { 1048 editor->blockSignals(true); 1049 editor->setDate(value); 1050 editor->blockSignals(false); 1051 } 1052 } 1053 1054 void QtDateEditFactoryPrivate::slotRangeChanged(QtProperty *property, 1055 const QDate &min, const QDate &max) 1056 { 1057 const auto it = m_createdEditors.constFind(property); 1058 if (it == m_createdEditors.constEnd()) 1059 return; 1060 1061 QtDatePropertyManager *manager = q_ptr->propertyManager(property); 1062 if (!manager) 1063 return; 1064 1065 for (QDateEdit *editor : it.value()) { 1066 editor->blockSignals(true); 1067 editor->setDateRange(min, max); 1068 editor->setDate(manager->value(property)); 1069 editor->blockSignals(false); 1070 } 1071 } 1072 1073 void QtDateEditFactoryPrivate::slotSetValue(const QDate &value) 1074 { 1075 QObject *object = q_ptr->sender(); 1076 const QMap<QDateEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 1077 for (QMap<QDateEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 1078 if (itEditor.key() == object) { 1079 QtProperty *property = itEditor.value(); 1080 QtDatePropertyManager *manager = q_ptr->propertyManager(property); 1081 if (!manager) 1082 return; 1083 manager->setValue(property, value); 1084 return; 1085 } 1086 } 1087 1088 /*! 1089 \class QtDateEditFactory 1090 \internal 1091 \inmodule QtDesigner 1092 \since 4.4 1093 1094 \brief The QtDateEditFactory class provides QDateEdit widgets for 1095 properties created by QtDatePropertyManager objects. 1096 1097 \sa QtAbstractEditorFactory, QtDatePropertyManager 1098 */ 1099 1100 /*! 1101 Creates a factory with the given \a parent. 1102 */ 1103 QtDateEditFactory::QtDateEditFactory(QObject *parent) 1104 : QtAbstractEditorFactory<QtDatePropertyManager>(parent), d_ptr(new QtDateEditFactoryPrivate()) 1105 { 1106 d_ptr->q_ptr = this; 1107 1108 } 1109 1110 /*! 1111 Destroys this factory, and all the widgets it has created. 1112 */ 1113 QtDateEditFactory::~QtDateEditFactory() 1114 { 1115 qDeleteAll(d_ptr->m_editorToProperty.keys()); 1116 } 1117 1118 /*! 1119 \internal 1120 1121 Reimplemented from the QtAbstractEditorFactory class. 1122 */ 1123 void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager *manager) 1124 { 1125 connect(manager, SIGNAL(valueChanged(QtProperty*,QDate)), 1126 this, SLOT(slotPropertyChanged(QtProperty*,QDate))); 1127 connect(manager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)), 1128 this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate))); 1129 } 1130 1131 /*! 1132 \internal 1133 1134 Reimplemented from the QtAbstractEditorFactory class. 1135 */ 1136 QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtProperty *property, 1137 QWidget *parent) 1138 { 1139 QDateEdit *editor = d_ptr->createEditor(property, parent); 1140 editor->setDisplayFormat(QtPropertyBrowserUtils::dateFormat()); 1141 editor->setCalendarPopup(true); 1142 editor->setDateRange(manager->minimum(property), manager->maximum(property)); 1143 editor->setDate(manager->value(property)); 1144 1145 connect(editor, SIGNAL(dateChanged(QDate)), 1146 this, SLOT(slotSetValue(QDate))); 1147 connect(editor, SIGNAL(destroyed(QObject*)), 1148 this, SLOT(slotEditorDestroyed(QObject*))); 1149 return editor; 1150 } 1151 1152 /*! 1153 \internal 1154 1155 Reimplemented from the QtAbstractEditorFactory class. 1156 */ 1157 void QtDateEditFactory::disconnectPropertyManager(QtDatePropertyManager *manager) 1158 { 1159 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QDate)), 1160 this, SLOT(slotPropertyChanged(QtProperty*,QDate))); 1161 disconnect(manager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)), 1162 this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate))); 1163 } 1164 1165 // QtTimeEditFactory 1166 1167 class QtTimeEditFactoryPrivate : public EditorFactoryPrivate<QTimeEdit> 1168 { 1169 QtTimeEditFactory *q_ptr; 1170 Q_DECLARE_PUBLIC(QtTimeEditFactory) 1171 public: 1172 1173 void slotPropertyChanged(QtProperty *property, const QTime &value); 1174 void slotSetValue(const QTime &value); 1175 }; 1176 1177 void QtTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, const QTime &value) 1178 { 1179 const auto it = m_createdEditors.constFind(property); 1180 if (it == m_createdEditors.constEnd()) 1181 return; 1182 for (QTimeEdit *editor : it.value()) { 1183 editor->blockSignals(true); 1184 editor->setTime(value); 1185 editor->blockSignals(false); 1186 } 1187 } 1188 1189 void QtTimeEditFactoryPrivate::slotSetValue(const QTime &value) 1190 { 1191 QObject *object = q_ptr->sender(); 1192 const QMap<QTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 1193 for (QMap<QTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 1194 if (itEditor.key() == object) { 1195 QtProperty *property = itEditor.value(); 1196 QtTimePropertyManager *manager = q_ptr->propertyManager(property); 1197 if (!manager) 1198 return; 1199 manager->setValue(property, value); 1200 return; 1201 } 1202 } 1203 1204 /*! 1205 \class QtTimeEditFactory 1206 \internal 1207 \inmodule QtDesigner 1208 \since 4.4 1209 1210 \brief The QtTimeEditFactory class provides QTimeEdit widgets for 1211 properties created by QtTimePropertyManager objects. 1212 1213 \sa QtAbstractEditorFactory, QtTimePropertyManager 1214 */ 1215 1216 /*! 1217 Creates a factory with the given \a parent. 1218 */ 1219 QtTimeEditFactory::QtTimeEditFactory(QObject *parent) 1220 : QtAbstractEditorFactory<QtTimePropertyManager>(parent), d_ptr(new QtTimeEditFactoryPrivate()) 1221 { 1222 d_ptr->q_ptr = this; 1223 1224 } 1225 1226 /*! 1227 Destroys this factory, and all the widgets it has created. 1228 */ 1229 QtTimeEditFactory::~QtTimeEditFactory() 1230 { 1231 qDeleteAll(d_ptr->m_editorToProperty.keys()); 1232 } 1233 1234 /*! 1235 \internal 1236 1237 Reimplemented from the QtAbstractEditorFactory class. 1238 */ 1239 void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager *manager) 1240 { 1241 connect(manager, SIGNAL(valueChanged(QtProperty*,QTime)), 1242 this, SLOT(slotPropertyChanged(QtProperty*,QTime))); 1243 } 1244 1245 /*! 1246 \internal 1247 1248 Reimplemented from the QtAbstractEditorFactory class. 1249 */ 1250 QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtProperty *property, 1251 QWidget *parent) 1252 { 1253 QTimeEdit *editor = d_ptr->createEditor(property, parent); 1254 editor->setDisplayFormat(QtPropertyBrowserUtils::timeFormat()); 1255 editor->setTime(manager->value(property)); 1256 1257 connect(editor, SIGNAL(timeChanged(QTime)), 1258 this, SLOT(slotSetValue(QTime))); 1259 connect(editor, SIGNAL(destroyed(QObject*)), 1260 this, SLOT(slotEditorDestroyed(QObject*))); 1261 return editor; 1262 } 1263 1264 /*! 1265 \internal 1266 1267 Reimplemented from the QtAbstractEditorFactory class. 1268 */ 1269 void QtTimeEditFactory::disconnectPropertyManager(QtTimePropertyManager *manager) 1270 { 1271 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QTime)), 1272 this, SLOT(slotPropertyChanged(QtProperty*,QTime))); 1273 } 1274 1275 // QtDateTimeEditFactory 1276 1277 class QtDateTimeEditFactoryPrivate : public EditorFactoryPrivate<QDateTimeEdit> 1278 { 1279 QtDateTimeEditFactory *q_ptr; 1280 Q_DECLARE_PUBLIC(QtDateTimeEditFactory) 1281 public: 1282 1283 void slotPropertyChanged(QtProperty *property, const QDateTime &value); 1284 void slotSetValue(const QDateTime &value); 1285 1286 }; 1287 1288 void QtDateTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, 1289 const QDateTime &value) 1290 { 1291 const auto it = m_createdEditors.constFind(property); 1292 if (it == m_createdEditors.constEnd()) 1293 return; 1294 1295 for (QDateTimeEdit *editor : it.value()) { 1296 editor->blockSignals(true); 1297 editor->setDateTime(value); 1298 editor->blockSignals(false); 1299 } 1300 } 1301 1302 void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime &value) 1303 { 1304 QObject *object = q_ptr->sender(); 1305 const QMap<QDateTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 1306 for (QMap<QDateTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 1307 if (itEditor.key() == object) { 1308 QtProperty *property = itEditor.value(); 1309 QtDateTimePropertyManager *manager = q_ptr->propertyManager(property); 1310 if (!manager) 1311 return; 1312 manager->setValue(property, value); 1313 return; 1314 } 1315 } 1316 1317 /*! 1318 \class QtDateTimeEditFactory 1319 \internal 1320 \inmodule QtDesigner 1321 \since 4.4 1322 1323 \brief The QtDateTimeEditFactory class provides QDateTimeEdit 1324 widgets for properties created by QtDateTimePropertyManager objects. 1325 1326 \sa QtAbstractEditorFactory, QtDateTimePropertyManager 1327 */ 1328 1329 /*! 1330 Creates a factory with the given \a parent. 1331 */ 1332 QtDateTimeEditFactory::QtDateTimeEditFactory(QObject *parent) 1333 : QtAbstractEditorFactory<QtDateTimePropertyManager>(parent), d_ptr(new QtDateTimeEditFactoryPrivate()) 1334 { 1335 d_ptr->q_ptr = this; 1336 1337 } 1338 1339 /*! 1340 Destroys this factory, and all the widgets it has created. 1341 */ 1342 QtDateTimeEditFactory::~QtDateTimeEditFactory() 1343 { 1344 qDeleteAll(d_ptr->m_editorToProperty.keys()); 1345 } 1346 1347 /*! 1348 \internal 1349 1350 Reimplemented from the QtAbstractEditorFactory class. 1351 */ 1352 void QtDateTimeEditFactory::connectPropertyManager(QtDateTimePropertyManager *manager) 1353 { 1354 connect(manager, SIGNAL(valueChanged(QtProperty*,QDateTime)), 1355 this, SLOT(slotPropertyChanged(QtProperty*,QDateTime))); 1356 } 1357 1358 /*! 1359 \internal 1360 1361 Reimplemented from the QtAbstractEditorFactory class. 1362 */ 1363 QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager, 1364 QtProperty *property, QWidget *parent) 1365 { 1366 QDateTimeEdit *editor = d_ptr->createEditor(property, parent); 1367 editor->setDisplayFormat(QtPropertyBrowserUtils::dateTimeFormat()); 1368 editor->setDateTime(manager->value(property)); 1369 1370 connect(editor, SIGNAL(dateTimeChanged(QDateTime)), 1371 this, SLOT(slotSetValue(QDateTime))); 1372 connect(editor, SIGNAL(destroyed(QObject*)), 1373 this, SLOT(slotEditorDestroyed(QObject*))); 1374 return editor; 1375 } 1376 1377 /*! 1378 \internal 1379 1380 Reimplemented from the QtAbstractEditorFactory class. 1381 */ 1382 void QtDateTimeEditFactory::disconnectPropertyManager(QtDateTimePropertyManager *manager) 1383 { 1384 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QDateTime)), 1385 this, SLOT(slotPropertyChanged(QtProperty*,QDateTime))); 1386 } 1387 1388 // QtKeySequenceEditorFactory 1389 1390 class QtKeySequenceEditorFactoryPrivate : public EditorFactoryPrivate<QKeySequenceEdit> 1391 { 1392 QtKeySequenceEditorFactory *q_ptr; 1393 Q_DECLARE_PUBLIC(QtKeySequenceEditorFactory) 1394 public: 1395 1396 void slotPropertyChanged(QtProperty *property, const QKeySequence &value); 1397 void slotSetValue(const QKeySequence &value); 1398 }; 1399 1400 void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, 1401 const QKeySequence &value) 1402 { 1403 const auto it = m_createdEditors.constFind(property); 1404 if (it == m_createdEditors.constEnd()) 1405 return; 1406 1407 for (QKeySequenceEdit *editor : it.value()) { 1408 editor->blockSignals(true); 1409 editor->setKeySequence(value); 1410 editor->blockSignals(false); 1411 } 1412 } 1413 1414 void QtKeySequenceEditorFactoryPrivate::slotSetValue(const QKeySequence &value) 1415 { 1416 QObject *object = q_ptr->sender(); 1417 const QMap<QKeySequenceEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 1418 for (QMap<QKeySequenceEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 1419 if (itEditor.key() == object) { 1420 QtProperty *property = itEditor.value(); 1421 QtKeySequencePropertyManager *manager = q_ptr->propertyManager(property); 1422 if (!manager) 1423 return; 1424 manager->setValue(property, value); 1425 return; 1426 } 1427 } 1428 1429 /*! 1430 \class QtKeySequenceEditorFactory 1431 \internal 1432 \inmodule QtDesigner 1433 \since 4.4 1434 1435 \brief The QtKeySequenceEditorFactory class provides editor 1436 widgets for properties created by QtKeySequencePropertyManager objects. 1437 1438 \sa QtAbstractEditorFactory 1439 */ 1440 1441 /*! 1442 Creates a factory with the given \a parent. 1443 */ 1444 QtKeySequenceEditorFactory::QtKeySequenceEditorFactory(QObject *parent) 1445 : QtAbstractEditorFactory<QtKeySequencePropertyManager>(parent), d_ptr(new QtKeySequenceEditorFactoryPrivate()) 1446 { 1447 d_ptr->q_ptr = this; 1448 1449 } 1450 1451 /*! 1452 Destroys this factory, and all the widgets it has created. 1453 */ 1454 QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory() 1455 { 1456 qDeleteAll(d_ptr->m_editorToProperty.keys()); 1457 } 1458 1459 /*! 1460 \internal 1461 1462 Reimplemented from the QtAbstractEditorFactory class. 1463 */ 1464 void QtKeySequenceEditorFactory::connectPropertyManager(QtKeySequencePropertyManager *manager) 1465 { 1466 connect(manager, SIGNAL(valueChanged(QtProperty*,QKeySequence)), 1467 this, SLOT(slotPropertyChanged(QtProperty*,QKeySequence))); 1468 } 1469 1470 /*! 1471 \internal 1472 1473 Reimplemented from the QtAbstractEditorFactory class. 1474 */ 1475 QWidget *QtKeySequenceEditorFactory::createEditor(QtKeySequencePropertyManager *manager, 1476 QtProperty *property, QWidget *parent) 1477 { 1478 QKeySequenceEdit *editor = d_ptr->createEditor(property, parent); 1479 editor->setKeySequence(manager->value(property)); 1480 1481 connect(editor, SIGNAL(keySequenceChanged(QKeySequence)), 1482 this, SLOT(slotSetValue(QKeySequence))); 1483 connect(editor, SIGNAL(destroyed(QObject*)), 1484 this, SLOT(slotEditorDestroyed(QObject*))); 1485 return editor; 1486 } 1487 1488 /*! 1489 \internal 1490 1491 Reimplemented from the QtAbstractEditorFactory class. 1492 */ 1493 void QtKeySequenceEditorFactory::disconnectPropertyManager(QtKeySequencePropertyManager *manager) 1494 { 1495 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QKeySequence)), 1496 this, SLOT(slotPropertyChanged(QtProperty*,QKeySequence))); 1497 } 1498 1499 // QtCharEdit 1500 1501 class QtCharEdit : public QWidget 1502 { 1503 Q_OBJECT 1504 public: 1505 QtCharEdit(QWidget *parent = 0); 1506 1507 QChar value() const; 1508 bool eventFilter(QObject *o, QEvent *e); 1509 public Q_SLOTS: 1510 void setValue(const QChar &value); 1511 Q_SIGNALS: 1512 void valueChanged(const QChar &value); 1513 protected: 1514 void focusInEvent(QFocusEvent *e); 1515 void focusOutEvent(QFocusEvent *e); 1516 void keyPressEvent(QKeyEvent *e); 1517 void keyReleaseEvent(QKeyEvent *e); 1518 bool event(QEvent *e); 1519 private Q_SLOTS: 1520 void slotClearChar(); 1521 private: 1522 void handleKeyEvent(QKeyEvent *e); 1523 1524 QChar m_value; 1525 QLineEdit *m_lineEdit; 1526 }; 1527 1528 QtCharEdit::QtCharEdit(QWidget *parent) 1529 : QWidget(parent), m_lineEdit(new QLineEdit(this)) 1530 { 1531 QHBoxLayout *layout = new QHBoxLayout(this); 1532 layout->addWidget(m_lineEdit); 1533 layout->setContentsMargins(0, 0, 0, 0); 1534 m_lineEdit->installEventFilter(this); 1535 m_lineEdit->setReadOnly(true); 1536 m_lineEdit->setFocusProxy(this); 1537 setFocusPolicy(m_lineEdit->focusPolicy()); 1538 setAttribute(Qt::WA_InputMethodEnabled); 1539 } 1540 1541 bool QtCharEdit::eventFilter(QObject *o, QEvent *e) 1542 { 1543 if (o == m_lineEdit && e->type() == QEvent::ContextMenu) { 1544 QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e); 1545 QMenu *menu = m_lineEdit->createStandardContextMenu(); 1546 const QList<QAction *> actions = menu->actions(); 1547 for (QAction *action : actions) { 1548 action->setShortcut(QKeySequence()); 1549 QString actionString = action->text(); 1550 const int pos = actionString.lastIndexOf(QLatin1Char('\t')); 1551 if (pos > 0) 1552 actionString = actionString.remove(pos, actionString.length() - pos); 1553 action->setText(actionString); 1554 } 1555 QAction *actionBefore = 0; 1556 if (actions.count() > 0) 1557 actionBefore = actions[0]; 1558 QAction *clearAction = new QAction(tr("Clear Char"), menu); 1559 menu->insertAction(actionBefore, clearAction); 1560 menu->insertSeparator(actionBefore); 1561 clearAction->setEnabled(!m_value.isNull()); 1562 connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar())); 1563 menu->exec(c->globalPos()); 1564 delete menu; 1565 e->accept(); 1566 return true; 1567 } 1568 1569 return QWidget::eventFilter(o, e); 1570 } 1571 1572 void QtCharEdit::slotClearChar() 1573 { 1574 if (m_value.isNull()) 1575 return; 1576 setValue(QChar()); 1577 Q_EMIT valueChanged(m_value); 1578 } 1579 1580 void QtCharEdit::handleKeyEvent(QKeyEvent *e) 1581 { 1582 const int key = e->key(); 1583 switch (key) { 1584 case Qt::Key_Control: 1585 case Qt::Key_Shift: 1586 case Qt::Key_Meta: 1587 case Qt::Key_Alt: 1588 case Qt::Key_Super_L: 1589 case Qt::Key_Return: 1590 return; 1591 default: 1592 break; 1593 } 1594 1595 const QString text = e->text(); 1596 if (text.count() != 1) 1597 return; 1598 1599 const QChar c = text.at(0); 1600 if (!c.isPrint()) 1601 return; 1602 1603 if (m_value == c) 1604 return; 1605 1606 m_value = c; 1607 const QString str = m_value.isNull() ? QString() : QString(m_value); 1608 m_lineEdit->setText(str); 1609 e->accept(); 1610 Q_EMIT valueChanged(m_value); 1611 } 1612 1613 void QtCharEdit::setValue(const QChar &value) 1614 { 1615 if (value == m_value) 1616 return; 1617 1618 m_value = value; 1619 QString str = value.isNull() ? QString() : QString(value); 1620 m_lineEdit->setText(str); 1621 } 1622 1623 QChar QtCharEdit::value() const 1624 { 1625 return m_value; 1626 } 1627 1628 void QtCharEdit::focusInEvent(QFocusEvent *e) 1629 { 1630 m_lineEdit->event(e); 1631 m_lineEdit->selectAll(); 1632 QWidget::focusInEvent(e); 1633 } 1634 1635 void QtCharEdit::focusOutEvent(QFocusEvent *e) 1636 { 1637 m_lineEdit->event(e); 1638 QWidget::focusOutEvent(e); 1639 } 1640 1641 void QtCharEdit::keyPressEvent(QKeyEvent *e) 1642 { 1643 handleKeyEvent(e); 1644 e->accept(); 1645 } 1646 1647 void QtCharEdit::keyReleaseEvent(QKeyEvent *e) 1648 { 1649 m_lineEdit->event(e); 1650 } 1651 1652 bool QtCharEdit::event(QEvent *e) 1653 { 1654 switch(e->type()) { 1655 case QEvent::Shortcut: 1656 case QEvent::ShortcutOverride: 1657 case QEvent::KeyRelease: 1658 e->accept(); 1659 return true; 1660 default: 1661 break; 1662 } 1663 return QWidget::event(e); 1664 } 1665 1666 // QtCharEditorFactory 1667 1668 class QtCharEditorFactoryPrivate : public EditorFactoryPrivate<QtCharEdit> 1669 { 1670 QtCharEditorFactory *q_ptr; 1671 Q_DECLARE_PUBLIC(QtCharEditorFactory) 1672 public: 1673 1674 void slotPropertyChanged(QtProperty *property, const QChar &value); 1675 void slotSetValue(const QChar &value); 1676 1677 }; 1678 1679 void QtCharEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, 1680 const QChar &value) 1681 { 1682 const auto it = m_createdEditors.constFind(property); 1683 if (it == m_createdEditors.constEnd()) 1684 return; 1685 1686 for (QtCharEdit *editor : it.value()) { 1687 editor->blockSignals(true); 1688 editor->setValue(value); 1689 editor->blockSignals(false); 1690 } 1691 } 1692 1693 void QtCharEditorFactoryPrivate::slotSetValue(const QChar &value) 1694 { 1695 QObject *object = q_ptr->sender(); 1696 const QMap<QtCharEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 1697 for (QMap<QtCharEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 1698 if (itEditor.key() == object) { 1699 QtProperty *property = itEditor.value(); 1700 QtCharPropertyManager *manager = q_ptr->propertyManager(property); 1701 if (!manager) 1702 return; 1703 manager->setValue(property, value); 1704 return; 1705 } 1706 } 1707 1708 /*! 1709 \class QtCharEditorFactory 1710 \internal 1711 \inmodule QtDesigner 1712 \since 4.4 1713 1714 \brief The QtCharEditorFactory class provides editor 1715 widgets for properties created by QtCharPropertyManager objects. 1716 1717 \sa QtAbstractEditorFactory 1718 */ 1719 1720 /*! 1721 Creates a factory with the given \a parent. 1722 */ 1723 QtCharEditorFactory::QtCharEditorFactory(QObject *parent) 1724 : QtAbstractEditorFactory<QtCharPropertyManager>(parent), d_ptr(new QtCharEditorFactoryPrivate()) 1725 { 1726 d_ptr->q_ptr = this; 1727 1728 } 1729 1730 /*! 1731 Destroys this factory, and all the widgets it has created. 1732 */ 1733 QtCharEditorFactory::~QtCharEditorFactory() 1734 { 1735 qDeleteAll(d_ptr->m_editorToProperty.keys()); 1736 } 1737 1738 /*! 1739 \internal 1740 1741 Reimplemented from the QtAbstractEditorFactory class. 1742 */ 1743 void QtCharEditorFactory::connectPropertyManager(QtCharPropertyManager *manager) 1744 { 1745 connect(manager, SIGNAL(valueChanged(QtProperty*,QChar)), 1746 this, SLOT(slotPropertyChanged(QtProperty*,QChar))); 1747 } 1748 1749 /*! 1750 \internal 1751 1752 Reimplemented from the QtAbstractEditorFactory class. 1753 */ 1754 QWidget *QtCharEditorFactory::createEditor(QtCharPropertyManager *manager, 1755 QtProperty *property, QWidget *parent) 1756 { 1757 QtCharEdit *editor = d_ptr->createEditor(property, parent); 1758 editor->setValue(manager->value(property)); 1759 1760 connect(editor, SIGNAL(valueChanged(QChar)), 1761 this, SLOT(slotSetValue(QChar))); 1762 connect(editor, SIGNAL(destroyed(QObject*)), 1763 this, SLOT(slotEditorDestroyed(QObject*))); 1764 return editor; 1765 } 1766 1767 /*! 1768 \internal 1769 1770 Reimplemented from the QtAbstractEditorFactory class. 1771 */ 1772 void QtCharEditorFactory::disconnectPropertyManager(QtCharPropertyManager *manager) 1773 { 1774 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QChar)), 1775 this, SLOT(slotPropertyChanged(QtProperty*,QChar))); 1776 } 1777 1778 // QtEnumEditorFactory 1779 1780 class QtEnumEditorFactoryPrivate : public EditorFactoryPrivate<QComboBox> 1781 { 1782 QtEnumEditorFactory *q_ptr; 1783 Q_DECLARE_PUBLIC(QtEnumEditorFactory) 1784 public: 1785 1786 void slotPropertyChanged(QtProperty *property, int value); 1787 void slotEnumNamesChanged(QtProperty *property, const QStringList &); 1788 void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &); 1789 void slotSetValue(int value); 1790 }; 1791 1792 void QtEnumEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) 1793 { 1794 const auto it = m_createdEditors.constFind(property); 1795 if (it == m_createdEditors.constEnd()) 1796 return; 1797 1798 for (QComboBox *editor : it.value()) { 1799 editor->blockSignals(true); 1800 editor->setCurrentIndex(value); 1801 editor->blockSignals(false); 1802 } 1803 } 1804 1805 void QtEnumEditorFactoryPrivate::slotEnumNamesChanged(QtProperty *property, 1806 const QStringList &enumNames) 1807 { 1808 const auto it = m_createdEditors.constFind(property); 1809 if (it == m_createdEditors.constEnd()) 1810 return; 1811 1812 QtEnumPropertyManager *manager = q_ptr->propertyManager(property); 1813 if (!manager) 1814 return; 1815 1816 QMap<int, QIcon> enumIcons = manager->enumIcons(property); 1817 1818 for (QComboBox *editor : it.value()) { 1819 editor->blockSignals(true); 1820 editor->clear(); 1821 editor->addItems(enumNames); 1822 const int nameCount = enumNames.count(); 1823 for (int i = 0; i < nameCount; i++) 1824 editor->setItemIcon(i, enumIcons.value(i)); 1825 editor->setCurrentIndex(manager->value(property)); 1826 editor->blockSignals(false); 1827 } 1828 } 1829 1830 void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property, 1831 const QMap<int, QIcon> &enumIcons) 1832 { 1833 const auto it = m_createdEditors.constFind(property); 1834 if (it == m_createdEditors.constEnd()) 1835 return; 1836 1837 QtEnumPropertyManager *manager = q_ptr->propertyManager(property); 1838 if (!manager) 1839 return; 1840 1841 const QStringList enumNames = manager->enumNames(property); 1842 for (QComboBox *editor : it.value()) { 1843 editor->blockSignals(true); 1844 const int nameCount = enumNames.count(); 1845 for (int i = 0; i < nameCount; i++) 1846 editor->setItemIcon(i, enumIcons.value(i)); 1847 editor->setCurrentIndex(manager->value(property)); 1848 editor->blockSignals(false); 1849 } 1850 } 1851 1852 void QtEnumEditorFactoryPrivate::slotSetValue(int value) 1853 { 1854 QObject *object = q_ptr->sender(); 1855 const QMap<QComboBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); 1856 for (QMap<QComboBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 1857 if (itEditor.key() == object) { 1858 QtProperty *property = itEditor.value(); 1859 QtEnumPropertyManager *manager = q_ptr->propertyManager(property); 1860 if (!manager) 1861 return; 1862 manager->setValue(property, value); 1863 return; 1864 } 1865 } 1866 1867 /*! 1868 \class QtEnumEditorFactory 1869 \internal 1870 \inmodule QtDesigner 1871 \since 4.4 1872 1873 \brief The QtEnumEditorFactory class provides QComboBox widgets for 1874 properties created by QtEnumPropertyManager objects. 1875 1876 \sa QtAbstractEditorFactory, QtEnumPropertyManager 1877 */ 1878 1879 /*! 1880 Creates a factory with the given \a parent. 1881 */ 1882 QtEnumEditorFactory::QtEnumEditorFactory(QObject *parent) 1883 : QtAbstractEditorFactory<QtEnumPropertyManager>(parent), d_ptr(new QtEnumEditorFactoryPrivate()) 1884 { 1885 d_ptr->q_ptr = this; 1886 1887 } 1888 1889 /*! 1890 Destroys this factory, and all the widgets it has created. 1891 */ 1892 QtEnumEditorFactory::~QtEnumEditorFactory() 1893 { 1894 qDeleteAll(d_ptr->m_editorToProperty.keys()); 1895 } 1896 1897 /*! 1898 \internal 1899 1900 Reimplemented from the QtAbstractEditorFactory class. 1901 */ 1902 void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager *manager) 1903 { 1904 connect(manager, SIGNAL(valueChanged(QtProperty*,int)), 1905 this, SLOT(slotPropertyChanged(QtProperty*,int))); 1906 connect(manager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)), 1907 this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); 1908 } 1909 1910 /*! 1911 \internal 1912 1913 Reimplemented from the QtAbstractEditorFactory class. 1914 */ 1915 QWidget *QtEnumEditorFactory::createEditor(QtEnumPropertyManager *manager, QtProperty *property, 1916 QWidget *parent) 1917 { 1918 QComboBox *editor = d_ptr->createEditor(property, parent); 1919 editor->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); 1920 editor->view()->setTextElideMode(Qt::ElideRight); 1921 QStringList enumNames = manager->enumNames(property); 1922 editor->addItems(enumNames); 1923 QMap<int, QIcon> enumIcons = manager->enumIcons(property); 1924 const int enumNamesCount = enumNames.count(); 1925 for (int i = 0; i < enumNamesCount; i++) 1926 editor->setItemIcon(i, enumIcons.value(i)); 1927 editor->setCurrentIndex(manager->value(property)); 1928 1929 connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int))); 1930 connect(editor, SIGNAL(destroyed(QObject*)), 1931 this, SLOT(slotEditorDestroyed(QObject*))); 1932 return editor; 1933 } 1934 1935 /*! 1936 \internal 1937 1938 Reimplemented from the QtAbstractEditorFactory class. 1939 */ 1940 void QtEnumEditorFactory::disconnectPropertyManager(QtEnumPropertyManager *manager) 1941 { 1942 disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), 1943 this, SLOT(slotPropertyChanged(QtProperty*,int))); 1944 disconnect(manager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)), 1945 this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); 1946 } 1947 1948 // QtCursorEditorFactory 1949 1950 Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) 1951 1952 class QtCursorEditorFactoryPrivate 1953 { 1954 QtCursorEditorFactory *q_ptr; 1955 Q_DECLARE_PUBLIC(QtCursorEditorFactory) 1956 public: 1957 QtCursorEditorFactoryPrivate(); 1958 1959 void slotPropertyChanged(QtProperty *property, const QCursor &cursor); 1960 void slotEnumChanged(QtProperty *property, int value); 1961 void slotEditorDestroyed(QObject *object); 1962 1963 QtEnumEditorFactory *m_enumEditorFactory; 1964 QtEnumPropertyManager *m_enumPropertyManager; 1965 1966 QMap<QtProperty *, QtProperty *> m_propertyToEnum; 1967 QMap<QtProperty *, QtProperty *> m_enumToProperty; 1968 QMap<QtProperty *, QWidgetList > m_enumToEditors; 1969 QMap<QWidget *, QtProperty *> m_editorToEnum; 1970 bool m_updatingEnum; 1971 }; 1972 1973 QtCursorEditorFactoryPrivate::QtCursorEditorFactoryPrivate() 1974 : m_updatingEnum(false) 1975 { 1976 1977 } 1978 1979 void QtCursorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, const QCursor &cursor) 1980 { 1981 // update enum property 1982 QtProperty *enumProp = m_propertyToEnum.value(property); 1983 if (!enumProp) 1984 return; 1985 1986 m_updatingEnum = true; 1987 m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(cursor)); 1988 m_updatingEnum = false; 1989 } 1990 1991 void QtCursorEditorFactoryPrivate::slotEnumChanged(QtProperty *property, int value) 1992 { 1993 if (m_updatingEnum) 1994 return; 1995 // update cursor property 1996 QtProperty *prop = m_enumToProperty.value(property); 1997 if (!prop) 1998 return; 1999 QtCursorPropertyManager *cursorManager = q_ptr->propertyManager(prop); 2000 if (!cursorManager) 2001 return; 2002 #ifndef QT_NO_CURSOR 2003 cursorManager->setValue(prop, QCursor(cursorDatabase()->valueToCursor(value))); 2004 #endif 2005 } 2006 2007 void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject *object) 2008 { 2009 // remove from m_editorToEnum map; 2010 // remove from m_enumToEditors map; 2011 // if m_enumToEditors doesn't contains more editors delete enum property; 2012 const QMap<QWidget *, QtProperty *>::ConstIterator ecend = m_editorToEnum.constEnd(); 2013 for (QMap<QWidget *, QtProperty *>::ConstIterator itEditor = m_editorToEnum.constBegin(); itEditor != ecend; ++itEditor) 2014 if (itEditor.key() == object) { 2015 QWidget *editor = itEditor.key(); 2016 QtProperty *enumProp = itEditor.value(); 2017 m_editorToEnum.remove(editor); 2018 m_enumToEditors[enumProp].removeAll(editor); 2019 if (m_enumToEditors[enumProp].isEmpty()) { 2020 m_enumToEditors.remove(enumProp); 2021 QtProperty *property = m_enumToProperty.value(enumProp); 2022 m_enumToProperty.remove(enumProp); 2023 m_propertyToEnum.remove(property); 2024 delete enumProp; 2025 } 2026 return; 2027 } 2028 } 2029 2030 /*! 2031 \class QtCursorEditorFactory 2032 \internal 2033 \inmodule QtDesigner 2034 \since 4.4 2035 2036 \brief The QtCursorEditorFactory class provides QComboBox widgets for 2037 properties created by QtCursorPropertyManager objects. 2038 2039 \sa QtAbstractEditorFactory, QtCursorPropertyManager 2040 */ 2041 2042 /*! 2043 Creates a factory with the given \a parent. 2044 */ 2045 QtCursorEditorFactory::QtCursorEditorFactory(QObject *parent) 2046 : QtAbstractEditorFactory<QtCursorPropertyManager>(parent), d_ptr(new QtCursorEditorFactoryPrivate()) 2047 { 2048 d_ptr->q_ptr = this; 2049 2050 d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this); 2051 d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); 2052 connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), 2053 this, SLOT(slotEnumChanged(QtProperty*,int))); 2054 d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager); 2055 } 2056 2057 /*! 2058 Destroys this factory, and all the widgets it has created. 2059 */ 2060 QtCursorEditorFactory::~QtCursorEditorFactory() 2061 { 2062 } 2063 2064 /*! 2065 \internal 2066 2067 Reimplemented from the QtAbstractEditorFactory class. 2068 */ 2069 void QtCursorEditorFactory::connectPropertyManager(QtCursorPropertyManager *manager) 2070 { 2071 connect(manager, SIGNAL(valueChanged(QtProperty*,QCursor)), 2072 this, SLOT(slotPropertyChanged(QtProperty*,QCursor))); 2073 } 2074 2075 /*! 2076 \internal 2077 2078 Reimplemented from the QtAbstractEditorFactory class. 2079 */ 2080 QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, QtProperty *property, 2081 QWidget *parent) 2082 { 2083 QtProperty *enumProp = 0; 2084 if (d_ptr->m_propertyToEnum.contains(property)) { 2085 enumProp = d_ptr->m_propertyToEnum[property]; 2086 } else { 2087 enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName()); 2088 d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cursorDatabase()->cursorShapeNames()); 2089 d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cursorDatabase()->cursorShapeIcons()); 2090 #ifndef QT_NO_CURSOR 2091 d_ptr->m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(manager->value(property))); 2092 #endif 2093 d_ptr->m_propertyToEnum[property] = enumProp; 2094 d_ptr->m_enumToProperty[enumProp] = property; 2095 } 2096 QtAbstractEditorFactoryBase *af = d_ptr->m_enumEditorFactory; 2097 QWidget *editor = af->createEditor(enumProp, parent); 2098 d_ptr->m_enumToEditors[enumProp].append(editor); 2099 d_ptr->m_editorToEnum[editor] = enumProp; 2100 connect(editor, SIGNAL(destroyed(QObject*)), 2101 this, SLOT(slotEditorDestroyed(QObject*))); 2102 return editor; 2103 } 2104 2105 /*! 2106 \internal 2107 2108 Reimplemented from the QtAbstractEditorFactory class. 2109 */ 2110 void QtCursorEditorFactory::disconnectPropertyManager(QtCursorPropertyManager *manager) 2111 { 2112 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QCursor)), 2113 this, SLOT(slotPropertyChanged(QtProperty*,QCursor))); 2114 } 2115 2116 // QtColorEditWidget 2117 2118 class QtColorEditWidget : public QWidget { 2119 Q_OBJECT 2120 2121 public: 2122 QtColorEditWidget(QWidget *parent); 2123 2124 bool eventFilter(QObject *obj, QEvent *ev); 2125 2126 public Q_SLOTS: 2127 void setValue(const QColor &value); 2128 2129 private Q_SLOTS: 2130 void buttonClicked(); 2131 2132 Q_SIGNALS: 2133 void valueChanged(const QColor &value); 2134 2135 private: 2136 QColor m_color; 2137 QLabel *m_pixmapLabel; 2138 QLabel *m_label; 2139 QToolButton *m_button; 2140 }; 2141 2142 QtColorEditWidget::QtColorEditWidget(QWidget *parent) : 2143 QWidget(parent), 2144 m_pixmapLabel(new QLabel), 2145 m_label(new QLabel), 2146 m_button(new QToolButton) 2147 { 2148 QHBoxLayout *lt = new QHBoxLayout(this); 2149 setupTreeViewEditorMargin(lt); 2150 lt->setSpacing(0); 2151 lt->addWidget(m_pixmapLabel); 2152 lt->addWidget(m_label); 2153 lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); 2154 2155 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); 2156 m_button->setFixedWidth(20); 2157 setFocusProxy(m_button); 2158 setFocusPolicy(m_button->focusPolicy()); 2159 m_button->setText(tr("...")); 2160 m_button->installEventFilter(this); 2161 connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); 2162 lt->addWidget(m_button); 2163 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color))); 2164 m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color)); 2165 } 2166 2167 void QtColorEditWidget::setValue(const QColor &c) 2168 { 2169 if (m_color != c) { 2170 m_color = c; 2171 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(c))); 2172 m_label->setText(QtPropertyBrowserUtils::colorValueText(c)); 2173 } 2174 } 2175 2176 void QtColorEditWidget::buttonClicked() 2177 { 2178 const QColor newColor = QColorDialog::getColor(m_color, this, QString(), QColorDialog::ShowAlphaChannel); 2179 if (newColor.isValid() && newColor != m_color) { 2180 setValue(newColor); 2181 Q_EMIT valueChanged(m_color); 2182 } 2183 } 2184 2185 bool QtColorEditWidget::eventFilter(QObject *obj, QEvent *ev) 2186 { 2187 if (obj == m_button) { 2188 switch (ev->type()) { 2189 case QEvent::KeyPress: 2190 case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate 2191 switch (static_cast<const QKeyEvent*>(ev)->key()) { 2192 case Qt::Key_Escape: 2193 case Qt::Key_Enter: 2194 case Qt::Key_Return: 2195 ev->ignore(); 2196 return true; 2197 default: 2198 break; 2199 } 2200 } 2201 break; 2202 default: 2203 break; 2204 } 2205 } 2206 return QWidget::eventFilter(obj, ev); 2207 } 2208 2209 // QtColorEditorFactoryPrivate 2210 2211 class QtColorEditorFactoryPrivate : public EditorFactoryPrivate<QtColorEditWidget> 2212 { 2213 QtColorEditorFactory *q_ptr; 2214 Q_DECLARE_PUBLIC(QtColorEditorFactory) 2215 public: 2216 2217 void slotPropertyChanged(QtProperty *property, const QColor &value); 2218 void slotSetValue(const QColor &value); 2219 }; 2220 2221 void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, 2222 const QColor &value) 2223 { 2224 const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property); 2225 if (it == m_createdEditors.constEnd()) 2226 return; 2227 2228 for (QtColorEditWidget *e : it.value()) 2229 e->setValue(value); 2230 } 2231 2232 void QtColorEditorFactoryPrivate::slotSetValue(const QColor &value) 2233 { 2234 QObject *object = q_ptr->sender(); 2235 const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); 2236 for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 2237 if (itEditor.key() == object) { 2238 QtProperty *property = itEditor.value(); 2239 QtColorPropertyManager *manager = q_ptr->propertyManager(property); 2240 if (!manager) 2241 return; 2242 manager->setValue(property, value); 2243 return; 2244 } 2245 } 2246 2247 /*! 2248 \class QtColorEditorFactory 2249 \internal 2250 \inmodule QtDesigner 2251 \since 4.4 2252 2253 \brief The QtColorEditorFactory class provides color editing for 2254 properties created by QtColorPropertyManager objects. 2255 2256 \sa QtAbstractEditorFactory, QtColorPropertyManager 2257 */ 2258 2259 /*! 2260 Creates a factory with the given \a parent. 2261 */ 2262 QtColorEditorFactory::QtColorEditorFactory(QObject *parent) : 2263 QtAbstractEditorFactory<QtColorPropertyManager>(parent), 2264 d_ptr(new QtColorEditorFactoryPrivate()) 2265 { 2266 d_ptr->q_ptr = this; 2267 } 2268 2269 /*! 2270 Destroys this factory, and all the widgets it has created. 2271 */ 2272 QtColorEditorFactory::~QtColorEditorFactory() 2273 { 2274 qDeleteAll(d_ptr->m_editorToProperty.keys()); 2275 } 2276 2277 /*! 2278 \internal 2279 2280 Reimplemented from the QtAbstractEditorFactory class. 2281 */ 2282 void QtColorEditorFactory::connectPropertyManager(QtColorPropertyManager *manager) 2283 { 2284 connect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), 2285 this, SLOT(slotPropertyChanged(QtProperty*,QColor))); 2286 } 2287 2288 /*! 2289 \internal 2290 2291 Reimplemented from the QtAbstractEditorFactory class. 2292 */ 2293 QWidget *QtColorEditorFactory::createEditor(QtColorPropertyManager *manager, 2294 QtProperty *property, QWidget *parent) 2295 { 2296 QtColorEditWidget *editor = d_ptr->createEditor(property, parent); 2297 editor->setValue(manager->value(property)); 2298 connect(editor, SIGNAL(valueChanged(QColor)), this, SLOT(slotSetValue(QColor))); 2299 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); 2300 return editor; 2301 } 2302 2303 /*! 2304 \internal 2305 2306 Reimplemented from the QtAbstractEditorFactory class. 2307 */ 2308 void QtColorEditorFactory::disconnectPropertyManager(QtColorPropertyManager *manager) 2309 { 2310 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), this, SLOT(slotPropertyChanged(QtProperty*,QColor))); 2311 } 2312 2313 // QtFontEditWidget 2314 2315 class QtFontEditWidget : public QWidget { 2316 Q_OBJECT 2317 2318 public: 2319 QtFontEditWidget(QWidget *parent); 2320 2321 bool eventFilter(QObject *obj, QEvent *ev); 2322 2323 public Q_SLOTS: 2324 void setValue(const QFont &value); 2325 2326 private Q_SLOTS: 2327 void buttonClicked(); 2328 2329 Q_SIGNALS: 2330 void valueChanged(const QFont &value); 2331 2332 private: 2333 QFont m_font; 2334 QLabel *m_pixmapLabel; 2335 QLabel *m_label; 2336 QToolButton *m_button; 2337 }; 2338 2339 QtFontEditWidget::QtFontEditWidget(QWidget *parent) : 2340 QWidget(parent), 2341 m_pixmapLabel(new QLabel), 2342 m_label(new QLabel), 2343 m_button(new QToolButton) 2344 { 2345 QHBoxLayout *lt = new QHBoxLayout(this); 2346 setupTreeViewEditorMargin(lt); 2347 lt->setSpacing(0); 2348 lt->addWidget(m_pixmapLabel); 2349 lt->addWidget(m_label); 2350 lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); 2351 2352 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); 2353 m_button->setFixedWidth(20); 2354 setFocusProxy(m_button); 2355 setFocusPolicy(m_button->focusPolicy()); 2356 m_button->setText(tr("...")); 2357 m_button->installEventFilter(this); 2358 connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); 2359 lt->addWidget(m_button); 2360 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(m_font)); 2361 m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font)); 2362 } 2363 2364 void QtFontEditWidget::setValue(const QFont &f) 2365 { 2366 if (m_font != f) { 2367 m_font = f; 2368 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(f)); 2369 m_label->setText(QtPropertyBrowserUtils::fontValueText(f)); 2370 } 2371 } 2372 2373 void QtFontEditWidget::buttonClicked() 2374 { 2375 bool ok = false; 2376 QFont newFont = QFontDialog::getFont(&ok, m_font, this, tr("Select Font")); 2377 if (ok && newFont != m_font) { 2378 QFont f = m_font; 2379 // prevent mask for unchanged attributes, don't change other attributes (like kerning, etc...) 2380 if (m_font.family() != newFont.family()) 2381 f.setFamily(newFont.family()); 2382 if (m_font.pointSize() != newFont.pointSize()) 2383 f.setPointSize(newFont.pointSize()); 2384 if (m_font.bold() != newFont.bold()) 2385 f.setBold(newFont.bold()); 2386 if (m_font.italic() != newFont.italic()) 2387 f.setItalic(newFont.italic()); 2388 if (m_font.underline() != newFont.underline()) 2389 f.setUnderline(newFont.underline()); 2390 if (m_font.strikeOut() != newFont.strikeOut()) 2391 f.setStrikeOut(newFont.strikeOut()); 2392 setValue(f); 2393 Q_EMIT valueChanged(m_font); 2394 } 2395 } 2396 2397 bool QtFontEditWidget::eventFilter(QObject *obj, QEvent *ev) 2398 { 2399 if (obj == m_button) { 2400 switch (ev->type()) { 2401 case QEvent::KeyPress: 2402 case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate 2403 switch (static_cast<const QKeyEvent*>(ev)->key()) { 2404 case Qt::Key_Escape: 2405 case Qt::Key_Enter: 2406 case Qt::Key_Return: 2407 ev->ignore(); 2408 return true; 2409 default: 2410 break; 2411 } 2412 } 2413 break; 2414 default: 2415 break; 2416 } 2417 } 2418 return QWidget::eventFilter(obj, ev); 2419 } 2420 2421 // QtFontEditorFactoryPrivate 2422 2423 class QtFontEditorFactoryPrivate : public EditorFactoryPrivate<QtFontEditWidget> 2424 { 2425 QtFontEditorFactory *q_ptr; 2426 Q_DECLARE_PUBLIC(QtFontEditorFactory) 2427 public: 2428 2429 void slotPropertyChanged(QtProperty *property, const QFont &value); 2430 void slotSetValue(const QFont &value); 2431 }; 2432 2433 void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, 2434 const QFont &value) 2435 { 2436 const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property); 2437 if (it == m_createdEditors.constEnd()) 2438 return; 2439 2440 for (QtFontEditWidget *e : it.value()) 2441 e->setValue(value); 2442 } 2443 2444 void QtFontEditorFactoryPrivate::slotSetValue(const QFont &value) 2445 { 2446 QObject *object = q_ptr->sender(); 2447 const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); 2448 for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) 2449 if (itEditor.key() == object) { 2450 QtProperty *property = itEditor.value(); 2451 QtFontPropertyManager *manager = q_ptr->propertyManager(property); 2452 if (!manager) 2453 return; 2454 manager->setValue(property, value); 2455 return; 2456 } 2457 } 2458 2459 /*! 2460 \class QtFontEditorFactory 2461 \internal 2462 \inmodule QtDesigner 2463 \since 4.4 2464 2465 \brief The QtFontEditorFactory class provides font editing for 2466 properties created by QtFontPropertyManager objects. 2467 2468 \sa QtAbstractEditorFactory, QtFontPropertyManager 2469 */ 2470 2471 /*! 2472 Creates a factory with the given \a parent. 2473 */ 2474 QtFontEditorFactory::QtFontEditorFactory(QObject *parent) : 2475 QtAbstractEditorFactory<QtFontPropertyManager>(parent), 2476 d_ptr(new QtFontEditorFactoryPrivate()) 2477 { 2478 d_ptr->q_ptr = this; 2479 } 2480 2481 /*! 2482 Destroys this factory, and all the widgets it has created. 2483 */ 2484 QtFontEditorFactory::~QtFontEditorFactory() 2485 { 2486 qDeleteAll(d_ptr->m_editorToProperty.keys()); 2487 } 2488 2489 /*! 2490 \internal 2491 2492 Reimplemented from the QtAbstractEditorFactory class. 2493 */ 2494 void QtFontEditorFactory::connectPropertyManager(QtFontPropertyManager *manager) 2495 { 2496 connect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), 2497 this, SLOT(slotPropertyChanged(QtProperty*,QFont))); 2498 } 2499 2500 /*! 2501 \internal 2502 2503 Reimplemented from the QtAbstractEditorFactory class. 2504 */ 2505 QWidget *QtFontEditorFactory::createEditor(QtFontPropertyManager *manager, 2506 QtProperty *property, QWidget *parent) 2507 { 2508 QtFontEditWidget *editor = d_ptr->createEditor(property, parent); 2509 editor->setValue(manager->value(property)); 2510 connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont))); 2511 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); 2512 return editor; 2513 } 2514 2515 /*! 2516 \internal 2517 2518 Reimplemented from the QtAbstractEditorFactory class. 2519 */ 2520 void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager *manager) 2521 { 2522 disconnect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), this, SLOT(slotPropertyChanged(QtProperty*,QFont))); 2523 } 2524 2525 QT_END_NAMESPACE 2526 2527 #include "moc_qteditorfactory.cpp" 2528 #include "qteditorfactory.moc"