New property list of objects (points, arcs, curves).

--HG--
branch : feature
This commit is contained in:
dismine 2014-08-28 14:05:58 +03:00
parent a8a99febf4
commit a9667aac09
16 changed files with 514 additions and 54 deletions

View File

@ -32,6 +32,7 @@
#include "../../dialogs/tools/dialogendline.h" #include "../../dialogs/tools/dialogendline.h"
#include "../../dialogs/tools/dialogeditwrongformula.h" #include "../../dialogs/tools/dialogeditwrongformula.h"
#include "../../geometry/vpointf.h" #include "../../geometry/vpointf.h"
#include "../../undocommands/savetooloptions.h"
const QString VToolEndLine::ToolType = QStringLiteral("endLine"); const QString VToolEndLine::ToolType = QStringLiteral("endLine");
@ -170,6 +171,51 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
return nullptr; return nullptr;
} }
void VToolEndLine::SaveOption(const VPointF &point)
{
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
SaveOptions(newDomElement, point);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
void VToolEndLine::setName(const QString &name)
{
VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id).data());
newPoint.setName(name);
SaveOption(newPoint);
}
void VToolEndLine::setBasePointId(const quint32 &value)
{
if (value != NULL_ID)
{
basePointId = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
}
void VToolEndLine::setFormulaLength(const QString &value)
{
formulaLength = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief FullUpdateFromFile update tool data form file. * @brief FullUpdateFromFile update tool data form file.
@ -216,16 +262,7 @@ void VToolEndLine::AddToFile()
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id); SaveOptions(domElement, *point.data());
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, formulaAngle);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
AddToCalculation(domElement); AddToCalculation(domElement);
} }
@ -240,13 +277,7 @@ void VToolEndLine::RefreshDataInFile()
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement()) if (domElement.isElement())
{ {
doc->SetAttribute(domElement, AttrName, point->name()); SaveOptions(domElement, *point.data());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, formulaAngle);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
} }
} }
@ -265,3 +296,41 @@ void VToolEndLine::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId()));
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::SaveOptions(QDomElement &tag, const VPointF &point)
{
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point.name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId);
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolEndLine::getFormulaAngle() const
{
return formulaAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::setFormulaAngle(const QString &value)
{
formulaAngle = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
void VToolEndLine::setTypeLine(const QString &value)
{
typeLine = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}

View File

@ -51,6 +51,12 @@ public:
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::EndLine)}; enum { Type = UserType + static_cast<int>(Tool::EndLine)};
void setName(const QString &name);
QString getFormulaAngle() const;
void setFormulaAngle(const QString &value);
void setTypeLine(const QString &value);
void setFormulaLength(const QString &value);
void setBasePointId(const quint32 &value);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
@ -61,6 +67,8 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
private: private:
QString formulaAngle; QString formulaAngle;
void SaveOptions(QDomElement &tag, const VPointF &point);
void SaveOption(const VPointF &point);
}; };
#endif // VTOOLENDLINE_H #endif // VTOOLENDLINE_H

View File

@ -107,3 +107,13 @@ void VToolLinePoint::SetFactor(qreal factor)
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }
quint32 VToolLinePoint::getBasePointId() const
{
return basePointId;
}
QString VToolLinePoint::getFormulaLength() const
{
return formulaLength;
}

View File

@ -42,6 +42,12 @@ public:
const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr); const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr);
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LinePoint)}; enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
QString getFormulaLength() const;
//void setFormulaLength(const QString &value)=0;
quint32 getBasePointId() const;
//void setBasePointId(const quint32 &value)=0;
public slots: public slots:
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);

View File

@ -72,6 +72,12 @@ void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
QGraphicsEllipseItem::paint(painter, &myOption, widget); QGraphicsEllipseItem::paint(painter, &myOption, widget);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolPoint::name() const
{
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief NameChangePosition handle change posion point label. * @brief NameChangePosition handle change posion point label.

View File

@ -46,6 +46,8 @@ public:
virtual ~VToolPoint(){} virtual ~VToolPoint(){}
static const QString TagName; static const QString TagName;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
QString name() const;
//void setName(const QString &name)=0;
public slots: public slots:
void NameChangePosition(const QPointF &pos); void NameChangePosition(const QPointF &pos);
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);

View File

