Qt Quick Ultralite swipe_game Demo

/****************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include <qul/model.h> #include <array> struct Highscore { int time{}; int tries{}; int score{}; }; inline bool operator==(const Highscore &lhs, const Highscore &rhs) { return lhs.time == rhs.time && lhs.tries == rhs.tries && lhs.score == rhs.score; } inline bool operator>(const Highscore &lhs, const Highscore &rhs) { return lhs.score > rhs.score; } inline bool operator<(const Highscore &lhs, const Highscore &rhs) { return lhs.score < rhs.score; } class HighscoreModel : public Qul::ListModel<Highscore> { public: HighscoreModel(); int count() const override; Highscore data(int index) const override; void addEntry(int time, int tries, int score); private: using scoreContainer = std::array<Highscore, 10>; scoreContainer::iterator back(); scoreContainer m_highscores; }; #endif // HIGHSCOREMODEL_H