// SPDX-FileCopyrightText: 2022 Carl Schwan // SPDX-License-Identifier: LGPL-2.0-or-later #pragma once #include class Poll { Q_GADGET Q_PROPERTY(QString id READ id CONSTANT) Q_PROPERTY(QDateTime expiresAt READ expiresAt CONSTANT) Q_PROPERTY(bool expired READ expired CONSTANT) Q_PROPERTY(bool multiple READ multiple CONSTANT) Q_PROPERTY(int votesCount READ votesCount CONSTANT) Q_PROPERTY(int votersCount READ votersCount CONSTANT) Q_PROPERTY(bool voted READ voted CONSTANT) Q_PROPERTY(QList ownVotes READ ownVotes CONSTANT) Q_PROPERTY(QList options READ options CONSTANT) public: Poll(); explicit Poll(const QJsonObject &json); [[nodiscard]] QString id() const; [[nodiscard]] QDateTime expiresAt() const; [[nodiscard]] bool expired() const; [[nodiscard]] bool multiple() const; [[nodiscard]] int votesCount() const; [[nodiscard]] int votersCount() const; [[nodiscard]] bool voted() const; [[nodiscard]] QList ownVotes() const; [[nodiscard]] QList options() const; [[nodiscard]] Q_INVOKABLE bool hasVotedFor(int index) const; private: QString m_id; QDateTime m_expiresAt; bool m_expired = false; bool m_multiple = false; int m_votesCount = 0; int m_votersCount = 0; bool m_voted = false; QList m_ownVotes; QList m_options; };