Commit fd6d0d8c authored by Mathias Hasselmann's avatar Mathias Hasselmann Committed by Orgad Shaneh
Browse files

ProjectExplorer: Show VCS topic in tree



Topic is usually the current branch name

Change-Id: Id6ecc48744a5b3d9c7502b36b4895eb18d0ff0c6
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 3685ce75
......@@ -41,4 +41,9 @@ QString IVersionControl::vcsMakeWritableText() const
return QString();
}
QString IVersionControl::vcsTopic(const QString &)
{
return QString();
}
}
......@@ -136,6 +136,11 @@ public:
*/
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
* 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)) {
FolderNode *folderNode = qobject_cast<FolderNode*>(node);
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: {
result = node->displayName();
break;
......
......@@ -34,6 +34,9 @@
#include <coreplugin/mimedatabase.h>
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/icore.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
......@@ -104,6 +107,11 @@ QString Node::displayName() const
return QFileInfo(path()).fileName();
}
QString Node::vcsTopic() const
{
return QString();
}
QString Node::tooltip() const
{
return QDir::toNativeSeparators(path());
......@@ -269,6 +277,16 @@ ProjectNode::ProjectNode(const QString &projectFilePath)
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
{
return m_subProjectNodes;
......
......@@ -86,6 +86,7 @@ public:
FolderNode *parentFolderNode() const; // parent folder or project
QString path() const; // file system path
virtual QString displayName() const;
virtual QString vcsTopic() const;
virtual QString tooltip() const;
protected:
......@@ -183,6 +184,8 @@ public:
HasSubProjectRunConfigurations
};
QString vcsTopic() const;
// all subFolders that are projects
QList<ProjectNode*> subProjectNodes() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment