Changeset View
Changeset View
Standalone View
Standalone View
core/form.cpp
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Line(s) | 228 | public: | |||
---|---|---|---|---|---|
231 | { | 231 | { | ||
232 | } | 232 | } | ||
233 | 233 | | |||
234 | Q_DECLARE_PUBLIC( FormFieldChoice ) | 234 | Q_DECLARE_PUBLIC( FormFieldChoice ) | ||
235 | 235 | | |||
236 | void setValue( const QString& v ) override | 236 | void setValue( const QString& v ) override | ||
237 | { | 237 | { | ||
238 | Q_Q( FormFieldChoice ); | 238 | Q_Q( FormFieldChoice ); | ||
239 | QStringList choices = v.split( QLatin1Char (';'), QString::SkipEmptyParts ); | 239 | const QStringList choices = v.split( QLatin1Char (';'), QString::SkipEmptyParts ); | ||
240 | QList<int> newchoices; | 240 | QList<int> newchoices; | ||
241 | foreach ( const QString& str, choices ) | 241 | for ( const QString &str : choices ) | ||
242 | { | 242 | { | ||
243 | bool ok = true; | 243 | bool ok = true; | ||
244 | int val = str.toInt( &ok ); | 244 | int val = str.toInt( &ok ); | ||
245 | if ( ok ) | 245 | if ( ok ) | ||
246 | newchoices.append( val ); | 246 | newchoices.append( val ); | ||
247 | } | 247 | } | ||
248 | if ( !newchoices.isEmpty() ) | 248 | if ( !newchoices.isEmpty() ) | ||
249 | q->setCurrentChoices( newchoices ); | 249 | q->setCurrentChoices( newchoices ); | ||
250 | } | 250 | } | ||
251 | 251 | | |||
252 | QString value() const override | 252 | QString value() const override | ||
253 | { | 253 | { | ||
254 | Q_Q( const FormFieldChoice ); | 254 | Q_Q( const FormFieldChoice ); | ||
255 | QList<int> choices = q->currentChoices(); | 255 | QList<int> choices = q->currentChoices(); | ||
256 | std::sort(choices.begin(), choices.end()); | 256 | std::sort(choices.begin(), choices.end()); | ||
257 | QStringList list; | 257 | QStringList list; | ||
258 | foreach ( int c, choices ) | 258 | for ( const int &c : qAsConst(choices) ) | ||
aacid: same | |||||
259 | { | 259 | { | ||
260 | list.append( QString::number( c ) ); | 260 | list.append( QString::number( c ) ); | ||
261 | } | 261 | } | ||
262 | return list.join( QStringLiteral( ";" ) ); | 262 | return list.join( QStringLiteral( ";" ) ); | ||
263 | } | 263 | } | ||
264 | }; | 264 | }; | ||
265 | 265 | | |||
266 | 266 | | |||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
same