Commit 3c301387 authored by Karel Slaný's avatar Karel Slaný
Browse files

Completely removed globMessagesModel.

parent 5bf65894
......@@ -44,6 +44,7 @@ Component {
property int msgType
property string msgId
property bool canDeleteMsg
property var messageModel: null
property int myWidht: mainLayout.width - 2 * defaultMargin
Component.onCompleted: {
......@@ -160,13 +161,13 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
isds.downloadMessage(messageListModel, userName, msgType, msgId)
isds.downloadMessage(messageModel, userName, msgType, msgId)
} else if (index == 1) {
messages.markMessageAsLocallyRead(messageListModel, userName, msgId, true)
messages.markMessageAsLocallyRead(messageModel, userName, msgId, true)
} else if (index == 2) {
messages.markMessageAsLocallyRead(messageListModel, userName, msgId, false)
messages.markMessageAsLocallyRead(messageModel, userName, msgId, false)
} else if (index == 3) {
messages.deleteMessageFromDbs(messageListModel, userName, msgId)
messages.deleteMessageFromDbs(messageModel, userName, msgId)
}
pageView.pop(StackView.Immediate)
}
......
......@@ -43,6 +43,7 @@ Component {
property string userName
property int msgType
property string msgId
property var messageModel: null
property var attachmentModel: null /* The QVariant holds actually a pointer to the model. */
property int myWidht: mainLayout.width - 2 * defaultMargin
......@@ -152,7 +153,7 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
isds.downloadMessage(messageListModel, userName, msgType, msgId)
isds.downloadMessage(messageModel, userName, msgType, msgId)
} else if (index == 1) {
files.sendAttachmentsWithEmailFromDb(userName, msgId)
} else if (index == 2) {
......
......@@ -41,6 +41,7 @@ Component {
property string acntName
property string userName
property int msgType
property var messageModel: null
property int myWidht: mainLayout.width - 2 * defaultMargin
......@@ -137,9 +138,9 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
messages.markMessagesAsLocallyRead(messageListModel, userName, msgType, true)
messages.markMessagesAsLocallyRead(messageModel, userName, msgType, true)
} else if (index == 1) {
messages.markMessagesAsLocallyRead(messageListModel, userName, msgType, false)
messages.markMessagesAsLocallyRead(messageModel, userName, msgType, false)
}
pageView.pop(StackView.Immediate)
}
......
......@@ -44,6 +44,7 @@ Component {
property string userName: ""
property string msgId: ""
property int msgType
property var messageModel: null
/* These properties are set from within the page. */
property string zfoId /*Prevents infinite loop that would be caused by setting msgId from within the page. */
......@@ -87,7 +88,7 @@ Component {
} else if (fromLocalDb && (userName.length != 0) && (msgId.length != 0)) {
zfoId = msgId
messages.markMessageAsLocallyRead(messageListModel, userName, msgId, true)
messages.markMessageAsLocallyRead(messageModel, userName, msgId, true)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
......@@ -204,7 +205,7 @@ Component {
anchors.fill: parent
onClicked: {
if (fromLocalDb) {
isds.downloadMessage(messageListModel, userName, msgType, zfoId)
isds.downloadMessage(messageModel, userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
emptyList.visible = (attachmentList.count == 0)
......@@ -229,6 +230,7 @@ Component {
"userName": userName,
"msgType": msgType,
"msgId": zfoId,
"messageModel": messageModel,
"attachmentModel" : attachmentModel
}, StackView.Immediate)
}
......@@ -415,7 +417,7 @@ Component {
if (downloadStart) {
downloadStart = false
if (fromLocalDb) {
isds.downloadMessage(messageListModel, userName, msgType, zfoId)
isds.downloadMessage(messageModel, userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
}
......
......@@ -47,14 +47,21 @@ Component {
property int msgType
Component.onCompleted: {
messages.fillMessageList(messageListModel, userName, msgType)
messages.fillMessageList(messageModel, userName, msgType)
if (messageList.count == 0) {
emptyList.visible = true
/* Don't use visible property as it hides the element. */
settingsButton.enabled = false
}
proxyMessageModel.setSourceModel(messageListModel)
proxyMessageModel.setSourceModel(messageModel)
}
MessageListModel {
id: messageModel
Component.onCompleted: {
}
}
ListSortFilterProxyModel {
......@@ -123,7 +130,8 @@ Component {
"statusBar": statusBar,
"acntName": acntName,
"userName": userName,
"msgType": msgType
"msgType": msgType,
"messageModel": messageModel
}, StackView.Immediate)
}
}
......@@ -172,7 +180,8 @@ Component {
"acntName": acntName,
"userName": userName,
"msgType": msgType,
"msgId": msgId
"msgId": msgId,
"messageModel": messageModel
}, StackView.Immediate)
}
onMsgPressAndHold: {
......@@ -184,7 +193,8 @@ Component {
"userName": userName,
"msgType": msgType,
"msgId": msgId,
"canDeleteMsg": canDelete
"canDeleteMsg": canDelete,
"messageModel": messageModel
}, StackView.Immediate)
}
......@@ -193,11 +203,11 @@ Component {
if (downloadStart) {
downloadStart = false
if (msgType == MessageType.TYPE_RECEIVED) {
isds.syncSingleAccountReceived(messageListModel, userName)
isds.syncSingleAccountReceived(messageModel, userName)
} else if (msgType == MessageType.TYPE_SENT) {
isds.syncSingleAccountSent(messageListModel, userName)
isds.syncSingleAccountSent(messageModel, userName)
}
messages.fillMessageList(messageListModel, userName, msgType)
messages.fillMessageList(messageModel, userName, msgType)
}
}
onDragEnded: {
......
......@@ -289,8 +289,6 @@ int main(int argc, char *argv[])
QtAppDelegateInitialize(&interactionZfoFile);
#endif
globMessagesModel.setObjectName("messageListModel"); /* TODO -- Remove it. */
/* register classes in QML */
ctx->setContextProperty("isds", &isds);
ctx->setContextProperty("messages", &messages);
......@@ -304,8 +302,6 @@ int main(int argc, char *argv[])
/* register and set models in QML */
ctx->setContextProperty(globAccountsModelPtr->objectName(),
globAccountsModelPtr);
ctx->setContextProperty(globMessagesModel.objectName(),
&globMessagesModel);
/* Localise description in tables. */
accntinfTbl.reloadLocalisedDescription();
......
......@@ -154,8 +154,6 @@ void MessageModelEntry::setMsgType(int msgType)
m_msgType = msgType;
}
MessageListModel globMessagesModel;
void MessageListModel::declareQML(void)
{
qmlRegisterType<MessageListModel>("cz.nic.mobileDatovka.models", 1, 0, "MessageListModel");
......
......@@ -242,6 +242,4 @@ private:
Q_DECLARE_METATYPE(MessageListModel)
Q_DECLARE_METATYPE(MessageListModel::Roles)
extern MessageListModel globMessagesModel;
#endif // MESSAGEMODEL_H
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