git-svn-id: svn://db.shs.com.ru/libs@475 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -163,7 +163,7 @@ QVariantEdit::QVariantEdit(QWidget * parent): QWidget(parent) {
|
||||
_point = 0;
|
||||
_path = 0;
|
||||
_enum = 0;
|
||||
_cur_edit = 0;
|
||||
_custom =_cur_edit = 0;
|
||||
_recreate(QVariant());
|
||||
}
|
||||
|
||||
@@ -314,6 +314,18 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
|
||||
_cur_edit = _path;
|
||||
connect(_path, SIGNAL(valueChanged()), this, SLOT(_changed()));
|
||||
}
|
||||
if (!_cur_edit) { // try custom
|
||||
QVariantEditorFactoryBase * f = QVariantEditorFactories::editorFactory(new_value.userType());
|
||||
if (f) {
|
||||
QWidget * fw = f->createEditor();
|
||||
if (fw) {
|
||||
fw->setParent(this);
|
||||
_custom = fw;
|
||||
_cur_edit = _custom;
|
||||
connect(_custom, SIGNAL(valueChanged()), this, SLOT(_changed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//qDebug() << _cur_edit;
|
||||
if (_cur_edit) {
|
||||
@@ -368,6 +380,9 @@ QVariant QVariantEdit::value() const {
|
||||
return QVariant::fromValue<QAD::Dir>(ret);
|
||||
}
|
||||
}
|
||||
if (_custom) {
|
||||
return _custom->property("value");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@@ -390,6 +405,7 @@ void QVariantEdit::setValue(const QVariant & v) {
|
||||
else _setFile(v.value<QAD::File>());
|
||||
}
|
||||
if (_enum) {_setEnum(v.value<QAD::Enum>());}
|
||||
if (_custom) {_setCustom(v);}
|
||||
if (_cur_edit) _cur_edit->blockSignals(false);
|
||||
}
|
||||
|
||||
@@ -398,6 +414,7 @@ void QVariantEdit::_delete() {
|
||||
if (_cur_edit)
|
||||
delete _cur_edit;
|
||||
_cur_edit = 0;
|
||||
_custom = 0;
|
||||
_empty = 0;
|
||||
_line = 0;
|
||||
_check = 0;
|
||||
@@ -460,6 +477,12 @@ void QVariantEdit::_setDir(const QAD::Dir & v) {
|
||||
_path->is_abs = v.is_abs;
|
||||
}
|
||||
|
||||
|
||||
void QVariantEdit::_setCustom(const QVariant & v) {
|
||||
_custom->setProperty("value", v);
|
||||
}
|
||||
|
||||
|
||||
void QVariantEdit::_changed() {
|
||||
if (_check) _check->setText(_check->isChecked() ? "true" : "false");
|
||||
emit valueChanged(value());
|
||||
|
||||
Reference in New Issue
Block a user