| 12
 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
 
 | /*
    SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
    SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
    SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KDEVPLATFORM_VCSLOCATION_H
#define KDEVPLATFORM_VCSLOCATION_H
#include <QHash>
#include <QUrl>
#include <QMetaType>
#include <QSharedDataPointer>
class QVariant;
#include "vcsexport.h"
namespace KDevelop
{
/**
 * Denotes a local or repository location for a Vcs system.
 *
 * For the RepositoryLocation type, most of the information
 * is vcs-specific.
 */
class KDEVPLATFORMVCS_EXPORT VcsLocation
{
public:
    enum LocationType
    {
        LocalLocation = 0      /**< this is a local location */,
        RepositoryLocation = 1 /**< this is a repository location */
    };
    VcsLocation();
    explicit VcsLocation( const QUrl& );
    explicit VcsLocation( const QString& );
    ~VcsLocation();
    VcsLocation( const VcsLocation& );
    VcsLocation& operator=( const VcsLocation& );
    /**
     * @returns Local url if this location is a LocalLocation
     */
    QUrl localUrl() const;
    /**
     * Returns a string for the repository, usually this identifies the server.
     * @returns a vcs-implementation-specific string identifying the server
     */
    QString repositoryServer() const;
    /**
     * Returns the module or module path inside the server.
     * @returns a vcs-implementation-specific string identifying the module
     */
    QString repositoryModule() const;
    /**
     * Identifies the tag which this location belongs to.
     * @returns a vcs-implementation-specific string identifying the tag
     */
    QString repositoryTag() const;
    /**
     * Identifies the branch to which this location belongs to.
     * @returns a vcs-implementation-specific string identifying the branch
     */
    QString repositoryBranch() const;
    /**
     * This can define a path relative to the module. This is used
     * when identifying a subdirectory or file inside a repository location
     * @returns a path relative to module
     */
    QString repositoryPath() const;
    /**
     * @returns the type of this location
     */
    LocationType type() const;
    /**
     * Set the local url for this location, automatically sets the type to LocalLocation
     * @param url the local url
     */
    void setLocalUrl( const QUrl& url );
    /**
     * Set the server string for this location, automatically sets the type to RepositoryLocation
     */
    void setRepositoryServer( const QString& );
    /**
     * Set the module for this location, automatically sets the type to RepositoryLocation
     */
    void setRepositoryModule( const QString& );
    /**
     * Set the branch string for this location, automatically sets the type to RepositoryLocation
     */
    void setRepositoryBranch( const QString& );
    /**
     * Set the tag string for this location, automatically sets the type to RepositoryLocation
     */
    void setRepositoryTag( const QString& );
    /**
     * Set the path for this location, automatically sets the type to RepositoryLocation
     */
    void setRepositoryPath( const QString& );
    /**
     * Allows to add vcs-specific data to this location.
     * Automatically sets the type to RepositoryLocation
     * @param data the vcs-specific data
     */
    void setUserData( const QVariant& data );
    /**
     * retrieve vcs-specific data
     */
    QVariant userData() const;
    bool operator==( const KDevelop::VcsLocation& );
    bool isValid() const;
private:
    QSharedDataPointer<class VcsLocationPrivate> d;
};
inline size_t qHash(const KDevelop::VcsLocation& loc)
{
    if( loc.type() == KDevelop::VcsLocation::LocalLocation )
    {
        return qHash(loc.localUrl());
    }else
    {
        return qHash(loc.repositoryServer());
    }
}
inline bool operator==( const KDevelop::VcsLocation& lhs, const KDevelop::VcsLocation& rhs )
{
    return( lhs.type() == rhs.type()
            && lhs.repositoryServer() == rhs.repositoryServer()
            && lhs.localUrl() == rhs.localUrl() );
}
}
Q_DECLARE_METATYPE( KDevelop::VcsLocation )
Q_DECLARE_TYPEINFO(KDevelop::VcsLocation, Q_MOVABLE_TYPE);
#endif
 |