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