diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-03-05 18:00:34 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-03-05 18:17:49 (GMT) |
commit | 651f10eee7bce78b95b61061b9aef6bb4ab81841 (patch) | |
tree | dbc10b7f2bbe90a07e6eb1bf15d17a5edc6843e9 /Swift/QtUI/QtJoinMUCWindow.h | |
parent | e1602cbe8c5fb1525bc66ecf5d7a939816f259c5 (diff) | |
download | swift-contrib-651f10eee7bce78b95b61061b9aef6bb4ab81841.zip swift-contrib-651f10eee7bce78b95b61061b9aef6bb4ab81841.tar.bz2 |
Check validity of MUC names in join dialog
Resolves: #868
Diffstat (limited to 'Swift/QtUI/QtJoinMUCWindow.h')
-rw-r--r-- | Swift/QtUI/QtJoinMUCWindow.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Swift/QtUI/QtJoinMUCWindow.h b/Swift/QtUI/QtJoinMUCWindow.h index 90b4f3f..c7e2d74 100644 --- a/Swift/QtUI/QtJoinMUCWindow.h +++ b/Swift/QtUI/QtJoinMUCWindow.h @@ -6,12 +6,29 @@ #pragma once +#include <QValidator> #include <string> +#include "QtSwiftUtil.h" #include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h> #include <Swift/QtUI/ui_QtJoinMUCWindow.h> namespace Swift { class UIEventStream; + class NickValidator : public QValidator { + Q_OBJECT + public: + NickValidator(QObject* parent) : QValidator(parent) { + } + + virtual QValidator::State validate(QString& input, int& /*pos*/) const { + if (input.isEmpty()) { + return QValidator::Acceptable; + } + JID test("alice", "wonderland.lit", Q2PSTRING(input)); + + return test.isValid() ? QValidator::Acceptable : QValidator::Invalid; + } + }; class QtJoinMUCWindow : public QWidget, public JoinMUCWindow { Q_OBJECT public: |