ClipLibraryView.qml 1.91 KB
Newer Older
luyikei's avatar
luyikei committed
1 2 3 4 5 6 7 8 9 10 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51
import QtQuick 2.0
import QtQuick.Controls 1.4

Rectangle {
    id: clipLibraryView
    anchors.fill: parent
    color: "#999999"

    property var clipItems: []
    property int currentMediaId: -1

    ListModel {
        id: clips
    }

    ListModel {
        id: subClips
    }

    ScrollView {
        id: sView
        height: parent.height
        width: parent.width

        ListView {
            id: clipListView
            width: sView.viewport.width
            model: clips
            focus: true
            delegate: ClipItem {
                uuid: model.uuid
                isBaseClip: model.isBaseClip
                duration: model.duration
                thumbnailPath: model.thumbnailPath
                mediaId: model.mediaId
                onTimeline: model.onTimeline
                title: model.title
                width: parent.width
            }
        }
    }

    Connections {
        target: view

        onClipAdded: {
            var clip = view.clip( uuid );
            clips.append( clip );
        }

        onClipOnTimelineChanged: {
52 53 54
            for ( var i = 0; i < clips.count; ++i ) {
                if ( clips.get(i)["uuid"] === uuid ) {
                    clips.get(i)["onTimeline"] = onTimeline;
luyikei's avatar
luyikei committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
                    break;
                }
            }
        }

        onClipRemoved: {
            var clip = view.clip( uuid );
            if ( clip.isBaseClip === false ) {
                for ( var i = 0; i < clipItems.length; ++i ) {
                    if ( clipItems[i].mediaId === clip.mediaId && clipItems[i].isBaseClip ) {
                        clipItems[i].removeSubClip( uuid );
                        break;
                    }
                }
            }
70
            for ( i = 0; i < clips.count; ++i ) {
luyikei's avatar
luyikei committed
71 72 73 74 75 76 77 78
                if ( clips[i].uuid === uuid ) {
                    clips.remove( i );
                    break;
                }
            }
        }
    }
}