| 1 |
/* |
| 2 |
SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}> |
| 3 |
|
| 4 |
SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef MYDATASYSTEM_H |
| 8 |
#define MYDATASYSTEM_H |
| 9 |
|
| 10 |
// Qt |
| 11 |
#include <QHash> |
| 12 |
#include <QStringList> |
| 13 |
#include <QByteArray> |
| 14 |
|
| 15 |
// A sample class transporting the system data structure that would be mapped onto a file |
| 16 |
class DataItem |
| 17 |
{ |
| 18 |
public: |
| 19 |
QString name; |
| 20 |
QByteArray data() const; |
| 21 |
bool isValid() const { return !name.isEmpty(); } |
| 22 |
}; |
| 23 |
|
| 24 |
// A sample class transporting the system data structure that would be mapped onto a directory |
| 25 |
class DataGroup |
| 26 |
{ |
| 27 |
public: |
| 28 |
QHash<QString, DataGroup> subGroups; |
| 29 |
QList<DataItem> items; |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
// A sample data system adapter |
| 34 |
class MyDataSystem |
| 35 |
{ |
| 36 |
public: |
| 37 |
MyDataSystem(); |
| 38 |
|
| 39 |
public: // sync calls querying data from the actual data system |
| 40 |
bool hasGroup(const QStringList &groupPath) const; |
| 41 |
QList<DataItem> items(const QStringList &groupPath) const; |
| 42 |
DataItem item(const QStringList& groupPath, const QString &itemName) const; |
| 43 |
QStringList subGroupNames(const QStringList &groupPath) const; |
| 44 |
|
| 45 |
private: |
| 46 |
const DataGroup* group(const QStringList& groupPath) const; |
| 47 |
|
| 48 |
private: |
| 49 |
// hardcoded sample data to simulate that in the data system |
| 50 |
DataGroup m_toplevelGroup; |
| 51 |
}; |
| 52 |
|
| 53 |
#endif |