Marker.qml 1.13 KB
Newer Older
luyikei's avatar
luyikei committed
1 2 3 4 5 6 7 8
import QtQuick 2.0

Rectangle {
    id: marker

    width: 1
    height: page.height
    color: "#3F6644"
9 10
    x: ftop( position )
    visible: x < sView.flickableItem.contentX ? false : true
luyikei's avatar
luyikei committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

    property int position: 0
    property var markerModel

    onPositionChanged: {
        markerModel["position"] = position;
        length = Math.max( length, position + 100 );
    }

    onMarkerModelChanged: {
        position = markerModel["position"];
    }

    Drag.keys: ["Marker"]
    Drag.active: markerMouseArea.drag.active
    Rectangle {
        x: - ( width - 1 ) / 2
        width: 5
        height: 9
        color: "#63ff44"

        MouseArea {
            id: markerMouseArea
            anchors.fill: parent
            drag.target: marker
            drag.axis: Drag.XAxis
            drag.minimumX: 0
luyikei's avatar
luyikei committed
38 39 40 41 42 43 44 45 46 47 48 49
            acceptedButtons: Qt.LeftButton | Qt.RightButton

            onClicked: {
                if ( mouse.button & Qt.RightButton ) {
                    markerContextMenu.popup();
                }
            }
        }

        MarkerContextMenu {
            id: markerContextMenu
            marker: marker
luyikei's avatar
luyikei committed
50 51 52 53
        }
    }
}