MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / addConfig

Method addConfig

MiniZincIDE/configwindow.cpp:116–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116bool ConfigWindow::addConfig(const QString &fileName)
117{
118 int index = findConfigFile(fileName);
119 if (index != -1) {
120 // Already have this config
121 setCurrentIndex(index);
122 return true;
123 }
124
125 try {
126 QStringList warnings;
127 updateSolverConfig(configs[currentIndex()]);
128 configs.append(new (SolverConfiguration) (SolverConfiguration::loadJSON(fileName, warnings)));
129 for (auto sc : configs) {
130 if (!sc->syncedOptionsMatch(*(configs.last()))) {
131 populating = true; // Make sure this doesn't mark the config as modified
132 ui->sync_checkBox->setChecked(false);
133 populating = false;
134 break;
135 }
136 }
137 populateComboBox();
138
139 if (ui->sync_checkBox->isChecked()) {
140 // Ensure that newly loaded config overrides synced options
141 populating = true; // Make sure this doesn't mark the config as modified
142 ui->sync_checkBox->setChecked(false);
143 populating = false;
144 setCurrentIndex(configs.length() - 1);
145 populating = true; // Make sure this doesn't mark the config as modified
146 ui->sync_checkBox->setChecked(true);
147 populating = false;
148 }
149
150 if (!warnings.empty()) {
151 QMessageBox::warning(this, "MiniZinc IDE", warnings.join("\n"), QMessageBox::Ok);
152 }
153
154 return true;
155 } catch (Exception& e) {
156 QMessageBox::warning(this, "Parameter configuration error", e.message(), QMessageBox::Ok);
157 return false;
158 }
159}
160
161void ConfigWindow::mergeConfigs(const QList<SolverConfiguration*> confs)
162{

Callers 2

openFileMethod · 0.80
loadProjectMethod · 0.80

Calls 1

syncedOptionsMatchMethod · 0.80

Tested by

no test coverage detected