@@ -280,7 +280,7 @@ void VariableDialog::onVariablesTableUpdated()
280
280
}
281
281
282
282
auto item = ui->variablesTable ->item (currentRow, 0 );
283
- SCP_string itemText = item->text ().toStdString ();
283
+ SCP_string itemText = item->text ().toUtf8 (). constData ();
284
284
bool apply = false ;
285
285
286
286
// This will only be true if the user is trying to add a new variable.
@@ -327,7 +327,7 @@ void VariableDialog::onVariablesTableUpdated()
327
327
auto ret = _model->changeVariableName (item->row (), itemText);
328
328
329
329
// we put something in the cell, but the model couldn't process it.
330
- if (strlen (item->text ().toStdString ().c_str ()) && ret.empty ()){
330
+ if (strlen (item->text ().toUtf8 ().constData ()) && ret.empty ()) {
331
331
// update of variable name failed, resync UI
332
332
apply = true ;
333
333
@@ -341,7 +341,7 @@ void VariableDialog::onVariablesTableUpdated()
341
341
342
342
// now work on the variable data cell
343
343
item = ui->variablesTable ->item (currentRow, 1 );
344
- itemText = item->text ().toStdString ();
344
+ itemText = item->text ().toUtf8 (). constData ();
345
345
346
346
// check if data column was altered
347
347
if (itemText != _currentVariableData) {
@@ -360,7 +360,7 @@ void VariableDialog::onVariablesTableUpdated()
360
360
361
361
// Variable is a number
362
362
} else {
363
- SCP_string source = item->text ().toStdString ();
363
+ SCP_string source = item->text ().toUtf8 (). constData ();
364
364
SCP_string temp = _model->trimIntegerString (source);
365
365
366
366
try {
@@ -404,13 +404,13 @@ void VariableDialog::onVariablesSelectionChanged()
404
404
auto item = ui->variablesTable ->item (row, 0 );
405
405
406
406
if (item){
407
- newVariableName = item->text ().toStdString ();
407
+ newVariableName = item->text ().toUtf8 (). constData ();
408
408
}
409
409
410
410
item = ui->variablesTable ->item (row, 1 );
411
411
412
412
if (item){
413
- _currentVariableData = item->text ().toStdString ();
413
+ _currentVariableData = item->text ().toUtf8 (). constData ();
414
414
}
415
415
416
416
if (newVariableName != _currentVariable){
@@ -439,7 +439,7 @@ void VariableDialog::onContainersTableUpdated()
439
439
// Are they adding a new container?
440
440
if (row == ui->containersTable ->rowCount () - 1 ){
441
441
if (ui->containersTable ->item (row, 0 )) {
442
- SCP_string newString = ui->containersTable ->item (row, 0 )->text ().toStdString ();
442
+ SCP_string newString = ui->containersTable ->item (row, 0 )->text ().toUtf8 (). constData ();
443
443
if (!newString.empty () && newString != " Add Container ..." ){
444
444
_model->addContainer (newString);
445
445
_currentContainer = newString;
@@ -454,7 +454,7 @@ void VariableDialog::onContainersTableUpdated()
454
454
455
455
// are they editing an existing container name?
456
456
} else if (ui->containersTable ->item (row, 0 )){
457
- SCP_string newName = ui->containersTable ->item (row,0 )->text ().toStdString ();
457
+ SCP_string newName = ui->containersTable ->item (row,0 )->text ().toUtf8 (). constData ();
458
458
459
459
// Restoring a deleted container?
460
460
if (_currentContainer.empty ()){
@@ -484,7 +484,7 @@ void VariableDialog::onContainersSelectionChanged()
484
484
}
485
485
486
486
// guaranteed not to be null, since getCurrentContainerRow already checked.
487
- _currentContainer = ui->containersTable ->item (row, 0 )->text ().toStdString ();
487
+ _currentContainer = ui->containersTable ->item (row, 0 )->text ().toUtf8 (). constData ();
488
488
applyModel ();
489
489
}
490
490
@@ -512,7 +512,7 @@ void VariableDialog::onContainerContentsTableUpdated()
512
512
SCP_string newString;
513
513
514
514
if (ui->containerContentsTable ->item (row, 0 )) {
515
- newString = ui->containerContentsTable ->item (row, 0 )->text ().toStdString ();
515
+ newString = ui->containerContentsTable ->item (row, 0 )->text ().toUtf8 (). constData ();
516
516
517
517
if (!newString.empty () && newString != " Add item ..." ){
518
518
@@ -532,7 +532,7 @@ void VariableDialog::onContainerContentsTableUpdated()
532
532
}
533
533
534
534
if (ui->containerContentsTable ->item (row, 1 )) {
535
- newString = ui->containerContentsTable ->item (row, 1 )->text ().toStdString ();
535
+ newString = ui->containerContentsTable ->item (row, 1 )->text ().toUtf8 (). constData ();
536
536
537
537
if (!newString.empty () && newString != " Add item ..." ){
538
538
@@ -554,7 +554,7 @@ void VariableDialog::onContainerContentsTableUpdated()
554
554
555
555
// are they editing an existing container item column 1?
556
556
} else if (ui->containerContentsTable ->item (row, 0 )){
557
- SCP_string newText = ui->containerContentsTable ->item (row, 0 )->text ().toStdString ();
557
+ SCP_string newText = ui->containerContentsTable ->item (row, 0 )->text ().toUtf8 (). constData ();
558
558
559
559
if (_model->getContainerListOrMap (containerRow)){
560
560
@@ -581,7 +581,7 @@ void VariableDialog::onContainerContentsTableUpdated()
581
581
// if we're here, nothing has changed so far. So let's attempt column 2
582
582
if (ui->containerContentsTable ->item (row, 1 ) && !_model->getContainerListOrMap (containerRow)){
583
583
584
- SCP_string newText = ui->containerContentsTable ->item (row, 1 )->text ().toStdString ();
584
+ SCP_string newText = ui->containerContentsTable ->item (row, 1 )->text ().toUtf8 (). constData ();
585
585
586
586
if (newText != _currentContainerItemCol2){
587
587
@@ -624,9 +624,9 @@ void VariableDialog::onContainerContentsSelectionChanged()
624
624
return ;
625
625
}
626
626
627
- newContainerItemName = item->text ().toStdString ();
627
+ newContainerItemName = item->text ().toUtf8 (). constData ();
628
628
item = ui->containerContentsTable ->item (row, 1 );
629
- SCP_string newContainerDataText = (item) ? item->text ().toStdString () : " " ;
629
+ SCP_string newContainerDataText = (item) ? item->text ().toUtf8 (). constData () : " " ;
630
630
631
631
if (newContainerItemName != _currentContainerItemCol1 || _currentContainerItemCol2 != newContainerDataText){
632
632
_currentContainerItemCol1 = newContainerItemName;
@@ -676,7 +676,8 @@ void VariableDialog::onDeleteVariableButtonPressed()
676
676
}
677
677
678
678
// Because of the text update we'll need, this needs an applyModel, whether it fails or not.
679
- if (ui->deleteVariableButton ->text ().toStdString () == " Restore" ) {
679
+ SCP_string btn_text = ui->deleteVariableButton ->text ().toUtf8 ().constData ();
680
+ if (btn_text == " Restore" ) {
680
681
_model->removeVariable (currentRow, false );
681
682
applyModel ();
682
683
} else {
@@ -853,7 +854,8 @@ void VariableDialog::onDeleteContainerButtonPressed()
853
854
}
854
855
855
856
// Because of the text update we'll need, this needs an applyModel, whether it fails or not.
856
- if (ui->deleteContainerButton ->text ().toStdString () == " Restore" ){
857
+ SCP_string btn_text = ui->deleteContainerButton ->text ().toUtf8 ().constData ();
858
+ if (btn_text == " Restore" ){
857
859
_model->removeContainer (row, false );
858
860
} else {
859
861
_model->removeContainer (row, true );
@@ -1248,12 +1250,13 @@ void VariableDialog::applyModel()
1248
1250
}
1249
1251
1250
1252
if (_currentVariable.empty () || selectedRow < 0 ){
1251
- if (ui->variablesTable ->item (0 , 0 ) && !ui->variablesTable ->item (0 , 0 )->text ().toStdString ().empty ()){
1252
- _currentVariable = ui->variablesTable ->item (0 , 0 )->text ().toStdString ();
1253
+ SCP_string text = ui->variablesTable ->item (0 , 0 )->text ().toUtf8 ().constData ();
1254
+ if (ui->variablesTable ->item (0 , 0 ) && !text.empty ()) {
1255
+ _currentVariable = text;
1253
1256
}
1254
1257
1255
1258
if (ui->variablesTable ->item (0 , 1 )) {
1256
- _currentVariableData = ui->variablesTable ->item (0 , 1 )->text ().toStdString ();
1259
+ _currentVariableData = ui->variablesTable ->item (0 , 1 )->text ().toUtf8 (). constData ();
1257
1260
}
1258
1261
}
1259
1262
@@ -1294,11 +1297,13 @@ void VariableDialog::applyModel()
1294
1297
}
1295
1298
1296
1299
// do we need to switch the delete button to a restore button?
1297
- if (selectedRow > -1 && ui->containersTable ->item (selectedRow, 2 ) && ui->containersTable ->item (selectedRow, 2 )->text ().toStdString () == " To Be Deleted" ) {
1300
+ SCP_string var = selectedRow > -1 ? ui->containersTable ->item (selectedRow, 2 )->text ().toUtf8 ().constData () : " " ;
1301
+ if (selectedRow > -1 && ui->containersTable ->item (selectedRow, 2 ) && var == " To Be Deleted" ) {
1298
1302
ui->deleteContainerButton ->setText (" Restore" );
1299
1303
1300
1304
// We can't restore empty container names.
1301
- if (ui->containersTable ->item (selectedRow, 0 ) && ui->containersTable ->item (selectedRow, 0 )->text ().toStdString ().empty ()){
1305
+ SCP_string text = ui->containersTable ->item (selectedRow, 0 )->text ().toUtf8 ().constData ();
1306
+ if (ui->containersTable ->item (selectedRow, 0 ) && text.empty ()){
1302
1307
ui->deleteContainerButton ->setEnabled (false );
1303
1308
} else {
1304
1309
ui->deleteContainerButton ->setEnabled (true );
@@ -1338,7 +1343,7 @@ void VariableDialog::applyModel()
1338
1343
1339
1344
if (selectedRow < 0 && ui->containersTable ->rowCount () > 1 ) {
1340
1345
if (ui->containersTable ->item (0 , 0 )){
1341
- _currentContainer = ui->containersTable ->item (0 , 0 )->text ().toStdString ();
1346
+ _currentContainer = ui->containersTable ->item (0 , 0 )->text ().toUtf8 (). constData ();
1342
1347
ui->containersTable ->clearSelection ();
1343
1348
ui->containersTable ->item (0 , 0 )->setSelected (true );
1344
1349
}
@@ -1396,11 +1401,13 @@ void VariableDialog::updateVariableOptions(bool safeToAlter)
1396
1401
ui->setVariableAsNumberRadio ->setChecked (!string);
1397
1402
1398
1403
// do we need to switch the delete button to a restore button?
1399
- if (ui->variablesTable ->item (row, 2 ) && ui->variablesTable ->item (row, 2 )->text ().toStdString () == " To Be Deleted" ){
1404
+ SCP_string var = ui->variablesTable ->item (row, 2 ) ? ui->variablesTable ->item (row, 2 )->text ().toUtf8 ().constData () : " " ;
1405
+ if (ui->variablesTable ->item (row, 2 ) && var == " To Be Deleted" ){
1400
1406
ui->deleteVariableButton ->setText (" Restore" );
1401
1407
1402
1408
// We can't restore empty variable names.
1403
- if (ui->variablesTable ->item (row, 0 ) && ui->variablesTable ->item (row, 0 )->text ().toStdString ().empty ()){
1409
+ SCP_string text = ui->variablesTable ->item (row, 0 )->text ().toUtf8 ().constData ();
1410
+ if (ui->variablesTable ->item (row, 0 ) && text.empty ()){
1404
1411
ui->deleteVariableButton ->setEnabled (false );
1405
1412
} else {
1406
1413
ui->deleteVariableButton ->setEnabled (true );
@@ -1823,7 +1830,8 @@ int VariableDialog::getCurrentVariableRow()
1823
1830
1824
1831
// yes, selected items returns a list, but we really should only have one item because multiselect will be off.
1825
1832
for (const auto & item : items) {
1826
- if (item && item->column () == 0 && item->text ().toStdString () != " Add Variable ..." ) {
1833
+ SCP_string var = item->text ().toUtf8 ().constData ();
1834
+ if (item && item->column () == 0 && var != " Add Variable ..." ) {
1827
1835
return item->row ();
1828
1836
}
1829
1837
}
@@ -1837,7 +1845,8 @@ int VariableDialog::getCurrentContainerRow()
1837
1845
1838
1846
// yes, selected items returns a list, but we really should only have one item because multiselect will be off.
1839
1847
for (const auto & item : items) {
1840
- if (item && item->column () == 0 && item->text ().toStdString () != " Add Container ..." ) {
1848
+ SCP_string var = item->text ().toUtf8 ().constData ();
1849
+ if (item && item->column () == 0 && var != " Add Container ..." ) {
1841
1850
return item->row ();
1842
1851
}
1843
1852
}
@@ -1851,7 +1860,8 @@ int VariableDialog::getCurrentContainerItemRow()
1851
1860
1852
1861
// yes, selected items returns a list, but we really should only have one item because multiselect will be off.
1853
1862
for (const auto & item : items) {
1854
- if (item && ((item->column () == 0 && item->text ().toStdString () != " Add item ..." ) || (item->column () == 1 && item->text ().toStdString () != " Add item ..." ))) {
1863
+ SCP_string var = item->text ().toUtf8 ().constData ();
1864
+ if (item && ((item->column () == 0 && var != " Add item ..." ) || (item->column () == 1 && var != " Add item ..." ))) {
1855
1865
return item->row ();
1856
1866
}
1857
1867
}
0 commit comments