+ fixes #0001038: Improve and show List properties in Tree View
This commit is contained in:
parent
78f07f8731
commit
6e5118c9c8
|
@ -287,6 +287,8 @@ public:
|
|||
void setValues (const std::vector<long>& values);
|
||||
|
||||
const std::vector<long> &getValues(void) const{return _lValueList;}
|
||||
virtual const char* getEditorName(void) const
|
||||
{ return "Gui::PropertyEditor::PropertyIntegerListItem"; }
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual void setPyObject(PyObject *);
|
||||
|
@ -535,7 +537,10 @@ public:
|
|||
void setValues (const std::vector<double>& values);
|
||||
|
||||
const std::vector<double> &getValues(void) const{return _lValueList;}
|
||||
|
||||
|
||||
virtual const char* getEditorName(void) const
|
||||
{ return "Gui::PropertyEditor::PropertyFloatListItem"; }
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual void setPyObject(PyObject *);
|
||||
|
||||
|
@ -688,7 +693,8 @@ public:
|
|||
|
||||
const std::vector<std::string> &getValues(void) const{return _lValueList;}
|
||||
|
||||
virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyStringListItem"; }
|
||||
virtual const char* getEditorName(void) const
|
||||
{ return "Gui::PropertyEditor::PropertyStringListItem"; }
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual void setPyObject(PyObject *);
|
||||
|
|
|
@ -120,6 +120,8 @@ void Gui::SoFCDB::init()
|
|||
PropertyPlacementItem ::init();
|
||||
PropertyEnumItem ::init();
|
||||
PropertyStringListItem ::init();
|
||||
PropertyFloatListItem ::init();
|
||||
PropertyIntegerListItem ::init();
|
||||
PropertyColorItem ::init();
|
||||
PropertyFileItem ::init();
|
||||
PropertyPathItem ::init();
|
||||
|
|
|
@ -1021,7 +1021,7 @@ void LabelEditor::changeText()
|
|||
QDialog dlg(this);
|
||||
QVBoxLayout* hboxLayout = new QVBoxLayout(&dlg);
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(&dlg);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Close);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
QPlainTextEdit *edit = new QPlainTextEdit(&dlg);
|
||||
edit->setPlainText(this->lineEdit->text());
|
||||
|
|
|
@ -1841,6 +1841,140 @@ void PropertyStringListItem::setValue(const QVariant& value)
|
|||
setPropertyValue(data);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyFloatListItem, Gui::PropertyEditor::PropertyItem);
|
||||
|
||||
PropertyFloatListItem::PropertyFloatListItem()
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* PropertyFloatListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const
|
||||
{
|
||||
Gui::LabelEditor* le = new Gui::LabelEditor(parent);
|
||||
le->setAutoFillBackground(true);
|
||||
QObject::connect(le, SIGNAL(textChanged(const QString&)), receiver, method);
|
||||
return le;
|
||||
}
|
||||
|
||||
void PropertyFloatListItem::setEditorData(QWidget *editor, const QVariant& data) const
|
||||
{
|
||||
Gui::LabelEditor *le = qobject_cast<Gui::LabelEditor*>(editor);
|
||||
QStringList list = data.toStringList();
|
||||
le->setText(list.join(QChar::fromAscii('\n')));
|
||||
}
|
||||
|
||||
QVariant PropertyFloatListItem::editorData(QWidget *editor) const
|
||||
{
|
||||
Gui::LabelEditor *le = qobject_cast<Gui::LabelEditor*>(editor);
|
||||
QString complete = le->text();
|
||||
QStringList list = complete.split(QChar::fromAscii('\n'));
|
||||
return QVariant(list);
|
||||
}
|
||||
|
||||
QVariant PropertyFloatListItem::toString(const QVariant& prop) const
|
||||
{
|
||||
QStringList list = prop.toStringList();
|
||||
QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(",")));
|
||||
|
||||
return QVariant(text);
|
||||
}
|
||||
|
||||
QVariant PropertyFloatListItem::value(const App::Property* prop) const
|
||||
{
|
||||
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloatList::getClassTypeId()));
|
||||
|
||||
QStringList list;
|
||||
const std::vector<double>& value = static_cast<const App::PropertyFloatList*>(prop)->getValues();
|
||||
for (std::vector<double>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
|
||||
list << QString::number(*jt);
|
||||
}
|
||||
|
||||
return QVariant(list);
|
||||
}
|
||||
|
||||
void PropertyFloatListItem::setValue(const QVariant& value)
|
||||
{
|
||||
if (!value.canConvert(QVariant::StringList))
|
||||
return;
|
||||
QStringList values = value.toStringList();
|
||||
QString data;
|
||||
QTextStream str(&data);
|
||||
str << "[";
|
||||
for (QStringList::Iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str << *it << ",";
|
||||
}
|
||||
str << "]";
|
||||
setPropertyValue(data);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyIntegerListItem, Gui::PropertyEditor::PropertyItem);
|
||||
|
||||
PropertyIntegerListItem::PropertyIntegerListItem()
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* PropertyIntegerListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const
|
||||
{
|
||||
Gui::LabelEditor* le = new Gui::LabelEditor(parent);
|
||||
le->setAutoFillBackground(true);
|
||||
QObject::connect(le, SIGNAL(textChanged(const QString&)), receiver, method);
|
||||
return le;
|
||||
}
|
||||
|
||||
void PropertyIntegerListItem::setEditorData(QWidget *editor, const QVariant& data) const
|
||||
{
|
||||
Gui::LabelEditor *le = qobject_cast<Gui::LabelEditor*>(editor);
|
||||
QStringList list = data.toStringList();
|
||||
le->setText(list.join(QChar::fromAscii('\n')));
|
||||
}
|
||||
|
||||
QVariant PropertyIntegerListItem::editorData(QWidget *editor) const
|
||||
{
|
||||
Gui::LabelEditor *le = qobject_cast<Gui::LabelEditor*>(editor);
|
||||
QString complete = le->text();
|
||||
QStringList list = complete.split(QChar::fromAscii('\n'));
|
||||
return QVariant(list);
|
||||
}
|
||||
|
||||
QVariant PropertyIntegerListItem::toString(const QVariant& prop) const
|
||||
{
|
||||
QStringList list = prop.toStringList();
|
||||
QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(",")));
|
||||
|
||||
return QVariant(text);
|
||||
}
|
||||
|
||||
QVariant PropertyIntegerListItem::value(const App::Property* prop) const
|
||||
{
|
||||
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyIntegerList::getClassTypeId()));
|
||||
|
||||
QStringList list;
|
||||
const std::vector<long>& value = static_cast<const App::PropertyIntegerList*>(prop)->getValues();
|
||||
for (std::vector<long>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
|
||||
list << QString::number(*jt);
|
||||
}
|
||||
|
||||
return QVariant(list);
|
||||
}
|
||||
|
||||
void PropertyIntegerListItem::setValue(const QVariant& value)
|
||||
{
|
||||
if (!value.canConvert(QVariant::StringList))
|
||||
return;
|
||||
QStringList values = value.toStringList();
|
||||
QString data;
|
||||
QTextStream str(&data);
|
||||
str << "[";
|
||||
for (QStringList::Iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str << *it << ",";
|
||||
}
|
||||
str << "]";
|
||||
setPropertyValue(data);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyColorItem, Gui::PropertyEditor::PropertyItem);
|
||||
|
|
|
@ -559,7 +559,7 @@ protected:
|
|||
};
|
||||
|
||||
/**
|
||||
* Edit properties of enum type.
|
||||
* Edit properties of string list type.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport PropertyStringListItem: public PropertyItem
|
||||
|
@ -579,6 +579,48 @@ protected:
|
|||
PropertyStringListItem();
|
||||
};
|
||||
|
||||
/**
|
||||
* Edit properties of float list type.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport PropertyFloatListItem: public PropertyItem
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
|
||||
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
|
||||
virtual QVariant editorData(QWidget *editor) const;
|
||||
|
||||
protected:
|
||||
QVariant toString(const QVariant&) const;
|
||||
virtual QVariant value(const App::Property*) const;
|
||||
virtual void setValue(const QVariant&);
|
||||
|
||||
protected:
|
||||
PropertyFloatListItem();
|
||||
};
|
||||
|
||||
/**
|
||||
* Edit properties of float list type.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport PropertyIntegerListItem: public PropertyItem
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
|
||||
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
|
||||
virtual QVariant editorData(QWidget *editor) const;
|
||||
|
||||
protected:
|
||||
QVariant toString(const QVariant&) const;
|
||||
virtual QVariant value(const App::Property*) const;
|
||||
virtual void setValue(const QVariant&);
|
||||
|
||||
protected:
|
||||
PropertyIntegerListItem();
|
||||
};
|
||||
|
||||
/**
|
||||
* Change a color property.
|
||||
* \author Werner Mayer
|
||||
|
|
Loading…
Reference in New Issue
Block a user