Changeset View
Changeset View
Standalone View
Standalone View
plugins/cgit/projectvcstracker.h
- This file was added.
1 | /* This file is part of KDevelop | ||||
---|---|---|---|---|---|
2 | Copyright 2013 Aleix Pol <aleixpol@kde.org> | ||||
3 | Copyright 2017 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Library General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This library is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | Library General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Library General Public License | ||||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef PROJECTVCSTRACKER_H | ||||
22 | #define PROJECTVCSTRACKER_H | ||||
23 | | ||||
24 | #include <QObject> | ||||
25 | #include <QSet> | ||||
26 | #include <QString> | ||||
27 | | ||||
28 | class QUrl; | ||||
29 | | ||||
30 | namespace KDevelop { | ||||
31 | class IProject; | ||||
32 | class VcsJob; | ||||
33 | } | ||||
34 | | ||||
35 | /** | ||||
36 | * Keeps track of the current branches of the loaded projects | ||||
37 | * to allow sync read access to the current branch name | ||||
38 | * forked&adapted from plugins/projectmanagerview/vcsoverlayproxymodel | ||||
39 | */ | ||||
40 | class ProjectVcsTracker : public QObject | ||||
41 | { | ||||
42 | Q_OBJECT | ||||
43 | | ||||
44 | public: | ||||
45 | explicit ProjectVcsTracker(QObject* parent = nullptr); | ||||
46 | | ||||
47 | QString currentBranchName(KDevelop::IProject* project) const; | ||||
48 | | ||||
49 | private: | ||||
50 | void startProjectTracking(KDevelop::IProject* project); | ||||
51 | void stopProjectTracking(KDevelop::IProject* project); | ||||
52 | void onBranchNameReady(KDevelop::VcsJob* job); | ||||
53 | private Q_SLOTS: // needs to be tagged as slot for a string-based connect | ||||
54 | void handleRepositoryBranchChange(const QUrl& url); | ||||
55 | | ||||
56 | private: | ||||
57 | QSet<KDevelop::IProject*> m_pendingProjects; | ||||
58 | QHash<KDevelop::IProject*, QString> m_branchNamePerProject; | ||||
59 | }; | ||||
60 | | ||||
61 | #endif // PROJECTVCSTRACKER_H |