Analyzer: Base ISettingsAspect on Utils::AspectContainer

Change-Id: Ib4c19d0cb167911dc50d989771dd53f3569db087
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-04-06 18:35:27 +02:00
parent 8eb74080ab
commit 454e8a31e2
10 changed files with 59 additions and 103 deletions

View File

@@ -2183,6 +2183,9 @@ void AspectContainer::fromMap(const QVariantMap &map)
{ {
for (BaseAspect *aspect : qAsConst(d->m_items)) for (BaseAspect *aspect : qAsConst(d->m_items))
aspect->fromMap(map); aspect->fromMap(map);
emit fromMapFinished();
} }
void AspectContainer::toMap(QVariantMap &map) const void AspectContainer::toMap(QVariantMap &map) const

View File

@@ -513,6 +513,7 @@ public:
registerAspect(aspect); registerAspect(aspect);
return aspect; return aspect;
} }
void fromMap(const QVariantMap &map); void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const; void toMap(QVariantMap &map) const;
@@ -560,6 +561,7 @@ public:
signals: signals:
void applied(); void applied();
void fromMapFinished();
private: private:
std::unique_ptr<Internal::AspectContainerPrivate> d; std::unique_ptr<Internal::AspectContainerPrivate> d;

View File

@@ -46,19 +46,19 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
return widget; return widget;
}); });
group.registerAspect(&period); registerAspect(&period);
period.setSettingsKey("Analyzer.Perf.Frequency"); period.setSettingsKey("Analyzer.Perf.Frequency");
period.setRange(250, 2147483647); period.setRange(250, 2147483647);
period.setDefaultValue(250); period.setDefaultValue(250);
period.setLabelText(tr("Sample period:")); period.setLabelText(tr("Sample period:"));
group.registerAspect(&stackSize); registerAspect(&stackSize);
stackSize.setSettingsKey("Analyzer.Perf.StackSize"); stackSize.setSettingsKey("Analyzer.Perf.StackSize");
stackSize.setRange(4096, 65536); stackSize.setRange(4096, 65536);
stackSize.setDefaultValue(4096); stackSize.setDefaultValue(4096);
stackSize.setLabelText(tr("Stack snapshot size (kB):")); stackSize.setLabelText(tr("Stack snapshot size (kB):"));
group.registerAspect(&sampleMode); registerAspect(&sampleMode);
sampleMode.setSettingsKey("Analyzer.Perf.SampleMode"); sampleMode.setSettingsKey("Analyzer.Perf.SampleMode");
sampleMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); sampleMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
sampleMode.setLabelText(tr("Sample mode:")); sampleMode.setLabelText(tr("Sample mode:"));
@@ -66,7 +66,7 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
sampleMode.addOption({tr("event count"), {}, QString("-c")}); sampleMode.addOption({tr("event count"), {}, QString("-c")});
sampleMode.setDefaultValue(0); sampleMode.setDefaultValue(0);
group.registerAspect(&callgraphMode); registerAspect(&callgraphMode);
callgraphMode.setSettingsKey("Analyzer.Perf.CallgraphMode"); callgraphMode.setSettingsKey("Analyzer.Perf.CallgraphMode");
callgraphMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); callgraphMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
callgraphMode.setLabelText(tr("Call graph mode:")); callgraphMode.setLabelText(tr("Call graph mode:"));
@@ -75,11 +75,11 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
callgraphMode.addOption({tr("last branch record"), {}, QString("lbr")}); callgraphMode.addOption({tr("last branch record"), {}, QString("lbr")});
callgraphMode.setDefaultValue(0); callgraphMode.setDefaultValue(0);
group.registerAspect(&events); registerAspect(&events);
events.setSettingsKey("Analyzer.Perf.Events"); events.setSettingsKey("Analyzer.Perf.Events");
events.setDefaultValue({"cpu-cycles"}); events.setDefaultValue({"cpu-cycles"});
group.registerAspect(&extraArguments); registerAspect(&extraArguments);
extraArguments.setSettingsKey("Analyzer.Perf.ExtraArguments"); extraArguments.setSettingsKey("Analyzer.Perf.ExtraArguments");
extraArguments.setDisplayStyle(StringAspect::DisplayStyle::LineEditDisplay); extraArguments.setDisplayStyle(StringAspect::DisplayStyle::LineEditDisplay);
extraArguments.setLabelText(tr("Additional arguments:")); extraArguments.setLabelText(tr("Additional arguments:"));
@@ -89,6 +89,8 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
stackSize.setEnabled(index == 0); stackSize.setEnabled(index == 0);
}); });
connect(this, &AspectContainer::fromMapFinished, this, &PerfSettings::changed);
readGlobalSettings(); readGlobalSettings();
} }
@@ -122,17 +124,6 @@ void PerfSettings::writeGlobalSettings() const
settings->endGroup(); settings->endGroup();
} }
void PerfSettings::toMap(QVariantMap &map) const
{
group.toMap(map);
}
void PerfSettings::fromMap(const QVariantMap &map)
{
group.fromMap(map);
emit changed();
}
QStringList PerfSettings::perfRecordArguments() const QStringList PerfSettings::perfRecordArguments() const
{ {
QString callgraphArg = callgraphMode.itemValue().toString(); QString callgraphArg = callgraphMode.itemValue().toString();

View File

@@ -56,14 +56,8 @@ public:
Utils::StringListAspect events; Utils::StringListAspect events;
Utils::StringAspect extraArguments; Utils::StringAspect extraArguments;
Utils::AspectContainer group;
signals: signals:
void changed(); void changed();
protected:
void toMap(QVariantMap &map) const final;
void fromMap(const QVariantMap &map) final;
}; };
} // namespace PerfProfiler } // namespace PerfProfiler

