forked from qt-creator/qt-creator
Add way to recursively link a variable chooser to suitable child widget
Change-Id: Id4937fc4367cca96833c46db87e37ed6524bda0a Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -372,6 +372,18 @@ void VariableChooser::addSupportedWidget(QWidget *textcontrol, const QByteArray
|
|||||||
textcontrol->setProperty(kVariableNameProperty, ownName);
|
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
|
* \internal
|
||||||
*/
|
*/
|
||||||
|
@@ -55,6 +55,8 @@ public:
|
|||||||
void addMacroExpanderProvider(const Utils::MacroExpanderProvider &provider);
|
void addMacroExpanderProvider(const Utils::MacroExpanderProvider &provider);
|
||||||
void addSupportedWidget(QWidget *textcontrol, const QByteArray &ownName = QByteArray());
|
void addSupportedWidget(QWidget *textcontrol, const QByteArray &ownName = QByteArray());
|
||||||
|
|
||||||
|
static void addSupportForChildWidgets(QWidget *parent, Utils::MacroExpander *expander);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *ev);
|
void keyPressEvent(QKeyEvent *ev);
|
||||||
bool eventFilter(QObject *, QEvent *event);
|
bool eventFilter(QObject *, QEvent *event);
|
||||||
|
Reference in New Issue
Block a user