diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-04-28 14:49:56 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-05-06 15:47:27 +0000 |
commit | 3fc72220626da58b1174da4b6a61e45da9871158 (patch) | |
tree | 2272d81cda375f6cd22ed81300a4259dc7b1cd76 /src/libs/utils/filenamevalidatinglineedit.cpp | |
parent | e8862cd21f94259f22b87b5d5eb8a0a60cd511f8 (diff) | |
download | qt-creator-3fc72220626da58b1174da4b6a61e45da9871158.tar.gz |
Get rid of FancyLineEdit::validate
Use aggregation instead of inheritance for customization of validation.
Gets rid of a few additional classes.
Change-Id: Iaf8f12026c40a55bfde98b3786100f8ac431d750
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/libs/utils/filenamevalidatinglineedit.cpp')
-rw-r--r-- | src/libs/utils/filenamevalidatinglineedit.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libs/utils/filenamevalidatinglineedit.cpp b/src/libs/utils/filenamevalidatinglineedit.cpp index 8ddba93c35..f409102b62 100644 --- a/src/libs/utils/filenamevalidatinglineedit.cpp +++ b/src/libs/utils/filenamevalidatinglineedit.cpp @@ -71,6 +71,10 @@ FileNameValidatingLineEdit::FileNameValidatingLineEdit(QWidget *parent) : m_allowDirectories(false), m_forceFirstCapitalLetter(false) { + setValidationFunction([this](FancyLineEdit *edit, QString *errorMessage) { + return validateFileNameExtension(edit->text(), requiredExtensions(), errorMessage) + && validateFileName(edit->text(), allowDirectories(), errorMessage); + }); } bool FileNameValidatingLineEdit::allowDirectories() const @@ -148,12 +152,6 @@ bool FileNameValidatingLineEdit::validateFileName(const QString &name, return true; } -bool FileNameValidatingLineEdit::validate(const QString &value, QString *errorMessage) const -{ - return validateFileNameExtension(value, requiredExtensions(), errorMessage) - && validateFileName(value, allowDirectories(), errorMessage); -} - QString FileNameValidatingLineEdit::fixInputString(const QString &string) { if (!forceFirstCapitalLetter()) |