Skip to content

Commit 9f41d8e

Browse files
committed
Now disabled attributes cannot be edited in GNEOptionsEditor. Refs #17321
1 parent 9b2cfa7 commit 9f41d8e

File tree

5 files changed

+88
-41
lines changed

5 files changed

+88
-41
lines changed

src/netedit/GNELoadThread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,6 @@ GNELoadThread::fillOptions(OptionsCont& neteditOptions) {
306306
neteditOptions.addXMLDefault("netconvert-file", "netconvertConfiguration");
307307
neteditOptions.setOptionEditable("netconvert-file", false);
308308

309-
neteditOptions.doRegister("autosave-netconvert-file", new Option_Bool(false));
310-
neteditOptions.addDescription("autosave-netconvert-file", "Input", TL("If enabled, automatically save a netconvert configuration after saving a netedit config"));
311-
312309
neteditOptions.doRegister("additional-files", 'a', new Option_FileName());
313310
neteditOptions.addSynonyme("additional-files", "additional");
314311
neteditOptions.addDescription("additional-files", "Input", TL("Load additional and shapes descriptions from FILE(s)"));
@@ -332,6 +329,9 @@ GNELoadThread::fillOptions(OptionsCont& neteditOptions) {
332329
neteditOptions.doRegister("ignore-missing-inputs", new Option_Bool(false));
333330
neteditOptions.addDescription("ignore-missing-inputs", "Input", TL("Reset path values (additional, route, data...) after loading netedit config"));
334331

332+
neteditOptions.doRegister("autosave-netconvert-file", new Option_Bool(false));
333+
neteditOptions.addDescription("autosave-netconvert-file", "Input", TL("If enabled, automatically save a netconvert configuration after saving a netedit config"));
334+
335335
neteditOptions.doRegister("selection-file", new Option_FileName());
336336
neteditOptions.addDescription("selection-file", "Input", TL("Load element selection"));
337337

src/netedit/dialogs/options/GNEOptionsEditor.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,25 @@ GNEOptionsEditor::GNEOptionsEditor(GNEDialog* dialog, const std::string& titleNa
121121
const std::string description = myOptionsContainer.getDescription(entry);
122122
// get default value
123123
const std::string defaultValue = myOptionsContainer.getValueString(entry);
124+
// check if is editable
125+
const bool editable = myOptionsContainer.isEditable(entry);
124126
// continue depending of type
125127
if (type == "STR") {
126-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionString(this, myEntriesFrame, topic, entry, description, defaultValue));
128+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionString(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
127129
} else if (type == "TIME") {
128-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionTime(this, myEntriesFrame, topic, entry, description, defaultValue));
130+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionTime(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
129131
} else if ((type == "FILE") || (type == "NETWORK") || (type == "ADDITIONAL") || (type == "ROUTE") || (type == "DATA")) {
130-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionFilename(this, myEntriesFrame, topic, entry, description, defaultValue));
132+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionFilename(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
131133
} else if (type == "BOOL") {
132-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionBool(this, myEntriesFrame, topic, entry, description, defaultValue));
134+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionBool(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
133135
} else if (type == "INT") {
134-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionInt(this, myEntriesFrame, topic, entry, description, defaultValue));
136+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionInt(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
135137
} else if (type == "FLOAT") {
136-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionFloat(this, myEntriesFrame, topic, entry, description, defaultValue));
138+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionFloat(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
137139
} else if (type == "INT[]") {
138-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionIntVector(this, myEntriesFrame, topic, entry, description, defaultValue));
140+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionIntVector(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
139141
} else if (type == "STR[]") {
140-
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionStringVector(this, myEntriesFrame, topic, entry, description, defaultValue));
142+
myOptionRowEntries.push_back(new GNEOptionsEditorRow::OptionStringVector(this, myEntriesFrame, topic, entry, description, defaultValue, editable));
141143
}
142144
}
143145
}

