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 56
namespace Utils {
class ParameterAction;
}
con's avatar
con committed
57 58 59 60

namespace Git {
namespace Internal {

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

// 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:
86 87 88
    GitPlugin();
    ~GitPlugin();

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

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

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

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

99
    GitClient *gitClient() const;
100
    GitVersionControl *versionControl() const;
101

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

private slots:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    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
129 130

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

    static GitPlugin *m_instance;
    Core::ICore *m_core;
138 139 140 141 142 143 144 145
    Utils::ParameterAction *m_diffAction;
    Utils::ParameterAction *m_diffProjectAction;
    Utils::ParameterAction *m_statusAction;
    Utils::ParameterAction *m_statusProjectAction;
    Utils::ParameterAction *m_logAction;
    Utils::ParameterAction *m_blameAction;
    Utils::ParameterAction *m_logProjectAction;
    Utils::ParameterAction *m_undoFileAction;
146 147
    QAction *m_undoProjectAction;
    QAction *m_showAction;
148 149
    Utils::ParameterAction *m_stageAction;
    Utils::ParameterAction *m_unstageAction;
150 151 152 153 154 155 156 157 158 159 160 161
    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
162 163

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

} // namespace Git
} // namespace Internal

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