File indexing completed on 2024-06-02 05:51:44

0001 /*
0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com>
0003 
0004 SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libkommit_export.h"
0010 #include <QObject>
0011 #include <QString>
0012 
0013 namespace Git
0014 {
0015 
0016 class LIBKOMMIT_EXPORT FileStatus
0017 {
0018 public:
0019     enum Status {
0020         Unknown = 0,
0021         Unmodified = 1,
0022         Modified = 2,
0023         Added = 3,
0024         Removed = 4,
0025         Renamed = 5,
0026         Copied = 6,
0027         UpdatedButInmerged = 7,
0028         Ignored = 8,
0029         Untracked = 9,
0030         NoGit = 10
0031     };
0032 
0033     FileStatus();
0034     explicit FileStatus(QString name, Status status);
0035 
0036     const QString &name() const;
0037     Q_REQUIRED_RESULT Status status() const;
0038 
0039     void parseStatusLine(const QString &line);
0040     Q_REQUIRED_RESULT const QString &fullPath() const;
0041 
0042     void setFullPath(const QString &newFullPath);
0043 
0044     void setStatus(Status status);
0045     void setStatus(const QString &x, const QString &y = QString());
0046     void setName(const QString &newName);
0047 
0048     bool operator==(const FileStatus &other);
0049 
0050 private:
0051     QString mFullPath;
0052     QString mName;
0053     Status mStatus;
0054 
0055     friend class Manager;
0056 };
0057 LIBKOMMIT_EXPORT bool operator==(const FileStatus &f1, const FileStatus &f2);
0058 }
0059 
0060 Q_DECLARE_METATYPE(Git::FileStatus)
0061 Q_DECLARE_TYPEINFO(Git::FileStatus, Q_MOVABLE_TYPE);