src/netedit/dialogs/options/GNEOptionsEditorRow.cpp

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ FXIMPLEMENT_ABSTRACT(GNEOptionsEditorRow::OptionFilename, GNEOptionsEditorRow:
6262
// ---------------------------------------------------------------------------
6363

6464
GNEOptionsEditorRow::OptionRow::OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
65-
const std::string& name, const std::string& description, const std::string& defaultValue) :
65+
const std::string& name, const std::string& description, const std::string& defaultValue, const bool editable) :
6666
FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame),
6767
myOptionsEditor(optionsEditor),
6868
myTopic(topic),
6969
myName(name),
7070
myDescription(description),
71-
myDefaultValue(defaultValue) {
71+
myDefaultValue(defaultValue),
72+
myEditable(editable) {
7273
// build label with name (default width 150)
7374
myNameLabel = new MFXLabelTooltip(this, myOptionsEditor->myDialog->getApplicationWindow()->getStaticTooltipMenu(),
7475
name.c_str(), nullptr, GUIDesignLabelThickedFixed(MINNAMEWIDTH));
@@ -122,10 +123,14 @@ GNEOptionsEditorRow::OptionRow::updateResetButton() {
122123
// ---------------------------------------------------------------------------
123124

124125
GNEOptionsEditorRow::OptionString::OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent,
125-
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
126-
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
126+
const std::string& topic, const std::string& name, const std::string& description,
127+
const std::string& defaultValue, const bool editable) :
128+
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
127129
myStringTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
128130
myStringTextField->setText(myOptionsEditor->myOptionsContainer.getString(name).c_str());
131+
if (!editable) {
132+
myStringTextField->disable();
133+
}
129134
updateOption();
130135
}
131136

@@ -169,9 +174,13 @@ GNEOptionsEditorRow::OptionString::getValue() const {
169174

170175

171176
GNEOptionsEditorRow::OptionStringVector::OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent,
172-
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
173-
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
177+
const std::string& topic, const std::string& name, const std::string& description,
178+
const std::string& defaultValue, const bool editable) :
179+
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
174180
myStringVectorTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
181+
if (!editable) {
182+
myStringVectorTextField->disable();
183+
}
175184
updateOption();
176185
}
177186

@@ -218,9 +227,13 @@ GNEOptionsEditorRow::OptionStringVector::getValue() const {
218227
// ---------------------------------------------------------------------------
219228

220229
GNEOptionsEditorRow::OptionBool::OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent,
221-
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
222-
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
230+
const std::string& topic, const std::string& name, const std::string& description,
231+
const std::string& defaultValue, const bool editable) :
232+
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
223233
myCheckButton = new FXCheckButton(myContentFrame, "", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
234+
if (!editable) {
235+
myCheckButton->disable();
236+
}
224237
updateOption();
225238
}
226239

@@ -301,9 +314,13 @@ GNEOptionsEditorRow::OptionBool::getValue() const {
301314
// ---------------------------------------------------------------------------
302315

303316
GNEOptionsEditorRow::OptionInt::OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent,
304-
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
305-
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
317+
const std::string& topic, const std::string& name, const std::string& description,
318+
const std::string& defaultValue, const bool editable) :
319+
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
306320
myIntTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_INTEGER));
321+
if (!editable) {
322+
myIntTextField->disable();
323+
}
307324
updateOption();
308325
}
309326

@@ -354,10 +371,14 @@ GNEOptionsEditorRow::OptionInt::getValue() const {
354371
// ---------------------------------------------------------------------------
355372

356373
GNEOptionsEditorRow::OptionIntVector::OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent,
357-
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
358-
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
374+
const std::string& topic, const std::string& name, const std::string& description,
375+
const std::string& defaultValue, const bool editable) :
376+
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
359377
myIntVectorTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
360378
myIntVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getIntVector(name)).c_str());
379+
if (!editable) {
380+
myIntVectorTextField->disable();
381+
}
361382
updateOption();
362383
}
363384

@@ -413,11 +434,15 @@ GNEOptionsEditorRow::OptionIntVector::getValue() const {
413434
// GNEOptionsEditorRow::OptionFloat - methods
414435
// ---------------------------------------------------------------------------
415436

416-
GNEOptionsEditorRow::OptionFloat::OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
417-
const std::string& name, const std::string& description, const std::string& defaultValue) :
418-
OptionRow(optionsEditor, parent, topic, name, description, parseFloat(defaultValue)) {
437+
GNEOptionsEditorRow::OptionFloat::OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent,
438+
const std::string& topic, const std::string& name, const std::string& description,
439+
const std::string& defaultValue, const bool editable) :
440+
OptionRow(optionsEditor, parent, topic, name, description, parseFloat(defaultValue), editable) {
419441
myFloatTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));
420442
myFloatTextField->setText(toString(myOptionsEditor->myOptionsContainer.getFloat(name)).c_str());
443+
if (!editable) {
444+
myFloatTextField->disable();
445+
}
421446
updateOption();
422447
}
423448

@@ -478,11 +503,15 @@ GNEOptionsEditorRow::OptionFloat::parseFloat(const std::string& value) const {
478503
// GNEOptionsEditorRow::OptionTime - methods
479504
// ---------------------------------------------------------------------------
480505

481-
GNEOptionsEditorRow::OptionTime::OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
482-
const std::string& name, const std::string& description, const std::string& defaultValue) :
483-
OptionRow(optionsEditor, parent, topic, name, description, parseTime(defaultValue)) {
506+
GNEOptionsEditorRow::OptionTime::OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent,
507+
const std::string& topic, const std::string& name, const std::string& description,
508+
const std::string& defaultValue, const bool editable) :
509+
OptionRow(optionsEditor, parent, topic, name, description, parseTime(defaultValue), editable) {
484510
myTimeTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
485511
myTimeTextField->setText(toString(myOptionsEditor->myOptionsContainer.getString(name)).c_str());
512+
if (!editable) {
513+
myTimeTextField->disable();
514+
}
486515
updateOption();
487516
}
488517

