Commit eb90d039 authored by Karel Slaný's avatar Karel Slaný

Merge branch 'fix-open-attachment' into 'develop'

Fixed attachment open in the create a new message page

Closes #139

See merge request !143
parents d49a61e6 606f9b06
...@@ -554,7 +554,7 @@ Item { ...@@ -554,7 +554,7 @@ Item {
"fromLocalDb": false, "fromLocalDb": false,
"rawZfoContent": files.rawFileContent(rFilePath)}) "rawZfoContent": files.rawFileContent(rFilePath)})
} else { } else {
files.openAttachmentFromPath(rFilePath) files.openAttachment(getFileNameFromPath(rFilePath), files.rawFileContent(rFilePath))
} }
} }
} }
......
...@@ -64,19 +64,6 @@ Files::Files(QObject *parent) ...@@ -64,19 +64,6 @@ Files::Files(QObject *parent)
{ {
} }
void Files::attachmentSavingNotification(const QString &destPath)
{
QFileInfo fi(destPath);
Dialogues::errorMessage(
!destPath.isEmpty() ? Dialogues::INFORMATION : Dialogues::CRITICAL,
tr("Attachment saving"),
!destPath.isEmpty() ? tr("Attachments have been saved.") :
tr("Attachments have not been saved!"),
!destPath.isEmpty() ?
tr("Path: '%1'").arg(fi.absolutePath()) : QString());
}
void Files::deleteExpiredFilesFromDbs(int days) void Files::deleteExpiredFilesFromDbs(int days)
{ {
debugFuncCall(); debugFuncCall();
...@@ -255,7 +242,7 @@ void Files::openAttachmentFromPath(const QString &filePath) ...@@ -255,7 +242,7 @@ void Files::openAttachmentFromPath(const QString &filePath)
return; return;
} }
if (isZfoFile(filePath)) { if (Q_UNLIKELY(isZfoFile(filePath))) {
/* Don't open zfo files from here. */ /* Don't open zfo files from here. */
logErrorNL("%s", "The application should open ZFO files by itself."); logErrorNL("%s", "The application should open ZFO files by itself.");
Q_ASSERT(0); Q_ASSERT(0);
...@@ -744,7 +731,7 @@ void Files::saveMsgFilesToDisk(const QString &userName, ...@@ -744,7 +731,7 @@ void Files::saveMsgFilesToDisk(const QString &userName,
} }
#ifndef Q_OS_IOS #ifndef Q_OS_IOS
attachmentSavingNotification(destFilePath); fileSavingNotification(destFilePath);
#else #else
exportFilesiOS(destFilePaths, joinDirs(userName, msgIdStr)); exportFilesiOS(destFilePaths, joinDirs(userName, msgIdStr));
#endif #endif
...@@ -785,7 +772,7 @@ void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant, ...@@ -785,7 +772,7 @@ void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant,
} }
#ifndef Q_OS_IOS #ifndef Q_OS_IOS
attachmentSavingNotification(destFilePath); fileSavingNotification(destFilePath);
#else #else
exportFilesiOS(destFilePaths, msgIdStr); exportFilesiOS(destFilePaths, msgIdStr);
#endif #endif
...@@ -801,6 +788,20 @@ void Files::deleteTmpFileFromStorage(const QString &filePath) ...@@ -801,6 +788,20 @@ void Files::deleteTmpFileFromStorage(const QString &filePath)
#endif #endif
} }
void Files::fileSavingNotification(const QString &destPath)
{
if (!destPath.isEmpty()) {
const QFileInfo fi(destPath);
Dialogues::errorMessage(Dialogues::INFORMATION,
tr("Saving Successful"), tr("Files have been saved."),
tr("Path: '%1'").arg(fi.absolutePath()));
} else {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Saving Failed"), tr("Files have not been saved."),
tr("Please check whether the application has permissions to access the storage."));
}
}
bool Files::parseXmlData(enum MsgInfo::ZfoType *type, QString *idStr, bool Files::parseXmlData(enum MsgInfo::ZfoType *type, QString *idStr,
QString *annotation, QString *msgDescrHtml, FileListModel *attachModel, QString *annotation, QString *msgDescrHtml, FileListModel *attachModel,
QString *emailBody, QByteArray xmlData) QString *emailBody, QByteArray xmlData)
......
...@@ -71,15 +71,6 @@ public: ...@@ -71,15 +71,6 @@ public:
*/ */
explicit Files(QObject *parent = Q_NULLPTR); explicit Files(QObject *parent = Q_NULLPTR);
/*!
* @brief Generates a notification dialogue about the
* result of attachment saving.
*
* @param[in] destPath Path to which the attachment was saved.
*/
static
void attachmentSavingNotification(const QString &destPath);
/*! /*!
* @brief Delete files from all databases where file lifetime expired. * @brief Delete files from all databases where file lifetime expired.
* *
...@@ -134,14 +125,6 @@ public: ...@@ -134,14 +125,6 @@ public:
void openAttachment(const QString &fileName, void openAttachment(const QString &fileName,
const QByteArray &binaryData); const QByteArray &binaryData);
/*!
* @brief Open attachment from path in default application.
*
* @param[in] filePath File path.
*/
Q_INVOKABLE static
void openAttachmentFromPath(const QString &filePath);
/*! /*!
* @brief Send message attachments or complete zfo message * @brief Send message attachments or complete zfo message
* from database with email application. * from database with email application.
...@@ -295,6 +278,23 @@ signals: ...@@ -295,6 +278,23 @@ signals:
void statusBarTextChanged(QString txt, bool busy); void statusBarTextChanged(QString txt, bool busy);
private: private:
/*!
* @brief Generates a notification dialogue about the result of the file
* saving.
*
* @param[in] destPath Path to which the attachment was saved,
* failure notification is generated when path is empty.
*/
static
void fileSavingNotification(const QString &destPath);
/*!
* @brief Open attachment from path in default application.
*
* @param[in] filePath File path.
*/
static
void openAttachmentFromPath(const QString &filePath);
/*! /*!
* @brief Parse xml data of zfo file. * @brief Parse xml data of zfo file.
......
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