File indexing completed on 2024-04-28 16:52:16
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 // SPDX-FileCopyrightText: 2011 Craig Drummond <craig.p.drummond@gmail.com> 0003 // SPDX-FileCopyrightText: 2018 Alexis Lopes Zubeta <contact@azubieta.net> 0004 // SPDX-FileCopyrightText: 2020 Tomaz Canabrava <tcanabrava@kde.org> 0005 /* 0006 * UFW KControl Module 0007 */ 0008 0009 #pragma once 0010 0011 #include <kcm_firewall_core_export.h> 0012 0013 #include <QAbstractListModel> 0014 #include <QVariantList> 0015 0016 struct LogData { 0017 QString sourceAddress; 0018 QString sourcePort; 0019 QString destinationAddress; 0020 QString destinationPort; 0021 QString protocol; 0022 QString interface; 0023 QString action; 0024 QString time; 0025 QString date; 0026 }; 0027 Q_DECLARE_TYPEINFO(LogData, Q_MOVABLE_TYPE); 0028 0029 class KCM_FIREWALL_CORE_EXPORT LogListModel : public QAbstractListModel 0030 { 0031 Q_OBJECT 0032 0033 Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) 0034 Q_PROPERTY(int count READ rowCount NOTIFY countChanged) 0035 0036 public: 0037 explicit LogListModel(QObject *parent = nullptr); 0038 0039 enum LogItemModelRoles { 0040 SourceAddressRole = Qt::UserRole + 1, 0041 SourcePortRole, 0042 DestinationAddressRole, 0043 DestinationPortRole, 0044 ProtocolRole, 0045 InterfaceRole, 0046 ActionRole, 0047 TimeRole, 0048 DateRole, 0049 }; 0050 Q_ENUM(LogItemModelRoles) 0051 0052 bool busy() const; 0053 void setBusy(bool busy); 0054 Q_SIGNAL void busyChanged(); 0055 0056 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0057 0058 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0059 0060 virtual void addRawLogs(const QStringList &rawLogsList) = 0; 0061 0062 void appendLogData(const QVector<LogData> &newData); 0063 0064 Q_SIGNALS: 0065 void countChanged(); 0066 0067 void showErrorMessage(const QString &message); 0068 0069 protected: 0070 QHash<int, QByteArray> roleNames() const override; 0071 0072 private: 0073 QVector<LogData> m_logsData; 0074 bool m_busy = false; 0075 };