File indexing completed on 2024-05-05 17:33:22
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Jonathan Thomas <echidnaman@kubuntu.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #include <QVariant> 0011 0012 #include "discovercommon_export.h" 0013 0014 class DISCOVERCOMMON_EXPORT Rating 0015 { 0016 Q_GADGET 0017 Q_PROPERTY(double sortableRating READ sortableRating CONSTANT) 0018 Q_PROPERTY(float rating READ rating CONSTANT) 0019 Q_PROPERTY(int ratingPoints READ ratingPoints CONSTANT) 0020 Q_PROPERTY(quint64 ratingCount READ ratingCount CONSTANT) 0021 public: 0022 Rating() 0023 { 0024 } 0025 explicit Rating(const QString &packageName, quint64 ratingCount, int rating); 0026 explicit Rating(const QString &packageName, quint64 ratingCount, int data[6]); 0027 ~Rating(); 0028 0029 QString packageName() const; 0030 quint64 ratingCount() const; 0031 // 0.0 - 10.0 ranged rating 0032 float rating() const; 0033 int ratingPoints() const; 0034 // Returns a dampened rating calculated with the Wilson Score Interval algorithm 0035 double sortableRating() const; 0036 0037 private: 0038 QString m_packageName; 0039 quint64 m_ratingCount = 0; 0040 float m_rating = 0; 0041 int m_ratingPoints = 0; 0042 double m_sortableRating = 0; 0043 }; 0044 0045 Q_DECLARE_METATYPE(Rating)