Commit edd960a0 authored by hjk's avatar hjk
Browse files

Add way to recursively link a variable chooser to suitable child widget



Change-Id: Id4937fc4367cca96833c46db87e37ed6524bda0a
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 61ae8563
......@@ -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<QWidget *>()) {
if (qobject_cast<QLineEdit *>(child)
|| qobject_cast<QTextEdit *>(child)
|| qobject_cast<QPlainTextEdit *>(child))
chooser->addSupportedWidget(child);
}
}
/*!
* \internal
*/
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment