From edd960a01274488cfb590a4f81c5c980cdddf08d Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 5 Nov 2014 16:10:09 +0100 Subject: [PATCH] Add way to recursively link a variable chooser to suitable child widget Change-Id: Id4937fc4367cca96833c46db87e37ed6524bda0a Reviewed-by: Tobias Hunger --- src/plugins/coreplugin/variablechooser.cpp | 12 ++++++++++++ src/plugins/coreplugin/variablechooser.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index 5b7bda4d3ef..f09fc95385e 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -372,6 +372,18 @@ void VariableChooser::addSupportedWidget(QWidget *textcontrol, const QByteArray textcontrol->setProperty(kVariableNameProperty, ownName); } +void VariableChooser::addSupportForChildWidgets(QWidget *parent, MacroExpander *expander) +{ + auto chooser = new VariableChooser(parent); + chooser->addMacroExpanderProvider([expander] { return expander; }); + foreach (QWidget *child, parent->findChildren()) { + if (qobject_cast(child) + || qobject_cast(child) + || qobject_cast(child)) + chooser->addSupportedWidget(child); + } +} + /*! * \internal */ diff --git a/src/plugins/coreplugin/variablechooser.h b/src/plugins/coreplugin/variablechooser.h index 7c4a1568bd2..74ca3abdec2 100644 --- a/src/plugins/coreplugin/variablechooser.h +++ b/src/plugins/coreplugin/variablechooser.h @@ -55,6 +55,8 @@ public: void addMacroExpanderProvider(const Utils::MacroExpanderProvider &provider); void addSupportedWidget(QWidget *textcontrol, const QByteArray &ownName = QByteArray()); + static void addSupportForChildWidgets(QWidget *parent, Utils::MacroExpander *expander); + protected: void keyPressEvent(QKeyEvent *ev); bool eventFilter(QObject *, QEvent *event);