diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-14 15:28:44 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-14 14:15:26 +0000 |
commit | c0c2df203dd26b6af2be5757501bb3cacd692ef6 (patch) | |
tree | 961d12dc7ba7db4fb0c9cb3a338250d65efd64b0 /src/plugins/projectexplorer | |
parent | 70bddbcab42759c3105db6801a918375449b848c (diff) |
Utils: Split up OutputFormatter class
An OutputFormatter takes some string and prints it into a text edit.
In addition, it can ask any number of registered OutputLineParsers
whether they think any special formatting should be applied to the
current line.
This mechanism is now properly modeled by our class design, rather than
being hidden in a monolithic class where everything had the same type,
no matter what its purpose was.
Prospective contributors can now simply be pointed to the
OutputLineParser class and will see at one glance what they have to do.
Change-Id: I9844499f062c94fb038ce73fd6f26576910148c2
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r-- | src/plugins/projectexplorer/appoutputpane.cpp | 4 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.cpp | 18 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.h | 10 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index cb24b7c1c2..d16f6fb702 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -154,7 +154,7 @@ AppOutputPane::RunControlTab::RunControlTab(RunControl *runControl, Core::Output runControl(runControl), window(w) { if (runControl && w) - w->setFormatters(runControl->outputFormatters()); + w->setLineParsers(runControl->outputParsers()); } AppOutputPane::AppOutputPane() : @@ -404,7 +404,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) if (tab.runControl) tab.runControl->initiateFinish(); tab.runControl = rc; - tab.window->setFormatters(rc->outputFormatters()); + tab.window->setLineParsers(rc->outputParsers()); handleOldOutput(tab.window); diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 18cf5a3099..241dac4021 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -288,7 +288,7 @@ public: q = nullptr; qDeleteAll(m_workers); m_workers.clear(); - qDeleteAll(outputFormatters); + qDeleteAll(outputParsers); } Q_ENUM(RunControlState) @@ -333,7 +333,7 @@ public: Kit *kit = nullptr; // Not owned. QPointer<Target> target; // Not owned. QPointer<Project> project; // Not owned. - QList<Utils::OutputFormatter *> outputFormatters; + QList<Utils::OutputLineParser *> outputParsers; std::function<bool(bool*)> promptToStop; std::vector<RunWorkerFactory> m_factories; @@ -384,8 +384,8 @@ void RunControl::setTarget(Target *target) d->buildEnvironment = bc->environment(); } - QTC_CHECK(d->outputFormatters.isEmpty()); - d->outputFormatters = OutputFormatterFactory::createFormatters(target); + QTC_CHECK(d->outputParsers.isEmpty()); + d->outputParsers = OutputFormatterFactory::createFormatters(target); setKit(target->kit()); d->project = target->project(); @@ -828,9 +828,9 @@ void RunControlPrivate::showError(const QString &msg) q->appendMessage(msg + '\n', ErrorMessageFormat); } -QList<Utils::OutputFormatter *> RunControl::outputFormatters() const +QList<Utils::OutputLineParser *> RunControl::outputParsers() const { - return d->outputFormatters; + return d->outputParsers; } Core::Id RunControl::runMode() const @@ -1606,9 +1606,9 @@ OutputFormatterFactory::~OutputFormatterFactory() g_outputFormatterFactories.removeOne(this); } -QList<OutputFormatter *> OutputFormatterFactory::createFormatters(Target *target) +QList<OutputLineParser *> OutputFormatterFactory::createFormatters(Target *target) { - QList<OutputFormatter *> formatters; + QList<OutputLineParser *> formatters; for (auto factory : qAsConst(g_outputFormatterFactories)) { if (auto formatter = factory->m_creator(target)) formatters << formatter; @@ -1617,7 +1617,7 @@ QList<OutputFormatter *> OutputFormatterFactory::createFormatters(Target *target } void OutputFormatterFactory::setFormatterCreator - (const std::function<OutputFormatter *(Target *)> &creator) + (const std::function<OutputLineParser *(Target *)> &creator) { m_creator = creator; } diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 99c6a7636c..f68f6fee35 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -45,7 +45,7 @@ namespace Utils { class MacroExpander; -class OutputFormatter; +class OutputLineParser; } // Utils namespace ProjectExplorer { @@ -238,7 +238,7 @@ public: Utils::FilePath targetFilePath() const; Utils::FilePath projectFilePath() const; - QList<Utils::OutputFormatter *> outputFormatters() const; + QList<Utils::OutputLineParser *> outputParsers() const; Core::Id runMode() const; const Runnable &runnable() const; @@ -309,13 +309,13 @@ protected: public: virtual ~OutputFormatterFactory(); - static QList<Utils::OutputFormatter *> createFormatters(Target *target); + static QList<Utils::OutputLineParser *> createFormatters(Target *target); protected: - void setFormatterCreator(const std::function<Utils::OutputFormatter *(Target *)> &creator); + void setFormatterCreator(const std::function<Utils::OutputLineParser *(Target *)> &creator); private: - std::function<Utils::OutputFormatter *(Target *)> m_creator; + std::function<Utils::OutputLineParser *(Target *)> m_creator; }; } // namespace ProjectExplorer |