/*!
 * \brief Class holding information about an Android device to be sent to
 * the whitelist server.
 *
 * \copyright Copyright (c) 2019-2020 Governikus GmbH & Co. KG, Germany
 */

#pragma once

#include <QAbstractListModel>
#include <QObject>
#include <QPair>
#include <QString>

class test_SurveyModel;

namespace governikus
{

class SurveyModel
	: public QAbstractListModel
{
	Q_OBJECT
	friend class Env;
	friend class ::test_SurveyModel;

	private:
		const QString mBuildNumber;
		const QString mAndroidVersion;
		const QString mKernelVersion;
		int mMaximumNfcPacketLength;
		const QString mVendor;
		const QString mModelNumber;
		const QString mModelName;
		const QString mAusweisAppVersionNumber;

		QVector<QPair<QString, QString>> mData;

		enum UserRoles
		{
			TITLE = Qt::UserRole + 1,
			VALUE
		};

		SurveyModel();
		virtual ~SurveyModel() override = default;

		void buildDataObject();
		QByteArray toJsonByteArray() const;

	public:
		int rowCount(const QModelIndex& = QModelIndex()) const override;
		QVariant data(const QModelIndex& pIndex, int pRole = Qt::DisplayRole) const override;
		QHash<int, QByteArray> roleNames() const override;

		void setMaximumNfcPacketLength(int pMaximumNfcPacketLength);

		void transmitSurvey() const;
};

} // namespace governikus
