Warning, /rolisteam/rolisteam/src/libraries/mindmap/resources/qml/PackageItem.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick
0002 import QtQuick.Controls
0003 import Customization
0004 
0005 GroupBox {
0006     id: _root
0007     property QtObject style: Theme.styleSheet("Package")
0008     property QtObject packageItem
0009     property bool selected: false
0010     property bool dropOver: false
0011 
0012     signal addItem(var itemid)
0013     signal clicked(var mouse)
0014 
0015     padding: 0
0016 
0017     label : TextEdit {
0018         id: textEdit
0019         x:  _root.style.padding
0020         text: _root.packageItem.title
0021         color: _root.style.borderColor
0022         onEditingFinished: {
0023             _root.packageItem.title = field.text
0024             textEdit.readOnly = true
0025         }
0026 
0027     }
0028 
0029     Dialog {
0030         id: editTitle
0031         standardButtons: Dialog.Ok | Dialog.Cancel
0032         TextField {
0033             id: field
0034             placeholderText: qsTr("Title")
0035             text: _root.title
0036         }
0037         onAccepted: {
0038             _root.packageItem.title = field.text
0039             editTitle.close()
0040         }
0041     }
0042 
0043     x: packageItem.position.x
0044     y: packageItem.position.y
0045 
0046     onXChanged: {
0047         if(dragMouse.drag.active)
0048             packageItem.position=Qt.point(x, y)
0049     }
0050     onYChanged: {
0051         if(dragMouse.drag.active)
0052             packageItem.position=Qt.point(x, y)
0053     }
0054 
0055 
0056     background: Rectangle {
0057         color: _root.style.backgroundColor
0058         border.color: _root.style.borderColor
0059         border.width: _root.style.borderWidth
0060         Rectangle {
0061             border.width: 1
0062             border.color: "red"
0063             color: "transparent"
0064             visible: _root.selected
0065             anchors.fill: parent
0066         }
0067     }
0068 
0069     contentItem: MouseArea {
0070         id: dragMouse
0071         drag.target: _root
0072         drag.axis: Drag.XAndYAxis
0073         drag.minimumX: 0
0074         drag.minimumY: 0
0075         preventStealing: true
0076         drag.onActiveChanged: packageItem.isDragged = drag.active
0077         onDoubleClicked: {
0078             //editTitle.open()
0079             textEdit.readOnly = false
0080             textEdit.focus = true
0081         }
0082         onPressed: (mouse) => {_root.clicked(mouse)}
0083 
0084         Rectangle {
0085             id: _handle
0086             color: _root.style.borderColor
0087             width: _root.style.handleSize
0088             height: _root.style.handleSize
0089             x: dragMouse.width - width
0090             y: dragMouse.height - height
0091             onXChanged: {
0092                 if(_handleMouse.drag.active)
0093                     packageItem.width= _handle.x + _handle.width
0094             }
0095             onYChanged: {
0096                 if(_handleMouse.drag.active)
0097                     packageItem.height= _handle.y + _handle.height
0098             }
0099             MouseArea {
0100                     id: _handleMouse
0101                     anchors.fill: parent
0102                     drag.target: _handle
0103                     drag.axis: Drag.XAndYAxis
0104                     drag.minimumX: 0
0105                     drag.minimumY: 0
0106                     preventStealing: true
0107             }
0108         }
0109     }
0110 
0111 
0112     DropArea {
0113         anchors.fill: parent
0114         keys: [ "rmindmap/reparenting","text/plain" ]
0115         onDropped: (drop)=>{
0116             addItem(drop.text)
0117         }
0118         onEntered: (drag)=>{
0119             if(drag.source === root)
0120                 drag.accepted = false
0121 
0122             if(drag.source !== root)
0123                 _root.dropOver = true
0124         }
0125         onExited:_root.dropOver = false
0126     }
0127 }
0128