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

#include <QGCFileDialogController.h>

+ Inheritance diagram for QGCFileDialogController:
+ Collaboration diagram for QGCFileDialogController:

Signals

void fileImported (const QString &filePath)
 
void importFailed (const QString &errorMessage)
 

Public Member Functions

 QGCFileDialogController (QObject *parent=nullptr)
 
 ~QGCFileDialogController ()
 
Q_INVOKABLE void importFromNativePicker ()
 

Static Public Member Functions

static Q_INVOKABLE QStringList getFiles (const QString &directoryPath, const QStringList &nameFilters)
 Return all file in the specified path which match the specified extension.
 
static Q_INVOKABLE QString fullyQualifiedFilename (const QString &directoryPath, const QString &filename, const QStringList &nameFilters=QStringList())
 
static Q_INVOKABLE bool fileExists (const QString &filename)
 Check for file existence of specified fully qualified file name.
 
static Q_INVOKABLE void deleteFile (const QString &filename)
 Deletes the file specified by the fully qualified file name.
 
static Q_INVOKABLE QString urlToLocalFile (QUrl url)
 
static Q_INVOKABLE QString fullFolderPathToShortMobilePath (const QString &fullFolderPath)
 
Unit test file dialog shim

Native file dialogs cannot be driven from automated tests. Tests arm the shim with the result the next dialog should produce; QGCFileDialog.qml checks testHookArmed() in openForLoad()/openForSave() and, when armed, emits acceptedForLoad/acceptedForSave (or rejected) directly instead of opening the native dialog. Outside of unit test builds the hook is never armed and the QML check is a no-op.

static Q_INVOKABLE bool testHookArmed ()
 Returns true if a test result has been armed for the next dialog open.
 
static Q_INVOKABLE QString takeTestNextFile ()
 Returns the armed file path (empty for reject) and disarms the hook.
 

Detailed Description

Definition at line 7 of file QGCFileDialogController.h.

Constructor & Destructor Documentation

◆ QGCFileDialogController()

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

Definition at line 55 of file QGCFileDialogController.cc.

◆ ~QGCFileDialogController()

QGCFileDialogController::~QGCFileDialogController ( )

Definition at line 61 of file QGCFileDialogController.cc.

Member Function Documentation

◆ deleteFile()

void QGCFileDialogController::deleteFile ( const QString &  filename)
static

Deletes the file specified by the fully qualified file name.

Definition at line 123 of file QGCFileDialogController.cc.

◆ fileExists()

bool QGCFileDialogController::fileExists ( const QString &  filename)
static

Check for file existence of specified fully qualified file name.

Definition at line 82 of file QGCFileDialogController.cc.

◆ fileImported

void QGCFileDialogController::fileImported ( const QString &  filePath)
signal

Emitted when the selected file has been successfully imported to the Missions directory.

Parameters
filePathFully-qualified path of the imported file in the Missions directory.

◆ fullFolderPathToShortMobilePath()

QString QGCFileDialogController::fullFolderPathToShortMobilePath ( const QString &  fullFolderPath)
static

Important: Should only be used in mobile builds where default save location cannot be changed. Returns the standard QGC location portion of a fully qualified folder path. Example: "/Users/Don/Document/QGroundControl/Missions" returns "QGroundControl/Missions"

Definition at line 128 of file QGCFileDialogController.cc.

References SettingsManager::appSettings(), and SettingsManager::instance().

◆ fullyQualifiedFilename()

QString QGCFileDialogController::fullyQualifiedFilename ( const QString &  directoryPath,
const QString &  filename,
const QStringList &  nameFilters = QStringList() 
)
static

Returns the fully qualified file name from the specified parts. If filename has no file extension the first file extension is nameFilters is added to the filename.

Definition at line 87 of file QGCFileDialogController.cc.

◆ getFiles()

QStringList QGCFileDialogController::getFiles ( const QString &  directoryPath,
const QStringList &  nameFilters 
)
static

Return all file in the specified path which match the specified extension.

Definition at line 66 of file QGCFileDialogController.cc.

◆ importFailed

void QGCFileDialogController::importFailed ( const QString &  errorMessage)
signal

Emitted when the import operation fails.

Parameters
errorMessageHuman-readable description of the error.

Referenced by importFromNativePicker().

◆ importFromNativePicker()

void QGCFileDialogController::importFromNativePicker ( )

Opens Android's native file picker (ACTION_OPEN_DOCUMENT). On non-Android platforms this is a no-op.

Definition at line 166 of file QGCFileDialogController.cc.

References SettingsManager::appSettings(), importFailed(), SettingsManager::instance(), AppSettings::missionSavePath(), and AndroidInterface::openFileImportDialog().

◆ takeTestNextFile()

QString QGCFileDialogController::takeTestNextFile ( )
static

Returns the armed file path (empty for reject) and disarms the hook.

Definition at line 49 of file QGCFileDialogController.cc.

◆ testHookArmed()

bool QGCFileDialogController::testHookArmed ( )
static

Returns true if a test result has been armed for the next dialog open.

Definition at line 44 of file QGCFileDialogController.cc.

◆ urlToLocalFile()

QString QGCFileDialogController::urlToLocalFile ( QUrl  url)
static

Definition at line 142 of file QGCFileDialogController.cc.


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