~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/git/branchadddialog.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-11-15 12:25:23 UTC
  • mfrom: (1.1.28)
  • Revision ID: timo.jyrinki@canonical.com-20131115122523-i2kyamsu4gs2mu1m
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "branchadddialog.h"
31
31
#include "ui_branchadddialog.h"
32
32
 
 
33
#include <utils/hostosinfo.h>
 
34
 
33
35
#include <QPushButton>
34
36
#include <QValidator>
35
37
 
46
48
class BranchNameValidator : public QValidator
47
49
{
48
50
public:
49
 
    BranchNameValidator(QObject *parent = 0) :
 
51
    BranchNameValidator(const QStringList &localBranches, QObject *parent = 0) :
50
52
        QValidator(parent),
51
53
        m_invalidChars(QLatin1String(
52
54
                                   "\\s"          // no whitespace
59
61
                                   "|@\\{"      // no "@{" sequence
60
62
                                   "|\\\\"      // no backslash
61
63
                                   "|//"    // no double slash
62
 
                                   "|^/"  // no leading slash
63
 
                                   ))
 
64
                                   "|^[/-]"  // no leading slash or dash
 
65
                                   )),
 
66
        m_localBranches(localBranches)
64
67
    {
65
68
    }
66
69
 
87
90
        if (input.endsWith(QLatin1Char('/'))) // no slash at the end (but allowed in the middle)
88
91
            return Intermediate;
89
92
 
 
93
        if (m_localBranches.contains(input, Utils::HostOsInfo::isWindowsHost()
 
94
                                     ? Qt::CaseInsensitive : Qt::CaseSensitive)) {
 
95
            return Intermediate;
 
96
        }
 
97
 
90
98
        // is a valid branch name
91
99
        return Acceptable;
92
100
    }
93
101
 
94
102
private:
95
103
    const QRegExp m_invalidChars;
 
104
    QStringList m_localBranches;
96
105
};
97
106
 
98
107
 
99
 
BranchAddDialog::BranchAddDialog(bool addBranch, QWidget *parent) :
 
108
BranchAddDialog::BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent) :
100
109
    QDialog(parent),
101
110
    m_ui(new Ui::BranchAddDialog)
102
111
{
103
112
    m_ui->setupUi(this);
104
113
    setWindowTitle(addBranch ? tr("Add Branch") : tr("Rename Branch"));
105
 
    m_ui->branchNameEdit->setValidator(new BranchNameValidator(this));
 
114
    m_ui->branchNameEdit->setValidator(new BranchNameValidator(localBranches, this));
106
115
    connect(m_ui->branchNameEdit, SIGNAL(textChanged(QString)), this, SLOT(updateButtonStatus()));
107
116
}
108
117