Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
RecentCaptureFilesListModel Class Reference

Qt model for displaying recent capture files. More...

#include <recentcapturefiles_list_model.h>

Inheritance diagram for RecentCaptureFilesListModel:

Public Types

enum  RecentFileRoles { FilenameRole = Qt::UserRole , FileSizeRole , AccessibleRole }
 Custom data roles for RecentCaptureFilesListModel. More...
 

Public Member Functions

 RecentCaptureFilesListModel (QObject *parent=nullptr)
 Constructs the model and connects it to WorkspaceState change notifications.
 
 ~RecentCaptureFilesListModel ()
 Destroys the model.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of recent capture file entries.
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Returns data for the given index and role.
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns item flags for the given index.
 

Detailed Description

Qt model for displaying recent capture files.

This is a thin wrapper over WorkspaceState — it does not store data, but provides a Qt model interface for views.

Thread safety: Assumes single-threaded access (UI thread only).

Member Enumeration Documentation

◆ RecentFileRoles

Custom data roles for RecentCaptureFilesListModel.

Enumerator
FilenameRole 

QString — absolute path of the capture file.

FileSizeRole 

qint64 — file size in bytes; -1 if unknown.

AccessibleRole 

bool — true if the file exists and is readable.

Constructor & Destructor Documentation

◆ RecentCaptureFilesListModel()

RecentCaptureFilesListModel::RecentCaptureFilesListModel ( QObject *  parent = nullptr)
explicit

Constructs the model and connects it to WorkspaceState change notifications.

Parameters
parentOptional parent QObject.

Member Function Documentation

◆ data()

QVariant RecentCaptureFilesListModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

Returns data for the given index and role.

Parameters
indexModel index of the requested item.
roleQt item data role or a RecentFileRoles value.
Returns
QVariant with the requested data, or an invalid QVariant if unavailable.

◆ flags()

Qt::ItemFlags RecentCaptureFilesListModel::flags ( const QModelIndex &  index) const
override

Returns item flags for the given index.

Inaccessible files are returned as non-enabled so they cannot be opened.

Parameters
indexModel index to query.
Returns
Qt::ItemIsEnabled | Qt::ItemIsSelectable for accessible files; Qt::ItemIsSelectable only for inaccessible ones.

◆ rowCount()

int RecentCaptureFilesListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of recent capture file entries.

Parameters
parentUnused; pass a default QModelIndex for list models.
Returns
Number of entries in WorkspaceState's recent file list.

The documentation for this class was generated from the following files: