1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef IVERSIONCONTROL_H
34 #define IVERSIONCONTROL_H
36 #include "core_global.h"
38 #include <QtCore/QObject>
39 #include <QtCore/QString>
40 #include <QtCore/QFlags>
44 class CORE_EXPORT IVersionControl : public QObject
47 Q_ENUMS(SettingsFlag Operation)
52 Q_DECLARE_FLAGS(SettingsFlags, SettingsFlag)
55 AddOperation, DeleteOperation, OpenOperation, MoveOperation,
56 CreateRepositoryOperation,
60 GetRepositoryRootOperation
63 explicit IVersionControl(QObject *parent = 0) : QObject(parent) {}
64 virtual ~IVersionControl() {}
66 virtual QString displayName() const = 0;
69 * Returns whether files in this directory should be managed with this
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.
76 virtual bool managesDirectory(const QString &filename, QString *topLevel = 0) const = 0;
79 * Called to query whether a VCS supports the respective operations.
81 virtual bool supportsOperation(Operation operation) const = 0;
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'
87 * \note The EditorManager calls this for the editors.
89 virtual bool vcsOpen(const QString &fileName) = 0;
95 virtual SettingsFlags settingsFlags() const { return 0; }
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'.
102 * \note This function should be called from IProject subclasses after
103 * files are added to the project.
105 virtual bool vcsAdd(const QString &filename) = 0;
108 * Called after a file has been removed from the project (if the user
109 * wants), e.g. 'p4 delete', 'svn delete'.
111 virtual bool vcsDelete(const QString &filename) = 0;
114 * Called to rename a file, should do the actual on disk renaming
115 * (e.g. git mv, svn move, p4 move)
117 virtual bool vcsMove(const QString &from, const QString &to) = 0;
120 * Called to initialize the version control system in a directory.
122 virtual bool vcsCreateRepository(const QString &directory) = 0;
125 * Called to clone/checkout the version control system in a directory.
127 virtual bool vcsCheckout(const QString &directory, const QByteArray &url) = 0;
130 * Called to get the version control repository root.
132 virtual QString vcsGetRepositoryURL(const QString &director) = 0;
135 * Create a snapshot of the current state and return an identifier or
136 * an empty string in case of failure.
138 virtual QString vcsCreateSnapshot(const QString &topLevel) = 0;
143 virtual QStringList vcsSnapshots(const QString &topLevel) = 0;
146 * Restore a snapshot.
148 virtual bool vcsRestoreSnapshot(const QString &topLevel, const QString &name) = 0;
153 virtual bool vcsRemoveSnapshot(const QString &topLevel, const QString &name) = 0;
156 * Display annotation for a file and scroll to line
158 virtual bool vcsAnnotate(const QString &file, int line) = 0;
161 void repositoryChanged(const QString &repository);
162 void filesChanged(const QStringList &files);
164 // TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g
165 // virtual bool sccManaged(const QString &filename) = 0;
168 Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IVersionControl::SettingsFlags)
172 #endif // IVERSIONCONTROL_H