File: vcslocation.cpp

package info (click to toggle)
kdevelop 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 73,508 kB
  • sloc: cpp: 291,803; python: 4,322; javascript: 3,518; sh: 1,316; ansic: 703; xml: 414; php: 95; lisp: 66; makefile: 31; sed: 12
file content (173 lines) | stat: -rw-r--r-- 3,614 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
    SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "vcslocation.h"

#include <QVariant>

namespace KDevelop
{

class VcsLocationPrivate : public QSharedData
{
public:
    QUrl m_localUrl;
    QString m_repoServer;
    QString m_repoPath;
    QString m_repoModule;
    QString m_repoBranch;
    QString m_repoTag;
    VcsLocation::LocationType m_type;
    QVariant m_userData;
};

VcsLocation::VcsLocation()
    : d(new VcsLocationPrivate)
{
    d->m_type = VcsLocation::LocalLocation;
}


VcsLocation::VcsLocation( const QUrl& u )
    : d(new VcsLocationPrivate)
{
    setLocalUrl( u );
}

VcsLocation::VcsLocation( const QString& s )
    : d(new VcsLocationPrivate)
{
    setRepositoryServer( s );
}

VcsLocation::~VcsLocation() = default;

VcsLocation::VcsLocation( const VcsLocation& rhs )
    : d(rhs.d)
{
}

VcsLocation& VcsLocation::operator=( const VcsLocation& rhs )
{
    d = rhs.d;
    return *this;
}

QUrl VcsLocation::localUrl() const
{
    return d->m_localUrl;
}
QString VcsLocation::repositoryServer() const
{
    return d->m_repoServer;
}

VcsLocation::LocationType VcsLocation::type() const
{
    return d->m_type;
}

bool VcsLocation::isValid() const
{
    return( ( d->m_localUrl.isValid()
              && d->m_type == VcsLocation::LocalLocation )
            || ( !d->m_repoServer.isEmpty()
                && d->m_type == VcsLocation::RepositoryLocation ) );
}

void VcsLocation::setLocalUrl( const QUrl& url )
{
    d->m_repoServer.clear();
    d->m_repoModule.clear();
    d->m_repoBranch.clear();
    d->m_repoTag.clear();
    d->m_repoPath.clear();
    d->m_type = VcsLocation::LocalLocation;
    d->m_localUrl = url;
}
void VcsLocation::setRepositoryServer( const QString& location )
{
    d->m_repoServer = location;
    d->m_type = VcsLocation::RepositoryLocation;
    d->m_localUrl = QUrl();
}

bool VcsLocation::operator==( const KDevelop::VcsLocation& rhs )
{
    return( type() == rhs.type()
            && repositoryServer() == rhs.repositoryServer()
            && localUrl() == rhs.localUrl()
            && repositoryPath() == rhs.repositoryPath()
            && repositoryModule() == rhs.repositoryModule()
            && repositoryBranch() == rhs.repositoryBranch()
            && repositoryTag() == rhs.repositoryTag()
            && userData() == rhs.userData() );
}


QString VcsLocation::repositoryModule( ) const
{
    return d->m_repoModule;
}

QString VcsLocation::repositoryTag( ) const
{
    return d->m_repoTag;
}

QString VcsLocation::repositoryBranch( ) const
{
    return d->m_repoBranch;
}

QString VcsLocation::repositoryPath( ) const
{
    return d->m_repoPath;
}

void VcsLocation::setRepositoryModule( const QString & module )
{
    d->m_repoModule = module;
    d->m_type = VcsLocation::RepositoryLocation;
    d->m_localUrl.clear();
}

void VcsLocation::setRepositoryBranch( const QString & branch )
{
    d->m_repoBranch = branch;
    d->m_type = VcsLocation::RepositoryLocation;
    d->m_localUrl.clear();
}

void VcsLocation::setRepositoryTag( const QString & tag )
{
    d->m_repoTag = tag;
    d->m_type = VcsLocation::RepositoryLocation;
    d->m_localUrl.clear();
}

void VcsLocation::setRepositoryPath( const QString & path )
{
    d->m_repoPath = path;
    d->m_type = VcsLocation::RepositoryLocation;
    d->m_localUrl.clear();
}


QVariant VcsLocation::userData( ) const
{
    return d->m_userData;
}

void VcsLocation::setUserData( const QVariant& data )
{
    d->m_type = VcsLocation::RepositoryLocation;
    d->m_localUrl.clear();
    d->m_userData = data;
}

}