DtRecursiveFileModel is a Qt model class that provides a list of files to QML list views. It manages a collection of file entries and exposes them through the Qt model-view framework, making them accessible to the UI.
#include <vreStartPage.h>
|
| | DtRecursiveFileModel (QObject *parent=0) |
| |
| virtual void | addFile (const DtFileEntry &entry) |
| |
| virtual void | clear () |
| |
| virtual void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override |
| |
| virtual bool | removeRows (int row, int column=0, const QModelIndex &parent=QModelIndex()) override |
| |
| virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| |
| virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| |
| virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
| |
|
| virtual QHash< int, QByteArray > | roleNames () const override |
| |
◆ FileModelRoles
Enumeration of data roles for the model.
Defines the custom roles used to access different aspects of the file entries.
| Enumerator |
|---|
| FileNameRole | Role for accessing the file name.
|
| FilePathRole | Role for accessing the file path.
|
◆ DtRecursiveFileModel()
| makVre::DtRecursiveFileModel::DtRecursiveFileModel |
( |
QObject * | parent = 0 | ) |
|
Constructor.
- Parameters
-
| parent | Optional parent QObject for memory management |
Creates a new empty file model.
◆ addFile()
| virtual void makVre::DtRecursiveFileModel::addFile |
( |
const DtFileEntry & | entry | ) |
|
|
virtual |
Adds a file entry to the model.
- Parameters
-
Adds a new file entry to the end of the model's file list.
◆ clear()
| virtual void makVre::DtRecursiveFileModel::clear |
( |
| ) |
|
|
virtual |
Clears all file entries from the model.
Removes all file entries from the model, leaving it empty.
◆ sort()
| virtual void makVre::DtRecursiveFileModel::sort |
( |
int | column, |
|
|
Qt::SortOrder | order = Qt::AscendingOrder ) |
|
overridevirtual |
Sorts the file entries.
- Parameters
-
| column | Column index to sort by (ignored in this implementation) |
| order | Sort order (ascending or descending) |
Sorts the file entries case-insensitively using QCollator. This ensures proper alphabetical sorting regardless of locale.
◆ removeRows()
| virtual bool makVre::DtRecursiveFileModel::removeRows |
( |
int | row, |
|
|
int | column = 0, |
|
|
const QModelIndex & | parent = QModelIndex() ) |
|
overridevirtual |
Removes rows from the model.
- Parameters
-
| row | Starting row index |
| column | Number of columns to remove (ignored in this implementation) |
| parent | Parent model index (ignored in this implementation) |
- Returns
- True if rows were successfully removed
Implementation of QAbstractItemModel::removeRows for removing file entries.
◆ rowCount()
| virtual int makVre::DtRecursiveFileModel::rowCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
overridevirtual |
Gets the number of rows in the model.
- Parameters
-
| parent | Parent model index (ignored in this implementation) |
- Returns
- Number of file entries in the model
Implementation of QAbstractItemModel::rowCount that returns the number of file entries.
◆ data()
| virtual QVariant makVre::DtRecursiveFileModel::data |
( |
const QModelIndex & | index, |
|
|
int | role = Qt::DisplayRole ) const |
|
overridevirtual |
Gets data for a specific index and role.
- Parameters
-
| index | Model index to get data for |
| role | Data role to retrieve |
- Returns
- Requested data as a QVariant
Implementation of QAbstractItemModel::data that provides access to file entry data.
◆ setData()
| virtual bool makVre::DtRecursiveFileModel::setData |
( |
const QModelIndex & | index, |
|
|
const QVariant & | value, |
|
|
int | role ) |
|
overridevirtual |
Sets data for a specific index and role.
- Parameters
-
| index | Model index to set data for |
| value | New value to set |
| role | Data role to set |
- Returns
- True if data was successfully set
Implementation of QAbstractItemModel::setData for updating file entry data.
◆ roleNames()
| virtual QHash< int, QByteArray > makVre::DtRecursiveFileModel::roleNames |
( |
| ) |
const |
|
overrideprotectedvirtual |
Gets the mapping from role IDs to role names.
- Returns
- Hash mapping role IDs to their name strings
Implementation of QAbstractItemModel::roleNames that provides the mapping from role enum values to the string names used in QML.
◆ myFiles
| QList<DtFileEntry> makVre::DtRecursiveFileModel::myFiles |
|
protected |
List of file entries in the model.
Storage for all the file entries managed by this model.
The documentation for this class was generated from the following file: