Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -21,19 +21,6 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <NetworkLogging.h> |
| 22 | 22 | #include <OffscreenUi.h> |
| 23 | 23 | |
| 24 | −void AssetMappingModel::clear() { | |
| 25 | − // make sure we are on the same thread before we touch the hash | |
| 26 | − if (thread() != QThread::currentThread()) { | |
| 27 | − QMetaObject::invokeMethod(this, "clear"); | |
| 28 | − return; | |
| 29 | − } | |
| 30 | − | |
| 31 | − qDebug() << "Clearing loaded asset mappings for Asset Browser"; | |
| 32 | − | |
| 33 | − _pathToItemMap.clear(); | |
| 34 | − QStandardItemModel::clear(); | |
| 35 | −} | |
| 36 | − | |
| 37 | 24 | AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() { |
| 38 | 25 | _proxyModel.setSourceModel(&_assetMappingModel); |
| 39 | 26 | _proxyModel.setSortRole(Qt::DisplayRole); |
| @@ -154,7 +141,7 @@ void AssetMappingsScriptingInterface::getAllMappings(QJSValue callback) { · 114 unmodified lines | ||
| 154 | 141 | auto map = callback.engine()->newObject(); |
| 155 | 142 | |
| 156 | 143 | for (auto& kv : mappings ) { |
| 157 | − map.setProperty(kv.first, kv.second); | |
| 144 | + map.setProperty(kv.first, kv.second.hash); | |
| 158 | 145 | } |
| 159 | 146 | |
| 160 | 147 | if (callback.isCallable()) { |
| @@ -184,6 +171,10 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new · 23 unmodified lines | ||
| 184 | 171 | request->start(); |
| 185 | 172 | } |
| 186 | 173 | |
| 174 | +AssetMappingModel::AssetMappingModel() { | |
| 175 | + setupHeaders(); | |
| 176 | +} | |
| 177 | + | |
| 187 | 178 | bool AssetMappingModel::isKnownFolder(QString path) const { |
| 188 | 179 | if (!path.endsWith("/")) { |
| 189 | 180 | return false; |
| @@ -228,17 +219,19 @@ void AssetMappingModel::refresh() { · 38 unmodified lines | ||
| 228 | 219 | if (it == _pathToItemMap.end()) { |
| 229 | 220 | auto item = new QStandardItem(parts[i]); |
| 230 | 221 | bool isFolder = i < length - 1; |
| 222 | + auto statusString = isFolder ? "--" : bakingStatusToString(mapping.second.status); | |
| 231 | 223 | item->setData(isFolder ? fullPath + "/" : fullPath, Qt::UserRole); |
| 232 | 224 | item->setData(isFolder, Qt::UserRole + 1); |
| 233 | 225 | item->setData(parts[i], Qt::UserRole + 2); |
| 234 | 226 | item->setData("atp:" + fullPath, Qt::UserRole + 3); |
| 235 | 227 | item->setData(fullPath, Qt::UserRole + 4); |
| 228 | + item->setData(statusString, Qt::UserRole + 5); | |
| 229 | + | |
| 236 | 230 | if (lastItem) { |
| 237 | − lastItem->setChild(lastItem->rowCount(), 0, item); | |
| 231 | + lastItem->appendRow(item); | |
| 238 | 232 | } else { |
| 239 | 233 | appendRow(item); |
| 240 | 234 | } |
| 241 | − | |
| 242 | 235 | lastItem = item; |
| 243 | 236 | _pathToItemMap[fullPath] = lastItem; |
| 244 | 237 | } else { |
| @@ -300,3 +293,25 @@ void AssetMappingModel::refresh() { · 55 unmodified lines | ||
| 300 | 293 | |
| 301 | 294 | request->start(); |
| 302 | 295 | } |
| 296 | + | |
| 297 | +void AssetMappingModel::clear() { | |
| 298 | + // make sure we are on the same thread before we touch the hash | |
| 299 | + if (thread() != QThread::currentThread()) { | |
| 300 | + QMetaObject::invokeMethod(this, "clear"); | |
| 301 | + return; | |
| 302 | + } | |
| 303 | + | |
| 304 | + qDebug() << "Clearing loaded asset mappings for Asset Browser"; | |
| 305 | + | |
| 306 | + _pathToItemMap.clear(); | |
| 307 | + QStandardItemModel::clear(); | |
| 308 | + setupHeaders(); // restore headers | |
| 309 | +} | |
| 310 | + | |
| 311 | +void AssetMappingModel::setupHeaders() { | |
| 312 | + setHorizontalHeaderLabels(QStringList() << "Name" << "Use Baked?"); | |
| 313 | + QHash<int, QByteArray> roleNames; | |
| 314 | + roleNames[Qt::DisplayRole] = "name"; | |
| 315 | + roleNames[Qt::UserRole + 5] = "baked"; | |
| 316 | + setItemRoleNames(roleNames); | |
| 317 | +} | |