diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2011-09-20 12:54:18 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@nokia.com> | 2011-09-20 13:29:31 +0200 |
commit | dfbdf287034fca3cc9c59c546d06fda2af3e67ba (patch) | |
tree | 1119541029f435331ab3328f052e6f2f4bf6901e /src/libs/utils/filenamevalidatinglineedit.h | |
parent | 71cbd765b2f887a68495b947e202ee4ca4295fd8 (diff) | |
download | qt-creator-dfbdf287034fca3cc9c59c546d06fda2af3e67ba.tar.gz |
Add extension property to FileNameValidatingLineEdit
Does nothing if extension is empty. The extension check is case
sensitive.
Change-Id: I58f89eb57d53146dae95e58d77cd8b47826b8f42
Reviewed-on: http://codereview.qt-project.org/5163
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
Diffstat (limited to 'src/libs/utils/filenamevalidatinglineedit.h')
-rw-r--r-- | src/libs/utils/filenamevalidatinglineedit.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libs/utils/filenamevalidatinglineedit.h b/src/libs/utils/filenamevalidatinglineedit.h index 75f04ff708..4e84af07df 100644 --- a/src/libs/utils/filenamevalidatinglineedit.h +++ b/src/libs/utils/filenamevalidatinglineedit.h @@ -41,6 +41,7 @@ class QTCREATOR_UTILS_EXPORT FileNameValidatingLineEdit : public BaseValidatingL { Q_OBJECT Q_PROPERTY(bool allowDirectories READ allowDirectories WRITE setAllowDirectories) + Q_PROPERTY(QStringList requiredExtensions READ requiredExtensions WRITE setRequiredExtensions) public: explicit FileNameValidatingLineEdit(QWidget *parent = 0); @@ -49,6 +50,10 @@ public: bool allowDirectories = false, QString *errorMessage = 0); + static bool validateFileNameExtension(const QString &name, + const QStringList &requiredExtensions = QStringList(), + QString *errorMessage = 0); + /** * Sets whether entering directories is allowed. This will enable the user * to enter slashes in the filename. Default is off. @@ -56,12 +61,19 @@ public: bool allowDirectories() const; void setAllowDirectories(bool v); + /** + * Sets a requred extension. If the extension is empty no extension is required. + * Default is empty. + */ + QStringList requiredExtensions() const; + void setRequiredExtensions(const QStringList &extensionList); + protected: virtual bool validate(const QString &value, QString *errorMessage) const; private: bool m_allowDirectories; - void *m_unused; + QStringList m_requiredExtensionList; }; } // namespace Utils |