1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Qt Components project.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
47 property alias text: textArea.text
49 // Symbian specific API
50 property bool platformInverted: false
51 property bool platformSubItemIndicator: false
52 property real platformLeftMargin: platformStyle.paddingLarge
56 width: parent.width; height: privateStyle.menuItemHeight
61 function bg_postfix() {
62 if (activeFocus && android.listInteractionMode == Android.KeyNavigation)
64 else if (mouseArea.pressed && mouseArea.containsMouse && !mouseArea.canceled)
70 function textColor() {
72 return root.platformInverted ? platformStyle.colorDisabledLightInverted
73 : platformStyle.colorDisabledLight
74 else if (activeFocus && android.listInteractionMode == Android.KeyNavigation)
75 return root.platformInverted ? platformStyle.colorHighlightedInverted
76 : platformStyle.colorHighlighted
77 else if (mouseArea.pressed && mouseArea.containsMouse)
78 return root.platformInverted ? platformStyle.colorPressedInverted
79 : platformStyle.colorPressed
81 return root.platformInverted ? platformStyle.colorNormalLightInverted
82 : platformStyle.colorNormalLight
87 source: privateStyle.imagePath("qtg_fr_list_" + internal.bg_postfix(), root.platformInverted)
88 border { left: 20; top: 20; right: 20; bottom: 20 }
95 verticalCenter: parent.verticalCenter
97 leftMargin: platformLeftMargin
98 right: iconLoader.status == Loader.Ready ? iconLoader.left : parent.right
99 rightMargin: iconLoader.status == Loader.Ready ? platformStyle.paddingMedium : privateStyle.scrollBarThickness
101 font { family: platformStyle.fontFamilyRegular; pixelSize: platformStyle.fontSizeMedium }
102 color: internal.textColor()
103 horizontalAlignment: Text.AlignLeft
104 elide: Text.ElideRight
109 sourceComponent: root.platformSubItemIndicator ? subItemIcon : undefined
112 rightMargin: privateStyle.scrollBarThickness
113 verticalCenter: parent.verticalCenter
121 source: privateStyle.imagePath("qtg_graf_drill_down_indicator", platformInverted)
122 sourceSize.width: platformStyle.graphicSizeSmall
123 sourceSize.height: platformStyle.graphicSizeSmall
124 mirror: LayoutMirroring.enabled
132 property bool canceled: false
138 android.listInteractionMode = Android.TouchInteraction
139 privateStyle.play(Android.BasicItem)
147 privateStyle.play(Android.PopupClose)
149 onExited: canceled = true
153 event.accepted = true
157 case Qt.Key_Return: {
158 if (!event.isAutoRepeat) {
159 if (android.listInteractionMode != Android.KeyNavigation)
160 android.listInteractionMode = Android.KeyNavigation
168 if (android.listInteractionMode != Android.KeyNavigation) {
169 android.listInteractionMode = Android.KeyNavigation
170 if (ListView.view != null)
171 ListView.view.positionViewAtIndex(index, ListView.Beginning)
173 if (ListView.view != null)
174 ListView.view.decrementCurrentIndex()
176 event.accepted = false
182 if (android.listInteractionMode != Android.KeyNavigation) {
183 android.listInteractionMode = Android.KeyNavigation
184 if (ListView.view != null)
185 ListView.view.positionViewAtIndex(index, ListView.Beginning)
187 if (ListView.view != null)
188 ListView.view.incrementCurrentIndex()
190 event.accepted = false
196 // If this MenuItem belongs to Menu invoke highlight
197 // in other cases consume event but do nothing
198 if (ListView.view == null && android.listInteractionMode != Android.KeyNavigation)
199 android.listInteractionMode = Android.KeyNavigation
203 event.accepted = false