commiteditor.cpp 3.45 KB
Newer Older
dt's avatar
dt committed
1
2
/**************************************************************************
**
3
** Copyright (c) 2014 Brian McGillion
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
dt's avatar
dt committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
dt's avatar
dt committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
Eike Ziller's avatar
Eike Ziller committed
13
14
** conditions see http://www.qt.io/licensing.  For further information
** use the contact form at http://www.qt.io/contact-us.
dt's avatar
dt committed
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18
19
20
21
22
23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
hjk's avatar
hjk committed
24
25
26
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
27
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
dt's avatar
dt committed
30

31
32
33
#include "commiteditor.h"
#include "mercurialcommitwidget.h"

34
#include <coreplugin/idocument.h>
35
36
#include <vcsbase/submitfilemodel.h>

37
#include <QDebug>
38

hjk's avatar
hjk committed
39
using namespace VcsBase;
40

41
42
43
namespace Mercurial {
namespace Internal  {

44
45
CommitEditor::CommitEditor(const VcsBaseSubmitEditorParameters *parameters)
        : VcsBaseSubmitEditor(parameters, new MercurialCommitWidget),
46
47
        fileModel(0)
{
48
    document()->setDisplayName(tr("Commit Editor"));
49
50
51
52
53
54
55
56
57
}

MercurialCommitWidget *CommitEditor::commitWidget()
{
    return static_cast<MercurialCommitWidget *>(widget());
}

void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &branch,
                             const QString &userName, const QString &email,
hjk's avatar
hjk committed
58
                             const QList<VcsBaseClient::StatusItem> &repoStatus)
59
60
61
62
63
64
65
{
    MercurialCommitWidget *mercurialWidget = commitWidget();
    if (!mercurialWidget)
        return;

    mercurialWidget->setFields(repositoryRoot.absoluteFilePath(), branch, userName, email);

hjk's avatar
hjk committed
66
    fileModel = new SubmitFileModel(this);
67
68
69

    QStringList shouldTrack;

hjk's avatar
hjk committed
70
    foreach (const VcsBaseClient::StatusItem &item, repoStatus) {
71
72
        if (item.flags == QLatin1String("Untracked"))
            shouldTrack.append(item.file);
73
        else
74
            fileModel->addFile(item.file, item.flags, VcsBase::Unchecked);
75
76
    }

hjk's avatar
hjk committed
77
    VcsBaseSubmitEditor::filterUntrackedFilesOfProject(repositoryRoot.absoluteFilePath(),
78
79
                                                                &shouldTrack);

80
    foreach (const QString &track, shouldTrack) {
hjk's avatar
hjk committed
81
        foreach (const VcsBaseClient::StatusItem &item, repoStatus) {
82
            if (item.file == track)
83
                fileModel->addFile(item.file, item.flags, VcsBase::Unchecked);
84
85
86
        }
    }

87
    setFileModel(fileModel, repositoryRoot.absoluteFilePath());
88
89
90
91
92
93
94
95
96
97
98
}

QString CommitEditor::committerInfo()
{
    return commitWidget()->committer();
}

QString CommitEditor::repoRoot()
{
    return commitWidget()->repoRoot();
}
99
100
101

} // namespace Internal
} // namespace Mercurial