Commit 685dabd5 authored by Martin Straka's avatar Martin Straka

Show short send file path in QML

parent 08695739
......@@ -622,7 +622,11 @@ Item {
font.bold: true
}
Text {
text: (rFilePath != "") ? rFilePath : qsTr("Local database")
text: if (rFilePath != "") {
iOS ? iCloudHelper.getShortSendFilePath(rFilePath) : rFilePath
} else {
qsTr("Local database")
}
color: datovkaPalette.mid
font.pointSize: textFontSizeSmall
}
......
......@@ -36,6 +36,7 @@
#include "ios/src/icloud_io.h"
#define ICLOUD_DATOVKA_CONTAINER_NAME "Datovka"
#define ICLOUD_FILE_CONTAINER_ID "iCloud~cz~nic~mobile-datovka/Documents"
#define SEND_FILE_PATH_PREFIX "Documents/Datovka"
#endif /* Q_OS_IOS */
#ifndef Q_OS_IOS
......@@ -235,6 +236,7 @@ QString ICloudHelper::copyFileFromCloud(const QString &cloudFilePath,
/*
* Retrun short iCloud path.
*/
static
QString getShortPathFromCloudPath(const QString &fileCloudPath)
{
#ifdef Q_OS_IOS
......@@ -242,7 +244,7 @@ QString getShortPathFromCloudPath(const QString &fileCloudPath)
// Get short file path from iCloud path
QString pattern(ICLOUD_FILE_CONTAINER_ID);
int pos = fileCloudPath.indexOf(pattern) + pattern.length();
return fileCloudPath.mid(pos);
return QUrl::fromPercentEncoding(fileCloudPath.mid(pos).toUtf8());
#else
Q_UNUSED(fileCloudPath);
......@@ -250,6 +252,24 @@ QString getShortPathFromCloudPath(const QString &fileCloudPath)
#endif
}
/*
* Retrun short local send file path.
*/
QString ICloudHelper::getShortSendFilePath(const QString &sandBoxFilePath)
{
#ifdef Q_OS_IOS
// Get short local send file path
QString pattern(SEND_FILE_PATH_PREFIX);
int pos = sandBoxFilePath.indexOf(pattern) + pattern.length();
return QUrl::fromPercentEncoding(sandBoxFilePath.mid(pos).toUtf8());
#else
Q_UNUSED(sandBoxFilePath);
return QString();
#endif
}
void ICloudHelper::setCloudFileModel(const QVariant &cloudFileModelVariant,
const QStringList &fileList)
{
......
......@@ -122,6 +122,15 @@ public:
Q_INVOKABLE
void openDocumentPickerController(void);
/*!
* @brief Retrun short local send file path.
*
* @param[in] sandBoxFilePath Send file path.
* @return Short path to app sandbox where send file was stored.
*/
Q_INVOKABLE
QString getShortSendFilePath(const QString &sandBoxFilePath);
signals:
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment