KUserFeedback

auditlogbrowserdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#include "auditlogbrowserdialog.h"
8#include "ui_auditlogbrowserdialog.h"
9
10#include <auditloguicontroller.h>
11
12#include <QDateTime>
13#include <QPushButton>
14
15using namespace KUserFeedback;
16
17AuditLogBrowserDialog::AuditLogBrowserDialog(QWidget *parent)
18 : QDialog(parent)
19 , ui(new Ui::AuditLogBrowserDialog)
20 , m_controller(nullptr)
21{
22 ui->setupUi(this);
23
24 connect(ui->logEntryBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &AuditLogBrowserDialog::logEntrySelected);
25
26 auto clearButton = ui->buttonBox->button(QDialogButtonBox::Discard);
27 Q_ASSERT(clearButton);
28 clearButton->setText(tr("Delete Log"));
29 connect(clearButton, &QPushButton::clicked, this, &AuditLogBrowserDialog::close);
30
31 setEnabled(false);
32}
33
34AuditLogBrowserDialog::~AuditLogBrowserDialog()
35{
36}
37
38void AuditLogBrowserDialog::setUiController(AuditLogUiController *controller)
39{
40 Q_ASSERT(controller);
41 m_controller = controller;
42 ui->logEntryBox->setModel(controller->logEntryModel());
43 logEntrySelected();
44
45 auto clearButton = ui->buttonBox->button(QDialogButtonBox::Discard);
46 connect(clearButton, &QPushButton::clicked, controller, &AuditLogUiController::clear);
47
48 setEnabled(true);
49}
50
51void AuditLogBrowserDialog::logEntrySelected()
52{
53 const auto dt = ui->logEntryBox->currentData().toDateTime();
54 ui->logEntryView->setText(m_controller->logEntry(dt));
55}
56
57#include "moc_auditlogbrowserdialog.cpp"
Dialog to browse audit log entries.
Widget/QtQuick-independent logic and data for the audit log browser UI.
QAbstractItemModel * logEntryModel
Returns a model listing all log entries.
Q_INVOKABLE QString logEntry(const QDateTime &dt) const
Returns a formatted text for display of the specified log entry.
void clear()
Delete all audit log entries.
Classes for integrating telemetry collection, survey targeting, and contribution encouragenemt and co...
void clicked(bool checked)
void activated(int index)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setEnabled(bool)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.