2022-10-02 19:45:46 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_COMPONENT_LIST_MODEL_H_
|
|
|
|
#define DUST3D_APPLICATION_COMPONENT_LIST_MODEL_H_
|
|
|
|
|
2022-11-07 09:41:43 +00:00
|
|
|
#include "document.h"
|
2022-10-06 09:05:09 +00:00
|
|
|
#include <QAbstractListModel>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <dust3d/base/uuid.h>
|
|
|
|
#include <unordered_map>
|
2022-10-02 19:45:46 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
class ComponentListModel : public QAbstractListModel {
|
2022-10-02 19:45:46 +00:00
|
|
|
Q_OBJECT
|
2022-10-04 09:50:39 +00:00
|
|
|
signals:
|
2022-10-18 09:35:04 +00:00
|
|
|
void listingComponentChanged(const dust3d::Uuid& componentId);
|
|
|
|
|
2022-10-02 19:45:46 +00:00
|
|
|
public:
|
2022-10-18 09:35:04 +00:00
|
|
|
ComponentListModel(const Document* document, QObject* parent = nullptr);
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex& index, int role) const;
|
2022-11-07 09:41:43 +00:00
|
|
|
const Document::Component* modelIndexToComponent(const QModelIndex& index) const;
|
2022-10-18 09:35:04 +00:00
|
|
|
QModelIndex componentIdToIndex(const dust3d::Uuid& componentId) const;
|
|
|
|
const dust3d::Uuid modelIndexToComponentId(const QModelIndex& index) const;
|
2022-10-04 09:50:39 +00:00
|
|
|
const dust3d::Uuid listingComponentId() const;
|
2022-10-02 19:45:46 +00:00
|
|
|
public slots:
|
2022-10-18 09:35:04 +00:00
|
|
|
void setListingComponentId(const dust3d::Uuid& componentId);
|
2022-10-06 09:05:09 +00:00
|
|
|
void reload();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2022-10-02 19:45:46 +00:00
|
|
|
private:
|
2022-10-18 09:35:04 +00:00
|
|
|
const Document* m_document = nullptr;
|
2022-10-02 19:45:46 +00:00
|
|
|
dust3d::Uuid m_listingComponentId;
|
2022-10-06 09:05:09 +00:00
|
|
|
std::unordered_map<dust3d::Uuid, QModelIndex> m_componentIdToIndexMap;
|
2022-10-02 19:45:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|