mirror of
https://github.com/overte-org/overte.git
synced 2025-07-26 09:18:26 +02:00
commit
cbed674cba
4 changed files with 109 additions and 24 deletions
|
@ -164,6 +164,27 @@ Window {
|
||||||
Window.copyToClipboard(url);
|
Window.copyToClipboard(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renameEl(index, data) {
|
||||||
|
if (!index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var path = assetProxyModel.data(index, 0x100);
|
||||||
|
if (!path) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var destinationPath = path.split('/');
|
||||||
|
destinationPath[destinationPath.length - (path[path.length - 1] === '/' ? 2 : 1)] = data;
|
||||||
|
destinationPath = destinationPath.join('/').trim();
|
||||||
|
|
||||||
|
if (path === destinationPath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!fileExists(destinationPath)) {
|
||||||
|
doRenameFile(path, destinationPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
function renameFile(index) {
|
function renameFile(index) {
|
||||||
if (!index) {
|
if (!index) {
|
||||||
index = treeView.selection.currentIndex;
|
index = treeView.selection.currentIndex;
|
||||||
|
@ -371,8 +392,13 @@ Window {
|
||||||
height: 400
|
height: 400
|
||||||
treeModel: assetProxyModel
|
treeModel: assetProxyModel
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
|
canEdit: true
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
modifyEl: renameEl
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -19,9 +19,12 @@ TreeView {
|
||||||
id: treeView
|
id: treeView
|
||||||
|
|
||||||
property var treeModel: ListModel { }
|
property var treeModel: ListModel { }
|
||||||
|
property var canEdit: false
|
||||||
property int colorScheme: hifi.colorSchemes.light
|
property int colorScheme: hifi.colorSchemes.light
|
||||||
readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light
|
readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light
|
||||||
|
|
||||||
|
property var modifyEl: function(index, data) { return false; }
|
||||||
|
|
||||||
model: treeModel
|
model: treeModel
|
||||||
selection: ItemSelectionModel {
|
selection: ItemSelectionModel {
|
||||||
model: treeModel
|
model: treeModel
|
||||||
|
@ -124,7 +127,9 @@ TreeView {
|
||||||
: (styleData.alternate ? hifi.colors.tableRowDarkEven : hifi.colors.tableRowDarkOdd)
|
: (styleData.alternate ? hifi.colors.tableRowDarkEven : hifi.colors.tableRowDarkOdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemDelegate: FiraSansSemiBold {
|
itemDelegate: Loader {
|
||||||
|
id: itemDelegateLoader
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
left: parent ? parent.left : undefined
|
left: parent ? parent.left : undefined
|
||||||
leftMargin: (2 + styleData.depth) * hifi.dimensions.tablePadding
|
leftMargin: (2 + styleData.depth) * hifi.dimensions.tablePadding
|
||||||
|
@ -133,11 +138,83 @@ TreeView {
|
||||||
verticalCenter: parent ? parent.verticalCenter : undefined
|
verticalCenter: parent ? parent.verticalCenter : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
text: styleData.value
|
function getComponent() {
|
||||||
size: hifi.fontSizes.tableText
|
if (treeView.canEdit && styleData.selected) {
|
||||||
color: colorScheme == hifi.colorSchemes.light
|
return textFieldComponent;
|
||||||
? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight)
|
} else {
|
||||||
: (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText)
|
return labelComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
sourceComponent: getComponent()
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: labelComponent
|
||||||
|
FiraSansSemiBold {
|
||||||
|
|
||||||
|
text: styleData.value
|
||||||
|
size: hifi.fontSizes.tableText
|
||||||
|
color: colorScheme == hifi.colorSchemes.light
|
||||||
|
? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight)
|
||||||
|
: (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: textFieldComponent
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: textField
|
||||||
|
readOnly: !activeFocus
|
||||||
|
|
||||||
|
text: styleData.value
|
||||||
|
|
||||||
|
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; }
|
||||||
|
font.family: firaSansSemiBold.name
|
||||||
|
font.pixelSize: hifi.fontSizes.textFieldInput
|
||||||
|
height: hifi.dimensions.tableRowHeight
|
||||||
|
|
||||||
|
style: TextFieldStyle {
|
||||||
|
textColor: readOnly
|
||||||
|
? hifi.colors.black
|
||||||
|
: (treeView.isLightColorScheme ? hifi.colors.black : hifi.colors.white)
|
||||||
|
background: Rectangle {
|
||||||
|
visible: !readOnly
|
||||||
|
color: treeView.isLightColorScheme ? hifi.colors.white : hifi.colors.black
|
||||||
|
border.color: hifi.colors.primaryHighlight
|
||||||
|
border.width: 1
|
||||||
|
}
|
||||||
|
selectedTextColor: hifi.colors.black
|
||||||
|
selectionColor: hifi.colors.primaryHighlight
|
||||||
|
padding.left: readOnly ? 0 : hifi.dimensions.textPadding
|
||||||
|
padding.right: readOnly ? 0 : hifi.dimensions.textPadding
|
||||||
|
}
|
||||||
|
|
||||||
|
validator: RegExpValidator {
|
||||||
|
regExp: /[^/]+/
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onPressed: {
|
||||||
|
if (event.key == Qt.Key_Escape) {
|
||||||
|
text = styleData.value;
|
||||||
|
unfocusHelper.forceActiveFocus();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onAccepted: {
|
||||||
|
if (acceptableInput && styleData.selected) {
|
||||||
|
if (!modifyEl(selection.currentIndex, text)) {
|
||||||
|
text = styleData.value;
|
||||||
|
}
|
||||||
|
unfocusHelper.forceActiveFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: unfocusHelper
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index)
|
onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index)
|
||||||
|
|
|
@ -169,14 +169,6 @@ bool AssetMappingModel::isKnownFolder(QString path) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetMappingItem::AssetMappingItem(const QString& name, const QString& fullPath, bool isFolder) :
|
|
||||||
name(name),
|
|
||||||
fullPath(fullPath),
|
|
||||||
isFolder(isFolder)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
static int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
||||||
|
|
||||||
void AssetMappingModel::refresh() {
|
void AssetMappingModel::refresh() {
|
||||||
|
|
|
@ -20,16 +20,6 @@
|
||||||
#include <AssetClient.h>
|
#include <AssetClient.h>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
class AssetMappingItem : public QStandardItem {
|
|
||||||
public:
|
|
||||||
AssetMappingItem(const QString& name, const QString& fullPath, bool isFolder);
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
QString fullPath;
|
|
||||||
bool isFolder;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AssetMappingModel : public QStandardItemModel {
|
class AssetMappingModel : public QStandardItemModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue