New property for point type.
--HG-- branch : feature
This commit is contained in:
parent
0d0bcb9005
commit
c48c627682
|
@ -34,6 +34,7 @@
|
||||||
#include "visualization/vcontrolpointspline.h"
|
#include "visualization/vcontrolpointspline.h"
|
||||||
#include "../libs/vpropertyexplorer/plugins/vnumberproperty.h"
|
#include "../libs/vpropertyexplorer/plugins/vnumberproperty.h"
|
||||||
#include "../libs/vpropertyexplorer/plugins/vstringproperty.h"
|
#include "../libs/vpropertyexplorer/plugins/vstringproperty.h"
|
||||||
|
#include "../libs/vpropertyexplorer/plugins/vpointfproperty.h"
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -88,9 +89,17 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
||||||
{
|
{
|
||||||
if (!propertyToId.contains(property))
|
VProperty *prop = property;
|
||||||
|
if (!propertyToId.contains(prop))
|
||||||
{
|
{
|
||||||
return;
|
if (!propertyToId.contains(prop->getParent()))// Maybe we know parent
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prop = prop->getParent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentItem)
|
if (!currentItem)
|
||||||
|
@ -98,9 +107,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant variant = property->data(VProperty::DPC_Data);
|
QVariant variant = prop->data(VProperty::DPC_Data);
|
||||||
|
|
||||||
QString id = propertyToId[property];
|
QString id = propertyToId[prop];
|
||||||
switch (currentItem->type())
|
switch (currentItem->type())
|
||||||
{
|
{
|
||||||
case VToolSinglePoint::Type:
|
case VToolSinglePoint::Type:
|
||||||
|
@ -125,13 +134,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id == QLatin1String("posX"))
|
else if (id == QLatin1String("position"))
|
||||||
{
|
{
|
||||||
currentItem->setX(variant.toDouble());
|
currentItem->setPos(variant.toPointF());
|
||||||
}
|
|
||||||
else if (id == QLatin1String("posY"))
|
|
||||||
{
|
|
||||||
currentItem->setY(variant.toDouble());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +166,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
||||||
{
|
{
|
||||||
VToolSinglePoint *i = qgraphicsitem_cast<VToolSinglePoint *>(currentItem);
|
VToolSinglePoint *i = qgraphicsitem_cast<VToolSinglePoint *>(currentItem);
|
||||||
idToProperty[QLatin1String("name")]->setValue(i->name());
|
idToProperty[QLatin1String("name")]->setValue(i->name());
|
||||||
idToProperty[QLatin1String("posX")]->setValue(i->x());
|
idToProperty[QLatin1String("position")]->setValue(i->pos());
|
||||||
idToProperty[QLatin1String("posY")]->setValue(i->y());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VGraphicsSimpleTextItem::Type:
|
case VGraphicsSimpleTextItem::Type:
|
||||||
|
@ -181,7 +185,7 @@ void VToolOptionsPropertyBrowser::AddProperty(VProperty *property, const QString
|
||||||
{
|
{
|
||||||
propertyToId[property] = id;
|
propertyToId[property] = id;
|
||||||
idToProperty[id] = property;
|
idToProperty[id] = property;
|
||||||
PropertyModel->addProperty(property, QLatin1String("name"));
|
PropertyModel->addProperty(property, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -199,18 +203,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
||||||
itemName->setValue(i->name());
|
itemName->setValue(i->name());
|
||||||
AddProperty(itemName, QLatin1String("name"));
|
AddProperty(itemName, QLatin1String("name"));
|
||||||
|
|
||||||
VDoubleProperty* positionX = new VDoubleProperty(tr("Position X"));
|
VPointFProperty* itemPosition = new VPointFProperty(tr("Position"));
|
||||||
positionX->setValue(i->x());
|
itemPosition->setValue(i->pos());
|
||||||
AddProperty(positionX, QLatin1String("posX"));
|
AddProperty(itemPosition, QLatin1String("position"));
|
||||||
|
|
||||||
VDoubleProperty* positionY = new VDoubleProperty(tr("Position Y"));
|
|
||||||
positionY->setValue(i->y());
|
|
||||||
AddProperty(positionY, QLatin1String("posY"));
|
|
||||||
|
|
||||||
// QtVariantProperty *position = variantManager->addProperty(QVariant::PointF, tr("Position"));
|
|
||||||
// position->setValue(i->pos());
|
|
||||||
// AddProperty(position, QLatin1String("position"));
|
|
||||||
// mainGroup->addSubProperty(position);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VGraphicsSimpleTextItem::Type:
|
case VGraphicsSimpleTextItem::Type:
|
||||||
|
|
|
@ -31,8 +31,7 @@ public:
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QPE::Vector3D) // todo
|
Q_DECLARE_METATYPE(QPE::Vector3D) // todo
|
||||||
|
|
||||||
|
*/
|
||||||
namespace QPE{*/
|
|
||||||
|
|
||||||
class VPROPERTYEXPLORERSHARED_EXPORT QVector3DProperty : public VProperty
|
class VPROPERTYEXPLORERSHARED_EXPORT QVector3DProperty : public VProperty
|
||||||
{
|
{
|
||||||
|
|
129
src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp
Normal file
129
src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vpointfproperty.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 27 8, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** All rights reserved. This program and the accompanying materials
|
||||||
|
** 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
|
||||||
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
**
|
||||||
|
** This library is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
** Lesser General Public License for more details.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "vpointfproperty.h"
|
||||||
|
|
||||||
|
using namespace VPE;
|
||||||
|
|
||||||
|
#include "vproperty_p.h"
|
||||||
|
#include "vnumberproperty.h"
|
||||||
|
#include <QPointF>
|
||||||
|
|
||||||
|
VPE::VPointFProperty::VPointFProperty(const QString &name)
|
||||||
|
: VProperty(name, QVariant::PointF)
|
||||||
|
{
|
||||||
|
d_ptr->VariantValue.setValue(0);
|
||||||
|
d_ptr->VariantValue.convert(QVariant::PointF);
|
||||||
|
|
||||||
|
VDoubleProperty* tmpX = new VDoubleProperty("X");
|
||||||
|
addChild(tmpX);
|
||||||
|
tmpX->setUpdateBehaviour(true, false);
|
||||||
|
|
||||||
|
VDoubleProperty* tmpY = new VDoubleProperty("Y");
|
||||||
|
addChild(tmpY);
|
||||||
|
tmpY->setUpdateBehaviour(true, false);
|
||||||
|
|
||||||
|
setValue(QPointF());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant VPointFProperty::data(int column, int role) const
|
||||||
|
{
|
||||||
|
if(column == DPC_Data && Qt::DisplayRole == role)
|
||||||
|
{
|
||||||
|
return getPointF();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return VProperty::data(column, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags VPointFProperty::flags(int column) const
|
||||||
|
{
|
||||||
|
if(column == DPC_Name || column == DPC_Data)
|
||||||
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
else
|
||||||
|
return Qt::NoItemFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VPointFProperty::getPointF() const
|
||||||
|
{
|
||||||
|
QPointF tmpValue;
|
||||||
|
|
||||||
|
if(d_ptr->Children.count() < 2)
|
||||||
|
return tmpValue;
|
||||||
|
|
||||||
|
tmpValue.setX(d_ptr->Children.at(0)->getValue().toDouble());
|
||||||
|
tmpValue.setY(d_ptr->Children.at(1)->getValue().toDouble());
|
||||||
|
|
||||||
|
return tmpValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VPointFProperty::setPointF(const QPointF &point)
|
||||||
|
{
|
||||||
|
setPointF(point.x(), point.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VPointFProperty::setPointF(qreal x, qreal y)
|
||||||
|
{
|
||||||
|
if(d_ptr->Children.count() < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QVariant tmpX(x);
|
||||||
|
tmpX.convert(QVariant::Double);
|
||||||
|
|
||||||
|
QVariant tmpY(y);
|
||||||
|
tmpY.convert(QVariant::Double);
|
||||||
|
|
||||||
|
d_ptr->Children.at(0)->setValue(tmpX);
|
||||||
|
d_ptr->Children.at(1)->setValue(tmpY);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VPointFProperty::type() const
|
||||||
|
{
|
||||||
|
return "pointF";
|
||||||
|
}
|
||||||
|
|
||||||
|
VProperty *VPointFProperty::clone(bool include_children, VProperty *container) const
|
||||||
|
{
|
||||||
|
if(!container) {
|
||||||
|
container = new VPointFProperty(getName());
|
||||||
|
|
||||||
|
if(!include_children) {
|
||||||
|
QList<VProperty*> tmpChildren = container->getChildren();
|
||||||
|
foreach(VProperty* tmpChild, tmpChildren) {
|
||||||
|
container->removeChild(tmpChild);
|
||||||
|
delete tmpChild;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return VProperty::clone(false, container); // Child
|
||||||
|
}
|
||||||
|
|
||||||
|
void VPointFProperty::setValue(const QVariant &value)
|
||||||
|
{
|
||||||
|
QPointF tmpPoint = value.toPointF();
|
||||||
|
setPointF(tmpPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant VPointFProperty::getValue() const
|
||||||
|
{
|
||||||
|
QPointF tmpValue = getPointF();
|
||||||
|
return QString("%1,%2").arg(QString::number(tmpValue.x()), QString::number(tmpValue.y()));
|
||||||
|
}
|
71
src/libs/vpropertyexplorer/plugins/vpointfproperty.h
Normal file
71
src/libs/vpropertyexplorer/plugins/vpointfproperty.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vpointfproperty.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 27 8, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** All rights reserved. This program and the accompanying materials
|
||||||
|
** 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
|
||||||
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
**
|
||||||
|
** This library is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
** Lesser General Public License for more details.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VPOINTFPROPERTY_H
|
||||||
|
#define VPOINTFPROPERTY_H
|
||||||
|
|
||||||
|
#include "vpropertyexplorer_global.h"
|
||||||
|
|
||||||
|
#include "vproperty.h"
|
||||||
|
|
||||||
|
namespace VPE{
|
||||||
|
|
||||||
|
class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VPointFProperty(const QString& name);
|
||||||
|
|
||||||
|
virtual ~VPointFProperty() {}
|
||||||
|
|
||||||
|
//! Get the data how it should be displayed
|
||||||
|
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
//! Returns item flags
|
||||||
|
Qt::ItemFlags flags(int column = DPC_Name) const;
|
||||||
|
|
||||||
|
//! Returns the QPointF
|
||||||
|
virtual QPointF getPointF() const;
|
||||||
|
|
||||||
|
//! Sets the QPointF
|
||||||
|
virtual void setPointF(const QPointF& point);
|
||||||
|
|
||||||
|
//! Sets the QPointF
|
||||||
|
virtual void setPointF(qreal x, qreal y);
|
||||||
|
|
||||||
|
//! Returns a string containing the type of the property
|
||||||
|
virtual QString type() const;
|
||||||
|
|
||||||
|
//! Clones this property
|
||||||
|
//! \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.
|
||||||
|
//! \return Returns the newly created property (or container, if it was not NULL)
|
||||||
|
virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const;
|
||||||
|
|
||||||
|
//! Sets the value of the property
|
||||||
|
virtual void setValue(const QVariant& value);
|
||||||
|
|
||||||
|
//! Returns the value of the property as a QVariant
|
||||||
|
virtual QVariant getValue() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // VPOINTFPROPERTY_H
|
|
@ -6,18 +6,15 @@
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** This program is free software: you can redistribute it and/or modify
|
** All rights reserved. This program and the accompanying materials
|
||||||
** it under the terms of the GNU General Public License as published by
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** (at your option) any later version.
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This program 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
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** GNU General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,15 @@
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
** This program is free software: you can redistribute it and/or modify
|
** All rights reserved. This program and the accompanying materials
|
||||||
** it under the terms of the GNU General Public License as published by
|
** are made available under the terms of the GNU Lesser General Public License
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
||||||
** (at your option) any later version.
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
**
|
**
|
||||||
** This program 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
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** GNU General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,8 @@ SOURCES += \
|
||||||
plugins/vnumberproperty.cpp \
|
plugins/vnumberproperty.cpp \
|
||||||
plugins/Vector3d/vvector3dproperty.cpp \
|
plugins/Vector3d/vvector3dproperty.cpp \
|
||||||
vstandardpropertyfactory.cpp \
|
vstandardpropertyfactory.cpp \
|
||||||
plugins/vstringproperty.cpp
|
plugins/vstringproperty.cpp \
|
||||||
|
plugins/vpointfproperty.cpp
|
||||||
|
|
||||||
HEADERS +=\
|
HEADERS +=\
|
||||||
vpropertyexplorer_global.h \
|
vpropertyexplorer_global.h \
|
||||||
|
@ -83,7 +84,8 @@ HEADERS +=\
|
||||||
plugins/Vector3d/vvector3dproperty.h \
|
plugins/Vector3d/vvector3dproperty.h \
|
||||||
vpropertyfactorymanager.h \
|
vpropertyfactorymanager.h \
|
||||||
vserializedproperty.h \
|
vserializedproperty.h \
|
||||||
plugins/vstringproperty.h
|
plugins/vstringproperty.h \
|
||||||
|
plugins/vpointfproperty.h
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
target.path = /usr/lib
|
target.path = /usr/lib
|
||||||
|
|
|
@ -121,7 +121,7 @@ void VPropertyFormView::dataSubmitted(VProperty *property)
|
||||||
|
|
||||||
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);
|
||||||
tmpModel->showDataChangedByEditor(property);
|
tmpModel->showDataChangedByEditor(property);
|
||||||
|
|
||||||
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = false;
|
static_cast<VPropertyFormViewPrivate*>(d_ptr)->IgnoreDataChangedSignal = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user