forked from qt-creator/qt-creator
JsonWizard: Split Fields out of fieldpage header
Change-Id: I9029b8da8d095216ec320a8e03ec5f3d4092dddc Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Benjamin Zeller <benjamin.zeller@canonical.com>
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "jsonfieldpage.h"
|
#include "jsonfieldpage.h"
|
||||||
|
#include "jsonfieldpage_p.h"
|
||||||
|
|
||||||
#include "jsonwizard.h"
|
#include "jsonwizard.h"
|
||||||
#include "jsonwizardfactory.h"
|
#include "jsonwizardfactory.h"
|
||||||
@@ -75,19 +76,19 @@ namespace ProjectExplorer {
|
|||||||
static JsonFieldPage::Field *createFieldData(const QString &type)
|
static JsonFieldPage::Field *createFieldData(const QString &type)
|
||||||
{
|
{
|
||||||
if (type == QLatin1String("Label"))
|
if (type == QLatin1String("Label"))
|
||||||
return new JsonFieldPage::LabelField;
|
return new LabelField;
|
||||||
else if (type == QLatin1String("Spacer"))
|
else if (type == QLatin1String("Spacer"))
|
||||||
return new JsonFieldPage::SpacerField;
|
return new SpacerField;
|
||||||
else if (type == QLatin1String("LineEdit"))
|
else if (type == QLatin1String("LineEdit"))
|
||||||
return new JsonFieldPage::LineEditField;
|
return new LineEditField;
|
||||||
else if (type == QLatin1String("TextEdit"))
|
else if (type == QLatin1String("TextEdit"))
|
||||||
return new JsonFieldPage::TextEditField;
|
return new TextEditField;
|
||||||
else if (type == QLatin1String("PathChooser"))
|
else if (type == QLatin1String("PathChooser"))
|
||||||
return new JsonFieldPage::PathChooserField;
|
return new PathChooserField;
|
||||||
else if (type == QLatin1String("CheckBox"))
|
else if (type == QLatin1String("CheckBox"))
|
||||||
return new JsonFieldPage::CheckBoxField;
|
return new CheckBoxField;
|
||||||
else if (type == QLatin1String("ComboBox"))
|
else if (type == QLatin1String("ComboBox"))
|
||||||
return new JsonFieldPage::ComboBoxField;
|
return new ComboBoxField;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,14 +229,13 @@ void JsonFieldPage::Field::initialize(MacroExpander *expander)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::LabelFieldData:
|
// LabelFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
JsonFieldPage::LabelField::LabelField() :
|
LabelField::LabelField() : m_wordWrap(false)
|
||||||
m_wordWrap(false)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool JsonFieldPage::LabelField::parseData(const QVariant &data, QString *errorMessage)
|
bool LabelField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.type() != QVariant::Map) {
|
if (data.type() != QVariant::Map) {
|
||||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage",
|
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage",
|
||||||
@@ -257,7 +257,7 @@ bool JsonFieldPage::LabelField::parseData(const QVariant &data, QString *errorMe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::LabelField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *LabelField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
Q_UNUSED(displayName);
|
Q_UNUSED(displayName);
|
||||||
Q_UNUSED(page);
|
Q_UNUSED(page);
|
||||||
@@ -272,14 +272,13 @@ QWidget *JsonFieldPage::LabelField::widget(const QString &displayName, JsonField
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::SpacerFieldData:
|
// SpacerFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
JsonFieldPage::SpacerField::SpacerField() :
|
SpacerField::SpacerField() : m_factor(1)
|
||||||
m_factor(1)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool JsonFieldPage::SpacerField::parseData(const QVariant &data, QString *errorMessage)
|
bool SpacerField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.isNull())
|
if (data.isNull())
|
||||||
return true;
|
return true;
|
||||||
@@ -304,7 +303,7 @@ bool JsonFieldPage::SpacerField::parseData(const QVariant &data, QString *errorM
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::SpacerField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *SpacerField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
Q_UNUSED(displayName);
|
Q_UNUSED(displayName);
|
||||||
Q_UNUSED(page);
|
Q_UNUSED(page);
|
||||||
@@ -320,13 +319,13 @@ QWidget *JsonFieldPage::SpacerField::widget(const QString &displayName, JsonFiel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::LineEditFieldData:
|
// LineEditFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
JsonFieldPage::LineEditField::LineEditField() : m_isModified(false), m_isValidating(false)
|
LineEditField::LineEditField() : m_isModified(false), m_isValidating(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool JsonFieldPage::LineEditField::parseData(const QVariant &data, QString *errorMessage)
|
bool LineEditField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.isNull())
|
if (data.isNull())
|
||||||
return true;
|
return true;
|
||||||
@@ -358,7 +357,7 @@ bool JsonFieldPage::LineEditField::parseData(const QVariant &data, QString *erro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::LineEditField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *LineEditField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
Q_UNUSED(displayName);
|
Q_UNUSED(displayName);
|
||||||
QTC_ASSERT(!m_widget, return m_widget);
|
QTC_ASSERT(!m_widget, return m_widget);
|
||||||
@@ -374,15 +373,15 @@ QWidget *JsonFieldPage::LineEditField::widget(const QString &displayName, JsonFi
|
|||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::LineEditField::setup(JsonFieldPage *page, const QString &name)
|
void LineEditField::setup(JsonFieldPage *page, const QString &name)
|
||||||
{
|
{
|
||||||
QLineEdit *w = static_cast<QLineEdit *>(m_widget);
|
QLineEdit *w = static_cast<QLineEdit *>(m_widget);
|
||||||
page->registerFieldWithName(name, w);
|
page->registerFieldWithName(name, w);
|
||||||
connect(w, &QLineEdit::textChanged,
|
QObject::connect(w, &QLineEdit::textChanged,
|
||||||
page, [this, page]() -> void { m_isModified = true; emit page->completeChanged(); });
|
page, [this, page]() -> void { m_isModified = true; emit page->completeChanged(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonFieldPage::LineEditField::validate(MacroExpander *expander, QString *message)
|
bool LineEditField::validate(MacroExpander *expander, QString *message)
|
||||||
{
|
{
|
||||||
if (!JsonFieldPage::Field::validate(expander, message))
|
if (!JsonFieldPage::Field::validate(expander, message))
|
||||||
return false;
|
return false;
|
||||||
@@ -414,7 +413,7 @@ bool JsonFieldPage::LineEditField::validate(MacroExpander *expander, QString *me
|
|||||||
return !w->text().isEmpty();
|
return !w->text().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::LineEditField::initializeData(MacroExpander *expander)
|
void LineEditField::initializeData(MacroExpander *expander)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_widget, return);
|
QTC_ASSERT(m_widget, return);
|
||||||
|
|
||||||
@@ -427,15 +426,14 @@ void JsonFieldPage::LineEditField::initializeData(MacroExpander *expander)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::TextEditFieldData:
|
// TextEditFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
JsonFieldPage::TextEditField::TextEditField() :
|
TextEditField::TextEditField() : m_acceptRichText(false)
|
||||||
m_acceptRichText(false)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool JsonFieldPage::TextEditField::parseData(const QVariant &data, QString *errorMessage)
|
bool TextEditField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.isNull())
|
if (data.isNull())
|
||||||
return true;
|
return true;
|
||||||
@@ -455,7 +453,7 @@ bool JsonFieldPage::TextEditField::parseData(const QVariant &data, QString *erro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::TextEditField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *TextEditField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
// TODO: Set up modification monitoring...
|
// TODO: Set up modification monitoring...
|
||||||
Q_UNUSED(displayName);
|
Q_UNUSED(displayName);
|
||||||
@@ -467,14 +465,14 @@ QWidget *JsonFieldPage::TextEditField::widget(const QString &displayName, JsonFi
|
|||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::TextEditField::setup(JsonFieldPage *page, const QString &name)
|
void TextEditField::setup(JsonFieldPage *page, const QString &name)
|
||||||
{
|
{
|
||||||
QTextEdit *w = static_cast<QTextEdit *>(m_widget);
|
QTextEdit *w = static_cast<QTextEdit *>(m_widget);
|
||||||
page->registerFieldWithName(name, w, "plainText", SIGNAL(textChanged()));
|
page->registerFieldWithName(name, w, "plainText", SIGNAL(textChanged()));
|
||||||
connect(w, &QTextEdit::textChanged, page, &QWizardPage::completeChanged);
|
QObject::connect(w, &QTextEdit::textChanged, page, &QWizardPage::completeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonFieldPage::TextEditField::validate(MacroExpander *expander, QString *message)
|
bool TextEditField::validate(MacroExpander *expander, QString *message)
|
||||||
{
|
{
|
||||||
if (!JsonFieldPage::Field::validate(expander, message))
|
if (!JsonFieldPage::Field::validate(expander, message))
|
||||||
return false;
|
return false;
|
||||||
@@ -492,21 +490,20 @@ bool JsonFieldPage::TextEditField::validate(MacroExpander *expander, QString *me
|
|||||||
return !w->toPlainText().isEmpty();
|
return !w->toPlainText().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::TextEditField::initializeData(MacroExpander *expander)
|
void TextEditField::initializeData(MacroExpander *expander)
|
||||||
{
|
{
|
||||||
QTextEdit *w = static_cast<QTextEdit *>(m_widget);
|
QTextEdit *w = static_cast<QTextEdit *>(m_widget);
|
||||||
w->setPlainText(expander->expand(m_defaultText));
|
w->setPlainText(expander->expand(m_defaultText));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::PathChooserFieldData:
|
// PathChooserFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
JsonFieldPage::PathChooserField::PathChooserField() :
|
PathChooserField::PathChooserField() : m_kind(PathChooser::ExistingDirectory)
|
||||||
m_kind(PathChooser::ExistingDirectory)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool JsonFieldPage::PathChooserField::parseData(const QVariant &data, QString *errorMessage)
|
bool PathChooserField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.isNull())
|
if (data.isNull())
|
||||||
return true;
|
return true;
|
||||||
@@ -549,7 +546,7 @@ bool JsonFieldPage::PathChooserField::parseData(const QVariant &data, QString *e
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::PathChooserField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *PathChooserField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
Q_UNUSED(displayName);
|
Q_UNUSED(displayName);
|
||||||
Q_UNUSED(page);
|
Q_UNUSED(page);
|
||||||
@@ -558,21 +555,22 @@ QWidget *JsonFieldPage::PathChooserField::widget(const QString &displayName, Jso
|
|||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::PathChooserField::setEnabled(bool e)
|
void PathChooserField::setEnabled(bool e)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_widget, return);
|
QTC_ASSERT(m_widget, return);
|
||||||
PathChooser *w = static_cast<PathChooser *>(m_widget);
|
PathChooser *w = static_cast<PathChooser *>(m_widget);
|
||||||
w->setReadOnly(!e);
|
w->setReadOnly(!e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::PathChooserField::setup(JsonFieldPage *page, const QString &name)
|
void PathChooserField::setup(JsonFieldPage *page, const QString &name)
|
||||||
{
|
{
|
||||||
PathChooser *w = static_cast<PathChooser *>(m_widget);
|
PathChooser *w = static_cast<PathChooser *>(m_widget);
|
||||||
page->registerFieldWithName(name, w, "path", SIGNAL(rawPathChanged(QString)));
|
page->registerFieldWithName(name, w, "path", SIGNAL(rawPathChanged(QString)));
|
||||||
connect(w, &PathChooser::rawPathChanged, page, [page](QString) { page->completeChanged(); });
|
QObject::connect(w, &PathChooser::rawPathChanged,
|
||||||
|
page, [page](QString) { page->completeChanged(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonFieldPage::PathChooserField::validate(MacroExpander *expander, QString *message)
|
bool PathChooserField::validate(MacroExpander *expander, QString *message)
|
||||||
{
|
{
|
||||||
if (!JsonFieldPage::Field::validate(expander, message))
|
if (!JsonFieldPage::Field::validate(expander, message))
|
||||||
return false;
|
return false;
|
||||||
@@ -581,7 +579,7 @@ bool JsonFieldPage::PathChooserField::validate(MacroExpander *expander, QString
|
|||||||
return w->isValid();
|
return w->isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::PathChooserField::initializeData(MacroExpander *expander)
|
void PathChooserField::initializeData(MacroExpander *expander)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_widget, return);
|
QTC_ASSERT(m_widget, return);
|
||||||
PathChooser *w = static_cast<PathChooser *>(m_widget);
|
PathChooser *w = static_cast<PathChooser *>(m_widget);
|
||||||
@@ -595,16 +593,16 @@ void JsonFieldPage::PathChooserField::initializeData(MacroExpander *expander)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::CheckBoxFieldData:
|
// CheckBoxFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
JsonFieldPage::CheckBoxField::CheckBoxField() :
|
CheckBoxField::CheckBoxField() :
|
||||||
m_checkedValue(QLatin1String("0")),
|
m_checkedValue(QLatin1String("0")),
|
||||||
m_uncheckedValue(QLatin1String("1")),
|
m_uncheckedValue(QLatin1String("1")),
|
||||||
m_isModified(false)
|
m_isModified(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool JsonFieldPage::CheckBoxField::parseData(const QVariant &data, QString *errorMessage)
|
bool CheckBoxField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.isNull())
|
if (data.isNull())
|
||||||
return true;
|
return true;
|
||||||
@@ -629,7 +627,7 @@ bool JsonFieldPage::CheckBoxField::parseData(const QVariant &data, QString *erro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::CheckBoxField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *CheckBoxField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
Q_UNUSED(page);
|
Q_UNUSED(page);
|
||||||
QTC_ASSERT(!m_widget, return m_widget);
|
QTC_ASSERT(!m_widget, return m_widget);
|
||||||
@@ -638,14 +636,15 @@ QWidget *JsonFieldPage::CheckBoxField::widget(const QString &displayName, JsonFi
|
|||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::CheckBoxField::setup(JsonFieldPage *page, const QString &name)
|
void CheckBoxField::setup(JsonFieldPage *page, const QString &name)
|
||||||
{
|
{
|
||||||
TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget);
|
TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget);
|
||||||
connect(w, &TextFieldCheckBox::clicked, [this, page]() { m_isModified = true; page->completeChanged();});
|
QObject::connect(w, &TextFieldCheckBox::clicked,
|
||||||
|
page, [this, page]() { m_isModified = true; page->completeChanged();});
|
||||||
page->registerFieldWithName(name, w, "text", SIGNAL(textChanged(QString)));
|
page->registerFieldWithName(name, w, "text", SIGNAL(textChanged(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonFieldPage::CheckBoxField::validate(MacroExpander *expander, QString *message)
|
bool CheckBoxField::validate(MacroExpander *expander, QString *message)
|
||||||
{
|
{
|
||||||
if (!JsonFieldPage::Field::validate(expander, message))
|
if (!JsonFieldPage::Field::validate(expander, message))
|
||||||
return false;
|
return false;
|
||||||
@@ -657,7 +656,7 @@ bool JsonFieldPage::CheckBoxField::validate(MacroExpander *expander, QString *me
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::CheckBoxField::initializeData(MacroExpander *expander)
|
void CheckBoxField::initializeData(MacroExpander *expander)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_widget, return);
|
QTC_ASSERT(m_widget, return);
|
||||||
|
|
||||||
@@ -669,11 +668,10 @@ void JsonFieldPage::CheckBoxField::initializeData(MacroExpander *expander)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// JsonFieldPage::ComboBoxFieldData:
|
// ComboBoxFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
JsonFieldPage::ComboBoxField::ComboBoxField() :
|
ComboBoxField::ComboBoxField() : m_index(-1), m_disabledIndex(-1), m_savedIndex(-1)
|
||||||
m_index(-1), m_disabledIndex(-1), m_savedIndex(-1)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
struct ComboBoxItem {
|
struct ComboBoxItem {
|
||||||
@@ -711,7 +709,7 @@ ComboBoxItem parseComboBoxItem(const QVariant &item, QString *errorMessage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonFieldPage::ComboBoxField::parseData(const QVariant &data, QString *errorMessage)
|
bool ComboBoxField::parseData(const QVariant &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (data.type() != QVariant::Map) {
|
if (data.type() != QVariant::Map) {
|
||||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage",
|
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage",
|
||||||
@@ -769,7 +767,7 @@ bool JsonFieldPage::ComboBoxField::parseData(const QVariant &data, QString *erro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *JsonFieldPage::ComboBoxField::widget(const QString &displayName, JsonFieldPage *page)
|
QWidget *ComboBoxField::widget(const QString &displayName, JsonFieldPage *page)
|
||||||
{
|
{
|
||||||
Q_UNUSED(displayName);
|
Q_UNUSED(displayName);
|
||||||
Q_UNUSED(page);
|
Q_UNUSED(page);
|
||||||
@@ -778,14 +776,15 @@ QWidget *JsonFieldPage::ComboBoxField::widget(const QString &displayName, JsonFi
|
|||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::ComboBoxField::setup(JsonFieldPage *page, const QString &name)
|
void ComboBoxField::setup(JsonFieldPage *page, const QString &name)
|
||||||
{
|
{
|
||||||
TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
|
TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
|
||||||
page->registerFieldWithName(name, w, "text", SIGNAL(text4Changed(QString)));
|
page->registerFieldWithName(name, w, "text", SIGNAL(text4Changed(QString)));
|
||||||
connect(w, &TextFieldComboBox::text4Changed, page, [page](QString) { page->completeChanged(); });
|
QObject::connect(w, &TextFieldComboBox::text4Changed,
|
||||||
|
page, [page](QString) { page->completeChanged(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonFieldPage::ComboBoxField::validate(MacroExpander *expander, QString *message)
|
bool ComboBoxField::validate(MacroExpander *expander, QString *message)
|
||||||
{
|
{
|
||||||
if (!JsonFieldPage::Field::validate(expander, message))
|
if (!JsonFieldPage::Field::validate(expander, message))
|
||||||
return false;
|
return false;
|
||||||
@@ -802,7 +801,7 @@ bool JsonFieldPage::ComboBoxField::validate(MacroExpander *expander, QString *me
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonFieldPage::ComboBoxField::initializeData(MacroExpander *expander)
|
void ComboBoxField::initializeData(MacroExpander *expander)
|
||||||
{
|
{
|
||||||
TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
|
TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
|
||||||
QStringList tmpItems
|
QStringList tmpItems
|
||||||
|
|||||||
@@ -99,149 +99,6 @@ public:
|
|||||||
QWidget *m_widget;
|
QWidget *m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LabelField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LabelField();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
|
|
||||||
bool m_wordWrap;
|
|
||||||
QString m_text;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SpacerField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SpacerField();
|
|
||||||
|
|
||||||
bool suppressName() const { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
|
|
||||||
int m_factor;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LineEditField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LineEditField();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
|
|
||||||
void setup(JsonFieldPage *page, const QString &name);
|
|
||||||
|
|
||||||
bool validate(Utils::MacroExpander *expander, QString *message);
|
|
||||||
void initializeData(Utils::MacroExpander *expander);
|
|
||||||
|
|
||||||
bool m_isModified;
|
|
||||||
bool m_isValidating;
|
|
||||||
QString m_placeholderText;
|
|
||||||
QString m_defaultText;
|
|
||||||
QString m_disabledText;
|
|
||||||
QRegularExpression m_validatorRegExp;
|
|
||||||
QString m_fixupExpando;
|
|
||||||
mutable QString m_currentText;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TextEditField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextEditField();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
|
|
||||||
void setup(JsonFieldPage *page, const QString &name);
|
|
||||||
|
|
||||||
bool validate(Utils::MacroExpander *expander, QString *message);
|
|
||||||
void initializeData(Utils::MacroExpander *expander);
|
|
||||||
|
|
||||||
QString m_defaultText;
|
|
||||||
bool m_acceptRichText;
|
|
||||||
QString m_disabledText;
|
|
||||||
|
|
||||||
mutable QString m_currentText;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PathChooserField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PathChooserField();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
void setEnabled(bool e);
|
|
||||||
|
|
||||||
void setup(JsonFieldPage *page, const QString &name);
|
|
||||||
|
|
||||||
bool validate(Utils::MacroExpander *expander, QString *message);
|
|
||||||
void initializeData(Utils::MacroExpander *expander);
|
|
||||||
|
|
||||||
QString m_path;
|
|
||||||
QString m_basePath;
|
|
||||||
Utils::PathChooser::Kind m_kind;
|
|
||||||
|
|
||||||
QString m_currentPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CheckBoxField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CheckBoxField();
|
|
||||||
|
|
||||||
bool suppressName() const { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
|
|
||||||
void setup(JsonFieldPage *page, const QString &name);
|
|
||||||
|
|
||||||
bool validate(Utils::MacroExpander *expander, QString *message);
|
|
||||||
void initializeData(Utils::MacroExpander *expander);
|
|
||||||
|
|
||||||
QString m_checkedValue;
|
|
||||||
QString m_uncheckedValue;
|
|
||||||
QVariant m_checkedExpression;
|
|
||||||
|
|
||||||
bool m_isModified;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ComboBoxField : public Field
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ComboBoxField();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool parseData(const QVariant &data, QString *errorMessage);
|
|
||||||
|
|
||||||
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
|
||||||
|
|
||||||
void setup(JsonFieldPage *page, const QString &name);
|
|
||||||
|
|
||||||
bool validate(Utils::MacroExpander *expander, QString *message);
|
|
||||||
void initializeData(Utils::MacroExpander *expander);
|
|
||||||
|
|
||||||
QStringList m_itemList;
|
|
||||||
QStringList m_itemDataList;
|
|
||||||
QVariantList m_itemConditionList;
|
|
||||||
int m_index;
|
|
||||||
int m_disabledIndex;
|
|
||||||
|
|
||||||
mutable int m_savedIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0);
|
JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0);
|
||||||
~JsonFieldPage();
|
~JsonFieldPage();
|
||||||
|
|
||||||
|
|||||||
189
src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h
Normal file
189
src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef JSONFIELDPAGE_P_H
|
||||||
|
#define JSONFIELDPAGE_P_H
|
||||||
|
|
||||||
|
#include "jsonfieldpage.h"
|
||||||
|
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
|
class LabelField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LabelField();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
|
||||||
|
bool m_wordWrap;
|
||||||
|
QString m_text;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SpacerField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpacerField();
|
||||||
|
|
||||||
|
bool suppressName() const { return true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
|
||||||
|
int m_factor;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LineEditField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LineEditField();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
|
||||||
|
void setup(JsonFieldPage *page, const QString &name);
|
||||||
|
|
||||||
|
bool validate(Utils::MacroExpander *expander, QString *message);
|
||||||
|
void initializeData(Utils::MacroExpander *expander);
|
||||||
|
|
||||||
|
bool m_isModified;
|
||||||
|
bool m_isValidating;
|
||||||
|
QString m_placeholderText;
|
||||||
|
QString m_defaultText;
|
||||||
|
QString m_disabledText;
|
||||||
|
QRegularExpression m_validatorRegExp;
|
||||||
|
QString m_fixupExpando;
|
||||||
|
mutable QString m_currentText;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TextEditField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextEditField();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
|
||||||
|
void setup(JsonFieldPage *page, const QString &name);
|
||||||
|
|
||||||
|
bool validate(Utils::MacroExpander *expander, QString *message);
|
||||||
|
void initializeData(Utils::MacroExpander *expander);
|
||||||
|
|
||||||
|
QString m_defaultText;
|
||||||
|
bool m_acceptRichText;
|
||||||
|
QString m_disabledText;
|
||||||
|
|
||||||
|
mutable QString m_currentText;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PathChooserField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PathChooserField();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
void setEnabled(bool e);
|
||||||
|
|
||||||
|
void setup(JsonFieldPage *page, const QString &name);
|
||||||
|
|
||||||
|
bool validate(Utils::MacroExpander *expander, QString *message);
|
||||||
|
void initializeData(Utils::MacroExpander *expander);
|
||||||
|
|
||||||
|
QString m_path;
|
||||||
|
QString m_basePath;
|
||||||
|
Utils::PathChooser::Kind m_kind;
|
||||||
|
|
||||||
|
QString m_currentPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CheckBoxField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CheckBoxField();
|
||||||
|
|
||||||
|
bool suppressName() const { return true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
|
||||||
|
void setup(JsonFieldPage *page, const QString &name);
|
||||||
|
|
||||||
|
bool validate(Utils::MacroExpander *expander, QString *message);
|
||||||
|
void initializeData(Utils::MacroExpander *expander);
|
||||||
|
|
||||||
|
QString m_checkedValue;
|
||||||
|
QString m_uncheckedValue;
|
||||||
|
QVariant m_checkedExpression;
|
||||||
|
|
||||||
|
bool m_isModified;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ComboBoxField : public JsonFieldPage::Field
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ComboBoxField();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseData(const QVariant &data, QString *errorMessage);
|
||||||
|
|
||||||
|
QWidget *widget(const QString &displayName, JsonFieldPage *page);
|
||||||
|
|
||||||
|
void setup(JsonFieldPage *page, const QString &name);
|
||||||
|
|
||||||
|
bool validate(Utils::MacroExpander *expander, QString *message);
|
||||||
|
void initializeData(Utils::MacroExpander *expander);
|
||||||
|
|
||||||
|
QStringList m_itemList;
|
||||||
|
QStringList m_itemDataList;
|
||||||
|
QVariantList m_itemConditionList;
|
||||||
|
int m_index;
|
||||||
|
int m_disabledIndex;
|
||||||
|
|
||||||
|
mutable int m_savedIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ProjectExplorer
|
||||||
|
|
||||||
|
#endif // JSONFIELDPAGE_P_H
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
HEADERS += $$PWD/jsonfieldpage.h \
|
HEADERS += $$PWD/jsonfieldpage.h \
|
||||||
|
$$PWD/jsonfieldpage_p.h \
|
||||||
$$PWD/jsonfilepage.h \
|
$$PWD/jsonfilepage.h \
|
||||||
$$PWD/jsonkitspage.h \
|
$$PWD/jsonkitspage.h \
|
||||||
$$PWD/jsonprojectpage.h \
|
$$PWD/jsonprojectpage.h \
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ QtcPlugin {
|
|||||||
name: "JsonWizard"
|
name: "JsonWizard"
|
||||||
prefix: "jsonwizard/"
|
prefix: "jsonwizard/"
|
||||||
files: [
|
files: [
|
||||||
"jsonfieldpage.cpp", "jsonfieldpage.h",
|
"jsonfieldpage.cpp", "jsonfieldpage_p.h", "jsonfieldpage.h",
|
||||||
"jsonfilepage.cpp", "jsonfilepage.h",
|
"jsonfilepage.cpp", "jsonfilepage.h",
|
||||||
"jsonkitspage.cpp", "jsonkitspage.h",
|
"jsonkitspage.cpp", "jsonkitspage.h",
|
||||||
"jsonprojectpage.cpp", "jsonprojectpage.h",
|
"jsonprojectpage.cpp", "jsonprojectpage.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user