diff --git a/kmymoney/mymoney/mymoneyobject.cpp b/kmymoney/mymoney/mymoneyobject.cpp index 8e9c34f69..fdb3aec14 100644 --- a/kmymoney/mymoney/mymoneyobject.cpp +++ b/kmymoney/mymoney/mymoneyobject.cpp @@ -1,95 +1,87 @@ /*************************************************************************** mymoneyobject.cpp ------------------- copyright : (C) 2005 by Thomas Baumagrt email : ipwizard@users.sourceforge.net (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ /*************************************************************************** * * * This program 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 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "mymoneyobject.h" #include "mymoneyobject_p.h" // ---------------------------------------------------------------------------- // QT Includes // ---------------------------------------------------------------------------- // Project Includes #include "mymoneyexception.h" MyMoneyObject::MyMoneyObject(const QString& id) : d_ptr(new MyMoneyObjectPrivate) { Q_D(MyMoneyObject); d->m_id = id; } -MyMoneyObject::MyMoneyObject(const QDomElement& node, bool forceId) -{ - Q_D(MyMoneyObject); - d->m_id = node.attribute(QStringLiteral("id")); - if (d->m_id.length() == 0 && forceId) - throw MYMONEYEXCEPTION("Node has no ID"); -} - MyMoneyObject::MyMoneyObject() : d_ptr(new MyMoneyObjectPrivate) { } MyMoneyObject::MyMoneyObject(MyMoneyObjectPrivate &dd) : d_ptr(&dd) { } MyMoneyObject::MyMoneyObject(MyMoneyObjectPrivate &dd, const QString& id) : d_ptr(&dd) { Q_D(MyMoneyObject); d->m_id = id; } MyMoneyObject::MyMoneyObject(MyMoneyObjectPrivate &dd, const QDomElement& node, bool forceId) : d_ptr(&dd) { Q_D(MyMoneyObject); d->m_id = node.attribute(QStringLiteral("id")); if (d->m_id.length() == 0 && forceId) throw MYMONEYEXCEPTION("Node has no ID"); } MyMoneyObject::~MyMoneyObject() { Q_D(MyMoneyObject); delete d; } QString MyMoneyObject::id() const { Q_D(const MyMoneyObject); return d->m_id; } bool MyMoneyObject::operator == (const MyMoneyObject& right) const { Q_D(const MyMoneyObject); return d->m_id == right.d_func()->m_id; } void MyMoneyObject::clearId() { Q_D(MyMoneyObject); d->m_id.clear(); } diff --git a/kmymoney/mymoney/mymoneyobject.h b/kmymoney/mymoney/mymoneyobject.h index d8bb5b19d..ba08ca01d 100644 --- a/kmymoney/mymoney/mymoneyobject.h +++ b/kmymoney/mymoney/mymoneyobject.h @@ -1,129 +1,113 @@ /*************************************************************************** mymoneyobject.h ------------------- copyright : (C) 2005 by Thomas Baumgart email : ipwizard@users.sourceforge.net (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ /*************************************************************************** * * * This program 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 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef MYMONEYOBJECT_H #define MYMONEYOBJECT_H // ---------------------------------------------------------------------------- // QT Includes #include // ---------------------------------------------------------------------------- // Project Includes #include "kmm_mymoney_export.h" #include "mymoneyunittestable.h" class QString; class QDomDocument; class QDomElement; /** * @author Thomas Baumgart */ /** * This class represents the base class of all MyMoney objects. */ class MyMoneyObjectPrivate; class KMM_MYMONEY_EXPORT MyMoneyObject { Q_DECLARE_PRIVATE(MyMoneyObject) KMM_MYMONEY_UNIT_TESTABLE public: /** * This is the constructor for the MyMoneyObject object */ MyMoneyObject(); /** * This is the destructor for the MyMoneyObject object */ virtual ~MyMoneyObject(); /** * This method retrieves the id of the object * * @return ID of object */ QString id() const; /** * This method clears the id of the object */ void clearId(); /** * This method must be provided by all derived objects. It returns, * a @p true if the object is referencing the one requested by the * parameter @p id. If it does not, this method returns @p false. * * @param id id of the object to be checked for references * @retval true This object references object with id @p id. * @retval false This object does not reference the object with id @p id. */ virtual bool hasReferenceTo(const QString& id) const = 0; /** * This method creates a QDomElement for the @p document * under the parent node @p parent. * * @param document reference to QDomDocument * @param parent reference to QDomElement parent node */ virtual void writeXML(QDomDocument& document, QDomElement& parent) const = 0; bool operator == (const MyMoneyObject& right) const; protected: MyMoneyObjectPrivate * d_ptr; MyMoneyObject(MyMoneyObjectPrivate &dd); MyMoneyObject(MyMoneyObjectPrivate &dd, const QString& id); MyMoneyObject(MyMoneyObjectPrivate &dd, const QDomElement& node, bool forceId = true); /** * This contructor assigns the id to the MyMoneyObject * * @param id ID of object */ MyMoneyObject(const QString& id); - - /** - * This contructor reads the id from the @p id attribute of the - * QDomElement. - * - * @param node const reference to the QDomElement from which to - * obtain the id of the object - * @param forceId flag to be able to suppress enforcement of an id - * defaults to true which requires the node to have an - * attribute with name @p id. If it does not contain such - * an attribute, an exception will be thrown. If @p forceId - * is false, no check for an id is performed. This will be - * used by objects, which are stored w/o id (eg. splits, - * transactions within schedules) - */ - explicit MyMoneyObject(const QDomElement& node, bool forceId = true); }; #endif