Source

Target

Showing with 223 additions and 109 deletions
TEMPLATE = aux
OTHER_FILES += \
main.qml \
ButtonMenu.qml \
View.qml
......@@ -43,10 +43,11 @@
import QtQuick 2.1
import QtQuick.Window 2.1
import QtQuick.Controls 1.0
import QtQuick.XmlListModel 2.0
Rectangle {
Window {
width: 538 + frame.margins * 2
height: 360 + frame.margins * 2
......@@ -301,9 +302,9 @@ Rectangle {
target: loaderEditor.item
onAccepted: {
if (typeof itemValue === 'number')
model.setProperty(rowIndex, role, Number(parseFloat(loaderEditor.item.text).toFixed(0)))
model.setProperty(row, role, Number(parseFloat(loaderEditor.item.text).toFixed(0)))
else
model.setProperty(rowIndex, role, loaderEditor.item.text)
model.setProperty(row, role, loaderEditor.item.text)
}
}
sourceComponent: itemSelected ? editor : null
......
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>main.qml</file>
<file>images/selectedrow.png</file>
<file>images/header.png</file>
</qresource>
</RCC>
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "../../shared/qt_quick_controls_examplemain.h"
QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml)
SOURCES += \
$$PWD/main.cpp
TEMPLATE = aux
QT += qml quick
TARGET = tableview
qtHaveModule(widgets) {
QT += widgets
}
include(src/src.pri)
OTHER_FILES += \
main.qml
RESOURCES += \
resources.qrc
QT += qml quick
CONFIG += console
TARGET = text
qtHaveModule(widgets) {
QT += widgets
......@@ -12,8 +11,3 @@ OTHER_FILES += \
RESOURCES += \
resources.qrc
MOC_DIR = ./.moc
OBJECTS_DIR = ./.obj
UI_DIR = ./.ui
RCC_DIR = ./.rcc
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>main.qml</file>
<file>content/AndroidDelegate.qml</file>
<file>content/ButtonPage.qml</file>
<file>content/ProgressBarPage.qml</file>
<file>content/SliderPage.qml</file>
<file>content/TabBarPage.qml</file>
<file>content/TextInputPage.qml</file>
<file>images/button_default.png</file>
<file>images/button_pressed.png</file>
<file>images/navigation_next_item.png</file>
<file>images/navigation_previous_item.png</file>
<file>images/tab_selected.png</file>
<file>images/tabs_standard.png</file>
<file>images/textinput.png</file>
<file>images/toolbar.png</file>
</qresource>
</RCC>
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "../../shared/qt_quick_controls_examplemain.h"
QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml)
SOURCES += \
$$PWD/main.cpp
TEMPLATE = aux
QT += qml quick
TARGET = touch
qtHaveModule(widgets) {
QT += widgets
}
include(src/src.pri)
OTHER_FILES += \
main.qml \
......@@ -8,3 +14,6 @@ OTHER_FILES += \
content/SliderPage.qml \
content/TabBarPage.qml \
content/TextInputPage.qml
RESOURCES += \
resources.qrc
......@@ -106,7 +106,7 @@ MenuPrivate {
/*! \internal
\omit
Documented in qtmenu.cpp.
Documented in qqquickmenu.cpp.
\endomit
*/
function addMenu(title) {
......@@ -115,7 +115,7 @@ MenuPrivate {
/*! \internal
\omit
Documented in qtmenu.cpp.
Documented in qquickmenu.cpp.
\endomit
*/
function insertMenu(index, title) {
......
......@@ -47,7 +47,7 @@ import QtQuick.Controls.Private 1.0
\qmltype MenuBar
\inqmlmodule QtQuick.Controls 1.0
\since QtQuick.Controls 1.0
\ingroup menus
\ingroup applicationwindow
\brief Provides a horizontal menu bar.
\code
......
......@@ -162,6 +162,7 @@ FocusScope {
contentItem.parent = internal.flickableItem.contentItem
}
internal.flickableItem.anchors.fill = viewportItem
internal.flickableItem.interactive = false
}
......
......@@ -166,6 +166,9 @@ Control {
/*! \internal */
property bool __horizontal: orientation === Qt.Horizontal
/*! \internal */
property real __handlePos: range.valueForPosition(__horizontal ? fakeHandle.x : fakeHandle.y)
activeFocusOnTab: true
Accessible.role: Accessible.Slider
......@@ -198,10 +201,16 @@ Control {
inverted: __horizontal ? false : true
positionAtMinimum: 0
positionAtMaximum: __horizontal ? slider.width : slider.height
positionAtMaximum: __horizontal ? slider.width - fakeHandle.width : slider.height - fakeHandle.height
}
Item { id: fakeHandle }
Item {
id: fakeHandle
anchors.verticalCenter: __horizontal ? parent.verticalCenter : undefined
anchors.horizontalCenter: !__horizontal ? parent.horizontalCenter : undefined
width: __panel.handleWidth
height: __panel.handleHeight
}
MouseArea {
id: mouseArea
......@@ -212,22 +221,27 @@ Control {
width: parent.width
height: parent.height
drag.target: fakeHandle
drag.axis: __horizontal ? Drag.XAxis : Drag.YAxis
drag.minimumX: range.positionAtMinimum
drag.maximumX: range.positionAtMaximum
function clamp ( val ) {
return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val))
}
onMouseXChanged: {
if (pressed && __horizontal) {
var pos = clamp (mouse.x - fakeHandle.width/2)
fakeHandle.x = pos
}
}
onMouseYChanged: {
if (pressed && !__horizontal) {
var pos = clamp (mouse.y - fakeHandle.height/2)
fakeHandle.y = pos
}
}
onPressed: {
if (slider.activeFocusOnPress)
slider.forceActiveFocus();
// Clamp the value
var current = __horizontal ? mouse.x : mouse.y
var minimum = __horizontal ? drag.minimumX : drag.minimumY
var maximum = __horizontal ? drag.maximumX : drag.maximumY
var newVal = Math.max(current, minimum);
newVal = Math.min(newVal, maximum);
range.position = newVal;
}
onReleased: {
......@@ -238,13 +252,10 @@ Control {
}
}
// Range position normally follow fakeHandle, except when
// 'updateValueWhileDragging' is false. In this case it will only follow
// if the user is not pressing the handle.
// Range position normally follows handle, except when
// 'updateValueWhileDragging' is false.
Binding {
when: updateValueWhileDragging || !mouseArea.pressed
when: updateValueWhileDragging && !mouseArea.drag.active
target: range
property: "position"
value: __horizontal ? fakeHandle.x : fakeHandle.y
......
......@@ -231,9 +231,9 @@ Item {
function clampedMinMax(value, minimum, maximum)
{
if (minimum !== -1 && value < minimum)
if (value < minimum)
value = minimum
if (maximum !== -1 && value > maximum)
if (value > maximum)
value = maximum
return value
}
......@@ -286,8 +286,7 @@ Item {
var fillItem = __items[fillIndex]
var superfluous = root[d.size] - d.accumulatedSize(0, __items.length, false)
var s = Math.max(superfluous, fillItem.Layout[minimum])
if (fillItem.Layout[maximum] !== -1)
s = Math.min(s, fillItem.Layout[maximum])
s = Math.min(s, fillItem.Layout[maximum])
fillItem[d.size] = s
}
......
......@@ -88,9 +88,9 @@ import QtQuick.Controls.Styles 1.0
on the model, and enable sort indicators on headers.
\list
\li sortColumnIndex - The index of the current sort column
\li sortIndicatorVisible - Whether the sort indicator should be enabled
\li sortIndicatorOrder - Qt.AscendingOrder or Qt.DescendingOrder depending on state
\li int sortIndicatorColumn - The index of the current sort column
\li bool sortIndicatorVisible - Whether the sort indicator should be enabled
\li enum sortIndicatorOrder - Qt.AscendingOrder or Qt.DescendingOrder depending on state
\endlist
*/
......@@ -131,8 +131,8 @@ ScrollView {
\li itemSelected - if the item is currently selected
\li itemValue - the value or text for this item
\li itemTextColor - the default text color for an item
\li rowIndex - the index of the row
\li columnIndex - the index of the column
\li row - the index of the row
\li column - the index of the column
\li itemElideMode - the elide mode of the column
\li itemTextAlignment - the horizontal text alignment of the column
\endlist
......@@ -171,7 +171,7 @@ ScrollView {
/*! Index of the current sort column.
The default value is \c {0}. */
property int sortColumnIndex
property int sortIndicatorColumn
/*! This property shows or hides the sort indicator
The default value is \c false.
......@@ -202,10 +202,6 @@ ScrollView {
This is the content footer of the TableView */
property alias contentFooter: listView.footer
/*! \qmlproperty Item TableView::currentRowItem
This is the current item of the TableView */
property alias currentRowItem: listView.currentItem
/*! \qmlproperty int TableView::rowCount
The current number of rows */
readonly property alias rowCount: listView.count
......@@ -227,15 +223,18 @@ ScrollView {
*/
property alias currentRow: listView.currentIndex
/*! \internal */
property alias __currentRowItem: listView.currentItem
/*! \qmlsignal TableView::activated()
Emitted when the user activates an item by single or double-clicking (depending on the platform).
*/
signal activated
/*!
\qmlmethod TableView::positionViewAtIndex
\qmlmethod TableView::positionViewAtRow( int row, PositionMode mode )
Positions the view such that the \a index is at the position specified by \a mode:
Positions the view such that the specified \a row is at the position defined by \a mode:
\list
\li ListView.Beginning - position item at the top of the view.
\li ListView.Center - position item in the center of the view.
......@@ -245,29 +244,41 @@ ScrollView {
at the top of the view.
\endlist
If using the \a index to position the view creates an empty space at the beginning
If positioning the \a row creates an empty space at the beginning
or end of the view, then the view is positioned at the boundary.
The correct way to bring an item into view is with positionViewAtIndex.
Note that this method should only be called after the Component has completed.
To position the view at startup, this method should be called by Component.onCompleted.
For example, to position the view at the end at startup:
\code
Component.onCompleted: table.positionViewAtIndex(rowCount -1, ListView.Contain)
Component.onCompleted: table.positionViewAtRow(rowCount -1, ListView.Contain)
\endcode
Depending on how the model is populated, the model may not be ready when
TableView Component.onCompleted is called. In that case you may need to
delay the call to positionViewAtIndex by using a \l {Timer}.
delay the call to positionViewAtRow by using a \l {Timer}.
\note This method should only be called after the component has completed.
*/
function positionViewAtRow(row, mode) {
listView.positionViewAtRow(row, mode)
}
/*!
\qmlmethod int TableView::rowAt( int x, int y )
Returns the index of the visible row at the point \a x, \a y in content
coordinates. If there is no visible row at the point specified, \c -1 is returned.
\note This method should only be called after the component has completed.
*/
function positionViewAtIndex(index, mode) {
listView.positionViewAtIndex(index, mode)
function rowAt(x, y) {
var obj = root.mapToItem(listView.contentItem, x, y)
return listView.indexAt(obj.x, obj.y)
}
style: Qt.createComponent(Settings.theme() + "/TableViewStyle.qml", root)
......@@ -304,8 +315,9 @@ ScrollView {
anchors.topMargin: tableHeader.height
anchors.fill: parent
currentIndex: -1
visible: columns.length > 0
interactive: false
SystemPalette {
id: palette
colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
......@@ -423,7 +435,7 @@ ScrollView {
delegate: Item {
id: rowitem
width: row.width
width: itemrow.width
height: rowstyle.height
property int rowIndex: model.index
......@@ -437,6 +449,7 @@ ScrollView {
sourceComponent: root.rowDelegate
// Row fills the view width regardless of item size
// But scrollbar should not adjust to it
height: item ? item.height : 16
width: parent.width + __scroller.horizontalScrollBar.width
x: flickableItem.contentX
......@@ -444,14 +457,14 @@ ScrollView {
// Note: these properties should be mirrored in the row filler as well
readonly property bool alternateBackground: rowitem.alternateBackground
readonly property bool rowSelected: rowitem.ListView.isCurrentItem
readonly property int index: rowitem.rowIndex
readonly property int row: rowitem.rowIndex
readonly property var model: listView.model
readonly property var modelData: rowitem.itemModelData
readonly property var itemModel: rowitem.itemModel
readonly property bool hasActiveFocus: root.activeFocus
}
Row {
id: row
id: itemrow
anchors.left: parent.left
height: parent.height
Repeater {
......@@ -471,8 +484,8 @@ ScrollView {
property var itemValue: __getValue()
property bool itemSelected: rowitem.ListView.isCurrentItem
property color itemTextColor: itemSelected ? __style.highlightedTextColor : __style.textColor
property int rowIndex: rowitem.rowIndex
property int columnIndex: index
property int row: rowitem.rowIndex
property int column: index
property int itemElideMode: columns[index].elideMode
property int itemTextAlignment: columns[index].horizontalAlignment
property string role: columns[index].role
......@@ -538,7 +551,7 @@ ScrollView {
anchors.left: parent.left
anchors.right: parent.right
property string itemValue: columns[index].title
property string itemSort: (sortIndicatorVisible && index == sortColumnIndex) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
property string itemSort: (sortIndicatorVisible && index == sortIndicatorColumn) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
property bool itemPressed: headerClickArea.pressed
property bool itemContainsMouse: headerClickArea.containsMouse
property string itemPosition: columns.length === 1 ? "only" :
......@@ -560,9 +573,9 @@ ScrollView {
hoverEnabled: true
anchors.fill: parent
onClicked: {
if (sortColumnIndex == index)
if (sortIndicatorColumn == index)
sortIndicatorOrder = sortIndicatorOrder == Qt.AscendingOrder ? Qt.DescendingOrder : Qt.AscendingOrder
sortColumnIndex = index
sortIndicatorColumn = index
}
// Here we handle moving header sections
// NOTE: the direction is different from the master branch
......@@ -592,8 +605,8 @@ ScrollView {
items.splice(index, 1);
items.splice(repeater.targetIndex, 0, columns[index]);
columns = items
if (sortColumnIndex == index)
sortColumnIndex = repeater.targetIndex
if (sortIndicatorColumn == index)
sortIndicatorColumn = repeater.targetIndex
}
repeater.targetIndex = -1
}
......@@ -605,7 +618,7 @@ ScrollView {
Loader {
id: draghandle
property string itemValue: columns[index].title
property string itemSort: (sortIndicatorVisible && index == sortColumnIndex) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
property string itemSort: (sortIndicatorVisible && index == sortIndicatorColumn) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
property bool itemPressed: headerClickArea.pressed
property bool itemContainsMouse: headerClickArea.containsMouse
property string itemPosition
......
src/controls/doc/images/qtquickcontrols-example-stackview.png

22.1 KB

/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\group indicators
\title Status Indicators
*/
......@@ -27,5 +27,5 @@
/*!
\group menus
\title Application Menus
\title Menus
*/