OSDN Git Service

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