Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -161,7 +161,23 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new · 160 unmodified lines | |||
| 161 | 161 | ||
| 162 | connect(request, &RenameMappingRequest::finished, this, [this, callback](RenameMappingRequest* request) mutable { | 162 | connect(request, &RenameMappingRequest::finished, this, [this, callback](RenameMappingRequest* request) mutable { |
| 163 | if (callback.isCallable()) { | 163 | if (callback.isCallable()) { |
| 164 | QJSValueList args { request->getErrorString() }; | 164 | QJSValueList args{ request->getErrorString() }; |
| 165 | callback.call(args); | ||
| 166 | } | ||
| 167 | |||
| 168 | request->deleteLater(); | ||
| 169 | }); | ||
| 170 | |||
| 171 | request->start(); | ||
| 172 | } | ||
| 173 | |||
| 174 | void AssetMappingsScriptingInterface::setBakingEnabled(QStringList paths, bool enabled, QJSValue callback) { | ||
| 175 | auto assetClient = DependencyManager::get<AssetClient>(); | ||
| 176 | auto request = assetClient->createSetBakingEnabledRequest(paths, enabled); | ||
| 177 | |||
| 178 | connect(request, &SetBakingEnabledRequest::finished, this, [this, callback](SetBakingEnabledRequest* request) mutable { | ||
| 179 | if (callback.isCallable()) { | ||
| 180 | QJSValueList args{ request->getErrorString() }; | ||
| 165 | callback.call(args); | 181 | callback.call(args); |
| 166 | } | 182 | } |
| 167 | 183 | ||
| @@ -214,18 +230,16 @@ void AssetMappingModel::refresh() { · 46 unmodified lines | |||
| 214 | // start index at 1 to avoid empty string from leading slash | 230 | // start index at 1 to avoid empty string from leading slash |
| 215 | for (int i = 1; i < length; ++i) { | 231 | for (int i = 1; i < length; ++i) { |
| 216 | fullPath += (i == 1 ? "" : "/") + parts[i]; | 232 | fullPath += (i == 1 ? "" : "/") + parts[i]; |
| 233 | bool isFolder = i < length - 1; | ||
| 217 | 234 | ||
| 218 | auto it = _pathToItemMap.find(fullPath); | 235 | auto it = _pathToItemMap.find(fullPath); |
| 219 | if (it == _pathToItemMap.end()) { | 236 | if (it == _pathToItemMap.end()) { |
| 220 | auto item = new QStandardItem(parts[i]); | 237 | auto item = new QStandardItem(parts[i]); |
| 221 | bool isFolder = i < length - 1; | ||
| 222 | auto statusString = isFolder ? "--" : bakingStatusToString(mapping.second.status); | ||
| 223 | item->setData(isFolder ? fullPath + "/" : fullPath, Qt::UserRole); | 238 | item->setData(isFolder ? fullPath + "/" : fullPath, Qt::UserRole); |
| 224 | item->setData(isFolder, Qt::UserRole + 1); | 239 | item->setData(isFolder, Qt::UserRole + 1); |
| 225 | item->setData(parts[i], Qt::UserRole + 2); | 240 | item->setData(parts[i], Qt::UserRole + 2); |
| 226 | item->setData("atp:" + fullPath, Qt::UserRole + 3); | 241 | item->setData("atp:" + fullPath, Qt::UserRole + 3); |
| 227 | item->setData(fullPath, Qt::UserRole + 4); | 242 | item->setData(fullPath, Qt::UserRole + 4); |
| 228 | item->setData(statusString, Qt::UserRole + 5); | ||
| 229 | 243 | ||
| 230 | if (lastItem) { | 244 | if (lastItem) { |
| 231 | lastItem->appendRow(item); | 245 | lastItem->appendRow(item); |
| @@ -237,6 +251,10 @@ void AssetMappingModel::refresh() { · 5 unmodified lines | |||
| 237 | } else { | 251 | } else { |
| 238 | lastItem = it.value(); | 252 | lastItem = it.value(); |
| 239 | } | 253 | } |
| 254 | |||
| 255 | // update status | ||
| 256 | auto statusString = isFolder ? "--" : bakingStatusToString(mapping.second.status); | ||
| 257 | lastItem->setData(statusString, Qt::UserRole + 5); | ||
| 240 | } | 258 | } |
| 241 | 259 | ||
| 242 | Q_ASSERT(fullPath == path); | 260 | Q_ASSERT(fullPath == path); |