OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / iversioncontrol.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef IVERSIONCONTROL_H
34 #define IVERSIONCONTROL_H
35
36 #include "core_global.h"
37
38 #include <QtCore/QObject>
39 #include <QtCore/QString>
40 #include <QtCore/QFlags>
41
42 namespace Core {
43
44 class CORE_EXPORT IVersionControl : public QObject
45 {
46     Q_OBJECT
47     Q_ENUMS(SettingsFlag Operation)
48 public:
49     enum SettingsFlag {
50         AutoOpen = 0x1
51     };
52     Q_DECLARE_FLAGS(SettingsFlags, SettingsFlag)
53
54     enum Operation {
55         AddOperation, DeleteOperation, OpenOperation, MoveOperation,
56         CreateRepositoryOperation,
57         SnapshotOperations,
58         AnnotateOperation,
59         CheckoutOperation,
60         GetRepositoryRootOperation
61         };
62
63     explicit IVersionControl(QObject *parent = 0) : QObject(parent) {}
64     virtual ~IVersionControl() {}
65
66     virtual QString displayName() const = 0;
67
68     /*!
69      * Returns whether files in this directory should be managed with this
70      * version control.
71      * If \a topLevel is non-null, it should return the topmost directory,
72      * for which this IVersionControl should be used. The VcsManager assumes
73      * that all files in the returned directory are managed by the same IVersionControl.
74      */
75
76     virtual bool managesDirectory(const QString &filename, QString *topLevel = 0) const = 0;
77
78     /*!
79      * Called to query whether a VCS supports the respective operations.
80      */
81     virtual bool supportsOperation(Operation operation) const = 0;
82
83     /*!
84      * Called prior to save, if the file is read only. Should be implemented if
85      * the scc requires a operation before editing the file, e.g. 'p4 edit'
86      *
87      * \note The EditorManager calls this for the editors.
88      */
89     virtual bool vcsOpen(const QString &fileName) = 0;
90
91     /*!
92      * Returns settings.
93      */
94
95     virtual SettingsFlags settingsFlags() const { return 0; }
96
97     /*!
98      * Called after a file has been added to a project If the version control
99      * needs to know which files it needs to track you should reimplement this
100      * function, e.g. 'p4 add', 'cvs add', 'svn add'.
101      *
102      * \note This function should be called from IProject subclasses after
103      *       files are added to the project.
104      */
105     virtual bool vcsAdd(const QString &filename) = 0;
106
107     /*!
108      * Called after a file has been removed from the project (if the user
109      * wants), e.g. 'p4 delete', 'svn delete'.
110      */
111     virtual bool vcsDelete(const QString &filename) = 0;
112
113     /*!
114      * Called to rename a file, should do the actual on disk renaming
115      * (e.g. git mv, svn move, p4 move)
116      */
117     virtual bool vcsMove(const QString &from, const QString &to) = 0;
118
119     /*!
120      * Called to initialize the version control system in a directory.
121      */
122     virtual bool vcsCreateRepository(const QString &directory) = 0;
123
124     /*!
125      * Called to clone/checkout the version control system in a directory.
126      */
127     virtual bool vcsCheckout(const QString &directory, const QByteArray &url) = 0;
128
129     /*!
130      * Called to get the version control repository root.
131      */
132     virtual QString vcsGetRepositoryURL(const QString &director) = 0;
133
134     /*!
135      * Create a snapshot of the current state and return an identifier or
136      * an empty string in case of failure.
137      */
138     virtual QString vcsCreateSnapshot(const QString &topLevel) = 0;
139
140     /*!
141      * List snapshots.
142      */
143     virtual QStringList vcsSnapshots(const QString &topLevel) = 0;
144
145     /*!
146      * Restore a snapshot.
147      */
148     virtual bool vcsRestoreSnapshot(const QString &topLevel, const QString &name) = 0;
149
150     /*!
151      * Remove a snapshot.
152      */
153     virtual bool vcsRemoveSnapshot(const QString &topLevel, const QString &name) = 0;
154
155     /*!
156      * Display annotation for a file and scroll to line
157      */
158     virtual bool vcsAnnotate(const QString &file, int line) = 0;
159
160 signals:
161     void repositoryChanged(const QString &repository);
162     void filesChanged(const QStringList &files);
163
164     // TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g
165     // virtual bool sccManaged(const QString &filename) = 0;
166 };
167
168 Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IVersionControl::SettingsFlags)
169
170 } // namespace Core
171
172 #endif // IVERSIONCONTROL_H