forked from qt-creator/qt-creator
Make adding variable support to textcontrol easier.
Add convenience method in variable chooser and move magic constant to the place where it's used. Change-Id: Ie93acb98e13efcacb77d1a478df927a11b16926b Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "coreconstants.h"
|
||||
|
||||
#include <utils/fancylineedit.h> // IconButton
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QLineEdit>
|
||||
@@ -42,6 +43,8 @@
|
||||
|
||||
using namespace Core;
|
||||
|
||||
const char VariableChooser::kVariableSupportProperty[] = "QtCreator.VariableSupport";
|
||||
|
||||
VariableChooser::VariableChooser(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Internal::Ui::VariableChooser),
|
||||
@@ -76,6 +79,12 @@ VariableChooser::~VariableChooser()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void VariableChooser::addVariableSupport(QWidget *textcontrol)
|
||||
{
|
||||
QTC_ASSERT(textcontrol, return);
|
||||
textcontrol->setProperty(kVariableSupportProperty, true);
|
||||
}
|
||||
|
||||
void VariableChooser::updateDescription(const QString &variable)
|
||||
{
|
||||
if (variable.isNull())
|
||||
@@ -109,7 +118,7 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
|
||||
m_lineEdit = 0;
|
||||
m_textEdit = 0;
|
||||
m_plainTextEdit = 0;
|
||||
QVariant variablesSupportProperty = widget->property(Constants::VARIABLE_SUPPORT_PROPERTY);
|
||||
QVariant variablesSupportProperty = widget->property(kVariableSupportProperty);
|
||||
bool supportsVariables = (variablesSupportProperty.isValid()
|
||||
? variablesSupportProperty.toBool() : false);
|
||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget))
|
||||
|
||||
Reference in New Issue
Block a user