aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/jsonwizard
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@qt.io>2017-09-26 11:00:21 +0200
committerTim Jenssen <tim.jenssen@qt.io>2017-09-29 09:34:08 +0000
commit7dbd399a97b10190447e1c93cd7e5110b1306dc3 (patch)
tree12b298b5055494170472a4f7a7168d493cf65e24 /src/plugins/projectexplorer/jsonwizard
parentdefcb6a55a6561fd80ee9377c06984f3cd450c07 (diff)
Wizards: introduce ObjectToFieldWidgetConverter
With it as a wrapper we can register any QObject to use widget based field mechanism from QWizard. It also helps to avoid the necessity for inheritance to just adjust the text property of a widget. Can not remove the TextCheckBox, because it is used in some old C++ wizards. Change-Id: I85a85a834714a4b38b501c13357fa8c8bb02b5bd Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/jsonwizard')
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp24
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h1
2 files changed, 14 insertions, 11 deletions
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp
index a207e1863c..bb625cf889 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp
@@ -33,7 +33,6 @@
#include <utils/fancylineedit.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
-#include <utils/textfieldcheckbox.h>
#include <utils/textfieldcombobox.h>
#include <utils/theme/theme.h>
@@ -702,16 +701,23 @@ bool CheckBoxField::parseData(const QVariant &data, QString *errorMessage)
QWidget *CheckBoxField::createWidget(const QString &displayName, JsonFieldPage *page)
{
Q_UNUSED(page);
- return new TextFieldCheckBox(displayName);
+ return new QCheckBox(displayName);
}
void CheckBoxField::setup(JsonFieldPage *page, const QString &name)
{
- auto w = qobject_cast<TextFieldCheckBox *>(widget());
+ auto w = qobject_cast<QCheckBox *>(widget());
QTC_ASSERT(w, return);
- QObject::connect(w, &TextFieldCheckBox::clicked,
- page, [this, page]() { m_isModified = true; page->completeChanged();});
- page->registerFieldWithName(name, w, "compareText", SIGNAL(textChanged(QString)));
+ page->registerObjectAsFieldWithName<QCheckBox>(name, w, &QCheckBox::stateChanged, [this, page, w] () -> QString {
+ if (w->checkState() == Qt::Checked)
+ return page->expander()->expand(m_checkedValue);
+ return page->expander()->expand(m_uncheckedValue);
+ });
+
+ QObject::connect(w, &QCheckBox::stateChanged, page, [this, page]() {
+ m_isModified = true;
+ emit page->completeChanged();
+ });
}
bool CheckBoxField::validate(MacroExpander *expander, QString *message)
@@ -720,7 +726,7 @@ bool CheckBoxField::validate(MacroExpander *expander, QString *message)
return false;
if (!m_isModified) {
- auto w = qobject_cast<TextFieldCheckBox *>(widget());
+ auto w = qobject_cast<QCheckBox *>(widget());
QTC_ASSERT(w, return false);
w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander));
}
@@ -729,10 +735,8 @@ bool CheckBoxField::validate(MacroExpander *expander, QString *message)
void CheckBoxField::initializeData(MacroExpander *expander)
{
- auto w = qobject_cast<TextFieldCheckBox *>(widget());
+ auto w = qobject_cast<QCheckBox *>(widget());
QTC_ASSERT(widget(), return);
- w->setTrueText(expander->expand(m_checkedValue));
- w->setFalseText(expander->expand(m_uncheckedValue));
w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander));
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h
index b9eb6692a1..f21d3a7d46 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h
+++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h
@@ -42,7 +42,6 @@ QT_END_NAMESPACE
namespace Utils {
class MacroExpander;
-class TextFieldCheckBox;
class TextFieldComboBox;
} // namespace Utils