gitplugin.h 7.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/***************************************************************************
 *   This file was partly taken from KDevelop's cvs plugin                 *
 *   Copyright 2007 Robert Gruber <rgruber@users.sourceforge.net>          *
 *                                                                         *
 *   Adapted for Git                                                       *
 *   Copyright 2008 Evgeniy Ivanov <powerfox@kde.ru>                       *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU General Public License as        *
 *   published by the Free Software Foundation; either version 2 of        *
 *   the License or (at your option) version 3 or any later version        *
 *   accepted by the membership of KDE e.V. (or its successor approved     *
 *   by the membership of KDE e.V.), which shall act as a proxy            *
 *   defined in Section 14 of version 3 of the license.                    *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/

#ifndef GIT_PLUGIN_H
#define GIT_PLUGIN_H

#include <KUrl>
#include <KJob>

#include <vcs/interfaces/idistributedversioncontrol.h>
#include <vcs/vcslocation.h>
#include <interfaces/iplugin.h>
#include <qobject.h>

class GitProxy;

namespace KDevelop
{
    class ContextMenuExtension;
}

/**
 * This is the main class of KDevelop's Git plugin.
 *
 * It implements the IBasicVersionControl and IDistributedVersionControl interfaces.
 * @author Robert Gruber <rgruber@users.sourceforge.net>
 * @author Evgeniy Ivanov <powerfox@kde.ru>
 */
class GitPlugin: public KDevelop::IPlugin, public KDevelop::IDistributedVersionControl
{
    Q_OBJECT
    Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::IDistributedVersionControl)

friend class GitProxy;

public:
    GitPlugin( QObject *parent, const QVariantList & args = QVariantList() );
    ~GitPlugin();

    // From KDevelop::IPlugin
    KDevelop::ContextMenuExtension contextMenuExtension( KDevelop::Context* );

    // Begin: KDevelop::IBasicVersionControl
    QString name() const;
    KDevelop::VcsImportMetadataWidget* createImportMetadataWidget( QWidget* parent );
    bool isVersionControlled( const KUrl& localLocation );
    KDevelop::VcsJob* repositoryLocation( const KUrl& localLocation );
    KDevelop::VcsJob* add( const KUrl::List& localLocations,
                           KDevelop::IBasicVersionControl::RecursionMode recursion );
    KDevelop::VcsJob* remove( const KUrl::List& localLocations );
    KDevelop::VcsJob* status( const KUrl::List& localLocations,
                                      KDevelop::IBasicVersionControl::RecursionMode recursion );
    KDevelop::VcsJob* copy( const KUrl& localLocationSrc,
                                    const KUrl& localLocationDstn ); ///Not used in DVCS;
    KDevelop::VcsJob* move( const KUrl& localLocationSrc,
                                    const KUrl& localLocationDst ); ///Not used in DVCS;
    KDevelop::VcsJob* revert( const KUrl::List& localLocations,
                                      KDevelop::IBasicVersionControl::RecursionMode recursion );
    KDevelop::VcsJob* update( const KUrl::List& localLocations,
                                      const KDevelop::VcsRevision& rev,
                                      KDevelop::IBasicVersionControl::RecursionMode recursion );
    KDevelop::VcsJob* commit( const QString& message,
                                      const KUrl::List& localLocations,
                                      KDevelop::IBasicVersionControl::RecursionMode recursion );
    KDevelop::VcsJob* diff( const KDevelop::VcsLocation& localOrRepoLocationSrc,
                                    const KDevelop::VcsLocation& localOrRepoLocationDst,
                                    const KDevelop::VcsRevision& srcRevision,
                                    const KDevelop::VcsRevision& dstRevision,
                                    KDevelop::VcsDiff::Type,
                                    KDevelop::IBasicVersionControl::RecursionMode = KDevelop::IBasicVersionControl::Recursive );
    KDevelop::VcsJob* log( const KUrl& localLocation,
                                   const KDevelop::VcsRevision& rev,
                                   unsigned long limit );
    KDevelop::VcsJob* log( const KUrl& localLocation,
                                   const KDevelop::VcsRevision& rev,
                                   const KDevelop::VcsRevision& limit );
    KDevelop::VcsJob* annotate( const KUrl& localLocation,
                                        const KDevelop::VcsRevision& rev );
    KDevelop::VcsJob* merge( const KDevelop::VcsLocation& localOrRepoLocationSrc,
                                     const KDevelop::VcsLocation& localOrRepoLocationDst,
                                     const KDevelop::VcsRevision& srcRevision,
                                     const KDevelop::VcsRevision& dstRevision,
                                     const KUrl& localLocation );
    KDevelop::VcsJob* resolve( const KUrl::List& localLocations,
                                       KDevelop::IBasicVersionControl::RecursionMode recursion );
    // End:  KDevelop::IBasicVersionControl


    // Begin:  KDevelop::IDistributedVersionControl
    KDevelop::VcsJob* init( const KUrl& localRepositoryRoot );
    KDevelop::VcsJob* clone( const QString& repositoryLocationSrc,
                   const KUrl& localRepositoryRoot );
    KDevelop::VcsJob* push( const KUrl& localRepositoryLocation,
                  const QString& repositoryLocation );
    KDevelop::VcsJob* pull( const QString& repositoryLocation,
                  const KUrl& localRepositoryLocation );
    // End:  KDevelop::IDistributedVersionControl

    GitProxy* proxy();

    const KUrl urlFocusedDocument() const;

public slots:
    // slots for context menu
    void ctxCommit();
    void ctxAdd();
    void ctxRemove();
//     void ctxUpdate();
//     void ctxLog();
//     void ctxAnnotate();
//     void ctxRevert();
//     void ctxDiff();
//     void ctxEditors();

    // slots for menu
    void slotInit();
//     void slotCheckout();
//     void slotStatus();

signals:
    /**
     * Some actions like commit, add, remove... will connect the job's
     * result() signal to this signal. Anybody, like for instance the
     * GitMainView class, that is interested in getting notified about
     * jobs that finished can connect to this signal.
     * @see class GitMainView
     */
    void jobFinished(KJob* job);

    /**
     * Gets emmited when a job like log, editors... was created.
     * GitPlugin will connect the newly created view to the result() signal
     * of a job. So the new view will show the output of that job as
     * soon as it has finished.
     */
    void addNewTabToMainView(QWidget* tab, QString label);

private:
    class GitPluginPrivate* d;

    void setupActions();
};

#endif