Commit 1dea16cd authored by Karel Slaný's avatar Karel Slaný

Data boxes can be deselected in box search page.

parent 11b9285a
......@@ -32,13 +32,15 @@ ListView {
id: root
/* These properties must be set by caller. */
// sendMsgRecipientListModel holds recipient list from send message page (can be NULL)
property var sendMsgRecipientListModel: null
property bool canDetailBoxes: false // enables viewing of box details
property bool canSelectBoxes: false // enables selecting of entries
property bool canDeselectBoxes: false // enables deselecting of entries
property bool canRemoveBoxes: false // enables removing of entries
/* This signal should be captured to implement find databox or add to recipient. */
signal boxClicked(string boxId)
/* This signal should be captured to implement model interaction. */
signal boxDetail(string boxId)
signal boxSelect(string boxId)
signal boxDeselect(string boxId)
signal boxRemove(string boxId)
delegate: Rectangle {
......@@ -97,7 +99,15 @@ ListView {
MouseArea {
anchors.fill: parent
onClicked: {
root.boxClicked(rDbID)
if (canDetailBoxes && !(canSelectBoxes || canDeselectBoxes)) {
root.boxDetail(rDbID)
} else if (!canDetailBoxes && (canSelectBoxes || canDeselectBoxes)) {
if (rDbSelected && canDeselectBoxes) {
root.boxDeselect(rDbID)
} else if (!rDbSelected && canSelectBoxes) {
root.boxSelect(rDbID)
}
}
}
}
Rectangle {
......@@ -115,14 +125,17 @@ ListView {
sourceSize.height: canDetailBoxes ? navImgHeight : imgHeight
source: {
// set icon based on the databox list operation
if (canDetailBoxes) {
// we can view databox detail only
if (canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && !canRemoveBoxes) {
// we can view data box detail only
"qrc:/ui/next.svg"
} else if (canSelectBoxes) {
// we can add databox into send message recipient list
"qrc:/ui/add.svg"
} else {
// we can remove databox from send message recipient list
} else if (!canDetailBoxes && (canSelectBoxes || canDeselectBoxes) && !canRemoveBoxes) {
if (rDbSelected && canDeselectBoxes) {
"qrc:/ui/remove.svg"
} else if (!rDbSelected && canSelectBoxes) {
"qrc:/ui/add.svg"
}
} else if (!canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && canRemoveBoxes) {
// we can remove data box from send message recipient list
"qrc:/ui/remove.svg"
}
}
......@@ -134,11 +147,11 @@ ListView {
}
MouseArea {
// visible only if canDetailBoxes
visible: (!canDetailBoxes && !canSelectBoxes)
visible: (!canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && canRemoveBoxes)
anchors.fill: parent
onClicked: {
// we must allow remove exist recipients from model.
if (!canDetailBoxes && !canSelectBoxes) {
if (!canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && canRemoveBoxes) {
root.boxRemove(rDbID)
}
}
......
......@@ -300,9 +300,6 @@ Item {
}
DataboxList {
id: databoxList
// Set canSelectBoxes to True if sendMsgRecipientModel is NOT NULL.
// It allows to add databoxes to sendMsgRecipientModel.
canSelectBoxes: !(sendMsgRecipientModel == null)
anchors.top: searchPanel.bottom
anchors.bottom: parent.bottom
clip: true
......@@ -313,11 +310,28 @@ Item {
interactive: true
model: proxyDataboxModel
canDetailBoxes: sendMsgRecipientModel == null
onBoxClicked: {
canSelectBoxes: sendMsgRecipientModel != null
canDeselectBoxes: sendMsgRecipientModel != null
onBoxSelect: {
var boxEntry = databoxModel.entry(boxId)
statusBar.visible = false
if (sendMsgRecipientModel != null) {
databoxModel.selectEntry(boxEntry.dbID, true)
sendMsgRecipientModel.addEntry(boxEntry)
}
}
onBoxDeselect: {
statusBar.visible = false
if (sendMsgRecipientModel != null) {
databoxModel.selectEntry(boxId, false)
sendMsgRecipientModel.removeEntry(boxId)
}
}
onBoxDetail: {
var boxEntry = databoxModel.entry(boxId)
statusBar.visible = false
// If sendMsgRecipientModel is NULL, we show databox detail page
if (sendMsgRecipientModel == null) {
pageView.push(pageDataboxDetail, {
"pageView": pageView,
......@@ -326,10 +340,6 @@ Item {
"dbID": boxEntry.dbID,
"dbType": boxEntry.dbType
}, StackView.Immediate)
} else {
// sendMsgRecipientModel exists so we can add/append new databox to sendMsgRecipientModel
databoxModel.selectEntry(boxEntry.dbID, true)
sendMsgRecipientModel.addEntry(boxEntry)
}
}
} // DataboxList
......
......@@ -288,7 +288,7 @@ Item {
height: 600
interactive: true
model: sendMsgRecipientModel
canDetailBoxes: sendMsgRecipientModel == null
canRemoveBoxes: true
onCountChanged: {
mainPanel.areReguiredFieldsFilled()
}
......
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