Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qteditorfactory.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
7
8#include <QtWidgets/qabstractitemview.h>
9#include <QtWidgets/qapplication.h>
10#include <QtWidgets/qboxlayout.h>
11#include <QtWidgets/qcolordialog.h>
12#include <QtWidgets/qcombobox.h>
13#include <QtWidgets/qdatetimeedit.h>
14#include <QtWidgets/qfontdialog.h>
15#include <QtWidgets/qkeysequenceedit.h>
16#include <QtWidgets/qlabel.h>
17#include <QtWidgets/qlayoutitem.h>
18#include <QtWidgets/qlineedit.h>
19#include <QtWidgets/qmenu.h>
20#include <QtWidgets/qscrollbar.h>
21#include <QtWidgets/qspinbox.h>
22#include <QtWidgets/qtoolbutton.h>
23
24#include <QtGui/qevent.h>
25#include <QtGui/qvalidator.h>
26
27#include <QtCore/qhash.h>
28#include <QtCore/qregularexpression.h>
29
31
32// Set a hard coded left margin to account for the indentation
33// of the tree view icon when switching to an editor
34
35static inline void setupTreeViewEditorMargin(QLayout *lt)
36{
37 enum { DecorationMargin = 4 };
38 if (QApplication::layoutDirection() == Qt::LeftToRight)
39 lt->setContentsMargins(DecorationMargin, 0, 0, 0);
40 else
41 lt->setContentsMargins(0, 0, DecorationMargin, 0);
42}
43
44// ---------- EditorFactoryPrivate :
45// Base class for editor factory private classes. Manages mapping of properties to editors and vice versa.
46
47template <class Editor>
49{
50public:
51
55
56 Editor *createEditor(QtProperty *property, QWidget *parent);
57 void initializeEditor(QtProperty *property, Editor *e);
58 void slotEditorDestroyed(QObject *object);
59
61
63};
64
65template <class Editor>
66Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget *parent)
67{
68 auto *editor = new Editor(parent);
69 initializeEditor(property, editor);
70 return editor;
71}
72
73template <class Editor>
74void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor *editor)
75{
76 auto it = m_createdEditors.find(property);
77 if (it == m_createdEditors.end())
78 it = m_createdEditors.insert(property, EditorList());
79 it.value().append(editor);
80}
81
82template <class Editor>
83void EditorFactoryPrivate<Editor>::slotEditorDestroyed(QObject *object)
84{
85 auto pred = [object] (const Editor *e) { return object == e; };
86 for (auto it = m_createdEditors.begin(), end = m_createdEditors.end(); it != end; ++it) {
87 auto &editorList = it.value();
88 auto listIt = std::find_if(editorList.cbegin(), editorList.cend(), pred);
89 if (listIt != editorList.cend()) {
90 editorList.erase(listIt);
91 if (editorList.isEmpty())
92 m_createdEditors.erase(it) ;
93 break;
94 }
95 }
96}
97
98template <class Editor>
100{
101 for (auto it = m_createdEditors.begin(), end = m_createdEditors.end(); it != end; ++it)
102 qDeleteAll(it.value());
103 m_createdEditors.clear();
104}
105
106// ------------ QtSpinBoxFactory
107
109{
110 QtSpinBoxFactory *q_ptr = nullptr;
111 Q_DECLARE_PUBLIC(QtSpinBoxFactory)
112public:
113
115 void slotRangeChanged(QtProperty *property, int min, int max);
116 void slotSingleStepChanged(QtProperty *property, int step);
117 void slotSetValue(QtProperty *property, int value);
118};
119
120void QtSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, int value)
121{
122 const auto it = m_createdEditors.constFind(property);
123 if (it == m_createdEditors.cend())
124 return;
125 for (QSpinBox *editor : it.value()) {
126 if (editor->value() != value) {
127 editor->blockSignals(true);
128 editor->setValue(value);
129 editor->blockSignals(false);
130 }
131 }
132}
133
134void QtSpinBoxFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max)
135{
136 const auto it = m_createdEditors.constFind(property);
137 if (it == m_createdEditors.cend())
138 return;
139
140 QtIntPropertyManager *manager = q_ptr->propertyManager(property);
141 if (!manager)
142 return;
143
144 for (QSpinBox *editor : it.value()) {
145 editor->blockSignals(true);
146 editor->setRange(min, max);
147 editor->setValue(manager->value(property));
148 editor->blockSignals(false);
149 }
150}
151
153{
154 const auto it = m_createdEditors.constFind(property);
155 if (it == m_createdEditors.cend())
156 return;
157 for (QSpinBox *editor : it.value()) {
158 editor->blockSignals(true);
159 editor->setSingleStep(step);
160 editor->blockSignals(false);
161 }
162}
163
165{
166 if (QtIntPropertyManager *manager = q_ptr->propertyManager(property))
167 manager->setValue(property, value);
168}
169
170/*!
171 \class QtSpinBoxFactory
172 \internal
173 \inmodule QtDesigner
174 \since 4.4
175
176 \brief The QtSpinBoxFactory class provides QSpinBox widgets for
177 properties created by QtIntPropertyManager objects.
178
179 \sa QtAbstractEditorFactory, QtIntPropertyManager
180*/
181
182/*!
183 Creates a factory with the given \a parent.
184*/
185QtSpinBoxFactory::QtSpinBoxFactory(QObject *parent)
186 : QtAbstractEditorFactory<QtIntPropertyManager>(parent), d_ptr(new QtSpinBoxFactoryPrivate())
187{
188 d_ptr->q_ptr = this;
189
190}
191
192/*!
193 Destroys this factory, and all the widgets it has created.
194*/
196{
197 d_ptr->deleteEditors();
198}
199
200/*!
201 \internal
202
203 Reimplemented from the QtAbstractEditorFactory class.
204*/
206{
207 connect(manager, &QtIntPropertyManager::valueChanged,
208 this, [this](QtProperty *property, int value)
209 { d_ptr->slotPropertyChanged(property, value); });
210 connect(manager, &QtIntPropertyManager::rangeChanged,
211 this, [this](QtProperty *property, int min, int max)
212 { d_ptr->slotRangeChanged(property, min, max); });
214 this, [this](QtProperty *property, int value)
215 { d_ptr->slotSingleStepChanged(property, value); });
216}
217
218/*!
219 \internal
220
221 Reimplemented from the QtAbstractEditorFactory class.
222*/
224 QWidget *parent)
225{
226 QSpinBox *editor = d_ptr->createEditor(property, parent);
227 editor->setSingleStep(manager->singleStep(property));
228 editor->setRange(manager->minimum(property), manager->maximum(property));
229 editor->setValue(manager->value(property));
230 editor->setKeyboardTracking(false);
231
232 connect(editor, &QSpinBox::valueChanged,
233 this, [this, property](int value) { d_ptr->slotSetValue(property, value); });
234 connect(editor, &QObject::destroyed,
235 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
236 return editor;
237}
238
239/*!
240 \internal
241
242 Reimplemented from the QtAbstractEditorFactory class.
243*/
245{
246 disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr);
247 disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr);
248 disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr);
249}
250
251// QtSliderFactory
252
254{
255 QtSliderFactory *q_ptr = nullptr;
256 Q_DECLARE_PUBLIC(QtSliderFactory)
257public:
259 void slotRangeChanged(QtProperty *property, int min, int max);
260 void slotSingleStepChanged(QtProperty *property, int step);
261 void slotSetValue(QtProperty *property, int value);
262};
263
264void QtSliderFactoryPrivate::slotPropertyChanged(QtProperty *property, int value)
265{
266 const auto it = m_createdEditors.constFind(property);
267 if (it == m_createdEditors.cend())
268 return;
269 for (QSlider *editor : it.value()) {
270 editor->blockSignals(true);
271 editor->setValue(value);
272 editor->blockSignals(false);
273 }
274}
275
276void QtSliderFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max)
277{
278 const auto it = m_createdEditors.constFind(property);
279 if (it == m_createdEditors.cend())
280 return;
281
282 QtIntPropertyManager *manager = q_ptr->propertyManager(property);
283 if (!manager)
284 return;
285
286 for (QSlider *editor : it.value()) {
287 editor->blockSignals(true);
288 editor->setRange(min, max);
289 editor->setValue(manager->value(property));
290 editor->blockSignals(false);
291 }
292}
293
295{
296 const auto it = m_createdEditors.constFind(property);
297 if (it == m_createdEditors.cend())
298 return;
299 for (QSlider *editor : it.value()) {
300 editor->blockSignals(true);
301 editor->setSingleStep(step);
302 editor->blockSignals(false);
303 }
304}
305
307{
308 if (QtIntPropertyManager *manager = q_ptr->propertyManager(property))
309 manager->setValue(property, value);
310}
311
312/*!
313 \class QtSliderFactory
314 \internal
315 \inmodule QtDesigner
316 \since 4.4
317
318 \brief The QtSliderFactory class provides QSlider widgets for
319 properties created by QtIntPropertyManager objects.
320
321 \sa QtAbstractEditorFactory, QtIntPropertyManager
322*/
323
324/*!
325 Creates a factory with the given \a parent.
326*/
327QtSliderFactory::QtSliderFactory(QObject *parent)
328 : QtAbstractEditorFactory<QtIntPropertyManager>(parent), d_ptr(new QtSliderFactoryPrivate())
329{
330 d_ptr->q_ptr = this;
331
332}
333
334/*!
335 Destroys this factory, and all the widgets it has created.
336*/
338{
339 d_ptr->deleteEditors();
340}
341
342/*!
343 \internal
344
345 Reimplemented from the QtAbstractEditorFactory class.
346*/
348{
349 connect(manager, &QtIntPropertyManager::valueChanged,
350 this, [this](QtProperty *property, int value)
351 { d_ptr->slotPropertyChanged(property, value); });
352 connect(manager, &QtIntPropertyManager::rangeChanged,
353 this, [this](QtProperty *property, int min, int max)
354 { d_ptr->slotRangeChanged(property, min, max); });
356 this, [this](QtProperty *property, int value)
357 { d_ptr->slotSingleStepChanged(property, value); });
358}
359
360/*!
361 \internal
362
363 Reimplemented from the QtAbstractEditorFactory class.
364*/
366 QWidget *parent)
367{
368 auto *editor = new QSlider(Qt::Horizontal, parent);
369 d_ptr->initializeEditor(property, editor);
370 editor->setSingleStep(manager->singleStep(property));
371 editor->setRange(manager->minimum(property), manager->maximum(property));
372 editor->setValue(manager->value(property));
373
374 connect(editor, &QSlider::valueChanged,
375 this, [this, property](int value) { d_ptr->slotSetValue(property, value); });
376 connect(editor, &QObject::destroyed,
377 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
378 return editor;
379}
380
381/*!
382 \internal
383
384 Reimplemented from the QtAbstractEditorFactory class.
385*/
387{
388 disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr);
389 disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr);
390 disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr);
391}
392
393// QtSliderFactory
394
396{
397 QtScrollBarFactory *q_ptr = nullptr;
398 Q_DECLARE_PUBLIC(QtScrollBarFactory)
399public:
401 void slotRangeChanged(QtProperty *property, int min, int max);
402 void slotSingleStepChanged(QtProperty *property, int step);
403 void slotSetValue(QtProperty *property, int value);
404};
405
406void QtScrollBarFactoryPrivate::slotPropertyChanged(QtProperty *property, int value)
407{
408 const auto it = m_createdEditors.constFind(property);
409 if (it == m_createdEditors.cend())
410 return;
411
412 for (QScrollBar *editor : it.value()) {
413 editor->blockSignals(true);
414 editor->setValue(value);
415 editor->blockSignals(false);
416 }
417}
418
419void QtScrollBarFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max)
420{
421 const auto it = m_createdEditors.constFind(property);
422 if (it == m_createdEditors.cend())
423 return;
424
425 QtIntPropertyManager *manager = q_ptr->propertyManager(property);
426 if (!manager)
427 return;
428
429 for (QScrollBar *editor : it.value()) {
430 editor->blockSignals(true);
431 editor->setRange(min, max);
432 editor->setValue(manager->value(property));
433 editor->blockSignals(false);
434 }
435}
436
438{
439 const auto it = m_createdEditors.constFind(property);
440 if (it == m_createdEditors.cend())
441 return;
442 for (QScrollBar *editor : it.value()) {
443 editor->blockSignals(true);
444 editor->setSingleStep(step);
445 editor->blockSignals(false);
446 }
447}
448
450{
451 if (QtIntPropertyManager *manager = q_ptr->propertyManager(property))
452 manager->setValue(property, value);
453}
454
455/*!
456 \class QtScrollBarFactory
457 \internal
458 \inmodule QtDesigner
459 \since 4.4
460
461 \brief The QtScrollBarFactory class provides QScrollBar widgets for
462 properties created by QtIntPropertyManager objects.
463
464 \sa QtAbstractEditorFactory, QtIntPropertyManager
465*/
466
467/*!
468 Creates a factory with the given \a parent.
469*/
470QtScrollBarFactory::QtScrollBarFactory(QObject *parent)
471 : QtAbstractEditorFactory<QtIntPropertyManager>(parent), d_ptr(new QtScrollBarFactoryPrivate())
472{
473 d_ptr->q_ptr = this;
474
475}
476
477/*!
478 Destroys this factory, and all the widgets it has created.
479*/
481{
482 d_ptr->deleteEditors();
483}
484
485/*!
486 \internal
487
488 Reimplemented from the QtAbstractEditorFactory class.
489*/
491{
492 connect(manager, &QtIntPropertyManager::valueChanged,
493 this, [this](QtProperty *property, int value)
494 { d_ptr->slotPropertyChanged(property, value); });
495 connect(manager, &QtIntPropertyManager::rangeChanged,
496 this, [this](QtProperty *property, int min, int max)
497 { d_ptr->slotRangeChanged(property, min, max); });
499 this, [this](QtProperty *property, int value)
500 { d_ptr->slotSingleStepChanged(property, value); });
501}
502
503/*!
504 \internal
505
506 Reimplemented from the QtAbstractEditorFactory class.
507*/
509 QWidget *parent)
510{
511 auto *editor = new QScrollBar(Qt::Horizontal, parent);
512 d_ptr->initializeEditor(property, editor);
513 editor->setSingleStep(manager->singleStep(property));
514 editor->setRange(manager->minimum(property), manager->maximum(property));
515 editor->setValue(manager->value(property));
516 connect(editor, &QScrollBar::valueChanged,
517 this, [this, property](int value) { d_ptr->slotSetValue(property, value); });
518 connect(editor, &QObject::destroyed,
519 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
520 return editor;
521}
522
523/*!
524 \internal
525
526 Reimplemented from the QtAbstractEditorFactory class.
527*/
529{
530 disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr);
531 disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr);
532 disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr);
533}
534
535// QtCheckBoxFactory
536
538{
539 QtCheckBoxFactory *q_ptr = nullptr;
540 Q_DECLARE_PUBLIC(QtCheckBoxFactory)
541public:
543 void slotSetValue(QtProperty *property, bool value);
544};
545
546void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value)
547{
548 const auto it = m_createdEditors.constFind(property);
549 if (it == m_createdEditors.cend())
550 return;
551
552 for (QtBoolEdit *editor : it.value()) {
553 editor->blockCheckBoxSignals(true);
554 editor->setChecked(value);
555 editor->blockCheckBoxSignals(false);
556 }
557}
558
560{
561 if (QtBoolPropertyManager *manager = q_ptr->propertyManager(property))
562 manager->setValue(property, value);
563}
564
565/*!
566 \class QtCheckBoxFactory
567 \internal
568 \inmodule QtDesigner
569 \since 4.4
570
571 \brief The QtCheckBoxFactory class provides QCheckBox widgets for
572 properties created by QtBoolPropertyManager objects.
573
574 \sa QtAbstractEditorFactory, QtBoolPropertyManager
575*/
576
577/*!
578 Creates a factory with the given \a parent.
579*/
580QtCheckBoxFactory::QtCheckBoxFactory(QObject *parent)
581 : QtAbstractEditorFactory<QtBoolPropertyManager>(parent), d_ptr(new QtCheckBoxFactoryPrivate())
582{
583 d_ptr->q_ptr = this;
584
585}
586
587/*!
588 Destroys this factory, and all the widgets it has created.
589*/
591{
592 d_ptr->deleteEditors();
593}
594
595/*!
596 \internal
597
598 Reimplemented from the QtAbstractEditorFactory class.
599*/
601{
602 connect(manager, &QtBoolPropertyManager::valueChanged,
603 this, [this](QtProperty *property, bool value)
604 { d_ptr->slotPropertyChanged(property, value); });
605}
606
607/*!
608 \internal
609
610 Reimplemented from the QtAbstractEditorFactory class.
611*/
613 QWidget *parent)
614{
615 QtBoolEdit *editor = d_ptr->createEditor(property, parent);
616 editor->setChecked(manager->value(property));
617
618 connect(editor, &QtBoolEdit::toggled,
619 this, [this, property](bool value) { d_ptr->slotSetValue(property, value); });
620 connect(editor, &QObject::destroyed,
621 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
622 return editor;
623}
624
625/*!
626 \internal
627
628 Reimplemented from the QtAbstractEditorFactory class.
629*/
631{
632 disconnect(manager, &QtBoolPropertyManager::valueChanged, this, nullptr);
633}
634
635// QtDoubleSpinBoxFactory
636
638{
639 QtDoubleSpinBoxFactory *q_ptr = nullptr;
640 Q_DECLARE_PUBLIC(QtDoubleSpinBoxFactory)
641public:
642
644 void slotRangeChanged(QtProperty *property, double min, double max);
645 void slotSingleStepChanged(QtProperty *property, double step);
646 void slotDecimalsChanged(QtProperty *property, int prec);
647 void slotSetValue(QtProperty *property, double value);
648};
649
650void QtDoubleSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, double value)
651{
652 const auto it = m_createdEditors.constFind(property);
653 if (it == m_createdEditors.cend())
654 return;
655 for (QDoubleSpinBox *editor : it.value()) {
656 if (editor->value() != value) {
657 editor->blockSignals(true);
658 editor->setValue(value);
659 editor->blockSignals(false);
660 }
661 }
662}
663
665 double min, double max)
666{
667 const auto it = m_createdEditors.constFind(property);
668 if (it == m_createdEditors.cend())
669 return;
670
671 QtDoublePropertyManager *manager = q_ptr->propertyManager(property);
672 if (!manager)
673 return;
674
675 for (QDoubleSpinBox *editor : it.value()) {
676 editor->blockSignals(true);
677 editor->setRange(min, max);
678 editor->setValue(manager->value(property));
679 editor->blockSignals(false);
680 }
681}
682
684{
685 const auto it = m_createdEditors.constFind(property);
686 if (it == m_createdEditors.cend())
687 return;
688
689 QtDoublePropertyManager *manager = q_ptr->propertyManager(property);
690 if (!manager)
691 return;
692
693 for (QDoubleSpinBox *editor : it.value()) {
694 editor->blockSignals(true);
695 editor->setSingleStep(step);
696 editor->blockSignals(false);
697 }
698}
699
701{
702 const auto it = m_createdEditors.constFind(property);
703 if (it == m_createdEditors.constEnd())
704 return;
705
706 QtDoublePropertyManager *manager = q_ptr->propertyManager(property);
707 if (!manager)
708 return;
709
710 for (QDoubleSpinBox *editor : it.value()) {
711 editor->blockSignals(true);
712 editor->setDecimals(prec);
713 editor->setValue(manager->value(property));
714 editor->blockSignals(false);
715 }
716}
717
719{
720 if (QtDoublePropertyManager *manager = q_ptr->propertyManager(property))
721 manager->setValue(property, value);
722}
723
724/*! \class QtDoubleSpinBoxFactory
725 \internal
726 \inmodule QtDesigner
727 \since 4.4
728
729 \brief The QtDoubleSpinBoxFactory class provides QDoubleSpinBox
730 widgets for properties created by QtDoublePropertyManager objects.
731
732 \sa QtAbstractEditorFactory, QtDoublePropertyManager
733*/
734
735/*!
736 Creates a factory with the given \a parent.
737*/
738QtDoubleSpinBoxFactory::QtDoubleSpinBoxFactory(QObject *parent)
739 : QtAbstractEditorFactory<QtDoublePropertyManager>(parent), d_ptr(new QtDoubleSpinBoxFactoryPrivate())
740{
741 d_ptr->q_ptr = this;
742
743}
744
745/*!
746 Destroys this factory, and all the widgets it has created.
747*/
749{
750 d_ptr->deleteEditors();
751}
752
753/*!
754 \internal
755
756 Reimplemented from the QtAbstractEditorFactory class.
757*/
759{
760 connect(manager, &QtDoublePropertyManager::valueChanged,
761 this, [this](QtProperty *property, double value)
762 { d_ptr->slotPropertyChanged(property, value); });
764 this, [this](QtProperty *property, double min, double max)
765 { d_ptr->slotRangeChanged(property, min, max); });
767 this, [this](QtProperty *property, double value)
768 { d_ptr->slotSingleStepChanged(property, value); });
770 this, [this](QtProperty *property, int value)
771 { d_ptr->slotDecimalsChanged(property, value); });
772}
773
774/*!
775 \internal
776
777 Reimplemented from the QtAbstractEditorFactory class.
778*/
780 QtProperty *property, QWidget *parent)
781{
782 QDoubleSpinBox *editor = d_ptr->createEditor(property, parent);
783 editor->setSingleStep(manager->singleStep(property));
784 editor->setDecimals(manager->decimals(property));
785 editor->setRange(manager->minimum(property), manager->maximum(property));
786 editor->setValue(manager->value(property));
787 editor->setKeyboardTracking(false);
788
789 connect(editor, &QDoubleSpinBox::valueChanged,
790 this, [this, property](double value) { d_ptr->slotSetValue(property, value); });
791 connect(editor, &QObject::destroyed,
792 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
793 return editor;
794}
795
796/*!
797 \internal
798
799 Reimplemented from the QtAbstractEditorFactory class.
800*/
802{
803 disconnect(manager, &QtDoublePropertyManager::valueChanged, this, nullptr);
804 disconnect(manager, &QtDoublePropertyManager::rangeChanged, this, nullptr);
805 disconnect(manager, &QtDoublePropertyManager::singleStepChanged, this, nullptr);
806 disconnect(manager, &QtDoublePropertyManager::decimalsChanged, this, nullptr);
807}
808
809// QtLineEditFactory
810
812{
813 QtLineEditFactory *q_ptr = nullptr;
814 Q_DECLARE_PUBLIC(QtLineEditFactory)
815public:
816
818 void slotRegExpChanged(QtProperty *property, const QRegularExpression &regExp);
819 void slotSetValue(QtProperty *property, const QString &value);
820};
821
822void QtLineEditFactoryPrivate::slotPropertyChanged(QtProperty *property,
823 const QString &value)
824{
825 const auto it = m_createdEditors.constFind(property);
826 if (it == m_createdEditors.constEnd())
827 return;
828
829 for (QLineEdit *editor : it.value()) {
830 if (editor->text() != value)
831 editor->setText(value);
832 }
833}
834
836 const QRegularExpression &regExp)
837{
838 const auto it = m_createdEditors.constFind(property);
839 if (it == m_createdEditors.constEnd())
840 return;
841
842 QtStringPropertyManager *manager = q_ptr->propertyManager(property);
843 if (!manager)
844 return;
845
846 for (QLineEdit *editor : it.value()) {
847 editor->blockSignals(true);
848 const QValidator *oldValidator = editor->validator();
849 QValidator *newValidator = nullptr;
850 if (regExp.isValid()) {
851 newValidator = new QRegularExpressionValidator(regExp, editor);
852 }
853 editor->setValidator(newValidator);
854 delete oldValidator;
855 editor->blockSignals(false);
856 }
857}
858
859void QtLineEditFactoryPrivate::slotSetValue(QtProperty *property, const QString &value)
860{
861 if (QtStringPropertyManager *manager = q_ptr->propertyManager(property))
862 manager->setValue(property, value);
863}
864
865/*!
866 \class QtLineEditFactory
867 \internal
868 \inmodule QtDesigner
869 \since 4.4
870
871 \brief The QtLineEditFactory class provides QLineEdit widgets for
872 properties created by QtStringPropertyManager objects.
873
874 \sa QtAbstractEditorFactory, QtStringPropertyManager
875*/
876
877/*!
878 Creates a factory with the given \a parent.
879*/
880QtLineEditFactory::QtLineEditFactory(QObject *parent)
881 : QtAbstractEditorFactory<QtStringPropertyManager>(parent), d_ptr(new QtLineEditFactoryPrivate())
882{
883 d_ptr->q_ptr = this;
884
885}
886
887/*!
888 Destroys this factory, and all the widgets it has created.
889*/
891{
892 d_ptr->deleteEditors();
893}
894
895/*!
896 \internal
897
898 Reimplemented from the QtAbstractEditorFactory class.
899*/
901{
902 connect(manager, &QtStringPropertyManager::valueChanged,
903 this, [this](QtProperty *property, const QString &value)
904 { d_ptr->slotPropertyChanged(property, value); });
906 this, [this](QtProperty *property, const QRegularExpression &value)
907 { d_ptr->slotRegExpChanged(property, value); });
908}
909
910/*!
911 \internal
912
913 Reimplemented from the QtAbstractEditorFactory class.
914*/
916 QtProperty *property, QWidget *parent)
917{
918 QLineEdit *editor = d_ptr->createEditor(property, parent);
919 QRegularExpression regExp = manager->regExp(property);
920 if (regExp.isValid() && !regExp.pattern().isEmpty()) {
921 auto *validator = new QRegularExpressionValidator(regExp, editor);
922 editor->setValidator(validator);
923 }
924 editor->setText(manager->value(property));
925
926 connect(editor, &QLineEdit::textEdited,
927 this, [this, property](const QString &value) { d_ptr->slotSetValue(property, value); });
928 connect(editor, &QObject::destroyed,
929 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
930 return editor;
931}
932
933/*!
934 \internal
935
936 Reimplemented from the QtAbstractEditorFactory class.
937*/
939{
940 disconnect(manager, &QtStringPropertyManager::valueChanged, this, nullptr);
941 disconnect(manager, &QtStringPropertyManager::regExpChanged, this, nullptr);
942}
943
944// QtDateEditFactory
945
947{
948 QtDateEditFactory *q_ptr = nullptr;
949 Q_DECLARE_PUBLIC(QtDateEditFactory)
950public:
951
953 void slotRangeChanged(QtProperty *property, QDate min, QDate max);
954 void slotSetValue(QtProperty *property, QDate value);
955};
956
957void QtDateEditFactoryPrivate::slotPropertyChanged(QtProperty *property, QDate value)
958{
959 const auto it = m_createdEditors.constFind(property);
960 if (it == m_createdEditors.constEnd())
961 return;
962 for (QDateEdit *editor : it.value()) {
963 editor->blockSignals(true);
964 editor->setDate(value);
965 editor->blockSignals(false);
966 }
967}
968
969void QtDateEditFactoryPrivate::slotRangeChanged(QtProperty *property, QDate min, QDate max)
970{
971 const auto it = m_createdEditors.constFind(property);
972 if (it == m_createdEditors.constEnd())
973 return;
974
975 QtDatePropertyManager *manager = q_ptr->propertyManager(property);
976 if (!manager)
977 return;
978
979 for (QDateEdit *editor : it.value()) {
980 editor->blockSignals(true);
981 editor->setDateRange(min, max);
982 editor->setDate(manager->value(property));
983 editor->blockSignals(false);
984 }
985}
986
988{
989 if (QtDatePropertyManager *manager = q_ptr->propertyManager(property))
990 manager->setValue(property, value);
991}
992
993/*!
994 \class QtDateEditFactory
995 \internal
996 \inmodule QtDesigner
997 \since 4.4
998
999 \brief The QtDateEditFactory class provides QDateEdit widgets for
1000 properties created by QtDatePropertyManager objects.
1001
1002 \sa QtAbstractEditorFactory, QtDatePropertyManager
1003*/
1004
1005/*!
1006 Creates a factory with the given \a parent.
1007*/
1008QtDateEditFactory::QtDateEditFactory(QObject *parent)
1009 : QtAbstractEditorFactory<QtDatePropertyManager>(parent), d_ptr(new QtDateEditFactoryPrivate())
1010{
1011 d_ptr->q_ptr = this;
1012
1013}
1014
1015/*!
1016 Destroys this factory, and all the widgets it has created.
1017*/
1019{
1020 d_ptr->deleteEditors();
1021}
1022
1023/*!
1024 \internal
1025
1026 Reimplemented from the QtAbstractEditorFactory class.
1027*/
1029{
1030 connect(manager, &QtDatePropertyManager::valueChanged,
1031 this, [this](QtProperty *property, QDate value)
1032 { d_ptr->slotPropertyChanged(property, value); });
1033 connect(manager, &QtDatePropertyManager::rangeChanged,
1034 this, [this](QtProperty *property, QDate min, QDate max)
1035 { d_ptr->slotRangeChanged(property, min, max); });
1036}
1037
1038/*!
1039 \internal
1040
1041 Reimplemented from the QtAbstractEditorFactory class.
1042*/
1044 QWidget *parent)
1045{
1046 QDateEdit *editor = d_ptr->createEditor(property, parent);
1047 editor->setDisplayFormat(QtPropertyBrowserUtils::dateFormat());
1048 editor->setCalendarPopup(true);
1049 editor->setDateRange(manager->minimum(property), manager->maximum(property));
1050 editor->setDate(manager->value(property));
1051
1052 connect(editor, &QDateEdit::dateChanged,
1053 this, [this, property](QDate value) { d_ptr->slotSetValue(property, value); });
1054 connect(editor, &QObject::destroyed,
1055 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1056 return editor;
1057}
1058
1059/*!
1060 \internal
1061
1062 Reimplemented from the QtAbstractEditorFactory class.
1063*/
1065{
1066 disconnect(manager, &QtDatePropertyManager::valueChanged, this, nullptr);
1067 disconnect(manager, &QtDatePropertyManager::rangeChanged, this, nullptr);
1068}
1069
1070// QtTimeEditFactory
1071
1073{
1074 QtTimeEditFactory *q_ptr = nullptr;
1075 Q_DECLARE_PUBLIC(QtTimeEditFactory)
1076public:
1077
1079 void slotSetValue(QtProperty *property, QTime value);
1080};
1081
1082void QtTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, QTime value)
1083{
1084 const auto it = m_createdEditors.constFind(property);
1085 if (it == m_createdEditors.constEnd())
1086 return;
1087 for (QTimeEdit *editor : it.value()) {
1088 editor->blockSignals(true);
1089 editor->setTime(value);
1090 editor->blockSignals(false);
1091 }
1092}
1093
1095{
1096 if (QtTimePropertyManager *manager = q_ptr->propertyManager(property))
1097 manager->setValue(property, value);
1098}
1099
1100/*!
1101 \class QtTimeEditFactory
1102 \internal
1103 \inmodule QtDesigner
1104 \since 4.4
1105
1106 \brief The QtTimeEditFactory class provides QTimeEdit widgets for
1107 properties created by QtTimePropertyManager objects.
1108
1109 \sa QtAbstractEditorFactory, QtTimePropertyManager
1110*/
1111
1112/*!
1113 Creates a factory with the given \a parent.
1114*/
1115QtTimeEditFactory::QtTimeEditFactory(QObject *parent)
1116 : QtAbstractEditorFactory<QtTimePropertyManager>(parent), d_ptr(new QtTimeEditFactoryPrivate())
1117{
1118 d_ptr->q_ptr = this;
1119
1120}
1121
1122/*!
1123 Destroys this factory, and all the widgets it has created.
1124*/
1126{
1127 d_ptr->deleteEditors();
1128}
1129
1130/*!
1131 \internal
1132
1133 Reimplemented from the QtAbstractEditorFactory class.
1134*/
1136{
1137 connect(manager, &QtTimePropertyManager::valueChanged,
1138 this, [this](QtProperty *property, QTime value)
1139 { d_ptr->slotPropertyChanged(property, value); });
1140}
1141
1142/*!
1143 \internal
1144
1145 Reimplemented from the QtAbstractEditorFactory class.
1146*/
1148 QWidget *parent)
1149{
1150 QTimeEdit *editor = d_ptr->createEditor(property, parent);
1151 editor->setDisplayFormat(QtPropertyBrowserUtils::timeFormat());
1152 editor->setTime(manager->value(property));
1153
1154 connect(editor, &QTimeEdit::timeChanged,
1155 this, [this, property](QTime value) { d_ptr->slotSetValue(property, value); });
1156 connect(editor, &QObject::destroyed,
1157 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1158 return editor;
1159}
1160
1161/*!
1162 \internal
1163
1164 Reimplemented from the QtAbstractEditorFactory class.
1165*/
1167{
1168 disconnect(manager, &QtTimePropertyManager::valueChanged, this, nullptr);
1169}
1170
1171// QtDateTimeEditFactory
1172
1174{
1175 QtDateTimeEditFactory *q_ptr = nullptr;
1176 Q_DECLARE_PUBLIC(QtDateTimeEditFactory)
1177public:
1178
1180 void slotSetValue(QtProperty *property, const QDateTime &value);
1181
1182};
1183
1184void QtDateTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property,
1185 const QDateTime &value)
1186{
1187 const auto it = m_createdEditors.constFind(property);
1188 if (it == m_createdEditors.constEnd())
1189 return;
1190
1191 for (QDateTimeEdit *editor : it.value()) {
1192 editor->blockSignals(true);
1193 editor->setDateTime(value);
1194 editor->blockSignals(false);
1195 }
1196}
1197
1198void QtDateTimeEditFactoryPrivate::slotSetValue(QtProperty *property, const QDateTime &value)
1199{
1200 if (QtDateTimePropertyManager *manager = q_ptr->propertyManager(property))
1201 manager->setValue(property, value);
1202}
1203
1204/*!
1205 \class QtDateTimeEditFactory
1206 \internal
1207 \inmodule QtDesigner
1208 \since 4.4
1209
1210 \brief The QtDateTimeEditFactory class provides QDateTimeEdit
1211 widgets for properties created by QtDateTimePropertyManager objects.
1212
1213 \sa QtAbstractEditorFactory, QtDateTimePropertyManager
1214*/
1215
1216/*!
1217 Creates a factory with the given \a parent.
1218*/
1219QtDateTimeEditFactory::QtDateTimeEditFactory(QObject *parent)
1220 : QtAbstractEditorFactory<QtDateTimePropertyManager>(parent), d_ptr(new QtDateTimeEditFactoryPrivate())
1221{
1222 d_ptr->q_ptr = this;
1223
1224}
1225
1226/*!
1227 Destroys this factory, and all the widgets it has created.
1228*/
1230{
1231 d_ptr->deleteEditors();
1232}
1233
1234/*!
1235 \internal
1236
1237 Reimplemented from the QtAbstractEditorFactory class.
1238*/
1240{
1241 connect(manager, &QtDateTimePropertyManager::valueChanged,
1242 this, [this](QtProperty *property, const QDateTime &value)
1243 { d_ptr->slotPropertyChanged(property, value); });
1244}
1245
1246/*!
1247 \internal
1248
1249 Reimplemented from the QtAbstractEditorFactory class.
1250*/
1252 QtProperty *property, QWidget *parent)
1253{
1254 QDateTimeEdit *editor = d_ptr->createEditor(property, parent);
1255 editor->setDisplayFormat(QtPropertyBrowserUtils::dateTimeFormat());
1256 editor->setDateTime(manager->value(property));
1257
1258 connect(editor, &QDateTimeEdit::dateTimeChanged,
1259 this, [this, property](const QDateTime &value) { d_ptr->slotSetValue(property, value); });
1260 connect(editor, &QObject::destroyed,
1261 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1262 return editor;
1263}
1264
1265/*!
1266 \internal
1267
1268 Reimplemented from the QtAbstractEditorFactory class.
1269*/
1271{
1272 disconnect(manager, &QtDateTimePropertyManager::valueChanged, this, nullptr);
1273}
1274
1275// QtKeySequenceEditorFactory
1276
1278{
1279 QtKeySequenceEditorFactory *q_ptr = nullptr;
1280 Q_DECLARE_PUBLIC(QtKeySequenceEditorFactory)
1281public:
1282
1284 void slotSetValue(QtProperty *property, const QKeySequence &value);
1285};
1286
1287void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
1288 const QKeySequence &value)
1289{
1290 const auto it = m_createdEditors.constFind(property);
1291 if (it == m_createdEditors.constEnd())
1292 return;
1293
1294 for (QKeySequenceEdit *editor : it.value()) {
1295 editor->blockSignals(true);
1296 editor->setKeySequence(value);
1297 editor->blockSignals(false);
1298 }
1299}
1300
1301void QtKeySequenceEditorFactoryPrivate::slotSetValue(QtProperty *property, const QKeySequence &value)
1302{
1303 if (QtKeySequencePropertyManager *manager = q_ptr->propertyManager(property))
1304 manager->setValue(property, value);
1305}
1306
1307/*!
1308 \class QtKeySequenceEditorFactory
1309 \internal
1310 \inmodule QtDesigner
1311 \since 4.4
1312
1313 \brief The QtKeySequenceEditorFactory class provides editor
1314 widgets for properties created by QtKeySequencePropertyManager objects.
1315
1316 \sa QtAbstractEditorFactory
1317*/
1318
1319/*!
1320 Creates a factory with the given \a parent.
1321*/
1322QtKeySequenceEditorFactory::QtKeySequenceEditorFactory(QObject *parent)
1323 : QtAbstractEditorFactory<QtKeySequencePropertyManager>(parent), d_ptr(new QtKeySequenceEditorFactoryPrivate())
1324{
1325 d_ptr->q_ptr = this;
1326
1327}
1328
1329/*!
1330 Destroys this factory, and all the widgets it has created.
1331*/
1333{
1334 d_ptr->deleteEditors();
1335}
1336
1337/*!
1338 \internal
1339
1340 Reimplemented from the QtAbstractEditorFactory class.
1341*/
1343{
1344 connect(manager, &QtKeySequencePropertyManager::valueChanged,
1345 this, [this](QtProperty *property, const QKeySequence &value)
1346 { d_ptr->slotPropertyChanged(property, value); });
1347}
1348
1349/*!
1350 \internal
1351
1352 Reimplemented from the QtAbstractEditorFactory class.
1353*/
1355 QtProperty *property, QWidget *parent)
1356{
1357 QKeySequenceEdit *editor = d_ptr->createEditor(property, parent);
1358 editor->setKeySequence(manager->value(property));
1359
1360 connect(editor, &QKeySequenceEdit::keySequenceChanged,
1361 this, [this, property](const QKeySequence &value) { d_ptr->slotSetValue(property, value); });
1362 connect(editor, &QObject::destroyed,
1363 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1364 return editor;
1365}
1366
1367/*!
1368 \internal
1369
1370 Reimplemented from the QtAbstractEditorFactory class.
1371*/
1373{
1374 disconnect(manager, &QtKeySequencePropertyManager::valueChanged, this, nullptr);
1375}
1376
1377// QtCharEdit
1378
1379class QtCharEdit : public QWidget
1380{
1381 Q_OBJECT
1382public:
1384
1385 QChar value() const;
1386 bool eventFilter(QObject *o, QEvent *e) override;
1387public Q_SLOTS:
1388 void setValue(const QChar &value);
1389Q_SIGNALS:
1391protected:
1392 void focusInEvent(QFocusEvent *e) override;
1393 void focusOutEvent(QFocusEvent *e) override;
1394 void keyPressEvent(QKeyEvent *e) override;
1395 void keyReleaseEvent(QKeyEvent *e) override;
1396 bool event(QEvent *e) override;
1397private slots:
1398 void slotClearChar();
1399private:
1400 void handleKeyEvent(QKeyEvent *e);
1401
1402 QChar m_value;
1403 QLineEdit *m_lineEdit;
1404};
1405
1406QtCharEdit::QtCharEdit(QWidget *parent)
1407 : QWidget(parent), m_lineEdit(new QLineEdit(this))
1408{
1409 auto *layout = new QHBoxLayout(this);
1410 layout->addWidget(m_lineEdit);
1411 layout->setContentsMargins(QMargins());
1412 m_lineEdit->installEventFilter(this);
1413 m_lineEdit->setReadOnly(true);
1414 m_lineEdit->setFocusProxy(this);
1415 setFocusPolicy(m_lineEdit->focusPolicy());
1416 setAttribute(Qt::WA_InputMethodEnabled);
1417}
1418
1419bool QtCharEdit::eventFilter(QObject *o, QEvent *e)
1420{
1421 if (o == m_lineEdit && e->type() == QEvent::ContextMenu) {
1422 QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e);
1423 QMenu *menu = m_lineEdit->createStandardContextMenu();
1424 const auto actions = menu->actions();
1425 for (QAction *action : actions) {
1426 action->setShortcut(QKeySequence());
1427 QString actionString = action->text();
1428 const auto pos = actionString.lastIndexOf(QLatin1Char('\t'));
1429 if (pos > 0)
1430 actionString = actionString.remove(pos, actionString.size() - pos);
1431 action->setText(actionString);
1432 }
1433 QAction *actionBefore = nullptr;
1434 if (!actions.empty())
1435 actionBefore = actions[0];
1436 auto *clearAction = new QAction(tr("Clear Char"), menu);
1437 menu->insertAction(actionBefore, clearAction);
1438 menu->insertSeparator(actionBefore);
1439 clearAction->setEnabled(!m_value.isNull());
1440 connect(clearAction, &QAction::triggered, this, &QtCharEdit::slotClearChar);
1441 menu->exec(c->globalPos());
1442 delete menu;
1443 e->accept();
1444 return true;
1445 }
1446
1447 return QWidget::eventFilter(o, e);
1448}
1449
1450void QtCharEdit::slotClearChar()
1451{
1452 if (m_value.isNull())
1453 return;
1454 setValue(QChar());
1455 emit valueChanged(m_value);
1456}
1457
1458void QtCharEdit::handleKeyEvent(QKeyEvent *e)
1459{
1460 const int key = e->key();
1461 switch (key) {
1462 case Qt::Key_Control:
1463 case Qt::Key_Shift:
1464 case Qt::Key_Meta:
1465 case Qt::Key_Alt:
1466 case Qt::Key_Super_L:
1467 case Qt::Key_Return:
1468 return;
1469 default:
1470 break;
1471 }
1472
1473 const QString text = e->text();
1474 if (text.size() != 1)
1475 return;
1476
1477 const QChar c = text.at(0);
1478 if (!c.isPrint())
1479 return;
1480
1481 if (m_value == c)
1482 return;
1483
1484 m_value = c;
1485 const QString str = m_value.isNull() ? QString() : QString(m_value);
1486 m_lineEdit->setText(str);
1487 e->accept();
1488 emit valueChanged(m_value);
1489}
1490
1491void QtCharEdit::setValue(const QChar &value)
1492{
1493 if (value == m_value)
1494 return;
1495
1496 m_value = value;
1497 QString str = value.isNull() ? QString() : QString(value);
1498 m_lineEdit->setText(str);
1499}
1500
1502{
1503 return m_value;
1504}
1505
1506void QtCharEdit::focusInEvent(QFocusEvent *e)
1507{
1508 m_lineEdit->event(e);
1509 m_lineEdit->selectAll();
1510 QWidget::focusInEvent(e);
1511}
1512
1513void QtCharEdit::focusOutEvent(QFocusEvent *e)
1514{
1515 m_lineEdit->event(e);
1516 QWidget::focusOutEvent(e);
1517}
1518
1519void QtCharEdit::keyPressEvent(QKeyEvent *e)
1520{
1521 handleKeyEvent(e);
1522 e->accept();
1523}
1524
1525void QtCharEdit::keyReleaseEvent(QKeyEvent *e)
1526{
1527 m_lineEdit->event(e);
1528}
1529
1530bool QtCharEdit::event(QEvent *e)
1531{
1532 switch(e->type()) {
1533 case QEvent::Shortcut:
1534 case QEvent::ShortcutOverride:
1535 case QEvent::KeyRelease:
1536 e->accept();
1537 return true;
1538 default:
1539 break;
1540 }
1541 return QWidget::event(e);
1542}
1543
1544// QtCharEditorFactory
1545
1547{
1548 QtCharEditorFactory *q_ptr = nullptr;
1549 Q_DECLARE_PUBLIC(QtCharEditorFactory)
1550public:
1551
1553 void slotSetValue(QtProperty *property, const QChar &value);
1554
1555};
1556
1557void QtCharEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
1558 const QChar &value)
1559{
1560 const auto it = m_createdEditors.constFind(property);
1561 if (it == m_createdEditors.constEnd())
1562 return;
1563
1564 for (QtCharEdit *editor : it.value()) {
1565 editor->blockSignals(true);
1566 editor->setValue(value);
1567 editor->blockSignals(false);
1568 }
1569}
1570
1571void QtCharEditorFactoryPrivate::slotSetValue(QtProperty *property, const QChar &value)
1572{
1573 if (QtCharPropertyManager *manager = q_ptr->propertyManager(property))
1574 manager->setValue(property, value);
1575}
1576
1577/*!
1578 \class QtCharEditorFactory
1579 \internal
1580 \inmodule QtDesigner
1581 \since 4.4
1582
1583 \brief The QtCharEditorFactory class provides editor
1584 widgets for properties created by QtCharPropertyManager objects.
1585
1586 \sa QtAbstractEditorFactory
1587*/
1588
1589/*!
1590 Creates a factory with the given \a parent.
1591*/
1592QtCharEditorFactory::QtCharEditorFactory(QObject *parent)
1593 : QtAbstractEditorFactory<QtCharPropertyManager>(parent), d_ptr(new QtCharEditorFactoryPrivate())
1594{
1595 d_ptr->q_ptr = this;
1596
1597}
1598
1599/*!
1600 Destroys this factory, and all the widgets it has created.
1601*/
1603{
1604 d_ptr->deleteEditors();
1605}
1606
1607/*!
1608 \internal
1609
1610 Reimplemented from the QtAbstractEditorFactory class.
1611*/
1613{
1614 connect(manager, &QtCharPropertyManager::valueChanged,
1615 this, [this](QtProperty *property, const QChar &value)
1616 { d_ptr->slotPropertyChanged(property, value); });
1617}
1618
1619/*!
1620 \internal
1621
1622 Reimplemented from the QtAbstractEditorFactory class.
1623*/
1625 QtProperty *property, QWidget *parent)
1626{
1627 QtCharEdit *editor = d_ptr->createEditor(property, parent);
1628 editor->setValue(manager->value(property));
1629
1630 connect(editor, &QtCharEdit::valueChanged,
1631 this, [this, property](const QChar &value) { d_ptr->slotSetValue(property, value); });
1632 connect(editor, &QObject::destroyed,
1633 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1634 return editor;
1635}
1636
1637/*!
1638 \internal
1639
1640 Reimplemented from the QtAbstractEditorFactory class.
1641*/
1643{
1644 disconnect(manager, &QtCharPropertyManager::valueChanged, this, nullptr);
1645}
1646
1647// QtEnumEditorFactory
1648
1650{
1651 QtEnumEditorFactory *q_ptr = nullptr;
1652 Q_DECLARE_PUBLIC(QtEnumEditorFactory)
1653public:
1654
1656 void slotEnumNamesChanged(QtProperty *property, const QStringList &);
1657 void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &);
1658 void slotSetValue(QtProperty *property, int value);
1659};
1660
1661void QtEnumEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, int value)
1662{
1663 const auto it = m_createdEditors.constFind(property);
1664 if (it == m_createdEditors.constEnd())
1665 return;
1666
1667 for (QComboBox *editor : it.value()) {
1668 editor->blockSignals(true);
1669 editor->setCurrentIndex(value);
1670 editor->blockSignals(false);
1671 }
1672}
1673
1675 const QStringList &enumNames)
1676{
1677 const auto it = m_createdEditors.constFind(property);
1678 if (it == m_createdEditors.constEnd())
1679 return;
1680
1681 QtEnumPropertyManager *manager = q_ptr->propertyManager(property);
1682 if (!manager)
1683 return;
1684
1685 QMap<int, QIcon> enumIcons = manager->enumIcons(property);
1686
1687 for (QComboBox *editor : it.value()) {
1688 editor->blockSignals(true);
1689 editor->clear();
1690 editor->addItems(enumNames);
1691 const auto nameCount = enumNames.size();
1692 for (qsizetype i = 0; i < nameCount; i++)
1693 editor->setItemIcon(i, enumIcons.value(i));
1694 editor->setCurrentIndex(manager->value(property));
1695 editor->blockSignals(false);
1696 }
1697}
1698
1700 const QMap<int, QIcon> &enumIcons)
1701{
1702 const auto it = m_createdEditors.constFind(property);
1703 if (it == m_createdEditors.constEnd())
1704 return;
1705
1706 QtEnumPropertyManager *manager = q_ptr->propertyManager(property);
1707 if (!manager)
1708 return;
1709
1710 const QStringList enumNames = manager->enumNames(property);
1711 for (QComboBox *editor : it.value()) {
1712 editor->blockSignals(true);
1713 const auto nameCount = enumNames.size();
1714 for (qsizetype i = 0; i < nameCount; i++)
1715 editor->setItemIcon(i, enumIcons.value(i));
1716 editor->setCurrentIndex(manager->value(property));
1717 editor->blockSignals(false);
1718 }
1719}
1720
1722{
1723 if (QtEnumPropertyManager *manager = q_ptr->propertyManager(property))
1724 manager->setValue(property, value);
1725}
1726
1727/*!
1728 \class QtEnumEditorFactory
1729 \internal
1730 \inmodule QtDesigner
1731 \since 4.4
1732
1733 \brief The QtEnumEditorFactory class provides QComboBox widgets for
1734 properties created by QtEnumPropertyManager objects.
1735
1736 \sa QtAbstractEditorFactory, QtEnumPropertyManager
1737*/
1738
1739/*!
1740 Creates a factory with the given \a parent.
1741*/
1742QtEnumEditorFactory::QtEnumEditorFactory(QObject *parent)
1743 : QtAbstractEditorFactory<QtEnumPropertyManager>(parent), d_ptr(new QtEnumEditorFactoryPrivate())
1744{
1745 d_ptr->q_ptr = this;
1746
1747}
1748
1749/*!
1750 Destroys this factory, and all the widgets it has created.
1751*/
1753{
1754 d_ptr->deleteEditors();
1755}
1756
1757/*!
1758 \internal
1759
1760 Reimplemented from the QtAbstractEditorFactory class.
1761*/
1763{
1764 connect(manager, &QtEnumPropertyManager::valueChanged,
1765 this, [this](QtProperty *property, int value)
1766 { d_ptr->slotPropertyChanged(property, value); });
1767 connect(manager, &QtEnumPropertyManager::enumNamesChanged,
1768 this, [this](QtProperty *property, const QStringList &value)
1769 { d_ptr->slotEnumNamesChanged(property, value); });
1770}
1771
1772/*!
1773 \internal
1774
1775 Reimplemented from the QtAbstractEditorFactory class.
1776*/
1778 QWidget *parent)
1779{
1780 QComboBox *editor = d_ptr->createEditor(property, parent);
1781 editor->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
1782 editor->view()->setTextElideMode(Qt::ElideRight);
1783 QStringList enumNames = manager->enumNames(property);
1784 editor->addItems(enumNames);
1785 QMap<int, QIcon> enumIcons = manager->enumIcons(property);
1786 const auto enumNamesCount = enumNames.size();
1787 for (qsizetype i = 0; i < enumNamesCount; i++)
1788 editor->setItemIcon(i, enumIcons.value(i));
1789 editor->setCurrentIndex(manager->value(property));
1790
1791 connect(editor, &QComboBox::currentIndexChanged,
1792 this, [this, property](int value) { d_ptr->slotSetValue(property, value); });
1793 connect(editor, &QObject::destroyed,
1794 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1795 return editor;
1796}
1797
1798/*!
1799 \internal
1800
1801 Reimplemented from the QtAbstractEditorFactory class.
1802*/
1804{
1805 disconnect(manager, &QtEnumPropertyManager::valueChanged, this, nullptr);
1806 disconnect(manager, &QtEnumPropertyManager::enumNamesChanged, this, nullptr);
1807}
1808
1809// QtCursorEditorFactory
1810
1829
1830void QtCursorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, const QCursor &cursor)
1831{
1832 // update enum property
1833 QtProperty *enumProp = m_propertyToEnum.value(property);
1834 if (!enumProp)
1835 return;
1836
1837 m_updatingEnum = true;
1838 auto *cdb = QtCursorDatabase::instance();
1839 m_enumPropertyManager->setValue(enumProp, cdb->cursorToValue(cursor));
1840 m_updatingEnum = false;
1841}
1842
1844{
1845 if (m_updatingEnum)
1846 return;
1847 // update cursor property
1848 QtProperty *prop = m_enumToProperty.value(property);
1849 if (!prop)
1850 return;
1851 QtCursorPropertyManager *cursorManager = q_ptr->propertyManager(prop);
1852 if (!cursorManager)
1853 return;
1854#ifndef QT_NO_CURSOR
1855 auto *cdb = QtCursorDatabase::instance();
1856 cursorManager->setValue(prop, QCursor(cdb->valueToCursor(value)));
1857#endif
1858}
1859
1861{
1862 // remove from m_editorToEnum map;
1863 // remove from m_enumToEditors map;
1864 // if m_enumToEditors doesn't contains more editors delete enum property;
1865 for (auto itEditor = m_editorToEnum.cbegin(), ecend = m_editorToEnum.cend(); itEditor != ecend; ++itEditor)
1866 if (itEditor.key() == object) {
1867 QWidget *editor = itEditor.key();
1868 QtProperty *enumProp = itEditor.value();
1869 m_editorToEnum.remove(editor);
1870 m_enumToEditors[enumProp].removeAll(editor);
1871 if (m_enumToEditors[enumProp].isEmpty()) {
1872 m_enumToEditors.remove(enumProp);
1873 QtProperty *property = m_enumToProperty.value(enumProp);
1874 m_enumToProperty.remove(enumProp);
1875 m_propertyToEnum.remove(property);
1876 delete enumProp;
1877 }
1878 return;
1879 }
1880}
1881
1882/*!
1883 \class QtCursorEditorFactory
1884 \internal
1885 \inmodule QtDesigner
1886 \since 4.4
1887
1888 \brief The QtCursorEditorFactory class provides QComboBox widgets for
1889 properties created by QtCursorPropertyManager objects.
1890
1891 \sa QtAbstractEditorFactory, QtCursorPropertyManager
1892*/
1893
1894/*!
1895 Creates a factory with the given \a parent.
1896*/
1897QtCursorEditorFactory::QtCursorEditorFactory(QObject *parent)
1898 : QtAbstractEditorFactory<QtCursorPropertyManager>(parent), d_ptr(new QtCursorEditorFactoryPrivate())
1899{
1900 d_ptr->q_ptr = this;
1901
1902 d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this);
1903 d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
1904 connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged,
1905 this, [this](QtProperty *property, int value)
1906 { d_ptr->slotEnumChanged(property, value); });
1907 d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager);
1908}
1909
1910/*!
1911 Destroys this factory, and all the widgets it has created.
1912*/
1914
1915/*!
1916 \internal
1917
1918 Reimplemented from the QtAbstractEditorFactory class.
1919*/
1921{
1922 connect(manager, &QtCursorPropertyManager::valueChanged,
1923 this, [this](QtProperty *property, const QCursor &value)
1924 { d_ptr->slotPropertyChanged(property, value); });
1925}
1926
1927/*!
1928 \internal
1929
1930 Reimplemented from the QtAbstractEditorFactory class.
1931*/
1933 QWidget *parent)
1934{
1935 QtProperty *enumProp = d_ptr->m_propertyToEnum.value(property, nullptr);
1936 if (enumProp == nullptr) {
1937 enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName());
1938 auto *cdb = QtCursorDatabase::instance();
1939 d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cdb->cursorShapeNames());
1940 d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cdb->cursorShapeIcons());
1941#ifndef QT_NO_CURSOR
1942 d_ptr->m_enumPropertyManager->setValue(enumProp, cdb->cursorToValue(manager->value(property)));
1943#endif
1944 d_ptr->m_propertyToEnum[property] = enumProp;
1945 d_ptr->m_enumToProperty[enumProp] = property;
1946 }
1947 QtAbstractEditorFactoryBase *af = d_ptr->m_enumEditorFactory;
1948 QWidget *editor = af->createEditor(enumProp, parent);
1949 d_ptr->m_enumToEditors[enumProp].append(editor);
1950 d_ptr->m_editorToEnum[editor] = enumProp;
1951 connect(editor, &QObject::destroyed,
1952 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
1953 return editor;
1954}
1955
1956/*!
1957 \internal
1958
1959 Reimplemented from the QtAbstractEditorFactory class.
1960*/
1962{
1963 disconnect(manager, &QtCursorPropertyManager::valueChanged, this, nullptr);
1964}
1965
1966// QtColorEditWidget
1967
1969 Q_OBJECT
1970
1971public:
1973
1974 bool eventFilter(QObject *obj, QEvent *ev) override;
1975
1976public Q_SLOTS:
1978
1979private Q_SLOTS:
1980 void buttonClicked();
1981
1982Q_SIGNALS:
1984
1985private:
1986 void updateColor();
1987
1988 QColor m_color;
1989 QLabel *m_pixmapLabel;
1990 QLabel *m_label;
1991 QToolButton *m_button;
1992};
1993
1994QtColorEditWidget::QtColorEditWidget(QWidget *parent) :
1995 QWidget(parent),
1996 m_pixmapLabel(new QLabel),
1997 m_label(new QLabel),
1998 m_button(new QToolButton)
1999{
2000 auto *lt = new QHBoxLayout(this);
2001 setupTreeViewEditorMargin(lt);
2002 lt->setSpacing(0);
2003 lt->addWidget(m_pixmapLabel);
2004 lt->addWidget(m_label);
2005 lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
2006
2007 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
2008 m_button->setFixedWidth(20);
2009 setFocusProxy(m_button);
2010 setFocusPolicy(m_button->focusPolicy());
2011 m_button->setText(tr("..."));
2012 m_button->installEventFilter(this);
2013 connect(m_button, &QAbstractButton::clicked, this, &QtColorEditWidget::buttonClicked);
2014 lt->addWidget(m_button);
2015 updateColor();
2016}
2017
2018void QtColorEditWidget::setValue(QColor c)
2019{
2020 if (m_color != c) {
2021 m_color = c;
2022 updateColor();
2023 }
2024}
2025
2026void QtColorEditWidget::updateColor()
2027{
2028 const auto pm =
2029 QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color),
2030 QtPropertyBrowserUtils::itemViewIconSize,
2031 devicePixelRatioF());
2032 m_pixmapLabel->setPixmap(pm);
2033 m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color));
2034}
2035
2036void QtColorEditWidget::buttonClicked()
2037{
2038 const QColor newColor = QColorDialog::getColor(m_color, this, QString(), QColorDialog::ShowAlphaChannel);
2039 if (newColor.isValid() && newColor != m_color) {
2040 setValue(newColor);
2041 emit valueChanged(m_color);
2042 }
2043}
2044
2045bool QtColorEditWidget::eventFilter(QObject *obj, QEvent *ev)
2046{
2047 if (obj == m_button) {
2048 switch (ev->type()) {
2049 case QEvent::KeyPress:
2050 case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate
2051 switch (static_cast<const QKeyEvent*>(ev)->key()) {
2052 case Qt::Key_Escape:
2053 case Qt::Key_Enter:
2054 case Qt::Key_Return:
2055 ev->ignore();
2056 return true;
2057 default:
2058 break;
2059 }
2060 }
2061 break;
2062 default:
2063 break;
2064 }
2065 }
2066 return QWidget::eventFilter(obj, ev);
2067}
2068
2069// QtColorEditorFactoryPrivate
2070
2071class QtColorEditorFactoryPrivate : public EditorFactoryPrivate<QtColorEditWidget>
2072{
2073 QtColorEditorFactory *q_ptr = nullptr;
2074 Q_DECLARE_PUBLIC(QtColorEditorFactory)
2075public:
2076
2077 void slotPropertyChanged(QtProperty *property, QColor value);
2078 void slotSetValue(QtProperty *property, QColor value);
2079};
2080
2081void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
2082 QColor value)
2083{
2084 const auto it = m_createdEditors.constFind(property);
2085 if (it == m_createdEditors.constEnd())
2086 return;
2087
2088 for (QtColorEditWidget *e : it.value())
2089 e->setValue(value);
2090}
2091
2092void QtColorEditorFactoryPrivate::slotSetValue(QtProperty *property, QColor value)
2093{
2094 if (QtColorPropertyManager *manager = q_ptr->propertyManager(property))
2095 manager->setValue(property, value);
2096}
2097
2098/*!
2099 \class QtColorEditorFactory
2100 \internal
2101 \inmodule QtDesigner
2102 \since 4.4
2103
2104 \brief The QtColorEditorFactory class provides color editing for
2105 properties created by QtColorPropertyManager objects.
2106
2107 \sa QtAbstractEditorFactory, QtColorPropertyManager
2108*/
2109
2110/*!
2111 Creates a factory with the given \a parent.
2112*/
2113QtColorEditorFactory::QtColorEditorFactory(QObject *parent) :
2114 QtAbstractEditorFactory<QtColorPropertyManager>(parent),
2115 d_ptr(new QtColorEditorFactoryPrivate())
2116{
2117 d_ptr->q_ptr = this;
2118}
2119
2120/*!
2121 Destroys this factory, and all the widgets it has created.
2122*/
2124{
2125 d_ptr->deleteEditors();
2126}
2127
2128/*!
2129 \internal
2130
2131 Reimplemented from the QtAbstractEditorFactory class.
2132*/
2134{
2135 connect(manager, &QtColorPropertyManager::valueChanged,
2136 this, [this](QtProperty *property, QColor value)
2137 { d_ptr->slotPropertyChanged(property, value); });
2138}
2139
2140/*!
2141 \internal
2142
2143 Reimplemented from the QtAbstractEditorFactory class.
2144*/
2146 QtProperty *property, QWidget *parent)
2147{
2148 QtColorEditWidget *editor = d_ptr->createEditor(property, parent);
2149 editor->setValue(manager->value(property));
2150 connect(editor, &QtColorEditWidget::valueChanged,
2151 this, [this, property](QColor value) { d_ptr->slotSetValue(property, value); });
2152 connect(editor, &QObject::destroyed,
2153 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
2154 return editor;
2155}
2156
2157/*!
2158 \internal
2159
2160 Reimplemented from the QtAbstractEditorFactory class.
2161*/
2163{
2164 disconnect(manager, &QtColorPropertyManager::valueChanged, this, nullptr);
2165}
2166
2167// QtFontEditWidget
2168
2170 Q_OBJECT
2171
2172public:
2174
2175 bool eventFilter(QObject *obj, QEvent *ev) override;
2176
2177public Q_SLOTS:
2178 void setValue(const QFont &value);
2179
2180private Q_SLOTS:
2181 void buttonClicked();
2182
2183Q_SIGNALS:
2185
2186private:
2187 void updateFont();
2188
2189 QFont m_font;
2190 QLabel *m_pixmapLabel;
2191 QLabel *m_label;
2192 QToolButton *m_button;
2193};
2194
2195QtFontEditWidget::QtFontEditWidget(QWidget *parent) :
2196 QWidget(parent),
2197 m_pixmapLabel(new QLabel),
2198 m_label(new QLabel),
2199 m_button(new QToolButton)
2200{
2201 auto *lt = new QHBoxLayout(this);
2202 setupTreeViewEditorMargin(lt);
2203 lt->setSpacing(0);
2204 lt->addWidget(m_pixmapLabel);
2205 lt->addWidget(m_label);
2206 lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
2207
2208 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
2209 m_button->setFixedWidth(20);
2210 setFocusProxy(m_button);
2211 setFocusPolicy(m_button->focusPolicy());
2212 m_button->setText(tr("..."));
2213 m_button->installEventFilter(this);
2214 connect(m_button, &QAbstractButton::clicked, this, &QtFontEditWidget::buttonClicked);
2215 lt->addWidget(m_button);
2216 updateFont();
2217}
2218
2219void QtFontEditWidget::updateFont()
2220{
2221 const auto pm = QtPropertyBrowserUtils::fontValuePixmap(
2222 m_font, QtPropertyBrowserUtils::itemViewIconSize, devicePixelRatioF());
2223 m_pixmapLabel->setPixmap(pm);
2224 m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font));
2225}
2226
2227void QtFontEditWidget::setValue(const QFont &f)
2228{
2229 if (m_font != f) {
2230 m_font = f;
2231 updateFont();
2232 }
2233}
2234
2235void QtFontEditWidget::buttonClicked()
2236{
2237 bool ok = false;
2238 QFont newFont = QFontDialog::getFont(&ok, m_font, this, tr("Select Font"));
2239 if (ok && newFont != m_font) {
2240 QFont f = m_font;
2241 // prevent mask for unchanged attributes, don't change other attributes (like kerning, etc...)
2242 if (m_font.family() != newFont.family())
2243 f.setFamily(newFont.family());
2244 if (m_font.pointSize() != newFont.pointSize())
2245 f.setPointSize(newFont.pointSize());
2246 if (m_font.bold() != newFont.bold())
2247 f.setBold(newFont.bold());
2248 if (m_font.italic() != newFont.italic())
2249 f.setItalic(newFont.italic());
2250 if (m_font.underline() != newFont.underline())
2251 f.setUnderline(newFont.underline());
2252 if (m_font.strikeOut() != newFont.strikeOut())
2253 f.setStrikeOut(newFont.strikeOut());
2254 setValue(f);
2255 emit valueChanged(m_font);
2256 }
2257}
2258
2259bool QtFontEditWidget::eventFilter(QObject *obj, QEvent *ev)
2260{
2261 if (obj == m_button) {
2262 switch (ev->type()) {
2263 case QEvent::KeyPress:
2264 case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate
2265 switch (static_cast<const QKeyEvent*>(ev)->key()) {
2266 case Qt::Key_Escape:
2267 case Qt::Key_Enter:
2268 case Qt::Key_Return:
2269 ev->ignore();
2270 return true;
2271 default:
2272 break;
2273 }
2274 }
2275 break;
2276 default:
2277 break;
2278 }
2279 }
2280 return QWidget::eventFilter(obj, ev);
2281}
2282
2283// QtFontEditorFactoryPrivate
2284
2285class QtFontEditorFactoryPrivate : public EditorFactoryPrivate<QtFontEditWidget>
2286{
2287 QtFontEditorFactory *q_ptr = nullptr;
2288 Q_DECLARE_PUBLIC(QtFontEditorFactory)
2289public:
2290
2291 void slotPropertyChanged(QtProperty *property, const QFont &value);
2292 void slotSetValue(QtProperty *property, const QFont &value);
2293};
2294
2295void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
2296 const QFont &value)
2297{
2298 const auto it = m_createdEditors.constFind(property);
2299 if (it == m_createdEditors.constEnd())
2300 return;
2301
2302 for (QtFontEditWidget *e : it.value())
2303 e->setValue(value);
2304}
2305
2306void QtFontEditorFactoryPrivate::slotSetValue(QtProperty *property, const QFont &value)
2307{
2308 if (QtFontPropertyManager *manager = q_ptr->propertyManager(property))
2309 manager->setValue(property, value);
2310}
2311
2312/*!
2313 \class QtFontEditorFactory
2314 \internal
2315 \inmodule QtDesigner
2316 \since 4.4
2317
2318 \brief The QtFontEditorFactory class provides font editing for
2319 properties created by QtFontPropertyManager objects.
2320
2321 \sa QtAbstractEditorFactory, QtFontPropertyManager
2322*/
2323
2324/*!
2325 Creates a factory with the given \a parent.
2326*/
2327QtFontEditorFactory::QtFontEditorFactory(QObject *parent) :
2328 QtAbstractEditorFactory<QtFontPropertyManager>(parent),
2329 d_ptr(new QtFontEditorFactoryPrivate())
2330{
2331 d_ptr->q_ptr = this;
2332}
2333
2334/*!
2335 Destroys this factory, and all the widgets it has created.
2336*/
2338{
2339 d_ptr->deleteEditors();
2340}
2341
2342/*!
2343 \internal
2344
2345 Reimplemented from the QtAbstractEditorFactory class.
2346*/
2348{
2349 connect(manager, &QtFontPropertyManager::valueChanged,
2350 this, [this](QtProperty *property, const QFont &value)
2351 { d_ptr->slotPropertyChanged(property, value); });
2352}
2353
2354/*!
2355 \internal
2356
2357 Reimplemented from the QtAbstractEditorFactory class.
2358*/
2360 QtProperty *property, QWidget *parent)
2361{
2362 QtFontEditWidget *editor = d_ptr->createEditor(property, parent);
2363 editor->setValue(manager->value(property));
2364 connect(editor, &QtFontEditWidget::valueChanged,
2365 this, [this, property](const QFont &value) { d_ptr->slotSetValue(property, value); });
2366 connect(editor, &QObject::destroyed,
2367 this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
2368 return editor;
2369}
2370
2371/*!
2372 \internal
2373
2374 Reimplemented from the QtAbstractEditorFactory class.
2375*/
2377{
2378 disconnect(manager, &QtFontPropertyManager::valueChanged, this, nullptr);
2379}
2380
2381QT_END_NAMESPACE
2382
2383#include "moc_qteditorfactory_p.cpp"
2384#include "qteditorfactory.moc"
PropertyToEditorListMap m_createdEditors
Editor * createEditor(QtProperty *property, QWidget *parent)
void initializeEditor(QtProperty *property, Editor *e)
void slotEditorDestroyed(QObject *object)
The QtAbstractEditorFactoryBase provides an interface for editor factories.
The QtBoolPropertyManager class provides and manages boolean properties.
bool value(const QtProperty *property) const
Returns the given property's value.
QChar value() const
void focusInEvent(QFocusEvent *e) override
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
void focusOutEvent(QFocusEvent *e) override
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
void keyPressEvent(QKeyEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
void keyReleaseEvent(QKeyEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive key release events...
bool event(QEvent *e) override
This virtual function receives events to an object and should return true if the event e was recogniz...
bool eventFilter(QObject *o, QEvent *e) override
Filters events if this object has been installed as an event filter for the watched object.
void slotSetValue(QtProperty *property, const QChar &value)
The QtCharEditorFactory class provides editor widgets for properties created by QtCharPropertyManager...
void disconnectPropertyManager(QtCharPropertyManager *manager) override
~QtCharEditorFactory() override
Destroys this factory, and all the widgets it has created.
void connectPropertyManager(QtCharPropertyManager *manager) override
QWidget * createEditor(QtCharPropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtCharPropertyManager provides and manages QChar properties.
void slotSetValue(QtProperty *property, bool value)
The QtCheckBoxFactory class provides QCheckBox widgets for properties created by QtBoolPropertyManage...
~QtCheckBoxFactory() override
Destroys this factory, and all the widgets it has created.
QWidget * createEditor(QtBoolPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtBoolPropertyManager *manager) override
void connectPropertyManager(QtBoolPropertyManager *manager) override
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
The QtColorEditorFactory class provides color editing for properties created by QtColorPropertyManage...
void disconnectPropertyManager(QtColorPropertyManager *manager) override
void connectPropertyManager(QtColorPropertyManager *manager) override
QWidget * createEditor(QtColorPropertyManager *manager, QtProperty *property, QWidget *parent) override
~QtColorEditorFactory() override
Destroys this factory, and all the widgets it has created.
The QtColorPropertyManager provides and manages QColor properties.
static QtCursorDatabase * instance()
QtEnumPropertyManager * m_enumPropertyManager
QHash< QWidget *, QtProperty * > m_editorToEnum
QHash< QtProperty *, QWidgetList > m_enumToEditors
QtEnumEditorFactory * m_enumEditorFactory
QHash< QtProperty *, QtProperty * > m_propertyToEnum
QHash< QtProperty *, QtProperty * > m_enumToProperty
void slotEnumChanged(QtProperty *property, int value)
void slotEditorDestroyed(QObject *object)
The QtCursorEditorFactory class provides QComboBox widgets for properties created by QtCursorProperty...
~QtCursorEditorFactory() override
Destroys this factory, and all the widgets it has created.
void disconnectPropertyManager(QtCursorPropertyManager *manager) override
void connectPropertyManager(QtCursorPropertyManager *manager) override
QWidget * createEditor(QtCursorPropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtCursorPropertyManager provides and manages QCursor properties.
void slotSetValue(QtProperty *property, QDate value)
void slotRangeChanged(QtProperty *property, QDate min, QDate max)
The QtDateEditFactory class provides QDateEdit widgets for properties created by QtDatePropertyManage...
void disconnectPropertyManager(QtDatePropertyManager *manager) override
void connectPropertyManager(QtDatePropertyManager *manager) override
~QtDateEditFactory() override
Destroys this factory, and all the widgets it has created.
QWidget * createEditor(QtDatePropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtDatePropertyManager provides and manages QDate properties.
void rangeChanged(QtProperty *property, QDate minVal, QDate maxVal)
This signal is emitted whenever a property created by this manager changes its range of valid dates,...
QDate minimum(const QtProperty *property) const
Returns the given property's minimum date.
QDate maximum(const QtProperty *property) const
Returns the given property's maximum date.
QDate value(const QtProperty *property) const
Returns the given property's value.
void slotSetValue(QtProperty *property, const QDateTime &value)
The QtDateTimeEditFactory class provides QDateTimeEdit widgets for properties created by QtDateTimePr...
void disconnectPropertyManager(QtDateTimePropertyManager *manager) override
~QtDateTimeEditFactory() override
Destroys this factory, and all the widgets it has created.
void connectPropertyManager(QtDateTimePropertyManager *manager) override
QWidget * createEditor(QtDateTimePropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtDateTimePropertyManager provides and manages QDateTime properties.
QDateTime value(const QtProperty *property) const
Returns the given property's value.
The QtDoublePropertyManager provides and manages double properties.
double singleStep(const QtProperty *property) const
Returns the given property's step value.
int decimals(const QtProperty *property) const
Returns the given property's precision, in decimals.
void singleStepChanged(QtProperty *property, double step)
This signal is emitted whenever a property created by this manager changes its single step property,...
void decimalsChanged(QtProperty *property, int prec)
This signal is emitted whenever a property created by this manager changes its precision of value,...
double minimum(const QtProperty *property) const
Returns the given property's minimum value.
double value(const QtProperty *property) const
Returns the given property's value.
void rangeChanged(QtProperty *property, double minVal, double maxVal)
This signal is emitted whenever a property created by this manager changes its range of valid values,...
double maximum(const QtProperty *property) const
Returns the given property's maximum value.
void slotSetValue(QtProperty *property, double value)
void slotSingleStepChanged(QtProperty *property, double step)
void slotDecimalsChanged(QtProperty *property, int prec)
void slotRangeChanged(QtProperty *property, double min, double max)
The QtDoubleSpinBoxFactory class provides QDoubleSpinBox widgets for properties created by QtDoublePr...
QWidget * createEditor(QtDoublePropertyManager *manager, QtProperty *property, QWidget *parent) override
void connectPropertyManager(QtDoublePropertyManager *manager) override
void disconnectPropertyManager(QtDoublePropertyManager *manager) override
~QtDoubleSpinBoxFactory() override
Destroys this factory, and all the widgets it has created.
void slotEnumNamesChanged(QtProperty *property, const QStringList &)
void slotEnumIconsChanged(QtProperty *property, const QMap< int, QIcon > &)
void slotSetValue(QtProperty *property, int value)
The QtEnumEditorFactory class provides QComboBox widgets for properties created by QtEnumPropertyMana...
~QtEnumEditorFactory() override
Destroys this factory, and all the widgets it has created.
QWidget * createEditor(QtEnumPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtEnumPropertyManager *manager) override
void connectPropertyManager(QtEnumPropertyManager *manager) override
The QtEnumPropertyManager provides and manages enum properties.
int value(const QtProperty *property) const
Returns the given property's value which is an index in the list returned by enumNames().
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
The QtFontEditorFactory class provides font editing for properties created by QtFontPropertyManager o...
void disconnectPropertyManager(QtFontPropertyManager *manager) override
QWidget * createEditor(QtFontPropertyManager *manager, QtProperty *property, QWidget *parent) override
~QtFontEditorFactory() override
Destroys this factory, and all the widgets it has created.
void connectPropertyManager(QtFontPropertyManager *manager) override
The QtFontPropertyManager provides and manages QFont properties.
The QtIntPropertyManager provides and manages int properties.
void rangeChanged(QtProperty *property, int minVal, int maxVal)
This signal is emitted whenever a property created by this manager changes its range of valid values,...
void singleStepChanged(QtProperty *property, int step)
This signal is emitted whenever a property created by this manager changes its single step property,...
int singleStep(const QtProperty *property) const
Returns the given property's step value.
int minimum(const QtProperty *property) const
Returns the given property's minimum value.
int value(const QtProperty *property) const
Returns the given property's value.
int maximum(const QtProperty *property) const
Returns the given property's maximum value.
void slotSetValue(QtProperty *property, const QKeySequence &value)
The QtKeySequenceEditorFactory class provides editor widgets for properties created by QtKeySequenceP...
void connectPropertyManager(QtKeySequencePropertyManager *manager) override
~QtKeySequenceEditorFactory() override
Destroys this factory, and all the widgets it has created.
QWidget * createEditor(QtKeySequencePropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtKeySequencePropertyManager *manager) override
The QtKeySequencePropertyManager provides and manages QKeySequence properties.
void slotSetValue(QtProperty *property, const QString &value)
void slotRegExpChanged(QtProperty *property, const QRegularExpression &regExp)
The QtLineEditFactory class provides QLineEdit widgets for properties created by QtStringPropertyMana...
void disconnectPropertyManager(QtStringPropertyManager *manager) override
QWidget * createEditor(QtStringPropertyManager *manager, QtProperty *property, QWidget *parent) override
void connectPropertyManager(QtStringPropertyManager *manager) override
~QtLineEditFactory() override
Destroys this factory, and all the widgets it has created.
The QtProperty class encapsulates an instance of a property.
void slotSingleStepChanged(QtProperty *property, int step)
void slotRangeChanged(QtProperty *property, int min, int max)
void slotSetValue(QtProperty *property, int value)
The QtScrollBarFactory class provides QScrollBar widgets for properties created by QtIntPropertyManag...
~QtScrollBarFactory() override
Destroys this factory, and all the widgets it has created.
QWidget * createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) override
void connectPropertyManager(QtIntPropertyManager *manager) override
void disconnectPropertyManager(QtIntPropertyManager *manager) override
void slotSetValue(QtProperty *property, int value)
void slotSingleStepChanged(QtProperty *property, int step)
void slotRangeChanged(QtProperty *property, int min, int max)
The QtSliderFactory class provides QSlider widgets for properties created by QtIntPropertyManager obj...
void connectPropertyManager(QtIntPropertyManager *manager) override
void disconnectPropertyManager(QtIntPropertyManager *manager) override
QWidget * createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) override
~QtSliderFactory() override
Destroys this factory, and all the widgets it has created.
void slotRangeChanged(QtProperty *property, int min, int max)
void slotSetValue(QtProperty *property, int value)
void slotSingleStepChanged(QtProperty *property, int step)
The QtSpinBoxFactory class provides QSpinBox widgets for properties created by QtIntPropertyManager o...
void disconnectPropertyManager(QtIntPropertyManager *manager) override
void connectPropertyManager(QtIntPropertyManager *manager) override
~QtSpinBoxFactory() override
Destroys this factory, and all the widgets it has created.
QWidget * createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtStringPropertyManager provides and manages QString properties.
void regExpChanged(QtProperty *property, const QRegularExpression &regExp)
This signal is emitted whenever a property created by this manager changes its currenlty set regular ...
void slotSetValue(QtProperty *property, QTime value)
The QtTimeEditFactory class provides QTimeEdit widgets for properties created by QtTimePropertyManage...
QWidget * createEditor(QtTimePropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtTimePropertyManager *manager) override
void connectPropertyManager(QtTimePropertyManager *manager) override
~QtTimeEditFactory() override
Destroys this factory, and all the widgets it has created.
The QtTimePropertyManager provides and manages QTime properties.
QTime value(const QtProperty *property) const
Returns the given property's value.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE void setupTreeViewEditorMargin(QLayout *lt)