summaryrefslogtreecommitdiffstats
path: root/framework/qml/AutocompleteLineEdit.qml
diff options
context:
space:
mode:
Diffstat (limited to 'framework/qml/AutocompleteLineEdit.qml')
-rw-r--r--framework/qml/AutocompleteLineEdit.qml28
1 files changed, 20 insertions, 8 deletions
diff --git a/framework/qml/AutocompleteLineEdit.qml b/framework/qml/AutocompleteLineEdit.qml
index dbe00421..e7518867 100644
--- a/framework/qml/AutocompleteLineEdit.qml
+++ b/framework/qml/AutocompleteLineEdit.qml
@@ -24,10 +24,13 @@ import org.kde.kirigami 1.0 as Kirigami
24import org.kube.framework 1.0 as Kube 24import org.kube.framework 1.0 as Kube
25 25
26Kube.TextField { 26Kube.TextField {
27 id: textField 27 id: root
28 28
29 property string searchTerm 29 property string searchTerm
30 property variant model 30 property variant model
31
32 selectByMouse: true
33
31 onTextChanged: { 34 onTextChanged: {
32 if (text.length >= 2) { 35 if (text.length >= 2) {
33 searchTerm = text 36 searchTerm = text
@@ -68,8 +71,11 @@ Kube.TextField {
68 } 71 }
69 72
70 function accept() { 73 function accept() {
71 textField.text = listView.currentItem.text; 74 if (listView.currentItem) {
75 root.text = listView.currentItem.text;
76 }
72 popup.close() 77 popup.close()
78 root.accepted();
73 } 79 }
74 80
75 function abort() { 81 function abort() {
@@ -79,9 +85,9 @@ Kube.TextField {
79 Controls2.Popup { 85 Controls2.Popup {
80 id: popup 86 id: popup
81 x: 0 87 x: 0
82 y: textField.y + textField.height 88 y: root.height
83 padding: 0 89 padding: 0
84 contentWidth: rect.width 90 width: root.width
85 contentHeight: rect.height 91 contentHeight: rect.height
86 92
87 Rectangle { 93 Rectangle {
@@ -91,7 +97,7 @@ Kube.TextField {
91 anchors.left: popup.left 97 anchors.left: popup.left
92 98
93 height: listView.contentHeight 99 height: listView.contentHeight
94 width: textField.width 100 width: popup.width
95 101
96 border.color: Kube.Colors.textColor 102 border.color: Kube.Colors.textColor
97 color: Kube.Colors.backgroundColor 103 color: Kube.Colors.backgroundColor
@@ -99,16 +105,16 @@ Kube.TextField {
99 radius: 5 105 radius: 5
100 ListView { 106 ListView {
101 id: listView 107 id: listView
102 height: childrenRect.height 108 height: contentHeight
103 width: parent.width 109 width: parent.width
104 interactive: true 110 interactive: true
105 model: textField.model 111 model: root.model
106 delegate: Kirigami.AbstractListItem { 112 delegate: Kirigami.AbstractListItem {
107 id: listDelegate 113 id: listDelegate
108 property string text: model.text 114 property string text: model.text
109 115
110 width: listView.width 116 width: listView.width
111 height: textField.height 117 height: root.height
112 118
113 enabled: true 119 enabled: true
114 supportsMouseEvents: true 120 supportsMouseEvents: true
@@ -128,11 +134,17 @@ Kube.TextField {
128 anchors { 134 anchors {
129 verticalCenter: parent.verticalCenter 135 verticalCenter: parent.verticalCenter
130 left: parent.left 136 left: parent.left
137 right: parent.right
131 } 138 }
132 139
133 Kube.Label{ 140 Kube.Label{
141 anchors {
142 left: parent.left
143 right: parent.right
144 }
134 text: model.text 145 text: model.text
135 color: listDelegate.checked ? Kube.Colors.highlightedTextColor : Kube.Colors.textColor 146 color: listDelegate.checked ? Kube.Colors.highlightedTextColor : Kube.Colors.textColor
147 elide: Text.ElideRight
136 } 148 }
137 } 149 }
138 } 150 }