Changeset View
Changeset View
Standalone View
Standalone View
kmplot/xparser.cpp
Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | 201 | { | |||
---|---|---|---|---|---|
206 | 206 | | |||
207 | for ( ; ; ++pos) | 207 | for ( ; ; ++pos) | ||
208 | { | 208 | { | ||
209 | for ( QChar lastChar = 'f'; lastChar<'x'; ++lastChar.unicode() ) | 209 | for ( QChar lastChar = 'f'; lastChar<'x'; ++lastChar.unicode() ) | ||
210 | { | 210 | { | ||
211 | bool ok = true; | 211 | bool ok = true; | ||
212 | name[pos] = lastChar; | 212 | name[pos] = lastChar; | ||
213 | 213 | | |||
214 | foreach ( Function * it, m_ufkt ) | 214 | for ( Function * it : qAsConst(m_ufkt) ) | ||
215 | { | 215 | { | ||
216 | if ( int(it->id()) == id ) | 216 | if ( int(it->id()) == id ) | ||
217 | continue; | 217 | continue; | ||
218 | 218 | | |||
219 | foreach ( Equation * eq, it->eq ) | 219 | for ( Equation * eq : qAsConst(it->eq) ) | ||
220 | { | 220 | { | ||
221 | foreach ( const QString& pattern, neededPatterns) { | 221 | for ( const QString& pattern : neededPatterns) { | ||
222 | if ( eq->name() == pattern.arg(name) ) | 222 | if ( eq->name() == pattern.arg(name) ) | ||
223 | ok = false; | 223 | ok = false; | ||
224 | } | 224 | } | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | if (!ok) | 227 | if (!ok) | ||
228 | break; | 228 | break; | ||
229 | } | 229 | } | ||
Show All 20 Lines | 243 | { | |||
250 | 250 | | |||
251 | for ( int i = p2+1; i < p3; ++i ) | 251 | for ( int i = p2+1; i < p3; ++i ) | ||
252 | { | 252 | { | ||
253 | if ( !str.at(i).isSpace() ) | 253 | if ( !str.at(i).isSpace() ) | ||
254 | return; | 254 | return; | ||
255 | } | 255 | } | ||
256 | 256 | | |||
257 | QString const fname = str.left(p1); | 257 | QString const fname = str.left(p1); | ||
258 | foreach ( Function * it, m_ufkt ) | 258 | for ( Function * it : qAsConst(m_ufkt) ) | ||
259 | { | 259 | { | ||
260 | if ( int(it->id()) == id ) | 260 | if ( int(it->id()) == id ) | ||
261 | continue; | 261 | continue; | ||
262 | 262 | | |||
263 | foreach ( Equation * eq, it->eq ) | 263 | for ( Equation * eq : qAsConst(it->eq) ) | ||
264 | { | 264 | { | ||
265 | if ( eq->name() != fname ) | 265 | if ( eq->name() != fname ) | ||
266 | continue; | 266 | continue; | ||
267 | 267 | | |||
268 | str = str.mid(p1,str.length()-1); | 268 | str = str.mid(p1,str.length()-1); | ||
269 | QString function_name; | 269 | QString function_name; | ||
270 | if ( type == Equation::ParametricX ) | 270 | if ( type == Equation::ParametricX ) | ||
271 | function_name = 'x'; | 271 | function_name = 'x'; | ||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Line(s) | |||||
643 | } | 643 | } | ||
644 | 644 | | |||
645 | QStringList XParser::functionParameterList(uint id) | 645 | QStringList XParser::functionParameterList(uint id) | ||
646 | { | 646 | { | ||
647 | if ( !m_ufkt.contains( id ) ) | 647 | if ( !m_ufkt.contains( id ) ) | ||
648 | return QStringList(); | 648 | return QStringList(); | ||
649 | Function *item = m_ufkt[id]; | 649 | Function *item = m_ufkt[id]; | ||
650 | QStringList str_parameter; | 650 | QStringList str_parameter; | ||
651 | foreach ( const Value &it, item->m_parameters.list ) | 651 | for ( const Value &it : qAsConst(item->m_parameters.list) ) | ||
652 | str_parameter << it.expression(); | 652 | str_parameter << it.expression(); | ||
653 | return str_parameter; | 653 | return str_parameter; | ||
654 | } | 654 | } | ||
655 | bool XParser::functionAddParameter(uint id, const QString &new_parameter) | 655 | bool XParser::functionAddParameter(uint id, const QString &new_parameter) | ||
656 | { | 656 | { | ||
657 | if ( !m_ufkt.contains( id ) ) | 657 | if ( !m_ufkt.contains( id ) ) | ||
658 | return false; | 658 | return false; | ||
659 | Function *tmp_ufkt = m_ufkt[id]; | 659 | Function *tmp_ufkt = m_ufkt[id]; | ||
660 | 660 | | |||
661 | //check if the parameter already exists | 661 | //check if the parameter already exists | ||
662 | foreach ( const Value &it, tmp_ufkt->m_parameters.list ) | 662 | for ( const Value &it : qAsConst(tmp_ufkt->m_parameters.list) ) | ||
663 | { | 663 | { | ||
664 | if ( it.expression() == new_parameter ) | 664 | if ( it.expression() == new_parameter ) | ||
665 | return false; | 665 | return false; | ||
666 | } | 666 | } | ||
667 | 667 | | |||
668 | Value value; | 668 | Value value; | ||
669 | if ( !value.updateExpression( new_parameter ) ) | 669 | if ( !value.updateExpression( new_parameter ) ) | ||
670 | return false; | 670 | return false; | ||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |