File indexing completed on 2024-05-12 05:35:59
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 <QAbstractTableModel> 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_RELOCATABLE_TYPE); 0028 0029 class KCM_FIREWALL_CORE_EXPORT LogListModel : public QAbstractTableModel 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 LogItemModelColumns { 0040 SourceAddressColumn = 0, 0041 SourcePortColumn, 0042 DestinationAddressColumn, 0043 DestinationPortColumn, 0044 ProtocolColumn, 0045 InterfaceColumn, 0046 ActionColumn, 0047 TimeColumn, 0048 DateColumn, 0049 }; 0050 Q_ENUM(LogItemModelColumns) 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 int columnCount(const QModelIndex &parent) const override; 0058 0059 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0060 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0061 0062 virtual void addRawLogs(const QStringList &rawLogsList) = 0; 0063 0064 void appendLogData(const QList<LogData> &newData); 0065 0066 Q_SIGNALS: 0067 void countChanged(); 0068 0069 void showErrorMessage(const QString &message); 0070 0071 private: 0072 QList<LogData> m_logsData; 0073 bool m_busy = false; 0074 };