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

ZFO file is parsed only once to set all content of the message detail page.

parent b501bee2
......@@ -68,7 +68,8 @@ Component {
function fillContentFromDb() {
if (!fromLocalDb && (rawZfoContent != null)) {
var msgInfo = files.msgInfo(rawZfoContent)
/* This method also sets the attachment model. */
var msgInfo = files.zfoData(attachmentModel, rawZfoContent)
zfoId = msgInfo.idStr
msgAnnotation = msgInfo.annotation
......@@ -77,8 +78,6 @@ Component {
showDeliveryInfo = msgInfo.deliveryInfo
attachmentModel.setZfo(rawZfoContent)
attachmentLabel.visible = !showDeliveryInfo
emptyList.visible = !showDeliveryInfo
attachmentList.visible = !showDeliveryInfo
......
......@@ -523,13 +523,15 @@ QByteArray Files::base64ToRaw(const QByteArray &base64Data)
return QByteArray::fromBase64(base64Data);
}
MsgInfo *Files::msgInfo(const QByteArray &rawZfoData)
MsgInfo *Files::zfoData(const QVariant &attachModelVariant,
const QByteArray &rawZfoData)
{
bool deliveryInfo = false;
QString idStr, annot, htmlDescr, emailBody;
bool ret = parseXmlData(&deliveryInfo, &idStr, &annot, &htmlDescr,
Q_NULLPTR, &emailBody, getXmlFromCms(rawZfoData));
FileListModel::modelFromVariant(attachModelVariant),
&emailBody, getXmlFromCms(rawZfoData));
return ret ?
new (std::nothrow) MsgInfo(deliveryInfo, idStr, annot, htmlDescr,
......@@ -537,13 +539,6 @@ MsgInfo *Files::msgInfo(const QByteArray &rawZfoData)
new (std::nothrow) MsgInfo();
}
bool Files::setAttachmentModel(FileListModel &attachModel,
const QByteArray &rawZfoData)
{
return parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR,
&attachModel, Q_NULLPTR, getXmlFromCms(rawZfoData));
}
bool Files::setAttachmentModel(FileListModel &attachModel,
const QString &userName, qint64 msgId)
{
......
......@@ -155,22 +155,14 @@ public:
* of 'Data Type Conversion Between QML and C++'
* at http://doc.qt.io/qt-5/qtqml-cppintegration-data.html .
*
* @param[in,out] attachModelVariant QVariant holding attachment model
* to be set.
* @param[in] rawZfoData Raw ZFO data.
* @return Pointer to newly allocated structure containing message
* information.
*/
Q_INVOKABLE static
MsgInfo *msgInfo(const QByteArray &rawZfoData);
/*!
* @brief Sets attachment model.
*
* @param[out] attachModel Attachment model to be set.
* @param[in] rawZfoData Raw ZFO data.
* @return true if success.
*/
static
bool setAttachmentModel(FileListModel &attachModel,
MsgInfo *zfoData(const QVariant &attachModelVariant,
const QByteArray &rawZfoData);
/*!
......
......@@ -215,11 +215,6 @@ FileListModel *FileListModel::modelFromVariant(
return qobject_cast<FileListModel *>(obj);
}
bool FileListModel::setZfo(const QByteArray &rawZfoData)
{
return Files::setAttachmentModel(*this, rawZfoData);
}
bool FileListModel::setFromDb(const QString &userName, const QString &msgIdStr)
{
bool ok = false;
......
......@@ -159,15 +159,6 @@ public:
static
FileListModel *modelFromVariant(const QVariant &attachModelVariant);
/*!
* @brief Set content from ZFO content.
*
* @param[in] rawZfoData Message content.
* @return True on success.
*/
Q_INVOKABLE
bool setZfo(const QByteArray &rawZfoData);
/*!
* @brief Set content from database.
*
......
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