Commit 91884f63 authored by Stephane Mankowski's avatar Stephane Mankowski

Q_GADGET

parent 3af7b219
......@@ -154,7 +154,7 @@ void SKGDebugPluginWidget::onExecuteSqlOrder(bool iInTransaction)
auto t = myEngine.globalObject();
t.setProperty(QStringLiteral("skgresult"), myEngine.newQObject(ui.kSQLResult));
t.setProperty(QStringLiteral("skgdocument"), myEngine.newQObject(getDocument()));
t.setProperty(QStringLiteral("skgerror"), myEngine.newQObject(&err));
//t.setProperty(QStringLiteral("skgerror"), myEngine.newQObject(&err));
t.setProperty(QStringLiteral("skgmainpanel"), myEngine.newQObject(SKGMainPanel::getMainPanel()));
// Finally execute the scripting code.
......
......@@ -141,7 +141,7 @@ SKGError SKGImportPluginMny::importFile()
IFKO(err) return err;
} else {
err.setReturnCode(ERR_INSTALL).setMessage(i18nc("Error message", "The sunriise application is needed for Microsoft Money import but is not installed in '%1'", sunriise_jar));
err.setProperty("application", "sunriise");
err.setProperty("sunriise");
return err;
}
}
......
......@@ -620,7 +620,7 @@ void SKGImportExportPlugin::importFiles(const QList<QUrl>& iFiles, int mode, boo
m_install = false;
KMessageWidget* msg = SKGMainPanel::displayErrorMessage(err);
if (err.getReturnCode() == ERR_INSTALL && (msg != nullptr)) {
QString application = err.property("application").toString();
QString application = err.getProperty();
auto install = new QAction(i18nc("Noun", "Install %1", application), msg);
install->setIcon(SKGServices::fromTheme(QStringLiteral("download")));
msg->addAction(install);
......
......@@ -34,7 +34,6 @@ class SKGInterestObject;
*/
class SKGBANKMODELER_EXPORT SKGAccountObject : public SKGNamedObject
{
Q_OBJECT
public:
/**
* Describe a interest item
......@@ -110,7 +109,7 @@ public:
/**
* Destructor
*/
~SKGAccountObject() override;
virtual ~SKGAccountObject();
/**
* Get the parent bank
......
......@@ -31,8 +31,6 @@ class SKGAccountObject;
*/
class SKGBANKMODELER_EXPORT SKGBankObject final : public SKGNamedObject
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -73,7 +71,7 @@ public:
/**
* Destructor
*/
~SKGBankObject() override;
virtual ~SKGBankObject();
/**
* Add an account
......
......@@ -34,7 +34,6 @@ class SKGDocumentBank;
*/
class SKGBANKMODELER_EXPORT SKGBudgetObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -51,7 +50,7 @@ public:
/**
* Destructor
*/
~SKGBudgetObject() override;
virtual ~SKGBudgetObject();
/**
* Copy constructor
......
......@@ -34,7 +34,6 @@ class SKGDocumentBank;
*/
class SKGBANKMODELER_EXPORT SKGBudgetRuleObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* Condition
......@@ -75,7 +74,7 @@ public:
/**
* Destructor
*/
~SKGBudgetRuleObject() override;
virtual ~SKGBudgetRuleObject();
/**
* Copy constructor
......
......@@ -30,7 +30,6 @@ class SKGDocumentBank;
*/
class SKGBANKMODELER_EXPORT SKGCategoryObject final : public SKGNamedObject
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -65,7 +64,7 @@ public:
/**
* Destructor
*/
~SKGCategoryObject() override;
virtual ~SKGCategoryObject();
/**
* Create a category branch if needed and return the leaf of the branch
......
......@@ -54,7 +54,7 @@ public:
/**
* Destructor
*/
~SKGImportExportManager() override;
virtual ~SKGImportExportManager() override;
/**
* Set the codec used for imports.
......
......@@ -34,7 +34,6 @@ class SKGInterestObject;
*/
class SKGBANKMODELER_EXPORT SKGInterestObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* This enumerate defines how to compute value date
......@@ -97,7 +96,7 @@ public:
/**
* Destructor
*/
~SKGInterestObject() override;
virtual ~SKGInterestObject();
/**
* Get the parent account
......
......@@ -35,7 +35,6 @@ class SKGPayeeObject;
*/
class SKGBANKMODELER_EXPORT SKGOperationObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* This enumerate defines status for operations
......@@ -96,7 +95,7 @@ public:
/**
* Destructor
*/
~SKGOperationObject() override;
virtual ~SKGOperationObject();
/**
* Duplicate current operation including suboperations and grouped operations
......
......@@ -32,8 +32,6 @@ class SKGCategoryObject;
*/
class SKGBANKMODELER_EXPORT SKGPayeeObject final : public SKGNamedObject
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -68,7 +66,7 @@ public:
/**
* Destructor
*/
~SKGPayeeObject() override;
virtual ~SKGPayeeObject();
/**
* Create a payee if needed and return it
......
......@@ -32,7 +32,6 @@ class SKGDocumentBank;
*/
class SKGBANKMODELER_EXPORT SKGRecurrentOperationObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* This enumerate defines the period unit
......@@ -80,7 +79,7 @@ public:
/**
* Destructor
*/
~SKGRecurrentOperationObject() override;
virtual ~SKGRecurrentOperationObject();
/**
* Get the parent operation
......
......@@ -158,7 +158,7 @@ public:
/**
* Default Destructor
*/
~SKGReportBank() override;
virtual ~SKGReportBank() override;
/**
* Get the budget table
......
......@@ -32,7 +32,6 @@
*/
class SKGBANKMODELER_EXPORT SKGRuleObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* Alarm
......@@ -108,7 +107,7 @@ public:
/**
* Destructor
*/
~SKGRuleObject() override;
virtual ~SKGRuleObject();
/**
* Return the name of the object for the display
......
......@@ -33,8 +33,6 @@ class SKGTrackerObject;
*/
class SKGBANKMODELER_EXPORT SKGSubOperationObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -69,7 +67,7 @@ public:
/**
* Destructor
*/
~SKGSubOperationObject() override;
virtual ~SKGSubOperationObject();
/**
* Set date of this suboperation
......
......@@ -31,8 +31,6 @@ class SKGDocumentBank;
*/
class SKGBANKMODELER_EXPORT SKGTrackerObject final : public SKGNamedObject
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -67,7 +65,7 @@ public:
/**
* Destructor
*/
~SKGTrackerObject() override;
virtual ~SKGTrackerObject();
/**
* Create a tracker if needed and return it
......
......@@ -36,7 +36,6 @@ class SKGDocumentBank;
*/
class SKGBANKMODELER_EXPORT SKGUnitObject final : public SKGNamedObject
{
Q_OBJECT
public:
/**
* This enumerate defines type of units
......@@ -84,7 +83,7 @@ public:
/**
* Destructor
*/
~SKGUnitObject() override;
virtual ~SKGUnitObject();
/**
* Copy constructor
......
......@@ -33,8 +33,6 @@ class SKGUnitObject;
*/
class SKGBANKMODELER_EXPORT SKGUnitValueObject final : public SKGObjectBase
{
Q_OBJECT
public:
/**
* Default constructor
......@@ -69,7 +67,7 @@ public:
/**
* Destructor
*/
~SKGUnitValueObject() override;
virtual ~SKGUnitValueObject();
/**
* Set the quantity for the date of this unit
......
......@@ -22,18 +22,18 @@
#include "skgerror.h"
SKGError::SKGError()
: QObject(), m_message(QLatin1String(""))
: m_message(QLatin1String("")), m_property(QLatin1String(""))
{}
SKGError::SKGError(int iRc, QString iMessage, QString iAction)
: QObject(), m_rc(iRc), m_message(std::move(iMessage)), m_action(std::move(iAction)), m_previousError(nullptr)
: m_rc(iRc), m_message(std::move(iMessage)), m_property(QLatin1String("")), m_action(std::move(iAction)), m_previousError(nullptr)
{}
SKGError::SKGError(const SKGError& iError)
: QObject()
{
m_rc = iError.m_rc;
m_message = iError.m_message;
m_property = iError.m_property;
m_action = iError.m_action;
if (Q_UNLIKELY(iError.m_previousError != nullptr)) {
m_previousError = new SKGError(*iError.m_previousError);
......@@ -43,10 +43,10 @@ SKGError::SKGError(const SKGError& iError)
}
SKGError::SKGError(SKGError&& iError) noexcept
: QObject()
{
m_rc = iError.m_rc;
m_message = iError.m_message;
m_property = iError.m_property;
m_action = iError.m_action;
m_previousError = iError.m_previousError;
iError.m_previousError = nullptr;
......@@ -66,12 +66,12 @@ SKGError& SKGError::operator= (const SKGError& iError)
m_rc = iError.m_rc;
m_message = iError.m_message;
m_property = iError.m_property;
m_action = iError.m_action;
if (Q_UNLIKELY(iError.m_previousError != nullptr)) {
m_previousError = new SKGError(*iError.m_previousError);
}
}
Q_EMIT modified();
return *this;
}
......@@ -107,19 +107,13 @@ int SKGError::getReturnCode() const
SKGError& SKGError::setReturnCode(int iReturnCode)
{
if (m_rc != iReturnCode) {
m_rc = iReturnCode;
Q_EMIT modified();
}
m_rc = iReturnCode;
return *this;
}
SKGError& SKGError::setMessage(const QString& iMessage)
{
if (m_message != iMessage) {
m_message = iMessage;
Q_EMIT modified();
}
m_message = iMessage;
return *this;
}
......@@ -128,6 +122,17 @@ QString SKGError::getMessage() const
return m_message;
}
SKGError& SKGError::setProperty(const QString& iProperty)
{
m_property = iProperty;
return *this;
}
QString SKGError::getProperty() const
{
return m_property;
}
QString SKGError::getFullMessage() const
{
QString output('[');
......@@ -167,7 +172,6 @@ SKGError& SKGError::setAction(const QString& iAction)
{
if (m_action != iAction) {
m_action = iAction;
Q_EMIT modified();
}
return *this;
}
......@@ -185,7 +189,6 @@ SKGError& SKGError::addError(int iRc, const QString& iMessage, const QString& iA
setAction(iAction);
delete m_previousError;
m_previousError = pe;
Q_EMIT modified();
return *this;
}
......
......@@ -48,29 +48,32 @@
/**
* This class manages errors
*/
class SKGBASEMODELER_EXPORT SKGError final : public QObject
class SKGBASEMODELER_EXPORT SKGError final
{
Q_OBJECT
/**
* Return code of the error
*/
Q_PROPERTY(int returnCode READ getReturnCode WRITE setReturnCode NOTIFY modified)
Q_PROPERTY(int returnCode READ getReturnCode WRITE setReturnCode)
/**
* Message of the error
*/
Q_PROPERTY(QString message READ getMessage WRITE setMessage NOTIFY modified)
Q_PROPERTY(QString message READ getMessage WRITE setMessage)
/**
* Internal data of the error
*/
Q_PROPERTY(QString property READ getProperty WRITE setProperty)
/**
* Action of the error
*/
Q_PROPERTY(QString action READ getAction WRITE setAction NOTIFY modified)
Q_PROPERTY(QString action READ getAction WRITE setAction)
/**
* To know if it is a success of the error
*/
Q_PROPERTY(bool succeeded READ isSucceeded NOTIFY modified)
Q_PROPERTY(bool succeeded READ isSucceeded)
/**
* To know if it is a failure of the error
*/
Q_PROPERTY(bool failed READ isFailed NOTIFY modified)
Q_PROPERTY(bool failed READ isFailed)
public:
/**
* Constructor
......@@ -100,7 +103,7 @@ public:
/**
* Destructor
*/
~SKGError() override;
~SKGError();
/**
* Operator affectation
......@@ -155,6 +158,12 @@ public:
*/
QString getMessage() const;
/**
* Return the internal data associated to this error
* @return the internal data
*/
QString getProperty() const;
/**
* Return the full message associated to this error
* @return the full message
......@@ -202,7 +211,14 @@ public Q_SLOTS:
* @param iMessage the message
* @return itself to facilitate usage
*/
SKGError& setMessage(const QString& iMessage);
SKGError& setMessage(const QString& iMessage);
/**
* Set internal data associated to this error
* @param iProperty the internal data
* @return itself to facilitate usage
*/
SKGError& setProperty(const QString& iProperty);
/**
* Set the action associated to this error
......@@ -227,13 +243,8 @@ public Q_SLOTS:
*/
SKGError& addError(const SKGError& iError);
Q_SIGNALS:
/**
* This signal is launched when the error is modified
*/
void modified();
private:
Q_GADGET
/**
* the return code of the error
* 0 : It is not an error (SUCCEEDED)
......@@ -247,6 +258,11 @@ private:
*/
QString m_message;
/**
* the property of the error
*/
QString m_property;
/**
* the action of the error
*/
......
......@@ -32,7 +32,6 @@
*/
class SKGBASEMODELER_EXPORT SKGNamedObject : public SKGObjectBase
{
Q_OBJECT
/**
* Name of the object
*/
......@@ -87,7 +86,7 @@ public:
/**
* Destructor
*/
~SKGNamedObject() override;
virtual ~SKGNamedObject();
/**
* Set the name of this object
......
......@@ -31,7 +31,6 @@ class SKGDocument;
*/
class SKGBASEMODELER_EXPORT SKGNodeObject final : public SKGNamedObject
{
Q_OBJECT
/**
* Order of the node
*/
......@@ -84,7 +83,7 @@ public:
/**
* Destructor
*/
~SKGNodeObject() override;
virtual ~SKGNodeObject();
/**
* Create a node branch if needed and return the leaf of the branch
......
......@@ -85,7 +85,7 @@ SKGObjectBase::~SKGObjectBase()
}
SKGObjectBase::SKGObjectBase(const SKGObjectBase& iObject)
: QObject(), d(new SKGObjectBasePrivate)
: d(new SKGObjectBasePrivate)
{
copyFrom(iObject);
}
......@@ -170,7 +170,6 @@ void SKGObjectBase::copyFrom(const SKGObjectBase& iObject)
d->table = iObject.d->table;
d->document = iObject.d->document;
d->attributes = iObject.d->attributes;
Q_EMIT modified();
}
SKGObjectBase SKGObjectBase::cloneInto()
......@@ -189,14 +188,12 @@ SKGObjectBase SKGObjectBase::cloneInto(SKGDocument* iDocument)
output.copyFrom(*this);
output.d->id = 0;
output.d->document = targetDocument;
Q_EMIT modified();
return output;
}
SKGError SKGObjectBase::resetID()
{
d->id = 0;
Q_EMIT modified();
return SKGError();
}
......@@ -285,7 +282,6 @@ SKGError SKGObjectBase::setAttribute(const QString& iName, const QString& iValue
}
d->attributes[iName] = val;
}
Q_EMIT modified();
return err;
}
......@@ -399,7 +395,6 @@ SKGError SKGObjectBase::load()
}
}
}
Q_EMIT modified();
return err;
}
......
......@@ -40,9 +40,8 @@ class SKGObjectBasePrivate;
* R1: Each table must have a view named v_[tablename] where [tablename] is the name of the table.
* R2: Each computed attribute of the view must have a name starting with v_
*/
class SKGBASEMODELER_EXPORT SKGObjectBase : public QObject
class SKGBASEMODELER_EXPORT SKGObjectBase
{
Q_OBJECT
/**
* Unique ide of the object
*/
......@@ -136,7 +135,7 @@ public:
/**
* Destructor
*/
~SKGObjectBase() override;
virtual ~SKGObjectBase();
/**
* Return the unique id of this object
......@@ -341,13 +340,8 @@ protected:
*/
virtual QString getWhereclauseId() const;
Q_SIGNALS:
/**
* This signal is launched when the object is modified
*/
void modified();
private:
Q_GADGET
SKGObjectBasePrivate* d;
};
/**
......
......@@ -31,7 +31,6 @@ class SKGDocument;
*/
class SKGBASEMODELER_EXPORT SKGPropertyObject final : public SKGNamedObject
{
Q_OBJECT
/**
* Value of the property
*/
......@@ -74,7 +73,7 @@ public:
/**
* Destructor
*/
~SKGPropertyObject() override;
virtual ~SKGPropertyObject();
/**
* Set the value of the property
......
......@@ -255,6 +255,8 @@ void test_errors(int& nberror, int& nbcheck, bool showonlyfailures)
SKGTEST(QStringLiteral("ERR:getHistoricalSize"), err.getHistoricalSize(), 1)
SKGTEST(QStringLiteral("ERR:RC 10"), err.getReturnCode(), 11)
SKGTEST(QStringLiteral("ERR:MSG Message 11"), err.getMessage(), QStringLiteral("Message 11"))
err.setProperty("ABC");
SKGTEST(QStringLiteral("ERR:Property ABC"), err.getProperty(), QStringLiteral("ABC"))
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment