diff --git a/plots.cpp b/plots.cpp index cf3d300..1ecc661 100644 --- a/plots.cpp +++ b/plots.cpp @@ -26,7 +26,7 @@ #include "plots.h" -std::multimap)>> Plots::plots; +std::multimap Plots::plots; Plots::_init Plots::_initializer; Plot* Plots::samplePlot(std::shared_ptr source) diff --git a/plots.h b/plots.h index 0187ca3..707974f 100644 --- a/plots.h +++ b/plots.h @@ -24,11 +24,17 @@ #include "plot.h" #include "samplesource.h" +struct PlotInfo +{ + const char *name; + std::function)> creator; +}; + class Plots { public: - static std::multimap)>> plots; + static std::multimap plots; static Plot* samplePlot(std::shared_ptr source); static Plot* frequencyPlot(std::shared_ptr source); @@ -37,8 +43,8 @@ public: { public: _init() { - plots.emplace(typeid(std::complex), samplePlot); - plots.emplace(typeid(std::complex), frequencyPlot); + plots.emplace(typeid(std::complex), PlotInfo{"sample plot", samplePlot}); + plots.emplace(typeid(std::complex), PlotInfo{"frequency plot", frequencyPlot}); }; } _initializer; }; \ No newline at end of file diff --git a/plotview.cpp b/plotview.cpp index 65aa984..27cc4cd 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -66,8 +66,9 @@ void PlotView::contextMenuEvent(QContextMenuEvent * event) auto src = selectedPlot->output(); auto compatiblePlots = as_range(Plots::plots.equal_range(src->sampleType())); for (auto p : compatiblePlots) { - auto action = new QAction("Add plot", &menu); - auto plotCreator = p.second; + auto plotInfo = p.second; + auto action = new QAction(QString("Add %1").arg(plotInfo.name), &menu); + auto plotCreator = plotInfo.creator; connect( action, &QAction::triggered, this, [=]() {