gitsubmiteditor.h 2.74 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
** 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
12
13
14
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16
17
18
19
20
21
22
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
con's avatar
con committed
23
**
hjk's avatar
hjk committed
24
****************************************************************************/
hjk's avatar
hjk committed
25

Tobias Hunger's avatar
Tobias Hunger committed
26
#pragma once
con's avatar
con committed
27

28
#include "commitdata.h"
29

con's avatar
con committed
30
31
#include <vcsbase/vcsbasesubmiteditor.h>

32
#include <QFutureWatcher>
33
#include <QStringList>
34

35
namespace VcsBase { class SubmitFileModel; }
36

con's avatar
con committed
37
38
39
namespace Git {
namespace Internal {

40
class GitClient;
con's avatar
con committed
41
class GitSubmitEditorWidget;
Tobias Hunger's avatar
Tobias Hunger committed
42
class GitSubmitEditorPanelData;
con's avatar
con committed
43

44
45
46
47
48
49
50
51
52
53
class CommitDataFetchResult
{
public:
    static CommitDataFetchResult fetch(CommitType commitType, const QString &workingDirectory);

    QString errorMessage;
    CommitData commitData;
    bool success;
};

hjk's avatar
hjk committed
54
class GitSubmitEditor : public VcsBase::VcsBaseSubmitEditor
con's avatar
con committed
55
56
{
    Q_OBJECT
Tobias Hunger's avatar
Tobias Hunger committed
57

con's avatar
con committed
58
public:
59
    explicit GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
60
    ~GitSubmitEditor() override;
con's avatar
con committed
61
62
63

    void setCommitData(const CommitData &);
    GitSubmitEditorPanelData panelData() const;
64
65
    CommitType commitType() const { return m_commitType; }
    QString amendSHA1() const;
con's avatar
con committed
66

67
protected:
Orgad Shaneh's avatar
Orgad Shaneh committed
68
69
    QByteArray fileContents() const override;
    void updateFileModel() override;
70
    void forceUpdateFileModel();
71

Tobias Hunger's avatar
Tobias Hunger committed
72
private:
73
    void slotDiffSelected(const QList<int> &rows);
74
    void showCommit(const QString &commit);
75
    void commitDataRetrieved();
76

con's avatar
con committed
77
    inline GitSubmitEditorWidget *submitEditorWidget();
Orgad Shaneh's avatar
Orgad Shaneh committed
78
    inline const GitSubmitEditorWidget *submitEditorWidget() const;
79

Tobias Hunger's avatar
Tobias Hunger committed
80
81
82
    VcsBase::SubmitFileModel *m_model = nullptr;
    QTextCodec *m_commitEncoding = nullptr;
    CommitType m_commitType = SimpleCommit;
83
    QString m_amendSHA1;
84
    QString m_workingDirectory;
Tobias Hunger's avatar
Tobias Hunger committed
85
    bool m_firstUpdate = true;
86
    QFutureWatcher<CommitDataFetchResult> m_fetchWatcher;
con's avatar
con committed
87
88
89
90
};

} // namespace Internal
} // namespace Git