1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-706 Added isKnown to UAVObject with signal on change.

This commit is contained in:
m_thread 2014-10-17 00:46:31 +02:00
parent 1766776c30
commit 1a28d17eff
2 changed files with 30 additions and 3 deletions

View File

@ -63,6 +63,7 @@ UAVObject::UAVObject(quint32 objID, bool isSingleInst, const QString & name)
this->data = 0;
this->numBytes = 0;
this->mutex = new QMutex(QMutex::Recursive);
m_isKnown = false;
}
/**
@ -603,6 +604,25 @@ void UAVObject::emitNewInstance(UAVObject *obj)
emit newInstance(obj);
}
bool UAVObject::isKnown() const
{
QMutexLocker locker(mutex);
return m_isKnown;
}
void UAVObject::setIsKnown(bool isKnown)
{
lock();
bool changed = m_isKnown != isKnown;
m_isKnown = isKnown;
unlock();
if (changed) {
emit isKnownChanged(this, isKnown);
}
}
bool UAVObject::isSettingsObject()
{
return false;

View File

@ -142,6 +142,9 @@ public:
void emitTransactionCompleted(bool success);
void emitNewInstance(UAVObject *);
bool isKnown() const;
void setIsKnown(bool isKnown);
virtual bool isSettingsObject();
virtual bool isDataObject();
virtual bool isMetaDataObject();
@ -178,9 +181,7 @@ signals:
void updateRequested(UAVObject *obj, bool all = false);
void transactionCompleted(UAVObject *obj, bool success);
void newInstance(UAVObject *obj);
private slots:
void fieldUpdated(UAVObjectField *field);
void isKnownChanged(UAVObject *obj, bool isKnown);
protected:
quint32 objID;
@ -197,6 +198,12 @@ protected:
void initializeFields(QList<UAVObjectField *> & fields, quint8 *data, quint32 numBytes);
void setDescription(const QString & description);
void setCategory(const QString & category);
private:
bool m_isKnown;
private slots:
void fieldUpdated(UAVObjectField *field);
};
#endif // UAVOBJECT_H