1 /***************************************************************************
2 * This file is part of KDevelop *
3 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 2 of the *
8 * License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU Library General Public *
16 * License along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "vcslocation.h"
23 #include <QtCore/QVariant>
29 class VcsLocationPrivate
38 VcsLocation::LocationType m_type
;
42 VcsLocation::VcsLocation()
43 : d(new VcsLocationPrivate
)
45 d
->m_type
= VcsLocation::LocalLocation
;
49 VcsLocation::VcsLocation( const KUrl
& u
)
50 : d(new VcsLocationPrivate
)
55 VcsLocation::VcsLocation( const QString
& s
)
56 : d(new VcsLocationPrivate
)
58 setRepositoryServer( s
);
61 VcsLocation::~VcsLocation()
66 VcsLocation::VcsLocation( const VcsLocation
& rhs
)
67 : d(new VcsLocationPrivate
)
69 d
->m_type
= rhs
.d
->m_type
;
70 d
->m_localUrl
= rhs
.d
->m_localUrl
;
71 d
->m_repoServer
= rhs
.d
->m_repoServer
;
72 d
->m_repoPath
= rhs
.d
->m_repoPath
;
73 d
->m_repoModule
= rhs
.d
->m_repoModule
;
74 d
->m_repoBranch
= rhs
.d
->m_repoBranch
;
75 d
->m_repoTag
= rhs
.d
->m_repoTag
;
76 d
->m_userData
= rhs
.d
->m_userData
;
79 VcsLocation
& VcsLocation::operator=( const VcsLocation
& rhs
)
83 d
->m_type
= rhs
.d
->m_type
;
84 d
->m_localUrl
= rhs
.d
->m_localUrl
;
85 d
->m_repoServer
= rhs
.d
->m_repoServer
;
86 d
->m_repoPath
= rhs
.d
->m_repoPath
;
87 d
->m_repoModule
= rhs
.d
->m_repoModule
;
88 d
->m_repoBranch
= rhs
.d
->m_repoBranch
;
89 d
->m_repoTag
= rhs
.d
->m_repoTag
;
90 d
->m_userData
= rhs
.d
->m_userData
;
94 KUrl
VcsLocation::localUrl() const
98 QString
VcsLocation::repositoryServer() const
100 return d
->m_repoServer
;
103 VcsLocation::LocationType
VcsLocation::type() const
108 bool VcsLocation::isValid() const
110 return( ( d
->m_localUrl
.isValid()
111 && d
->m_type
== VcsLocation::LocalLocation
)
112 || ( !d
->m_repoServer
.isEmpty()
113 && d
->m_type
== VcsLocation::RepositoryLocation
) );
116 void VcsLocation::setLocalUrl( const KUrl
& url
)
118 d
->m_repoServer
.clear();
119 d
->m_repoModule
.clear();
120 d
->m_repoBranch
.clear();
121 d
->m_repoTag
.clear();
122 d
->m_repoPath
.clear();
123 d
->m_type
= VcsLocation::LocalLocation
;
126 void VcsLocation::setRepositoryServer( const QString
& location
)
128 d
->m_repoServer
= location
;
129 d
->m_type
= VcsLocation::RepositoryLocation
;
130 d
->m_localUrl
= KUrl();
133 bool VcsLocation::operator==( const KDevelop::VcsLocation
& rhs
)
135 return( type() == rhs
.type()
136 && repositoryServer() == rhs
.repositoryServer()
137 && localUrl() == rhs
.localUrl()
138 && repositoryPath() == rhs
.repositoryPath()
139 && repositoryModule() == rhs
.repositoryModule()
140 && repositoryBranch() == rhs
.repositoryBranch()
141 && repositoryTag() == rhs
.repositoryTag()
142 && userData() == rhs
.userData() );
146 QString
VcsLocation::repositoryModule( ) const
148 return d
->m_repoModule
;
151 QString
VcsLocation::repositoryTag( ) const
156 QString
VcsLocation::repositoryBranch( ) const
158 return d
->m_repoBranch
;
161 QString
VcsLocation::repositoryPath( ) const
163 return d
->m_repoPath
;
166 void VcsLocation::setRepositoryModule( const QString
& module
)
168 d
->m_repoModule
= module
;
169 d
->m_type
= VcsLocation::RepositoryLocation
;
170 d
->m_localUrl
.clear();
173 void VcsLocation::setRepositoryBranch( const QString
& branch
)
175 d
->m_repoBranch
= branch
;
176 d
->m_type
= VcsLocation::RepositoryLocation
;
177 d
->m_localUrl
.clear();
180 void VcsLocation::setRepositoryTag( const QString
& tag
)
183 d
->m_type
= VcsLocation::RepositoryLocation
;
184 d
->m_localUrl
.clear();
187 void VcsLocation::setRepositoryPath( const QString
& path
)
189 d
->m_repoPath
= path
;
190 d
->m_type
= VcsLocation::RepositoryLocation
;
191 d
->m_localUrl
.clear();
195 QVariant
VcsLocation::userData( ) const
197 return d
->m_userData
;
200 void VcsLocation::setUserData( const QVariant
& data
)
202 d
->m_type
= VcsLocation::RepositoryLocation
;
203 d
->m_localUrl
.clear();
204 d
->m_userData
= data
;