forked from qt-creator/qt-creator
Use double underscores instead of single ones in QML
Also, fixed some QML errors -- they didn't have any real consequence, so they could be considered warnings. Also, AssetsView._modelIndex() was being called with two arguments instead of one -- this didn't result in any warnings. Change-Id: I08274a49531a4082fa94fb89e4230fdac5b1b658 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -18,17 +18,17 @@ TreeViewDelegate {
|
|||||||
readonly property bool isEffect: root.suffix === ".qep"
|
readonly property bool isEffect: root.suffix === ".qep"
|
||||||
property bool currFileSelected: false
|
property bool currFileSelected: false
|
||||||
property int initialDepth: -1
|
property int initialDepth: -1
|
||||||
property bool _isDirectory: assetsModel.isDirectory(model.filePath)
|
property bool __isDirectory: assetsModel.isDirectory(model.filePath)
|
||||||
property int _currentRow: model.index
|
property int __currentRow: model.index
|
||||||
property string _itemPath: model.filePath
|
property string __itemPath: model.filePath
|
||||||
|
|
||||||
readonly property int _fileItemHeight: thumbnailImage.height
|
readonly property int __fileItemHeight: thumbnailImage.height
|
||||||
readonly property int _dirItemHeight: 21
|
readonly property int __dirItemHeight: 21
|
||||||
|
|
||||||
implicitHeight: root._isDirectory ? root._dirItemHeight : root._fileItemHeight
|
implicitHeight: root.__isDirectory ? root.__dirItemHeight : root.__fileItemHeight
|
||||||
implicitWidth: root.assetsView.width > 0 ? root.assetsView.width : 10
|
implicitWidth: root.assetsView.width > 0 ? root.assetsView.width : 10
|
||||||
|
|
||||||
leftMargin: root._isDirectory ? 0 : thumbnailImage.width
|
leftMargin: root.__isDirectory ? 0 : thumbnailImage.width
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// the depth of the root path will become available before we get to the actual
|
// the depth of the root path will become available before we get to the actual
|
||||||
@@ -36,7 +36,7 @@ TreeViewDelegate {
|
|||||||
// tree items (below the root) will have the indentation (basically, depth) adjusted.
|
// tree items (below the root) will have the indentation (basically, depth) adjusted.
|
||||||
if (model.filePath === assetsModel.rootPath()) {
|
if (model.filePath === assetsModel.rootPath()) {
|
||||||
root.assetsView.rootPathDepth = root.depth
|
root.assetsView.rootPathDepth = root.depth
|
||||||
root.assetsView.rootPathRow = root._currentRow
|
root.assetsView.rootPathRow = root.__currentRow
|
||||||
} else if (model.filePath.includes(assetsModel.rootPath())) {
|
} else if (model.filePath.includes(assetsModel.rootPath())) {
|
||||||
root.depth -= root.assetsView.rootPathDepth
|
root.depth -= root.assetsView.rootPathDepth
|
||||||
root.initialDepth = root.depth
|
root.initialDepth = root.depth
|
||||||
@@ -45,7 +45,7 @@ TreeViewDelegate {
|
|||||||
|
|
||||||
// workaround for a bug -- might be fixed by https://codereview.qt-project.org/c/qt/qtdeclarative/+/442721
|
// workaround for a bug -- might be fixed by https://codereview.qt-project.org/c/qt/qtdeclarative/+/442721
|
||||||
onYChanged: {
|
onYChanged: {
|
||||||
if (root._currentRow === root.assetsView.firstRow) {
|
if (root.__currentRow === root.assetsView.firstRow) {
|
||||||
if (root.y > root.assetsView.contentY) {
|
if (root.y > root.assetsView.contentY) {
|
||||||
let item = root.assetsView.itemAtCell(0, root.assetsView.rootPathRow)
|
let item = root.assetsView.itemAtCell(0, root.assetsView.rootPathRow)
|
||||||
if (!item)
|
if (!item)
|
||||||
@@ -74,16 +74,16 @@ TreeViewDelegate {
|
|||||||
id: bg
|
id: bg
|
||||||
|
|
||||||
color: {
|
color: {
|
||||||
if (root._isDirectory && (root.isHoveringDrop || root.hasChildWithDropHover))
|
if (root.__isDirectory && (root.isHoveringDrop || root.hasChildWithDropHover))
|
||||||
return StudioTheme.Values.themeInteraction
|
return StudioTheme.Values.themeInteraction
|
||||||
|
|
||||||
if (!root._isDirectory && root.assetsView.selectedAssets[root._itemPath])
|
if (!root.__isDirectory && root.assetsView.selectedAssets[root.__itemPath])
|
||||||
return StudioTheme.Values.themeInteraction
|
return StudioTheme.Values.themeInteraction
|
||||||
|
|
||||||
if (mouseArea.containsMouse)
|
if (mouseArea.containsMouse)
|
||||||
return StudioTheme.Values.themeSectionHeadBackground
|
return StudioTheme.Values.themeSectionHeadBackground
|
||||||
|
|
||||||
return root._isDirectory
|
return root.__isDirectory
|
||||||
? StudioTheme.Values.themeSectionHeadBackground
|
? StudioTheme.Values.themeSectionHeadBackground
|
||||||
: "transparent"
|
: "transparent"
|
||||||
}
|
}
|
||||||
@@ -104,15 +104,15 @@ TreeViewDelegate {
|
|||||||
|
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
id: assetLabel
|
id: assetLabel
|
||||||
text: assetLabel._computeText()
|
text: assetLabel.__computeText()
|
||||||
color: StudioTheme.Values.themeTextColor
|
color: StudioTheme.Values.themeTextColor
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
|
||||||
function _computeText()
|
function __computeText()
|
||||||
{
|
{
|
||||||
return root._isDirectory
|
return root.__isDirectory
|
||||||
? (root.hasChildren
|
? (root.hasChildren
|
||||||
? model.display.toUpperCase()
|
? model.display.toUpperCase()
|
||||||
: model.display.toUpperCase() + qsTr(" (empty)"))
|
: model.display.toUpperCase() + qsTr(" (empty)"))
|
||||||
@@ -130,14 +130,14 @@ TreeViewDelegate {
|
|||||||
root.assetsRoot.updateDropExtFiles(drag)
|
root.assetsRoot.updateDropExtFiles(drag)
|
||||||
root.isHoveringDrop = drag.accepted && root.assetsRoot.dropSimpleExtFiles.length > 0
|
root.isHoveringDrop = drag.accepted && root.assetsRoot.dropSimpleExtFiles.length > 0
|
||||||
if (root.isHoveringDrop)
|
if (root.isHoveringDrop)
|
||||||
root.assetsView.startDropHoverOver(root._currentRow)
|
root.assetsView.startDropHoverOver(root.__currentRow)
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropped: (drag) => {
|
onDropped: (drag) => {
|
||||||
root.isHoveringDrop = false
|
root.isHoveringDrop = false
|
||||||
root.assetsView.endDropHover(root._currentRow)
|
root.assetsView.endDropHover(root.__currentRow)
|
||||||
|
|
||||||
let dirPath = root._isDirectory
|
let dirPath = root.__isDirectory
|
||||||
? model.filePath
|
? model.filePath
|
||||||
: assetsModel.parentDirPath(model.filePath);
|
: assetsModel.parentDirPath(model.filePath);
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ TreeViewDelegate {
|
|||||||
onExited: {
|
onExited: {
|
||||||
if (root.isHoveringDrop) {
|
if (root.isHoveringDrop) {
|
||||||
root.isHoveringDrop = false
|
root.isHoveringDrop = false
|
||||||
root.assetsView.endDropHover(root._currentRow)
|
root.assetsView.endDropHover(root.__currentRow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,25 +178,25 @@ TreeViewDelegate {
|
|||||||
mouseArea.allowTooltip = false
|
mouseArea.allowTooltip = false
|
||||||
tooltipBackend.hideTooltip()
|
tooltipBackend.hideTooltip()
|
||||||
|
|
||||||
if (root._isDirectory)
|
if (root.__isDirectory)
|
||||||
return
|
return
|
||||||
|
|
||||||
var ctrlDown = mouse.modifiers & Qt.ControlModifier
|
var ctrlDown = mouse.modifiers & Qt.ControlModifier
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
if (!root.assetsView.isAssetSelected(root._itemPath) && !ctrlDown)
|
if (!root.assetsView.isAssetSelected(root.__itemPath) && !ctrlDown)
|
||||||
root.assetsView.clearSelectedAssets()
|
root.assetsView.clearSelectedAssets()
|
||||||
root.currFileSelected = ctrlDown ? !root.assetsView.isAssetSelected(root._itemPath) : true
|
root.currFileSelected = ctrlDown ? !root.assetsView.isAssetSelected(root.__itemPath) : true
|
||||||
root.assetsView.setAssetSelected(root._itemPath, root.currFileSelected)
|
root.assetsView.setAssetSelected(root.__itemPath, root.currFileSelected)
|
||||||
|
|
||||||
if (root.currFileSelected) {
|
if (root.currFileSelected) {
|
||||||
let selectedPaths = root.assetsView.selectedPathsAsList()
|
let selectedPaths = root.assetsView.selectedPathsAsList()
|
||||||
rootView.startDragAsset(selectedPaths, mapToGlobal(mouse.x, mouse.y))
|
rootView.startDragAsset(selectedPaths, mapToGlobal(mouse.x, mouse.y))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!root.assetsView.isAssetSelected(root._itemPath) && !ctrlDown)
|
if (!root.assetsView.isAssetSelected(root.__itemPath) && !ctrlDown)
|
||||||
root.assetsView.clearSelectedAssets()
|
root.assetsView.clearSelectedAssets()
|
||||||
root.currFileSelected = root.assetsView.isAssetSelected(root._itemPath) || !ctrlDown
|
root.currFileSelected = root.assetsView.isAssetSelected(root.__itemPath) || !ctrlDown
|
||||||
root.assetsView.setAssetSelected(root._itemPath, root.currFileSelected)
|
root.assetsView.setAssetSelected(root.__itemPath, root.currFileSelected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ TreeViewDelegate {
|
|||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
if (!(mouse.modifiers & Qt.ControlModifier))
|
if (!(mouse.modifiers & Qt.ControlModifier))
|
||||||
root.assetsView.selectedAssets = {}
|
root.assetsView.selectedAssets = {}
|
||||||
root.assetsView.selectedAssets[root._itemPath] = root.currFileSelected
|
root.assetsView.selectedAssets[root.__itemPath] = root.currFileSelected
|
||||||
root.assetsView.selectedAssetsChanged()
|
root.assetsView.selectedAssetsChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,28 +239,28 @@ TreeViewDelegate {
|
|||||||
|
|
||||||
onClicked: (mouse) => {
|
onClicked: (mouse) => {
|
||||||
if (mouse.button === Qt.LeftButton)
|
if (mouse.button === Qt.LeftButton)
|
||||||
root._toggleExpandCurrentRow()
|
root.__toggleExpandCurrentRow()
|
||||||
else
|
else
|
||||||
root._openContextMenuForCurrentRow()
|
root.__openContextMenuForCurrentRow()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} // MouseArea
|
} // MouseArea
|
||||||
|
|
||||||
function _openContextMenuForCurrentRow()
|
function __openContextMenuForCurrentRow()
|
||||||
{
|
{
|
||||||
let modelIndex = assetsModel.indexForPath(model.filePath)
|
let modelIndex = assetsModel.indexForPath(model.filePath)
|
||||||
|
|
||||||
if (root._isDirectory) {
|
|
||||||
var row = root.assetsView.rowAtIndex(modelIndex)
|
|
||||||
var expanded = root.assetsView.isExpanded(row)
|
|
||||||
|
|
||||||
var allExpandedState = root.assetsView.computeAllExpandedState()
|
|
||||||
|
|
||||||
function onFolderCreated(path) {
|
function onFolderCreated(path) {
|
||||||
root.assetsView.addCreatedFolder(path)
|
root.assetsView.addCreatedFolder(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (root.__isDirectory) {
|
||||||
|
var row = root.assetsView.rowAtIndex(modelIndex)
|
||||||
|
var expanded = root.assetsView.isExpanded(row)
|
||||||
|
|
||||||
|
var allExpandedState = root.assetsView.computeAllExpandedState()
|
||||||
|
|
||||||
function onFolderRenamed() {
|
function onFolderRenamed() {
|
||||||
if (expanded)
|
if (expanded)
|
||||||
root.assetsView.rowToExpand = row
|
root.assetsView.rowToExpand = row
|
||||||
@@ -272,40 +272,40 @@ TreeViewDelegate {
|
|||||||
let parentDirIndex = assetsModel.parentDirIndex(model.filePath)
|
let parentDirIndex = assetsModel.parentDirIndex(model.filePath)
|
||||||
let selectedPaths = root.assetsView.selectedPathsAsList()
|
let selectedPaths = root.assetsView.selectedPathsAsList()
|
||||||
root.assetsView.contextMenu.openContextMenuForFile(modelIndex, parentDirIndex,
|
root.assetsView.contextMenu.openContextMenuForFile(modelIndex, parentDirIndex,
|
||||||
selectedPaths)
|
selectedPaths, onFolderCreated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _toggleExpandCurrentRow()
|
function __toggleExpandCurrentRow()
|
||||||
{
|
{
|
||||||
if (!root._isDirectory)
|
if (!root.__isDirectory)
|
||||||
return
|
return
|
||||||
|
|
||||||
let index = root.assetsView._modelIndex(root._currentRow, 0)
|
let index = root.assetsView.__modelIndex(root.__currentRow)
|
||||||
// if the user manually clicked on a directory, then this is definitely not a
|
// if the user manually clicked on a directory, then this is definitely not a
|
||||||
// an automatic request to expand all.
|
// an automatic request to expand all.
|
||||||
root.assetsView.requestedExpandAll = false
|
root.assetsView.requestedExpandAll = false
|
||||||
|
|
||||||
if (root.assetsView.isExpanded(root._currentRow)) {
|
if (root.assetsView.isExpanded(root.__currentRow)) {
|
||||||
root.assetsView.requestedExpandAll = false
|
root.assetsView.requestedExpandAll = false
|
||||||
root.assetsView.collapse(root._currentRow)
|
root.assetsView.collapse(root.__currentRow)
|
||||||
} else {
|
} else {
|
||||||
root.assetsView.expand(root._currentRow)
|
root.assetsView.expand(root.__currentRow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadImage()
|
function reloadImage()
|
||||||
{
|
{
|
||||||
if (root._isDirectory)
|
if (root.__isDirectory)
|
||||||
return
|
return
|
||||||
|
|
||||||
thumbnailImage.source = ""
|
thumbnailImage.source = ""
|
||||||
thumbnailImage.source = thumbnailImage._computeSource()
|
thumbnailImage.source = thumbnailImage.__computeSource()
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: thumbnailImage
|
id: thumbnailImage
|
||||||
visible: !root._isDirectory
|
visible: !root.__isDirectory
|
||||||
x: root.depth * root.indentation
|
x: root.depth * root.indentation
|
||||||
width: 48
|
width: 48
|
||||||
height: 48
|
height: 48
|
||||||
@@ -314,11 +314,11 @@ TreeViewDelegate {
|
|||||||
sourceSize.height: 48
|
sourceSize.height: 48
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
source: thumbnailImage._computeSource()
|
source: thumbnailImage.__computeSource()
|
||||||
|
|
||||||
function _computeSource()
|
function __computeSource()
|
||||||
{
|
{
|
||||||
return root._isDirectory
|
return root.__isDirectory
|
||||||
? ""
|
? ""
|
||||||
: "image://qmldesigner_assets/" + model.filePath
|
: "image://qmldesigner_assets/" + model.filePath
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ Item {
|
|||||||
property var dropComplexExtFiles: []
|
property var dropComplexExtFiles: []
|
||||||
|
|
||||||
readonly property int qtVersionAtLeast6_4: rootView.qtVersionIsAtLeast6_4()
|
readonly property int qtVersionAtLeast6_4: rootView.qtVersionIsAtLeast6_4()
|
||||||
property bool _searchBoxEmpty: true
|
property bool __searchBoxEmpty: true
|
||||||
|
|
||||||
AssetsContextMenu {
|
AssetsContextMenu {
|
||||||
id: contextMenu
|
id: contextMenu
|
||||||
@@ -136,10 +136,10 @@ Item {
|
|||||||
rootView.handleSearchFilterChanged(searchBox.text)
|
rootView.handleSearchFilterChanged(searchBox.text)
|
||||||
assetsView.expandAll()
|
assetsView.expandAll()
|
||||||
|
|
||||||
if (root._searchBoxEmpty && searchBox.text)
|
if (root.__searchBoxEmpty && searchBox.text)
|
||||||
root._searchBoxEmpty = false
|
root.__searchBoxEmpty = false
|
||||||
else if (!root._searchBoxEmpty && !searchBox.text)
|
else if (!root.__searchBoxEmpty && !searchBox.text)
|
||||||
root._searchBoxEmpty = true
|
root.__searchBoxEmpty = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,13 +159,13 @@ Item {
|
|||||||
leftPadding: 10
|
leftPadding: 10
|
||||||
color: StudioTheme.Values.themeTextColor
|
color: StudioTheme.Values.themeTextColor
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
visible: !assetsModel.haveFiles && !root._searchBoxEmpty
|
visible: !assetsModel.haveFiles && !root.__searchBoxEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { // placeholder when the assets library is empty
|
Item { // placeholder when the assets library is empty
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - searchRow.height
|
height: parent.height - searchRow.height
|
||||||
visible: !assetsModel.haveFiles && root._searchBoxEmpty
|
visible: !assetsModel.haveFiles && root.__searchBoxEmpty
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
DropArea { // handles external drop (goes into default folder based on suffix)
|
DropArea { // handles external drop (goes into default folder based on suffix)
|
||||||
|
@@ -11,84 +11,85 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
required property Item assetsView
|
required property Item assetsView
|
||||||
|
|
||||||
property bool _isDirectory: false
|
property bool __isDirectory: false
|
||||||
property var _fileIndex: null
|
property var __fileIndex: null
|
||||||
property string _dirPath: ""
|
property string __dirPath: ""
|
||||||
property string _dirName: ""
|
property string __dirName: ""
|
||||||
property var _onFolderCreated: null
|
property var __onFolderCreated: null
|
||||||
property var _onFolderRenamed: null
|
property var __onFolderRenamed: null
|
||||||
property var _dirIndex: null
|
property var __dirIndex: null
|
||||||
property string _allExpandedState: ""
|
property string __allExpandedState: ""
|
||||||
property var _selectedAssetPathsList: null
|
property var __selectedAssetPathsList: null
|
||||||
|
|
||||||
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
|
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
|
||||||
|
|
||||||
function openContextMenuForRoot(rootModelIndex, dirPath, dirName, onFolderCreated)
|
function openContextMenuForRoot(rootModelIndex, dirPath, dirName, onFolderCreated)
|
||||||
{
|
{
|
||||||
root._onFolderCreated = onFolderCreated
|
root.__onFolderCreated = onFolderCreated
|
||||||
root._fileIndex = ""
|
root.__fileIndex = ""
|
||||||
root._dirPath = dirPath
|
root.__dirPath = dirPath
|
||||||
root._dirName = dirName
|
root.__dirName = dirName
|
||||||
root._dirIndex = rootModelIndex
|
root.__dirIndex = rootModelIndex
|
||||||
root._isDirectory = false
|
root.__isDirectory = false
|
||||||
root.popup()
|
root.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openContextMenuForDir(dirModelIndex, dirPath, dirName, allExpandedState,
|
function openContextMenuForDir(dirModelIndex, dirPath, dirName, allExpandedState,
|
||||||
onFolderCreated, onFolderRenamed)
|
onFolderCreated, onFolderRenamed)
|
||||||
{
|
{
|
||||||
root._onFolderCreated = onFolderCreated
|
root.__onFolderCreated = onFolderCreated
|
||||||
root._onFolderRenamed = onFolderRenamed
|
root.__onFolderRenamed = onFolderRenamed
|
||||||
root._dirPath = dirPath
|
root.__dirPath = dirPath
|
||||||
root._dirName = dirName
|
root.__dirName = dirName
|
||||||
root._fileIndex = ""
|
root.__fileIndex = ""
|
||||||
root._dirIndex = dirModelIndex
|
root.__dirIndex = dirModelIndex
|
||||||
root._isDirectory = true
|
root.__isDirectory = true
|
||||||
root._allExpandedState = allExpandedState
|
root.__allExpandedState = allExpandedState
|
||||||
root.popup()
|
root.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openContextMenuForFile(fileIndex, dirModelIndex, selectedAssetPathsList)
|
function openContextMenuForFile(fileIndex, dirModelIndex, selectedAssetPathsList, onFolderCreated)
|
||||||
{
|
{
|
||||||
var numSelected = selectedAssetPathsList.filter(p => p).length
|
var numSelected = selectedAssetPathsList.filter(p => p).length
|
||||||
deleteFileItem.text = numSelected > 1 ? qsTr("Delete Files") : qsTr("Delete File")
|
deleteFileItem.text = numSelected > 1 ? qsTr("Delete Files") : qsTr("Delete File")
|
||||||
|
|
||||||
root._selectedAssetPathsList = selectedAssetPathsList
|
root.__onFolderCreated = onFolderCreated
|
||||||
root._fileIndex = fileIndex
|
root.__selectedAssetPathsList = selectedAssetPathsList
|
||||||
root._dirIndex = dirModelIndex
|
root.__fileIndex = fileIndex
|
||||||
root._dirPath = assetsModel.filePath(dirModelIndex)
|
root.__dirIndex = dirModelIndex
|
||||||
root._isDirectory = false
|
root.__dirPath = assetsModel.filePath(dirModelIndex)
|
||||||
|
root.__isDirectory = false
|
||||||
root.popup()
|
root.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Expand All")
|
text: qsTr("Expand All")
|
||||||
enabled: root._allExpandedState !== "all_expanded"
|
enabled: root.__allExpandedState !== "all_expanded"
|
||||||
visible: root._isDirectory
|
visible: root.__isDirectory
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: root.assetsView.expandAll()
|
onTriggered: root.assetsView.expandAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Collapse All")
|
text: qsTr("Collapse All")
|
||||||
enabled: root._allExpandedState !== "all_collapsed"
|
enabled: root.__allExpandedState !== "all_collapsed"
|
||||||
visible: root._isDirectory
|
visible: root.__isDirectory
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: root.assetsView.collapseAll()
|
onTriggered: root.assetsView.collapseAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuSeparator {
|
StudioControls.MenuSeparator {
|
||||||
visible: root._isDirectory
|
visible: root.__isDirectory
|
||||||
height: visible ? StudioTheme.Values.border : 0
|
height: visible ? StudioTheme.Values.border : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
id: deleteFileItem
|
id: deleteFileItem
|
||||||
text: qsTr("Delete File")
|
text: qsTr("Delete File")
|
||||||
visible: root._fileIndex
|
visible: root.__fileIndex
|
||||||
height: deleteFileItem.visible ? deleteFileItem.implicitHeight : 0
|
height: deleteFileItem.visible ? deleteFileItem.implicitHeight : 0
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
let deleted = assetsModel.requestDeleteFiles(root._selectedAssetPathsList)
|
let deleted = assetsModel.requestDeleteFiles(root.__selectedAssetPathsList)
|
||||||
if (!deleted)
|
if (!deleted)
|
||||||
confirmDeleteFiles.open()
|
confirmDeleteFiles.open()
|
||||||
}
|
}
|
||||||
@@ -96,30 +97,30 @@ StudioControls.Menu {
|
|||||||
ConfirmDeleteFilesDialog {
|
ConfirmDeleteFilesDialog {
|
||||||
id: confirmDeleteFiles
|
id: confirmDeleteFiles
|
||||||
parent: root.assetsView
|
parent: root.assetsView
|
||||||
files: root._selectedAssetPathsList
|
files: root.__selectedAssetPathsList
|
||||||
|
|
||||||
onAccepted: root.assetsView.selectedAssets = {}
|
onAccepted: root.assetsView.selectedAssets = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuSeparator {
|
StudioControls.MenuSeparator {
|
||||||
visible: root._fileIndex
|
visible: root.__fileIndex
|
||||||
height: visible ? StudioTheme.Values.border : 0
|
height: visible ? StudioTheme.Values.border : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Rename Folder")
|
text: qsTr("Rename Folder")
|
||||||
visible: root._isDirectory
|
visible: root.__isDirectory
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: renameFolderDialog.open()
|
onTriggered: renameFolderDialog.open()
|
||||||
|
|
||||||
RenameFolderDialog {
|
RenameFolderDialog {
|
||||||
id: renameFolderDialog
|
id: renameFolderDialog
|
||||||
parent: root.assetsView
|
parent: root.assetsView
|
||||||
dirPath: root._dirPath
|
dirPath: root.__dirPath
|
||||||
dirName: root._dirName
|
dirName: root.__dirName
|
||||||
|
|
||||||
onAccepted: root._onFolderRenamed()
|
onAccepted: root.__onFolderRenamed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,9 +130,9 @@ StudioControls.Menu {
|
|||||||
NewFolderDialog {
|
NewFolderDialog {
|
||||||
id: newFolderDialog
|
id: newFolderDialog
|
||||||
parent: root.assetsView
|
parent: root.assetsView
|
||||||
dirPath: root._dirPath
|
dirPath: root.__dirPath
|
||||||
|
|
||||||
onAccepted: root._onFolderCreated(newFolderDialog.createdDirPath)
|
onAccepted: root.__onFolderCreated(newFolderDialog.createdDirPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
onTriggered: newFolderDialog.open()
|
onTriggered: newFolderDialog.open()
|
||||||
@@ -139,22 +140,22 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Delete Folder")
|
text: qsTr("Delete Folder")
|
||||||
visible: root._isDirectory
|
visible: root.__isDirectory
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
|
|
||||||
ConfirmDeleteFolderDialog {
|
ConfirmDeleteFolderDialog {
|
||||||
id: confirmDeleteFolderDialog
|
id: confirmDeleteFolderDialog
|
||||||
parent: root.assetsView
|
parent: root.assetsView
|
||||||
dirName: root._dirName
|
dirName: root.__dirName
|
||||||
dirIndex: root._dirIndex
|
dirIndex: root.__dirIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (!assetsModel.hasChildren(root._dirIndex)) {
|
if (!assetsModel.hasChildren(root.__dirIndex)) {
|
||||||
// NOTE: the folder may still not be empty -- it doesn't have files visible to the
|
// NOTE: the folder may still not be empty -- it doesn't have files visible to the
|
||||||
// user, but that doesn't mean that there are no other files (e.g. files of unknown
|
// user, but that doesn't mean that there are no other files (e.g. files of unknown
|
||||||
// types) on disk in this directory.
|
// types) on disk in this directory.
|
||||||
assetsModel.deleteFolderRecursively(root._dirIndex)
|
assetsModel.deleteFolderRecursively(root.__dirIndex)
|
||||||
} else {
|
} else {
|
||||||
confirmDeleteFolderDialog.open()
|
confirmDeleteFolderDialog.open()
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ TreeView {
|
|||||||
// i.e. first child of the root path
|
// i.e. first child of the root path
|
||||||
readonly property int firstRow: root.rootPathRow + 1
|
readonly property int firstRow: root.rootPathRow + 1
|
||||||
property int rowToExpand: -1
|
property int rowToExpand: -1
|
||||||
property var _createdDirectories: []
|
property var __createdDirectories: []
|
||||||
|
|
||||||
rowHeightProvider: (row) => {
|
rowHeightProvider: (row) => {
|
||||||
if (row <= root.rootPathRow)
|
if (row <= root.rootPathRow)
|
||||||
@@ -70,7 +70,7 @@ TreeView {
|
|||||||
|
|
||||||
function onDirectoryCreated(path)
|
function onDirectoryCreated(path)
|
||||||
{
|
{
|
||||||
root._createdDirectories.push(path)
|
root.__createdDirectories.push(path)
|
||||||
|
|
||||||
updateRowsTimer.restart()
|
updateRowsTimer.restart()
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ TreeView {
|
|||||||
|
|
||||||
function addCreatedFolder(path)
|
function addCreatedFolder(path)
|
||||||
{
|
{
|
||||||
root._createdDirectories.push(path)
|
root.__createdDirectories.push(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectedPathsAsList()
|
function selectedPathsAsList()
|
||||||
@@ -140,8 +140,8 @@ TreeView {
|
|||||||
if (root.rows <= 0)
|
if (root.rows <= 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
while (root._createdDirectories.length > 0) {
|
while (root.__createdDirectories.length > 0) {
|
||||||
let dirPath = root._createdDirectories.pop()
|
let dirPath = root.__createdDirectories.pop()
|
||||||
let index = assetsModel.indexForPath(dirPath)
|
let index = assetsModel.indexForPath(dirPath)
|
||||||
let row = root.rowAtIndex(index)
|
let row = root.rowAtIndex(index)
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ TreeView {
|
|||||||
|
|
||||||
if (expanding) {
|
if (expanding) {
|
||||||
if (root.requestedExpandAll)
|
if (root.requestedExpandAll)
|
||||||
root._doExpandAll()
|
root.__doExpandAll()
|
||||||
} else {
|
} else {
|
||||||
if (root.rowToExpand > 0) {
|
if (root.rowToExpand > 0) {
|
||||||
root.expand(root.rowToExpand)
|
root.expand(root.rowToExpand)
|
||||||
@@ -182,11 +182,11 @@ TreeView {
|
|||||||
root.lastRowCount = root.rows
|
root.lastRowCount = root.rows
|
||||||
}
|
}
|
||||||
|
|
||||||
function _doExpandAll()
|
function __doExpandAll()
|
||||||
{
|
{
|
||||||
let expandedAny = false
|
let expandedAny = false
|
||||||
for (let nRow = 0; nRow < root.rows; ++nRow) {
|
for (let nRow = 0; nRow < root.rows; ++nRow) {
|
||||||
let index = root._modelIndex(nRow, 0)
|
let index = root.__modelIndex(nRow)
|
||||||
if (assetsModel.isDirectory(index) && !root.isExpanded(nRow)) {
|
if (assetsModel.isDirectory(index) && !root.isExpanded(nRow)) {
|
||||||
root.expand(nRow);
|
root.expand(nRow);
|
||||||
expandedAny = true
|
expandedAny = true
|
||||||
@@ -199,10 +199,10 @@ TreeView {
|
|||||||
|
|
||||||
function expandAll()
|
function expandAll()
|
||||||
{
|
{
|
||||||
// In order for _doExpandAll() to be called repeatedly (every time a new node is
|
// In order for __doExpandAll() to be called repeatedly (every time a new node is
|
||||||
// loaded, and then, expanded), we need to set requestedExpandAll to true.
|
// loaded, and then, expanded), we need to set requestedExpandAll to true.
|
||||||
root.requestedExpandAll = true
|
root.requestedExpandAll = true
|
||||||
root._doExpandAll()
|
root.__doExpandAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
function collapseAll()
|
function collapseAll()
|
||||||
@@ -211,7 +211,7 @@ TreeView {
|
|||||||
|
|
||||||
// collapse all, except for the root path - from the last item (leaves) up to the root
|
// collapse all, except for the root path - from the last item (leaves) up to the root
|
||||||
for (let nRow = root.rows - 1; nRow >= 0; --nRow) {
|
for (let nRow = root.rows - 1; nRow >= 0; --nRow) {
|
||||||
let index = root._modelIndex(nRow, 0)
|
let index = root.__modelIndex(nRow)
|
||||||
// we don't want to collapse the root path, because doing so will hide the contents
|
// we don't want to collapse the root path, because doing so will hide the contents
|
||||||
// of the tree.
|
// of the tree.
|
||||||
if (assetsModel.filePath(index) === assetsModel.rootPath())
|
if (assetsModel.filePath(index) === assetsModel.rootPath())
|
||||||
@@ -233,7 +233,7 @@ TreeView {
|
|||||||
function computeAllExpandedState()
|
function computeAllExpandedState()
|
||||||
{
|
{
|
||||||
var dirsWithChildren = [...Array(root.rows).keys()].filter(row => {
|
var dirsWithChildren = [...Array(root.rows).keys()].filter(row => {
|
||||||
let index = root._modelIndex(row, 0)
|
let index = root.__modelIndex(row)
|
||||||
return assetsModel.isDirectory(index) && assetsModel.hasChildren(index)
|
return assetsModel.isDirectory(index) && assetsModel.hasChildren(index)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -249,21 +249,23 @@ TreeView {
|
|||||||
|
|
||||||
function startDropHoverOver(row)
|
function startDropHoverOver(row)
|
||||||
{
|
{
|
||||||
let index = root._modelIndex(row, 0)
|
let index = root.__modelIndex(row)
|
||||||
if (assetsModel.isDirectory(index))
|
if (assetsModel.isDirectory(index))
|
||||||
return
|
return
|
||||||
|
|
||||||
let parentItem = root._getDelegateParentForIndex(index)
|
let parentItem = root.__getDelegateParentForIndex(index)
|
||||||
|
if (parentItem)
|
||||||
parentItem.hasChildWithDropHover = true
|
parentItem.hasChildWithDropHover = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function endDropHover(row)
|
function endDropHover(row)
|
||||||
{
|
{
|
||||||
let index = root._modelIndex(row, 0)
|
let index = root.__modelIndex(row)
|
||||||
if (assetsModel.isDirectory(index))
|
if (assetsModel.isDirectory(index))
|
||||||
return
|
return
|
||||||
|
|
||||||
let parentItem = root._getDelegateParentForIndex(index)
|
let parentItem = root.__getDelegateParentForIndex(index)
|
||||||
|
if (parentItem)
|
||||||
parentItem.hasChildWithDropHover = false
|
parentItem.hasChildWithDropHover = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,14 +285,14 @@ TreeView {
|
|||||||
root.selectedAssetsChanged()
|
root.selectedAssetsChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getDelegateParentForIndex(index)
|
function __getDelegateParentForIndex(index)
|
||||||
{
|
{
|
||||||
let parentIndex = assetsModel.parentDirIndex(index)
|
let parentIndex = assetsModel.parentDirIndex(index)
|
||||||
let parentCell = root.cellAtIndex(parentIndex)
|
let parentCell = root.cellAtIndex(parentIndex)
|
||||||
return root.itemAtCell(parentCell)
|
return root.itemAtCell(parentCell)
|
||||||
}
|
}
|
||||||
|
|
||||||
function _modelIndex(row)
|
function __modelIndex(row)
|
||||||
{
|
{
|
||||||
// The modelIndex() function exists since 6.3. In Qt 6.3, this modelIndex() function was a
|
// The modelIndex() function exists since 6.3. In Qt 6.3, this modelIndex() function was a
|
||||||
// member of the TreeView, while in Qt6.4 it was moved to TableView. In Qt6.4, the order of
|
// member of the TreeView, while in Qt6.4 it was moved to TableView. In Qt6.4, the order of
|
||||||
|
@@ -17,7 +17,7 @@ Dialog {
|
|||||||
|
|
||||||
required property string dirPath
|
required property string dirPath
|
||||||
property string createdDirPath: ""
|
property string createdDirPath: ""
|
||||||
readonly property int _maxPath: 260
|
readonly property int __maxPath: 260
|
||||||
|
|
||||||
HelperWidgets.RegExpValidator {
|
HelperWidgets.RegExpValidator {
|
||||||
id: folderNameValidator
|
id: folderNameValidator
|
||||||
@@ -67,7 +67,7 @@ Dialog {
|
|||||||
text: qsTr("Folder path is too long.")
|
text: qsTr("Folder path is too long.")
|
||||||
color: "#ff0000"
|
color: "#ff0000"
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
visible: root.createdDirPath.length > root._maxPath
|
visible: root.createdDirPath.length > root.__maxPath
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { // spacer
|
Item { // spacer
|
||||||
@@ -82,7 +82,7 @@ Dialog {
|
|||||||
id: btnCreate
|
id: btnCreate
|
||||||
|
|
||||||
text: qsTr("Create")
|
text: qsTr("Create")
|
||||||
enabled: folderName.text !== "" && root.createdDirPath.length <= root._maxPath
|
enabled: folderName.text !== "" && root.createdDirPath.length <= root.__maxPath
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.createdDirPath = root.dirPath + '/' + folderName.text
|
root.createdDirPath = root.dirPath + '/' + folderName.text
|
||||||
if (assetsModel.addNewFolder(root.createdDirPath))
|
if (assetsModel.addNewFolder(root.createdDirPath))
|
||||||
|
Reference in New Issue
Block a user