Pimcommon

customlogwidget.h
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#pragma once
7
8#include "pimcommon_export.h"
9#include <QListWidget>
10#include <QStyledItemDelegate>
11
12class QTextDocument;
13
14namespace PimCommon
15{
16class LogItemDelegate : public QStyledItemDelegate
17{
19public:
20 explicit LogItemDelegate(QObject *parent);
21 ~LogItemDelegate() override;
22
23 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
24 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
25 [[nodiscard]] QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override;
26
27private:
28 QTextDocument *document(const QStyleOptionViewItem &option, const QModelIndex &index) const;
29};
30
31class PIMCOMMON_EXPORT CustomLogWidget : public QListWidget
32{
33public:
34 explicit CustomLogWidget(QWidget *parent = nullptr);
35 ~CustomLogWidget() override;
36
37 void addInfoLogEntry(const QString &log);
38 void addErrorLogEntry(const QString &log);
39 void addTitleLogEntry(const QString &log);
40 void addEndLineLogEntry();
41
42 [[nodiscard]] QString toHtml() const;
43 [[nodiscard]] QString toPlainText() const;
44 [[nodiscard]] bool isEmpty() const;
45
46private:
47 enum ItemType {
48 ItemLogType = Qt::UserRole + 1,
49 };
50
51 enum LogType {
52 Title = 0,
53 Error,
54 Info,
55 EndLine,
56 };
57};
58}
ItemType
Trait::String toHtml(std::shared_ptr< Document< Trait > > doc, bool wrapInBodyTag=true, const typename Trait::String &hrefForRefBackImage={}, bool wrapInArticle=true)
folderdialogacltab.h
Q_OBJECTQ_OBJECT
QObject * parent() const const
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.