Commit 22aa8683 authored by Martin Straka's avatar Martin Straka

Update message model after upload to records management

parent 7178e6f1
......@@ -115,7 +115,8 @@ Component {
"acntName" : acntName,
"userName": userName,
"msgId": msgId,
"msgType": msgType
"msgType": msgType,
"messageModel": messageModel
}, StackView.Immediate)
},
"sendEmail": function callSendEmail() {
......
......@@ -40,6 +40,7 @@ Component {
property string userName
property int msgType
property string msgId
property var messageModel: null
Component.onCompleted: {
uploadHierarchyProxyModel.setSourceModel(uploadHierarchyListModel)
......@@ -141,7 +142,10 @@ Component {
font.pointSize: defaultTextFont.font.pointSize
text: qsTr("Upload message")
onClicked: {
recordsManagement.uploadMessage(userName, msgId, msgType, uploadHierarchyListModel)
if (recordsManagement.uploadMessage(userName, msgId, msgType, uploadHierarchyListModel)) {
messages.updateRmStatus(messageModel, msgId, true)
pageView.pop(StackView.Immediate)
}
}
}
}
......
......@@ -234,6 +234,20 @@ void Messages::markMessagesAsLocallyRead(const QVariant &msgModelVariant,
messageModel->overrideReadAll(isRead);
}
void Messages::updateRmStatus(const QVariant &msgModelVariant, qint64 dmId,
bool isUploadRm)
{
qDebug("%s()", __func__);
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
qWarning("%s", "Cannot access message model.");
return;
}
messageModel->updateRmStatus(dmId, isUploadRm);
}
void Messages::deleteMessageFromDbs(const QVariant &acntModelVariant,
const QVariant &msgModelVariant, const QString &userName, qint64 msgId)
{
......
......@@ -130,6 +130,18 @@ public:
void markMessagesAsLocallyRead(const QVariant &msgModelVariant,
const QString &userName, enum MessageType msgType, bool isRead);
/*!
* @brief Update records management icon after message upload.
*
* @param[in,out] msgModelVariant QVariant holding message model to be set.
* @param[in] dmId Message id.
* @param[in] isUploadRm Set whether to force records management
* upload state.
*/
Q_INVOKABLE static
void updateRmStatus(const QVariant &msgModelVariant, qint64 dmId,
bool isUploadRm);
/*!
* @brief Delete selected message from databases.
*
......
......@@ -417,3 +417,21 @@ MessageListModel *MessageListModel::fromVariant(const QVariant &modelVariant)
QObject *obj = qvariant_cast<QObject *>(modelVariant);
return qobject_cast<MessageListModel *>(obj);
}
bool MessageListModel::updateRmStatus(qint64 dmId, bool isUploadRm)
{
QModelIndex msgIdx(messageIndex(dmId));
if (!msgIdx.isValid()) {
return false;
}
int row = msgIdx.row();
Q_ASSERT((row >= 0) && (row < m_messages.size()));
m_messages[row].setSecordsManagement(isUploadRm);
emit dataChanged(msgIdx, msgIdx);
return true;
}
......@@ -237,6 +237,18 @@ public:
static
MessageListModel *fromVariant(const QVariant &modelVariant);
/*!
* @brief Update records management icon after message upload.
*
* @note Emits dataChanged signal.
*
* @param[in] dmId Message id.
* @param[in] isUploadRm Set whether to force records management
* upload state.
* @return True on success.
*/
bool updateRmStatus(qint64 dmId, bool isUploadRm);
private:
QList<MessageModelEntry> m_messages; /*!< List of messages stored. */
......
......@@ -305,9 +305,6 @@ bool RecordsManagement::uploadMessage(const QString &userName,
return false;
}
/* TODO - removed this return */
return true;
return uploadFile(msgId, msgFileName, msgData, hierarchyModel->selectedIds());
}
......
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