Vera++.
--HG-- branch : develop
This commit is contained in:
parent
9a735b29bf
commit
1d4f0a6a55
|
@ -40,8 +40,8 @@ VFormula::VFormula()
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VFormula::VFormula(const QString &formula, const VContainer *container)
|
VFormula::VFormula(const QString &formula, const VContainer *container)
|
||||||
:formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container), toolId(NULL_ID),
|
:formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container),
|
||||||
postfix(QStringLiteral("")), _error(true), dValue(0)
|
toolId(NULL_ID), postfix(QStringLiteral("")), _error(true), dValue(0)
|
||||||
{
|
{
|
||||||
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
||||||
Eval();
|
Eval();
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
|
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
|
||||||
:DialogTool(data, NULL_ID, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0), m(nullptr)
|
:DialogTool(data, NULL_ID, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0),
|
||||||
|
m(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -393,4 +393,3 @@ void VToolBisector::setFirstPointId(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,4 +338,3 @@ void VToolHeight::setP1LineId(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,4 +397,3 @@ void VToolLineIntersect::setP1Line1(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,4 +353,3 @@ void VToolNormal::ShowVisualization(bool show)
|
||||||
vis = nullptr;
|
vis = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,4 +397,3 @@ void VToolShoulderPoint::setP2Line(const quint32 &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,8 +112,3 @@ void VisToolSpline::setKCurve(const qreal &value)
|
||||||
{
|
{
|
||||||
kCurve = value;
|
kCurve = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,18 +63,26 @@ VFormulaProperty::VFormulaProperty(const QString &name) :
|
||||||
QVariant VFormulaProperty::data (int column, int role) const
|
QVariant VFormulaProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return getValue();
|
return getValue();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Qt::ItemFlags VFormulaProperty::flags(int column) const
|
Qt::ItemFlags VFormulaProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Name || column == DPC_Data)
|
if (column == DPC_Name || column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
|
@ -132,12 +140,15 @@ QString VFormulaProperty::type() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const
|
VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const
|
||||||
{
|
{
|
||||||
if(!container) {
|
if (!container)
|
||||||
|
{
|
||||||
container = new VFormulaProperty(getName());
|
container = new VFormulaProperty(getName());
|
||||||
|
|
||||||
if(!include_children) {
|
if (!include_children)
|
||||||
|
{
|
||||||
QList<VProperty*> tmpChildren = container->getChildren();
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
foreach(VProperty* tmpChild, tmpChildren) {
|
foreach (VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
container->removeChild(tmpChild);
|
container->removeChild(tmpChild);
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +185,9 @@ VFormula VFormulaProperty::getFormula() const
|
||||||
void VFormulaProperty::setFormula(const VFormula &formula)
|
void VFormulaProperty::setFormula(const VFormula &formula)
|
||||||
{
|
{
|
||||||
if (d_ptr->Children.count() < 2)
|
if (d_ptr->Children.count() < 2)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant value;
|
QVariant value;
|
||||||
value.setValue(formula);
|
value.setValue(formula);
|
||||||
|
|
|
@ -33,9 +33,7 @@
|
||||||
|
|
||||||
class VFormula;
|
class VFormula;
|
||||||
|
|
||||||
using namespace VPE;
|
class VFormulaProperty : public VPE::VProperty
|
||||||
|
|
||||||
class VFormulaProperty : public VProperty
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -50,8 +48,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -64,7 +64,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -267,4 +267,3 @@ void VMainGraphicsView::setShowToolOptions(bool value)
|
||||||
{
|
{
|
||||||
showToolOptions = value;
|
showToolOptions = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,6 @@ class QGraphicsItem;
|
||||||
class QScrollArea;
|
class QScrollArea;
|
||||||
class VFormula;
|
class VFormula;
|
||||||
|
|
||||||
using namespace VPE;
|
|
||||||
|
|
||||||
class VToolOptionsPropertyBrowser : public QObject
|
class VToolOptionsPropertyBrowser : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -50,19 +48,19 @@ public:
|
||||||
VToolOptionsPropertyBrowser(QDockWidget *parent);
|
VToolOptionsPropertyBrowser(QDockWidget *parent);
|
||||||
public slots:
|
public slots:
|
||||||
void itemClicked(QGraphicsItem *item);
|
void itemClicked(QGraphicsItem *item);
|
||||||
void userChangedData(VProperty* property);
|
void userChangedData(VPE::VProperty* property);
|
||||||
void UpdateOptions();
|
void UpdateOptions();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolOptionsPropertyBrowser)
|
Q_DISABLE_COPY(VToolOptionsPropertyBrowser)
|
||||||
|
|
||||||
VPropertyModel* PropertyModel;
|
VPE::VPropertyModel* PropertyModel;
|
||||||
VPropertyFormView* formView;
|
VPE::VPropertyFormView* formView;
|
||||||
|
|
||||||
QGraphicsItem *currentItem;
|
QGraphicsItem *currentItem;
|
||||||
QMap<VProperty *, QString> propertyToId;
|
QMap<VPE::VProperty *, QString> propertyToId;
|
||||||
QMap<QString, VProperty *> idToProperty;
|
QMap<QString, VPE::VProperty *> idToProperty;
|
||||||
|
|
||||||
void AddProperty(VProperty *property, const QString &id);
|
void AddProperty(VPE::VProperty *property, const QString &id);
|
||||||
void ShowItemOptions(QGraphicsItem *item);
|
void ShowItemOptions(QGraphicsItem *item);
|
||||||
|
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
|
@ -78,24 +76,24 @@ private:
|
||||||
|
|
||||||
QStringList PropertiesList() const;
|
QStringList PropertiesList() const;
|
||||||
|
|
||||||
void ChangeDataToolSinglePoint(VProperty *property);
|
void ChangeDataToolSinglePoint(VPE::VProperty *property);
|
||||||
void ChangeDataToolEndLine(VProperty *property);
|
void ChangeDataToolEndLine(VPE::VProperty *property);
|
||||||
void ChangeDataToolAlongLine(VProperty *property);
|
void ChangeDataToolAlongLine(VPE::VProperty *property);
|
||||||
void ChangeDataToolArc(VProperty *property);
|
void ChangeDataToolArc(VPE::VProperty *property);
|
||||||
void ChangeDataToolBisector(VProperty *property);
|
void ChangeDataToolBisector(VPE::VProperty *property);
|
||||||
void ChangeDataToolCutArc(VProperty *property);
|
void ChangeDataToolCutArc(VPE::VProperty *property);
|
||||||
void ChangeDataToolCutSpline(VProperty *property);
|
void ChangeDataToolCutSpline(VPE::VProperty *property);
|
||||||
void ChangeDataToolCutSplinePath(VProperty *property);
|
void ChangeDataToolCutSplinePath(VPE::VProperty *property);
|
||||||
void ChangeDataToolHeight(VProperty *property);
|
void ChangeDataToolHeight(VPE::VProperty *property);
|
||||||
void ChangeDataToolLine(VProperty *property);
|
void ChangeDataToolLine(VPE::VProperty *property);
|
||||||
void ChangeDataToolLineIntersect(VProperty *property);
|
void ChangeDataToolLineIntersect(VPE::VProperty *property);
|
||||||
void ChangeDataToolNormal(VProperty *property);
|
void ChangeDataToolNormal(VPE::VProperty *property);
|
||||||
void ChangeDataToolPointOfContact(VProperty *property);
|
void ChangeDataToolPointOfContact(VPE::VProperty *property);
|
||||||
void ChangeDataToolPointOfIntersection(VProperty *property);
|
void ChangeDataToolPointOfIntersection(VPE::VProperty *property);
|
||||||
void ChangeDataToolShoulderPoint(VProperty *property);
|
void ChangeDataToolShoulderPoint(VPE::VProperty *property);
|
||||||
void ChangeDataToolSpline(VProperty *property);
|
void ChangeDataToolSpline(VPE::VProperty *property);
|
||||||
void ChangeDataToolSplinePath(VProperty *property);
|
void ChangeDataToolSplinePath(VPE::VProperty *property);
|
||||||
void ChangeDataToolTriangle(VProperty *property);
|
void ChangeDataToolTriangle(VPE::VProperty *property);
|
||||||
|
|
||||||
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
||||||
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
||||||
|
|
|
@ -55,7 +55,9 @@ QVariant QVector3DProperty::data (int column, int role) const
|
||||||
Qt::ItemFlags QVector3DProperty::flags(int column) const
|
Qt::ItemFlags QVector3DProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Name || column == DPC_Data)
|
if (column == DPC_Name || column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +69,9 @@ Vector3D QVector3DProperty::getVector() const
|
||||||
Vector3D tmpVect;
|
Vector3D tmpVect;
|
||||||
|
|
||||||
if (d_ptr->Children.count() < 3)
|
if (d_ptr->Children.count() < 3)
|
||||||
|
{
|
||||||
return tmpVect;
|
return tmpVect;
|
||||||
|
}
|
||||||
|
|
||||||
tmpVect.X = d_ptr->Children.at(0)->getValue().toFloat();
|
tmpVect.X = d_ptr->Children.at(0)->getValue().toFloat();
|
||||||
tmpVect.Y = d_ptr->Children.at(1)->getValue().toFloat();
|
tmpVect.Y = d_ptr->Children.at(1)->getValue().toFloat();
|
||||||
|
@ -85,7 +89,9 @@ void QVector3DProperty::setVector(const Vector3D &vect)
|
||||||
void QVector3DProperty::setVector(float x, float y, float z)
|
void QVector3DProperty::setVector(float x, float y, float z)
|
||||||
{
|
{
|
||||||
if (d_ptr->Children.count() < 3)
|
if (d_ptr->Children.count() < 3)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant tmpX(x); tmpX.convert(QVariant::Double);
|
QVariant tmpX(x); tmpX.convert(QVariant::Double);
|
||||||
QVariant tmpY(y); tmpY.convert(QVariant::Double);
|
QVariant tmpY(y); tmpY.convert(QVariant::Double);
|
||||||
|
@ -102,12 +108,15 @@ QString QVector3DProperty::type() const
|
||||||
|
|
||||||
VProperty* QVector3DProperty::clone(bool include_children, VProperty* container) const
|
VProperty* QVector3DProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
if(!container) {
|
if (!container)
|
||||||
|
{
|
||||||
container = new QVector3DProperty(getName());
|
container = new QVector3DProperty(getName());
|
||||||
|
|
||||||
if(!include_children) {
|
if (!include_children)
|
||||||
|
{
|
||||||
QList<VProperty*> tmpChildren = container->getChildren();
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
foreach(VProperty* tmpChild, tmpChildren) {
|
foreach (VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
container->removeChild(tmpChild);
|
container->removeChild(tmpChild);
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +129,8 @@ VProperty* QVector3DProperty::clone(bool include_children, VProperty* container)
|
||||||
void QVector3DProperty::setValue(const QVariant &value)
|
void QVector3DProperty::setValue(const QVariant &value)
|
||||||
{
|
{
|
||||||
QStringList tmpStrings = value.toString().split(",");
|
QStringList tmpStrings = value.toString().split(",");
|
||||||
if(tmpStrings.count() == 3) {
|
if (tmpStrings.count() == 3)
|
||||||
|
{
|
||||||
setVector(tmpStrings[0].toDouble(), tmpStrings[1].toDouble(), tmpStrings[2].toDouble());
|
setVector(tmpStrings[0].toDouble(), tmpStrings[1].toDouble(), tmpStrings[2].toDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D
|
struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D
|
||||||
{
|
{
|
||||||
|
@ -80,7 +81,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,14 @@ VBoolProperty::VBoolProperty(const QString& name) :
|
||||||
d_ptr->VariantValue.convert(QVariant::Bool);
|
d_ptr->VariantValue.convert(QVariant::Bool);
|
||||||
|
|
||||||
// I'm not sure, how Qt handles the translations...
|
// I'm not sure, how Qt handles the translations...
|
||||||
if(TrueText.isNull()) TrueText = QObject::tr("True");
|
if (TrueText.isNull())
|
||||||
if(TrueText.isNull()) FalseText = QObject::tr("False");
|
{
|
||||||
|
TrueText = QObject::tr("True");
|
||||||
|
}
|
||||||
|
if (TrueText.isNull())
|
||||||
|
{
|
||||||
|
FalseText = QObject::tr("False");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,9 +56,13 @@ VBoolProperty::VBoolProperty(const QString& name) :
|
||||||
QVariant VBoolProperty::data (int column, int role) const
|
QVariant VBoolProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return d_ptr->VariantValue.toBool() ? TrueText : FalseText;
|
return d_ptr->VariantValue.toBool() ? TrueText : FalseText;
|
||||||
|
}
|
||||||
if (column == DPC_Data && Qt::CheckStateRole == role)
|
if (column == DPC_Data && Qt::CheckStateRole == role)
|
||||||
|
{
|
||||||
return d_ptr->VariantValue.toBool() ? Qt::Checked : Qt::Unchecked;
|
return d_ptr->VariantValue.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +71,8 @@ bool VBoolProperty::setData(const QVariant &data, int role)
|
||||||
{
|
{
|
||||||
if (Qt::CheckStateRole == role)
|
if (Qt::CheckStateRole == role)
|
||||||
{
|
{
|
||||||
d_ptr->VariantValue = (Qt::Checked == static_cast<Qt::CheckState>(data.toInt())); return true;
|
d_ptr->VariantValue = (Qt::Checked == static_cast<Qt::CheckState>(data.toInt()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -71,7 +82,9 @@ bool VBoolProperty::setData(const QVariant &data, int role)
|
||||||
Qt::ItemFlags VBoolProperty::flags(int column) const
|
Qt::ItemFlags VBoolProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Data)
|
if (column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::flags(column);
|
return VProperty::flags(column);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
//! The VBoolProperty can take two states: True or False.
|
//! The VBoolProperty can take two states: True or False.
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VBoolProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VBoolProperty : public VProperty
|
||||||
|
@ -52,7 +53,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -35,17 +35,24 @@ VColorProperty::VColorProperty(const QString &name) :
|
||||||
QVariant VColorProperty::data (int column, int role) const
|
QVariant VColorProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Data && (Qt::DisplayRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role))
|
||||||
|
{
|
||||||
return VColorPropertyEditor::getColorString(d_ptr->VariantValue.value<QColor>());
|
return VColorPropertyEditor::getColorString(d_ptr->VariantValue.value<QColor>());
|
||||||
|
}
|
||||||
else if (Qt::EditRole == role)
|
else if (Qt::EditRole == role)
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
else if (column == DPC_Data && (Qt::DecorationRole == role))
|
else if (column == DPC_Data && (Qt::DecorationRole == role))
|
||||||
|
{
|
||||||
return VColorPropertyEditor::getColorPixmap(d_ptr->VariantValue.value<QColor>());
|
return VColorPropertyEditor::getColorPixmap(d_ptr->VariantValue.value<QColor>());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
@ -60,7 +67,9 @@ bool VColorProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
||||||
if (tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
tmpWidget->setColor(d_ptr->VariantValue.value<QColor>());
|
tmpWidget->setColor(d_ptr->VariantValue.value<QColor>());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -72,7 +81,9 @@ QVariant VColorProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
VColorPropertyEditor* tmpWidget = qobject_cast<VColorPropertyEditor*>(editor);
|
||||||
if (tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
return tmpWidget->getColor();
|
return tmpWidget->getColor();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -39,8 +40,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -53,7 +56,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,8 @@ void VColorPropertyEditor::onToolButtonClicked()
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QRgb oldRgba = Color.rgba();
|
QRgb oldRgba = Color.rgba();
|
||||||
QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this);
|
QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this);
|
||||||
if (ok && newRgba != oldRgba) {
|
if (ok && newRgba != oldRgba)
|
||||||
|
{
|
||||||
setColor(QColor::fromRgba(newRgba));
|
setColor(QColor::fromRgba(newRgba));
|
||||||
emit dataChangedByUser(Color, this);
|
emit dataChangedByUser(Color, this);
|
||||||
UserChangeEvent *event = new UserChangeEvent();
|
UserChangeEvent *event = new UserChangeEvent();
|
||||||
|
@ -127,8 +128,6 @@ VColorPropertyEditor::~VColorPropertyEditor()
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QColor VColorPropertyEditor::getColor()
|
QColor VColorPropertyEditor::getColor()
|
||||||
{
|
{
|
||||||
return Color;
|
return Color;
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,17 +43,24 @@ VEmptyProperty::~VEmptyProperty()
|
||||||
QVariant VEmptyProperty::data (int column, int role) const
|
QVariant VEmptyProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
else if (role == Qt::BackgroundRole)
|
else if (role == Qt::BackgroundRole)
|
||||||
|
{
|
||||||
return QBrush(QColor(217, 217, 217));
|
return QBrush(QColor(217, 217, 217));
|
||||||
|
}
|
||||||
else if (role == Qt::FontRole)
|
else if (role == Qt::FontRole)
|
||||||
{ QFont tmpFont; tmpFont.setBold(true); return tmpFont; }
|
{
|
||||||
|
QFont tmpFont; tmpFont.setBold(true); return tmpFont;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VEmptyProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VEmptyProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -40,8 +41,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -54,7 +57,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -38,24 +38,33 @@ VEnumProperty::VEnumProperty(const QString& name)
|
||||||
QVariant VEnumProperty::data (int column, int role) const
|
QVariant VEnumProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (EnumerationLiterals.empty())
|
if (EnumerationLiterals.empty())
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
int tmpIndex = VProperty::d_ptr->VariantValue.toInt();
|
int tmpIndex = VProperty::d_ptr->VariantValue.toInt();
|
||||||
|
|
||||||
if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
||||||
|
{
|
||||||
tmpIndex = 0;
|
tmpIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (column == DPC_Data && Qt::DisplayRole == role)
|
if (column == DPC_Data && Qt::DisplayRole == role)
|
||||||
|
{
|
||||||
return EnumerationLiterals.at(tmpIndex);
|
return EnumerationLiterals.at(tmpIndex);
|
||||||
|
}
|
||||||
else if (column == DPC_Data && Qt::EditRole == role)
|
else if (column == DPC_Data && Qt::EditRole == role)
|
||||||
|
{
|
||||||
return tmpIndex;
|
return tmpIndex;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
@ -75,7 +84,9 @@ QVariant VEnumProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
||||||
if (tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->currentIndex();
|
return tmpEditor->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +109,9 @@ void VEnumProperty::setValue(const QVariant& value)
|
||||||
int tmpIndex = value.toInt();
|
int tmpIndex = value.toInt();
|
||||||
|
|
||||||
if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
|
||||||
|
{
|
||||||
tmpIndex = 0;
|
tmpIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
VProperty::d_ptr->VariantValue = tmpIndex;
|
VProperty::d_ptr->VariantValue = tmpIndex;
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
||||||
|
@ -122,13 +135,17 @@ VProperty* VEnumProperty::clone(bool include_children, VProperty* container) con
|
||||||
void VEnumProperty::setSetting(const QString& key, const QVariant& value)
|
void VEnumProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (key == "literals")
|
if (key == "literals")
|
||||||
|
{
|
||||||
setLiterals(value.toString().split(";;"));
|
setLiterals(value.toString().split(";;"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant VEnumProperty::getSetting(const QString& key) const
|
QVariant VEnumProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if (key == "literals")
|
if (key == "literals")
|
||||||
|
{
|
||||||
return getLiterals().join(";;");
|
return getLiterals().join(";;");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -43,8 +44,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -63,7 +66,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
@ -84,7 +88,8 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
//! The list of possible options to choose frome
|
//! The list of possible options to choose frome
|
||||||
QStringList EnumerationLiterals;
|
QStringList EnumerationLiterals;
|
||||||
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other members by reimplementing the VPropertyPrivate class without touching this header file.
|
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
|
||||||
|
//members by reimplementing the VPropertyPrivate class without touching this header file.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,13 +76,17 @@ QVariant VFileProperty::data (int column, int role) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
|
|
||||||
VFileEditWidget* tmpWidget = new VFileEditWidget(parent);
|
VFileEditWidget* tmpWidget = new VFileEditWidget(parent);
|
||||||
if (delegate)
|
if (delegate)
|
||||||
|
{
|
||||||
VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
||||||
|
|
||||||
|
}
|
||||||
tmpWidget->setFilter(static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters); // todo: parse this string
|
tmpWidget->setFilter(static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters); // todo: parse this string
|
||||||
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
||||||
tmpWidget->setDirectory(static_cast<VFilePropertyPrivate*>(d_ptr)->Directory);
|
tmpWidget->setDirectory(static_cast<VFilePropertyPrivate*>(d_ptr)->Directory);
|
||||||
|
@ -94,7 +98,9 @@ bool VFileProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
||||||
if (tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
tmpWidget->setFile(d_ptr->VariantValue.toString());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -106,7 +112,9 @@ QVariant VFileProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
VFileEditWidget* tmpWidget = qobject_cast<VFileEditWidget*>(editor);
|
||||||
if (tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
return tmpWidget->getFile();
|
return tmpWidget->getFile();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -114,17 +122,25 @@ QVariant VFileProperty::getEditorData(QWidget* editor) const
|
||||||
void VFileProperty::setSetting(const QString& key, const QVariant& value)
|
void VFileProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (key == "FileFilters")
|
if (key == "FileFilters")
|
||||||
|
{
|
||||||
setFileFilters(value.toString());
|
setFileFilters(value.toString());
|
||||||
|
}
|
||||||
else if (key == "Directory")
|
else if (key == "Directory")
|
||||||
|
{
|
||||||
setDirectory(value.toBool());
|
setDirectory(value.toBool());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant VFileProperty::getSetting(const QString& key) const
|
QVariant VFileProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if (key == "FileFilters")
|
if (key == "FileFilters")
|
||||||
|
{
|
||||||
return getFileFilters();
|
return getFileFilters();
|
||||||
|
}
|
||||||
else if (key == "Directory")
|
else if (key == "Directory")
|
||||||
|
{
|
||||||
return isDirectory();
|
return isDirectory();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -55,8 +56,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -80,7 +83,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,14 @@ QString VFileEditWidget::getFile()
|
||||||
|
|
||||||
void VFileEditWidget::onToolButtonClicked()
|
void VFileEditWidget::onToolButtonClicked()
|
||||||
{
|
{
|
||||||
QString filepath = (Directory ? QFileDialog::getExistingDirectory(0, tr("Directory"), CurrentFilePath) : QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath, FileDialogFilter));
|
QString filepath = (Directory ? QFileDialog::getExistingDirectory(0, tr("Directory"), CurrentFilePath)
|
||||||
if (!filepath.isNull())
|
: QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath,
|
||||||
|
FileDialogFilter));
|
||||||
|
if (filepath.isNull() == false)
|
||||||
|
{
|
||||||
setFile(filepath, true);
|
setFile(filepath, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
|
@ -113,12 +117,18 @@ bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
if (ev->type() == QEvent::DragEnter)
|
if (ev->type() == QEvent::DragEnter)
|
||||||
|
{
|
||||||
dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
|
dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
|
||||||
|
}
|
||||||
else if (ev->type() == QEvent::Drop)
|
else if (ev->type() == QEvent::Drop)
|
||||||
|
{
|
||||||
dropEvent(static_cast<QDropEvent*>(ev));
|
dropEvent(static_cast<QDropEvent*>(ev));
|
||||||
|
}
|
||||||
|
|
||||||
if (ev->isAccepted())
|
if (ev->isAccepted())
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QWidget::eventFilter(obj, ev);
|
return QWidget::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +200,9 @@ bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const
|
||||||
|
|
||||||
foreach(QUrl tmpUrl, tmpUrlList)
|
foreach(QUrl tmpUrl, tmpUrlList)
|
||||||
if (QFile::exists(tmpUrl.toLocalFile()))
|
if (QFile::exists(tmpUrl.toLocalFile()))
|
||||||
{ tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); break; }
|
{
|
||||||
|
tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); break;
|
||||||
|
}
|
||||||
|
|
||||||
if (checkFileFilter(tmpFileInfo.fileName()))
|
if (checkFileFilter(tmpFileInfo.fileName()))
|
||||||
{
|
{
|
||||||
|
@ -205,20 +217,25 @@ bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const
|
||||||
bool VFileEditWidget::checkFileFilter(const QString& file) const
|
bool VFileEditWidget::checkFileFilter(const QString& file) const
|
||||||
{
|
{
|
||||||
if (FilterList.isEmpty())
|
if (FilterList.isEmpty())
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QFileInfo tmpFileInfo(file);
|
QFileInfo tmpFileInfo(file);
|
||||||
|
|
||||||
if ((Directory && !tmpFileInfo.isDir()) || (!Directory && !tmpFileInfo.isFile()))
|
if ((Directory && !tmpFileInfo.isDir()) || (!Directory && !tmpFileInfo.isFile()))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach(QString tmpFilter, FilterList)
|
foreach(QString tmpFilter, FilterList)
|
||||||
{
|
{
|
||||||
QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||||
if (tmpRegExpFilter.exactMatch(file))
|
if (tmpRegExpFilter.exactMatch(file))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
||||||
|
@ -85,8 +86,6 @@ protected:
|
||||||
void dragLeaveEvent(QDragLeaveEvent* event);
|
void dragLeaveEvent(QDragLeaveEvent* event);
|
||||||
void dropEvent(QDropEvent* event);
|
void dropEvent(QDropEvent* event);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! This function checks the mime data, if it is compatible with the filters
|
//! This function checks the mime data, if it is compatible with the filters
|
||||||
virtual bool checkMimeData(const QMimeData* data, QString& getFile) const;
|
virtual bool checkMimeData(const QMimeData* data, QString& getFile) const;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ const int VIntegerProperty::StandardMin = -1000000;
|
||||||
const int VIntegerProperty::StandardMax = 1000000;
|
const int VIntegerProperty::StandardMax = 1000000;
|
||||||
|
|
||||||
VIntegerProperty::VIntegerProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
VIntegerProperty::VIntegerProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
||||||
: VProperty(name, QVariant::Int), min(StandardMin), max(StandardMax), singleStep(1.0)
|
: VProperty(name, QVariant::Int), minValue(StandardMin), maxValue(StandardMax), singleStep(1.0)
|
||||||
{
|
{
|
||||||
VProperty::setSettings(settings);
|
VProperty::setSettings(settings);
|
||||||
VProperty::d_ptr->VariantValue.setValue(0);
|
VProperty::d_ptr->VariantValue.setValue(0);
|
||||||
|
@ -42,21 +42,22 @@ VIntegerProperty::VIntegerProperty(const QString& name, const QMap<QString, QVar
|
||||||
}
|
}
|
||||||
|
|
||||||
VIntegerProperty::VIntegerProperty(const QString &name)
|
VIntegerProperty::VIntegerProperty(const QString &name)
|
||||||
: VProperty(name), min(StandardMin), max(StandardMax)
|
: VProperty(name), minValue(StandardMin), maxValue(StandardMax)
|
||||||
{
|
{
|
||||||
VProperty::d_ptr->VariantValue.setValue(0);
|
VProperty::d_ptr->VariantValue.setValue(0);
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
|
||||||
QSpinBox* tmpEditor = new QSpinBox(parent);
|
QSpinBox* tmpEditor = new QSpinBox(parent);
|
||||||
tmpEditor->setMinimum(min);
|
tmpEditor->setMinimum(minValue);
|
||||||
tmpEditor->setMaximum(max);
|
tmpEditor->setMaximum(maxValue);
|
||||||
tmpEditor->setSingleStep(singleStep);
|
tmpEditor->setSingleStep(singleStep);
|
||||||
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toInt());
|
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toInt());
|
||||||
|
@ -72,36 +73,50 @@ QVariant VIntegerProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QSpinBox* tmpEditor = qobject_cast<QSpinBox*>(editor);
|
QSpinBox* tmpEditor = qobject_cast<QSpinBox*>(editor);
|
||||||
if (tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->value();
|
return tmpEditor->value();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VIntegerProperty::setSettings(int minimum, int maxiumum, int singleStep)
|
void VIntegerProperty::setSettings(int minimum, int maxiumum, int singleStep)
|
||||||
{
|
{
|
||||||
min = minimum;
|
minValue = minimum;
|
||||||
max = maxiumum;
|
maxValue = maxiumum;
|
||||||
this->singleStep = singleStep;
|
this->singleStep = singleStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VIntegerProperty::setSetting(const QString& key, const QVariant& value)
|
void VIntegerProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
setSettings(value.toInt(), max);
|
{
|
||||||
|
setSettings(value.toInt(), maxValue);
|
||||||
|
}
|
||||||
else if (key == QLatin1String("Max"))
|
else if (key == QLatin1String("Max"))
|
||||||
setSettings(min, value.toInt());
|
{
|
||||||
|
setSettings(minValue, value.toInt());
|
||||||
|
}
|
||||||
else if (key == QLatin1String("Step"))
|
else if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
setSettings(singleStep, value.toInt());
|
setSettings(singleStep, value.toInt());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant VIntegerProperty::getSetting(const QString& key) const
|
QVariant VIntegerProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if (key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
return min;
|
{
|
||||||
|
return minValue;
|
||||||
|
}
|
||||||
if (key == QLatin1String("Max"))
|
if (key == QLatin1String("Max"))
|
||||||
return max;
|
{
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
if (key == QLatin1String("Step"))
|
if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
return singleStep;
|
return singleStep;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
@ -128,10 +143,6 @@ void VIntegerProperty::valueChanged(int i)
|
||||||
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const double VDoubleProperty::StandardPrecision = 5;
|
const double VDoubleProperty::StandardPrecision = 5;
|
||||||
|
|
||||||
VDoubleProperty::VDoubleProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
VDoubleProperty::VDoubleProperty(const QString& name, const QMap<QString, QVariant>& settings)
|
||||||
|
@ -152,13 +163,14 @@ VDoubleProperty::VDoubleProperty(const QString &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent);
|
QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent);
|
||||||
tmpEditor->setMinimum(min);
|
tmpEditor->setMinimum(minValue);
|
||||||
tmpEditor->setMaximum(max);
|
tmpEditor->setMaximum(maxValue);
|
||||||
tmpEditor->setDecimals(Precision);
|
tmpEditor->setDecimals(Precision);
|
||||||
tmpEditor->setSingleStep(singleStep);
|
tmpEditor->setSingleStep(singleStep);
|
||||||
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
@ -175,15 +187,17 @@ QVariant VDoubleProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QDoubleSpinBox* tmpEditor = qobject_cast<QDoubleSpinBox*>(editor);
|
QDoubleSpinBox* tmpEditor = qobject_cast<QDoubleSpinBox*>(editor);
|
||||||
if (tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->value();
|
return tmpEditor->value();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDoubleProperty::setSettings(double minimum, double maxiumum, double singleStep, int precision)
|
void VDoubleProperty::setSettings(double minimum, double maxiumum, double singleStep, int precision)
|
||||||
{
|
{
|
||||||
min = minimum;
|
minValue = minimum;
|
||||||
max = maxiumum;
|
maxValue = maxiumum;
|
||||||
this->singleStep = singleStep;
|
this->singleStep = singleStep;
|
||||||
Precision = precision;
|
Precision = precision;
|
||||||
}
|
}
|
||||||
|
@ -191,25 +205,41 @@ void VDoubleProperty::setSettings(double minimum, double maxiumum, double single
|
||||||
void VDoubleProperty::setSetting(const QString& key, const QVariant& value)
|
void VDoubleProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
setSettings(value.toDouble(), max, singleStep, Precision);
|
{
|
||||||
|
setSettings(value.toDouble(), maxValue, singleStep, Precision);
|
||||||
|
}
|
||||||
else if (key == QLatin1String("Max"))
|
else if (key == QLatin1String("Max"))
|
||||||
setSettings(min, value.toDouble(), singleStep, Precision);
|
{
|
||||||
|
setSettings(minValue, value.toDouble(), singleStep, Precision);
|
||||||
|
}
|
||||||
else if (key == QLatin1String("Step"))
|
else if (key == QLatin1String("Step"))
|
||||||
setSettings(min, max, value.toDouble(), Precision);
|
{
|
||||||
|
setSettings(minValue, maxValue, value.toDouble(), Precision);
|
||||||
|
}
|
||||||
else if (key == QLatin1String("Precision"))
|
else if (key == QLatin1String("Precision"))
|
||||||
setSettings(min, max, singleStep, value.toDouble());
|
{
|
||||||
|
setSettings(minValue, maxValue, singleStep, value.toDouble());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VDoubleProperty::getSetting(const QString& key) const
|
QVariant VDoubleProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
if (key == QLatin1String("Min"))
|
if (key == QLatin1String("Min"))
|
||||||
return min;
|
{
|
||||||
|
return minValue;
|
||||||
|
}
|
||||||
if (key == QLatin1String("Max"))
|
if (key == QLatin1String("Max"))
|
||||||
return max;
|
{
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
if (key == QLatin1String("Step"))
|
if (key == QLatin1String("Step"))
|
||||||
|
{
|
||||||
return singleStep;
|
return singleStep;
|
||||||
|
}
|
||||||
if (key == QLatin1String("Precision"))
|
if (key == QLatin1String("Precision"))
|
||||||
|
{
|
||||||
return Precision;
|
return Precision;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
//! Class for holding an integer property
|
//! Class for holding an integer property
|
||||||
|
@ -39,8 +40,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -67,13 +70,14 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
public slots:
|
public slots:
|
||||||
void valueChanged(int i);
|
void valueChanged(int i);
|
||||||
protected:
|
protected:
|
||||||
double min, max, singleStep;
|
double minValue, maxValue, singleStep;
|
||||||
|
|
||||||
static const int StandardMin;// = -1000000;
|
static const int StandardMin;// = -1000000;
|
||||||
static const int StandardMax;// = 1000000;
|
static const int StandardMax;// = 1000000;
|
||||||
|
@ -92,8 +96,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -121,7 +127,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,9 @@ VObjectProperty::VObjectProperty(const QString& name)
|
||||||
QVariant VObjectProperty::data (int column, int role) const
|
QVariant VObjectProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (objects.empty())
|
if (objects.empty())
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(VProperty::d_ptr->editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(VProperty::d_ptr->editor);
|
||||||
|
|
||||||
|
@ -47,7 +49,9 @@ QVariant VObjectProperty::data (int column, int role) const
|
||||||
return VProperty::d_ptr->VariantValue;
|
return VProperty::d_ptr->VariantValue;
|
||||||
}
|
}
|
||||||
else if (column == DPC_Data && Qt::EditRole == role)
|
else if (column == DPC_Data && Qt::EditRole == role)
|
||||||
|
{
|
||||||
return tmpEditor->currentIndex();
|
return tmpEditor->currentIndex();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +76,9 @@ QWidget* VObjectProperty::createEditor(QWidget * parent, const QStyleOptionViewI
|
||||||
bool VObjectProperty::setEditorData(QWidget *editor)
|
bool VObjectProperty::setEditorData(QWidget *editor)
|
||||||
{
|
{
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
||||||
if (tmpEditor)
|
if (tmpEditor)
|
||||||
|
@ -98,7 +104,9 @@ QVariant VObjectProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
|
||||||
if (tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->itemData(tmpEditor->currentIndex());
|
return tmpEditor->itemData(tmpEditor->currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(0);
|
return QVariant(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -45,8 +46,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -68,7 +71,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
@ -80,7 +84,8 @@ protected:
|
||||||
QMap<QString, quint32> objects;
|
QMap<QString, quint32> objects;
|
||||||
|
|
||||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||||
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other members by reimplementing the VPropertyPrivate class without touching this header file.
|
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
|
||||||
|
//members by reimplementing the VPropertyPrivate class without touching this header file.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,9 @@ QVariant VPointFProperty::data(int column, int role) const
|
||||||
Qt::ItemFlags VPointFProperty::flags(int column) const
|
Qt::ItemFlags VPointFProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Name || column == DPC_Data)
|
if (column == DPC_Name || column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +68,9 @@ QPointF VPointFProperty::getPointF() const
|
||||||
QPointF tmpValue;
|
QPointF tmpValue;
|
||||||
|
|
||||||
if (d_ptr->Children.count() < 2)
|
if (d_ptr->Children.count() < 2)
|
||||||
|
{
|
||||||
return tmpValue;
|
return tmpValue;
|
||||||
|
}
|
||||||
|
|
||||||
tmpValue.setX(d_ptr->Children.at(0)->getValue().toDouble());
|
tmpValue.setX(d_ptr->Children.at(0)->getValue().toDouble());
|
||||||
tmpValue.setY(d_ptr->Children.at(1)->getValue().toDouble());
|
tmpValue.setY(d_ptr->Children.at(1)->getValue().toDouble());
|
||||||
|
@ -82,7 +86,9 @@ void VPointFProperty::setPointF(const QPointF &point)
|
||||||
void VPointFProperty::setPointF(qreal x, qreal y)
|
void VPointFProperty::setPointF(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
if (d_ptr->Children.count() < 2)
|
if (d_ptr->Children.count() < 2)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant tmpX(x);
|
QVariant tmpX(x);
|
||||||
tmpX.convert(QVariant::Double);
|
tmpX.convert(QVariant::Double);
|
||||||
|
@ -101,12 +107,15 @@ QString VPointFProperty::type() const
|
||||||
|
|
||||||
VProperty *VPointFProperty::clone(bool include_children, VProperty *container) const
|
VProperty *VPointFProperty::clone(bool include_children, VProperty *container) const
|
||||||
{
|
{
|
||||||
if(!container) {
|
if (!container)
|
||||||
|
{
|
||||||
container = new VPointFProperty(getName());
|
container = new VPointFProperty(getName());
|
||||||
|
|
||||||
if(!include_children) {
|
if (!include_children)
|
||||||
|
{
|
||||||
QList<VProperty*> tmpChildren = container->getChildren();
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
foreach(VProperty* tmpChild, tmpChildren) {
|
foreach(VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
container->removeChild(tmpChild);
|
container->removeChild(tmpChild);
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
@ -54,7 +55,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,9 @@ QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionVie
|
||||||
|
|
||||||
VShortcutEditWidget* tmpWidget = new VShortcutEditWidget(parent);
|
VShortcutEditWidget* tmpWidget = new VShortcutEditWidget(parent);
|
||||||
if (delegate)
|
if (delegate)
|
||||||
|
{
|
||||||
VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
|
||||||
|
}
|
||||||
|
|
||||||
return tmpWidget;
|
return tmpWidget;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -69,7 +71,9 @@ bool VShortcutProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
||||||
if (tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
tmpWidget->setShortcut(d_ptr->VariantValue.toString(), false);
|
tmpWidget->setShortcut(d_ptr->VariantValue.toString(), false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -81,7 +85,9 @@ QVariant VShortcutProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
VShortcutEditWidget* tmpWidget = qobject_cast<VShortcutEditWidget*>(editor);
|
||||||
if (tmpWidget)
|
if (tmpWidget)
|
||||||
|
{
|
||||||
return tmpWidget->getShortcutAsString();
|
return tmpWidget->getShortcutAsString();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -101,4 +107,3 @@ void VShortcutProperty::setValue(const QVariant &value)
|
||||||
{
|
{
|
||||||
VProperty::setValue(QKeySequence::fromString(value.toString()).toString());
|
VProperty::setValue(QKeySequence::fromString(value.toString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
//! This property can be used to handle key shortcuts
|
//! This property can be used to handle key shortcuts
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutProperty : public VProperty
|
||||||
|
@ -41,7 +42,8 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
|
//! slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
const QAbstractItemDelegate* delegate);
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
|
@ -56,7 +58,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,10 @@ VShortcutEditWidget::~VShortcutEditWidget()
|
||||||
|
|
||||||
bool VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event)
|
bool VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if (obj == LineEdit) {
|
if (obj == LineEdit)
|
||||||
if (event->type() == QEvent::KeyPress) {
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
|
|
||||||
int keys = keyEvent->key();
|
int keys = keyEvent->key();
|
||||||
|
@ -83,8 +85,6 @@ QKeySequence VShortcutEditWidget::getShortcut()
|
||||||
return CurrentKeySequence;
|
return CurrentKeySequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal)
|
void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal)
|
||||||
{
|
{
|
||||||
setShortcut(QKeySequence::fromString(shortcut), emit_signal);
|
setShortcut(QKeySequence::fromString(shortcut), emit_signal);
|
||||||
|
@ -92,13 +92,16 @@ void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal)
|
||||||
|
|
||||||
void VShortcutEditWidget::setShortcut(const QKeySequence &shortcut, bool emit_signal)
|
void VShortcutEditWidget::setShortcut(const QKeySequence &shortcut, bool emit_signal)
|
||||||
{
|
{
|
||||||
if(shortcut != CurrentKeySequence) {
|
if (shortcut != CurrentKeySequence)
|
||||||
|
{
|
||||||
CurrentKeySequence = shortcut;
|
CurrentKeySequence = shortcut;
|
||||||
LineEdit->setText(CurrentKeySequence.toString());
|
LineEdit->setText(CurrentKeySequence.toString());
|
||||||
if (emit_signal)
|
if (emit_signal)
|
||||||
|
{
|
||||||
emit dataChangedByUser(CurrentKeySequence, this);
|
emit dataChangedByUser(CurrentKeySequence, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VShortcutEditWidget::onTextEdited(const QString &text)
|
void VShortcutEditWidget::onTextEdited(const QString &text)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget
|
||||||
|
|
|
@ -62,7 +62,9 @@ QVariant VPE::VStringProperty::getEditorData(QWidget *editor) const
|
||||||
{
|
{
|
||||||
QLineEdit* tmpEditor = qobject_cast<QLineEdit*>(editor);
|
QLineEdit* tmpEditor = qobject_cast<QLineEdit*>(editor);
|
||||||
if (tmpEditor)
|
if (tmpEditor)
|
||||||
|
{
|
||||||
return tmpEditor->text();
|
return tmpEditor->text();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant(QStringLiteral(""));
|
return QVariant(QStringLiteral(""));
|
||||||
}
|
}
|
||||||
|
@ -75,17 +77,25 @@ void VPE::VStringProperty::setReadOnly(bool readOnly)
|
||||||
void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value)
|
void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (key == QLatin1String("ReadOnly"))
|
if (key == QLatin1String("ReadOnly"))
|
||||||
|
{
|
||||||
setReadOnly(value.toBool());
|
setReadOnly(value.toBool());
|
||||||
|
}
|
||||||
if (key == QLatin1String("TypeForParent"))
|
if (key == QLatin1String("TypeForParent"))
|
||||||
|
{
|
||||||
setTypeForParent(value.toInt());
|
setTypeForParent(value.toInt());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant VPE::VStringProperty::getSetting(const QString &key) const
|
QVariant VPE::VStringProperty::getSetting(const QString &key) const
|
||||||
{
|
{
|
||||||
if (key == QLatin1String("ReadOnly"))
|
if (key == QLatin1String("ReadOnly"))
|
||||||
|
{
|
||||||
return readOnly;
|
return readOnly;
|
||||||
|
}
|
||||||
else if (key == QLatin1String("TypeForParent"))
|
else if (key == QLatin1String("TypeForParent"))
|
||||||
|
{
|
||||||
return typeForParent;
|
return typeForParent;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
@ -121,4 +131,3 @@ void VStringProperty::setTypeForParent(int value)
|
||||||
{
|
{
|
||||||
typeForParent = value;
|
typeForParent = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
//! Class for holding a string property
|
//! Class for holding a string property
|
||||||
|
@ -38,8 +39,10 @@ public:
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
@ -60,7 +63,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VWidgetProperty::VWidgetProperty(const QString& name, QWidget* widget)
|
VWidgetProperty::VWidgetProperty(const QString& name, QWidget* widget)
|
||||||
: VEmptyProperty(new VWidgetPropertyPrivate(name, QVariant::Invalid, widget))
|
: VEmptyProperty(new VWidgetPropertyPrivate(name, QVariant::Invalid, widget))
|
||||||
{
|
{
|
||||||
|
@ -48,7 +45,9 @@ void VWidgetProperty::setWidget(QWidget* widget)
|
||||||
VWidgetPropertyPrivate* tmpDPtr = static_cast<VWidgetPropertyPrivate*>(d_ptr);
|
VWidgetPropertyPrivate* tmpDPtr = static_cast<VWidgetPropertyPrivate*>(d_ptr);
|
||||||
QWidget* tmpOldWidget = tmpDPtr->Widget.data();
|
QWidget* tmpOldWidget = tmpDPtr->Widget.data();
|
||||||
if (tmpOldWidget)
|
if (tmpOldWidget)
|
||||||
|
{
|
||||||
tmpOldWidget->deleteLater();
|
tmpOldWidget->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
tmpDPtr->Widget = widget;
|
tmpDPtr->Widget = widget;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +60,8 @@ QString VWidgetProperty::type() const
|
||||||
|
|
||||||
VProperty* VWidgetProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VWidgetProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
// todo: This is a tricky one to clone... don't know what would be the best way to do so... Maybe serialize the widget somehow?
|
/* todo: This is a tricky one to clone... don't know what would be the best way to do so... Maybe serialize the
|
||||||
|
* widget somehow?
|
||||||
|
*/
|
||||||
return VProperty::clone(include_children, container ? container : new VWidgetProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VWidgetProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,14 @@
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
// todo: this way, this class doesn't really make sense. What we have to do is pass a widget factory instead of the actual widget!
|
// todo: this way, this class doesn't really make sense. What we have to do is pass a widget factory instead of the
|
||||||
|
// actual widget!
|
||||||
|
|
||||||
//! This property holds a QWidget and displays it, if the view supports that. If not, it will behave like an empty property
|
//! This property holds a QWidget and displays it, if the view supports that. If not, it will behave like an empty
|
||||||
|
//! property
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VWidgetProperty : public VEmptyProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VWidgetProperty : public VEmptyProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -52,7 +55,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,11 @@
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VFilePropertyPrivate : public VPropertyPrivate {
|
class VFilePropertyPrivate : public VPropertyPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! File filters
|
//! File filters
|
||||||
QString FileFilters;
|
QString FileFilters;
|
||||||
|
|
|
@ -63,11 +63,17 @@ QString VProperty::type() const
|
||||||
QVariant VProperty::data (int column, int role) const
|
QVariant VProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Name && Qt::DisplayRole == role)
|
if (column == DPC_Name && Qt::DisplayRole == role)
|
||||||
|
{
|
||||||
return QVariant(d_ptr->Name);
|
return QVariant(d_ptr->Name);
|
||||||
|
}
|
||||||
else if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
else if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||||
|
{
|
||||||
return d_ptr->VariantValue;
|
return d_ptr->VariantValue;
|
||||||
|
}
|
||||||
else if (Qt::ToolTipRole == role)
|
else if (Qt::ToolTipRole == role)
|
||||||
|
{
|
||||||
return QVariant(d_ptr->Description);
|
return QVariant(d_ptr->Description);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +90,8 @@ bool VProperty::setData(const QVariant &data, int role)
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const QAbstractItemDelegate *delegate) const
|
bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index,
|
||||||
|
const QAbstractItemDelegate *delegate) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(painter);
|
Q_UNUSED(painter);
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
|
@ -95,7 +102,8 @@ bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, con
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate)
|
QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
@ -112,11 +120,14 @@ QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& o
|
||||||
bool VProperty::setEditorData(QWidget* editor)
|
bool VProperty::setEditorData(QWidget* editor)
|
||||||
{
|
{
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray n = editor->metaObject()->userProperty().name();
|
QByteArray n = editor->metaObject()->userProperty().name();
|
||||||
|
|
||||||
if (!n.isEmpty()) {
|
if (!n.isEmpty())
|
||||||
|
{
|
||||||
editor->blockSignals(true);
|
editor->blockSignals(true);
|
||||||
editor->setProperty(n, d_ptr->VariantValue);
|
editor->setProperty(n, d_ptr->VariantValue);
|
||||||
editor->blockSignals(false);
|
editor->blockSignals(false);
|
||||||
|
@ -130,12 +141,16 @@ bool VProperty::setEditorData(QWidget* editor)
|
||||||
QVariant VProperty::getEditorData(QWidget* editor) const
|
QVariant VProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray n = editor->metaObject()->userProperty().name();
|
QByteArray n = editor->metaObject()->userProperty().name();
|
||||||
|
|
||||||
if (!n.isEmpty())
|
if (!n.isEmpty())
|
||||||
|
{
|
||||||
return editor->property(n);
|
return editor->property(n);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -144,9 +159,13 @@ QVariant VProperty::getEditorData(QWidget* editor) const
|
||||||
Qt::ItemFlags VProperty::flags(int column) const
|
Qt::ItemFlags VProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
if (column == DPC_Name)
|
if (column == DPC_Name)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else if (column == DPC_Data)
|
else if (column == DPC_Data)
|
||||||
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +181,6 @@ void VProperty::setValue(const QVariant &value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant VProperty::getValue() const
|
QVariant VProperty::getValue() const
|
||||||
{
|
{
|
||||||
return d_ptr->VariantValue;
|
return d_ptr->VariantValue;
|
||||||
|
@ -202,9 +220,6 @@ QString VProperty::getDescription() const
|
||||||
return d_ptr->Description;
|
return d_ptr->Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns a reference to the list of children
|
//! Returns a reference to the list of children
|
||||||
QList<VProperty*>& VProperty::getChildren()
|
QList<VProperty*>& VProperty::getChildren()
|
||||||
{
|
{
|
||||||
|
@ -221,7 +236,9 @@ const QList<VProperty*>& VProperty::getChildren() const
|
||||||
VProperty* VProperty::getChild(int row) const
|
VProperty* VProperty::getChild(int row) const
|
||||||
{
|
{
|
||||||
if (row >= 0 && row < getRowCount())
|
if (row >= 0 && row < getRowCount())
|
||||||
|
{
|
||||||
return d_ptr->Children.at(row);
|
return d_ptr->Children.at(row);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -242,22 +259,30 @@ VProperty* VProperty::getParent() const
|
||||||
void VProperty::setParent(VProperty* parent)
|
void VProperty::setParent(VProperty* parent)
|
||||||
{
|
{
|
||||||
if (d_ptr->Parent == parent)
|
if (d_ptr->Parent == parent)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* oldParent = d_ptr->Parent;
|
VProperty* oldParent = d_ptr->Parent;
|
||||||
d_ptr->Parent = parent;
|
d_ptr->Parent = parent;
|
||||||
|
|
||||||
if (oldParent)
|
if (oldParent)
|
||||||
|
{
|
||||||
oldParent->removeChild(this);
|
oldParent->removeChild(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (d_ptr->Parent && d_ptr->Parent->getChildRow(this) == -1)
|
if (d_ptr->Parent && d_ptr->Parent->getChildRow(this) == -1)
|
||||||
|
{
|
||||||
d_ptr->Parent->addChild(this);
|
d_ptr->Parent->addChild(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int VProperty::addChild(VProperty *child)
|
int VProperty::addChild(VProperty *child)
|
||||||
{
|
{
|
||||||
if (child && child->getParent() != this)
|
if (child && child->getParent() != this)
|
||||||
|
{
|
||||||
child->setParent(this);
|
child->setParent(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!d_ptr->Children.contains(child) && child != nullptr)
|
if (!d_ptr->Children.contains(child) && child != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -276,8 +301,10 @@ void VProperty::removeChild(VProperty* child)
|
||||||
d_ptr->Children.removeAll(child);
|
d_ptr->Children.removeAll(child);
|
||||||
|
|
||||||
if (child && child->getParent() == this)
|
if (child && child->getParent() == this)
|
||||||
|
{
|
||||||
child->setParent(nullptr);
|
child->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Returns the row the child has
|
//! Returns the row the child has
|
||||||
int VProperty::getChildRow(VProperty* child) const
|
int VProperty::getChildRow(VProperty* child) const
|
||||||
|
@ -285,7 +312,6 @@ int VProperty::getChildRow(VProperty* child) const
|
||||||
return d_ptr->Children.indexOf(child);
|
return d_ptr->Children.indexOf(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns whether the views have to update the parent of this property if it changes
|
//! Returns whether the views have to update the parent of this property if it changes
|
||||||
bool VProperty::getUpdateParent() const
|
bool VProperty::getUpdateParent() const
|
||||||
{
|
{
|
||||||
|
@ -309,7 +335,8 @@ void VProperty::setUpdateBehaviour(bool update_parent, bool update_children)
|
||||||
void VProperty::setSettings(const QMap<QString, QVariant>& settings)
|
void VProperty::setSettings(const QMap<QString, QVariant>& settings)
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant>::const_iterator tmpIterator = settings.constBegin();
|
QMap<QString, QVariant>::const_iterator tmpIterator = settings.constBegin();
|
||||||
for (; tmpIterator != settings.constEnd(); ++tmpIterator) {
|
for (; tmpIterator != settings.constEnd(); ++tmpIterator)
|
||||||
|
{
|
||||||
setSetting(tmpIterator.key(), tmpIterator.value());
|
setSetting(tmpIterator.key(), tmpIterator.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +374,9 @@ QStringList VProperty::getSettingKeys() const
|
||||||
VProperty* VProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
if (!container)
|
if (!container)
|
||||||
|
{
|
||||||
container = new VProperty(getName(), d_ptr->PropertyVariantType);
|
container = new VProperty(getName(), d_ptr->PropertyVariantType);
|
||||||
|
}
|
||||||
|
|
||||||
container->setName(getName());
|
container->setName(getName());
|
||||||
container->setDescription(getDescription());
|
container->setDescription(getDescription());
|
||||||
|
@ -356,7 +385,8 @@ VProperty* VProperty::clone(bool include_children, VProperty* container) const
|
||||||
container->setUpdateBehaviour(getUpdateParent(), getUpdateChildren());
|
container->setUpdateBehaviour(getUpdateParent(), getUpdateChildren());
|
||||||
container->setPropertyType(propertyType());
|
container->setPropertyType(propertyType());
|
||||||
|
|
||||||
if(include_children) {
|
if (include_children)
|
||||||
|
{
|
||||||
foreach(VProperty* tmpChild, d_ptr->Children)
|
foreach(VProperty* tmpChild, d_ptr->Children)
|
||||||
container->addChild(tmpChild->clone(true));
|
container->addChild(tmpChild->clone(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
enum class Property : char{Simple, Complex};
|
enum class Property : char{Simple, Complex};
|
||||||
|
|
||||||
|
@ -48,7 +49,8 @@ class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum DPC_DisplayColumn {
|
enum DPC_DisplayColumn
|
||||||
|
{
|
||||||
DPC_Name = 0,
|
DPC_Name = 0,
|
||||||
DPC_Data
|
DPC_Data
|
||||||
};
|
};
|
||||||
|
@ -74,13 +76,16 @@ public:
|
||||||
//! This is called by the delegate when the property value is being drawn.
|
//! This is called by the delegate when the property value is being drawn.
|
||||||
//! The standard implementation doesn't do anything.
|
//! The standard implementation doesn't do anything.
|
||||||
//! If you reimplement this in a sub property, make sure to return true or the delegate will draw the item.
|
//! If you reimplement this in a sub property, make sure to return true or the delegate will draw the item.
|
||||||
virtual bool paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QAbstractItemDelegate* delegate) const;
|
virtual bool paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index,
|
||||||
|
const QAbstractItemDelegate* delegate) const;
|
||||||
|
|
||||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||||
//! \param parent The widget to which the editor will be added as a child
|
//! \param parent The widget to which the editor will be added as a child
|
||||||
//! \options Render options
|
//! \options Render options
|
||||||
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and slots.
|
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
//! slots.
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
|
const QAbstractItemDelegate* delegate);
|
||||||
|
|
||||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||||
virtual bool setEditorData(QWidget* editor);
|
virtual bool setEditorData(QWidget* editor);
|
||||||
|
@ -104,12 +109,15 @@ public:
|
||||||
virtual void deserialize(const QString& value);
|
virtual void deserialize(const QString& value);
|
||||||
|
|
||||||
// The following functions are experimental and not yet implemented.
|
// The following functions are experimental and not yet implemented.
|
||||||
/*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be used.
|
/*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be
|
||||||
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this implementation returns a NULL pointer.
|
//! used.
|
||||||
|
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this
|
||||||
|
//! implementation returns a NULL pointer.
|
||||||
virtual void* getDataPointer();
|
virtual void* getDataPointer();
|
||||||
|
|
||||||
//! Sets the data.
|
//! Sets the data.
|
||||||
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this implementation returns a NULL pointer.
|
//! \return Returns a void pointer to the data. Not all properties have to support this. By default, this
|
||||||
|
//! implementation returns a NULL pointer.
|
||||||
virtual bool setDataPointer(void* pointer);*/
|
virtual bool setDataPointer(void* pointer);*/
|
||||||
|
|
||||||
//! Sets the name of the property
|
//! Sets the name of the property
|
||||||
|
@ -160,7 +168,8 @@ public:
|
||||||
//! Sets whether the views should update Parents or children after this property changes
|
//! Sets whether the views should update Parents or children after this property changes
|
||||||
virtual void setUpdateBehaviour(bool update_parent, bool update_children);
|
virtual void setUpdateBehaviour(bool update_parent, bool update_children);
|
||||||
|
|
||||||
//! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item in the map.
|
//! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item
|
||||||
|
//! in the map.
|
||||||
virtual void setSettings(const QMap<QString, QVariant>& settings);
|
virtual void setSettings(const QMap<QString, QVariant>& settings);
|
||||||
|
|
||||||
//! Get the settings.
|
//! Get the settings.
|
||||||
|
@ -177,7 +186,8 @@ public:
|
||||||
|
|
||||||
//! Clones this property
|
//! Clones this property
|
||||||
//! \param include_children Indicates whether to also clone the children
|
//! \param include_children Indicates whether to also clone the children
|
||||||
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried to fill all the data into container. This can also be used when subclassing this function.
|
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
|
||||||
|
//! to fill all the data into container. This can also be used when subclassing this function.
|
||||||
//! \return Returns the newly created property (or container, if it was not NULL)
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,11 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyPrivate {
|
class VPropertyPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! The property's value.
|
//! The property's value.
|
||||||
//! This does not have to be used by subclasses, but it makes sense in cases where QVariant supports
|
//! This does not have to be used by subclasses, but it makes sense in cases where QVariant supports
|
||||||
|
|
|
@ -38,7 +38,8 @@ VPropertyDelegate::~VPropertyDelegate()
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* VPropertyDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
QWidget* VPropertyDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option,
|
||||||
|
const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
QWidget* tmpWidget = nullptr;
|
QWidget* tmpWidget = nullptr;
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
|
@ -62,8 +63,10 @@ void VPropertyDelegate::setEditorData (QWidget * editor, const QModelIndex & ind
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
|
{
|
||||||
QStyledItemDelegate::setEditorData(editor, index);
|
QStyledItemDelegate::setEditorData(editor, index);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Updates the index data
|
//! Updates the index data
|
||||||
void VPropertyDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
void VPropertyDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
||||||
|
@ -76,7 +79,9 @@ void VPropertyDelegate::setModelData (QWidget * editor, QAbstractItemModel * mod
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpData.isNull())
|
if (tmpData.isNull())
|
||||||
|
{
|
||||||
QStyledItemDelegate::setModelData(editor, model, index);
|
QStyledItemDelegate::setModelData(editor, model, index);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
model->setData(index, tmpData);
|
model->setData(index, tmpData);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +92,9 @@ QSize VPropertyDelegate::sizeHint (const QStyleOptionViewItem& option, const QMo
|
||||||
tmpStandardSizeHint.setHeight(tmpStandardSizeHint.height() + 1);
|
tmpStandardSizeHint.setHeight(tmpStandardSizeHint.height() + 1);
|
||||||
|
|
||||||
if (RowHeight > 0)
|
if (RowHeight > 0)
|
||||||
|
{
|
||||||
return QSize(tmpStandardSizeHint.width(), AddRowHeight ? tmpStandardSizeHint.height() + RowHeight : RowHeight);
|
return QSize(tmpStandardSizeHint.width(), AddRowHeight ? tmpStandardSizeHint.height() + RowHeight : RowHeight);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return tmpStandardSizeHint;
|
return tmpStandardSizeHint;
|
||||||
}
|
}
|
||||||
|
@ -102,10 +109,14 @@ void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
if (index.isValid() && index.column() == 1)
|
if (index.isValid() && index.column() == 1)
|
||||||
|
{
|
||||||
done = reinterpret_cast<VProperty*>(index.internalPointer())->paint(painter, option, index, this);
|
done = reinterpret_cast<VProperty*>(index.internalPointer())->paint(painter, option, index, this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
|
{
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
}
|
||||||
|
|
||||||
QColor tmpPenColor = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
|
QColor tmpPenColor = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
|
||||||
|
|
||||||
|
@ -115,6 +126,3 @@ void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt
|
||||||
painter->drawLine(option.rect.x(), option.rect.bottom(), option.rect.right(), option.rect.bottom());
|
painter->drawLine(option.rect.x(), option.rect.bottom(), option.rect.right(), option.rect.bottom());
|
||||||
painter->setPen(tmpOldPen);
|
painter->setPen(tmpOldPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,8 @@ VPropertyFactoryManager::~VPropertyFactoryManager()
|
||||||
{
|
{
|
||||||
// Delete all factories
|
// Delete all factories
|
||||||
QList<VAbstractPropertyFactory*> tmpFactories = d_ptr->Factories.values();
|
QList<VAbstractPropertyFactory*> tmpFactories = d_ptr->Factories.values();
|
||||||
while(!tmpFactories.isEmpty()) {
|
while (!tmpFactories.isEmpty())
|
||||||
|
{
|
||||||
VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast();
|
VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast();
|
||||||
tmpFactories.removeAll(tmpFactory);
|
tmpFactories.removeAll(tmpFactory);
|
||||||
delete tmpFactory;
|
delete tmpFactory;
|
||||||
|
@ -48,13 +49,17 @@ VPropertyFactoryManager::~VPropertyFactoryManager()
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
if (this == DefaultManager)
|
if (this == DefaultManager)
|
||||||
|
{
|
||||||
DefaultManager = NULL;
|
DefaultManager = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory)
|
void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory)
|
||||||
{
|
{
|
||||||
if (type.isEmpty())
|
if (type.isEmpty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove old factory
|
// Remove old factory
|
||||||
unregisterFactory(getFactory(type), type, true);
|
unregisterFactory(getFactory(type), type, true);
|
||||||
|
@ -62,27 +67,41 @@ void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractProp
|
||||||
d_ptr->Factories[type] = factory;
|
d_ptr->Factories[type] = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type, bool delete_if_unused)
|
void VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type,
|
||||||
|
bool delete_if_unused)
|
||||||
{
|
{
|
||||||
if (!factory)
|
if (!factory)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!type.isEmpty()) {
|
if (!type.isEmpty())
|
||||||
|
{
|
||||||
// Remove all occurances
|
// Remove all occurances
|
||||||
QString tmpKey;
|
QString tmpKey;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
tmpKey = d_ptr->Factories.key(factory, QString());
|
tmpKey = d_ptr->Factories.key(factory, QString());
|
||||||
if(!tmpKey.isEmpty()) d_ptr->Factories.remove(tmpKey);
|
if (!tmpKey.isEmpty())
|
||||||
|
{
|
||||||
|
d_ptr->Factories.remove(tmpKey);
|
||||||
|
}
|
||||||
} while(!tmpKey.isEmpty());
|
} while(!tmpKey.isEmpty());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Only remove one type
|
// Only remove one type
|
||||||
if (d_ptr->Factories.value(type, NULL) == factory)
|
if (d_ptr->Factories.value(type, NULL) == factory)
|
||||||
|
{
|
||||||
d_ptr->Factories.remove(type);
|
d_ptr->Factories.remove(type);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (delete_if_unused && !isRegistered(factory))
|
if (delete_if_unused && !isRegistered(factory))
|
||||||
|
{
|
||||||
delete factory;
|
delete factory;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool VPropertyFactoryManager::isRegistered(VAbstractPropertyFactory* factory)
|
bool VPropertyFactoryManager::isRegistered(VAbstractPropertyFactory* factory)
|
||||||
{
|
{
|
||||||
|
@ -95,27 +114,33 @@ VAbstractPropertyFactory* VPropertyFactoryManager::getFactory(const QString& typ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VProperty* VPropertyFactoryManager::createProperty(const QString& type, const QString& name, const QString& description, const QString &default_value)
|
VProperty* VPropertyFactoryManager::createProperty(const QString& type, const QString& name, const QString& description,
|
||||||
|
const QString &default_value)
|
||||||
{
|
{
|
||||||
VAbstractPropertyFactory* tmpFactory = getFactory(type);
|
VAbstractPropertyFactory* tmpFactory = getFactory(type);
|
||||||
VProperty* tmpResult = NULL;
|
VProperty* tmpResult = NULL;
|
||||||
if(tmpFactory) {
|
if (tmpFactory)
|
||||||
|
{
|
||||||
tmpResult = tmpFactory->createProperty(type, name);
|
tmpResult = tmpFactory->createProperty(type, name);
|
||||||
|
|
||||||
if(tmpResult) {
|
if (tmpResult)
|
||||||
|
{
|
||||||
tmpResult->setDescription(description);
|
tmpResult->setDescription(description);
|
||||||
|
|
||||||
if (!default_value.isEmpty())
|
if (!default_value.isEmpty())
|
||||||
|
{
|
||||||
tmpResult->deserialize(default_value);
|
tmpResult->deserialize(default_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFactoryManager *VPropertyFactoryManager::getDefaultManager()
|
VPropertyFactoryManager *VPropertyFactoryManager::getDefaultManager()
|
||||||
{
|
{
|
||||||
if(!DefaultManager) {
|
if (!DefaultManager)
|
||||||
|
{
|
||||||
DefaultManager = new VPropertyFactoryManager();
|
DefaultManager = new VPropertyFactoryManager();
|
||||||
/*VStandardPropertyFactory* tmpStandardProp = */new VStandardPropertyFactory(DefaultManager);
|
/*VStandardPropertyFactory* tmpStandardProp = */new VStandardPropertyFactory(DefaultManager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VAbstractPropertyFactory;
|
class VAbstractPropertyFactory;
|
||||||
class VPropertyFactoryManagerPrivate;
|
class VPropertyFactoryManagerPrivate;
|
||||||
|
@ -47,8 +48,10 @@ public:
|
||||||
|
|
||||||
//! Removes a factory from the manager.
|
//! Removes a factory from the manager.
|
||||||
//! \param factory The factory to unregister
|
//! \param factory The factory to unregister
|
||||||
//! \param type The type from which to remove the factory. If this is empty, all the types the factory is registered for are being removed
|
//! \param type The type from which to remove the factory. If this is empty, all the types the factory is registered
|
||||||
//! \param delete_if_unused Determines whether the factory should be deleted, if it not used anymore by this manager. Default: true. Otherwise, if the factory is unused by this manager, ownership is being passed on.
|
//! for are being removed
|
||||||
|
//! \param delete_if_unused Determines whether the factory should be deleted, if it not used anymore by this
|
||||||
|
//! manager. Default: true. Otherwise, if the factory is unused by this manager, ownership is being passed on.
|
||||||
void unregisterFactory(VAbstractPropertyFactory* factory, const QString& type = QString(),
|
void unregisterFactory(VAbstractPropertyFactory* factory, const QString& type = QString(),
|
||||||
bool delete_if_unused = true);
|
bool delete_if_unused = true);
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,13 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VAbstractPropertyFactory;
|
class VAbstractPropertyFactory;
|
||||||
|
|
||||||
class VPropertyFactoryManagerPrivate {
|
class VPropertyFactoryManagerPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
QMap<QString, VAbstractPropertyFactory*> Factories;
|
QMap<QString, VAbstractPropertyFactory*> Factories;
|
||||||
|
|
||||||
|
|
|
@ -67,16 +67,21 @@ void VPropertyFormView::setModel(VPropertyModel *model)
|
||||||
|
|
||||||
// Set model
|
// Set model
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = model;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = model;
|
||||||
if(model) {
|
if (model)
|
||||||
|
{
|
||||||
// Set the property list
|
// Set the property list
|
||||||
if (model->getPropertySet())
|
if (model->getPropertySet())
|
||||||
|
{
|
||||||
d_ptr->Properties = model->getPropertySet()->getRootProperties();
|
d_ptr->Properties = model->getPropertySet()->getRootProperties();
|
||||||
|
}
|
||||||
|
|
||||||
// Connect signals // todo: more signals neccesary!!!
|
// Connect signals // todo: more signals neccesary!!!
|
||||||
connect(model, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));
|
connect(model, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));
|
||||||
connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(rowsInserted(QModelIndex,int,int)));
|
connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this,
|
||||||
|
SLOT(rowsInserted(QModelIndex, int, int)));
|
||||||
connect(model, SIGNAL(modelReset()), this, SLOT(modelReset()));
|
connect(model, SIGNAL(modelReset()), this, SLOT(modelReset()));
|
||||||
connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(rowsRemoved(QModelIndex,int,int)));
|
connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this,
|
||||||
|
SLOT(rowsRemoved(QModelIndex, int, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the widget
|
// Build the widget
|
||||||
|
@ -90,7 +95,8 @@ void VPropertyFormView::setPropertySet(VPropertySet* property_set)
|
||||||
|
|
||||||
// Set property set
|
// Set property set
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet = property_set;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet = property_set;
|
||||||
if(property_set) {
|
if (property_set)
|
||||||
|
{
|
||||||
// Set the property list
|
// Set the property list
|
||||||
d_ptr->Properties = property_set->getRootProperties();
|
d_ptr->Properties = property_set->getRootProperties();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +137,9 @@ void VPropertyFormView::modelDestroyed()
|
||||||
void VPropertyFormView::dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right)
|
void VPropertyFormView::dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right)
|
||||||
{
|
{
|
||||||
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal)
|
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// todo: handle data changes
|
// todo: handle data changes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +147,8 @@ void VPropertyFormView::dataSubmitted(VProperty *property)
|
||||||
{
|
{
|
||||||
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
||||||
|
|
||||||
if(tmpModel && d_ptr->UpdateEditors) {
|
if (tmpModel && d_ptr->UpdateEditors)
|
||||||
|
{
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = true;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = true;
|
||||||
tmpModel->onDataChangedByModel(property);
|
tmpModel->onDataChangedByModel(property);
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = false;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = false;
|
||||||
|
@ -150,7 +159,9 @@ void VPropertyFormView::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild)
|
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild)
|
||||||
|
{
|
||||||
build();
|
build();
|
||||||
|
}
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = false;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,21 +171,28 @@ void VPropertyFormView::updatePropertyList()
|
||||||
VPropertySet* tmpSet = static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet;
|
VPropertySet* tmpSet = static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet;
|
||||||
|
|
||||||
if (tmpModel && tmpModel->getPropertySet())
|
if (tmpModel && tmpModel->getPropertySet())
|
||||||
|
{
|
||||||
d_ptr->Properties = tmpModel->getPropertySet()->getRootProperties();
|
d_ptr->Properties = tmpModel->getPropertySet()->getRootProperties();
|
||||||
|
}
|
||||||
else if (tmpSet)
|
else if (tmpSet)
|
||||||
|
{
|
||||||
d_ptr->Properties = tmpSet->getRootProperties();
|
d_ptr->Properties = tmpSet->getRootProperties();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
d_ptr->Properties.clear();
|
d_ptr->Properties.clear();
|
||||||
|
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
|
{
|
||||||
build();
|
build();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = true;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::removeModelAndSet()
|
void VPropertyFormView::removeModelAndSet()
|
||||||
{
|
{
|
||||||
if(static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model) {
|
if (static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model)
|
||||||
|
{
|
||||||
disconnect(static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model, 0, this, 0);
|
disconnect(static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model, 0, this, 0);
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = nullptr;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -187,13 +205,16 @@ void VPropertyFormView::removeModelAndSet()
|
||||||
void VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widget)
|
void VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widget)
|
||||||
{
|
{
|
||||||
if (!widget)
|
if (!widget)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted,
|
connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
QList<VPropertyFormWidget*> tmpList = widget->getChildPropertyFormWidgets();
|
QList<VPropertyFormWidget*> tmpList = widget->getChildPropertyFormWidgets();
|
||||||
|
|
||||||
foreach(VPropertyFormWidget* tmpEditorWidget, tmpList) {
|
foreach(VPropertyFormWidget* tmpEditorWidget, tmpList)
|
||||||
|
{
|
||||||
connectPropertyFormWidget(tmpEditorWidget);
|
connectPropertyFormWidget(tmpEditorWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include "vpropertyformwidget.h"
|
#include "vpropertyformwidget.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
class VPropertyModel;
|
class VPropertyModel;
|
||||||
|
@ -57,7 +58,8 @@ public slots:
|
||||||
//! \param model The model to use
|
//! \param model The model to use
|
||||||
void setModel(VPropertyModel* model);
|
void setModel(VPropertyModel* model);
|
||||||
|
|
||||||
//! Set the property set to use. Note that if using a property set directly, adding and removing properties to the property set leads to undifined behaviour for the property set misses notification signals.
|
//! Set the property set to use. Note that if using a property set directly, adding and removing properties to the
|
||||||
|
//! property set leads to undifined behaviour for the property set misses notification signals.
|
||||||
//! \param model The property set to use
|
//! \param model The property set to use
|
||||||
void setPropertySet(VPropertySet* property_set);
|
void setPropertySet(VPropertySet* property_set);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "vpropertyformwidget_p.h"
|
#include "vpropertyformwidget_p.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyModel;
|
class VPropertyModel;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &description, const QList<VProperty*>& properties, QWidget *parent)
|
VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &description,
|
||||||
|
const QList<VProperty*>& properties, QWidget *parent)
|
||||||
: QGroupBox(title, parent), d_ptr(new VPropertyFormWidgetPrivate(properties))
|
: QGroupBox(title, parent), d_ptr(new VPropertyFormWidgetPrivate(properties))
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
|
@ -42,7 +43,8 @@ VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &de
|
||||||
VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *parent)
|
VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *parent)
|
||||||
: QGroupBox(parent), d_ptr(new VPropertyFormWidgetPrivate())
|
: QGroupBox(parent), d_ptr(new VPropertyFormWidgetPrivate())
|
||||||
{
|
{
|
||||||
if(parent_property) {
|
if (parent_property)
|
||||||
|
{
|
||||||
d_ptr->Properties = parent_property->getChildren();
|
d_ptr->Properties = parent_property->getChildren();
|
||||||
build();
|
build();
|
||||||
setTitle(parent_property->getName());
|
setTitle(parent_property->getName());
|
||||||
|
@ -51,7 +53,8 @@ VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFormWidget::VPropertyFormWidget(VPropertyFormWidgetPrivate *d_pointer, QWidget *parent, const QString &title, const QString &description)
|
VPropertyFormWidget::VPropertyFormWidget(VPropertyFormWidgetPrivate *d_pointer, QWidget *parent, const QString &title,
|
||||||
|
const QString &description)
|
||||||
: QGroupBox(title, parent), d_ptr(d_pointer)
|
: QGroupBox(title, parent), d_ptr(d_pointer)
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
|
@ -69,28 +72,40 @@ void VPropertyFormWidget::build()
|
||||||
{
|
{
|
||||||
// Clear the old content, delete old widgets
|
// Clear the old content, delete old widgets
|
||||||
d_ptr->EditorWidgets.clear();
|
d_ptr->EditorWidgets.clear();
|
||||||
if(layout()) {
|
if (layout())
|
||||||
|
{
|
||||||
QLayoutItem *child;
|
QLayoutItem *child;
|
||||||
while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0) {
|
while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0)
|
||||||
|
{
|
||||||
if (child->widget())
|
if (child->widget())
|
||||||
|
{
|
||||||
delete child->widget();
|
delete child->widget();
|
||||||
|
}
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
delete layout();
|
delete layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new content
|
// Create new content
|
||||||
if(d_ptr->Properties.isEmpty()) return; //... only if there are properties
|
if (d_ptr->Properties.isEmpty())
|
||||||
|
{
|
||||||
|
return; //... only if there are properties
|
||||||
|
}
|
||||||
|
|
||||||
QFormLayout* tmpFormLayout = new QFormLayout(this);
|
QFormLayout* tmpFormLayout = new QFormLayout(this);
|
||||||
setLayout(tmpFormLayout);
|
setLayout(tmpFormLayout);
|
||||||
|
|
||||||
for(int i = 0; i < d_ptr->Properties.count(); ++i) {
|
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
||||||
|
{
|
||||||
// Get the current property
|
// Get the current property
|
||||||
VProperty* tmpProperty = d_ptr->Properties.value(i, nullptr);
|
VProperty* tmpProperty = d_ptr->Properties.value(i, nullptr);
|
||||||
if(!tmpProperty) continue;
|
if (!tmpProperty)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(tmpProperty->getRowCount() > 0) {
|
if (tmpProperty->getRowCount() > 0)
|
||||||
|
{
|
||||||
if (tmpProperty->propertyType() == Property::Complex)
|
if (tmpProperty->propertyType() == Property::Complex)
|
||||||
{
|
{
|
||||||
buildEditor(tmpProperty, tmpFormLayout, Property::Complex);
|
buildEditor(tmpProperty, tmpFormLayout, Property::Complex);
|
||||||
|
@ -122,11 +137,15 @@ void VPropertyFormWidget::build()
|
||||||
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpNewFormWidget));
|
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpNewFormWidget));
|
||||||
tmpNewFormWidget->setCommitBehaviour(d_ptr->UpdateEditors);
|
tmpNewFormWidget->setCommitBehaviour(d_ptr->UpdateEditors);
|
||||||
}
|
}
|
||||||
} else if(tmpProperty->type() == "widget") {
|
}
|
||||||
|
else if (tmpProperty->type() == "widget")
|
||||||
|
{
|
||||||
VWidgetProperty* tmpWidgetProperty = static_cast<VWidgetProperty*>(tmpProperty);
|
VWidgetProperty* tmpWidgetProperty = static_cast<VWidgetProperty*>(tmpProperty);
|
||||||
tmpFormLayout->addRow(tmpWidgetProperty->getWidget());
|
tmpFormLayout->addRow(tmpWidgetProperty->getWidget());
|
||||||
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpWidgetProperty->getWidget()));
|
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpWidgetProperty->getWidget()));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
buildEditor(tmpProperty, tmpFormLayout);
|
buildEditor(tmpProperty, tmpFormLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +157,9 @@ void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayo
|
||||||
// Create the editor (if it doesn't work, create empty widget)
|
// Create the editor (if it doesn't work, create empty widget)
|
||||||
QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr);
|
QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr);
|
||||||
if (!tmpEditor)
|
if (!tmpEditor)
|
||||||
|
{
|
||||||
tmpEditor = new QWidget(this);
|
tmpEditor = new QWidget(this);
|
||||||
|
}
|
||||||
|
|
||||||
// set tooltip and whats this
|
// set tooltip and whats this
|
||||||
tmpEditor->setToolTip(property->getDescription());
|
tmpEditor->setToolTip(property->getDescription());
|
||||||
|
@ -167,23 +188,32 @@ void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayo
|
||||||
void VPropertyFormWidget::commitData()
|
void VPropertyFormWidget::commitData()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
||||||
|
{
|
||||||
commitData(i);
|
commitData(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VPropertyFormWidget::loadData()
|
void VPropertyFormWidget::loadData()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
for (int i = 0; i < d_ptr->Properties.count(); ++i)
|
||||||
|
{
|
||||||
loadData(i);
|
loadData(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VPropertyFormWidget::commitData(int row)
|
void VPropertyFormWidget::commitData(int row)
|
||||||
{
|
{
|
||||||
if(row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count()) return;
|
if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
||||||
VProperty* tmpProperty = d_ptr->Properties[row];
|
VProperty* tmpProperty = d_ptr->Properties[row];
|
||||||
if (tmpEditorWidget.FormWidget)
|
if (tmpEditorWidget.FormWidget)
|
||||||
|
{
|
||||||
tmpEditorWidget.FormWidget->commitData();
|
tmpEditorWidget.FormWidget->commitData();
|
||||||
|
}
|
||||||
else if (tmpEditorWidget.Editor && tmpProperty)
|
else if (tmpEditorWidget.Editor && tmpProperty)
|
||||||
{
|
{
|
||||||
QVariant newValue = tmpProperty->getEditorData(tmpEditorWidget.Editor);
|
QVariant newValue = tmpProperty->getEditorData(tmpEditorWidget.Editor);
|
||||||
|
@ -212,13 +242,19 @@ void VPropertyFormWidget::commitData(int row)
|
||||||
|
|
||||||
void VPropertyFormWidget::loadData(int row)
|
void VPropertyFormWidget::loadData(int row)
|
||||||
{
|
{
|
||||||
if(row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count()) return;
|
if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row];
|
||||||
VProperty* tmpProperty = d_ptr->Properties[row];
|
VProperty* tmpProperty = d_ptr->Properties[row];
|
||||||
if (tmpEditorWidget.FormWidget)
|
if (tmpEditorWidget.FormWidget)
|
||||||
|
{
|
||||||
tmpEditorWidget.FormWidget->loadData();
|
tmpEditorWidget.FormWidget->loadData();
|
||||||
else if(tmpEditorWidget.Editor && tmpProperty) {
|
}
|
||||||
|
else if (tmpEditorWidget.Editor && tmpProperty)
|
||||||
|
{
|
||||||
tmpProperty->setEditorData(tmpEditorWidget.Editor);
|
tmpProperty->setEditorData(tmpEditorWidget.Editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,19 +264,25 @@ void VPropertyFormWidget::setCommitBehaviour(bool auto_commit)
|
||||||
d_ptr->UpdateEditors = auto_commit;
|
d_ptr->UpdateEditors = auto_commit;
|
||||||
|
|
||||||
QList<VPropertyFormWidget*> tmpChildFormWidgets = getChildPropertyFormWidgets();
|
QList<VPropertyFormWidget*> tmpChildFormWidgets = getChildPropertyFormWidgets();
|
||||||
foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets) {
|
foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets)
|
||||||
|
{
|
||||||
if (tmpChild)
|
if (tmpChild)
|
||||||
|
{
|
||||||
tmpChild->setCommitBehaviour(auto_commit);
|
tmpChild->setCommitBehaviour(auto_commit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<VPropertyFormWidget *> VPropertyFormWidget::getChildPropertyFormWidgets() const
|
QList<VPropertyFormWidget *> VPropertyFormWidget::getChildPropertyFormWidgets() const
|
||||||
{
|
{
|
||||||
QList<VPropertyFormWidget *> tmpResult;
|
QList<VPropertyFormWidget *> tmpResult;
|
||||||
foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets) {
|
foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets)
|
||||||
|
{
|
||||||
if (tmpEditorWidget.FormWidget)
|
if (tmpEditorWidget.FormWidget)
|
||||||
|
{
|
||||||
tmpResult.append(tmpEditorWidget.FormWidget);
|
tmpResult.append(tmpEditorWidget.FormWidget);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
@ -248,14 +290,20 @@ QList<VPropertyFormWidget *> VPropertyFormWidget::getChildPropertyFormWidgets()
|
||||||
bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
if (!d_ptr->UpdateEditors)
|
if (!d_ptr->UpdateEditors)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* editor = qobject_cast<QWidget*>(object);
|
QWidget* editor = qobject_cast<QWidget*>(object);
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress)
|
||||||
switch (static_cast<QKeyEvent *>(event)->key()) {
|
{
|
||||||
|
switch (static_cast<QKeyEvent *>(event)->key())
|
||||||
|
{
|
||||||
case Qt::Key_Tab:
|
case Qt::Key_Tab:
|
||||||
case Qt::Key_Backtab:
|
case Qt::Key_Backtab:
|
||||||
case Qt::Key_Enter:
|
case Qt::Key_Enter:
|
||||||
|
@ -267,16 +315,23 @@ bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) {
|
}
|
||||||
|
else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow()))
|
||||||
|
{
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
return false;
|
return false;
|
||||||
} else if (event->type() == QEvent::ShortcutOverride) {
|
}
|
||||||
if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
|
else if (event->type() == QEvent::ShortcutOverride)
|
||||||
|
{
|
||||||
|
if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->type() == MyCustomEventType) {
|
}
|
||||||
|
else if (event->type() == MyCustomEventType)
|
||||||
|
{
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
|
@ -293,11 +348,16 @@ bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
void VPropertyFormWidget::commitData(QWidget *editor)
|
void VPropertyFormWidget::commitData(QWidget *editor)
|
||||||
{
|
{
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < d_ptr->EditorWidgets.count(); ++i) {
|
for (int i = 0; i < d_ptr->EditorWidgets.count(); ++i)
|
||||||
|
{
|
||||||
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[i];
|
VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[i];
|
||||||
if (tmpEditorWidget.Editor == editor)
|
if (tmpEditorWidget.Editor == editor)
|
||||||
|
{
|
||||||
commitData(i);
|
commitData(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
class QFormLayout;
|
class QFormLayout;
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyFormWidgetPrivate;
|
class VPropertyFormWidgetPrivate;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
@ -38,7 +39,8 @@ class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormWidget : public QGroupBox
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyFormWidget(const QString& title, const QString& description, const QList<VProperty*>& properties, QWidget* parent);
|
VPropertyFormWidget(const QString& title, const QString& description, const QList<VProperty*>& properties,
|
||||||
|
QWidget* parent);
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyFormWidget(VProperty* parent_property, QWidget* parent);
|
VPropertyFormWidget(VProperty* parent_property, QWidget* parent);
|
||||||
|
@ -69,7 +71,8 @@ public slots:
|
||||||
void loadData(int row);
|
void loadData(int row);
|
||||||
|
|
||||||
//! Sets the update behaviour
|
//! Sets the update behaviour
|
||||||
//! \param auto_commit If set to true, whenever an event like focusOut is triggered on an editor, the data will be submitted to the property.
|
//! \param auto_commit If set to true, whenever an event like focusOut is triggered on an editor, the data will be
|
||||||
|
//! submitted to the property.
|
||||||
void setCommitBehaviour(bool auto_commit = true);
|
void setCommitBehaviour(bool auto_commit = true);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -26,12 +26,15 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyFormWidgetPrivate {
|
class VPropertyFormWidgetPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null)
|
//! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null)
|
||||||
struct SEditorWidget {
|
struct SEditorWidget
|
||||||
|
{
|
||||||
SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {}
|
SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {}
|
||||||
SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {}
|
SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {}
|
||||||
SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {}
|
SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {}
|
||||||
|
@ -46,7 +49,8 @@ public:
|
||||||
//! Binds the properties to their editors
|
//! Binds the properties to their editors
|
||||||
QList<SEditorWidget> EditorWidgets;
|
QList<SEditorWidget> EditorWidgets;
|
||||||
|
|
||||||
//! Determines the behaviour of the editors. If this is true, when a focus out event etc. happens, the data will be submitted to the VProperty. If false, you will have to call commitData() yourself.
|
//! Determines the behaviour of the editors. If this is true, when a focus out event etc. happens, the data will be
|
||||||
|
//! submitted to the VProperty. If false, you will have to call commitData() yourself.
|
||||||
bool UpdateEditors;
|
bool UpdateEditors;
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
|
|
|
@ -41,7 +41,9 @@ VPropertyModel::VPropertyModel(QObject * parent) :
|
||||||
VPropertyModel::~VPropertyModel()
|
VPropertyModel::~VPropertyModel()
|
||||||
{
|
{
|
||||||
if (d_ptr->Properties)
|
if (d_ptr->Properties)
|
||||||
|
{
|
||||||
delete d_ptr->Properties;
|
delete d_ptr->Properties;
|
||||||
|
}
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
@ -50,12 +52,17 @@ VPropertyModel::~VPropertyModel()
|
||||||
bool VPropertyModel::addProperty(VProperty* property, const QString& id, const QString &parentid, bool emitsignals)
|
bool VPropertyModel::addProperty(VProperty* property, const QString& id, const QString &parentid, bool emitsignals)
|
||||||
{
|
{
|
||||||
if (!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!d_ptr->Properties) // If not existant, create property set
|
if (!d_ptr->Properties) // If not existant, create property set
|
||||||
|
{
|
||||||
d_ptr->Properties = new VPropertySet();
|
d_ptr->Properties = new VPropertySet();
|
||||||
|
}
|
||||||
|
|
||||||
if(emitsignals) {
|
if (emitsignals)
|
||||||
|
{
|
||||||
VProperty* tmpParent = getProperty(parentid);
|
VProperty* tmpParent = getProperty(parentid);
|
||||||
int tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() : d_ptr->Properties->getRootPropertyCount();
|
int tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() : d_ptr->Properties->getRootPropertyCount();
|
||||||
beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), tmpRow, tmpRow);
|
beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), tmpRow, tmpRow);
|
||||||
|
@ -64,19 +71,24 @@ bool VPropertyModel::addProperty(VProperty* property, const QString& id, const Q
|
||||||
d_ptr->Properties->addProperty(property, id, parentid);
|
d_ptr->Properties->addProperty(property, id, parentid);
|
||||||
|
|
||||||
if (emitsignals)
|
if (emitsignals)
|
||||||
|
{
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Creates a property and adds it to the model
|
//! Creates a property and adds it to the model
|
||||||
VProperty* VPropertyModel::createProperty(const QString& id, const QString& name, const QString& parentid, const QVariant& data)
|
VProperty* VPropertyModel::createProperty(const QString& id, const QString& name, const QString& parentid,
|
||||||
|
const QVariant& data)
|
||||||
{
|
{
|
||||||
VProperty* tmpProp = new VProperty(name);
|
VProperty* tmpProp = new VProperty(name);
|
||||||
tmpProp->setValue(data);
|
tmpProp->setValue(data);
|
||||||
if (tmpProp && addProperty(tmpProp, id, parentid))
|
if (tmpProp && addProperty(tmpProp, id, parentid))
|
||||||
|
{
|
||||||
return tmpProp;
|
return tmpProp;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -87,23 +99,29 @@ VProperty* VPropertyModel::getProperty(const QString& id)
|
||||||
return d_ptr->Properties != nullptr ? d_ptr->Properties->getProperty(id) : nullptr;
|
return d_ptr->Properties != nullptr ? d_ptr->Properties->getProperty(id) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns the model index at row/column
|
//! Returns the model index at row/column
|
||||||
QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent) const
|
QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
if (d_ptr->Properties == nullptr || (parent.isValid() && parent.column() > 1))
|
if (d_ptr->Properties == nullptr || (parent.isValid() && parent.column() > 1))
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
if(parent.isValid()) {
|
if (parent.isValid())
|
||||||
|
{
|
||||||
// Get the parent index
|
// Get the parent index
|
||||||
VProperty* parentItem = getProperty(parent);
|
VProperty* parentItem = getProperty(parent);
|
||||||
if(parentItem) {
|
if (parentItem)
|
||||||
|
{
|
||||||
VProperty* childItem = parentItem->getChild(row);
|
VProperty* childItem = parentItem->getChild(row);
|
||||||
if (childItem)
|
if (childItem)
|
||||||
|
{
|
||||||
return createIndex(row, column, childItem);
|
return createIndex(row, column, childItem);
|
||||||
}
|
}
|
||||||
} else if(row >= 0 && row < d_ptr->Properties->count()) {
|
}
|
||||||
|
}
|
||||||
|
else if (row >= 0 && row < d_ptr->Properties->count())
|
||||||
|
{
|
||||||
return createIndex(row, column, d_ptr->Properties->getRootProperty(row));
|
return createIndex(row, column, d_ptr->Properties->getRootProperty(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,19 +132,26 @@ QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent
|
||||||
QModelIndex VPropertyModel::parent ( const QModelIndex & index ) const
|
QModelIndex VPropertyModel::parent ( const QModelIndex & index ) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* childItem = getProperty(index);
|
VProperty* childItem = getProperty(index);
|
||||||
if(childItem) {
|
if (childItem)
|
||||||
|
{
|
||||||
VProperty* parentItem = childItem->getParent();
|
VProperty* parentItem = childItem->getParent();
|
||||||
if(parentItem) {
|
if (parentItem)
|
||||||
|
{
|
||||||
VProperty* grandParentItem = parentItem->getParent();
|
VProperty* grandParentItem = parentItem->getParent();
|
||||||
int parents_row = grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem) : d_ptr->Properties->getRootProperties().indexOf(parentItem);
|
int parents_row = grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem)
|
||||||
|
: d_ptr->Properties->getRootProperties().indexOf(parentItem);
|
||||||
|
|
||||||
if (parents_row >= 0)
|
if (parents_row >= 0)
|
||||||
|
{
|
||||||
return createIndex(parents_row, 0, parentItem);
|
return createIndex(parents_row, 0, parentItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +161,9 @@ Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = getProperty(index);
|
VProperty* tmpProperty = getProperty(index);
|
||||||
if (!tmpProperty)
|
if (!tmpProperty)
|
||||||
|
{
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return tmpProperty->flags(index.column());
|
return tmpProperty->flags(index.column());
|
||||||
}
|
}
|
||||||
|
@ -145,16 +172,20 @@ Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const
|
||||||
bool VPropertyModel::setData (const QModelIndex& index, const QVariant& value, int role)
|
bool VPropertyModel::setData (const QModelIndex& index, const QVariant& value, int role)
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = getProperty(index);
|
VProperty* tmpProperty = getProperty(index);
|
||||||
if(index.column() == 1 && tmpProperty) {
|
if (index.column() == 1 && tmpProperty)
|
||||||
|
{
|
||||||
bool tmpHasChanged = tmpProperty->setData(value, role);
|
bool tmpHasChanged = tmpProperty->setData(value, role);
|
||||||
if(tmpProperty->getUpdateParent() && tmpHasChanged) { // If neccessary, update the parent as well
|
if (tmpProperty->getUpdateParent() && tmpHasChanged)
|
||||||
|
{ // If neccessary, update the parent as well
|
||||||
QModelIndex tmpParentIndex = parent(index);
|
QModelIndex tmpParentIndex = parent(index);
|
||||||
emit dataChanged(tmpParentIndex, tmpParentIndex);
|
emit dataChanged(tmpParentIndex, tmpParentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpHasChanged)
|
if (tmpHasChanged)
|
||||||
|
{
|
||||||
emit onDataChangedByEditor(tmpProperty);
|
emit onDataChangedByEditor(tmpProperty);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -166,7 +197,9 @@ QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = getProperty(index);
|
VProperty* tmpProperty = getProperty(index);
|
||||||
if (!tmpProperty)
|
if (!tmpProperty)
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return tmpProperty->data(index.column(), role);
|
return tmpProperty->data(index.column(), role);
|
||||||
}
|
}
|
||||||
|
@ -174,13 +207,22 @@ QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const
|
||||||
|
|
||||||
QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, int role) const
|
QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if(orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
// Header data
|
// Header data
|
||||||
if (section == 0) return d_ptr->HeadlineProperty;
|
if (section == 0)
|
||||||
else if (section == 1) return d_ptr->HeadlineValue;
|
{
|
||||||
|
return d_ptr->HeadlineProperty;
|
||||||
|
}
|
||||||
|
else if (section == 1)
|
||||||
|
{
|
||||||
|
return d_ptr->HeadlineValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (role == Qt::DisplayRole)
|
else if (role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
return QVariant(section);
|
return QVariant(section);
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -189,15 +231,20 @@ QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, i
|
||||||
//! Returns the number of rows
|
//! Returns the number of rows
|
||||||
int VPropertyModel::rowCount ( const QModelIndex & parent ) const
|
int VPropertyModel::rowCount ( const QModelIndex & parent ) const
|
||||||
{
|
{
|
||||||
if(parent.isValid()) {
|
if (parent.isValid())
|
||||||
|
{
|
||||||
VProperty* tmpParent = getProperty(parent);
|
VProperty* tmpParent = getProperty(parent);
|
||||||
if (tmpParent)
|
if (tmpParent)
|
||||||
|
{
|
||||||
return tmpParent->getRowCount();
|
return tmpParent->getRowCount();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return the root property count
|
// Return the root property count
|
||||||
if (d_ptr->Properties)
|
if (d_ptr->Properties)
|
||||||
|
{
|
||||||
return d_ptr->Properties->getRootPropertyCount();
|
return d_ptr->Properties->getRootPropertyCount();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -214,12 +261,15 @@ int VPropertyModel::columnCount ( const QModelIndex & parent) const
|
||||||
//! Gets a property by its ModelIndex
|
//! Gets a property by its ModelIndex
|
||||||
VProperty* VPropertyModel::getProperty(const QModelIndex &index) const
|
VProperty* VPropertyModel::getProperty(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid())
|
||||||
|
{
|
||||||
VProperty* prop = static_cast<VProperty*>(index.internalPointer());
|
VProperty* prop = static_cast<VProperty*>(index.internalPointer());
|
||||||
|
|
||||||
if (prop)
|
if (prop)
|
||||||
|
{
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,12 +281,15 @@ QString VPropertyModel::getPropertyID(VProperty *prop) const
|
||||||
QModelIndex VPropertyModel::getIndexFromProperty(VProperty* property, int column) const
|
QModelIndex VPropertyModel::getIndexFromProperty(VProperty* property, int column) const
|
||||||
{
|
{
|
||||||
if (!property || column > columnCount() || column < 0)
|
if (!property || column > columnCount() || column < 0)
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* parentItem = property->getParent();
|
VProperty* parentItem = property->getParent();
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
if(parentItem) {
|
if (parentItem)
|
||||||
|
{
|
||||||
row = parentItem->getChildRow(property);
|
row = parentItem->getChildRow(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,9 +321,15 @@ VPropertySet *VPropertyModel::takePropertySet(VPropertySet *new_property_set, bo
|
||||||
{
|
{
|
||||||
VPropertySet* tmpOldPropertySet = d_ptr->Properties;
|
VPropertySet* tmpOldPropertySet = d_ptr->Properties;
|
||||||
|
|
||||||
if(emit_signals) emit beginResetModel();
|
if (emit_signals)
|
||||||
|
{
|
||||||
|
emit beginResetModel();
|
||||||
|
}
|
||||||
d_ptr->Properties = new_property_set;
|
d_ptr->Properties = new_property_set;
|
||||||
if(emit_signals) emit endResetModel();
|
if (emit_signals)
|
||||||
|
{
|
||||||
|
emit endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
return tmpOldPropertySet;
|
return tmpOldPropertySet;
|
||||||
}
|
}
|
||||||
|
@ -279,13 +338,16 @@ void VPropertyModel::setPropertySet(VPropertySet *property_set, bool emit_signal
|
||||||
{
|
{
|
||||||
VPropertySet* tmpOldPropertySet = takePropertySet(property_set, emit_signals);
|
VPropertySet* tmpOldPropertySet = takePropertySet(property_set, emit_signals);
|
||||||
if (tmpOldPropertySet)
|
if (tmpOldPropertySet)
|
||||||
|
{
|
||||||
delete tmpOldPropertySet;
|
delete tmpOldPropertySet;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VProperty *VPropertyModel::takeProperty(const QString &id)
|
VProperty *VPropertyModel::takeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
||||||
if(d_ptr->Properties && tmpIndex.isValid()) {
|
if (d_ptr->Properties && tmpIndex.isValid())
|
||||||
|
{
|
||||||
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
||||||
VProperty* tmpProp = d_ptr->Properties->takeProperty(id);
|
VProperty* tmpProp = d_ptr->Properties->takeProperty(id);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
@ -298,7 +360,8 @@ VProperty *VPropertyModel::takeProperty(const QString &id)
|
||||||
void VPropertyModel::removeProperty(const QString &id)
|
void VPropertyModel::removeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
QModelIndex tmpIndex = getIndexFromProperty(getProperty(id));
|
||||||
if(d_ptr->Properties && tmpIndex.isValid()) {
|
if (d_ptr->Properties && tmpIndex.isValid())
|
||||||
|
{
|
||||||
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row());
|
||||||
d_ptr->Properties->removeProperty(id);
|
d_ptr->Properties->removeProperty(id);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyModelPrivate;
|
class VPropertyModelPrivate;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
@ -61,7 +62,8 @@ public:
|
||||||
virtual ~VPropertyModel();
|
virtual ~VPropertyModel();
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parentid
|
//! Adds the property to the model and attaches it to the parentid
|
||||||
//! \param emitsignals If this is set to false, this function will not call beginInsertRows() and endInsertRows(), so it has to be called from a subclass
|
//! \param emitsignals If this is set to false, this function will not call beginInsertRows() and endInsertRows(),
|
||||||
|
//! so it has to be called from a subclass
|
||||||
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid = QString(),
|
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid = QString(),
|
||||||
bool emitsignals = true);
|
bool emitsignals = true);
|
||||||
|
|
||||||
|
@ -96,8 +98,6 @@ public:
|
||||||
//! Returns the number of columns
|
//! Returns the number of columns
|
||||||
virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
|
virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Gets a property by its ModelIndex
|
//! Gets a property by its ModelIndex
|
||||||
//! \param index The modelIndex of the property.
|
//! \param index The modelIndex of the property.
|
||||||
//! \return Returns the property with the given index, or NULL if none such property exists
|
//! \return Returns the property with the given index, or NULL if none such property exists
|
||||||
|
@ -110,23 +110,29 @@ public:
|
||||||
//! \return Returns the ID under which the property is stored within the model
|
//! \return Returns the ID under which the property is stored within the model
|
||||||
virtual QString getPropertyID(VProperty* prop) const;
|
virtual QString getPropertyID(VProperty* prop) const;
|
||||||
|
|
||||||
//! Returns a const pointer to the property set managed by this model. If you want to manipulate the property set, either use the methods provided by the model or use takePropertySet() and setPropertySet().
|
//! Returns a const pointer to the property set managed by this model. If you want to manipulate the property set,
|
||||||
|
//! either use the methods provided by the model or use takePropertySet() and setPropertySet().
|
||||||
//! \return A constant pointer to the property set or NULL if there currently is none.
|
//! \return A constant pointer to the property set or NULL if there currently is none.
|
||||||
virtual const VPropertySet* getPropertySet() const;
|
virtual const VPropertySet* getPropertySet() const;
|
||||||
|
|
||||||
//! Clears the model, deletes the property set managed by this model.
|
//! Clears the model, deletes the property set managed by this model.
|
||||||
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals
|
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset
|
||||||
|
//! model signals
|
||||||
virtual void clear(bool emit_signals = true);
|
virtual void clear(bool emit_signals = true);
|
||||||
|
|
||||||
//! Removes the current property set and returns it. If new_property_set is set, the old one will be replaced by the new one
|
//! Removes the current property set and returns it. If new_property_set is set, the old one will be replaced by the
|
||||||
|
//! new one
|
||||||
//! \param new_property_set The new property set to replace the old one with. Default: NULL
|
//! \param new_property_set The new property set to replace the old one with. Default: NULL
|
||||||
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals
|
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset
|
||||||
|
//! model signals
|
||||||
//! \return A constant pointer to the property set or NULL if there currently is none.
|
//! \return A constant pointer to the property set or NULL if there currently is none.
|
||||||
virtual VPropertySet* takePropertySet(VPropertySet* new_property_set = nullptr, bool emit_signals = true);
|
virtual VPropertySet* takePropertySet(VPropertySet* new_property_set = nullptr, bool emit_signals = true);
|
||||||
|
|
||||||
//! Sets a new property set. The model will take ownership of the property set. The old property set will be deleted.
|
//! Sets a new property set. The model will take ownership of the property set. The old property set will be
|
||||||
|
//! deleted.
|
||||||
//! \param property_set The new property set. Setting this to NULL has the same effect as calling clear.
|
//! \param property_set The new property set. Setting this to NULL has the same effect as calling clear.
|
||||||
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals
|
//! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset
|
||||||
|
//! model signals
|
||||||
//! \return A constant pointer to the property set or NULL if there currently is none.
|
//! \return A constant pointer to the property set or NULL if there currently is none.
|
||||||
virtual void setPropertySet(VPropertySet* property_set, bool emit_signals = true);
|
virtual void setPropertySet(VPropertySet* property_set, bool emit_signals = true);
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,14 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
class VPropertyModelPrivate {
|
class VPropertyModelPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! The property set holding the properties
|
//! The property set holding the properties
|
||||||
VPropertySet* Properties;
|
VPropertySet* Properties;
|
||||||
|
|
|
@ -42,7 +42,9 @@ bool VPropertySet::addProperty(VProperty *property, const QString &id, const QSt
|
||||||
{
|
{
|
||||||
// Check if the property to add is not a null pointer
|
// Check if the property to add is not a null pointer
|
||||||
if (!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
VProperty* tmpParent = parentid.isEmpty() ? NULL : getProperty(parentid);
|
VProperty* tmpParent = parentid.isEmpty() ? NULL : getProperty(parentid);
|
||||||
return addProperty(property, id, tmpParent);
|
return addProperty(property, id, tmpParent);
|
||||||
|
@ -52,22 +54,33 @@ bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty
|
||||||
{
|
{
|
||||||
// Check if the property to add is not a null pointer
|
// Check if the property to add is not a null pointer
|
||||||
if (!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString tmpOldID = getPropertyID(property);
|
QString tmpOldID = getPropertyID(property);
|
||||||
if (!tmpOldID.isEmpty())
|
if (!tmpOldID.isEmpty())
|
||||||
|
{
|
||||||
d_ptr->Properties.remove(tmpOldID);
|
d_ptr->Properties.remove(tmpOldID);
|
||||||
|
}
|
||||||
|
|
||||||
if (parent_property)
|
if (parent_property)
|
||||||
|
{
|
||||||
parent_property->addChild(property);
|
parent_property->addChild(property);
|
||||||
else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
d_ptr->RootProperties.append(property);
|
d_ptr->RootProperties.append(property);
|
||||||
if (property->getParent())
|
if (property->getParent())
|
||||||
|
{
|
||||||
property->getParent()->removeChild(property);
|
property->getParent()->removeChild(property);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!id.isEmpty())
|
if (!id.isEmpty())
|
||||||
|
{
|
||||||
d_ptr->Properties.insert(id, property);
|
d_ptr->Properties.insert(id, property);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +88,9 @@ bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty
|
||||||
bool VPropertySet::hasProperty(VProperty *property) const
|
bool VPropertySet::hasProperty(VProperty *property) const
|
||||||
{
|
{
|
||||||
if (!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return hasProperty(property, NULL);
|
return hasProperty(property, NULL);
|
||||||
}
|
}
|
||||||
|
@ -98,8 +113,10 @@ void VPropertySet::removeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
VProperty* tmpProp = takeProperty(id);
|
VProperty* tmpProp = takeProperty(id);
|
||||||
if (tmpProp)
|
if (tmpProp)
|
||||||
|
{
|
||||||
delete tmpProp;
|
delete tmpProp;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VPropertySet::removeProperty(VProperty* prop, bool delete_property)
|
void VPropertySet::removeProperty(VProperty* prop, bool delete_property)
|
||||||
{
|
{
|
||||||
|
@ -107,13 +124,16 @@ void VPropertySet::removeProperty(VProperty* prop, bool delete_property)
|
||||||
removePropertyFromSet(prop);
|
removePropertyFromSet(prop);
|
||||||
|
|
||||||
// Remove from parent and optionally delete
|
// Remove from parent and optionally delete
|
||||||
if(prop) {
|
if (prop)
|
||||||
|
{
|
||||||
prop->setParent(NULL);
|
prop->setParent(NULL);
|
||||||
|
|
||||||
if (delete_property)
|
if (delete_property)
|
||||||
|
{
|
||||||
delete prop;
|
delete prop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int VPropertySet::count() const
|
int VPropertySet::count() const
|
||||||
{
|
{
|
||||||
|
@ -123,9 +143,11 @@ int VPropertySet::count() const
|
||||||
void VPropertySet::clear(bool delete_properties)
|
void VPropertySet::clear(bool delete_properties)
|
||||||
{
|
{
|
||||||
d_ptr->Properties.clear();
|
d_ptr->Properties.clear();
|
||||||
while(!d_ptr->RootProperties.isEmpty()) {
|
while (!d_ptr->RootProperties.isEmpty())
|
||||||
|
{
|
||||||
VProperty* tmpProp = d_ptr->RootProperties.takeLast();
|
VProperty* tmpProp = d_ptr->RootProperties.takeLast();
|
||||||
if(tmpProp != nullptr && delete_properties) {
|
if (tmpProp != nullptr && delete_properties)
|
||||||
|
{
|
||||||
delete tmpProp;
|
delete tmpProp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,16 +158,21 @@ QString VPropertySet::getPropertyID(const VProperty *prop, bool look_for_parent_
|
||||||
QString tmpResult;
|
QString tmpResult;
|
||||||
const VProperty* tmpCurrentProp = prop;
|
const VProperty* tmpCurrentProp = prop;
|
||||||
|
|
||||||
while(tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) && tmpResult.isEmpty()) {
|
while (tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) && tmpResult.isEmpty())
|
||||||
|
{
|
||||||
|
|
||||||
// todo: The following code doesn't work, because .key() doesn't accept a const VProperty* pointer ...
|
// todo: The following code doesn't work, because .key() doesn't accept a const VProperty* pointer ...
|
||||||
//tmpResult = d_ptr->Properties.key(tmpCurrentProp, QString());
|
//tmpResult = d_ptr->Properties.key(tmpCurrentProp, QString());
|
||||||
|
|
||||||
// ... which is why we need the code below
|
// ... which is why we need the code below
|
||||||
for (QMap<QString, VProperty*>::const_iterator i = d_ptr->Properties.constBegin(); i != d_ptr->Properties.constEnd(); ++i) {
|
for (QMap<QString, VProperty*>::const_iterator i = d_ptr->Properties.constBegin();
|
||||||
|
i != d_ptr->Properties.constEnd(); ++i)
|
||||||
|
{
|
||||||
if (tmpCurrentProp == (*i))
|
if (tmpCurrentProp == (*i))
|
||||||
|
{
|
||||||
return i.key();
|
return i.key();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmpCurrentProp = tmpCurrentProp->getParent();
|
tmpCurrentProp = tmpCurrentProp->getParent();
|
||||||
}
|
}
|
||||||
|
@ -184,36 +211,48 @@ VPropertySet* VPropertySet::clone() const
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool VPropertySet::hasProperty(VProperty *property, VProperty *parent) const
|
bool VPropertySet::hasProperty(VProperty *property, VProperty *parent) const
|
||||||
{
|
{
|
||||||
if (!property)
|
if (!property)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const QList<VProperty*>& tmpChildrenList = (parent != NULL ? parent->getChildren() : d_ptr->RootProperties);
|
const QList<VProperty*>& tmpChildrenList = (parent != NULL ? parent->getChildren() : d_ptr->RootProperties);
|
||||||
foreach(VProperty* tmpProp, tmpChildrenList) {
|
foreach(VProperty* tmpProp, tmpChildrenList)
|
||||||
|
{
|
||||||
if (!tmpProp)
|
if (!tmpProp)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
else if (tmpProp == property || hasProperty(property, tmpProp))
|
else if (tmpProp == property || hasProperty(property, tmpProp))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *parent_property, VPropertySet *output_set) const
|
void VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *parent_property,
|
||||||
|
VPropertySet *output_set) const
|
||||||
{
|
{
|
||||||
if (!output_set || !property_to_clone || !hasProperty(property_to_clone))
|
if (!output_set || !property_to_clone || !hasProperty(property_to_clone))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString tmpID = getPropertyID(property_to_clone, false);
|
QString tmpID = getPropertyID(property_to_clone, false);
|
||||||
VProperty* tmpNewProperty = property_to_clone->clone(false); // We want to clone the children ourselves (because of the IDs)
|
|
||||||
|
// We want to clone the children ourselves (because of the IDs)
|
||||||
|
VProperty* tmpNewProperty = property_to_clone->clone(false);
|
||||||
|
|
||||||
output_set->addProperty(tmpNewProperty, tmpID, parent_property);
|
output_set->addProperty(tmpNewProperty, tmpID, parent_property);
|
||||||
for (int i = 0; i < property_to_clone->getRowCount(); ++i)
|
for (int i = 0; i < property_to_clone->getRowCount(); ++i)
|
||||||
|
{
|
||||||
cloneProperty(property_to_clone->getChild(i), tmpNewProperty, output_set);
|
cloneProperty(property_to_clone->getChild(i), tmpNewProperty, output_set);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VPropertySet::removePropertyFromSet(VProperty *prop)
|
void VPropertySet::removePropertyFromSet(VProperty *prop)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
class VPropertySetPrivate;
|
class VPropertySetPrivate;
|
||||||
|
@ -49,15 +50,19 @@ public:
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VPropertySet();
|
virtual ~VPropertySet();
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parentid. Note that if the property has a parent which is not part of this set, it will be removed from that parent.
|
//! Adds the property to the model and attaches it to the parentid. Note that if the property has a parent which is
|
||||||
|
//! not part of this set, it will be removed from that parent.
|
||||||
//! \param property The property to add
|
//! \param property The property to add
|
||||||
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added. If the property was filed under another ID before, that will no longer be valid.
|
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added.
|
||||||
//! \param parentid The property's ID to which to add the property as child. Pass empty string to add it to the root properties.
|
//! If the property was filed under another ID before, that will no longer be valid.
|
||||||
|
//! \param parentid The property's ID to which to add the property as child. Pass empty string to add it to the
|
||||||
|
//! root properties.
|
||||||
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid);
|
virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid);
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parent property.
|
//! Adds the property to the model and attaches it to the parent property.
|
||||||
//! \param property The property to add
|
//! \param property The property to add
|
||||||
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added. If the property was filed under another ID before, that will no longer be valid.
|
//! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added.
|
||||||
|
//! If the property was filed under another ID before, that will no longer be valid.
|
||||||
//! \param parentid The property to which to add the property as child. Pass NULL to add it to the root properties.
|
//! \param parentid The property to which to add the property as child. Pass NULL to add it to the root properties.
|
||||||
virtual bool addProperty(VProperty* property, const QString& id, VProperty* parent_property = nullptr);
|
virtual bool addProperty(VProperty* property, const QString& id, VProperty* parent_property = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,17 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
class VPropertySetPrivate {
|
class VPropertySetPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! Property map (ID, Property)
|
//! Property map (ID, Property)
|
||||||
QMap<QString, VProperty*> Properties; // All the Properties managed by this model are being stored in this map for quick access
|
QMap<QString, VProperty*> Properties; // All the Properties managed by this model are being stored in this map for
|
||||||
|
//quick access
|
||||||
|
|
||||||
//! List containing the root properties
|
//! List containing the root properties
|
||||||
QList<VProperty*> RootProperties;
|
QList<VProperty*> RootProperties;
|
||||||
|
|
|
@ -39,15 +39,19 @@ VPropertyTreeView::VPropertyTreeView(VPropertyModel *model, QWidget *parent)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
if (model)
|
if (model)
|
||||||
|
{
|
||||||
setModel(model);
|
setModel(model);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyTreeView::VPropertyTreeView(VPropertyTreeViewPrivate *d, bool init_, QWidget *parent)
|
VPropertyTreeView::VPropertyTreeView(VPropertyTreeViewPrivate *d, bool init_, QWidget *parent)
|
||||||
: QTreeView(parent), d_ptr(d)
|
: QTreeView(parent), d_ptr(d)
|
||||||
{
|
{
|
||||||
if (init_)
|
if (init_)
|
||||||
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyTreeView::~VPropertyTreeView()
|
VPropertyTreeView::~VPropertyTreeView()
|
||||||
{
|
{
|
||||||
|
@ -73,5 +77,3 @@ void VPropertyTreeView::init()
|
||||||
|
|
||||||
setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
|
setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyTreeViewPrivate;
|
class VPropertyTreeViewPrivate;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VPropertyDelegate;
|
class VPropertyDelegate;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ VSerializedProperty::VSerializedProperty()
|
||||||
VSerializedProperty::VSerializedProperty(const VProperty* property, const VPropertySet* set)
|
VSerializedProperty::VSerializedProperty(const VProperty* property, const VPropertySet* set)
|
||||||
: ID(), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant())
|
: ID(), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant())
|
||||||
{
|
{
|
||||||
if(set) {
|
if (set)
|
||||||
|
{
|
||||||
ID = set->getPropertyID(property);
|
ID = set->getPropertyID(property);
|
||||||
|
|
||||||
initChildren(property, set);
|
initChildren(property, set);
|
||||||
|
@ -58,12 +59,13 @@ VPE::VSerializedProperty::~VSerializedProperty()
|
||||||
|
|
||||||
void VSerializedProperty::initChildren(const VProperty *property, const VPropertySet *set)
|
void VSerializedProperty::initChildren(const VProperty *property, const VPropertySet *set)
|
||||||
{
|
{
|
||||||
if(property && set) {
|
if (property && set)
|
||||||
|
{
|
||||||
const QList<VProperty*>& tmpChildren = property->getChildren();
|
const QList<VProperty*>& tmpChildren = property->getChildren();
|
||||||
foreach(const VProperty* tmpChild, tmpChildren) {
|
foreach(const VProperty* tmpChild, tmpChildren)
|
||||||
|
{
|
||||||
QString tmpChildID = set->getPropertyID(property);
|
QString tmpChildID = set->getPropertyID(property);
|
||||||
Children.append(VSerializedProperty(tmpChild, tmpChildID, set));
|
Children.append(VSerializedProperty(tmpChild, tmpChildID, set));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
#include "vpropertyset.h"
|
#include "vpropertyset.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty
|
||||||
|
|
|
@ -44,7 +44,8 @@ VStandardPropertyFactory::VStandardPropertyFactory()
|
||||||
VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *manager)
|
VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *manager)
|
||||||
: VAbstractPropertyFactory()
|
: VAbstractPropertyFactory()
|
||||||
{
|
{
|
||||||
if(manager) {
|
if (manager)
|
||||||
|
{
|
||||||
manager->registerFactory("string", this);
|
manager->registerFactory("string", this);
|
||||||
manager->registerFactory("bool", this);
|
manager->registerFactory("bool", this);
|
||||||
manager->registerFactory("color", this);
|
manager->registerFactory("color", this);
|
||||||
|
@ -60,25 +61,44 @@ VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *mana
|
||||||
|
|
||||||
VProperty *VStandardPropertyFactory::createProperty(const QString &type, const QString &name)
|
VProperty *VStandardPropertyFactory::createProperty(const QString &type, const QString &name)
|
||||||
{
|
{
|
||||||
if(type == QString("string")) {
|
if (type == QString("string"))
|
||||||
|
{
|
||||||
return new VProperty(name);
|
return new VProperty(name);
|
||||||
} else if(type == QString("bool")) {
|
}
|
||||||
|
else if (type == QString("bool"))
|
||||||
|
{
|
||||||
return new VBoolProperty(name);
|
return new VBoolProperty(name);
|
||||||
} else if(type == QString("color")) {
|
}
|
||||||
|
else if (type == QString("color"))
|
||||||
|
{
|
||||||
return new VColorProperty(name);
|
return new VColorProperty(name);
|
||||||
} else if(type == QString("empty")) {
|
}
|
||||||
|
else if (type == QString("empty"))
|
||||||
|
{
|
||||||
return new VEmptyProperty(name);
|
return new VEmptyProperty(name);
|
||||||
} else if(type == QString("enum")) {
|
}
|
||||||
|
else if (type == QString("enum"))
|
||||||
|
{
|
||||||
return new VEnumProperty(name);
|
return new VEnumProperty(name);
|
||||||
} else if(type == QString("file")) {
|
}
|
||||||
|
else if (type == QString("file"))
|
||||||
|
{
|
||||||
return new VFileProperty(name);
|
return new VFileProperty(name);
|
||||||
} else if(type == QString("integer")) {
|
}
|
||||||
|
else if (type == QString("integer"))
|
||||||
|
{
|
||||||
return new VIntegerProperty(name);
|
return new VIntegerProperty(name);
|
||||||
} else if(type == QString("double")) {
|
}
|
||||||
|
else if (type == QString("double"))
|
||||||
|
{
|
||||||
return new VDoubleProperty(name);
|
return new VDoubleProperty(name);
|
||||||
} else if(type == QString("shortcut")) {
|
}
|
||||||
|
else if (type == QString("shortcut"))
|
||||||
|
{
|
||||||
return new VShortcutProperty(name);
|
return new VShortcutProperty(name);
|
||||||
} else if(type == QString("vector3d")) {
|
}
|
||||||
|
else if (type == QString("vector3d"))
|
||||||
|
{
|
||||||
return new QVector3DProperty(name);
|
return new QVector3DProperty(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vabstractpropertyfactory.h"
|
#include "vabstractpropertyfactory.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,11 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE
|
||||||
|
{
|
||||||
|
|
||||||
class VWidgetPropertyPrivate : public VPropertyPrivate {
|
class VWidgetPropertyPrivate : public VPropertyPrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! The widget to show
|
//! The widget to show
|
||||||
QPointer<QWidget> Widget;
|
QPointer<QWidget> Widget;
|
||||||
|
@ -44,10 +46,13 @@ public:
|
||||||
: VPropertyPrivate(), Widget(nullptr) {}
|
: VPropertyPrivate(), Widget(nullptr) {}
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VWidgetPropertyPrivate() {
|
~VWidgetPropertyPrivate()
|
||||||
|
{
|
||||||
if (Widget)
|
if (Widget)
|
||||||
|
{
|
||||||
Widget->deleteLater();
|
Widget->deleteLater();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user