QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCArchiveModel Class Reference

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")
 

Detailed Description

List model for archive contents, suitable for QML ListView binding.

Provides natural sorting, filtering by type, and lazy loading support.

Usage in QML:

import QGroundControl.Utilities
ListView {
model: QGCArchiveModel {
archivePath: "/path/to/archive.zip"
}
delegate: ItemDelegate {
text: model.name
icon.name: model.isDirectory ? "folder" : "file"
}
}

Definition at line 29 of file QGCArchiveModel.h.

Member Enumeration Documentation

◆ FilterMode

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.

◆ Role

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

Enumerator
NameRole 

Entry name/path (QString)

SizeRole 

Uncompressed size in bytes (qint64)

ModifiedRole 

Last modified date (QDateTime)

IsDirectoryRole 

Whether entry is a directory (bool)

PermissionsRole 

Unix permissions (quint32)

FileNameRole 

Just the filename without path (QString)

DirectoryRole 

Parent directory path (QString)

FormattedSizeRole 

Human-readable size string (QString)

Definition at line 64 of file QGCArchiveModel.h.

Constructor & Destructor Documentation

◆ QGCArchiveModel()

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

Definition at line 14 of file QGCArchiveModel.cc.

◆ ~QGCArchiveModel()

QGCArchiveModel::~QGCArchiveModel ( )
overridedefault

Member Function Documentation

◆ archivePath()

QString QGCArchiveModel::archivePath ( ) const
inline

Definition at line 88 of file QGCArchiveModel.h.

◆ archivePathChanged

void QGCArchiveModel::archivePathChanged ( )
signal

Referenced by setArchivePath().

◆ archiveUrl()

QUrl QGCArchiveModel::archiveUrl ( ) const
inline

Definition at line 91 of file QGCArchiveModel.h.

◆ clear()

void QGCArchiveModel::clear ( )

Clear the model and reset all properties.

Definition at line 134 of file QGCArchiveModel.cc.

References countChanged(), directoryCountChanged(), fileCountChanged(), and totalSizeChanged().

◆ contains()

bool QGCArchiveModel::contains ( const QString &  fileName) const

Check if a file exists in the archive.

Definition at line 191 of file QGCArchiveModel.cc.

◆ count()

int QGCArchiveModel::count ( ) const
inline

Definition at line 94 of file QGCArchiveModel.h.

◆ countChanged

void QGCArchiveModel::countChanged ( )
signal

Referenced by clear().

◆ data()

◆ directoryCount()

int QGCArchiveModel::directoryCount ( ) const
inline

Definition at line 96 of file QGCArchiveModel.h.

◆ directoryCountChanged

void QGCArchiveModel::directoryCountChanged ( )
signal

Referenced by clear().

◆ errorString()

QString QGCArchiveModel::errorString ( ) const
inline

Definition at line 99 of file QGCArchiveModel.h.

◆ errorStringChanged

void QGCArchiveModel::errorStringChanged ( )
signal

◆ fileCount()

int QGCArchiveModel::fileCount ( ) const
inline

Definition at line 95 of file QGCArchiveModel.h.

◆ fileCountChanged

void QGCArchiveModel::fileCountChanged ( )
signal

Referenced by clear().

◆ filterMode()

FilterMode QGCArchiveModel::filterMode ( ) const
inline

Definition at line 101 of file QGCArchiveModel.h.

◆ filterModeChanged

void QGCArchiveModel::filterModeChanged ( )
signal

Referenced by setFilterMode().

◆ formatSize()

QString QGCArchiveModel::formatSize ( qint64  bytes)
static

Format bytes as human-readable string (e.g., "1.5 MB")

Definition at line 205 of file QGCArchiveModel.cc.

Referenced by data(), and get().

◆ get()

◆ loading()

bool QGCArchiveModel::loading ( ) const
inline

Definition at line 98 of file QGCArchiveModel.h.

◆ loadingChanged

void QGCArchiveModel::loadingChanged ( )
signal

◆ loadingComplete

void QGCArchiveModel::loadingComplete ( bool  success)
signal

Emitted when archive loading completes (success or failure)

◆ refresh()

void QGCArchiveModel::refresh ( )

Reload archive contents (useful after external changes)

Definition at line 129 of file QGCArchiveModel.cc.

◆ roleNames()

QHash< int, QByteArray > QGCArchiveModel::roleNames ( ) const
override

◆ rowCount()

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

Definition at line 57 of file QGCArchiveModel.cc.

◆ setArchivePath()

void QGCArchiveModel::setArchivePath ( const QString &  path)

Definition at line 21 of file QGCArchiveModel.cc.

References archivePathChanged().

Referenced by FTPController::browseArchive(), and setArchiveUrl().

◆ setArchiveUrl()

void QGCArchiveModel::setArchiveUrl ( const QUrl &  url)

◆ setFilterMode()

void QGCArchiveModel::setFilterMode ( FilterMode  mode)

Definition at line 45 of file QGCArchiveModel.cc.

References filterModeChanged().

◆ totalSize()

qint64 QGCArchiveModel::totalSize ( ) const
inline

Definition at line 97 of file QGCArchiveModel.h.

◆ totalSizeChanged

void QGCArchiveModel::totalSizeChanged ( )
signal

Referenced by clear().


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