@@ -30,6 +30,7 @@ FactorsFormBase::FactorsFormBase(QQuickItem *parent)
30
30
_useControlMouseArea = false ;
31
31
_containsVariables = true ;
32
32
_mayUseFormula = false ;
33
+ _useTermsInRSyntax = false ;
33
34
}
34
35
35
36
void FactorsFormBase::setUpModel ()
@@ -48,61 +49,38 @@ void FactorsFormBase::setUpModel()
48
49
void FactorsFormBase::bindTo (const Json::Value& value)
49
50
{
50
51
ListModelFactorsForm::FactorVec factors;
51
- Json::Value updatedValue = value; // If the value has no types, then we need to update it.
52
52
53
- for (Json::Value& factor : updatedValue )
53
+ for (const Json::Value& factor : value )
54
54
{
55
- Json::Value types (Json::arrayValue);
56
- if (factor.isMember (" types" ))
57
- {
58
- if (factor[" types" ].isArray ())
59
- types = factor[" types" ];
60
- else if (factor[" types" ].isString ())
61
- types.append (factor[" types" ].asString ());
62
- }
63
- int i = 0 ;
64
-
65
55
Terms initTerms;
66
- for (const Json::Value& termsJson : factor[fq (_optionKey)])
56
+ for (const Json::Value& termJson : factor[fq (_optionKey)])
67
57
{
68
58
std::vector<std::string> components;
69
59
70
- if (termsJson .isArray ())
60
+ if (termJson .isArray ())
71
61
{
72
62
// For interaction, each term is an array of strings
73
- for (const Json::Value& elt : termsJson )
63
+ for (const Json::Value& elt : termJson )
74
64
if (elt.isString ())
75
65
components.push_back (elt.asString ());
76
66
}
77
- else if (termsJson .isString ())
67
+ else if (termJson .isString ())
78
68
// If not, each term is just a string
79
- components.push_back (termsJson .asString ());
69
+ components.push_back (termJson .asString ());
80
70
81
71
if (components.size () > 0 )
82
72
{
83
- Term term (components);
84
- columnType type = columnType::unknown;
85
- if (types.size () <= i)
86
- {
87
- if (components.size () == 1 )
88
- type = model ()->getVariableRealType (tq (components[0 ]));
89
- types.append (columnTypeToString (type));
90
- }
91
- else
92
- {
93
- type = columnTypeFromString (types[i].asString ());
94
- term.setType (type);
95
- }
73
+ columnTypeVec types;
74
+ for (const std::string& component : components)
75
+ types.push_back (model ()->getVariableRealType (tq (component)));
76
+ Term term (components, types);
96
77
initTerms.add (term);
97
78
}
98
-
99
- i++;
100
79
}
101
- factor[" types" ] = types;
102
80
factors.push_back (ListModelFactorsForm::Factor (tq (factor[" name" ].asString ()), tq (factor[" title" ].asString ()), initTerms));
103
81
}
104
82
105
- BoundControlBase::bindTo (updatedValue );
83
+ BoundControlBase::bindTo (value );
106
84
107
85
_factorsModel->initFactors (factors);
108
86
}
@@ -117,7 +95,6 @@ Json::Value FactorsFormBase::createJson() const
117
95
row[" name" ] = fq (baseName () + QString::number (i + startIndex ()));
118
96
row[" title" ] = fq (baseTitle () + " " + QString::number (i + startIndex ()));
119
97
row[fq (_optionKey)] = Json::Value (Json::arrayValue);
120
- row[" types" ] = Json::Value (Json::arrayValue);
121
98
122
99
result.append (row);
123
100
}
@@ -158,7 +135,6 @@ void FactorsFormBase::termsChangedHandler()
158
135
factorJson[" name" ] = fq (factor.name );
159
136
factorJson[" title" ] = fq (factor.title );
160
137
Json::Value termsJson (Json::arrayValue);
161
- Json::Value typesJson (Json::arrayValue);
162
138
163
139
for (const Term &term : factor.listView ? factor.listView ->model ()->terms () : factor.initTerms )
164
140
{
@@ -171,10 +147,8 @@ void FactorsFormBase::termsChangedHandler()
171
147
else
172
148
termJson = term.asString ();
173
149
termsJson.append (termJson);
174
- typesJson.append (columnTypeToString (term.type ()));
175
150
}
176
151
factorJson[fq (_optionKey)] = termsJson;
177
- factorJson[" types" ] = typesJson;
178
152
boundValue.append (factorJson);
179
153
}
180
154
0 commit comments