Template CopyGObject.

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-31 10:08:14 +02:00
parent 6669a0a15a
commit a9dfc45f99
2 changed files with 13 additions and 13 deletions

View File

@ -81,32 +81,26 @@ void VContainer::setData(const VContainer &data)
{
case(GObject::Arc):
{
VArc *arc = new VArc(*data.GeometricObject<const VArc *>(i.key()));
Q_ASSERT(arc != 0);
UpdateGObject(i.key(), arc);
CopyGObject<VArc>(data, i.key());
break;
}
case(GObject::Point):
{
VPointF *point = new VPointF(*data.GeometricObject<const VPointF *>(i.key()));
Q_ASSERT(point != 0);
UpdateGObject(i.key(), point);
CopyGObject<VPointF>(data, i.key());
break;
}
case(GObject::Spline):
{
VSpline *spl = new VSpline(*data.GeometricObject<const VSpline *>(i.key()));
Q_ASSERT(spl != 0);
UpdateGObject(i.key(), spl);
CopyGObject<VSpline>(data, i.key());
break;
}
case(GObject::SplinePath):
{
VSplinePath *path = new VSplinePath(*data.GeometricObject<const VSplinePath *>(i.key()));
Q_ASSERT(path != 0);
UpdateGObject(i.key(), path);
CopyGObject<VSplinePath>(data, i.key());
break;
}
default:
qWarning()<<"Don't know how copy this type.";
}
}
standartTable = *data.DataStandartTable();

View File

@ -61,6 +61,13 @@ public:
*/
VContainer(const VContainer &data);
~VContainer();
template <typename T>
void CopyGObject(const VContainer &data, const qint64 &id)
{
T *obj = new T(*data.GeometricObject<const T *>(id));
Q_ASSERT(obj != 0);
UpdateGObject(id, obj);
}
/**
* @brief setData copy data from container
* @param data container
@ -79,7 +86,6 @@ public:
throw VExceptionBadId(tr("Can't find object"), id);
}
T obj = dynamic_cast<T>(gObj);
//T obj = qobject_cast<T>(gObj);
Q_ASSERT(obj != 0);
return obj;
}