Warning, /education/gcompris/src/activities/ordering_numbers/OrderingPlaceholder.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - orderingPlaceholder.qml 0002 * 0003 * SPDX-FileCopyrightText: 2021 Emmanuel Charruau <echarruau@gmail.com> 0004 * 0005 * Authors: 0006 * Harsh Kumar <hadron43@yahoo.com> 0007 * Emmanuel Charruau <echarruau@gmail.com> 0008 * Timothée Giet <animtim@gmail.com> 0009 * 0010 * SPDX-License-Identifier: GPL-3.0-or-later 0011 */ 0012 import QtQuick 2.12 0013 import QtQml.Models 2.12 0014 import QtQuick.Controls 2.12 0015 0016 import GCompris 1.0 0017 import "../../core/core.js" as Core 0018 0019 Rectangle { 0020 id: orderingPlaceholder 0021 0022 property ListModel placeholderListModel 0023 property Image highestParent 0024 // Mode : numbers | alphabets | sentences | chronology 0025 property string mode 0026 property string placeholderName 0027 0028 property string elementKey 0029 property string targetPlaceholderKey 0030 0031 property bool colorResetRequired: false 0032 0033 border.color: placeholderDropArea.containsDrag ? "#FFFFFFFF" : "#00FFFFFF" 0034 border.width: 4 * ApplicationInfo.ratio 0035 color: placeholderDropArea.containsDrag ? "#B0FFFFFF" : "#80FFFFFF" 0036 width: parent.width * 0.8 0037 radius: 10 0038 anchors.horizontalCenter: parent.horizontalCenter 0039 0040 DelegateModel { 0041 id: originPHDelegateModel 0042 model: placeholderListModel 0043 0044 delegate: OrderingElement { 0045 id: orderingElement 0046 mode: orderingPlaceholder.mode 0047 elementKey: orderingPlaceholder.elementKey 0048 index: DelegateModel.itemsIndex 0049 highestParent: orderingPlaceholder.highestParent 0050 placeholderName: orderingPlaceholder.placeholderName 0051 } 0052 } 0053 0054 // Drop area to detect drops in the target placeholder 0055 DropArea { 0056 id: placeholderDropArea 0057 0058 keys: orderingPlaceholder.targetPlaceholderKey 0059 anchors.fill: parent 0060 0061 onDropped: { 0062 var element = drag.source 0063 var modelObj = { 0064 "elementValue" : element.draggableText, 0065 "borderColor" : "#808080" 0066 } 0067 if (element.placeholderName === "origin" && placeholderName === "target") { 0068 targetListModel.append(modelObj) 0069 targetListModel.setProperty(0,"placeholderName", "target") 0070 originListModel.remove(drag.source.index) 0071 } 0072 0073 if (element.placeholderName === "target" && placeholderName === "origin") { 0074 originListModel.append(modelObj) 0075 originListModel.setProperty(0,"placeholderName", "origin") 0076 targetListModel.remove(drag.source.index) 0077 } 0078 } 0079 0080 Flickable { 0081 id: flick 0082 width: parent.width 0083 height: parent.height 0084 clip: true 0085 flickableDirection: Flickable.VerticalFlick 0086 contentWidth: originListView.width + 2*0.01 * placeholderDropArea.width 0087 contentHeight: originListView.height + 2*0.01 * placeholderDropArea.width 0088 0089 Flow { 0090 id: originListView 0091 width: placeholderDropArea.width * 0.98 0092 spacing: 0.01 * placeholderDropArea.width 0093 anchors { 0094 top: flick.contentItem.top 0095 left: flick.contentItem.left 0096 margins: 0.01 * placeholderDropArea.width 0097 } 0098 0099 layoutDirection: (Core.isLeftToRightLocale(ApplicationSettings.locale)) ? Qt.LeftToRight : Qt.RightToLeft 0100 0101 Repeater { 0102 model: originPHDelegateModel 0103 } 0104 } 0105 } 0106 } 0107 } 0108 0109