mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 07:43:57 +02:00
Integrate JobConfig with JSON/qml
This commit is contained in:
parent
e61636e8a7
commit
5f395654f0
1 changed files with 4 additions and 1 deletions
|
@ -74,7 +74,7 @@ public:
|
|||
Q_INVOKABLE QString toJSON() { return QJsonDocument(toJsonValue(*this).toObject()).toJson(QJsonDocument::Compact); }
|
||||
|
||||
public slots:
|
||||
void load(const QJsonValue& json) { qObjectFromJsonValue(json, *this); }
|
||||
Q_INVOKABLE void fromJSON(const QJsonValue& json) { qObjectFromJsonValue(json, *this); }
|
||||
};
|
||||
|
||||
class TaskConfig : public JobConfig {
|
||||
|
@ -85,6 +85,9 @@ public:
|
|||
|
||||
void init(Task* task) { _task = task; }
|
||||
|
||||
// getter for qml integration, prefer the templated getter
|
||||
Q_INVOKABLE QObject* getConfig(const QString& name) { return QObject::findChild<JobConfig*>(name); }
|
||||
// getter for cpp (strictly typed), prefer this getter
|
||||
template <class T> typename T::Config* getConfig(std::string job = "") const {
|
||||
QString name = job.empty() ? QString() : QString(job.c_str()); // an empty string is not a null string
|
||||
return findChild<typename T::Config*>(name);
|
||||
|
|
Loading…
Reference in a new issue