|
QGroundControl
Ground Control Station for MAVLink Drones
|
List model for archive contents, suitable for QML ListView binding. More...
#include <QGCArchiveModel.h>
Inheritance diagram for QGCArchiveModel:
Collaboration diagram for QGCArchiveModel:Public Types | |
| enum | Role { NameRole = Qt::UserRole + 1 , SizeRole , ModifiedRole , IsDirectoryRole , PermissionsRole , FileNameRole , DirectoryRole , FormattedSizeRole } |
| Path to the archive file to display (QString) More... | |
| enum | FilterMode { AllEntries , FilesOnly , DirectoriesOnly } |
| Filter modes for showing subsets of entries. More... | |
Signals | |
| void | archivePathChanged () |
| void | countChanged () |
| void | fileCountChanged () |
| void | directoryCountChanged () |
| void | totalSizeChanged () |
| void | loadingChanged () |
| void | errorStringChanged () |
| void | filterModeChanged () |
| void | loadingComplete (bool success) |
| Emitted when archive loading completes (success or failure) | |
Public Member Functions | |
| QGCArchiveModel (QObject *parent=nullptr) | |
| ~QGCArchiveModel () override | |
| QString | archivePath () const |
| void | setArchivePath (const QString &path) |
| QUrl | archiveUrl () const |
| void | setArchiveUrl (const QUrl &url) |
| int | count () const |
| int | fileCount () const |
| int | directoryCount () const |
| qint64 | totalSize () const |
| bool | loading () const |
| QString | errorString () const |
| FilterMode | filterMode () const |
| void | setFilterMode (FilterMode mode) |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| QHash< int, QByteArray > | roleNames () const override |
| Q_INVOKABLE void | refresh () |
| Reload archive contents (useful after external changes) | |
| Q_INVOKABLE void | clear () |
| Clear the model and reset all properties. | |
| Q_INVOKABLE QVariantMap | get (int index) const |
| Get entry at index (for C++ usage) | |
| Q_INVOKABLE bool | contains (const QString &fileName) const |
| Check if a file exists in the archive. | |
Static Public Member Functions | |
| static Q_INVOKABLE QString | formatSize (qint64 bytes) |
| Format bytes as human-readable string (e.g., "1.5 MB") | |
List model for archive contents, suitable for QML ListView binding.
Provides natural sorting, filtering by type, and lazy loading support.
Usage in QML:
Definition at line 29 of file QGCArchiveModel.h.
Filter modes for showing subsets of entries.
| Enumerator | |
|---|---|
| AllEntries | Show all files and directories. |
| FilesOnly | Show only files (no directories) |
| DirectoriesOnly | Show only directories. |
Definition at line 77 of file QGCArchiveModel.h.
Path to the archive file to display (QString)
URL to the archive file (QUrl convenience for QML file dialogs) Supports file://, qrc:/, and plain local paths Number of entries in the archive (files + directories) Number of files in the archive (excludes directories) Number of directories in the archive Total uncompressed size of all files in bytes Whether the model is currently loading archive contents Error message if loading failed (empty on success) Filter to show only files, only directories, or all entries Roles for accessing entry data from QML/delegates
Definition at line 64 of file QGCArchiveModel.h.
|
explicit |
Definition at line 14 of file QGCArchiveModel.cc.
|
overridedefault |
|
inline |
Definition at line 88 of file QGCArchiveModel.h.
|
signal |
Referenced by setArchivePath().
|
inline |
Definition at line 91 of file QGCArchiveModel.h.
| void QGCArchiveModel::clear | ( | ) |
Clear the model and reset all properties.
Definition at line 134 of file QGCArchiveModel.cc.
References countChanged(), directoryCountChanged(), fileCountChanged(), and totalSizeChanged().
| bool QGCArchiveModel::contains | ( | const QString & | fileName | ) | const |
Check if a file exists in the archive.
Definition at line 191 of file QGCArchiveModel.cc.
|
inline |
Definition at line 94 of file QGCArchiveModel.h.
|
signal |
Referenced by clear().
|
override |
Definition at line 65 of file QGCArchiveModel.cc.
References DirectoryRole, FileNameRole, formatSize(), FormattedSizeRole, QGCCompression::ArchiveEntry::isDirectory, IsDirectoryRole, QGCCompression::ArchiveEntry::modified, ModifiedRole, QGCCompression::ArchiveEntry::name, NameRole, QGCCompression::ArchiveEntry::permissions, PermissionsRole, QGCCompression::ArchiveEntry::size, and SizeRole.
|
inline |
Definition at line 96 of file QGCArchiveModel.h.
|
signal |
Referenced by clear().
|
inline |
Definition at line 99 of file QGCArchiveModel.h.
|
signal |
|
inline |
Definition at line 95 of file QGCArchiveModel.h.
|
signal |
Referenced by clear().
|
inline |
Definition at line 101 of file QGCArchiveModel.h.
|
signal |
Referenced by setFilterMode().
|
static |
Format bytes as human-readable string (e.g., "1.5 MB")
Definition at line 205 of file QGCArchiveModel.cc.
| QVariantMap QGCArchiveModel::get | ( | int | index | ) | const |
Get entry at index (for C++ usage)
Definition at line 161 of file QGCArchiveModel.cc.
References formatSize(), QGCCompression::ArchiveEntry::isDirectory, QGCCompression::ArchiveEntry::modified, QGCCompression::ArchiveEntry::name, QGCCompression::ArchiveEntry::permissions, and QGCCompression::ArchiveEntry::size.
|
inline |
Definition at line 98 of file QGCArchiveModel.h.
|
signal |
|
signal |
Emitted when archive loading completes (success or failure)
| void QGCArchiveModel::refresh | ( | ) |
Reload archive contents (useful after external changes)
Definition at line 129 of file QGCArchiveModel.cc.
|
override |
Definition at line 114 of file QGCArchiveModel.cc.
References DirectoryRole, FileNameRole, FormattedSizeRole, IsDirectoryRole, ModifiedRole, NameRole, PermissionsRole, and SizeRole.
|
override |
Definition at line 57 of file QGCArchiveModel.cc.
| void QGCArchiveModel::setArchivePath | ( | const QString & | path | ) |
Definition at line 21 of file QGCArchiveModel.cc.
References archivePathChanged().
Referenced by FTPController::browseArchive(), and setArchiveUrl().
| void QGCArchiveModel::setArchiveUrl | ( | const QUrl & | url | ) |
Definition at line 33 of file QGCArchiveModel.cc.
References QGCFileHelper::isLocalPath(), setArchivePath(), and QGCFileHelper::toLocalPath().
| void QGCArchiveModel::setFilterMode | ( | FilterMode | mode | ) |
Definition at line 45 of file QGCArchiveModel.cc.
References filterModeChanged().
|
inline |
Definition at line 97 of file QGCArchiveModel.h.
|
signal |
Referenced by clear().