Unix Line Endings.
--HG-- branch : develop
This commit is contained in:
parent
750288fa7e
commit
9a735b29bf
|
@ -1,133 +1,133 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vvector3dproperty.cpp
|
** @file vvector3dproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vvector3dproperty.h"
|
#include "vvector3dproperty.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
#include "../vnumberproperty.h"
|
#include "../vnumberproperty.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
QVector3DProperty::QVector3DProperty(const QString& name)
|
QVector3DProperty::QVector3DProperty(const QString& name)
|
||||||
: VProperty(name, QVariant::String) // todo: QVariant::Vector3D??
|
: VProperty(name, QVariant::String) // todo: QVariant::Vector3D??
|
||||||
{
|
{
|
||||||
QVariant tmpFloat(0); tmpFloat.convert(QVariant::Double);
|
QVariant tmpFloat(0); tmpFloat.convert(QVariant::Double);
|
||||||
VDoubleProperty* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false);
|
VDoubleProperty* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false);
|
||||||
VDoubleProperty* tmpY = new VDoubleProperty("Y"); addChild(tmpY); tmpY->setUpdateBehaviour(true, false);
|
VDoubleProperty* tmpY = new VDoubleProperty("Y"); addChild(tmpY); tmpY->setUpdateBehaviour(true, false);
|
||||||
VDoubleProperty* tmpZ = new VDoubleProperty("Z"); addChild(tmpZ); tmpZ->setUpdateBehaviour(true, false);
|
VDoubleProperty* tmpZ = new VDoubleProperty("Z"); addChild(tmpZ); tmpZ->setUpdateBehaviour(true, false);
|
||||||
setVector(Vector3D());
|
setVector(Vector3D());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
QVariant QVector3DProperty::data (int column, int role) const
|
QVariant QVector3DProperty::data (int column, int role) const
|
||||||
{
|
{
|
||||||
if(column == DPC_Data && Qt::DisplayRole == role)
|
if(column == DPC_Data && Qt::DisplayRole == role)
|
||||||
{
|
{
|
||||||
Vector3D tmpVect = getVector();
|
Vector3D tmpVect = getVector();
|
||||||
return QString("(%1, %2, %3)").arg(QString::number(tmpVect.X),
|
return QString("(%1, %2, %3)").arg(QString::number(tmpVect.X),
|
||||||
QString::number(tmpVect.Y),
|
QString::number(tmpVect.Y),
|
||||||
QString::number(tmpVect.Z));
|
QString::number(tmpVect.Z));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns the Vector3d
|
//! Returns the Vector3d
|
||||||
Vector3D QVector3DProperty::getVector() const
|
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();
|
||||||
tmpVect.Z = d_ptr->Children.at(2)->getValue().toFloat();
|
tmpVect.Z = d_ptr->Children.at(2)->getValue().toFloat();
|
||||||
|
|
||||||
return tmpVect;
|
return tmpVect;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the Vector3d
|
//! Sets the Vector3d
|
||||||
void QVector3DProperty::setVector(const Vector3D &vect)
|
void QVector3DProperty::setVector(const Vector3D &vect)
|
||||||
{
|
{
|
||||||
setVector(vect.X, vect.Y, vect.Z);
|
setVector(vect.X, vect.Y, vect.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
QVariant tmpZ(z); tmpZ.convert(QVariant::Double);
|
QVariant tmpZ(z); tmpZ.convert(QVariant::Double);
|
||||||
d_ptr->Children.at(0)->setValue(tmpX);
|
d_ptr->Children.at(0)->setValue(tmpX);
|
||||||
d_ptr->Children.at(1)->setValue(tmpY);
|
d_ptr->Children.at(1)->setValue(tmpY);
|
||||||
d_ptr->Children.at(2)->setValue(tmpZ);
|
d_ptr->Children.at(2)->setValue(tmpZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QVector3DProperty::type() const
|
QString QVector3DProperty::type() const
|
||||||
{
|
{
|
||||||
return "vector3d";
|
return "vector3d";
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VProperty::clone(false, container); // Child
|
return VProperty::clone(false, container); // Child
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QVector3DProperty::getValue() const
|
QVariant QVector3DProperty::getValue() const
|
||||||
{
|
{
|
||||||
Vector3D tmpVect = getVector();
|
Vector3D tmpVect = getVector();
|
||||||
return QString("%1,%2,%3").arg(QString::number(tmpVect.X), QString::number(tmpVect.Y), QString::number(tmpVect.Z));
|
return QString("%1,%2,%3").arg(QString::number(tmpVect.X), QString::number(tmpVect.Y), QString::number(tmpVect.Z));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,97 +1,97 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vvector3dproperty.h
|
** @file vvector3dproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VVECTOR3DPROPERTY_H
|
#ifndef VVECTOR3DPROPERTY_H
|
||||||
#define VVECTOR3DPROPERTY_H
|
#define VVECTOR3DPROPERTY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE{
|
||||||
|
|
||||||
struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D
|
struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Vector3D()
|
Vector3D()
|
||||||
{
|
{
|
||||||
X = Y = Z = 0;
|
X = Y = Z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3D(const Vector3D& other)
|
Vector3D(const Vector3D& other)
|
||||||
{
|
{
|
||||||
X = other.X;
|
X = other.X;
|
||||||
Y = other.Y;
|
Y = other.Y;
|
||||||
Z = other.Z;
|
Z = other.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Vector3D() {}
|
~Vector3D() {}
|
||||||
|
|
||||||
float X, Y, Z;
|
float X, Y, Z;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QPE::Vector3D) // todo
|
Q_DECLARE_METATYPE(QPE::Vector3D) // todo
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT QVector3DProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT QVector3DProperty : public VProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVector3DProperty(const QString& name);
|
QVector3DProperty(const QString& name);
|
||||||
|
|
||||||
virtual ~QVector3DProperty() {}
|
virtual ~QVector3DProperty() {}
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
Qt::ItemFlags flags(int column = DPC_Name) const;
|
Qt::ItemFlags flags(int column = DPC_Name) const;
|
||||||
|
|
||||||
//! Returns the Vector3d
|
//! Returns the Vector3d
|
||||||
virtual Vector3D getVector() const;
|
virtual Vector3D getVector() const;
|
||||||
|
|
||||||
//! Sets the Vector3d
|
//! Sets the Vector3d
|
||||||
virtual void setVector(const Vector3D& vect);
|
virtual void setVector(const Vector3D& vect);
|
||||||
|
|
||||||
//! Sets the Vector3d
|
//! Sets the Vector3d
|
||||||
virtual void setVector(float x, float y, float z);
|
virtual void setVector(float x, float y, float z);
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
//! Sets the value of the property
|
//! Sets the value of the property
|
||||||
virtual void setValue(const QVariant& value);
|
virtual void setValue(const QVariant& value);
|
||||||
|
|
||||||
//! Returns the value of the property as a QVariant
|
//! Returns the value of the property as a QVariant
|
||||||
virtual QVariant getValue() const;
|
virtual QVariant getValue() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VVECTOR3DPROPERTY_H
|
#endif // VVECTOR3DPROPERTY_H
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vboolproperty.cpp
|
** @file vboolproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vboolproperty.h"
|
#include "vboolproperty.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
QVariant VBoolProperty::TrueText;
|
QVariant VBoolProperty::TrueText;
|
||||||
QVariant VBoolProperty::FalseText;
|
QVariant VBoolProperty::FalseText;
|
||||||
|
|
||||||
VBoolProperty::VBoolProperty(const QString& name) :
|
VBoolProperty::VBoolProperty(const QString& name) :
|
||||||
VProperty(name, QVariant::Bool)
|
VProperty(name, QVariant::Bool)
|
||||||
{
|
{
|
||||||
d_ptr->VariantValue.setValue(false);
|
d_ptr->VariantValue.setValue(false);
|
||||||
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()) TrueText = QObject::tr("True");
|
||||||
if(TrueText.isNull()) FalseText = QObject::tr("False");
|
if(TrueText.isNull()) FalseText = QObject::tr("False");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VBoolProperty::setData(const QVariant &data, int role)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VBoolProperty::type() const
|
QString VBoolProperty::type() const
|
||||||
{
|
{
|
||||||
return "bool";
|
return "bool";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty *VBoolProperty::clone(bool include_children, VProperty *container) const
|
VProperty *VBoolProperty::clone(bool include_children, VProperty *container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VBoolProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VBoolProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vboolproperty.h
|
** @file vboolproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VBOOLPROPERTY_H
|
#ifndef VBOOLPROPERTY_H
|
||||||
#define VBOOLPROPERTY_H
|
#define VBOOLPROPERTY_H
|
||||||
|
|
||||||
#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
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
VBoolProperty(const QString& name);
|
VBoolProperty(const QString& name);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VBoolProperty() {}
|
~VBoolProperty() {}
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
//! This is used by the model to set the data
|
//! This is used by the model to set the data
|
||||||
//! \param data The data to set
|
//! \param data The data to set
|
||||||
//! \param role The role. Default is Qt::EditRole
|
//! \param role The role. Default is Qt::EditRole
|
||||||
//! \return Returns true, if the data was changed, false if not.
|
//! \return Returns true, if the data was changed, false if not.
|
||||||
virtual bool setData (const QVariant& data, int role = Qt::EditRole);
|
virtual bool setData (const QVariant& data, int role = Qt::EditRole);
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
virtual Qt::ItemFlags flags(int column = DPC_Name) const;
|
virtual Qt::ItemFlags flags(int column = DPC_Name) const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! The (translatable) text displayed when the property is set to true (default: "True")
|
//! The (translatable) text displayed when the property is set to true (default: "True")
|
||||||
static QVariant TrueText;
|
static QVariant TrueText;
|
||||||
|
|
||||||
//! The (translatable) text displayed when the property is set to false (default: "False")
|
//! The (translatable) text displayed when the property is set to false (default: "False")
|
||||||
static QVariant FalseText;
|
static QVariant FalseText;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VBOOLPROPERTY_H
|
#endif // VBOOLPROPERTY_H
|
||||||
|
|
|
@ -1,88 +1,88 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vcolorproperty.cpp
|
** @file vcolorproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vcolorproperty.h"
|
#include "vcolorproperty.h"
|
||||||
#include "vcolorpropertyeditor.h"
|
#include "vcolorpropertyeditor.h"
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VColorProperty::VColorProperty(const QString &name) :
|
VColorProperty::VColorProperty(const QString &name) :
|
||||||
VProperty(name, QVariant::Color)
|
VProperty(name, QVariant::Color)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
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);
|
||||||
|
|
||||||
VColorPropertyEditor* tmpWidget = new VColorPropertyEditor(parent);
|
VColorPropertyEditor* tmpWidget = new VColorPropertyEditor(parent);
|
||||||
tmpWidget->setColor(d_ptr->VariantValue.value<QColor>());
|
tmpWidget->setColor(d_ptr->VariantValue.value<QColor>());
|
||||||
return tmpWidget;
|
return tmpWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! 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)
|
||||||
bool VColorProperty::setEditorData(QWidget* editor)
|
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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
QVariant VColorProperty::getEditorData(QWidget* editor) const
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VColorProperty::type() const
|
QString VColorProperty::type() const
|
||||||
{
|
{
|
||||||
return "color";
|
return "color";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty *VColorProperty::clone(bool include_children, VProperty *container) const
|
VProperty *VColorProperty::clone(bool include_children, VProperty *container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VColorProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VColorProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vcolorproperty.h
|
** @file vcolorproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VCOLORPROPERTY_H
|
#ifndef VCOLORPROPERTY_H
|
||||||
#define VCOLORPROPERTY_H
|
#define VCOLORPROPERTY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VColorProperty(const QString &name);
|
VColorProperty(const QString &name);
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) 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 slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
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);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VCOLORPROPERTY_H
|
#endif // VCOLORPROPERTY_H
|
||||||
|
|
|
@ -1,135 +1,135 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vcolorpropertyeditor.cpp
|
** @file vcolorpropertyeditor.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vcolorpropertyeditor.h"
|
#include "vcolorpropertyeditor.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) :
|
VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
setAutoFillBackground(true);
|
setAutoFillBackground(true);
|
||||||
|
|
||||||
// Create the tool button
|
// Create the tool button
|
||||||
ToolButton = new QToolButton(this);
|
ToolButton = new QToolButton(this);
|
||||||
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||||
ToolButton->setText(tr("..."));
|
ToolButton->setText(tr("..."));
|
||||||
ToolButton->setFixedWidth(20);
|
ToolButton->setFixedWidth(20);
|
||||||
ToolButton->installEventFilter(this);
|
ToolButton->installEventFilter(this);
|
||||||
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
||||||
setFocusPolicy(ToolButton->focusPolicy());
|
setFocusPolicy(ToolButton->focusPolicy());
|
||||||
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
||||||
|
|
||||||
// Create the text label
|
// Create the text label
|
||||||
TextLabel = new QLabel(this);
|
TextLabel = new QLabel(this);
|
||||||
TextLabel->setText(getColorString(Color));
|
TextLabel->setText(getColorString(Color));
|
||||||
|
|
||||||
// Create the label for the pixmap
|
// Create the label for the pixmap
|
||||||
ColorLabel = new QLabel(this);
|
ColorLabel = new QLabel(this);
|
||||||
ColorLabel->setPixmap(getColorPixmap(Color));
|
ColorLabel->setPixmap(getColorPixmap(Color));
|
||||||
|
|
||||||
// Spacer (this is needed for proper display of the label and button)
|
// Spacer (this is needed for proper display of the label and button)
|
||||||
Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored);
|
Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored);
|
||||||
|
|
||||||
// The layout (a horizontal layout)
|
// The layout (a horizontal layout)
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
layout->setSpacing(3);
|
layout->setSpacing(3);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(ColorLabel);
|
layout->addWidget(ColorLabel);
|
||||||
layout->addWidget(TextLabel);
|
layout->addWidget(TextLabel);
|
||||||
layout->addItem(Spacer);
|
layout->addItem(Spacer);
|
||||||
layout->addWidget(ToolButton);
|
layout->addWidget(ToolButton);
|
||||||
//TextLabel->hide();
|
//TextLabel->hide();
|
||||||
//ColorLabel->hide(); // for now, we just use the standard display and only add the button
|
//ColorLabel->hide(); // for now, we just use the standard display and only add the button
|
||||||
}
|
}
|
||||||
|
|
||||||
void VColorPropertyEditor::setColor(const QColor& color_)
|
void VColorPropertyEditor::setColor(const QColor& color_)
|
||||||
{
|
{
|
||||||
if (Color != color_)
|
if (Color != color_)
|
||||||
{
|
{
|
||||||
Color = color_;
|
Color = color_;
|
||||||
ColorLabel->setPixmap(getColorPixmap(Color));
|
ColorLabel->setPixmap(getColorPixmap(Color));
|
||||||
TextLabel->setText(getColorString(Color));
|
TextLabel->setText(getColorString(Color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap VColorPropertyEditor::getColorPixmap(const QColor& color, unsigned int size)
|
QPixmap VColorPropertyEditor::getColorPixmap(const QColor& color, unsigned int size)
|
||||||
{
|
{
|
||||||
QImage tmpImgage(size, size, QImage::Format_ARGB32_Premultiplied);
|
QImage tmpImgage(size, size, QImage::Format_ARGB32_Premultiplied);
|
||||||
tmpImgage.fill(static_cast<unsigned int>(color.rgb()));
|
tmpImgage.fill(static_cast<unsigned int>(color.rgb()));
|
||||||
return QPixmap::fromImage(tmpImgage);
|
return QPixmap::fromImage(tmpImgage);
|
||||||
// todo: support alpha channel
|
// todo: support alpha channel
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VColorPropertyEditor::getColorString(const QColor& color)
|
QString VColorPropertyEditor::getColorString(const QColor& color)
|
||||||
{
|
{
|
||||||
return QApplication::translate("QtPropertyExplorer", "[%1, %2, %3] (%4)", "Colors as string")
|
return QApplication::translate("QtPropertyExplorer", "[%1, %2, %3] (%4)", "Colors as string")
|
||||||
.arg(QString::number(color.red()))
|
.arg(QString::number(color.red()))
|
||||||
.arg(QString::number(color.green()))
|
.arg(QString::number(color.green()))
|
||||||
.arg(QString::number(color.blue()))
|
.arg(QString::number(color.blue()))
|
||||||
.arg(QString::number(color.alpha()));
|
.arg(QString::number(color.alpha()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VColorPropertyEditor::onToolButtonClicked()
|
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();
|
||||||
QCoreApplication::postEvent ( this, event );
|
QCoreApplication::postEvent ( this, event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VColorPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
|
bool VColorPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
||||||
{
|
{
|
||||||
// Ignore the event, so that eventually the delegate gets the event.
|
// Ignore the event, so that eventually the delegate gets the event.
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(obj, ev);
|
return QWidget::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VColorPropertyEditor::~VColorPropertyEditor()
|
VColorPropertyEditor::~VColorPropertyEditor()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QColor VColorPropertyEditor::getColor()
|
QColor VColorPropertyEditor::getColor()
|
||||||
{
|
{
|
||||||
return Color;
|
return Color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vcolorpropertyeditor.h
|
** @file vcolorpropertyeditor.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VCOLORPROPERTYEDITOR_H
|
#ifndef VCOLORPROPERTYEDITOR_H
|
||||||
#define VCOLORPROPERTYEDITOR_H
|
#define VCOLORPROPERTYEDITOR_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor taking a widget as parent
|
//! Constructor taking a widget as parent
|
||||||
VColorPropertyEditor(QWidget *parent);
|
VColorPropertyEditor(QWidget *parent);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VColorPropertyEditor();
|
virtual ~VColorPropertyEditor();
|
||||||
|
|
||||||
|
|
||||||
//! Returns the color currently set
|
//! Returns the color currently set
|
||||||
QColor getColor();
|
QColor getColor();
|
||||||
|
|
||||||
//! A little helper function generating an image to represent a color
|
//! A little helper function generating an image to represent a color
|
||||||
//! \param color The color to fill the image with
|
//! \param color The color to fill the image with
|
||||||
//! \size The size of the generated pixmap
|
//! \size The size of the generated pixmap
|
||||||
//! \return Returns a QPixmap
|
//! \return Returns a QPixmap
|
||||||
static QPixmap getColorPixmap(const QColor& color, unsigned int size = 16);
|
static QPixmap getColorPixmap(const QColor& color, unsigned int size = 16);
|
||||||
|
|
||||||
//! A helper function to convert a color into a string.
|
//! A helper function to convert a color into a string.
|
||||||
//! \param color The color to fill the image with
|
//! \param color The color to fill the image with
|
||||||
//! \return The color as string, usually in the format [RRR, GGG, BBB] (AAA)
|
//! \return The color as string, usually in the format [RRR, GGG, BBB] (AAA)
|
||||||
static QString getColorString(const QColor& color);
|
static QString getColorString(const QColor& color);
|
||||||
|
|
||||||
//! Needed for proper event handling
|
//! Needed for proper event handling
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! This is emitted, when the user changes the color
|
//! This is emitted, when the user changes the color
|
||||||
void dataChangedByUser(const QColor &getColor, VColorPropertyEditor* editor);
|
void dataChangedByUser(const QColor &getColor, VColorPropertyEditor* editor);
|
||||||
|
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Sets the color of the widget
|
//! Sets the color of the widget
|
||||||
void setColor(const QColor &color_);
|
void setColor(const QColor &color_);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onToolButtonClicked();
|
void onToolButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QColor Color;
|
QColor Color;
|
||||||
QToolButton* ToolButton;
|
QToolButton* ToolButton;
|
||||||
QLineEdit* Lineedit;
|
QLineEdit* Lineedit;
|
||||||
QLabel* TextLabel;
|
QLabel* TextLabel;
|
||||||
QLabel* ColorLabel;
|
QLabel* ColorLabel;
|
||||||
QSpacerItem* Spacer;
|
QSpacerItem* Spacer;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QFILEPROPERTYEDITOR_H
|
#endif // QFILEPROPERTYEDITOR_H
|
||||||
|
|
|
@ -1,90 +1,90 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vemptyproperty.cpp
|
** @file vemptyproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vemptyproperty.h"
|
#include "vemptyproperty.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VEmptyProperty::VEmptyProperty(const QString& name)
|
VEmptyProperty::VEmptyProperty(const QString& name)
|
||||||
: VProperty(name, QVariant::Invalid)
|
: VProperty(name, QVariant::Invalid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VEmptyProperty::VEmptyProperty(VPropertyPrivate *d)
|
VEmptyProperty::VEmptyProperty(VPropertyPrivate *d)
|
||||||
: VProperty(d)
|
: VProperty(d)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VEmptyProperty::~VEmptyProperty()
|
VEmptyProperty::~VEmptyProperty()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
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);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
QVariant VEmptyProperty::getEditorData(QWidget* editor) const
|
QVariant VEmptyProperty::getEditorData(QWidget* editor) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(editor);
|
Q_UNUSED(editor);
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
Qt::ItemFlags VEmptyProperty::flags(int column) const
|
Qt::ItemFlags VEmptyProperty::flags(int column) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(column);
|
Q_UNUSED(column);
|
||||||
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VEmptyProperty::type() const
|
QString VEmptyProperty::type() const
|
||||||
{
|
{
|
||||||
return "empty";
|
return "empty";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty* VEmptyProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VEmptyProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VEmptyProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VEmptyProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +1,68 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vemptyproperty.h
|
** @file vemptyproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VEMPTYPROPERTY_H
|
#ifndef VEMPTYPROPERTY_H
|
||||||
#define VEMPTYPROPERTY_H
|
#define VEMPTYPROPERTY_H
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Standard constructor, takes a name and a parent property as argument
|
//! Standard constructor, takes a name and a parent property as argument
|
||||||
explicit VEmptyProperty(const QString& name);
|
explicit VEmptyProperty(const QString& name);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VEmptyProperty();
|
virtual ~VEmptyProperty();
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) 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 slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
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;
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
virtual Qt::ItemFlags flags(int column = DPC_Name) const;
|
virtual Qt::ItemFlags flags(int column = DPC_Name) const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Protected constructor
|
//! Protected constructor
|
||||||
VEmptyProperty(VPropertyPrivate* d);
|
VEmptyProperty(VPropertyPrivate* d);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VEMPTYPROPERTY_H
|
#endif // VEMPTYPROPERTY_H
|
||||||
|
|
|
@ -1,146 +1,146 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file venumproperty.cpp
|
** @file venumproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "venumproperty.h"
|
#include "venumproperty.h"
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VEnumProperty::VEnumProperty(const QString& name)
|
VEnumProperty::VEnumProperty(const QString& name)
|
||||||
: VProperty(name, QVariant::Int)
|
: VProperty(name, QVariant::Int)
|
||||||
{
|
{
|
||||||
VProperty::d_ptr->VariantValue = 0;
|
VProperty::d_ptr->VariantValue = 0;
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
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);
|
||||||
QComboBox* tmpEditor = new QComboBox(parent);
|
QComboBox* tmpEditor = new QComboBox(parent);
|
||||||
tmpEditor->clear();
|
tmpEditor->clear();
|
||||||
tmpEditor->addItems(EnumerationLiterals);
|
tmpEditor->addItems(EnumerationLiterals);
|
||||||
tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt());
|
tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt());
|
||||||
connect(tmpEditor, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
connect(tmpEditor, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||||
&VEnumProperty::currentIndexChanged);
|
&VEnumProperty::currentIndexChanged);
|
||||||
|
|
||||||
VProperty::d_ptr->editor = tmpEditor;
|
VProperty::d_ptr->editor = tmpEditor;
|
||||||
return VProperty::d_ptr->editor;
|
return VProperty::d_ptr->editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
QVariant VEnumProperty::getEditorData(QWidget* editor) const
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the enumeration literals
|
//! Sets the enumeration literals
|
||||||
void VEnumProperty::setLiterals(const QStringList& literals)
|
void VEnumProperty::setLiterals(const QStringList& literals)
|
||||||
{
|
{
|
||||||
EnumerationLiterals = literals;
|
EnumerationLiterals = literals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
QStringList VEnumProperty::getLiterals() const
|
QStringList VEnumProperty::getLiterals() const
|
||||||
{
|
{
|
||||||
return EnumerationLiterals;
|
return EnumerationLiterals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the value of the property
|
//! Sets the value of the property
|
||||||
void VEnumProperty::setValue(const QVariant& value)
|
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);
|
||||||
|
|
||||||
if (VProperty::d_ptr->editor != nullptr)
|
if (VProperty::d_ptr->editor != nullptr)
|
||||||
{
|
{
|
||||||
setEditorData(VProperty::d_ptr->editor);
|
setEditorData(VProperty::d_ptr->editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VEnumProperty::type() const
|
QString VEnumProperty::type() const
|
||||||
{
|
{
|
||||||
return "enum";
|
return "enum";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty* VEnumProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VEnumProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VEnumProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VEnumProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList VEnumProperty::getSettingKeys() const
|
QStringList VEnumProperty::getSettingKeys() const
|
||||||
{
|
{
|
||||||
return QStringList("literals");
|
return QStringList("literals");
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEnumProperty::currentIndexChanged(int index)
|
void VEnumProperty::currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
UserChangeEvent *event = new UserChangeEvent();
|
UserChangeEvent *event = new UserChangeEvent();
|
||||||
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,92 +1,92 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file venumproperty.h
|
** @file venumproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VENUMPROPERTY_H
|
#ifndef VENUMPROPERTY_H
|
||||||
#define VENUMPROPERTY_H
|
#define VENUMPROPERTY_H
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE{
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VEnumProperty(const QString& name);
|
VEnumProperty(const QString& name);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VEnumProperty() {}
|
~VEnumProperty() {}
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) 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 slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
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;
|
||||||
|
|
||||||
//! Sets the enumeration literals
|
//! Sets the enumeration literals
|
||||||
virtual void setLiterals(const QStringList &literals);
|
virtual void setLiterals(const QStringList &literals);
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual QStringList getLiterals() const;
|
virtual QStringList getLiterals() const;
|
||||||
|
|
||||||
//! Sets the value of the property
|
//! Sets the value of the property
|
||||||
virtual void setValue(const QVariant& value);
|
virtual void setValue(const QVariant& value);
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
//! Sets the settings. Available settings:
|
//! Sets the settings. Available settings:
|
||||||
//!
|
//!
|
||||||
//! key: "literals" - value: "item1;;item2;;item3"
|
//! key: "literals" - value: "item1;;item2;;item3"
|
||||||
virtual void setSetting(const QString& key, const QVariant& value);
|
virtual void setSetting(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual QVariant getSetting(const QString& key) const;
|
virtual QVariant getSetting(const QString& key) const;
|
||||||
|
|
||||||
//! Returns the list of keys of the property's settings
|
//! Returns the list of keys of the property's settings
|
||||||
virtual QStringList getSettingKeys() const;
|
virtual QStringList getSettingKeys() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void currentIndexChanged(int index);
|
void currentIndexChanged(int index);
|
||||||
|
|
||||||
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.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VENUMPROPERTY_H
|
#endif // VENUMPROPERTY_H
|
||||||
|
|
|
@ -1,156 +1,156 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vfileproperty.cpp
|
** @file vfileproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vfileproperty.h"
|
#include "vfileproperty.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
|
|
||||||
#include "vfilepropertyeditor.h"
|
#include "vfilepropertyeditor.h"
|
||||||
|
|
||||||
#include "vfileproperty_p.h"
|
#include "vfileproperty_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VFileProperty::VFileProperty(const QString& name)
|
VFileProperty::VFileProperty(const QString& name)
|
||||||
: VProperty(new VFilePropertyPrivate(name, QVariant::String))
|
: VProperty(new VFilePropertyPrivate(name, QVariant::String))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VFileProperty::~VFileProperty()
|
VFileProperty::~VFileProperty()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VFileProperty::setFileFilters(const QString& filefilters)
|
void VFileProperty::setFileFilters(const QString& filefilters)
|
||||||
{
|
{
|
||||||
static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters = filefilters;
|
static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters = filefilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString VFileProperty::getFileFilters() const
|
QString VFileProperty::getFileFilters() const
|
||||||
{
|
{
|
||||||
return static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters;
|
return static_cast<VFilePropertyPrivate*>(d_ptr)->FileFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VFileProperty::setFile(const QString& file)
|
void VFileProperty::setFile(const QString& file)
|
||||||
{
|
{
|
||||||
d_ptr->VariantValue.setValue(file);
|
d_ptr->VariantValue.setValue(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString VFileProperty::getFile() const
|
QString VFileProperty::getFile() const
|
||||||
{
|
{
|
||||||
return d_ptr->VariantValue.toString();
|
return d_ptr->VariantValue.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant VFileProperty::data (int column, int role) const
|
QVariant VFileProperty::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))
|
||||||
{
|
{
|
||||||
QFileInfo tmpFile(d_ptr->VariantValue.toString());
|
QFileInfo tmpFile(d_ptr->VariantValue.toString());
|
||||||
return tmpFile.fileName();
|
return tmpFile.fileName();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
return tmpWidget;
|
return tmpWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VFileProperty::setEditorData(QWidget* editor)
|
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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant VFileProperty::getEditorData(QWidget* editor) const
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList VFileProperty::getSettingKeys() const
|
QStringList VFileProperty::getSettingKeys() const
|
||||||
{
|
{
|
||||||
return QStringList("FileFilters") << "Directory";
|
return QStringList("FileFilters") << "Directory";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VFileProperty::type() const
|
QString VFileProperty::type() const
|
||||||
{
|
{
|
||||||
return "file";
|
return "file";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty* VFileProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VFileProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VFileProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VFileProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VFileProperty::isDirectory() const
|
bool VFileProperty::isDirectory() const
|
||||||
{
|
{
|
||||||
return static_cast<VFilePropertyPrivate*>(d_ptr)->Directory;
|
return static_cast<VFilePropertyPrivate*>(d_ptr)->Directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VFileProperty::setDirectory(bool is_directory)
|
void VFileProperty::setDirectory(bool is_directory)
|
||||||
{
|
{
|
||||||
static_cast<VFilePropertyPrivate*>(d_ptr)->Directory = is_directory;
|
static_cast<VFilePropertyPrivate*>(d_ptr)->Directory = is_directory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +1,96 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vfileproperty.h
|
** @file vfileproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VFILEPROPERTY_H
|
#ifndef VFILEPROPERTY_H
|
||||||
#define VFILEPROPERTY_H
|
#define VFILEPROPERTY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VFileProperty(const QString &name);
|
VFileProperty(const QString &name);
|
||||||
|
|
||||||
//! The destructor
|
//! The destructor
|
||||||
~VFileProperty();
|
~VFileProperty();
|
||||||
|
|
||||||
//! Sets the file filters. The file filters have to be like the ones passed a QFileOpenDialog.
|
//! Sets the file filters. The file filters have to be like the ones passed a QFileOpenDialog.
|
||||||
virtual void setFileFilters(const QString& filefilters);
|
virtual void setFileFilters(const QString& filefilters);
|
||||||
|
|
||||||
//! Returns the current file filters as a string
|
//! Returns the current file filters as a string
|
||||||
virtual QString getFileFilters() const;
|
virtual QString getFileFilters() const;
|
||||||
|
|
||||||
//! Set file
|
//! Set file
|
||||||
virtual void setFile(const QString& file);
|
virtual void setFile(const QString& file);
|
||||||
|
|
||||||
//! Get file
|
//! Get file
|
||||||
virtual QString getFile() const;
|
virtual QString getFile() const;
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) 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 slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
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);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
|
||||||
//! Sets the settings. Available settings:
|
//! Sets the settings. Available settings:
|
||||||
//!
|
//!
|
||||||
//! key: "FileFilters" - value: File filters in the same format the QFileDialog expects it
|
//! key: "FileFilters" - value: File filters in the same format the QFileDialog expects it
|
||||||
virtual void setSetting(const QString& key, const QVariant& value);
|
virtual void setSetting(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual QVariant getSetting(const QString& key) const;
|
virtual QVariant getSetting(const QString& key) const;
|
||||||
|
|
||||||
//! Returns the list of keys of the property's settings
|
//! Returns the list of keys of the property's settings
|
||||||
virtual QStringList getSettingKeys() const;
|
virtual QStringList getSettingKeys() const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
//! Returns whether this is a file (false) or a directory (true)
|
//! Returns whether this is a file (false) or a directory (true)
|
||||||
virtual bool isDirectory() const;
|
virtual bool isDirectory() const;
|
||||||
|
|
||||||
//! Sets whether this is a file (false) or a directory (true)
|
//! Sets whether this is a file (false) or a directory (true)
|
||||||
virtual void setDirectory(bool is_directory);
|
virtual void setDirectory(bool is_directory);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VFILEPROPERTY_H
|
#endif // VFILEPROPERTY_H
|
||||||
|
|
|
@ -1,224 +1,224 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vfilepropertyeditor.cpp
|
** @file vfilepropertyeditor.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vfilepropertyeditor.h"
|
#include "vfilepropertyeditor.h"
|
||||||
|
|
||||||
#include "vfileproperty.h"
|
#include "vfileproperty.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VFileEditWidget::VFileEditWidget(QWidget *parent, bool is_directory)
|
VFileEditWidget::VFileEditWidget(QWidget *parent, bool is_directory)
|
||||||
: QWidget(parent), Directory(is_directory)
|
: QWidget(parent), Directory(is_directory)
|
||||||
{
|
{
|
||||||
// Create the tool button,ToolButton = new QToolButton(this);
|
// Create the tool button,ToolButton = new QToolButton(this);
|
||||||
ToolButton = new QToolButton(this);
|
ToolButton = new QToolButton(this);
|
||||||
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
|
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
|
||||||
ToolButton->setText(tr("..."));
|
ToolButton->setText(tr("..."));
|
||||||
ToolButton->setFixedWidth(20);
|
ToolButton->setFixedWidth(20);
|
||||||
ToolButton->installEventFilter(this);
|
ToolButton->installEventFilter(this);
|
||||||
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
|
||||||
setFocusPolicy(ToolButton->focusPolicy());
|
setFocusPolicy(ToolButton->focusPolicy());
|
||||||
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked()));
|
||||||
|
|
||||||
// Create the line edit widget
|
// Create the line edit widget
|
||||||
FileLineEdit = new QLineEdit(this);
|
FileLineEdit = new QLineEdit(this);
|
||||||
FileLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
FileLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
FileLineEdit->setText(CurrentFilePath);
|
FileLineEdit->setText(CurrentFilePath);
|
||||||
FileLineEdit->installEventFilter(this);
|
FileLineEdit->installEventFilter(this);
|
||||||
|
|
||||||
// The layout (a horizontal layout)
|
// The layout (a horizontal layout)
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(FileLineEdit);
|
layout->addWidget(FileLineEdit);
|
||||||
layout->addWidget(ToolButton);
|
layout->addWidget(ToolButton);
|
||||||
|
|
||||||
// Accept drops
|
// Accept drops
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VFileEditWidget::~VFileEditWidget()
|
VFileEditWidget::~VFileEditWidget()
|
||||||
{
|
{
|
||||||
// nothing needs to be done here
|
// nothing needs to be done here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VFileEditWidget::setFile(const QString &value, bool emit_signal)
|
void VFileEditWidget::setFile(const QString &value, bool emit_signal)
|
||||||
{
|
{
|
||||||
if (CurrentFilePath != value)
|
if (CurrentFilePath != value)
|
||||||
{
|
{
|
||||||
CurrentFilePath = value;
|
CurrentFilePath = value;
|
||||||
FileLineEdit->setText(CurrentFilePath);
|
FileLineEdit->setText(CurrentFilePath);
|
||||||
|
|
||||||
if(emit_signal)
|
if(emit_signal)
|
||||||
{
|
{
|
||||||
emit dataChangedByUser(CurrentFilePath, this);
|
emit dataChangedByUser(CurrentFilePath, this);
|
||||||
emit commitData(this);
|
emit commitData(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VFileEditWidget::setFilter(const QString &dialog_filter, const QStringList& filter_list)
|
void VFileEditWidget::setFilter(const QString &dialog_filter, const QStringList& filter_list)
|
||||||
{
|
{
|
||||||
FileDialogFilter = dialog_filter;
|
FileDialogFilter = dialog_filter;
|
||||||
FilterList = filter_list;
|
FilterList = filter_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileEditWidget::setDirectory(bool dir)
|
void VFileEditWidget::setDirectory(bool dir)
|
||||||
{
|
{
|
||||||
Directory = dir;
|
Directory = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VFileEditWidget::getFile()
|
QString VFileEditWidget::getFile()
|
||||||
{
|
{
|
||||||
return CurrentFilePath;
|
return CurrentFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) : QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath, FileDialogFilter));
|
||||||
if (!filepath.isNull())
|
if (!filepath.isNull())
|
||||||
setFile(filepath, true);
|
setFile(filepath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(ev->type() == QEvent::DragEnter || ev->type() == QEvent::Drop)
|
if(ev->type() == QEvent::DragEnter || ev->type() == QEvent::Drop)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
else if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
else if(obj == ToolButton && (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyPress))
|
||||||
{
|
{
|
||||||
// Ignore the event, so that eventually the delegate gets the event.
|
// Ignore the event, so that eventually the delegate gets the event.
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(obj == FileLineEdit)
|
else if(obj == FileLineEdit)
|
||||||
{
|
{
|
||||||
if(ev->type() == QEvent::FocusOut)
|
if(ev->type() == QEvent::FocusOut)
|
||||||
{
|
{
|
||||||
setFile(FileLineEdit->text(), true);
|
setFile(FileLineEdit->text(), true);
|
||||||
// We don't return true here because we still want the line edit to catch the event as well
|
// We don't return true here because we still want the line edit to catch the event as well
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward the signal to the parent class
|
// forward the signal to the parent class
|
||||||
return QWidget::eventFilter(obj, ev);
|
return QWidget::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VFileEditWidget::isDirectory()
|
bool VFileEditWidget::isDirectory()
|
||||||
{
|
{
|
||||||
return Directory;
|
return Directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VFileEditWidget::dragEnterEvent(QDragEnterEvent* event)
|
void VFileEditWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||||
{
|
{
|
||||||
QString tmpFileName;
|
QString tmpFileName;
|
||||||
if(checkMimeData(event->mimeData(), tmpFileName))
|
if(checkMimeData(event->mimeData(), tmpFileName))
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileEditWidget::dragMoveEvent(QDragMoveEvent* event)
|
void VFileEditWidget::dragMoveEvent(QDragMoveEvent* event)
|
||||||
{
|
{
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileEditWidget::dragLeaveEvent(QDragLeaveEvent* event)
|
void VFileEditWidget::dragLeaveEvent(QDragLeaveEvent* event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileEditWidget::dropEvent(QDropEvent* event)
|
void VFileEditWidget::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
QString tmpFileName;
|
QString tmpFileName;
|
||||||
if(checkMimeData(event->mimeData(), tmpFileName))
|
if(checkMimeData(event->mimeData(), tmpFileName))
|
||||||
{
|
{
|
||||||
setFile(tmpFileName);
|
setFile(tmpFileName);
|
||||||
emit dataChangedByUser(getFile(), this);
|
emit dataChangedByUser(getFile(), this);
|
||||||
emit commitData(this);
|
emit commitData(this);
|
||||||
event->accept();
|
event->accept();
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const
|
bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const
|
||||||
{
|
{
|
||||||
if (data->hasUrls())
|
if (data->hasUrls())
|
||||||
{
|
{
|
||||||
QList<QUrl> tmpUrlList = data->urls();
|
QList<QUrl> tmpUrlList = data->urls();
|
||||||
QFileInfo tmpFileInfo;
|
QFileInfo tmpFileInfo;
|
||||||
|
|
||||||
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()))
|
||||||
{
|
{
|
||||||
file = tmpFileInfo.absoluteFilePath();
|
file = tmpFileInfo.absoluteFilePath();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,109 +1,109 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vfilepropertyeditor.h
|
** @file vfilepropertyeditor.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VFILEPROPERTYEDITOR_H
|
#ifndef VFILEPROPERTYEDITOR_H
|
||||||
#define VFILEPROPERTYEDITOR_H
|
#define VFILEPROPERTYEDITOR_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VFileEditWidget(QWidget* parent, bool is_directory = false);
|
VFileEditWidget(QWidget* parent, bool is_directory = false);
|
||||||
virtual ~VFileEditWidget();
|
virtual ~VFileEditWidget();
|
||||||
|
|
||||||
|
|
||||||
//! This function returns the file currently set to this editor
|
//! This function returns the file currently set to this editor
|
||||||
QString getFile();
|
QString getFile();
|
||||||
|
|
||||||
//! Needed for proper event handling
|
//! Needed for proper event handling
|
||||||
bool eventFilter(QObject* obj, QEvent* ev);
|
bool eventFilter(QObject* obj, QEvent* ev);
|
||||||
|
|
||||||
//! Returns the directory/file setting
|
//! Returns the directory/file setting
|
||||||
//! \return True, if a directory dialog is being shown, false if a file dialog
|
//! \return True, if a directory dialog is being shown, false if a file dialog
|
||||||
bool isDirectory();
|
bool isDirectory();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! This signal is emitted when the user changed the curret file.
|
//! This signal is emitted when the user changed the curret file.
|
||||||
//! Actions triggering this signal are either using the file dialog
|
//! Actions triggering this signal are either using the file dialog
|
||||||
//! to select a new file or changing the file path in the line edit.
|
//! to select a new file or changing the file path in the line edit.
|
||||||
void dataChangedByUser(const QString &getFile, VFileEditWidget* editor);
|
void dataChangedByUser(const QString &getFile, VFileEditWidget* editor);
|
||||||
|
|
||||||
//! This signal is emitted whenever dataChangedByUser() gets emmitted
|
//! This signal is emitted whenever dataChangedByUser() gets emmitted
|
||||||
//! and is connected to the delegate's commitData() signal
|
//! and is connected to the delegate's commitData() signal
|
||||||
void commitData(QWidget* editor);
|
void commitData(QWidget* editor);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Sets the current file, does not check if it is valid
|
//! Sets the current file, does not check if it is valid
|
||||||
//! \param file The new filepath the widget should show
|
//! \param file The new filepath the widget should show
|
||||||
//! \emit_signal If true, this will emit the dataChangedByUser()-signal (if file differs from the current file)
|
//! \emit_signal If true, this will emit the dataChangedByUser()-signal (if file differs from the current file)
|
||||||
void setFile(const QString &getFile, bool emit_signal = false);
|
void setFile(const QString &getFile, bool emit_signal = false);
|
||||||
|
|
||||||
//! Sets a filter for the file field
|
//! Sets a filter for the file field
|
||||||
//! \param dialog_filter The filter used for the File Dialog
|
//! \param dialog_filter The filter used for the File Dialog
|
||||||
//! \param filter_list The list of file endings. The filters are being checked using regular expressions
|
//! \param filter_list The list of file endings. The filters are being checked using regular expressions
|
||||||
void setFilter(const QString& dialog_filter = QString(), const QStringList& filter_list = QStringList());
|
void setFilter(const QString& dialog_filter = QString(), const QStringList& filter_list = QStringList());
|
||||||
|
|
||||||
//! Sets whether the property stores a directory or a file
|
//! Sets whether the property stores a directory or a file
|
||||||
void setDirectory(bool dir);
|
void setDirectory(bool dir);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! This slot gets activated, when the "..." button gets clicked
|
//! This slot gets activated, when the "..." button gets clicked
|
||||||
void onToolButtonClicked();
|
void onToolButtonClicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
void dragMoveEvent(QDragMoveEvent* event);
|
void dragMoveEvent(QDragMoveEvent* event);
|
||||||
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;
|
||||||
|
|
||||||
//! This checks, if a file is compatible with the filters
|
//! This checks, if a file is compatible with the filters
|
||||||
virtual bool checkFileFilter(const QString& getFile) const;
|
virtual bool checkFileFilter(const QString& getFile) const;
|
||||||
|
|
||||||
|
|
||||||
QString CurrentFilePath;
|
QString CurrentFilePath;
|
||||||
QToolButton* ToolButton;
|
QToolButton* ToolButton;
|
||||||
QLineEdit* FileLineEdit;
|
QLineEdit* FileLineEdit;
|
||||||
QString FileDialogFilter;
|
QString FileDialogFilter;
|
||||||
QStringList FilterList;
|
QStringList FilterList;
|
||||||
|
|
||||||
//! Specifies whether it is being looked for a directory (true) or a file (false, default)
|
//! Specifies whether it is being looked for a directory (true) or a file (false, default)
|
||||||
bool Directory;
|
bool Directory;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VFILEPROPERTYEDITOR_H
|
#endif // VFILEPROPERTYEDITOR_H
|
||||||
|
|
|
@ -1,230 +1,230 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vnumberproperty.cpp
|
** @file vnumberproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vnumberproperty.h"
|
#include "vnumberproperty.h"
|
||||||
|
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
|
|
||||||
const int VIntegerProperty::StandardMin = -1000000;
|
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), min(StandardMin), max(StandardMax), singleStep(1.0)
|
||||||
{
|
{
|
||||||
VProperty::setSettings(settings);
|
VProperty::setSettings(settings);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIntegerProperty::VIntegerProperty(const QString &name)
|
VIntegerProperty::VIntegerProperty(const QString &name)
|
||||||
: VProperty(name), min(StandardMin), max(StandardMax)
|
: VProperty(name), min(StandardMin), max(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(min);
|
||||||
tmpEditor->setMaximum(max);
|
tmpEditor->setMaximum(max);
|
||||||
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());
|
||||||
connect(tmpEditor, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
connect(tmpEditor, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||||
&VIntegerProperty::valueChanged);
|
&VIntegerProperty::valueChanged);
|
||||||
|
|
||||||
VProperty::d_ptr->editor = tmpEditor;
|
VProperty::d_ptr->editor = tmpEditor;
|
||||||
return VProperty::d_ptr->editor;
|
return VProperty::d_ptr->editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
QVariant VIntegerProperty::getEditorData(QWidget* editor) const
|
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;
|
min = minimum;
|
||||||
max = maxiumum;
|
max = 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(), max);
|
||||||
else if(key == QLatin1String("Max"))
|
else if(key == QLatin1String("Max"))
|
||||||
setSettings(min, value.toInt());
|
setSettings(min, 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 min;
|
||||||
if(key == QLatin1String("Max"))
|
if(key == QLatin1String("Max"))
|
||||||
return max;
|
return max;
|
||||||
if(key == QLatin1String("Step"))
|
if(key == QLatin1String("Step"))
|
||||||
return singleStep;
|
return singleStep;
|
||||||
else
|
else
|
||||||
return VProperty::getSetting(key);
|
return VProperty::getSetting(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList VIntegerProperty::getSettingKeys() const
|
QStringList VIntegerProperty::getSettingKeys() const
|
||||||
{
|
{
|
||||||
return (QStringList("Min") << "Max" << "Step");
|
return (QStringList("Min") << "Max" << "Step");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VIntegerProperty::type() const
|
QString VIntegerProperty::type() const
|
||||||
{
|
{
|
||||||
return "integer";
|
return "integer";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty* VIntegerProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VIntegerProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VIntegerProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VIntegerProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VIntegerProperty::valueChanged(int i)
|
void VIntegerProperty::valueChanged(int i)
|
||||||
{
|
{
|
||||||
Q_UNUSED(i)
|
Q_UNUSED(i)
|
||||||
UserChangeEvent *event = new UserChangeEvent();
|
UserChangeEvent *event = new UserChangeEvent();
|
||||||
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)
|
||||||
: VIntegerProperty(name), Precision(StandardPrecision)
|
: VIntegerProperty(name), Precision(StandardPrecision)
|
||||||
{
|
{
|
||||||
VProperty::setSettings(settings);
|
VProperty::setSettings(settings);
|
||||||
VProperty::d_ptr->VariantValue.setValue(0);
|
VProperty::d_ptr->VariantValue.setValue(0);
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Double);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Double);
|
||||||
VProperty::d_ptr->PropertyVariantType = QVariant::Double;
|
VProperty::d_ptr->PropertyVariantType = QVariant::Double;
|
||||||
}
|
}
|
||||||
|
|
||||||
VDoubleProperty::VDoubleProperty(const QString &name)
|
VDoubleProperty::VDoubleProperty(const QString &name)
|
||||||
: VIntegerProperty(name), Precision(StandardPrecision)
|
: VIntegerProperty(name), Precision(StandardPrecision)
|
||||||
{
|
{
|
||||||
VProperty::d_ptr->VariantValue.setValue(0);
|
VProperty::d_ptr->VariantValue.setValue(0);
|
||||||
VProperty::d_ptr->VariantValue.convert(QVariant::Double);
|
VProperty::d_ptr->VariantValue.convert(QVariant::Double);
|
||||||
VProperty::d_ptr->PropertyVariantType = QVariant::Double;
|
VProperty::d_ptr->PropertyVariantType = QVariant::Double;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! 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(min);
|
||||||
tmpEditor->setMaximum(max);
|
tmpEditor->setMaximum(max);
|
||||||
tmpEditor->setDecimals(Precision);
|
tmpEditor->setDecimals(Precision);
|
||||||
tmpEditor->setSingleStep(singleStep);
|
tmpEditor->setSingleStep(singleStep);
|
||||||
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toDouble());
|
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toDouble());
|
||||||
connect(tmpEditor, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this,
|
connect(tmpEditor, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this,
|
||||||
&VIntegerProperty::valueChanged);
|
&VIntegerProperty::valueChanged);
|
||||||
|
|
||||||
VProperty::d_ptr->editor = tmpEditor;
|
VProperty::d_ptr->editor = tmpEditor;
|
||||||
return VProperty::d_ptr->editor;
|
return VProperty::d_ptr->editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
QVariant VDoubleProperty::getEditorData(QWidget* editor) const
|
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;
|
min = minimum;
|
||||||
max = maxiumum;
|
max = maxiumum;
|
||||||
this->singleStep = singleStep;
|
this->singleStep = singleStep;
|
||||||
Precision = precision;
|
Precision = precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(), max, singleStep, Precision);
|
||||||
else if(key == QLatin1String("Max"))
|
else if(key == QLatin1String("Max"))
|
||||||
setSettings(min, value.toDouble(), singleStep, Precision);
|
setSettings(min, value.toDouble(), singleStep, Precision);
|
||||||
else if(key == QLatin1String("Step"))
|
else if(key == QLatin1String("Step"))
|
||||||
setSettings(min, max, value.toDouble(), Precision);
|
setSettings(min, max, value.toDouble(), Precision);
|
||||||
else if(key == QLatin1String("Precision"))
|
else if(key == QLatin1String("Precision"))
|
||||||
setSettings(min, max, singleStep, value.toDouble());
|
setSettings(min, max, 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 min;
|
||||||
if(key == QLatin1String("Max"))
|
if(key == QLatin1String("Max"))
|
||||||
return max;
|
return max;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList VDoubleProperty::getSettingKeys() const
|
QStringList VDoubleProperty::getSettingKeys() const
|
||||||
{
|
{
|
||||||
return (QStringList("Min") << "Max" << "Step" << "Precision");
|
return (QStringList("Min") << "Max" << "Step" << "Precision");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VDoubleProperty::type() const
|
QString VDoubleProperty::type() const
|
||||||
{
|
{
|
||||||
return "double";
|
return "double";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty* VDoubleProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VDoubleProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
return VIntegerProperty::clone(include_children, container ? container : new VDoubleProperty(getName()));
|
return VIntegerProperty::clone(include_children, container ? container : new VDoubleProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,138 +1,138 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vnumberproperty.h
|
** @file vnumberproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VNUMBERPROPERTY_H
|
#ifndef VNUMBERPROPERTY_H
|
||||||
#define VNUMBERPROPERTY_H
|
#define VNUMBERPROPERTY_H
|
||||||
|
|
||||||
#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
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VIntegerProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VIntegerProperty : public VProperty
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VIntegerProperty(const QString& name, const QMap<QString, QVariant>& settings);
|
VIntegerProperty(const QString& name, const QMap<QString, QVariant>& settings);
|
||||||
|
|
||||||
VIntegerProperty(const QString& name);
|
VIntegerProperty(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
|
||||||
//! \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, const QAbstractItemDelegate* delegate);
|
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;
|
||||||
|
|
||||||
//! Sets the settings of a basic integer property
|
//! Sets the settings of a basic integer property
|
||||||
//! \param minimum The minimum value
|
//! \param minimum The minimum value
|
||||||
//! \param maxiumum The maximum value
|
//! \param maxiumum The maximum value
|
||||||
virtual void setSettings(int minimum, int maxiumum, int singleStep = 1.0);
|
virtual void setSettings(int minimum, int maxiumum, int singleStep = 1.0);
|
||||||
|
|
||||||
//! Sets the settings. Available settings:
|
//! Sets the settings. Available settings:
|
||||||
//!
|
//!
|
||||||
//! key: "Min" - value: Minimum number as integer
|
//! key: "Min" - value: Minimum number as integer
|
||||||
//! key: "Max" - value: Maximum number as integer
|
//! key: "Max" - value: Maximum number as integer
|
||||||
virtual void setSetting(const QString& key, const QVariant& value);
|
virtual void setSetting(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual QVariant getSetting(const QString& key) const;
|
virtual QVariant getSetting(const QString& key) const;
|
||||||
|
|
||||||
//! Returns the list of keys of the property's settings
|
//! Returns the list of keys of the property's settings
|
||||||
virtual QStringList getSettingKeys() const;
|
virtual QStringList getSettingKeys() const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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 min, max, singleStep;
|
||||||
|
|
||||||
static const int StandardMin;// = -1000000;
|
static const int StandardMin;// = -1000000;
|
||||||
static const int StandardMax;// = 1000000;
|
static const int StandardMax;// = 1000000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! Class for holding a double property
|
//! Class for holding a double property
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VDoubleProperty : public VIntegerProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VDoubleProperty : public VIntegerProperty
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VDoubleProperty(const QString& name, const QMap<QString, QVariant>& settings);
|
VDoubleProperty(const QString& name, const QMap<QString, QVariant>& settings);
|
||||||
|
|
||||||
VDoubleProperty(const QString& name);
|
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
|
||||||
//! \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, const QAbstractItemDelegate* delegate);
|
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;
|
||||||
|
|
||||||
//! Sets the settings of a double property
|
//! Sets the settings of a double property
|
||||||
//! \param minimum The minimum value
|
//! \param minimum The minimum value
|
||||||
//! \param maxiumum The maximum value
|
//! \param maxiumum The maximum value
|
||||||
//! \param precision The number of decimal places
|
//! \param precision The number of decimal places
|
||||||
virtual void setSettings(double minimum, double maxiumum, double singleStep, int precision);
|
virtual void setSettings(double minimum, double maxiumum, double singleStep, int precision);
|
||||||
|
|
||||||
//! Sets the settings. Available settings:
|
//! Sets the settings. Available settings:
|
||||||
//!
|
//!
|
||||||
//! key: "Min" - value: Minimum number as integer
|
//! key: "Min" - value: Minimum number as integer
|
||||||
//! key: "Max" - value: Maximum number as integer
|
//! key: "Max" - value: Maximum number as integer
|
||||||
virtual void setSetting(const QString& key, const QVariant& value);
|
virtual void setSetting(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual QVariant getSetting(const QString& key) const;
|
virtual QVariant getSetting(const QString& key) const;
|
||||||
|
|
||||||
//! Returns the list of keys of the property's settings
|
//! Returns the list of keys of the property's settings
|
||||||
virtual QStringList getSettingKeys() const;
|
virtual QStringList getSettingKeys() const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Number of decimals after the decimal point
|
//! Number of decimals after the decimal point
|
||||||
int Precision;
|
int Precision;
|
||||||
|
|
||||||
const static double StandardPrecision;// = 5;
|
const static double StandardPrecision;// = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VNUMBERPROPERTY_H
|
#endif // VNUMBERPROPERTY_H
|
||||||
|
|
|
@ -1,104 +1,104 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vshortcutproperty.cpp
|
** @file vshortcutproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vshortcutproperty.h"
|
#include "vshortcutproperty.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
|
|
||||||
#include "vshortcutpropertyeditor.h"
|
#include "vshortcutpropertyeditor.h"
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VShortcutProperty::VShortcutProperty(const QString& name)
|
VShortcutProperty::VShortcutProperty(const QString& name)
|
||||||
: VProperty(name, QVariant::String)
|
: VProperty(name, QVariant::String)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VShortcutProperty::~VShortcutProperty()
|
VShortcutProperty::~VShortcutProperty()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VShortcutProperty::data (int column, int role) const
|
QVariant VShortcutProperty::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;
|
return d_ptr->VariantValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return VProperty::data(column, role);
|
return VProperty::data(column, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
|
||||||
const QAbstractItemDelegate* delegate)
|
const QAbstractItemDelegate* delegate)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VShortcutProperty::setEditorData(QWidget* editor)
|
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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant VShortcutProperty::getEditorData(QWidget* editor) const
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString VShortcutProperty::type() const
|
QString VShortcutProperty::type() const
|
||||||
{
|
{
|
||||||
return "shortcut";
|
return "shortcut";
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty* VShortcutProperty::clone(bool include_children, VProperty* container) const
|
VProperty* VShortcutProperty::clone(bool include_children, VProperty* container) const
|
||||||
{
|
{
|
||||||
return VProperty::clone(include_children, container ? container : new VShortcutProperty(getName()));
|
return VProperty::clone(include_children, container ? container : new VShortcutProperty(getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VShortcutProperty::setValue(const QVariant &value)
|
void VShortcutProperty::setValue(const QVariant &value)
|
||||||
{
|
{
|
||||||
VProperty::setValue(QKeySequence::fromString(value.toString()).toString());
|
VProperty::setValue(QKeySequence::fromString(value.toString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vshortcutproperty.h
|
** @file vshortcutproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VSHORTCUTROPERTY_H
|
#ifndef VSHORTCUTROPERTY_H
|
||||||
#define VSHORTCUTROPERTY_H
|
#define VSHORTCUTROPERTY_H
|
||||||
|
|
||||||
#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
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VShortcutProperty(const QString &name);
|
VShortcutProperty(const QString &name);
|
||||||
|
|
||||||
//! The destructor
|
//! The destructor
|
||||||
~VShortcutProperty();
|
~VShortcutProperty();
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) 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 slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||||
const QAbstractItemDelegate* delegate);
|
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);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
//! Sets the value of the property
|
//! Sets the value of the property
|
||||||
virtual void setValue(const QVariant& value);
|
virtual void setValue(const QVariant& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VFILEPROPERTY_H
|
#endif // VFILEPROPERTY_H
|
||||||
|
|
|
@ -1,106 +1,106 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vshortcutpropertyeditor.cpp
|
** @file vshortcutpropertyeditor.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vshortcutpropertyeditor.h"
|
#include "vshortcutpropertyeditor.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VShortcutEditWidget::VShortcutEditWidget(QWidget *parent)
|
VShortcutEditWidget::VShortcutEditWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
// Create the line edit widget
|
// Create the line edit widget
|
||||||
LineEdit = new QLineEdit(this);
|
LineEdit = new QLineEdit(this);
|
||||||
LineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
LineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
LineEdit->clear();
|
LineEdit->clear();
|
||||||
LineEdit->installEventFilter(this);
|
LineEdit->installEventFilter(this);
|
||||||
setFocusProxy(LineEdit);
|
setFocusProxy(LineEdit);
|
||||||
connect(LineEdit, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited(QString)));
|
connect(LineEdit, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited(QString)));
|
||||||
|
|
||||||
// The layout (a horizontal layout)
|
// The layout (a horizontal layout)
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(LineEdit);
|
layout->addWidget(LineEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VShortcutEditWidget::~VShortcutEditWidget()
|
VShortcutEditWidget::~VShortcutEditWidget()
|
||||||
{
|
{
|
||||||
// nothing needs to be done here
|
// nothing needs to be done here
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
if(keys != Qt::Key_Shift &&
|
if(keys != Qt::Key_Shift &&
|
||||||
keys != Qt::Key_Control &&
|
keys != Qt::Key_Control &&
|
||||||
keys != Qt::Key_Meta &&
|
keys != Qt::Key_Meta &&
|
||||||
keys != Qt::Key_AltGr &&
|
keys != Qt::Key_AltGr &&
|
||||||
keys != Qt::Key_Alt)
|
keys != Qt::Key_Alt)
|
||||||
{
|
{
|
||||||
keys += keyEvent->modifiers();
|
keys += keyEvent->modifiers();
|
||||||
setShortcut(QKeySequence(keys), true);
|
setShortcut(QKeySequence(keys), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(obj, event);
|
return QWidget::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VShortcutEditWidget::getShortcutAsString()
|
QString VShortcutEditWidget::getShortcutAsString()
|
||||||
{
|
{
|
||||||
return CurrentKeySequence.toString();
|
return CurrentKeySequence.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QKeySequence VShortcutEditWidget::getShortcut()
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
setShortcut(text, true);
|
setShortcut(text, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,84 +1,84 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vshortcutpropertyeditor.h
|
** @file vshortcutpropertyeditor.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VSHORTCUTPROPERTYEDITOR_H
|
#ifndef VSHORTCUTPROPERTYEDITOR_H
|
||||||
#define VSHORTCUTPROPERTYEDITOR_H
|
#define VSHORTCUTPROPERTYEDITOR_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
namespace VPE{
|
namespace VPE{
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VShortcutEditWidget(QWidget* parent);
|
VShortcutEditWidget(QWidget* parent);
|
||||||
virtual ~VShortcutEditWidget();
|
virtual ~VShortcutEditWidget();
|
||||||
|
|
||||||
//! Needed for proper event handling
|
//! Needed for proper event handling
|
||||||
bool eventFilter(QObject* obj, QEvent* evenvt);
|
bool eventFilter(QObject* obj, QEvent* evenvt);
|
||||||
|
|
||||||
//! Returns the currently set shortcut
|
//! Returns the currently set shortcut
|
||||||
QString getShortcutAsString();
|
QString getShortcutAsString();
|
||||||
|
|
||||||
//! Returns the currently set shortcut
|
//! Returns the currently set shortcut
|
||||||
QKeySequence getShortcut();
|
QKeySequence getShortcut();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! This signal is emitted when the user changed the current shortcut
|
//! This signal is emitted when the user changed the current shortcut
|
||||||
void dataChangedByUser(const QKeySequence& sequence, VShortcutEditWidget* editor);
|
void dataChangedByUser(const QKeySequence& sequence, VShortcutEditWidget* editor);
|
||||||
|
|
||||||
//! This signal is emitted whenever dataChangedByUser() gets emmitted
|
//! This signal is emitted whenever dataChangedByUser() gets emmitted
|
||||||
//! and is connected to the delegate's commitData() signal
|
//! and is connected to the delegate's commitData() signal
|
||||||
void commitData(QWidget* editor);
|
void commitData(QWidget* editor);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Sets the shortcut
|
//! Sets the shortcut
|
||||||
//! \param shortcut The new shortcut
|
//! \param shortcut The new shortcut
|
||||||
//! \emit_signal If true, this will emit the dataChangedByUser()-signal
|
//! \emit_signal If true, this will emit the dataChangedByUser()-signal
|
||||||
void setShortcut(const QString &shortcut, bool emit_signal);
|
void setShortcut(const QString &shortcut, bool emit_signal);
|
||||||
|
|
||||||
//! Sets the shortcut
|
//! Sets the shortcut
|
||||||
//! \param shortcut The new shortcut
|
//! \param shortcut The new shortcut
|
||||||
//! \emit_signal If true, this will emit the dataChangedByUser()-signal
|
//! \emit_signal If true, this will emit the dataChangedByUser()-signal
|
||||||
void setShortcut(const QKeySequence &shortcut, bool emit_signal);
|
void setShortcut(const QKeySequence &shortcut, bool emit_signal);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! This slot is called when the user edits the line edit (e.g. by removing or pasting text using the mouse)
|
//! This slot is called when the user edits the line edit (e.g. by removing or pasting text using the mouse)
|
||||||
void onTextEdited(const QString& text);
|
void onTextEdited(const QString& text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! The current key sequence
|
//! The current key sequence
|
||||||
QKeySequence CurrentKeySequence;
|
QKeySequence CurrentKeySequence;
|
||||||
|
|
||||||
//! The line to display and edit the key sequence
|
//! The line to display and edit the key sequence
|
||||||
QLineEdit* LineEdit;
|
QLineEdit* LineEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VFILEPROPERTYEDITOR_H
|
#endif // VFILEPROPERTYEDITOR_H
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vwidgetproperty.cpp
|
** @file vwidgetproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vwidgetproperty.h"
|
#include "vwidgetproperty.h"
|
||||||
|
|
||||||
|
|
||||||
#include "vwidgetproperty_p.h"
|
#include "vwidgetproperty_p.h"
|
||||||
|
|
||||||
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))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VWidgetProperty::~VWidgetProperty()
|
VWidgetProperty::~VWidgetProperty()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *VWidgetProperty::getWidget() const
|
QWidget *VWidgetProperty::getWidget() const
|
||||||
{
|
{
|
||||||
return static_cast<VWidgetPropertyPrivate*>(d_ptr)->Widget.data();
|
return static_cast<VWidgetPropertyPrivate*>(d_ptr)->Widget.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VWidgetProperty::setWidget(QWidget* widget)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString VWidgetProperty::type() const
|
QString VWidgetProperty::type() const
|
||||||
{
|
{
|
||||||
return "widget";
|
return "widget";
|
||||||
}
|
}
|
||||||
|
|
||||||
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()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,62 +1,62 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vwidgetproperty.h
|
** @file vwidgetproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VWIDGETROPERTY_H
|
#ifndef VWIDGETROPERTY_H
|
||||||
#define VWIDGETROPERTY_H
|
#define VWIDGETROPERTY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include "vemptyproperty.h"
|
#include "vemptyproperty.h"
|
||||||
|
|
||||||
#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:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VWidgetProperty(const QString &name, QWidget* widget = nullptr);
|
VWidgetProperty(const QString &name, QWidget* widget = nullptr);
|
||||||
|
|
||||||
//! The destructor
|
//! The destructor
|
||||||
~VWidgetProperty();
|
~VWidgetProperty();
|
||||||
|
|
||||||
//! Returns the widget held by this property
|
//! Returns the widget held by this property
|
||||||
QWidget* getWidget() const;
|
QWidget* getWidget() const;
|
||||||
|
|
||||||
//! Sets the widget for this property. If there is already an old one, it will be deleted.
|
//! Sets the widget for this property. If there is already an old one, it will be deleted.
|
||||||
void setWidget(QWidget* widget);
|
void setWidget(QWidget* widget);
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VWIDGETROPERTY_H
|
#endif // VWIDGETROPERTY_H
|
||||||
|
|
|
@ -1,46 +1,46 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vabstractpropertyfactory.h
|
** @file vabstractpropertyfactory.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VABSTRACTPROPERTYFACTORY_H
|
#ifndef VABSTRACTPROPERTYFACTORY_H
|
||||||
#define VABSTRACTPROPERTYFACTORY_H
|
#define VABSTRACTPROPERTYFACTORY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VAbstractPropertyFactory
|
class VPROPERTYEXPLORERSHARED_EXPORT VAbstractPropertyFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty virtual destructor
|
//! Empty virtual destructor
|
||||||
virtual ~VAbstractPropertyFactory() {}
|
virtual ~VAbstractPropertyFactory() {}
|
||||||
|
|
||||||
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
||||||
//! \param type The type of the property as string
|
//! \param type The type of the property as string
|
||||||
//! \param name The property's name
|
//! \param name The property's name
|
||||||
//! \return Returns the created property or NULL if it couldn't be be created
|
//! \return Returns the created property or NULL if it couldn't be be created
|
||||||
virtual VProperty* createProperty(const QString& type, const QString &name) = 0;
|
virtual VProperty* createProperty(const QString& type, const QString &name) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VABSTRACTPROPERTYFACTORY_H
|
#endif // VABSTRACTPROPERTYFACTORY_H
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vfileproperty_p.h
|
** @file vfileproperty_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VFILEPROPERTY_P_H
|
#ifndef VFILEPROPERTY_P_H
|
||||||
#define VFILEPROPERTY_P_H
|
#define VFILEPROPERTY_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
//! Determines whether the file property is a file or a directory. Default: false
|
//! Determines whether the file property is a file or a directory. Default: false
|
||||||
bool Directory;
|
bool Directory;
|
||||||
|
|
||||||
|
|
||||||
//! Constructor passing name and type
|
//! Constructor passing name and type
|
||||||
VFilePropertyPrivate(const QString& name, QVariant::Type type, bool directory = false)
|
VFilePropertyPrivate(const QString& name, QVariant::Type type, bool directory = false)
|
||||||
: VPropertyPrivate(name, type), FileFilters(), Directory(directory) {}
|
: VPropertyPrivate(name, type), FileFilters(), Directory(directory) {}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VFilePropertyPrivate()
|
VFilePropertyPrivate()
|
||||||
: VPropertyPrivate(), FileFilters(), Directory(false) {}
|
: VPropertyPrivate(), FileFilters(), Directory(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VFILEPROPERTY_P_H
|
#endif // VFILEPROPERTY_P_H
|
||||||
|
|
|
@ -1,385 +1,385 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vproperty.cpp
|
** @file vproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMetaProperty>
|
#include <QMetaProperty>
|
||||||
#include <QItemEditorFactory>
|
#include <QItemEditorFactory>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
//! Standard constructor, takes a name and a parent property as argument
|
//! Standard constructor, takes a name and a parent property as argument
|
||||||
VProperty::VProperty(const QString& name, QVariant::Type type)
|
VProperty::VProperty(const QString& name, QVariant::Type type)
|
||||||
: QObject(), d_ptr(new VPropertyPrivate(name, type))
|
: QObject(), d_ptr(new VPropertyPrivate(name, type))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty::VProperty(VPropertyPrivate *d)
|
VProperty::VProperty(VPropertyPrivate *d)
|
||||||
: d_ptr(d)
|
: d_ptr(d)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VProperty::~VProperty()
|
VProperty::~VProperty()
|
||||||
{
|
{
|
||||||
setParent(nullptr);
|
setParent(nullptr);
|
||||||
|
|
||||||
while(!d_ptr->Children.isEmpty())
|
while(!d_ptr->Children.isEmpty())
|
||||||
{
|
{
|
||||||
VProperty* tmpChild = d_ptr->Children.takeLast();
|
VProperty* tmpChild = d_ptr->Children.takeLast();
|
||||||
delete tmpChild;
|
delete tmpChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VProperty::type() const
|
QString VProperty::type() const
|
||||||
{
|
{
|
||||||
return "string";
|
return "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VProperty::setData(const QVariant &data, int role)
|
bool VProperty::setData(const QVariant &data, int role)
|
||||||
{
|
{
|
||||||
bool tmpResult = false;
|
bool tmpResult = false;
|
||||||
if(Qt::EditRole == role)
|
if(Qt::EditRole == role)
|
||||||
{
|
{
|
||||||
tmpResult = (d_ptr->VariantValue != data);
|
tmpResult = (d_ptr->VariantValue != data);
|
||||||
setValue(data);
|
setValue(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
Q_UNUSED(index);
|
Q_UNUSED(index);
|
||||||
Q_UNUSED(delegate);
|
Q_UNUSED(delegate);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! 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);
|
||||||
|
|
||||||
QItemEditorFactory *factory = new QItemEditorFactory;
|
QItemEditorFactory *factory = new QItemEditorFactory;
|
||||||
QItemEditorCreatorBase *lineCreator = new QStandardItemEditorCreator<QLineEdit>();
|
QItemEditorCreatorBase *lineCreator = new QStandardItemEditorCreator<QLineEdit>();
|
||||||
factory->registerEditor(QVariant::String, lineCreator);
|
factory->registerEditor(QVariant::String, lineCreator);
|
||||||
QItemEditorFactory::setDefaultFactory(factory);
|
QItemEditorFactory::setDefaultFactory(factory);
|
||||||
|
|
||||||
d_ptr->editor = factory->createEditor(d_ptr->PropertyVariantType, parent);
|
d_ptr->editor = factory->createEditor(d_ptr->PropertyVariantType, parent);
|
||||||
return d_ptr->editor;
|
return d_ptr->editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VProperty::setValue(const QVariant &value)
|
void VProperty::setValue(const QVariant &value)
|
||||||
{
|
{
|
||||||
d_ptr->VariantValue = value;
|
d_ptr->VariantValue = value;
|
||||||
d_ptr->VariantValue.convert(d_ptr->PropertyVariantType);
|
d_ptr->VariantValue.convert(d_ptr->PropertyVariantType);
|
||||||
if (d_ptr->editor != nullptr)
|
if (d_ptr->editor != nullptr)
|
||||||
{
|
{
|
||||||
setEditorData(d_ptr->editor);
|
setEditorData(d_ptr->editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant VProperty::getValue() const
|
QVariant VProperty::getValue() const
|
||||||
{
|
{
|
||||||
return d_ptr->VariantValue;
|
return d_ptr->VariantValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VProperty::serialize() const
|
QString VProperty::serialize() const
|
||||||
{
|
{
|
||||||
return getValue().toString();
|
return getValue().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VProperty::deserialize(const QString& value)
|
void VProperty::deserialize(const QString& value)
|
||||||
{
|
{
|
||||||
setValue(QVariant(value));
|
setValue(QVariant(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VProperty::setName(const QString& name)
|
void VProperty::setName(const QString& name)
|
||||||
{
|
{
|
||||||
d_ptr->Name = name;
|
d_ptr->Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString VProperty::getName() const
|
QString VProperty::getName() const
|
||||||
{
|
{
|
||||||
return d_ptr->Name;
|
return d_ptr->Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VProperty::setDescription(const QString& desc)
|
void VProperty::setDescription(const QString& desc)
|
||||||
{
|
{
|
||||||
d_ptr->Description = desc;
|
d_ptr->Description = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString VProperty::getDescription() const
|
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()
|
||||||
{
|
{
|
||||||
return d_ptr->Children;
|
return d_ptr->Children;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns a reference to the list of children
|
//! Returns a reference to the list of children
|
||||||
const QList<VProperty*>& VProperty::getChildren() const
|
const QList<VProperty*>& VProperty::getChildren() const
|
||||||
{
|
{
|
||||||
return d_ptr->Children;
|
return d_ptr->Children;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the child at a certain row
|
//! Returns the child at a certain row
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the number of children
|
//! Gets the number of children
|
||||||
int VProperty::getRowCount() const
|
int VProperty::getRowCount() const
|
||||||
{
|
{
|
||||||
return d_ptr->Children.count();
|
return d_ptr->Children.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets the parent of this property
|
//! Gets the parent of this property
|
||||||
VProperty* VProperty::getParent() const
|
VProperty* VProperty::getParent() const
|
||||||
{
|
{
|
||||||
return d_ptr->Parent;
|
return d_ptr->Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the parent of this property
|
//! Sets the parent of this property
|
||||||
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)
|
||||||
{
|
{
|
||||||
d_ptr->Children.push_back(child);
|
d_ptr->Children.push_back(child);
|
||||||
return d_ptr->Children.count()-1;
|
return d_ptr->Children.count()-1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return d_ptr->Children.indexOf(child);
|
return d_ptr->Children.indexOf(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Removes a child from the children list
|
//! Removes a child from the children list
|
||||||
void VProperty::removeChild(VProperty* child)
|
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
|
||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
return d_ptr->UpdateParent;
|
return d_ptr->UpdateParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns whether the views have to update the children of this property if it changes
|
//! Returns whether the views have to update the children of this property if it changes
|
||||||
bool VProperty::getUpdateChildren() const
|
bool VProperty::getUpdateChildren() const
|
||||||
{
|
{
|
||||||
return d_ptr->UpdateChildren;
|
return d_ptr->UpdateChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! 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
|
||||||
void VProperty::setUpdateBehaviour(bool update_parent, bool update_children)
|
void VProperty::setUpdateBehaviour(bool update_parent, bool update_children)
|
||||||
{
|
{
|
||||||
d_ptr->UpdateParent = update_parent;
|
d_ptr->UpdateParent = update_parent;
|
||||||
d_ptr->UpdateChildren = update_children;
|
d_ptr->UpdateChildren = 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> VProperty::getSettings() const
|
QMap<QString, QVariant> VProperty::getSettings() const
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant> tmpResult;
|
QMap<QString, QVariant> tmpResult;
|
||||||
|
|
||||||
QStringList tmpKeyList = getSettingKeys();
|
QStringList tmpKeyList = getSettingKeys();
|
||||||
foreach(const QString& tmpKey, tmpKeyList)
|
foreach(const QString& tmpKey, tmpKeyList)
|
||||||
tmpResult.insert(tmpKey, getSetting(tmpKey));
|
tmpResult.insert(tmpKey, getSetting(tmpKey));
|
||||||
|
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VProperty::setSetting(const QString& key, const QVariant& value)
|
void VProperty::setSetting(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
Q_UNUSED(key)
|
Q_UNUSED(key)
|
||||||
Q_UNUSED(value)
|
Q_UNUSED(value)
|
||||||
// Not needed in the Standard property
|
// Not needed in the Standard property
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VProperty::getSetting(const QString& key) const
|
QVariant VProperty::getSetting(const QString& key) const
|
||||||
{
|
{
|
||||||
// Not needed in the Standard property
|
// Not needed in the Standard property
|
||||||
Q_UNUSED(key)
|
Q_UNUSED(key)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList VProperty::getSettingKeys() const
|
QStringList VProperty::getSettingKeys() const
|
||||||
{
|
{
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
container->setValue(getValue());
|
container->setValue(getValue());
|
||||||
container->setSettings(getSettings());
|
container->setSettings(getSettings());
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
Property VProperty::propertyType() const
|
Property VProperty::propertyType() const
|
||||||
{
|
{
|
||||||
return d_ptr->type;
|
return d_ptr->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VProperty::setPropertyType(const Property &type)
|
void VProperty::setPropertyType(const Property &type)
|
||||||
{
|
{
|
||||||
d_ptr->type = type;
|
d_ptr->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VProperty::UpdateParent(const QVariant &value)
|
void VProperty::UpdateParent(const QVariant &value)
|
||||||
{
|
{
|
||||||
Q_UNUSED(value);
|
Q_UNUSED(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VProperty::ValueChildChanged(const QVariant &value, int typeForParent)
|
void VProperty::ValueChildChanged(const QVariant &value, int typeForParent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,207 +1,207 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vproperty.h
|
** @file vproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTY_H
|
#ifndef VPROPERTY_H
|
||||||
#define VPROPERTY_H
|
#define VPROPERTY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QStyleOptionViewItem>
|
#include <QStyleOptionViewItem>
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
enum class Property : char{Simple, Complex};
|
enum class Property : char{Simple, Complex};
|
||||||
|
|
||||||
static const int MyCustomEventType = 1099;
|
static const int MyCustomEventType = 1099;
|
||||||
|
|
||||||
class UserChangeEvent : public QEvent
|
class UserChangeEvent : public QEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UserChangeEvent() : QEvent((QEvent::Type)MyCustomEventType) {}
|
UserChangeEvent() : QEvent((QEvent::Type)MyCustomEventType) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VPropertyPrivate;
|
class VPropertyPrivate;
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject
|
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
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Standard constructor, takes a name and a parent property as argument
|
//! Standard constructor, takes a name and a parent property as argument
|
||||||
explicit VProperty(const QString& name, QVariant::Type type = QVariant::String);
|
explicit VProperty(const QString& name, QVariant::Type type = QVariant::String);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VProperty();
|
virtual ~VProperty();
|
||||||
|
|
||||||
//! Returns a string containing the type of the property
|
//! Returns a string containing the type of the property
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
//! Get the data how it should be displayed
|
//! Get the data how it should be displayed
|
||||||
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
//! This is used by the model to set the data
|
//! This is used by the model to set the data
|
||||||
//! \param data The data to set
|
//! \param data The data to set
|
||||||
//! \param role The role. Default is Qt::EditRole
|
//! \param role The role. Default is Qt::EditRole
|
||||||
//! \return Returns true, if the data was changed, false if not.
|
//! \return Returns true, if the data was changed, false if not.
|
||||||
virtual bool setData (const QVariant& data, int role = Qt::EditRole);
|
virtual bool setData (const QVariant& data, int role = Qt::EditRole);
|
||||||
|
|
||||||
//! 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 slots.
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, const QAbstractItemDelegate* delegate);
|
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);
|
||||||
|
|
||||||
//! Gets the data from the widget
|
//! Gets the data from the widget
|
||||||
virtual QVariant getEditorData(QWidget* editor) const;
|
virtual QVariant getEditorData(QWidget* editor) const;
|
||||||
|
|
||||||
//! Returns item flags
|
//! Returns item flags
|
||||||
virtual Qt::ItemFlags flags(int column = DPC_Name) const;
|
virtual Qt::ItemFlags flags(int column = DPC_Name) const;
|
||||||
|
|
||||||
//! Sets the value of the property
|
//! Sets the value of the property
|
||||||
virtual void setValue(const QVariant& value);
|
virtual void setValue(const QVariant& value);
|
||||||
|
|
||||||
//! Returns the value of the property as a QVariant
|
//! Returns the value of the property as a QVariant
|
||||||
virtual QVariant getValue() const;
|
virtual QVariant getValue() const;
|
||||||
|
|
||||||
//! Serializes the value to a string
|
//! Serializes the value to a string
|
||||||
virtual QString serialize() const;
|
virtual QString serialize() const;
|
||||||
|
|
||||||
//! Deserializes the value from a string
|
//! Deserializes the value from a string
|
||||||
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 used.
|
||||||
//! \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 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
|
||||||
virtual void setName(const QString& name);
|
virtual void setName(const QString& name);
|
||||||
|
|
||||||
//! Gets the name of the property
|
//! Gets the name of the property
|
||||||
virtual QString getName() const;
|
virtual QString getName() const;
|
||||||
|
|
||||||
//! Sets the name of the property
|
//! Sets the name of the property
|
||||||
virtual void setDescription(const QString& desc);
|
virtual void setDescription(const QString& desc);
|
||||||
|
|
||||||
//! Gets the name of the property
|
//! Gets the name of the property
|
||||||
virtual QString getDescription() const;
|
virtual QString getDescription() const;
|
||||||
|
|
||||||
//! Adds a child to this property
|
//! Adds a child to this property
|
||||||
virtual int addChild(VProperty* child);
|
virtual int addChild(VProperty* child);
|
||||||
|
|
||||||
//! Returns a reference to the list of children
|
//! Returns a reference to the list of children
|
||||||
virtual QList<VProperty*>& getChildren();
|
virtual QList<VProperty*>& getChildren();
|
||||||
|
|
||||||
//! Returns a reference to the list of children
|
//! Returns a reference to the list of children
|
||||||
virtual const QList<VProperty*>& getChildren() const;
|
virtual const QList<VProperty*>& getChildren() const;
|
||||||
|
|
||||||
//! Returns the child at a certain row
|
//! Returns the child at a certain row
|
||||||
virtual VProperty* getChild(int row) const;
|
virtual VProperty* getChild(int row) const;
|
||||||
|
|
||||||
//! Gets the number of children
|
//! Gets the number of children
|
||||||
virtual int getRowCount() const;
|
virtual int getRowCount() const;
|
||||||
|
|
||||||
//! Gets the parent of this property
|
//! Gets the parent of this property
|
||||||
virtual VProperty* getParent() const;
|
virtual VProperty* getParent() const;
|
||||||
|
|
||||||
//! Sets the parent of this property
|
//! Sets the parent of this property
|
||||||
virtual void setParent(VProperty* parent);
|
virtual void setParent(VProperty* parent);
|
||||||
|
|
||||||
//! Removes a child from the children list, doesn't delete the child!
|
//! Removes a child from the children list, doesn't delete the child!
|
||||||
virtual void removeChild(VProperty* child);
|
virtual void removeChild(VProperty* child);
|
||||||
|
|
||||||
//! Returns the row the child has
|
//! Returns the row the child has
|
||||||
virtual int getChildRow(VProperty* child) const;
|
virtual int getChildRow(VProperty* child) const;
|
||||||
|
|
||||||
//! 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
|
||||||
virtual bool getUpdateParent() const;
|
virtual bool getUpdateParent() const;
|
||||||
|
|
||||||
//! Returns whether the views have to update the children of this property if it changes
|
//! Returns whether the views have to update the children of this property if it changes
|
||||||
virtual bool getUpdateChildren() const;
|
virtual bool getUpdateChildren() const;
|
||||||
|
|
||||||
//! 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.
|
||||||
virtual QMap<QString, QVariant> getSettings() const;
|
virtual QMap<QString, QVariant> getSettings() const;
|
||||||
|
|
||||||
//! Sets the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Sets the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual void setSetting(const QString& key, const QVariant& value);
|
virtual void setSetting(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
|
||||||
virtual QVariant getSetting(const QString& key) const;
|
virtual QVariant getSetting(const QString& key) const;
|
||||||
|
|
||||||
//! Returns the list of keys of the property's settings
|
//! Returns the list of keys of the property's settings
|
||||||
virtual QStringList getSettingKeys() const;
|
virtual QStringList getSettingKeys() const;
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
Property propertyType() const;
|
Property propertyType() const;
|
||||||
void setPropertyType(const Property &type);
|
void setPropertyType(const Property &type);
|
||||||
|
|
||||||
virtual void UpdateParent(const QVariant &value);
|
virtual void UpdateParent(const QVariant &value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ValueChildChanged(const QVariant &value, int typeForParent);
|
virtual void ValueChildChanged(const QVariant &value, int typeForParent);
|
||||||
signals:
|
signals:
|
||||||
void childChanged(const QVariant &value, int typeForParent);
|
void childChanged(const QVariant &value, int typeForParent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Protected constructor
|
//! Protected constructor
|
||||||
VProperty(VPropertyPrivate* d);
|
VProperty(VPropertyPrivate* d);
|
||||||
|
|
||||||
//! The protected structure holding the member variables (to assure binary compatibility)
|
//! The protected structure holding the member variables (to assure binary compatibility)
|
||||||
VPropertyPrivate* d_ptr;
|
VPropertyPrivate* d_ptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Provide access functions for the d_ptr
|
// Provide access functions for the d_ptr
|
||||||
Q_DECLARE_PRIVATE(VProperty)
|
Q_DECLARE_PRIVATE(VProperty)
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTY_H
|
#endif // VPROPERTY_H
|
||||||
|
|
|
@ -1,83 +1,83 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vproperty_p.h
|
** @file vproperty_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTY_P_H
|
#ifndef VPROPERTY_P_H
|
||||||
#define VPROPERTY_P_H
|
#define VPROPERTY_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#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
|
||||||
//! the data type. Also, this can be used as cache, so that when the data() function gets called by
|
//! the data type. Also, this can be used as cache, so that when the data() function gets called by
|
||||||
//! the model, the data does not have to be converted in a QVariant every time.
|
//! the model, the data does not have to be converted in a QVariant every time.
|
||||||
QVariant VariantValue;
|
QVariant VariantValue;
|
||||||
|
|
||||||
//! Property name
|
//! Property name
|
||||||
QString Name;
|
QString Name;
|
||||||
|
|
||||||
//! Description
|
//! Description
|
||||||
QString Description;
|
QString Description;
|
||||||
|
|
||||||
//! Specifies whether the property is empty or not
|
//! Specifies whether the property is empty or not
|
||||||
bool IsEmpty;
|
bool IsEmpty;
|
||||||
|
|
||||||
//! Stores the property type
|
//! Stores the property type
|
||||||
QVariant::Type PropertyVariantType;
|
QVariant::Type PropertyVariantType;
|
||||||
|
|
||||||
//! Stores whether the views have to update the parent of this property if it changes
|
//! Stores whether the views have to update the parent of this property if it changes
|
||||||
bool UpdateParent;
|
bool UpdateParent;
|
||||||
|
|
||||||
//! Stores whether the views have to update the children of this property if it changes
|
//! Stores whether the views have to update the children of this property if it changes
|
||||||
bool UpdateChildren;
|
bool UpdateChildren;
|
||||||
|
|
||||||
//! The parent property
|
//! The parent property
|
||||||
VProperty* Parent;
|
VProperty* Parent;
|
||||||
|
|
||||||
QWidget* editor;
|
QWidget* editor;
|
||||||
|
|
||||||
Property type;
|
Property type;
|
||||||
|
|
||||||
//! List of child properties
|
//! List of child properties
|
||||||
QList<VProperty*> Children;
|
QList<VProperty*> Children;
|
||||||
|
|
||||||
//! Constructor passing name and type
|
//! Constructor passing name and type
|
||||||
VPropertyPrivate(const QString& name, QVariant::Type type)
|
VPropertyPrivate(const QString& name, QVariant::Type type)
|
||||||
: VariantValue(type), Name(name), PropertyVariantType(type), UpdateParent(false), UpdateChildren(false),
|
: VariantValue(type), Name(name), PropertyVariantType(type), UpdateParent(false), UpdateChildren(false),
|
||||||
Parent(nullptr), editor(nullptr), type(Property::Simple)
|
Parent(nullptr), editor(nullptr), type(Property::Simple)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyPrivate()
|
VPropertyPrivate()
|
||||||
: VariantValue(), Name(), PropertyVariantType(QVariant::Invalid), UpdateParent(false), UpdateChildren(false),
|
: VariantValue(), Name(), PropertyVariantType(QVariant::Invalid), UpdateParent(false), UpdateChildren(false),
|
||||||
Parent(nullptr), editor(nullptr)
|
Parent(nullptr), editor(nullptr)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTY_P_H
|
#endif // VPROPERTY_P_H
|
||||||
|
|
|
@ -1,120 +1,120 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertydelegate.cpp
|
** @file vpropertydelegate.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertydelegate.h"
|
#include "vpropertydelegate.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VPropertyDelegate::VPropertyDelegate(QObject *parent) :
|
VPropertyDelegate::VPropertyDelegate(QObject *parent) :
|
||||||
QStyledItemDelegate(parent), RowHeight(0), AddRowHeight(false)
|
QStyledItemDelegate(parent), RowHeight(0), AddRowHeight(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyDelegate::~VPropertyDelegate()
|
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())
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
||||||
tmpWidget = tmpProperty->createEditor(parent, option, this);
|
tmpWidget = tmpProperty->createEditor(parent, option, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpWidget ? tmpWidget : QStyledItemDelegate::createEditor(parent, option, index);
|
return tmpWidget ? tmpWidget : QStyledItemDelegate::createEditor(parent, option, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Sets the index data to the editor
|
//! Sets the index data to the editor
|
||||||
void VPropertyDelegate::setEditorData (QWidget * editor, const QModelIndex & index) const
|
void VPropertyDelegate::setEditorData (QWidget * editor, const QModelIndex & index) const
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
if(index.isValid() && editor)
|
if(index.isValid() && editor)
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
||||||
done = tmpProperty->setEditorData(editor);
|
done = tmpProperty->setEditorData(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
QVariant tmpData;
|
QVariant tmpData;
|
||||||
if(index.isValid() && editor)
|
if(index.isValid() && editor)
|
||||||
{
|
{
|
||||||
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
VProperty* tmpProperty = reinterpret_cast<VProperty*>(index.internalPointer());
|
||||||
tmpData = tmpProperty->getEditorData(editor);
|
tmpData = tmpProperty->getEditorData(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize VPropertyDelegate::sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const
|
QSize VPropertyDelegate::sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
QSize tmpStandardSizeHint = QStyledItemDelegate::sizeHint(option, index);
|
QSize tmpStandardSizeHint = QStyledItemDelegate::sizeHint(option, index);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyDelegate::setRowHeight(int height, bool add_to_standard)
|
void VPropertyDelegate::setRowHeight(int height, bool add_to_standard)
|
||||||
{
|
{
|
||||||
RowHeight = height;
|
RowHeight = height;
|
||||||
AddRowHeight = add_to_standard;
|
AddRowHeight = add_to_standard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
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));
|
||||||
|
|
||||||
QPen tmpOldPen = painter->pen();
|
QPen tmpOldPen = painter->pen();
|
||||||
painter->setPen(QPen(tmpPenColor));
|
painter->setPen(QPen(tmpPenColor));
|
||||||
painter->drawLine(option.rect.right(), option.rect.y(), option.rect.right(), option.rect.bottom());
|
painter->drawLine(option.rect.right(), option.rect.y(), option.rect.right(), option.rect.bottom());
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertydelegate.h
|
** @file vpropertydelegate.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYDELEGATE_H
|
#ifndef VPROPERTYDELEGATE_H
|
||||||
#define VPROPERTYDELEGATE_H
|
#define VPROPERTYDELEGATE_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VPropertyDelegate(QObject *parent = 0);
|
explicit VPropertyDelegate(QObject *parent = 0);
|
||||||
virtual ~VPropertyDelegate();
|
virtual ~VPropertyDelegate();
|
||||||
|
|
||||||
//! Creates the editor widget
|
//! Creates the editor widget
|
||||||
virtual QWidget* createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
virtual QWidget* createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
|
|
||||||
//! Sets the index data to the editor
|
//! Sets the index data to the editor
|
||||||
virtual void setEditorData (QWidget * editor, const QModelIndex & index) const;
|
virtual void setEditorData (QWidget * editor, const QModelIndex & index) const;
|
||||||
|
|
||||||
//! Updates the index data
|
//! Updates the index data
|
||||||
virtual void setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
|
virtual void setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
|
||||||
|
|
||||||
//! Returns the size hint
|
//! Returns the size hint
|
||||||
virtual QSize sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
virtual QSize sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
|
|
||||||
//! Sets the row height. Set this to 0 and the standard will be taken
|
//! Sets the row height. Set this to 0 and the standard will be taken
|
||||||
void setRowHeight(int height = 0, bool add_to_standard = false);
|
void setRowHeight(int height = 0, bool add_to_standard = false);
|
||||||
|
|
||||||
//! Renders the delegate using the given painter and style option for the item specified by index.
|
//! Renders the delegate using the given painter and style option for the item specified by index.
|
||||||
virtual void paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual void paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int RowHeight;
|
int RowHeight;
|
||||||
bool AddRowHeight;
|
bool AddRowHeight;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYDELEGATE_H
|
#endif // VPROPERTYDELEGATE_H
|
||||||
|
|
|
@ -1,129 +1,129 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyfactorymanager.cpp
|
** @file vpropertyfactorymanager.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertyfactorymanager.h"
|
#include "vpropertyfactorymanager.h"
|
||||||
#include "vpropertyfactorymanager_p.h"
|
#include "vpropertyfactorymanager_p.h"
|
||||||
|
|
||||||
#include "vstandardpropertyfactory.h"
|
#include "vstandardpropertyfactory.h"
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
|
|
||||||
VPropertyFactoryManager* VPropertyFactoryManager::DefaultManager = NULL;
|
VPropertyFactoryManager* VPropertyFactoryManager::DefaultManager = NULL;
|
||||||
|
|
||||||
VPropertyFactoryManager::VPropertyFactoryManager(QObject *parent)
|
VPropertyFactoryManager::VPropertyFactoryManager(QObject *parent)
|
||||||
: QObject(parent), d_ptr(new VPropertyFactoryManagerPrivate())
|
: QObject(parent), d_ptr(new VPropertyFactoryManagerPrivate())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFactoryManager::~VPropertyFactoryManager()
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
// Register new one
|
// Register new one
|
||||||
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)
|
||||||
{
|
{
|
||||||
return (!d_ptr->Factories.key(factory, QString()).isEmpty());
|
return (!d_ptr->Factories.key(factory, QString()).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
VAbstractPropertyFactory* VPropertyFactoryManager::getFactory(const QString& type)
|
VAbstractPropertyFactory* VPropertyFactoryManager::getFactory(const QString& type)
|
||||||
{
|
{
|
||||||
return d_ptr->Factories.value(type, NULL);
|
return d_ptr->Factories.value(type, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefaultManager;
|
return DefaultManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList VPropertyFactoryManager::getSupportedTypes()
|
QStringList VPropertyFactoryManager::getSupportedTypes()
|
||||||
{
|
{
|
||||||
return d_ptr->Factories.keys();
|
return d_ptr->Factories.keys();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyfactorymanager.h
|
** @file vpropertyfactorymanager.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYFACTORYMANAGER_H
|
#ifndef VPROPERTYFACTORYMANAGER_H
|
||||||
#define VPROPERTYFACTORYMANAGER_H
|
#define VPROPERTYFACTORYMANAGER_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VAbstractPropertyFactory;
|
class VAbstractPropertyFactory;
|
||||||
class VPropertyFactoryManagerPrivate;
|
class VPropertyFactoryManagerPrivate;
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFactoryManager : public QObject
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFactoryManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyFactoryManager(QObject* parent = nullptr);
|
VPropertyFactoryManager(QObject* parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VPropertyFactoryManager();
|
virtual ~VPropertyFactoryManager();
|
||||||
|
|
||||||
//! Register a factory to the factory manager
|
//! Register a factory to the factory manager
|
||||||
//! Note that the manager takes ownership of the factory, so don't delete it.
|
//! Note that the manager takes ownership of the factory, so don't delete it.
|
||||||
//! You can unregister a factory using unregisterFactory()
|
//! You can unregister a factory using unregisterFactory()
|
||||||
void registerFactory(const QString& type, VAbstractPropertyFactory* factory);
|
void registerFactory(const QString& type, VAbstractPropertyFactory* factory);
|
||||||
|
|
||||||
//! 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 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.
|
//! \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);
|
||||||
|
|
||||||
//! Returns whether a factory is registered (and thus owned) by this factory manager
|
//! Returns whether a factory is registered (and thus owned) by this factory manager
|
||||||
bool isRegistered(VAbstractPropertyFactory* factory);
|
bool isRegistered(VAbstractPropertyFactory* factory);
|
||||||
|
|
||||||
//! Returns a pointer to a factory registered for a certain type
|
//! Returns a pointer to a factory registered for a certain type
|
||||||
//! \param type The type to return the factory for
|
//! \param type The type to return the factory for
|
||||||
//! \return Returns NULL, if there is none registered for this type
|
//! \return Returns NULL, if there is none registered for this type
|
||||||
VAbstractPropertyFactory* getFactory(const QString& type);
|
VAbstractPropertyFactory* getFactory(const QString& type);
|
||||||
|
|
||||||
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
||||||
//! \param type The type of the property as string
|
//! \param type The type of the property as string
|
||||||
//! \param name The name of the property
|
//! \param name The name of the property
|
||||||
//! \param description The property's description. Optional.
|
//! \param description The property's description. Optional.
|
||||||
//! \param default_value The properties initial value as string. Optional.
|
//! \param default_value The properties initial value as string. Optional.
|
||||||
//! \return Returns the created property or NULL if it couldn't be be created
|
//! \return Returns the created property or NULL if it couldn't be be created
|
||||||
VProperty* createProperty(const QString& type, const QString& name, const QString& description = QString(),
|
VProperty* createProperty(const QString& type, const QString& name, const QString& description = QString(),
|
||||||
const QString& default_value = QString());
|
const QString& default_value = QString());
|
||||||
|
|
||||||
//! Returns the default manager.
|
//! Returns the default manager.
|
||||||
static VPropertyFactoryManager* getDefaultManager();
|
static VPropertyFactoryManager* getDefaultManager();
|
||||||
|
|
||||||
//! Returns a list of all supported property types
|
//! Returns a list of all supported property types
|
||||||
QStringList getSupportedTypes();
|
QStringList getSupportedTypes();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
VPropertyFactoryManagerPrivate* d_ptr;
|
VPropertyFactoryManagerPrivate* d_ptr;
|
||||||
|
|
||||||
//! The default manager
|
//! The default manager
|
||||||
static VPropertyFactoryManager* DefaultManager;
|
static VPropertyFactoryManager* DefaultManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYFACTORYMANAGER_H
|
#endif // VPROPERTYFACTORYMANAGER_H
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyfactorymanager_p.h
|
** @file vpropertyfactorymanager_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYFACTORYMANAGER_P_H
|
#ifndef VPROPERTYFACTORYMANAGER_P_H
|
||||||
#define VPROPERTYFACTORYMANAGER_P_H
|
#define VPROPERTYFACTORYMANAGER_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYFACTORYMANAGER_P_H
|
#endif // VPROPERTYFACTORYMANAGER_P_H
|
||||||
|
|
|
@ -1,199 +1,199 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyformview.cpp
|
** @file vpropertyformview.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertyformview.h"
|
#include "vpropertyformview.h"
|
||||||
#include "vpropertymodel.h"
|
#include "vpropertymodel.h"
|
||||||
#include "vpropertyset.h"
|
#include "vpropertyset.h"
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
|
||||||
#include "vpropertyformview_p.h"
|
#include "vpropertyformview_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VPropertyFormView::VPropertyFormView(QWidget* parent)
|
VPropertyFormView::VPropertyFormView(QWidget* parent)
|
||||||
: VPropertyFormWidget(new VPropertyFormViewPrivate(), parent)
|
: VPropertyFormWidget(new VPropertyFormViewPrivate(), parent)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFormView::VPropertyFormView(VPropertyModel* model, QWidget *parent)
|
VPropertyFormView::VPropertyFormView(VPropertyModel* model, QWidget *parent)
|
||||||
: VPropertyFormWidget(new VPropertyFormViewPrivate(), parent)
|
: VPropertyFormWidget(new VPropertyFormViewPrivate(), parent)
|
||||||
{
|
{
|
||||||
setModel(model);
|
setModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFormView::VPropertyFormView(VPropertySet* property_set, QWidget *parent)
|
VPropertyFormView::VPropertyFormView(VPropertySet* property_set, QWidget *parent)
|
||||||
: VPropertyFormWidget(new VPropertyFormViewPrivate(), parent)
|
: VPropertyFormWidget(new VPropertyFormViewPrivate(), parent)
|
||||||
{
|
{
|
||||||
setPropertySet(property_set);
|
setPropertySet(property_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFormView::~VPropertyFormView()
|
VPropertyFormView::~VPropertyFormView()
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::build()
|
void VPropertyFormView::build()
|
||||||
{
|
{
|
||||||
VPropertyFormWidget::build();
|
VPropertyFormWidget::build();
|
||||||
|
|
||||||
// Go through all sub widgets and connect
|
// Go through all sub widgets and connect
|
||||||
connectPropertyFormWidget(this);
|
connectPropertyFormWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::setModel(VPropertyModel *model)
|
void VPropertyFormView::setModel(VPropertyModel *model)
|
||||||
{
|
{
|
||||||
// Remove old model or set
|
// Remove old model or set
|
||||||
removeModelAndSet();
|
removeModelAndSet();
|
||||||
|
|
||||||
// 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
|
||||||
updatePropertyList();
|
updatePropertyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::setPropertySet(VPropertySet* property_set)
|
void VPropertyFormView::setPropertySet(VPropertySet* property_set)
|
||||||
{
|
{
|
||||||
// Remove old model or set
|
// Remove old model or set
|
||||||
removeModelAndSet();
|
removeModelAndSet();
|
||||||
|
|
||||||
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the widget
|
// Build the widget
|
||||||
updatePropertyList();
|
updatePropertyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::rowsRemoved(const QModelIndex &parent, int start, int end)
|
void VPropertyFormView::rowsRemoved(const QModelIndex &parent, int start, int end)
|
||||||
{
|
{
|
||||||
// todo: Only rebuild the neccessary parts
|
// todo: Only rebuild the neccessary parts
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
Q_UNUSED(start)
|
Q_UNUSED(start)
|
||||||
Q_UNUSED(end)
|
Q_UNUSED(end)
|
||||||
updatePropertyList();
|
updatePropertyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::rowsInserted(const QModelIndex &parent, int start, int end)
|
void VPropertyFormView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||||
{
|
{
|
||||||
// todo: Only rebuild the neccessary parts
|
// todo: Only rebuild the neccessary parts
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
Q_UNUSED(start)
|
Q_UNUSED(start)
|
||||||
Q_UNUSED(end)
|
Q_UNUSED(end)
|
||||||
updatePropertyList();
|
updatePropertyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::modelReset()
|
void VPropertyFormView::modelReset()
|
||||||
{
|
{
|
||||||
updatePropertyList();
|
updatePropertyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::modelDestroyed()
|
void VPropertyFormView::modelDestroyed()
|
||||||
{
|
{
|
||||||
removeModelAndSet();
|
removeModelAndSet();
|
||||||
updatePropertyList();
|
updatePropertyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::dataSubmitted(VProperty *property)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::showEvent(QShowEvent *event)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormView::updatePropertyList()
|
void VPropertyFormView::updatePropertyList()
|
||||||
{
|
{
|
||||||
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
VPropertyModel* tmpModel = static_cast<VPropertyFormViewPrivate*>(d_ptr)->Model;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = true;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->NeedsRebuild = true;
|
||||||
d_ptr->Properties.clear();
|
d_ptr->Properties.clear();
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet = nullptr;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->PropertySet = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +1,101 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyformview.h
|
** @file vpropertyformview.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYFORMVIEW_H
|
#ifndef VPROPERTYFORMVIEW_H
|
||||||
#define VPROPERTYFORMVIEW_H
|
#define VPROPERTYFORMVIEW_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include "vpropertyformwidget.h"
|
#include "vpropertyformwidget.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
class VPropertyModel;
|
class VPropertyModel;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
//! This class populates a form layout with the properties in a model
|
//! This class populates a form layout with the properties in a model
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormView : public VPropertyFormWidget
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormView : public VPropertyFormWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit VPropertyFormView(QWidget *parent = 0);
|
explicit VPropertyFormView(QWidget *parent = 0);
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit VPropertyFormView(VPropertyModel* model, QWidget *parent = 0);
|
explicit VPropertyFormView(VPropertyModel* model, QWidget *parent = 0);
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit VPropertyFormView(VPropertySet* property_set, QWidget *parent = 0);
|
explicit VPropertyFormView(VPropertySet* property_set, QWidget *parent = 0);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VPropertyFormView();
|
virtual ~VPropertyFormView();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Rebuilds the whole form
|
//! Rebuilds the whole form
|
||||||
virtual void build();
|
virtual void build();
|
||||||
|
|
||||||
//! Set the source model. Leads to the rebuild of the form
|
//! Set the source model. Leads to the rebuild of the form
|
||||||
//! \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);
|
||||||
|
|
||||||
//! Called when a row gets removed in the model
|
//! Called when a row gets removed in the model
|
||||||
void rowsRemoved(const QModelIndex& parent, int start, int end);
|
void rowsRemoved(const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
//! Called when a new row is being inserted into the model
|
//! Called when a new row is being inserted into the model
|
||||||
void rowsInserted(const QModelIndex& parent, int start, int end);
|
void rowsInserted(const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
//! Called when the model is being reset
|
//! Called when the model is being reset
|
||||||
void modelReset();
|
void modelReset();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Called, when the model gets destroyed
|
//! Called, when the model gets destroyed
|
||||||
void modelDestroyed();
|
void modelDestroyed();
|
||||||
|
|
||||||
//! Called when data in the model gets changed
|
//! Called when data in the model gets changed
|
||||||
void dataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right);
|
void dataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right);
|
||||||
|
|
||||||
//! Updates the model when data was submitted by the view
|
//! Updates the model when data was submitted by the view
|
||||||
void dataSubmitted(VProperty* property);
|
void dataSubmitted(VProperty* property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
|
|
||||||
//! Rebuilds the widegt only if it is visible
|
//! Rebuilds the widegt only if it is visible
|
||||||
void updatePropertyList();
|
void updatePropertyList();
|
||||||
|
|
||||||
//! Removes the model and property set if they were set
|
//! Removes the model and property set if they were set
|
||||||
void removeModelAndSet();
|
void removeModelAndSet();
|
||||||
|
|
||||||
//! Function to handle newly created VPropertyWidgets
|
//! Function to handle newly created VPropertyWidgets
|
||||||
virtual void connectPropertyFormWidget(VPropertyFormWidget* widget);
|
virtual void connectPropertyFormWidget(VPropertyFormWidget* widget);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace VPE
|
} // Namespace VPE
|
||||||
|
|
||||||
#endif // VPROPERTYFORMVIEW_H
|
#endif // VPROPERTYFORMVIEW_H
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyformview_p.h
|
** @file vpropertyformview_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYFORMVIEW_P_H
|
#ifndef VPROPERTYFORMVIEW_P_H
|
||||||
#define VPROPERTYFORMVIEW_P_H
|
#define VPROPERTYFORMVIEW_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#include "vpropertyformwidget_p.h"
|
#include "vpropertyformwidget_p.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPropertyModel;
|
class VPropertyModel;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
class VPropertyFormViewPrivate : public VPropertyFormWidgetPrivate
|
class VPropertyFormViewPrivate : public VPropertyFormWidgetPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! The current property model
|
//! The current property model
|
||||||
VPropertyModel* Model;
|
VPropertyModel* Model;
|
||||||
|
|
||||||
//! The currently used property set
|
//! The currently used property set
|
||||||
VPropertySet* PropertySet;
|
VPropertySet* PropertySet;
|
||||||
|
|
||||||
//! Determines whether the widget needs to be rebuild
|
//! Determines whether the widget needs to be rebuild
|
||||||
bool NeedsRebuild;
|
bool NeedsRebuild;
|
||||||
|
|
||||||
//! Helper variable
|
//! Helper variable
|
||||||
bool IgnoreDataChangedSignal;
|
bool IgnoreDataChangedSignal;
|
||||||
|
|
||||||
VPropertyFormViewPrivate()
|
VPropertyFormViewPrivate()
|
||||||
: VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(NULL), NeedsRebuild(false) {}
|
: VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(NULL), NeedsRebuild(false) {}
|
||||||
|
|
||||||
VPropertyFormViewPrivate(VPropertyModel* prop_model)
|
VPropertyFormViewPrivate(VPropertyModel* prop_model)
|
||||||
: VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(NULL), NeedsRebuild(false) {}
|
: VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(NULL), NeedsRebuild(false) {}
|
||||||
|
|
||||||
VPropertyFormViewPrivate(VPropertySet* prop_set)
|
VPropertyFormViewPrivate(VPropertySet* prop_set)
|
||||||
: VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(prop_set), NeedsRebuild(false) {}
|
: VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(prop_set), NeedsRebuild(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYFORMVIEW_P_H
|
#endif // VPROPERTYFORMVIEW_P_H
|
||||||
|
|
|
@ -1,303 +1,303 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyformwidget.cpp
|
** @file vpropertyformwidget.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertyformwidget.h"
|
#include "vpropertyformwidget.h"
|
||||||
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include "vpropertyformwidget_p.h"
|
#include "vpropertyformwidget_p.h"
|
||||||
|
|
||||||
#include "plugins/vwidgetproperty.h"
|
#include "plugins/vwidgetproperty.h"
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
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();
|
||||||
setToolTip(description);
|
setToolTip(description);
|
||||||
setWhatsThis(description);
|
setWhatsThis(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
setToolTip(parent_property->getDescription());
|
setToolTip(parent_property->getDescription());
|
||||||
setWhatsThis(parent_property->getDescription());
|
setWhatsThis(parent_property->getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
setToolTip(description);
|
setToolTip(description);
|
||||||
setWhatsThis(description);
|
setWhatsThis(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyFormWidget::~VPropertyFormWidget()
|
VPropertyFormWidget::~VPropertyFormWidget()
|
||||||
{
|
{
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VPropertyFormWidget::build()
|
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);
|
||||||
QWidget *group = new QWidget(this);
|
QWidget *group = new QWidget(this);
|
||||||
tmpFormLayout->addRow(group);
|
tmpFormLayout->addRow(group);
|
||||||
|
|
||||||
QFormLayout* subFormLayout = new QFormLayout(group);
|
QFormLayout* subFormLayout = new QFormLayout(group);
|
||||||
QMargins margins = subFormLayout->contentsMargins();
|
QMargins margins = subFormLayout->contentsMargins();
|
||||||
margins.setTop(0);
|
margins.setTop(0);
|
||||||
margins.setLeft(14);
|
margins.setLeft(14);
|
||||||
subFormLayout->setContentsMargins(margins);
|
subFormLayout->setContentsMargins(margins);
|
||||||
|
|
||||||
group->setLayout(subFormLayout);
|
group->setLayout(subFormLayout);
|
||||||
QList<VProperty*> children = tmpProperty->getChildren();
|
QList<VProperty*> children = tmpProperty->getChildren();
|
||||||
for (int j = 0; j < children.size(); ++j)
|
for (int j = 0; j < children.size(); ++j)
|
||||||
{
|
{
|
||||||
buildEditor(children[j], subFormLayout);
|
buildEditor(children[j], subFormLayout);
|
||||||
connect(children[j], &VProperty::childChanged, tmpProperty, &VProperty::ValueChildChanged,
|
connect(children[j], &VProperty::childChanged, tmpProperty, &VProperty::ValueChildChanged,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
++i;
|
++i;
|
||||||
d_ptr->Properties.insert(i, children[j]);
|
d_ptr->Properties.insert(i, children[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Child properties, the property itself is not being added
|
// Child properties, the property itself is not being added
|
||||||
VPropertyFormWidget* tmpNewFormWidget = new VPropertyFormWidget(tmpProperty, this);
|
VPropertyFormWidget* tmpNewFormWidget = new VPropertyFormWidget(tmpProperty, this);
|
||||||
tmpFormLayout->addRow(tmpNewFormWidget);
|
tmpFormLayout->addRow(tmpNewFormWidget);
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayout, Property type)
|
void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayout, Property type)
|
||||||
{
|
{
|
||||||
// Add property (no child properties)
|
// Add property (no child properties)
|
||||||
// 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());
|
||||||
tmpEditor->setWhatsThis(property->getDescription());
|
tmpEditor->setWhatsThis(property->getDescription());
|
||||||
|
|
||||||
// Install event filter
|
// Install event filter
|
||||||
tmpEditor->installEventFilter(this);
|
tmpEditor->installEventFilter(this);
|
||||||
|
|
||||||
// Set the editor data
|
// Set the editor data
|
||||||
property->setEditorData(tmpEditor);
|
property->setEditorData(tmpEditor);
|
||||||
|
|
||||||
// add new row
|
// add new row
|
||||||
if (type == Property::Complex)
|
if (type == Property::Complex)
|
||||||
{
|
{
|
||||||
QString name = "<b>"+property->getName()+"</b>";
|
QString name = "<b>"+property->getName()+"</b>";
|
||||||
formLayout->addRow(name, tmpEditor);
|
formLayout->addRow(name, tmpEditor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
formLayout->addRow(property->getName(), tmpEditor);
|
formLayout->addRow(property->getName(), tmpEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpEditor));
|
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpEditor));
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
QVariant oldValue = tmpProperty->data(VProperty::DPC_Data, Qt::EditRole);
|
QVariant oldValue = tmpProperty->data(VProperty::DPC_Data, Qt::EditRole);
|
||||||
if (oldValue != newValue)
|
if (oldValue != newValue)
|
||||||
{
|
{
|
||||||
VProperty *parent = tmpProperty->getParent();
|
VProperty *parent = tmpProperty->getParent();
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
{
|
{
|
||||||
tmpProperty->setValue(newValue);
|
tmpProperty->setValue(newValue);
|
||||||
emit propertyDataSubmitted(tmpProperty);
|
emit propertyDataSubmitted(tmpProperty);
|
||||||
}
|
}
|
||||||
else if (parent->propertyType() == Property::Complex)
|
else if (parent->propertyType() == Property::Complex)
|
||||||
{
|
{
|
||||||
tmpProperty->UpdateParent(newValue);
|
tmpProperty->UpdateParent(newValue);
|
||||||
emit propertyDataSubmitted(parent);
|
emit propertyDataSubmitted(parent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpProperty->setValue(newValue);
|
tmpProperty->setValue(newValue);
|
||||||
emit propertyDataSubmitted(tmpProperty);
|
emit propertyDataSubmitted(tmpProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyFormWidget::setCommitBehaviour(bool auto_commit)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
commitData(editor);
|
commitData(editor);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
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) {
|
} else if (event->type() == QEvent::ShortcutOverride) {
|
||||||
if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
|
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;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QGroupBox::eventFilter(object, event);
|
return QGroupBox::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default:
|
// Default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,97 +1,97 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyformwidget.h
|
** @file vpropertyformwidget.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYFORMWIDGET_H
|
#ifndef VPROPERTYFORMWIDGET_H
|
||||||
#define VPROPERTYFORMWIDGET_H
|
#define VPROPERTYFORMWIDGET_H
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
class QFormLayout;
|
class QFormLayout;
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPropertyFormWidgetPrivate;
|
class VPropertyFormWidgetPrivate;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
//! Class that displays the sub properties of a property using a form layout
|
//! Class that displays the sub properties of a property using a form layout
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormWidget : public QGroupBox
|
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);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VPropertyFormWidget();
|
~VPropertyFormWidget();
|
||||||
|
|
||||||
|
|
||||||
//! Returns a list of all child property form widgets (note that indirect children will not be in the list)
|
//! Returns a list of all child property form widgets (note that indirect children will not be in the list)
|
||||||
QList<VPropertyFormWidget*> getChildPropertyFormWidgets() const;
|
QList<VPropertyFormWidget*> getChildPropertyFormWidgets() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Rebuilds the whole form
|
//! Rebuilds the whole form
|
||||||
virtual void build();
|
virtual void build();
|
||||||
|
|
||||||
void buildEditor(VProperty *property, QFormLayout *formLayout, Property type = Property::Simple);
|
void buildEditor(VProperty *property, QFormLayout *formLayout, Property type = Property::Simple);
|
||||||
|
|
||||||
//! Reads the data from the editors and commits it to the properties
|
//! Reads the data from the editors and commits it to the properties
|
||||||
void commitData();
|
void commitData();
|
||||||
|
|
||||||
//! Refills the editors with the propertie's data
|
//! Refills the editors with the propertie's data
|
||||||
void loadData();
|
void loadData();
|
||||||
|
|
||||||
//! Reads the data from row'th editor and commits it to the property
|
//! Reads the data from row'th editor and commits it to the property
|
||||||
void commitData(int row);
|
void commitData(int row);
|
||||||
|
|
||||||
//! Reads the data from row'th property
|
//! Reads the data from row'th property
|
||||||
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:
|
||||||
//! Emitted whenever a property data changes
|
//! Emitted whenever a property data changes
|
||||||
void propertyDataSubmitted(VProperty* property);
|
void propertyDataSubmitted(VProperty* property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Protected Constructor
|
//! Protected Constructor
|
||||||
VPropertyFormWidget(VPropertyFormWidgetPrivate* d_pointer, QWidget* parent, const QString &title = QString(),
|
VPropertyFormWidget(VPropertyFormWidgetPrivate* d_pointer, QWidget* parent, const QString &title = QString(),
|
||||||
const QString &description = QString());
|
const QString &description = QString());
|
||||||
|
|
||||||
//! The protected data
|
//! The protected data
|
||||||
VPropertyFormWidgetPrivate* d_ptr;
|
VPropertyFormWidgetPrivate* d_ptr;
|
||||||
|
|
||||||
//! Event filter for the editor widgets
|
//! Event filter for the editor widgets
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
//! Commits data of an editor
|
//! Commits data of an editor
|
||||||
void commitData(QWidget* editor);
|
void commitData(QWidget* editor);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace VPE
|
} // Namespace VPE
|
||||||
|
|
||||||
#endif // VPROPERTYFORMWIDGET_H
|
#endif // VPROPERTYFORMWIDGET_H
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyformwidget_p.h
|
** @file vpropertyformwidget_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYFORMWIDGET_P_H
|
#ifndef VPROPERTYFORMWIDGET_P_H
|
||||||
#define VPROPERTYFORMWIDGET_P_H
|
#define VPROPERTYFORMWIDGET_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#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) {}
|
||||||
|
|
||||||
VPropertyFormWidget* FormWidget;
|
VPropertyFormWidget* FormWidget;
|
||||||
QWidget* Editor;
|
QWidget* Editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! The root property to use
|
//! The root property to use
|
||||||
QList<VProperty*> Properties;
|
QList<VProperty*> Properties;
|
||||||
|
|
||||||
//! 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
|
||||||
VPropertyFormWidgetPrivate()
|
VPropertyFormWidgetPrivate()
|
||||||
: UpdateEditors(true)
|
: UpdateEditors(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyFormWidgetPrivate(const QList<VProperty*>& properties)
|
VPropertyFormWidgetPrivate(const QList<VProperty*>& properties)
|
||||||
: Properties(properties), UpdateEditors(true) {}
|
: Properties(properties), UpdateEditors(true) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYFORMWIDGET_P_H
|
#endif // VPROPERTYFORMWIDGET_P_H
|
||||||
|
|
|
@ -1,306 +1,306 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertymodel.cpp
|
** @file vpropertymodel.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertymodel.h"
|
#include "vpropertymodel.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include "vpropertyset.h"
|
#include "vpropertyset.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
#include "vpropertymodel_p.h"
|
#include "vpropertymodel_p.h"
|
||||||
|
|
||||||
VPropertyModel::VPropertyModel(VPropertyModelPrivate *d, QObject *parent)
|
VPropertyModel::VPropertyModel(VPropertyModelPrivate *d, QObject *parent)
|
||||||
: QAbstractItemModel(parent), d_ptr(d)
|
: QAbstractItemModel(parent), d_ptr(d)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VPropertyModel::VPropertyModel(QObject * parent) :
|
VPropertyModel::VPropertyModel(QObject * parent) :
|
||||||
QAbstractItemModel(parent), d_ptr(new VPropertyModelPrivate())
|
QAbstractItemModel(parent), d_ptr(new VPropertyModelPrivate())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Adds the property to the model and attaches it to the parentid
|
//! Adds the property to the model and attaches it to the parentid
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Gets a property by it's ID
|
//! Gets a property by it's ID
|
||||||
VProperty* VPropertyModel::getProperty(const QString& id)
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the parent of one model index
|
//! Returns the parent of one model index
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the item flags for the given index
|
//! Returns the item flags for the given index
|
||||||
Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the role data for the item at index to value
|
//! Sets the role data for the item at index to value
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns the data of an model index
|
//! Returns the data of an model index
|
||||||
QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) return d_ptr->HeadlineProperty;
|
||||||
else if (section == 1) return d_ptr->HeadlineValue;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns the number of columns
|
//! Returns the number of columns
|
||||||
int VPropertyModel::columnCount ( const QModelIndex & parent) const
|
int VPropertyModel::columnCount ( const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VPropertyModel::getPropertyID(VProperty *prop) const
|
QString VPropertyModel::getPropertyID(VProperty *prop) const
|
||||||
{
|
{
|
||||||
return d_ptr->Properties != nullptr ? d_ptr->Properties->getPropertyID(prop) : QString();
|
return d_ptr->Properties != nullptr ? d_ptr->Properties->getPropertyID(prop) : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return createIndex(row, column, property);
|
return createIndex(row, column, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VPropertyModel::onDataChangedByModel(VProperty* property)
|
void VPropertyModel::onDataChangedByModel(VProperty* property)
|
||||||
{
|
{
|
||||||
QModelIndex tmpIndex = getIndexFromProperty(property, 1);
|
QModelIndex tmpIndex = getIndexFromProperty(property, 1);
|
||||||
if(tmpIndex.isValid())
|
if(tmpIndex.isValid())
|
||||||
{
|
{
|
||||||
emit dataChanged(tmpIndex, tmpIndex);
|
emit dataChanged(tmpIndex, tmpIndex);
|
||||||
emit onDataChangedByEditor(property);
|
emit onDataChangedByEditor(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VPropertySet *VPropertyModel::getPropertySet() const
|
const VPropertySet *VPropertyModel::getPropertySet() const
|
||||||
{
|
{
|
||||||
return d_ptr->Properties;
|
return d_ptr->Properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyModel::clear(bool emit_signals)
|
void VPropertyModel::clear(bool emit_signals)
|
||||||
{
|
{
|
||||||
setPropertySet(nullptr, emit_signals);
|
setPropertySet(nullptr, emit_signals);
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertySet *VPropertyModel::takePropertySet(VPropertySet *new_property_set, bool emit_signals)
|
VPropertySet *VPropertyModel::takePropertySet(VPropertySet *new_property_set, bool emit_signals)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyModel::setPropertySet(VPropertySet *property_set, bool emit_signals)
|
void VPropertyModel::setPropertySet(VPropertySet *property_set, bool emit_signals)
|
||||||
{
|
{
|
||||||
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();
|
||||||
return tmpProp;
|
return tmpProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,160 +1,160 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertymodel.h
|
** @file vpropertymodel.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYMODEL_H
|
#ifndef VPROPERTYMODEL_H
|
||||||
#define VPROPERTYMODEL_H
|
#define VPROPERTYMODEL_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPropertyModelPrivate;
|
class VPropertyModelPrivate;
|
||||||
class VPropertySet;
|
class VPropertySet;
|
||||||
|
|
||||||
//! \brief This is the base model for managing all the properties
|
//! \brief This is the base model for managing all the properties
|
||||||
//! and passing them to the view.
|
//! and passing them to the view.
|
||||||
//!
|
//!
|
||||||
//! When you create your own "proxy models", this is the place to
|
//! When you create your own "proxy models", this is the place to
|
||||||
//! start: just subclass VPropertyModel and extend the new class.
|
//! start: just subclass VPropertyModel and extend the new class.
|
||||||
//! Have a look at existing examples of proxies.
|
//! Have a look at existing examples of proxies.
|
||||||
//!
|
//!
|
||||||
//! <strong>Note that in this context, the term "proxy model" does not refer
|
//! <strong>Note that in this context, the term "proxy model" does not refer
|
||||||
//! to VProxyModel as that is another concept.</strong>
|
//! to VProxyModel as that is another concept.</strong>
|
||||||
//! The idea behind "proxy models" in the QtPropertyExplorer framework
|
//! The idea behind "proxy models" in the QtPropertyExplorer framework
|
||||||
//! is to provide an convenient interface which takes data as your
|
//! is to provide an convenient interface which takes data as your
|
||||||
//! application (or a third-party-library) provides it, and converts this
|
//! application (or a third-party-library) provides it, and converts this
|
||||||
//! data to VProperty-objects, manage them and produce output for the views.
|
//! data to VProperty-objects, manage them and produce output for the views.
|
||||||
//!
|
//!
|
||||||
//! In most cases, you will not need to rewrite the basic functions of
|
//! In most cases, you will not need to rewrite the basic functions of
|
||||||
//! QAbstractItemModel, as VPropertyModel provides standard implementations
|
//! QAbstractItemModel, as VPropertyModel provides standard implementations
|
||||||
//! to work with. Thus, instead of subclassing VPropertyModel, it is also
|
//! to work with. Thus, instead of subclassing VPropertyModel, it is also
|
||||||
//! possible to use VPropertyModel directly (as it is not an abstract class).
|
//! possible to use VPropertyModel directly (as it is not an abstract class).
|
||||||
//! This might be more convenient in some cases.
|
//! This might be more convenient in some cases.
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel : public QAbstractItemModel
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VPropertyModel(QObject * parent = 0);
|
explicit VPropertyModel(QObject * parent = 0);
|
||||||
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);
|
||||||
|
|
||||||
//! Creates a property and adds it to the model
|
//! Creates a property and adds it to the model
|
||||||
virtual VProperty* createProperty(const QString& id, const QString& name, const QString& parentid = QString(),
|
virtual VProperty* createProperty(const QString& id, const QString& name, const QString& parentid = QString(),
|
||||||
const QVariant& data = QVariant());
|
const QVariant& data = QVariant());
|
||||||
|
|
||||||
//! Gets a property by it's ID
|
//! Gets a property by it's ID
|
||||||
virtual VProperty* getProperty(const QString& id);
|
virtual VProperty* getProperty(const QString& id);
|
||||||
|
|
||||||
//! Returns the item flags for the given index
|
//! Returns the item flags for the given index
|
||||||
virtual Qt::ItemFlags flags (const QModelIndex& index) const;
|
virtual Qt::ItemFlags flags (const QModelIndex& index) const;
|
||||||
|
|
||||||
//! Sets the role data for the item at index to value
|
//! Sets the role data for the item at index to value
|
||||||
virtual bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
virtual bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
|
|
||||||
//! Returns the model index at row/column
|
//! Returns the model index at row/column
|
||||||
virtual QModelIndex index (int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
virtual QModelIndex index (int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||||
|
|
||||||
//! Returns the parent of one model index
|
//! Returns the parent of one model index
|
||||||
virtual QModelIndex parent (const QModelIndex& index) const;
|
virtual QModelIndex parent (const QModelIndex& index) const;
|
||||||
|
|
||||||
//! Returns the data of an model index
|
//! Returns the data of an model index
|
||||||
virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
|
virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
//! Returns the data for the given role and section in the header with the specified orientation.
|
//! Returns the data for the given role and section in the header with the specified orientation.
|
||||||
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
//! Returns the number of rows
|
//! Returns the number of rows
|
||||||
virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
|
virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
|
||||||
|
|
||||||
//! 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
|
||||||
virtual VProperty* getProperty(const QModelIndex &index) const;
|
virtual VProperty* getProperty(const QModelIndex &index) const;
|
||||||
|
|
||||||
//! Returns the ID of the property within the model
|
//! Returns the ID of the property within the model
|
||||||
//! The concept of property IDs is, that the object that manages the properties
|
//! The concept of property IDs is, that the object that manages the properties
|
||||||
//! and not the properties themselves handle the IDs.
|
//! and not the properties themselves handle the IDs.
|
||||||
//! \param property
|
//! \param property
|
||||||
//! \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);
|
||||||
|
|
||||||
//! Removes a property from the model and returns it
|
//! Removes a property from the model and returns it
|
||||||
virtual VProperty* takeProperty(const QString& id);
|
virtual VProperty* takeProperty(const QString& id);
|
||||||
|
|
||||||
//! Removes a property from the model and deletes it
|
//! Removes a property from the model and deletes it
|
||||||
virtual void removeProperty(const QString& id);
|
virtual void removeProperty(const QString& id);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! This signal is being emitted, when the setData method is being called
|
//! This signal is being emitted, when the setData method is being called
|
||||||
void onDataChangedByEditor(VProperty* property);
|
void onDataChangedByEditor(VProperty* property);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! This function causes the views to update the property
|
//! This function causes the views to update the property
|
||||||
void onDataChangedByModel(VProperty* property);
|
void onDataChangedByModel(VProperty* property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Gets a property by its ModelIndex
|
//! Gets a property by its ModelIndex
|
||||||
virtual QModelIndex getIndexFromProperty(VProperty* property, int column = 0) const;
|
virtual QModelIndex getIndexFromProperty(VProperty* property, int column = 0) const;
|
||||||
|
|
||||||
//! Protected constructor passing the private object
|
//! Protected constructor passing the private object
|
||||||
VPropertyModel(VPropertyModelPrivate* d, QObject* parent = 0);
|
VPropertyModel(VPropertyModelPrivate* d, QObject* parent = 0);
|
||||||
|
|
||||||
//! The model data
|
//! The model data
|
||||||
VPropertyModelPrivate* d_ptr;
|
VPropertyModelPrivate* d_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYMODEL_H
|
#endif // VPROPERTYMODEL_H
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertymodel_p.h
|
** @file vpropertymodel_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYMODEL_P_H
|
#ifndef VPROPERTYMODEL_P_H
|
||||||
#define VPROPERTYMODEL_P_H
|
#define VPROPERTYMODEL_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#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;
|
||||||
|
|
||||||
//! The header data for the property name column
|
//! The header data for the property name column
|
||||||
QString HeadlineProperty;
|
QString HeadlineProperty;
|
||||||
|
|
||||||
//! The header data for the value column
|
//! The header data for the value column
|
||||||
QString HeadlineValue;
|
QString HeadlineValue;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyModelPrivate()
|
VPropertyModelPrivate()
|
||||||
: Properties(nullptr)
|
: Properties(nullptr)
|
||||||
{
|
{
|
||||||
//: The text that appears in the first column header
|
//: The text that appears in the first column header
|
||||||
HeadlineProperty = QObject::tr("Property");
|
HeadlineProperty = QObject::tr("Property");
|
||||||
|
|
||||||
//: The text that appears in the second column header
|
//: The text that appears in the second column header
|
||||||
HeadlineValue = QObject::tr("Value");
|
HeadlineValue = QObject::tr("Value");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYMODEL_P_H
|
#endif // VPROPERTYMODEL_P_H
|
||||||
|
|
|
@ -1,231 +1,231 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyset.cpp
|
** @file vpropertyset.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertyset.h"
|
#include "vpropertyset.h"
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
#include "vpropertyset_p.h"
|
#include "vpropertyset_p.h"
|
||||||
|
|
||||||
|
|
||||||
VPropertySet::VPropertySet()
|
VPropertySet::VPropertySet()
|
||||||
: d_ptr(new VPropertySetPrivate())
|
: d_ptr(new VPropertySetPrivate())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VPropertySet::~VPropertySet()
|
VPropertySet::~VPropertySet()
|
||||||
{
|
{
|
||||||
// Delete all the properties
|
// Delete all the properties
|
||||||
clear(true);
|
clear(true);
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VPropertySet::addProperty(VProperty *property, const QString &id, const QString &parentid)
|
bool VPropertySet::addProperty(VProperty *property, const QString &id, const QString &parentid)
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty *parent_property)
|
bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty *parent_property)
|
||||||
{
|
{
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty *VPropertySet::getProperty(const QString &id) const
|
VProperty *VPropertySet::getProperty(const QString &id) const
|
||||||
{
|
{
|
||||||
return d_ptr->Properties.value(id, NULL);
|
return d_ptr->Properties.value(id, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty *VPropertySet::takeProperty(const QString &id)
|
VProperty *VPropertySet::takeProperty(const QString &id)
|
||||||
{
|
{
|
||||||
VProperty* tmpProp = getProperty(id);
|
VProperty* tmpProp = getProperty(id);
|
||||||
removeProperty(tmpProp, false);
|
removeProperty(tmpProp, false);
|
||||||
|
|
||||||
// Return the property
|
// Return the property
|
||||||
return tmpProp;
|
return tmpProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertySet::removeProperty(const QString &id)
|
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)
|
||||||
{
|
{
|
||||||
// Remove all the children
|
// Remove all the children
|
||||||
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
|
||||||
{
|
{
|
||||||
return d_ptr->Properties.count();
|
return d_ptr->Properties.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VPropertySet::getPropertyID(const VProperty *prop, bool look_for_parent_id) const
|
QString VPropertySet::getPropertyID(const VProperty *prop, bool look_for_parent_id) const
|
||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpResult;
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<QString, VProperty *> &VPropertySet::getPropertiesMap() const
|
const QMap<QString, VProperty *> &VPropertySet::getPropertiesMap() const
|
||||||
{
|
{
|
||||||
return d_ptr->Properties;
|
return d_ptr->Properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<VProperty *> &VPropertySet::getRootProperties() const
|
const QList<VProperty *> &VPropertySet::getRootProperties() const
|
||||||
{
|
{
|
||||||
return d_ptr->RootProperties;
|
return d_ptr->RootProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
VProperty *VPropertySet::getRootProperty(int row) const
|
VProperty *VPropertySet::getRootProperty(int row) const
|
||||||
{
|
{
|
||||||
return d_ptr->RootProperties.value(row, NULL);
|
return d_ptr->RootProperties.value(row, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VPropertySet::getRootPropertyCount() const
|
int VPropertySet::getRootPropertyCount() const
|
||||||
{
|
{
|
||||||
return d_ptr->RootProperties.count();
|
return d_ptr->RootProperties.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertySet* VPropertySet::clone() const
|
VPropertySet* VPropertySet::clone() const
|
||||||
{
|
{
|
||||||
VPropertySet* tmpResult = new VPropertySet();
|
VPropertySet* tmpResult = new VPropertySet();
|
||||||
|
|
||||||
foreach(VProperty* tmpProperty, d_ptr->RootProperties)
|
foreach(VProperty* tmpProperty, d_ptr->RootProperties)
|
||||||
cloneProperty(tmpProperty, NULL, tmpResult);
|
cloneProperty(tmpProperty, NULL, tmpResult);
|
||||||
|
|
||||||
|
|
||||||
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)
|
VProperty* tmpNewProperty = property_to_clone->clone(false); // We want to clone the children ourselves (because of the IDs)
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
// Remove all the children
|
// Remove all the children
|
||||||
foreach(VProperty* tmpChild, prop->getChildren())
|
foreach(VProperty* tmpChild, prop->getChildren())
|
||||||
removeProperty(tmpChild);
|
removeProperty(tmpChild);
|
||||||
|
|
||||||
|
|
||||||
QList<QString> tmpKeys = d_ptr->Properties.keys(prop);
|
QList<QString> tmpKeys = d_ptr->Properties.keys(prop);
|
||||||
foreach(const QString& tmpID, tmpKeys)
|
foreach(const QString& tmpID, tmpKeys)
|
||||||
d_ptr->Properties.remove(tmpID);
|
d_ptr->Properties.remove(tmpID);
|
||||||
|
|
||||||
// Remove from list
|
// Remove from list
|
||||||
d_ptr->RootProperties.removeAll(prop);
|
d_ptr->RootProperties.removeAll(prop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,131 +1,131 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyset.h
|
** @file vpropertyset.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYSET_H
|
#ifndef VPROPERTYSET_H
|
||||||
#define VPROPERTYSET_H
|
#define VPROPERTYSET_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
class VPropertySetPrivate;
|
class VPropertySetPrivate;
|
||||||
|
|
||||||
// todo: better description
|
// todo: better description
|
||||||
//! \brief VPropertySet is a simple class for managing a set of properties.
|
//! \brief VPropertySet is a simple class for managing a set of properties.
|
||||||
//! If you don't need all the Model-functionality, chose this class
|
//! If you don't need all the Model-functionality, chose this class
|
||||||
//! over VPropertyModel.
|
//! over VPropertyModel.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
//!
|
//!
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertySet
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertySet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Default constructor, creating an empty property set
|
//! Default constructor, creating an empty property set
|
||||||
explicit VPropertySet();
|
explicit VPropertySet();
|
||||||
|
|
||||||
//! 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. 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.
|
//! \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);
|
||||||
|
|
||||||
//! Checks whether a property belongs to this set and returns the result
|
//! Checks whether a property belongs to this set and returns the result
|
||||||
//! \param property The property to check for
|
//! \param property The property to check for
|
||||||
//! \return True, if the property is part of this set, false otherwise
|
//! \return True, if the property is part of this set, false otherwise
|
||||||
virtual bool hasProperty(VProperty* property) const;
|
virtual bool hasProperty(VProperty* property) const;
|
||||||
|
|
||||||
//! Gets a property by it's ID
|
//! Gets a property by it's ID
|
||||||
virtual VProperty* getProperty(const QString& id) const;
|
virtual VProperty* getProperty(const QString& id) const;
|
||||||
|
|
||||||
//! Removes a property from the set and returns it
|
//! Removes a property from the set and returns it
|
||||||
virtual VProperty* takeProperty(const QString& id);
|
virtual VProperty* takeProperty(const QString& id);
|
||||||
|
|
||||||
//! Removes a property from the set and deletes it
|
//! Removes a property from the set and deletes it
|
||||||
virtual void removeProperty(const QString& id);
|
virtual void removeProperty(const QString& id);
|
||||||
|
|
||||||
//! Removes a property from the set and deletes it optionally
|
//! Removes a property from the set and deletes it optionally
|
||||||
virtual void removeProperty(VProperty* prop, bool delete_property = true);
|
virtual void removeProperty(VProperty* prop, bool delete_property = true);
|
||||||
|
|
||||||
//! Returns the number of properties with in ID that are directly accessable by getProperty()
|
//! Returns the number of properties with in ID that are directly accessable by getProperty()
|
||||||
virtual int count() const;
|
virtual int count() const;
|
||||||
|
|
||||||
//! Clears the set and (optionally) deletes all properties
|
//! Clears the set and (optionally) deletes all properties
|
||||||
//! \param delete_properties Set this to false, if you don't want the properties to get deleted.
|
//! \param delete_properties Set this to false, if you don't want the properties to get deleted.
|
||||||
virtual void clear(bool delete_properties = true);
|
virtual void clear(bool delete_properties = true);
|
||||||
|
|
||||||
//! Returns the ID of the property within the set
|
//! Returns the ID of the property within the set
|
||||||
//! The concept of property IDs is, that the object that manages the properties
|
//! The concept of property IDs is, that the object that manages the properties
|
||||||
//! and not the properties themselves handle the IDs.
|
//! and not the properties themselves handle the IDs.
|
||||||
//! \param prop The property of which to get the ID.
|
//! \param prop The property of which to get the ID.
|
||||||
//! \param look_for_parent_id If this is TRUE and the property has no ID, all the parent properties are checked.
|
//! \param look_for_parent_id If this is TRUE and the property has no ID, all the parent properties are checked.
|
||||||
//! \return Returns the ID under which the property is stored within the set
|
//! \return Returns the ID under which the property is stored within the set
|
||||||
virtual QString getPropertyID(const VProperty* prop, bool look_for_parent_id = true) const;
|
virtual QString getPropertyID(const VProperty* prop, bool look_for_parent_id = true) const;
|
||||||
|
|
||||||
//! Returns a const reference to the map of properties
|
//! Returns a const reference to the map of properties
|
||||||
const QMap<QString, VProperty*>& getPropertiesMap() const;
|
const QMap<QString, VProperty*>& getPropertiesMap() const;
|
||||||
|
|
||||||
//! Returns a const reference to the list of root properties
|
//! Returns a const reference to the list of root properties
|
||||||
const QList<VProperty*>& getRootProperties() const;
|
const QList<VProperty*>& getRootProperties() const;
|
||||||
|
|
||||||
//! Returns the root property in a certain row
|
//! Returns the root property in a certain row
|
||||||
//! \param row The root row in which to look for the root property
|
//! \param row The root row in which to look for the root property
|
||||||
VProperty* getRootProperty(int row) const;
|
VProperty* getRootProperty(int row) const;
|
||||||
|
|
||||||
//! Returns the number of independent properties
|
//! Returns the number of independent properties
|
||||||
int getRootPropertyCount() const;
|
int getRootPropertyCount() const;
|
||||||
|
|
||||||
//! Clones the property set
|
//! Clones the property set
|
||||||
VPropertySet* clone() const;
|
VPropertySet* clone() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Checks whether a property belongs to this set and returns the result
|
//! Checks whether a property belongs to this set and returns the result
|
||||||
//! \param property The property to check for
|
//! \param property The property to check for
|
||||||
//! \param parent The parent property from which to start checking all the children
|
//! \param parent The parent property from which to start checking all the children
|
||||||
//! \return True, if the property is part of this set, false otherwise
|
//! \return True, if the property is part of this set, false otherwise
|
||||||
virtual bool hasProperty(VProperty* property, VProperty* parent) const;
|
virtual bool hasProperty(VProperty* property, VProperty* parent) const;
|
||||||
|
|
||||||
//! Clones a property into another property set
|
//! Clones a property into another property set
|
||||||
void cloneProperty(VProperty* property_to_clone, VProperty* parent_property, VPropertySet* output_set) const;
|
void cloneProperty(VProperty* property_to_clone, VProperty* parent_property, VPropertySet* output_set) const;
|
||||||
|
|
||||||
//! Recursivly removes a property's child properties from the set, but not from the parent
|
//! Recursivly removes a property's child properties from the set, but not from the parent
|
||||||
virtual void removePropertyFromSet(VProperty* prop);
|
virtual void removePropertyFromSet(VProperty* prop);
|
||||||
|
|
||||||
//! The data
|
//! The data
|
||||||
VPropertySetPrivate* d_ptr;
|
VPropertySetPrivate* d_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYMODEL_H
|
#endif // VPROPERTYMODEL_H
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertyset_p.h
|
** @file vpropertyset_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYSET_P_H
|
#ifndef VPROPERTYSET_P_H
|
||||||
#define VPROPERTYSET_P_H
|
#define VPROPERTYSET_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertySetPrivate()
|
VPropertySetPrivate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYMODEL_P_H
|
#endif // VPROPERTYMODEL_P_H
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertytreeview.cpp
|
** @file vpropertytreeview.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpropertytreeview.h"
|
#include "vpropertytreeview.h"
|
||||||
|
|
||||||
#include "vpropertydelegate.h"
|
#include "vpropertydelegate.h"
|
||||||
#include "vpropertymodel.h"
|
#include "vpropertymodel.h"
|
||||||
|
|
||||||
#include "vpropertytreeview_p.h"
|
#include "vpropertytreeview_p.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VPropertyTreeView::VPropertyTreeView(QWidget *parent)
|
VPropertyTreeView::VPropertyTreeView(QWidget *parent)
|
||||||
: QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate())
|
: QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate())
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
VPropertyTreeView::VPropertyTreeView(VPropertyModel *model, QWidget *parent)
|
VPropertyTreeView::VPropertyTreeView(VPropertyModel *model, QWidget *parent)
|
||||||
: QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate())
|
: QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate())
|
||||||
{
|
{
|
||||||
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()
|
||||||
{
|
{
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VPropertyTreeView::setRowHeight(int height, bool add_to_standard)
|
void VPropertyTreeView::setRowHeight(int height, bool add_to_standard)
|
||||||
{
|
{
|
||||||
d_ptr->PropertyDelegate->setRowHeight(height, add_to_standard);
|
d_ptr->PropertyDelegate->setRowHeight(height, add_to_standard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPropertyTreeView::init()
|
void VPropertyTreeView::init()
|
||||||
{
|
{
|
||||||
setAlternatingRowColors(true);
|
setAlternatingRowColors(true);
|
||||||
setUniformRowHeights(true);
|
setUniformRowHeights(true);
|
||||||
d_ptr->PropertyDelegate = new VPropertyDelegate(this);
|
d_ptr->PropertyDelegate = new VPropertyDelegate(this);
|
||||||
setItemDelegate(d_ptr->PropertyDelegate);
|
setItemDelegate(d_ptr->PropertyDelegate);
|
||||||
|
|
||||||
setSelectionMode(QTreeView::SingleSelection);
|
setSelectionMode(QTreeView::SingleSelection);
|
||||||
setSelectionBehavior(QTreeView::SelectRows);
|
setSelectionBehavior(QTreeView::SelectRows);
|
||||||
setRootIsDecorated(true);
|
setRootIsDecorated(true);
|
||||||
|
|
||||||
setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
|
setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertytreeview.h
|
** @file vpropertytreeview.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYTREEVIEW_H
|
#ifndef VPROPERTYTREEVIEW_H
|
||||||
#define VPROPERTYTREEVIEW_H
|
#define VPROPERTYTREEVIEW_H
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPropertyTreeViewPrivate;
|
class VPropertyTreeViewPrivate;
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate;
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate;
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel;
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel;
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyTreeView : public QTreeView
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyTreeView : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
explicit VPropertyTreeView(QWidget *parent = 0);
|
explicit VPropertyTreeView(QWidget *parent = 0);
|
||||||
|
|
||||||
//! The destructor, taking a model and setting it to the tree view
|
//! The destructor, taking a model and setting it to the tree view
|
||||||
//! \param The model to set as model for this tree view
|
//! \param The model to set as model for this tree view
|
||||||
VPropertyTreeView(VPropertyModel* model, QWidget *parent = 0);
|
VPropertyTreeView(VPropertyModel* model, QWidget *parent = 0);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VPropertyTreeView();
|
virtual ~VPropertyTreeView();
|
||||||
|
|
||||||
//! Sets the height for each row. Set this to 0 in order to let the standard delegate decide
|
//! Sets the height for each row. Set this to 0 in order to let the standard delegate decide
|
||||||
void setRowHeight(int height = 0, bool add_to_standard = false);
|
void setRowHeight(int height = 0, bool add_to_standard = false);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! This method is called by the constructors to initialize the view
|
//! This method is called by the constructors to initialize the view
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
//! protected constructor
|
//! protected constructor
|
||||||
explicit VPropertyTreeView(VPropertyTreeViewPrivate* d, bool init_, QWidget *parent = 0);
|
explicit VPropertyTreeView(VPropertyTreeViewPrivate* d, bool init_, QWidget *parent = 0);
|
||||||
|
|
||||||
//! The protected data
|
//! The protected data
|
||||||
VPropertyTreeViewPrivate* d_ptr;
|
VPropertyTreeViewPrivate* d_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYTREEVIEWEEVIEW_H
|
#endif // VPROPERTYTREEVIEWEEVIEW_H
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vpropertytreeview_p.h
|
** @file vpropertytreeview_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VPROPERTYTREEVIEW_P_H
|
#ifndef VPROPERTYTREEVIEW_P_H
|
||||||
#define VPROPERTYTREEVIEW_P_H
|
#define VPROPERTYTREEVIEW_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VPropertyDelegate;
|
class VPropertyDelegate;
|
||||||
|
|
||||||
class VPropertyTreeViewPrivate
|
class VPropertyTreeViewPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Property Delegate
|
//! Property Delegate
|
||||||
VPropertyDelegate* PropertyDelegate;
|
VPropertyDelegate* PropertyDelegate;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyTreeViewPrivate(VPropertyDelegate* delegate)
|
VPropertyTreeViewPrivate(VPropertyDelegate* delegate)
|
||||||
: PropertyDelegate(delegate) {}
|
: PropertyDelegate(delegate) {}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VPropertyTreeViewPrivate()
|
VPropertyTreeViewPrivate()
|
||||||
: PropertyDelegate(nullptr) {}
|
: PropertyDelegate(nullptr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VPROPERTYTREEVIEW_P_H
|
#endif // VPROPERTYTREEVIEW_P_H
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vserializedproperty.cpp
|
** @file vserializedproperty.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vserializedproperty.h"
|
#include "vserializedproperty.h"
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VSerializedProperty::VSerializedProperty()
|
VSerializedProperty::VSerializedProperty()
|
||||||
: ID(), Type(), Value()
|
: ID(), Type(), Value()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Creates a new VSerializedProperty from an existing property
|
/*! Creates a new VSerializedProperty from an existing property
|
||||||
|
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VSerializedProperty::VSerializedProperty(const VProperty *property, const QString &id, const VPropertySet *set)
|
VSerializedProperty::VSerializedProperty(const VProperty *property, const QString &id, const VPropertySet *set)
|
||||||
: ID(id), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant())
|
: ID(id), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant())
|
||||||
{
|
{
|
||||||
initChildren(property, set);
|
initChildren(property, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
VSerializedProperty::VSerializedProperty(const QString &id, const QString &type, const QVariant &value)
|
VSerializedProperty::VSerializedProperty(const QString &id, const QString &type, const QVariant &value)
|
||||||
: ID(id), Type(type), Value(value)
|
: ID(id), Type(type), Value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VPE::VSerializedProperty::~VSerializedProperty()
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vserializedproperty.h
|
** @file vserializedproperty.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VSERIALIZEDPROPERTY_H
|
#ifndef VSERIALIZEDPROPERTY_H
|
||||||
#define VSERIALIZEDPROPERTY_H
|
#define VSERIALIZEDPROPERTY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
#include "vpropertyset.h"
|
#include "vpropertyset.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VSerializedProperty();
|
VSerializedProperty();
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VSerializedProperty(const VProperty* property, const VPropertySet* set);
|
VSerializedProperty(const VProperty* property, const VPropertySet* set);
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VSerializedProperty(const VProperty* property, const QString& id, const VPropertySet* set);
|
VSerializedProperty(const VProperty* property, const QString& id, const VPropertySet* set);
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VSerializedProperty(const QString& id, const QString& type, const QVariant& value);
|
VSerializedProperty(const QString& id, const QString& type, const QVariant& value);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VSerializedProperty();
|
~VSerializedProperty();
|
||||||
|
|
||||||
//! The property type
|
//! The property type
|
||||||
QString ID;
|
QString ID;
|
||||||
|
|
||||||
//! The property type
|
//! The property type
|
||||||
QString Type;
|
QString Type;
|
||||||
|
|
||||||
//! The serialized value of the property
|
//! The serialized value of the property
|
||||||
QVariant Value;
|
QVariant Value;
|
||||||
|
|
||||||
//! List of child properties
|
//! List of child properties
|
||||||
QList<VSerializedProperty> Children;
|
QList<VSerializedProperty> Children;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initChildren(const VProperty* property, const VPropertySet* set);
|
void initChildren(const VProperty* property, const VPropertySet* set);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VSERIALIZEDPROPERTY_H
|
#endif // VSERIALIZEDPROPERTY_H
|
||||||
|
|
|
@ -1,86 +1,86 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vstandardpropertyfactory.cpp
|
** @file vstandardpropertyfactory.cpp
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vstandardpropertyfactory.h"
|
#include "vstandardpropertyfactory.h"
|
||||||
|
|
||||||
#include "vpropertyfactorymanager.h"
|
#include "vpropertyfactorymanager.h"
|
||||||
|
|
||||||
// Supported Properties
|
// Supported Properties
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
#include "plugins/vboolproperty.h"
|
#include "plugins/vboolproperty.h"
|
||||||
#include "plugins/vcolorproperty.h"
|
#include "plugins/vcolorproperty.h"
|
||||||
#include "plugins/vemptyproperty.h"
|
#include "plugins/vemptyproperty.h"
|
||||||
#include "plugins/venumproperty.h"
|
#include "plugins/venumproperty.h"
|
||||||
#include "plugins/vfileproperty.h"
|
#include "plugins/vfileproperty.h"
|
||||||
#include "plugins/vnumberproperty.h"
|
#include "plugins/vnumberproperty.h"
|
||||||
#include "plugins/vshortcutproperty.h"
|
#include "plugins/vshortcutproperty.h"
|
||||||
#include "plugins/Vector3d/vvector3dproperty.h"
|
#include "plugins/Vector3d/vvector3dproperty.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace VPE;
|
using namespace VPE;
|
||||||
|
|
||||||
VStandardPropertyFactory::VStandardPropertyFactory()
|
VStandardPropertyFactory::VStandardPropertyFactory()
|
||||||
: VAbstractPropertyFactory()
|
: VAbstractPropertyFactory()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
manager->registerFactory("empty", this);
|
manager->registerFactory("empty", this);
|
||||||
manager->registerFactory("enum", this);
|
manager->registerFactory("enum", this);
|
||||||
manager->registerFactory("file", this);
|
manager->registerFactory("file", this);
|
||||||
manager->registerFactory("integer", this);
|
manager->registerFactory("integer", this);
|
||||||
manager->registerFactory("double", this);
|
manager->registerFactory("double", this);
|
||||||
manager->registerFactory("shortcut", this);
|
manager->registerFactory("shortcut", this);
|
||||||
manager->registerFactory("vector3d", this);
|
manager->registerFactory("vector3d", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vstandardpropertyfactory.h
|
** @file vstandardpropertyfactory.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VASTANDARDPROPERTYFACTORY_H
|
#ifndef VASTANDARDPROPERTYFACTORY_H
|
||||||
#define VASTANDARDPROPERTYFACTORY_H
|
#define VASTANDARDPROPERTYFACTORY_H
|
||||||
|
|
||||||
#include "vpropertyexplorer_global.h"
|
#include "vpropertyexplorer_global.h"
|
||||||
#include "vabstractpropertyfactory.h"
|
#include "vabstractpropertyfactory.h"
|
||||||
|
|
||||||
namespace VPE {
|
namespace VPE {
|
||||||
|
|
||||||
class VProperty;
|
class VProperty;
|
||||||
|
|
||||||
class VPropertyFactoryManager;
|
class VPropertyFactoryManager;
|
||||||
|
|
||||||
//! The standard property factory is able to create all the properties that are included in VPropertyExplorer
|
//! The standard property factory is able to create all the properties that are included in VPropertyExplorer
|
||||||
//! by default.
|
//! by default.
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT VStandardPropertyFactory : public VAbstractPropertyFactory
|
class VPROPERTYEXPLORERSHARED_EXPORT VStandardPropertyFactory : public VAbstractPropertyFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VStandardPropertyFactory();
|
VStandardPropertyFactory();
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
//! \param manager Registers this factory at the manager for all it's types
|
//! \param manager Registers this factory at the manager for all it's types
|
||||||
VStandardPropertyFactory(VPropertyFactoryManager* manager);
|
VStandardPropertyFactory(VPropertyFactoryManager* manager);
|
||||||
|
|
||||||
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
||||||
//! \param type The type of the property as string
|
//! \param type The type of the property as string
|
||||||
//! \return Returns the created property or NULL if it couldn't be be created
|
//! \return Returns the created property or NULL if it couldn't be be created
|
||||||
virtual VProperty* createProperty(const QString& type, const QString &name);
|
virtual VProperty* createProperty(const QString& type, const QString &name);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VASTANDARDPROPERTYFACTORY_H
|
#endif // VASTANDARDPROPERTYFACTORY_H
|
||||||
|
|
|
@ -1,55 +1,55 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vwidgetproperty_p.h
|
** @file vwidgetproperty_p.h
|
||||||
** @author hedgeware <internal(at)hedgeware.net>
|
** @author hedgeware <internal(at)hedgeware.net>
|
||||||
** @date
|
** @date
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** All rights reserved. This program and the accompanying materials
|
** All rights reserved. This program and the accompanying materials
|
||||||
** are made available under the terms of the GNU Lesser General Public License
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** http://www.gnu.org/licenses/lgpl-2.1.html
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This library is distributed in the hope that it will be useful,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VWIDGETPROPERTY_P_H
|
#ifndef VWIDGETPROPERTY_P_H
|
||||||
#define VWIDGETPROPERTY_P_H
|
#define VWIDGETPROPERTY_P_H
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#include "vproperty_p.h"
|
#include "vproperty_p.h"
|
||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
//! Constructor passing name and type
|
//! Constructor passing name and type
|
||||||
VWidgetPropertyPrivate(const QString& name, QVariant::Type type, QWidget* widget = nullptr)
|
VWidgetPropertyPrivate(const QString& name, QVariant::Type type, QWidget* widget = nullptr)
|
||||||
: VPropertyPrivate(name, type), Widget(widget) {}
|
: VPropertyPrivate(name, type), Widget(widget) {}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VWidgetPropertyPrivate()
|
VWidgetPropertyPrivate()
|
||||||
: VPropertyPrivate(), Widget(nullptr) {}
|
: VPropertyPrivate(), Widget(nullptr) {}
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~VWidgetPropertyPrivate() {
|
~VWidgetPropertyPrivate() {
|
||||||
if(Widget)
|
if(Widget)
|
||||||
Widget->deleteLater();
|
Widget->deleteLater();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VWIDGETPROPERTY_P_H
|
#endif // VWIDGETPROPERTY_P_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user