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

0001 /*
0002     SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KUSERFEEDBACK_AUDITLOGUICONTROLLER_H
0008 #define KUSERFEEDBACK_AUDITLOGUICONTROLLER_H
0009 
0010 #include "kuserfeedbackcore_export.h"
0011 
0012 #include <QAbstractItemModel>
0013 #include <QObject>
0014 
0015 #include <memory>
0016 
0017 QT_BEGIN_NAMESPACE
0018 class QDateTime;
0019 QT_END_NAMESPACE
0020 
0021 namespace KUserFeedback {
0022 
0023 class AuditLogUiControllerPrivate;
0024 
0025 /** Widget/QtQuick-independent logic and data for the audit log browser UI. */
0026 class KUSERFEEDBACKCORE_EXPORT AuditLogUiController : public QObject
0027 {
0028     Q_OBJECT
0029     /** Returns a model listing all log entries.
0030      *  @see logEntryModel()
0031      */
0032     Q_PROPERTY(QAbstractItemModel* logEntryModel READ logEntryModel CONSTANT)
0033     /** Returns @c true if there are log entries to display. */
0034     Q_PROPERTY(bool hasLogEntries READ hasLogEntries NOTIFY logEntryCountChanged)
0035 public:
0036     AuditLogUiController(QObject *parent = nullptr);
0037     ~AuditLogUiController() override;
0038 
0039     /** Returns @c true if there are log entries to display. */
0040     bool hasLogEntries() const;
0041 
0042     /** Returns a model listing all telemetry data submission events.
0043      *  Qt::UserRole contains the timestamp of the log entry for use in logEntry().
0044      */
0045     QAbstractItemModel* logEntryModel() const;
0046 
0047     /** Returns a formatted text for display of the specified log entry. */
0048     Q_INVOKABLE QString logEntry(const QDateTime &dt) const;
0049 
0050 public Q_SLOTS:
0051     /** Delete all audit log entries. */
0052     void clear();
0053 
0054 Q_SIGNALS:
0055     /** Change notification for the hasLogEntries property. */
0056     void logEntryCountChanged();
0057 
0058 private:
0059     std::unique_ptr<AuditLogUiControllerPrivate> d;
0060 };
0061 
0062 }
0063 
0064 #endif // KUSERFEEDBACK_AUDITLOGUICONTROLLER_H