| 1 | /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or |
| 4 | modify it under the terms of the GNU General Public License as |
| 5 | published by the Free Software Foundation; either version 2 of |
| 6 | the License or (at your option) version 3 |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | #ifndef EMAILVALIDATOR_H |
| 17 | #define EMAILVALIDATOR_H |
| 18 | |
| 19 | #include <QObject> |
| 20 | #include <QChar> |
| 21 | #include <QtQuick> |
| 22 | #include <QQmlEngine> |
| 23 | #include <QJSEngine> |
| 24 | #include <QDebug> |
| 25 | #include <QtGui/QGuiApplication> |
| 26 | |
| 27 | class EmailValidator : public QObject |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | public: |
| 31 | explicit EmailValidator(QObject *parent = 0); |
| 32 | |
| 33 | Q_INVOKABLE bool validate(const QString &emailAddress); |
| 34 | |
| 35 | // For qml singleton |
| 36 | static QObject *factory(QQmlEngine *engine, QJSEngine *scriptEngine); |
| 37 | // For c++ singleton |
| 38 | static QSharedPointer<EmailValidator> instance(); |
| 39 | }; |
| 40 | |
| 41 | #endif // EMAILVALIDATOR_H |