View File

@@ -61,7 +61,7 @@ class Target;
* *
*/ */
class PROJECTEXPLORER_EXPORT ISettingsAspect : public QObject class PROJECTEXPLORER_EXPORT ISettingsAspect : public Utils::AspectContainer
{ {
Q_OBJECT Q_OBJECT
@@ -76,10 +76,6 @@ protected:
void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator); void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator);
friend class GlobalOrProjectAspect; friend class GlobalOrProjectAspect;
/// Converts current object into map for storage.
virtual void toMap(QVariantMap &map) const = 0;
/// Read object state from @p map.
virtual void fromMap(const QVariantMap &map) = 0;
ConfigWidgetCreator m_configWidgetCreator; ConfigWidgetCreator m_configWidgetCreator;
}; };

View File

@@ -57,9 +57,9 @@ QmlProfilerSettings::QmlProfilerSettings()
{ {
setConfigWidgetCreator([this] { return createQmlConfigWidget(this); }); setConfigWidgetCreator([this] { return createQmlConfigWidget(this); });
group.setSettingsGroup(Constants::ANALYZER); setSettingsGroup(Constants::ANALYZER);
group.registerAspect(&flushEnabled); registerAspect(&flushEnabled);
flushEnabled.setSettingsKey("Analyzer.QmlProfiler.FlushEnabled"); flushEnabled.setSettingsKey("Analyzer.QmlProfiler.FlushEnabled");
flushEnabled.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel); flushEnabled.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
flushEnabled.setLabelText(tr("Flush data while profiling:")); flushEnabled.setLabelText(tr("Flush data while profiling:"));
@@ -68,17 +68,17 @@ QmlProfilerSettings::QmlProfilerSettings()
"data and the memory usage in the application. It distorts the profile as the flushing\n" "data and the memory usage in the application. It distorts the profile as the flushing\n"
"itself takes time.")); "itself takes time."));
group.registerAspect(&flushInterval); registerAspect(&flushInterval);
flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval"); flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval");
flushInterval.setRange(1, 10000000); flushInterval.setRange(1, 10000000);
flushInterval.setDefaultValue(1000); flushInterval.setDefaultValue(1000);
flushInterval.setLabelText(tr("Flush interval (ms):", nullptr)); flushInterval.setLabelText(tr("Flush interval (ms):", nullptr));
flushInterval.setEnabled(false); // Controled by flushEnabled. flushInterval.setEnabled(false); // Controled by flushEnabled.
group.registerAspect(&lastTraceFile); registerAspect(&lastTraceFile);
lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile"); lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");
group.registerAspect(&aggregateTraces); registerAspect(&aggregateTraces);
aggregateTraces.setSettingsKey("Analyzer.QmlProfiler.AggregateTraces"); aggregateTraces.setSettingsKey("Analyzer.QmlProfiler.AggregateTraces");
aggregateTraces.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel); aggregateTraces.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
aggregateTraces.setLabelText(tr("Process data only when process ends:")); aggregateTraces.setLabelText(tr("Process data only when process ends:"));
@@ -94,25 +94,14 @@ QmlProfilerSettings::QmlProfilerSettings()
&flushInterval, &BaseAspect::setEnabled); &flushInterval, &BaseAspect::setEnabled);
// Read stored values // Read stored values
group.readSettings(Core::ICore::settings()); readSettings(Core::ICore::settings());
} }
void QmlProfilerSettings::writeGlobalSettings() const void QmlProfilerSettings::writeGlobalSettings() const
{ {
group.writeSettings(Core::ICore::settings()); writeSettings(Core::ICore::settings());
} }
void QmlProfilerSettings::toMap(QVariantMap &map) const
{
group.toMap(map);
}
void QmlProfilerSettings::fromMap(const QVariantMap &map)
{
group.fromMap(map);
}
// QmlProfilerOptionsPage // QmlProfilerOptionsPage
QmlProfilerOptionsPage::QmlProfilerOptionsPage() QmlProfilerOptionsPage::QmlProfilerOptionsPage()

