OSDN Git Service

4db95962697da0c79fafab02a861dfc4d487f6eb
[qt-creator-jp/qt-creator-jp.git] / src / plugins / subversion / subversioncontrol.cpp
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 #include "subversioncontrol.h"
35 #include "subversionplugin.h"
36
37 #include <QtCore/QFileInfo>
38
39 using namespace Subversion;
40 using namespace Subversion::Internal;
41
42 SubversionControl::SubversionControl(SubversionPlugin *plugin) :
43     m_enabled(true),
44     m_plugin(plugin)
45 {
46 }
47
48 QString SubversionControl::displayName() const
49 {
50     return QLatin1String("subversion");
51 }
52
53 bool SubversionControl::supportsOperation(Operation operation) const
54 {
55     bool rc = true;
56     switch (operation) {
57     case AddOperation:
58     case DeleteOperation:
59     case MoveOperation:
60     case AnnotateOperation:
61     case CheckoutOperation:
62     case GetRepositoryRootOperation:
63         break;
64     case OpenOperation:
65     case CreateRepositoryOperation:
66     case SnapshotOperations:
67         rc = false;
68         break;
69     }
70     return rc;
71 }
72
73 bool SubversionControl::vcsOpen(const QString & /* fileName */)
74 {
75     // Open for edit: N/A
76     return true;
77 }
78
79 bool SubversionControl::vcsAdd(const QString &fileName)
80 {
81     const QFileInfo fi(fileName);
82     return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
83 }
84
85 bool SubversionControl::vcsDelete(const QString &fileName)
86 {
87     const QFileInfo fi(fileName);
88     return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
89 }
90
91 bool SubversionControl::vcsMove(const QString &from, const QString &to)
92 {
93     const QFileInfo fromInfo(from);
94     const QFileInfo toInfo(to);
95     return m_plugin->vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
96 }
97
98 bool SubversionControl::vcsCheckout(const QString &directory, const QByteArray &url)
99 {
100     return m_plugin->vcsCheckout(directory, url);
101 }
102
103 QString SubversionControl::vcsGetRepositoryURL(const QString &directory)
104 {
105     return m_plugin->vcsGetRepositoryURL(directory);
106 }
107
108 bool SubversionControl::vcsCreateRepository(const QString &)
109 {
110     return false;
111 }
112
113 QString SubversionControl::vcsCreateSnapshot(const QString &)
114 {
115     return QString();
116 }
117
118 QStringList SubversionControl::vcsSnapshots(const QString &)
119 {
120     return QStringList();
121 }
122
123 bool SubversionControl::vcsRestoreSnapshot(const QString &, const QString &)
124 {
125     return false;
126 }
127
128 bool SubversionControl::vcsRemoveSnapshot(const QString &, const QString &)
129 {
130     return false;
131 }
132
133 bool SubversionControl::managesDirectory(const QString &directory, QString *topLevel) const
134 {
135     return m_plugin->managesDirectory(directory, topLevel);
136 }
137
138 bool SubversionControl::vcsAnnotate(const QString &file, int line)
139 {
140     const QFileInfo fi(file);
141     m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
142     return true;
143 }
144
145 void SubversionControl::emitRepositoryChanged(const QString &s)
146 {
147     emit repositoryChanged(s);
148 }
149
150 void SubversionControl::emitFilesChanged(const QStringList &l)
151 {
152     emit filesChanged(l);
153 }