summaryrefslogtreecommitdiff
path: root/src/controls/TabView.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-04-25 10:11:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-30 13:06:23 +0200
commit3337fad0343da19ca4ede81b73ef3459862712aa (patch)
treeef7c3ea3b116967ac87f4009dbc433eb0bce2cba /src/controls/TabView.qml
parentba1051707c0ba65ecfbf2535e15a496e7f8ec75d (diff)
downloadqtquickcontrols-3337fad0343da19ca4ede81b73ef3459862712aa.tar.gz
TabView: use internally ListModel instead of JS array for tabs
Change-Id: I096571283dc66acbe86f75310b55d2da3ef808af Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/controls/TabView.qml')
-rw-r--r--src/controls/TabView.qml22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml
index 40cf5caa..456f4ba7 100644
--- a/src/controls/TabView.qml
+++ b/src/controls/TabView.qml
@@ -86,7 +86,7 @@ FocusScope {
function addTab(title, component) {
var tab = tabcomp.createObject(stack)
tab.sourceComponent = component
- __tabs.push(tab)
+ __tabs.append({tab: tab})
tab.parent = stack
tab.title = title
__setOpacities()
@@ -101,15 +101,15 @@ FocusScope {
tab.sourceComponent = component
tab.parent = stack
tab.title = title
- __tabs.splice(index, 0, tab);
+ __tabs.insert(index, {tab: tab})
__setOpacities()
return tab
}
/*! Removes and destroys a tab at the given \a index. */
function removeTab(index) {
- var tab = __tabs[index]
- __tabs.splice(index, 1);
+ var tab = __tabs.get(index).tab
+ __tabs.remove(index, 1)
tab.destroy()
if (currentIndex > 0)
currentIndex--
@@ -136,11 +136,11 @@ FocusScope {
/*! Returns the \l Tab item at \a index. */
function tabAt(index) {
- return __tabs[index]
+ return __tabs.get(index).tab
}
/*! \internal */
- property var __tabs: new Array()
+ property ListModel __tabs: ListModel { }
/*! \internal */
property Component style: Qt.createComponent(Settings.theme() + "/TabViewStyle.qml", root)
@@ -152,11 +152,11 @@ FocusScope {
/*! \internal */
function __setOpacities() {
- for (var i = 0; i < __tabs.length; ++i) {
- var child = __tabs[i];
+ for (var i = 0; i < __tabs.count; ++i) {
+ var child = __tabs.get(i).tab
child.visible = (i == currentIndex ? true : false)
}
- count = __tabs.length
+ count = __tabs.count
}
activeFocusOnTab: false
@@ -208,7 +208,7 @@ FocusScope {
Component.onCompleted: {
for (var i = 0 ; i < stack.children.length ; ++i) {
if (stack.children[i].Accessible.role === Accessible.LayeredPane)
- __tabs.push(stack.children[i])
+ __tabs.append({tab: stack.children[i]})
}
__setOpacities()
}
@@ -230,7 +230,7 @@ FocusScope {
for (var i = 0; i < children.length; ++i) {
var child = children[i]
if (child.Accessible.role === Accessible.LayeredPane) {
- __tabs.push(child)
+ __tabs.append({tab: child})
child.parent = stack
child.Component.onDestruction.connect(stack.onDynamicTabDestroyed.bind(child))
tabAdded = true