File indexing completed on 2024-12-15 03:45:04

0001 /*
0002     SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KUSERFEEDBACK_SELECTIONRATIOSOURCE_H
0008 #define KUSERFEEDBACK_SELECTIONRATIOSOURCE_H
0009 
0010 #include "kuserfeedbackcore_export.h"
0011 #include "abstractdatasource.h"
0012 
0013 QT_BEGIN_NAMESPACE
0014 class QItemSelectionModel;
0015 QT_END_NAMESPACE
0016 
0017 namespace KUserFeedback {
0018 
0019 class SelectionRatioSourcePrivate;
0020 
0021 /*! Records the time ratio a given entry is selected via a QItemSelectionModel.
0022  *
0023  *  An example use-case would be the usage ratio of a applications
0024  *  views/modes selected using a model-based view sidebar (such as
0025  *  used in e.g. Kontact).
0026  *
0027  *  The default telemetry mode for this source is Provider::DetailedUsageStatistics.
0028  */
0029 class KUSERFEEDBACKCORE_EXPORT SelectionRatioSource : public AbstractDataSource
0030 {
0031 public:
0032     /*! Create a new selection ratio data source.
0033      * @param selectionModel The selection to monitor.
0034      * @param sampleName This is the name of the database field this data source is
0035      * associated with.
0036      */
0037     explicit SelectionRatioSource(QItemSelectionModel *selectionModel, const QString &sampleName);
0038 
0039     /*! Determine which role to consider for the reported value.
0040      *  By default this is Qt::DisplayRole.
0041      */
0042     void setRole(int role);
0043 
0044     QString description() const override;
0045     /*! Set human-readable and translated description of the data provided by this source.
0046      *  @note This must be set before adding this source, sources without description are
0047      *  discarded.
0048      *  @param desc The description.
0049      */
0050     void setDescription(const QString &desc);
0051 
0052     QVariant data() override;
0053     void loadImpl(QSettings *settings) override;
0054     void storeImpl(QSettings *settings) override;
0055     void resetImpl(QSettings *settings) override;
0056 
0057 private:
0058     Q_DECLARE_PRIVATE(SelectionRatioSource)
0059 };
0060 
0061 }
0062 
0063 #endif // KUSERFEEDBACK_SELECTIONRATIOSOURCE_H