Add line for debugging
[kdevelopdvcssupport.git] / vcs / vcsmapping.cpp
blobe708066513702b7eb835aa5d525fdeaa0526ad75
1 /***************************************************************************
2 * This file is part of KDevelop *
3 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
4 * *
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. *
9 * *
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. *
14 * *
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 "vcsmapping.h"
23 //Needed first as it provides a hash-function for QHash
24 #include "vcslocation.h"
26 #include <QtCore/QPair>
27 #include <QtCore/QHash>
30 namespace KDevelop
33 class VcsMappingPrivate
35 public:
36 QHash<VcsLocation,QPair<VcsLocation, VcsMapping::MappingFlag> > mapping;
39 VcsMapping::VcsMapping()
40 : d(new VcsMappingPrivate)
44 VcsMapping::~VcsMapping()
46 delete d;
49 VcsMapping::VcsMapping( const VcsMapping& rhs )
50 : d(new VcsMappingPrivate)
52 d->mapping = rhs.d->mapping;
55 void VcsMapping::addMapping( const VcsLocation& sourceLocation,
56 const VcsLocation& destinationLocation,
57 VcsMapping::MappingFlag recursion )
59 QPair<VcsLocation,VcsMapping::MappingFlag> val = qMakePair(destinationLocation,recursion);
60 d->mapping[sourceLocation] = val;
63 void VcsMapping::removeMapping( const VcsLocation& sourceLocation)
65 if( d->mapping.contains(sourceLocation) )
66 d->mapping.remove(sourceLocation);
69 QList<VcsLocation> VcsMapping::sourceLocations() const
71 return d->mapping.keys();
74 VcsLocation VcsMapping::destinationLocation( const VcsLocation& sourceLocation ) const
76 if( d->mapping.contains( sourceLocation ) )
77 return d->mapping[sourceLocation].first;
78 return QString();
81 VcsMapping::MappingFlag VcsMapping::mappingFlag( const VcsLocation& sourceLocation ) const
83 if( d->mapping.contains( sourceLocation ) )
84 return d->mapping[sourceLocation].second;
85 return NonRecursive;
89 VcsMapping& VcsMapping::operator=( const VcsMapping& rhs)
91 if(this == &rhs)
92 return *this;
93 d->mapping = rhs.d->mapping;
94 return *this;