Browse Source

add checkbox in statedialog.

cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
1e60fb5d09
  1. 15
      mix/qml/StateDialog.qml
  2. 20
      mix/qml/StateListModel.qml

15
mix/qml/StateDialog.qml

@ -17,11 +17,12 @@ Window {
property alias stateTitle: titleField.text
property alias stateBalance: balanceField.value
property alias isDefault: defaultCheckBox.checked
property int stateIndex
property var stateTransactions: []
signal accepted
function open(index, item) {
function open(index, item, setDefault) {
stateIndex = index;
stateTitle = item.title;
balanceField.value = item.balance;
@ -33,7 +34,10 @@ Window {
stateTransactions.push(item.transactions[t]);
}
visible = true;
isDefault = setDefault;
titleField.focus = true;
defaultCheckBox.enabled = !isDefault;
}
function close() {
@ -77,6 +81,15 @@ Window {
Layout.fillWidth: true
}
Label {
text: qsTr("Default")
}
CheckBox {
id: defaultCheckBox
Layout.fillWidth: true
}
Label {
text: qsTr("Transactions")
}

20
mix/qml/StateListModel.qml

@ -125,16 +125,19 @@ Item {
id: stateDialog
onAccepted: {
var item = stateDialog.getItem();
if (stateDialog.stateIndex < stateListModel.count)
{
if (stateDialog.stateIndex < stateListModel.count) {
if (stateDialog.isDefault)
defaultStateIndex = stateIndex;
stateList[stateDialog.stateIndex] = item;
stateListModel.set(stateDialog.stateIndex, item);
}
else
{
} else {
if (stateDialog.isDefault)
defaultStateIndex = 0;
stateList.push(item);
stateListModel.append(item);
}
if (stateDialog.isDefault)
stateListModel.defaultStateChanged();
stateListModel.save();
}
}
@ -187,11 +190,11 @@ Item {
function addState() {
var item = createDefaultState();
stateDialog.open(stateListModel.count, item);
stateDialog.open(stateListModel.count, item, false);
}
function editState(index) {
stateDialog.open(index, stateList[index]);
stateDialog.open(index, stateList[index], defaultStateIndex === index);
}
function debugDefaultState() {
@ -208,7 +211,10 @@ Item {
stateListModel.remove(index);
stateList.splice(index, 1);
if (index === defaultStateIndex)
{
defaultStateIndex = 0;
defaultStateChanged();
}
save();
}

Loading…
Cancel
Save