Browse Source

Adding "create state"

minor correction
cl-refactor
Ali Mashatan 10 years ago
parent
commit
b9a7f0815f
  1. 169
      mix/qml/StatesComboBox.qml
  2. 7
      mix/qml/TransactionLog.qml

169
mix/qml/StatesComboBox.qml

@ -47,6 +47,7 @@ Rectangle {
signal selectItem(real item); signal selectItem(real item);
signal editItem(real item); signal editItem(real item);
signal selectCreate();
property variant items; property variant items;
readonly property alias selectedItem: chosenItemText.text; readonly property alias selectedItem: chosenItemText.text;
@ -86,7 +87,7 @@ Rectangle {
} }
} }
} }
//ToDo: We need scrollbar for items
Rectangle { Rectangle {
id:dropDownList id:dropDownList
width:statesComboBox.width; width:statesComboBox.width;
@ -96,93 +97,123 @@ Rectangle {
anchors.top: chosenItem.bottom; anchors.top: chosenItem.bottom;
anchors.margins: 2; anchors.margins: 2;
color: statesComboBox.color color: statesComboBox.color
ColumnLayout{
spacing: 2
TableView {
id:listView
height:20;
implicitHeight: 0
width:statesComboBox.width;
model: statesComboBox.items
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff;
currentRow: -1
headerVisible: false;
backgroundVisible: false
alternatingRowColors : false;
frameVisible: false
TableViewColumn {
role: "title"
title: ""
width: statesComboBox.width;
delegate: mainItemDelegate
}
Component {
id: mainItemDelegate
Item{
id: itemDelegate
width:statesComboBox.width;
height: statesComboBox.height;
Text {
id: textItemid
text: styleData.value
color: statesComboBox.colorItem;
anchors.top: parent.top;
anchors.left: parent.left;
anchors.margins: 5;
TableView { }
id:listView Rectangle
height:500; {
width:statesComboBox.width; id: spaceItemid
model: statesComboBox.items anchors.top: textItemid.top;
currentRow: -1 anchors.left: textItemid.right
headerVisible: false; width: parent.width - textItemid.width - imageItemid.width - textItemid.anchors.margins- textItemid.anchors.margins
backgroundVisible: false }
alternatingRowColors : false; Image {
frameVisible: false id: imageItemid
height:20
TableViewColumn { width:20;
role: "title" visible: false;
title: "" fillMode: Image.PreserveAspectFit
width: statesComboBox.width; source: "img/edit_combox.png"
delegate: mainItemDelegate anchors.top: spaceItemid.top;
//elideMode: Text.ElideNone anchors.left: spaceItemid.right;
} }
Component { MouseArea {
id: mainItemDelegate anchors.fill: parent;
Item{ hoverEnabled : true
id: itemDelegate
onEntered: {
imageItemid.visible = true;
textItemid.color = statesComboBox.colorSelect;
}
onExited: {
imageItemid.visible = false;
textItemid.color = statesComboBox.colorItem;
}
onClicked: {
if (mouseX > imageItemid.x && mouseX < imageItemid.x+ imageItemid.width
&& mouseY > imageItemid.y && mouseY < imageItemid.y+ imageItemid.height)
statesComboBox.editItem(styleData.row);
else {
statesComboBox.state = ""
var prevSelection = chosenItemText.text
chosenItemText.text = styleData.value
listView.currentRow = styleData.row;
statesComboBox.selectItem(styleData.row);
}
}
}
}//Item
}//Component
}//Table View
RowLayout{
Rectangle{
width: 1
}
Text{
id:createStateText
width:statesComboBox.width; width:statesComboBox.width;
height: statesComboBox.height; height: statesComboBox.height;
Text { font.pointSize: 10
id: textItemid text:"Create State ..."
text: styleData.value MouseArea
color: statesComboBox.colorItem;
anchors.top: parent.top;
anchors.left: parent.left;
anchors.margins: 5;
}
Rectangle
{ {
id: spaceItemid
anchors.top: textItemid.top;
anchors.left: textItemid.right
width: parent.width - textItemid.width - imageItemid.width - textItemid.anchors.margins- textItemid.anchors.margins
}
Image {
id: imageItemid
height:20
width:20;
visible: false;
fillMode: Image.PreserveAspectFit
source: "img/edit_combox.png"
anchors.top: spaceItemid.top;
anchors.left: spaceItemid.right;
}
MouseArea {
anchors.fill: parent; anchors.fill: parent;
hoverEnabled : true hoverEnabled : true
onEntered: { onEntered: {
imageItemid.visible = true; createStateText.color = statesComboBox.colorSelect;
textItemid.color = statesComboBox.colorSelect;
} }
onExited: { onExited: {
imageItemid.visible = false; createStateText.color = statesComboBox.colorItem;
textItemid.color = statesComboBox.colorItem;
} }
onClicked: { onClicked: {
if (mouseX > imageItemid.x && mouseX < imageItemid.x+ imageItemid.width statesComboBox.state = ""
&& mouseY > imageItemid.y && mouseY < imageItemid.y+ imageItemid.height) statesComboBox.selectCreate();
statesComboBox.editItem(styleData.row);
else {
statesComboBox.state = ""
var prevSelection = chosenItemText.text
chosenItemText.text = styleData.value
if(chosenItemText.text != prevSelection)
statesComboBox.comboClicked();
listView.currentRow = styleData.row;
statesComboBox.selectItem(styleData.row);
}
} }
} }
}//Item }
}//Component }
} }
} }
states: State { states: State {
name: "dropDown"; name: "dropDown";
PropertyChanges { target: dropDownList; height:20*statesComboBox.items.count } PropertyChanges { target: dropDownList; height:(20*(statesComboBox.items.count+1)) }
PropertyChanges { target:listView; height:20; implicitHeight: (20*(statesComboBox.items.count)) }
} }
} }

7
mix/qml/TransactionLog.qml

@ -64,7 +64,8 @@ Item {
{ {
id: statesCombo id: statesCombo
items:projectModel.stateListModel items:projectModel.stateListModel
onSelectItem: console.log("Combobox Select Item: " + item ) //onSelectItem: console.log("Combobox Select Item: " + item )
onSelectCreate: projectModel.stateListModel.addState();
onEditItem: projectModel.stateListModel.editState(item) onEditItem: projectModel.stateListModel.editState(item)
colorItem: "black" colorItem: "black"
colorSelect: "blue" colorSelect: "blue"
@ -77,7 +78,7 @@ Item {
} }
} }
} }
Button /*Button
{ {
anchors.rightMargin: 9 anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -88,7 +89,7 @@ Item {
anchors.rightMargin: 9 anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
action: addStateAction action: addStateAction
} }*/
Button Button
{ {
anchors.rightMargin: 9 anchors.rightMargin: 9

Loading…
Cancel
Save