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

0001 /*
0002     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0003     SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KDEVPLATFORM_VCSSTATUSINFO_H
0009 #define KDEVPLATFORM_VCSSTATUSINFO_H
0010 
0011 #include "vcsexport.h"
0012 #include <QMetaType>
0013 #include <QSharedDataPointer>
0014 
0015 class QUrl;
0016 
0017 namespace KDevelop
0018 {
0019 
0020 /**
0021  *
0022  * Class that encapsulates status information
0023  * for one local url.
0024  *
0025  * The extendedState functions allow to transport
0026  * extended status information
0027  *
0028  * Note for VCS implementations:
0029  * If you want to use this class in queued signal/slot connections
0030  * you should call qRegisterMetaType<KDevelop::VcsStatusInfo>()
0031  * in the constructor of the plugin class
0032  */
0033 class KDEVPLATFORMVCS_EXPORT VcsStatusInfo
0034 {
0035 public:
0036     /**
0037      * Status of a local file
0038      */
0039     enum State
0040     {
0041         ItemUnknown       = 0    /**< No VCS information about a file is known (or file is not under VCS control). */,
0042         ItemUpToDate      = 1    /**< Item was updated or it is already at up to date version. */,
0043         ItemAdded         = 2    /**< Item was added to the repository but not committed. */,
0044         ItemModified      = 3    /**< Item was modified locally. */,
0045         ItemDeleted       = 4    /**< Item is scheduled to be deleted. */,
0046         ItemHasConflicts  = 8    /**< Local version has conflicts that need to be resolved before commit. */,
0047 
0048         ItemUserState     = 1000 /**< special states for individual vcs implementations should use this as base. */,
0049 
0050     };
0051 
0052     VcsStatusInfo();
0053     virtual ~VcsStatusInfo();
0054     VcsStatusInfo(const VcsStatusInfo&);
0055 
0056     /**
0057      * retrieves the url of this status information item
0058      * @return the url
0059      */
0060     QUrl url() const;
0061     /**
0062      * Change the url of this status information item
0063      * @param url the url
0064      */
0065     void setUrl( const QUrl& url );
0066 
0067     VcsStatusInfo::State state() const;
0068     void setState( VcsStatusInfo::State );
0069 
0070     /**
0071      * @returns the extended state which may be set by individual vcs implementations
0072      */
0073     int extendedState() const;
0074 
0075     /**
0076      * Individual vcs implementations may use this function to set a special vcs status.
0077      * They should also always set an appropriate basic state, if possible.
0078      */
0079     void setExtendedState( int );
0080 
0081     VcsStatusInfo& operator=( const VcsStatusInfo& rhs);
0082     bool operator==( const KDevelop::VcsStatusInfo& rhs) const;
0083     bool operator!=( const KDevelop::VcsStatusInfo& rhs) const;
0084 
0085 private:
0086     QSharedDataPointer<class VcsStatusInfoPrivate> d;
0087 };
0088 
0089 }
0090 
0091 Q_DECLARE_METATYPE( KDevelop::VcsStatusInfo )
0092 Q_DECLARE_TYPEINFO( KDevelop::VcsStatusInfo, Q_MOVABLE_TYPE );
0093 
0094 KDEVPLATFORMVCS_EXPORT QDebug operator<<(QDebug s, const KDevelop::VcsStatusInfo& statusInfo);
0095 
0096 #endif
0097