File indexing completed on 2025-01-19 04:22: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 // 0008 // Created by hamed on 25.03.22. 0009 // 0010 0011 #pragma once 0012 #include "abstractgititemsmodel.h" 0013 #include "libkommit_export.h" 0014 0015 namespace Git 0016 { 0017 class Remote; 0018 0019 class LIBKOMMIT_EXPORT RemotesModel : public AbstractGitItemsModel 0020 { 0021 Q_OBJECT 0022 0023 enum Roles 0024 { 0025 Name, 0026 HeadBranch, 0027 FetchUrl, 0028 PushUrl 0029 }; 0030 0031 public: 0032 explicit RemotesModel(Manager *git, QObject *parent = nullptr); 0033 int rowCount(const QModelIndex &parent) const override; 0034 QVariant data(const QModelIndex &index, int role) const override; 0035 Remote *fromIndex(const QModelIndex &index); 0036 Remote *findByName(const QString &name); 0037 0038 void rename(const QString &oldName, const QString &newName); 0039 void setUrl(const QString &remoteName, const QString &newUrl); 0040 0041 protected: 0042 void fill() override; 0043 0044 private: 0045 QList<Remote *> mData; 0046 0047 // QAbstractItemModel interface 0048 public: 0049 QHash<int, QByteArray> roleNames() const override final; 0050 }; 0051 } // namespace Git