History

Set Baking Enabled API

Atlante45 committed 9 years ago

Commit a9cfc011 parent aad0be26 files · +48 −14Browse files

Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 6 files). Show all

Unified · Split

interface/src/scripting/AssetMappingsScriptingInterface.cpp+22−4
@@ -161,7 +161,23 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new · 160 unmodified lines
161161
162162 connect(request, &RenameMappingRequest::finished, this, [this, callback](RenameMappingRequest* request) mutable {
163163 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() };
165181 callback.call(args);
166182 }
167183
@@ -214,18 +230,16 @@ void AssetMappingModel::refresh() { · 46 unmodified lines
214230 // start index at 1 to avoid empty string from leading slash
215231 for (int i = 1; i < length; ++i) {
216232 fullPath += (i == 1 ? "" : "/") + parts[i];
233+ bool isFolder = i < length - 1;
217234
218235 auto it = _pathToItemMap.find(fullPath);
219236 if (it == _pathToItemMap.end()) {
220237 auto item = new QStandardItem(parts[i]);
221− bool isFolder = i < length - 1;
222− auto statusString = isFolder ? "--" : bakingStatusToString(mapping.second.status);
223238 item->setData(isFolder ? fullPath + "/" : fullPath, Qt::UserRole);
224239 item->setData(isFolder, Qt::UserRole + 1);
225240 item->setData(parts[i], Qt::UserRole + 2);
226241 item->setData("atp:" + fullPath, Qt::UserRole + 3);
227242 item->setData(fullPath, Qt::UserRole + 4);
228− item->setData(statusString, Qt::UserRole + 5);
229243
230244 if (lastItem) {
231245 lastItem->appendRow(item);
@@ -237,6 +251,10 @@ void AssetMappingModel::refresh() { · 5 unmodified lines
237251 } else {
238252 lastItem = it.value();
239253 }
254+
255+ // update status
256+ auto statusString = isFolder ? "--" : bakingStatusToString(mapping.second.status);
257+ lastItem->setData(statusString, Qt::UserRole + 5);
240258 }
241259
242260 Q_ASSERT(fullPath == path);