Commit d2df5534 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Use the currently shown error messages for the error summary

This way the same error messages are used for the error summary as for
the individual input fields.

GnuPG-bug-id: 5916
parent b5e66009
......@@ -190,15 +190,13 @@ private:
&& !ui.nameInput->isRequired() && !ui.emailInput->isRequired()) {
errors.push_back(i18n("Name and email address cannot both be empty."));
}
if (ui.nameInput->isRequired() && !ui.nameInput->hasValue()) {
errors.push_back(i18n("A name is required."));
} else if (!ui.nameInput->hasAcceptableInput()) {
errors.push_back(i18n("The entered name is not valid."));
const auto nameError = ui.nameInput->currentError();
if (!nameError.isEmpty()) {
errors.push_back(nameError);
}
if (ui.emailInput->isRequired() && !ui.emailInput->hasValue()) {
errors.push_back(i18n("An email address is required."));
} else if (!ui.emailInput->hasAcceptableInput()) {
errors.push_back(i18n("The entered email address is not valid."));
const auto emailError = ui.emailInput->currentError();
if (!emailError.isEmpty()) {
errors.push_back(emailError);
}
if (errors.size() > 1) {
KMessageBox::errorList(q, i18n("Sorry, the entered data is not acceptable."), errors);
......
......@@ -356,6 +356,14 @@ void FormTextInputBase::setEnabled(bool enabled)
}
}
QString FormTextInputBase::currentError() const
{
if (d->mError) {
return d->errorMessage(d->mError);
}
return {};
}
bool FormTextInputBase::validate(const QString &text, int pos) const
{
QString textCopy = text;
......
......@@ -115,6 +115,11 @@ public:
*/
void setEnabled(bool enabled);
/**
* Returns the currently shown error message for this input field.
*/
QString currentError() const;
/**
* Returns \c true, if the input has a value. This function is used to
* check required input fields for non-empty user input.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment