Base: simplify UnitsSchemas management
Fixes: Maintaining schemas is difficult and error-prone - Facilitate easy schemas add, remove, change, etc. - Remove 14 files containing approx 2,190 lines of if/else code and data - Place data in one file (UnitsSchemasData.h) using a normalized structure (including special functions) - Isolate and simplify data operations (code) - Remove schemas enum to keep data independent of code - Separate responsibilities: Specifications, data, schemas, schema - Add schema data 'isDefault' - Add schema data name - Prefer algorithms to raw loops - Add schemas unit tests - Tweak quantity unit tests
This commit is contained in:
@@ -83,11 +83,12 @@ DlgProjectInformationImp::DlgProjectInformationImp(App::Document* doc,
|
||||
ui->lineEditCompany->setText(QString::fromUtf8(doc->Company.getValue()));
|
||||
|
||||
// Load comboBox with unit systems
|
||||
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
|
||||
for (int i = 0; i < num; i++) {
|
||||
QString item = Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i));
|
||||
ui->comboBox_unitSystem->addItem(item, i);
|
||||
}
|
||||
auto addDesc = [&, index {0}](const std::string& item) mutable {
|
||||
ui->comboBox_unitSystem->addItem(QString::fromStdString(item), index++);
|
||||
};
|
||||
const auto descriptions = Base::UnitsApi::getDescriptions();
|
||||
std::for_each(descriptions.begin(), descriptions.end(), addDesc);
|
||||
|
||||
ui->comboBox_unitSystem->setCurrentIndex(doc->UnitSystem.getValue());
|
||||
|
||||
// load comboBox with license names
|
||||
|
||||
Reference in New Issue
Block a user