mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:10:06 +00:00
Add select Map Layers to View menu
This commit is contained in:
parent
54047b7645
commit
9e3b2916e1
6 changed files with 199 additions and 5 deletions
|
|
@ -395,11 +395,63 @@ void LayerModel::Impl::WriteLayerSettings()
|
|||
util::json::WriteJsonFile(layerSettingsPath_, layerJson);
|
||||
}
|
||||
|
||||
types::LayerInfo
|
||||
LayerModel::GetLayerInfo(types::LayerType type,
|
||||
types::LayerDescription description) const
|
||||
{
|
||||
// Find the matching layer
|
||||
auto it = std::find_if(p->layers_.begin(),
|
||||
p->layers_.end(),
|
||||
[&](const types::LayerInfo& layer) {
|
||||
return layer.type_ == type &&
|
||||
layer.description_ == description;
|
||||
});
|
||||
if (it != p->layers_.end())
|
||||
{
|
||||
// Return the layer info
|
||||
return *it;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
types::LayerVector LayerModel::GetLayers() const
|
||||
{
|
||||
return p->layers_;
|
||||
}
|
||||
|
||||
void LayerModel::SetLayerDisplayed(types::LayerType type,
|
||||
types::LayerDescription description,
|
||||
bool displayed)
|
||||
{
|
||||
// Find the matching layer
|
||||
auto it = std::find_if(p->layers_.begin(),
|
||||
p->layers_.end(),
|
||||
[&](const types::LayerInfo& layer) {
|
||||
return layer.type_ == type &&
|
||||
layer.description_ == description;
|
||||
});
|
||||
|
||||
if (it != p->layers_.end())
|
||||
{
|
||||
// Find the row
|
||||
const int row = std::distance(p->layers_.begin(), it);
|
||||
QModelIndex topLeft =
|
||||
createIndex(row, static_cast<int>(Column::DisplayMap1));
|
||||
QModelIndex bottomRight =
|
||||
createIndex(row, static_cast<int>(Column::DisplayMap4));
|
||||
|
||||
// Set the layer to displayed
|
||||
for (std::size_t i = 0; i < kMapCount_; ++i)
|
||||
{
|
||||
it->displayed_[i] = displayed;
|
||||
}
|
||||
|
||||
// Notify observers
|
||||
Q_EMIT dataChanged(topLeft, bottomRight);
|
||||
}
|
||||
}
|
||||
|
||||
void LayerModel::ResetLayers()
|
||||
{
|
||||
// Initialize a new layer vector from the default
|
||||
|
|
@ -751,6 +803,7 @@ bool LayerModel::setData(const QModelIndex& index,
|
|||
if (result)
|
||||
{
|
||||
Q_EMIT dataChanged(index, index);
|
||||
Q_EMIT LayerDisplayChanged(layer);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace model
|
|||
|
||||
class LayerModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(LayerModel)
|
||||
|
||||
public:
|
||||
|
|
@ -36,7 +37,12 @@ public:
|
|||
explicit LayerModel(QObject* parent = nullptr);
|
||||
~LayerModel();
|
||||
|
||||
types::LayerInfo GetLayerInfo(types::LayerType type,
|
||||
types::LayerDescription description) const;
|
||||
types::LayerVector GetLayers() const;
|
||||
void SetLayerDisplayed(types::LayerType type,
|
||||
types::LayerDescription description,
|
||||
bool displayed);
|
||||
|
||||
void ResetLayers();
|
||||
|
||||
|
|
@ -77,6 +83,9 @@ public:
|
|||
|
||||
static std::shared_ptr<LayerModel> Instance();
|
||||
|
||||
signals:
|
||||
void LayerDisplayChanged(types::LayerInfo layer);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue