qteditorfactory.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the Qt Solutions component.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** You may use this file under the terms of the BSD license as follows:
10**
11** "Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are
13** met:
14** * Redistributions of source code must retain the above copyright
15** notice, this list of conditions and the following disclaimer.
16** * Redistributions in binary form must reproduce the above copyright
17** notice, this list of conditions and the following disclaimer in
18** the documentation and/or other materials provided with the
19** distribution.
20** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21** of its contributors may be used to endorse or promote products derived
22** from this software without specific prior written permission.
23**
24**
25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41
42#include "qteditorfactory.h"
43
44#include <QAbstractItemView>
45#include <QApplication>
46#include <QColorDialog>
47#include <QComboBox>
48#include <QDateTimeEdit>
49#include <QFontDialog>
50#include <QHBoxLayout>
51#include <QKeyEvent>
52#include <QLabel>
53#include <QLineEdit>
54#include <QMap>
55#include <QMenu>
56#include <QPainter>
57#include <QScrollBar>
58#include <QSpacerItem>
59#include <QSpinBox>
60#include <QStyleOption>
61#include <QToolButton>
62
64
65#if defined(Q_CC_MSVC)
66#pragma warning(disable : 4786) /* MS VS 6: truncating debug info after 255 characters */
67#endif
68
69QT_BEGIN_NAMESPACE
70
71// Set a hard coded left margin to account for the indentation
72// of the tree view icon when switching to an editor
73
74static inline void
75setupTreeViewEditorMargin(QLayout* lt)
76{
77 enum
78 {
79 DecorationMargin = 4
80 };
81
82 if (QApplication::layoutDirection() == Qt::LeftToRight)
83 {
84 lt->setContentsMargins(DecorationMargin, 0, 0, 0);
85 }
86 else
87 {
88 lt->setContentsMargins(0, 0, DecorationMargin, 0);
89 }
90}
91
92// ---------- EditorFactoryPrivate :
93// Base class for editor factory private classes. Manages mapping of properties to editors and vice versa.
94
95template <class Editor>
97{
98public:
99 using EditorList = QList<Editor*>;
100 using PropertyToEditorListMap = QMap<QtProperty*, EditorList>;
101 using EditorToPropertyMap = QMap<Editor*, QtProperty*>;
102
103 Editor* createEditor(QtProperty* property, QWidget* parent);
104 void initializeEditor(QtProperty* property, Editor* e);
105 void slotEditorDestroyed(QObject* object);
106
109};
110
111template <class Editor>
112Editor*
114{
115 Editor* editor = new Editor(parent);
116 initializeEditor(property, editor);
117 return editor;
118}
119
120template <class Editor>
121void
123{
124 typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
125
126 if (it == m_createdEditors.end())
127 {
128 it = m_createdEditors.insert(property, EditorList());
129 }
130
131 it.value().append(editor);
132 m_editorToProperty.insert(editor, property);
133}
134
135template <class Editor>
136void
138{
139 const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end();
140
141 for (typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin();
142 itEditor != ecend;
143 ++itEditor)
144 {
145 if (itEditor.key() == object)
146 {
147 Editor* editor = itEditor.key();
148 QtProperty* property = itEditor.value();
149 const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property);
150
151 if (pit != m_createdEditors.end())
152 {
153 pit.value().removeAll(editor);
154
155 if (pit.value().empty())
156 {
157 m_createdEditors.erase(pit);
158 }
159 }
160
161 m_editorToProperty.erase(itEditor);
162 return;
163 }
164 }
165}
166
167// ------------ QtSpinBoxFactory
168
170{
171 QtSpinBoxFactory* q_ptr;
172 Q_DECLARE_PUBLIC(QtSpinBoxFactory)
173public:
174 void slotPropertyChanged(QtProperty* property, int value);
175 void slotRangeChanged(QtProperty* property, int min, int max);
176 void slotSingleStepChanged(QtProperty* property, int step);
177 void slotReadOnlyChanged(QtProperty* property, bool readOnly);
178 void slotSetValue(int value);
179};
180
181void
183{
184 if (!m_createdEditors.contains(property))
185 {
186 return;
187 }
188
189 QListIterator<QSpinBox*> itEditor(m_createdEditors[property]);
190
191 while (itEditor.hasNext())
192 {
193 QSpinBox* editor = itEditor.next();
194
195 if (editor->value() != value)
196 {
197 editor->blockSignals(true);
198 editor->setValue(value);
199 editor->blockSignals(false);
200 }
201 }
202}
203
204void
206{
207 if (!m_createdEditors.contains(property))
208 {
209 return;
210 }
211
212 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
213
214 if (!manager)
215 {
216 return;
217 }
218
219 QListIterator<QSpinBox*> itEditor(m_createdEditors[property]);
220
221 while (itEditor.hasNext())
222 {
223 QSpinBox* editor = itEditor.next();
224 editor->blockSignals(true);
225 editor->setRange(min, max);
226 editor->setValue(manager->value(property));
227 editor->blockSignals(false);
228 }
229}
230
231void
233{
234 if (!m_createdEditors.contains(property))
235 {
236 return;
237 }
238
239 QListIterator<QSpinBox*> itEditor(m_createdEditors[property]);
240
241 while (itEditor.hasNext())
242 {
243 QSpinBox* editor = itEditor.next();
244 editor->blockSignals(true);
245 editor->setSingleStep(step);
246 editor->blockSignals(false);
247 }
248}
249
250void
252{
253 if (!m_createdEditors.contains(property))
254 {
255 return;
256 }
257
258 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
259
260 if (!manager)
261 {
262 return;
263 }
264
265 QListIterator<QSpinBox*> itEditor(m_createdEditors[property]);
266
267 while (itEditor.hasNext())
268 {
269 QSpinBox* editor = itEditor.next();
270 editor->blockSignals(true);
271 editor->setReadOnly(readOnly);
272 editor->blockSignals(false);
273 }
274}
275
276void
278{
279 QObject* object = q_ptr->sender();
280 const QMap<QSpinBox*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
281
282 for (QMap<QSpinBox*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
283 itEditor != ecend;
284 ++itEditor)
285 {
286 if (itEditor.key() == object)
287 {
288 QtProperty* property = itEditor.value();
289 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
290
291 if (!manager)
292 {
293 return;
294 }
295
296 manager->setValue(property, value);
297 return;
298 }
299 }
300}
301
302/*!
303 \class QtSpinBoxFactory
304
305 \brief The QtSpinBoxFactory class provides QSpinBox widgets for
306 properties created by QtIntPropertyManager objects.
307
308 \sa QtAbstractEditorFactory, QtIntPropertyManager
309*/
310
311/*!
312 Creates a factory with the given \a parent.
313*/
316{
317 d_ptr = new QtSpinBoxFactoryPrivate();
318 d_ptr->q_ptr = this;
319}
320
321/*!
322 Destroys this factory, and all the widgets it has created.
323*/
325{
326 qDeleteAll(d_ptr->m_editorToProperty.keys());
327 delete d_ptr;
328}
329
330/*!
331 \internal
332
333 Reimplemented from the QtAbstractEditorFactory class.
334*/
335void
337{
338 connect(manager,
339 SIGNAL(valueChanged(QtProperty*, int)),
340 this,
341 SLOT(slotPropertyChanged(QtProperty*, int)));
342 connect(manager,
343 SIGNAL(rangeChanged(QtProperty*, int, int)),
344 this,
345 SLOT(slotRangeChanged(QtProperty*, int, int)));
346 connect(manager,
347 SIGNAL(singleStepChanged(QtProperty*, int)),
348 this,
349 SLOT(slotSingleStepChanged(QtProperty*, int)));
350 connect(manager,
351 SIGNAL(readOnlyChanged(QtProperty*, bool)),
352 this,
353 SLOT(slotReadOnlyChanged(QtProperty*, bool)));
354}
355
356/*!
357 \internal
358
359 Reimplemented from the QtAbstractEditorFactory class.
360*/
361QWidget*
363{
364 QSpinBox* editor = d_ptr->createEditor(property, parent);
365 editor->setSingleStep(manager->singleStep(property));
366 editor->setRange(manager->minimum(property), manager->maximum(property));
367 editor->setValue(manager->value(property));
368 editor->setKeyboardTracking(false);
369 editor->setReadOnly(manager->isReadOnly(property));
370
371 connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
372 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
373 return editor;
374}
375
376/*!
377 \internal
378
379 Reimplemented from the QtAbstractEditorFactory class.
380*/
381void
383{
384 disconnect(manager,
385 SIGNAL(valueChanged(QtProperty*, int)),
386 this,
387 SLOT(slotPropertyChanged(QtProperty*, int)));
388 disconnect(manager,
389 SIGNAL(rangeChanged(QtProperty*, int, int)),
390 this,
391 SLOT(slotRangeChanged(QtProperty*, int, int)));
392 disconnect(manager,
393 SIGNAL(singleStepChanged(QtProperty*, int)),
394 this,
395 SLOT(slotSingleStepChanged(QtProperty*, int)));
396 disconnect(manager,
397 SIGNAL(readOnlyChanged(QtProperty*, bool)),
398 this,
399 SLOT(slotReadOnlyChanged(QtProperty*, bool)));
400}
401
402// QtSliderFactory
403
405{
406 QtSliderFactory* q_ptr;
407 Q_DECLARE_PUBLIC(QtSliderFactory)
408public:
409 void slotPropertyChanged(QtProperty* property, int value);
410 void slotRangeChanged(QtProperty* property, int min, int max);
411 void slotSingleStepChanged(QtProperty* property, int step);
412 void slotSetValue(int value);
413};
414
415void
417{
418 if (!m_createdEditors.contains(property))
419 {
420 return;
421 }
422
423 QListIterator<QSlider*> itEditor(m_createdEditors[property]);
424
425 while (itEditor.hasNext())
426 {
427 QSlider* editor = itEditor.next();
428 editor->blockSignals(true);
429 editor->setValue(value);
430 editor->blockSignals(false);
431 }
432}
433
434void
436{
437 if (!m_createdEditors.contains(property))
438 {
439 return;
440 }
441
442 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
443
444 if (!manager)
445 {
446 return;
447 }
448
449 QListIterator<QSlider*> itEditor(m_createdEditors[property]);
450
451 while (itEditor.hasNext())
452 {
453 QSlider* editor = itEditor.next();
454 editor->blockSignals(true);
455 editor->setRange(min, max);
456 editor->setValue(manager->value(property));
457 editor->blockSignals(false);
458 }
459}
460
461void
463{
464 if (!m_createdEditors.contains(property))
465 {
466 return;
467 }
468
469 QListIterator<QSlider*> itEditor(m_createdEditors[property]);
470
471 while (itEditor.hasNext())
472 {
473 QSlider* editor = itEditor.next();
474 editor->blockSignals(true);
475 editor->setSingleStep(step);
476 editor->blockSignals(false);
477 }
478}
479
480void
482{
483 QObject* object = q_ptr->sender();
484 const QMap<QSlider*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
485
486 for (QMap<QSlider*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
487 itEditor != ecend;
488 ++itEditor)
489 {
490 if (itEditor.key() == object)
491 {
492 QtProperty* property = itEditor.value();
493 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
494
495 if (!manager)
496 {
497 return;
498 }
499
500 manager->setValue(property, value);
501 return;
502 }
503 }
504}
505
506/*!
507 \class QtSliderFactory
508
509 \brief The QtSliderFactory class provides QSlider widgets for
510 properties created by QtIntPropertyManager objects.
511
512 \sa QtAbstractEditorFactory, QtIntPropertyManager
513*/
514
515/*!
516 Creates a factory with the given \a parent.
517*/
520{
521 d_ptr = new QtSliderFactoryPrivate();
522 d_ptr->q_ptr = this;
523}
524
525/*!
526 Destroys this factory, and all the widgets it has created.
527*/
529{
530 qDeleteAll(d_ptr->m_editorToProperty.keys());
531 delete d_ptr;
532}
533
534/*!
535 \internal
536
537 Reimplemented from the QtAbstractEditorFactory class.
538*/
539void
541{
542 connect(manager,
543 SIGNAL(valueChanged(QtProperty*, int)),
544 this,
545 SLOT(slotPropertyChanged(QtProperty*, int)));
546 connect(manager,
547 SIGNAL(rangeChanged(QtProperty*, int, int)),
548 this,
549 SLOT(slotRangeChanged(QtProperty*, int, int)));
550 connect(manager,
551 SIGNAL(singleStepChanged(QtProperty*, int)),
552 this,
553 SLOT(slotSingleStepChanged(QtProperty*, int)));
554}
555
556/*!
557 \internal
558
559 Reimplemented from the QtAbstractEditorFactory class.
560*/
561QWidget*
563{
564 QSlider* editor = new QSlider(Qt::Horizontal, parent);
565 d_ptr->initializeEditor(property, editor);
566 editor->setSingleStep(manager->singleStep(property));
567 editor->setRange(manager->minimum(property), manager->maximum(property));
568 editor->setValue(manager->value(property));
569
570 connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
571 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
572 return editor;
573}
574
575/*!
576 \internal
577
578 Reimplemented from the QtAbstractEditorFactory class.
579*/
580void
582{
583 disconnect(manager,
584 SIGNAL(valueChanged(QtProperty*, int)),
585 this,
586 SLOT(slotPropertyChanged(QtProperty*, int)));
587 disconnect(manager,
588 SIGNAL(rangeChanged(QtProperty*, int, int)),
589 this,
590 SLOT(slotRangeChanged(QtProperty*, int, int)));
591 disconnect(manager,
592 SIGNAL(singleStepChanged(QtProperty*, int)),
593 this,
594 SLOT(slotSingleStepChanged(QtProperty*, int)));
595}
596
597// QtSliderFactory
598
600{
601 QtScrollBarFactory* q_ptr;
602 Q_DECLARE_PUBLIC(QtScrollBarFactory)
603public:
604 void slotPropertyChanged(QtProperty* property, int value);
605 void slotRangeChanged(QtProperty* property, int min, int max);
606 void slotSingleStepChanged(QtProperty* property, int step);
607 void slotSetValue(int value);
608};
609
610void
612{
613 if (!m_createdEditors.contains(property))
614 {
615 return;
616 }
617
618 QListIterator<QScrollBar*> itEditor(m_createdEditors[property]);
619
620 while (itEditor.hasNext())
621 {
622 QScrollBar* editor = itEditor.next();
623 editor->blockSignals(true);
624 editor->setValue(value);
625 editor->blockSignals(false);
626 }
627}
628
629void
631{
632 if (!m_createdEditors.contains(property))
633 {
634 return;
635 }
636
637 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
638
639 if (!manager)
640 {
641 return;
642 }
643
644 QListIterator<QScrollBar*> itEditor(m_createdEditors[property]);
645
646 while (itEditor.hasNext())
647 {
648 QScrollBar* editor = itEditor.next();
649 editor->blockSignals(true);
650 editor->setRange(min, max);
651 editor->setValue(manager->value(property));
652 editor->blockSignals(false);
653 }
654}
655
656void
658{
659 if (!m_createdEditors.contains(property))
660 {
661 return;
662 }
663
664 QListIterator<QScrollBar*> itEditor(m_createdEditors[property]);
665
666 while (itEditor.hasNext())
667 {
668 QScrollBar* editor = itEditor.next();
669 editor->blockSignals(true);
670 editor->setSingleStep(step);
671 editor->blockSignals(false);
672 }
673}
674
675void
677{
678 QObject* object = q_ptr->sender();
679 const QMap<QScrollBar*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
680
681 for (QMap<QScrollBar*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
682 itEditor != ecend;
683 ++itEditor)
684 if (itEditor.key() == object)
685 {
686 QtProperty* property = itEditor.value();
687 QtIntPropertyManager* manager = q_ptr->propertyManager(property);
688
689 if (!manager)
690 {
691 return;
692 }
693
694 manager->setValue(property, value);
695 return;
696 }
697}
698
699/*!
700 \class QtScrollBarFactory
701
702 \brief The QtScrollBarFactory class provides QScrollBar widgets for
703 properties created by QtIntPropertyManager objects.
704
705 \sa QtAbstractEditorFactory, QtIntPropertyManager
706*/
707
708/*!
709 Creates a factory with the given \a parent.
710*/
713{
714 d_ptr = new QtScrollBarFactoryPrivate();
715 d_ptr->q_ptr = this;
716}
717
718/*!
719 Destroys this factory, and all the widgets it has created.
720*/
722{
723 qDeleteAll(d_ptr->m_editorToProperty.keys());
724 delete d_ptr;
725}
726
727/*!
728 \internal
729
730 Reimplemented from the QtAbstractEditorFactory class.
731*/
732void
734{
735 connect(manager,
736 SIGNAL(valueChanged(QtProperty*, int)),
737 this,
738 SLOT(slotPropertyChanged(QtProperty*, int)));
739 connect(manager,
740 SIGNAL(rangeChanged(QtProperty*, int, int)),
741 this,
742 SLOT(slotRangeChanged(QtProperty*, int, int)));
743 connect(manager,
744 SIGNAL(singleStepChanged(QtProperty*, int)),
745 this,
746 SLOT(slotSingleStepChanged(QtProperty*, int)));
747}
748
749/*!
750 \internal
751
752 Reimplemented from the QtAbstractEditorFactory class.
753*/
754QWidget*
756 QtProperty* property,
757 QWidget* parent)
758{
759 QScrollBar* editor = new QScrollBar(Qt::Horizontal, parent);
760 d_ptr->initializeEditor(property, editor);
761 editor->setSingleStep(manager->singleStep(property));
762 editor->setRange(manager->minimum(property), manager->maximum(property));
763 editor->setValue(manager->value(property));
764 connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
765 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
766 return editor;
767}
768
769/*!
770 \internal
771
772 Reimplemented from the QtAbstractEditorFactory class.
773*/
774void
776{
777 disconnect(manager,
778 SIGNAL(valueChanged(QtProperty*, int)),
779 this,
780 SLOT(slotPropertyChanged(QtProperty*, int)));
781 disconnect(manager,
782 SIGNAL(rangeChanged(QtProperty*, int, int)),
783 this,
784 SLOT(slotRangeChanged(QtProperty*, int, int)));
785 disconnect(manager,
786 SIGNAL(singleStepChanged(QtProperty*, int)),
787 this,
788 SLOT(slotSingleStepChanged(QtProperty*, int)));
789}
790
791// QtCheckBoxFactory
792
794{
795 QtCheckBoxFactory* q_ptr;
796 Q_DECLARE_PUBLIC(QtCheckBoxFactory)
797public:
798 void slotPropertyChanged(QtProperty* property, bool value);
799 void slotTextVisibleChanged(QtProperty* property, bool textVisible);
800 void slotSetValue(bool value);
801};
802
803void
805{
806 if (!m_createdEditors.contains(property))
807 {
808 return;
809 }
810
811 QListIterator<QtBoolEdit*> itEditor(m_createdEditors[property]);
812
813 while (itEditor.hasNext())
814 {
815 QtBoolEdit* editor = itEditor.next();
816 editor->blockCheckBoxSignals(true);
817 editor->setChecked(value);
818 editor->blockCheckBoxSignals(false);
819 }
820}
821
822void
824{
825 if (!m_createdEditors.contains(property))
826 {
827 return;
828 }
829
830 QtBoolPropertyManager* manager = q_ptr->propertyManager(property);
831
832 if (!manager)
833 {
834 return;
835 }
836
837 QListIterator<QtBoolEdit*> itEditor(m_createdEditors[property]);
838
839 while (itEditor.hasNext())
840 {
841 QtBoolEdit* editor = itEditor.next();
842 editor->setTextVisible(textVisible);
843 }
844}
845
846void
848{
849 QObject* object = q_ptr->sender();
850
851 const QMap<QtBoolEdit*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
852
853 for (QMap<QtBoolEdit*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
854 itEditor != ecend;
855 ++itEditor)
856 if (itEditor.key() == object)
857 {
858 QtProperty* property = itEditor.value();
859 QtBoolPropertyManager* manager = q_ptr->propertyManager(property);
860
861 if (!manager)
862 {
863 return;
864 }
865
866 manager->setValue(property, value);
867 return;
868 }
869}
870
871/*!
872 \class QtCheckBoxFactory
873
874 \brief The QtCheckBoxFactory class provides QCheckBox widgets for
875 properties created by QtBoolPropertyManager objects.
876
877 \sa QtAbstractEditorFactory, QtBoolPropertyManager
878*/
879
880/*!
881 Creates a factory with the given \a parent.
882*/
885{
886 d_ptr = new QtCheckBoxFactoryPrivate();
887 d_ptr->q_ptr = this;
888}
889
890/*!
891 Destroys this factory, and all the widgets it has created.
892*/
894{
895 qDeleteAll(d_ptr->m_editorToProperty.keys());
896 delete d_ptr;
897}
898
899/*!
900 \internal
901
902 Reimplemented from the QtAbstractEditorFactory class.
903*/
904void
906{
907 connect(manager,
908 SIGNAL(valueChanged(QtProperty*, bool)),
909 this,
910 SLOT(slotPropertyChanged(QtProperty*, bool)));
911 connect(manager,
912 SIGNAL(textVisibleChanged(QtProperty*, bool)),
913 this,
914 SLOT(slotTextVisibleChanged(QtProperty*, bool)));
915}
916
917/*!
918 \internal
919
920 Reimplemented from the QtAbstractEditorFactory class.
921*/
922QWidget*
924 QtProperty* property,
925 QWidget* parent)
926{
927 QtBoolEdit* editor = d_ptr->createEditor(property, parent);
928 editor->setChecked(manager->value(property));
929 editor->setTextVisible(manager->textVisible(property));
930
931 connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool)));
932 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
933 return editor;
934}
935
936/*!
937 \internal
938
939 Reimplemented from the QtAbstractEditorFactory class.
940*/
941void
943{
944 disconnect(manager,
945 SIGNAL(valueChanged(QtProperty*, bool)),
946 this,
947 SLOT(slotPropertyChanged(QtProperty*, bool)));
948 disconnect(manager,
949 SIGNAL(textVisibleChanged(QtProperty*, bool)),
950 this,
951 SLOT(slotTextVisibleChanged(QtProperty*, bool)));
952}
953
954// QtDoubleSpinBoxFactory
955
957{
959 Q_DECLARE_PUBLIC(QtDoubleSpinBoxFactory)
960public:
961 void slotPropertyChanged(QtProperty* property, double value);
962 void slotRangeChanged(QtProperty* property, double min, double max);
963 void slotSingleStepChanged(QtProperty* property, double step);
964 void slotDecimalsChanged(QtProperty* property, int prec);
965 void slotReadOnlyChanged(QtProperty* property, bool readOnly);
966 void slotSetValue(double value);
967};
968
969void
971{
972 QList<QDoubleSpinBox*> editors = m_createdEditors[property];
973 QListIterator<QDoubleSpinBox*> itEditor(m_createdEditors[property]);
974
975 while (itEditor.hasNext())
976 {
977 QDoubleSpinBox* editor = itEditor.next();
978
979 if (editor->value() != value)
980 {
981 editor->blockSignals(true);
982 editor->setValue(value);
983 editor->blockSignals(false);
984 }
985 }
986}
987
988void
990{
991 if (!m_createdEditors.contains(property))
992 {
993 return;
994 }
995
996 QtDoublePropertyManager* manager = q_ptr->propertyManager(property);
997
998 if (!manager)
999 {
1000 return;
1001 }
1002
1003 QList<QDoubleSpinBox*> editors = m_createdEditors[property];
1004 QListIterator<QDoubleSpinBox*> itEditor(editors);
1005
1006 while (itEditor.hasNext())
1007 {
1008 QDoubleSpinBox* editor = itEditor.next();
1009 editor->blockSignals(true);
1010 editor->setRange(min, max);
1011 editor->setValue(manager->value(property));
1012 editor->blockSignals(false);
1013 }
1014}
1015
1016void
1018{
1019 if (!m_createdEditors.contains(property))
1020 {
1021 return;
1022 }
1023
1024 QtDoublePropertyManager* manager = q_ptr->propertyManager(property);
1025
1026 if (!manager)
1027 {
1028 return;
1029 }
1030
1031 QList<QDoubleSpinBox*> editors = m_createdEditors[property];
1032 QListIterator<QDoubleSpinBox*> itEditor(editors);
1033
1034 while (itEditor.hasNext())
1035 {
1036 QDoubleSpinBox* editor = itEditor.next();
1037 editor->blockSignals(true);
1038 editor->setSingleStep(step);
1039 editor->blockSignals(false);
1040 }
1041}
1042
1043void
1045{
1046 if (!m_createdEditors.contains(property))
1047 {
1048 return;
1049 }
1050
1051 QtDoublePropertyManager* manager = q_ptr->propertyManager(property);
1052
1053 if (!manager)
1054 {
1055 return;
1056 }
1057
1058 QListIterator<QDoubleSpinBox*> itEditor(m_createdEditors[property]);
1059
1060 while (itEditor.hasNext())
1061 {
1062 QDoubleSpinBox* editor = itEditor.next();
1063 editor->blockSignals(true);
1064 editor->setReadOnly(readOnly);
1065 editor->blockSignals(false);
1066 }
1067}
1068
1069void
1071{
1072 if (!m_createdEditors.contains(property))
1073 {
1074 return;
1075 }
1076
1077 QtDoublePropertyManager* manager = q_ptr->propertyManager(property);
1078
1079 if (!manager)
1080 {
1081 return;
1082 }
1083
1084 QList<QDoubleSpinBox*> editors = m_createdEditors[property];
1085 QListIterator<QDoubleSpinBox*> itEditor(editors);
1086
1087 while (itEditor.hasNext())
1088 {
1089 QDoubleSpinBox* editor = itEditor.next();
1090 editor->blockSignals(true);
1091 editor->setDecimals(prec);
1092 editor->setValue(manager->value(property));
1093 editor->blockSignals(false);
1094 }
1095}
1096
1097void
1099{
1100 QObject* object = q_ptr->sender();
1101 const QMap<QDoubleSpinBox*, QtProperty*>::ConstIterator itcend = m_editorToProperty.constEnd();
1102
1103 for (QMap<QDoubleSpinBox*, QtProperty*>::ConstIterator itEditor =
1104 m_editorToProperty.constBegin();
1105 itEditor != itcend;
1106 ++itEditor)
1107 {
1108 if (itEditor.key() == object)
1109 {
1110 QtProperty* property = itEditor.value();
1111 QtDoublePropertyManager* manager = q_ptr->propertyManager(property);
1112
1113 if (!manager)
1114 {
1115 return;
1116 }
1117
1118 manager->setValue(property, value);
1119 return;
1120 }
1121 }
1122}
1123
1124/*! \class QtDoubleSpinBoxFactory
1125
1126 \brief The QtDoubleSpinBoxFactory class provides QDoubleSpinBox
1127 widgets for properties created by QtDoublePropertyManager objects.
1128
1129 \sa QtAbstractEditorFactory, QtDoublePropertyManager
1130*/
1131
1132/*!
1133 Creates a factory with the given \a parent.
1134*/
1137{
1138 d_ptr = new QtDoubleSpinBoxFactoryPrivate();
1139 d_ptr->q_ptr = this;
1140}
1141
1142/*!
1143 Destroys this factory, and all the widgets it has created.
1144*/
1146{
1147 qDeleteAll(d_ptr->m_editorToProperty.keys());
1148 delete d_ptr;
1149}
1150
1151/*!
1152 \internal
1153
1154 Reimplemented from the QtAbstractEditorFactory class.
1155*/
1156void
1158{
1159 connect(manager,
1160 SIGNAL(valueChanged(QtProperty*, double)),
1161 this,
1162 SLOT(slotPropertyChanged(QtProperty*, double)));
1163 connect(manager,
1164 SIGNAL(rangeChanged(QtProperty*, double, double)),
1165 this,
1166 SLOT(slotRangeChanged(QtProperty*, double, double)));
1167 connect(manager,
1168 SIGNAL(singleStepChanged(QtProperty*, double)),
1169 this,
1170 SLOT(slotSingleStepChanged(QtProperty*, double)));
1171 connect(manager,
1172 SIGNAL(decimalsChanged(QtProperty*, int)),
1173 this,
1174 SLOT(slotDecimalsChanged(QtProperty*, int)));
1175 connect(manager,
1176 SIGNAL(readOnlyChanged(QtProperty*, bool)),
1177 this,
1178 SLOT(slotReadOnlyChanged(QtProperty*, bool)));
1179}
1180
1181/*!
1182 \internal
1183
1184 Reimplemented from the QtAbstractEditorFactory class.
1185*/
1186QWidget*
1188 QtProperty* property,
1189 QWidget* parent)
1190{
1191 QDoubleSpinBox* editor = d_ptr->createEditor(property, parent);
1192 editor->setSingleStep(manager->singleStep(property));
1193 editor->setDecimals(manager->decimals(property));
1194 editor->setRange(manager->minimum(property), manager->maximum(property));
1195 editor->setValue(manager->value(property));
1196 editor->setKeyboardTracking(false);
1197 editor->setReadOnly(manager->isReadOnly(property));
1198
1199 connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double)));
1200 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
1201 return editor;
1202}
1203
1204/*!
1205 \internal
1206
1207 Reimplemented from the QtAbstractEditorFactory class.
1208*/
1209void
1211{
1212 disconnect(manager,
1213 SIGNAL(valueChanged(QtProperty*, double)),
1214 this,
1215 SLOT(slotPropertyChanged(QtProperty*, double)));
1216 disconnect(manager,
1217 SIGNAL(rangeChanged(QtProperty*, double, double)),
1218 this,
1219 SLOT(slotRangeChanged(QtProperty*, double, double)));
1220 disconnect(manager,
1221 SIGNAL(singleStepChanged(QtProperty*, double)),
1222 this,
1223 SLOT(slotSingleStepChanged(QtProperty*, double)));
1224 disconnect(manager,
1225 SIGNAL(decimalsChanged(QtProperty*, int)),
1226 this,
1227 SLOT(slotDecimalsChanged(QtProperty*, int)));
1228 disconnect(manager,
1229 SIGNAL(readOnlyChanged(QtProperty*, bool)),
1230 this,
1231 SLOT(slotReadOnlyChanged(QtProperty*, bool)));
1232}
1233
1234// QtLineEditFactory
1235
1237{
1238 QtLineEditFactory* q_ptr;
1239 Q_DECLARE_PUBLIC(QtLineEditFactory)
1240public:
1241 void slotPropertyChanged(QtProperty* property, const QString& value);
1242 void slotRegExpChanged(QtProperty* property, const QRegExp& regExp);
1243 void slotSetValue(const QString& value);
1244 void slotEchoModeChanged(QtProperty*, int);
1245 void slotReadOnlyChanged(QtProperty*, bool);
1246};
1247
1248void
1250{
1251 if (!m_createdEditors.contains(property))
1252 {
1253 return;
1254 }
1255
1256 QListIterator<QLineEdit*> itEditor(m_createdEditors[property]);
1257
1258 while (itEditor.hasNext())
1259 {
1260 QLineEdit* editor = itEditor.next();
1261
1262 if (editor->text() != value)
1263 {
1264 editor->blockSignals(true);
1265 editor->setText(value);
1266 editor->blockSignals(false);
1267 }
1268 }
1269}
1270
1271void
1273{
1274 if (!m_createdEditors.contains(property))
1275 {
1276 return;
1277 }
1278
1279 QtStringPropertyManager* manager = q_ptr->propertyManager(property);
1280
1281 if (!manager)
1282 {
1283 return;
1284 }
1285
1286 QListIterator<QLineEdit*> itEditor(m_createdEditors[property]);
1287
1288 while (itEditor.hasNext())
1289 {
1290 QLineEdit* editor = itEditor.next();
1291 editor->blockSignals(true);
1292 const QValidator* oldValidator = editor->validator();
1293 QValidator* newValidator = 0;
1294
1295 if (regExp.isValid())
1296 {
1297 newValidator = new QRegExpValidator(regExp, editor);
1298 }
1299
1300 editor->setValidator(newValidator);
1301
1302 if (oldValidator)
1303 {
1304 delete oldValidator;
1305 }
1306
1307 editor->blockSignals(false);
1308 }
1309}
1310
1311void
1313{
1314 if (!m_createdEditors.contains(property))
1315 {
1316 return;
1317 }
1318
1319 QtStringPropertyManager* manager = q_ptr->propertyManager(property);
1320
1321 if (!manager)
1322 {
1323 return;
1324 }
1325
1326 QListIterator<QLineEdit*> itEditor(m_createdEditors[property]);
1327
1328 while (itEditor.hasNext())
1329 {
1330 QLineEdit* editor = itEditor.next();
1331 editor->blockSignals(true);
1332 editor->setEchoMode((EchoMode)echoMode);
1333 editor->blockSignals(false);
1334 }
1335}
1336
1337void
1339{
1340 if (!m_createdEditors.contains(property))
1341 {
1342 return;
1343 }
1344
1345 QtStringPropertyManager* manager = q_ptr->propertyManager(property);
1346
1347 if (!manager)
1348 {
1349 return;
1350 }
1351
1352 QListIterator<QLineEdit*> itEditor(m_createdEditors[property]);
1353
1354 while (itEditor.hasNext())
1355 {
1356 QLineEdit* editor = itEditor.next();
1357 editor->blockSignals(true);
1358 editor->setReadOnly(readOnly);
1359 editor->blockSignals(false);
1360 }
1361}
1362
1363void
1365{
1366 QObject* object = q_ptr->sender();
1367 const QMap<QLineEdit*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
1368
1369 for (QMap<QLineEdit*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
1370 itEditor != ecend;
1371 ++itEditor)
1372 if (itEditor.key() == object)
1373 {
1374 QtProperty* property = itEditor.value();
1375 QtStringPropertyManager* manager = q_ptr->propertyManager(property);
1376
1377 if (!manager)
1378 {
1379 return;
1380 }
1381
1382 manager->setValue(property, value);
1383 return;
1384 }
1385}
1386
1387/*!
1388 \class QtLineEditFactory
1389
1390 \brief The QtLineEditFactory class provides QLineEdit widgets for
1391 properties created by QtStringPropertyManager objects.
1392
1393 \sa QtAbstractEditorFactory, QtStringPropertyManager
1394*/
1395
1396/*!
1397 Creates a factory with the given \a parent.
1398*/
1401{
1402 d_ptr = new QtLineEditFactoryPrivate();
1403 d_ptr->q_ptr = this;
1404}
1405
1406/*!
1407 Destroys this factory, and all the widgets it has created.
1408*/
1410{
1411 qDeleteAll(d_ptr->m_editorToProperty.keys());
1412 delete d_ptr;
1413}
1414
1415/*!
1416 \internal
1417
1418 Reimplemented from the QtAbstractEditorFactory class.
1419*/
1420void
1422{
1423 connect(manager,
1424 SIGNAL(valueChanged(QtProperty*, const QString&)),
1425 this,
1426 SLOT(slotPropertyChanged(QtProperty*, const QString&)));
1427 connect(manager,
1428 SIGNAL(regExpChanged(QtProperty*, const QRegExp&)),
1429 this,
1430 SLOT(slotRegExpChanged(QtProperty*, const QRegExp&)));
1431 connect(manager,
1432 SIGNAL(echoModeChanged(QtProperty*, int)),
1433 this,
1434 SLOT(slotEchoModeChanged(QtProperty*, int)));
1435 connect(manager,
1436 SIGNAL(readOnlyChanged(QtProperty*, bool)),
1437 this,
1438 SLOT(slotReadOnlyChanged(QtProperty*, bool)));
1439}
1440
1441/*!
1442 \internal
1443
1444 Reimplemented from the QtAbstractEditorFactory class.
1445*/
1446QWidget*
1448 QtProperty* property,
1449 QWidget* parent)
1450{
1451
1452 QLineEdit* editor = d_ptr->createEditor(property, parent);
1453 editor->setEchoMode((EchoMode)manager->echoMode(property));
1454 editor->setReadOnly(manager->isReadOnly(property));
1455 QRegExp regExp = manager->regExp(property);
1456
1457 if (regExp.isValid())
1458 {
1459 QValidator* validator = new QRegExpValidator(regExp, editor);
1460 editor->setValidator(validator);
1461 }
1462
1463 editor->setText(manager->value(property));
1464
1465 connect(editor, SIGNAL(textChanged(const QString&)), this, SLOT(slotSetValue(const QString&)));
1466 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
1467 return editor;
1468}
1469
1470/*!
1471 \internal
1472
1473 Reimplemented from the QtAbstractEditorFactory class.
1474*/
1475void
1477{
1478 disconnect(manager,
1479 SIGNAL(valueChanged(QtProperty*, const QString&)),
1480 this,
1481 SLOT(slotPropertyChanged(QtProperty*, const QString&)));
1482 disconnect(manager,
1483 SIGNAL(regExpChanged(QtProperty*, const QRegExp&)),
1484 this,
1485 SLOT(slotRegExpChanged(QtProperty*, const QRegExp&)));
1486 disconnect(manager,
1487 SIGNAL(echoModeChanged(QtProperty*, int)),
1488 this,
1489 SLOT(slotEchoModeChanged(QtProperty*, int)));
1490 disconnect(manager,
1491 SIGNAL(readOnlyChanged(QtProperty*, bool)),
1492 this,
1493 SLOT(slotReadOnlyChanged(QtProperty*, bool)));
1494}
1495
1496// QtDateEditFactory
1497
1499{
1500 QtDateEditFactory* q_ptr;
1501 Q_DECLARE_PUBLIC(QtDateEditFactory)
1502public:
1503 void slotPropertyChanged(QtProperty* property, const QDate& value);
1504 void slotRangeChanged(QtProperty* property, const QDate& min, const QDate& max);
1505 void slotSetValue(const QDate& value);
1506};
1507
1508void
1510{
1511 if (!m_createdEditors.contains(property))
1512 {
1513 return;
1514 }
1515
1516 QListIterator<QDateEdit*> itEditor(m_createdEditors[property]);
1517
1518 while (itEditor.hasNext())
1519 {
1520 QDateEdit* editor = itEditor.next();
1521 editor->blockSignals(true);
1522 editor->setDate(value);
1523 editor->blockSignals(false);
1524 }
1525}
1526
1527void
1528QtDateEditFactoryPrivate::slotRangeChanged(QtProperty* property, const QDate& min, const QDate& max)
1529{
1530 if (!m_createdEditors.contains(property))
1531 {
1532 return;
1533 }
1534
1535 QtDatePropertyManager* manager = q_ptr->propertyManager(property);
1536
1537 if (!manager)
1538 {
1539 return;
1540 }
1541
1542 QListIterator<QDateEdit*> itEditor(m_createdEditors[property]);
1543
1544 while (itEditor.hasNext())
1545 {
1546 QDateEdit* editor = itEditor.next();
1547 editor->blockSignals(true);
1548 editor->setDateRange(min, max);
1549 editor->setDate(manager->value(property));
1550 editor->blockSignals(false);
1551 }
1552}
1553
1554void
1556{
1557 QObject* object = q_ptr->sender();
1558 const QMap<QDateEdit*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
1559
1560 for (QMap<QDateEdit*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
1561 itEditor != ecend;
1562 ++itEditor)
1563 if (itEditor.key() == object)
1564 {
1565 QtProperty* property = itEditor.value();
1566 QtDatePropertyManager* manager = q_ptr->propertyManager(property);
1567
1568 if (!manager)
1569 {
1570 return;
1571 }
1572
1573 manager->setValue(property, value);
1574 return;
1575 }
1576}
1577
1578/*!
1579 \class QtDateEditFactory
1580
1581 \brief The QtDateEditFactory class provides QDateEdit widgets for
1582 properties created by QtDatePropertyManager objects.
1583
1584 \sa QtAbstractEditorFactory, QtDatePropertyManager
1585*/
1586
1587/*!
1588 Creates a factory with the given \a parent.
1589*/
1592{
1593 d_ptr = new QtDateEditFactoryPrivate();
1594 d_ptr->q_ptr = this;
1595}
1596
1597/*!
1598 Destroys this factory, and all the widgets it has created.
1599*/
1601{
1602 qDeleteAll(d_ptr->m_editorToProperty.keys());
1603 delete d_ptr;
1604}
1605
1606/*!
1607 \internal
1608
1609 Reimplemented from the QtAbstractEditorFactory class.
1610*/
1611void
1613{
1614 connect(manager,
1615 SIGNAL(valueChanged(QtProperty*, const QDate&)),
1616 this,
1617 SLOT(slotPropertyChanged(QtProperty*, const QDate&)));
1618 connect(manager,
1619 SIGNAL(rangeChanged(QtProperty*, const QDate&, const QDate&)),
1620 this,
1621 SLOT(slotRangeChanged(QtProperty*, const QDate&, const QDate&)));
1622}
1623
1624/*!
1625 \internal
1626
1627 Reimplemented from the QtAbstractEditorFactory class.
1628*/
1629QWidget*
1631 QtProperty* property,
1632 QWidget* parent)
1633{
1634 QDateEdit* editor = d_ptr->createEditor(property, parent);
1635 editor->setCalendarPopup(true);
1636 editor->setDateRange(manager->minimum(property), manager->maximum(property));
1637 editor->setDate(manager->value(property));
1638
1639 connect(editor, SIGNAL(dateChanged(const QDate&)), this, SLOT(slotSetValue(const QDate&)));
1640 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
1641 return editor;
1642}
1643
1644/*!
1645 \internal
1646
1647 Reimplemented from the QtAbstractEditorFactory class.
1648*/
1649void
1651{
1652 disconnect(manager,
1653 SIGNAL(valueChanged(QtProperty*, const QDate&)),
1654 this,
1655 SLOT(slotPropertyChanged(QtProperty*, const QDate&)));
1656 disconnect(manager,
1657 SIGNAL(rangeChanged(QtProperty*, const QDate&, const QDate&)),
1658 this,
1659 SLOT(slotRangeChanged(QtProperty*, const QDate&, const QDate&)));
1660}
1661
1662// QtTimeEditFactory
1663
1665{
1666 QtTimeEditFactory* q_ptr;
1667 Q_DECLARE_PUBLIC(QtTimeEditFactory)
1668public:
1669 void slotPropertyChanged(QtProperty* property, const QTime& value);
1670 void slotSetValue(const QTime& value);
1671};
1672
1673void
1675{
1676 if (!m_createdEditors.contains(property))
1677 {
1678 return;
1679 }
1680
1681 QListIterator<QTimeEdit*> itEditor(m_createdEditors[property]);
1682
1683 while (itEditor.hasNext())
1684 {
1685 QTimeEdit* editor = itEditor.next();
1686 editor->blockSignals(true);
1687 editor->setTime(value);
1688 editor->blockSignals(false);
1689 }
1690}
1691
1692void
1694{
1695 QObject* object = q_ptr->sender();
1696 const QMap<QTimeEdit*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
1697
1698 for (QMap<QTimeEdit*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
1699 itEditor != ecend;
1700 ++itEditor)
1701 if (itEditor.key() == object)
1702 {
1703 QtProperty* property = itEditor.value();
1704 QtTimePropertyManager* manager = q_ptr->propertyManager(property);
1705
1706 if (!manager)
1707 {
1708 return;
1709 }
1710
1711 manager->setValue(property, value);
1712 return;
1713 }
1714}
1715
1716/*!
1717 \class QtTimeEditFactory
1718
1719 \brief The QtTimeEditFactory class provides QTimeEdit widgets for
1720 properties created by QtTimePropertyManager objects.
1721
1722 \sa QtAbstractEditorFactory, QtTimePropertyManager
1723*/
1724
1725/*!
1726 Creates a factory with the given \a parent.
1727*/
1730{
1731 d_ptr = new QtTimeEditFactoryPrivate();
1732 d_ptr->q_ptr = this;
1733}
1734
1735/*!
1736 Destroys this factory, and all the widgets it has created.
1737*/
1739{
1740 qDeleteAll(d_ptr->m_editorToProperty.keys());
1741 delete d_ptr;
1742}
1743
1744/*!
1745 \internal
1746
1747 Reimplemented from the QtAbstractEditorFactory class.
1748*/
1749void
1751{
1752 connect(manager,
1753 SIGNAL(valueChanged(QtProperty*, const QTime&)),
1754 this,
1755 SLOT(slotPropertyChanged(QtProperty*, const QTime&)));
1756}
1757
1758/*!
1759 \internal
1760
1761 Reimplemented from the QtAbstractEditorFactory class.
1762*/
1763QWidget*
1765 QtProperty* property,
1766 QWidget* parent)
1767{
1768 QTimeEdit* editor = d_ptr->createEditor(property, parent);
1769 editor->setTime(manager->value(property));
1770
1771 connect(editor, SIGNAL(timeChanged(const QTime&)), this, SLOT(slotSetValue(const QTime&)));
1772 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
1773 return editor;
1774}
1775
1776/*!
1777 \internal
1778
1779 Reimplemented from the QtAbstractEditorFactory class.
1780*/
1781void
1783{
1784 disconnect(manager,
1785 SIGNAL(valueChanged(QtProperty*, const QTime&)),
1786 this,
1787 SLOT(slotPropertyChanged(QtProperty*, const QTime&)));
1788}
1789
1790// QtDateTimeEditFactory
1791
1793{
1794 QtDateTimeEditFactory* q_ptr;
1795 Q_DECLARE_PUBLIC(QtDateTimeEditFactory)
1796public:
1797 void slotPropertyChanged(QtProperty* property, const QDateTime& value);
1798 void slotSetValue(const QDateTime& value);
1799};
1800
1801void
1803{
1804 if (!m_createdEditors.contains(property))
1805 {
1806 return;
1807 }
1808
1809 QListIterator<QDateTimeEdit*> itEditor(m_createdEditors[property]);
1810
1811 while (itEditor.hasNext())
1812 {
1813 QDateTimeEdit* editor = itEditor.next();
1814 editor->blockSignals(true);
1815 editor->setDateTime(value);
1816 editor->blockSignals(false);
1817 }
1818}
1819
1820void
1822{
1823 QObject* object = q_ptr->sender();
1824 const QMap<QDateTimeEdit*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
1825
1826 for (QMap<QDateTimeEdit*, QtProperty*>::ConstIterator itEditor =
1827 m_editorToProperty.constBegin();
1828 itEditor != ecend;
1829 ++itEditor)
1830 if (itEditor.key() == object)
1831 {
1832 QtProperty* property = itEditor.value();
1833 QtDateTimePropertyManager* manager = q_ptr->propertyManager(property);
1834
1835 if (!manager)
1836 {
1837 return;
1838 }
1839
1840 manager->setValue(property, value);
1841 return;
1842 }
1843}
1844
1845/*!
1846 \class QtDateTimeEditFactory
1847
1848 \brief The QtDateTimeEditFactory class provides QDateTimeEdit
1849 widgets for properties created by QtDateTimePropertyManager objects.
1850
1851 \sa QtAbstractEditorFactory, QtDateTimePropertyManager
1852*/
1853
1854/*!
1855 Creates a factory with the given \a parent.
1856*/
1859{
1860 d_ptr = new QtDateTimeEditFactoryPrivate();
1861 d_ptr->q_ptr = this;
1862}
1863
1864/*!
1865 Destroys this factory, and all the widgets it has created.
1866*/
1868{
1869 qDeleteAll(d_ptr->m_editorToProperty.keys());
1870 delete d_ptr;
1871}
1872
1873/*!
1874 \internal
1875
1876 Reimplemented from the QtAbstractEditorFactory class.
1877*/
1878void
1880{
1881 connect(manager,
1882 SIGNAL(valueChanged(QtProperty*, const QDateTime&)),
1883 this,
1884 SLOT(slotPropertyChanged(QtProperty*, const QDateTime&)));
1885}
1886
1887/*!
1888 \internal
1889
1890 Reimplemented from the QtAbstractEditorFactory class.
1891*/
1892QWidget*
1894 QtProperty* property,
1895 QWidget* parent)
1896{
1897 QDateTimeEdit* editor = d_ptr->createEditor(property, parent);
1898 editor->setDateTime(manager->value(property));
1899
1900 connect(editor,
1901 SIGNAL(dateTimeChanged(const QDateTime&)),
1902 this,
1903 SLOT(slotSetValue(const QDateTime&)));
1904 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
1905 return editor;
1906}
1907
1908/*!
1909 \internal
1910
1911 Reimplemented from the QtAbstractEditorFactory class.
1912*/
1913void
1915{
1916 disconnect(manager,
1917 SIGNAL(valueChanged(QtProperty*, const QDateTime&)),
1918 this,
1919 SLOT(slotPropertyChanged(QtProperty*, const QDateTime&)));
1920}
1921
1922// QtKeySequenceEditorFactory
1923
1925{
1927 Q_DECLARE_PUBLIC(QtKeySequenceEditorFactory)
1928public:
1929 void slotPropertyChanged(QtProperty* property, const QKeySequence& value);
1930 void slotSetValue(const QKeySequence& value);
1931};
1932
1933void
1935 const QKeySequence& value)
1936{
1937 if (!m_createdEditors.contains(property))
1938 {
1939 return;
1940 }
1941
1942 QListIterator<QtKeySequenceEdit*> itEditor(m_createdEditors[property]);
1943
1944 while (itEditor.hasNext())
1945 {
1946 QtKeySequenceEdit* editor = itEditor.next();
1947 editor->blockSignals(true);
1948 editor->setKeySequence(value);
1949 editor->blockSignals(false);
1950 }
1951}
1952
1953void
1955{
1956 QObject* object = q_ptr->sender();
1957 const QMap<QtKeySequenceEdit*, QtProperty*>::ConstIterator ecend =
1958 m_editorToProperty.constEnd();
1959
1960 for (QMap<QtKeySequenceEdit*, QtProperty*>::ConstIterator itEditor =
1961 m_editorToProperty.constBegin();
1962 itEditor != ecend;
1963 ++itEditor)
1964 if (itEditor.key() == object)
1965 {
1966 QtProperty* property = itEditor.value();
1967 QtKeySequencePropertyManager* manager = q_ptr->propertyManager(property);
1968
1969 if (!manager)
1970 {
1971 return;
1972 }
1973
1974 manager->setValue(property, value);
1975 return;
1976 }
1977}
1978
1979/*!
1980 \class QtKeySequenceEditorFactory
1981
1982 \brief The QtKeySequenceEditorFactory class provides editor
1983 widgets for properties created by QtKeySequencePropertyManager objects.
1984
1985 \sa QtAbstractEditorFactory
1986*/
1987
1988/*!
1989 Creates a factory with the given \a parent.
1990*/
1997
1998/*!
1999 Destroys this factory, and all the widgets it has created.
2000*/
2002{
2003 qDeleteAll(d_ptr->m_editorToProperty.keys());
2004 delete d_ptr;
2005}
2006
2007/*!
2008 \internal
2009
2010 Reimplemented from the QtAbstractEditorFactory class.
2011*/
2012void
2014{
2015 connect(manager,
2016 SIGNAL(valueChanged(QtProperty*, const QKeySequence&)),
2017 this,
2018 SLOT(slotPropertyChanged(QtProperty*, const QKeySequence&)));
2019}
2020
2021/*!
2022 \internal
2023
2024 Reimplemented from the QtAbstractEditorFactory class.
2025*/
2026QWidget*
2028 QtProperty* property,
2029 QWidget* parent)
2030{
2031 QtKeySequenceEdit* editor = d_ptr->createEditor(property, parent);
2032 editor->setKeySequence(manager->value(property));
2033
2034 connect(editor,
2035 SIGNAL(keySequenceChanged(const QKeySequence&)),
2036 this,
2037 SLOT(slotSetValue(const QKeySequence&)));
2038 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
2039 return editor;
2040}
2041
2042/*!
2043 \internal
2044
2045 Reimplemented from the QtAbstractEditorFactory class.
2046*/
2047void
2049{
2050 disconnect(manager,
2051 SIGNAL(valueChanged(QtProperty*, const QKeySequence&)),
2052 this,
2053 SLOT(slotPropertyChanged(QtProperty*, const QKeySequence&)));
2054}
2055
2056// QtCharEdit
2057
2058class QtCharEdit : public QWidget
2059{
2060 Q_OBJECT
2061public:
2062 QtCharEdit(QWidget* parent = 0);
2063
2064 QChar value() const;
2065 bool eventFilter(QObject* o, QEvent* e) override;
2066public Q_SLOTS:
2067 void setValue(const QChar& value);
2068Q_SIGNALS:
2069 void valueChanged(const QChar& value);
2070
2071protected:
2072 void focusInEvent(QFocusEvent* e) override;
2073 void focusOutEvent(QFocusEvent* e) override;
2074 void keyPressEvent(QKeyEvent* e) override;
2075 void keyReleaseEvent(QKeyEvent* e) override;
2076 void paintEvent(QPaintEvent*) override;
2077 bool event(QEvent* e) override;
2078private slots:
2079 void slotClearChar();
2080
2081private:
2082 void handleKeyEvent(QKeyEvent* e);
2083
2084 QChar m_value;
2085 QLineEdit* m_lineEdit;
2086};
2087
2088QtCharEdit::QtCharEdit(QWidget* parent) : QWidget(parent), m_lineEdit(new QLineEdit(this))
2089{
2090 QHBoxLayout* layout = new QHBoxLayout(this);
2091 layout->addWidget(m_lineEdit);
2092 layout->setMargin(0);
2093 m_lineEdit->installEventFilter(this);
2094 m_lineEdit->setReadOnly(true);
2095 m_lineEdit->setFocusProxy(this);
2096 setFocusPolicy(m_lineEdit->focusPolicy());
2097 setAttribute(Qt::WA_InputMethodEnabled);
2098}
2099
2100bool
2101QtCharEdit::eventFilter(QObject* o, QEvent* e)
2102{
2103 if (o == m_lineEdit && e->type() == QEvent::ContextMenu)
2104 {
2105 QContextMenuEvent* c = static_cast<QContextMenuEvent*>(e);
2106 QMenu* menu = m_lineEdit->createStandardContextMenu();
2107 QList<QAction*> actions = menu->actions();
2108 QListIterator<QAction*> itAction(actions);
2109
2110 while (itAction.hasNext())
2111 {
2112 QAction* action = itAction.next();
2113 action->setShortcut(QKeySequence());
2114 QString actionString = action->text();
2115 const int pos = actionString.lastIndexOf(QLatin1Char('\t'));
2116
2117 if (pos > 0)
2118 {
2119 actionString = actionString.remove(pos, actionString.length() - pos);
2120 }
2121
2122 action->setText(actionString);
2123 }
2124
2125 QAction* actionBefore = 0;
2126
2127 if (actions.count() > 0)
2128 {
2129 actionBefore = actions[0];
2130 }
2131
2132 QAction* clearAction = new QAction(tr("Clear Char"), menu);
2133 menu->insertAction(actionBefore, clearAction);
2134 menu->insertSeparator(actionBefore);
2135 clearAction->setEnabled(!m_value.isNull());
2136 connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar()));
2137 menu->exec(c->globalPos());
2138 delete menu;
2139 e->accept();
2140 return true;
2141 }
2142
2143 return QWidget::eventFilter(o, e);
2144}
2145
2146void
2147QtCharEdit::slotClearChar()
2148{
2149 if (m_value.isNull())
2150 {
2151 return;
2152 }
2153
2154 setValue(QChar());
2155 emit valueChanged(m_value);
2156}
2157
2158void
2159QtCharEdit::handleKeyEvent(QKeyEvent* e)
2160{
2161 const int key = e->key();
2162
2163 switch (key)
2164 {
2165 case Qt::Key_Control:
2166 case Qt::Key_Shift:
2167 case Qt::Key_Meta:
2168 case Qt::Key_Alt:
2169 case Qt::Key_Super_L:
2170 case Qt::Key_Return:
2171 return;
2172
2173 default:
2174 break;
2175 }
2176
2177 const QString text = e->text();
2178
2179 if (text.count() != 1)
2180 {
2181 return;
2182 }
2183
2184 const QChar c = text.at(0);
2185
2186 if (!c.isPrint())
2187 {
2188 return;
2189 }
2190
2191 if (m_value == c)
2192 {
2193 return;
2194 }
2195
2196 m_value = c;
2197 const QString str = m_value.isNull() ? QString() : QString(m_value);
2198 m_lineEdit->setText(str);
2199 e->accept();
2200 emit valueChanged(m_value);
2201}
2202
2203void
2205{
2206 if (value == m_value)
2207 {
2208 return;
2209 }
2210
2211 m_value = value;
2212 QString str = value.isNull() ? QString() : QString(value);
2213 m_lineEdit->setText(str);
2214}
2215
2216QChar
2218{
2219 return m_value;
2220}
2221
2222void
2224{
2225 m_lineEdit->event(e);
2226 m_lineEdit->selectAll();
2227 QWidget::focusInEvent(e);
2228}
2229
2230void
2232{
2233 m_lineEdit->event(e);
2234 QWidget::focusOutEvent(e);
2235}
2236
2237void
2239{
2240 handleKeyEvent(e);
2241 e->accept();
2242}
2243
2244void
2246{
2247 m_lineEdit->event(e);
2248}
2249
2250void
2252{
2253 QStyleOption opt;
2254 opt.init(this);
2255 QPainter p(this);
2256 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
2257}
2258
2259bool
2261{
2262 switch (e->type())
2263 {
2264 case QEvent::Shortcut:
2265 case QEvent::ShortcutOverride:
2266 case QEvent::KeyRelease:
2267 e->accept();
2268 return true;
2269
2270 default:
2271 break;
2272 }
2273
2274 return QWidget::event(e);
2275}
2276
2277// QtCharEditorFactory
2278
2280{
2281 QtCharEditorFactory* q_ptr;
2282 Q_DECLARE_PUBLIC(QtCharEditorFactory)
2283public:
2284 void slotPropertyChanged(QtProperty* property, const QChar& value);
2285 void slotSetValue(const QChar& value);
2286};
2287
2288void
2290{
2291 if (!m_createdEditors.contains(property))
2292 {
2293 return;
2294 }
2295
2296 QListIterator<QtCharEdit*> itEditor(m_createdEditors[property]);
2297
2298 while (itEditor.hasNext())
2299 {
2300 QtCharEdit* editor = itEditor.next();
2301 editor->blockSignals(true);
2302 editor->setValue(value);
2303 editor->blockSignals(false);
2304 }
2305}
2306
2307void
2309{
2310 QObject* object = q_ptr->sender();
2311 const QMap<QtCharEdit*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
2312
2313 for (QMap<QtCharEdit*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
2314 itEditor != ecend;
2315 ++itEditor)
2316 if (itEditor.key() == object)
2317 {
2318 QtProperty* property = itEditor.value();
2319 QtCharPropertyManager* manager = q_ptr->propertyManager(property);
2320
2321 if (!manager)
2322 {
2323 return;
2324 }
2325
2326 manager->setValue(property, value);
2327 return;
2328 }
2329}
2330
2331/*!
2332 \class QtCharEditorFactory
2333
2334 \brief The QtCharEditorFactory class provides editor
2335 widgets for properties created by QtCharPropertyManager objects.
2336
2337 \sa QtAbstractEditorFactory
2338*/
2339
2340/*!
2341 Creates a factory with the given \a parent.
2342*/
2345{
2346 d_ptr = new QtCharEditorFactoryPrivate();
2347 d_ptr->q_ptr = this;
2348}
2349
2350/*!
2351 Destroys this factory, and all the widgets it has created.
2352*/
2354{
2355 qDeleteAll(d_ptr->m_editorToProperty.keys());
2356 delete d_ptr;
2357}
2358
2359/*!
2360 \internal
2361
2362 Reimplemented from the QtAbstractEditorFactory class.
2363*/
2364void
2366{
2367 connect(manager,
2368 SIGNAL(valueChanged(QtProperty*, const QChar&)),
2369 this,
2370 SLOT(slotPropertyChanged(QtProperty*, const QChar&)));
2371}
2372
2373/*!
2374 \internal
2375
2376 Reimplemented from the QtAbstractEditorFactory class.
2377*/
2378QWidget*
2380 QtProperty* property,
2381 QWidget* parent)
2382{
2383 QtCharEdit* editor = d_ptr->createEditor(property, parent);
2384 editor->setValue(manager->value(property));
2385
2386 connect(editor, SIGNAL(valueChanged(const QChar&)), this, SLOT(slotSetValue(const QChar&)));
2387 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
2388 return editor;
2389}
2390
2391/*!
2392 \internal
2393
2394 Reimplemented from the QtAbstractEditorFactory class.
2395*/
2396void
2398{
2399 disconnect(manager,
2400 SIGNAL(valueChanged(QtProperty*, const QChar&)),
2401 this,
2402 SLOT(slotPropertyChanged(QtProperty*, const QChar&)));
2403}
2404
2405// QtEnumEditorFactory
2406
2408{
2409 QtEnumEditorFactory* q_ptr;
2410 Q_DECLARE_PUBLIC(QtEnumEditorFactory)
2411public:
2412 void slotPropertyChanged(QtProperty* property, int value);
2413 void slotEnumNamesChanged(QtProperty* property, const QStringList&);
2414 void slotEnumIconsChanged(QtProperty* property, const QMap<int, QIcon>&);
2415 void slotSetValue(int value);
2416};
2417
2418void
2420{
2421 if (!m_createdEditors.contains(property))
2422 {
2423 return;
2424 }
2425
2426 QListIterator<QComboBox*> itEditor(m_createdEditors[property]);
2427
2428 while (itEditor.hasNext())
2429 {
2430 QComboBox* editor = itEditor.next();
2431 editor->blockSignals(true);
2432 editor->setCurrentIndex(value);
2433 editor->blockSignals(false);
2434 }
2435}
2436
2437void
2438QtEnumEditorFactoryPrivate::slotEnumNamesChanged(QtProperty* property, const QStringList& enumNames)
2439{
2440 if (!m_createdEditors.contains(property))
2441 {
2442 return;
2443 }
2444
2445 QtEnumPropertyManager* manager = q_ptr->propertyManager(property);
2446
2447 if (!manager)
2448 {
2449 return;
2450 }
2451
2452 QMap<int, QIcon> enumIcons = manager->enumIcons(property);
2453
2454 QListIterator<QComboBox*> itEditor(m_createdEditors[property]);
2455
2456 while (itEditor.hasNext())
2457 {
2458 QComboBox* editor = itEditor.next();
2459 editor->blockSignals(true);
2460 editor->clear();
2461 editor->addItems(enumNames);
2462 const int nameCount = enumNames.count();
2463
2464 for (int i = 0; i < nameCount; i++)
2465 {
2466 editor->setItemIcon(i, enumIcons.value(i));
2467 }
2468
2469 editor->setCurrentIndex(manager->value(property));
2470 editor->blockSignals(false);
2471 }
2472}
2473
2474void
2476 const QMap<int, QIcon>& enumIcons)
2477{
2478 if (!m_createdEditors.contains(property))
2479 {
2480 return;
2481 }
2482
2483 QtEnumPropertyManager* manager = q_ptr->propertyManager(property);
2484
2485 if (!manager)
2486 {
2487 return;
2488 }
2489
2490 const QStringList enumNames = manager->enumNames(property);
2491 QListIterator<QComboBox*> itEditor(m_createdEditors[property]);
2492
2493 while (itEditor.hasNext())
2494 {
2495 QComboBox* editor = itEditor.next();
2496 editor->blockSignals(true);
2497 const int nameCount = enumNames.count();
2498
2499 for (int i = 0; i < nameCount; i++)
2500 {
2501 editor->setItemIcon(i, enumIcons.value(i));
2502 }
2503
2504 editor->setCurrentIndex(manager->value(property));
2505 editor->blockSignals(false);
2506 }
2507}
2508
2509void
2511{
2512 QObject* object = q_ptr->sender();
2513 const QMap<QComboBox*, QtProperty*>::ConstIterator ecend = m_editorToProperty.constEnd();
2514
2515 for (QMap<QComboBox*, QtProperty*>::ConstIterator itEditor = m_editorToProperty.constBegin();
2516 itEditor != ecend;
2517 ++itEditor)
2518 if (itEditor.key() == object)
2519 {
2520 QtProperty* property = itEditor.value();
2521 QtEnumPropertyManager* manager = q_ptr->propertyManager(property);
2522
2523 if (!manager)
2524 {
2525 return;
2526 }
2527
2528 manager->setValue(property, value);
2529 return;
2530 }
2531}
2532
2533/*!
2534 \class QtEnumEditorFactory
2535
2536 \brief The QtEnumEditorFactory class provides QComboBox widgets for
2537 properties created by QtEnumPropertyManager objects.
2538
2539 \sa QtAbstractEditorFactory, QtEnumPropertyManager
2540*/
2541
2542/*!
2543 Creates a factory with the given \a parent.
2544*/
2547{
2548 d_ptr = new QtEnumEditorFactoryPrivate();
2549 d_ptr->q_ptr = this;
2550}
2551
2552/*!
2553 Destroys this factory, and all the widgets it has created.
2554*/
2556{
2557 qDeleteAll(d_ptr->m_editorToProperty.keys());
2558 delete d_ptr;
2559}
2560
2561/*!
2562 \internal
2563
2564 Reimplemented from the QtAbstractEditorFactory class.
2565*/
2566void
2568{
2569 connect(manager,
2570 SIGNAL(valueChanged(QtProperty*, int)),
2571 this,
2572 SLOT(slotPropertyChanged(QtProperty*, int)));
2573 connect(manager,
2574 SIGNAL(enumNamesChanged(QtProperty*, const QStringList&)),
2575 this,
2576 SLOT(slotEnumNamesChanged(QtProperty*, const QStringList&)));
2577}
2578
2579/*!
2580 \internal
2581
2582 Reimplemented from the QtAbstractEditorFactory class.
2583*/
2584QWidget*
2586 QtProperty* property,
2587 QWidget* parent)
2588{
2589 QComboBox* editor = d_ptr->createEditor(property, parent);
2590 editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
2591 editor->setMinimumContentsLength(1);
2592 editor->view()->setTextElideMode(Qt::ElideRight);
2593 QStringList enumNames = manager->enumNames(property);
2594 editor->addItems(enumNames);
2595 QMap<int, QIcon> enumIcons = manager->enumIcons(property);
2596 const int enumNamesCount = enumNames.count();
2597
2598 for (int i = 0; i < enumNamesCount; i++)
2599 {
2600 editor->setItemIcon(i, enumIcons.value(i));
2601 }
2602
2603 editor->setCurrentIndex(manager->value(property));
2604
2605 connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
2606 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
2607 return editor;
2608}
2609
2610/*!
2611 \internal
2612
2613 Reimplemented from the QtAbstractEditorFactory class.
2614*/
2615void
2617{
2618 disconnect(manager,
2619 SIGNAL(valueChanged(QtProperty*, int)),
2620 this,
2621 SLOT(slotPropertyChanged(QtProperty*, int)));
2622 disconnect(manager,
2623 SIGNAL(enumNamesChanged(QtProperty*, const QStringList&)),
2624 this,
2625 SLOT(slotEnumNamesChanged(QtProperty*, const QStringList&)));
2626}
2627
2628// QtCursorEditorFactory
2629
2630Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase)
2631
2633{
2634 QtCursorEditorFactory* q_ptr;
2635 Q_DECLARE_PUBLIC(QtCursorEditorFactory)
2636public:
2638
2639 void slotPropertyChanged(QtProperty* property, const QCursor& cursor);
2640 void slotEnumChanged(QtProperty* property, int value);
2641 void slotEditorDestroyed(QObject* object);
2642
2645
2646 QMap<QtProperty*, QtProperty*> m_propertyToEnum;
2647 QMap<QtProperty*, QtProperty*> m_enumToProperty;
2648 QMap<QtProperty*, QList<QWidget*>> m_enumToEditors;
2649 QMap<QWidget*, QtProperty*> m_editorToEnum;
2651};
2652
2656
2657void
2659{
2660 // update enum property
2661 QtProperty* enumProp = m_propertyToEnum.value(property);
2662
2663 if (!enumProp)
2664 {
2665 return;
2666 }
2667
2668 m_updatingEnum = true;
2669 m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(cursor));
2670 m_updatingEnum = false;
2671}
2672
2673void
2675{
2676 if (m_updatingEnum)
2677 {
2678 return;
2679 }
2680
2681 // update cursor property
2682 QtProperty* prop = m_enumToProperty.value(property);
2683
2684 if (!prop)
2685 {
2686 return;
2687 }
2688
2689 QtCursorPropertyManager* cursorManager = q_ptr->propertyManager(prop);
2690
2691 if (!cursorManager)
2692 {
2693 return;
2694 }
2695
2696#ifndef QT_NO_CURSOR
2697 cursorManager->setValue(prop, QCursor(cursorDatabase()->valueToCursor(value)));
2698#endif
2699}
2700
2701void
2703{
2704 // remove from m_editorToEnum map;
2705 // remove from m_enumToEditors map;
2706 // if m_enumToEditors doesn't contains more editors delete enum property;
2707 const QMap<QWidget*, QtProperty*>::ConstIterator ecend = m_editorToEnum.constEnd();
2708
2709 for (QMap<QWidget*, QtProperty*>::ConstIterator itEditor = m_editorToEnum.constBegin();
2710 itEditor != ecend;
2711 ++itEditor)
2712 if (itEditor.key() == object)
2713 {
2714 QWidget* editor = itEditor.key();
2715 QtProperty* enumProp = itEditor.value();
2716 m_editorToEnum.remove(editor);
2717 m_enumToEditors[enumProp].removeAll(editor);
2718
2719 if (m_enumToEditors[enumProp].isEmpty())
2720 {
2721 m_enumToEditors.remove(enumProp);
2722 QtProperty* property = m_enumToProperty.value(enumProp);
2723 m_enumToProperty.remove(enumProp);
2724 m_propertyToEnum.remove(property);
2725 delete enumProp;
2726 }
2727
2728 return;
2729 }
2730}
2731
2732/*!
2733 \class QtCursorEditorFactory
2734
2735 \brief The QtCursorEditorFactory class provides QComboBox widgets for
2736 properties created by QtCursorPropertyManager objects.
2737
2738 \sa QtAbstractEditorFactory, QtCursorPropertyManager
2739*/
2740
2741/*!
2742 Creates a factory with the given \a parent.
2743*/
2746{
2747 d_ptr = new QtCursorEditorFactoryPrivate();
2748 d_ptr->q_ptr = this;
2749
2750 d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this);
2751 d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
2752 connect(d_ptr->m_enumPropertyManager,
2753 SIGNAL(valueChanged(QtProperty*, int)),
2754 this,
2755 SLOT(slotEnumChanged(QtProperty*, int)));
2756 d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager);
2757}
2758
2759/*!
2760 Destroys this factory, and all the widgets it has created.
2761*/
2763{
2764 delete d_ptr;
2765}
2766
2767/*!
2768 \internal
2769
2770 Reimplemented from the QtAbstractEditorFactory class.
2771*/
2772void
2774{
2775 connect(manager,
2776 SIGNAL(valueChanged(QtProperty*, const QCursor&)),
2777 this,
2778 SLOT(slotPropertyChanged(QtProperty*, const QCursor&)));
2779}
2780
2781/*!
2782 \internal
2783
2784 Reimplemented from the QtAbstractEditorFactory class.
2785*/
2786QWidget*
2788 QtProperty* property,
2789 QWidget* parent)
2790{
2791 QtProperty* enumProp = 0;
2792
2793 if (d_ptr->m_propertyToEnum.contains(property))
2794 {
2795 enumProp = d_ptr->m_propertyToEnum[property];
2796 }
2797 else
2798 {
2799 enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName());
2800 d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cursorDatabase()->cursorShapeNames());
2801 d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cursorDatabase()->cursorShapeIcons());
2802#ifndef QT_NO_CURSOR
2803 d_ptr->m_enumPropertyManager->setValue(
2804 enumProp, cursorDatabase()->cursorToValue(manager->value(property)));
2805#endif
2806 d_ptr->m_propertyToEnum[property] = enumProp;
2807 d_ptr->m_enumToProperty[enumProp] = property;
2808 }
2809
2810 QtAbstractEditorFactoryBase* af = d_ptr->m_enumEditorFactory;
2811 QWidget* editor = af->createEditor(enumProp, parent);
2812 d_ptr->m_enumToEditors[enumProp].append(editor);
2813 d_ptr->m_editorToEnum[editor] = enumProp;
2814 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
2815 return editor;
2816}
2817
2818/*!
2819 \internal
2820
2821 Reimplemented from the QtAbstractEditorFactory class.
2822*/
2823void
2825{
2826 disconnect(manager,
2827 SIGNAL(valueChanged(QtProperty*, const QCursor&)),
2828 this,
2829 SLOT(slotPropertyChanged(QtProperty*, const QCursor&)));
2830}
2831
2832// QtColorEditWidget
2833
2834class QtColorEditWidget : public QWidget
2835{
2836 Q_OBJECT
2837
2838public:
2839 QtColorEditWidget(QWidget* parent);
2840
2841 bool eventFilter(QObject* obj, QEvent* ev) override;
2842
2843public Q_SLOTS:
2844 void setValue(const QColor& value);
2845
2846Q_SIGNALS:
2847 void valueChanged(const QColor& value);
2848
2849protected:
2850 void paintEvent(QPaintEvent*) override;
2851
2852private Q_SLOTS:
2853 void buttonClicked();
2854
2855private:
2856 QColor m_color;
2857 QLabel* m_pixmapLabel;
2858 QLabel* m_label;
2859 QToolButton* m_button;
2860};
2861
2863 QWidget(parent), m_pixmapLabel(new QLabel), m_label(new QLabel), m_button(new QToolButton)
2864{
2865 QHBoxLayout* lt = new QHBoxLayout(this);
2866 setupTreeViewEditorMargin(lt);
2867 lt->setSpacing(0);
2868 lt->addWidget(m_pixmapLabel);
2869 lt->addWidget(m_label);
2870 lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
2871
2872 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
2873 m_button->setFixedWidth(20);
2874 setFocusProxy(m_button);
2875 setFocusPolicy(m_button->focusPolicy());
2876 m_button->setText(tr("..."));
2877 m_button->installEventFilter(this);
2878 connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
2879 lt->addWidget(m_button);
2880 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color)));
2881 m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color));
2882}
2883
2884void
2886{
2887 if (m_color != c)
2888 {
2889 m_color = c;
2890 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(c)));
2891 m_label->setText(QtPropertyBrowserUtils::colorValueText(c));
2892 }
2893}
2894
2895void
2896QtColorEditWidget::buttonClicked()
2897{
2898 bool ok = false;
2899 QRgb oldRgba = m_color.rgba();
2900 QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this);
2901
2902 if (ok && newRgba != oldRgba)
2903 {
2904 setValue(QColor::fromRgba(newRgba));
2905 emit valueChanged(m_color);
2906 }
2907}
2908
2909bool
2910QtColorEditWidget::eventFilter(QObject* obj, QEvent* ev)
2911{
2912 if (obj == m_button)
2913 {
2914 switch (ev->type())
2915 {
2916 case QEvent::KeyPress:
2917 case QEvent::
2918 KeyRelease: // Prevent the QToolButton from handling Enter/Escape meant control the delegate
2919 {
2920 switch (static_cast<const QKeyEvent*>(ev)->key())
2921 {
2922 case Qt::Key_Escape:
2923 case Qt::Key_Enter:
2924 case Qt::Key_Return:
2925 ev->ignore();
2926 return true;
2927
2928 default:
2929 break;
2930 }
2931 }
2932 break;
2933
2934 default:
2935 break;
2936 }
2937 }
2938
2939 return QWidget::eventFilter(obj, ev);
2940}
2941
2942void
2944{
2945 QStyleOption opt;
2946 opt.init(this);
2947 QPainter p(this);
2948 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
2949}
2950
2951// QtColorEditorFactoryPrivate
2952
2953class QtColorEditorFactoryPrivate : public EditorFactoryPrivate<QtColorEditWidget>
2954{
2955 QtColorEditorFactory* q_ptr;
2956 Q_DECLARE_PUBLIC(QtColorEditorFactory)
2957public:
2958 void slotPropertyChanged(QtProperty* property, const QColor& value);
2959 void slotSetValue(const QColor& value);
2960};
2961
2962void
2964{
2965 const PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
2966
2967 if (it == m_createdEditors.end())
2968 {
2969 return;
2970 }
2971
2972 QListIterator<QtColorEditWidget*> itEditor(it.value());
2973
2974 while (itEditor.hasNext())
2975 {
2976 itEditor.next()->setValue(value);
2977 }
2978}
2979
2980void
2982{
2983 QObject* object = q_ptr->sender();
2984 const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd();
2985
2986 for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin();
2987 itEditor != ecend;
2988 ++itEditor)
2989 if (itEditor.key() == object)
2990 {
2991 QtProperty* property = itEditor.value();
2992 QtColorPropertyManager* manager = q_ptr->propertyManager(property);
2993
2994 if (!manager)
2995 {
2996 return;
2997 }
2998
2999 manager->setValue(property, value);
3000 return;
3001 }
3002}
3003
3004/*!
3005 \class QtColorEditorFactory
3006
3007 \brief The QtColorEditorFactory class provides color editing for
3008 properties created by QtColorPropertyManager objects.
3009
3010 \sa QtAbstractEditorFactory, QtColorPropertyManager
3011*/
3012
3013/*!
3014 Creates a factory with the given \a parent.
3015*/
3018 d_ptr(new QtColorEditorFactoryPrivate())
3019{
3020 d_ptr->q_ptr = this;
3021}
3022
3023/*!
3024 Destroys this factory, and all the widgets it has created.
3025*/
3027{
3028 qDeleteAll(d_ptr->m_editorToProperty.keys());
3029 delete d_ptr;
3030}
3031
3032/*!
3033 \internal
3034
3035 Reimplemented from the QtAbstractEditorFactory class.
3036*/
3037void
3039{
3040 connect(manager,
3041 SIGNAL(valueChanged(QtProperty*, QColor)),
3042 this,
3043 SLOT(slotPropertyChanged(QtProperty*, QColor)));
3044}
3045
3046/*!
3047 \internal
3048
3049 Reimplemented from the QtAbstractEditorFactory class.
3050*/
3051QWidget*
3053 QtProperty* property,
3054 QWidget* parent)
3055{
3056 QtColorEditWidget* editor = d_ptr->createEditor(property, parent);
3057 editor->setValue(manager->value(property));
3058 connect(editor, SIGNAL(valueChanged(QColor)), this, SLOT(slotSetValue(QColor)));
3059 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
3060 return editor;
3061}
3062
3063/*!
3064 \internal
3065
3066 Reimplemented from the QtAbstractEditorFactory class.
3067*/
3068void
3070{
3071 disconnect(manager,
3072 SIGNAL(valueChanged(QtProperty*, QColor)),
3073 this,
3074 SLOT(slotPropertyChanged(QtProperty*, QColor)));
3075}
3076
3077// QtFontEditWidget
3078
3079class QtFontEditWidget : public QWidget
3080{
3081 Q_OBJECT
3082
3083public:
3084 QtFontEditWidget(QWidget* parent);
3085
3086 bool eventFilter(QObject* obj, QEvent* ev) override;
3087
3088public Q_SLOTS:
3089 void setValue(const QFont& value);
3090
3091Q_SIGNALS:
3092 void valueChanged(const QFont& value);
3093
3094protected:
3095 void paintEvent(QPaintEvent*) override;
3096
3097private Q_SLOTS:
3098 void buttonClicked();
3099
3100private:
3101 QFont m_font;
3102 QLabel* m_pixmapLabel;
3103 QLabel* m_label;
3104 QToolButton* m_button;
3105};
3106
3108 QWidget(parent), m_pixmapLabel(new QLabel), m_label(new QLabel), m_button(new QToolButton)
3109{
3110 QHBoxLayout* lt = new QHBoxLayout(this);
3111 setupTreeViewEditorMargin(lt);
3112 lt->setSpacing(0);
3113 lt->addWidget(m_pixmapLabel);
3114 lt->addWidget(m_label);
3115 lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
3116
3117 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
3118 m_button->setFixedWidth(20);
3119 setFocusProxy(m_button);
3120 setFocusPolicy(m_button->focusPolicy());
3121 m_button->setText(tr("..."));
3122 m_button->installEventFilter(this);
3123 connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
3124 lt->addWidget(m_button);
3125 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(m_font));
3126 m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font));
3127}
3128
3129void
3131{
3132 if (m_font != f)
3133 {
3134 m_font = f;
3135 m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(f));
3136 m_label->setText(QtPropertyBrowserUtils::fontValueText(f));
3137 }
3138}
3139
3140void
3141QtFontEditWidget::buttonClicked()
3142{
3143 bool ok = false;
3144 QFont newFont = QFontDialog::getFont(&ok, m_font, this, tr("Select Font"));
3145
3146 if (ok && newFont != m_font)
3147 {
3148 QFont f = m_font;
3149
3150 // prevent mask for unchanged attributes, don't change other attributes (like kerning, etc...)
3151 if (m_font.family() != newFont.family())
3152 {
3153 f.setFamily(newFont.family());
3154 }
3155
3156 if (m_font.pointSize() != newFont.pointSize())
3157 {
3158 f.setPointSize(newFont.pointSize());
3159 }
3160
3161 if (m_font.bold() != newFont.bold())
3162 {
3163 f.setBold(newFont.bold());
3164 }
3165
3166 if (m_font.italic() != newFont.italic())
3167 {
3168 f.setItalic(newFont.italic());
3169 }
3170
3171 if (m_font.underline() != newFont.underline())
3172 {
3173 f.setUnderline(newFont.underline());
3174 }
3175
3176 if (m_font.strikeOut() != newFont.strikeOut())
3177 {
3178 f.setStrikeOut(newFont.strikeOut());
3179 }
3180
3181 setValue(f);
3182 emit valueChanged(m_font);
3183 }
3184}
3185
3186bool
3187QtFontEditWidget::eventFilter(QObject* obj, QEvent* ev)
3188{
3189 if (obj == m_button)
3190 {
3191 switch (ev->type())
3192 {
3193 case QEvent::KeyPress:
3194 case QEvent::
3195 KeyRelease: // Prevent the QToolButton from handling Enter/Escape meant control the delegate
3196 {
3197 switch (static_cast<const QKeyEvent*>(ev)->key())
3198 {
3199 case Qt::Key_Escape:
3200 case Qt::Key_Enter:
3201 case Qt::Key_Return:
3202 ev->ignore();
3203 return true;
3204
3205 default:
3206 break;
3207 }
3208 }
3209 break;
3210
3211 default:
3212 break;
3213 }
3214 }
3215
3216 return QWidget::eventFilter(obj, ev);
3217}
3218
3219void
3221{
3222 QStyleOption opt;
3223 opt.init(this);
3224 QPainter p(this);
3225 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
3226}
3227
3228// QtFontEditorFactoryPrivate
3229
3230class QtFontEditorFactoryPrivate : public EditorFactoryPrivate<QtFontEditWidget>
3231{
3232 QtFontEditorFactory* q_ptr;
3233 Q_DECLARE_PUBLIC(QtFontEditorFactory)
3234public:
3235 void slotPropertyChanged(QtProperty* property, const QFont& value);
3236 void slotSetValue(const QFont& value);
3237};
3238
3239void
3241{
3242 const PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
3243
3244 if (it == m_createdEditors.end())
3245 {
3246 return;
3247 }
3248
3249 QListIterator<QtFontEditWidget*> itEditor(it.value());
3250
3251 while (itEditor.hasNext())
3252 {
3253 itEditor.next()->setValue(value);
3254 }
3255}
3256
3257void
3259{
3260 QObject* object = q_ptr->sender();
3261 const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd();
3262
3263 for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin();
3264 itEditor != ecend;
3265 ++itEditor)
3266 if (itEditor.key() == object)
3267 {
3268 QtProperty* property = itEditor.value();
3269 QtFontPropertyManager* manager = q_ptr->propertyManager(property);
3270
3271 if (!manager)
3272 {
3273 return;
3274 }
3275
3276 manager->setValue(property, value);
3277 return;
3278 }
3279}
3280
3281/*!
3282 \class QtFontEditorFactory
3283
3284 \brief The QtFontEditorFactory class provides font editing for
3285 properties created by QtFontPropertyManager objects.
3286
3287 \sa QtAbstractEditorFactory, QtFontPropertyManager
3288*/
3289
3290/*!
3291 Creates a factory with the given \a parent.
3292*/
3295{
3296 d_ptr->q_ptr = this;
3297}
3298
3299/*!
3300 Destroys this factory, and all the widgets it has created.
3301*/
3303{
3304 qDeleteAll(d_ptr->m_editorToProperty.keys());
3305 delete d_ptr;
3306}
3307
3308/*!
3309 \internal
3310
3311 Reimplemented from the QtAbstractEditorFactory class.
3312*/
3313void
3315{
3316 connect(manager,
3317 SIGNAL(valueChanged(QtProperty*, QFont)),
3318 this,
3319 SLOT(slotPropertyChanged(QtProperty*, QFont)));
3320}
3321
3322/*!
3323 \internal
3324
3325 Reimplemented from the QtAbstractEditorFactory class.
3326*/
3327QWidget*
3329 QtProperty* property,
3330 QWidget* parent)
3331{
3332 QtFontEditWidget* editor = d_ptr->createEditor(property, parent);
3333 editor->setValue(manager->value(property));
3334 connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont)));
3335 connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
3336 return editor;
3337}
3338
3339/*!
3340 \internal
3341
3342 Reimplemented from the QtAbstractEditorFactory class.
3343*/
3344void
3346{
3347 disconnect(manager,
3348 SIGNAL(valueChanged(QtProperty*, QFont)),
3349 this,
3350 SLOT(slotPropertyChanged(QtProperty*, QFont)));
3351}
3352
3353QT_END_NAMESPACE
3354
3355#include "moc_qteditorfactory.cpp"
3356#include "qteditorfactory.moc"
constexpr T c
std::string str(const T &t)
EditorToPropertyMap m_editorToProperty
QMap< QtProperty *, EditorList > PropertyToEditorListMap
QMap< Editor *, QtProperty * > EditorToPropertyMap
QList< Editor * > EditorList
void initializeEditor(QtProperty *property, Editor *e)
void slotEditorDestroyed(QObject *object)
PropertyToEditorListMap m_createdEditors
Editor * createEditor(QtProperty *property, QWidget *parent)
QtAbstractEditorFactoryBase(QObject *parent=0)
virtual QWidget * createEditor(QtProperty *property, QWidget *parent)=0
void setTextVisible(bool textVisible)
bool blockCheckBoxSignals(bool block)
The QtBoolPropertyManager class provides and manages boolean properties.
void setValue(QtProperty *property, bool val)
bool textVisible(const QtProperty *property) const
bool value(const QtProperty *property) const
void paintEvent(QPaintEvent *) override
void focusInEvent(QFocusEvent *e) override
bool eventFilter(QObject *o, QEvent *e) override
QChar value() const
void setValue(const QChar &value)
QtCharEdit(QWidget *parent=0)
void keyReleaseEvent(QKeyEvent *e) override
void keyPressEvent(QKeyEvent *e) override
void focusOutEvent(QFocusEvent *e) override
bool event(QEvent *e) override
void valueChanged(const QChar &value)
void slotPropertyChanged(QtProperty *property, const QChar &value)
void slotSetValue(const QChar &value)
The QtCharEditorFactory class provides editor widgets for properties created by QtCharPropertyManager...
void disconnectPropertyManager(QtCharPropertyManager *manager) override
QWidget * createEditor(QtCharPropertyManager *manager, QtProperty *property, QWidget *parent) override
QtCharEditorFactory(QObject *parent=0)
void connectPropertyManager(QtCharPropertyManager *manager) override
The QtCharPropertyManager provides and manages QChar properties.
QChar value(const QtProperty *property) const
void setValue(QtProperty *property, const QChar &val)
void slotPropertyChanged(QtProperty *property, bool value)
void slotTextVisibleChanged(QtProperty *property, bool textVisible)
The QtCheckBoxFactory class provides QCheckBox widgets for properties created by QtBoolPropertyManage...
void disconnectPropertyManager(QtBoolPropertyManager *manager) override
~QtCheckBoxFactory() override
QWidget * createEditor(QtBoolPropertyManager *manager, QtProperty *property, QWidget *parent) override
QtCheckBoxFactory(QObject *parent=0)
void connectPropertyManager(QtBoolPropertyManager *manager) override
void paintEvent(QPaintEvent *) override
QtColorEditWidget(QWidget *parent)
bool eventFilter(QObject *obj, QEvent *ev) override
void setValue(const QColor &value)
void valueChanged(const QColor &value)
void slotSetValue(const QColor &value)
void slotPropertyChanged(QtProperty *property, const QColor &value)
The QtColorEditorFactory class provides color editing for properties created by QtColorPropertyManage...
QtColorEditorFactory(QObject *parent=0)
QWidget * createEditor(QtColorPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtColorPropertyManager *manager) override
void connectPropertyManager(QtColorPropertyManager *manager) override
The QtColorPropertyManager provides and manages QColor properties.
void setValue(QtProperty *property, const QColor &val)
QColor value(const QtProperty *property) const
QtEnumEditorFactory * m_enumEditorFactory
QMap< QtProperty *, QtProperty * > m_enumToProperty
void slotEnumChanged(QtProperty *property, int value)
QMap< QWidget *, QtProperty * > m_editorToEnum
QtEnumPropertyManager * m_enumPropertyManager
void slotEditorDestroyed(QObject *object)
QMap< QtProperty *, QtProperty * > m_propertyToEnum
void slotPropertyChanged(QtProperty *property, const QCursor &cursor)
QMap< QtProperty *, QList< QWidget * > > m_enumToEditors
The QtCursorEditorFactory class provides QComboBox widgets for properties created by QtCursorProperty...
QtCursorEditorFactory(QObject *parent=0)
void connectPropertyManager(QtCursorPropertyManager *manager) override
QWidget * createEditor(QtCursorPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtCursorPropertyManager *manager) override
The QtCursorPropertyManager provides and manages QCursor properties.
void setValue(QtProperty *property, const QCursor &val)
QCursor value(const QtProperty *property) const
void slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max)
void slotPropertyChanged(QtProperty *property, const QDate &value)
void slotSetValue(const QDate &value)
The QtDateEditFactory class provides QDateEdit widgets for properties created by QtDatePropertyManage...
void disconnectPropertyManager(QtDatePropertyManager *manager) override
void connectPropertyManager(QtDatePropertyManager *manager) override
QtDateEditFactory(QObject *parent=0)
QWidget * createEditor(QtDatePropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtDatePropertyManager provides and manages QDate properties.
void setValue(QtProperty *property, const QDate &val)
QDate minimum(const QtProperty *property) const
QDate value(const QtProperty *property) const
QDate maximum(const QtProperty *property) const
void slotPropertyChanged(QtProperty *property, const QDateTime &value)
void slotSetValue(const QDateTime &value)
The QtDateTimeEditFactory class provides QDateTimeEdit widgets for properties created by QtDateTimePr...
void disconnectPropertyManager(QtDateTimePropertyManager *manager) override
QWidget * createEditor(QtDateTimePropertyManager *manager, QtProperty *property, QWidget *parent) override
QtDateTimeEditFactory(QObject *parent=0)
void connectPropertyManager(QtDateTimePropertyManager *manager) override
The QtDateTimePropertyManager provides and manages QDateTime properties.
QDateTime value(const QtProperty *property) const
void setValue(QtProperty *property, const QDateTime &val)
The QtDoublePropertyManager provides and manages double properties.
int decimals(const QtProperty *property) const
double maximum(const QtProperty *property) const
double minimum(const QtProperty *property) const
bool isReadOnly(const QtProperty *property) const
void setValue(QtProperty *property, double val)
double value(const QtProperty *property) const
double singleStep(const QtProperty *property) const
void slotSingleStepChanged(QtProperty *property, double step)
void slotDecimalsChanged(QtProperty *property, int prec)
void slotRangeChanged(QtProperty *property, double min, double max)
void slotReadOnlyChanged(QtProperty *property, bool readOnly)
void slotPropertyChanged(QtProperty *property, double value)
The QtDoubleSpinBoxFactory class provides QDoubleSpinBox widgets for properties created by QtDoublePr...
void connectPropertyManager(QtDoublePropertyManager *manager) override
void disconnectPropertyManager(QtDoublePropertyManager *manager) override
QWidget * createEditor(QtDoublePropertyManager *manager, QtProperty *property, QWidget *parent) override
QtDoubleSpinBoxFactory(QObject *parent=0)
void slotEnumNamesChanged(QtProperty *property, const QStringList &)
void slotPropertyChanged(QtProperty *property, int value)
void slotEnumIconsChanged(QtProperty *property, const QMap< int, QIcon > &)
The QtEnumEditorFactory class provides QComboBox widgets for properties created by QtEnumPropertyMana...
void connectPropertyManager(QtEnumPropertyManager *manager) override
void disconnectPropertyManager(QtEnumPropertyManager *manager) override
QtEnumEditorFactory(QObject *parent=0)
QWidget * createEditor(QtEnumPropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtEnumPropertyManager provides and manages enum properties.
QMap< int, QIcon > enumIcons(const QtProperty *property) const
QStringList enumNames(const QtProperty *property) const
void setValue(QtProperty *property, int val)
int value(const QtProperty *property) const
void paintEvent(QPaintEvent *) override
void setValue(const QFont &value)
bool eventFilter(QObject *obj, QEvent *ev) override
QtFontEditWidget(QWidget *parent)
void valueChanged(const QFont &value)
void slotSetValue(const QFont &value)
void slotPropertyChanged(QtProperty *property, const QFont &value)
The QtFontEditorFactory class provides font editing for properties created by QtFontPropertyManager o...
void disconnectPropertyManager(QtFontPropertyManager *manager) override
void connectPropertyManager(QtFontPropertyManager *manager) override
QWidget * createEditor(QtFontPropertyManager *manager, QtProperty *property, QWidget *parent) override
QtFontEditorFactory(QObject *parent=0)
The QtFontPropertyManager provides and manages QFont properties.
QFont value(const QtProperty *property) const
void setValue(QtProperty *property, const QFont &val)
The QtIntPropertyManager provides and manages int properties.
int minimum(const QtProperty *property) const
void setValue(QtProperty *property, int val)
bool isReadOnly(const QtProperty *property) const
int singleStep(const QtProperty *property) const
int maximum(const QtProperty *property) const
int value(const QtProperty *property) const
void setKeySequence(const QKeySequence &sequence)
void slotPropertyChanged(QtProperty *property, const QKeySequence &value)
void slotSetValue(const QKeySequence &value)
The QtKeySequenceEditorFactory class provides editor widgets for properties created by QtKeySequenceP...
QtKeySequenceEditorFactory(QObject *parent=0)
void disconnectPropertyManager(QtKeySequencePropertyManager *manager) override
void connectPropertyManager(QtKeySequencePropertyManager *manager) override
QWidget * createEditor(QtKeySequencePropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtKeySequencePropertyManager provides and manages QKeySequence properties.
QKeySequence value(const QtProperty *property) const
void setValue(QtProperty *property, const QKeySequence &val)
void slotRegExpChanged(QtProperty *property, const QRegExp &regExp)
void slotEchoModeChanged(QtProperty *, int)
void slotPropertyChanged(QtProperty *property, const QString &value)
void slotSetValue(const QString &value)
void slotReadOnlyChanged(QtProperty *, bool)
The QtLineEditFactory class provides QLineEdit widgets for properties created by QtStringPropertyMana...
QWidget * createEditor(QtStringPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtStringPropertyManager *manager) override
QtLineEditFactory(QObject *parent=0)
void connectPropertyManager(QtStringPropertyManager *manager) override
static QString fontValueText(const QFont &f)
static QPixmap brushValuePixmap(const QBrush &b)
static QString colorValueText(const QColor &c)
static QPixmap fontValuePixmap(const QFont &f)
The QtProperty class encapsulates an instance of a property.
QString propertyName() const
void slotSingleStepChanged(QtProperty *property, int step)
void slotRangeChanged(QtProperty *property, int min, int max)
void slotPropertyChanged(QtProperty *property, int value)
The QtScrollBarFactory class provides QScrollBar widgets for properties created by QtIntPropertyManag...
void connectPropertyManager(QtIntPropertyManager *manager) override
QtScrollBarFactory(QObject *parent=0)
QWidget * createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtIntPropertyManager *manager) override
void slotSingleStepChanged(QtProperty *property, int step)
void slotRangeChanged(QtProperty *property, int min, int max)
void slotPropertyChanged(QtProperty *property, int value)
The QtSliderFactory class provides QSlider widgets for properties created by QtIntPropertyManager obj...
void connectPropertyManager(QtIntPropertyManager *manager) override
QtSliderFactory(QObject *parent=0)
~QtSliderFactory() override
QWidget * createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtIntPropertyManager *manager) override
void slotSingleStepChanged(QtProperty *property, int step)
void slotRangeChanged(QtProperty *property, int min, int max)
void slotReadOnlyChanged(QtProperty *property, bool readOnly)
void slotPropertyChanged(QtProperty *property, int value)
The QtSpinBoxFactory class provides QSpinBox widgets for properties created by QtIntPropertyManager o...
void connectPropertyManager(QtIntPropertyManager *manager) override
~QtSpinBoxFactory() override
QtSpinBoxFactory(QObject *parent=0)
QWidget * createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) override
void disconnectPropertyManager(QtIntPropertyManager *manager) override
The QtStringPropertyManager provides and manages QString properties.
QRegExp regExp(const QtProperty *property) const
bool isReadOnly(const QtProperty *property) const
QString value(const QtProperty *property) const
void setValue(QtProperty *property, const QString &val)
EchoMode echoMode(const QtProperty *property) const override
void slotPropertyChanged(QtProperty *property, const QTime &value)
void slotSetValue(const QTime &value)
The QtTimeEditFactory class provides QTimeEdit widgets for properties created by QtTimePropertyManage...
QWidget * createEditor(QtTimePropertyManager *manager, QtProperty *property, QWidget *parent) override
QtTimeEditFactory(QObject *parent=0)
void connectPropertyManager(QtTimePropertyManager *manager) override
void disconnectPropertyManager(QtTimePropertyManager *manager) override
The QtTimePropertyManager provides and manages QTime properties.
QTime value(const QtProperty *property) const
void setValue(QtProperty *property, const QTime &val)
T min(T t1, T t2)
Definition gdiam.h:44
T max(T t1, T t2)
Definition gdiam.h:51
QLineEdit::EchoMode EchoMode