Merge PR #109: Dont ask the user for confirmation to cancel a rule edit if there was no change
This commit is contained in:
commit
41f2f8fb70
@ -1,6 +1,7 @@
|
|||||||
#include "calendaritem.h"
|
#include "calendaritem.h"
|
||||||
|
|
||||||
#include "repeatingoption.h"
|
#include "repeatingoption.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
CalendarItem::CalendarItem(QObject *parent) : QObject(parent)
|
CalendarItem::CalendarItem(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@ -60,3 +61,14 @@ CalendarItem *CalendarItem::clone() const
|
|||||||
ret->m_startTime = this->m_startTime;
|
ret->m_startTime = this->m_startTime;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool CalendarItem::operator ==(CalendarItem *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_dateTime, other->dateTime());
|
||||||
|
COMPARE(m_startTime, other->startTime());
|
||||||
|
COMPARE(m_duration, other->duration());
|
||||||
|
COMPARE(m_repeatingOption, other->repeatingOption());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ public:
|
|||||||
RepeatingOption* repeatingOption() const;
|
RepeatingOption* repeatingOption() const;
|
||||||
|
|
||||||
CalendarItem* clone() const;
|
CalendarItem* clone() const;
|
||||||
|
bool operator==(CalendarItem* other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void durationChanged();
|
void durationChanged();
|
||||||
|
|||||||
@ -50,3 +50,16 @@ CalendarItem *CalendarItems::get(int index) const
|
|||||||
}
|
}
|
||||||
return m_list.at(index);
|
return m_list.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CalendarItems::operator==(CalendarItems *other) const
|
||||||
|
{
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ public:
|
|||||||
Q_INVOKABLE CalendarItem* createNewCalendarItem() const;
|
Q_INVOKABLE CalendarItem* createNewCalendarItem() const;
|
||||||
Q_INVOKABLE CalendarItem* get(int index) const;
|
Q_INVOKABLE CalendarItem* get(int index) const;
|
||||||
|
|
||||||
|
bool operator==(CalendarItems *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "eventdescriptor.h"
|
#include "eventdescriptor.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
EventDescriptor::EventDescriptor(QObject *parent) : QObject(parent)
|
EventDescriptor::EventDescriptor(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@ -74,3 +75,15 @@ EventDescriptor *EventDescriptor::clone() const
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool EventDescriptor::operator==(EventDescriptor *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_deviceId, other->deviceId());
|
||||||
|
COMPARE(m_eventTypeId, other->eventTypeId());
|
||||||
|
COMPARE(m_interfaceName, other->interfaceName());
|
||||||
|
COMPARE(m_interfaceEvent, other->interfaceEvent());
|
||||||
|
COMPARE_PTR(m_paramDescriptors, other->paramDescriptors());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public:
|
|||||||
ParamDescriptors* paramDescriptors() const;
|
ParamDescriptors* paramDescriptors() const;
|
||||||
|
|
||||||
EventDescriptor* clone() const;
|
EventDescriptor* clone() const;
|
||||||
|
bool operator==(EventDescriptor* other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceIdChanged();
|
void deviceIdChanged();
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#include "eventdescriptors.h"
|
#include "eventdescriptors.h"
|
||||||
#include "eventdescriptor.h"
|
#include "eventdescriptor.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
EventDescriptors::EventDescriptors(QObject *parent) :
|
EventDescriptors::EventDescriptors(QObject *parent) :
|
||||||
QAbstractListModel(parent)
|
QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
@ -61,3 +63,18 @@ void EventDescriptors::removeEventDescriptor(int index)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EventDescriptors::operator==(EventDescriptors *other) const
|
||||||
|
{
|
||||||
|
qDebug() << "EventDescriptors comparison";
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
qDebug() << "EventDescriptors count not matching";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -26,6 +26,8 @@ public:
|
|||||||
Q_INVOKABLE void addEventDescriptor(EventDescriptor *eventDescriptor);
|
Q_INVOKABLE void addEventDescriptor(EventDescriptor *eventDescriptor);
|
||||||
Q_INVOKABLE void removeEventDescriptor(int index);
|
Q_INVOKABLE void removeEventDescriptor(int index);
|
||||||
|
|
||||||
|
bool operator==(EventDescriptors* other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "paramdescriptor.h"
|
#include "paramdescriptor.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
ParamDescriptor::ParamDescriptor(QObject *parent) : Param(parent)
|
ParamDescriptor::ParamDescriptor(QObject *parent) : Param(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -40,3 +42,14 @@ ParamDescriptor *ParamDescriptor::clone() const
|
|||||||
ret->setOperatorType(this->operatorType());
|
ret->setOperatorType(this->operatorType());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool ParamDescriptor::operator==(ParamDescriptor *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_paramTypeId, other->paramTypeId());
|
||||||
|
COMPARE(m_paramName, other->paramName());
|
||||||
|
COMPARE(m_value, other->value());
|
||||||
|
COMPARE(m_operator, other->operatorType());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ public:
|
|||||||
void setOperatorType(ValueOperator operatorType);
|
void setOperatorType(ValueOperator operatorType);
|
||||||
|
|
||||||
ParamDescriptor* clone() const;
|
ParamDescriptor* clone() const;
|
||||||
|
bool operator==(ParamDescriptor *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void paramNameChanged();
|
void paramNameChanged();
|
||||||
|
|||||||
@ -98,3 +98,16 @@ void ParamDescriptors::clear()
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ParamDescriptors::operator==(ParamDescriptors *other) const
|
||||||
|
{
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -42,6 +42,8 @@ public:
|
|||||||
Q_INVOKABLE void setParamDescriptorByName(const QString ¶mName, const QVariant &value, ValueOperator operatorType);
|
Q_INVOKABLE void setParamDescriptorByName(const QString ¶mName, const QVariant &value, ValueOperator operatorType);
|
||||||
Q_INVOKABLE void clear();
|
Q_INVOKABLE void clear();
|
||||||
|
|
||||||
|
bool operator==(ParamDescriptors *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
|
|||||||
@ -159,6 +159,28 @@ Rule *Rule::clone() const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Rule::compare(Rule *other) const
|
||||||
|
{
|
||||||
|
qDebug() << "comparing rule" << this << "to" << other;
|
||||||
|
return this->operator==(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a && !b) return true; if (!a || !b) return false; if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool Rule::operator==(Rule *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_id, other->id());
|
||||||
|
COMPARE(m_name, other->name());
|
||||||
|
COMPARE(m_enabled, other->enabled());
|
||||||
|
COMPARE(m_executable, other->executable());
|
||||||
|
COMPARE_PTR(m_eventDescriptors, other->eventDescriptors());
|
||||||
|
COMPARE_PTR(m_stateEvaluator, other->stateEvaluator());
|
||||||
|
COMPARE_PTR(m_actions, other->actions());
|
||||||
|
COMPARE_PTR(m_exitActions, other->exitActions());
|
||||||
|
COMPARE_PTR(m_timeDescriptor, other->timeDescriptor());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QDebug operator <<(QDebug &dbg, Rule *rule)
|
QDebug operator <<(QDebug &dbg, Rule *rule)
|
||||||
{
|
{
|
||||||
dbg << rule->name() << " (Enabled:" << rule->enabled() << "Active:" << rule->active() << ")" << endl;
|
dbg << rule->name() << " (Enabled:" << rule->enabled() << "Active:" << rule->active() << ")" << endl;
|
||||||
|
|||||||
@ -52,6 +52,9 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE Rule *clone() const;
|
Q_INVOKABLE Rule *clone() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE bool compare(Rule* other) const;
|
||||||
|
bool operator==(Rule *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void enabledChanged();
|
void enabledChanged();
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include "ruleactionparam.h"
|
#include "ruleactionparam.h"
|
||||||
#include "ruleactionparams.h"
|
#include "ruleactionparams.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
RuleAction::RuleAction(QObject *parent) : QObject(parent)
|
RuleAction::RuleAction(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_ruleActionParams = new RuleActionParams(this);
|
m_ruleActionParams = new RuleActionParams(this);
|
||||||
@ -77,3 +79,15 @@ RuleAction *RuleAction::clone() const
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool RuleAction::operator==(RuleAction *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_deviceId, other->deviceId());
|
||||||
|
COMPARE(m_actionTypeId, other->actionTypeId());
|
||||||
|
COMPARE(m_interfaceName, other->interfaceName());
|
||||||
|
COMPARE(m_interfaceAction, other->interfaceAction());
|
||||||
|
COMPARE_PTR(m_ruleActionParams, other->ruleActionParams());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ public:
|
|||||||
RuleActionParams* ruleActionParams() const;
|
RuleActionParams* ruleActionParams() const;
|
||||||
|
|
||||||
RuleAction *clone() const;
|
RuleAction *clone() const;
|
||||||
|
bool operator==(RuleAction *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceIdChanged();
|
void deviceIdChanged();
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "ruleactionparam.h"
|
#include "ruleactionparam.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
RuleActionParam::RuleActionParam(const QString ¶mName, const QVariant &value, QObject *parent):
|
RuleActionParam::RuleActionParam(const QString ¶mName, const QVariant &value, QObject *parent):
|
||||||
Param(parent),
|
Param(parent),
|
||||||
m_paramName(paramName)
|
m_paramName(paramName)
|
||||||
@ -61,3 +63,15 @@ RuleActionParam *RuleActionParam::clone() const
|
|||||||
ret->setEventParamTypeId(eventParamTypeId());
|
ret->setEventParamTypeId(eventParamTypeId());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool RuleActionParam::operator==(RuleActionParam *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_paramTypeId, other->paramTypeId());
|
||||||
|
COMPARE(m_paramName, other->paramName());
|
||||||
|
COMPARE(m_eventTypeId, other->eventTypeId());
|
||||||
|
COMPARE(m_eventParamTypeId, other->eventParamTypeId());
|
||||||
|
COMPARE(m_value, other->value());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ public:
|
|||||||
void setEventParamTypeId(const QString &eventParamTypeId);
|
void setEventParamTypeId(const QString &eventParamTypeId);
|
||||||
|
|
||||||
RuleActionParam* clone() const;
|
RuleActionParam* clone() const;
|
||||||
|
bool operator==(RuleActionParam *other) const;
|
||||||
signals:
|
signals:
|
||||||
void paramNameChanged();
|
void paramNameChanged();
|
||||||
void eventTypeIdChanged();
|
void eventTypeIdChanged();
|
||||||
|
|||||||
@ -98,3 +98,16 @@ RuleActionParam *RuleActionParams::get(int index) const
|
|||||||
{
|
{
|
||||||
return m_list.at(index);
|
return m_list.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RuleActionParams::operator==(RuleActionParams *other) const
|
||||||
|
{
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -31,6 +31,8 @@ public:
|
|||||||
Q_INVOKABLE void setRuleActionParamEvent(const QString ¶mTypeId, const QString &eventTypeId, const QString &eventParamTypeId);
|
Q_INVOKABLE void setRuleActionParamEvent(const QString ¶mTypeId, const QString &eventTypeId, const QString &eventParamTypeId);
|
||||||
Q_INVOKABLE RuleActionParam* get(int index) const;
|
Q_INVOKABLE RuleActionParam* get(int index) const;
|
||||||
|
|
||||||
|
bool operator==(RuleActionParams *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
|
|||||||
@ -48,3 +48,16 @@ RuleAction *RuleActions::createNewRuleAction() const
|
|||||||
{
|
{
|
||||||
return new RuleAction();
|
return new RuleAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RuleActions::operator==(RuleActions *other) const
|
||||||
|
{
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ public:
|
|||||||
Q_INVOKABLE RuleAction* get(int index) const;
|
Q_INVOKABLE RuleAction* get(int index) const;
|
||||||
Q_INVOKABLE RuleAction* createNewRuleAction() const;
|
Q_INVOKABLE RuleAction* createNewRuleAction() const;
|
||||||
|
|
||||||
|
bool operator==(RuleActions *other) const;
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "statedescriptor.h"
|
#include "statedescriptor.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
StateDescriptor::StateDescriptor(const QUuid &deviceId, const QUuid &stateTypeId, StateDescriptor::ValueOperator valueOperator, const QVariant &value, QObject *parent):
|
StateDescriptor::StateDescriptor(const QUuid &deviceId, const QUuid &stateTypeId, StateDescriptor::ValueOperator valueOperator, const QVariant &value, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_deviceId(deviceId),
|
m_deviceId(deviceId),
|
||||||
@ -110,3 +112,16 @@ StateDescriptor *StateDescriptor::clone() const
|
|||||||
ret->setInterfaceState(interfaceState());
|
ret->setInterfaceState(interfaceState());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool StateDescriptor::operator==(StateDescriptor *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_deviceId, other->deviceId());
|
||||||
|
COMPARE(m_stateTypeId, other->stateTypeId());
|
||||||
|
COMPARE(m_interfaceName, other->interfaceName());
|
||||||
|
COMPARE(m_interfaceState, other->interfaceState());
|
||||||
|
COMPARE(m_operator, other->valueOperator());
|
||||||
|
COMPARE(m_value, other->value());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -49,6 +49,7 @@ public:
|
|||||||
void setValue(const QVariant &value);
|
void setValue(const QVariant &value);
|
||||||
|
|
||||||
StateDescriptor* clone() const;
|
StateDescriptor* clone() const;
|
||||||
|
bool operator==(StateDescriptor *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceIdChanged();
|
void deviceIdChanged();
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
#include "stateevaluators.h"
|
#include "stateevaluators.h"
|
||||||
#include "statedescriptor.h"
|
#include "statedescriptor.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
StateEvaluator::StateEvaluator(QObject *parent) : QObject(parent)
|
StateEvaluator::StateEvaluator(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_childEvaluators = new StateEvaluators(this);
|
m_childEvaluators = new StateEvaluators(this);
|
||||||
@ -75,3 +77,13 @@ StateEvaluator *StateEvaluator::clone() const
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool StateEvaluator::operator==(StateEvaluator *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_operator, other->stateOperator());
|
||||||
|
COMPARE_PTR(m_stateDescriptor, other->stateDescriptor());
|
||||||
|
COMPARE_PTR(m_childEvaluators, other->childEvaluators());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ public:
|
|||||||
Q_INVOKABLE StateEvaluator* addChildEvaluator();
|
Q_INVOKABLE StateEvaluator* addChildEvaluator();
|
||||||
|
|
||||||
StateEvaluator* clone() const;
|
StateEvaluator* clone() const;
|
||||||
|
bool operator==(StateEvaluator *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateOperatorChanged();
|
void stateOperatorChanged();
|
||||||
|
|||||||
@ -56,3 +56,16 @@ void StateEvaluators::remove(int index)
|
|||||||
{
|
{
|
||||||
take(index)->deleteLater();
|
take(index)->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StateEvaluators::operator==(StateEvaluators *other) const
|
||||||
|
{
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -26,6 +26,8 @@ public:
|
|||||||
// StateEvaluator will be deleted
|
// StateEvaluator will be deleted
|
||||||
Q_INVOKABLE void remove(int index);
|
Q_INVOKABLE void remove(int index);
|
||||||
|
|
||||||
|
bool operator==(StateEvaluators *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include "timeeventitems.h"
|
#include "timeeventitems.h"
|
||||||
#include "calendaritems.h"
|
#include "calendaritems.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
TimeDescriptor::TimeDescriptor(QObject *parent) : QObject(parent)
|
TimeDescriptor::TimeDescriptor(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_timeEventItems = new TimeEventItems(this);
|
m_timeEventItems = new TimeEventItems(this);
|
||||||
@ -18,3 +20,12 @@ CalendarItems *TimeDescriptor::calendarItems() const
|
|||||||
{
|
{
|
||||||
return m_calendarItems;
|
return m_calendarItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool TimeDescriptor::operator==(TimeDescriptor *other) const
|
||||||
|
{
|
||||||
|
COMPARE_PTR(m_timeEventItems, other->timeEventItems());
|
||||||
|
COMPARE_PTR(m_calendarItems, other->calendarItems());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -18,6 +18,8 @@ public:
|
|||||||
|
|
||||||
TimeEventItems* timeEventItems() const;
|
TimeEventItems* timeEventItems() const;
|
||||||
CalendarItems* calendarItems() const;
|
CalendarItems* calendarItems() const;
|
||||||
|
|
||||||
|
bool operator==(TimeDescriptor* other) const;
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "repeatingoption.h"
|
#include "repeatingoption.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
TimeEventItem::TimeEventItem(QObject *parent):
|
TimeEventItem::TimeEventItem(QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_repeatingOption(new RepeatingOption(this))
|
m_repeatingOption(new RepeatingOption(this))
|
||||||
@ -47,3 +49,13 @@ TimeEventItem *TimeEventItem::clone() const
|
|||||||
ret->m_repeatingOption = this->m_repeatingOption;
|
ret->m_repeatingOption = this->m_repeatingOption;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define COMPARE(a, b) if (a != b) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
#define COMPARE_PTR(a, b) if (!a->operator==(b)) { qDebug() << a << "!=" << b; return false; }
|
||||||
|
bool TimeEventItem::operator==(TimeEventItem *other) const
|
||||||
|
{
|
||||||
|
COMPARE(m_time, other->time());
|
||||||
|
COMPARE(m_dateTime, other->dateTime());
|
||||||
|
COMPARE(m_repeatingOption, other->repeatingOption());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public:
|
|||||||
RepeatingOption* repeatingOption() const;
|
RepeatingOption* repeatingOption() const;
|
||||||
|
|
||||||
TimeEventItem* clone() const;
|
TimeEventItem* clone() const;
|
||||||
|
bool operator==(TimeEventItem *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dateTimeChanged();
|
void dateTimeChanged();
|
||||||
|
|||||||
@ -53,3 +53,16 @@ TimeEventItem *TimeEventItems::createNewTimeEventItem() const
|
|||||||
{
|
{
|
||||||
return new TimeEventItem();
|
return new TimeEventItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TimeEventItems::operator==(TimeEventItems *other) const
|
||||||
|
{
|
||||||
|
if (rowCount() != other->rowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (!get(i)->operator==(other->get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ public:
|
|||||||
Q_INVOKABLE TimeEventItem* get(int index) const;
|
Q_INVOKABLE TimeEventItem* get(int index) const;
|
||||||
Q_INVOKABLE TimeEventItem* createNewTimeEventItem() const;
|
Q_INVOKABLE TimeEventItem* createNewTimeEventItem() const;
|
||||||
|
|
||||||
|
bool operator==(TimeEventItems *other) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import Nymea 1.0
|
|||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var rule: null
|
property Rule rule: null
|
||||||
property var initialDeviceToBeAdded: null
|
property Device initialDeviceToBeAdded: null
|
||||||
|
|
||||||
property bool busy: false
|
property bool busy: false
|
||||||
|
|
||||||
@ -27,7 +27,23 @@ Page {
|
|||||||
signal cancel();
|
signal cancel();
|
||||||
|
|
||||||
Component.onCompleted: print("+++ created editrulepage")
|
Component.onCompleted: print("+++ created editrulepage")
|
||||||
Component.onDestruction: print("--- destroying editrulepage")
|
Component.onDestruction: {
|
||||||
|
print("--- destroying editrulepage")
|
||||||
|
d.backupRule.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
onRuleChanged: d.createRuleBackup();
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
property Rule backupRule: null
|
||||||
|
|
||||||
|
function createRuleBackup() {
|
||||||
|
if (backupRule !== null) {
|
||||||
|
backupRule.destroy();
|
||||||
|
}
|
||||||
|
backupRule = root.rule.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addEventDescriptor(interfaceMode) {
|
function addEventDescriptor(interfaceMode) {
|
||||||
if (interfaceMode === undefined) {
|
if (interfaceMode === undefined) {
|
||||||
@ -208,6 +224,12 @@ Page {
|
|||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: root.rule.name.length === 0 ? qsTr("Add new magic") : qsTr("Edit %1").arg(root.rule.name)
|
text: root.rule.name.length === 0 ? qsTr("Add new magic") : qsTr("Edit %1").arg(root.rule.name)
|
||||||
onBackPressed: {
|
onBackPressed: {
|
||||||
|
if (root.rule.compare(d.backupRule)) {
|
||||||
|
print("Rule has not been changed. Exiting EditRulePage");
|
||||||
|
root.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print("Rule has changed. Asking for cancellation dialog")
|
||||||
var component = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
var component = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
||||||
var popup = component.createObject(root, {headerIcon: "../images/question.svg",
|
var popup = component.createObject(root, {headerIcon: "../images/question.svg",
|
||||||
title: qsTr("Cancel?"),
|
title: qsTr("Cancel?"),
|
||||||
@ -349,7 +371,7 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Repeater {
|
Repeater {
|
||||||
model: ["light-on", "light-off", "alarm-clock", "media-play", "network-secure", "notification", "sensors", "shutter-10", "attention", "eye"]
|
model: ["light-on", "light-off", "alarm-clock", "media-playback-start", "network-secure", "notification", "sensors", "shutter/shutter-050", "attention", "eye"]
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: app.iconSize + app.margins
|
Layout.preferredHeight: app.iconSize + app.margins
|
||||||
|
|||||||
Reference in New Issue
Block a user