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

Removed global variables used to identify account and message in QML.

parent 7e97d16f
......@@ -76,12 +76,6 @@ ApplicationWindow {
property int acntListSpacing: defaultMargin * 2
property int formItemVerticalSpacing: defaultMargin * 3
property int formButtonHorizontalSpacing: defaultMargin * 5
// global passing arguments between pages
property string gUserName
property string gAcntName
property int gMsgType
property string gMsgId
property bool gCanDeleteMsg: false
/* compare message delivery date with current date-90days */
property int deleteAfterDays: 90
......
......@@ -28,8 +28,13 @@ Component {
id: pageAccountDetail
Item {
id: acntDetailPage
/* These properties must be set by caller. */
property string acntName
property string userName
Component.onCompleted: {
accounts.fillAccountInfo(gUserName)
accounts.fillAccountInfo(userName)
}
Rectangle {
id: header
......@@ -57,7 +62,7 @@ Component {
anchors.left: backElement4.right
anchors.leftMargin: defaultMargin
Label {
text: gAcntName + " (" + gUserName + ")"
text: acntName + " (" + userName + ")"
font.bold: true
color: datovkaPalette.text
}
......@@ -80,8 +85,8 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
isds.getAccountInfo(gUserName, false)
accounts.fillAccountInfo(gUserName)
isds.getAccountInfo(userName, false)
accounts.fillAccountInfo(userName)
}
}
}
......
......@@ -29,6 +29,11 @@ import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka.messages 1.0
/*
* Roles are defined in AccountListModel::roleNames() and are accessed directly
* via their names.
*/
Component {
id: pageAccountList
Item {
......@@ -57,7 +62,6 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
gUserName = ""
pageView.push(pageAboutApp, StackView.Immediate)
}
}
......@@ -104,8 +108,7 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
gUserName = ""
pageView.push(pageSettingsAccount, StackView.Immediate)
pageView.push(pageSettingsAccount, {"acntName": "", "userName": ""}, StackView.Immediate)
}
}
}
......@@ -197,9 +200,7 @@ Component {
anchors.fill: parent
onClicked: {
statusBar.visible = false
gAcntName = rAcntName
gUserName = rUserName
pageView.push(pageMenuAccount, StackView.Immediate)
pageView.push(pageMenuAccount, {"acntName": rAcntName, "userName": rUserName}, StackView.Immediate)
}
}
}
......@@ -280,12 +281,9 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
gAcntName = rAcntName
gUserName = rUserName
gMsgType = MessageType.TYPE_RECEIVED
statusBar.visible = false
messages.fillMessageList(rUserName, MessageType.TYPE_RECEIVED)
pageView.push(pageMessageList, StackView.Immediate)
pageView.push(pageMessageList, {"acntName": rAcntName, "userName": rUserName, "msgType": MessageType.TYPE_RECEIVED}, StackView.Immediate)
}
}
Rectangle {
......@@ -346,12 +344,9 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
gAcntName = rAcntName
gUserName = rUserName
gMsgType = MessageType.TYPE_SENT
statusBar.visible = false
messages.fillMessageList(rUserName, MessageType.TYPE_SENT)
pageView.push(pageMessageList, StackView.Immediate)
pageView.push(pageMessageList, {"acntName": rAcntName, "userName": rUserName, "msgType": MessageType.TYPE_SENT}, StackView.Immediate)
}
}
Rectangle {
......
......@@ -32,6 +32,11 @@ Component {
id: menuAccount
Item {
id: mainLayout
/* These properties must be set by caller. */
property string acntName
property string userName
property int myWidht: mainLayout.width - 2 * defaultMargin
Rectangle {
id: header
......@@ -55,8 +60,6 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
gAcntName = ""
gUserName = ""
pageView.pop(StackView.Immediate)
}
}
......@@ -66,7 +69,7 @@ Component {
anchors.left: backElement.right
anchors.leftMargin: defaultMargin
Label {
text: gAcntName + " (" + gUserName + ")"
text: acntName + " (" + userName + ")"
font.bold: true
color: datovkaPalette.text
}
......@@ -167,15 +170,15 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
pageView.replace(pageSettingsAccount, StackView.Immediate)
pageView.replace(pageSettingsAccount, {"acntName": acntName, "userName": userName}, StackView.Immediate)
} else if (index == 1) {
pageView.replace(pageAccountDetail, StackView.Immediate)
pageView.replace(pageAccountDetail, {"acntName": acntName, "userName": userName}, StackView.Immediate)
} else if (index == 2) {
files.deleteFileDb(gUserName)
files.deleteFileDb(userName)
} else if (index == 3) {
isds.changePassword(gUserName, gAcntName)
isds.changePassword(userName, acntName)
} else if (index == 4) {
if (accounts.removeAccount(gUserName, true)) {
if (accounts.removeAccount(userName, true)) {
pageView.pop(StackView.Immediate)
}
} else {
......
......@@ -157,8 +157,7 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 1) {
gUserName = ""
pageView.replace(pageSettingsAccount, StackView.Immediate)
pageView.replace(pageSettingsAccount, {"acntName": "", "userName": ""}, StackView.Immediate)
} else if (index == 2) {
pageView.replace(pageSettingsGeneral, StackView.Immediate)
} else if (index == 3) {
......
......@@ -33,8 +33,15 @@ Component {
id: menuMessage
Item {
id: mainLayout
/* These properties must be set by caller. */
property string acntName
property string userName
property int msgType
property string msgId
property bool canDeleteMsg
property int myWidht: mainLayout.width - 2 * defaultMargin
property bool canDeleteMsg: gCanDeleteMsg
Component.onCompleted: {
messageMenuListModel.setProperty(3, "showIt", canDeleteMsg)
}
......@@ -70,10 +77,10 @@ Component {
anchors.leftMargin: defaultMargin
Label {
text: {
if (gMsgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + gMsgId
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + msgId
} else {
qsTr("Sent message") + " " + gMsgId
qsTr("Sent message") + " " + msgId
}
}
font.bold: true
......@@ -175,13 +182,13 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
isds.downloadMessage(gUserName, gMsgType, gMsgId)
isds.downloadMessage(userName, msgType, msgId)
} else if (index == 1) {
messages.markMessageAsLocallyRead(gUserName, gMsgId, true)
messages.markMessageAsLocallyRead(userName, msgId, true)
} else if (index == 2) {
messages.markMessageAsLocallyRead(gUserName, gMsgId, false)
messages.markMessageAsLocallyRead(userName, msgId, false)
} else if (index == 3) {
messages.deleteMessageFromDbs(gUserName, gMsgId)
messages.deleteMessageFromDbs(userName, msgId)
}
pageView.pop(StackView.Immediate)
}
......
......@@ -33,6 +33,13 @@ Component {
id: menuMessageDetail
Item {
id: mainLayout
/* These properties must be set by caller. */
property string acntName
property string userName
property int msgType
property string msgId
property int myWidht: mainLayout.width - 2 * defaultMargin
Rectangle {
id: header
......@@ -66,10 +73,10 @@ Component {
anchors.leftMargin: defaultMargin
Label {
text: {
if (gMsgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + gMsgId
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + msgId
} else {
qsTr("Sent message") + " " + gMsgId
qsTr("Sent message") + " " + msgId
}
}
font.bold: true
......@@ -166,13 +173,13 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
isds.downloadMessage(gUserName, gMsgType, gMsgId)
isds.downloadMessage(userName, msgType, msgId)
} else if (index == 1) {
files.sendAttachmentsWithEmail(gUserName, gMsgId)
files.sendAttachmentsWithEmail(userName, msgId)
} else if (index == 2) {
files.saveAttachmentsToDisk(gUserName, gMsgId)
files.saveAttachmentsToDisk(userName, msgId)
} else if (index == 3) {
if (files.deleteAttachmentsFromDb(gUserName, gMsgId)) {
if (files.deleteAttachmentsFromDb(userName, msgId)) {
files.clearFileModel()
}
}
......
......@@ -33,6 +33,12 @@ Component {
id: menuMessageList
Item {
id: mainLayout
/* These properties must be set by caller. */
property string acntName
property string userName
property int msgType
property int myWidht: mainLayout.width - 2 * defaultMargin
Rectangle {
id: header
......@@ -66,7 +72,7 @@ Component {
anchors.leftMargin: defaultMargin
Label {
text: {
if (gMsgType == MessageType.TYPE_RECEIVED) {
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received messages")
} else {
qsTr("Sent messages")
......@@ -154,9 +160,9 @@ Component {
anchors.fill: parent
onClicked: {
if (index == 0) {
messages.markMessagesAsLocallyRead(gUserName, gMsgType, true)
messages.markMessagesAsLocallyRead(userName, msgType, true)
} else if (index == 1) {
messages.markMessagesAsLocallyRead(gUserName, gMsgType, false)
messages.markMessagesAsLocallyRead(userName, msgType, false)
}
pageView.pop(StackView.Immediate)
}
......
......@@ -33,6 +33,13 @@ Component {
id: pageMessageDetail
Item {
id: msgDetailPage
/* These properties must be set by caller. */
property string acntName
property string userName
property int msgType
property string msgId
Component.onCompleted: {
if (attachmentList.count == 0) {
emptyList.visible = true
......@@ -73,16 +80,16 @@ Component {
anchors.left: backElement3.right
anchors.leftMargin: defaultMargin
Label {
text: gAcntName + " (" + gUserName + ")"
text: acntName + " (" + userName + ")"
font.bold: true
color: datovkaPalette.text
}
Label {
text: {
if (gMsgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + gMsgId
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received message") + " " + msgId
} else {
qsTr("Sent message") + " " + gMsgId
qsTr("Sent message") + " " + msgId
}
}
font.bold: true
......@@ -102,7 +109,7 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
isds.downloadMessage(gUserName, gMsgType, gMsgId)
isds.downloadMessage(userName, msgType, msgId)
msgDownloadButton.visible = false
attachmentMenuButon.visible = true
}
......@@ -116,7 +123,7 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
pageView.push(pageMenuMessageDetail, StackView.Immediate)
pageView.push(pageMenuMessageDetail, {"acntName": acntName, "userName": userName, "msgType": msgType, "msgId": msgId}, StackView.Immediate)
}
}
}
......@@ -263,7 +270,7 @@ Component {
anchors.fill: parent
onClicked: {
locker.ignoreNextSuspension()
files.openAttachment(gUserName, gMsgId, rFileId)
files.openAttachment(userName, msgId, rFileId)
}
}
Rectangle {
......@@ -280,7 +287,7 @@ Component {
onMovementEnded: {
if (downloadStart) {
downloadStart = false
isds.downloadMessage(gUserName, gMsgType, gMsgId)
isds.downloadMessage(userName, msgType, msgId)
}
}
onDragEnded: {
......
......@@ -29,10 +29,21 @@ import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka.messages 1.0
/*
* Roles are defined in MessageListModel::roleNames() and are accessed directly
* via their names.
*/
Component {
id: pageMessageList
Item {
id: msgListPage
/* These properties must be set by caller. */
property string acntName
property string userName
property int msgType
Component.onCompleted: {
if (messageList.count == 0) {
emptyList.visible = true
......@@ -62,7 +73,7 @@ Component {
anchors.fill: parent
onClicked: {
messages.clearMessagesModel()
accounts.updateNewMessageCounter(gUserName)
accounts.updateNewMessageCounter(userName)
statusBar.visible = false
pageView.pop(StackView.Immediate)
}
......@@ -73,13 +84,13 @@ Component {
anchors.left: backElement2.right
anchors.leftMargin: defaultMargin
Label {
text: gAcntName + " (" + gUserName + ")"
text: acntName + " (" + userName + ")"
font.bold: true
color: datovkaPalette.text
}
Label {
text: {
if (gMsgType == MessageType.TYPE_RECEIVED) {
if (msgType == MessageType.TYPE_RECEIVED) {
qsTr("Received messages")
} else {
qsTr("Sent messages")
......@@ -103,7 +114,7 @@ Component {
anchors.fill: parent
onClicked: {
statusBar.visible = false
pageView.push(pageMenuMessageList, StackView.Immediate)
pageView.push(pageMenuMessageList, {"acntName": acntName, "userName": userName, "msgType": msgType}, StackView.Immediate)
}
}
}
......@@ -259,18 +270,15 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
gMsgId = rMsgId
statusBar.visible = false
pageView.push(pageMessageDetail, StackView.Immediate)
messages.markMessageAsLocallyRead(gUserName, rMsgId, true)
messages.fillMessageDetail(gUserName, rMsgId)
files.fillFileList(gUserName, rMsgId)
pageView.push(pageMessageDetail, {"acntName": acntName, "userName": userName, "msgType": msgType, "msgId": rMsgId}, StackView.Immediate)
messages.markMessageAsLocallyRead(userName, rMsgId, true)
messages.fillMessageDetail(userName, rMsgId)
files.fillFileList(userName, rMsgId)
}
onPressAndHold: {
gMsgId = rMsgId
gCanDeleteMsg = compareMsgDate(rDelivTime)
statusBar.visible = false
pageView.push(pageMenuMessage, StackView.Immediate)
pageView.push(pageMenuMessage, {"acntName": acntName, "userName": userName, "msgType": msgType, "msgId": rMsgId, "canDeleteMsg": compareMsgDate(rDelivTime)}, StackView.Immediate)
}
}
Rectangle {
......@@ -285,12 +293,12 @@ Component {
onMovementEnded: {
if (downloadStart) {
downloadStart = false
if (gMsgType == MessageType.TYPE_RECEIVED) {
isds.syncSingleAccountReceived(gUserName)
} else if (gMsgType == MessageType.TYPE_SENT) {
isds.syncSingleAccountSent(gUserName)
if (msgType == MessageType.TYPE_RECEIVED) {
isds.syncSingleAccountReceived(userName)
} else if (msgType == MessageType.TYPE_SENT) {
isds.syncSingleAccountSent(userName)
}
messages.fillMessageList(gUserName, gMsgType)
messages.fillMessageList(userName, msgType)
}
}
onDragEnded: {
......
......@@ -29,12 +29,17 @@ Component {
id: settingsAccount
Item {
id: mainLayout
property bool isNewAccount: (gUserName == "")
/* These properties must be set by caller. */
property string acntName
property string userName
property bool isNewAccount: (userName == "")
property string sLoginMethod: "pwd"
property int myWidht: mainLayout.width - 2 * defaultMargin
Component.onCompleted: {
if (!isNewAccount) {
accounts.getAccountData(gUserName)
accounts.getAccountData(userName)
}
}
Rectangle {
......@@ -349,8 +354,8 @@ Component {
Connections {
target: accounts
onSendAccountData: {
accountNameTextField.text = gAcntName
userNameTextField.text = gUserName
accountNameTextField.text = acntName
userNameTextField.text = userName
passwordTextField.text = password
rememberPassword.checked = rememberPwd
testAccount.checked = isTestAccount
......@@ -359,7 +364,7 @@ Component {
loginMethodComboBox.currentIndex = loginMethod
userNameTextField.enabled = false
testAccount.enabled = false
pageLabel.text = qsTr("Account settings") + ": "+ gUserName
pageLabel.text = qsTr("Account settings") + ": "+ userName
}
}
Connections {
......
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