@@ -544,11 +573,15 @@ GNEOptionsEditorRow::OptionTime::parseTime(const std::string& value) const {
544573
// ---------------------------------------------------------------------------
545574

546575
GNEOptionsEditorRow::OptionFilename::OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
547-
const std::string& name, const std::string& description, const std::string& defaultValue) :
548-
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
576+
const std::string& name, const std::string& description, const std::string& defaultValue, const bool editable) :
577+
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
549578
myOpenFilenameButton = GUIDesigns::buildFXButton(myContentFrame, "", "", TL("Select filename"),
550579
GUIIconSubSys::getIcon(GUIIcon::OPEN), this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonIcon);
551580
myFilenameTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
581+
if (!editable) {
582+
myOpenFilenameButton->disable();
583+
myFilenameTextField->disable();
584+
}
552585
updateOption();
553586
}
554587

src/netedit/dialogs/options/GNEOptionsEditorRow.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class GNEOptionsEditorRow {
4646
public:
4747
/// @brief constructor
4848
OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
49-
const std::string& name, const std::string& description, const std::string& defaultValue);
49+
const std::string& name, const std::string& description, const std::string& defaultValue,
50+
const bool editable);
5051

5152
/// @brief adjust input name size
5253
void adjustNameSize();
@@ -94,6 +95,9 @@ class GNEOptionsEditorRow {
9495
/// @brief content frame
9596
FXHorizontalFrame* myContentFrame = nullptr;
9697

98+
/// @brief editable
99+
const bool myEditable = true;
100+
97101
/// @brief update reset button
98102
void updateResetButton();
99103

@@ -114,7 +118,8 @@ class GNEOptionsEditorRow {
114118
public:
115119
/// @brief constructor
116120
OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
117-
const std::string& name, const std::string& description, const std::string& defaultValue);
121+
const std::string& name, const std::string& description, const std::string& defaultValue,
122+
const bool editable);
118123

119124
/// @brief update option
120125
void updateOption();
@@ -142,7 +147,8 @@ class GNEOptionsEditorRow {
142147
public:
143148
/// @brief constructor
144149
OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
145-
const std::string& name, const std::string& description, const std::string& defaultValue);
150+
const std::string& name, const std::string& description, const std::string& defaultValue,
151+
const bool editable);
146152

147153
/// @brief update option
148154
void updateOption();
@@ -170,7 +176,8 @@ class GNEOptionsEditorRow {
170176
public:
171177
/// @brief constructor
172178
OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
173-
const std::string& name, const std::string& description, const std::string& defaultValue);
179+
const std::string& name, const std::string& description, const std::string& defaultValue,
180+
const bool editable);
174181

175182
/// @brief update option
176183
void updateOption();
@@ -198,7 +205,8 @@ class GNEOptionsEditorRow {
198205
public:
199206
/// @brief
200207
OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
201-
const std::string& name, const std::string& description, const std::string& defaultValue);
208+
const std::string& name, const std::string& description, const std::string& defaultValue,
209+
const bool editable);
202210

203211
/// @brief update option
204212
void updateOption();
@@ -226,7 +234,8 @@ class GNEOptionsEditorRow {
226234
public:
227235
/// @brief
228236
OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
229-
const std::string& name, const std::string& description, const std::string& defaultValue);
237+
const std::string& name, const std::string& description, const std::string& defaultValue,
238+
const bool editable);
230239

231240
/// @brief update option
232241
void updateOption();
@@ -254,7 +263,8 @@ class GNEOptionsEditorRow {
254263
public:
255264
/// @brief constructor
256265
OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
257-
const std::string& name, const std::string& description, const std::string& defaultValue);
266+
const std::string& name, const std::string& description, const std::string& defaultValue,
267+
const bool editable);
258268

259269
/// @brief update option
260270
void updateOption();
@@ -285,7 +295,8 @@ class GNEOptionsEditorRow {
285295
public:
286296
/// @brief constructor
287297
OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
288-
const std::string& name, const std::string& description, const std::string& defaultValue);
298+
const std::string& name, const std::string& description, const std::string& defaultValue,
299+
const bool editable);
289300

290301
/// @brief update option
291302
void updateOption();
@@ -318,7 +329,8 @@ class GNEOptionsEditorRow {
318329
public:
319330
/// @brief constructor
320331
OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
321-
const std::string& name, const std::string& description, const std::string& defaultValue);
332+
const std::string& name, const std::string& description, const std::string& defaultValue,
333+
const bool editable);
322334

323335
/// @brief update option
324336
void updateOption();

src/utils/options/Option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class Option {
389389
bool myPositional = false;
390390

391391
/// @brief this option can be edited using option dialog
392-
bool myEditable = false;
392+
bool myEditable = true;
393393

394394
/// @brief the list separator for this option (needed for python tools)
395395
std::string myListSeparator = "";

0 commit comments

Comments
 (0)