forked from qt-creator/qt-creator
ProjectExplorer: Show VCS topic in tree
Topic is usually the current branch name Change-Id: Id6ecc48744a5b3d9c7502b36b4895eb18d0ff0c6 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
3685ce7599
commit
fd6d0d8c29
@@ -41,4 +41,9 @@ QString IVersionControl::vcsMakeWritableText() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IVersionControl::vcsTopic(const QString &)
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual QString vcsGetRepositoryURL(const QString &director) = 0;
|
virtual QString vcsGetRepositoryURL(const QString &director) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Topic (e.g. name of the current branch)
|
||||||
|
*/
|
||||||
|
virtual QString vcsTopic(const QString &directory);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create a snapshot of the current state and return an identifier or
|
* Create a snapshot of the current state and return an identifier or
|
||||||
* an empty string in case of failure.
|
* an empty string in case of failure.
|
||||||
|
|||||||
@@ -258,7 +258,20 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
|
|||||||
if (Node *node = nodeForIndex(index)) {
|
if (Node *node = nodeForIndex(index)) {
|
||||||
FolderNode *folderNode = qobject_cast<FolderNode*>(node);
|
FolderNode *folderNode = qobject_cast<FolderNode*>(node);
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole: {
|
||||||
|
QString name = node->displayName();
|
||||||
|
|
||||||
|
if (node->parentFolderNode()
|
||||||
|
&& node->parentFolderNode()->nodeType() == SessionNodeType) {
|
||||||
|
const QString vcsTopic = node->vcsTopic();
|
||||||
|
|
||||||
|
if (!vcsTopic.isEmpty())
|
||||||
|
name += " (" + vcsTopic + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
result = name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Qt::EditRole: {
|
case Qt::EditRole: {
|
||||||
result = node->displayName();
|
result = node->displayName();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
|
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/fileiconprovider.h>
|
#include <coreplugin/fileiconprovider.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/iversioncontrol.h>
|
||||||
|
#include <coreplugin/vcsmanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -104,6 +107,11 @@ QString Node::displayName() const
|
|||||||
return QFileInfo(path()).fileName();
|
return QFileInfo(path()).fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Node::vcsTopic() const
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QString Node::tooltip() const
|
QString Node::tooltip() const
|
||||||
{
|
{
|
||||||
return QDir::toNativeSeparators(path());
|
return QDir::toNativeSeparators(path());
|
||||||
@@ -269,6 +277,16 @@ ProjectNode::ProjectNode(const QString &projectFilePath)
|
|||||||
setDisplayName(QFileInfo(projectFilePath).fileName());
|
setDisplayName(QFileInfo(projectFilePath).fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProjectNode::vcsTopic() const {
|
||||||
|
const QString dir = QFileInfo(path()).absolutePath();
|
||||||
|
|
||||||
|
if (Core::IVersionControl *const vc =
|
||||||
|
Core::ICore::vcsManager()->findVersionControlForDirectory(dir))
|
||||||
|
return vc->vcsTopic(dir);
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QList<ProjectNode*> ProjectNode::subProjectNodes() const
|
QList<ProjectNode*> ProjectNode::subProjectNodes() const
|
||||||
{
|
{
|
||||||
return m_subProjectNodes;
|
return m_subProjectNodes;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public:
|
|||||||
FolderNode *parentFolderNode() const; // parent folder or project
|
FolderNode *parentFolderNode() const; // parent folder or project
|
||||||
QString path() const; // file system path
|
QString path() const; // file system path
|
||||||
virtual QString displayName() const;
|
virtual QString displayName() const;
|
||||||
|
virtual QString vcsTopic() const;
|
||||||
virtual QString tooltip() const;
|
virtual QString tooltip() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -183,6 +184,8 @@ public:
|
|||||||
HasSubProjectRunConfigurations
|
HasSubProjectRunConfigurations
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString vcsTopic() const;
|
||||||
|
|
||||||
// all subFolders that are projects
|
// all subFolders that are projects
|
||||||
QList<ProjectNode*> subProjectNodes() const;
|
QList<ProjectNode*> subProjectNodes() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user