Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
recentcapturefiles_list_model.h
Go to the documentation of this file.
1
10#ifndef RECENTCAPTUREFILES_LIST_MODEL_H
11#define RECENTCAPTUREFILES_LIST_MODEL_H
12
13#include <QAbstractListModel>
14#include <QModelIndex>
15#include <QSortFilterProxyModel>
16#include <QStyledItemDelegate>
17
26class RecentCaptureFilesListModel : public QAbstractListModel
27{
28 Q_OBJECT
29public:
38
43 explicit RecentCaptureFilesListModel(QObject *parent = nullptr);
44
49
55 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
56
63 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
64
74 Qt::ItemFlags flags(const QModelIndex &index) const override;
75
76private slots:
81 void invalidateModel();
82};
83
84
92class RecentCaptureFilesReverseProxyModel : public QSortFilterProxyModel
93{
94 Q_OBJECT
95public:
100 explicit RecentCaptureFilesReverseProxyModel(QObject *parent = nullptr);
101
108 QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
109
116 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
117};
118
119
127class RecentCaptureFilesDelegate : public QStyledItemDelegate
128{
129 Q_OBJECT
130public:
135 explicit RecentCaptureFilesDelegate(QObject *parent = nullptr);
136
146 QString displayText(const QVariant &value, const QLocale &locale) const override;
147
154 void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override;
155
156private:
162 QString formatFileSize(qint64 bytes) const;
163};
164
165#endif // RECENTCAPTUREFILES_LIST_MODEL_H
Item delegate that formats recent file entries with human-readable size information.
Definition recentcapturefiles_list_model.h:128
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override
Initialises the style option for rendering, applying italic style to entries whose file is inaccessib...
Definition recentcapturefiles_list_model.cpp:165
QString displayText(const QVariant &value, const QLocale &locale) const override
Returns the display string for a recent file entry.
Definition recentcapturefiles_list_model.cpp:158
Qt model for displaying recent capture files.
Definition recentcapturefiles_list_model.h:27
~RecentCaptureFilesListModel()
Destroys the model.
Definition recentcapturefiles_list_model.cpp:30
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of recent capture file entries.
Definition recentcapturefiles_list_model.cpp:40
RecentFileRoles
Custom data roles for RecentCaptureFilesListModel.
Definition recentcapturefiles_list_model.h:33
@ AccessibleRole
Definition recentcapturefiles_list_model.h:36
@ FileSizeRole
Definition recentcapturefiles_list_model.h:35
@ FilenameRole
Definition recentcapturefiles_list_model.h:34
Proxy model that reverses row order for display (newest first).
Definition recentcapturefiles_list_model.h:93
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
Maps a proxy index to the corresponding source index by mirroring the row about the midpoint of the l...
Definition recentcapturefiles_list_model.cpp:107
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
Maps a source index to the corresponding proxy index by mirroring the row about the midpoint of the l...
Definition recentcapturefiles_list_model.cpp:121