Skip to content

Commit

Permalink
Ensure types are correct in formula
Browse files Browse the repository at this point in the history
  • Loading branch information
boutinb committed Nov 11, 2024
1 parent 6c190b2 commit 85dbb81
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions QMLComponents/models/listmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Term ListModel::_checkTermType(const Term &term) const
return checkedTerm;
}

Terms ListModel::_checkTermsTypes(const std::vector<Term>& terms) const
Terms ListModel::checkTermsTypes(const std::vector<Term>& terms) const
{
Terms checkedTerms;
for (const Term& term : terms)
Expand All @@ -127,7 +127,7 @@ Terms ListModel::_checkTermsTypes(const std::vector<Term>& terms) const
}


Terms ListModel::_checkTermsTypes(const Terms& terms) const
Terms ListModel::checkTermsTypes(const Terms& terms) const
{
Terms checkedTerms = terms; // Keep terms properties
for (Term& term : checkedTerms)
Expand Down Expand Up @@ -742,14 +742,14 @@ void ListModel::_setTerms(const Terms &terms, const Terms& parentTerms)

void ListModel::_setTerms(const std::vector<Term> &terms)
{
_checkTermsTypes(terms);
checkTermsTypes(terms);
_terms.set(terms);
setUpRowControls();
}

void ListModel::_setTerms(const Terms &terms)
{
_terms.set(_checkTermsTypes(terms));
_terms.set(checkTermsTypes(terms));
setUpRowControls();
}

Expand Down Expand Up @@ -779,7 +779,7 @@ void ListModel::_removeLastTerm()

void ListModel::_addTerms(const Terms &terms)
{
_terms.add(_checkTermsTypes(terms));
_terms.add(checkTermsTypes(terms));
setUpRowControls();
}

Expand Down
5 changes: 3 additions & 2 deletions QMLComponents/models/listmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class ListModel : public QAbstractTableModel, public VariableInfoConsumer
QString getVariablePreview( const QString& name) const;
QStringList getUsedTypes() const;

Terms checkTermsTypes(const Terms& terms) const;
Terms checkTermsTypes(const std::vector<Term>& terms) const;

Q_INVOKABLE int searchTermWith(QString searchString);
Q_INVOKABLE void selectItem(int _index, bool _select);
Q_INVOKABLE void clearSelectedItems(bool emitSelectedChange = true);
Expand Down Expand Up @@ -137,8 +140,6 @@ public slots:
void _addTerm(const Term& term, bool isUnique = true);
void _replaceTerm(int index, const Term& term);
void _connectAllSourcesControls();
Terms _checkTermsTypes(const Terms& terms) const;
Terms _checkTermsTypes(const std::vector<Term>& terms) const;
Term _checkTermType(const Term& terms) const;
void _setAllowedType(Term& term) const;

Expand Down
2 changes: 2 additions & 0 deletions QMLComponents/rsyntax/formulasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ FormulaParser::ParsedTerms FormulaSource::_fillOptionsWithFixedTerms(ListModel*

if (found)
{
terms = sourceModel->checkTermsTypes(terms);
termsToSearch = sourceModel->checkTermsTypes(termsToSearch);
_addTermsToOptions(sourceModel, options, termsToSearch);
break;
}
Expand Down

0 comments on commit 85dbb81

Please sign in to comment.