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:
34 FilenameRole = Qt::UserRole,
35 FileSizeRole,
36 AccessibleRole
37 };
38
39 explicit RecentCaptureFilesListModel(QObject *parent = nullptr);
41
42 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
43 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
44 Qt::ItemFlags flags(const QModelIndex &index) const override;
45
46private slots:
47 void invalidateModel();
48};
49
56class RecentCaptureFilesReverseProxyModel : public QSortFilterProxyModel
57{
58 Q_OBJECT
59public:
60 explicit RecentCaptureFilesReverseProxyModel(QObject *parent = nullptr);
61
62 QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
63 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
64};
65
72class RecentCaptureFilesDelegate : public QStyledItemDelegate
73{
74 Q_OBJECT
75public:
76 explicit RecentCaptureFilesDelegate(QObject *parent = nullptr);
77
78 QString displayText(const QVariant &value, const QLocale &locale) const override;
79 void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override;
80
81private:
82 QString formatFileSize(qint64 bytes) const;
83};
84
85#endif // RECENTCAPTUREFILES_LIST_MODEL_H
Item delegate that formats recent file entries with size info.
Definition recentcapturefiles_list_model.h:73
Qt model for displaying recent capture files.
Definition recentcapturefiles_list_model.h:27
RecentFileRoles
Custom data roles for RecentCaptureFilesListModel.
Definition recentcapturefiles_list_model.h:33
Proxy model that reverses row order for display (newest first).
Definition recentcapturefiles_list_model.h:57