Commit 01a0f72b authored by Martin Straka's avatar Martin Straka

Save attachments to predefined path - removed filedialog

parent 976ce35f
......@@ -23,10 +23,10 @@
#include <QDebug>
#include <QDesktopServices>
#include <QUrl>
#include <QFileInfo>
#include <QMimeDatabase>
#include <QFileDialog>
#include <QMimeType>
#include <QUrl>
#include <QQmlEngine> /* qmlRegisterType */
#include "src/common.h"
......@@ -602,25 +602,9 @@ void Files::sendAttachmentEmailZfo(const QVariant &attachModelVariant,
* @return Path to location where attachment can be stored.
*/
static
QString obtainStoragePath(void)
QString fileSaveLocation(void)
{
QString path(getBasePathBasedOnPlatform());
#if defined Q_OS_IOS
/* There is only one location where files or data can store
* permanently and share with Desktop.
* See: https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
*/
path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#else
/* Another platform can select destination for attachment saving. */
path = QFileDialog::getExistingDirectory(Q_NULLPTR,
QObject::tr("Select directory"), path,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
#endif
return path;
return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
}
/*!
......@@ -679,7 +663,7 @@ void Files::saveAttachmentsToDiskDb(const QString &userName,
}
QString path(obtainStoragePath());
QString path(fileSaveLocation());
QString destPath;
foreach (const FileDb::FileData &file, filelist) {
......@@ -710,7 +694,7 @@ void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant,
return;
}
QString path(obtainStoragePath());
QString path(fileSaveLocation());
QString destPath;
for (int row = 0; row < attachModel->rowCount(); ++row) {
......
......@@ -228,7 +228,6 @@ QString writeTemporaryFile(const QString &fileName, const QByteArray &data,
return fullName;
}
QString writeFileToDir(const QString &basePath, const QString &fileName,
qint64 msgId, const QByteArray &data, bool deleteOnError)
{
......@@ -236,13 +235,7 @@ QString writeFileToDir(const QString &basePath, const QString &fileName,
return QString();
}
QString filePath = basePath;
#if defined Q_OS_IOS
filePath = setFilePath(basePath, QString::number(msgId));
#else
Q_UNUSED(msgId);
#endif
QString filePath = setFilePath(basePath, QString::number(msgId));
return writeFile(filePath, fileName, data, deleteOnError);
}
......
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