mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2024-11-24 09:10:16 -06:00
qt: add ReadableData
This commit is contained in:
parent
5b9c0b2cc4
commit
b5874a3ea0
32
src/modules/interface/qt/data/ReadableData.h
Normal file
32
src/modules/interface/qt/data/ReadableData.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
#include <tc_readable.h>
|
||||
|
||||
class ReadableData {
|
||||
private:
|
||||
tc_readable_node_t *m_readableNode;
|
||||
public:
|
||||
ReadableData(tc_readable_node_t *node) {m_readableNode = node;}
|
||||
static QString mimeType() {return QString("tc-readable-data");}
|
||||
bool isConstant() {return m_readableNode->constant;}
|
||||
QString name() {return QString(m_readableNode->name);}
|
||||
QString unit() {return QString(m_readableNode->unit);}
|
||||
const tc_variant_t constData() {
|
||||
if (!isConstant()) {
|
||||
tc_variant_t retval;
|
||||
retval.data_type = TC_TYPE_NONE;
|
||||
return retval;
|
||||
}
|
||||
return m_readableNode->data;
|
||||
}
|
||||
|
||||
const tc_readable_result_t value() {
|
||||
if (isConstant() || !m_readableNode->value_callback) {
|
||||
return tc_readable_result_create(TC_TYPE_NONE, NULL, 0);
|
||||
}
|
||||
return m_readableNode->value_callback(m_readableNode);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user