X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmdictionary%2Fqml%2FMySpinBox.qml;h=a30ecbabf79bef76bded53ab5d9a0793a0701c86;hb=11ada56e37ed724c4777ad2ac555eabe19c65c12;hp=e0d536b32b4eed4bf117d279273ec3ca08c3ef4b;hpb=ac86fa7a460e6fb10126eb63372d18a5dd1e1f4d;p=mdictionary diff --git a/src/mdictionary/qml/MySpinBox.qml b/src/mdictionary/qml/MySpinBox.qml index e0d536b..a30ecba 100644 --- a/src/mdictionary/qml/MySpinBox.qml +++ b/src/mdictionary/qml/MySpinBox.qml @@ -7,47 +7,114 @@ Rectangle { property int maxValue:500; property int minValue:0; property alias value:text_input1.text + property bool isTextInMinValue:true; + property string textInMinValue:"inf"; + property int singleStep: 2; + + signal valueChange(int intiger); + + function stringToInt(string){ + var value=0; + var pow10=1; + if(isTextInMinValue && textInMinValue==string) + value=minValue; + else + for (var i=string.length-1;i>=0;i--){ + value+=(string.charCodeAt(i)-48)*pow10; + pow10= pow10*10; + } + if(value>maxValue) + return maxValue; + if(valuemaxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep); + else if (event.key == Qt.Key_Down){ + text_input1.text=((stringToInt(text_input1.text)-singleStep)maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep); + else + running=false; + } + } + + Timer { + id:timerDown; + interval: 100; + running: false; + repeat: true + onTriggered:{ + if(mouseAreaDown.pressedButtons==Qt.LeftButton){ + text_input1.text=((stringToInt(text_input1.text)-singleStep)maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep); + onPressAndHold:{ + timerUp.restart; + timerUp.running=true; } } MouseArea { id: mouseAreaDown + z:5 + width: 13; + height: rectangle1.height/2; anchors.right: parent.right - anchors.top: parent.top - anchors.rightMargin: 2 - anchors.topMargin: 2 - width: 11; - height: rectangle1/2; - onClicked: { - console.log("t2"); - //rectangle.clicked(); + anchors.bottom: parent.bottom + onClicked:{ + text_input1.text=((stringToInt(text_input1.text)-singleStep)