1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-05-19 14:47:46 +00:00
novus/apps/mapeditor/include/objectlistmodel.h
Joshua Goins 77f93c5224 Don't show all layers at once, allow selecting which ones to see
You can now select which layers are currently visible in the object list
view, and makes the performance *so much better* because it doesn't load
everything by default.
2025-05-17 11:32:23 -04:00

54 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QAbstractItemModel>
class AppState;
enum class TreeType {
/// Root of the tree
Root,
/// LGB file
File,
/// A layer.
Layer,
/// A single object
Object,
};
struct TreeInformation {
TreeType type;
TreeInformation *parent = nullptr;
int row = 0;
QString name;
uint32_t id;
std::vector<TreeInformation *> children;
};
class ObjectListModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit ObjectListModel(AppState *appState, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &child) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
private:
void refresh();
AppState *m_appState = nullptr;
TreeInformation *m_rootItem = nullptr;
};