23 qCDebug(QGCFileDialogControllerLog) <<
"getFiles" << directoryPath << nameFilters;
25 QDir fileDir(directoryPath);
26 const QFileInfoList fileInfoList = fileDir.entryInfoList(nameFilters, QDir::Files, QDir::Name);
29 for (
const QFileInfo &fileInfo: fileInfoList) {
30 qCDebug(QGCFileDialogControllerLog) <<
"getFiles found" << fileInfo.fileName();
31 files << fileInfo.fileName();
44 QString firstFileExtention;
48 bool extensionFound =
true;
49 if (nameFilters.count()) {
50 extensionFound =
false;
51 for (
const QString& nameFilter: nameFilters) {
52 if (nameFilter.startsWith(
"*.")) {
53 const QString fileExtension = nameFilter.right(nameFilter.length() - 2);
54 if (fileExtension !=
"*") {
55 if (firstFileExtention.isEmpty()) {
56 firstFileExtention = fileExtension;
58 if (filename.endsWith(fileExtension)) {
59 extensionFound =
true;
63 }
else if (nameFilter !=
"*") {
64 qCWarning(QGCFileDialogControllerLog) <<
"unsupported name filter format" << nameFilter;
70 QString filenameWithExtension = filename;
71 if (!extensionFound) {
72 filenameWithExtension = QStringLiteral(
"%1.%2").arg(filename).arg(firstFileExtention);
75 return (directoryPath + QStringLiteral(
"/") + filenameWithExtension);
85#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
86 const QString defaultSavePath = SettingsManager::instance()->appSettings()->
savePath()->rawValueString();
87 if (fullFolderPath.startsWith(defaultSavePath)) {
88 const int lastDirSepIndex = fullFolderPath.lastIndexOf(QStringLiteral(
"/"));
89 return (QCoreApplication::applicationName() + QStringLiteral(
"/") + fullFolderPath.right(fullFolderPath.length() - lastDirSepIndex));
92 qCWarning(QGCFileDialogControllerLog) << Q_FUNC_INFO <<
"should only be used in mobile builds";
94 return fullFolderPath;