Warning, /maui/mauikit/src/controls.6/SplitView.qml is written in an unsupported language. File is not indexed.
0001 // Copyright 2018-2020 Camilo Higuita <milo.h@aol.com> 0002 // Copyright 2018-2020 Nitrux Latinoamericana S.C. 0003 // 0004 // SPDX-License-Identifier: GPL-3.0-or-later 0005 0006 0007 import QtQuick 0008 import QtQuick.Controls 0009 0010 import org.mauikit.controls 1.3 as Maui 0011 0012 /** 0013 * @inherit QtQuick.Controls.SplitView 0014 * @brief An extension to the QQC2 SplitView control, adding some extra functionality. 0015 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-splitview.html">This controls inherits from QQC2 SplitView, to checkout its inherited properties refer to the Qt Docs.</a> 0016 * This control add a quick way to add split views and remove them. 0017 * @see addSplit 0018 * @see closeSplit 0019 * 0020 * @image html Misc/splitview.png 0021 * 0022 * @code 0023 * Maui.SplitView 0024 * { 0025 * anchors.fill: parent 0026 * 0027 * Maui.SplitViewItem 0028 * { 0029 * Rectangle 0030 * { 0031 * color: "orange" 0032 * anchors.fill: parent 0033 * } 0034 * } 0035 * 0036 * Maui.SplitViewItem 0037 * { 0038 * Rectangle 0039 * { 0040 * color: "yellow" 0041 * anchors.fill: parent 0042 * } 0043 * } 0044 * } 0045 * @endcode 0046 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/SplitView.qml">You can find a more complete example at this link.</a> 0047 */ 0048 SplitView 0049 { 0050 id: control 0051 0052 clip: false 0053 0054 onCurrentItemChanged: 0055 { 0056 currentItem.forceActiveFocus() 0057 } 0058 0059 /** 0060 * @brief Forces to close the split view at a given index. 0061 * If there is onyl one view at the time, then this method does nothing, in order to keep the control with at least one view. 0062 * @note This function calls to the SplitView `removeItem` function. 0063 * @param index the index of view to be closed 0064 */ 0065 function closeSplit(index) 0066 { 0067 if(control.count === 1) 0068 { 0069 return // do not close aall 0070 } 0071 0072 control.removeItem(control.takeItem(index)) 0073 } 0074 0075 /** 0076 * @brief Adds a QQC2 Component as a view to the control. 0077 * @param component The QQC2 Component wrapping the view to be added. Consider using a MauiKit SplitViewItem control as the view root element. 0078 * @param properties an optional map of properties to be applied to the created view component 0079 * @return the newly created object view. 0080 */ 0081 function addSplit(component, properties) 0082 { 0083 const object = component.createObject(control.contentModel, properties); 0084 0085 control.addItem(object) 0086 control.currentIndex = Math.max(control.count -1, 0) 0087 object.forceActiveFocus() 0088 0089 return object 0090 } 0091 }