mirror of
https://github.com/redstrate/Novus.git
synced 2025-05-19 06:47:44 +00:00
Separate map layers into their own tree items
This commit is contained in:
parent
7213b1865f
commit
da0240b3bf
2 changed files with 14 additions and 11 deletions
|
@ -12,6 +12,8 @@ enum class TreeType {
|
||||||
Root,
|
Root,
|
||||||
/// LGB file
|
/// LGB file
|
||||||
File,
|
File,
|
||||||
|
/// A layer.
|
||||||
|
Layer,
|
||||||
/// A single object
|
/// A single object
|
||||||
Object,
|
Object,
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,16 +74,9 @@ QVariant ObjectListModel::data(const QModelIndex &index, int role) const
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto item = static_cast<TreeInformation *>(index.internalPointer());
|
auto item = static_cast<TreeInformation *>(index.internalPointer());
|
||||||
|
|
||||||
if (item->type == TreeType::File) {
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return item->name;
|
return item->name;
|
||||||
}
|
}
|
||||||
} else if (item->type == TreeType::Object) {
|
|
||||||
if (role == Qt::DisplayRole) {
|
|
||||||
return item->name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -117,15 +110,23 @@ void ObjectListModel::refresh()
|
||||||
const auto chunk = lgb.chunks[i];
|
const auto chunk = lgb.chunks[i];
|
||||||
for (int j = 0; j < chunk.num_layers; j++) {
|
for (int j = 0; j < chunk.num_layers; j++) {
|
||||||
const auto layer = chunk.layers[j];
|
const auto layer = chunk.layers[j];
|
||||||
|
|
||||||
|
auto layerItem = new TreeInformation();
|
||||||
|
layerItem->type = TreeType::Layer;
|
||||||
|
layerItem->parent = fileItem;
|
||||||
|
layerItem->name = i18n("Layer %1", j); // TODO: do display names if we have them
|
||||||
|
layerItem->row = j;
|
||||||
|
fileItem->children.push_back(layerItem);
|
||||||
|
|
||||||
for (int z = 0; z < layer.num_objects; z++) {
|
for (int z = 0; z < layer.num_objects; z++) {
|
||||||
const auto object = layer.objects[z];
|
const auto object = layer.objects[z];
|
||||||
|
|
||||||
auto objectItem = new TreeInformation();
|
auto objectItem = new TreeInformation();
|
||||||
objectItem->type = TreeType::Object;
|
objectItem->type = TreeType::Object;
|
||||||
objectItem->parent = fileItem;
|
objectItem->parent = layerItem;
|
||||||
objectItem->name = i18n("Unknown (%1)", object.instance_id); // TODO: do display names if we have them
|
objectItem->name = i18n("Unknown (%1)", object.instance_id); // TODO: do display names if we have them
|
||||||
objectItem->row = z;
|
objectItem->row = z;
|
||||||
fileItem->children.push_back(objectItem);
|
layerItem->children.push_back(objectItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue