|
Wireshark 4.7.0
The Wireshark network protocol analyzer
|
Table model that manages the full set of configuration profiles, supporting creation, duplication, deletion, import, and export. More...
#include <profile_model.h>
Public Types | |
| enum | { COL_NAME = 0 , COL_TYPE , COL_AUTO_SWITCH_FILTER , _LAST_ENTRY } |
| Column index constants for the profile table. More... | |
| enum | { DATA_IS_DEFAULT = Qt::UserRole , DATA_IS_GLOBAL } |
| Custom Qt::UserRole data keys returned by data(). More... | |
Public Member Functions | |
| ProfileModel (QObject *parent=Q_NULLPTR) | |
| Constructs a ProfileModel and populates it from the current profile directories. | |
| virtual | ~ProfileModel () |
| Destroys the model and frees all ProfileItem instances. | |
| void | fillTable () |
| (Re-)populates the model from the on-disk profile directories. | |
| virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| Returns the number of profile rows. | |
| virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const |
Returns the number of columns (always _LAST_ENTRY). | |
| virtual QVariant | data (const QModelIndex &idx, int role=Qt::DisplayRole) const |
| Returns data for the given index and role. | |
| virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) |
| Sets data for an editable cell (profile name or auto-switch filter). | |
| virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
| Returns the header label for the given section. | |
| virtual Qt::ItemFlags | flags (const QModelIndex &index) const |
| Returns the item flags for the given index. | |
| void | deleteEntries (QModelIndexList idcs) |
| Marks the profiles at the given indices for deletion. | |
| bool | restoreEntries (QModelIndexList idcs) |
| Clears the deletion flag on the profiles at the given indices. | |
| int | findByName (const QString &name) |
| Returns the row index of the first profile whose name matches exactly. | |
| QModelIndex | addNewProfile (QString name) |
| Adds a new empty personal profile with the given name. | |
| QModelIndex | duplicateEntry (QModelIndex idx, ProfileItem::StatusType status=ProfileItem::StatusType::Copy) |
Creates a duplicate of the profile at idx. | |
| QModelIndex | activeProfile () const |
| Returns the model index of the currently active (in-use) profile row. | |
| bool | userProfilesExist () const |
| Returns whether any editable (non-global, non-default) profiles exist. | |
| bool | isDataValid (QString &err) |
| Validates all pending profile changes for conflicts and illegal names. | |
| void | importProfilesFromDir (QString filename, int &skippedCnt, QStringList &importList, bool fromZip=false) |
| Imports profiles from a directory (or an extracted ZIP staging area). | |
| QList< int > | findAllByNameAndVisibility (const QString &name, bool isGlobal=false, bool searchReference=false) const |
| Finds all profiles matching the given name and global-scope flag. | |
| bool | checkDuplicate (const QModelIndex &index, bool isOriginalToDuplicate=false) const |
Checks whether the profile at index has a name collision with another entry. | |
| void | applyChanges () |
| Applies all pending changes (additions, renames, copies, deletions) to the on-disk profile directories and updates libwireshark's profile list. | |
| const ProfileItem * | getCurrentProfile () const |
| Returns the ProfileItem representing the profile that was active when the model was constructed. | |
| const ProfileItem * | getProfile (int index) const |
| Returns the ProfileItem at the given flat list index. | |
| const ProfileItem * | getPersonalProfile (const QString &name) |
| Finds a personal (non-global) profile by name. | |
| QVariant | dataPath (const QModelIndex &idx, QString &profilePath) const |
| Returns display data for a cell together with the profile's filesystem path. | |
Static Public Member Functions | |
| static bool | checkNameValidity (QString name, QString &msg) |
| Validates a candidate profile name for illegal characters and reserved names. | |
Public Attributes | |
| enum ProfileModel:: { ... } | columns_ |
| Column index constants for the profile table. | |
| enum ProfileModel:: { ... } | data_values_ |
| Custom Qt::UserRole data keys returned by data(). | |
Protected Member Functions | |
| QModelIndex | addNewProfile (QString name, QString reference, bool isGlobal=false, bool fromGlobal=false, bool isImport=false) |
| Internal helper that inserts a new ProfileItem with explicit field values. | |
Static Protected Member Functions | |
| static QString | illegalCharacters () |
| Returns the set of characters that are not permitted in profile names. | |
Table model that manages the full set of configuration profiles, supporting creation, duplication, deletion, import, and export.
| anonymous enum |
| anonymous enum |
|
explicit |
Constructs a ProfileModel and populates it from the current profile directories.
| parent | Optional parent QObject. |
| QModelIndex ProfileModel::activeProfile | ( | ) | const |
Returns the model index of the currently active (in-use) profile row.
| QModelIndex ProfileModel::addNewProfile | ( | QString | name | ) |
Adds a new empty personal profile with the given name.
| name | Display name for the new profile. |
|
protected |
Internal helper that inserts a new ProfileItem with explicit field values.
| name | Display name. |
| reference | Original/reference name for on-disk directory resolution. |
| isGlobal | true for global profiles. |
| fromGlobal | true if copied from a global profile. |
| isImport | true if imported from an external source. |
| bool ProfileModel::checkDuplicate | ( | const QModelIndex & | index, |
| bool | isOriginalToDuplicate = false |
||
| ) | const |
Checks whether the profile at index has a name collision with another entry.
| index | Model index of the profile to check. |
| isOriginalToDuplicate | true when checking whether the source of a pending duplication would cause a conflict. |
true if a duplicate name exists.
|
static |
Validates a candidate profile name for illegal characters and reserved names.
| name | Display name to validate. |
| msg | Populated with a human-readable reason if the name is invalid. |
true if the name is acceptable.
|
virtual |
Returns the number of columns (always _LAST_ENTRY).
| parent | Unused. |
columns_ enum.
|
virtual |
Returns data for the given index and role.
| idx | Model index of the requested cell. |
| role | Qt item data role. |
| QVariant ProfileModel::dataPath | ( | const QModelIndex & | idx, |
| QString & | profilePath | ||
| ) | const |
Returns display data for a cell together with the profile's filesystem path.
| idx | Model index of the cell to query. |
| profilePath | Set to the filesystem path of the profile at idx. |
| void ProfileModel::deleteEntries | ( | QModelIndexList | idcs | ) |
Marks the profiles at the given indices for deletion.
| idcs | List of model indices to delete. |
| QModelIndex ProfileModel::duplicateEntry | ( | QModelIndex | idx, |
| ProfileItem::StatusType | status = ProfileItem::StatusType::Copy |
||
| ) |
Creates a duplicate of the profile at idx.
| idx | Index of the profile to copy. |
| status | StatusType to assign to the duplicate (default: Copy). |
| void ProfileModel::fillTable | ( | ) |
(Re-)populates the model from the on-disk profile directories.
Clears all existing items, then walks both the personal and global profile directories and adds a ProfileItem for each discovered profile.
| QList< int > ProfileModel::findAllByNameAndVisibility | ( | const QString & | name, |
| bool | isGlobal = false, |
||
| bool | searchReference = false |
||
| ) | const |
Finds all profiles matching the given name and global-scope flag.
| name | Name to match. |
| isGlobal | If true, restrict the search to global profiles. |
| searchReference | If true, also match against the reference (original) name. |
| int ProfileModel::findByName | ( | const QString & | name | ) |
Returns the row index of the first profile whose name matches exactly.
| name | Profile name to search for. |
-1 if not found.
|
virtual |
Returns the item flags for the given index.
Global and default profiles are not editable; personal profiles support Qt::ItemIsEditable in the name and auto-switch-filter columns.
| index | Model index to query. |
|
inline |
Returns the ProfileItem representing the profile that was active when the model was constructed.
nullptr if unknown. | const ProfileItem * ProfileModel::getPersonalProfile | ( | const QString & | name | ) |
Finds a personal (non-global) profile by name.
| name | Display name to search for. |
nullptr if not found.
|
inline |
Returns the ProfileItem at the given flat list index.
| index | Zero-based index into the internal profile list. |
|
virtual |
Returns the header label for the given section.
| section | Column (horizontal) or row (vertical) index. |
| orientation | Header orientation. |
| role | Qt item data role. |
|
staticprotected |
Returns the set of characters that are not permitted in profile names.
| void ProfileModel::importProfilesFromDir | ( | QString | filename, |
| int & | skippedCnt, | ||
| QStringList & | importList, | ||
| bool | fromZip = false |
||
| ) |
Imports profiles from a directory (or an extracted ZIP staging area).
| filename | Path to the source directory. |
| skippedCnt | Set to the number of profiles skipped due to conflicts. |
| importList | Populated with the names of successfully imported profiles. |
| fromZip | true when the directory is a temporary ZIP extraction; affects name sanitisation. |
| bool ProfileModel::isDataValid | ( | QString & | err | ) |
Validates all pending profile changes for conflicts and illegal names.
| err | Populated with a human-readable error message on failure. |
true if all data is valid and changes can be applied. | bool ProfileModel::restoreEntries | ( | QModelIndexList | idcs | ) |
Clears the deletion flag on the profiles at the given indices.
| idcs | List of model indices to restore. |
true if at least one entry was successfully restored.
|
virtual |
Returns the number of profile rows.
| parent | Unused; pass a default QModelIndex for table models. |
|
virtual |
Sets data for an editable cell (profile name or auto-switch filter).
| index | Model index of the cell to modify. |
| value | New value to assign. |
| role | Must be Qt::EditRole. |
true if the value was successfully applied. | bool ProfileModel::userProfilesExist | ( | ) | const |
Returns whether any editable (non-global, non-default) profiles exist.
true if at least one personal profile is present.