File indexing completed on 2024-04-28 04:37:47

0001 /*
0002     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "vcsstatusinfo.h"
0008 
0009 #include <QDebug>
0010 #include <QUrl>
0011 #include <QSharedData>
0012 
0013 namespace KDevelop
0014 {
0015 
0016 class VcsStatusInfoPrivate : public QSharedData
0017 {
0018 public:
0019     int state;
0020     int extendedState;
0021     QUrl url;
0022 };
0023 
0024 VcsStatusInfo::VcsStatusInfo()
0025     : d( new VcsStatusInfoPrivate)
0026 {
0027     d->state = VcsStatusInfo::ItemUnknown;
0028     d->extendedState = VcsStatusInfo::ItemUnknown;
0029 }
0030 
0031 VcsStatusInfo::~VcsStatusInfo() = default;
0032 
0033 VcsStatusInfo::VcsStatusInfo( const VcsStatusInfo& rhs )
0034     : d(rhs.d)
0035 {
0036 }
0037 
0038 VcsStatusInfo& VcsStatusInfo::operator=( const VcsStatusInfo& rhs)
0039 {
0040     d = rhs.d;
0041     return *this;
0042 }
0043 
0044 bool VcsStatusInfo::operator==( const KDevelop::VcsStatusInfo& rhs) const
0045 {
0046     return ( d->state == rhs.d->state && d->url == rhs.d->url );
0047 }
0048 
0049 bool VcsStatusInfo::operator!=( const KDevelop::VcsStatusInfo& rhs) const
0050 {
0051     return !(operator==(rhs));
0052 }
0053 
0054 void VcsStatusInfo::setUrl( const QUrl& url )
0055 {
0056     d->url = url;
0057 }
0058 
0059 void VcsStatusInfo::setExtendedState( int newstate )
0060 {
0061     d->extendedState = newstate;
0062 }
0063 
0064 void VcsStatusInfo::setState( VcsStatusInfo::State state )
0065 {
0066     d->state = state;
0067 }
0068 
0069 int VcsStatusInfo::extendedState() const
0070 {
0071     return d->extendedState;
0072 }
0073 
0074 QUrl VcsStatusInfo::url() const
0075 {
0076     return d->url;
0077 }
0078 
0079 VcsStatusInfo::State VcsStatusInfo::state() const
0080 {
0081     return VcsStatusInfo::State(d->state);
0082 }
0083 
0084 }
0085 
0086 QDebug operator<<(QDebug s, const KDevelop::VcsStatusInfo& statusInfo)
0087 {
0088     s.nospace() << statusInfo.state() << "@" << statusInfo.url();
0089     return s.space();
0090 }