@ -83,12 +83,6 @@ void VToolSinglePoint::setDialog()
dialogTool->setData(p->name(), p->toQPointF()); dialogTool->setData(p->name(), p->toQPointF());
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolSinglePoint::name() const
{
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::setName(const QString &name) void VToolSinglePoint::setName(const QString &name)
{ {

View File

@ -43,7 +43,6 @@ public:
const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr ); const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr );
virtual void setDialog(); virtual void setDialog();
static const QString ToolType; static const QString ToolType;
QString name() const;
void setName(const QString &name); void setName(const QString &name);
virtual int type()const; virtual int type()const;
enum { Type = UserType + static_cast<int>(Tool::SinglePoint)}; enum { Type = UserType + static_cast<int>(Tool::SinglePoint)};

View File

@ -31,6 +31,7 @@
#include <QMessageBox> #include <QMessageBox>
#include "../undocommands/deltool.h" #include "../undocommands/deltool.h"
#include "../widgets/vapplication.h" #include "../widgets/vapplication.h"
#include "../geometry/vpointf.h"
const QString VAbstractTool::AttrType = QStringLiteral("type"); const QString VAbstractTool::AttrType = QStringLiteral("type");
const QString VAbstractTool::AttrMx = QStringLiteral("mx"); const QString VAbstractTool::AttrMx = QStringLiteral("mx");
@ -288,6 +289,31 @@ Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine)
break; break;
} }
} }
QString VAbstractTool::getTypeLine() const
{
return typeLine;
}
QMap<QString, quint32> VAbstractTool::PointsList() const
{
const QHash<quint32, QSharedPointer<VGObject> > *objs = data.DataGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (i.key() != id)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VPointF> point = data.GeometricObject<VPointF>(i.key());
list[point->name()] = i.key();
}
}
}
return list;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VAbstractTool::ConfirmDeletion() int VAbstractTool::ConfirmDeletion()

View File

