Warning, /maui/mauikit/src/controls.6/TabView.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQml 0003 0004 import QtQuick.Controls 0005 import QtQuick.Layouts 0006 import Qt5Compat.GraphicalEffects 0007 0008 import org.mauikit.controls 1.3 as Maui 0009 0010 /** 0011 * @brief Container to organize items as a tab view. 0012 * 0013 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-pane.html">This controls inherits from QQC2 Pane, to checkout its inherited properties refer to the Qt Docs.</a> 0014 * 0015 * The TabView organizes its children into different tabs - a tab for each child. 0016 * There are two ways for adding tabs to this view. The first one and easier is to declare the items as children. This will create a tab for each declared child item. 0017 * @see content 0018 * 0019 * @code 0020 * TabView 0021 * { 0022 * Rectangle 0023 * { 0024 * TabViewInfo.tabTitle: "Tab1" 0025 * TabViewInfo.tabIcon: "folder" 0026 * color: "blue" 0027 * } 0028 * 0029 * Rectangle 0030 * { 0031 * TabViewInfo.tabTitle: "Tab2" 0032 * TabViewInfo.tabIcon: "folder" 0033 * color: "yellow" 0034 * } 0035 * } 0036 * @endcode 0037 * 0038 * The second way to create tabs dynamically by adding new items using the control functions. 0039 * @see addTab 0040 * 0041 * @code 0042 * TabView 0043 * { 0044 * id: _tabView 0045 * tabBar.leftContent: Button 0046 * { 0047 * text: "Add Tab" 0048 * onClicked: 0049 * { 0050 * _tabView.addTab(_component) 0051 * } 0052 * } 0053 * 0054 * Component 0055 * { 0056 * id: _component 0057 * Rectangle 0058 * { 0059 * TabViewInfo.tabTitle: "Tab1" 0060 * TabViewInfo.tabIcon: "folder" 0061 * color: "blue" 0062 * } 0063 * } 0064 * } 0065 * @endcode 0066 * 0067 * @section structure Structure 0068 * 0069 * @note If you use this as the application window main control, remember you can use the attached Controls.showCSD property to display the window control buttons. 0070 * @code 0071 * TabView 0072 * { 0073 * Controls.showCSD : true 0074 * } 0075 * @endcode 0076 * 0077 * The TabView has two main sections, [1] the main contents area and [2] the tab bar, where the tab buttons - representing all the tab views - are listed. 0078 * 0079 * The tab bar listing has two "modes": one designed to fit desktop computers as a horizontal set of tab buttons; and the other one - more mobile friendly - as a grid overview of miniatures of the tab-views. Both modes can be toggle by using the mobile property. 0080 * @see mobile 0081 * 0082 * The main tab bar - usually in the top section - can be moved to the bottom area, for better reachability. 0083 * @see altTabBar 0084 * 0085 * The tab bar component is exposed via an alias, and items can be added to it - to the left or right side, using the leftContent or rightContent properties. This tab bar is handled by a MauiKit TabBar. 0086 * @see tabBar 0087 * @see TabBar 0088 * 0089 * @image html TabView/tabviews.png "TabView different states/sections. Further down the regular tab view with a tab bar on top, in the middle the tab view overview mode, and in the front the mobile mode with a single tab - other tab buttons can be flicked." 0090 * 0091 * @subsection finder Finder 0092 * The TabView has an integrated dialog to quickly perform searchers for an tab. 0093 * 0094 * @section notes Notes 0095 * 0096 * @subsection tabinfo Tabs Info 0097 * To add information, such as title, icon, etc, to the views, there is the `TabViewInfo` attached property. 0098 * Some of the available properties are: 0099 * - TabViewInfo.tabTitle 0100 * - TabViewInfo.tabToolTipText 0101 * - TabViewInfo.tabColor 0102 * - TabViewInfo.tabIcon 0103 * @see TabViewInfo 0104 * 0105 * @subsection menus Menus 0106 * It is possible to add actions to the the tab contextual menus. 0107 * @see menuActions 0108 * 0109 * @subsection customize Custom Tab Button 0110 * It is possible to set a different tab button for the tab bar. This will allow you to have more control about how the tab button is presented. To make it easier to integrate there is a control template that can be use as a base TabViewButton - different from TabButton. 0111 * @see tabViewButton 0112 * @see TabViewButton 0113 * 0114 * @note If you plan to change the tab button, consider using TabViewButton as a base, since it already has many of the needed things by the TabView to be integrated smoothly. 0115 * 0116 * @subsection functionality Functionality 0117 * 0118 * By default when clicking/tapping on the current tab button, the overview of tabs miniatures will be opened. The overview can also be oped using the corresponding function. 0119 * @see openOverview 0120 * @see closeOverview 0121 * 0122 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/TabView.qml">You can find a more complete example at this link.</a> 0123 * 0124 */ 0125 Pane 0126 { 0127 id: control 0128 0129 /** 0130 * @brief Each one of the items declared as the children of this component will become a tab view. 0131 * @property list<QtObject> TabView::content 0132 */ 0133 default property alias content: _listView.contentData 0134 0135 /** 0136 * @brief An alias to the model of the container. 0137 * @property model TabView::contentModel 0138 */ 0139 readonly property alias contentModel: _listView.contentModel 0140 0141 /** 0142 * @brief Current index number of the current tab in the view port. 0143 * @property int TabView::currentIndex 0144 */ 0145 property alias currentIndex: _listView.currentIndex 0146 0147 /** 0148 * @brief The current item/tab view in focus. 0149 * @property Item TabView::currentItem 0150 */ 0151 readonly property alias currentItem: _listView.currentItem 0152 0153 /** 0154 * @brief The total amount of tab views in this container. 0155 * @property int TabView::count 0156 */ 0157 property alias count: _listView.count 0158 0159 /** 0160 * @brief An alias to a place holder text handled by a MauiKit Holder control. This is useful to display messages when there is not tab views in this container. To see how to set the message, icon and actions to it checkout the Holder documentation. 0161 * @see holder 0162 * @property Holder TabView::holder 0163 */ 0164 property alias holder : _holder 0165 0166 /** 0167 * @brief Whether the layout of the tab bar should be in mobile or desktop mode. In mobile mode there is only one tab button in the tab bar view port, other tab button can be navigated by using the touch swipe gesture. In mobile mode the main method to switch between tab views is using the overview. 0168 * @see structure 0169 */ 0170 property bool mobile : control.width <= Maui.Style.units.gridUnit * 30 0171 0172 /** 0173 * @brief Whether the tab bar hosting the tab buttons, should go in the bottom section or not. Moving it to the bottom section is a good idea for reachability in hand-held devices, such a phones. You can check if the current platform is a mobile one using the Handy attached property `Handy.isMobile` 0174 * @see Handy 0175 * 0176 */ 0177 property bool altTabBar : false 0178 0179 /** 0180 * @brief Whether the view will support swipe gestures for switching between tab views. 0181 */ 0182 property bool interactive: Maui.Handy.isTouch 0183 0184 /** 0185 * @brief Checks if the overview mode is open. 0186 */ 0187 readonly property bool overviewMode : _stackView.depth === 2 0188 0189 /** 0190 * @brief An alias to the tab bar element. This is exposed so any other items can be placed on the right or left sections of it, or to fine tweak its public properties. 0191 * @see TabBar 0192 * @property TabBar TabView::tabBar 0193 */ 0194 property alias tabBar: _tabBar 0195 0196 /** 0197 * @brief An alias to the contextual menu for the tab buttons. This has a child property named index, which refers to the index number of the tab for which the contextual menu was opened. 0198 * @see ContextualMenu 0199 * @property ContextualMenu TabView::menu 0200 */ 0201 property alias menu :_menu 0202 0203 /** 0204 * @brief A set of actions can be added to the tab button contextual menu. 0205 * @code 0206 * TabView 0207 * { 0208 * id: _tabView 0209 * menuActions: Action 0210 * { 0211 * text: "Detach Tab" 0212 * onTriggered: 0213 * { 0214 * console.log("Detach tab at index, ", _tabView.menu.index) 0215 * } 0216 * } 0217 * } 0218 * @endcode 0219 */ 0220 property list<Action> menuActions 0221 0222 /** 0223 * @brief The component to be used as the tab button in the tab bar. This can be changed to any other item, but it is recommend it to use TabViewButton as the base of the new custom control for the better integration. 0224 * @see TabViewButton 0225 */ 0226 property Component tabViewButton : _tabButtonComponent 0227 0228 onWidthChanged: _tabBar.positionViewAtIndex(control.currentIndex) 0229 onCurrentIndexChanged: _tabBar.positionViewAtIndex(control.currentIndex) 0230 0231 spacing: 0 0232 padding: 0 0233 0234 Component 0235 { 0236 id: _tabButtonComponent 0237 0238 Maui.TabViewButton 0239 { 0240 id: _tabButton 0241 tabView: control 0242 closeButtonVisible: !control.mobile 0243 0244 onClicked: 0245 { 0246 if(_tabButton.mindex === control.currentIndex && control.count > 1) 0247 { 0248 control.openOverview() 0249 return 0250 } 0251 0252 _listView.setCurrentIndex(_tabButton.mindex) 0253 } 0254 0255 onRightClicked: 0256 { 0257 openTabMenu(_tabButton.mindex) 0258 } 0259 0260 onCloseClicked: 0261 { 0262 control.closeTabClicked(_tabButton.mindex) 0263 } 0264 } 0265 } 0266 0267 /** 0268 * @brief Emitted when the new-tab button has been clicked. This is the same as catching the signal from the TabBar element itself, using the exposed alias property. 0269 * @see tabBar 0270 */ 0271 signal newTabClicked() 0272 0273 /** 0274 * @brief Emitted when the close button has been clicked on a tab button, or tab miniature in the overview. This signal sends the index of the tab. To correctly close the tab and release the resources, use the function `closeTab()`. 0275 * @param The index of the tab requested to be closed. 0276 * @see closeTab 0277 */ 0278 signal closeTabClicked(int index) 0279 0280 Keys.enabled: true 0281 Keys.onPressed: (event) => 0282 { 0283 if((event.key === Qt.Key_H) && (event.modifiers & Qt.ControlModifier)) 0284 { 0285 control.findTab() 0286 } 0287 } 0288 0289 Maui.ContextualMenu 0290 { 0291 id: _menu 0292 parent: control 0293 property int index //tabindex 0294 0295 Repeater 0296 { 0297 model: control.menuActions 0298 delegate: MenuItem 0299 { 0300 action: modelData 0301 } 0302 } 0303 0304 MenuItem 0305 { 0306 text: i18nd("mauikit", "Open") 0307 icon.name: "tab-new" 0308 onTriggered: 0309 { 0310 _listView.setCurrentIndex(_menu.index) 0311 control.closeOverview() 0312 } 0313 } 0314 0315 MenuItem 0316 { 0317 text: i18nd("mauikit", "Close") 0318 icon.name: "tab-close" 0319 onTriggered: 0320 { 0321 control.closeTabClicked(_menu.index) 0322 } 0323 } 0324 } 0325 0326 data: Loader 0327 { 0328 id: _loader 0329 } 0330 0331 Component 0332 { 0333 id: _quickSearchComponent 0334 0335 Maui.PopupPage 0336 { 0337 id: _quickSearch 0338 persistent: false 0339 headBar.visible: true 0340 0341 onOpened: _quickSearchField.forceActiveFocus() 0342 0343 function find(query) 0344 { 0345 for(var i = 0; i < control.count; i ++) 0346 { 0347 var obj = _listView.contentModel.get(i) 0348 if(obj.Maui.TabViewInfo.tabTitle) 0349 { 0350 console.log("Trying to find tab", i, query, obj.Maui.TabViewInfo.tabTitle, String(obj.Maui.TabViewInfo.tabTitle).indexOf(query)) 0351 0352 if(String(obj.Maui.TabViewInfo.tabTitle).toLowerCase().indexOf(query.toLowerCase()) !== -1) 0353 { 0354 return i 0355 } 0356 } 0357 } 0358 0359 return -1 0360 } 0361 0362 Timer 0363 { 0364 id: _typingTimer 0365 interval: 250 0366 onTriggered: 0367 { 0368 var index = _quickSearch.find(_quickSearchField.text) 0369 if(index > -1) 0370 { 0371 _filterTabsList.currentIndex = index 0372 } 0373 } 0374 } 0375 0376 headBar.middleContent: TextField 0377 { 0378 id: _quickSearchField 0379 Layout.fillWidth: true 0380 Layout.maximumWidth: 500 0381 0382 onTextChanged: _typingTimer.restart() 0383 0384 onAccepted: 0385 { 0386 control.setCurrentIndex(_filterTabsList.currentIndex) 0387 _quickSearch.close() 0388 } 0389 0390 Keys.enabled: true 0391 0392 Keys.onPressed: (event) => 0393 { 0394 if((event.key === Qt.Key_Up)) 0395 { 0396 _filterTabsList.flickable.decrementCurrentIndex() 0397 } 0398 0399 if((event.key === Qt.Key_Down)) 0400 { 0401 _filterTabsList.flickable.incrementCurrentIndex() 0402 } 0403 } 0404 } 0405 0406 stack: Maui.ListBrowser 0407 { 0408 id: _filterTabsList 0409 Layout.fillWidth: true 0410 Layout.fillHeight: true 0411 currentIndex: _listView.currentIndex 0412 0413 model: _listView.count 0414 0415 delegate: Maui.ListDelegate 0416 { 0417 width: ListView.view.width 0418 0419 label: _listView.contentModel.get(index).Maui.TabViewInfo.tabTitle 0420 0421 onClicked: 0422 { 0423 currentIndex =index 0424 _listView.setCurrentIndex(index) 0425 _quickSearch.close() 0426 } 0427 } 0428 } 0429 } 0430 } 0431 0432 contentItem: Item 0433 { 0434 StackView 0435 { 0436 anchors.fill: parent 0437 id: _stackView 0438 0439 initialItem: Item 0440 { 0441 Maui.TabBar 0442 { 0443 id: _tabBar 0444 0445 z : _listView.z+1 0446 0447 anchors.left: parent.left 0448 anchors.right: parent.right 0449 Maui.Controls.showCSD : control.Maui.Controls.showCSD === true 0450 visible: _listView.count > 1 0451 0452 interactive: control.interactive 0453 showNewTabButton: !control.mobile 0454 0455 onNewTabClicked: control.newTabClicked() 0456 onNewTabFocused: 0457 { 0458 if(control.mobile) 0459 { 0460 _listView.setCurrentIndex(index) 0461 } 0462 } 0463 0464 position: control.altTabBar ? TabBar.Footer : TabBar.Header 0465 0466 Repeater 0467 { 0468 model: control.count 0469 delegate: control.tabViewButton 0470 } 0471 0472 // rightContent: Button 0473 // { 0474 // visible: control.mobile && control.count > 1 0475 // text: control.count 0476 // onClicked: openOverview() 0477 // } 0478 0479 Keys.onPressed: (event) => 0480 { 0481 if(event.key == Qt.Key_Return) 0482 { 0483 _listView.setCurrentIndex(currentIndex) 0484 } 0485 0486 if(event.key == Qt.Key_Down) 0487 { 0488 _listView.currentItem.forceActiveFocus() 0489 } 0490 } 0491 0492 states: [ State 0493 { 0494 when: !control.altTabBar && control.tabBar.visible 0495 0496 AnchorChanges 0497 { 0498 target: _tabBar 0499 anchors.top: parent.top 0500 anchors.bottom: undefined 0501 } 0502 0503 PropertyChanges 0504 { 0505 target: _tabBar 0506 position: TabBar.Header 0507 } 0508 }, 0509 0510 State 0511 { 0512 when: control.altTabBar && control.tabBar.visible 0513 0514 AnchorChanges 0515 { 0516 target: _tabBar 0517 anchors.top: undefined 0518 anchors.bottom: parent.bottom 0519 } 0520 0521 PropertyChanges 0522 { 0523 target: _tabBar 0524 position: ToolBar.Footer 0525 } 0526 } ] 0527 } 0528 0529 SwipeView 0530 { 0531 id: _listView 0532 anchors.fill: parent 0533 0534 anchors.bottomMargin: control.altTabBar && _tabBar.visible ? _tabBar.height : 0 0535 anchors.topMargin: !control.altTabBar && _tabBar.visible ? _tabBar.height : 0 0536 0537 interactive: false 0538 0539 spacing: control.spacing 0540 0541 clip: control.clip 0542 0543 orientation: ListView.Horizontal 0544 background: null 0545 0546 contentItem: ListView 0547 { 0548 id: _listView2 0549 model: _listView.contentModel 0550 interactive: false 0551 currentIndex: _listView.currentIndex 0552 0553 spacing: _listView.spacing 0554 0555 clip: false 0556 0557 orientation: ListView.Horizontal 0558 snapMode: ListView.SnapOneItem 0559 0560 boundsBehavior: Flickable.StopAtBounds 0561 boundsMovement :Flickable.StopAtBounds 0562 0563 preferredHighlightBegin: 0 0564 preferredHighlightEnd: width 0565 0566 highlightRangeMode: ListView.StrictlyEnforceRange 0567 highlightMoveDuration: 0 0568 highlightFollowsCurrentItem: true 0569 highlightResizeDuration: 0 0570 highlightMoveVelocity: -1 0571 highlightResizeVelocity: -1 0572 0573 maximumFlickVelocity: 4 * width 0574 0575 cacheBuffer: _listView.count * width 0576 keyNavigationEnabled : false 0577 keyNavigationWraps : false 0578 } 0579 } 0580 0581 Maui.Holder 0582 { 0583 id: _holder 0584 anchors.fill: parent 0585 visible: !control.count 0586 emojiSize: Maui.Style.iconSizes.huge 0587 } 0588 } 0589 0590 Component 0591 { 0592 id: _overviewComponent 0593 0594 Pane 0595 { 0596 id: _pane 0597 Maui.Theme.colorSet: Maui.Theme.View 0598 Maui.Theme.inherit: false 0599 0600 background: Rectangle 0601 { 0602 color: Maui.Theme.backgroundColor 0603 Loader 0604 { 0605 active: !Maui.Handy.isMobile 0606 asynchronous: true 0607 anchors.fill: parent 0608 sourceComponent: Item 0609 { 0610 DragHandler 0611 { 0612 acceptedDevices: PointerDevice.GenericPointer 0613 grabPermissions: PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType | PointerHandler.ApprovesTakeOverByAnything 0614 onActiveChanged: if (active) { control.Window.window.startSystemMove(); } 0615 } 0616 } 0617 } 0618 } 0619 0620 contentItem: Maui.GridBrowser 0621 { 0622 id: _overviewGrid 0623 model: control.count 0624 0625 currentIndex: control.currentIndex 0626 0627 itemSize: Math.min(200, availableWidth /2) 0628 0629 Loader 0630 { 0631 asynchronous: true 0632 anchors.bottom: parent.bottom 0633 anchors.right: parent.right 0634 anchors.margins: Maui.Style.space.big 0635 sourceComponent: Maui.FloatingButton 0636 { 0637 icon.name: "list-add" 0638 onClicked: control.newTabClicked() 0639 } 0640 } 0641 0642 onAreaClicked: 0643 { 0644 control.closeOverview() 0645 } 0646 0647 delegate: Item 0648 { 0649 height: GridView.view.cellHeight 0650 width: GridView.view.cellWidth 0651 0652 Maui.GridBrowserDelegate 0653 { 0654 id: _delegate 0655 0656 anchors.fill: parent 0657 anchors.margins: Maui.Style.space.medium 0658 0659 isCurrentItem : parent.GridView.isCurrentItem 0660 label1.text: _listView.contentModel.get(index).Maui.TabViewInfo.tabTitle 0661 // template.labelSizeHint: 32 0662 iconSource: "tab-new" 0663 flat: false 0664 0665 tooltipText: _listView.contentModel.get(index).Maui.TabViewInfo.tabToolTipText 0666 0667 Rectangle 0668 { 0669 parent: _delegate.background 0670 color: _listView.contentModel.get(index).Maui.TabViewInfo.tabColor 0671 height: 2 0672 width: parent.width*0.9 0673 anchors.bottom: parent.bottom 0674 anchors.horizontalCenter: parent.horizontalCenter 0675 } 0676 0677 onRightClicked: 0678 { 0679 _listView.setCurrentIndex(index) 0680 openTabMenu(_listView.currentIndex) 0681 } 0682 0683 onClicked: 0684 { 0685 control.closeOverview() 0686 _listView.setCurrentIndex(index) 0687 } 0688 0689 onPressAndHold: 0690 { 0691 _listView.setCurrentIndex(index) 0692 openTabMenu(control.currentIndex) 0693 } 0694 0695 template.iconComponent: Item 0696 { 0697 clip: true 0698 0699 ShaderEffectSource 0700 { 0701 id: _effect 0702 0703 anchors.centerIn: parent 0704 0705 readonly property double m_scale: Math.min(parent.height/sourceItem.height, parent.width/sourceItem.width) 0706 0707 height: sourceItem.height * m_scale 0708 width: sourceItem.width * m_scale 0709 0710 hideSource: false 0711 live: false 0712 smooth: true 0713 0714 textureSize: Qt.size(width,height) 0715 sourceItem: _listView.contentModel.get(index) 0716 layer.enabled: Maui.Style.enableEffects 0717 layer.smooth: true 0718 layer.effect: OpacityMask 0719 { 0720 maskSource: Rectangle 0721 { 0722 width: _effect.width 0723 height: _effect.height 0724 radius: Maui.Style.radiusV 0725 } 0726 } 0727 } 0728 0729 Maui.CloseButton 0730 { 0731 id: _closeButton 0732 visible: _delegate.isCurrentItem || _delegate.hovered || Maui.Handy.isMobile 0733 anchors.top: parent.top 0734 anchors.right: parent.right 0735 // anchors.margins: Maui.Style.space.small 0736 0737 onClicked: control.closeTabClicked(index) 0738 0739 background: Rectangle 0740 { 0741 radius: height/2 0742 color: _closeButton.hovered || _closeButton.containsPress ? Maui.Theme.negativeBackgroundColor : Maui.Theme.backgroundColor 0743 0744 Behavior on color 0745 { 0746 Maui.ColorTransition{} 0747 } 0748 } 0749 } 0750 } 0751 } 0752 } 0753 } 0754 } 0755 } 0756 } 0757 } 0758 0759 /** 0760 * @brief Close a tab view at a given index. This will release the resources, and move the focus to the previous tab view 0761 * @param index index of the tab to be closed 0762 */ 0763 function closeTab(index) 0764 { 0765 _listView.removeItem(_listView.itemAt(index)) 0766 // _tabBar.removeItem(_tabBar.itemAt(index)) 0767 0768 _listView.currentItemChanged() 0769 _listView.currentItem.forceActiveFocus() 0770 } 0771 0772 /** 0773 * @brief Adds a new tab view element, the passed element must be a component which will be created by the function and then added to the container 0774 * @param component a Component element hosting the actual element to be created. 0775 * @param properties set of values that can be passed as a map of properties to be assigned to the component when created 0776 * @param quiet optionally you can choose to create the tab quietly or not: by quietly it means that the tab-component will be instantiated and created but will not be focused right away. If quiet is set to `false` - to which it defaults - then after the creation of the component the new tab will get focused. 0777 */ 0778 function addTab(component, properties, quiet = false) : Item 0779 { 0780 if(control.overviewMode) 0781 { 0782 control.closeOverview() 0783 } 0784 0785 const object = component.createObject(control, properties); 0786 0787 _listView.addItem(object) 0788 0789 if(!quiet) 0790 { 0791 _listView.setCurrentIndex(Math.max(_listView.count -1, 0)) 0792 object.forceActiveFocus() 0793 } 0794 0795 return object 0796 } 0797 0798 /** 0799 * @brief Method to open the tab finder. 0800 */ 0801 function findTab() 0802 { 0803 if(control.count > 1) 0804 { 0805 _loader.sourceComponent = _quickSearchComponent 0806 _loader.item.open() 0807 } 0808 } 0809 0810 /** 0811 * @brief Method to open the tabs overview. 0812 */ 0813 function openOverview() 0814 { 0815 if(_stackView.depth === 2) 0816 { 0817 return 0818 } 0819 _stackView.push(_overviewComponent) 0820 } 0821 0822 /** 0823 * @brief Close the overview of miniature tabs. 0824 */ 0825 function closeOverview() 0826 { 0827 if(_stackView.depth === 1) 0828 { 0829 return 0830 } 0831 0832 _stackView.pop() 0833 } 0834 0835 /** 0836 * @brief Method to correctly move a tab from one place to another by using the index numbers 0837 * @param from the current index number of the tab to be moved 0838 * @param to the new index value to where to move the tab 0839 */ 0840 function moveTab(from, to) 0841 { 0842 _listView.moveItem(from, to) 0843 _tabBar.moveItem(from, to) 0844 0845 _listView.setCurrentIndex(to) 0846 _tabBar.setCurrentIndex(_listView.currentIndex) 0847 0848 _listView2.positionViewAtIndex(_listView.currentIndex, ListView.Contain) 0849 0850 _listView.currentItemChanged() 0851 _listView.currentItem.forceActiveFocus() 0852 } 0853 0854 /** 0855 * @brief This allows to change the current tab without breaking the bindings from the `currentIndex` property 0856 * @param index the index to change to 0857 */ 0858 function setCurrentIndex(index) 0859 { 0860 _tabBar.setCurrentIndex(index) 0861 _listView.setCurrentIndex(index) 0862 _listView.currentItem.forceActiveFocus() 0863 } 0864 0865 /** 0866 * @brief Return the Item of the tab view at a given index number 0867 * @return the Item element representing the tab view 0868 */ 0869 function tabAt(index) 0870 { 0871 return _listView.itemAt(index) 0872 } 0873 0874 /** 0875 * @brief Opens the tab contextual menu at a given index number 0876 */ 0877 function openTabMenu(index) 0878 { 0879 _menu.index = index 0880 _menu.show() 0881 } 0882 }