44 #include <QAbstractItemView>
45 #include <QApplication>
46 #include <QColorDialog>
48 #include <QDateTimeEdit>
49 #include <QFontDialog>
50 #include <QHBoxLayout>
58 #include <QSpacerItem>
60 #include <QStyleOption>
61 #include <QToolButton>
65 #if defined(Q_CC_MSVC)
66 #pragma warning(disable : 4786)
75 setupTreeViewEditorMargin(QLayout* lt)
82 if (QApplication::layoutDirection() == Qt::LeftToRight)
84 lt->setContentsMargins(DecorationMargin, 0, 0, 0);
88 lt->setContentsMargins(0, 0, DecorationMargin, 0);
95 template <
class Editor>
111 template <
class Editor>
115 Editor* editor =
new Editor(parent);
116 initializeEditor(property, editor);
120 template <
class Editor>
124 typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
126 if (it == m_createdEditors.end())
128 it = m_createdEditors.insert(property,
EditorList());
131 it.value().append(editor);
132 m_editorToProperty.insert(editor, property);
135 template <
class Editor>
139 const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end();
141 for (
typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin();
145 if (itEditor.key() ==
object)
147 Editor* editor = itEditor.key();
149 const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property);
151 if (pit != m_createdEditors.end())
153 pit.value().removeAll(editor);
155 if (pit.value().empty())
157 m_createdEditors.erase(pit);
161 m_editorToProperty.erase(itEditor);
191 while (itEditor.hasNext())
193 QSpinBox* editor = itEditor.next();
195 if (editor->value() !=
value)
197 editor->blockSignals(
true);
198 editor->setValue(
value);
199 editor->blockSignals(
false);
221 while (itEditor.hasNext())
223 QSpinBox* editor = itEditor.next();
224 editor->blockSignals(
true);
225 editor->setRange(
min,
max);
226 editor->setValue(manager->
value(property));
227 editor->blockSignals(
false);
241 while (itEditor.hasNext())
243 QSpinBox* editor = itEditor.next();
244 editor->blockSignals(
true);
245 editor->setSingleStep(step);
246 editor->blockSignals(
false);
267 while (itEditor.hasNext())
269 QSpinBox* editor = itEditor.next();
270 editor->blockSignals(
true);
271 editor->setReadOnly(readOnly);
272 editor->blockSignals(
false);
279 QObject*
object = q_ptr->sender();
280 const QMap<QSpinBox*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
282 for (QMap<QSpinBox*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
286 if (itEditor.key() ==
object)
345 SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
349 SLOT(slotSingleStepChanged(
QtProperty*,
int)));
353 SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
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));
371 connect(editor, SIGNAL(valueChanged(
int)),
this, SLOT(slotSetValue(
int)));
372 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
391 SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
395 SLOT(slotSingleStepChanged(
QtProperty*,
int)));
399 SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
425 while (itEditor.hasNext())
427 QSlider* editor = itEditor.next();
428 editor->blockSignals(
true);
429 editor->setValue(
value);
430 editor->blockSignals(
false);
451 while (itEditor.hasNext())
453 QSlider* editor = itEditor.next();
454 editor->blockSignals(
true);
455 editor->setRange(
min,
max);
456 editor->setValue(manager->
value(property));
457 editor->blockSignals(
false);
471 while (itEditor.hasNext())
473 QSlider* editor = itEditor.next();
474 editor->blockSignals(
true);
475 editor->setSingleStep(step);
476 editor->blockSignals(
false);
483 QObject*
object = q_ptr->sender();
484 const QMap<QSlider*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
486 for (QMap<QSlider*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
490 if (itEditor.key() ==
object)
549 SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
553 SLOT(slotSingleStepChanged(
QtProperty*,
int)));
564 QSlider* editor =
new QSlider(Qt::Horizontal, parent);
566 editor->setSingleStep(manager->
singleStep(property));
567 editor->setRange(manager->
minimum(property), manager->
maximum(property));
568 editor->setValue(manager->
value(property));
570 connect(editor, SIGNAL(valueChanged(
int)),
this, SLOT(slotSetValue(
int)));
571 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
590 SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
594 SLOT(slotSingleStepChanged(
QtProperty*,
int)));
620 while (itEditor.hasNext())
622 QScrollBar* editor = itEditor.next();
623 editor->blockSignals(
true);
624 editor->setValue(
value);
625 editor->blockSignals(
false);
646 while (itEditor.hasNext())
648 QScrollBar* editor = itEditor.next();
649 editor->blockSignals(
true);
650 editor->setRange(
min,
max);
651 editor->setValue(manager->
value(property));
652 editor->blockSignals(
false);
666 while (itEditor.hasNext())
668 QScrollBar* editor = itEditor.next();
669 editor->blockSignals(
true);
670 editor->setSingleStep(step);
671 editor->blockSignals(
false);
678 QObject*
object = q_ptr->sender();
679 const QMap<QScrollBar*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
681 for (QMap<QScrollBar*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
684 if (itEditor.key() ==
object)
742 SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
746 SLOT(slotSingleStepChanged(
QtProperty*,
int)));
759 QScrollBar* editor =
new QScrollBar(Qt::Horizontal, parent);
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*)));
784 SLOT(slotRangeChanged(
QtProperty*,
int,
int)));
788 SLOT(slotSingleStepChanged(
QtProperty*,
int)));
813 while (itEditor.hasNext())
839 while (itEditor.hasNext())
849 QObject*
object = q_ptr->sender();
851 const QMap<QtBoolEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
853 for (QMap<QtBoolEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
856 if (itEditor.key() ==
object)
910 SLOT(slotPropertyChanged(
QtProperty*,
bool)));
912 SIGNAL(textVisibleChanged(
QtProperty*,
bool)),
914 SLOT(slotTextVisibleChanged(
QtProperty*,
bool)));
931 connect(editor, SIGNAL(toggled(
bool)),
this, SLOT(slotSetValue(
bool)));
932 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
947 SLOT(slotPropertyChanged(
QtProperty*,
bool)));
949 SIGNAL(textVisibleChanged(
QtProperty*,
bool)),
951 SLOT(slotTextVisibleChanged(
QtProperty*,
bool)));
975 while (itEditor.hasNext())
977 QDoubleSpinBox* editor = itEditor.next();
979 if (editor->value() !=
value)
981 editor->blockSignals(
true);
982 editor->setValue(
value);
983 editor->blockSignals(
false);
1004 QListIterator<QDoubleSpinBox*> itEditor(editors);
1006 while (itEditor.hasNext())
1008 QDoubleSpinBox* editor = itEditor.next();
1009 editor->blockSignals(
true);
1010 editor->setRange(
min,
max);
1011 editor->setValue(manager->
value(property));
1012 editor->blockSignals(
false);
1032 QListIterator<QDoubleSpinBox*> itEditor(editors);
1034 while (itEditor.hasNext())
1036 QDoubleSpinBox* editor = itEditor.next();
1037 editor->blockSignals(
true);
1038 editor->setSingleStep(step);
1039 editor->blockSignals(
false);
1060 while (itEditor.hasNext())
1062 QDoubleSpinBox* editor = itEditor.next();
1063 editor->blockSignals(
true);
1064 editor->setReadOnly(readOnly);
1065 editor->blockSignals(
false);
1085 QListIterator<QDoubleSpinBox*> itEditor(editors);
1087 while (itEditor.hasNext())
1089 QDoubleSpinBox* editor = itEditor.next();
1090 editor->blockSignals(
true);
1091 editor->setDecimals(prec);
1092 editor->setValue(manager->
value(property));
1093 editor->blockSignals(
false);
1100 QObject*
object = q_ptr->sender();
1101 const QMap<QDoubleSpinBox*, QtProperty*>::ConstIterator itcend =
m_editorToProperty.constEnd();
1103 for (QMap<QDoubleSpinBox*, QtProperty*>::ConstIterator itEditor =
1108 if (itEditor.key() ==
object)
1139 d_ptr->q_ptr =
this;
1162 SLOT(slotPropertyChanged(
QtProperty*,
double)));
1164 SIGNAL(rangeChanged(
QtProperty*,
double,
double)),
1166 SLOT(slotRangeChanged(
QtProperty*,
double,
double)));
1168 SIGNAL(singleStepChanged(
QtProperty*,
double)),
1170 SLOT(slotSingleStepChanged(
QtProperty*,
double)));
1174 SLOT(slotDecimalsChanged(
QtProperty*,
int)));
1178 SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
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));
1199 connect(editor, SIGNAL(valueChanged(
double)),
this, SLOT(slotSetValue(
double)));
1200 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
1215 SLOT(slotPropertyChanged(
QtProperty*,
double)));
1217 SIGNAL(rangeChanged(
QtProperty*,
double,
double)),
1219 SLOT(slotRangeChanged(
QtProperty*,
double,
double)));
1221 SIGNAL(singleStepChanged(
QtProperty*,
double)),
1223 SLOT(slotSingleStepChanged(
QtProperty*,
double)));
1227 SLOT(slotDecimalsChanged(
QtProperty*,
int)));
1231 SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1258 while (itEditor.hasNext())
1260 QLineEdit* editor = itEditor.next();
1262 if (editor->text() !=
value)
1264 editor->blockSignals(
true);
1265 editor->setText(
value);
1266 editor->blockSignals(
false);
1288 while (itEditor.hasNext())
1290 QLineEdit* editor = itEditor.next();
1291 editor->blockSignals(
true);
1292 const QValidator* oldValidator = editor->validator();
1293 QValidator* newValidator = 0;
1295 if (regExp.isValid())
1297 newValidator =
new QRegExpValidator(regExp, editor);
1300 editor->setValidator(newValidator);
1304 delete oldValidator;
1307 editor->blockSignals(
false);
1328 while (itEditor.hasNext())
1330 QLineEdit* editor = itEditor.next();
1331 editor->blockSignals(
true);
1332 editor->setEchoMode((
EchoMode)echoMode);
1333 editor->blockSignals(
false);
1354 while (itEditor.hasNext())
1356 QLineEdit* editor = itEditor.next();
1357 editor->blockSignals(
true);
1358 editor->setReadOnly(readOnly);
1359 editor->blockSignals(
false);
1366 QObject*
object = q_ptr->sender();
1367 const QMap<QLineEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1369 for (QMap<QLineEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
1372 if (itEditor.key() ==
object)
1403 d_ptr->q_ptr =
this;
1424 SIGNAL(valueChanged(
QtProperty*,
const QString&)),
1426 SLOT(slotPropertyChanged(
QtProperty*,
const QString&)));
1428 SIGNAL(regExpChanged(
QtProperty*,
const QRegExp&)),
1430 SLOT(slotRegExpChanged(
QtProperty*,
const QRegExp&)));
1434 SLOT(slotEchoModeChanged(
QtProperty*,
int)));
1438 SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1452 QLineEdit* editor = d_ptr->
createEditor(property, parent);
1454 editor->setReadOnly(manager->
isReadOnly(property));
1455 QRegExp regExp = manager->
regExp(property);
1457 if (regExp.isValid())
1459 QValidator* validator =
new QRegExpValidator(regExp, editor);
1460 editor->setValidator(validator);
1463 editor->setText(manager->
value(property));
1465 connect(editor, SIGNAL(textChanged(
const QString&)),
this, SLOT(slotSetValue(
const QString&)));
1466 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
1479 SIGNAL(valueChanged(
QtProperty*,
const QString&)),
1481 SLOT(slotPropertyChanged(
QtProperty*,
const QString&)));
1483 SIGNAL(regExpChanged(
QtProperty*,
const QRegExp&)),
1485 SLOT(slotRegExpChanged(
QtProperty*,
const QRegExp&)));
1489 SLOT(slotEchoModeChanged(
QtProperty*,
int)));
1493 SLOT(slotReadOnlyChanged(
QtProperty*,
bool)));
1518 while (itEditor.hasNext())
1520 QDateEdit* editor = itEditor.next();
1521 editor->blockSignals(
true);
1522 editor->setDate(
value);
1523 editor->blockSignals(
false);
1544 while (itEditor.hasNext())
1546 QDateEdit* editor = itEditor.next();
1547 editor->blockSignals(
true);
1548 editor->setDateRange(
min,
max);
1549 editor->setDate(manager->
value(property));
1550 editor->blockSignals(
false);
1557 QObject*
object = q_ptr->sender();
1558 const QMap<QDateEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1560 for (QMap<QDateEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
1563 if (itEditor.key() ==
object)
1594 d_ptr->q_ptr =
this;
1615 SIGNAL(valueChanged(
QtProperty*,
const QDate&)),
1617 SLOT(slotPropertyChanged(
QtProperty*,
const QDate&)));
1619 SIGNAL(rangeChanged(
QtProperty*,
const QDate&,
const QDate&)),
1621 SLOT(slotRangeChanged(
QtProperty*,
const QDate&,
const QDate&)));
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));
1639 connect(editor, SIGNAL(dateChanged(
const QDate&)),
this, SLOT(slotSetValue(
const QDate&)));
1640 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
1653 SIGNAL(valueChanged(
QtProperty*,
const QDate&)),
1655 SLOT(slotPropertyChanged(
QtProperty*,
const QDate&)));
1657 SIGNAL(rangeChanged(
QtProperty*,
const QDate&,
const QDate&)),
1659 SLOT(slotRangeChanged(
QtProperty*,
const QDate&,
const QDate&)));
1683 while (itEditor.hasNext())
1685 QTimeEdit* editor = itEditor.next();
1686 editor->blockSignals(
true);
1687 editor->setTime(
value);
1688 editor->blockSignals(
false);
1695 QObject*
object = q_ptr->sender();
1696 const QMap<QTimeEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1698 for (QMap<QTimeEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
1701 if (itEditor.key() ==
object)
1732 d_ptr->q_ptr =
this;
1753 SIGNAL(valueChanged(
QtProperty*,
const QTime&)),
1755 SLOT(slotPropertyChanged(
QtProperty*,
const QTime&)));
1768 QTimeEdit* editor = d_ptr->
createEditor(property, parent);
1769 editor->setTime(manager->
value(property));
1771 connect(editor, SIGNAL(timeChanged(
const QTime&)),
this, SLOT(slotSetValue(
const QTime&)));
1772 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
1785 SIGNAL(valueChanged(
QtProperty*,
const QTime&)),
1787 SLOT(slotPropertyChanged(
QtProperty*,
const QTime&)));
1811 while (itEditor.hasNext())
1813 QDateTimeEdit* editor = itEditor.next();
1814 editor->blockSignals(
true);
1815 editor->setDateTime(
value);
1816 editor->blockSignals(
false);
1823 QObject*
object = q_ptr->sender();
1824 const QMap<QDateTimeEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
1826 for (QMap<QDateTimeEdit*, QtProperty*>::ConstIterator itEditor =
1830 if (itEditor.key() ==
object)
1861 d_ptr->q_ptr =
this;
1882 SIGNAL(valueChanged(
QtProperty*,
const QDateTime&)),
1884 SLOT(slotPropertyChanged(
QtProperty*,
const QDateTime&)));
1897 QDateTimeEdit* editor = d_ptr->
createEditor(property, parent);
1898 editor->setDateTime(manager->
value(property));
1901 SIGNAL(dateTimeChanged(
const QDateTime&)),
1903 SLOT(slotSetValue(
const QDateTime&)));
1904 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
1917 SIGNAL(valueChanged(
QtProperty*,
const QDateTime&)),
1919 SLOT(slotPropertyChanged(
QtProperty*,
const QDateTime&)));
1935 const QKeySequence&
value)
1944 while (itEditor.hasNext())
1947 editor->blockSignals(
true);
1949 editor->blockSignals(
false);
1956 QObject*
object = q_ptr->sender();
1957 const QMap<QtKeySequenceEdit*, QtProperty*>::ConstIterator ecend =
1960 for (QMap<QtKeySequenceEdit*, QtProperty*>::ConstIterator itEditor =
1964 if (itEditor.key() ==
object)
1995 d_ptr->q_ptr =
this;
2016 SIGNAL(valueChanged(
QtProperty*,
const QKeySequence&)),
2018 SLOT(slotPropertyChanged(
QtProperty*,
const QKeySequence&)));
2035 SIGNAL(keySequenceChanged(
const QKeySequence&)),
2037 SLOT(slotSetValue(
const QKeySequence&)));
2038 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
2051 SIGNAL(valueChanged(
QtProperty*,
const QKeySequence&)),
2053 SLOT(slotPropertyChanged(
QtProperty*,
const QKeySequence&)));
2064 QChar
value()
const;
2077 bool event(QEvent* e)
override;
2079 void slotClearChar();
2082 void handleKeyEvent(QKeyEvent* e);
2085 QLineEdit* m_lineEdit;
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);
2103 if (o == m_lineEdit && e->type() == QEvent::ContextMenu)
2105 QContextMenuEvent*
c =
static_cast<QContextMenuEvent*
>(e);
2106 QMenu* menu = m_lineEdit->createStandardContextMenu();
2107 QList<QAction*> actions = menu->actions();
2108 QListIterator<QAction*> itAction(actions);
2110 while (itAction.hasNext())
2112 QAction* action = itAction.next();
2113 action->setShortcut(QKeySequence());
2114 QString actionString = action->text();
2115 const int pos = actionString.lastIndexOf(QLatin1Char(
'\t'));
2119 actionString = actionString.remove(pos, actionString.length() - pos);
2122 action->setText(actionString);
2125 QAction* actionBefore = 0;
2127 if (actions.count() > 0)
2129 actionBefore = actions[0];
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());
2143 return QWidget::eventFilter(o, e);
2147 QtCharEdit::slotClearChar()
2149 if (m_value.isNull())
2159 QtCharEdit::handleKeyEvent(QKeyEvent* e)
2161 const int key = e->key();
2165 case Qt::Key_Control:
2169 case Qt::Key_Super_L:
2170 case Qt::Key_Return:
2177 const QString text = e->text();
2179 if (text.count() != 1)
2184 const QChar
c = text.at(0);
2197 const QString
str = m_value.isNull() ? QString() : QString(m_value);
2198 m_lineEdit->setText(
str);
2206 if (
value == m_value)
2213 m_lineEdit->setText(
str);
2225 m_lineEdit->event(e);
2226 m_lineEdit->selectAll();
2227 QWidget::focusInEvent(e);
2233 m_lineEdit->event(e);
2234 QWidget::focusOutEvent(e);
2247 m_lineEdit->event(e);
2256 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
2264 case QEvent::Shortcut:
2265 case QEvent::ShortcutOverride:
2266 case QEvent::KeyRelease:
2274 return QWidget::event(e);
2298 while (itEditor.hasNext())
2301 editor->blockSignals(
true);
2303 editor->blockSignals(
false);
2310 QObject*
object = q_ptr->sender();
2311 const QMap<QtCharEdit*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
2313 for (QMap<QtCharEdit*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
2316 if (itEditor.key() ==
object)
2347 d_ptr->q_ptr =
this;
2368 SIGNAL(valueChanged(
QtProperty*,
const QChar&)),
2370 SLOT(slotPropertyChanged(
QtProperty*,
const QChar&)));
2386 connect(editor, SIGNAL(valueChanged(
const QChar&)),
this, SLOT(slotSetValue(
const QChar&)));
2387 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
2400 SIGNAL(valueChanged(
QtProperty*,
const QChar&)),
2402 SLOT(slotPropertyChanged(
QtProperty*,
const QChar&)));
2428 while (itEditor.hasNext())
2430 QComboBox* editor = itEditor.next();
2431 editor->blockSignals(
true);
2432 editor->setCurrentIndex(
value);
2433 editor->blockSignals(
false);
2452 QMap<int, QIcon> enumIcons = manager->
enumIcons(property);
2456 while (itEditor.hasNext())
2458 QComboBox* editor = itEditor.next();
2459 editor->blockSignals(
true);
2461 editor->addItems(enumNames);
2462 const int nameCount = enumNames.count();
2464 for (
int i = 0; i < nameCount; i++)
2466 editor->setItemIcon(i, enumIcons.value(i));
2469 editor->setCurrentIndex(manager->
value(property));
2470 editor->blockSignals(
false);
2476 const QMap<int, QIcon>& enumIcons)
2490 const QStringList enumNames = manager->
enumNames(property);
2493 while (itEditor.hasNext())
2495 QComboBox* editor = itEditor.next();
2496 editor->blockSignals(
true);
2497 const int nameCount = enumNames.count();
2499 for (
int i = 0; i < nameCount; i++)
2501 editor->setItemIcon(i, enumIcons.value(i));
2504 editor->setCurrentIndex(manager->
value(property));
2505 editor->blockSignals(
false);
2512 QObject*
object = q_ptr->sender();
2513 const QMap<QComboBox*, QtProperty*>::ConstIterator ecend =
m_editorToProperty.constEnd();
2515 for (QMap<QComboBox*, QtProperty*>::ConstIterator itEditor =
m_editorToProperty.constBegin();
2518 if (itEditor.key() ==
object)
2549 d_ptr->q_ptr =
this;
2572 SLOT(slotPropertyChanged(
QtProperty*,
int)));
2574 SIGNAL(enumNamesChanged(
QtProperty*,
const QStringList&)),
2576 SLOT(slotEnumNamesChanged(
QtProperty*,
const QStringList&)));
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();
2598 for (
int i = 0; i < enumNamesCount; i++)
2600 editor->setItemIcon(i, enumIcons.value(i));
2603 editor->setCurrentIndex(manager->
value(property));
2605 connect(editor, SIGNAL(currentIndexChanged(
int)),
this, SLOT(slotSetValue(
int)));
2606 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
2621 SLOT(slotPropertyChanged(
QtProperty*,
int)));
2623 SIGNAL(enumNamesChanged(
QtProperty*,
const QStringList&)),
2625 SLOT(slotEnumNamesChanged(
QtProperty*,
const QStringList&)));
2639 void slotPropertyChanged(
QtProperty* property,
const QCursor& cursor);
2641 void slotEditorDestroyed(QObject*
object);
2696 #ifndef QT_NO_CURSOR
2697 cursorManager->
setValue(prop, QCursor(cursorDatabase()->valueToCursor(
value)));
2707 const QMap<QWidget*, QtProperty*>::ConstIterator ecend =
m_editorToEnum.constEnd();
2709 for (QMap<QWidget*, QtProperty*>::ConstIterator itEditor =
m_editorToEnum.constBegin();
2712 if (itEditor.key() ==
object)
2714 QWidget* editor = itEditor.key();
2748 d_ptr->q_ptr =
this;
2776 SIGNAL(valueChanged(
QtProperty*,
const QCursor&)),
2778 SLOT(slotPropertyChanged(
QtProperty*,
const QCursor&)));
2802 #ifndef QT_NO_CURSOR
2804 enumProp, cursorDatabase()->cursorToValue(manager->
value(property)));
2814 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
2827 SIGNAL(valueChanged(
QtProperty*,
const QCursor&)),
2829 SLOT(slotPropertyChanged(
QtProperty*,
const QCursor&)));
2841 bool eventFilter(QObject* obj, QEvent* ev)
override;
2853 void buttonClicked();
2857 QLabel* m_pixmapLabel;
2859 QToolButton* m_button;
2863 QWidget(parent), m_pixmapLabel(new QLabel), m_label(new QLabel), m_button(new QToolButton)
2865 QHBoxLayout* lt =
new QHBoxLayout(
this);
2866 setupTreeViewEditorMargin(lt);
2868 lt->addWidget(m_pixmapLabel);
2869 lt->addWidget(m_label);
2870 lt->addItem(
new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
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);
2896 QtColorEditWidget::buttonClicked()
2899 QRgb oldRgba = m_color.rgba();
2900 QRgb newRgba = QColorDialog::getRgba(oldRgba, &
ok,
this);
2902 if (
ok && newRgba != oldRgba)
2904 setValue(QColor::fromRgba(newRgba));
2912 if (obj == m_button)
2916 case QEvent::KeyPress:
2920 switch (
static_cast<const QKeyEvent*
>(ev)->key())
2922 case Qt::Key_Escape:
2924 case Qt::Key_Return:
2939 return QWidget::eventFilter(obj, ev);
2948 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
2965 const PropertyToEditorListMap::iterator it =
m_createdEditors.find(property);
2972 QListIterator<QtColorEditWidget*> itEditor(it.value());
2974 while (itEditor.hasNext())
2976 itEditor.next()->setValue(
value);
2983 QObject*
object = q_ptr->sender();
2989 if (itEditor.key() ==
object)
3020 d_ptr->q_ptr =
this;
3043 SLOT(slotPropertyChanged(
QtProperty*, QColor)));
3058 connect(editor, SIGNAL(valueChanged(QColor)),
this, SLOT(slotSetValue(QColor)));
3059 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
3074 SLOT(slotPropertyChanged(
QtProperty*, QColor)));
3086 bool eventFilter(QObject* obj, QEvent* ev)
override;
3098 void buttonClicked();
3102 QLabel* m_pixmapLabel;
3104 QToolButton* m_button;
3108 QWidget(parent), m_pixmapLabel(new QLabel), m_label(new QLabel), m_button(new QToolButton)
3110 QHBoxLayout* lt =
new QHBoxLayout(
this);
3111 setupTreeViewEditorMargin(lt);
3113 lt->addWidget(m_pixmapLabel);
3114 lt->addWidget(m_label);
3115 lt->addItem(
new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
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);
3141 QtFontEditWidget::buttonClicked()
3144 QFont newFont = QFontDialog::getFont(&
ok, m_font,
this, tr(
"Select Font"));
3146 if (
ok && newFont != m_font)
3151 if (m_font.family() != newFont.family())
3153 f.setFamily(newFont.family());
3156 if (m_font.pointSize() != newFont.pointSize())
3158 f.setPointSize(newFont.pointSize());
3161 if (m_font.bold() != newFont.bold())
3163 f.setBold(newFont.bold());
3166 if (m_font.italic() != newFont.italic())
3168 f.setItalic(newFont.italic());
3171 if (m_font.underline() != newFont.underline())
3173 f.setUnderline(newFont.underline());
3176 if (m_font.strikeOut() != newFont.strikeOut())
3178 f.setStrikeOut(newFont.strikeOut());
3189 if (obj == m_button)
3193 case QEvent::KeyPress:
3197 switch (
static_cast<const QKeyEvent*
>(ev)->key())
3199 case Qt::Key_Escape:
3201 case Qt::Key_Return:
3216 return QWidget::eventFilter(obj, ev);
3225 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
3242 const PropertyToEditorListMap::iterator it =
m_createdEditors.find(property);
3249 QListIterator<QtFontEditWidget*> itEditor(it.value());
3251 while (itEditor.hasNext())
3253 itEditor.next()->setValue(
value);
3260 QObject*
object = q_ptr->sender();
3266 if (itEditor.key() ==
object)
3296 d_ptr->q_ptr =
this;
3319 SLOT(slotPropertyChanged(
QtProperty*, QFont)));
3334 connect(editor, SIGNAL(valueChanged(QFont)),
this, SLOT(slotSetValue(QFont)));
3335 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
3350 SLOT(slotPropertyChanged(
QtProperty*, QFont)));
3355 #include "moc_qteditorfactory.cpp"
3356 #include "qteditorfactory.moc"