@ -100,6 +100,10 @@ public:
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc); static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);
static Qt::PenStyle LineStyle(const QString &typeLine); static Qt::PenStyle LineStyle(const QString &typeLine);
const VContainer *getData() const; const VContainer *getData() const;
QString getTypeLine() const;
//void setTypeLine(const QString &value)=0;
QMap<QString, quint32> PointsList() const;
public slots: public slots:
/** /**
* @brief FullUpdateFromFile update tool data form file. * @brief FullUpdateFromFile update tool data form file.

View File

@ -32,10 +32,7 @@
#include "widgets/vmaingraphicsview.h" #include "widgets/vmaingraphicsview.h"
#include "visualization/vgraphicssimpletextitem.h" #include "visualization/vgraphicssimpletextitem.h"
#include "visualization/vcontrolpointspline.h" #include "visualization/vcontrolpointspline.h"
#include "../libs/vpropertyexplorer/plugins/vnumberproperty.h" #include "../libs/vpropertyexplorer/vproperties.h"
#include "../libs/vpropertyexplorer/plugins/vstringproperty.h"
#include "../libs/vpropertyexplorer/plugins/vpointfproperty.h"
#include "../libs/vpropertyexplorer/plugins/venumproperty.h"
#include <QDockWidget> #include <QDockWidget>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -108,7 +105,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
return; return;
} }
QVariant variant = prop->data(VProperty::DPC_Data); QVariant variant = prop->data(VProperty::DPC_Data, Qt::DisplayRole);
QString id = propertyToId[prop]; QString id = propertyToId[prop];
switch (currentItem->type()) switch (currentItem->type())
@ -117,23 +114,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
{ {
if (id == QLatin1String("name")) if (id == QLatin1String("name"))
{ {
if (VToolSinglePoint *i = qgraphicsitem_cast<VToolSinglePoint *>(currentItem)) SetPointName<VToolSinglePoint>(variant.toString());
{
if (variant.toString() == i->name())
{
return;
}
if (variant.toString().isEmpty())
{
idToProperty[QLatin1String("name")]->setValue(i->name());
}
else
{
//TODO check if label name is unique
i->setName(variant.toString());
}
}
} }
else if (id == QLatin1String("position")) else if (id == QLatin1String("position"))
{ {
@ -145,18 +126,51 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
// } // }
break; break;
} }
// case VGraphicsSimpleTextItem::Type: case VToolEndLine::Type:
// ShowItemOptions(currentItem->parentItem()); {
// break; if (id == QLatin1String("name"))
// case VControlPointSpline::Type: {
// ShowItemOptions(currentItem->parentItem()); SetPointName<VToolEndLine>(variant.toString());
// break; }
else if (id == QLatin1String("basePoint"))
{
VToolEndLine *i = qgraphicsitem_cast<VToolEndLine *>(currentItem);
i->setBasePointId(variant.toUInt());
}
break;
}
default: default:
break; break;
} }
qApp->getSceneView()->update(); qApp->getSceneView()->update();
} }
template<class Tool>
void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
{
if (Tool *i = qgraphicsitem_cast<Tool *>(currentItem))
{
if (name == i->name())
{
return;
}
if (name.isEmpty())
{
idToProperty[QLatin1String("name")]->setValue(i->name());
}
else
{
//TODO check if label name is unique
i->setName(name);
}
}
else
{
qWarning()<<"Can't cast item";
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptions() void VToolOptionsPropertyBrowser::UpdateOptions()
{ {
@ -174,6 +188,14 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
idToProperty[QLatin1String("position")]->setValue(i->pos()); idToProperty[QLatin1String("position")]->setValue(i->pos());
break; break;
} }
case VToolEndLine::Type:
{
VToolEndLine *i = qgraphicsitem_cast<VToolEndLine *>(currentItem);
idToProperty[QLatin1String("name")]->setValue(i->name());
idToProperty[QLatin1String("basePoint")]->setValue(i->getBasePointId());
break;
}
case VGraphicsSimpleTextItem::Type: case VGraphicsSimpleTextItem::Type:
ShowItemOptions(currentItem->parentItem()); ShowItemOptions(currentItem->parentItem());
break; break;
@ -212,6 +234,24 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
itemPosition->setValue(i->pos()); itemPosition->setValue(i->pos());
AddProperty(itemPosition, QLatin1String("position")); AddProperty(itemPosition, QLatin1String("position"));
break;
}
case VToolEndLine::Type:
{
VToolEndLine *i = qgraphicsitem_cast<VToolEndLine *>(item);
QDockWidget *parent = qobject_cast<QDockWidget *>(this->parent());
parent->setWindowTitle(tr("Tool options (End of line)"));
VProperty* itemName = new VProperty(tr("Point name"));
itemName->setValue(i->name());
AddProperty(itemName, QLatin1String("name"));
VObjectProperty *pointsProperty = new VObjectProperty(tr("Base point"));
QMap<QString, quint32> pointsList = i->PointsList();
pointsProperty->setObjectsList(pointsList);
pointsProperty->setValue(i->getBasePointId());
AddProperty(pointsProperty, QLatin1String("basePoint"));
// VEnumProperty *enumProperty = new VEnumProperty(tr("list")); // VEnumProperty *enumProperty = new VEnumProperty(tr("list"));
// QStringList list = QStringList()<<"a1"<<"a2"<<"a3"; // QStringList list = QStringList()<<"a1"<<"a2"<<"a3";
// enumProperty->setLiterals(list); // enumProperty->setLiterals(list);

View File

@ -63,6 +63,9 @@ private:
void AddProperty(VProperty *property, const QString &id); void AddProperty(VProperty *property, const QString &id);
void ShowItemOptions(QGraphicsItem *item); void ShowItemOptions(QGraphicsItem *item);
template<class Tool>
void SetPointName(const QString &name);
}; };
#endif // VTOOLOPTIONSPROPERTYBROWSER_H #endif // VTOOLOPTIONSPROPERTYBROWSER_H

View File

@ -0,0 +1,156 @@
/************************************************************************
**
** @file vobjectproperty.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 28 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 "vobjectproperty.h"
#include "vproperty_p.h"
#include <QComboBox>
#include <QCoreApplication>
#include <QDebug>
using namespace VPE;
VObjectProperty::VObjectProperty(const QString& name)
: QObject(), VProperty(name, QVariant::Int)
{
VProperty::d_ptr->VariantValue = 0;
VProperty::d_ptr->VariantValue.convert(QVariant::UInt);
}
//! Get the data how it should be displayed
QVariant VObjectProperty::data (int column, int role) const
{
if(objects.empty())
return QVariant();
QComboBox* tmpEditor = qobject_cast<QComboBox*>(VProperty::d_ptr->editor);
if(column == DPC_Data && Qt::DisplayRole == role)
{
return VProperty::d_ptr->VariantValue;
}
else if(column == DPC_Data && Qt::EditRole == role)
return tmpEditor->currentIndex();
else
return VProperty::data(column, role);
}
//! Returns an editor widget, or NULL if it doesn't supply one
QWidget* VObjectProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate)
{
Q_UNUSED(options);
Q_UNUSED(delegate);
QComboBox* tmpEditor = new QComboBox(parent);
tmpEditor->clear();
FillList(tmpEditor, objects);
tmpEditor->setCurrentIndex(tmpEditor->findData(VProperty::d_ptr->VariantValue.toUInt()));
connect(tmpEditor, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&VObjectProperty::currentIndexChanged);
VProperty::d_ptr->editor = tmpEditor;
return VProperty::d_ptr->editor;
}
bool VObjectProperty::setEditorData(QWidget *editor)
{
if(!editor)
return false;
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
if(tmpEditor)
{
quint32 objId = VProperty::d_ptr->VariantValue.toUInt();
qint32 tmpIndex = tmpEditor->findData(objId);
if (tmpIndex == -1)
{
tmpIndex = 0;
}
tmpEditor->blockSignals(true);
tmpEditor->setCurrentIndex(tmpIndex);
tmpEditor->blockSignals(false);
return true;
}
return false;
}
//! Gets the data from the widget
QVariant VObjectProperty::getEditorData(QWidget* editor) const
{
QComboBox* tmpEditor = qobject_cast<QComboBox*>(editor);
if(tmpEditor)
return tmpEditor->itemData(tmpEditor->currentIndex());
return QVariant(0);
}
//! Sets the objects list
void VObjectProperty::setObjectsList(const QMap<QString, quint32> &objects)
{
this->objects = objects;
}
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
QMap<QString, quint32> VObjectProperty::getObjects() const
{
return objects;
}
//! Sets the value of the property
void VObjectProperty::setValue(const QVariant& value)
{
VProperty::d_ptr->VariantValue = value;
VProperty::d_ptr->VariantValue.convert(QVariant::UInt);
if (VProperty::d_ptr->editor != nullptr)
{
setEditorData(VProperty::d_ptr->editor);
}
}
QString VObjectProperty::type() const
{
return "objectList";
}
VProperty* VObjectProperty::clone(bool include_children, VProperty* container) const
{
return VProperty::clone(include_children, container ? container : new VObjectProperty(getName()));
}
void VObjectProperty::currentIndexChanged(int index)
{
Q_UNUSED(index)
UserChangeEvent *event = new UserChangeEvent();
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
}
void VObjectProperty::FillList(QComboBox *box, const QMap<QString, quint32> &list) const
{
box->clear();
QMap<QString, quint32>::const_iterator i;
for (i = list.constBegin(); i != list.constEnd(); ++i)
{
box->addItem(i.key(), i.value());
}
}

View File

@ -0,0 +1,88 @@
/************************************************************************
**
** @file vobjectproperty.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 28 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 VOBJECTPROPERTY_H
#define VOBJECTPROPERTY_H
#include "vproperty.h"
#include <QStringList>
class QComboBox;
namespace VPE{
class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public QObject, public VProperty
{
Q_OBJECT
public:
//! Constructor
VObjectProperty(const QString& name);
//! Destructor
~VObjectProperty() {}
//! Get the data how it should be displayed
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
//! 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
//! \options Render options
//! \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);
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor);
//! Gets the data from the widget
virtual QVariant getEditorData(QWidget* editor) const;
//! Sets the objects list
void setObjectsList(const QMap<QString, quint32> &objects);
//! Get the settings. This function has to be implemented in a subclass in order to have an effect
virtual QMap<QString, quint32> getObjects() const;
//! Sets the value of the property
virtual void setValue(const QVariant& value);
//! 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 = nullptr) const;
public slots:
void currentIndexChanged(int index);
protected:
//! The list of possible objects
QMap<QString, quint32> objects;
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other members by reimplementing the VPropertyPrivate class without touching this header file.
};
}
#endif // VOBJECTPROPERTY_H

View File

@ -0,0 +1,46 @@
/************************************************************************
**
** @file vproperties.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 28 8, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPROPERTIES_H
#define VPROPERTIES_H
#include "vproperty.h"
#include "plugins/vboolproperty.h"
#include "plugins/vcolorproperty.h"
#include "plugins/Vector3d/vvector3dproperty.h"
#include "plugins/vemptyproperty.h"
#include "plugins/venumproperty.h"
#include "plugins/vfileproperty.h"
#include "plugins/vnumberproperty.h"
#include "plugins/vobjectproperty.h"
#include "plugins/vpointfproperty.h"
#include "plugins/vshortcutproperty.h"
#include "plugins/vstringproperty.h"
#include "plugins/vwidgetproperty.h"
#endif // VPROPERTIES_H

View File

@ -48,7 +48,8 @@ SOURCES += \
plugins/Vector3d/vvector3dproperty.cpp \ plugins/Vector3d/vvector3dproperty.cpp \
vstandardpropertyfactory.cpp \ vstandardpropertyfactory.cpp \
plugins/vstringproperty.cpp \ plugins/vstringproperty.cpp \
plugins/vpointfproperty.cpp plugins/vpointfproperty.cpp \
plugins/vobjectproperty.cpp
HEADERS +=\ HEADERS +=\
vpropertyexplorer_global.h \ vpropertyexplorer_global.h \
@ -85,7 +86,9 @@ HEADERS +=\
vpropertyfactorymanager.h \ vpropertyfactorymanager.h \
vserializedproperty.h \ vserializedproperty.h \
plugins/vstringproperty.h \ plugins/vstringproperty.h \
plugins/vpointfproperty.h plugins/vpointfproperty.h \
plugins/vobjectproperty.h \
vproperties.h
unix { unix {
target.path = /usr/lib target.path = /usr/lib