View File

@@ -46,12 +46,6 @@ public:
Utils::IntegerAspect flushInterval; Utils::IntegerAspect flushInterval;
Utils::StringAspect lastTraceFile; Utils::StringAspect lastTraceFile;
Utils::BoolAspect aggregateTraces; Utils::BoolAspect aggregateTraces;
Utils::AspectContainer group;
protected:
void toMap(QVariantMap &map) const override;
void fromMap(const QVariantMap &map) override;
}; };
class QmlProfilerOptionsPage final : public Core::IOptionsPage class QmlProfilerOptionsPage final : public Core::IOptionsPage

View File

@@ -50,13 +50,13 @@ public:
void apply() final void apply() final
{ {
ValgrindGlobalSettings::instance()->group.apply(); ValgrindGlobalSettings::instance()->apply();
ValgrindGlobalSettings::instance()->writeSettings(); ValgrindGlobalSettings::instance()->writeSettings();
} }
void finish() final void finish() final
{ {
ValgrindGlobalSettings::instance()->group.finish(); ValgrindGlobalSettings::instance()->finish();
} }
}; };

View File

@@ -297,9 +297,9 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
// the same key to facilitate copying using fromMap/toMap. // the same key to facilitate copying using fromMap/toMap.
QString base = "Analyzer.Valgrind."; QString base = "Analyzer.Valgrind.";
group.registerAspect(&suppressions); registerAspect(&suppressions);
group.registerAspect(&valgrindExecutable); registerAspect(&valgrindExecutable);
valgrindExecutable.setSettingsKey(base + "ValgrindExecutable"); valgrindExecutable.setSettingsKey(base + "ValgrindExecutable");
valgrindExecutable.setDefaultValue("valgrind"); valgrindExecutable.setDefaultValue("valgrind");
valgrindExecutable.setDisplayStyle(StringAspect::PathChooserDisplay); valgrindExecutable.setDisplayStyle(StringAspect::PathChooserDisplay);
@@ -315,12 +315,12 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
//valgrindExecutable. ... buttonAtIndex(0)->hide(); //valgrindExecutable. ... buttonAtIndex(0)->hide();
} }
group.registerAspect(&valgrindArguments); registerAspect(&valgrindArguments);
valgrindArguments.setSettingsKey(base + "ValgrindArguments"); valgrindArguments.setSettingsKey(base + "ValgrindArguments");
valgrindArguments.setDisplayStyle(StringAspect::LineEditDisplay); valgrindArguments.setDisplayStyle(StringAspect::LineEditDisplay);
valgrindArguments.setLabelText(tr("Valgrind arguments:")); valgrindArguments.setLabelText(tr("Valgrind arguments:"));
group.registerAspect(&selfModifyingCodeDetection); registerAspect(&selfModifyingCodeDetection);
selfModifyingCodeDetection.setSettingsKey(base + "SelfModifyingCodeDetection"); selfModifyingCodeDetection.setSettingsKey(base + "SelfModifyingCodeDetection");
selfModifyingCodeDetection.setDefaultValue(DetectSmcStackOnly); selfModifyingCodeDetection.setDefaultValue(DetectSmcStackOnly);
selfModifyingCodeDetection.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); selfModifyingCodeDetection.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
@@ -331,12 +331,12 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
selfModifyingCodeDetection.setLabelText(tr("Detect self-modifying code:")); selfModifyingCodeDetection.setLabelText(tr("Detect self-modifying code:"));
// Memcheck // Memcheck
group.registerAspect(&memcheckArguments); registerAspect(&memcheckArguments);
memcheckArguments.setSettingsKey(base + "Memcheck.Arguments"); memcheckArguments.setSettingsKey(base + "Memcheck.Arguments");
memcheckArguments.setDisplayStyle(StringAspect::LineEditDisplay); memcheckArguments.setDisplayStyle(StringAspect::LineEditDisplay);
memcheckArguments.setLabelText(tr("Extra MemCheck arguments:")); memcheckArguments.setLabelText(tr("Extra MemCheck arguments:"));
group.registerAspect(&filterExternalIssues); registerAspect(&filterExternalIssues);
filterExternalIssues.setSettingsKey(base + "FilterExternalIssues"); filterExternalIssues.setSettingsKey(base + "FilterExternalIssues");
filterExternalIssues.setDefaultValue(true); filterExternalIssues.setDefaultValue(true);
filterExternalIssues.setIcon(Icons::FILTER.icon()); filterExternalIssues.setIcon(Icons::FILTER.icon());
@@ -344,18 +344,18 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
filterExternalIssues.setLabelText(tr("Show Project Costs Only")); filterExternalIssues.setLabelText(tr("Show Project Costs Only"));
filterExternalIssues.setToolTip(tr("Show only profiling info that originated from this project source.")); filterExternalIssues.setToolTip(tr("Show only profiling info that originated from this project source."));
group.registerAspect(&trackOrigins); registerAspect(&trackOrigins);
trackOrigins.setSettingsKey(base + "TrackOrigins"); trackOrigins.setSettingsKey(base + "TrackOrigins");
trackOrigins.setDefaultValue(true); trackOrigins.setDefaultValue(true);
trackOrigins.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); trackOrigins.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
trackOrigins.setLabelText(tr("Track origins of uninitialized memory")); trackOrigins.setLabelText(tr("Track origins of uninitialized memory"));
group.registerAspect(&showReachable); registerAspect(&showReachable);
showReachable.setSettingsKey(base + "ShowReachable"); showReachable.setSettingsKey(base + "ShowReachable");
showReachable.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); showReachable.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
showReachable.setLabelText(tr("Show reachable and indirectly lost blocks")); showReachable.setLabelText(tr("Show reachable and indirectly lost blocks"));
group.registerAspect(&leakCheckOnFinish); registerAspect(&leakCheckOnFinish);
leakCheckOnFinish.setSettingsKey(base + "LeakCheckOnFinish"); leakCheckOnFinish.setSettingsKey(base + "LeakCheckOnFinish");
leakCheckOnFinish.setDefaultValue(LeakCheckOnFinishSummaryOnly); leakCheckOnFinish.setDefaultValue(LeakCheckOnFinishSummaryOnly);
leakCheckOnFinish.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); leakCheckOnFinish.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
@@ -364,14 +364,14 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
leakCheckOnFinish.addOption(tr("Full")); leakCheckOnFinish.addOption(tr("Full"));
leakCheckOnFinish.setLabelText(tr("Check for leaks on finish:")); leakCheckOnFinish.setLabelText(tr("Check for leaks on finish:"));
group.registerAspect(&numCallers); registerAspect(&numCallers);
numCallers.setSettingsKey(base + "NumCallers"); numCallers.setSettingsKey(base + "NumCallers");
numCallers.setDefaultValue(25); numCallers.setDefaultValue(25);
numCallers.setLabelText(tr("Backtrace frame count:")); numCallers.setLabelText(tr("Backtrace frame count:"));
// Callgrind // Callgrind
group.registerAspect(&kcachegrindExecutable); registerAspect(&kcachegrindExecutable);
kcachegrindExecutable.setSettingsKey(base + "KCachegrindExecutable"); kcachegrindExecutable.setSettingsKey(base + "KCachegrindExecutable");
kcachegrindExecutable.setDefaultValue("kcachegrind"); kcachegrindExecutable.setDefaultValue("kcachegrind");
kcachegrindExecutable.setDisplayStyle(StringAspect::PathChooserDisplay); kcachegrindExecutable.setDisplayStyle(StringAspect::PathChooserDisplay);
@@ -379,18 +379,18 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
kcachegrindExecutable.setExpectedKind(Utils::PathChooser::Command); kcachegrindExecutable.setExpectedKind(Utils::PathChooser::Command);
kcachegrindExecutable.setDisplayName(tr("KCachegrind Command")); kcachegrindExecutable.setDisplayName(tr("KCachegrind Command"));
group.registerAspect(&callgrindArguments); registerAspect(&callgrindArguments);
callgrindArguments.setSettingsKey(base + "Callgrind.Arguments"); callgrindArguments.setSettingsKey(base + "Callgrind.Arguments");
callgrindArguments.setDisplayStyle(StringAspect::LineEditDisplay); callgrindArguments.setDisplayStyle(StringAspect::LineEditDisplay);
callgrindArguments.setLabelText(tr("Extra CallGrind arguments:")); callgrindArguments.setLabelText(tr("Extra CallGrind arguments:"));
group.registerAspect(&enableEventToolTips); registerAspect(&enableEventToolTips);
enableEventToolTips.setDefaultValue(true); enableEventToolTips.setDefaultValue(true);
enableEventToolTips.setSettingsKey(base + "Callgrind.EnableEventToolTips"); enableEventToolTips.setSettingsKey(base + "Callgrind.EnableEventToolTips");
enableEventToolTips.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); enableEventToolTips.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
enableEventToolTips.setLabelText(tr("Show additional information for events in tooltips")); enableEventToolTips.setLabelText(tr("Show additional information for events in tooltips"));
group.registerAspect(&enableCacheSim); registerAspect(&enableCacheSim);
enableCacheSim.setSettingsKey(base + "Callgrind.EnableCacheSim"); enableCacheSim.setSettingsKey(base + "Callgrind.EnableCacheSim");
enableCacheSim.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); enableCacheSim.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
enableCacheSim.setLabelText(tr("Enable cache simulation")); enableCacheSim.setLabelText(tr("Enable cache simulation"));
@@ -404,7 +404,7 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
"<li>Data write accesses (\"Dw\") and related cache misses (\"D1mw\"/\"D2mw\").</li></ul>\n" "<li>Data write accesses (\"Dw\") and related cache misses (\"D1mw\"/\"D2mw\").</li></ul>\n"
"</p>") + "</body></html>"); "</p>") + "</body></html>");
group.registerAspect(&enableBranchSim); registerAspect(&enableBranchSim);
enableBranchSim.setSettingsKey(base + "Callgrind.EnableBranchSim"); enableBranchSim.setSettingsKey(base + "Callgrind.EnableBranchSim");
enableBranchSim.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); enableBranchSim.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
enableBranchSim.setLabelText(tr("Enable branch prediction simulation")); enableBranchSim.setLabelText(tr("Enable branch prediction simulation"));
@@ -416,20 +416,20 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
"<li>Executed indirect jumps and related misses of the jump address predictor (\n" "<li>Executed indirect jumps and related misses of the jump address predictor (\n"
"\"Bi\"/\"Bim\").)</li></ul>") + "</body></html>"); "\"Bi\"/\"Bim\").)</li></ul>") + "</body></html>");
group.registerAspect(&collectSystime); registerAspect(&collectSystime);
collectSystime.setSettingsKey(base + "Callgrind.CollectSystime"); collectSystime.setSettingsKey(base + "Callgrind.CollectSystime");
collectSystime.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); collectSystime.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
collectSystime.setLabelText(tr("Collect system call time")); collectSystime.setLabelText(tr("Collect system call time"));
collectSystime.setToolTip(tr("Collects information for system call times.")); collectSystime.setToolTip(tr("Collects information for system call times."));
group.registerAspect(&collectBusEvents); registerAspect(&collectBusEvents);
collectBusEvents.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); collectBusEvents.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
collectBusEvents.setSettingsKey(base + "Callgrind.CollectBusEvents"); collectBusEvents.setSettingsKey(base + "Callgrind.CollectBusEvents");
collectBusEvents.setLabelText(tr("Collect global bus events")); collectBusEvents.setLabelText(tr("Collect global bus events"));
collectBusEvents.setToolTip(tr("Collect the number of global bus events that are executed. " collectBusEvents.setToolTip(tr("Collect the number of global bus events that are executed. "
"The event type \"Ge\" is used for these events.")); "The event type \"Ge\" is used for these events."));
group.registerAspect(&minimumInclusiveCostRatio); registerAspect(&minimumInclusiveCostRatio);
minimumInclusiveCostRatio.setSettingsKey(base + "Callgrind.MinimumCostRatio"); minimumInclusiveCostRatio.setSettingsKey(base + "Callgrind.MinimumCostRatio");
minimumInclusiveCostRatio.setDefaultValue(0.01); minimumInclusiveCostRatio.setDefaultValue(0.01);
minimumInclusiveCostRatio.setSuffix(tr("%")); minimumInclusiveCostRatio.setSuffix(tr("%"));
@@ -437,13 +437,13 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
minimumInclusiveCostRatio.setToolTip(tr("Limits the amount of results the profiler gives you. " minimumInclusiveCostRatio.setToolTip(tr("Limits the amount of results the profiler gives you. "
"A lower limit will likely increase performance.")); "A lower limit will likely increase performance."));
group.registerAspect(&visualizationMinimumInclusiveCostRatio); registerAspect(&visualizationMinimumInclusiveCostRatio);
visualizationMinimumInclusiveCostRatio.setSettingsKey(base + "Callgrind.VisualisationMinimumCostRatio"); visualizationMinimumInclusiveCostRatio.setSettingsKey(base + "Callgrind.VisualisationMinimumCostRatio");
visualizationMinimumInclusiveCostRatio.setDefaultValue(10.0); visualizationMinimumInclusiveCostRatio.setDefaultValue(10.0);
visualizationMinimumInclusiveCostRatio.setLabelText(tr("Visualization: Minimum event cost:")); visualizationMinimumInclusiveCostRatio.setLabelText(tr("Visualization: Minimum event cost:"));
visualizationMinimumInclusiveCostRatio.setSuffix(tr("%")); visualizationMinimumInclusiveCostRatio.setSuffix(tr("%"));
group.registerAspect(&visibleErrorKinds); registerAspect(&visibleErrorKinds);
visibleErrorKinds.setSettingsKey(base + "VisibleErrorKinds"); visibleErrorKinds.setSettingsKey(base + "VisibleErrorKinds");
QList<int> defaultErrorKinds; QList<int> defaultErrorKinds;
for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i) for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i)
@@ -451,24 +451,6 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
visibleErrorKinds.setDefaultValue(defaultErrorKinds); visibleErrorKinds.setDefaultValue(defaultErrorKinds);
} }
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
{
group.fromMap(map);
if (ValgrindGlobalSettings::instance() != this) {
// FIXME: Update project page e.g. on "Restore Global", aspects
// there are 'autoapply', and Aspect::cancel() is normally part of
// the 'manual apply' machinery.
group.setAutoApply(false);
group.cancel();
group.setAutoApply(true);
}
}
void ValgrindBaseSettings::toMap(QVariantMap &map) const
{
group.toMap(map);
}
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// //
@@ -485,25 +467,25 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
const QString base = "Analyzer.Valgrind"; const QString base = "Analyzer.Valgrind";
group.registerAspect(&lastSuppressionDirectory); registerAspect(&lastSuppressionDirectory);
lastSuppressionDirectory.setSettingsKey(base + "LastSuppressionDirectory"); lastSuppressionDirectory.setSettingsKey(base + "LastSuppressionDirectory");
group.registerAspect(&lastSuppressionHistory); registerAspect(&lastSuppressionHistory);
lastSuppressionHistory.setSettingsKey(base + "LastSuppressionHistory"); lastSuppressionHistory.setSettingsKey(base + "LastSuppressionHistory");
group.registerAspect(&detectCycles); registerAspect(&detectCycles);
detectCycles.setSettingsKey(base + "Callgrind.CycleDetection"); detectCycles.setSettingsKey(base + "Callgrind.CycleDetection");
detectCycles.setDefaultValue(true); detectCycles.setDefaultValue(true);
detectCycles.setLabelText("O"); // FIXME: Create a real icon detectCycles.setLabelText("O"); // FIXME: Create a real icon
detectCycles.setToolTip(tr("Enable cycle detection to properly handle recursive " detectCycles.setToolTip(tr("Enable cycle detection to properly handle recursive "
"or circular function calls.")); "or circular function calls."));
group.registerAspect(&costFormat); registerAspect(&costFormat);
costFormat.setSettingsKey(base + "Callgrind.CostFormat"); costFormat.setSettingsKey(base + "Callgrind.CostFormat");
costFormat.setDefaultValue(CostDelegate::FormatRelative); costFormat.setDefaultValue(CostDelegate::FormatRelative);
costFormat.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); costFormat.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
group.registerAspect(&shortenTemplates); registerAspect(&shortenTemplates);
shortenTemplates.setSettingsKey(base + "Callgrind.ShortenTemplates"); shortenTemplates.setSettingsKey(base + "Callgrind.ShortenTemplates");
shortenTemplates.setDefaultValue(true); shortenTemplates.setDefaultValue(true);
shortenTemplates.setLabelText("<>"); // FIXME: Create a real icon shortenTemplates.setLabelText("<>"); // FIXME: Create a real icon
@@ -512,7 +494,7 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); }); setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
readSettings(); readSettings();
group.forEachAspect([](BaseAspect *aspect) { aspect->setAutoApply(false); }); setAutoApply(false);
} }
ValgrindGlobalSettings *ValgrindGlobalSettings::instance() ValgrindGlobalSettings *ValgrindGlobalSettings::instance()
@@ -527,7 +509,7 @@ ValgrindGlobalSettings *ValgrindGlobalSettings::instance()
QVariantMap ValgrindBaseSettings::defaultSettings() const QVariantMap ValgrindBaseSettings::defaultSettings() const
{ {
QVariantMap defaults; QVariantMap defaults;
group.forEachAspect([&defaults](BaseAspect *aspect) { forEachAspect([&defaults](BaseAspect *aspect) {
defaults.insert(aspect->settingsKey(), aspect->defaultValue()); defaults.insert(aspect->settingsKey(), aspect->defaultValue());
}); });
return defaults; return defaults;
@@ -572,6 +554,15 @@ ValgrindProjectSettings::ValgrindProjectSettings()
: ValgrindBaseSettings(false) : ValgrindBaseSettings(false)
{ {
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); }); setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
connect(this, &AspectContainer::fromMapFinished, [this] {
// FIXME: Update project page e.g. on "Restore Global", aspects
// there are 'autoapply', and Aspect::cancel() is normally part of
// the 'manual apply' machinery.
setAutoApply(false);
cancel();
setAutoApply(true);
});
} }
} // namespace Internal } // namespace Internal

View File

@@ -89,9 +89,6 @@ public:
LeakCheckOnFinishYes LeakCheckOnFinishYes
}; };
void toMap(QVariantMap &map) const override;
void fromMap(const QVariantMap &map) override;
signals: signals:
void changed(); // sent when multiple values have changed simulatenously (e.g. fromMap) void changed(); // sent when multiple values have changed simulatenously (e.g. fromMap)
@@ -134,7 +131,6 @@ public:
Utils::DoubleAspect minimumInclusiveCostRatio; Utils::DoubleAspect minimumInclusiveCostRatio;
Utils::DoubleAspect visualizationMinimumInclusiveCostRatio; Utils::DoubleAspect visualizationMinimumInclusiveCostRatio;
Utils::AspectContainer group;
QVariantMap defaultSettings() const; QVariantMap defaultSettings() const;
}; };