vcs
vcslocation.cpp
00001 /*************************************************************************** 00002 * This file is part of KDevelop * 00003 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Library General Public License as * 00007 * published by the Free Software Foundation; either version 2 of the * 00008 * License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Library General Public * 00016 * License along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 00021 #include "vcslocation.h" 00022 00023 #include <QtCore/QVariant> 00024 #include <kurl.h> 00025 00026 namespace KDevelop 00027 { 00028 00029 class VcsLocationPrivate 00030 { 00031 public: 00032 KUrl m_localUrl; 00033 QString m_repoServer; 00034 QString m_repoPath; 00035 QString m_repoModule; 00036 QString m_repoBranch; 00037 QString m_repoTag; 00038 VcsLocation::LocationType m_type; 00039 QVariant m_userData; 00040 }; 00041 00042 VcsLocation::VcsLocation() 00043 : d(new VcsLocationPrivate) 00044 { 00045 d->m_type = VcsLocation::LocalLocation; 00046 } 00047 00048 00049 VcsLocation::VcsLocation( const KUrl& u ) 00050 : d(new VcsLocationPrivate) 00051 { 00052 setLocalUrl( u ); 00053 } 00054 00055 VcsLocation::VcsLocation( const QString& s ) 00056 : d(new VcsLocationPrivate) 00057 { 00058 setRepositoryServer( s ); 00059 } 00060 00061 VcsLocation::~VcsLocation() 00062 { 00063 delete d; 00064 } 00065 00066 VcsLocation::VcsLocation( const VcsLocation& rhs ) 00067 : d(new VcsLocationPrivate) 00068 { 00069 d->m_type = rhs.d->m_type; 00070 d->m_localUrl = rhs.d->m_localUrl; 00071 d->m_repoServer = rhs.d->m_repoServer; 00072 d->m_repoPath = rhs.d->m_repoPath; 00073 d->m_repoModule = rhs.d->m_repoModule; 00074 d->m_repoBranch = rhs.d->m_repoBranch; 00075 d->m_repoTag = rhs.d->m_repoTag; 00076 d->m_userData = rhs.d->m_userData; 00077 } 00078 00079 VcsLocation& VcsLocation::operator=( const VcsLocation& rhs ) 00080 { 00081 if( &rhs == this ) 00082 return *this; 00083 d->m_type = rhs.d->m_type; 00084 d->m_localUrl = rhs.d->m_localUrl; 00085 d->m_repoServer = rhs.d->m_repoServer; 00086 d->m_repoPath = rhs.d->m_repoPath; 00087 d->m_repoModule = rhs.d->m_repoModule; 00088 d->m_repoBranch = rhs.d->m_repoBranch; 00089 d->m_repoTag = rhs.d->m_repoTag; 00090 d->m_userData = rhs.d->m_userData; 00091 return *this; 00092 } 00093 00094 KUrl VcsLocation::localUrl() const 00095 { 00096 return d->m_localUrl; 00097 } 00098 QString VcsLocation::repositoryServer() const 00099 { 00100 return d->m_repoServer; 00101 } 00102 00103 VcsLocation::LocationType VcsLocation::type() const 00104 { 00105 return d->m_type; 00106 } 00107 00108 bool VcsLocation::isValid() const 00109 { 00110 return( ( d->m_localUrl.isValid() 00111 && d->m_type == VcsLocation::LocalLocation ) 00112 || ( !d->m_repoServer.isEmpty() 00113 && d->m_type == VcsLocation::RepositoryLocation ) ); 00114 } 00115 00116 void VcsLocation::setLocalUrl( const KUrl& url ) 00117 { 00118 d->m_repoServer.clear(); 00119 d->m_repoModule.clear(); 00120 d->m_repoBranch.clear(); 00121 d->m_repoTag.clear(); 00122 d->m_repoPath.clear(); 00123 d->m_type = VcsLocation::LocalLocation; 00124 d->m_localUrl = url; 00125 } 00126 void VcsLocation::setRepositoryServer( const QString& location ) 00127 { 00128 d->m_repoServer = location; 00129 d->m_type = VcsLocation::RepositoryLocation; 00130 d->m_localUrl = KUrl(); 00131 } 00132 00133 bool VcsLocation::operator==( const KDevelop::VcsLocation& rhs ) 00134 { 00135 return( type() == rhs.type() 00136 && repositoryServer() == rhs.repositoryServer() 00137 && localUrl() == rhs.localUrl() 00138 && repositoryPath() == rhs.repositoryPath() 00139 && repositoryModule() == rhs.repositoryModule() 00140 && repositoryBranch() == rhs.repositoryBranch() 00141 && repositoryTag() == rhs.repositoryTag() 00142 && userData() == rhs.userData() ); 00143 } 00144 00145 00146 QString VcsLocation::repositoryModule( ) const 00147 { 00148 return d->m_repoModule; 00149 } 00150 00151 QString VcsLocation::repositoryTag( ) const 00152 { 00153 return d->m_repoTag; 00154 } 00155 00156 QString VcsLocation::repositoryBranch( ) const 00157 { 00158 return d->m_repoBranch; 00159 } 00160 00161 QString VcsLocation::repositoryPath( ) const 00162 { 00163 return d->m_repoPath; 00164 } 00165 00166 void VcsLocation::setRepositoryModule( const QString & module ) 00167 { 00168 d->m_repoModule = module; 00169 d->m_type = VcsLocation::RepositoryLocation; 00170 d->m_localUrl.clear(); 00171 } 00172 00173 void VcsLocation::setRepositoryBranch( const QString & branch ) 00174 { 00175 d->m_repoBranch = branch; 00176 d->m_type = VcsLocation::RepositoryLocation; 00177 d->m_localUrl.clear(); 00178 } 00179 00180 void VcsLocation::setRepositoryTag( const QString & tag ) 00181 { 00182 d->m_repoTag = tag; 00183 d->m_type = VcsLocation::RepositoryLocation; 00184 d->m_localUrl.clear(); 00185 } 00186 00187 void VcsLocation::setRepositoryPath( const QString & path ) 00188 { 00189 d->m_repoPath = path; 00190 d->m_type = VcsLocation::RepositoryLocation; 00191 d->m_localUrl.clear(); 00192 } 00193 00194 00195 QVariant VcsLocation::userData( ) const 00196 { 00197 return d->m_userData; 00198 } 00199 00200 void VcsLocation::setUserData( const QVariant& data ) 00201 { 00202 d->m_type = VcsLocation::RepositoryLocation; 00203 d->m_localUrl.clear(); 00204 d->m_userData = data; 00205 } 00206 00207 } 00208
KDE 4.2 API Reference