初步统一了多航线采集和打开影像功能
This commit is contained in:
48
HPPA/MapLayerStore.h
Normal file
48
HPPA/MapLayerStore.h
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class MapLayer;
|
||||
class QWidget;
|
||||
|
||||
class MapLayerStore : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MapLayerStore(QObject* parent = nullptr);
|
||||
~MapLayerStore() override = default;
|
||||
|
||||
// Take ownership of the layer (store will own and manage its lifetime)
|
||||
// Now also accept the associated QWidget so UI widget can be retrieved by layer pointer
|
||||
void addLayer(MapLayer* layer, QWidget* widget = nullptr);
|
||||
|
||||
// Remove by pointer or by name. Destruction happens when removed from store.
|
||||
public slots:
|
||||
void removeLayer(MapLayer* layer);
|
||||
void removeLayerByName(const QString& name);
|
||||
|
||||
// Queries
|
||||
MapLayer* getLayer(const QString& name) const;
|
||||
MapLayer* getLayerAt(int index) const;
|
||||
int layerCount() const;
|
||||
|
||||
// Get associated widget for a layer (or nullptr if none)
|
||||
QWidget* widgetForLayer(MapLayer* layer) const;
|
||||
// Get associated widget by layer absolute data path
|
||||
QWidget* widgetForLayer(const QString& absolutePath) const;
|
||||
|
||||
signals:
|
||||
void layerAdded(MapLayer* layer);
|
||||
// Emitted just before the layer is destroyed/removed from store
|
||||
void layerAboutToBeRemoved(MapLayer* layer);
|
||||
|
||||
private:
|
||||
// store shared ownership so other parts can keep raw pointers safely (or use QPointer)
|
||||
std::vector<std::shared_ptr<MapLayer>> m_layers;
|
||||
// mapping from raw MapLayer pointer to associated QWidget*
|
||||
std::unordered_map<MapLayer*, QWidget*> m_layerWidgets;
|
||||
};
|
||||
Reference in New Issue
Block a user