| 1227 | } |
| 1228 | |
| 1229 | int |
| 1230 | Project::tryAddProjectFormat(const Format & f, bool* existed) |
| 1231 | { |
| 1232 | //assert( !_imp->formatMutex.tryLock() ); |
| 1233 | if ( ( f.left() >= f.right() ) || ( f.bottom() >= f.top() ) ) { |
| 1234 | return -1; |
| 1235 | } |
| 1236 | |
| 1237 | std::list<Format>::iterator foundFormat = std::find(_imp->builtinFormats.begin(), _imp->builtinFormats.end(), f); |
| 1238 | if ( foundFormat != _imp->builtinFormats.end() ) { |
| 1239 | *existed = true; |
| 1240 | return std::distance(_imp->builtinFormats.begin(), foundFormat); |
| 1241 | } else { |
| 1242 | foundFormat = std::find(_imp->additionalFormats.begin(), _imp->additionalFormats.end(), f); |
| 1243 | if ( foundFormat != _imp->additionalFormats.end() ) { |
| 1244 | *existed = true; |
| 1245 | return std::distance(_imp->additionalFormats.begin(), foundFormat) + _imp->builtinFormats.size(); |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | std::vector<ChoiceOption> entries; |
| 1250 | for (std::list<Format>::iterator it = _imp->builtinFormats.begin(); it != _imp->builtinFormats.end(); ++it) { |
| 1251 | const Format & f = *it; |
| 1252 | QString formatStr = ProjectPrivate::generateStringFromFormat(f); |
| 1253 | if ( !f.getName().empty() ) { |
| 1254 | entries.push_back( ChoiceOption(f.getName(), formatStr.toStdString(), "") ); |
| 1255 | } else { |
| 1256 | entries.push_back( ChoiceOption( formatStr.toStdString() ) ); |
| 1257 | } |
| 1258 | } |
| 1259 | for (std::list<Format>::iterator it = _imp->additionalFormats.begin(); it != _imp->additionalFormats.end(); ++it) { |
| 1260 | const Format & f = *it; |
| 1261 | QString formatStr = ProjectPrivate::generateStringFromFormat(f); |
| 1262 | if ( !f.getName().empty() ) { |
| 1263 | entries.push_back( ChoiceOption(f.getName(), formatStr.toStdString(), "") ); |
| 1264 | } else { |
| 1265 | entries.push_back( ChoiceOption( formatStr.toStdString() ) ); |
| 1266 | } |
| 1267 | } |
| 1268 | QString formatStr = ProjectPrivate::generateStringFromFormat(f); |
| 1269 | _imp->additionalFormats.push_back(f); |
| 1270 | if ( !f.getName().empty() ) { |
| 1271 | _imp->formatKnob->appendChoice( ChoiceOption(f.getName(), formatStr.toStdString(), "") ); |
| 1272 | } else { |
| 1273 | _imp->formatKnob->appendChoice( ChoiceOption( formatStr.toStdString() ) ); |
| 1274 | } |
| 1275 | |
| 1276 | return ( _imp->builtinFormats.size() + _imp->additionalFormats.size() ) - 1; |
| 1277 | } |
| 1278 | |
| 1279 | void |
| 1280 | Project::setProjectDefaultFormat(const Format & f) |
nothing calls this directly
no test coverage detected