gitplugin.h 4.83 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
33
34
35
36
37
38
39
40
#ifndef GITPLUGIN_H
#define GITPLUGIN_H

#include "settingspage.h"

#include <coreplugin/editormanager/ieditorfactory.h>
#include <coreplugin/icorelistener.h>
#include <extensionsystem/iplugin.h>

#include <QtCore/QObject>
#include <QtCore/QProcess>
41
#include <QtCore/QStringList>
con's avatar
con committed
42
43
44
45

QT_BEGIN_NAMESPACE
class QFile;
class QAction;
46
class QFileInfo;
con's avatar
con committed
47
48
49
QT_END_NAMESPACE

namespace Core {
50
51
52
class IEditorFactory;
class ICore;
class IVersionControl;
53
54
55
namespace Utils {
class ParameterAction;
}
56
} // namespace Core
con's avatar
con committed
57
58
59
60

namespace Git {
namespace Internal {

61
62
63
64
65
66
class GitPlugin;
class GitClient;
class ChangeSelectionDialog;
class GitSubmitEditor;
struct CommitData;
struct GitSettings;
con's avatar
con committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

// Just a proxy for GitPlugin
class CoreListener : public Core::ICoreListener
{
    Q_OBJECT
public:
    CoreListener(GitPlugin *plugin) : m_plugin(plugin) { }
    bool editorAboutToClose(Core::IEditor *editor);
    bool coreAboutToClose() { return true; }
private:
    GitPlugin *m_plugin;
};

class GitPlugin : public ExtensionSystem::IPlugin
{
    Q_OBJECT

public:
85
86
87
    GitPlugin();
    ~GitPlugin();

con's avatar
con committed
88
89
    static GitPlugin *instance();

90
91
    virtual bool initialize(const QStringList &arguments, QString *error_message);
    virtual void extensionsInitialized();
con's avatar
con committed
92

93
    QString getWorkingDirectory();
con's avatar
con committed
94

95
    GitSettings settings() const;
96
97
    void setSettings(const GitSettings &s);

98
99
    GitClient *gitClient() const;

con's avatar
con committed
100
public slots:
101
102
    void updateActions();
    bool editorAboutToClose(Core::IEditor *editor);
con's avatar
con committed
103
104

private slots:
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    void diffCurrentFile();
    void diffCurrentProject();
    void submitEditorDiff(const QStringList &unstaged, const QStringList &staged);
    void submitCurrentLog();
    void statusFile();
    void statusProject();
    void logFile();
    void blameFile();
    void logProject();
    void undoFileChanges();
    void undoProjectChanges();
    void stageFile();
    void unstageFile();

    void showCommit();
    void startCommit();
    void stash();
    void stashPop();
    void branchList();
    void stashList();
    void pull();
    void push();
con's avatar
con committed
127
128

private:
129
    bool isCommitEditorOpen() const;
130
131
    QFileInfo currentFile() const;
    Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd);
132
    void cleanCommitMessageFile();
133
134
135

    static GitPlugin *m_instance;
    Core::ICore *m_core;
136
137
138
139
140
141
142
143
    Core::Utils::ParameterAction *m_diffAction;
    Core::Utils::ParameterAction *m_diffProjectAction;
    Core::Utils::ParameterAction *m_statusAction;
    Core::Utils::ParameterAction *m_statusProjectAction;
    Core::Utils::ParameterAction *m_logAction;
    Core::Utils::ParameterAction *m_blameAction;
    Core::Utils::ParameterAction *m_logProjectAction;
    Core::Utils::ParameterAction *m_undoFileAction;
144
145
    QAction *m_undoProjectAction;
    QAction *m_showAction;
146
147
148
    Core::Utils::ParameterAction *m_stageAction;
    Core::Utils::ParameterAction *m_unstageAction;
    Core::Utils::ParameterAction *m_revertAction;
149
150
151
152
153
154
155
156
157
158
159
160
    QAction *m_commitAction;
    QAction *m_pullAction;
    QAction *m_pushAction;

    QAction *m_submitCurrentAction;
    QAction *m_diffSelectedFilesAction;
    QAction *m_undoAction;
    QAction *m_redoAction;
    QAction *m_stashAction;
    QAction *m_stashPopAction;
    QAction *m_stashListAction;
    QAction *m_branchListAction;
con's avatar
con committed
161
162
163
164

    GitClient                   *m_gitClient;
    ChangeSelectionDialog       *m_changeSelectionDialog;
    QString                     m_submitRepository;
165
    QStringList                 m_submitOrigCommitFiles;
166
    QStringList                 m_submitOrigDeleteFiles;
167
    QString                     m_commitMessageFileName;
168
    bool                        m_submitActionTriggered;
con's avatar
con committed
169
170
171
172
173
};

} // namespace Git
} // namespace Internal

hjk's avatar
hjk committed
174
#endif // GITPLUGIN_H