ProjectExplorer: Move user path conversion closer to the edge

And replace some foreach().

Change-Id: I788e112c0e314f5514af22dabd111f9cdb64dca5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-09-27 17:04:37 +02:00
parent ceae67022c
commit b115de563c

View File

@@ -303,7 +303,7 @@ void CustomWizardFieldPage::initializePage()
{ {
QWizardPage::initializePage(); QWizardPage::initializePage();
clearError(); clearError();
foreach (const LineEditData &led, m_lineEdits) { for (const LineEditData &led : qAsConst(m_lineEdits)) {
if (!led.userChange.isNull()) { if (!led.userChange.isNull()) {
led.lineEdit->setText(led.userChange); led.lineEdit->setText(led.userChange);
} else if (!led.defaultText.isEmpty()) { } else if (!led.defaultText.isEmpty()) {
@@ -314,7 +314,7 @@ void CustomWizardFieldPage::initializePage()
if (!led.placeholderText.isEmpty()) if (!led.placeholderText.isEmpty())
led.lineEdit->setPlaceholderText(led.placeholderText); led.lineEdit->setPlaceholderText(led.placeholderText);
} }
foreach (const TextEditData &ted, m_textEdits) { for (const TextEditData &ted : qAsConst(m_textEdits)) {
if (!ted.userChange.isNull()) { if (!ted.userChange.isNull()) {
ted.textEdit->setText(ted.userChange); ted.textEdit->setText(ted.userChange);
} else if (!ted.defaultText.isEmpty()) { } else if (!ted.defaultText.isEmpty()) {
@@ -323,13 +323,13 @@ void CustomWizardFieldPage::initializePage()
ted.textEdit->setText(defaultText); ted.textEdit->setText(defaultText);
} }
} }
foreach (const PathChooserData &ped, m_pathChoosers) { for (const PathChooserData &ped : qAsConst(m_pathChoosers)) {
if (!ped.userChange.isNull()) { if (!ped.userChange.isNull()) {
ped.pathChooser->setPath(ped.userChange); ped.pathChooser->setFilePath(FilePath::fromUserInput(ped.userChange));
} else if (!ped.defaultText.isEmpty()) { } else if (!ped.defaultText.isEmpty()) {
QString defaultText = ped.defaultText; QString defaultText = ped.defaultText;
CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText); CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText);
ped.pathChooser->setPath(defaultText); ped.pathChooser->setFilePath(FilePath::fromUserInput(defaultText));
} }
} }
} }