Serial-Studio/src/WidgetProvider.h

95 lines
3.0 KiB
C
Raw Normal View History

2020-11-26 20:43:25 -06:00
/*
* Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
2020-11-26 20:43:25 -06:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
2021-01-22 12:46:11 -05:00
#ifndef WIDGETPROVIDER_H
#define WIDGETPROVIDER_H
2020-11-26 20:43:25 -06:00
#include <QList>
#include <QObject>
class Group;
2020-12-26 22:53:16 -06:00
class Dataset;
2021-01-22 12:46:11 -05:00
class WidgetProvider : public QObject
{
2021-01-13 14:38:12 -05:00
// clang-format off
Q_OBJECT
2021-01-13 14:38:12 -05:00
Q_PROPERTY(int totalWidgetCount
READ totalWidgetCount
NOTIFY dataChanged)
// clang-format on
2020-11-26 20:43:25 -06:00
signals:
void dataChanged();
2020-11-26 20:43:25 -06:00
public:
2021-01-22 12:46:11 -05:00
static WidgetProvider *getInstance();
QList<Group *> mapGroup() const;
QList<Group *> gyroGroup() const;
QList<Dataset *> barDatasets() const;
QList<Group *> accelerometerGroup() const;
int totalWidgetCount() const;
2020-12-27 17:21:19 -06:00
Q_INVOKABLE int mapGroupCount() const;
Q_INVOKABLE int gyroGroupCount() const;
Q_INVOKABLE int barDatasetCount() const;
Q_INVOKABLE int accelerometerGroupCount() const;
Q_INVOKABLE Group *mapGroupAt(const int index);
Q_INVOKABLE Group *gyroGroupAt(const int index);
Q_INVOKABLE Dataset *barDatasetAt(const int index);
Q_INVOKABLE Group *accelerometerGroupAt(const int index);
Q_INVOKABLE double gyroYaw(const int index);
Q_INVOKABLE double gyroRoll(const int index);
Q_INVOKABLE double gyroPitch(const int index);
Q_INVOKABLE double accelerometerX(const int index);
Q_INVOKABLE double accelerometerY(const int index);
Q_INVOKABLE double accelerometerZ(const int index);
Q_INVOKABLE double bar(const int index);
Q_INVOKABLE double barMin(const int index);
Q_INVOKABLE double barMax(const int index);
Q_INVOKABLE double mapLatitude(const int index);
Q_INVOKABLE double mapLongitude(const int index);
2020-11-26 20:43:25 -06:00
private slots:
void updateModels();
2020-11-26 20:43:25 -06:00
private:
2021-01-22 12:46:11 -05:00
WidgetProvider();
QList<Group *> getWidgetGroup(const QString &handle);
QList<Dataset *> getWidgetDatasets(const QString &handle);
2020-11-26 20:43:25 -06:00
private:
QList<Group *> m_mapGroups;
QList<Group *> m_gyroGroups;
QList<Dataset *> m_barDatasets;
QList<Group *> m_accelerometerGroups;
2020-11-26 20:43:25 -06:00
};
#endif