diff --git a/src/RemotePushDialog.cpp b/src/RemotePushDialog.cpp index 2eaa4420..4513ed4f 100644 --- a/src/RemotePushDialog.cpp +++ b/src/RemotePushDialog.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "RemotePushDialog.h" #include "ui_RemotePushDialog.h" @@ -10,10 +11,14 @@ RemotePushDialog::RemotePushDialog(QWidget* parent, RemoteDatabase& remote, cons ui(new Ui::RemotePushDialog), m_host(host), m_clientCert(clientCert), - remoteDatabase(remote) + remoteDatabase(remote), + m_nameValidator(new QRegExpValidator(QRegExp("^[a-z,A-Z,0-9,\\.,\\-,\\_,\\(,\\),\\+,\\ ]+$"), this)), + m_branchValidator(new QRegExpValidator(QRegExp("^[a-z,A-Z,0-9,\\^,\\.,\\-,\\_,\\/,\\(,\\),\\:,\\&,\\ )]+$"), this)) { // Create UI ui->setupUi(this); + ui->editName->setValidator(m_nameValidator); + ui->comboBranch->setValidator(m_branchValidator); // Set start values ui->editName->setText(name); @@ -54,16 +59,12 @@ void RemotePushDialog::checkInput() if(ui->editName->text().trimmed().isEmpty()) valid = false; - if(!QRegExp("^[a-z,A-Z,0-9,\\.,\\-,\\_,\\(,\\),\\+,\\ ]+$").exactMatch(ui->editName->text())) - valid = false; if(ui->editCommitMessage->toPlainText().size() > 1024) valid = false; if(ui->comboBranch->currentText().size() < 1 || ui->comboBranch->currentText().size() > 32) valid = false; - if(!QRegExp("^[a-z,A-Z,0-9,\\^,\\.,\\-,\\_,\\/,\\(,\\),\\:,\\&,\\ )]+$").exactMatch(ui->comboBranch->currentText())) - valid = false; ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); } diff --git a/src/RemotePushDialog.h b/src/RemotePushDialog.h index 0873fea2..dce4b8f9 100644 --- a/src/RemotePushDialog.h +++ b/src/RemotePushDialog.h @@ -4,6 +4,7 @@ #include class RemoteDatabase; +class QRegExpValidator; namespace Ui { class RemotePushDialog; @@ -34,6 +35,10 @@ private: // Reference to the remote database object which is stored somewhere in the main window RemoteDatabase& remoteDatabase; + // Validators + QRegExpValidator* m_nameValidator; + QRegExpValidator* m_branchValidator; + protected slots: void checkInput(); virtual void accept();