File indexing completed on 2024-05-12 04:38:54

0001 /*
0002     SPDX-FileCopyrightText: 2008 Evgeniy Ivanov <powerfox@kde.ru>
0003     SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <aleixpol@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef KDEVPLATFORM_BRANCHESLISTMODEL_H
0009 #define KDEVPLATFORM_BRANCHESLISTMODEL_H
0010 
0011 #include <QStandardItemModel>
0012 #include <QUrl>
0013 
0014 #include <vcs/vcsexport.h>
0015 
0016 namespace KDevelop {
0017 class IBranchingVersionControl;
0018 class IProject;
0019 class BranchesListModelPrivate;
0020 
0021 class KDEVPLATFORMVCS_EXPORT BranchesListModel : public QStandardItemModel
0022 {
0023     Q_OBJECT
0024     Q_PROPERTY(KDevelop::IProject* project READ project WRITE setProject)
0025     Q_PROPERTY(QString currentBranch READ currentBranch WRITE setCurrentBranch NOTIFY currentBranchChanged)
0026     public:
0027         enum Roles { CurrentRole = Qt::UserRole+1 };
0028 
0029         explicit BranchesListModel(QObject* parent = nullptr);
0030         ~BranchesListModel() override;
0031 
0032         void initialize(KDevelop::IBranchingVersionControl* dvcsplugin, const QUrl& repo);
0033 
0034         QHash<int, QByteArray> roleNames() const override;
0035 
0036         Q_INVOKABLE void createBranch(const QString& baseBranch, const QString& newBranch);
0037         Q_INVOKABLE void removeBranch(const QString& branch);
0038 
0039         QUrl repository() const;
0040         KDevelop::IBranchingVersionControl* interface() const;
0041         void refresh();
0042         QString currentBranch() const;
0043         void setCurrentBranch(const QString& branch);
0044 
0045         KDevelop::IProject* project() const;
0046         void setProject(KDevelop::IProject* p);
0047 
0048     public Q_SLOTS:
0049         void resetCurrent();
0050 
0051     Q_SIGNALS:
0052         void currentBranchChanged();
0053 
0054     private:
0055         const QScopedPointer<class BranchesListModelPrivate> d_ptr;
0056         Q_DECLARE_PRIVATE(BranchesListModel)
0057 };
0058 
0059 }
0060 
0061 #endif // KDEVPLATFORM_BRANCHESLISTMODEL_H