47 #include <QAbstractItemView>
49 #include <QDateTimeEdit>
50 #include <QHBoxLayout>
53 #include <QApplication>
55 #include <QToolButton>
56 #include <QColorDialog>
57 #include <QFontDialog>
58 #include <QSpacerItem>
59 #include <QStyleOption>
63 #if defined(Q_CC_MSVC)
64 # pragma warning(disable: 4786)
72 static inline void setupTreeViewEditorMargin(QLayout* lt)
74 enum { DecorationMargin = 4 };
76 if (QApplication::layoutDirection() == Qt::LeftToRight)
78 lt->setContentsMargins(DecorationMargin, 0, 0, 0);
82 lt->setContentsMargins(0, 0, DecorationMargin, 0);
89 template <
class Editor>
106 template <
class Editor>
109 Editor* editor =
new Editor(parent);
110 initializeEditor(property, editor);
114 template <
class Editor>
117 typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
119 if (it == m_createdEditors.end())
121 it = m_createdEditors.insert(property,
EditorList());
124 it.value().append(editor);
125 m_editorToProperty.insert(editor, property);
128 template <
class Editor>
131 const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end();
133 for (
typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor)
135 if (itEditor.key() ==
object)
137 Editor* editor = itEditor.key();
139 const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property);
141 if (pit != m_createdEditors.end())
143 pit.value().removeAll(editor);
145 if (pit.value().empty())
147 m_createdEditors.erase(pit);
151 m_editorToProperty.erase(itEditor);
181 while (itEditor.hasNext())
183 QSpinBox* editor = itEditor.next();
185 if (editor->value() !=
value)
187 editor->blockSignals(
true);
188 editor->setValue(
value);
189 editor->blockSignals(
false);
210 while (itEditor.hasNext())
212 QSpinBox* editor = itEditor.next();
213 editor->blockSignals(
true);
214 editor->setRange(
min,
max);
215 editor->setValue(manager->
value(property));
216 editor->blockSignals(
false);
229 while (itEditor.hasNext())
231 QSpinBox* editor = itEditor.next();
232 editor->blockSignals(
true);
233 editor->setSingleStep(step);
234 editor->blockSignals(
false);
254 while (itEditor.hasNext())
256 QSpinBox* editor = itEditor.next();
257 editor->blockSignals(
true);
258 editor->setReadOnly(readOnly);
259 editor->blockSignals(
false);
265 QObject*
object = q_ptr->sender();
266 const QMap<QSpinBox*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
268 for (QMap<QSpinBox*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
270 if (itEditor.key() ==
object)
322 connect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
323 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
324 connect(manager, SIGNAL(rangeChanged(
QtProperty*,
int,
int)),
325 this, SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
326 connect(manager, SIGNAL(singleStepChanged(
QtProperty*,
int)),
327 this, SLOT(slotSingleStepChanged(
QtProperty*,
int)));
328 connect(manager, SIGNAL(readOnlyChanged(
QtProperty*,
bool)),
329 this, SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
340 QSpinBox* editor = d_ptr->
createEditor(property, parent);
341 editor->setSingleStep(manager->
singleStep(property));
342 editor->setRange(manager->
minimum(property), manager->
maximum(property));
343 editor->setValue(manager->
value(property));
344 editor->setKeyboardTracking(
false);
345 editor->setReadOnly(manager->
isReadOnly(property));
347 connect(editor, SIGNAL(valueChanged(
int)),
this, SLOT(slotSetValue(
int)));
348 connect(editor, SIGNAL(destroyed(QObject*)),
349 this, SLOT(slotEditorDestroyed(QObject*)));
360 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
361 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
362 disconnect(manager, SIGNAL(rangeChanged(
QtProperty*,
int,
int)),
363 this, SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
364 disconnect(manager, SIGNAL(singleStepChanged(
QtProperty*,
int)),
365 this, SLOT(slotSingleStepChanged(
QtProperty*,
int)));
366 disconnect(manager, SIGNAL(readOnlyChanged(
QtProperty*,
bool)),
367 this, SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
392 while (itEditor.hasNext())
394 QSlider* editor = itEditor.next();
395 editor->blockSignals(
true);
396 editor->setValue(
value);
397 editor->blockSignals(
false);
417 while (itEditor.hasNext())
419 QSlider* editor = itEditor.next();
420 editor->blockSignals(
true);
421 editor->setRange(
min,
max);
422 editor->setValue(manager->
value(property));
423 editor->blockSignals(
false);
436 while (itEditor.hasNext())
438 QSlider* editor = itEditor.next();
439 editor->blockSignals(
true);
440 editor->setSingleStep(step);
441 editor->blockSignals(
false);
447 QObject*
object = q_ptr->sender();
448 const QMap<QSlider*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
450 for (QMap<QSlider*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
452 if (itEditor.key() ==
object)
504 connect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
505 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
506 connect(manager, SIGNAL(rangeChanged(
QtProperty*,
int,
int)),
507 this, SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
508 connect(manager, SIGNAL(singleStepChanged(
QtProperty*,
int)),
509 this, SLOT(slotSingleStepChanged(
QtProperty*,
int)));
520 QSlider* editor =
new QSlider(Qt::Horizontal, parent);
522 editor->setSingleStep(manager->
singleStep(property));
523 editor->setRange(manager->
minimum(property), manager->
maximum(property));
524 editor->setValue(manager->
value(property));
526 connect(editor, SIGNAL(valueChanged(
int)),
this, SLOT(slotSetValue(
int)));
527 connect(editor, SIGNAL(destroyed(QObject*)),
528 this, SLOT(slotEditorDestroyed(QObject*)));
539 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
540 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
541 disconnect(manager, SIGNAL(rangeChanged(
QtProperty*,
int,
int)),
542 this, SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
543 disconnect(manager, SIGNAL(singleStepChanged(
QtProperty*,
int)),
544 this, SLOT(slotSingleStepChanged(
QtProperty*,
int)));
569 while (itEditor.hasNext())
571 QScrollBar* editor = itEditor.next();
572 editor->blockSignals(
true);
573 editor->setValue(
value);
574 editor->blockSignals(
false);
594 while (itEditor.hasNext())
596 QScrollBar* editor = itEditor.next();
597 editor->blockSignals(
true);
598 editor->setRange(
min,
max);
599 editor->setValue(manager->
value(property));
600 editor->blockSignals(
false);
613 while (itEditor.hasNext())
615 QScrollBar* editor = itEditor.next();
616 editor->blockSignals(
true);
617 editor->setSingleStep(step);
618 editor->blockSignals(
false);
624 QObject*
object = q_ptr->sender();
625 const QMap<QScrollBar*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
627 for (QMap<QScrollBar*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
628 if (itEditor.key() ==
object)
679 connect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
680 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
681 connect(manager, SIGNAL(rangeChanged(
QtProperty*,
int,
int)),
682 this, SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
683 connect(manager, SIGNAL(singleStepChanged(
QtProperty*,
int)),
684 this, SLOT(slotSingleStepChanged(
QtProperty*,
int)));
695 QScrollBar* editor =
new QScrollBar(Qt::Horizontal, parent);
697 editor->setSingleStep(manager->
singleStep(property));
698 editor->setRange(manager->
minimum(property), manager->
maximum(property));
699 editor->setValue(manager->
value(property));
700 connect(editor, SIGNAL(valueChanged(
int)),
this, SLOT(slotSetValue(
int)));
701 connect(editor, SIGNAL(destroyed(QObject*)),
702 this, SLOT(slotEditorDestroyed(QObject*)));
713 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
714 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
715 disconnect(manager, SIGNAL(rangeChanged(
QtProperty*,
int,
int)),
716 this, SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
717 disconnect(manager, SIGNAL(singleStepChanged(
QtProperty*,
int)),
718 this, SLOT(slotSingleStepChanged(
QtProperty*,
int)));
742 while (itEditor.hasNext())
767 while (itEditor.hasNext())
776 QObject*
object = q_ptr->sender();
778 const QMap<QtBoolEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
780 for (QMap<QtBoolEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
781 if (itEditor.key() ==
object)
832 connect(manager, SIGNAL(valueChanged(
QtProperty*,
bool)),
833 this, SLOT(slotPropertyChanged(
QtProperty*,
bool)));
834 connect(manager, SIGNAL(textVisibleChanged(
QtProperty*,
bool)),
835 this, SLOT(slotTextVisibleChanged(
QtProperty*,
bool)));
850 connect(editor, SIGNAL(toggled(
bool)),
this, SLOT(slotSetValue(
bool)));
851 connect(editor, SIGNAL(destroyed(QObject*)),
852 this, SLOT(slotEditorDestroyed(QObject*)));
863 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
bool)),
864 this, SLOT(slotPropertyChanged(
QtProperty*,
bool)));
865 disconnect(manager, SIGNAL(textVisibleChanged(
QtProperty*,
bool)),
866 this, SLOT(slotTextVisibleChanged(
QtProperty*,
bool)));
890 while (itEditor.hasNext())
892 QDoubleSpinBox* editor = itEditor.next();
894 if (editor->value() !=
value)
896 editor->blockSignals(
true);
897 editor->setValue(
value);
898 editor->blockSignals(
false);
919 QListIterator<QDoubleSpinBox*> itEditor(editors);
921 while (itEditor.hasNext())
923 QDoubleSpinBox* editor = itEditor.next();
924 editor->blockSignals(
true);
925 editor->setRange(
min,
max);
926 editor->setValue(manager->
value(property));
927 editor->blockSignals(
false);
946 QListIterator<QDoubleSpinBox*> itEditor(editors);
948 while (itEditor.hasNext())
950 QDoubleSpinBox* editor = itEditor.next();
951 editor->blockSignals(
true);
952 editor->setSingleStep(step);
953 editor->blockSignals(
false);
973 while (itEditor.hasNext())
975 QDoubleSpinBox* editor = itEditor.next();
976 editor->blockSignals(
true);
977 editor->setReadOnly(readOnly);
978 editor->blockSignals(
false);
997 QListIterator<QDoubleSpinBox*> itEditor(editors);
999 while (itEditor.hasNext())
1001 QDoubleSpinBox* editor = itEditor.next();
1002 editor->blockSignals(
true);
1003 editor->setDecimals(prec);
1004 editor->setValue(manager->
value(property));
1005 editor->blockSignals(
false);
1011 QObject*
object = q_ptr->sender();
1012 const QMap<QDoubleSpinBox*, QtProperty*>::ConstIterator itcend =
m_editorToProperty.constEnd();
1014 for (QMap<QDoubleSpinBox*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor)
1016 if (itEditor.key() ==
object)
1047 d_ptr->q_ptr =
this;
1067 connect(manager, SIGNAL(valueChanged(
QtProperty*,
double)),
1068 this, SLOT(slotPropertyChanged(
QtProperty*,
double)));
1069 connect(manager, SIGNAL(rangeChanged(
QtProperty*,
double,
double)),
1070 this, SLOT(slotRangeChanged(
QtProperty*,
double,
double)));
1071 connect(manager, SIGNAL(singleStepChanged(
QtProperty*,
double)),
1072 this, SLOT(slotSingleStepChanged(
QtProperty*,
double)));
1073 connect(manager, SIGNAL(decimalsChanged(
QtProperty*,
int)),
1074 this, SLOT(slotDecimalsChanged(
QtProperty*,
int)));
1075 connect(manager, SIGNAL(readOnlyChanged(
QtProperty*,
bool)),
1076 this, SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1087 QDoubleSpinBox* editor = d_ptr->
createEditor(property, parent);
1088 editor->setSingleStep(manager->
singleStep(property));
1089 editor->setDecimals(manager->
decimals(property));
1090 editor->setRange(manager->
minimum(property), manager->
maximum(property));
1091 editor->setValue(manager->
value(property));
1092 editor->setKeyboardTracking(
false);
1093 editor->setReadOnly(manager->
isReadOnly(property));
1095 connect(editor, SIGNAL(valueChanged(
double)),
this, SLOT(slotSetValue(
double)));
1096 connect(editor, SIGNAL(destroyed(QObject*)),
1097 this, SLOT(slotEditorDestroyed(QObject*)));
1108 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
double)),
1109 this, SLOT(slotPropertyChanged(
QtProperty*,
double)));
1110 disconnect(manager, SIGNAL(rangeChanged(
QtProperty*,
double,
double)),
1111 this, SLOT(slotRangeChanged(
QtProperty*,
double,
double)));
1112 disconnect(manager, SIGNAL(singleStepChanged(
QtProperty*,
double)),
1113 this, SLOT(slotSingleStepChanged(
QtProperty*,
double)));
1114 disconnect(manager, SIGNAL(decimalsChanged(
QtProperty*,
int)),
1115 this, SLOT(slotDecimalsChanged(
QtProperty*,
int)));
1116 disconnect(manager, SIGNAL(readOnlyChanged(
QtProperty*,
bool)),
1117 this, SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1136 const QString&
value)
1145 while (itEditor.hasNext())
1147 QLineEdit* editor = itEditor.next();
1149 if (editor->text() !=
value)
1151 editor->blockSignals(
true);
1152 editor->setText(
value);
1153 editor->blockSignals(
false);
1159 const QRegExp& regExp)
1175 while (itEditor.hasNext())
1177 QLineEdit* editor = itEditor.next();
1178 editor->blockSignals(
true);
1179 const QValidator* oldValidator = editor->validator();
1180 QValidator* newValidator = 0;
1182 if (regExp.isValid())
1184 newValidator =
new QRegExpValidator(regExp, editor);
1187 editor->setValidator(newValidator);
1191 delete oldValidator;
1194 editor->blockSignals(
false);
1214 while (itEditor.hasNext())
1216 QLineEdit* editor = itEditor.next();
1217 editor->blockSignals(
true);
1218 editor->setEchoMode((
EchoMode)echoMode);
1219 editor->blockSignals(
false);
1239 while (itEditor.hasNext())
1241 QLineEdit* editor = itEditor.next();
1242 editor->blockSignals(
true);
1243 editor->setReadOnly(readOnly);
1244 editor->blockSignals(
false);
1250 QObject*
object = q_ptr->sender();
1251 const QMap<QLineEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1253 for (QMap<QLineEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
1254 if (itEditor.key() ==
object)
1287 d_ptr->q_ptr =
this;
1307 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QString&)),
1308 this, SLOT(slotPropertyChanged(
QtProperty*,
const QString&)));
1309 connect(manager, SIGNAL(regExpChanged(
QtProperty*,
const QRegExp&)),
1310 this, SLOT(slotRegExpChanged(
QtProperty*,
const QRegExp&)));
1311 connect(manager, SIGNAL(echoModeChanged(
QtProperty*,
int)),
1312 this, SLOT(slotEchoModeChanged(
QtProperty*,
int)));
1313 connect(manager, SIGNAL(readOnlyChanged(
QtProperty*,
bool)),
1314 this, SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1326 QLineEdit* editor = d_ptr->
createEditor(property, parent);
1328 editor->setReadOnly(manager->
isReadOnly(property));
1329 QRegExp regExp = manager->
regExp(property);
1331 if (regExp.isValid())
1333 QValidator* validator =
new QRegExpValidator(regExp, editor);
1334 editor->setValidator(validator);
1337 editor->setText(manager->
value(property));
1339 connect(editor, SIGNAL(textChanged(
const QString&)),
1340 this, SLOT(slotSetValue(
const QString&)));
1341 connect(editor, SIGNAL(destroyed(QObject*)),
1342 this, SLOT(slotEditorDestroyed(QObject*)));
1353 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QString&)),
1354 this, SLOT(slotPropertyChanged(
QtProperty*,
const QString&)));
1355 disconnect(manager, SIGNAL(regExpChanged(
QtProperty*,
const QRegExp&)),
1356 this, SLOT(slotRegExpChanged(
QtProperty*,
const QRegExp&)));
1357 disconnect(manager, SIGNAL(echoModeChanged(
QtProperty*,
int)),
1358 this, SLOT(slotEchoModeChanged(
QtProperty*,
int)));
1359 disconnect(manager, SIGNAL(readOnlyChanged(
QtProperty*,
bool)),
1360 this, SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1386 while (itEditor.hasNext())
1388 QDateEdit* editor = itEditor.next();
1389 editor->blockSignals(
true);
1390 editor->setDate(
value);
1391 editor->blockSignals(
false);
1396 const QDate&
min,
const QDate&
max)
1412 while (itEditor.hasNext())
1414 QDateEdit* editor = itEditor.next();
1415 editor->blockSignals(
true);
1416 editor->setDateRange(
min,
max);
1417 editor->setDate(manager->
value(property));
1418 editor->blockSignals(
false);
1424 QObject*
object = q_ptr->sender();
1425 const QMap<QDateEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1427 for (QMap<QDateEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
1428 if (itEditor.key() ==
object)
1459 d_ptr->q_ptr =
this;
1479 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QDate&)),
1480 this, SLOT(slotPropertyChanged(
QtProperty*,
const QDate&)));
1481 connect(manager, SIGNAL(rangeChanged(
QtProperty*,
const QDate&,
const QDate&)),
1482 this, SLOT(slotRangeChanged(
QtProperty*,
const QDate&,
const QDate&)));
1493 QDateEdit* editor = d_ptr->
createEditor(property, parent);
1494 editor->setCalendarPopup(
true);
1495 editor->setDateRange(manager->
minimum(property), manager->
maximum(property));
1496 editor->setDate(manager->
value(property));
1498 connect(editor, SIGNAL(dateChanged(
const QDate&)),
1499 this, SLOT(slotSetValue(
const QDate&)));
1500 connect(editor, SIGNAL(destroyed(QObject*)),
1501 this, SLOT(slotEditorDestroyed(QObject*)));
1512 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QDate&)),
1513 this, SLOT(slotPropertyChanged(
QtProperty*,
const QDate&)));
1514 disconnect(manager, SIGNAL(rangeChanged(
QtProperty*,
const QDate&,
const QDate&)),
1515 this, SLOT(slotRangeChanged(
QtProperty*,
const QDate&,
const QDate&)));
1539 while (itEditor.hasNext())
1541 QTimeEdit* editor = itEditor.next();
1542 editor->blockSignals(
true);
1543 editor->setTime(
value);
1544 editor->blockSignals(
false);
1550 QObject*
object = q_ptr->sender();
1551 const QMap<QTimeEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1553 for (QMap<QTimeEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
1554 if (itEditor.key() ==
object)
1585 d_ptr->q_ptr =
this;
1605 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QTime&)),
1606 this, SLOT(slotPropertyChanged(
QtProperty*,
const QTime&)));
1617 QTimeEdit* editor = d_ptr->
createEditor(property, parent);
1618 editor->setTime(manager->
value(property));
1620 connect(editor, SIGNAL(timeChanged(
const QTime&)),
1621 this, SLOT(slotSetValue(
const QTime&)));
1622 connect(editor, SIGNAL(destroyed(QObject*)),
1623 this, SLOT(slotEditorDestroyed(QObject*)));
1634 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QTime&)),
1635 this, SLOT(slotPropertyChanged(
QtProperty*,
const QTime&)));
1652 const QDateTime&
value)
1661 while (itEditor.hasNext())
1663 QDateTimeEdit* editor = itEditor.next();
1664 editor->blockSignals(
true);
1665 editor->setDateTime(
value);
1666 editor->blockSignals(
false);
1672 QObject*
object = q_ptr->sender();
1673 const QMap<QDateTimeEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1675 for (QMap<QDateTimeEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
1676 if (itEditor.key() ==
object)
1707 d_ptr->q_ptr =
this;
1727 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QDateTime&)),
1728 this, SLOT(slotPropertyChanged(
QtProperty*,
const QDateTime&)));
1739 QDateTimeEdit* editor = d_ptr->
createEditor(property, parent);
1740 editor->setDateTime(manager->
value(property));
1742 connect(editor, SIGNAL(dateTimeChanged(
const QDateTime&)),
1743 this, SLOT(slotSetValue(
const QDateTime&)));
1744 connect(editor, SIGNAL(destroyed(QObject*)),
1745 this, SLOT(slotEditorDestroyed(QObject*)));
1756 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QDateTime&)),
1757 this, SLOT(slotPropertyChanged(
QtProperty*,
const QDateTime&)));
1773 const QKeySequence&
value)
1782 while (itEditor.hasNext())
1785 editor->blockSignals(
true);
1787 editor->blockSignals(
false);
1793 QObject*
object = q_ptr->sender();
1794 const QMap<QtKeySequenceEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1796 for (QMap<QtKeySequenceEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
1797 if (itEditor.key() ==
object)
1828 d_ptr->q_ptr =
this;
1848 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QKeySequence&)),
1849 this, SLOT(slotPropertyChanged(
QtProperty*,
const QKeySequence&)));
1863 connect(editor, SIGNAL(keySequenceChanged(
const QKeySequence&)),
1864 this, SLOT(slotSetValue(
const QKeySequence&)));
1865 connect(editor, SIGNAL(destroyed(QObject*)),
1866 this, SLOT(slotEditorDestroyed(QObject*)));
1877 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QKeySequence&)),
1878 this, SLOT(slotPropertyChanged(
QtProperty*,
const QKeySequence&)));
1889 QChar
value()
const;
1901 bool event(QEvent* e)
override;
1903 void slotClearChar();
1905 void handleKeyEvent(QKeyEvent* e);
1908 QLineEdit* m_lineEdit;
1912 : QWidget(parent), m_lineEdit(new QLineEdit(this))
1914 QHBoxLayout* layout =
new QHBoxLayout(
this);
1915 layout->addWidget(m_lineEdit);
1916 layout->setMargin(0);
1917 m_lineEdit->installEventFilter(
this);
1918 m_lineEdit->setReadOnly(
true);
1919 m_lineEdit->setFocusProxy(
this);
1920 setFocusPolicy(m_lineEdit->focusPolicy());
1921 setAttribute(Qt::WA_InputMethodEnabled);
1926 if (o == m_lineEdit && e->type() == QEvent::ContextMenu)
1928 QContextMenuEvent*
c =
static_cast<QContextMenuEvent*
>(e);
1929 QMenu* menu = m_lineEdit->createStandardContextMenu();
1930 QList<QAction*> actions = menu->actions();
1931 QListIterator<QAction*> itAction(actions);
1933 while (itAction.hasNext())
1935 QAction* action = itAction.next();
1936 action->setShortcut(QKeySequence());
1937 QString actionString = action->text();
1938 const int pos = actionString.lastIndexOf(QLatin1Char(
'\t'));
1942 actionString = actionString.remove(pos, actionString.length() - pos);
1945 action->setText(actionString);
1948 QAction* actionBefore = 0;
1950 if (actions.count() > 0)
1952 actionBefore = actions[0];
1955 QAction* clearAction =
new QAction(tr(
"Clear Char"), menu);
1956 menu->insertAction(actionBefore, clearAction);
1957 menu->insertSeparator(actionBefore);
1958 clearAction->setEnabled(!m_value.isNull());
1959 connect(clearAction, SIGNAL(triggered()),
this, SLOT(slotClearChar()));
1960 menu->exec(
c->globalPos());
1966 return QWidget::eventFilter(o, e);
1969 void QtCharEdit::slotClearChar()
1971 if (m_value.isNull())
1980 void QtCharEdit::handleKeyEvent(QKeyEvent* e)
1982 const int key = e->key();
1986 case Qt::Key_Control:
1990 case Qt::Key_Super_L:
1991 case Qt::Key_Return:
1998 const QString text = e->text();
2000 if (text.count() != 1)
2005 const QChar
c = text.at(0);
2018 const QString
str = m_value.isNull() ? QString() : QString(m_value);
2019 m_lineEdit->setText(
str);
2026 if (
value == m_value)
2033 m_lineEdit->setText(
str);
2043 m_lineEdit->event(e);
2044 m_lineEdit->selectAll();
2045 QWidget::focusInEvent(e);
2050 m_lineEdit->event(e);
2051 QWidget::focusOutEvent(e);
2062 m_lineEdit->event(e);
2070 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
2077 case QEvent::Shortcut:
2078 case QEvent::ShortcutOverride:
2079 case QEvent::KeyRelease:
2087 return QWidget::event(e);
2113 while (itEditor.hasNext())
2116 editor->blockSignals(
true);
2118 editor->blockSignals(
false);
2124 QObject*
object = q_ptr->sender();
2125 const QMap<QtCharEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
2127 for (QMap<QtCharEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
2128 if (itEditor.key() ==
object)
2159 d_ptr->q_ptr =
this;
2179 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QChar&)),
2180 this, SLOT(slotPropertyChanged(
QtProperty*,
const QChar&)));
2194 connect(editor, SIGNAL(valueChanged(
const QChar&)),
2195 this, SLOT(slotSetValue(
const QChar&)));
2196 connect(editor, SIGNAL(destroyed(QObject*)),
2197 this, SLOT(slotEditorDestroyed(QObject*)));
2208 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QChar&)),
2209 this, SLOT(slotPropertyChanged(
QtProperty*,
const QChar&)));
2235 while (itEditor.hasNext())
2237 QComboBox* editor = itEditor.next();
2238 editor->blockSignals(
true);
2239 editor->setCurrentIndex(
value);
2240 editor->blockSignals(
false);
2245 const QStringList& enumNames)
2259 QMap<int, QIcon> enumIcons = manager->
enumIcons(property);
2263 while (itEditor.hasNext())
2265 QComboBox* editor = itEditor.next();
2266 editor->blockSignals(
true);
2268 editor->addItems(enumNames);
2269 const int nameCount = enumNames.count();
2271 for (
int i = 0; i < nameCount; i++)
2273 editor->setItemIcon(i, enumIcons.value(i));
2276 editor->setCurrentIndex(manager->
value(property));
2277 editor->blockSignals(
false);
2282 const QMap<int, QIcon>& enumIcons)
2296 const QStringList enumNames = manager->
enumNames(property);
2299 while (itEditor.hasNext())
2301 QComboBox* editor = itEditor.next();
2302 editor->blockSignals(
true);
2303 const int nameCount = enumNames.count();
2305 for (
int i = 0; i < nameCount; i++)
2307 editor->setItemIcon(i, enumIcons.value(i));
2310 editor->setCurrentIndex(manager->
value(property));
2311 editor->blockSignals(
false);
2317 QObject*
object = q_ptr->sender();
2318 const QMap<QComboBox*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
2320 for (QMap<QComboBox*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
2321 if (itEditor.key() ==
object)
2352 d_ptr->q_ptr =
this;
2372 connect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
2373 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
2374 connect(manager, SIGNAL(enumNamesChanged(
QtProperty*,
const QStringList&)),
2375 this, SLOT(slotEnumNamesChanged(
QtProperty*,
const QStringList&)));
2386 QComboBox* editor = d_ptr->
createEditor(property, parent);
2387 editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
2388 editor->setMinimumContentsLength(1);
2389 editor->view()->setTextElideMode(Qt::ElideRight);
2390 QStringList enumNames = manager->
enumNames(property);
2391 editor->addItems(enumNames);
2392 QMap<int, QIcon> enumIcons = manager->
enumIcons(property);
2393 const int enumNamesCount = enumNames.count();
2395 for (
int i = 0; i < enumNamesCount; i++)
2397 editor->setItemIcon(i, enumIcons.value(i));
2400 editor->setCurrentIndex(manager->
value(property));
2402 connect(editor, SIGNAL(currentIndexChanged(
int)),
this, SLOT(slotSetValue(
int)));
2403 connect(editor, SIGNAL(destroyed(QObject*)),
2404 this, SLOT(slotEditorDestroyed(QObject*)));
2415 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
int)),
2416 this, SLOT(slotPropertyChanged(
QtProperty*,
int)));
2417 disconnect(manager, SIGNAL(enumNamesChanged(
QtProperty*,
const QStringList&)),
2418 this, SLOT(slotEnumNamesChanged(
QtProperty*,
const QStringList&)));
2432 void slotPropertyChanged(
QtProperty* property,
const QCursor& cursor);
2434 void slotEditorDestroyed(QObject*
object);
2447 : m_updatingEnum(false)
2489 #ifndef QT_NO_CURSOR
2490 cursorManager->
setValue(prop, QCursor(cursorDatabase()->valueToCursor(
value)));
2499 const QMap<QWidget*, QtProperty*>::ConstIterator ecend =
m_editorToEnum.constEnd();
2501 for (QMap<QWidget*, QtProperty*>::ConstIterator itEditor =
m_editorToEnum.constBegin(); itEditor != ecend; ++itEditor)
2502 if (itEditor.key() ==
object)
2504 QWidget* editor = itEditor.key();
2538 d_ptr->q_ptr =
this;
2543 this, SLOT(slotEnumChanged(
QtProperty*,
int)));
2562 connect(manager, SIGNAL(valueChanged(
QtProperty*,
const QCursor&)),
2563 this, SLOT(slotPropertyChanged(
QtProperty*,
const QCursor&)));
2585 #ifndef QT_NO_CURSOR
2596 connect(editor, SIGNAL(destroyed(QObject*)),
2597 this, SLOT(slotEditorDestroyed(QObject*)));
2608 disconnect(manager, SIGNAL(valueChanged(
QtProperty*,
const QCursor&)),
2609 this, SLOT(slotPropertyChanged(
QtProperty*,
const QCursor&)));
2621 bool eventFilter(QObject* obj, QEvent* ev)
override;
2633 void buttonClicked();
2637 QLabel* m_pixmapLabel;
2639 QToolButton* m_button;
2644 m_pixmapLabel(new QLabel),
2645 m_label(new QLabel),
2646 m_button(new QToolButton)
2648 QHBoxLayout* lt =
new QHBoxLayout(
this);
2649 setupTreeViewEditorMargin(lt);
2651 lt->addWidget(m_pixmapLabel);
2652 lt->addWidget(m_label);
2653 lt->addItem(
new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
2655 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
2656 m_button->setFixedWidth(20);
2657 setFocusProxy(m_button);
2658 setFocusPolicy(m_button->focusPolicy());
2659 m_button->setText(tr(
"..."));
2660 m_button->installEventFilter(
this);
2661 connect(m_button, SIGNAL(clicked()),
this, SLOT(buttonClicked()));
2662 lt->addWidget(m_button);
2677 void QtColorEditWidget::buttonClicked()
2680 QRgb oldRgba = m_color.rgba();
2681 QRgb newRgba = QColorDialog::getRgba(oldRgba, &
ok,
this);
2683 if (
ok && newRgba != oldRgba)
2685 setValue(QColor::fromRgba(newRgba));
2692 if (obj == m_button)
2696 case QEvent::KeyPress:
2697 case QEvent::KeyRelease:
2699 switch (
static_cast<const QKeyEvent*
>(ev)->key())
2701 case Qt::Key_Escape:
2703 case Qt::Key_Return:
2718 return QWidget::eventFilter(obj, ev);
2726 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
2742 const QColor&
value)
2744 const PropertyToEditorListMap::iterator it =
m_createdEditors.find(property);
2751 QListIterator<QtColorEditWidget*> itEditor(it.value());
2753 while (itEditor.hasNext())
2755 itEditor.next()->setValue(
value);
2761 QObject*
object = q_ptr->sender();
2764 for (EditorToPropertyMap::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
2765 if (itEditor.key() ==
object)
2796 d_ptr->q_ptr =
this;
2815 connect(manager, SIGNAL(valueChanged(
QtProperty*, QColor)),
2816 this, SLOT(slotPropertyChanged(
QtProperty*, QColor)));
2829 connect(editor, SIGNAL(valueChanged(QColor)),
this, SLOT(slotSetValue(QColor)));
2830 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
2841 disconnect(manager, SIGNAL(valueChanged(
QtProperty*, QColor)),
this, SLOT(slotPropertyChanged(
QtProperty*, QColor)));
2853 bool eventFilter(QObject* obj, QEvent* ev)
override;
2865 void buttonClicked();
2869 QLabel* m_pixmapLabel;
2871 QToolButton* m_button;
2876 m_pixmapLabel(new QLabel),
2877 m_label(new QLabel),
2878 m_button(new QToolButton)
2880 QHBoxLayout* lt =
new QHBoxLayout(
this);
2881 setupTreeViewEditorMargin(lt);
2883 lt->addWidget(m_pixmapLabel);
2884 lt->addWidget(m_label);
2885 lt->addItem(
new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
2887 m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
2888 m_button->setFixedWidth(20);
2889 setFocusProxy(m_button);
2890 setFocusPolicy(m_button->focusPolicy());
2891 m_button->setText(tr(
"..."));
2892 m_button->installEventFilter(
this);
2893 connect(m_button, SIGNAL(clicked()),
this, SLOT(buttonClicked()));
2894 lt->addWidget(m_button);
2909 void QtFontEditWidget::buttonClicked()
2912 QFont newFont = QFontDialog::getFont(&
ok, m_font,
this, tr(
"Select Font"));
2914 if (
ok && newFont != m_font)
2919 if (m_font.family() != newFont.family())
2921 f.setFamily(newFont.family());
2924 if (m_font.pointSize() != newFont.pointSize())
2926 f.setPointSize(newFont.pointSize());
2929 if (m_font.bold() != newFont.bold())
2931 f.setBold(newFont.bold());
2934 if (m_font.italic() != newFont.italic())
2936 f.setItalic(newFont.italic());
2939 if (m_font.underline() != newFont.underline())
2941 f.setUnderline(newFont.underline());
2944 if (m_font.strikeOut() != newFont.strikeOut())
2946 f.setStrikeOut(newFont.strikeOut());
2956 if (obj == m_button)
2960 case QEvent::KeyPress:
2961 case QEvent::KeyRelease:
2963 switch (
static_cast<const QKeyEvent*
>(ev)->key())
2965 case Qt::Key_Escape:
2967 case Qt::Key_Return:
2982 return QWidget::eventFilter(obj, ev);
2990 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
3008 const PropertyToEditorListMap::iterator it =
m_createdEditors.find(property);
3015 QListIterator<QtFontEditWidget*> itEditor(it.value());
3017 while (itEditor.hasNext())
3019 itEditor.next()->setValue(
value);
3025 QObject*
object = q_ptr->sender();
3028 for (EditorToPropertyMap::ConstIterator itEditor =
m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
3029 if (itEditor.key() ==
object)
3060 d_ptr->q_ptr =
this;
3079 connect(manager, SIGNAL(valueChanged(
QtProperty*, QFont)),
3080 this, SLOT(slotPropertyChanged(
QtProperty*, QFont)));
3093 connect(editor, SIGNAL(valueChanged(QFont)),
this, SLOT(slotSetValue(QFont)));
3094 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
3105 disconnect(manager, SIGNAL(valueChanged(
QtProperty*, QFont)),
this, SLOT(slotPropertyChanged(
QtProperty*, QFont)));
3110 #include "moc_qteditorfactory.cpp"
3111 #include "qteditorfactory.moc"